Files
dh-inspeccion-v2/api-v3/src/database/entities/asset.entity.ts
T
admin 35d4630581 F5 · Inventario operativo, territorio y catálogo autorizado (#25)
* fix(web): simplify inventory administration menu

* fix(web): remove legacy imports and function catalog routes

* fix(web): remove redundant inspections lifecycle legend

* feat(inventory): distinguish physical instances from structural records

* fix(dashboard): align inventory and act follow-up metrics

* fix(web): align dashboard summary contract

* fix(web): clarify dashboard act and report concepts

* feat(inventory): mark field-created records as real instances

* feat(inventory): map physical instance flag on asset entity

* fix(inventory): keep field yacimientos structural

* feat(inventory): classify future concrete instances at database level

* fix(inventory): count only installation and subinstallation instances

* feat(inventory): add authoritative F5 source snapshot

* feat(inventory): preload authoritative territory model

* feat(inventory): preload authoritative technical catalog

* fix(findings): use only authoritative F5 family catalog

* fix(inventory): preserve non-hierarchical operator snapshot compatibility

* feat(inventory): add inventory-only asset filter

* feat(inventory): add inventory-only tree filter

* feat(inventory): add inventory browser query contract

* feat(inventory): add area-owned inventory browser

* feat(inventory): expose area-owned inventory browser

* refactor(inventory): remove function catalog and add inventory browser

* fix(inventory): make operator relation temporal and non-owning

* feat(web): add inventory browser API client

* feat(inventory): extend inventory browser filters

* feat(inventory): add real inventory list endpoint logic

* feat(inventory): expose real inventory list

* feat(web): add real inventory list client

* refactor(web): make inventory hierarchy area-owned

* fix(web): show only real inventory instances

* fix(web): style act follow-up tabs and F5 inventory context

* fix(web): load F5 flow styles

* fix(inventory): apply area-owned operational guard on F5 up

* fix(inventory): treat company on asset as non-owning creation snapshot

* fix(inventory): resolve field inventory by area hierarchy, not company ownership

* fix(inventory): preserve custom catalog and apply authoritative universal findings

* fix(inventory): harden authoritative catalog migration checks

* fix(inventory): make authoritative territory preload safely reversible

* feat(inventory): allow independent company master creation

* fix(inventory): make guided creation area-owned and support companies

* feat(web): expose independent company master in inventory setup

* feat(web): create companies independently from physical inventory hierarchy

* fix(inventory): merge by physical area and preserve sealed documents

* test(inventory): lock F5 authoritative model and merge invariants

* feat(inventory): add family administration DTOs

* feat(inventory): administer installation and subinstallation classifications

* feat(inventory): expose family classification administration

* feat(web): add inventory classification administration API

* fix(web): configure finding applicability by inventory classification

* fix(web): redefine inventory configuration around hierarchy classifications and columns

* chore(release): identify F5 inventory model

* chore(release): bump API for F5 inventory model

* test(release): expect F5 health metadata

* chore(release): align WEB package with F5 inventory cut

* chore(release): expose F5 WEB phase

* test(dashboard): expect inspector activity and act follow-up metrics

* test(dashboard): route F5 summary query mocks explicitly

* ci: rehearse all migrations on clean PostGIS before merge

* ci: prove F5 migrations revert and reapply cleanly

* test(f5): align operational navigation contract

* test(f5): align operator lifecycle with area-owned inventory

* test(f5): make merge compatibility area-based

* test(f5): distinguish literal and normalized yacimiento counts

* test(f5): model normalized yacimiento collision explicitly

* ci(f5): bootstrap historical admin prerequisite in clean migration rehearsal

* ci(f5): bypass irreversible historical reset in clean rehearsal

* fix(f5): make territory SQL parameter types explicit

* fix(f5): guarantee canonical inventory hierarchy before territory preload

* ci(f5): include canonical hierarchy migration in rollback gate

* fix(f5): type relation backup markers explicitly

* fix(f5): make catalog SQL text parameter types explicit
2026-09-08 23:18:15 -03:00

122 lines
4.1 KiB
TypeScript

import { Column, Entity, Index, PrimaryGeneratedColumn } from 'typeorm';
import { TimestampedEntity } from './timestamped.entity';
export enum AssetInformationStatus {
DRAFT = 'DRAFT',
PENDING_SURVEY = 'PENDING_SURVEY',
SURVEYED = 'SURVEYED',
VALIDATED = 'VALIDATED',
OBSERVED = 'OBSERVED',
OUTDATED = 'OUTDATED',
INACTIVE = 'INACTIVE',
}
export enum AssetOperationalStatus {
UNKNOWN = 'UNKNOWN',
IN_SERVICE = 'IN_SERVICE',
TEMPORARILY_OUT_OF_SERVICE = 'TEMPORARILY_OUT_OF_SERVICE',
OUT_OF_SERVICE = 'OUT_OF_SERVICE',
DECOMMISSIONED = 'DECOMMISSIONED',
ABANDONED = 'ABANDONED',
}
export enum AssetDataOrigin {
MANUAL = 'MANUAL',
FIELD_SURVEY = 'FIELD_SURVEY',
PROVIDED_DOCUMENT = 'PROVIDED_DOCUMENT',
IMPORT = 'IMPORT',
SYSTEM = 'SYSTEM',
}
@Entity({ name: 'assets' })
@Index('idx_assets_type_id', ['assetTypeId'])
@Index('idx_assets_parent_id', ['parentId'])
@Index('idx_assets_operational_area_id', ['operationalAreaId'])
@Index('idx_assets_operator_company_id', ['operatorCompanyId'])
@Index('idx_assets_inventory_family_id', ['inventoryFamilyId'])
@Index('idx_assets_information_status', ['informationStatus'])
@Index('idx_assets_operational_status', ['operationalStatus'])
@Index('idx_assets_data_origin', ['dataOrigin'])
@Index('idx_assets_provenance_verified_at', ['provenanceVerifiedAt'])
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({ name: 'is_inventory_instance', type: 'boolean', default: false })
isInventoryInstance!: boolean;
@Column({ type: 'varchar', length: 120 })
code!: string;
@Column({ type: 'varchar', length: 200 })
name!: string;
@Column({ name: 'common_name', type: 'varchar', length: 200, nullable: true })
commonName!: string | null;
@Column({ type: 'text', nullable: true })
description!: string | null;
@Column({
name: 'information_status',
type: 'enum',
enum: AssetInformationStatus,
enumName: 'asset_information_status',
default: AssetInformationStatus.DRAFT,
})
informationStatus!: AssetInformationStatus;
@Column({ name: 'operational_status', type: 'enum', enum: AssetOperationalStatus, enumName: 'asset_operational_status', default: AssetOperationalStatus.UNKNOWN })
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: 'current_version', type: 'integer', default: 0 })
currentVersion!: number;
@Column({ name: 'data_origin', type: 'varchar', length: 32, default: AssetDataOrigin.MANUAL })
dataOrigin!: AssetDataOrigin;
@Column({ name: 'source_name', type: 'varchar', length: 160, nullable: true })
sourceName!: string | null;
@Column({ name: 'source_reference', type: 'varchar', length: 255, 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_at', type: 'timestamptz', default: () => 'CURRENT_TIMESTAMP' })
provenanceUpdatedAt!: Date;
@Column({ name: 'provenance_updated_by', type: 'uuid', nullable: true })
provenanceUpdatedBy!: string | null;
}