import { CreateDateColumn, Entity, Index, Column, RelationId, ManyToOne, PrimaryGeneratedColumn, UpdateDateColumn } from 'typeorm' import { ObjectType, Field, ID } from 'type-graphql' import { Domain, ScalarObject } from '@things-factory/shell' import { TwinSpaceRepresentation } from './twin-space-representation.js' /* * TwinSpaceArea — map/image 표현 위의 폴리곤 구역(design/ui/space-composition.md). * geometry=폴리곤(map=위경도, image=px). drillTo=클릭 시 이동할 model/표현(폴리곤→보드 모니터/시뮬 뷰). * binding=트윈 엔티티/데이터 태그(라이브 상태 결합). model 표현은 씬 컴포넌트가 이 역할을 대신함. */ @Entity() @Index('ix_twin_space_area_0', (e: TwinSpaceArea) => [e.domain, e.representation]) @ObjectType({ description: 'A polygon region on a map/image representation, linked to a model (drill-down) and bound to a twin entity.' }) export class TwinSpaceArea { @PrimaryGeneratedColumn('uuid') @Field(type => ID) readonly id: string @ManyToOne(type => Domain) @Field(type => Domain, { nullable: true, description: 'Owning tenant domain.' }) domain?: Domain @RelationId((e: TwinSpaceArea) => e.domain) domainId?: string @ManyToOne(type => TwinSpaceRepresentation) @Field(type => TwinSpaceRepresentation, { nullable: true, description: 'Owning representation.' }) representation?: TwinSpaceRepresentation @RelationId((e: TwinSpaceArea) => e.representation) representationId?: string @Column({ nullable: true }) @Field({ nullable: true, description: 'Area name.' }) name?: string @Column({ nullable: true }) @Field({ nullable: true, description: 'Region type (building/floor/zone/yard/dock…).' }) type?: string @Column({ type: 'simple-json', nullable: true }) @Field(type => ScalarObject, { nullable: true, description: 'Polygon geometry { kind:"polygon", points:[[x,y]…] } (map=lat/lon, image=px).' }) geometry?: any @Column({ type: 'simple-json', nullable: true }) @Field(type => ScalarObject, { nullable: true, description: 'Drill-down target { kind:"board"|"representation"|"space", id } — click navigates to a model monitor/sim view.' }) drillTo?: any @Column({ type: 'simple-json', nullable: true }) @Field(type => ScalarObject, { nullable: true, description: 'Twin binding { locationId?|entityId?|tag? } for live state.' }) binding?: any @Column({ type: 'simple-json', nullable: true }) @Field(type => ScalarObject, { nullable: true, description: 'Polygon decoration { stroke, fill, fillOpacity, strokeWidth } — line/fill color and opacity.' }) style?: any @CreateDateColumn() @Field({ nullable: true }) createdAt?: Date @UpdateDateColumn() @Field({ nullable: true }) updatedAt?: Date }