@operato/ops-contract 0.9.42 → 0.9.44

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.
@@ -0,0 +1,134 @@
1
+ import { isIsoDateTime } from "./epcis.js";
2
+ import { isYmsAppointmentStatus, YMS_APPOINTMENT_CANCEL_REASON, YMS_ORDER_KIND } from "./yms-profile.js";
3
+ /*
4
+ * **The dock between the yard and the warehouse** - the facts the two apps send each other about a slot at a door
5
+ * (ADR-0210 decisions 3 · 11 · 12, 2026-11-19).
6
+ *
7
+ * The yard owns the appointment (decision 3): the warehouse asks for a slot for one of its orders, a person at the yard desk
8
+ * confirms it with a door, a time and a carrier, and the yard tells the warehouse where the appointment stands every time it
9
+ * changes. No foreign key between them - the order name and the appointment id travel in the facts, and the order's
10
+ * documents become the appointment's (its events carry them).
11
+ *
12
+ * Each fact carries an id unique within its sender (`factId`). What a receiver does with a repeat, or with a second request
13
+ * for the same order, is the receiver's (README "계약이 정하는 것"). Closed: an unknown kind is refused.
14
+ *
15
+ * The direction is the yard's order kind on purpose - `appointment` (unloading) or `appointment-out` (loading) is what the
16
+ * appointment will be, so the yard books what it is told without a second word to map.
17
+ *
18
+ * warehouse → yard slot-request · slot-withdrawn
19
+ * yard → warehouse appointment (where the appointment for a request stands now) · slot-declined
20
+ */
21
+ export const DOCK_FACT_KIND = {
22
+ /** warehouse → yard: this order needs a slot at a door. */
23
+ slotRequest: 'slot-request',
24
+ /** warehouse → yard: the order no longer needs it. */
25
+ slotWithdrawn: 'slot-withdrawn',
26
+ /** yard → warehouse: the appointment for a request, as it stands now - booked, moved, cancelled, at the door, done. */
27
+ appointment: 'appointment',
28
+ /** yard → warehouse: the yard will not book this request, and why. */
29
+ slotDeclined: 'slot-declined'
30
+ };
31
+ /** Whether a record on a stream is a dock fact (the warehouse's door also takes the plant's lot statuses and moves). */
32
+ export function isDockRecord(record) {
33
+ const r = record;
34
+ return !!r && typeof r === 'object' && typeof r.factId === 'string' && Object.values(DOCK_FACT_KIND).includes(r.kind);
35
+ }
36
+ /* An instant with its offset - the contract's one measure for time fields (`isIsoDateTime`). */
37
+ const isInstant = (v) => isIsoDateTime(v);
38
+ /** **Read one record as a dock fact, or say why not.** The receiver passes the kinds it takes. */
39
+ export function dockFactOf(record, takes) {
40
+ const r = record;
41
+ if (!r || typeof r !== 'object' || typeof r.factId !== 'string' || typeof r.kind !== 'string')
42
+ return { errors: ['the record is not a dock fact: factId and kind are needed'] };
43
+ const kind = r.kind;
44
+ if (!Object.values(DOCK_FACT_KIND).includes(kind))
45
+ return { errors: [`${kind} is not a dock fact kind`] };
46
+ if (takes && !takes.includes(kind))
47
+ return { errors: [`a dock fact of kind ${kind} is not one this receiver takes`] };
48
+ const errors = [];
49
+ const text = (key) => typeof r[key] === 'string' && r[key].trim() !== '';
50
+ const s = (key) => r[key].trim();
51
+ if (!text('factId'))
52
+ errors.push('factId is empty');
53
+ switch (kind) {
54
+ case DOCK_FACT_KIND.slotRequest: {
55
+ if (!text('order'))
56
+ errors.push('order is missing: a request names the warehouse order');
57
+ if (!Object.values(YMS_ORDER_KIND).includes(r.direction))
58
+ errors.push(`direction must be ${Object.values(YMS_ORDER_KIND).join(' or ')}`);
59
+ for (const key of ['wantedFrom', 'wantedTo'])
60
+ if (r[key] !== undefined && !isInstant(r[key]))
61
+ errors.push(`${key} is not an instant`);
62
+ if (isInstant(r.wantedFrom) && isInstant(r.wantedTo) && Date.parse(r.wantedTo) <= Date.parse(r.wantedFrom))
63
+ errors.push('wantedTo is not after wantedFrom');
64
+ const documents = r.documents;
65
+ if (documents !== undefined && (!Array.isArray(documents) || documents.some(one => !one || typeof one.id !== 'string' || !one.id.trim())))
66
+ errors.push('documents must each have an id');
67
+ if (errors.length)
68
+ return { errors };
69
+ return {
70
+ fact: {
71
+ factId: s('factId'),
72
+ kind,
73
+ order: s('order'),
74
+ direction: r.direction,
75
+ ...(isInstant(r.wantedFrom) ? { wantedFrom: r.wantedFrom } : {}),
76
+ ...(isInstant(r.wantedTo) ? { wantedTo: r.wantedTo } : {}),
77
+ ...(text('dock') ? { dock: s('dock') } : {}),
78
+ ...(Array.isArray(documents) && documents.length
79
+ ? { documents: documents.map(one => ({ ...(one.type ? { type: String(one.type) } : {}), id: one.id.trim() })) }
80
+ : {}),
81
+ ...(text('note') ? { note: s('note') } : {})
82
+ }
83
+ };
84
+ }
85
+ case DOCK_FACT_KIND.slotWithdrawn: {
86
+ if (!text('request'))
87
+ errors.push('request is missing: a withdrawal names the request');
88
+ if (errors.length)
89
+ return { errors };
90
+ return { fact: { factId: s('factId'), kind, request: s('request'), ...(text('reason') ? { reason: s('reason') } : {}) } };
91
+ }
92
+ case DOCK_FACT_KIND.appointment: {
93
+ for (const key of ['request', 'order', 'appointment', 'dockDoor'])
94
+ if (!text(key))
95
+ errors.push(`${key} is missing`);
96
+ if (!isYmsAppointmentStatus(r.status))
97
+ errors.push(`status ${String(r.status)} is not an appointment status`);
98
+ if (!isInstant(r.startAt) || !isInstant(r.endAt))
99
+ errors.push('startAt and endAt must be instants');
100
+ if (r.cancelReason !== undefined && !YMS_APPOINTMENT_CANCEL_REASON.includes(r.cancelReason))
101
+ errors.push(`cancelReason ${String(r.cancelReason)} is not one`);
102
+ if (r.status === 'cancelled' && r.cancelReason === undefined)
103
+ errors.push('a cancelled appointment says why (cancelReason)');
104
+ if (r.status !== 'cancelled' && r.cancelReason !== undefined)
105
+ errors.push('only a cancelled appointment carries a cancelReason');
106
+ if (isInstant(r.startAt) && isInstant(r.endAt) && Date.parse(r.endAt) <= Date.parse(r.startAt))
107
+ errors.push('endAt is not after startAt');
108
+ if (errors.length)
109
+ return { errors };
110
+ return {
111
+ fact: {
112
+ factId: s('factId'),
113
+ kind,
114
+ request: s('request'),
115
+ order: s('order'),
116
+ appointment: s('appointment'),
117
+ status: r.status,
118
+ dockDoor: s('dockDoor'),
119
+ startAt: s('startAt'),
120
+ endAt: s('endAt'),
121
+ ...(r.cancelReason !== undefined ? { cancelReason: r.cancelReason } : {})
122
+ }
123
+ };
124
+ }
125
+ default: {
126
+ for (const key of ['request', 'order', 'reason'])
127
+ if (!text(key))
128
+ errors.push(`${key} is missing`);
129
+ if (errors.length)
130
+ return { errors };
131
+ return { fact: { factId: s('factId'), kind: DOCK_FACT_KIND.slotDeclined, request: s('request'), order: s('order'), reason: s('reason') } };
132
+ }
133
+ }
134
+ }
@@ -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
  * 돌려주고, 빈 배열이 유효다.
@@ -14,8 +14,7 @@ export declare const EMS_LOCATION_TYPES: readonly ["incoming", "feeder", "submet
14
14
  * `bidirectional` 은 **그 계량기가 순 유입을 재는 것**이다. 발전을 부하에서 빼는 것이 아니다 — 그
15
15
  * 계량기가 읽은 값이 그 접속점의 사실이고, 요금이 그 값에 매겨진다.
16
16
  *
17
- * 표준 근거: 계량기의 적산 레지스터가 유입·유출로 갈려 있고(IEC 62053 계열), ISO 50001 은 유입 경계를
18
- * 따로 둔다(`EnergyInput`). 우리가 지은 낱말이 아니다.
17
+ * 표준 근거: 계량기의 적산 레지스터가 유입·유출로 갈려 있다(IEC 62053 계열). 우리가 지은 낱말이 아니다.
19
18
  */
20
19
  export declare const METER_DIRECTION: readonly ["import", "export", "bidirectional"];
21
20
  export type MeterDirection = (typeof METER_DIRECTION)[number];
@@ -13,8 +13,7 @@ export const EMS_LOCATION_TYPES = ['incoming', 'feeder', 'submeter-zone'];
13
13
  * `bidirectional` 은 **그 계량기가 순 유입을 재는 것**이다. 발전을 부하에서 빼는 것이 아니다 — 그
14
14
  * 계량기가 읽은 값이 그 접속점의 사실이고, 요금이 그 값에 매겨진다.
15
15
  *
16
- * 표준 근거: 계량기의 적산 레지스터가 유입·유출로 갈려 있고(IEC 62053 계열), ISO 50001 은 유입 경계를
17
- * 따로 둔다(`EnergyInput`). 우리가 지은 낱말이 아니다.
16
+ * 표준 근거: 계량기의 적산 레지스터가 유입·유출로 갈려 있다(IEC 62053 계열). 우리가 지은 낱말이 아니다.
18
17
  */
19
18
  export const METER_DIRECTION = ['import', 'export', 'bidirectional'];
20
19
  /** 설비(능동) 타입 키 — 계량 지점과 에너지 자원. */
@@ -224,8 +223,9 @@ export const EMS_TYPES = [
224
223
  level: 'Other',
225
224
  label: 'twin.type.incoming',
226
225
  /* 수전 지점 — 계약전력이 걸리는 자리이고, 요금의 근거가 되는 수요는 여기서 잰다.
227
- ISO 50001 의 「에너지 유입」 경계이기도 하다(조직의 에너지 검토가 여기서 시작한다). */
228
- standardClass: { iec61850: 'MMTR', iso50001: 'EnergyInput' },
226
+ 조직의 에너지 검토가 여기서 시작하지만, ISO 50001 은 이 경계에 **분류 이름을 주지 않는다** — 그래서
227
+ 그 칸을 비운다(예전의 `EnergyInput` 은 표준의 낱말이 아니었다. 2026-11-19 내용 점검). */
228
+ standardClass: { iec61850: 'MMTR' },
229
229
  identity: { scheme: 'kernel:id' },
230
230
  capabilities: ['metered']
231
231
  },
@@ -235,8 +235,17 @@ export const EMS_TYPES = [
235
235
  /* 전기 계통의 구간은 **설비 계층의 단이 아니다** — 표준의 탈출구(`Other`)를 쓴다(아래 주석). */
236
236
  level: 'Other',
237
237
  label: 'twin.type.feeder',
238
- /* 분기 회로 — 부하 분해의 단위. 계약전력의 하위 배분이 여기서 정해진다. */
239
- standardClass: { iec61850: 'Feeder', iso50001: 'EnergyUse' },
238
+ /*
239
+ * 분기 회로 — 부하 분해의 단위. 계약전력의 하위 배분이 여기서 정해진다.
240
+ *
241
+ * **두 칸 다 비운다**(2026-11-19 내용 점검). 예전 값은 둘 다 맞지 않았다:
242
+ * · `Feeder` 는 IEC 61850 논리 노드가 아니다. 그 표준에서 급전 구간은 SCL 의 `Bay`(설비 구성의 자리)이고,
243
+ * 이 칸이 담는 논리 노드(MMTR·MMXU·XCBR…)와 다른 층이다. 회로의 계량은 그 회로에 달린 계량기(`meter`)가 진다.
244
+ * · ISO 50001 의 「energy use」는 **용도**(환기·조명처럼 에너지를 어디에 쓰나)이지 회로가 아니다. 회로 하나에
245
+ * 여러 용도가 걸리고, 한 용도가 여러 회로에 걸친다 — 대응시키면 SEU 분석이 회로를 용도로 센다.
246
+ * 표준의 이름이 없는 것을 「없다」고 두는 것이 파일 머리의 규율이다.
247
+ */
248
+ standardClass: {},
240
249
  identity: { scheme: 'kernel:id' },
241
250
  capabilities: ['metered']
242
251
  },
@@ -262,7 +271,8 @@ export const EMS_TYPES = [
262
271
  role: 'equipment',
263
272
  label: 'twin.type.meter',
264
273
  /* 계량기 — 측정 논리 노드(MMXU=측정단위, MMTR=적산). 자산으로도 하나다(ISO 55000). */
265
- standardClass: { iec61850: 'MMXU', iso55000: 'Asset', iso50001: 'MeasurementPoint' },
274
+ /* ISO 50001 칸은 비운다 — 계측 지점은 그 표준이 이름 붙인 분류가 아니다(파일 머리의 규율, 2026-11-19 내용 점검). */
275
+ standardClass: { iec61850: 'MMXU', iso55000: 'Asset' },
266
276
  identity: { scheme: 'kernel:id' },
267
277
  capabilities: ['metered', 'operable']
268
278
  },
@@ -287,7 +297,8 @@ export const EMS_TYPES = [
287
297
  role: 'equipment',
288
298
  label: 'twin.type.pv-array',
289
299
  /* 태양광 어레이 — IEC 61850-7-420(분산자원)의 `DPVA`. 발전과 계량은 다른 능력이다. */
290
- standardClass: { iec61850: 'DPVA', iso55000: 'Asset', iso50001: 'RenewableSupply' },
300
+ /* ISO 50001 칸은 비운다 — 「재생 공급」은 그 표준의 분류 이름이 아니다(파일 머리의 규율, 2026-11-19 내용 점검). */
301
+ standardClass: { iec61850: 'DPVA', iso55000: 'Asset' },
291
302
  identity: { scheme: 'kernel:id' },
292
303
  capabilities: ['energyGenerating', 'metered', 'operable']
293
304
  },
package/dist/epcis.d.ts CHANGED
@@ -275,7 +275,7 @@ export interface SensorElement {
275
275
  sensorReport: Record<string, unknown>[];
276
276
  }
277
277
  /** EPCIS 2.0 공통 헤더(모든 이벤트). action 은 여기 없음 — TransformationEvent 는 action 이 없다. */
278
- interface EpcisHeader {
278
+ export interface EpcisHeader {
279
279
  '@context': string;
280
280
  type: EpcisEventType;
281
281
  /**
@@ -326,8 +326,11 @@ interface EpcisHeader {
326
326
  persistentDisposition?: PersistentDisposition;
327
327
  /** 센서 관측 묶음(콜드체인 등). */
328
328
  sensorElementList?: SensorElement[];
329
- /** 인증 상세를 가리키는 URL(규제 산업). */
330
- certificationInfo?: string;
329
+ /**
330
+ * 인증 상세를 가리키는 URL(규제 산업). 표준 JSON 스키마(2.0.1 `definitions.certificationInfo`)는
331
+ * **URI 하나 또는 URI 배열**을 받는다 — 문자열만 받으면 배열로 보낸 상대의 이벤트를 잘못 읽는다.
332
+ */
333
+ certificationInfo?: string | string[];
331
334
  }
332
335
  /** action 을 갖는 이벤트(Object/Aggregation/Transaction). */
333
336
  interface EpcisActionEvent extends EpcisHeader {
@@ -361,7 +364,13 @@ export interface EpcisTransformationEvent extends EpcisHeader {
361
364
  transformationID?: string;
362
365
  }
363
366
  export type EpcisEvent = EpcisObjectEvent | EpcisAggregationEvent | EpcisTransactionEvent | EpcisTransformationEvent;
364
- /** SSCC (물류단위: 팔레트/화물/트레일러) — 결정적 카운터 기반. */
367
+ /**
368
+ * SSCC (물류단위: 팔레트/화물/트레일러) — 결정적 카운터 기반.
369
+ *
370
+ * **전제: 회사 프리픽스가 7자리다.** 직렬 참조를 10자리로 채우므로 프리픽스(7) + 참조(10) = 17 이 되어야
371
+ * GS1 TDS 의 SSCC 합계와 맞는다. 다른 자리 수의 프리픽스를 넣으면 이 함수가 만든 URI 를
372
+ * `gs1KeyDigitViolation` 이 바로 거절한다(시험 `identifier-builders.test.ts` 가 그 경계를 잡는다).
373
+ */
365
374
  export declare function ssccUri(companyPrefix: string, serial: number): string;
366
375
  /** 비직렬 수량용 SGTIN 패턴(epcClass) — 로트를 따지지 않는 품목 클래스. quantityList 에 사용. */
367
376
  export declare function sgtinClass(companyPrefix: string, itemRef: string): string;
@@ -372,8 +381,12 @@ export declare function sgtinClass(companyPrefix: string, itemRef: string): stri
372
381
  * 흩뿌리면 곧 방언이 된다. GS1 CBV 마스터데이터 이름공간(`urn:epcglobal:cbv:mda:`)의 정식 명칭을
373
382
  * 확인하면 **이 상수만 바꾸면 되도록** 여기 모아 둔다.
374
383
  *
375
- * ⚠ 아래 이름은 **아직 정본 확인 전**이다(CBV 마스터데이터 문서 필요). 받는 경로는 이름과 무관하게
376
- * 동작하므로(받은 것을 잃지 않고 통과) 이 상수는 우리가 **생산할 때**만 쓰인다.
384
+ * 두 이름은 CBV 2.0 에 있다(2026-11-19 확인): `itemExpirationDate` §9.2.3(로트 단위, Date),
385
+ * `lotNumber` §9.2.4(개체 단위, 1–20자 문자열). 접두 `cbvmda:` 는 EPCIS 2.0 JSON-LD 컨텍스트가
386
+ * `urn:epcglobal:cbv:mda:` 로 펼친다. (CBV §9.1.2.1 의 이름-값 쌍 표기는 `urn:epcglobal:cbv:mda#…` 로
387
+ * `#` 을 쓴다 — 두 문서의 표기가 다르다. 우리는 JSON-LD 바인딩을 따른다.)
388
+ *
389
+ * 받는 경로는 이름과 무관하게 동작하므로(받은 것을 잃지 않고 통과) 이 상수는 우리가 **생산할 때**만 쓰인다.
377
390
  */
378
391
  export declare const ILMD_ATTR: {
379
392
  /** 유통기한·만료(로트 단위). */
@@ -445,6 +458,21 @@ export declare function itemClassOf(uri: string | undefined): string | undefined
445
458
  * 그 밖(모르는 모양) → 원문 그대로 — 품목 이름이 그 글자일 수 있다(`itemClassOf` 와 같다)
446
459
  */
447
460
  export declare function materialDefinitionIdOf(epcClass: string | undefined): string | undefined;
461
+ /**
462
+ * **물품 하나의 품목 이름** — 그 물품이 무슨 품목인가(ISA-95 `MaterialDefinition` 의 ID). 피규어가 물품 모양을 고르는 코드다(도메인의
463
+ * `item-types` 표, ADR-0208 결정 5).
464
+ *
465
+ * 물품 상태의 세 칸에서 차례로 고른다:
466
+ * 1. `definitionId` — 상류가 품목 코드를 따로 말했으면 그것
467
+ * 2. `materialDefinitionIdOf(gtin)` — 품목 클래스에서(로트 · GTIN 품목 → GTIN 품목 패턴, 사내 클래스 → 품번)
468
+ * 3. `gtinKey` 의 GTIN 품목 패턴 — 직렬 물품(SGTIN)은 커널 상태에 `gtinKey` 만 있다
469
+ * 셋 다 없으면 `undefined` — 지어내지 않는다. 같은 품목의 직렬 물품과 로트 물품이 같은 이름이 된다.
470
+ */
471
+ export declare function itemMaterialDefinitionId(item: {
472
+ definitionId?: string;
473
+ gtin?: string;
474
+ gtinKey?: string;
475
+ } | undefined): string | undefined;
448
476
  /**
449
477
  * **이 품목 클래스의 그 로트** — `itemClassOf` 의 반대 방향. 시뮬의 도착 생성기처럼 품목 클래스만 들고 있는 곳이 부른다.
450
478
  *
@@ -551,6 +579,13 @@ export declare function lotClassUri(input: {
551
579
  gtin?: string;
552
580
  }): string | undefined;
553
581
  export declare function bizTransactionUri(namespace: string, transId: string | number): string | undefined;
582
+ /**
583
+ * 이름공간 아래 식별자의 표지 — CBV 2.0 의 도메인 기반 식별자마다 하나.
584
+ * `obj` §8.2 · `class` §8.3 · `bt` §8.5 · `sd` §8.7(Source/Destination — 거래 상대, `party.ts`).
585
+ */
586
+ export type NamespaceMarker = 'obj' | 'class' | 'bt' | 'sd';
587
+ /** 이 파일 밖에서 표지 규칙을 다시 적지 않도록 — 같은 부호화 · 같은 이름공간 판정을 쓴다(`party.ts`). */
588
+ export declare function identifierUnderNamespace(namespace: string, marker: NamespaceMarker, id: string | number): string | undefined;
554
589
  /** 모든 빌더가 공통으로 받는 표준 헤더 옵션(선택) — 방출부가 필요할 때 채운다. */
555
590
  export interface EpcisHeaderOptions {
556
591
  eventID?: string;
@@ -572,7 +607,7 @@ export interface EpcisHeaderOptions {
572
607
  destinationList?: DestinationElement[];
573
608
  persistentDisposition?: PersistentDisposition;
574
609
  sensorElementList?: SensorElement[];
575
- certificationInfo?: string;
610
+ certificationInfo?: string | string[];
576
611
  }
577
612
  export declare function objectEvent(p: {
578
613
  eventTime: string;
@@ -622,6 +657,11 @@ export declare function transformationEvent(p: {
622
657
  bizLocation?: string;
623
658
  bizTransactionList?: BizTransactionElement[];
624
659
  } & EpcisHeaderOptions): EpcisTransformationEvent;
660
+ /**
661
+ * 절대 시각 문자열인가 — 날짜·초까지, 끝에 `Z` 또는 `±hh:mm`. 이 패키지의 모든 시각 칸이 같은 잣대를 쓴다.
662
+ * 오프셋 없는 시각은 받지 않는다: 어느 시간대의 「01:00」인지 받는 쪽이 알 수 없다.
663
+ */
664
+ export declare function isIsoDateTime(value: unknown): value is string;
625
665
  /**
626
666
  * 그 GS1 키의 자리 수가 맞나 — 어긋나면 왜인지 말한다.
627
667
  *
package/dist/epcis.js CHANGED
@@ -196,7 +196,13 @@ export function isEpcisEventType(eventType) {
196
196
  return typeof eventType === 'string' && eventType.startsWith('epcis.');
197
197
  }
198
198
  // ── GS1 EPC URI 헬퍼 (표준) ────────────────────────────────────────────────
199
- /** SSCC (물류단위: 팔레트/화물/트레일러) — 결정적 카운터 기반. */
199
+ /**
200
+ * SSCC (물류단위: 팔레트/화물/트레일러) — 결정적 카운터 기반.
201
+ *
202
+ * **전제: 회사 프리픽스가 7자리다.** 직렬 참조를 10자리로 채우므로 프리픽스(7) + 참조(10) = 17 이 되어야
203
+ * GS1 TDS 의 SSCC 합계와 맞는다. 다른 자리 수의 프리픽스를 넣으면 이 함수가 만든 URI 를
204
+ * `gs1KeyDigitViolation` 이 바로 거절한다(시험 `identifier-builders.test.ts` 가 그 경계를 잡는다).
205
+ */
200
206
  export function ssccUri(companyPrefix, serial) {
201
207
  return `urn:epc:id:sscc:${companyPrefix}.${String(serial).padStart(10, '0')}`;
202
208
  }
@@ -211,8 +217,12 @@ export function sgtinClass(companyPrefix, itemRef) {
211
217
  * 흩뿌리면 곧 방언이 된다. GS1 CBV 마스터데이터 이름공간(`urn:epcglobal:cbv:mda:`)의 정식 명칭을
212
218
  * 확인하면 **이 상수만 바꾸면 되도록** 여기 모아 둔다.
213
219
  *
214
- * ⚠ 아래 이름은 **아직 정본 확인 전**이다(CBV 마스터데이터 문서 필요). 받는 경로는 이름과 무관하게
215
- * 동작하므로(받은 것을 잃지 않고 통과) 이 상수는 우리가 **생산할 때**만 쓰인다.
220
+ * 두 이름은 CBV 2.0 에 있다(2026-11-19 확인): `itemExpirationDate` §9.2.3(로트 단위, Date),
221
+ * `lotNumber` §9.2.4(개체 단위, 1–20자 문자열). 접두 `cbvmda:` 는 EPCIS 2.0 JSON-LD 컨텍스트가
222
+ * `urn:epcglobal:cbv:mda:` 로 펼친다. (CBV §9.1.2.1 의 이름-값 쌍 표기는 `urn:epcglobal:cbv:mda#…` 로
223
+ * `#` 을 쓴다 — 두 문서의 표기가 다르다. 우리는 JSON-LD 바인딩을 따른다.)
224
+ *
225
+ * 받는 경로는 이름과 무관하게 동작하므로(받은 것을 잃지 않고 통과) 이 상수는 우리가 **생산할 때**만 쓰인다.
216
226
  */
217
227
  export const ILMD_ATTR = {
218
228
  /** 유통기한·만료(로트 단위). */
@@ -369,6 +379,27 @@ export function materialDefinitionIdOf(epcClass) {
369
379
  }
370
380
  return raw;
371
381
  }
382
+ /**
383
+ * **물품 하나의 품목 이름** — 그 물품이 무슨 품목인가(ISA-95 `MaterialDefinition` 의 ID). 피규어가 물품 모양을 고르는 코드다(도메인의
384
+ * `item-types` 표, ADR-0208 결정 5).
385
+ *
386
+ * 물품 상태의 세 칸에서 차례로 고른다:
387
+ * 1. `definitionId` — 상류가 품목 코드를 따로 말했으면 그것
388
+ * 2. `materialDefinitionIdOf(gtin)` — 품목 클래스에서(로트 · GTIN 품목 → GTIN 품목 패턴, 사내 클래스 → 품번)
389
+ * 3. `gtinKey` 의 GTIN 품목 패턴 — 직렬 물품(SGTIN)은 커널 상태에 `gtinKey` 만 있다
390
+ * 셋 다 없으면 `undefined` — 지어내지 않는다. 같은 품목의 직렬 물품과 로트 물품이 같은 이름이 된다.
391
+ */
392
+ export function itemMaterialDefinitionId(item) {
393
+ if (!item)
394
+ return undefined;
395
+ if (item.definitionId)
396
+ return item.definitionId;
397
+ const fromClass = materialDefinitionIdOf(item.gtin);
398
+ if (fromClass)
399
+ return fromClass;
400
+ const [companyPrefix, itemRef] = (item.gtinKey ?? '').split('.');
401
+ return companyPrefix && itemRef ? sgtinClass(companyPrefix, itemRef) : undefined;
402
+ }
372
403
  /**
373
404
  * **이 품목 클래스의 그 로트** — `itemClassOf` 의 반대 방향. 시뮬의 도착 생성기처럼 품목 클래스만 들고 있는 곳이 부른다.
374
405
  *
@@ -564,6 +595,10 @@ const PERCENT_ENCODED = {
564
595
  /* 로트 클래스의 가르는 글자 — `lotClassUri` 만 쓴다(§`LOT_COMPONENT_BREAKING`). 표는 한 벌이다. */
565
596
  ';': '%3B'
566
597
  };
598
+ /** 이 파일 밖에서 표지 규칙을 다시 적지 않도록 — 같은 부호화 · 같은 이름공간 판정을 쓴다(`party.ts`). */
599
+ export function identifierUnderNamespace(namespace, marker, id) {
600
+ return underNamespace(namespace, marker, id);
601
+ }
567
602
  function underNamespace(namespace, marker, id) {
568
603
  const raw = String(id);
569
604
  if (!raw)
@@ -696,6 +731,13 @@ export function transformationEvent(p) {
696
731
  // EPCIS 2.0 이벤트의 필수 필드·형태를 검증. 위반 목록을 반환(빈 배열 = 유효).
697
732
  // JSON Schema 파일 파생은 후속 — 이 함수가 제약의 SoT.
698
733
  const ISO_RE = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[+-]\d{2}:\d{2})$/;
734
+ /**
735
+ * 절대 시각 문자열인가 — 날짜·초까지, 끝에 `Z` 또는 `±hh:mm`. 이 패키지의 모든 시각 칸이 같은 잣대를 쓴다.
736
+ * 오프셋 없는 시각은 받지 않는다: 어느 시간대의 「01:00」인지 받는 쪽이 알 수 없다.
737
+ */
738
+ export function isIsoDateTime(value) {
739
+ return typeof value === 'string' && ISO_RE.test(value);
740
+ }
699
741
  const TZ_RE = /^[+-]\d{2}:\d{2}$/;
700
742
  const ACTIONS = ['ADD', 'OBSERVE', 'DELETE'];
701
743
  /*
@@ -843,6 +885,17 @@ export function validateEpcisEvent(e) {
843
885
  v.push('eventTime ISO8601 아님');
844
886
  if (typeof e.eventTimeZoneOffset !== 'string' || !TZ_RE.test(e.eventTimeZoneOffset))
845
887
  v.push('eventTimeZoneOffset 형식 오류');
888
+ /*
889
+ * ── 표준보다 좁은 곳 (2026-11-19, EPCIS 2.0 원문과 대조) ─────────────────────────
890
+ * 이 검증기는 표준이 허용하는 것 셋을 **일부러** 거절한다. 셋 다 표준을 잘못 읽은 것이 아니라 이 트윈이
891
+ * 받는 입구의 선택이다 — 넓히려면 아래 「전제하는 곳」을 먼저 고쳐야 한다.
892
+ * · `bizStep` — 표준은 모든 이벤트에서 선택(§7.4.2–7.4.6). 우리 저널은 이 칸으로 사건 종류를 가르고
893
+ * (headless-twin `twin-event-keys` · `event-type-split`) 모든 생산자가 단계를 밝힌다.
894
+ * · `ObjectEvent.epcList` — 표준은 `quantityList` 만 있는 이벤트도 허용(§7.4.2: 둘 중 하나 이상).
895
+ * 커널 `observed-reducer` 가 `ev.epcList` 를 그대로 순회한다.
896
+ * · `AggregationEvent.parentID` — 표준은 OBSERVE 에서 선택(§7.4.3), DELETE 에서는 자식 목록이 비어도
897
+ * 된다(전부 해체). 커널의 집계 반영이 부모를 열쇠로 쓴다.
898
+ */
846
899
  if (typeof e.bizStep !== 'string' || !e.bizStep)
847
900
  v.push('bizStep 누락');
848
901
  /* 선택 헤더 — 있으면 형식을 지킨다(없는 것은 위반이 아니다). */
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';
@@ -32,4 +33,7 @@ export * from './reliability.ts';
32
33
  export * from './erp.ts';
33
34
  export * from './actuation.ts';
34
35
  export * from './operational-attention.ts';
36
+ export * from './records-of-event.ts';
37
+ export * from './material-move.ts';
38
+ export * from './dock-facts.ts';
35
39
  export * from './lot-lineage.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";
@@ -55,4 +56,7 @@ export * from "./reliability.js";
55
56
  export * from "./erp.js";
56
57
  export * from "./actuation.js";
57
58
  export * from "./operational-attention.js";
59
+ export * from "./records-of-event.js";
60
+ export * from "./material-move.js";
61
+ export * from "./dock-facts.js";
58
62
  export * from "./lot-lineage.js";