@operato/ops-contract 0.9.44 → 0.9.45
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/dist/dock-facts.d.ts +22 -1
- package/dist/dock-facts.js +34 -1
- package/dist-cjs/index.cjs +24 -0
- package/package.json +1 -1
package/dist/dock-facts.d.ts
CHANGED
|
@@ -4,6 +4,11 @@ export declare const DOCK_FACT_KIND: {
|
|
|
4
4
|
readonly slotRequest: "slot-request";
|
|
5
5
|
/** warehouse → yard: the order no longer needs it. */
|
|
6
6
|
readonly slotWithdrawn: "slot-withdrawn";
|
|
7
|
+
/**
|
|
8
|
+
* warehouse → yard: these logistic units (SSCC) came off or went onto the trailer at the door, as the warehouse received or
|
|
9
|
+
* shipped them (ADR-0210 decision 2, 2026-11-20) - the yard records the unloading or loading against the appointment's trailer.
|
|
10
|
+
*/
|
|
11
|
+
readonly cargo: "cargo";
|
|
7
12
|
/** yard → warehouse: the appointment for a request, as it stands now - booked, moved, cancelled, at the door, done. */
|
|
8
13
|
readonly appointment: "appointment";
|
|
9
14
|
/** yard → warehouse: the yard will not book this request, and why. */
|
|
@@ -39,6 +44,22 @@ export interface SlotWithdrawnFact {
|
|
|
39
44
|
request: string;
|
|
40
45
|
reason?: string;
|
|
41
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* **The units that crossed the door** - what the warehouse received (`appointment`, unloading) or shipped (`appointment-out`,
|
|
49
|
+
* loading) for an order the yard booked. The time is the warehouse's scan, which may differ from the moment the unit left or
|
|
50
|
+
* entered the trailer; the yard records it as it comes. The yard does not count - the units are the warehouse's.
|
|
51
|
+
*/
|
|
52
|
+
export interface CargoDockFact {
|
|
53
|
+
factId: string;
|
|
54
|
+
kind: typeof DOCK_FACT_KIND.cargo;
|
|
55
|
+
/** The warehouse order - the yard finds the appointment and its trailer through the order's requests. */
|
|
56
|
+
order: string;
|
|
57
|
+
direction: DockDirection;
|
|
58
|
+
/** The logistic units, SSCC URIs (`urn:epc:id:sscc:…`), each once; never empty. */
|
|
59
|
+
units: string[];
|
|
60
|
+
/** When the warehouse scanned them - an instant with its offset. */
|
|
61
|
+
eventTime: string;
|
|
62
|
+
}
|
|
42
63
|
export interface AppointmentDockFact {
|
|
43
64
|
factId: string;
|
|
44
65
|
kind: typeof DOCK_FACT_KIND.appointment;
|
|
@@ -62,7 +83,7 @@ export interface SlotDeclinedFact {
|
|
|
62
83
|
order: string;
|
|
63
84
|
reason: string;
|
|
64
85
|
}
|
|
65
|
-
export type DockFact = SlotRequestFact | SlotWithdrawnFact | AppointmentDockFact | SlotDeclinedFact;
|
|
86
|
+
export type DockFact = SlotRequestFact | SlotWithdrawnFact | CargoDockFact | AppointmentDockFact | SlotDeclinedFact;
|
|
66
87
|
/** Whether a record on a stream is a dock fact (the warehouse's door also takes the plant's lot statuses and moves). */
|
|
67
88
|
export declare function isDockRecord(record: unknown): boolean;
|
|
68
89
|
/** **Read one record as a dock fact, or say why not.** The receiver passes the kinds it takes. */
|
package/dist/dock-facts.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { isIsoDateTime } from "./epcis.js";
|
|
2
|
+
import { ssccDigitsOf } from "./gs1.js";
|
|
2
3
|
import { isYmsAppointmentStatus, YMS_APPOINTMENT_CANCEL_REASON, YMS_ORDER_KIND } from "./yms-profile.js";
|
|
3
4
|
/*
|
|
4
5
|
* **The dock between the yard and the warehouse** - the facts the two apps send each other about a slot at a door
|
|
@@ -15,7 +16,7 @@ import { isYmsAppointmentStatus, YMS_APPOINTMENT_CANCEL_REASON, YMS_ORDER_KIND }
|
|
|
15
16
|
* The direction is the yard's order kind on purpose - `appointment` (unloading) or `appointment-out` (loading) is what the
|
|
16
17
|
* appointment will be, so the yard books what it is told without a second word to map.
|
|
17
18
|
*
|
|
18
|
-
* warehouse → yard slot-request · slot-withdrawn
|
|
19
|
+
* warehouse → yard slot-request · slot-withdrawn · cargo
|
|
19
20
|
* yard → warehouse appointment (where the appointment for a request stands now) · slot-declined
|
|
20
21
|
*/
|
|
21
22
|
export const DOCK_FACT_KIND = {
|
|
@@ -23,6 +24,11 @@ export const DOCK_FACT_KIND = {
|
|
|
23
24
|
slotRequest: 'slot-request',
|
|
24
25
|
/** warehouse → yard: the order no longer needs it. */
|
|
25
26
|
slotWithdrawn: 'slot-withdrawn',
|
|
27
|
+
/**
|
|
28
|
+
* warehouse → yard: these logistic units (SSCC) came off or went onto the trailer at the door, as the warehouse received or
|
|
29
|
+
* shipped them (ADR-0210 decision 2, 2026-11-20) - the yard records the unloading or loading against the appointment's trailer.
|
|
30
|
+
*/
|
|
31
|
+
cargo: 'cargo',
|
|
26
32
|
/** yard → warehouse: the appointment for a request, as it stands now - booked, moved, cancelled, at the door, done. */
|
|
27
33
|
appointment: 'appointment',
|
|
28
34
|
/** yard → warehouse: the yard will not book this request, and why. */
|
|
@@ -89,6 +95,33 @@ export function dockFactOf(record, takes) {
|
|
|
89
95
|
return { errors };
|
|
90
96
|
return { fact: { factId: s('factId'), kind, request: s('request'), ...(text('reason') ? { reason: s('reason') } : {}) } };
|
|
91
97
|
}
|
|
98
|
+
case DOCK_FACT_KIND.cargo: {
|
|
99
|
+
if (!text('order'))
|
|
100
|
+
errors.push('order is missing: cargo names the warehouse order');
|
|
101
|
+
if (!Object.values(YMS_ORDER_KIND).includes(r.direction))
|
|
102
|
+
errors.push(`direction must be ${Object.values(YMS_ORDER_KIND).join(' or ')}`);
|
|
103
|
+
if (!isInstant(r.eventTime))
|
|
104
|
+
errors.push('eventTime is not an instant');
|
|
105
|
+
const units = r.units;
|
|
106
|
+
if (!Array.isArray(units) || !units.length)
|
|
107
|
+
errors.push('units is empty: cargo names the logistic units that crossed the door');
|
|
108
|
+
else
|
|
109
|
+
for (const unit of units)
|
|
110
|
+
if (typeof unit !== 'string' || !ssccDigitsOf(unit.trim()))
|
|
111
|
+
errors.push(`${String(unit)} is not an SSCC`);
|
|
112
|
+
if (errors.length)
|
|
113
|
+
return { errors };
|
|
114
|
+
return {
|
|
115
|
+
fact: {
|
|
116
|
+
factId: s('factId'),
|
|
117
|
+
kind,
|
|
118
|
+
order: s('order'),
|
|
119
|
+
direction: r.direction,
|
|
120
|
+
units: [...new Set(units.map(unit => unit.trim()))],
|
|
121
|
+
eventTime: r.eventTime
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
}
|
|
92
125
|
case DOCK_FACT_KIND.appointment: {
|
|
93
126
|
for (const key of ['request', 'order', 'appointment', 'dockDoor'])
|
|
94
127
|
if (!text(key))
|
package/dist-cjs/index.cjs
CHANGED
|
@@ -5732,6 +5732,11 @@ var DOCK_FACT_KIND = {
|
|
|
5732
5732
|
slotRequest: "slot-request",
|
|
5733
5733
|
/** warehouse → yard: the order no longer needs it. */
|
|
5734
5734
|
slotWithdrawn: "slot-withdrawn",
|
|
5735
|
+
/**
|
|
5736
|
+
* warehouse → yard: these logistic units (SSCC) came off or went onto the trailer at the door, as the warehouse received or
|
|
5737
|
+
* shipped them (ADR-0210 decision 2, 2026-11-20) - the yard records the unloading or loading against the appointment's trailer.
|
|
5738
|
+
*/
|
|
5739
|
+
cargo: "cargo",
|
|
5735
5740
|
/** yard → warehouse: the appointment for a request, as it stands now - booked, moved, cancelled, at the door, done. */
|
|
5736
5741
|
appointment: "appointment",
|
|
5737
5742
|
/** yard → warehouse: the yard will not book this request, and why. */
|
|
@@ -5780,6 +5785,25 @@ function dockFactOf(record, takes) {
|
|
|
5780
5785
|
if (errors.length) return { errors };
|
|
5781
5786
|
return { fact: { factId: s("factId"), kind, request: s("request"), ...text("reason") ? { reason: s("reason") } : {} } };
|
|
5782
5787
|
}
|
|
5788
|
+
case DOCK_FACT_KIND.cargo: {
|
|
5789
|
+
if (!text("order")) errors.push("order is missing: cargo names the warehouse order");
|
|
5790
|
+
if (!Object.values(YMS_ORDER_KIND).includes(r.direction)) errors.push(`direction must be ${Object.values(YMS_ORDER_KIND).join(" or ")}`);
|
|
5791
|
+
if (!isInstant(r.eventTime)) errors.push("eventTime is not an instant");
|
|
5792
|
+
const units = r.units;
|
|
5793
|
+
if (!Array.isArray(units) || !units.length) errors.push("units is empty: cargo names the logistic units that crossed the door");
|
|
5794
|
+
else for (const unit of units) if (typeof unit !== "string" || !ssccDigitsOf(unit.trim())) errors.push(`${String(unit)} is not an SSCC`);
|
|
5795
|
+
if (errors.length) return { errors };
|
|
5796
|
+
return {
|
|
5797
|
+
fact: {
|
|
5798
|
+
factId: s("factId"),
|
|
5799
|
+
kind,
|
|
5800
|
+
order: s("order"),
|
|
5801
|
+
direction: r.direction,
|
|
5802
|
+
units: [...new Set(units.map((unit) => unit.trim()))],
|
|
5803
|
+
eventTime: r.eventTime
|
|
5804
|
+
}
|
|
5805
|
+
};
|
|
5806
|
+
}
|
|
5783
5807
|
case DOCK_FACT_KIND.appointment: {
|
|
5784
5808
|
for (const key of ["request", "order", "appointment", "dockDoor"]) if (!text(key)) errors.push(`${key} is missing`);
|
|
5785
5809
|
if (!isYmsAppointmentStatus(r.status)) errors.push(`status ${String(r.status)} is not an appointment status`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@operato/ops-contract",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.45",
|
|
4
4
|
"description": "Operations domain contract — what producers and readers agree on: the standard vocabulary (EPCIS 2.0/GS1, ISA-95, IEC 61850/ISO 50001) and the records operations products exchange with the twin and with each other. Types, guards, validation. No state, no engine.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist-cjs/index.cjs",
|