@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.
- package/README.md +33 -0
- package/dist/actuation.d.ts +1 -0
- package/dist/capability.d.ts +6 -1
- package/dist/capability.js +0 -13
- package/dist/capacity.d.ts +0 -7
- package/dist/capacity.js +6 -123
- package/dist/contract.d.ts +40 -13
- package/dist/contract.js +37 -0
- package/dist/dock-facts.d.ts +73 -0
- package/dist/dock-facts.js +134 -0
- package/dist/domain-definition.d.ts +1 -1
- package/dist/domain-definition.js +2 -2
- package/dist/ems-profile.d.ts +1 -2
- package/dist/ems-profile.js +19 -8
- package/dist/epcis.d.ts +47 -7
- package/dist/epcis.js +56 -3
- package/dist/erp.d.ts +4 -4
- package/dist/gs1.d.ts +27 -0
- package/dist/gs1.js +86 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/dist/material-move.d.ts +124 -0
- package/dist/material-move.js +229 -0
- package/dist/mes-profile.js +1 -1
- package/dist/oee.js +8 -4
- package/dist/operational-attention.d.ts +27 -0
- package/dist/operational-attention.js +95 -15
- package/dist/operational-ingest.js +5 -6
- package/dist/operations-capability.d.ts +1 -8
- package/dist/operations-capability.js +0 -99
- package/dist/order-fold.d.ts +0 -30
- package/dist/order-fold.js +0 -75
- package/dist/party.d.ts +70 -0
- package/dist/party.js +131 -0
- package/dist/records-of-event.d.ts +74 -0
- package/dist/records-of-event.js +129 -0
- package/dist/yield.d.ts +1 -1
- package/dist/yms-profile.d.ts +82 -0
- package/dist/yms-profile.js +88 -0
- package/dist-cjs/index.cjs +705 -208
- package/package.json +12 -3
|
@@ -1,31 +1,3 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* 생산 능력 — **ISA-95 Part 4 `OperationsCapability`**: "이 현장이 어느 구간에 얼마나 할 수 있는가."
|
|
3
|
-
*
|
|
4
|
-
* ── 왜 용량 분석만으로는 부족한가 ────────────────────────────────────────────
|
|
5
|
-
* `capacity.ts` 는 이미 네 축(설비·인원·자산·자리) 정상상태 상한과 병목을 낸다. 그런데 그것은 **비율**
|
|
6
|
-
* 이다(시간당 몇 대). 표준이 게시하라는 것은 **구간의 양**이고, 그 양을 **종류로 구분한다.**
|
|
7
|
-
*
|
|
8
|
-
* 종류가 없으면 답할 수 없는 질문이 있다 — 그리고 그것이 이 개념을 쓰는 가장 흔한 질문이다:
|
|
9
|
-
* **"지금 주문을 더 받을 수 있나."** 상한만 있으면 "시간당 12대" 까지고, 이미 약속한 물량을 빼야
|
|
10
|
-
* 비로소 남은 능력이 나온다.
|
|
11
|
-
*
|
|
12
|
-
* ── 표준의 어휘를 그대로 쓴다 ────────────────────────────────────────────────
|
|
13
|
-
* `CapabilityType` 은 자유 문자열이 아니라 **열거형**이다(B2MML-Common.xsd 대조 완료). 그리고 표준은
|
|
14
|
-
* `Total` 을 **두 갈래**로 쪼갠다:
|
|
15
|
-
*
|
|
16
|
-
* · 과거 — `Total = Used + Unused` (쓴 몫 · 못 쓴 몫)
|
|
17
|
-
* · 미래 — `Total = Committed + Available + Unattainable` (약정 · 가용 · 달성불가)
|
|
18
|
-
*
|
|
19
|
-
* 이 보고서는 **미래 쪽**이다. 과거 쪽은 이미 두 곳에 있다(설비 OEE 의 가동/유휴, 호스트의 구간
|
|
20
|
-
* 가동률) — 우리가 "가동률이 두 벌이다" 로 본 것이 여기서 설명된다: **두 벌인 것이 맞고, 표준이 그
|
|
21
|
-
* 둘을 다른 종류로 부른다.** 합칠 일이 아니라 각자 어느 종류인지 밝힐 일이다.
|
|
22
|
-
*
|
|
23
|
-
* `Unattainable` 의 표준 정의는 우리 판정과 정확히 겹친다 — *설비 상태·설비 점유·인원 가용성·자재
|
|
24
|
-
* 가용성 때문에 앞으로 쓸 수 없는 용량.* 그래서 이 모듈은 그것을 **다시 판정하지 않는다**:
|
|
25
|
-
* 부르는 쪽이 "전량 선언 기준" 과 "지금 쓸 수 있는 자원 기준" 두 벌을 주면, 그 **차이가 곧
|
|
26
|
-
* 달성불가**다(§unattainableOf). 판정은 한 벌이어야 하고 그 한 벌은 `capabilityOf` 다.
|
|
27
|
-
*/
|
|
28
|
-
import { analyzeCapacity } from "./capacity.js";
|
|
29
1
|
import { inWorkCalendarAt } from "./contract.js";
|
|
30
2
|
/**
|
|
31
3
|
* 구간의 **가동 시간** — 1분 간격으로 캘린더에 묻는다.
|
|
@@ -47,74 +19,3 @@ export function workingHoursBetween(calendar, fromMs, toMs, utcOffsetMinutes) {
|
|
|
47
19
|
minutes++;
|
|
48
20
|
return minutes / 60;
|
|
49
21
|
}
|
|
50
|
-
/**
|
|
51
|
-
* 생산 능력 보고서 — 있는 용량 분석 위에 **구간 · 종류 · 약정**을 올린다.
|
|
52
|
-
*
|
|
53
|
-
* 용량 분석을 두 번 부른다(전량 · 가용). 같은 함수를 두 번 부르는 것이 요점이다: 달성불가를 따로
|
|
54
|
-
* 계산하면 규칙이 두 벌이 되고, 두 벌은 어긋난다.
|
|
55
|
-
*/
|
|
56
|
-
export function operationsCapabilityOf(input) {
|
|
57
|
-
const fromMs = Date.parse(input.window.fromTime);
|
|
58
|
-
const toMs = Date.parse(input.window.toTime);
|
|
59
|
-
if (!Number.isFinite(fromMs) || !Number.isFinite(toMs)) {
|
|
60
|
-
throw new Error(`능력의 구간을 읽을 수 없다: ${input.window.fromTime} ~ ${input.window.toTime}`);
|
|
61
|
-
}
|
|
62
|
-
if (toMs <= fromMs)
|
|
63
|
-
throw new Error(`능력의 구간이 뒤집혔다: ${input.window.fromTime} ~ ${input.window.toTime}`);
|
|
64
|
-
const workingHours = workingHoursBetween(input.calendar ?? input.capacity.calendar, fromMs, toMs, input.utcOffsetMinutes);
|
|
65
|
-
const full = analyzeCapacity(input.capacity);
|
|
66
|
-
const usable = input.usableCapacity ? analyzeCapacity(input.usableCapacity) : undefined;
|
|
67
|
-
/** 비율(시간당) → 구간의 양. 상한이 무한(요구가 없는 공정)이면 **모른다**. */
|
|
68
|
-
const amountOf = (perHour) => (Number.isFinite(perHour) ? perHour * workingHours : null);
|
|
69
|
-
const committedOf = (operation) => {
|
|
70
|
-
let sum = 0;
|
|
71
|
-
for (const d of input.demands ?? []) {
|
|
72
|
-
if (d.operation !== undefined && d.operation !== operation)
|
|
73
|
-
continue;
|
|
74
|
-
/* 납기가 없으면 이 구간의 약정이 아니다 — 짐작해서 넣으면 남은 능력이 실제보다 적게 보인다. */
|
|
75
|
-
if (!d.dueTime)
|
|
76
|
-
continue;
|
|
77
|
-
const due = Date.parse(d.dueTime);
|
|
78
|
-
if (!Number.isFinite(due) || due < fromMs || due >= toMs)
|
|
79
|
-
continue;
|
|
80
|
-
sum += Math.max(0, d.remaining);
|
|
81
|
-
}
|
|
82
|
-
return sum;
|
|
83
|
-
};
|
|
84
|
-
const perOperation = full.operations.map(op => {
|
|
85
|
-
const total = amountOf(op.perHour);
|
|
86
|
-
const committed = committedOf(op.operation);
|
|
87
|
-
/*
|
|
88
|
-
* 달성불가 = 전량 기준 − 가용 자원 기준. 자원의 현재 사실을 못 받았으면 **모른다**(0 이 아니다).
|
|
89
|
-
* 음수가 되는 일은 없어야 하지만(가용 ⊆ 전량), 되면 그것을 감추지 않고 0 으로 깎는다 — 부분집합이
|
|
90
|
-
* 아닌 입력을 받은 것이므로 값을 지어내는 대신 아래 `available` 이 어긋남을 드러낸다.
|
|
91
|
-
*/
|
|
92
|
-
let unattainable = null;
|
|
93
|
-
let unattainableBy;
|
|
94
|
-
if (usable) {
|
|
95
|
-
const left = usable.operations.find(o => o.operation === op.operation);
|
|
96
|
-
const usableAmount = amountOf(left?.perHour ?? NaN);
|
|
97
|
-
unattainable = total != null && usableAmount != null ? Math.max(0, total - usableAmount) : null;
|
|
98
|
-
/* 잃은 몫이 있을 때만 원인을 말한다 — 잃은 것이 없는데 "여기부터" 라고 하면 없는 일을 만든다. */
|
|
99
|
-
if (unattainable != null && unattainable > 0 && left?.constraint)
|
|
100
|
-
unattainableBy = left.constraint;
|
|
101
|
-
}
|
|
102
|
-
const available = total == null || unattainable == null ? null : total - committed - unattainable;
|
|
103
|
-
return {
|
|
104
|
-
operation: op.operation,
|
|
105
|
-
total,
|
|
106
|
-
committed,
|
|
107
|
-
unattainable,
|
|
108
|
-
available,
|
|
109
|
-
...(op.constraint ? { constraint: op.constraint } : {}),
|
|
110
|
-
...(unattainableBy ? { unattainableBy } : {})
|
|
111
|
-
};
|
|
112
|
-
});
|
|
113
|
-
return {
|
|
114
|
-
operationsType: input.operationsType ?? 'Production',
|
|
115
|
-
window: { fromTime: input.window.fromTime, toTime: input.window.toTime, workingHours },
|
|
116
|
-
perOperation,
|
|
117
|
-
...(full.bottleneck ? { bottleneck: full.bottleneck } : {}),
|
|
118
|
-
...(input.publishedDate ? { publishedDate: input.publishedDate } : {})
|
|
119
|
-
};
|
|
120
|
-
}
|
package/dist/order-fold.d.ts
CHANGED
|
@@ -48,36 +48,8 @@ export interface FoldedOrders {
|
|
|
48
48
|
*/
|
|
49
49
|
hours?: Record<string, Record<string, Record<string, number>>>;
|
|
50
50
|
}
|
|
51
|
-
export declare function emptyFoldedOrders(): FoldedOrders;
|
|
52
51
|
/** 접힌 오더의 총수 — 서랍의 「끝난 오더 N건」이 읽는다. */
|
|
53
52
|
export declare function foldedOrderCount(folded: FoldedOrders | null | undefined): number;
|
|
54
|
-
/**
|
|
55
|
-
* **이번에 접을 오더** — id 목록을 돌려준다(순서는 오래된 종결부터).
|
|
56
|
-
*
|
|
57
|
-
* · 열린 오더는 접지 않는다(`isOrderTerminal` 한 곳이 판정한다).
|
|
58
|
-
* · 보류(`held`)된 오더는 끝났어도 접지 않는다 — 제어판이 재개하려고 들고 있다.
|
|
59
|
-
* · 종결 시각을 모르는 오더는 접지 않는다 — 언제 끝났는지 지어내지 않는다. 두 구동은 종결을 볼 때 시각을 적는다.
|
|
60
|
-
* · 시간: 종결된 지 `afterMs` 가 지났으면 접는다.
|
|
61
|
-
* · 건수: 그러고도 뜨거운 종결 오더가 `maxTerminal` 보다 많으면 오래된 것부터 더 접는다.
|
|
62
|
-
*/
|
|
63
|
-
export declare function planOrderFold(orders: readonly FoldableOrderView[], nowMs: number, policy?: OrderFoldPolicy): string[];
|
|
64
|
-
/** 접은 오더를 세는 수에 더한다 — 새 값을 돌려준다(들어온 것을 바꾸지 않는다). */
|
|
65
|
-
export declare function foldOrdersInto(folded: FoldedOrders | null | undefined, orders: readonly FoldableOrderView[]): FoldedOrders;
|
|
66
|
-
/**
|
|
67
|
-
* **뜨거운 줄이 없는 오더의 레코드가 새 줄을 세우나.**
|
|
68
|
-
*
|
|
69
|
-
* 폴링 원본은 같은 종결을 다시 보낸다. 접힌 오더의 종결이 다시 오면 줄이 다시 서고 다음 경계에서 또 접혀 세는 수가 두 번
|
|
70
|
-
* 는다. 그래서 **종결 레코드이고, 그 레코드 자신의 시각이 경계보다 이르면** 줄을 세우지 않는다(결정 2).
|
|
71
|
-
*
|
|
72
|
-
* 비교하는 시각은 레코드의 `eventTime` 이다 — 도착 시각으로 재면 늦게 온 정당한 종결이 접힌 것으로 오인된다(판정 조건 1).
|
|
73
|
-
* 종결이 아닌 레코드(재개)는 새 뜨거운 줄이다 — 드물고 맞는 거동이라 막지 않는다. 이미 뜨거운 줄이 있는 오더의 레코드는
|
|
74
|
-
* 이 판정을 지나지 않는다(그것은 그 줄의 갱신이다).
|
|
75
|
-
*/
|
|
76
|
-
export declare function standsNewOrderRow(record: {
|
|
77
|
-
status?: string;
|
|
78
|
-
requested?: number;
|
|
79
|
-
fulfilled?: number;
|
|
80
|
-
}, eventTimeMs: number | undefined, folded: FoldedOrders | null | undefined): boolean;
|
|
81
53
|
/** 그 시각이 든 정시(ms) — 칸의 열쇠는 절대 시각의 정시다(판정 2026-09-24). */
|
|
82
54
|
export declare function hourStartOf(ms: number): number;
|
|
83
55
|
/**
|
|
@@ -88,8 +60,6 @@ export declare function hourStartOf(ms: number): number;
|
|
|
88
60
|
* T 이상 T + 1시간 미만이다.
|
|
89
61
|
*/
|
|
90
62
|
export declare function finishedWindowStartMs(nowMs: number, policy?: OrderFoldPolicy): number;
|
|
91
|
-
/** 창 밖 칸을 버린다 — 접을 때 부른다. 새 값을 돌려준다. */
|
|
92
|
-
export declare function pruneFoldedHours(folded: FoldedOrders, nowMs: number, policy?: OrderFoldPolicy): FoldedOrders;
|
|
93
63
|
/**
|
|
94
64
|
* **최근 T 안에 끝난 흐름 오더의 수** — 씬 오더 상자의 칩이 읽는다(ADR-0092 결정 2 보탬, 판정 2026-09-24).
|
|
95
65
|
*
|
package/dist/order-fold.js
CHANGED
|
@@ -32,9 +32,6 @@ export function orderFoldPolicyOf(declared) {
|
|
|
32
32
|
return { error: 'order fold maxTerminal must be at least 1 (ADR-0092)' };
|
|
33
33
|
return { policy };
|
|
34
34
|
}
|
|
35
|
-
export function emptyFoldedOrders() {
|
|
36
|
-
return { counts: {}, boundaryMs: null };
|
|
37
|
-
}
|
|
38
35
|
/** 접힌 오더의 총수 — 서랍의 「끝난 오더 N건」이 읽는다. */
|
|
39
36
|
export function foldedOrderCount(folded) {
|
|
40
37
|
let n = 0;
|
|
@@ -43,67 +40,6 @@ export function foldedOrderCount(folded) {
|
|
|
43
40
|
n += c;
|
|
44
41
|
return n;
|
|
45
42
|
}
|
|
46
|
-
/**
|
|
47
|
-
* **이번에 접을 오더** — id 목록을 돌려준다(순서는 오래된 종결부터).
|
|
48
|
-
*
|
|
49
|
-
* · 열린 오더는 접지 않는다(`isOrderTerminal` 한 곳이 판정한다).
|
|
50
|
-
* · 보류(`held`)된 오더는 끝났어도 접지 않는다 — 제어판이 재개하려고 들고 있다.
|
|
51
|
-
* · 종결 시각을 모르는 오더는 접지 않는다 — 언제 끝났는지 지어내지 않는다. 두 구동은 종결을 볼 때 시각을 적는다.
|
|
52
|
-
* · 시간: 종결된 지 `afterMs` 가 지났으면 접는다.
|
|
53
|
-
* · 건수: 그러고도 뜨거운 종결 오더가 `maxTerminal` 보다 많으면 오래된 것부터 더 접는다.
|
|
54
|
-
*/
|
|
55
|
-
export function planOrderFold(orders, nowMs, policy = ORDER_FOLD_DEFAULT) {
|
|
56
|
-
const candidates = orders
|
|
57
|
-
.filter(o => isOrderTerminal(o) && !o.held && typeof o.terminalAtMs === 'number' && Number.isFinite(o.terminalAtMs))
|
|
58
|
-
.sort((a, b) => a.terminalAtMs - b.terminalAtMs || (a.id < b.id ? -1 : a.id > b.id ? 1 : 0));
|
|
59
|
-
const cutoff = nowMs - policy.afterMs;
|
|
60
|
-
const byTime = candidates.filter(o => o.terminalAtMs <= cutoff);
|
|
61
|
-
const stay = candidates.length - byTime.length;
|
|
62
|
-
const byCount = stay > policy.maxTerminal ? candidates.slice(byTime.length, byTime.length + (stay - policy.maxTerminal)) : [];
|
|
63
|
-
return [...byTime, ...byCount].map(o => o.id);
|
|
64
|
-
}
|
|
65
|
-
/** 접은 오더를 세는 수에 더한다 — 새 값을 돌려준다(들어온 것을 바꾸지 않는다). */
|
|
66
|
-
export function foldOrdersInto(folded, orders) {
|
|
67
|
-
const out = {
|
|
68
|
-
counts: Object.fromEntries(Object.entries(folded?.counts ?? {}).map(([k, v]) => [k, { ...v }])),
|
|
69
|
-
boundaryMs: folded?.boundaryMs ?? null
|
|
70
|
-
};
|
|
71
|
-
const hours = Object.fromEntries(Object.entries(folded?.hours ?? {}).map(([h, byKind]) => [h, Object.fromEntries(Object.entries(byKind).map(([k, v]) => [k, { ...v }]))]));
|
|
72
|
-
for (const o of orders) {
|
|
73
|
-
const kind = String(o.kind ?? '');
|
|
74
|
-
const status = String(o.status ?? '');
|
|
75
|
-
const byStatus = (out.counts[kind] ??= {});
|
|
76
|
-
byStatus[status] = (byStatus[status] ?? 0) + 1;
|
|
77
|
-
if (typeof o.terminalAtMs === 'number' && Number.isFinite(o.terminalAtMs)) {
|
|
78
|
-
out.boundaryMs = out.boundaryMs === null ? o.terminalAtMs : Math.max(out.boundaryMs, o.terminalAtMs);
|
|
79
|
-
const slot = ((hours[String(hourStartOf(o.terminalAtMs))] ??= {})[kind] ??= {});
|
|
80
|
-
slot[status] = (slot[status] ?? 0) + 1;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
if (Object.keys(hours).length)
|
|
84
|
-
out.hours = hours;
|
|
85
|
-
return out;
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* **뜨거운 줄이 없는 오더의 레코드가 새 줄을 세우나.**
|
|
89
|
-
*
|
|
90
|
-
* 폴링 원본은 같은 종결을 다시 보낸다. 접힌 오더의 종결이 다시 오면 줄이 다시 서고 다음 경계에서 또 접혀 세는 수가 두 번
|
|
91
|
-
* 는다. 그래서 **종결 레코드이고, 그 레코드 자신의 시각이 경계보다 이르면** 줄을 세우지 않는다(결정 2).
|
|
92
|
-
*
|
|
93
|
-
* 비교하는 시각은 레코드의 `eventTime` 이다 — 도착 시각으로 재면 늦게 온 정당한 종결이 접힌 것으로 오인된다(판정 조건 1).
|
|
94
|
-
* 종결이 아닌 레코드(재개)는 새 뜨거운 줄이다 — 드물고 맞는 거동이라 막지 않는다. 이미 뜨거운 줄이 있는 오더의 레코드는
|
|
95
|
-
* 이 판정을 지나지 않는다(그것은 그 줄의 갱신이다).
|
|
96
|
-
*/
|
|
97
|
-
export function standsNewOrderRow(record, eventTimeMs, folded) {
|
|
98
|
-
if (!isOrderTerminal(record))
|
|
99
|
-
return true;
|
|
100
|
-
const boundary = folded?.boundaryMs;
|
|
101
|
-
if (boundary === null || boundary === undefined)
|
|
102
|
-
return true;
|
|
103
|
-
if (typeof eventTimeMs !== 'number' || !Number.isFinite(eventTimeMs))
|
|
104
|
-
return true;
|
|
105
|
-
return eventTimeMs > boundary;
|
|
106
|
-
}
|
|
107
43
|
/** 그 시각이 든 정시(ms) — 칸의 열쇠는 절대 시각의 정시다(판정 2026-09-24). */
|
|
108
44
|
export function hourStartOf(ms) {
|
|
109
45
|
return Math.floor(ms / ORDER_FOLD_HOUR_MS) * ORDER_FOLD_HOUR_MS;
|
|
@@ -118,17 +54,6 @@ export function hourStartOf(ms) {
|
|
|
118
54
|
export function finishedWindowStartMs(nowMs, policy = ORDER_FOLD_DEFAULT) {
|
|
119
55
|
return hourStartOf(nowMs) - policy.afterMs;
|
|
120
56
|
}
|
|
121
|
-
/** 창 밖 칸을 버린다 — 접을 때 부른다. 새 값을 돌려준다. */
|
|
122
|
-
export function pruneFoldedHours(folded, nowMs, policy = ORDER_FOLD_DEFAULT) {
|
|
123
|
-
if (!folded.hours)
|
|
124
|
-
return folded;
|
|
125
|
-
const start = finishedWindowStartMs(nowMs, policy);
|
|
126
|
-
const kept = Object.fromEntries(Object.entries(folded.hours).filter(([h]) => Number(h) >= start));
|
|
127
|
-
const out = { counts: folded.counts, boundaryMs: folded.boundaryMs };
|
|
128
|
-
if (Object.keys(kept).length)
|
|
129
|
-
out.hours = kept;
|
|
130
|
-
return out;
|
|
131
|
-
}
|
|
132
57
|
/**
|
|
133
58
|
* **최근 T 안에 끝난 흐름 오더의 수** — 씬 오더 상자의 칩이 읽는다(ADR-0092 결정 2 보탬, 판정 2026-09-24).
|
|
134
59
|
*
|
package/dist/party.d.ts
ADDED
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { type EpcisEvent, type EpcisHeader } from './epcis.ts';
|
|
2
|
+
import type { CanonicalAggregationRecord, CanonicalRecord, CanonicalTransformationRecord } from './canonical-record.ts';
|
|
3
|
+
/** The three logistics records the twin takes - object observed, contained, transformed. The twin tells them apart by shape. */
|
|
4
|
+
export type TwinRecord = CanonicalRecord | CanonicalAggregationRecord | CanonicalTransformationRecord;
|
|
5
|
+
/**
|
|
6
|
+
* Why an event is not sent as records. "None" and "not sent" are not written as one value: the order's fact
|
|
7
|
+
* (a TransactionEvent) is carried by the order record, and sending it twice would count it twice in the mirror.
|
|
8
|
+
*/
|
|
9
|
+
export type RecordsHeldBack = 'the-order-record-carries-it';
|
|
10
|
+
/**
|
|
11
|
+
* EPCIS fields the canonical records have no place for yet. They are **named, not dropped silently**: the result says which of them
|
|
12
|
+
* the event carried, so a product can tell what the twin will not see (contract review 2026-11-19). A field that would change what
|
|
13
|
+
* the record means is refused instead (`errorDeclaration` - a correction sent as a plain observation would read as a new fact).
|
|
14
|
+
*/
|
|
15
|
+
export declare const FIELDS_NOT_CARRIED: readonly ["ilmd", "sourceList", "destinationList", "persistentDisposition", "sensorElementList", "certificationInfo"];
|
|
16
|
+
export type FieldNotCarried = (typeof FIELDS_NOT_CARRIED)[number];
|
|
17
|
+
/**
|
|
18
|
+
* **The EPCIS header fields the canonical records carry** - the one list (contract content review 2026-11-19). `headerOf` writes
|
|
19
|
+
* exactly these and the three record types declare them; carrying one more (say `sourceList`) is a move from
|
|
20
|
+
* `FIELDS_NOT_CARRIED` to here, plus the field on the record types and the receiver's mapping.
|
|
21
|
+
*/
|
|
22
|
+
export declare const CARRIED_HEADER_FIELDS: readonly ["bizStep", "disposition", "bizTransactionList", "readPoint", "bizLocation"];
|
|
23
|
+
export type CarriedHeaderField = (typeof CARRIED_HEADER_FIELDS)[number];
|
|
24
|
+
/** What the event is and when - the record's own shape and the envelope carry these, not the header. `@context` is JSON-LD's, not a fact. */
|
|
25
|
+
declare const IDENTITY_HEADER_FIELDS: readonly ["@context", "type", "eventID", "eventTime", "eventTimeZoneOffset", "recordTime"];
|
|
26
|
+
/** Refused rather than sent: it would change what the record means (`correction-not-shaped`). */
|
|
27
|
+
declare const REFUSED_HEADER_FIELDS: readonly ["errorDeclaration"];
|
|
28
|
+
type ListedHeaderField = CarriedHeaderField | FieldNotCarried | (typeof IDENTITY_HEADER_FIELDS)[number] | (typeof REFUSED_HEADER_FIELDS)[number];
|
|
29
|
+
type UnlistedHeaderField = Exclude<keyof EpcisHeader, ListedHeaderField>;
|
|
30
|
+
type NotAHeaderField = Exclude<ListedHeaderField, keyof EpcisHeader>;
|
|
31
|
+
type MissingOnRecords = Exclude<CarriedHeaderField, keyof CanonicalRecord & keyof CanonicalAggregationRecord & keyof CanonicalTransformationRecord>;
|
|
32
|
+
export declare const HEADER_FIELDS_PARTITIONED: [UnlistedHeaderField, NotAHeaderField, MissingOnRecords] extends [never, never, never] ? true : never;
|
|
33
|
+
export interface RecordsOfEvent {
|
|
34
|
+
records: TwinRecord[];
|
|
35
|
+
heldBack?: RecordsHeldBack;
|
|
36
|
+
/** The fields this event carried that the records leave out - absent when none. */
|
|
37
|
+
notCarried?: FieldNotCarried[];
|
|
38
|
+
}
|
|
39
|
+
export type RecordShapeRefusal = 'nothing-observed' | 'quantity-across-many-units' | 'event-type-not-shaped' | 'correction-not-shaped' | 'event-invalid';
|
|
40
|
+
/** Why an event cannot be shaped - an `Error` with a `code` and its `params`. A product turns it into its own refusal. */
|
|
41
|
+
export interface RecordShapeError extends Error {
|
|
42
|
+
code: RecordShapeRefusal;
|
|
43
|
+
params: Record<string, unknown>;
|
|
44
|
+
}
|
|
45
|
+
/** Is this the shaping's refusal? */
|
|
46
|
+
export declare function isRecordShapeError(error: unknown): error is RecordShapeError;
|
|
47
|
+
/**
|
|
48
|
+
* One event as canonical records.
|
|
49
|
+
*
|
|
50
|
+
* Quantities go as the absolute remainder, as the contract says ("so much is left", not "so much was taken") - a lost
|
|
51
|
+
* event is corrected by the next. An event that carries one quantity over several units has not said whose it is: put on
|
|
52
|
+
* both it doubles, dropped it vanishes - so it is refused.
|
|
53
|
+
*/
|
|
54
|
+
export declare function recordsOfEvent(event: EpcisEvent): RecordsOfEvent;
|
|
55
|
+
/** A stored ledger row, as far as the outbox needs it. */
|
|
56
|
+
export interface StoredLedgerEvent {
|
|
57
|
+
eventId: string;
|
|
58
|
+
eventTime: string;
|
|
59
|
+
payload: object;
|
|
60
|
+
}
|
|
61
|
+
/** One input for the outbox machine - the machine adds the number and the time it was written. */
|
|
62
|
+
export interface TwinOutboxInput {
|
|
63
|
+
record: TwinRecord;
|
|
64
|
+
eventId: string;
|
|
65
|
+
eventTime: Date;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* A stored event as outbox inputs. When one event becomes several records **each gets its own idempotency key**
|
|
69
|
+
* (`<eventId>#<n>`): the receiver drops a second line with a key it has seen, so one key on two lines would lose the
|
|
70
|
+
* second silently. The record carries no time - the envelope does (a record with a field the contract lacks is refused
|
|
71
|
+
* whole).
|
|
72
|
+
*/
|
|
73
|
+
export declare function outboxInputsOfEvent(row: StoredLedgerEvent): TwinOutboxInput[];
|
|
74
|
+
export {};
|