@operato/ops-contract 0.9.43 → 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.
@@ -28,6 +28,7 @@ __export(index_exports, {
28
28
  BTT_PRODORDER: () => BTT_PRODORDER,
29
29
  CAPABILITIES: () => CAPABILITIES,
30
30
  CAPABILITY_KEYS: () => CAPABILITY_KEYS,
31
+ CARRIED_HEADER_FIELDS: () => CARRIED_HEADER_FIELDS,
31
32
  CBV_BIZSTEP: () => CBV_BIZSTEP,
32
33
  CMD: () => CMD,
33
34
  COMMAND_EVENT: () => COMMAND_EVENT,
@@ -36,6 +37,7 @@ __export(index_exports, {
36
37
  DISP: () => DISP,
37
38
  DISPOSITION_DECISION: () => DISPOSITION_DECISION,
38
39
  DOCK_DOOR_STATUS: () => DOCK_DOOR_STATUS,
40
+ DOCK_FACT_KIND: () => DOCK_FACT_KIND,
39
41
  DOMAIN_CATALOG: () => DOMAIN_CATALOG,
40
42
  DOMAIN_SYSTEMS: () => DOMAIN_SYSTEMS,
41
43
  EMPTY_BECAUSE: () => EMPTY_BECAUSE,
@@ -51,9 +53,11 @@ __export(index_exports, {
51
53
  EQUIPMENT_STATUS: () => EQUIPMENT_STATUS,
52
54
  ERP_CAPABILITY: () => ERP_CAPABILITY,
53
55
  ERP_MASTER_AXIS: () => ERP_MASTER_AXIS,
56
+ FIELDS_NOT_CARRIED: () => FIELDS_NOT_CARRIED,
54
57
  FIRST_PASS_RULE: () => FIRST_PASS_RULE,
55
58
  GUARD_PRAGMA: () => GUARD_PRAGMA,
56
59
  HATIOLAB_VOCABULARY: () => HATIOLAB_VOCABULARY,
60
+ HEADER_FIELDS_PARTITIONED: () => HEADER_FIELDS_PARTITIONED,
57
61
  ILMD_ATTR: () => ILMD_ATTR,
58
62
  LOCATION_SATURATION_NEAR: () => LOCATION_SATURATION_NEAR,
59
63
  MATERIAL_ACTUAL_USE: () => MATERIAL_ACTUAL_USE,
@@ -64,9 +68,11 @@ __export(index_exports, {
64
68
  MES_LOCATION_TYPES: () => MES_LOCATION_TYPES,
65
69
  MES_TYPES: () => MES_TYPES,
66
70
  METER_DIRECTION: () => METER_DIRECTION,
71
+ MOVE_KIND: () => MOVE_KIND,
67
72
  OBSERVATION_BASIS: () => OBSERVATION_BASIS,
68
73
  OPERATIONAL_ATTENTION_CONTRACT: () => OPERATIONAL_ATTENTION_CONTRACT,
69
74
  OPERATIONAL_ATTENTION_IMPACTS: () => OPERATIONAL_ATTENTION_IMPACTS,
75
+ OPERATIONAL_ATTENTION_KIND_PATTERN: () => OPERATIONAL_ATTENTION_KIND_PATTERN,
70
76
  OPERATIONAL_ATTENTION_TRANSITIONS: () => OPERATIONAL_ATTENTION_TRANSITIONS,
71
77
  OP_EVENT: () => OP_EVENT,
72
78
  OP_PARAM: () => OP_PARAM,
@@ -80,6 +86,7 @@ __export(index_exports, {
80
86
  PRIORITY_UNSET: () => PRIORITY_UNSET,
81
87
  PRIVATE_BIZSTEP: () => PRIVATE_BIZSTEP,
82
88
  READ_BASIS: () => READ_BASIS,
89
+ RECEIVED_MOVE_KIND: () => RECEIVED_MOVE_KIND,
83
90
  REFUSED_WITHOUT_CODE: () => REFUSED_WITHOUT_CODE,
84
91
  RESOURCE_KIND: () => RESOURCE_KIND,
85
92
  RETIRED_VOCABULARY: () => RETIRED_VOCABULARY,
@@ -87,6 +94,8 @@ __export(index_exports, {
87
94
  SCHEDULE_STATUS: () => SCHEDULE_STATUS,
88
95
  SIGNATURE_REJECTED_REASONS: () => SIGNATURE_REJECTED_REASONS,
89
96
  SOURCE_DEST_PARTY_TYPE: () => SOURCE_DEST_PARTY_TYPE,
97
+ TASK_STATUS: () => TASK_STATUS,
98
+ TASK_TERMINAL_STATUS: () => TASK_TERMINAL_STATUS,
90
99
  TRAILER_LOAD: () => TRAILER_LOAD,
91
100
  TWIN_AXES: () => TWIN_AXES,
92
101
  TWIN_PROPERTIES: () => TWIN_PROPERTIES,
@@ -118,7 +127,6 @@ __export(index_exports, {
118
127
  activeShiftAt: () => activeShiftAt,
119
128
  activeShiftOf: () => activeShiftOf,
120
129
  aggregationEvent: () => aggregationEvent,
121
- analyzeCapacity: () => analyzeCapacity,
122
130
  approveCommand: () => approveCommand,
123
131
  asApproved: () => asApproved,
124
132
  assertOperationalAttentionV1: () => assertOperationalAttentionV1,
@@ -146,19 +154,20 @@ __export(index_exports, {
146
154
  computeOee: () => computeOee,
147
155
  conversionFactorOf: () => conversionFactorOf,
148
156
  criterionSaysNothing: () => criterionSaysNothing,
157
+ dispatchMoveFactOf: () => dispatchMoveFactOf,
158
+ dockDoorCapacityOf: () => dockDoorCapacityOf,
149
159
  dockDoorStatusOf: () => dockDoorStatusOf,
160
+ dockFactOf: () => dockFactOf,
150
161
  documentPath: () => documentPath,
151
162
  dueStatusOf: () => dueStatusOf,
152
163
  effectivityAt: () => effectivityAt,
153
164
  electricalUpstreamOf: () => electricalUpstreamOf,
154
- emptyFoldedOrders: () => emptyFoldedOrders,
155
165
  epcCandidatesOfGs1: () => epcCandidatesOfGs1,
156
166
  equipmentClassMembership: () => equipmentClassMembership,
157
167
  erpCapabilityGaps: () => erpCapabilityGaps,
158
168
  expiryFromAttributes: () => expiryFromAttributes,
159
169
  finishedFlowOrdersWithin: () => finishedFlowOrdersWithin,
160
170
  finishedWindowStartMs: () => finishedWindowStartMs,
161
- foldOrdersInto: () => foldOrdersInto,
162
171
  foldedOrderCount: () => foldedOrderCount,
163
172
  gdtiUri: () => gdtiUri,
164
173
  generationFractionAt: () => generationFractionAt,
@@ -191,6 +200,7 @@ __export(index_exports, {
191
200
  isAppointmentClosed: () => isAppointmentClosed,
192
201
  isCacheableTense: () => isCacheableTense,
193
202
  isCommandTerminal: () => isCommandTerminal,
203
+ isDockRecord: () => isDockRecord,
194
204
  isElectricalLocationType: () => isElectricalLocationType,
195
205
  isEnergyBillRecord: () => isEnergyBillRecord,
196
206
  isEnergyEquipmentRecord: () => isEnergyEquipmentRecord,
@@ -205,8 +215,11 @@ __export(index_exports, {
205
215
  isEquipmentStatus: () => isEquipmentStatus,
206
216
  isFailureStatus: () => isFailureStatus,
207
217
  isFlowOrder: () => isFlowOrder,
218
+ isIsoDateTime: () => isIsoDateTime,
208
219
  isMasterDataRecord: () => isMasterDataRecord,
209
220
  isMaterialExecutionBasis: () => isMaterialExecutionBasis,
221
+ isMoveExpiry: () => isMoveExpiry,
222
+ isMoveRecord: () => isMoveRecord,
210
223
  isOperationalAttentionV1: () => isOperationalAttentionV1,
211
224
  isOperationalRecord: () => isOperationalRecord,
212
225
  isOrderTerminal: () => isOrderTerminal,
@@ -214,7 +227,9 @@ __export(index_exports, {
214
227
  isPartyUri: () => isPartyUri,
215
228
  isPlannedStopStatus: () => isPlannedStopStatus,
216
229
  isRecipeExecutionBasis: () => isRecipeExecutionBasis,
230
+ isRecordShapeError: () => isRecordShapeError,
217
231
  isResourceKind: () => isResourceKind,
232
+ isTaskTerminal: () => isTaskTerminal,
218
233
  isTestSpecificationBasis: () => isTestSpecificationBasis,
219
234
  isTransformationRecord: () => isTransformationRecord,
220
235
  isWebhookDeliveryCode: () => isWebhookDeliveryCode,
@@ -222,6 +237,8 @@ __export(index_exports, {
222
237
  isWorkShiftExecutionBasis: () => isWorkShiftExecutionBasis,
223
238
  isYmsAppointmentStatus: () => isYmsAppointmentStatus,
224
239
  isoDurationHours: () => isoDurationHours,
240
+ issueCancelMoveFactOf: () => issueCancelMoveFactOf,
241
+ issueMoveFactOf: () => issueMoveFactOf,
225
242
  itemClassOf: () => itemClassOf,
226
243
  itemKeyOf: () => itemKeyOf,
227
244
  itemMaterialDefinitionId: () => itemMaterialDefinitionId,
@@ -242,6 +259,8 @@ __export(index_exports, {
242
259
  meetsTests: () => meetsTests,
243
260
  minuteOfDayAt: () => minuteOfDayAt,
244
261
  missingCommandPayload: () => missingCommandPayload,
262
+ moveExpiryText: () => moveExpiryText,
263
+ moveFactOf: () => moveFactOf,
245
264
  nextCommandState: () => nextCommandState,
246
265
  nonWorkingMsIn: () => nonWorkingMsIn,
247
266
  normalizeEquipmentStatus: () => normalizeEquipmentStatus,
@@ -250,10 +269,12 @@ __export(index_exports, {
250
269
  observationAt: () => observationAt,
251
270
  offCalendarAt: () => offCalendarAt,
252
271
  offCalendarReasonAt: () => offCalendarReasonAt,
272
+ operationalAttentionErrors: () => operationalAttentionErrors,
273
+ operationalAttentionOf: () => operationalAttentionOf,
253
274
  operationalIdentityField: () => operationalIdentityField,
254
275
  operationalKindOf: () => operationalKindOf,
255
- operationsCapabilityOf: () => operationsCapabilityOf,
256
276
  orderFoldPolicyOf: () => orderFoldPolicyOf,
277
+ outboxInputsOfEvent: () => outboxInputsOfEvent,
257
278
  outsideLimit: () => outsideLimit,
258
279
  parseEpc: () => parseEpc,
259
280
  parseGs1: () => parseGs1,
@@ -266,16 +287,17 @@ __export(index_exports, {
266
287
  passThroughReversible: () => passThroughReversible,
267
288
  performanceKey: () => performanceKey,
268
289
  periodFactId: () => periodFactId,
269
- planOrderFold: () => planOrderFold,
270
290
  priorityRank: () => priorityRank,
271
291
  procedureViolations: () => procedureViolations,
272
292
  propertiesOf: () => propertiesOf,
273
- pruneFoldedHours: () => pruneFoldedHours,
274
293
  quantityIn: () => quantityIn,
275
294
  ratedUsageOf: () => ratedUsageOf,
276
295
  readBoardAssets: () => readBoardAssets,
277
296
  readBoardEquipment: () => readBoardEquipment,
278
297
  readBoardLocations: () => readBoardLocations,
298
+ receiptMoveFactOf: () => receiptMoveFactOf,
299
+ receivedMoveFactOf: () => receivedMoveFactOf,
300
+ recordsOfEvent: () => recordsOfEvent,
279
301
  referencedLocationIds: () => referencedLocationIds,
280
302
  relationsFrom: () => relationsFrom,
281
303
  relationsTo: () => relationsTo,
@@ -292,7 +314,6 @@ __export(index_exports, {
292
314
  splitRelationIds: () => splitRelationIds,
293
315
  ssccDigitsOf: () => ssccDigitsOf,
294
316
  ssccUri: () => ssccUri,
295
- standsNewOrderRow: () => standsNewOrderRow,
296
317
  stateFieldsOf: () => stateFieldsOf,
297
318
  subLotIdOf: () => subLotIdOf,
298
319
  tenseOf: () => tenseOf,
@@ -484,6 +505,11 @@ function ratedUsageOf(r) {
484
505
  }
485
506
 
486
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
+ }
487
513
  var ORDER_TERMINAL_STATUS = ["completed", "cancelled"];
488
514
  function isOrderTerminal(o) {
489
515
  const status = String(o?.status ?? "").trim().toLowerCase();
@@ -1283,9 +1309,6 @@ function isoDurationHours(iso) {
1283
1309
  if (!m) throw new Error(`\uAE30\uAC04 \uD45C\uAE30\uB97C \uC77D\uC744 \uC218 \uC5C6\uB2E4: ${iso}`);
1284
1310
  return Number(m[1] ?? 0) * 24 + Number(m[2] ?? 0) + Number(m[3] ?? 0) / 60 + Number(m[4] ?? 0) / 3600;
1285
1311
  }
1286
- function paramOf(op, id) {
1287
- return op.parameters?.find((p) => p.id === id)?.value;
1288
- }
1289
1312
  function workingTimeOfWeek(calendar, weekStartMs, utcOffsetMinutes) {
1290
1313
  if (!calendar?.length) return { hoursPerWeek: 7 * 24, daysPerWeek: 7 };
1291
1314
  let minutes = 0;
@@ -1299,76 +1322,6 @@ function workingTimeOfWeek(calendar, weekStartMs, utcOffsetMinutes) {
1299
1322
  for (const e of calendar) if (e.entryType !== "non-working") for (const d of e.daysOfWeek ?? []) declared.add(d);
1300
1323
  return { hoursPerWeek: minutes / 60, daysPerWeek: declared.size || touched.size };
1301
1324
  }
1302
- function availabilityOf(records) {
1303
- const ratios = records.map((r) => r.mtbfMs && r.mttrMs ? r.mtbfMs / (r.mtbfMs + r.mttrMs) : 1);
1304
- return ratios.length ? ratios.reduce((a, b) => a + b, 0) / ratios.length : 1;
1305
- }
1306
- function analyzeCapacity(input) {
1307
- const { hoursPerWeek, daysPerWeek } = workingTimeOfWeek(input.calendar, input.sampleWeekStartMs, input.utcOffsetMinutes);
1308
- const demandPerHour = hoursPerWeek > 0 ? input.unitsPerDay * daysPerWeek / hoursPerWeek : 0;
1309
- const equipmentByKind = /* @__PURE__ */ new Map();
1310
- for (const e of input.equipment ?? []) {
1311
- const list = equipmentByKind.get(e.kind) ?? [];
1312
- list.push(e);
1313
- equipmentByKind.set(e.kind, list);
1314
- }
1315
- const countByClass = (rows, field) => {
1316
- const out = /* @__PURE__ */ new Map();
1317
- for (const r of rows ?? []) for (const c of r[field] ?? []) out.set(c, (out.get(c) ?? 0) + 1);
1318
- return out;
1319
- };
1320
- const personsByClass = countByClass(input.persons, "personnelClassIds");
1321
- const assetsByClass = countByClass(input.assets, "assetClassIds");
1322
- const slotsByLocationType = /* @__PURE__ */ new Map();
1323
- for (const l of input.locations ?? [])
1324
- if (l.type) slotsByLocationType.set(l.type, (slotsByLocationType.get(l.type) ?? 0) + Math.max(l.capacity ?? 1, 1));
1325
- const order = input.route?.length ? input.route.map((k) => input.operations.find((o) => o.key === k)).filter((o) => !!o) : [...input.operations];
1326
- let downstream = 1;
1327
- const reversed = [];
1328
- for (const op of [...order].reverse()) {
1329
- const cycleHours = isoDurationHours(op.duration) + isoDurationHours(paramOf(op, "setupDuration"));
1330
- downstream *= Number(paramOf(op, "yield") ?? 1);
1331
- const requiredPerHour = downstream > 0 ? demandPerHour / downstream : Infinity;
1332
- const requirements = [];
1333
- const add = (axis, className, quantity, available, availability) => {
1334
- const q = Math.max(quantity, 1);
1335
- requirements.push({
1336
- axis,
1337
- className,
1338
- quantity: q,
1339
- available,
1340
- availability,
1341
- perHour: cycleHours > 0 ? Math.floor(available / q) / cycleHours * availability : Infinity
1342
- });
1343
- };
1344
- const equipSpecs = op.equipmentSpecification?.length ? op.equipmentSpecification.map((s) => ({ className: s.equipmentClass ?? op.resourceType ?? "", quantity: s.quantity })) : op.resourceType ? [{ className: op.resourceType, quantity: 1 }] : [];
1345
- for (const s of equipSpecs) {
1346
- if (!s.className) continue;
1347
- const records = equipmentByKind.get(s.className) ?? [];
1348
- add("equipment", s.className, s.quantity, records.length, availabilityOf(records));
1349
- }
1350
- for (const s of op.personnelSpecification ?? [])
1351
- if (s.personnelClass) add("personnel", s.personnelClass, s.quantity, personsByClass.get(s.personnelClass) ?? 0, 1);
1352
- for (const s of op.physicalAssetSpecification ?? [])
1353
- if (s.assetClass) add("asset", s.assetClass, s.quantity, assetsByClass.get(s.assetClass) ?? 0, 1);
1354
- if (op.locationType) add("location", op.locationType, 1, slotsByLocationType.get(op.locationType) ?? 0, 1);
1355
- const constraint = requirements.length ? requirements.reduce((a, b) => a.perHour <= b.perHour ? a : b) : void 0;
1356
- const perHour = constraint ? constraint.perHour : Infinity;
1357
- reversed.push({ operation: op.key, cycleHours, perHour, requiredPerHour, ok: perHour >= requiredPerHour, constraint, requirements });
1358
- }
1359
- const operations = reversed.reverse();
1360
- const tightest = operations.length ? operations.reduce((a, b) => a.perHour / a.requiredPerHour <= b.perHour / b.requiredPerHour ? a : b) : void 0;
1361
- const headroom = operations.length ? Math.min(...operations.map((o) => o.perHour / o.requiredPerHour)) : Infinity;
1362
- return {
1363
- workingHoursPerWeek: hoursPerWeek,
1364
- workingDaysPerWeek: daysPerWeek,
1365
- demandPerHour,
1366
- operations,
1367
- ...tightest ? { bottleneck: { operation: tightest.operation, axis: tightest.constraint?.axis, className: tightest.constraint?.className } } : {},
1368
- maxUnitsPerDay: input.unitsPerDay * headroom,
1369
- ok: operations.every((o) => o.ok)
1370
- };
1371
- }
1372
1325
  function nonWorkingMsIn(calendar, fromMs, toMs, utcOffsetMinutes) {
1373
1326
  if (!calendar?.length) return void 0;
1374
1327
  if (!Number.isFinite(fromMs) || !Number.isFinite(toMs) || toMs <= fromMs) return void 0;
@@ -1758,6 +1711,9 @@ function transformationEvent(p) {
1758
1711
  return e;
1759
1712
  }
1760
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
+ }
1761
1717
  var TZ_RE = /^[+-]\d{2}:\d{2}$/;
1762
1718
  var ACTIONS = ["ADD", "OBSERVE", "DELETE"];
1763
1719
  var EPC_CLASS_PREFIXES = ["urn:epc:idpat:", "urn:epc:class:"];
@@ -2026,8 +1982,7 @@ var YMS_TASK_KIND = {
2026
1982
  spotLive: "spot-live",
2027
1983
  pull: "pull",
2028
1984
  dwell: "dwell",
2029
- depart: "depart",
2030
- reposition: "reposition"
1985
+ depart: "depart"
2031
1986
  };
2032
1987
  var YARD_MODE = ["drop", "live"];
2033
1988
  var YMS_APPOINTMENT_STATUS = ["scheduled", "checked-in", "at-door", "completed", "cancelled"];
@@ -2041,8 +1996,10 @@ function isAppointmentClosed(status) {
2041
1996
  var DOCK_DOOR_STATUS = ["free", "occupied", "blocked"];
2042
1997
  function dockDoorStatusOf(d) {
2043
1998
  if (d.blocked) return "blocked";
2044
- const cap = typeof d.parallelism === "number" && d.parallelism > 0 ? d.parallelism : 1;
2045
- return (d.occupancy ?? 0) >= cap ? "occupied" : "free";
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));
2046
2003
  }
2047
2004
  var TRAILER_LOAD = ["empty", "loaded"];
2048
2005
 
@@ -2086,7 +2043,7 @@ var MES_TYPES = [
2086
2043
  var MES_COMMANDS = [
2087
2044
  {
2088
2045
  type: "production.order",
2089
- label: "\uC0DD\uC0B0 \uC9C0\uC2DC",
2046
+ label: "twin.command.production.order",
2090
2047
  /*
2091
2048
  * 되돌릴 수 없다. 지시가 나가면 사람과 설비가 그것으로 움직이고, 취소해도 이미 만든 것은 남는다.
2092
2049
  * 그래서 사람 승인을 지난다(§`requiresApproval`).
@@ -2289,8 +2246,9 @@ var EMS_TYPES = [
2289
2246
  level: "Other",
2290
2247
  label: "twin.type.incoming",
2291
2248
  /* 수전 지점 — 계약전력이 걸리는 자리이고, 요금의 근거가 되는 수요는 여기서 잰다.
2292
- ISO 50001 의 「에너지 유입」 경계이기도 하다(조직의 에너지 검토가 여기서 시작한다). */
2293
- standardClass: { iec61850: "MMTR", iso50001: "EnergyInput" },
2249
+ 조직의 에너지 검토가 여기서 시작하지만, ISO 50001 은 이 경계에 **분류 이름을 주지 않는다** — 그래서
2250
+ 그 칸을 비운다(예전의 `EnergyInput` 은 표준의 낱말이 아니었다. 2026-11-19 내용 점검). */
2251
+ standardClass: { iec61850: "MMTR" },
2294
2252
  identity: { scheme: "kernel:id" },
2295
2253
  capabilities: ["metered"]
2296
2254
  },
@@ -2300,8 +2258,17 @@ var EMS_TYPES = [
2300
2258
  /* 전기 계통의 구간은 **설비 계층의 단이 아니다** — 표준의 탈출구(`Other`)를 쓴다(아래 주석). */
2301
2259
  level: "Other",
2302
2260
  label: "twin.type.feeder",
2303
- /* 분기 회로 — 부하 분해의 단위. 계약전력의 하위 배분이 여기서 정해진다. */
2304
- 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: {},
2305
2272
  identity: { scheme: "kernel:id" },
2306
2273
  capabilities: ["metered"]
2307
2274
  },
@@ -2327,7 +2294,8 @@ var EMS_TYPES = [
2327
2294
  role: "equipment",
2328
2295
  label: "twin.type.meter",
2329
2296
  /* 계량기 — 측정 논리 노드(MMXU=측정단위, MMTR=적산). 자산으로도 하나다(ISO 55000). */
2330
- standardClass: { iec61850: "MMXU", iso55000: "Asset", iso50001: "MeasurementPoint" },
2297
+ /* ISO 50001 칸은 비운다 — 계측 지점은 그 표준이 이름 붙인 분류가 아니다(파일 머리의 규율, 2026-11-19 내용 점검). */
2298
+ standardClass: { iec61850: "MMXU", iso55000: "Asset" },
2331
2299
  identity: { scheme: "kernel:id" },
2332
2300
  capabilities: ["metered", "operable"]
2333
2301
  },
@@ -2352,7 +2320,8 @@ var EMS_TYPES = [
2352
2320
  role: "equipment",
2353
2321
  label: "twin.type.pv-array",
2354
2322
  /* 태양광 어레이 — IEC 61850-7-420(분산자원)의 `DPVA`. 발전과 계량은 다른 능력이다. */
2355
- standardClass: { iec61850: "DPVA", iso55000: "Asset", iso50001: "RenewableSupply" },
2323
+ /* ISO 50001 칸은 비운다 — 「재생 공급」은 그 표준의 분류 이름이 아니다(파일 머리의 규율, 2026-11-19 내용 점검). */
2324
+ standardClass: { iec61850: "DPVA", iso55000: "Asset" },
2356
2325
  identity: { scheme: "kernel:id" },
2357
2326
  capabilities: ["energyGenerating", "metered", "operable"]
2358
2327
  },
@@ -3765,65 +3734,17 @@ function orderFoldPolicyOf(declared) {
3765
3734
  if (policy.maxTerminal < 1) return { error: "order fold maxTerminal must be at least 1 (ADR-0092)" };
3766
3735
  return { policy };
3767
3736
  }
3768
- function emptyFoldedOrders() {
3769
- return { counts: {}, boundaryMs: null };
3770
- }
3771
3737
  function foldedOrderCount(folded) {
3772
3738
  let n = 0;
3773
3739
  for (const byStatus of Object.values(folded?.counts ?? {})) for (const c of Object.values(byStatus)) n += c;
3774
3740
  return n;
3775
3741
  }
3776
- function planOrderFold(orders, nowMs, policy = ORDER_FOLD_DEFAULT) {
3777
- 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));
3778
- const cutoff = nowMs - policy.afterMs;
3779
- const byTime = candidates.filter((o) => o.terminalAtMs <= cutoff);
3780
- const stay = candidates.length - byTime.length;
3781
- const byCount = stay > policy.maxTerminal ? candidates.slice(byTime.length, byTime.length + (stay - policy.maxTerminal)) : [];
3782
- return [...byTime, ...byCount].map((o) => o.id);
3783
- }
3784
- function foldOrdersInto(folded, orders) {
3785
- const out = {
3786
- counts: Object.fromEntries(Object.entries(folded?.counts ?? {}).map(([k, v]) => [k, { ...v }])),
3787
- boundaryMs: folded?.boundaryMs ?? null
3788
- };
3789
- const hours = Object.fromEntries(
3790
- Object.entries(folded?.hours ?? {}).map(([h, byKind]) => [h, Object.fromEntries(Object.entries(byKind).map(([k, v]) => [k, { ...v }]))])
3791
- );
3792
- for (const o of orders) {
3793
- const kind = String(o.kind ?? "");
3794
- const status = String(o.status ?? "");
3795
- const byStatus = out.counts[kind] ??= {};
3796
- byStatus[status] = (byStatus[status] ?? 0) + 1;
3797
- if (typeof o.terminalAtMs === "number" && Number.isFinite(o.terminalAtMs)) {
3798
- out.boundaryMs = out.boundaryMs === null ? o.terminalAtMs : Math.max(out.boundaryMs, o.terminalAtMs);
3799
- const slot = (hours[String(hourStartOf(o.terminalAtMs))] ??= {})[kind] ??= {};
3800
- slot[status] = (slot[status] ?? 0) + 1;
3801
- }
3802
- }
3803
- if (Object.keys(hours).length) out.hours = hours;
3804
- return out;
3805
- }
3806
- function standsNewOrderRow(record, eventTimeMs, folded) {
3807
- if (!isOrderTerminal(record)) return true;
3808
- const boundary = folded?.boundaryMs;
3809
- if (boundary === null || boundary === void 0) return true;
3810
- if (typeof eventTimeMs !== "number" || !Number.isFinite(eventTimeMs)) return true;
3811
- return eventTimeMs > boundary;
3812
- }
3813
3742
  function hourStartOf(ms) {
3814
3743
  return Math.floor(ms / ORDER_FOLD_HOUR_MS) * ORDER_FOLD_HOUR_MS;
3815
3744
  }
3816
3745
  function finishedWindowStartMs(nowMs, policy = ORDER_FOLD_DEFAULT) {
3817
3746
  return hourStartOf(nowMs) - policy.afterMs;
3818
3747
  }
3819
- function pruneFoldedHours(folded, nowMs, policy = ORDER_FOLD_DEFAULT) {
3820
- if (!folded.hours) return folded;
3821
- const start = finishedWindowStartMs(nowMs, policy);
3822
- const kept = Object.fromEntries(Object.entries(folded.hours).filter(([h]) => Number(h) >= start));
3823
- const out = { counts: folded.counts, boundaryMs: folded.boundaryMs };
3824
- if (Object.keys(kept).length) out.hours = kept;
3825
- return out;
3826
- }
3827
3748
  function finishedFlowOrdersWithin(hot, folded, nowMs, policy = ORDER_FOLD_DEFAULT) {
3828
3749
  const fromMs = finishedWindowStartMs(nowMs, policy);
3829
3750
  let count = 0;
@@ -4211,7 +4132,6 @@ function shapeErrors(where, row, shape) {
4211
4132
  }
4212
4133
  return errors;
4213
4134
  }
4214
- var TASK_STATUS = ["created", "assigned", "in-progress", "completed"];
4215
4135
  var SPECS = {
4216
4136
  task: {
4217
4137
  eventType: OP_EVENT.task,
@@ -4817,58 +4737,6 @@ function workingHoursBetween(calendar, fromMs, toMs, utcOffsetMinutes) {
4817
4737
  for (let ms = fromMs; ms < toMs; ms += 6e4) if (inWorkCalendarAt(calendar, ms, utcOffsetMinutes)) minutes++;
4818
4738
  return minutes / 60;
4819
4739
  }
4820
- function operationsCapabilityOf(input) {
4821
- const fromMs = Date.parse(input.window.fromTime);
4822
- const toMs = Date.parse(input.window.toTime);
4823
- if (!Number.isFinite(fromMs) || !Number.isFinite(toMs)) {
4824
- throw new Error(`\uB2A5\uB825\uC758 \uAD6C\uAC04\uC744 \uC77D\uC744 \uC218 \uC5C6\uB2E4: ${input.window.fromTime} ~ ${input.window.toTime}`);
4825
- }
4826
- if (toMs <= fromMs) throw new Error(`\uB2A5\uB825\uC758 \uAD6C\uAC04\uC774 \uB4A4\uC9D1\uD614\uB2E4: ${input.window.fromTime} ~ ${input.window.toTime}`);
4827
- const workingHours = workingHoursBetween(input.calendar ?? input.capacity.calendar, fromMs, toMs, input.utcOffsetMinutes);
4828
- const full = analyzeCapacity(input.capacity);
4829
- const usable = input.usableCapacity ? analyzeCapacity(input.usableCapacity) : void 0;
4830
- const amountOf = (perHour) => Number.isFinite(perHour) ? perHour * workingHours : null;
4831
- const committedOf = (operation) => {
4832
- let sum = 0;
4833
- for (const d of input.demands ?? []) {
4834
- if (d.operation !== void 0 && d.operation !== operation) continue;
4835
- if (!d.dueTime) continue;
4836
- const due = Date.parse(d.dueTime);
4837
- if (!Number.isFinite(due) || due < fromMs || due >= toMs) continue;
4838
- sum += Math.max(0, d.remaining);
4839
- }
4840
- return sum;
4841
- };
4842
- const perOperation = full.operations.map((op) => {
4843
- const total = amountOf(op.perHour);
4844
- const committed = committedOf(op.operation);
4845
- let unattainable = null;
4846
- let unattainableBy;
4847
- if (usable) {
4848
- const left = usable.operations.find((o) => o.operation === op.operation);
4849
- const usableAmount = amountOf(left?.perHour ?? NaN);
4850
- unattainable = total != null && usableAmount != null ? Math.max(0, total - usableAmount) : null;
4851
- if (unattainable != null && unattainable > 0 && left?.constraint) unattainableBy = left.constraint;
4852
- }
4853
- const available = total == null || unattainable == null ? null : total - committed - unattainable;
4854
- return {
4855
- operation: op.operation,
4856
- total,
4857
- committed,
4858
- unattainable,
4859
- available,
4860
- ...op.constraint ? { constraint: op.constraint } : {},
4861
- ...unattainableBy ? { unattainableBy } : {}
4862
- };
4863
- });
4864
- return {
4865
- operationsType: input.operationsType ?? "Production",
4866
- window: { fromTime: input.window.fromTime, toTime: input.window.toTime, workingHours },
4867
- perOperation,
4868
- ...full.bottleneck ? { bottleneck: full.bottleneck } : {},
4869
- ...input.publishedDate ? { publishedDate: input.publishedDate } : {}
4870
- };
4871
- }
4872
4740
 
4873
4741
  // src/scenario-validate.ts
4874
4742
  var DISTRIBUTIONS = /* @__PURE__ */ new Set(["poisson", "uniform", "constant", "profile"]);
@@ -5188,7 +5056,7 @@ function computeOee(c, nowMs) {
5188
5056
  const quality = produced > 0 ? c.goodCount / produced : void 0;
5189
5057
  if (c.plannedRunTimePerItemMs == null) missing.push("planned-run-time-per-item");
5190
5058
  else if (c.runMs <= 0) missing.push("actual-production-time");
5191
- 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;
5192
5060
  const overall = availability != null && performance != null && quality != null ? availability * performance * quality : void 0;
5193
5061
  return {
5194
5062
  ...availability != null ? { availability } : {},
@@ -5509,22 +5377,440 @@ function commandSpecGaps(specs, command) {
5509
5377
  var OPERATIONAL_ATTENTION_CONTRACT = "operational.attention.v1";
5510
5378
  var OPERATIONAL_ATTENTION_TRANSITIONS = ["opened", "changed", "resolved", "reopened"];
5511
5379
  var OPERATIONAL_ATTENTION_IMPACTS = ["medium", "high"];
5512
- function isOperationalAttentionV1(value) {
5380
+ var OPERATIONAL_ATTENTION_KIND_PATTERN = /^[a-z][a-z0-9-]*(\.[a-z0-9][a-z0-9-]*)+$/;
5381
+ function operationalAttentionErrors(value) {
5513
5382
  const one = value;
5514
- 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;
5515
5409
  }
5516
5410
  function assertOperationalAttentionV1(value) {
5517
- if (!isOperationalAttentionV1(value)) {
5518
- throw new Error("invalid operational.attention.v1: lifecycle fields and stable source-fact references are required");
5519
- }
5411
+ const errors = operationalAttentionErrors(value);
5412
+ if (errors.length) throw new Error(`invalid operational.attention.v1: ${errors.join("; ")}`);
5520
5413
  }
5521
- function isOperationalFactReference(value) {
5414
+ function factReferenceErrors(value) {
5522
5415
  const one = value;
5523
- 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;
5524
5426
  }
5525
5427
  function nonEmpty(value) {
5526
5428
  return typeof value === "string" && value.trim().length > 0;
5527
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
+ }
5528
5814
 
5529
5815
  // src/lot-lineage.ts
5530
5816
  function lotLineageOf(event, classOfUnit) {
@@ -5571,6 +5857,7 @@ function inheritedExpiry(inputExpiries) {
5571
5857
  BTT_PRODORDER,
5572
5858
  CAPABILITIES,
5573
5859
  CAPABILITY_KEYS,
5860
+ CARRIED_HEADER_FIELDS,
5574
5861
  CBV_BIZSTEP,
5575
5862
  CMD,
5576
5863
  COMMAND_EVENT,
@@ -5579,6 +5866,7 @@ function inheritedExpiry(inputExpiries) {
5579
5866
  DISP,
5580
5867
  DISPOSITION_DECISION,
5581
5868
  DOCK_DOOR_STATUS,
5869
+ DOCK_FACT_KIND,
5582
5870
  DOMAIN_CATALOG,
5583
5871
  DOMAIN_SYSTEMS,
5584
5872
  EMPTY_BECAUSE,
@@ -5594,9 +5882,11 @@ function inheritedExpiry(inputExpiries) {
5594
5882
  EQUIPMENT_STATUS,
5595
5883
  ERP_CAPABILITY,
5596
5884
  ERP_MASTER_AXIS,
5885
+ FIELDS_NOT_CARRIED,
5597
5886
  FIRST_PASS_RULE,
5598
5887
  GUARD_PRAGMA,
5599
5888
  HATIOLAB_VOCABULARY,
5889
+ HEADER_FIELDS_PARTITIONED,
5600
5890
  ILMD_ATTR,
5601
5891
  LOCATION_SATURATION_NEAR,
5602
5892
  MATERIAL_ACTUAL_USE,
@@ -5607,9 +5897,11 @@ function inheritedExpiry(inputExpiries) {
5607
5897
  MES_LOCATION_TYPES,
5608
5898
  MES_TYPES,
5609
5899
  METER_DIRECTION,
5900
+ MOVE_KIND,
5610
5901
  OBSERVATION_BASIS,
5611
5902
  OPERATIONAL_ATTENTION_CONTRACT,
5612
5903
  OPERATIONAL_ATTENTION_IMPACTS,
5904
+ OPERATIONAL_ATTENTION_KIND_PATTERN,
5613
5905
  OPERATIONAL_ATTENTION_TRANSITIONS,
5614
5906
  OP_EVENT,
5615
5907
  OP_PARAM,
@@ -5623,6 +5915,7 @@ function inheritedExpiry(inputExpiries) {
5623
5915
  PRIORITY_UNSET,
5624
5916
  PRIVATE_BIZSTEP,
5625
5917
  READ_BASIS,
5918
+ RECEIVED_MOVE_KIND,
5626
5919
  REFUSED_WITHOUT_CODE,
5627
5920
  RESOURCE_KIND,
5628
5921
  RETIRED_VOCABULARY,
@@ -5630,6 +5923,8 @@ function inheritedExpiry(inputExpiries) {
5630
5923
  SCHEDULE_STATUS,
5631
5924
  SIGNATURE_REJECTED_REASONS,
5632
5925
  SOURCE_DEST_PARTY_TYPE,
5926
+ TASK_STATUS,
5927
+ TASK_TERMINAL_STATUS,
5633
5928
  TRAILER_LOAD,
5634
5929
  TWIN_AXES,
5635
5930
  TWIN_PROPERTIES,
@@ -5661,7 +5956,6 @@ function inheritedExpiry(inputExpiries) {
5661
5956
  activeShiftAt,
5662
5957
  activeShiftOf,
5663
5958
  aggregationEvent,
5664
- analyzeCapacity,
5665
5959
  approveCommand,
5666
5960
  asApproved,
5667
5961
  assertOperationalAttentionV1,
@@ -5689,19 +5983,20 @@ function inheritedExpiry(inputExpiries) {
5689
5983
  computeOee,
5690
5984
  conversionFactorOf,
5691
5985
  criterionSaysNothing,
5986
+ dispatchMoveFactOf,
5987
+ dockDoorCapacityOf,
5692
5988
  dockDoorStatusOf,
5989
+ dockFactOf,
5693
5990
  documentPath,
5694
5991
  dueStatusOf,
5695
5992
  effectivityAt,
5696
5993
  electricalUpstreamOf,
5697
- emptyFoldedOrders,
5698
5994
  epcCandidatesOfGs1,
5699
5995
  equipmentClassMembership,
5700
5996
  erpCapabilityGaps,
5701
5997
  expiryFromAttributes,
5702
5998
  finishedFlowOrdersWithin,
5703
5999
  finishedWindowStartMs,
5704
- foldOrdersInto,
5705
6000
  foldedOrderCount,
5706
6001
  gdtiUri,
5707
6002
  generationFractionAt,
@@ -5734,6 +6029,7 @@ function inheritedExpiry(inputExpiries) {
5734
6029
  isAppointmentClosed,
5735
6030
  isCacheableTense,
5736
6031
  isCommandTerminal,
6032
+ isDockRecord,
5737
6033
  isElectricalLocationType,
5738
6034
  isEnergyBillRecord,
5739
6035
  isEnergyEquipmentRecord,
@@ -5748,8 +6044,11 @@ function inheritedExpiry(inputExpiries) {
5748
6044
  isEquipmentStatus,
5749
6045
  isFailureStatus,
5750
6046
  isFlowOrder,
6047
+ isIsoDateTime,
5751
6048
  isMasterDataRecord,
5752
6049
  isMaterialExecutionBasis,
6050
+ isMoveExpiry,
6051
+ isMoveRecord,
5753
6052
  isOperationalAttentionV1,
5754
6053
  isOperationalRecord,
5755
6054
  isOrderTerminal,
@@ -5757,7 +6056,9 @@ function inheritedExpiry(inputExpiries) {
5757
6056
  isPartyUri,
5758
6057
  isPlannedStopStatus,
5759
6058
  isRecipeExecutionBasis,
6059
+ isRecordShapeError,
5760
6060
  isResourceKind,
6061
+ isTaskTerminal,
5761
6062
  isTestSpecificationBasis,
5762
6063
  isTransformationRecord,
5763
6064
  isWebhookDeliveryCode,
@@ -5765,6 +6066,8 @@ function inheritedExpiry(inputExpiries) {
5765
6066
  isWorkShiftExecutionBasis,
5766
6067
  isYmsAppointmentStatus,
5767
6068
  isoDurationHours,
6069
+ issueCancelMoveFactOf,
6070
+ issueMoveFactOf,
5768
6071
  itemClassOf,
5769
6072
  itemKeyOf,
5770
6073
  itemMaterialDefinitionId,
@@ -5785,6 +6088,8 @@ function inheritedExpiry(inputExpiries) {
5785
6088
  meetsTests,
5786
6089
  minuteOfDayAt,
5787
6090
  missingCommandPayload,
6091
+ moveExpiryText,
6092
+ moveFactOf,
5788
6093
  nextCommandState,
5789
6094
  nonWorkingMsIn,
5790
6095
  normalizeEquipmentStatus,
@@ -5793,10 +6098,12 @@ function inheritedExpiry(inputExpiries) {
5793
6098
  observationAt,
5794
6099
  offCalendarAt,
5795
6100
  offCalendarReasonAt,
6101
+ operationalAttentionErrors,
6102
+ operationalAttentionOf,
5796
6103
  operationalIdentityField,
5797
6104
  operationalKindOf,
5798
- operationsCapabilityOf,
5799
6105
  orderFoldPolicyOf,
6106
+ outboxInputsOfEvent,
5800
6107
  outsideLimit,
5801
6108
  parseEpc,
5802
6109
  parseGs1,
@@ -5809,16 +6116,17 @@ function inheritedExpiry(inputExpiries) {
5809
6116
  passThroughReversible,
5810
6117
  performanceKey,
5811
6118
  periodFactId,
5812
- planOrderFold,
5813
6119
  priorityRank,
5814
6120
  procedureViolations,
5815
6121
  propertiesOf,
5816
- pruneFoldedHours,
5817
6122
  quantityIn,
5818
6123
  ratedUsageOf,
5819
6124
  readBoardAssets,
5820
6125
  readBoardEquipment,
5821
6126
  readBoardLocations,
6127
+ receiptMoveFactOf,
6128
+ receivedMoveFactOf,
6129
+ recordsOfEvent,
5822
6130
  referencedLocationIds,
5823
6131
  relationsFrom,
5824
6132
  relationsTo,
@@ -5835,7 +6143,6 @@ function inheritedExpiry(inputExpiries) {
5835
6143
  splitRelationIds,
5836
6144
  ssccDigitsOf,
5837
6145
  ssccUri,
5838
- standsNewOrderRow,
5839
6146
  stateFieldsOf,
5840
6147
  subLotIdOf,
5841
6148
  tenseOf,