@operato/ops-contract 0.9.40 → 0.9.42

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,50 @@
1
+ import type { MaterialLotUse } from './contract.ts';
2
+ import type { EpcisEvent } from './epcis.ts';
3
+ /** 계보 한 줄 — 나온 로트와, 들어간 로트 하나. 둘 다 클래스 식별자다. */
4
+ export interface LotLineageEdge {
5
+ lot: string;
6
+ input: string;
7
+ }
8
+ /**
9
+ * 변환 사건 하나가 말하는 계보 줄. 변환이 아닌 사건은 계보를 말하지 않는다(빈 목록).
10
+ *
11
+ * - 다 쓴 입력은 **단위**로 온다(`inputEPCList`). 그 단위가 무슨 로트였는지는 사건이 아니라 그 단위를 든 쪽(재고)이
12
+ * 안다 — `classOfUnit` 으로 묻는다. 모르면 그 줄은 없다(지어내지 않는다).
13
+ * - 일부만 쓴 입력은 이미 클래스다(`inputQuantityList`).
14
+ * - 나온 로트는 `outputQuantityList` 의 클래스다. 산출 단위만 있고 클래스가 없으면 무엇이 생겼는지 말할 수 없다.
15
+ * - 같은 로트가 들어가고 나오면(재작업) 자기 자신에게 잇지 않는다.
16
+ */
17
+ export declare function lotLineageOf(event: EpcisEvent, classOfUnit: (epc: string) => string | undefined): LotLineageEdge[];
18
+ /** 한 로트에 대해 아는 것 — 주인의 말이거나, 입력에서 물려받은 것. */
19
+ export interface InheritedLotUse {
20
+ use: MaterialLotUse;
21
+ /** 주인의 낱말 — 이 로트의 것이거나, 보류를 물려준 입력의 것. 입력이 전부 `allowed` 라 지어 낸 답이면 없다. */
22
+ status?: string;
23
+ /** 이 말이 이 로트의 것이 아니면, 물려준 입력 로트. */
24
+ from?: string;
25
+ }
26
+ /**
27
+ * 한 로트를 쓸 수 있나 — 무엇으로 만들어졌는지를 걸어서.
28
+ *
29
+ * ```
30
+ * 주인이 이 로트를 막았다 blocked — 자기 말
31
+ * 입력 하나(어느 깊이든)가 막혔다 blocked — 그 입력의 말과, 어느 입력인지
32
+ * 주인이 다른 말을 했다 그 말
33
+ * 입력이 있고 전부 allowed allowed — 지어 낸 답, 주인의 낱말 없음
34
+ * 그 밖 undefined — 모름. allowed 로 읽지 않는다
35
+ * ```
36
+ *
37
+ * 막힘이 주인의 `allowed` 보다 앞선다 — 주인은 이 로트를 낳을 때의 입력을 모를 수 있고, 그 입력이 뒤에 막혔을 수 있다.
38
+ * 기록된 순환(같은 길에서 이미 지난 로트)은 다시 걷지 않는다 — 더 말하는 것이 없다.
39
+ */
40
+ export declare function inheritedLotUse(lot: string, said: ReadonlyMap<string, {
41
+ use: string;
42
+ status: string;
43
+ }>, inputsOf: ReadonlyMap<string, readonly string[]>, seen?: ReadonlySet<string>): InheritedLotUse | undefined;
44
+ /**
45
+ * 변환이 만든 로트의 기한 — 입력 기한 중 **가장 이른 것.** 산출은 가장 먼저 지나는 입력과 함께 지난다.
46
+ *
47
+ * 기한을 모르는 입력은 한계를 더하지 않는다(그 입력이 기한을 말하지 않은 것과 같다). 아무 입력도 기한이 없으면
48
+ * 산출도 없다 — 「지금」이나 0 으로 메우지 않는다(§`expiryFromAttributes` 와 같은 규율). 값은 밀리초다.
49
+ */
50
+ export declare function inheritedExpiry(inputExpiries: readonly (number | undefined | null)[]): number | undefined;
@@ -0,0 +1,76 @@
1
+ /**
2
+ * 변환 사건 하나가 말하는 계보 줄. 변환이 아닌 사건은 계보를 말하지 않는다(빈 목록).
3
+ *
4
+ * - 다 쓴 입력은 **단위**로 온다(`inputEPCList`). 그 단위가 무슨 로트였는지는 사건이 아니라 그 단위를 든 쪽(재고)이
5
+ * 안다 — `classOfUnit` 으로 묻는다. 모르면 그 줄은 없다(지어내지 않는다).
6
+ * - 일부만 쓴 입력은 이미 클래스다(`inputQuantityList`).
7
+ * - 나온 로트는 `outputQuantityList` 의 클래스다. 산출 단위만 있고 클래스가 없으면 무엇이 생겼는지 말할 수 없다.
8
+ * - 같은 로트가 들어가고 나오면(재작업) 자기 자신에게 잇지 않는다.
9
+ */
10
+ export function lotLineageOf(event, classOfUnit) {
11
+ if (event.type !== 'TransformationEvent')
12
+ return [];
13
+ const inputs = new Set();
14
+ for (const epc of event.inputEPCList ?? []) {
15
+ const lot = classOfUnit(epc);
16
+ if (lot)
17
+ inputs.add(lot);
18
+ }
19
+ for (const one of event.inputQuantityList ?? [])
20
+ if (one.epcClass)
21
+ inputs.add(one.epcClass);
22
+ const edges = [];
23
+ for (const lot of new Set((event.outputQuantityList ?? []).map(one => one.epcClass).filter(Boolean))) {
24
+ for (const input of inputs)
25
+ if (input !== lot)
26
+ edges.push({ lot, input });
27
+ }
28
+ return edges;
29
+ }
30
+ /**
31
+ * 한 로트를 쓸 수 있나 — 무엇으로 만들어졌는지를 걸어서.
32
+ *
33
+ * ```
34
+ * 주인이 이 로트를 막았다 blocked — 자기 말
35
+ * 입력 하나(어느 깊이든)가 막혔다 blocked — 그 입력의 말과, 어느 입력인지
36
+ * 주인이 다른 말을 했다 그 말
37
+ * 입력이 있고 전부 allowed allowed — 지어 낸 답, 주인의 낱말 없음
38
+ * 그 밖 undefined — 모름. allowed 로 읽지 않는다
39
+ * ```
40
+ *
41
+ * 막힘이 주인의 `allowed` 보다 앞선다 — 주인은 이 로트를 낳을 때의 입력을 모를 수 있고, 그 입력이 뒤에 막혔을 수 있다.
42
+ * 기록된 순환(같은 길에서 이미 지난 로트)은 다시 걷지 않는다 — 더 말하는 것이 없다.
43
+ */
44
+ export function inheritedLotUse(lot, said, inputsOf, seen = new Set()) {
45
+ const own = said.get(lot);
46
+ if (own?.use === 'blocked')
47
+ return { use: 'blocked', status: own.status };
48
+ const along = new Set([...seen, lot]);
49
+ const words = (inputsOf.get(lot) ?? [])
50
+ .filter(input => !along.has(input))
51
+ .map(input => ({ input, word: inheritedLotUse(input, said, inputsOf, along) }));
52
+ const blocked = words.find(({ word }) => word?.use === 'blocked');
53
+ if (blocked)
54
+ return { use: 'blocked', ...(blocked.word.status !== undefined ? { status: blocked.word.status } : {}), from: blocked.word.from ?? blocked.input };
55
+ if (own?.use === 'allowed')
56
+ return { use: 'allowed', status: own.status };
57
+ if (!own && words.length && words.every(({ word }) => word?.use === 'allowed'))
58
+ return { use: 'allowed' };
59
+ return undefined;
60
+ }
61
+ /**
62
+ * 변환이 만든 로트의 기한 — 입력 기한 중 **가장 이른 것.** 산출은 가장 먼저 지나는 입력과 함께 지난다.
63
+ *
64
+ * 기한을 모르는 입력은 한계를 더하지 않는다(그 입력이 기한을 말하지 않은 것과 같다). 아무 입력도 기한이 없으면
65
+ * 산출도 없다 — 「지금」이나 0 으로 메우지 않는다(§`expiryFromAttributes` 와 같은 규율). 값은 밀리초다.
66
+ */
67
+ export function inheritedExpiry(inputExpiries) {
68
+ let earliest;
69
+ for (const at of inputExpiries) {
70
+ if (typeof at !== 'number' || !Number.isFinite(at))
71
+ continue;
72
+ if (earliest === undefined || at < earliest)
73
+ earliest = at;
74
+ }
75
+ return earliest;
76
+ }
@@ -41,6 +41,26 @@ export declare const BTT: {
41
41
  /** Bill of Lading — the carrier's document, attached when shipping. */
42
42
  readonly bol: "urn:epcglobal:cbv:btt:bol";
43
43
  };
44
+ /**
45
+ * **Goods going back to their supplier** (return to vendor) — the CBV words, read in the CBV ontology itself (gs1/EPCIS
46
+ * `Ontology/CBV.ttl`, versionInfo 2.0, 2026-10-23), before any document of that kind was built (operato-application
47
+ * ADR-0154 decision 2, chief architect: the vocabulary first).
48
+ *
49
+ * - **Step: `shipping`.** CBV has no returning step. Of its 41 steps, the one for goods leaving to another party is
50
+ * `shipping` ("the overall process of staging_outbound, loading and departing … a final event from a shipping
51
+ * point"); where they go is the destination, not the step.
52
+ * - **Disposition: `returned`** — "Object has been sent or brought back for various reasons. It may or may not be
53
+ * sellable." Not `in_transit` (between two trading partners, said of goods on their way to be received) and not
54
+ * `disposed` (returned for disposal - a supplier that destroys them says so itself).
55
+ * - **Document: `rma`** — "A document issued by the seller that authorises a buyer to return merchandise". In a return
56
+ * to supplier the warehouse is the buyer and the supplier issues it - the same document a customer's return comes in
57
+ * under, seen from the other side.
58
+ */
59
+ export declare const RETURN_TO_SUPPLIER: {
60
+ readonly bizStep: "urn:epcglobal:cbv:bizstep:shipping";
61
+ readonly disposition: "urn:epcglobal:cbv:disp:returned";
62
+ readonly bizTransactionType: "urn:epcglobal:cbv:btt:rma";
63
+ };
44
64
  export declare const WMS_ORDER_KIND: {
45
65
  /**
46
66
  * Expected receipt (ASN) — what was promised to arrive, and how much of it has.
@@ -1,3 +1,4 @@
1
+ import { DISP } from "./epcis.js";
1
2
  // bizStep — CBV URN (wms.md §11 확정 어휘)
2
3
  export const BIZSTEP = {
3
4
  receiving: 'urn:epcglobal:cbv:bizstep:receiving',
@@ -53,6 +54,26 @@ export const BTT = {
53
54
  /** Bill of Lading — the carrier's document, attached when shipping. */
54
55
  bol: 'urn:epcglobal:cbv:btt:bol'
55
56
  };
57
+ /**
58
+ * **Goods going back to their supplier** (return to vendor) — the CBV words, read in the CBV ontology itself (gs1/EPCIS
59
+ * `Ontology/CBV.ttl`, versionInfo 2.0, 2026-10-23), before any document of that kind was built (operato-application
60
+ * ADR-0154 decision 2, chief architect: the vocabulary first).
61
+ *
62
+ * - **Step: `shipping`.** CBV has no returning step. Of its 41 steps, the one for goods leaving to another party is
63
+ * `shipping` ("the overall process of staging_outbound, loading and departing … a final event from a shipping
64
+ * point"); where they go is the destination, not the step.
65
+ * - **Disposition: `returned`** — "Object has been sent or brought back for various reasons. It may or may not be
66
+ * sellable." Not `in_transit` (between two trading partners, said of goods on their way to be received) and not
67
+ * `disposed` (returned for disposal - a supplier that destroys them says so itself).
68
+ * - **Document: `rma`** — "A document issued by the seller that authorises a buyer to return merchandise". In a return
69
+ * to supplier the warehouse is the buyer and the supplier issues it - the same document a customer's return comes in
70
+ * under, seen from the other side.
71
+ */
72
+ export const RETURN_TO_SUPPLIER = {
73
+ bizStep: BIZSTEP.shipping,
74
+ disposition: DISP.returned,
75
+ bizTransactionType: BTT.rma
76
+ };
56
77
  /*
57
78
  * What an order in a warehouse is for — `OrderState.kind`.
58
79
  *