@operato/ops-contract 0.9.42 → 0.9.43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,4 @@
1
+ import type { EquipmentStatus } from './contract.ts';
1
2
  export type CapabilityKey = 'operable' | 'storable' | 'mobile' | 'processable' | 'trackable' | 'switching' | 'metered' | 'curtailable' | 'energyGenerating' | 'energyStoring';
2
3
  /** 이동 관측 — Mobile 이 노출. */
3
4
  export interface Motion {
@@ -8,8 +9,12 @@ export interface Motion {
8
9
  progress: number;
9
10
  elapsedMs: number;
10
11
  }
12
+ /**
13
+ * 능동 자원의 운영 상태 — 설비 상태 다섯 값(`EquipmentStatus`: 가동 · 준비 · 고장 · 대기 · 계획정지). 커널 미러는 관측한 다섯 값을
14
+ * 그대로 내보낸다. 셋(idle · busy · down)으로 적혀 있던 동안 준비와 계획정지를 읽는 쪽이 대기로 그렸다(ADR-0208 결정 2 수정).
15
+ */
11
16
  export interface OperableState {
12
- status: 'idle' | 'busy' | 'down';
17
+ status: EquipmentStatus;
13
18
  }
14
19
  export interface StorableState {
15
20
  occupancy: number;
@@ -1,16 +1,3 @@
1
- /*
2
- * 능력(capability) = 관측 계약(observable contract). 사상 토대: design/plans/capability-contract.md.
3
- *
4
- * 원칙 ① 관측만 — state(데이터형식)+models+invariants+results 만 계약. ops/구현은 없음(커널·씬 각 시뮬 자유).
5
- * "교환되는 것"을 계약하고 "계산하는 법"은 계약하지 않는다(결정성 지옥 회피·공유 가능성 핵심).
6
- * 원칙 ② 직교·조합 — 교차 관심사 status 는 Operable 하나에만(중복 제거). 엔티티는 능력 *조합*.
7
- * 원칙 ③ 작은 코어 + 열린 확장(무방언) — 도메인이 능력 선언, 코어는 발명 안 함.
8
- * 원칙 ④ 능력 ⟂ standardClass — 다른 축, 파생 없음.
9
- *
10
- * things-scene 정합: 이건 "의도(intent)" 계층(관측). 씬 기제 믹스(Capacity/Transferable/CarrierLine …)가
11
- * 이 의도를 *실현*한다 — 공유 계약은 관측(계층 B)뿐, 기제 methods(계층 A)는 공유 안 함.
12
- * ⚠ Mobile ≠ Transferable: Mobile=자원 자신이 이동, Transferable=자리가 아이템 이동(씬 기제).
13
- */
14
1
  /*
15
2
  * `label` 은 **언어 중립 i18n 키**(`twin.capability.<key>`) — 사람 언어는 표현계층이 렌더한다(L2).
16
3
  * 타입/시스템 라벨(domain-catalog)이 먼저 이 규약으로 옮겨졌고, 능력 라벨만 사람 말로 남아
@@ -282,7 +282,7 @@ levelOfType?: (type: string) => EquipmentLevel | undefined): Hierarchy;
282
282
  * 추정기까지 `any` 로 전달됐다. 자원에 붙는 사실이 계약에 자리가 없으면 소비처마다 다르게 읽는다.
283
283
  */
284
284
  /**
285
- * 이 속성 값을 **누가 말했나** — 근거를 값과 함께 나르는 규율의 속성 판(`basis`·`derived` 와 같은 결).
285
+ * 이 속성 값을 **누가 말했나** — 근거를 값과 함께 나르는 규율의 속성 버전(`basis`·`derived` 와 같은 결).
286
286
  *
287
287
  * ── 두 낱말이 한 축이다 (2026-08-18 확정) ───────────────────────────────────
288
288
  * · `reference` — **외부 원천 시스템**이 준 값이다(SCADA·WMS·MES 의 마스터). 우리가 고르지 않았다.
@@ -364,7 +364,7 @@ export type TestSpecificationRefs = string[];
364
364
  * 모델에 없어서 그 참조는 **허공을 가리켰다** — 값을 실을 수는 있어도 그것이 무엇인지 아무도 답할 수
365
365
  * 없었고, 화면은 그 사실을 조용히 넘겼다. 대상을 세우는 것이 이 선언의 일이다.
366
366
  *
367
- * 여기 담는 것은 **셋뿐이다**: 식별자·설명·판. 표준의 명세 타입(`B2MML-OperationsTest.xsd`)에는 재는
367
+ * 여기 담는 것은 **셋뿐이다**: 식별자·설명·버전. 표준의 명세 타입(`B2MML-OperationsTest.xsd`)에는 재는
368
368
  * 속성과 합격 기준이 더 있는데, 그 필드 이름을 **아직 1차 출처와 대조하지 않았다.** 짐작해 넣으면
369
369
  * 표준 이름을 발명하는 것이고 이 저장소의 가드가 그것을 잡는다 — 대조한 뒤에 늘린다.
370
370
  *
@@ -1950,20 +1950,20 @@ export interface AssetState extends EffectivePeriod {
1950
1950
  * 자리들이다.
1951
1951
  */
1952
1952
  /**
1953
- * **작업 지시서 참조**(ISA-95 `WorkDirective`) — 어느 판의 절차로 만들었나.
1953
+ * **작업 지시서 참조**(ISA-95 `WorkDirective`) — 어느 버전의 절차로 만들었나.
1954
1954
  *
1955
1955
  * ── 내용은 담지 않는다 (2026-08-30) ───────────────────────────────────────
1956
1956
  * 절차·도면·설정값은 MES 가 갖는다. 트윈은 그것으로 계산하지 않는다.
1957
1957
  *
1958
- * 담는 것은 **정체성과 판**이다. 같은 작업지시라도 절차 3판으로 만든 것과 4판으로 만든 것은 다른
1959
- * 사실이고, 나중에 문제가 났을 때 어느 판이었는지 말할 수 없으면 트윈이 답을 못 한다. 표준이
1960
- * `WorkDirective` 를 판으로 관리하는 이유가 그것이다.
1958
+ * 담는 것은 **정체성과 버전**이다. 같은 작업지시라도 절차 버전 3으로 만든 것과 버전 4로 만든 것은 다른
1959
+ * 사실이고, 나중에 문제가 났을 때 어느 버전이었는지 말할 수 없으면 트윈이 답을 못 한다. 표준이
1960
+ * `WorkDirective` 를 버전으로 관리하는 이유가 그것이다.
1961
1961
  *
1962
1962
  * `WorkMaster` 는 「이 제품을 이렇게 만든다」이고 이것은 「이번에 이 절차로 만들었다」이다.
1963
1963
  */
1964
1964
  export interface WorkDirectiveRef {
1965
1965
  id: string;
1966
- /** 절차의 판 — 없으면 「판을 말하지 않은 원천」이고, 지어내지 않는다. */
1966
+ /** 절차의 버전 — 없으면 「버전을 말하지 않은 원천」이고, 지어내지 않는다. */
1967
1967
  version?: string;
1968
1968
  /** 이 지시서가 따르는 `WorkMaster` — 있을 때만. */
1969
1969
  workMasterId?: string;
@@ -1973,7 +1973,7 @@ export interface TaskState {
1973
1973
  id: string;
1974
1974
  kind: string;
1975
1975
  status: TaskStatus;
1976
- /** 어느 판의 절차로 하는 작업인가 — 계보의 사실이다(§`WorkDirectiveRef`). */
1976
+ /** 어느 버전의 절차로 하는 작업인가 — 계보의 사실이다(§`WorkDirectiveRef`). */
1977
1977
  workDirective?: WorkDirectiveRef;
1978
1978
  itemRefs?: string[];
1979
1979
  fromNode?: string;
@@ -3178,7 +3178,7 @@ export interface EnergyGeneratedData {
3178
3178
  * 'billing' 요금기간부터 — 경계는 계약이 정하므로 시각을 함께 받아야 구간이 정해진다
3179
3179
  * 'unknown' **원본이 말하지 않는다.** 이 값을 다른 값과 비교하지 말라는 뜻이다
3180
3180
  *
3181
- * 없으면(칸이 아예 없으면) 커널은 `'unknown'` 으로 둔다 — 예전 판이 보내던 레코드가 조용히 평생치로
3181
+ * 없으면(칸이 아예 없으면) 커널은 `'unknown'` 으로 둔다 — 예전 버전이 보내던 레코드가 조용히 평생치로
3182
3182
  * 읽히지 않게.
3183
3183
  */
3184
3184
  accumulation?: 'lifetime' | 'daily' | 'monthly' | 'billing' | 'unknown';
@@ -3423,6 +3423,12 @@ export declare const EQUIPMENT_STATUS: readonly ["busy", "setup", "down", "idle"
3423
3423
  export type EquipmentStatus = (typeof EQUIPMENT_STATUS)[number];
3424
3424
  /** 선언된 상태인가. */
3425
3425
  export declare function isEquipmentStatus(value: unknown): value is EquipmentStatus;
3426
+ /** A person's observed status (`PersonStatusDelta.status`): assigned to work or free. */
3427
+ export declare const PERSON_STATUS: readonly ["idle", "busy"];
3428
+ export type PersonStatus = (typeof PERSON_STATUS)[number];
3429
+ /** A physical asset's observed status (`AssetStatusDelta.status`): in use or free. */
3430
+ export declare const ASSET_STATUS: readonly ["idle", "in-use"];
3431
+ export type AssetStatus = (typeof ASSET_STATUS)[number];
3426
3432
  /**
3427
3433
  * **ISA-95 의 네 자원** — 「무엇이 자원인가」를 한 자리에서 말한다.
3428
3434
  *
package/dist/contract.js CHANGED
@@ -1403,6 +1403,10 @@ export const EQUIPMENT_STATUS = ['busy', 'setup', 'down', 'idle', 'planned-stop'
1403
1403
  export function isEquipmentStatus(value) {
1404
1404
  return typeof value === 'string' && EQUIPMENT_STATUS.includes(value);
1405
1405
  }
1406
+ /** A person's observed status (`PersonStatusDelta.status`): assigned to work or free. */
1407
+ export const PERSON_STATUS = ['idle', 'busy'];
1408
+ /** A physical asset's observed status (`AssetStatusDelta.status`): in use or free. */
1409
+ export const ASSET_STATUS = ['idle', 'in-use'];
1406
1410
  /**
1407
1411
  * **ISA-95 의 네 자원** — 「무엇이 자원인가」를 한 자리에서 말한다.
1408
1412
  *
@@ -389,7 +389,7 @@ export interface CatalogSummary {
389
389
  supplier?: string;
390
390
  }
391
391
  /**
392
- * 배포 아티팩트 검증 = 정의 검증 + 판 번호.
392
+ * 배포 아티팩트 검증 = 정의 검증 + 버전 번호.
393
393
  *
394
394
  * 정의의 참조무결성은 `validateDomainDefinition` 이 소유한다 — 여기서 다시 쓰지 않는다. 위반 목록을
395
395
  * 돌려주고, 빈 배열이 유효다.
@@ -3,7 +3,7 @@
3
3
  * 커널이 "무엇이 있고 어떻게 흐르나"(타입 + 공정 route/BOM)를 **데이터로** 받는 형식. zero-dep(자기 타입).
4
4
  *
5
5
  * 특정 공정이 커널 코드에 하드코딩되던 것을 이 데이터 계약으로 대체한다(design/plans/domain-catalog-layering.md).
6
- * 판을 붙여 주고받는 꼴은 이 파일 아래쪽의 `DomainCatalog` 다 — 전에는 `@operato/twin-catalog` 라는
6
+ * 버전을 붙여 주고받는 꼴은 이 파일 아래쪽의 `DomainCatalog` 다 — 전에는 `@operato/twin-catalog` 라는
7
7
  * 별도 패키지였고, 2026-09-17 에 여기로 접었다.
8
8
  * 표준 앵커: GS1 EPCIS 2.0(bizStep) · ISA-95(WorkCenter·OperationsDefinition·BOM) · ISO 55000(Asset).
9
9
  */
@@ -138,7 +138,7 @@ export function validateDomainDefinition(def) {
138
138
  }
139
139
  const CATALOG_SEMVER = /^\d+\.\d+\.\d+([-+].+)?$/;
140
140
  /**
141
- * 배포 아티팩트 검증 = 정의 검증 + 판 번호.
141
+ * 배포 아티팩트 검증 = 정의 검증 + 버전 번호.
142
142
  *
143
143
  * 정의의 참조무결성은 `validateDomainDefinition` 이 소유한다 — 여기서 다시 쓰지 않는다. 위반 목록을
144
144
  * 돌려주고, 빈 배열이 유효다.
package/dist/epcis.d.ts CHANGED
@@ -445,6 +445,21 @@ export declare function itemClassOf(uri: string | undefined): string | undefined
445
445
  * 그 밖(모르는 모양) → 원문 그대로 — 품목 이름이 그 글자일 수 있다(`itemClassOf` 와 같다)
446
446
  */
447
447
  export declare function materialDefinitionIdOf(epcClass: string | undefined): string | undefined;
448
+ /**
449
+ * **물품 하나의 품목 이름** — 그 물품이 무슨 품목인가(ISA-95 `MaterialDefinition` 의 ID). 피규어가 물품 모양을 고르는 코드다(도메인의
450
+ * `item-types` 표, ADR-0208 결정 5).
451
+ *
452
+ * 물품 상태의 세 칸에서 차례로 고른다:
453
+ * 1. `definitionId` — 상류가 품목 코드를 따로 말했으면 그것
454
+ * 2. `materialDefinitionIdOf(gtin)` — 품목 클래스에서(로트 · GTIN 품목 → GTIN 품목 패턴, 사내 클래스 → 품번)
455
+ * 3. `gtinKey` 의 GTIN 품목 패턴 — 직렬 물품(SGTIN)은 커널 상태에 `gtinKey` 만 있다
456
+ * 셋 다 없으면 `undefined` — 지어내지 않는다. 같은 품목의 직렬 물품과 로트 물품이 같은 이름이 된다.
457
+ */
458
+ export declare function itemMaterialDefinitionId(item: {
459
+ definitionId?: string;
460
+ gtin?: string;
461
+ gtinKey?: string;
462
+ } | undefined): string | undefined;
448
463
  /**
449
464
  * **이 품목 클래스의 그 로트** — `itemClassOf` 의 반대 방향. 시뮬의 도착 생성기처럼 품목 클래스만 들고 있는 곳이 부른다.
450
465
  *
@@ -551,6 +566,13 @@ export declare function lotClassUri(input: {
551
566
  gtin?: string;
552
567
  }): string | undefined;
553
568
  export declare function bizTransactionUri(namespace: string, transId: string | number): string | undefined;
569
+ /**
570
+ * 이름공간 아래 식별자의 표지 — CBV 2.0 의 도메인 기반 식별자마다 하나.
571
+ * `obj` §8.2 · `class` §8.3 · `bt` §8.5 · `sd` §8.7(Source/Destination — 거래 상대, `party.ts`).
572
+ */
573
+ export type NamespaceMarker = 'obj' | 'class' | 'bt' | 'sd';
574
+ /** 이 파일 밖에서 표지 규칙을 다시 적지 않도록 — 같은 부호화 · 같은 이름공간 판정을 쓴다(`party.ts`). */
575
+ export declare function identifierUnderNamespace(namespace: string, marker: NamespaceMarker, id: string | number): string | undefined;
554
576
  /** 모든 빌더가 공통으로 받는 표준 헤더 옵션(선택) — 방출부가 필요할 때 채운다. */
555
577
  export interface EpcisHeaderOptions {
556
578
  eventID?: string;
package/dist/epcis.js CHANGED
@@ -369,6 +369,27 @@ export function materialDefinitionIdOf(epcClass) {
369
369
  }
370
370
  return raw;
371
371
  }
372
+ /**
373
+ * **물품 하나의 품목 이름** — 그 물품이 무슨 품목인가(ISA-95 `MaterialDefinition` 의 ID). 피규어가 물품 모양을 고르는 코드다(도메인의
374
+ * `item-types` 표, ADR-0208 결정 5).
375
+ *
376
+ * 물품 상태의 세 칸에서 차례로 고른다:
377
+ * 1. `definitionId` — 상류가 품목 코드를 따로 말했으면 그것
378
+ * 2. `materialDefinitionIdOf(gtin)` — 품목 클래스에서(로트 · GTIN 품목 → GTIN 품목 패턴, 사내 클래스 → 품번)
379
+ * 3. `gtinKey` 의 GTIN 품목 패턴 — 직렬 물품(SGTIN)은 커널 상태에 `gtinKey` 만 있다
380
+ * 셋 다 없으면 `undefined` — 지어내지 않는다. 같은 품목의 직렬 물품과 로트 물품이 같은 이름이 된다.
381
+ */
382
+ export function itemMaterialDefinitionId(item) {
383
+ if (!item)
384
+ return undefined;
385
+ if (item.definitionId)
386
+ return item.definitionId;
387
+ const fromClass = materialDefinitionIdOf(item.gtin);
388
+ if (fromClass)
389
+ return fromClass;
390
+ const [companyPrefix, itemRef] = (item.gtinKey ?? '').split('.');
391
+ return companyPrefix && itemRef ? sgtinClass(companyPrefix, itemRef) : undefined;
392
+ }
372
393
  /**
373
394
  * **이 품목 클래스의 그 로트** — `itemClassOf` 의 반대 방향. 시뮬의 도착 생성기처럼 품목 클래스만 들고 있는 곳이 부른다.
374
395
  *
@@ -564,6 +585,10 @@ const PERCENT_ENCODED = {
564
585
  /* 로트 클래스의 가르는 글자 — `lotClassUri` 만 쓴다(§`LOT_COMPONENT_BREAKING`). 표는 한 벌이다. */
565
586
  ';': '%3B'
566
587
  };
588
+ /** 이 파일 밖에서 표지 규칙을 다시 적지 않도록 — 같은 부호화 · 같은 이름공간 판정을 쓴다(`party.ts`). */
589
+ export function identifierUnderNamespace(namespace, marker, id) {
590
+ return underNamespace(namespace, marker, id);
591
+ }
567
592
  function underNamespace(namespace, marker, id) {
568
593
  const raw = String(id);
569
594
  if (!raw)
package/dist/erp.d.ts CHANGED
@@ -42,10 +42,10 @@ export interface ProductionScheduleEntry extends ProductionDemand {
42
42
  /** ERP 의 오더번호. 이 지시를 가리키는 이름이다. */
43
43
  orderId: string;
44
44
  /**
45
- * **이 지시의 판** — 수량 · 납기 · 취소가 바뀌면 올라간다.
45
+ * **이 지시의 버전** — 수량 · 납기 · 취소가 바뀌면 올라간다.
46
46
  *
47
- * 덮어쓰지 않고 판마다 남기는 이유는, 이미 올린 실적이 **어느 지시에 대한 것인지** 잃으면 정산이
48
- * 성립하지 않기 때문이다. ERP 가 판을 말해 주지 않으면 받은 시각으로 대신하지 않는다 — 그것은
47
+ * 덮어쓰지 않고 버전마다 남기는 이유는, 이미 올린 실적이 **어느 지시에 대한 것인지** 잃으면 정산이
48
+ * 성립하지 않기 때문이다. ERP 가 버전을 말해 주지 않으면 받은 시각으로 대신하지 않는다 — 그것은
49
49
  * 우리 사정이지 지시의 사실이 아니다.
50
50
  */
51
51
  revision?: string;
@@ -88,7 +88,7 @@ export declare function acceptsPerformance(status: ScheduleStatus): boolean;
88
88
  export interface ProductionPerformanceEntry {
89
89
  /** 어느 지시에 대한 것인가 — ERP 의 오더번호. */
90
90
  orderId: string;
91
- /** 그 지시의 어느 판에 대한 것인가. 지시가 판을 말했으면 그대로 옮긴다. */
91
+ /** 그 지시의 어느 버전에 대한 것인가. 지시가 버전을 말했으면 그대로 옮긴다. */
92
92
  revision?: string;
93
93
  /**
94
94
  * 어느 공정인가 — ERP 의 공정 식별자. **오더 단위로만 받는 ERP 가 있다.**
package/dist/gs1.d.ts CHANGED
@@ -67,3 +67,30 @@ export declare function gtin14OfItemClass(definitionId: string | null | undefine
67
67
  * 13 · 14 자리)면 앞을 0 으로 채운 14자리. 라벨의 AI 01 과 견줄 때 쓴다. 어느 것도 아니면 `undefined`.
68
68
  */
69
69
  export declare function gtin14OfItem(definitionId: string | null | undefined): string | undefined;
70
+ /**
71
+ * **The text a person reads for an identifier** - the one place screens turn a stored EPC into words.
72
+ *
73
+ * Stored identifiers stay long (EPCIS URNs, CBV domain URIs) because a journal mixes many sources and the value itself
74
+ * has to say what kind of key it is and who issued it. A screen has that context already, so it shows the short form
75
+ * people meet on labels: the GS1 element string with its application identifiers - the human readable interpretation
76
+ * printed under a GS1 barcode.
77
+ *
78
+ * urn:epc:id:sgtin:P.R.S -> (01)<GTIN-14>(21)<serial>
79
+ * urn:epc:class:lgtin:P.R.L -> (01)<GTIN-14>(10)<lot>
80
+ * urn:epc:idpat:sgtin:P.R.* -> (01)<GTIN-14>
81
+ * urn:epc:id:sscc:P.S -> (00)<SSCC-18>
82
+ * urn:epc:id:sgln:P.L.E -> (414)<GLN-13>, and (254)<E> when E is not 0
83
+ * urn:epc:id:grai:P.T.S -> (8003)0<GRAI-13><serial>
84
+ * urn:epc:id:gdti:P.T.S -> (253)<GDTI-13><serial>
85
+ * urn:epc:id:giai:P.A -> (8004)<P><A>
86
+ * <domain>/../obj/<id> -> <id>
87
+ * <domain>/../class/<item>;lot=<L> -> <item> · <L>
88
+ * <domain>/../class/<id> -> <id>
89
+ * <domain>/../bt/<id> -> <id>
90
+ *
91
+ * The reading is `parseEpc`'s - nothing here cuts at `:` or `.` on its own, which is how a screen once showed a lot as
92
+ * the item name. A value whose digits do not add up, or that is no identifier we know, comes back as written: a wrong
93
+ * short form would look trustworthy, the original at least says what is stored. A name from master data, where the
94
+ * screen has one, goes before this text; that lookup is the screen's.
95
+ */
96
+ export declare function identifierText(uri: string | null | undefined): string;
package/dist/gs1.js CHANGED
@@ -1,4 +1,4 @@
1
- import { lgtinClass, sgtinClass } from "./epcis.js";
1
+ import { lgtinClass, parseEpc, sgtinClass } from "./epcis.js";
2
2
  /**
3
3
  * GS1 바코드가 낸 문자열을 뜯는다 — **순수 계산.**
4
4
  *
@@ -259,3 +259,88 @@ export function gtin14OfItem(definitionId) {
259
259
  return byClass;
260
260
  return /^(\d{8}|\d{12,14})$/.test(definitionId ?? '') ? definitionId.padStart(14, '0') : undefined;
261
261
  }
262
+ /**
263
+ * **The text a person reads for an identifier** - the one place screens turn a stored EPC into words.
264
+ *
265
+ * Stored identifiers stay long (EPCIS URNs, CBV domain URIs) because a journal mixes many sources and the value itself
266
+ * has to say what kind of key it is and who issued it. A screen has that context already, so it shows the short form
267
+ * people meet on labels: the GS1 element string with its application identifiers - the human readable interpretation
268
+ * printed under a GS1 barcode.
269
+ *
270
+ * urn:epc:id:sgtin:P.R.S -> (01)<GTIN-14>(21)<serial>
271
+ * urn:epc:class:lgtin:P.R.L -> (01)<GTIN-14>(10)<lot>
272
+ * urn:epc:idpat:sgtin:P.R.* -> (01)<GTIN-14>
273
+ * urn:epc:id:sscc:P.S -> (00)<SSCC-18>
274
+ * urn:epc:id:sgln:P.L.E -> (414)<GLN-13>, and (254)<E> when E is not 0
275
+ * urn:epc:id:grai:P.T.S -> (8003)0<GRAI-13><serial>
276
+ * urn:epc:id:gdti:P.T.S -> (253)<GDTI-13><serial>
277
+ * urn:epc:id:giai:P.A -> (8004)<P><A>
278
+ * <domain>/../obj/<id> -> <id>
279
+ * <domain>/../class/<item>;lot=<L> -> <item> · <L>
280
+ * <domain>/../class/<id> -> <id>
281
+ * <domain>/../bt/<id> -> <id>
282
+ *
283
+ * The reading is `parseEpc`'s - nothing here cuts at `:` or `.` on its own, which is how a screen once showed a lot as
284
+ * the item name. A value whose digits do not add up, or that is no identifier we know, comes back as written: a wrong
285
+ * short form would look trustworthy, the original at least says what is stored. A name from master data, where the
286
+ * screen has one, goes before this text; that lookup is the screen's.
287
+ */
288
+ export function identifierText(uri) {
289
+ const raw = String(uri ?? '').trim();
290
+ if (!raw)
291
+ return '';
292
+ const parsed = parseEpc(raw);
293
+ if (parsed.scheme === 'sgtin' || parsed.scheme === 'lgtin' || parsed.scheme === 'idpat') {
294
+ const gtin = gtin14OfKey(parsed.gtinKey);
295
+ if (!gtin)
296
+ return raw;
297
+ if (parsed.scheme === 'sgtin')
298
+ return parsed.serial ? `(01)${gtin}(21)${decoded(parsed.serial)}` : raw;
299
+ if (parsed.scheme === 'lgtin')
300
+ return parsed.lot ? `(01)${gtin}(10)${parsed.lot}` : raw;
301
+ return `(01)${gtin}`;
302
+ }
303
+ if (parsed.scheme === 'sscc') {
304
+ const sscc = ssccDigitsOf(raw);
305
+ return sscc ? `(00)${sscc}` : raw;
306
+ }
307
+ if (parsed.scheme === 'sgln') {
308
+ const m = /^urn:epc:id:sgln:(\d+)\.(\d*)\.(.+)$/.exec(raw);
309
+ if (!m || m[1].length + m[2].length !== 12)
310
+ return raw;
311
+ const body = m[1] + m[2];
312
+ return `(414)${body}${checkDigitOf(body)}${m[3] === '0' ? '' : `(254)${decoded(m[3])}`}`;
313
+ }
314
+ if (parsed.scheme === 'grai' || parsed.scheme === 'gdti') {
315
+ const m = new RegExp(`^urn:epc:id:${parsed.scheme}:(\\d+)\\.(\\d*)\\.(.*)$`).exec(raw);
316
+ if (!m || m[1].length + m[2].length !== 12)
317
+ return raw;
318
+ const key = m[1] + m[2] + checkDigitOf(m[1] + m[2]);
319
+ return parsed.scheme === 'grai' ? `(8003)0${key}${decoded(m[3])}` : `(253)${key}${decoded(m[3])}`;
320
+ }
321
+ if (parsed.scheme === 'giai') {
322
+ const m = /^urn:epc:id:giai:(\d+)\.(.+)$/.exec(raw);
323
+ return m ? `(8004)${m[1]}${decoded(m[2])}` : raw;
324
+ }
325
+ if (parsed.item !== undefined && parsed.lot !== undefined)
326
+ return `${parsed.item} · ${parsed.lot}`;
327
+ const inHouse = /(?:\/(?:obj|class|bt)\/|:(?:obj|class|bt):)([^/:\s]+)$/.exec(raw);
328
+ return inHouse ? decoded(inHouse[1]) : raw;
329
+ }
330
+ /** GTIN-14 of a `CompanyPrefix.IndicatorAndItemRef` key, or `undefined` when the digits do not add up to 13. */
331
+ function gtin14OfKey(key) {
332
+ const m = /^(\d+)\.(\d+)$/.exec(key ?? '');
333
+ if (!m)
334
+ return undefined;
335
+ const body = m[2][0] + m[1] + m[2].slice(1);
336
+ return body.length === 13 ? body + checkDigitOf(body) : undefined;
337
+ }
338
+ /** A URI component as a person reads it; one that does not decode stays as written. */
339
+ function decoded(part) {
340
+ try {
341
+ return decodeURIComponent(part);
342
+ }
343
+ catch {
344
+ return part;
345
+ }
346
+ }
package/dist/index.d.ts CHANGED
@@ -20,6 +20,7 @@ export * from './scenario-validate.ts';
20
20
  export * from './vocabulary.ts';
21
21
  export * from './wms-profile.ts';
22
22
  export * from './yms-profile.ts';
23
+ export * from './party.ts';
23
24
  export * from './canonical-record.ts';
24
25
  export * from './command-verdict.ts';
25
26
  export * from './webhook-delivery.ts';
package/dist/index.js CHANGED
@@ -41,6 +41,7 @@ export * from "./scenario-validate.js";
41
41
  export * from "./vocabulary.js";
42
42
  export * from "./wms-profile.js";
43
43
  export * from "./yms-profile.js";
44
+ export * from "./party.js";
44
45
  export * from "./canonical-record.js";
45
46
  export * from "./command-verdict.js";
46
47
  export * from "./webhook-delivery.js";
@@ -34,7 +34,7 @@
34
34
  * 모르는 필드는 **조용히 버리지 않고 거부한다.** `taskID` 처럼 한 글자 틀린 이름은 통과시키면 영원히
35
35
  * 보이지 않는 손실이 된다(이 문에는 아직 옛 발신자가 없어 호환 부담도 없다).
36
36
  */
37
- import { OP_EVENT, BASIS_UNKNOWN, DISPOSITION_DECISION, MATERIAL_ACTUAL_USE, MATERIAL_LOT_USE, isTestSpecificationBasis, isRecipeExecutionBasis, isMaterialExecutionBasis } from "./contract.js";
37
+ import { OP_EVENT, BASIS_UNKNOWN, EQUIPMENT_STATUS, PERSON_STATUS, ASSET_STATUS, DISPOSITION_DECISION, MATERIAL_ACTUAL_USE, MATERIAL_LOT_USE, isTestSpecificationBasis, isRecipeExecutionBasis, isMaterialExecutionBasis } from "./contract.js";
38
38
  import { isWorkShiftExecutionBasis } from "./work-shift-basis.js";
39
39
  /**
40
40
  * 객체 한 줄이 선언된 안쪽 모양을 지키나 — **선언하지 않은 자리는 보지 않는다.**
@@ -106,10 +106,10 @@ const TASK_STATUS = ['created', 'assigned', 'in-progress', 'completed'];
106
106
  *
107
107
  * `down` 과 `idle` 은 22400 에서 다른 항목이고 공장이 손 쓰는 방법도 다르다(고장은 보전, 대기는
108
108
  * 자재·일정). 처음부터 갈라 두었던 것이 맞았고, 여기에 둘을 더해 22400 의 시간 모델을 덮는다.
109
+ *
110
+ * The lists themselves (equipment, person, asset) live in the contract (`contract.ts`) and are imported here, so
111
+ * the ingest boundary accepts exactly what the contract declares.
109
112
  */
110
- const EQUIPMENT_STATUS = ['idle', 'busy', 'down', 'setup', 'planned-stop'];
111
- const PERSON_STATUS = ['idle', 'busy'];
112
- const ASSET_STATUS = ['idle', 'in-use'];
113
113
  const SPECS = {
114
114
  task: {
115
115
  eventType: OP_EVENT.task,
@@ -0,0 +1,70 @@
1
+ /**
2
+ * **경계를 넘는 거래 상대 참조.** `id` 는 이 파일이 판별하는 URI 이고, `name` 은 사람이 읽을 이름이다(판정에 쓰지 않는다).
3
+ * 제품마다 다시 정의하지 않는다(ADR-0211 결정 4).
4
+ */
5
+ export interface PartyRef {
6
+ id: string;
7
+ name?: string;
8
+ }
9
+ /**
10
+ * EPCIS Source/Destination 의 **종류** 중 거래 상대인 것 — CBV 2.0 §7.4.3.
11
+ *
12
+ * · `owning_party` — 그 이전의 끝점에서 물건을 **소유한**(또는 소유할) 당사자.
13
+ * · `possessing_party` — 그 이전의 끝점에서 물건을 **물리적으로 가진**(또는 가질) 당사자. 실려 가는 동안의 운송사가 이것이다.
14
+ *
15
+ * 표준의 셋째 값 `location` 은 자리다 — 거래 상대가 아니므로 여기 두지 않는다.
16
+ */
17
+ export declare const SOURCE_DEST_PARTY_TYPE: {
18
+ readonly owning_party: "urn:epcglobal:cbv:sdt:owning_party";
19
+ readonly possessing_party: "urn:epcglobal:cbv:sdt:possessing_party";
20
+ };
21
+ export type SourceDestPartyType = (typeof SOURCE_DEST_PARTY_TYPE)[keyof typeof SOURCE_DEST_PARTY_TYPE];
22
+ /**
23
+ * **관계 안의 역할** — UN/CEFACT 당사자 역할 코드(UNTDID 3035). 닫힌 목록이고, **쓰는 날 하나씩** 올린다(ADR-0211 결정 4).
24
+ * 표준에 없는 역할은 지어내기 전에 판정을 받는다.
25
+ *
26
+ * · `CA` Carrier — 「Party undertaking or arranging transport of goods between named points.」
27
+ * (UNTDID 3035, D.96A 사본으로 확인 2026-11-17. 야드의 예약 · 게이트 방문, 창고 출하의 `bol` 을 낸 쪽.)
28
+ */
29
+ export declare const PARTY_ROLE: {
30
+ readonly carrier: "CA";
31
+ };
32
+ export type PartyRole = (typeof PARTY_ROLE)[keyof typeof PARTY_ROLE];
33
+ /** CBV 2.0 §8.1.4 — HTTP(S) 식별자는 이 길이를 넘지 않는다(SHALL). */
34
+ export declare const PARTY_URI_MAX_LENGTH = 128;
35
+ /** CBV 2.0 §8.1.4 — 이 길이를 넘지 않기를 권한다(SHOULD). 넘으면 거절하지 않고 알린다. */
36
+ export declare const PARTY_URI_RECOMMENDED_LENGTH = 60;
37
+ /**
38
+ * **거래 상대 식별자를 발급한다** — 소유 도메인의 이름공간과 거래처 행 id 로(ADR-0211 결정 11).
39
+ *
40
+ * 부르는 곳은 biz-base 한 곳이다(결정 13-4 — 다른 코드는 URI 를 조립하지 않는다). 꼴의 규칙을 그곳에 다시 적지 않도록 여기 둔다.
41
+ *
42
+ * · 행 id 는 uuid 여야 한다 — 하이픈 · 대소문자는 받아서 **하이픈 뺀 소문자 32자**로 쓴다(결정 11-8). 아니면 던진다.
43
+ * · 이름공간이 없거나 GS1 공간이면 `undefined` 다(지어내지 않는다 — `objectUri` 와 같다).
44
+ * · 만든 값이 128자를 넘으면 던진다 — 그 이름공간 선언이 틀린 것이다(결정 11-8).
45
+ */
46
+ export declare function partyUri(namespace: string, rowId: string): string | undefined;
47
+ /**
48
+ * **우리가 발급한 식별자에서 거래처 행 id 를 되찾는다** — 하이픈 있는 uuid 로.
49
+ *
50
+ * 토큰이 발급한 꼴(소문자 32자)일 때만 답한다. 대문자 · 하이픈이 섞인 꼴은 같은 값이 아니다(결정 11-8). 바깥에서 온 식별자
51
+ * (PGLN · 남의 `/sd/`)는 `undefined` 다 — 그때는 알려진 다른 식별자로 찾는다(결정 13-2). 이 함수는 **이름공간을 묻지 않는다**:
52
+ * 그 이름공간이 우리 것인지는 부르는 쪽(biz-base)이 안다.
53
+ */
54
+ export declare function partyRowIdOf(uri: string | undefined): string | undefined;
55
+ /**
56
+ * **거래 상대 식별자로 받을 수 있는가** — 받을 수 없으면 까닭, 받을 수 있으면 `undefined`.
57
+ *
58
+ * 받는 꼴은 CBV 2.0 §8.7 의 네 꼴 중 거래 상대의 것이다: PGLN EPC · PGLN Digital Link(정규 `id.gs1.org`) · `/sd/` URL · `:sd:` URN.
59
+ * 128자를 넘으면 거절한다(SHALL). 60자 초과는 거절하지 않는다 — `partyUriLengthNote` 가 말한다.
60
+ *
61
+ * 비정규 Digital Link(`https://example.com/…/417/…`)는 아직 판정하지 않는다 — 클래스 식별자와 같은 좁힘이다(`epcis.ts`
62
+ * `classIdentifierViolation`). 그것을 쓰는 원천이 붙는 날 연다.
63
+ */
64
+ export declare function partyIdentifierViolation(uri: string | undefined): string | undefined;
65
+ /** 판별의 참 · 거짓 — 까닭이 필요하면 `partyIdentifierViolation` 을 부른다. */
66
+ export declare function isPartyUri(v: unknown): v is string;
67
+ /** 60자 권장(SHOULD)을 넘었으면 알릴 말, 아니면 `undefined`. 거절하지 않는다. */
68
+ export declare function partyUriLengthNote(uri: string | undefined): string | undefined;
69
+ /** 경계를 넘어 받은 값이 거래 상대 참조인가 — `id` 가 판별을 지나야 한다. `name` 은 있으면 글이어야 한다. */
70
+ export declare function isPartyRef(v: unknown): v is PartyRef;
package/dist/party.js ADDED
@@ -0,0 +1,131 @@
1
+ /*
2
+ * **거래 상대** — 누구인가(정체성)와 어떤 관계로 나타났나(역할)를 가르는 계약 (operato-application ADR-0211).
3
+ *
4
+ * 정체성은 biz-base `Counterparty` 한 행이고, 그 행을 **경계 밖에서** 가리키는 값이 여기의 URI 다(ADR-0211 결정 13 —
5
+ * 같은 DB 안은 행 id 외래키, 사람에게는 이름). 역할은 상대의 칸이 아니라 관계(문서 · 사건 · 예약) 쪽에 붙는다(결정 1).
6
+ *
7
+ * ── 표준 (CBV 2.0, Release 2.0, Ratified, Jun 2022 — 원문 확인 2026-11-17) ─────────────────────────────
8
+ * 표준에 「거래 상대 식별자」라는 절은 따로 없다. 거래 상대는 EPCIS `sourceList` · `destinationList` 의 값이고 그 식별자는
9
+ * §8.7 Source/Destination identifiers 다. 네 꼴이 있다:
10
+ * · §8.7.1 EPC URI — 거래 상대에는 PGLN(`urn:epc:id:pgln:…`)이 「preferred」
11
+ * · §8.7.2 GS1 Digital Link — PGLN 은 AI (417): `https://id.gs1.org/417/{pgln}`
12
+ * · §8.7.3 `urn:URNNamespace:**:sd:Locid` — URN 이름공간 소유자가 배정, `Locid` 에 콜론 불가
13
+ * · §8.7.4 `http(s)://[Subdomain.]Domain/**\/sd/SourceOrDestId` — 그 도메인 소유자가 배정, `/sd/` 뒤 경로 성분 **하나**
14
+ * 길이는 128자 이하(SHALL), 60자 이하 권장(SHOULD)이다(§8.1.4).
15
+ *
16
+ * 표준은 PGLN 을 권한다(SHOULD). 우리는 발급한 `/sd/` 값을 원장에 쓴다 — 거래 상대 대부분이 GLN 이 없고 식별자는 바뀌지
17
+ * 않아야 하기 때문이다(ADR-0211 결정 11-2 · 11-3). PGLN 을 아는 상대는 내보내는 쪽이 바깥으로 PGLN 을 싣는다.
18
+ *
19
+ * §8.4 의 위치 꼴도 sourceList 에 들 수 있지만 그것은 **자리**(sdt `location`)다. 배송지 · 출하지는 거래 상대가 아니다
20
+ * (결정 4) — 그래서 이 파일의 판별은 위치 꼴을 거래 상대로 받지 않는다.
21
+ */
22
+ import { identifierUnderNamespace } from "./epcis.js";
23
+ /**
24
+ * EPCIS Source/Destination 의 **종류** 중 거래 상대인 것 — CBV 2.0 §7.4.3.
25
+ *
26
+ * · `owning_party` — 그 이전의 끝점에서 물건을 **소유한**(또는 소유할) 당사자.
27
+ * · `possessing_party` — 그 이전의 끝점에서 물건을 **물리적으로 가진**(또는 가질) 당사자. 실려 가는 동안의 운송사가 이것이다.
28
+ *
29
+ * 표준의 셋째 값 `location` 은 자리다 — 거래 상대가 아니므로 여기 두지 않는다.
30
+ */
31
+ export const SOURCE_DEST_PARTY_TYPE = {
32
+ owning_party: 'urn:epcglobal:cbv:sdt:owning_party',
33
+ possessing_party: 'urn:epcglobal:cbv:sdt:possessing_party'
34
+ };
35
+ /**
36
+ * **관계 안의 역할** — UN/CEFACT 당사자 역할 코드(UNTDID 3035). 닫힌 목록이고, **쓰는 날 하나씩** 올린다(ADR-0211 결정 4).
37
+ * 표준에 없는 역할은 지어내기 전에 판정을 받는다.
38
+ *
39
+ * · `CA` Carrier — 「Party undertaking or arranging transport of goods between named points.」
40
+ * (UNTDID 3035, D.96A 사본으로 확인 2026-11-17. 야드의 예약 · 게이트 방문, 창고 출하의 `bol` 을 낸 쪽.)
41
+ */
42
+ export const PARTY_ROLE = {
43
+ carrier: 'CA'
44
+ };
45
+ /** CBV 2.0 §8.1.4 — HTTP(S) 식별자는 이 길이를 넘지 않는다(SHALL). */
46
+ export const PARTY_URI_MAX_LENGTH = 128;
47
+ /** CBV 2.0 §8.1.4 — 이 길이를 넘지 않기를 권한다(SHOULD). 넘으면 거절하지 않고 알린다. */
48
+ export const PARTY_URI_RECOMMENDED_LENGTH = 60;
49
+ const UUID = /^[0-9a-f]{8}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{12}$/i;
50
+ /** 발급한 토큰의 꼴 — 하이픈 뺀 소문자 uuid 32자(ADR-0211 결정 11-8). 이 꼴만 행 id 로 되돌린다. */
51
+ const ISSUED_TOKEN = /^[0-9a-f]{32}$/;
52
+ const PGLN_EPC = /^urn:epc:id:pgln:\d+\.\d*$/;
53
+ const PGLN_DIGITAL_LINK = /^https:\/\/id\.gs1\.org\/417\/\d{13}$/;
54
+ /** §8.7.4 — 등록된 도메인(점이 있다) · 임의의 경로 · `/sd/` · 슬래시 없는 성분 하나. */
55
+ const SD_URL = /^https?:\/\/[^/\s.]+(?:\.[^/\s.]+)+\/(?:[^/\s]+\/)*sd\/[^/\s]+$/;
56
+ /** §8.7.3 — `urn:<이름공간>:**:sd:<콜론 없는 성분>`. GS1 의 `urn:epc:` · `urn:epcglobal:` 공간에는 우리가 표지를 만들 수 없다. */
57
+ const SD_URN = /^urn:[^:\s]+:(?:[^:\s]+:)*sd:[^:\s]+$/;
58
+ /**
59
+ * **거래 상대 식별자를 발급한다** — 소유 도메인의 이름공간과 거래처 행 id 로(ADR-0211 결정 11).
60
+ *
61
+ * 부르는 곳은 biz-base 한 곳이다(결정 13-4 — 다른 코드는 URI 를 조립하지 않는다). 꼴의 규칙을 그곳에 다시 적지 않도록 여기 둔다.
62
+ *
63
+ * · 행 id 는 uuid 여야 한다 — 하이픈 · 대소문자는 받아서 **하이픈 뺀 소문자 32자**로 쓴다(결정 11-8). 아니면 던진다.
64
+ * · 이름공간이 없거나 GS1 공간이면 `undefined` 다(지어내지 않는다 — `objectUri` 와 같다).
65
+ * · 만든 값이 128자를 넘으면 던진다 — 그 이름공간 선언이 틀린 것이다(결정 11-8).
66
+ */
67
+ export function partyUri(namespace, rowId) {
68
+ const raw = String(rowId ?? '').trim();
69
+ if (!UUID.test(raw))
70
+ throw new Error(`partyUri: 거래처 행 id 가 uuid 가 아니다: ${rowId}`);
71
+ const uri = identifierUnderNamespace(namespace, 'sd', raw.replace(/-/g, '').toLowerCase());
72
+ if (uri && uri.length > PARTY_URI_MAX_LENGTH) {
73
+ throw new Error(`partyUri: ${uri.length}자 — CBV 2.0 §8.1.4 는 ${PARTY_URI_MAX_LENGTH}자 이하를 요구한다. 이름공간 선언(${namespace})이 너무 길다.`);
74
+ }
75
+ return uri;
76
+ }
77
+ /**
78
+ * **우리가 발급한 식별자에서 거래처 행 id 를 되찾는다** — 하이픈 있는 uuid 로.
79
+ *
80
+ * 토큰이 발급한 꼴(소문자 32자)일 때만 답한다. 대문자 · 하이픈이 섞인 꼴은 같은 값이 아니다(결정 11-8). 바깥에서 온 식별자
81
+ * (PGLN · 남의 `/sd/`)는 `undefined` 다 — 그때는 알려진 다른 식별자로 찾는다(결정 13-2). 이 함수는 **이름공간을 묻지 않는다**:
82
+ * 그 이름공간이 우리 것인지는 부르는 쪽(biz-base)이 안다.
83
+ */
84
+ export function partyRowIdOf(uri) {
85
+ if (!uri || partyIdentifierViolation(uri))
86
+ return undefined;
87
+ const token = SD_URL.test(uri) ? uri.slice(uri.lastIndexOf('/') + 1) : SD_URN.test(uri) ? uri.slice(uri.lastIndexOf(':') + 1) : undefined;
88
+ if (!token || !ISSUED_TOKEN.test(token))
89
+ return undefined;
90
+ return `${token.slice(0, 8)}-${token.slice(8, 12)}-${token.slice(12, 16)}-${token.slice(16, 20)}-${token.slice(20)}`;
91
+ }
92
+ /**
93
+ * **거래 상대 식별자로 받을 수 있는가** — 받을 수 없으면 까닭, 받을 수 있으면 `undefined`.
94
+ *
95
+ * 받는 꼴은 CBV 2.0 §8.7 의 네 꼴 중 거래 상대의 것이다: PGLN EPC · PGLN Digital Link(정규 `id.gs1.org`) · `/sd/` URL · `:sd:` URN.
96
+ * 128자를 넘으면 거절한다(SHALL). 60자 초과는 거절하지 않는다 — `partyUriLengthNote` 가 말한다.
97
+ *
98
+ * 비정규 Digital Link(`https://example.com/…/417/…`)는 아직 판정하지 않는다 — 클래스 식별자와 같은 좁힘이다(`epcis.ts`
99
+ * `classIdentifierViolation`). 그것을 쓰는 원천이 붙는 날 연다.
100
+ */
101
+ export function partyIdentifierViolation(uri) {
102
+ if (typeof uri !== 'string' || !uri)
103
+ return `거래 상대 식별자가 비었다: ${uri}`;
104
+ if (uri.length > PARTY_URI_MAX_LENGTH)
105
+ return `거래 상대 식별자가 ${uri.length}자 — CBV 2.0 §8.1.4 는 ${PARTY_URI_MAX_LENGTH}자 이하를 요구한다: ${uri}`;
106
+ if (PGLN_EPC.test(uri) || PGLN_DIGITAL_LINK.test(uri))
107
+ return undefined;
108
+ if (/^urn:epc(global)?:/.test(uri))
109
+ return `거래 상대에는 GS1 공간에서 PGLN 만 받는다(CBV 2.0 §8.7.1): ${uri}`;
110
+ if (SD_URL.test(uri) || SD_URN.test(uri))
111
+ return undefined;
112
+ return (`거래 상대 식별자의 꼴이 아니다: ${uri} — CBV 2.0 §8.7 의 꼴이어야 한다 ` +
113
+ `(PGLN urn:epc:id:pgln: · https://id.gs1.org/417/<PGLN> · http(s)://<도메인>/**/sd/<id> · urn:<이름공간>:**:sd:<id>)`);
114
+ }
115
+ /** 판별의 참 · 거짓 — 까닭이 필요하면 `partyIdentifierViolation` 을 부른다. */
116
+ export function isPartyUri(v) {
117
+ return typeof v === 'string' && partyIdentifierViolation(v) === undefined;
118
+ }
119
+ /** 60자 권장(SHOULD)을 넘었으면 알릴 말, 아니면 `undefined`. 거절하지 않는다. */
120
+ export function partyUriLengthNote(uri) {
121
+ if (typeof uri !== 'string' || uri.length <= PARTY_URI_RECOMMENDED_LENGTH)
122
+ return undefined;
123
+ return `거래 상대 식별자가 ${uri.length}자 — CBV 2.0 §8.1.4 는 ${PARTY_URI_RECOMMENDED_LENGTH}자 이하를 권한다: ${uri}`;
124
+ }
125
+ /** 경계를 넘어 받은 값이 거래 상대 참조인가 — `id` 가 판별을 지나야 한다. `name` 은 있으면 글이어야 한다. */
126
+ export function isPartyRef(v) {
127
+ if (!v || typeof v !== 'object' || Array.isArray(v))
128
+ return false;
129
+ const r = v;
130
+ return isPartyUri(r.id) && (r.name === undefined || typeof r.name === 'string');
131
+ }
package/dist/yield.d.ts CHANGED
@@ -26,7 +26,7 @@ export interface FirstPassInput {
26
26
  /**
27
27
  * 분모는 **그 공정을 마친 수**다 — 양품과 부적합의 합.
28
28
  *
29
- * ── 왜 「들어간 수」가 분모가 아닌가 (첫 판을 고침) ─────────────────────────
29
+ * ── 왜 「들어간 수」가 분모가 아닌가 (첫 버전을 고침) ─────────────────────────
30
30
  * 처음에는 `들어간 수 − 부적합` 을 분자로 뒀다. **틀렸다.** 들어갔는데 아직 안 나온 것이 그 계산에서
31
31
  * 「처음에 통과」로 세어진다 — 158이 들어가고 154가 나왔는데 160으로 잰다면 2개를 통과로 센다.
32
32
  *
@@ -19,3 +19,77 @@ export declare function graiUri(companyPrefix: string, assetType: string, serial
19
19
  /** YMS 자리 타입 카탈로그 — 커널이 키로 쓰는 야드 로케이션 타입(locationByType/slotViews/.type). 도메인 SSOT. */
20
20
  export declare const YMS_LOCATION_TYPES: readonly ["gate", "yard-slot", "dock-door", "staging"];
21
21
  export declare const YMS_TYPES: TwinTypeInfo[];
22
+ /**
23
+ * 야드에서 **오더**인 것 — 도크 예약(어포인트먼트). `OrderState.kind`.
24
+ *
25
+ * 들어오는 예약(하차)과 나가는 예약(상차)이 둘이다. 야드 안의 이동은 오더가 아니라 작업이다(§`YMS_TASK_KIND`).
26
+ */
27
+ export declare const YMS_ORDER_KIND: {
28
+ /** 하차하러 들어오는 트레일러의 예약. */
29
+ readonly inbound: "appointment";
30
+ /** 상차하러 들어오는(빈) 트레일러의 예약. */
31
+ readonly outbound: "appointment-out";
32
+ };
33
+ export type YmsOrderKind = (typeof YMS_ORDER_KIND)[keyof typeof YMS_ORDER_KIND];
34
+ /**
35
+ * 야드의 **작업** — `TaskState.kind`.
36
+ *
37
+ * · `spot` — 게이트에서 야드 슬롯으로(drop 모드의 주차).
38
+ * · `spot-live` — 게이트에서 도어로 곧장(live 모드, 야드 미경유).
39
+ * · `pull` — 야드 슬롯에서 도어로(창이 열리고 도어가 비었을 때).
40
+ * · `dwell` — 도어에 붙어 상·하차하는 동안. 자리를 옮기지 않는 작업이다(from = to = 도어).
41
+ * · `depart` — 도어 또는 슬롯에서 게이트로.
42
+ * · `reposition` — 야드 안의 재배치(슬롯 → 슬롯). 커널은 아직 내지 않고 야드 앱이 낸다.
43
+ */
44
+ export declare const YMS_TASK_KIND: {
45
+ readonly spot: "spot";
46
+ readonly spotLive: "spot-live";
47
+ readonly pull: "pull";
48
+ readonly dwell: "dwell";
49
+ readonly depart: "depart";
50
+ readonly reposition: "reposition";
51
+ };
52
+ export type YmsTaskKind = (typeof YMS_TASK_KIND)[keyof typeof YMS_TASK_KIND];
53
+ /** 야드 운영 모드 — `drop`: 트레일러를 슬롯에 내려놓고 창이 오면 호슬러가 끈다. `live`: 게이트에서 기다리다 도어로 곧장. */
54
+ export declare const YARD_MODE: readonly ["drop", "live"];
55
+ export type YardMode = (typeof YARD_MODE)[number];
56
+ /**
57
+ * 예약의 **상태** — 닫힌 목록.
58
+ *
59
+ * 끝나는 낱말 둘(`completed` · `cancelled`)은 계약의 `ORDER_TERMINAL_STATUS` 와 **같은 낱말**이다. 다르게 쓰면 `isOrderTerminal` 이
60
+ * 그것을 모르고 트윈에서 그 예약은 영영 열린 오더가 된다.
61
+ */
62
+ export declare const YMS_APPOINTMENT_STATUS: readonly ["scheduled", "checked-in", "at-door", "completed", "cancelled"];
63
+ export type YmsAppointmentStatus = (typeof YMS_APPOINTMENT_STATUS)[number];
64
+ /**
65
+ * 예약이 **취소된 까닭** — 닫힌 목록. 노쇼는 상태가 아니라 이 사유다.
66
+ *
67
+ * 노쇼를 상태로 두면 위와 같은 까닭으로 끝나지 않는 오더가 된다. 노쇼율은 `cancelled` 중 `no-show` 를 세어 답한다.
68
+ * · `no-show` — 창이 지나도록 오지 않았다. · `carrier` — 운송사가 취소했다. · `site` — 현장이 취소했다.
69
+ */
70
+ export declare const YMS_APPOINTMENT_CANCEL_REASON: readonly ["no-show", "carrier", "site"];
71
+ export type YmsAppointmentCancelReason = (typeof YMS_APPOINTMENT_CANCEL_REASON)[number];
72
+ /** 그 낱말이 예약의 상태인가 — 모르는 낱말을 「진행 중」으로 받지 않도록 보내기 전에 묻는다. */
73
+ export declare function isYmsAppointmentStatus(v: unknown): v is YmsAppointmentStatus;
74
+ /** 예약이 끝났나 — 판정은 계약의 오더 종결 낱말 한 곳을 따른다. */
75
+ export declare function isAppointmentClosed(status: unknown): boolean;
76
+ /**
77
+ * 도크 도어의 상태 — **파생한다.** 저장하는 값이 아니다(`locationStatusOf` 와 같은 규율).
78
+ *
79
+ * · `blocked` — 차단 기간(고장 · 청소 · 점검) 안이다. 점유보다 먼저 본다: 막힌 도어는 비어 있어도 쓸 수 없다.
80
+ * · `occupied` — 붙어 있는 트레일러 수가 동시 수(`OperationalLocation.parallelism`, 없으면 1)에 닿았다.
81
+ * · `free` — 그 밖.
82
+ */
83
+ export declare const DOCK_DOOR_STATUS: readonly ["free", "occupied", "blocked"];
84
+ export type DockDoorStatus = (typeof DOCK_DOOR_STATUS)[number];
85
+ export declare function dockDoorStatusOf(d: {
86
+ occupancy?: number;
87
+ parallelism?: number;
88
+ blocked?: boolean;
89
+ }): DockDoorStatus;
90
+ /**
91
+ * 트레일러의 적재 — 게이트에서 **신고된** 것. 화물 SSCC 를 아는 경우 내용물은 AggregationEvent 가 말하며, 이 값은 그것을 대신하지 않는다
92
+ * (내용을 모르는 방문 트레일러가 「차 있다 / 비었다」만 말할 때의 칸이다).
93
+ */
94
+ export declare const TRAILER_LOAD: readonly ["empty", "loaded"];
95
+ export type TrailerLoad = (typeof TRAILER_LOAD)[number];
@@ -1,3 +1,4 @@
1
+ import { ORDER_TERMINAL_STATUS } from "./contract.js";
1
2
  import { HATIOLAB_VOCABULARY } from "./epcis.js";
2
3
  // 야드 bizStep — CBV (yms.md §11).
3
4
  export const YARD_BIZSTEP = {
@@ -49,3 +50,81 @@ export const YMS_TYPES = [
49
50
  ...YMS_LOCATION_TYPES.map((k) => ({ key: k, role: 'location', label: `twin.type.${k}`, standardClass: { epcis: 'bizLocation' }, identity: { scheme: 'gs1:SGLN' }, level: YMS_LOCATION_LEVEL[k], capabilities: ['storable'] })),
50
51
  { key: 'hostler', role: 'equipment', label: 'twin.type.hostler', standardClass: { epcis: 'object', iso55000: 'Asset' }, identity: { scheme: 'gs1:GIAI' }, capabilities: ['mobile', 'operable'] }
51
52
  ];
53
+ /*
54
+ * ── 야드 앱의 어휘 (operato-application ADR-0210 결정 7) ─────────────────────────────────────────
55
+ *
56
+ * 도크 관리와 야드 관리는 한 제품(영역 `yms`)이다. 커널이 글자로 쓰던 낱말에 먼저 이름을 붙인다 — 두 번째 생산자(야드 앱)가
57
+ * 서는 날 철자가 둘이 되지 않게(ADR-0059 결정 3, `WMS_ORDER_KIND` 와 같은 까닭). 값은 커널의 철자 그대로다: 저널은 쓴 것을 지킨다.
58
+ */
59
+ /**
60
+ * 야드에서 **오더**인 것 — 도크 예약(어포인트먼트). `OrderState.kind`.
61
+ *
62
+ * 들어오는 예약(하차)과 나가는 예약(상차)이 둘이다. 야드 안의 이동은 오더가 아니라 작업이다(§`YMS_TASK_KIND`).
63
+ */
64
+ export const YMS_ORDER_KIND = {
65
+ /** 하차하러 들어오는 트레일러의 예약. */
66
+ inbound: 'appointment',
67
+ /** 상차하러 들어오는(빈) 트레일러의 예약. */
68
+ outbound: 'appointment-out'
69
+ };
70
+ /**
71
+ * 야드의 **작업** — `TaskState.kind`.
72
+ *
73
+ * · `spot` — 게이트에서 야드 슬롯으로(drop 모드의 주차).
74
+ * · `spot-live` — 게이트에서 도어로 곧장(live 모드, 야드 미경유).
75
+ * · `pull` — 야드 슬롯에서 도어로(창이 열리고 도어가 비었을 때).
76
+ * · `dwell` — 도어에 붙어 상·하차하는 동안. 자리를 옮기지 않는 작업이다(from = to = 도어).
77
+ * · `depart` — 도어 또는 슬롯에서 게이트로.
78
+ * · `reposition` — 야드 안의 재배치(슬롯 → 슬롯). 커널은 아직 내지 않고 야드 앱이 낸다.
79
+ */
80
+ export const YMS_TASK_KIND = {
81
+ spot: 'spot',
82
+ spotLive: 'spot-live',
83
+ pull: 'pull',
84
+ dwell: 'dwell',
85
+ depart: 'depart',
86
+ reposition: 'reposition'
87
+ };
88
+ /** 야드 운영 모드 — `drop`: 트레일러를 슬롯에 내려놓고 창이 오면 호슬러가 끈다. `live`: 게이트에서 기다리다 도어로 곧장. */
89
+ export const YARD_MODE = ['drop', 'live'];
90
+ /**
91
+ * 예약의 **상태** — 닫힌 목록.
92
+ *
93
+ * 끝나는 낱말 둘(`completed` · `cancelled`)은 계약의 `ORDER_TERMINAL_STATUS` 와 **같은 낱말**이다. 다르게 쓰면 `isOrderTerminal` 이
94
+ * 그것을 모르고 트윈에서 그 예약은 영영 열린 오더가 된다.
95
+ */
96
+ export const YMS_APPOINTMENT_STATUS = ['scheduled', 'checked-in', 'at-door', 'completed', 'cancelled'];
97
+ /**
98
+ * 예약이 **취소된 까닭** — 닫힌 목록. 노쇼는 상태가 아니라 이 사유다.
99
+ *
100
+ * 노쇼를 상태로 두면 위와 같은 까닭으로 끝나지 않는 오더가 된다. 노쇼율은 `cancelled` 중 `no-show` 를 세어 답한다.
101
+ * · `no-show` — 창이 지나도록 오지 않았다. · `carrier` — 운송사가 취소했다. · `site` — 현장이 취소했다.
102
+ */
103
+ export const YMS_APPOINTMENT_CANCEL_REASON = ['no-show', 'carrier', 'site'];
104
+ /** 그 낱말이 예약의 상태인가 — 모르는 낱말을 「진행 중」으로 받지 않도록 보내기 전에 묻는다. */
105
+ export function isYmsAppointmentStatus(v) {
106
+ return typeof v === 'string' && YMS_APPOINTMENT_STATUS.includes(v);
107
+ }
108
+ /** 예약이 끝났나 — 판정은 계약의 오더 종결 낱말 한 곳을 따른다. */
109
+ export function isAppointmentClosed(status) {
110
+ return typeof status === 'string' && ORDER_TERMINAL_STATUS.includes(status);
111
+ }
112
+ /**
113
+ * 도크 도어의 상태 — **파생한다.** 저장하는 값이 아니다(`locationStatusOf` 와 같은 규율).
114
+ *
115
+ * · `blocked` — 차단 기간(고장 · 청소 · 점검) 안이다. 점유보다 먼저 본다: 막힌 도어는 비어 있어도 쓸 수 없다.
116
+ * · `occupied` — 붙어 있는 트레일러 수가 동시 수(`OperationalLocation.parallelism`, 없으면 1)에 닿았다.
117
+ * · `free` — 그 밖.
118
+ */
119
+ export const DOCK_DOOR_STATUS = ['free', 'occupied', 'blocked'];
120
+ export function dockDoorStatusOf(d) {
121
+ if (d.blocked)
122
+ return 'blocked';
123
+ const cap = typeof d.parallelism === 'number' && d.parallelism > 0 ? d.parallelism : 1;
124
+ return (d.occupancy ?? 0) >= cap ? 'occupied' : 'free';
125
+ }
126
+ /**
127
+ * 트레일러의 적재 — 게이트에서 **신고된** 것. 화물 SSCC 를 아는 경우 내용물은 AggregationEvent 가 말하며, 이 값은 그것을 대신하지 않는다
128
+ * (내용을 모르는 방문 트레일러가 「차 있다 / 비었다」만 말할 때의 칸이다).
129
+ */
130
+ export const TRAILER_LOAD = ['empty', 'loaded'];
@@ -21,6 +21,7 @@ var index_exports = {};
21
21
  __export(index_exports, {
22
22
  ABSENCE: () => ABSENCE,
23
23
  ALLOCATION_POLICY: () => ALLOCATION_POLICY,
24
+ ASSET_STATUS: () => ASSET_STATUS,
24
25
  BASIS_UNKNOWN: () => BASIS_UNKNOWN,
25
26
  BIZSTEP: () => BIZSTEP,
26
27
  BTT: () => BTT,
@@ -34,6 +35,7 @@ __export(index_exports, {
34
35
  COMMAND_STATE: () => COMMAND_STATE,
35
36
  DISP: () => DISP,
36
37
  DISPOSITION_DECISION: () => DISPOSITION_DECISION,
38
+ DOCK_DOOR_STATUS: () => DOCK_DOOR_STATUS,
37
39
  DOMAIN_CATALOG: () => DOMAIN_CATALOG,
38
40
  DOMAIN_SYSTEMS: () => DOMAIN_SYSTEMS,
39
41
  EMPTY_BECAUSE: () => EMPTY_BECAUSE,
@@ -71,6 +73,10 @@ __export(index_exports, {
71
73
  ORDER_FOLD_DEFAULT: () => ORDER_FOLD_DEFAULT,
72
74
  ORDER_FOLD_HOUR_MS: () => ORDER_FOLD_HOUR_MS,
73
75
  ORDER_TERMINAL_STATUS: () => ORDER_TERMINAL_STATUS,
76
+ PARTY_ROLE: () => PARTY_ROLE,
77
+ PARTY_URI_MAX_LENGTH: () => PARTY_URI_MAX_LENGTH,
78
+ PARTY_URI_RECOMMENDED_LENGTH: () => PARTY_URI_RECOMMENDED_LENGTH,
79
+ PERSON_STATUS: () => PERSON_STATUS,
74
80
  PRIORITY_UNSET: () => PRIORITY_UNSET,
75
81
  PRIVATE_BIZSTEP: () => PRIVATE_BIZSTEP,
76
82
  READ_BASIS: () => READ_BASIS,
@@ -80,6 +86,8 @@ __export(index_exports, {
80
86
  RETURN_TO_SUPPLIER: () => RETURN_TO_SUPPLIER,
81
87
  SCHEDULE_STATUS: () => SCHEDULE_STATUS,
82
88
  SIGNATURE_REJECTED_REASONS: () => SIGNATURE_REJECTED_REASONS,
89
+ SOURCE_DEST_PARTY_TYPE: () => SOURCE_DEST_PARTY_TYPE,
90
+ TRAILER_LOAD: () => TRAILER_LOAD,
83
91
  TWIN_AXES: () => TWIN_AXES,
84
92
  TWIN_PROPERTIES: () => TWIN_PROPERTIES,
85
93
  TWIN_RELATIONS: () => TWIN_RELATIONS,
@@ -98,8 +106,13 @@ __export(index_exports, {
98
106
  WMS_RECEIVING_ORDER_KINDS: () => WMS_RECEIVING_ORDER_KINDS,
99
107
  WMS_TYPES: () => WMS_TYPES,
100
108
  YARD_BIZSTEP: () => YARD_BIZSTEP,
109
+ YARD_MODE: () => YARD_MODE,
101
110
  YARD_PRIVATE_BIZSTEP: () => YARD_PRIVATE_BIZSTEP,
111
+ YMS_APPOINTMENT_CANCEL_REASON: () => YMS_APPOINTMENT_CANCEL_REASON,
112
+ YMS_APPOINTMENT_STATUS: () => YMS_APPOINTMENT_STATUS,
102
113
  YMS_LOCATION_TYPES: () => YMS_LOCATION_TYPES,
114
+ YMS_ORDER_KIND: () => YMS_ORDER_KIND,
115
+ YMS_TASK_KIND: () => YMS_TASK_KIND,
103
116
  YMS_TYPES: () => YMS_TYPES,
104
117
  acceptsPerformance: () => acceptsPerformance,
105
118
  activeShiftAt: () => activeShiftAt,
@@ -133,6 +146,7 @@ __export(index_exports, {
133
146
  computeOee: () => computeOee,
134
147
  conversionFactorOf: () => conversionFactorOf,
135
148
  criterionSaysNothing: () => criterionSaysNothing,
149
+ dockDoorStatusOf: () => dockDoorStatusOf,
136
150
  documentPath: () => documentPath,
137
151
  dueStatusOf: () => dueStatusOf,
138
152
  effectivityAt: () => effectivityAt,
@@ -155,6 +169,8 @@ __export(index_exports, {
155
169
  hierarchyOf: () => hierarchyOf,
156
170
  homeOf: () => homeOf,
157
171
  hourStartOf: () => hourStartOf,
172
+ identifierText: () => identifierText,
173
+ identifierUnderNamespace: () => identifierUnderNamespace,
158
174
  identityGroundingOf: () => identityGroundingOf,
159
175
  inWorkCalendar: () => inWorkCalendar,
160
176
  inWorkCalendarAt: () => inWorkCalendarAt,
@@ -172,6 +188,7 @@ __export(index_exports, {
172
188
  inheritedExpiry: () => inheritedExpiry,
173
189
  inheritedLotUse: () => inheritedLotUse,
174
190
  isAggregationRecord: () => isAggregationRecord,
191
+ isAppointmentClosed: () => isAppointmentClosed,
175
192
  isCacheableTense: () => isCacheableTense,
176
193
  isCommandTerminal: () => isCommandTerminal,
177
194
  isElectricalLocationType: () => isElectricalLocationType,
@@ -193,6 +210,8 @@ __export(index_exports, {
193
210
  isOperationalAttentionV1: () => isOperationalAttentionV1,
194
211
  isOperationalRecord: () => isOperationalRecord,
195
212
  isOrderTerminal: () => isOrderTerminal,
213
+ isPartyRef: () => isPartyRef,
214
+ isPartyUri: () => isPartyUri,
196
215
  isPlannedStopStatus: () => isPlannedStopStatus,
197
216
  isRecipeExecutionBasis: () => isRecipeExecutionBasis,
198
217
  isResourceKind: () => isResourceKind,
@@ -201,9 +220,11 @@ __export(index_exports, {
201
220
  isWebhookDeliveryCode: () => isWebhookDeliveryCode,
202
221
  isWebhookSecretSegment: () => isWebhookSecretSegment,
203
222
  isWorkShiftExecutionBasis: () => isWorkShiftExecutionBasis,
223
+ isYmsAppointmentStatus: () => isYmsAppointmentStatus,
204
224
  isoDurationHours: () => isoDurationHours,
205
225
  itemClassOf: () => itemClassOf,
206
226
  itemKeyOf: () => itemKeyOf,
227
+ itemMaterialDefinitionId: () => itemMaterialDefinitionId,
207
228
  judgeAgainstSpec: () => judgeAgainstSpec,
208
229
  levelOfLocationType: () => levelOfLocationType,
209
230
  lgtinClass: () => lgtinClass,
@@ -238,6 +259,10 @@ __export(index_exports, {
238
259
  parseGs1: () => parseGs1,
239
260
  parseIsoDuration: () => parseIsoDuration,
240
261
  partitionLensLocations: () => partitionLensLocations,
262
+ partyIdentifierViolation: () => partyIdentifierViolation,
263
+ partyRowIdOf: () => partyRowIdOf,
264
+ partyUri: () => partyUri,
265
+ partyUriLengthNote: () => partyUriLengthNote,
241
266
  passThroughReversible: () => passThroughReversible,
242
267
  performanceKey: () => performanceKey,
243
268
  periodFactId: () => periodFactId,
@@ -1167,6 +1192,8 @@ var EQUIPMENT_STATUS = ["busy", "setup", "down", "idle", "planned-stop"];
1167
1192
  function isEquipmentStatus(value) {
1168
1193
  return typeof value === "string" && EQUIPMENT_STATUS.includes(value);
1169
1194
  }
1195
+ var PERSON_STATUS = ["idle", "busy"];
1196
+ var ASSET_STATUS = ["idle", "in-use"];
1170
1197
  var RESOURCE_KIND = ["equipment", "personnel", "material", "asset"];
1171
1198
  function isResourceKind(value) {
1172
1199
  return typeof value === "string" && RESOURCE_KIND.includes(value);
@@ -1574,6 +1601,14 @@ function materialDefinitionIdOf(epcClass) {
1574
1601
  }
1575
1602
  return raw;
1576
1603
  }
1604
+ function itemMaterialDefinitionId(item) {
1605
+ if (!item) return void 0;
1606
+ if (item.definitionId) return item.definitionId;
1607
+ const fromClass = materialDefinitionIdOf(item.gtin);
1608
+ if (fromClass) return fromClass;
1609
+ const [companyPrefix, itemRef] = (item.gtinKey ?? "").split(".");
1610
+ return companyPrefix && itemRef ? sgtinClass(companyPrefix, itemRef) : void 0;
1611
+ }
1577
1612
  function lotClassOfItem(itemClass, lot) {
1578
1613
  if (!itemClass) return void 0;
1579
1614
  const idpat = /^urn:epc:idpat:sgtin:(\d+)\.(\d+)\.\*$/.exec(itemClass);
@@ -1639,6 +1674,9 @@ var PERCENT_ENCODED = {
1639
1674
  /* 로트 클래스의 가르는 글자 — `lotClassUri` 만 쓴다(§`LOT_COMPONENT_BREAKING`). 표는 한 벌이다. */
1640
1675
  ";": "%3B"
1641
1676
  };
1677
+ function identifierUnderNamespace(namespace, marker, id) {
1678
+ return underNamespace(namespace, marker, id);
1679
+ }
1642
1680
  function underNamespace(namespace, marker, id) {
1643
1681
  const raw = String(id);
1644
1682
  if (!raw) return void 0;
@@ -1977,6 +2015,36 @@ var YMS_TYPES = [
1977
2015
  ...YMS_LOCATION_TYPES.map((k) => ({ key: k, role: "location", label: `twin.type.${k}`, standardClass: { epcis: "bizLocation" }, identity: { scheme: "gs1:SGLN" }, level: YMS_LOCATION_LEVEL[k], capabilities: ["storable"] })),
1978
2016
  { key: "hostler", role: "equipment", label: "twin.type.hostler", standardClass: { epcis: "object", iso55000: "Asset" }, identity: { scheme: "gs1:GIAI" }, capabilities: ["mobile", "operable"] }
1979
2017
  ];
2018
+ var YMS_ORDER_KIND = {
2019
+ /** 하차하러 들어오는 트레일러의 예약. */
2020
+ inbound: "appointment",
2021
+ /** 상차하러 들어오는(빈) 트레일러의 예약. */
2022
+ outbound: "appointment-out"
2023
+ };
2024
+ var YMS_TASK_KIND = {
2025
+ spot: "spot",
2026
+ spotLive: "spot-live",
2027
+ pull: "pull",
2028
+ dwell: "dwell",
2029
+ depart: "depart",
2030
+ reposition: "reposition"
2031
+ };
2032
+ var YARD_MODE = ["drop", "live"];
2033
+ var YMS_APPOINTMENT_STATUS = ["scheduled", "checked-in", "at-door", "completed", "cancelled"];
2034
+ var YMS_APPOINTMENT_CANCEL_REASON = ["no-show", "carrier", "site"];
2035
+ function isYmsAppointmentStatus(v) {
2036
+ return typeof v === "string" && YMS_APPOINTMENT_STATUS.includes(v);
2037
+ }
2038
+ function isAppointmentClosed(status) {
2039
+ return typeof status === "string" && ORDER_TERMINAL_STATUS.includes(status);
2040
+ }
2041
+ var DOCK_DOOR_STATUS = ["free", "occupied", "blocked"];
2042
+ function dockDoorStatusOf(d) {
2043
+ if (d.blocked) return "blocked";
2044
+ const cap = typeof d.parallelism === "number" && d.parallelism > 0 ? d.parallelism : 1;
2045
+ return (d.occupancy ?? 0) >= cap ? "occupied" : "free";
2046
+ }
2047
+ var TRAILER_LOAD = ["empty", "loaded"];
1980
2048
 
1981
2049
  // src/mes-profile.ts
1982
2050
  var MES_BIZSTEP = {
@@ -3629,6 +3697,54 @@ function gtin14OfItem(definitionId) {
3629
3697
  if (byClass) return byClass;
3630
3698
  return /^(\d{8}|\d{12,14})$/.test(definitionId ?? "") ? definitionId.padStart(14, "0") : void 0;
3631
3699
  }
3700
+ function identifierText(uri) {
3701
+ const raw = String(uri ?? "").trim();
3702
+ if (!raw) return "";
3703
+ const parsed = parseEpc(raw);
3704
+ if (parsed.scheme === "sgtin" || parsed.scheme === "lgtin" || parsed.scheme === "idpat") {
3705
+ const gtin = gtin14OfKey(parsed.gtinKey);
3706
+ if (!gtin) return raw;
3707
+ if (parsed.scheme === "sgtin") return parsed.serial ? `(01)${gtin}(21)${decoded(parsed.serial)}` : raw;
3708
+ if (parsed.scheme === "lgtin") return parsed.lot ? `(01)${gtin}(10)${parsed.lot}` : raw;
3709
+ return `(01)${gtin}`;
3710
+ }
3711
+ if (parsed.scheme === "sscc") {
3712
+ const sscc = ssccDigitsOf(raw);
3713
+ return sscc ? `(00)${sscc}` : raw;
3714
+ }
3715
+ if (parsed.scheme === "sgln") {
3716
+ const m = /^urn:epc:id:sgln:(\d+)\.(\d*)\.(.+)$/.exec(raw);
3717
+ if (!m || m[1].length + m[2].length !== 12) return raw;
3718
+ const body = m[1] + m[2];
3719
+ return `(414)${body}${checkDigitOf(body)}${m[3] === "0" ? "" : `(254)${decoded(m[3])}`}`;
3720
+ }
3721
+ if (parsed.scheme === "grai" || parsed.scheme === "gdti") {
3722
+ const m = new RegExp(`^urn:epc:id:${parsed.scheme}:(\\d+)\\.(\\d*)\\.(.*)$`).exec(raw);
3723
+ if (!m || m[1].length + m[2].length !== 12) return raw;
3724
+ const key = m[1] + m[2] + checkDigitOf(m[1] + m[2]);
3725
+ return parsed.scheme === "grai" ? `(8003)0${key}${decoded(m[3])}` : `(253)${key}${decoded(m[3])}`;
3726
+ }
3727
+ if (parsed.scheme === "giai") {
3728
+ const m = /^urn:epc:id:giai:(\d+)\.(.+)$/.exec(raw);
3729
+ return m ? `(8004)${m[1]}${decoded(m[2])}` : raw;
3730
+ }
3731
+ if (parsed.item !== void 0 && parsed.lot !== void 0) return `${parsed.item} \xB7 ${parsed.lot}`;
3732
+ const inHouse = /(?:\/(?:obj|class|bt)\/|:(?:obj|class|bt):)([^/:\s]+)$/.exec(raw);
3733
+ return inHouse ? decoded(inHouse[1]) : raw;
3734
+ }
3735
+ function gtin14OfKey(key) {
3736
+ const m = /^(\d+)\.(\d+)$/.exec(key ?? "");
3737
+ if (!m) return void 0;
3738
+ const body = m[2][0] + m[1] + m[2].slice(1);
3739
+ return body.length === 13 ? body + checkDigitOf(body) : void 0;
3740
+ }
3741
+ function decoded(part) {
3742
+ try {
3743
+ return decodeURIComponent(part);
3744
+ } catch {
3745
+ return part;
3746
+ }
3747
+ }
3632
3748
 
3633
3749
  // src/order-fold.ts
3634
3750
  var ORDER_FOLD_HOUR_MS = 60 * 60 * 1e3;
@@ -4096,9 +4212,6 @@ function shapeErrors(where, row, shape) {
4096
4212
  return errors;
4097
4213
  }
4098
4214
  var TASK_STATUS = ["created", "assigned", "in-progress", "completed"];
4099
- var EQUIPMENT_STATUS2 = ["idle", "busy", "down", "setup", "planned-stop"];
4100
- var PERSON_STATUS = ["idle", "busy"];
4101
- var ASSET_STATUS = ["idle", "in-use"];
4102
4215
  var SPECS = {
4103
4216
  task: {
4104
4217
  eventType: OP_EVENT.task,
@@ -4191,7 +4304,7 @@ var SPECS = {
4191
4304
  재검사하지는 않는다: 그 모양은 `EquipmentMotion` 계약이고, 여기서 두 번 지키면 두 벌이 된다. */
4192
4305
  motion: "object"
4193
4306
  },
4194
- enums: { status: EQUIPMENT_STATUS2 }
4307
+ enums: { status: EQUIPMENT_STATUS }
4195
4308
  },
4196
4309
  person: {
4197
4310
  eventType: OP_EVENT.person,
@@ -4387,7 +4500,7 @@ var SPECS = {
4387
4500
  fields: { basisId: "string", arrangementId: "string", revisionId: "string", revisionNumber: "number", planId: "string", contentHash: "string", businessTime: "string", timezone: "string", workDate: "string" }
4388
4501
  }
4389
4502
  },
4390
- enums: { status: EQUIPMENT_STATUS2 }
4503
+ enums: { status: EQUIPMENT_STATUS }
4391
4504
  },
4392
4505
  /*
4393
4506
  * **부적합 처분** — 재고 판정을 받은 것을 어떻게 하기로 정했나.
@@ -4846,6 +4959,58 @@ function retiredVocabularyIn(line) {
4846
4959
  return hits;
4847
4960
  }
4848
4961
 
4962
+ // src/party.ts
4963
+ var SOURCE_DEST_PARTY_TYPE = {
4964
+ owning_party: "urn:epcglobal:cbv:sdt:owning_party",
4965
+ possessing_party: "urn:epcglobal:cbv:sdt:possessing_party"
4966
+ };
4967
+ var PARTY_ROLE = {
4968
+ carrier: "CA"
4969
+ };
4970
+ var PARTY_URI_MAX_LENGTH = 128;
4971
+ var PARTY_URI_RECOMMENDED_LENGTH = 60;
4972
+ var UUID = /^[0-9a-f]{8}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{12}$/i;
4973
+ var ISSUED_TOKEN = /^[0-9a-f]{32}$/;
4974
+ var PGLN_EPC = /^urn:epc:id:pgln:\d+\.\d*$/;
4975
+ var PGLN_DIGITAL_LINK = /^https:\/\/id\.gs1\.org\/417\/\d{13}$/;
4976
+ var SD_URL = /^https?:\/\/[^/\s.]+(?:\.[^/\s.]+)+\/(?:[^/\s]+\/)*sd\/[^/\s]+$/;
4977
+ var SD_URN = /^urn:[^:\s]+:(?:[^:\s]+:)*sd:[^:\s]+$/;
4978
+ function partyUri(namespace, rowId) {
4979
+ const raw = String(rowId ?? "").trim();
4980
+ if (!UUID.test(raw)) throw new Error(`partyUri: \uAC70\uB798\uCC98 \uD589 id \uAC00 uuid \uAC00 \uC544\uB2C8\uB2E4: ${rowId}`);
4981
+ const uri = identifierUnderNamespace(namespace, "sd", raw.replace(/-/g, "").toLowerCase());
4982
+ if (uri && uri.length > PARTY_URI_MAX_LENGTH) {
4983
+ throw new Error(`partyUri: ${uri.length}\uC790 \u2014 CBV 2.0 \xA78.1.4 \uB294 ${PARTY_URI_MAX_LENGTH}\uC790 \uC774\uD558\uB97C \uC694\uAD6C\uD55C\uB2E4. \uC774\uB984\uACF5\uAC04 \uC120\uC5B8(${namespace})\uC774 \uB108\uBB34 \uAE38\uB2E4.`);
4984
+ }
4985
+ return uri;
4986
+ }
4987
+ function partyRowIdOf(uri) {
4988
+ if (!uri || partyIdentifierViolation(uri)) return void 0;
4989
+ const token = SD_URL.test(uri) ? uri.slice(uri.lastIndexOf("/") + 1) : SD_URN.test(uri) ? uri.slice(uri.lastIndexOf(":") + 1) : void 0;
4990
+ if (!token || !ISSUED_TOKEN.test(token)) return void 0;
4991
+ return `${token.slice(0, 8)}-${token.slice(8, 12)}-${token.slice(12, 16)}-${token.slice(16, 20)}-${token.slice(20)}`;
4992
+ }
4993
+ function partyIdentifierViolation(uri) {
4994
+ if (typeof uri !== "string" || !uri) return `\uAC70\uB798 \uC0C1\uB300 \uC2DD\uBCC4\uC790\uAC00 \uBE44\uC5C8\uB2E4: ${uri}`;
4995
+ if (uri.length > PARTY_URI_MAX_LENGTH) return `\uAC70\uB798 \uC0C1\uB300 \uC2DD\uBCC4\uC790\uAC00 ${uri.length}\uC790 \u2014 CBV 2.0 \xA78.1.4 \uB294 ${PARTY_URI_MAX_LENGTH}\uC790 \uC774\uD558\uB97C \uC694\uAD6C\uD55C\uB2E4: ${uri}`;
4996
+ if (PGLN_EPC.test(uri) || PGLN_DIGITAL_LINK.test(uri)) return void 0;
4997
+ if (/^urn:epc(global)?:/.test(uri)) return `\uAC70\uB798 \uC0C1\uB300\uC5D0\uB294 GS1 \uACF5\uAC04\uC5D0\uC11C PGLN \uB9CC \uBC1B\uB294\uB2E4(CBV 2.0 \xA78.7.1): ${uri}`;
4998
+ if (SD_URL.test(uri) || SD_URN.test(uri)) return void 0;
4999
+ return `\uAC70\uB798 \uC0C1\uB300 \uC2DD\uBCC4\uC790\uC758 \uAF34\uC774 \uC544\uB2C8\uB2E4: ${uri} \u2014 CBV 2.0 \xA78.7 \uC758 \uAF34\uC774\uC5B4\uC57C \uD55C\uB2E4 (PGLN urn:epc:id:pgln: \xB7 https://id.gs1.org/417/<PGLN> \xB7 http(s)://<\uB3C4\uBA54\uC778>/**/sd/<id> \xB7 urn:<\uC774\uB984\uACF5\uAC04>:**:sd:<id>)`;
5000
+ }
5001
+ function isPartyUri(v) {
5002
+ return typeof v === "string" && partyIdentifierViolation(v) === void 0;
5003
+ }
5004
+ function partyUriLengthNote(uri) {
5005
+ if (typeof uri !== "string" || uri.length <= PARTY_URI_RECOMMENDED_LENGTH) return void 0;
5006
+ return `\uAC70\uB798 \uC0C1\uB300 \uC2DD\uBCC4\uC790\uAC00 ${uri.length}\uC790 \u2014 CBV 2.0 \xA78.1.4 \uB294 ${PARTY_URI_RECOMMENDED_LENGTH}\uC790 \uC774\uD558\uB97C \uAD8C\uD55C\uB2E4: ${uri}`;
5007
+ }
5008
+ function isPartyRef(v) {
5009
+ if (!v || typeof v !== "object" || Array.isArray(v)) return false;
5010
+ const r = v;
5011
+ return isPartyUri(r.id) && (r.name === void 0 || typeof r.name === "string");
5012
+ }
5013
+
4849
5014
  // src/command-verdict.ts
4850
5015
  var REFUSED_WITHOUT_CODE = "refused";
4851
5016
  function verdictOfAck(ack) {
@@ -5399,6 +5564,7 @@ function inheritedExpiry(inputExpiries) {
5399
5564
  0 && (module.exports = {
5400
5565
  ABSENCE,
5401
5566
  ALLOCATION_POLICY,
5567
+ ASSET_STATUS,
5402
5568
  BASIS_UNKNOWN,
5403
5569
  BIZSTEP,
5404
5570
  BTT,
@@ -5412,6 +5578,7 @@ function inheritedExpiry(inputExpiries) {
5412
5578
  COMMAND_STATE,
5413
5579
  DISP,
5414
5580
  DISPOSITION_DECISION,
5581
+ DOCK_DOOR_STATUS,
5415
5582
  DOMAIN_CATALOG,
5416
5583
  DOMAIN_SYSTEMS,
5417
5584
  EMPTY_BECAUSE,
@@ -5449,6 +5616,10 @@ function inheritedExpiry(inputExpiries) {
5449
5616
  ORDER_FOLD_DEFAULT,
5450
5617
  ORDER_FOLD_HOUR_MS,
5451
5618
  ORDER_TERMINAL_STATUS,
5619
+ PARTY_ROLE,
5620
+ PARTY_URI_MAX_LENGTH,
5621
+ PARTY_URI_RECOMMENDED_LENGTH,
5622
+ PERSON_STATUS,
5452
5623
  PRIORITY_UNSET,
5453
5624
  PRIVATE_BIZSTEP,
5454
5625
  READ_BASIS,
@@ -5458,6 +5629,8 @@ function inheritedExpiry(inputExpiries) {
5458
5629
  RETURN_TO_SUPPLIER,
5459
5630
  SCHEDULE_STATUS,
5460
5631
  SIGNATURE_REJECTED_REASONS,
5632
+ SOURCE_DEST_PARTY_TYPE,
5633
+ TRAILER_LOAD,
5461
5634
  TWIN_AXES,
5462
5635
  TWIN_PROPERTIES,
5463
5636
  TWIN_RELATIONS,
@@ -5476,8 +5649,13 @@ function inheritedExpiry(inputExpiries) {
5476
5649
  WMS_RECEIVING_ORDER_KINDS,
5477
5650
  WMS_TYPES,
5478
5651
  YARD_BIZSTEP,
5652
+ YARD_MODE,
5479
5653
  YARD_PRIVATE_BIZSTEP,
5654
+ YMS_APPOINTMENT_CANCEL_REASON,
5655
+ YMS_APPOINTMENT_STATUS,
5480
5656
  YMS_LOCATION_TYPES,
5657
+ YMS_ORDER_KIND,
5658
+ YMS_TASK_KIND,
5481
5659
  YMS_TYPES,
5482
5660
  acceptsPerformance,
5483
5661
  activeShiftAt,
@@ -5511,6 +5689,7 @@ function inheritedExpiry(inputExpiries) {
5511
5689
  computeOee,
5512
5690
  conversionFactorOf,
5513
5691
  criterionSaysNothing,
5692
+ dockDoorStatusOf,
5514
5693
  documentPath,
5515
5694
  dueStatusOf,
5516
5695
  effectivityAt,
@@ -5533,6 +5712,8 @@ function inheritedExpiry(inputExpiries) {
5533
5712
  hierarchyOf,
5534
5713
  homeOf,
5535
5714
  hourStartOf,
5715
+ identifierText,
5716
+ identifierUnderNamespace,
5536
5717
  identityGroundingOf,
5537
5718
  inWorkCalendar,
5538
5719
  inWorkCalendarAt,
@@ -5550,6 +5731,7 @@ function inheritedExpiry(inputExpiries) {
5550
5731
  inheritedExpiry,
5551
5732
  inheritedLotUse,
5552
5733
  isAggregationRecord,
5734
+ isAppointmentClosed,
5553
5735
  isCacheableTense,
5554
5736
  isCommandTerminal,
5555
5737
  isElectricalLocationType,
@@ -5571,6 +5753,8 @@ function inheritedExpiry(inputExpiries) {
5571
5753
  isOperationalAttentionV1,
5572
5754
  isOperationalRecord,
5573
5755
  isOrderTerminal,
5756
+ isPartyRef,
5757
+ isPartyUri,
5574
5758
  isPlannedStopStatus,
5575
5759
  isRecipeExecutionBasis,
5576
5760
  isResourceKind,
@@ -5579,9 +5763,11 @@ function inheritedExpiry(inputExpiries) {
5579
5763
  isWebhookDeliveryCode,
5580
5764
  isWebhookSecretSegment,
5581
5765
  isWorkShiftExecutionBasis,
5766
+ isYmsAppointmentStatus,
5582
5767
  isoDurationHours,
5583
5768
  itemClassOf,
5584
5769
  itemKeyOf,
5770
+ itemMaterialDefinitionId,
5585
5771
  judgeAgainstSpec,
5586
5772
  levelOfLocationType,
5587
5773
  lgtinClass,
@@ -5616,6 +5802,10 @@ function inheritedExpiry(inputExpiries) {
5616
5802
  parseGs1,
5617
5803
  parseIsoDuration,
5618
5804
  partitionLensLocations,
5805
+ partyIdentifierViolation,
5806
+ partyRowIdOf,
5807
+ partyUri,
5808
+ partyUriLengthNote,
5619
5809
  passThroughReversible,
5620
5810
  performanceKey,
5621
5811
  periodFactId,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@operato/ops-contract",
3
- "version": "0.9.42",
3
+ "version": "0.9.43",
4
4
  "description": "Operations domain contract — the standard vocabulary that producers and readers agree on (EPCIS 2.0/GS1, ISA-95, IEC 61850/ISO 50001). Types, guards, validation. No state, no engine.",
5
5
  "type": "module",
6
6
  "main": "./dist-cjs/index.cjs",
@@ -18,8 +18,17 @@
18
18
  }
19
19
  },
20
20
  "files": [
21
+ "README.md",
21
22
  "dist",
22
- "dist-cjs"
23
+ "dist-cjs",
24
+ "!**/*.map",
25
+ "!**/*.test.*",
26
+ "!**/*.spec.*",
27
+ "!**/test/**",
28
+ "!**/tests/**",
29
+ "!**/__tests__/**",
30
+ "!**/*.tsbuildinfo",
31
+ "!**/.DS_Store"
23
32
  ],
24
33
  "scripts": {
25
34
  "build": "rm -rf dist dist-cjs && npm run build:esm && npm run build:cjs",