@operato/ops-contract 0.9.23 → 0.9.24

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.
@@ -192,6 +192,24 @@ export type TwinRelationTarget = {
192
192
  | {
193
193
  kind: 'external';
194
194
  entity: string;
195
+ }
196
+ /**
197
+ * A reference that points **either** at an item of an axis **or** at something outside the kernel —
198
+ * told apart by looking the id up in that axis.
199
+ *
200
+ * `locations[].parentId` is this. `LocationState.parentId` says so in its own words: the parent is
201
+ * another location (a line, a cell, a zone — this is where the hierarchy gets deeper) or, when no
202
+ * location has that id, an area of the space. The relation was first declared `axis` (it drew lines
203
+ * to locations that did not exist), then `external` (a bin whose parent is a zone came back
204
+ * "nobody can resolve this", and a zone never listed its bins). Neither alone is true.
205
+ *
206
+ * A consumer that only knows `axis` and `external` skips this kind — it shows less, never a line
207
+ * that is not there. `splitRelationIds` does the lookup so that each consumer does not write its own.
208
+ */
209
+ | {
210
+ kind: 'axis-or-external';
211
+ axis: string;
212
+ entity: string;
195
213
  };
196
214
  /**
197
215
  * **그 관계가 가리키는 것이 언제의 일인가** — 화면의 판단이 여기서 갈린다.
@@ -344,6 +362,24 @@ export declare function documentPath(axis: string): string;
344
362
  /** 이 축에서 나가는 관계 · 이 축으로 들어오는 관계 — 항목 패널의 "이어진 것" 양방향. */
345
363
  export declare const relationsFrom: (axis: string) => TwinRelationInfo[];
346
364
  export declare const relationsTo: (axis: string) => TwinRelationInfo[];
365
+ /**
366
+ * Sorts the ids a relation holds into what they point at.
367
+ *
368
+ * `inAxis(axis, id)` answers "is there an item with this id in that axis" — the caller owns the data,
369
+ * the contract owns the rule. For `axis-or-external` an id found in the axis is an axis item and
370
+ * every other id belongs to the external entity. A `type` target has neither: its values are type
371
+ * keys, not item ids.
372
+ */
373
+ export declare function splitRelationIds(target: TwinRelationTarget, ids: readonly string[], inAxis: (axis: string, id: string) => boolean): {
374
+ axis?: {
375
+ axis: string;
376
+ ids: string[];
377
+ };
378
+ external?: {
379
+ entity: string;
380
+ ids: string[];
381
+ };
382
+ };
347
383
  /** 축 이름 → 서술. 모르는 축이면 `undefined` — 화면은 그것을 "미선언" 으로 낸다(숨기지 않는다). */
348
384
  export declare function axisInfo(axis: string): TwinAxisInfo | undefined;
349
385
  export declare const DOMAIN_SYSTEMS: DomainSystem[];
@@ -96,7 +96,12 @@ export const TWIN_AXES = [
96
96
  { axis: 'orders', label: 'twin.axis.orders', kind: 'instance', source: 'state', historical: true,
97
97
  standardClass: { isa95: 'OperationsRequest', epcis: 'TransactionEvent' }, systems: LOGISTICS },
98
98
  { axis: 'tasks', label: 'twin.axis.tasks', kind: 'instance', source: 'state', historical: true,
99
- standardClass: { isa95: 'SegmentResponse', epcis: 'TransformationEvent' }, systems: LOGISTICS },
99
+ /*
100
+ * No single EPCIS projection. A task's event kind follows its operation: a putaway or a pick is
101
+ * an ObjectEvent, only a transformation (production, kitting) is a TransformationEvent. This used
102
+ * to say `epcis: 'TransformationEvent'` for an axis that spans every logistics system.
103
+ */
104
+ standardClass: { isa95: 'SegmentResponse' }, systems: LOGISTICS },
100
105
  /*
101
106
  * ── 물품이 축이 아니었다 (2026-08-22) ──────────────────────────────────────
102
107
  * 트윈에서 **수가 가장 많은 것**이 물품인데(실측: 엔티티 3,611 중 2,400 · hatio-us 는 2,805) 그것을
@@ -175,8 +180,11 @@ export function tenseOf(r) {
175
180
  }
176
181
  /** 관계 전체 — 지도의 선과 항목의 이웃이 여기서 나온다(화면은 이 목록을 갖지 않는다). */
177
182
  export const TWIN_RELATIONS = [
178
- /* 자리가 속한 구역 — **board 밖**(호스트의 `TwinArea`). 해소는 호스트가 한다. */
179
- { from: 'locations', field: 'parentId', target: { kind: 'external', entity: 'space.area' }, via: 'ops.rel.area', optional: true, tense: 'standing' },
183
+ /*
184
+ * What a location sits in — another location (line ⊃ station, zone ⊃ aisle ⊃ bin) or, when no
185
+ * location has that id, an area of the space (host's `TwinArea`). See `axis-or-external`.
186
+ */
187
+ { from: 'locations', field: 'parentId', target: { kind: 'axis-or-external', axis: 'locations', entity: 'space.area' }, via: 'ops.rel.area', optional: true, tense: 'standing' },
180
188
  /* 자원이 사는 자리 */
181
189
  { from: 'equipment', field: 'homeLocation', target: { kind: 'axis', axis: 'locations' }, via: 'ops.rel.home', optional: true, tense: 'standing' },
182
190
  { from: 'persons', field: 'homeLocation', target: { kind: 'axis', axis: 'locations' }, via: 'ops.rel.home', optional: true, tense: 'standing' },
@@ -310,7 +318,27 @@ export function documentPath(axis) {
310
318
  }
311
319
  /** 이 축에서 나가는 관계 · 이 축으로 들어오는 관계 — 항목 패널의 "이어진 것" 양방향. */
312
320
  export const relationsFrom = (axis) => TWIN_RELATIONS.filter(r => r.from === axis);
313
- export const relationsTo = (axis) => TWIN_RELATIONS.filter(r => r.target.kind === 'axis' && r.target.axis === axis);
321
+ export const relationsTo = (axis) => TWIN_RELATIONS.filter(r => (r.target.kind === 'axis' || r.target.kind === 'axis-or-external') && r.target.axis === axis);
322
+ /**
323
+ * Sorts the ids a relation holds into what they point at.
324
+ *
325
+ * `inAxis(axis, id)` answers "is there an item with this id in that axis" — the caller owns the data,
326
+ * the contract owns the rule. For `axis-or-external` an id found in the axis is an axis item and
327
+ * every other id belongs to the external entity. A `type` target has neither: its values are type
328
+ * keys, not item ids.
329
+ */
330
+ export function splitRelationIds(target, ids, inAxis) {
331
+ if (target.kind === 'axis')
332
+ return { axis: { axis: target.axis, ids: [...ids] } };
333
+ if (target.kind === 'external')
334
+ return { external: { entity: target.entity, ids: [...ids] } };
335
+ if (target.kind === 'axis-or-external') {
336
+ const inside = ids.filter(id => inAxis(target.axis, id));
337
+ const outside = ids.filter(id => !inAxis(target.axis, id));
338
+ return { axis: { axis: target.axis, ids: inside }, external: { entity: target.entity, ids: outside } };
339
+ }
340
+ return {};
341
+ }
314
342
  /** 축 이름 → 서술. 모르는 축이면 `undefined` — 화면은 그것을 "미선언" 으로 낸다(숨기지 않는다). */
315
343
  export function axisInfo(axis) {
316
344
  return TWIN_AXES.find(a => a.axis === axis);
package/dist/epcis.d.ts CHANGED
@@ -153,7 +153,15 @@ export interface QuantityElement {
153
153
  uom?: string;
154
154
  }
155
155
  export interface BizTransactionElement {
156
- type: string;
156
+ /**
157
+ * The kind of document — a CBV business transaction type, or a private URI for a kind CBV does not have.
158
+ *
159
+ * **Optional, as in EPCIS 2.0**: only `bizTransaction` is required. When CBV has no value for the
160
+ * document, leave this out — do not coin one under `urn:epcglobal:cbv:btt:`. That namespace is a
161
+ * closed list (13 values, ref.gs1.org/cbv); this contract once carried `btt:so` and `btt:deliv`,
162
+ * neither of which exists there. `test/cbv-btt-values-exist.test.ts` holds the list.
163
+ */
164
+ type?: string;
157
165
  bizTransaction: string;
158
166
  }
159
167
  export interface LocationRef {
@@ -9,9 +9,30 @@ export declare const BIZSTEP: {
9
9
  readonly replenishing: "urn:epcglobal:cbv:bizstep:replenishing";
10
10
  };
11
11
  export declare const BTT: {
12
+ /** Purchase Order — the document an inbound receipt is made against. */
12
13
  readonly po: "urn:epcglobal:cbv:btt:po";
13
- readonly so: "urn:epcglobal:cbv:btt:so";
14
+ /** Purchase Order Confirmation — the seller's sales order. */
15
+ readonly poc: "urn:epcglobal:cbv:btt:poc";
16
+ /** Despatch Advice (ASN) — announces an inbound delivery; also attached when shipping. */
17
+ readonly desadv: "urn:epcglobal:cbv:btt:desadv";
18
+ /** Receiving Advice — the reply once an inbound receipt is complete. */
19
+ readonly recadv: "urn:epcglobal:cbv:btt:recadv";
20
+ /** Return Merchandise Authorization — what a return is received against. */
21
+ readonly rma: "urn:epcglobal:cbv:btt:rma";
22
+ /** Bill of Lading — the carrier's document, attached when shipping. */
23
+ readonly bol: "urn:epcglobal:cbv:btt:bol";
14
24
  };
25
+ export declare const WMS_ORDER_KIND: {
26
+ /** Expected receipt (ASN). The kernel has no inbound order yet — arrival carries a `po` without one. */
27
+ readonly inbound: "inbound";
28
+ /** Outbound order — what the kernel's sales order is. */
29
+ readonly outbound: "outbound";
30
+ /** Receipt of returned goods. */
31
+ readonly return: "return";
32
+ /** Stock transfer between sites. CBV has no document type for it: carry the id without a type. */
33
+ readonly transfer: "transfer";
34
+ };
35
+ export type WmsOrderKind = (typeof WMS_ORDER_KIND)[keyof typeof WMS_ORDER_KIND];
15
36
  /**
16
37
  * WMS 자리 타입 카탈로그 — 커널이 실제로 키로 쓰는 로케이션 타입(locationByType/slotViews).
17
38
  * 도메인 어휘 SSOT: 호스트·UI 는 이걸 소싱하고 재선언하지 않는다(방언 금지).
@@ -8,10 +8,49 @@ export const BIZSTEP = {
8
8
  shipping: 'urn:epcglobal:cbv:bizstep:shipping',
9
9
  replenishing: 'urn:epcglobal:cbv:bizstep:replenishing'
10
10
  };
11
- // bizTransaction 유형 — CBV btt (§2 "거래" 매핑: PO=입고 ASN, SO=출고 오더)
11
+ /*
12
+ * Business transaction types — CBV btt. Every value here exists at ref.gs1.org/cbv (checked
13
+ * 2026-09-17; `test/cbv-btt-values-exist.test.ts` holds the closed list).
14
+ *
15
+ * `poc` is what the kernel's outbound order carries. The kernel's document is a *sales order*
16
+ * (docKind 'salesorder'), and CBV's own definition of Purchase Order Confirmation reads
17
+ * "Sometimes internally referred to as a 'Sales Order'." There is no `btt:so` — this file used to
18
+ * say there was (ADR-0059 decision 4).
19
+ *
20
+ * A document CBV has no value for (a transfer between sites) carries **no type** — see
21
+ * BizTransactionElement.type.
22
+ */
12
23
  export const BTT = {
24
+ /** Purchase Order — the document an inbound receipt is made against. */
13
25
  po: 'urn:epcglobal:cbv:btt:po',
14
- so: 'urn:epcglobal:cbv:btt:so'
26
+ /** Purchase Order Confirmation — the seller's sales order. */
27
+ poc: 'urn:epcglobal:cbv:btt:poc',
28
+ /** Despatch Advice (ASN) — announces an inbound delivery; also attached when shipping. */
29
+ desadv: 'urn:epcglobal:cbv:btt:desadv',
30
+ /** Receiving Advice — the reply once an inbound receipt is complete. */
31
+ recadv: 'urn:epcglobal:cbv:btt:recadv',
32
+ /** Return Merchandise Authorization — what a return is received against. */
33
+ rma: 'urn:epcglobal:cbv:btt:rma',
34
+ /** Bill of Lading — the carrier's document, attached when shipping. */
35
+ bol: 'urn:epcglobal:cbv:btt:bol'
36
+ };
37
+ /*
38
+ * What an order in a warehouse is for — `OrderState.kind`.
39
+ *
40
+ * The contract leaves `kind` an open string because it is the domain's word. It was written as a
41
+ * literal in the kernel ('outbound') until a second producer appeared (operato-warehouse); two
42
+ * producers with one literal each is how two spellings start (ADR-0059 decision 3).
43
+ * Moves *inside* a warehouse are not orders — they are tasks.
44
+ */
45
+ export const WMS_ORDER_KIND = {
46
+ /** Expected receipt (ASN). The kernel has no inbound order yet — arrival carries a `po` without one. */
47
+ inbound: 'inbound',
48
+ /** Outbound order — what the kernel's sales order is. */
49
+ outbound: 'outbound',
50
+ /** Receipt of returned goods. */
51
+ return: 'return',
52
+ /** Stock transfer between sites. CBV has no document type for it: carry the id without a type. */
53
+ transfer: 'transfer'
15
54
  };
16
55
  /**
17
56
  * WMS 자리 타입 카탈로그 — 커널이 실제로 키로 쓰는 로케이션 타입(locationByType/slotViews).
@@ -6,8 +6,6 @@ export declare const YARD_BIZSTEP: {
6
6
  readonly unloading: "urn:epcglobal:cbv:bizstep:unloading";
7
7
  readonly departing: "urn:epcglobal:cbv:bizstep:departing";
8
8
  };
9
- /** 어포인트먼트/배송 거래 유형(CBV btt). */
10
- export declare const BTT_DELIVERY = "urn:epcglobal:cbv:btt:deliv";
11
9
  /** 트레일러/컨테이너 = GRAI(Global Returnable Asset Identifier, 반납형 자산). */
12
10
  export declare function graiUri(companyPrefix: string, assetType: string, serial: number): string;
13
11
  /** YMS 자리 타입 카탈로그 — 커널이 키로 쓰는 야드 로케이션 타입(locationByType/slotViews/.type). 도메인 SSOT. */
@@ -6,8 +6,11 @@ export const YARD_BIZSTEP = {
6
6
  unloading: 'urn:epcglobal:cbv:bizstep:unloading', // 도크 작업(하차: 트레일러→화물)
7
7
  departing: 'urn:epcglobal:cbv:bizstep:departing' // 게이트-아웃
8
8
  };
9
- /** 어포인트먼트/배송 거래 유형(CBV btt). */
10
- export const BTT_DELIVERY = 'urn:epcglobal:cbv:btt:deliv';
9
+ /*
10
+ * A dock appointment has **no CBV business transaction type** — `btt:deliv`, which this file used to
11
+ * export, does not exist at ref.gs1.org/cbv. The kernel now links the appointment by its id alone
12
+ * (EPCIS 2.0 makes `type` optional). ADR-0059 decision 4.
13
+ */
11
14
  /** 트레일러/컨테이너 = GRAI(Global Returnable Asset Identifier, 반납형 자산). */
12
15
  export function graiUri(companyPrefix, assetType, serial) {
13
16
  return `urn:epc:id:grai:${companyPrefix}.${assetType}.${String(serial).padStart(6, '0')}`;
@@ -21,7 +21,6 @@ var index_exports = {};
21
21
  __export(index_exports, {
22
22
  BIZSTEP: () => BIZSTEP,
23
23
  BTT: () => BTT,
24
- BTT_DELIVERY: () => BTT_DELIVERY,
25
24
  BTT_PRODORDER: () => BTT_PRODORDER,
26
25
  CAPABILITIES: () => CAPABILITIES,
27
26
  CAPABILITY_KEYS: () => CAPABILITY_KEYS,
@@ -84,6 +83,7 @@ __export(index_exports, {
84
83
  WEBHOOK_STATUS: () => WEBHOOK_STATUS,
85
84
  WEBHOOK_TOO_MANY: () => WEBHOOK_TOO_MANY,
86
85
  WMS_LOCATION_TYPES: () => WMS_LOCATION_TYPES,
86
+ WMS_ORDER_KIND: () => WMS_ORDER_KIND,
87
87
  WMS_TYPES: () => WMS_TYPES,
88
88
  YARD_BIZSTEP: () => YARD_BIZSTEP,
89
89
  YMS_LOCATION_TYPES: () => YMS_LOCATION_TYPES,
@@ -221,6 +221,7 @@ __export(index_exports, {
221
221
  rolledThroughputYield: () => rolledThroughputYield,
222
222
  sgtinClass: () => sgtinClass,
223
223
  sgtinUri: () => sgtinUri,
224
+ splitRelationIds: () => splitRelationIds,
224
225
  ssccUri: () => ssccUri,
225
226
  stateFieldsOf: () => stateFieldsOf,
226
227
  subLotIdOf: () => subLotIdOf,
@@ -1265,8 +1266,28 @@ var BIZSTEP = {
1265
1266
  replenishing: "urn:epcglobal:cbv:bizstep:replenishing"
1266
1267
  };
1267
1268
  var BTT = {
1269
+ /** Purchase Order — the document an inbound receipt is made against. */
1268
1270
  po: "urn:epcglobal:cbv:btt:po",
1269
- so: "urn:epcglobal:cbv:btt:so"
1271
+ /** Purchase Order Confirmation — the seller's sales order. */
1272
+ poc: "urn:epcglobal:cbv:btt:poc",
1273
+ /** Despatch Advice (ASN) — announces an inbound delivery; also attached when shipping. */
1274
+ desadv: "urn:epcglobal:cbv:btt:desadv",
1275
+ /** Receiving Advice — the reply once an inbound receipt is complete. */
1276
+ recadv: "urn:epcglobal:cbv:btt:recadv",
1277
+ /** Return Merchandise Authorization — what a return is received against. */
1278
+ rma: "urn:epcglobal:cbv:btt:rma",
1279
+ /** Bill of Lading — the carrier's document, attached when shipping. */
1280
+ bol: "urn:epcglobal:cbv:btt:bol"
1281
+ };
1282
+ var WMS_ORDER_KIND = {
1283
+ /** Expected receipt (ASN). The kernel has no inbound order yet — arrival carries a `po` without one. */
1284
+ inbound: "inbound",
1285
+ /** Outbound order — what the kernel's sales order is. */
1286
+ outbound: "outbound",
1287
+ /** Receipt of returned goods. */
1288
+ return: "return",
1289
+ /** Stock transfer between sites. CBV has no document type for it: carry the id without a type. */
1290
+ transfer: "transfer"
1270
1291
  };
1271
1292
  var WMS_LOCATION_TYPES = ["dock", "storage", "staging", "dock-ship", "vas-station"];
1272
1293
  var WMS_LOCATION_LEVEL = {
@@ -1297,7 +1318,6 @@ var YARD_BIZSTEP = {
1297
1318
  departing: "urn:epcglobal:cbv:bizstep:departing"
1298
1319
  // 게이트-아웃
1299
1320
  };
1300
- var BTT_DELIVERY = "urn:epcglobal:cbv:btt:deliv";
1301
1321
  function graiUri(companyPrefix, assetType, serial) {
1302
1322
  return `urn:epc:id:grai:${companyPrefix}.${assetType}.${String(serial).padStart(6, "0")}`;
1303
1323
  }
@@ -1856,7 +1876,12 @@ var TWIN_AXES = [
1856
1876
  kind: "instance",
1857
1877
  source: "state",
1858
1878
  historical: true,
1859
- standardClass: { isa95: "SegmentResponse", epcis: "TransformationEvent" },
1879
+ /*
1880
+ * No single EPCIS projection. A task's event kind follows its operation: a putaway or a pick is
1881
+ * an ObjectEvent, only a transformation (production, kitting) is a TransformationEvent. This used
1882
+ * to say `epcis: 'TransformationEvent'` for an axis that spans every logistics system.
1883
+ */
1884
+ standardClass: { isa95: "SegmentResponse" },
1860
1885
  systems: LOGISTICS
1861
1886
  },
1862
1887
  /*
@@ -1934,8 +1959,11 @@ function tenseOf(r) {
1934
1959
  return r?.tense;
1935
1960
  }
1936
1961
  var TWIN_RELATIONS = [
1937
- /* 자리가 속한 구역 — **board 밖**(호스트의 `TwinArea`). 해소는 호스트가 한다. */
1938
- { from: "locations", field: "parentId", target: { kind: "external", entity: "space.area" }, via: "ops.rel.area", optional: true, tense: "standing" },
1962
+ /*
1963
+ * What a location sits in — another location (line ⊃ station, zone ⊃ aisle ⊃ bin) or, when no
1964
+ * location has that id, an area of the space (host's `TwinArea`). See `axis-or-external`.
1965
+ */
1966
+ { from: "locations", field: "parentId", target: { kind: "axis-or-external", axis: "locations", entity: "space.area" }, via: "ops.rel.area", optional: true, tense: "standing" },
1939
1967
  /* 자원이 사는 자리 */
1940
1968
  { from: "equipment", field: "homeLocation", target: { kind: "axis", axis: "locations" }, via: "ops.rel.home", optional: true, tense: "standing" },
1941
1969
  { from: "persons", field: "homeLocation", target: { kind: "axis", axis: "locations" }, via: "ops.rel.home", optional: true, tense: "standing" },
@@ -2081,7 +2109,17 @@ function documentPath(axis) {
2081
2109
  return info.path;
2082
2110
  }
2083
2111
  var relationsFrom = (axis) => TWIN_RELATIONS.filter((r) => r.from === axis);
2084
- var relationsTo = (axis) => TWIN_RELATIONS.filter((r) => r.target.kind === "axis" && r.target.axis === axis);
2112
+ var relationsTo = (axis) => TWIN_RELATIONS.filter((r) => (r.target.kind === "axis" || r.target.kind === "axis-or-external") && r.target.axis === axis);
2113
+ function splitRelationIds(target, ids, inAxis) {
2114
+ if (target.kind === "axis") return { axis: { axis: target.axis, ids: [...ids] } };
2115
+ if (target.kind === "external") return { external: { entity: target.entity, ids: [...ids] } };
2116
+ if (target.kind === "axis-or-external") {
2117
+ const inside = ids.filter((id) => inAxis(target.axis, id));
2118
+ const outside = ids.filter((id) => !inAxis(target.axis, id));
2119
+ return { axis: { axis: target.axis, ids: inside }, external: { entity: target.entity, ids: outside } };
2120
+ }
2121
+ return {};
2122
+ }
2085
2123
  function axisInfo(axis) {
2086
2124
  return TWIN_AXES.find((a) => a.axis === axis);
2087
2125
  }
@@ -4592,7 +4630,6 @@ function nonEmpty(value) {
4592
4630
  0 && (module.exports = {
4593
4631
  BIZSTEP,
4594
4632
  BTT,
4595
- BTT_DELIVERY,
4596
4633
  BTT_PRODORDER,
4597
4634
  CAPABILITIES,
4598
4635
  CAPABILITY_KEYS,
@@ -4655,6 +4692,7 @@ function nonEmpty(value) {
4655
4692
  WEBHOOK_STATUS,
4656
4693
  WEBHOOK_TOO_MANY,
4657
4694
  WMS_LOCATION_TYPES,
4695
+ WMS_ORDER_KIND,
4658
4696
  WMS_TYPES,
4659
4697
  YARD_BIZSTEP,
4660
4698
  YMS_LOCATION_TYPES,
@@ -4792,6 +4830,7 @@ function nonEmpty(value) {
4792
4830
  rolledThroughputYield,
4793
4831
  sgtinClass,
4794
4832
  sgtinUri,
4833
+ splitRelationIds,
4795
4834
  ssccUri,
4796
4835
  stateFieldsOf,
4797
4836
  subLotIdOf,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@operato/ops-contract",
3
- "version": "0.9.23",
3
+ "version": "0.9.24",
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",