@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.
@@ -21,12 +21,14 @@ var index_exports = {};
21
21
  __export(index_exports, {
22
22
  ABSENCE: () => ABSENCE,
23
23
  ALLOCATION_POLICY: () => ALLOCATION_POLICY,
24
+ ASSET_STATUS: () => ASSET_STATUS,
24
25
  BASIS_UNKNOWN: () => BASIS_UNKNOWN,
25
26
  BIZSTEP: () => BIZSTEP,
26
27
  BTT: () => BTT,
27
28
  BTT_PRODORDER: () => BTT_PRODORDER,
28
29
  CAPABILITIES: () => CAPABILITIES,
29
30
  CAPABILITY_KEYS: () => CAPABILITY_KEYS,
31
+ CARRIED_HEADER_FIELDS: () => CARRIED_HEADER_FIELDS,
30
32
  CBV_BIZSTEP: () => CBV_BIZSTEP,
31
33
  CMD: () => CMD,
32
34
  COMMAND_EVENT: () => COMMAND_EVENT,
@@ -34,6 +36,8 @@ __export(index_exports, {
34
36
  COMMAND_STATE: () => COMMAND_STATE,
35
37
  DISP: () => DISP,
36
38
  DISPOSITION_DECISION: () => DISPOSITION_DECISION,
39
+ DOCK_DOOR_STATUS: () => DOCK_DOOR_STATUS,
40
+ DOCK_FACT_KIND: () => DOCK_FACT_KIND,
37
41
  DOMAIN_CATALOG: () => DOMAIN_CATALOG,
38
42
  DOMAIN_SYSTEMS: () => DOMAIN_SYSTEMS,
39
43
  EMPTY_BECAUSE: () => EMPTY_BECAUSE,
@@ -49,9 +53,11 @@ __export(index_exports, {
49
53
  EQUIPMENT_STATUS: () => EQUIPMENT_STATUS,
50
54
  ERP_CAPABILITY: () => ERP_CAPABILITY,
51
55
  ERP_MASTER_AXIS: () => ERP_MASTER_AXIS,
56
+ FIELDS_NOT_CARRIED: () => FIELDS_NOT_CARRIED,
52
57
  FIRST_PASS_RULE: () => FIRST_PASS_RULE,
53
58
  GUARD_PRAGMA: () => GUARD_PRAGMA,
54
59
  HATIOLAB_VOCABULARY: () => HATIOLAB_VOCABULARY,
60
+ HEADER_FIELDS_PARTITIONED: () => HEADER_FIELDS_PARTITIONED,
55
61
  ILMD_ATTR: () => ILMD_ATTR,
56
62
  LOCATION_SATURATION_NEAR: () => LOCATION_SATURATION_NEAR,
57
63
  MATERIAL_ACTUAL_USE: () => MATERIAL_ACTUAL_USE,
@@ -62,24 +68,35 @@ __export(index_exports, {
62
68
  MES_LOCATION_TYPES: () => MES_LOCATION_TYPES,
63
69
  MES_TYPES: () => MES_TYPES,
64
70
  METER_DIRECTION: () => METER_DIRECTION,
71
+ MOVE_KIND: () => MOVE_KIND,
65
72
  OBSERVATION_BASIS: () => OBSERVATION_BASIS,
66
73
  OPERATIONAL_ATTENTION_CONTRACT: () => OPERATIONAL_ATTENTION_CONTRACT,
67
74
  OPERATIONAL_ATTENTION_IMPACTS: () => OPERATIONAL_ATTENTION_IMPACTS,
75
+ OPERATIONAL_ATTENTION_KIND_PATTERN: () => OPERATIONAL_ATTENTION_KIND_PATTERN,
68
76
  OPERATIONAL_ATTENTION_TRANSITIONS: () => OPERATIONAL_ATTENTION_TRANSITIONS,
69
77
  OP_EVENT: () => OP_EVENT,
70
78
  OP_PARAM: () => OP_PARAM,
71
79
  ORDER_FOLD_DEFAULT: () => ORDER_FOLD_DEFAULT,
72
80
  ORDER_FOLD_HOUR_MS: () => ORDER_FOLD_HOUR_MS,
73
81
  ORDER_TERMINAL_STATUS: () => ORDER_TERMINAL_STATUS,
82
+ PARTY_ROLE: () => PARTY_ROLE,
83
+ PARTY_URI_MAX_LENGTH: () => PARTY_URI_MAX_LENGTH,
84
+ PARTY_URI_RECOMMENDED_LENGTH: () => PARTY_URI_RECOMMENDED_LENGTH,
85
+ PERSON_STATUS: () => PERSON_STATUS,
74
86
  PRIORITY_UNSET: () => PRIORITY_UNSET,
75
87
  PRIVATE_BIZSTEP: () => PRIVATE_BIZSTEP,
76
88
  READ_BASIS: () => READ_BASIS,
89
+ RECEIVED_MOVE_KIND: () => RECEIVED_MOVE_KIND,
77
90
  REFUSED_WITHOUT_CODE: () => REFUSED_WITHOUT_CODE,
78
91
  RESOURCE_KIND: () => RESOURCE_KIND,
79
92
  RETIRED_VOCABULARY: () => RETIRED_VOCABULARY,
80
93
  RETURN_TO_SUPPLIER: () => RETURN_TO_SUPPLIER,
81
94
  SCHEDULE_STATUS: () => SCHEDULE_STATUS,
82
95
  SIGNATURE_REJECTED_REASONS: () => SIGNATURE_REJECTED_REASONS,
96
+ SOURCE_DEST_PARTY_TYPE: () => SOURCE_DEST_PARTY_TYPE,
97
+ TASK_STATUS: () => TASK_STATUS,
98
+ TASK_TERMINAL_STATUS: () => TASK_TERMINAL_STATUS,
99
+ TRAILER_LOAD: () => TRAILER_LOAD,
83
100
  TWIN_AXES: () => TWIN_AXES,
84
101
  TWIN_PROPERTIES: () => TWIN_PROPERTIES,
85
102
  TWIN_RELATIONS: () => TWIN_RELATIONS,
@@ -98,14 +115,18 @@ __export(index_exports, {
98
115
  WMS_RECEIVING_ORDER_KINDS: () => WMS_RECEIVING_ORDER_KINDS,
99
116
  WMS_TYPES: () => WMS_TYPES,
100
117
  YARD_BIZSTEP: () => YARD_BIZSTEP,
118
+ YARD_MODE: () => YARD_MODE,
101
119
  YARD_PRIVATE_BIZSTEP: () => YARD_PRIVATE_BIZSTEP,
120
+ YMS_APPOINTMENT_CANCEL_REASON: () => YMS_APPOINTMENT_CANCEL_REASON,
121
+ YMS_APPOINTMENT_STATUS: () => YMS_APPOINTMENT_STATUS,
102
122
  YMS_LOCATION_TYPES: () => YMS_LOCATION_TYPES,
123
+ YMS_ORDER_KIND: () => YMS_ORDER_KIND,
124
+ YMS_TASK_KIND: () => YMS_TASK_KIND,
103
125
  YMS_TYPES: () => YMS_TYPES,
104
126
  acceptsPerformance: () => acceptsPerformance,
105
127
  activeShiftAt: () => activeShiftAt,
106
128
  activeShiftOf: () => activeShiftOf,
107
129
  aggregationEvent: () => aggregationEvent,
108
- analyzeCapacity: () => analyzeCapacity,
109
130
  approveCommand: () => approveCommand,
110
131
  asApproved: () => asApproved,
111
132
  assertOperationalAttentionV1: () => assertOperationalAttentionV1,
@@ -133,18 +154,20 @@ __export(index_exports, {
133
154
  computeOee: () => computeOee,
134
155
  conversionFactorOf: () => conversionFactorOf,
135
156
  criterionSaysNothing: () => criterionSaysNothing,
157
+ dispatchMoveFactOf: () => dispatchMoveFactOf,
158
+ dockDoorCapacityOf: () => dockDoorCapacityOf,
159
+ dockDoorStatusOf: () => dockDoorStatusOf,
160
+ dockFactOf: () => dockFactOf,
136
161
  documentPath: () => documentPath,
137
162
  dueStatusOf: () => dueStatusOf,
138
163
  effectivityAt: () => effectivityAt,
139
164
  electricalUpstreamOf: () => electricalUpstreamOf,
140
- emptyFoldedOrders: () => emptyFoldedOrders,
141
165
  epcCandidatesOfGs1: () => epcCandidatesOfGs1,
142
166
  equipmentClassMembership: () => equipmentClassMembership,
143
167
  erpCapabilityGaps: () => erpCapabilityGaps,
144
168
  expiryFromAttributes: () => expiryFromAttributes,
145
169
  finishedFlowOrdersWithin: () => finishedFlowOrdersWithin,
146
170
  finishedWindowStartMs: () => finishedWindowStartMs,
147
- foldOrdersInto: () => foldOrdersInto,
148
171
  foldedOrderCount: () => foldedOrderCount,
149
172
  gdtiUri: () => gdtiUri,
150
173
  generationFractionAt: () => generationFractionAt,
@@ -155,6 +178,8 @@ __export(index_exports, {
155
178
  hierarchyOf: () => hierarchyOf,
156
179
  homeOf: () => homeOf,
157
180
  hourStartOf: () => hourStartOf,
181
+ identifierText: () => identifierText,
182
+ identifierUnderNamespace: () => identifierUnderNamespace,
158
183
  identityGroundingOf: () => identityGroundingOf,
159
184
  inWorkCalendar: () => inWorkCalendar,
160
185
  inWorkCalendarAt: () => inWorkCalendarAt,
@@ -172,8 +197,10 @@ __export(index_exports, {
172
197
  inheritedExpiry: () => inheritedExpiry,
173
198
  inheritedLotUse: () => inheritedLotUse,
174
199
  isAggregationRecord: () => isAggregationRecord,
200
+ isAppointmentClosed: () => isAppointmentClosed,
175
201
  isCacheableTense: () => isCacheableTense,
176
202
  isCommandTerminal: () => isCommandTerminal,
203
+ isDockRecord: () => isDockRecord,
177
204
  isElectricalLocationType: () => isElectricalLocationType,
178
205
  isEnergyBillRecord: () => isEnergyBillRecord,
179
206
  isEnergyEquipmentRecord: () => isEnergyEquipmentRecord,
@@ -188,22 +215,33 @@ __export(index_exports, {
188
215
  isEquipmentStatus: () => isEquipmentStatus,
189
216
  isFailureStatus: () => isFailureStatus,
190
217
  isFlowOrder: () => isFlowOrder,
218
+ isIsoDateTime: () => isIsoDateTime,
191
219
  isMasterDataRecord: () => isMasterDataRecord,
192
220
  isMaterialExecutionBasis: () => isMaterialExecutionBasis,
221
+ isMoveExpiry: () => isMoveExpiry,
222
+ isMoveRecord: () => isMoveRecord,
193
223
  isOperationalAttentionV1: () => isOperationalAttentionV1,
194
224
  isOperationalRecord: () => isOperationalRecord,
195
225
  isOrderTerminal: () => isOrderTerminal,
226
+ isPartyRef: () => isPartyRef,
227
+ isPartyUri: () => isPartyUri,
196
228
  isPlannedStopStatus: () => isPlannedStopStatus,
197
229
  isRecipeExecutionBasis: () => isRecipeExecutionBasis,
230
+ isRecordShapeError: () => isRecordShapeError,
198
231
  isResourceKind: () => isResourceKind,
232
+ isTaskTerminal: () => isTaskTerminal,
199
233
  isTestSpecificationBasis: () => isTestSpecificationBasis,
200
234
  isTransformationRecord: () => isTransformationRecord,
201
235
  isWebhookDeliveryCode: () => isWebhookDeliveryCode,
202
236
  isWebhookSecretSegment: () => isWebhookSecretSegment,
203
237
  isWorkShiftExecutionBasis: () => isWorkShiftExecutionBasis,
238
+ isYmsAppointmentStatus: () => isYmsAppointmentStatus,
204
239
  isoDurationHours: () => isoDurationHours,
240
+ issueCancelMoveFactOf: () => issueCancelMoveFactOf,
241
+ issueMoveFactOf: () => issueMoveFactOf,
205
242
  itemClassOf: () => itemClassOf,
206
243
  itemKeyOf: () => itemKeyOf,
244
+ itemMaterialDefinitionId: () => itemMaterialDefinitionId,
207
245
  judgeAgainstSpec: () => judgeAgainstSpec,
208
246
  levelOfLocationType: () => levelOfLocationType,
209
247
  lgtinClass: () => lgtinClass,
@@ -221,6 +259,8 @@ __export(index_exports, {
221
259
  meetsTests: () => meetsTests,
222
260
  minuteOfDayAt: () => minuteOfDayAt,
223
261
  missingCommandPayload: () => missingCommandPayload,
262
+ moveExpiryText: () => moveExpiryText,
263
+ moveFactOf: () => moveFactOf,
224
264
  nextCommandState: () => nextCommandState,
225
265
  nonWorkingMsIn: () => nonWorkingMsIn,
226
266
  normalizeEquipmentStatus: () => normalizeEquipmentStatus,
@@ -229,28 +269,35 @@ __export(index_exports, {
229
269
  observationAt: () => observationAt,
230
270
  offCalendarAt: () => offCalendarAt,
231
271
  offCalendarReasonAt: () => offCalendarReasonAt,
272
+ operationalAttentionErrors: () => operationalAttentionErrors,
273
+ operationalAttentionOf: () => operationalAttentionOf,
232
274
  operationalIdentityField: () => operationalIdentityField,
233
275
  operationalKindOf: () => operationalKindOf,
234
- operationsCapabilityOf: () => operationsCapabilityOf,
235
276
  orderFoldPolicyOf: () => orderFoldPolicyOf,
277
+ outboxInputsOfEvent: () => outboxInputsOfEvent,
236
278
  outsideLimit: () => outsideLimit,
237
279
  parseEpc: () => parseEpc,
238
280
  parseGs1: () => parseGs1,
239
281
  parseIsoDuration: () => parseIsoDuration,
240
282
  partitionLensLocations: () => partitionLensLocations,
283
+ partyIdentifierViolation: () => partyIdentifierViolation,
284
+ partyRowIdOf: () => partyRowIdOf,
285
+ partyUri: () => partyUri,
286
+ partyUriLengthNote: () => partyUriLengthNote,
241
287
  passThroughReversible: () => passThroughReversible,
242
288
  performanceKey: () => performanceKey,
243
289
  periodFactId: () => periodFactId,
244
- planOrderFold: () => planOrderFold,
245
290
  priorityRank: () => priorityRank,
246
291
  procedureViolations: () => procedureViolations,
247
292
  propertiesOf: () => propertiesOf,
248
- pruneFoldedHours: () => pruneFoldedHours,
249
293
  quantityIn: () => quantityIn,
250
294
  ratedUsageOf: () => ratedUsageOf,
251
295
  readBoardAssets: () => readBoardAssets,
252
296
  readBoardEquipment: () => readBoardEquipment,
253
297
  readBoardLocations: () => readBoardLocations,
298
+ receiptMoveFactOf: () => receiptMoveFactOf,
299
+ receivedMoveFactOf: () => receivedMoveFactOf,
300
+ recordsOfEvent: () => recordsOfEvent,
254
301
  referencedLocationIds: () => referencedLocationIds,
255
302
  relationsFrom: () => relationsFrom,
256
303
  relationsTo: () => relationsTo,
@@ -267,7 +314,6 @@ __export(index_exports, {
267
314
  splitRelationIds: () => splitRelationIds,
268
315
  ssccDigitsOf: () => ssccDigitsOf,
269
316
  ssccUri: () => ssccUri,
270
- standsNewOrderRow: () => standsNewOrderRow,
271
317
  stateFieldsOf: () => stateFieldsOf,
272
318
  subLotIdOf: () => subLotIdOf,
273
319
  tenseOf: () => tenseOf,
@@ -459,6 +505,11 @@ function ratedUsageOf(r) {
459
505
  }
460
506
 
461
507
  // src/contract.ts
508
+ var TASK_STATUS = ["created", "assigned", "in-progress", "completed", "cancelled"];
509
+ var TASK_TERMINAL_STATUS = ["completed", "cancelled"];
510
+ function isTaskTerminal(t) {
511
+ return TASK_TERMINAL_STATUS.includes(String(t?.status ?? ""));
512
+ }
462
513
  var ORDER_TERMINAL_STATUS = ["completed", "cancelled"];
463
514
  function isOrderTerminal(o) {
464
515
  const status = String(o?.status ?? "").trim().toLowerCase();
@@ -1167,6 +1218,8 @@ var EQUIPMENT_STATUS = ["busy", "setup", "down", "idle", "planned-stop"];
1167
1218
  function isEquipmentStatus(value) {
1168
1219
  return typeof value === "string" && EQUIPMENT_STATUS.includes(value);
1169
1220
  }
1221
+ var PERSON_STATUS = ["idle", "busy"];
1222
+ var ASSET_STATUS = ["idle", "in-use"];
1170
1223
  var RESOURCE_KIND = ["equipment", "personnel", "material", "asset"];
1171
1224
  function isResourceKind(value) {
1172
1225
  return typeof value === "string" && RESOURCE_KIND.includes(value);
@@ -1256,9 +1309,6 @@ function isoDurationHours(iso) {
1256
1309
  if (!m) throw new Error(`\uAE30\uAC04 \uD45C\uAE30\uB97C \uC77D\uC744 \uC218 \uC5C6\uB2E4: ${iso}`);
1257
1310
  return Number(m[1] ?? 0) * 24 + Number(m[2] ?? 0) + Number(m[3] ?? 0) / 60 + Number(m[4] ?? 0) / 3600;
1258
1311
  }
1259
- function paramOf(op, id) {
1260
- return op.parameters?.find((p) => p.id === id)?.value;
1261
- }
1262
1312
  function workingTimeOfWeek(calendar, weekStartMs, utcOffsetMinutes) {
1263
1313
  if (!calendar?.length) return { hoursPerWeek: 7 * 24, daysPerWeek: 7 };
1264
1314
  let minutes = 0;
@@ -1272,76 +1322,6 @@ function workingTimeOfWeek(calendar, weekStartMs, utcOffsetMinutes) {
1272
1322
  for (const e of calendar) if (e.entryType !== "non-working") for (const d of e.daysOfWeek ?? []) declared.add(d);
1273
1323
  return { hoursPerWeek: minutes / 60, daysPerWeek: declared.size || touched.size };
1274
1324
  }
1275
- function availabilityOf(records) {
1276
- const ratios = records.map((r) => r.mtbfMs && r.mttrMs ? r.mtbfMs / (r.mtbfMs + r.mttrMs) : 1);
1277
- return ratios.length ? ratios.reduce((a, b) => a + b, 0) / ratios.length : 1;
1278
- }
1279
- function analyzeCapacity(input) {
1280
- const { hoursPerWeek, daysPerWeek } = workingTimeOfWeek(input.calendar, input.sampleWeekStartMs, input.utcOffsetMinutes);
1281
- const demandPerHour = hoursPerWeek > 0 ? input.unitsPerDay * daysPerWeek / hoursPerWeek : 0;
1282
- const equipmentByKind = /* @__PURE__ */ new Map();
1283
- for (const e of input.equipment ?? []) {
1284
- const list = equipmentByKind.get(e.kind) ?? [];
1285
- list.push(e);
1286
- equipmentByKind.set(e.kind, list);
1287
- }
1288
- const countByClass = (rows, field) => {
1289
- const out = /* @__PURE__ */ new Map();
1290
- for (const r of rows ?? []) for (const c of r[field] ?? []) out.set(c, (out.get(c) ?? 0) + 1);
1291
- return out;
1292
- };
1293
- const personsByClass = countByClass(input.persons, "personnelClassIds");
1294
- const assetsByClass = countByClass(input.assets, "assetClassIds");
1295
- const slotsByLocationType = /* @__PURE__ */ new Map();
1296
- for (const l of input.locations ?? [])
1297
- if (l.type) slotsByLocationType.set(l.type, (slotsByLocationType.get(l.type) ?? 0) + Math.max(l.capacity ?? 1, 1));
1298
- const order = input.route?.length ? input.route.map((k) => input.operations.find((o) => o.key === k)).filter((o) => !!o) : [...input.operations];
1299
- let downstream = 1;
1300
- const reversed = [];
1301
- for (const op of [...order].reverse()) {
1302
- const cycleHours = isoDurationHours(op.duration) + isoDurationHours(paramOf(op, "setupDuration"));
1303
- downstream *= Number(paramOf(op, "yield") ?? 1);
1304
- const requiredPerHour = downstream > 0 ? demandPerHour / downstream : Infinity;
1305
- const requirements = [];
1306
- const add = (axis, className, quantity, available, availability) => {
1307
- const q = Math.max(quantity, 1);
1308
- requirements.push({
1309
- axis,
1310
- className,
1311
- quantity: q,
1312
- available,
1313
- availability,
1314
- perHour: cycleHours > 0 ? Math.floor(available / q) / cycleHours * availability : Infinity
1315
- });
1316
- };
1317
- const equipSpecs = op.equipmentSpecification?.length ? op.equipmentSpecification.map((s) => ({ className: s.equipmentClass ?? op.resourceType ?? "", quantity: s.quantity })) : op.resourceType ? [{ className: op.resourceType, quantity: 1 }] : [];
1318
- for (const s of equipSpecs) {
1319
- if (!s.className) continue;
1320
- const records = equipmentByKind.get(s.className) ?? [];
1321
- add("equipment", s.className, s.quantity, records.length, availabilityOf(records));
1322
- }
1323
- for (const s of op.personnelSpecification ?? [])
1324
- if (s.personnelClass) add("personnel", s.personnelClass, s.quantity, personsByClass.get(s.personnelClass) ?? 0, 1);
1325
- for (const s of op.physicalAssetSpecification ?? [])
1326
- if (s.assetClass) add("asset", s.assetClass, s.quantity, assetsByClass.get(s.assetClass) ?? 0, 1);
1327
- if (op.locationType) add("location", op.locationType, 1, slotsByLocationType.get(op.locationType) ?? 0, 1);
1328
- const constraint = requirements.length ? requirements.reduce((a, b) => a.perHour <= b.perHour ? a : b) : void 0;
1329
- const perHour = constraint ? constraint.perHour : Infinity;
1330
- reversed.push({ operation: op.key, cycleHours, perHour, requiredPerHour, ok: perHour >= requiredPerHour, constraint, requirements });
1331
- }
1332
- const operations = reversed.reverse();
1333
- const tightest = operations.length ? operations.reduce((a, b) => a.perHour / a.requiredPerHour <= b.perHour / b.requiredPerHour ? a : b) : void 0;
1334
- const headroom = operations.length ? Math.min(...operations.map((o) => o.perHour / o.requiredPerHour)) : Infinity;
1335
- return {
1336
- workingHoursPerWeek: hoursPerWeek,
1337
- workingDaysPerWeek: daysPerWeek,
1338
- demandPerHour,
1339
- operations,
1340
- ...tightest ? { bottleneck: { operation: tightest.operation, axis: tightest.constraint?.axis, className: tightest.constraint?.className } } : {},
1341
- maxUnitsPerDay: input.unitsPerDay * headroom,
1342
- ok: operations.every((o) => o.ok)
1343
- };
1344
- }
1345
1325
  function nonWorkingMsIn(calendar, fromMs, toMs, utcOffsetMinutes) {
1346
1326
  if (!calendar?.length) return void 0;
1347
1327
  if (!Number.isFinite(fromMs) || !Number.isFinite(toMs) || toMs <= fromMs) return void 0;
@@ -1574,6 +1554,14 @@ function materialDefinitionIdOf(epcClass) {
1574
1554
  }
1575
1555
  return raw;
1576
1556
  }
1557
+ function itemMaterialDefinitionId(item) {
1558
+ if (!item) return void 0;
1559
+ if (item.definitionId) return item.definitionId;
1560
+ const fromClass = materialDefinitionIdOf(item.gtin);
1561
+ if (fromClass) return fromClass;
1562
+ const [companyPrefix, itemRef] = (item.gtinKey ?? "").split(".");
1563
+ return companyPrefix && itemRef ? sgtinClass(companyPrefix, itemRef) : void 0;
1564
+ }
1577
1565
  function lotClassOfItem(itemClass, lot) {
1578
1566
  if (!itemClass) return void 0;
1579
1567
  const idpat = /^urn:epc:idpat:sgtin:(\d+)\.(\d+)\.\*$/.exec(itemClass);
@@ -1639,6 +1627,9 @@ var PERCENT_ENCODED = {
1639
1627
  /* 로트 클래스의 가르는 글자 — `lotClassUri` 만 쓴다(§`LOT_COMPONENT_BREAKING`). 표는 한 벌이다. */
1640
1628
  ";": "%3B"
1641
1629
  };
1630
+ function identifierUnderNamespace(namespace, marker, id) {
1631
+ return underNamespace(namespace, marker, id);
1632
+ }
1642
1633
  function underNamespace(namespace, marker, id) {
1643
1634
  const raw = String(id);
1644
1635
  if (!raw) return void 0;
@@ -1720,6 +1711,9 @@ function transformationEvent(p) {
1720
1711
  return e;
1721
1712
  }
1722
1713
  var ISO_RE = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[+-]\d{2}:\d{2})$/;
1714
+ function isIsoDateTime(value) {
1715
+ return typeof value === "string" && ISO_RE.test(value);
1716
+ }
1723
1717
  var TZ_RE = /^[+-]\d{2}:\d{2}$/;
1724
1718
  var ACTIONS = ["ADD", "OBSERVE", "DELETE"];
1725
1719
  var EPC_CLASS_PREFIXES = ["urn:epc:idpat:", "urn:epc:class:"];
@@ -1977,6 +1971,37 @@ var YMS_TYPES = [
1977
1971
  ...YMS_LOCATION_TYPES.map((k) => ({ key: k, role: "location", label: `twin.type.${k}`, standardClass: { epcis: "bizLocation" }, identity: { scheme: "gs1:SGLN" }, level: YMS_LOCATION_LEVEL[k], capabilities: ["storable"] })),
1978
1972
  { key: "hostler", role: "equipment", label: "twin.type.hostler", standardClass: { epcis: "object", iso55000: "Asset" }, identity: { scheme: "gs1:GIAI" }, capabilities: ["mobile", "operable"] }
1979
1973
  ];
1974
+ var YMS_ORDER_KIND = {
1975
+ /** 하차하러 들어오는 트레일러의 예약. */
1976
+ inbound: "appointment",
1977
+ /** 상차하러 들어오는(빈) 트레일러의 예약. */
1978
+ outbound: "appointment-out"
1979
+ };
1980
+ var YMS_TASK_KIND = {
1981
+ spot: "spot",
1982
+ spotLive: "spot-live",
1983
+ pull: "pull",
1984
+ dwell: "dwell",
1985
+ depart: "depart"
1986
+ };
1987
+ var YARD_MODE = ["drop", "live"];
1988
+ var YMS_APPOINTMENT_STATUS = ["scheduled", "checked-in", "at-door", "completed", "cancelled"];
1989
+ var YMS_APPOINTMENT_CANCEL_REASON = ["no-show", "carrier", "site"];
1990
+ function isYmsAppointmentStatus(v) {
1991
+ return typeof v === "string" && YMS_APPOINTMENT_STATUS.includes(v);
1992
+ }
1993
+ function isAppointmentClosed(status) {
1994
+ return typeof status === "string" && ORDER_TERMINAL_STATUS.includes(status);
1995
+ }
1996
+ var DOCK_DOOR_STATUS = ["free", "occupied", "blocked"];
1997
+ function dockDoorStatusOf(d) {
1998
+ if (d.blocked) return "blocked";
1999
+ return (d.occupancy ?? 0) >= dockDoorCapacityOf(d.parallelism) ? "occupied" : "free";
2000
+ }
2001
+ function dockDoorCapacityOf(parallelism) {
2002
+ return Math.max(1, Math.floor(Number(parallelism) || 0));
2003
+ }
2004
+ var TRAILER_LOAD = ["empty", "loaded"];
1980
2005
 
1981
2006
  // src/mes-profile.ts
1982
2007
  var MES_BIZSTEP = {
@@ -2018,7 +2043,7 @@ var MES_TYPES = [
2018
2043
  var MES_COMMANDS = [
2019
2044
  {
2020
2045
  type: "production.order",
2021
- label: "\uC0DD\uC0B0 \uC9C0\uC2DC",
2046
+ label: "twin.command.production.order",
2022
2047
  /*
2023
2048
  * 되돌릴 수 없다. 지시가 나가면 사람과 설비가 그것으로 움직이고, 취소해도 이미 만든 것은 남는다.
2024
2049
  * 그래서 사람 승인을 지난다(§`requiresApproval`).
@@ -2221,8 +2246,9 @@ var EMS_TYPES = [
2221
2246
  level: "Other",
2222
2247
  label: "twin.type.incoming",
2223
2248
  /* 수전 지점 — 계약전력이 걸리는 자리이고, 요금의 근거가 되는 수요는 여기서 잰다.
2224
- ISO 50001 의 「에너지 유입」 경계이기도 하다(조직의 에너지 검토가 여기서 시작한다). */
2225
- standardClass: { iec61850: "MMTR", iso50001: "EnergyInput" },
2249
+ 조직의 에너지 검토가 여기서 시작하지만, ISO 50001 은 이 경계에 **분류 이름을 주지 않는다** — 그래서
2250
+ 그 칸을 비운다(예전의 `EnergyInput` 은 표준의 낱말이 아니었다. 2026-11-19 내용 점검). */
2251
+ standardClass: { iec61850: "MMTR" },
2226
2252
  identity: { scheme: "kernel:id" },
2227
2253
  capabilities: ["metered"]
2228
2254
  },
@@ -2232,8 +2258,17 @@ var EMS_TYPES = [
2232
2258
  /* 전기 계통의 구간은 **설비 계층의 단이 아니다** — 표준의 탈출구(`Other`)를 쓴다(아래 주석). */
2233
2259
  level: "Other",
2234
2260
  label: "twin.type.feeder",
2235
- /* 분기 회로 — 부하 분해의 단위. 계약전력의 하위 배분이 여기서 정해진다. */
2236
- standardClass: { iec61850: "Feeder", iso50001: "EnergyUse" },
2261
+ /*
2262
+ * 분기 회로 — 부하 분해의 단위. 계약전력의 하위 배분이 여기서 정해진다.
2263
+ *
2264
+ * **두 칸 다 비운다**(2026-11-19 내용 점검). 예전 값은 둘 다 맞지 않았다:
2265
+ * · `Feeder` 는 IEC 61850 논리 노드가 아니다. 그 표준에서 급전 구간은 SCL 의 `Bay`(설비 구성의 자리)이고,
2266
+ * 이 칸이 담는 논리 노드(MMTR·MMXU·XCBR…)와 다른 층이다. 회로의 계량은 그 회로에 달린 계량기(`meter`)가 진다.
2267
+ * · ISO 50001 의 「energy use」는 **용도**(환기·조명처럼 에너지를 어디에 쓰나)이지 회로가 아니다. 회로 하나에
2268
+ * 여러 용도가 걸리고, 한 용도가 여러 회로에 걸친다 — 대응시키면 SEU 분석이 회로를 용도로 센다.
2269
+ * 표준의 이름이 없는 것을 「없다」고 두는 것이 파일 머리의 규율이다.
2270
+ */
2271
+ standardClass: {},
2237
2272
  identity: { scheme: "kernel:id" },
2238
2273
  capabilities: ["metered"]
2239
2274
  },
@@ -2259,7 +2294,8 @@ var EMS_TYPES = [
2259
2294
  role: "equipment",
2260
2295
  label: "twin.type.meter",
2261
2296
  /* 계량기 — 측정 논리 노드(MMXU=측정단위, MMTR=적산). 자산으로도 하나다(ISO 55000). */
2262
- standardClass: { iec61850: "MMXU", iso55000: "Asset", iso50001: "MeasurementPoint" },
2297
+ /* ISO 50001 칸은 비운다 — 계측 지점은 그 표준이 이름 붙인 분류가 아니다(파일 머리의 규율, 2026-11-19 내용 점검). */
2298
+ standardClass: { iec61850: "MMXU", iso55000: "Asset" },
2263
2299
  identity: { scheme: "kernel:id" },
2264
2300
  capabilities: ["metered", "operable"]
2265
2301
  },
@@ -2284,7 +2320,8 @@ var EMS_TYPES = [
2284
2320
  role: "equipment",
2285
2321
  label: "twin.type.pv-array",
2286
2322
  /* 태양광 어레이 — IEC 61850-7-420(분산자원)의 `DPVA`. 발전과 계량은 다른 능력이다. */
2287
- standardClass: { iec61850: "DPVA", iso55000: "Asset", iso50001: "RenewableSupply" },
2323
+ /* ISO 50001 칸은 비운다 — 「재생 공급」은 그 표준의 분류 이름이 아니다(파일 머리의 규율, 2026-11-19 내용 점검). */
2324
+ standardClass: { iec61850: "DPVA", iso55000: "Asset" },
2288
2325
  identity: { scheme: "kernel:id" },
2289
2326
  capabilities: ["energyGenerating", "metered", "operable"]
2290
2327
  },
@@ -3629,6 +3666,54 @@ function gtin14OfItem(definitionId) {
3629
3666
  if (byClass) return byClass;
3630
3667
  return /^(\d{8}|\d{12,14})$/.test(definitionId ?? "") ? definitionId.padStart(14, "0") : void 0;
3631
3668
  }
3669
+ function identifierText(uri) {
3670
+ const raw = String(uri ?? "").trim();
3671
+ if (!raw) return "";
3672
+ const parsed = parseEpc(raw);
3673
+ if (parsed.scheme === "sgtin" || parsed.scheme === "lgtin" || parsed.scheme === "idpat") {
3674
+ const gtin = gtin14OfKey(parsed.gtinKey);
3675
+ if (!gtin) return raw;
3676
+ if (parsed.scheme === "sgtin") return parsed.serial ? `(01)${gtin}(21)${decoded(parsed.serial)}` : raw;
3677
+ if (parsed.scheme === "lgtin") return parsed.lot ? `(01)${gtin}(10)${parsed.lot}` : raw;
3678
+ return `(01)${gtin}`;
3679
+ }
3680
+ if (parsed.scheme === "sscc") {
3681
+ const sscc = ssccDigitsOf(raw);
3682
+ return sscc ? `(00)${sscc}` : raw;
3683
+ }
3684
+ if (parsed.scheme === "sgln") {
3685
+ const m = /^urn:epc:id:sgln:(\d+)\.(\d*)\.(.+)$/.exec(raw);
3686
+ if (!m || m[1].length + m[2].length !== 12) return raw;
3687
+ const body = m[1] + m[2];
3688
+ return `(414)${body}${checkDigitOf(body)}${m[3] === "0" ? "" : `(254)${decoded(m[3])}`}`;
3689
+ }
3690
+ if (parsed.scheme === "grai" || parsed.scheme === "gdti") {
3691
+ const m = new RegExp(`^urn:epc:id:${parsed.scheme}:(\\d+)\\.(\\d*)\\.(.*)$`).exec(raw);
3692
+ if (!m || m[1].length + m[2].length !== 12) return raw;
3693
+ const key = m[1] + m[2] + checkDigitOf(m[1] + m[2]);
3694
+ return parsed.scheme === "grai" ? `(8003)0${key}${decoded(m[3])}` : `(253)${key}${decoded(m[3])}`;
3695
+ }
3696
+ if (parsed.scheme === "giai") {
3697
+ const m = /^urn:epc:id:giai:(\d+)\.(.+)$/.exec(raw);
3698
+ return m ? `(8004)${m[1]}${decoded(m[2])}` : raw;
3699
+ }
3700
+ if (parsed.item !== void 0 && parsed.lot !== void 0) return `${parsed.item} \xB7 ${parsed.lot}`;
3701
+ const inHouse = /(?:\/(?:obj|class|bt)\/|:(?:obj|class|bt):)([^/:\s]+)$/.exec(raw);
3702
+ return inHouse ? decoded(inHouse[1]) : raw;
3703
+ }
3704
+ function gtin14OfKey(key) {
3705
+ const m = /^(\d+)\.(\d+)$/.exec(key ?? "");
3706
+ if (!m) return void 0;
3707
+ const body = m[2][0] + m[1] + m[2].slice(1);
3708
+ return body.length === 13 ? body + checkDigitOf(body) : void 0;
3709
+ }
3710
+ function decoded(part) {
3711
+ try {
3712
+ return decodeURIComponent(part);
3713
+ } catch {
3714
+ return part;
3715
+ }
3716
+ }
3632
3717
 
3633
3718
  // src/order-fold.ts
3634
3719
  var ORDER_FOLD_HOUR_MS = 60 * 60 * 1e3;
@@ -3649,65 +3734,17 @@ function orderFoldPolicyOf(declared) {
3649
3734
  if (policy.maxTerminal < 1) return { error: "order fold maxTerminal must be at least 1 (ADR-0092)" };
3650
3735
  return { policy };
3651
3736
  }
3652
- function emptyFoldedOrders() {
3653
- return { counts: {}, boundaryMs: null };
3654
- }
3655
3737
  function foldedOrderCount(folded) {
3656
3738
  let n = 0;
3657
3739
  for (const byStatus of Object.values(folded?.counts ?? {})) for (const c of Object.values(byStatus)) n += c;
3658
3740
  return n;
3659
3741
  }
3660
- function planOrderFold(orders, nowMs, policy = ORDER_FOLD_DEFAULT) {
3661
- const candidates = orders.filter((o) => isOrderTerminal(o) && !o.held && typeof o.terminalAtMs === "number" && Number.isFinite(o.terminalAtMs)).sort((a, b) => a.terminalAtMs - b.terminalAtMs || (a.id < b.id ? -1 : a.id > b.id ? 1 : 0));
3662
- const cutoff = nowMs - policy.afterMs;
3663
- const byTime = candidates.filter((o) => o.terminalAtMs <= cutoff);
3664
- const stay = candidates.length - byTime.length;
3665
- const byCount = stay > policy.maxTerminal ? candidates.slice(byTime.length, byTime.length + (stay - policy.maxTerminal)) : [];
3666
- return [...byTime, ...byCount].map((o) => o.id);
3667
- }
3668
- function foldOrdersInto(folded, orders) {
3669
- const out = {
3670
- counts: Object.fromEntries(Object.entries(folded?.counts ?? {}).map(([k, v]) => [k, { ...v }])),
3671
- boundaryMs: folded?.boundaryMs ?? null
3672
- };
3673
- const hours = Object.fromEntries(
3674
- Object.entries(folded?.hours ?? {}).map(([h, byKind]) => [h, Object.fromEntries(Object.entries(byKind).map(([k, v]) => [k, { ...v }]))])
3675
- );
3676
- for (const o of orders) {
3677
- const kind = String(o.kind ?? "");
3678
- const status = String(o.status ?? "");
3679
- const byStatus = out.counts[kind] ??= {};
3680
- byStatus[status] = (byStatus[status] ?? 0) + 1;
3681
- if (typeof o.terminalAtMs === "number" && Number.isFinite(o.terminalAtMs)) {
3682
- out.boundaryMs = out.boundaryMs === null ? o.terminalAtMs : Math.max(out.boundaryMs, o.terminalAtMs);
3683
- const slot = (hours[String(hourStartOf(o.terminalAtMs))] ??= {})[kind] ??= {};
3684
- slot[status] = (slot[status] ?? 0) + 1;
3685
- }
3686
- }
3687
- if (Object.keys(hours).length) out.hours = hours;
3688
- return out;
3689
- }
3690
- function standsNewOrderRow(record, eventTimeMs, folded) {
3691
- if (!isOrderTerminal(record)) return true;
3692
- const boundary = folded?.boundaryMs;
3693
- if (boundary === null || boundary === void 0) return true;
3694
- if (typeof eventTimeMs !== "number" || !Number.isFinite(eventTimeMs)) return true;
3695
- return eventTimeMs > boundary;
3696
- }
3697
3742
  function hourStartOf(ms) {
3698
3743
  return Math.floor(ms / ORDER_FOLD_HOUR_MS) * ORDER_FOLD_HOUR_MS;
3699
3744
  }
3700
3745
  function finishedWindowStartMs(nowMs, policy = ORDER_FOLD_DEFAULT) {
3701
3746
  return hourStartOf(nowMs) - policy.afterMs;
3702
3747
  }
3703
- function pruneFoldedHours(folded, nowMs, policy = ORDER_FOLD_DEFAULT) {
3704
- if (!folded.hours) return folded;
3705
- const start = finishedWindowStartMs(nowMs, policy);
3706
- const kept = Object.fromEntries(Object.entries(folded.hours).filter(([h]) => Number(h) >= start));
3707
- const out = { counts: folded.counts, boundaryMs: folded.boundaryMs };
3708
- if (Object.keys(kept).length) out.hours = kept;
3709
- return out;
3710
- }
3711
3748
  function finishedFlowOrdersWithin(hot, folded, nowMs, policy = ORDER_FOLD_DEFAULT) {
3712
3749
  const fromMs = finishedWindowStartMs(nowMs, policy);
3713
3750
  let count = 0;
@@ -4095,10 +4132,6 @@ function shapeErrors(where, row, shape) {
4095
4132
  }
4096
4133
  return errors;
4097
4134
  }
4098
- var TASK_STATUS = ["created", "assigned", "in-progress", "completed"];
4099
- var EQUIPMENT_STATUS2 = ["idle", "busy", "down", "setup", "planned-stop"];
4100
- var PERSON_STATUS = ["idle", "busy"];
4101
- var ASSET_STATUS = ["idle", "in-use"];
4102
4135
  var SPECS = {
4103
4136
  task: {
4104
4137
  eventType: OP_EVENT.task,
@@ -4191,7 +4224,7 @@ var SPECS = {
4191
4224
  재검사하지는 않는다: 그 모양은 `EquipmentMotion` 계약이고, 여기서 두 번 지키면 두 벌이 된다. */
4192
4225
  motion: "object"
4193
4226
  },
4194
- enums: { status: EQUIPMENT_STATUS2 }
4227
+ enums: { status: EQUIPMENT_STATUS }
4195
4228
  },
4196
4229
  person: {
4197
4230
  eventType: OP_EVENT.person,
@@ -4387,7 +4420,7 @@ var SPECS = {
4387
4420
  fields: { basisId: "string", arrangementId: "string", revisionId: "string", revisionNumber: "number", planId: "string", contentHash: "string", businessTime: "string", timezone: "string", workDate: "string" }
4388
4421
  }
4389
4422
  },
4390
- enums: { status: EQUIPMENT_STATUS2 }
4423
+ enums: { status: EQUIPMENT_STATUS }
4391
4424
  },
4392
4425
  /*
4393
4426
  * **부적합 처분** — 재고 판정을 받은 것을 어떻게 하기로 정했나.
@@ -4704,58 +4737,6 @@ function workingHoursBetween(calendar, fromMs, toMs, utcOffsetMinutes) {
4704
4737
  for (let ms = fromMs; ms < toMs; ms += 6e4) if (inWorkCalendarAt(calendar, ms, utcOffsetMinutes)) minutes++;
4705
4738
  return minutes / 60;
4706
4739
  }
4707
- function operationsCapabilityOf(input) {
4708
- const fromMs = Date.parse(input.window.fromTime);
4709
- const toMs = Date.parse(input.window.toTime);
4710
- if (!Number.isFinite(fromMs) || !Number.isFinite(toMs)) {
4711
- throw new Error(`\uB2A5\uB825\uC758 \uAD6C\uAC04\uC744 \uC77D\uC744 \uC218 \uC5C6\uB2E4: ${input.window.fromTime} ~ ${input.window.toTime}`);
4712
- }
4713
- if (toMs <= fromMs) throw new Error(`\uB2A5\uB825\uC758 \uAD6C\uAC04\uC774 \uB4A4\uC9D1\uD614\uB2E4: ${input.window.fromTime} ~ ${input.window.toTime}`);
4714
- const workingHours = workingHoursBetween(input.calendar ?? input.capacity.calendar, fromMs, toMs, input.utcOffsetMinutes);
4715
- const full = analyzeCapacity(input.capacity);
4716
- const usable = input.usableCapacity ? analyzeCapacity(input.usableCapacity) : void 0;
4717
- const amountOf = (perHour) => Number.isFinite(perHour) ? perHour * workingHours : null;
4718
- const committedOf = (operation) => {
4719
- let sum = 0;
4720
- for (const d of input.demands ?? []) {
4721
- if (d.operation !== void 0 && d.operation !== operation) continue;
4722
- if (!d.dueTime) continue;
4723
- const due = Date.parse(d.dueTime);
4724
- if (!Number.isFinite(due) || due < fromMs || due >= toMs) continue;
4725
- sum += Math.max(0, d.remaining);
4726
- }
4727
- return sum;
4728
- };
4729
- const perOperation = full.operations.map((op) => {
4730
- const total = amountOf(op.perHour);
4731
- const committed = committedOf(op.operation);
4732
- let unattainable = null;
4733
- let unattainableBy;
4734
- if (usable) {
4735
- const left = usable.operations.find((o) => o.operation === op.operation);
4736
- const usableAmount = amountOf(left?.perHour ?? NaN);
4737
- unattainable = total != null && usableAmount != null ? Math.max(0, total - usableAmount) : null;
4738
- if (unattainable != null && unattainable > 0 && left?.constraint) unattainableBy = left.constraint;
4739
- }
4740
- const available = total == null || unattainable == null ? null : total - committed - unattainable;
4741
- return {
4742
- operation: op.operation,
4743
- total,
4744
- committed,
4745
- unattainable,
4746
- available,
4747
- ...op.constraint ? { constraint: op.constraint } : {},
4748
- ...unattainableBy ? { unattainableBy } : {}
4749
- };
4750
- });
4751
- return {
4752
- operationsType: input.operationsType ?? "Production",
4753
- window: { fromTime: input.window.fromTime, toTime: input.window.toTime, workingHours },
4754
- perOperation,
4755
- ...full.bottleneck ? { bottleneck: full.bottleneck } : {},
4756
- ...input.publishedDate ? { publishedDate: input.publishedDate } : {}
4757
- };
4758
- }
4759
4740
 
4760
4741
  // src/scenario-validate.ts
4761
4742
  var DISTRIBUTIONS = /* @__PURE__ */ new Set(["poisson", "uniform", "constant", "profile"]);
@@ -4846,6 +4827,58 @@ function retiredVocabularyIn(line) {
4846
4827
  return hits;
4847
4828
  }
4848
4829
 
4830
+ // src/party.ts
4831
+ var SOURCE_DEST_PARTY_TYPE = {
4832
+ owning_party: "urn:epcglobal:cbv:sdt:owning_party",
4833
+ possessing_party: "urn:epcglobal:cbv:sdt:possessing_party"
4834
+ };
4835
+ var PARTY_ROLE = {
4836
+ carrier: "CA"
4837
+ };
4838
+ var PARTY_URI_MAX_LENGTH = 128;
4839
+ var PARTY_URI_RECOMMENDED_LENGTH = 60;
4840
+ var UUID = /^[0-9a-f]{8}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{12}$/i;
4841
+ var ISSUED_TOKEN = /^[0-9a-f]{32}$/;
4842
+ var PGLN_EPC = /^urn:epc:id:pgln:\d+\.\d*$/;
4843
+ var PGLN_DIGITAL_LINK = /^https:\/\/id\.gs1\.org\/417\/\d{13}$/;
4844
+ var SD_URL = /^https?:\/\/[^/\s.]+(?:\.[^/\s.]+)+\/(?:[^/\s]+\/)*sd\/[^/\s]+$/;
4845
+ var SD_URN = /^urn:[^:\s]+:(?:[^:\s]+:)*sd:[^:\s]+$/;
4846
+ function partyUri(namespace, rowId) {
4847
+ const raw = String(rowId ?? "").trim();
4848
+ if (!UUID.test(raw)) throw new Error(`partyUri: \uAC70\uB798\uCC98 \uD589 id \uAC00 uuid \uAC00 \uC544\uB2C8\uB2E4: ${rowId}`);
4849
+ const uri = identifierUnderNamespace(namespace, "sd", raw.replace(/-/g, "").toLowerCase());
4850
+ if (uri && uri.length > PARTY_URI_MAX_LENGTH) {
4851
+ throw new Error(`partyUri: ${uri.length}\uC790 \u2014 CBV 2.0 \xA78.1.4 \uB294 ${PARTY_URI_MAX_LENGTH}\uC790 \uC774\uD558\uB97C \uC694\uAD6C\uD55C\uB2E4. \uC774\uB984\uACF5\uAC04 \uC120\uC5B8(${namespace})\uC774 \uB108\uBB34 \uAE38\uB2E4.`);
4852
+ }
4853
+ return uri;
4854
+ }
4855
+ function partyRowIdOf(uri) {
4856
+ if (!uri || partyIdentifierViolation(uri)) return void 0;
4857
+ const token = SD_URL.test(uri) ? uri.slice(uri.lastIndexOf("/") + 1) : SD_URN.test(uri) ? uri.slice(uri.lastIndexOf(":") + 1) : void 0;
4858
+ if (!token || !ISSUED_TOKEN.test(token)) return void 0;
4859
+ return `${token.slice(0, 8)}-${token.slice(8, 12)}-${token.slice(12, 16)}-${token.slice(16, 20)}-${token.slice(20)}`;
4860
+ }
4861
+ function partyIdentifierViolation(uri) {
4862
+ if (typeof uri !== "string" || !uri) return `\uAC70\uB798 \uC0C1\uB300 \uC2DD\uBCC4\uC790\uAC00 \uBE44\uC5C8\uB2E4: ${uri}`;
4863
+ if (uri.length > PARTY_URI_MAX_LENGTH) return `\uAC70\uB798 \uC0C1\uB300 \uC2DD\uBCC4\uC790\uAC00 ${uri.length}\uC790 \u2014 CBV 2.0 \xA78.1.4 \uB294 ${PARTY_URI_MAX_LENGTH}\uC790 \uC774\uD558\uB97C \uC694\uAD6C\uD55C\uB2E4: ${uri}`;
4864
+ if (PGLN_EPC.test(uri) || PGLN_DIGITAL_LINK.test(uri)) return void 0;
4865
+ if (/^urn:epc(global)?:/.test(uri)) return `\uAC70\uB798 \uC0C1\uB300\uC5D0\uB294 GS1 \uACF5\uAC04\uC5D0\uC11C PGLN \uB9CC \uBC1B\uB294\uB2E4(CBV 2.0 \xA78.7.1): ${uri}`;
4866
+ if (SD_URL.test(uri) || SD_URN.test(uri)) return void 0;
4867
+ return `\uAC70\uB798 \uC0C1\uB300 \uC2DD\uBCC4\uC790\uC758 \uAF34\uC774 \uC544\uB2C8\uB2E4: ${uri} \u2014 CBV 2.0 \xA78.7 \uC758 \uAF34\uC774\uC5B4\uC57C \uD55C\uB2E4 (PGLN urn:epc:id:pgln: \xB7 https://id.gs1.org/417/<PGLN> \xB7 http(s)://<\uB3C4\uBA54\uC778>/**/sd/<id> \xB7 urn:<\uC774\uB984\uACF5\uAC04>:**:sd:<id>)`;
4868
+ }
4869
+ function isPartyUri(v) {
4870
+ return typeof v === "string" && partyIdentifierViolation(v) === void 0;
4871
+ }
4872
+ function partyUriLengthNote(uri) {
4873
+ if (typeof uri !== "string" || uri.length <= PARTY_URI_RECOMMENDED_LENGTH) return void 0;
4874
+ return `\uAC70\uB798 \uC0C1\uB300 \uC2DD\uBCC4\uC790\uAC00 ${uri.length}\uC790 \u2014 CBV 2.0 \xA78.1.4 \uB294 ${PARTY_URI_RECOMMENDED_LENGTH}\uC790 \uC774\uD558\uB97C \uAD8C\uD55C\uB2E4: ${uri}`;
4875
+ }
4876
+ function isPartyRef(v) {
4877
+ if (!v || typeof v !== "object" || Array.isArray(v)) return false;
4878
+ const r = v;
4879
+ return isPartyUri(r.id) && (r.name === void 0 || typeof r.name === "string");
4880
+ }
4881
+
4849
4882
  // src/command-verdict.ts
4850
4883
  var REFUSED_WITHOUT_CODE = "refused";
4851
4884
  function verdictOfAck(ack) {
@@ -5023,7 +5056,7 @@ function computeOee(c, nowMs) {
5023
5056
  const quality = produced > 0 ? c.goodCount / produced : void 0;
5024
5057
  if (c.plannedRunTimePerItemMs == null) missing.push("planned-run-time-per-item");
5025
5058
  else if (c.runMs <= 0) missing.push("actual-production-time");
5026
- const performance = c.plannedRunTimePerItemMs != null && c.runMs > 0 ? Math.min(1, c.plannedRunTimePerItemMs * produced / c.runMs) : void 0;
5059
+ const performance = c.plannedRunTimePerItemMs != null && c.runMs > 0 ? c.plannedRunTimePerItemMs * produced / c.runMs : void 0;
5027
5060
  const overall = availability != null && performance != null && quality != null ? availability * performance * quality : void 0;
5028
5061
  return {
5029
5062
  ...availability != null ? { availability } : {},
@@ -5344,22 +5377,440 @@ function commandSpecGaps(specs, command) {
5344
5377
  var OPERATIONAL_ATTENTION_CONTRACT = "operational.attention.v1";
5345
5378
  var OPERATIONAL_ATTENTION_TRANSITIONS = ["opened", "changed", "resolved", "reopened"];
5346
5379
  var OPERATIONAL_ATTENTION_IMPACTS = ["medium", "high"];
5347
- function isOperationalAttentionV1(value) {
5380
+ var OPERATIONAL_ATTENTION_KIND_PATTERN = /^[a-z][a-z0-9-]*(\.[a-z0-9][a-z0-9-]*)+$/;
5381
+ function operationalAttentionErrors(value) {
5348
5382
  const one = value;
5349
- return !!one && typeof one === "object" && one.contract === OPERATIONAL_ATTENTION_CONTRACT && nonEmpty(one.domainId) && nonEmpty(one.attentionId) && nonEmpty(one.dedupeKey) && nonEmpty(one.kind) && nonEmpty(one.subjectLabel) && nonEmpty(one.observedAt) && nonEmpty(one.evidenceFingerprint) && OPERATIONAL_ATTENTION_TRANSITIONS.includes(one.transition) && OPERATIONAL_ATTENTION_IMPACTS.includes(one.impact) && Array.isArray(one.facts) && one.facts.length > 0 && one.facts.every(isOperationalFactReference);
5383
+ if (!one || typeof one !== "object") return ["record: not an object"];
5384
+ const errors = [];
5385
+ if (one.contract !== OPERATIONAL_ATTENTION_CONTRACT) errors.push(`contract: must be ${OPERATIONAL_ATTENTION_CONTRACT}`);
5386
+ for (const field of ["domainId", "attentionId", "dedupeKey", "subjectLabel", "evidenceFingerprint"]) {
5387
+ if (!nonEmpty(one[field])) errors.push(`${field}: required`);
5388
+ }
5389
+ if (!nonEmpty(one.kind)) errors.push("kind: required");
5390
+ else if (!OPERATIONAL_ATTENTION_KIND_PATTERN.test(one.kind)) errors.push("kind: must be <product>.<code> in lower case");
5391
+ if (!isIsoDateTime(one.observedAt)) errors.push("observedAt: must be ISO 8601 with seconds and Z or an offset");
5392
+ if (!OPERATIONAL_ATTENTION_TRANSITIONS.includes(one.transition)) {
5393
+ errors.push(`transition: must be one of ${OPERATIONAL_ATTENTION_TRANSITIONS.join("|")}`);
5394
+ }
5395
+ if (!OPERATIONAL_ATTENTION_IMPACTS.includes(one.impact)) {
5396
+ errors.push(`impact: must be one of ${OPERATIONAL_ATTENTION_IMPACTS.join("|")}`);
5397
+ }
5398
+ if (!Array.isArray(one.facts) || one.facts.length === 0) {
5399
+ errors.push("facts: stable source-fact references are required (at least one {system,type,id})");
5400
+ } else {
5401
+ one.facts.forEach((fact, i) => {
5402
+ for (const reason of factReferenceErrors(fact)) errors.push(`facts[${i}].${reason}`);
5403
+ });
5404
+ }
5405
+ return errors;
5406
+ }
5407
+ function isOperationalAttentionV1(value) {
5408
+ return operationalAttentionErrors(value).length === 0;
5350
5409
  }
5351
5410
  function assertOperationalAttentionV1(value) {
5352
- if (!isOperationalAttentionV1(value)) {
5353
- throw new Error("invalid operational.attention.v1: lifecycle fields and stable source-fact references are required");
5354
- }
5411
+ const errors = operationalAttentionErrors(value);
5412
+ if (errors.length) throw new Error(`invalid operational.attention.v1: ${errors.join("; ")}`);
5355
5413
  }
5356
- function isOperationalFactReference(value) {
5414
+ function factReferenceErrors(value) {
5357
5415
  const one = value;
5358
- return !!one && typeof one === "object" && nonEmpty(one.system) && nonEmpty(one.type) && nonEmpty(one.id) && (one.observedAt === void 0 || nonEmpty(one.observedAt)) && (one.label === void 0 || nonEmpty(one.label));
5416
+ if (!one || typeof one !== "object") return ["reference: not an object"];
5417
+ const errors = [];
5418
+ for (const field of ["system", "type", "id"]) {
5419
+ if (!nonEmpty(one[field])) errors.push(`${field}: required (stable source-fact references are required)`);
5420
+ }
5421
+ if (one.observedAt !== void 0 && !isIsoDateTime(one.observedAt)) {
5422
+ errors.push("observedAt: must be ISO 8601 with seconds and Z or an offset");
5423
+ }
5424
+ if (one.label !== void 0 && !nonEmpty(one.label)) errors.push("label: empty");
5425
+ return errors;
5359
5426
  }
5360
5427
  function nonEmpty(value) {
5361
5428
  return typeof value === "string" && value.trim().length > 0;
5362
5429
  }
5430
+ function operationalAttentionOf(producer, attention, transition, observedAt) {
5431
+ const record = {
5432
+ contract: OPERATIONAL_ATTENTION_CONTRACT,
5433
+ domainId: producer.domainId,
5434
+ attentionId: attention.attentionId,
5435
+ dedupeKey: attention.dedupeKey,
5436
+ kind: attention.kind,
5437
+ subjectLabel: attention.subjectLabel,
5438
+ transition,
5439
+ impact: attention.impact,
5440
+ observedAt,
5441
+ evidenceFingerprint: attention.evidenceFingerprint,
5442
+ facts: attention.facts.map((one) => ({ system: producer.system, ...one }))
5443
+ };
5444
+ assertOperationalAttentionV1(record);
5445
+ return record;
5446
+ }
5447
+
5448
+ // src/records-of-event.ts
5449
+ var FIELDS_NOT_CARRIED = ["ilmd", "sourceList", "destinationList", "persistentDisposition", "sensorElementList", "certificationInfo"];
5450
+ var CARRIED_HEADER_FIELDS = ["bizStep", "disposition", "bizTransactionList", "readPoint", "bizLocation"];
5451
+ var HEADER_FIELDS_PARTITIONED = true;
5452
+ function shapeError(code, params, message) {
5453
+ return Object.assign(new Error(message), { name: "RecordShapeError", code, params });
5454
+ }
5455
+ function isRecordShapeError(error) {
5456
+ return error instanceof Error && error.name === "RecordShapeError";
5457
+ }
5458
+ function placeOf(ref) {
5459
+ return typeof ref?.id === "string" ? ref.id : void 0;
5460
+ }
5461
+ function headerOf(event) {
5462
+ return {
5463
+ bizStep: event.bizStep,
5464
+ ...event.disposition ? { disposition: event.disposition } : {},
5465
+ ...event.bizTransactionList?.length ? { bizTransactionList: event.bizTransactionList } : {},
5466
+ /* The twin's record takes a place as its value, an EPCIS document as `{ id }` - the sender moves it (connector ruling 2026-09-24). */
5467
+ ...placeOf(event.readPoint) ? { readPoint: placeOf(event.readPoint) } : {},
5468
+ ...placeOf(event.bizLocation) ? { bizLocation: placeOf(event.bizLocation) } : {}
5469
+ };
5470
+ }
5471
+ function recordsOfEvent(event) {
5472
+ if (event.errorDeclaration) {
5473
+ throw shapeError(
5474
+ "correction-not-shaped",
5475
+ { event: event.eventID },
5476
+ "the event declares an error in an earlier one: the canonical records have no correction, and sent as an observation it would read as a new fact"
5477
+ );
5478
+ }
5479
+ const notCarried = FIELDS_NOT_CARRIED.filter((field) => {
5480
+ const value = event[field];
5481
+ return value !== void 0 && value !== null && !(Array.isArray(value) && !value.length);
5482
+ });
5483
+ const shaped = shapedRecordsOf(event);
5484
+ return notCarried.length ? { ...shaped, notCarried } : shaped;
5485
+ }
5486
+ function shapedRecordsOf(event) {
5487
+ switch (event.type) {
5488
+ case "ObjectEvent": {
5489
+ const units = event.epcList ?? [];
5490
+ const quantities = event.quantityList;
5491
+ if (!units.length && !quantities?.length) {
5492
+ throw shapeError("nothing-observed", { event: event.eventID }, "the event names neither a logistic unit nor a quantity: there is nothing to observe");
5493
+ }
5494
+ if (units.length > 1 && quantities?.length) {
5495
+ throw shapeError(
5496
+ "quantity-across-many-units",
5497
+ { event: event.eventID, units: units.length },
5498
+ `the event carries a quantity and ${units.length} units: which unit holds it is not said`
5499
+ );
5500
+ }
5501
+ if (!units.length) {
5502
+ return { records: [{ quantityList: quantities, action: event.action, ...headerOf(event) }] };
5503
+ }
5504
+ return {
5505
+ records: units.map((epc) => ({
5506
+ epc,
5507
+ ...quantities?.length ? { quantityList: quantities } : {},
5508
+ action: event.action,
5509
+ ...headerOf(event)
5510
+ }))
5511
+ };
5512
+ }
5513
+ case "AggregationEvent":
5514
+ return {
5515
+ records: [
5516
+ {
5517
+ parentID: event.parentID,
5518
+ ...event.childEPCs?.length ? { childEPCs: event.childEPCs } : {},
5519
+ ...event.childQuantityList?.length ? { childQuantityList: event.childQuantityList } : {},
5520
+ action: event.action,
5521
+ ...headerOf(event)
5522
+ }
5523
+ ]
5524
+ };
5525
+ /* What went in and what came out (ADR-0151). A side the event does not name gets no field - an empty list would say "nothing". */
5526
+ case "TransformationEvent":
5527
+ return {
5528
+ records: [
5529
+ {
5530
+ ...event.inputEPCList?.length ? { inputEPCList: event.inputEPCList } : {},
5531
+ ...event.inputQuantityList?.length ? { inputQuantityList: event.inputQuantityList } : {},
5532
+ ...event.outputEPCList?.length ? { outputEPCList: event.outputEPCList } : {},
5533
+ ...event.outputQuantityList?.length ? { outputQuantityList: event.outputQuantityList } : {},
5534
+ ...event.transformationID ? { transformationID: event.transformationID } : {},
5535
+ ...headerOf(event)
5536
+ }
5537
+ ]
5538
+ };
5539
+ /* The order's fact - the order record carries it. Sent as an object observation it would make a thing out of nothing. */
5540
+ case "TransactionEvent":
5541
+ return { records: [], heldBack: "the-order-record-carries-it" };
5542
+ default:
5543
+ throw shapeError(
5544
+ "event-type-not-shaped",
5545
+ { type: event.type },
5546
+ `${event.type} has no canonical shape: no product writes one`
5547
+ );
5548
+ }
5549
+ }
5550
+ function outboxInputsOfEvent(row) {
5551
+ const event = row.payload;
5552
+ const violations = validateEpcisEvent(event);
5553
+ if (violations.length) throw shapeError("event-invalid", { event: row.eventId, violations }, `the stored event ${row.eventId} is not a valid EPCIS event: ${violations.join(" \xB7 ")}`);
5554
+ const { records } = recordsOfEvent(event);
5555
+ const eventTime = new Date(typeof event.eventTime === "string" && event.eventTime ? event.eventTime : row.eventTime);
5556
+ return records.map((record, index) => ({ record, eventId: records.length > 1 ? `${row.eventId}#${index}` : row.eventId, eventTime }));
5557
+ }
5558
+
5559
+ // src/material-move.ts
5560
+ var MOVE_KIND = {
5561
+ /** warehouse → plant: a pick for a production order put this container at the line. */
5562
+ issue: "issue",
5563
+ /** warehouse → plant: the issue was taken back - what was still on the way came back (ADR-0143 decision 5). */
5564
+ issueCancel: "issue-cancel",
5565
+ /** plant → warehouse: the line took this much of an issue. */
5566
+ receipt: "receipt",
5567
+ /** plant → warehouse: what is left at the line goes back (decision 3). */
5568
+ return: "return",
5569
+ /** plant → warehouse: finished goods leave the line for the warehouse (decision 4). */
5570
+ handover: "handover",
5571
+ /** warehouse → plant: this much of a return arrived. */
5572
+ returnReceived: "return-received",
5573
+ /** warehouse → plant: this much of a handover arrived. */
5574
+ handoverReceived: "handover-received",
5575
+ /** site → site: a transfer left for the peer site, one lot (ADR-0154 decision 1). */
5576
+ transfer: "transfer",
5577
+ /** site → site: this much of a transfer arrived at the peer site. */
5578
+ transferReceived: "transfer-received"
5579
+ };
5580
+ var RECEIVED_MOVE_KIND = {
5581
+ [MOVE_KIND.return]: MOVE_KIND.returnReceived,
5582
+ [MOVE_KIND.handover]: MOVE_KIND.handoverReceived,
5583
+ [MOVE_KIND.transfer]: MOVE_KIND.transferReceived
5584
+ };
5585
+ var DAY_MS = 864e5;
5586
+ var DATE_RE = /^\d{4}-\d{2}-\d{2}$/;
5587
+ function isMoveExpiry(value) {
5588
+ return typeof value === "string" && (DATE_RE.test(value) && !Number.isNaN(Date.parse(value)) || isIsoDateTime(value));
5589
+ }
5590
+ function moveExpiryText(expiry) {
5591
+ if (!expiry) return void 0;
5592
+ if (typeof expiry === "string") return isMoveExpiry(expiry) ? expiry : void 0;
5593
+ if (Number.isNaN(expiry.getTime())) return void 0;
5594
+ return expiry.getTime() % DAY_MS === 0 ? expiry.toISOString().slice(0, 10) : expiry.toISOString();
5595
+ }
5596
+ function isMoveRecord(record) {
5597
+ const r = record;
5598
+ return !!r && typeof r === "object" && typeof r.moveId === "string" && typeof r.kind === "string";
5599
+ }
5600
+ function namesALot(lotClass) {
5601
+ try {
5602
+ return !!parseEpc(lotClass)?.lot;
5603
+ } catch {
5604
+ return false;
5605
+ }
5606
+ }
5607
+ function moveFactOf(record, takes) {
5608
+ const r = record;
5609
+ if (!isMoveRecord(r)) return { errors: ["the record is not a move: moveId and kind are needed"] };
5610
+ const kind = r.kind;
5611
+ if (!Object.values(MOVE_KIND).includes(kind)) return { errors: [`${kind} is not a move kind`] };
5612
+ if (takes && !takes.includes(kind)) return { errors: [`a move of kind ${kind} is not one this receiver takes`] };
5613
+ const errors = [];
5614
+ const text = (key) => typeof r[key] === "string" && r[key].trim() !== "";
5615
+ const trimmed = (key) => r[key].trim();
5616
+ const quantity = (atLeast) => {
5617
+ const q = r.quantity;
5618
+ const ok = typeof q === "number" && Number.isFinite(q) && (atLeast === "above-zero" ? q > 0 : q >= 0);
5619
+ if (!ok) errors.push(atLeast === "above-zero" ? "quantity must be a number above 0" : "quantity must be a number, 0 or above");
5620
+ };
5621
+ const uom = () => typeof r.uom === "string" && r.uom.trim() ? { uom: r.uom.trim() } : {};
5622
+ if (!text("moveId")) errors.push("moveId is empty");
5623
+ if (r.uom !== void 0 && typeof r.uom !== "string") errors.push("uom must be text");
5624
+ switch (kind) {
5625
+ case MOVE_KIND.issue: {
5626
+ if (!text("order")) errors.push("order is missing: an issue names the production order it serves");
5627
+ if (!text("unit")) errors.push("unit is missing: an issue names the container at the line");
5628
+ if (!text("lotClass")) errors.push("lotClass is missing");
5629
+ else if (!namesALot(trimmed("lotClass"))) errors.push(`${r.lotClass} does not name a lot`);
5630
+ if (!text("to")) errors.push("to is missing: an issue names the line place");
5631
+ if (r.expiry !== void 0 && !isMoveExpiry(r.expiry)) errors.push("expiry is not a date (YYYY-MM-DD) or an instant with its offset");
5632
+ quantity("above-zero");
5633
+ if (errors.length) return { errors };
5634
+ return {
5635
+ fact: {
5636
+ moveId: trimmed("moveId"),
5637
+ kind: MOVE_KIND.issue,
5638
+ order: trimmed("order"),
5639
+ unit: trimmed("unit"),
5640
+ lotClass: trimmed("lotClass"),
5641
+ quantity: r.quantity,
5642
+ ...uom(),
5643
+ to: trimmed("to"),
5644
+ ...typeof r.expiry === "string" ? { expiry: r.expiry } : {},
5645
+ ...text("supplierLot") ? { supplierLot: trimmed("supplierLot") } : {}
5646
+ }
5647
+ };
5648
+ }
5649
+ case MOVE_KIND.issueCancel:
5650
+ case MOVE_KIND.receipt: {
5651
+ if (!text("issue")) errors.push(`issue is missing: ${kind === MOVE_KIND.receipt ? "a receipt names the issue it takes from" : "a cancel names the issue it takes back"}`);
5652
+ quantity(kind === MOVE_KIND.receipt ? "above-zero" : "zero-or-more");
5653
+ if (errors.length) return { errors };
5654
+ return { fact: { moveId: trimmed("moveId"), kind, issue: trimmed("issue"), quantity: r.quantity, ...uom() } };
5655
+ }
5656
+ case MOVE_KIND.return:
5657
+ case MOVE_KIND.handover:
5658
+ case MOVE_KIND.transfer: {
5659
+ if (!text("lotClass")) errors.push("lotClass is missing");
5660
+ else if (kind !== MOVE_KIND.transfer && !namesALot(trimmed("lotClass"))) errors.push(`${r.lotClass} does not name a lot`);
5661
+ if (!text("from")) errors.push("from is missing: the place it leaves");
5662
+ if (r.order !== void 0 && !text("order")) errors.push("order must be text");
5663
+ if (r.expiry !== void 0 && !isMoveExpiry(r.expiry)) errors.push("expiry is not a date (YYYY-MM-DD) or an instant with its offset");
5664
+ if (r.units !== void 0 && (!Array.isArray(r.units) || !r.units.length || !r.units.every((unit) => typeof unit === "string" && unit.trim()))) {
5665
+ errors.push("units must be a list of unit identifiers");
5666
+ }
5667
+ quantity("above-zero");
5668
+ if (errors.length) return { errors };
5669
+ return {
5670
+ fact: {
5671
+ moveId: trimmed("moveId"),
5672
+ kind,
5673
+ lotClass: trimmed("lotClass"),
5674
+ quantity: r.quantity,
5675
+ ...uom(),
5676
+ from: trimmed("from"),
5677
+ ...text("order") ? { order: trimmed("order") } : {},
5678
+ ...typeof r.expiry === "string" ? { expiry: r.expiry } : {},
5679
+ ...Array.isArray(r.units) ? { units: r.units.map((unit) => unit.trim()) } : {}
5680
+ }
5681
+ };
5682
+ }
5683
+ default: {
5684
+ if (!text("dispatch")) errors.push("dispatch is missing: it names what was sent");
5685
+ quantity("zero-or-more");
5686
+ if (errors.length) return { errors };
5687
+ return { fact: { moveId: trimmed("moveId"), kind, dispatch: trimmed("dispatch"), quantity: r.quantity, ...uom() } };
5688
+ }
5689
+ }
5690
+ }
5691
+ function issueMoveFactOf(input) {
5692
+ return {
5693
+ moveId: input.moveId,
5694
+ kind: MOVE_KIND.issue,
5695
+ order: input.order,
5696
+ unit: input.unit,
5697
+ lotClass: input.lotClass,
5698
+ quantity: input.quantity,
5699
+ ...input.uom ? { uom: input.uom } : {},
5700
+ to: input.to,
5701
+ ...input.expiry ? { expiry: input.expiry } : {},
5702
+ ...input.supplierLot ? { supplierLot: input.supplierLot } : {}
5703
+ };
5704
+ }
5705
+ function issueCancelMoveFactOf(input) {
5706
+ return { moveId: input.moveId, kind: MOVE_KIND.issueCancel, issue: input.issue, quantity: input.quantity, ...input.uom ? { uom: input.uom } : {} };
5707
+ }
5708
+ function receiptMoveFactOf(input) {
5709
+ return { moveId: input.moveId, kind: MOVE_KIND.receipt, issue: input.issue, quantity: input.quantity, ...input.uom ? { uom: input.uom } : {} };
5710
+ }
5711
+ function dispatchMoveFactOf(input) {
5712
+ const expiry = moveExpiryText(input.expiry);
5713
+ return {
5714
+ moveId: input.moveId,
5715
+ kind: input.kind,
5716
+ lotClass: input.lotClass,
5717
+ quantity: input.quantity,
5718
+ ...input.uom ? { uom: input.uom } : {},
5719
+ from: input.from,
5720
+ ...input.order ? { order: input.order } : {},
5721
+ ...expiry ? { expiry } : {},
5722
+ ...input.units?.length ? { units: input.units } : {}
5723
+ };
5724
+ }
5725
+ function receivedMoveFactOf(input) {
5726
+ return { moveId: input.moveId, kind: RECEIVED_MOVE_KIND[input.sent], dispatch: input.dispatch, quantity: input.quantity, ...input.uom ? { uom: input.uom } : {} };
5727
+ }
5728
+
5729
+ // src/dock-facts.ts
5730
+ var DOCK_FACT_KIND = {
5731
+ /** warehouse → yard: this order needs a slot at a door. */
5732
+ slotRequest: "slot-request",
5733
+ /** warehouse → yard: the order no longer needs it. */
5734
+ slotWithdrawn: "slot-withdrawn",
5735
+ /** yard → warehouse: the appointment for a request, as it stands now - booked, moved, cancelled, at the door, done. */
5736
+ appointment: "appointment",
5737
+ /** yard → warehouse: the yard will not book this request, and why. */
5738
+ slotDeclined: "slot-declined"
5739
+ };
5740
+ function isDockRecord(record) {
5741
+ const r = record;
5742
+ return !!r && typeof r === "object" && typeof r.factId === "string" && Object.values(DOCK_FACT_KIND).includes(r.kind);
5743
+ }
5744
+ var isInstant = (v) => isIsoDateTime(v);
5745
+ function dockFactOf(record, takes) {
5746
+ const r = record;
5747
+ if (!r || typeof r !== "object" || typeof r.factId !== "string" || typeof r.kind !== "string") return { errors: ["the record is not a dock fact: factId and kind are needed"] };
5748
+ const kind = r.kind;
5749
+ if (!Object.values(DOCK_FACT_KIND).includes(kind)) return { errors: [`${kind} is not a dock fact kind`] };
5750
+ if (takes && !takes.includes(kind)) return { errors: [`a dock fact of kind ${kind} is not one this receiver takes`] };
5751
+ const errors = [];
5752
+ const text = (key) => typeof r[key] === "string" && r[key].trim() !== "";
5753
+ const s = (key) => r[key].trim();
5754
+ if (!text("factId")) errors.push("factId is empty");
5755
+ switch (kind) {
5756
+ case DOCK_FACT_KIND.slotRequest: {
5757
+ if (!text("order")) errors.push("order is missing: a request names the warehouse order");
5758
+ if (!Object.values(YMS_ORDER_KIND).includes(r.direction)) errors.push(`direction must be ${Object.values(YMS_ORDER_KIND).join(" or ")}`);
5759
+ for (const key of ["wantedFrom", "wantedTo"]) if (r[key] !== void 0 && !isInstant(r[key])) errors.push(`${key} is not an instant`);
5760
+ if (isInstant(r.wantedFrom) && isInstant(r.wantedTo) && Date.parse(r.wantedTo) <= Date.parse(r.wantedFrom)) errors.push("wantedTo is not after wantedFrom");
5761
+ const documents = r.documents;
5762
+ if (documents !== void 0 && (!Array.isArray(documents) || documents.some((one) => !one || typeof one.id !== "string" || !one.id.trim()))) errors.push("documents must each have an id");
5763
+ if (errors.length) return { errors };
5764
+ return {
5765
+ fact: {
5766
+ factId: s("factId"),
5767
+ kind,
5768
+ order: s("order"),
5769
+ direction: r.direction,
5770
+ ...isInstant(r.wantedFrom) ? { wantedFrom: r.wantedFrom } : {},
5771
+ ...isInstant(r.wantedTo) ? { wantedTo: r.wantedTo } : {},
5772
+ ...text("dock") ? { dock: s("dock") } : {},
5773
+ ...Array.isArray(documents) && documents.length ? { documents: documents.map((one) => ({ ...one.type ? { type: String(one.type) } : {}, id: one.id.trim() })) } : {},
5774
+ ...text("note") ? { note: s("note") } : {}
5775
+ }
5776
+ };
5777
+ }
5778
+ case DOCK_FACT_KIND.slotWithdrawn: {
5779
+ if (!text("request")) errors.push("request is missing: a withdrawal names the request");
5780
+ if (errors.length) return { errors };
5781
+ return { fact: { factId: s("factId"), kind, request: s("request"), ...text("reason") ? { reason: s("reason") } : {} } };
5782
+ }
5783
+ case DOCK_FACT_KIND.appointment: {
5784
+ for (const key of ["request", "order", "appointment", "dockDoor"]) if (!text(key)) errors.push(`${key} is missing`);
5785
+ if (!isYmsAppointmentStatus(r.status)) errors.push(`status ${String(r.status)} is not an appointment status`);
5786
+ if (!isInstant(r.startAt) || !isInstant(r.endAt)) errors.push("startAt and endAt must be instants");
5787
+ if (r.cancelReason !== void 0 && !YMS_APPOINTMENT_CANCEL_REASON.includes(r.cancelReason)) errors.push(`cancelReason ${String(r.cancelReason)} is not one`);
5788
+ if (r.status === "cancelled" && r.cancelReason === void 0) errors.push("a cancelled appointment says why (cancelReason)");
5789
+ if (r.status !== "cancelled" && r.cancelReason !== void 0) errors.push("only a cancelled appointment carries a cancelReason");
5790
+ if (isInstant(r.startAt) && isInstant(r.endAt) && Date.parse(r.endAt) <= Date.parse(r.startAt)) errors.push("endAt is not after startAt");
5791
+ if (errors.length) return { errors };
5792
+ return {
5793
+ fact: {
5794
+ factId: s("factId"),
5795
+ kind,
5796
+ request: s("request"),
5797
+ order: s("order"),
5798
+ appointment: s("appointment"),
5799
+ status: r.status,
5800
+ dockDoor: s("dockDoor"),
5801
+ startAt: s("startAt"),
5802
+ endAt: s("endAt"),
5803
+ ...r.cancelReason !== void 0 ? { cancelReason: r.cancelReason } : {}
5804
+ }
5805
+ };
5806
+ }
5807
+ default: {
5808
+ for (const key of ["request", "order", "reason"]) if (!text(key)) errors.push(`${key} is missing`);
5809
+ if (errors.length) return { errors };
5810
+ return { fact: { factId: s("factId"), kind: DOCK_FACT_KIND.slotDeclined, request: s("request"), order: s("order"), reason: s("reason") } };
5811
+ }
5812
+ }
5813
+ }
5363
5814
 
5364
5815
  // src/lot-lineage.ts
5365
5816
  function lotLineageOf(event, classOfUnit) {
@@ -5399,12 +5850,14 @@ function inheritedExpiry(inputExpiries) {
5399
5850
  0 && (module.exports = {
5400
5851
  ABSENCE,
5401
5852
  ALLOCATION_POLICY,
5853
+ ASSET_STATUS,
5402
5854
  BASIS_UNKNOWN,
5403
5855
  BIZSTEP,
5404
5856
  BTT,
5405
5857
  BTT_PRODORDER,
5406
5858
  CAPABILITIES,
5407
5859
  CAPABILITY_KEYS,
5860
+ CARRIED_HEADER_FIELDS,
5408
5861
  CBV_BIZSTEP,
5409
5862
  CMD,
5410
5863
  COMMAND_EVENT,
@@ -5412,6 +5865,8 @@ function inheritedExpiry(inputExpiries) {
5412
5865
  COMMAND_STATE,
5413
5866
  DISP,
5414
5867
  DISPOSITION_DECISION,
5868
+ DOCK_DOOR_STATUS,
5869
+ DOCK_FACT_KIND,
5415
5870
  DOMAIN_CATALOG,
5416
5871
  DOMAIN_SYSTEMS,
5417
5872
  EMPTY_BECAUSE,
@@ -5427,9 +5882,11 @@ function inheritedExpiry(inputExpiries) {
5427
5882
  EQUIPMENT_STATUS,
5428
5883
  ERP_CAPABILITY,
5429
5884
  ERP_MASTER_AXIS,
5885
+ FIELDS_NOT_CARRIED,
5430
5886
  FIRST_PASS_RULE,
5431
5887
  GUARD_PRAGMA,
5432
5888
  HATIOLAB_VOCABULARY,
5889
+ HEADER_FIELDS_PARTITIONED,
5433
5890
  ILMD_ATTR,
5434
5891
  LOCATION_SATURATION_NEAR,
5435
5892
  MATERIAL_ACTUAL_USE,
@@ -5440,24 +5897,35 @@ function inheritedExpiry(inputExpiries) {
5440
5897
  MES_LOCATION_TYPES,
5441
5898
  MES_TYPES,
5442
5899
  METER_DIRECTION,
5900
+ MOVE_KIND,
5443
5901
  OBSERVATION_BASIS,
5444
5902
  OPERATIONAL_ATTENTION_CONTRACT,
5445
5903
  OPERATIONAL_ATTENTION_IMPACTS,
5904
+ OPERATIONAL_ATTENTION_KIND_PATTERN,
5446
5905
  OPERATIONAL_ATTENTION_TRANSITIONS,
5447
5906
  OP_EVENT,
5448
5907
  OP_PARAM,
5449
5908
  ORDER_FOLD_DEFAULT,
5450
5909
  ORDER_FOLD_HOUR_MS,
5451
5910
  ORDER_TERMINAL_STATUS,
5911
+ PARTY_ROLE,
5912
+ PARTY_URI_MAX_LENGTH,
5913
+ PARTY_URI_RECOMMENDED_LENGTH,
5914
+ PERSON_STATUS,
5452
5915
  PRIORITY_UNSET,
5453
5916
  PRIVATE_BIZSTEP,
5454
5917
  READ_BASIS,
5918
+ RECEIVED_MOVE_KIND,
5455
5919
  REFUSED_WITHOUT_CODE,
5456
5920
  RESOURCE_KIND,
5457
5921
  RETIRED_VOCABULARY,
5458
5922
  RETURN_TO_SUPPLIER,
5459
5923
  SCHEDULE_STATUS,
5460
5924
  SIGNATURE_REJECTED_REASONS,
5925
+ SOURCE_DEST_PARTY_TYPE,
5926
+ TASK_STATUS,
5927
+ TASK_TERMINAL_STATUS,
5928
+ TRAILER_LOAD,
5461
5929
  TWIN_AXES,
5462
5930
  TWIN_PROPERTIES,
5463
5931
  TWIN_RELATIONS,
@@ -5476,14 +5944,18 @@ function inheritedExpiry(inputExpiries) {
5476
5944
  WMS_RECEIVING_ORDER_KINDS,
5477
5945
  WMS_TYPES,
5478
5946
  YARD_BIZSTEP,
5947
+ YARD_MODE,
5479
5948
  YARD_PRIVATE_BIZSTEP,
5949
+ YMS_APPOINTMENT_CANCEL_REASON,
5950
+ YMS_APPOINTMENT_STATUS,
5480
5951
  YMS_LOCATION_TYPES,
5952
+ YMS_ORDER_KIND,
5953
+ YMS_TASK_KIND,
5481
5954
  YMS_TYPES,
5482
5955
  acceptsPerformance,
5483
5956
  activeShiftAt,
5484
5957
  activeShiftOf,
5485
5958
  aggregationEvent,
5486
- analyzeCapacity,
5487
5959
  approveCommand,
5488
5960
  asApproved,
5489
5961
  assertOperationalAttentionV1,
@@ -5511,18 +5983,20 @@ function inheritedExpiry(inputExpiries) {
5511
5983
  computeOee,
5512
5984
  conversionFactorOf,
5513
5985
  criterionSaysNothing,
5986
+ dispatchMoveFactOf,
5987
+ dockDoorCapacityOf,
5988
+ dockDoorStatusOf,
5989
+ dockFactOf,
5514
5990
  documentPath,
5515
5991
  dueStatusOf,
5516
5992
  effectivityAt,
5517
5993
  electricalUpstreamOf,
5518
- emptyFoldedOrders,
5519
5994
  epcCandidatesOfGs1,
5520
5995
  equipmentClassMembership,
5521
5996
  erpCapabilityGaps,
5522
5997
  expiryFromAttributes,
5523
5998
  finishedFlowOrdersWithin,
5524
5999
  finishedWindowStartMs,
5525
- foldOrdersInto,
5526
6000
  foldedOrderCount,
5527
6001
  gdtiUri,
5528
6002
  generationFractionAt,
@@ -5533,6 +6007,8 @@ function inheritedExpiry(inputExpiries) {
5533
6007
  hierarchyOf,
5534
6008
  homeOf,
5535
6009
  hourStartOf,
6010
+ identifierText,
6011
+ identifierUnderNamespace,
5536
6012
  identityGroundingOf,
5537
6013
  inWorkCalendar,
5538
6014
  inWorkCalendarAt,
@@ -5550,8 +6026,10 @@ function inheritedExpiry(inputExpiries) {
5550
6026
  inheritedExpiry,
5551
6027
  inheritedLotUse,
5552
6028
  isAggregationRecord,
6029
+ isAppointmentClosed,
5553
6030
  isCacheableTense,
5554
6031
  isCommandTerminal,
6032
+ isDockRecord,
5555
6033
  isElectricalLocationType,
5556
6034
  isEnergyBillRecord,
5557
6035
  isEnergyEquipmentRecord,
@@ -5566,22 +6044,33 @@ function inheritedExpiry(inputExpiries) {
5566
6044
  isEquipmentStatus,
5567
6045
  isFailureStatus,
5568
6046
  isFlowOrder,
6047
+ isIsoDateTime,
5569
6048
  isMasterDataRecord,
5570
6049
  isMaterialExecutionBasis,
6050
+ isMoveExpiry,
6051
+ isMoveRecord,
5571
6052
  isOperationalAttentionV1,
5572
6053
  isOperationalRecord,
5573
6054
  isOrderTerminal,
6055
+ isPartyRef,
6056
+ isPartyUri,
5574
6057
  isPlannedStopStatus,
5575
6058
  isRecipeExecutionBasis,
6059
+ isRecordShapeError,
5576
6060
  isResourceKind,
6061
+ isTaskTerminal,
5577
6062
  isTestSpecificationBasis,
5578
6063
  isTransformationRecord,
5579
6064
  isWebhookDeliveryCode,
5580
6065
  isWebhookSecretSegment,
5581
6066
  isWorkShiftExecutionBasis,
6067
+ isYmsAppointmentStatus,
5582
6068
  isoDurationHours,
6069
+ issueCancelMoveFactOf,
6070
+ issueMoveFactOf,
5583
6071
  itemClassOf,
5584
6072
  itemKeyOf,
6073
+ itemMaterialDefinitionId,
5585
6074
  judgeAgainstSpec,
5586
6075
  levelOfLocationType,
5587
6076
  lgtinClass,
@@ -5599,6 +6088,8 @@ function inheritedExpiry(inputExpiries) {
5599
6088
  meetsTests,
5600
6089
  minuteOfDayAt,
5601
6090
  missingCommandPayload,
6091
+ moveExpiryText,
6092
+ moveFactOf,
5602
6093
  nextCommandState,
5603
6094
  nonWorkingMsIn,
5604
6095
  normalizeEquipmentStatus,
@@ -5607,28 +6098,35 @@ function inheritedExpiry(inputExpiries) {
5607
6098
  observationAt,
5608
6099
  offCalendarAt,
5609
6100
  offCalendarReasonAt,
6101
+ operationalAttentionErrors,
6102
+ operationalAttentionOf,
5610
6103
  operationalIdentityField,
5611
6104
  operationalKindOf,
5612
- operationsCapabilityOf,
5613
6105
  orderFoldPolicyOf,
6106
+ outboxInputsOfEvent,
5614
6107
  outsideLimit,
5615
6108
  parseEpc,
5616
6109
  parseGs1,
5617
6110
  parseIsoDuration,
5618
6111
  partitionLensLocations,
6112
+ partyIdentifierViolation,
6113
+ partyRowIdOf,
6114
+ partyUri,
6115
+ partyUriLengthNote,
5619
6116
  passThroughReversible,
5620
6117
  performanceKey,
5621
6118
  periodFactId,
5622
- planOrderFold,
5623
6119
  priorityRank,
5624
6120
  procedureViolations,
5625
6121
  propertiesOf,
5626
- pruneFoldedHours,
5627
6122
  quantityIn,
5628
6123
  ratedUsageOf,
5629
6124
  readBoardAssets,
5630
6125
  readBoardEquipment,
5631
6126
  readBoardLocations,
6127
+ receiptMoveFactOf,
6128
+ receivedMoveFactOf,
6129
+ recordsOfEvent,
5632
6130
  referencedLocationIds,
5633
6131
  relationsFrom,
5634
6132
  relationsTo,
@@ -5645,7 +6143,6 @@ function inheritedExpiry(inputExpiries) {
5645
6143
  splitRelationIds,
5646
6144
  ssccDigitsOf,
5647
6145
  ssccUri,
5648
- standsNewOrderRow,
5649
6146
  stateFieldsOf,
5650
6147
  subLotIdOf,
5651
6148
  tenseOf,