108 lines
3.1 KiB
TypeScript
108 lines
3.1 KiB
TypeScript
import {
|
|
Column,
|
|
Entity,
|
|
Index,
|
|
PrimaryGeneratedColumn,
|
|
} from 'typeorm';
|
|
import { TimestampedEntity } from './timestamped.entity';
|
|
import {
|
|
AssetDataOrigin,
|
|
AssetInformationStatus,
|
|
AssetOperationalStatus,
|
|
} from './enums';
|
|
|
|
@Entity({ name: 'assets' })
|
|
@Index('uq_assets_code', ['code'], { unique: true })
|
|
@Index('idx_assets_parent', ['parentId'])
|
|
@Index('idx_assets_type', ['assetTypeId'])
|
|
@Index('idx_assets_status', ['informationStatus'])
|
|
@Index('idx_assets_operational_status', ['operationalStatus'])
|
|
@Index('idx_assets_operational_area', ['operationalAreaId'])
|
|
@Index('idx_assets_operator_company', ['operatorCompanyId'])
|
|
@Index('idx_assets_inventory_family', ['inventoryFamilyId'])
|
|
export class Asset extends TimestampedEntity {
|
|
@PrimaryGeneratedColumn('uuid')
|
|
id!: string;
|
|
|
|
@Column({ name: 'asset_type_id', type: 'uuid' })
|
|
assetTypeId!: string;
|
|
|
|
@Column({ name: 'parent_id', type: 'uuid', nullable: true })
|
|
parentId!: string | null;
|
|
|
|
@Column({ name: 'operational_area_id', type: 'uuid', nullable: true })
|
|
operationalAreaId!: string | null;
|
|
|
|
@Column({ name: 'operator_company_id', type: 'uuid', nullable: true })
|
|
operatorCompanyId!: string | null;
|
|
|
|
@Column({ name: 'inventory_family_id', type: 'uuid', nullable: true })
|
|
inventoryFamilyId!: string | null;
|
|
|
|
@Column({ type: 'varchar', length: 120 })
|
|
code!: string;
|
|
|
|
@Column({ type: 'varchar', length: 240 })
|
|
name!: string;
|
|
|
|
@Column({ name: 'common_name', type: 'varchar', length: 240, nullable: true })
|
|
commonName!: string | null;
|
|
|
|
@Column({ type: 'text', nullable: true })
|
|
description!: string | null;
|
|
|
|
@Column({
|
|
name: 'information_status',
|
|
type: 'varchar',
|
|
length: 20,
|
|
default: AssetInformationStatus.DRAFT,
|
|
})
|
|
informationStatus!: AssetInformationStatus;
|
|
|
|
@Column({
|
|
name: 'operational_status',
|
|
type: 'varchar',
|
|
length: 24,
|
|
default: AssetOperationalStatus.IN_SERVICE,
|
|
})
|
|
operationalStatus!: AssetOperationalStatus;
|
|
|
|
@Column({ name: 'created_by', type: 'uuid', nullable: true })
|
|
createdBy!: string | null;
|
|
|
|
@Column({ name: 'updated_by', type: 'uuid', nullable: true })
|
|
updatedBy!: string | null;
|
|
|
|
@Column({
|
|
name: 'data_origin',
|
|
type: 'varchar',
|
|
length: 20,
|
|
default: AssetDataOrigin.MANUAL,
|
|
})
|
|
dataOrigin!: AssetDataOrigin;
|
|
|
|
@Column({ name: 'source_name', type: 'varchar', length: 240, nullable: true })
|
|
sourceName!: string | null;
|
|
|
|
@Column({ name: 'source_reference', type: 'varchar', length: 500, nullable: true })
|
|
sourceReference!: string | null;
|
|
|
|
@Column({ name: 'source_observed_at', type: 'timestamptz', nullable: true })
|
|
sourceObservedAt!: Date | null;
|
|
|
|
@Column({ name: 'source_notes', type: 'text', nullable: true })
|
|
sourceNotes!: string | null;
|
|
|
|
@Column({ name: 'provenance_verified_at', type: 'timestamptz', nullable: true })
|
|
provenanceVerifiedAt!: Date | null;
|
|
|
|
@Column({ name: 'provenance_verified_by', type: 'uuid', nullable: true })
|
|
provenanceVerifiedBy!: string | null;
|
|
|
|
@Column({ name: 'provenance_updated_by', type: 'uuid', nullable: true })
|
|
provenanceUpdatedBy!: string | null;
|
|
|
|
@Column({ name: 'current_version', type: 'integer', default: 0 })
|
|
currentVersion!: number;
|
|
}
|