import { Column, CreateDateColumn, Entity, Index, ManyToOne, PrimaryGeneratedColumn, RelationId, UpdateDateColumn } from 'typeorm' import { Field, ID, Int, ObjectType } from 'type-graphql' import { Domain } from '@things-factory/shell' /* 한 연결·Twin·단위의 최신 번호 대사 상태. 과거 추이는 ingest window가, 현재 조치 판단은 이 표가 답한다. */ @Entity() @Index('uq_twin_reference_reconciliation_0', (e: TwinReferenceReconciliation) => [e.domain, e.instanceId, e.scope], { unique: true }) @Index('ix_twin_reference_reconciliation_0', (e: TwinReferenceReconciliation) => [e.domain, e.instanceId, e.checkedAt], { unique: false }) @ObjectType({ description: 'Latest durable sequence reconciliation for one connected source scope. It reports only what numbered source ranges can prove; it never substitutes replay-prone ingest-window counts for source facts.' }) export class TwinReferenceReconciliation { @PrimaryGeneratedColumn('uuid') @Field(type => ID) readonly id: string @ManyToOne(type => Domain) @Field(type => Domain, { nullable: true }) domain?: Domain @RelationId((e: TwinReferenceReconciliation) => e.domain) domainId?: string @Column() @Field() instanceId: string @Column() @Field() scope: string @Column() @Field() status: 'aligned' | 'gap' | 'unknown' @Column({ type: 'int', nullable: true }) @Field(type => Int, { nullable: true }) sourceFirst?: number @Column({ type: 'int', nullable: true }) @Field(type => Int, { nullable: true }) sourceLast?: number @Column({ type: 'int', nullable: true }) @Field(type => Int, { nullable: true }) cursorSeq?: number @Column({ type: 'int', nullable: true }) @Field(type => Int, { nullable: true }) firstSeqSeen?: number @Column({ type: 'int', nullable: true }) @Field(type => Int, { nullable: true }) headMissing?: number @Column({ type: 'int', nullable: true }) @Field(type => Int, { nullable: true }) behind?: number @Column({ nullable: true }) @Field({ nullable: true }) reason?: string @Column() @Field() checkedAt: Date @CreateDateColumn() createdAt?: Date @UpdateDateColumn() updatedAt?: Date }