@operato/ops-contract 0.9.47 → 0.9.49

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.
@@ -34,7 +34,10 @@ __export(index_exports, {
34
34
  COMMAND_EVENT: () => COMMAND_EVENT,
35
35
  COMMAND_ORIGIN: () => COMMAND_ORIGIN,
36
36
  COMMAND_STATE: () => COMMAND_STATE,
37
+ CONNECTION_DIRECTION: () => CONNECTION_DIRECTION,
38
+ DEFAULT_CONNECTION_CAPACITY: () => DEFAULT_CONNECTION_CAPACITY,
37
39
  DISP: () => DISP,
40
+ DISPATCH_RULE: () => DISPATCH_RULE,
38
41
  DISPOSITION_DECISION: () => DISPOSITION_DECISION,
39
42
  DOCK_DOOR_STATUS: () => DOCK_DOOR_STATUS,
40
43
  DOCK_FACT_KIND: () => DOCK_FACT_KIND,
@@ -55,9 +58,16 @@ __export(index_exports, {
55
58
  ERP_MASTER_AXIS: () => ERP_MASTER_AXIS,
56
59
  FIELDS_NOT_CARRIED: () => FIELDS_NOT_CARRIED,
57
60
  FIRST_PASS_RULE: () => FIRST_PASS_RULE,
61
+ FIXED_ROUTE_BINDING: () => FIXED_ROUTE_BINDING,
58
62
  GUARD_PRAGMA: () => GUARD_PRAGMA,
59
63
  HATIOLAB_VOCABULARY: () => HATIOLAB_VOCABULARY,
60
64
  HEADER_FIELDS_PARTITIONED: () => HEADER_FIELDS_PARTITIONED,
65
+ ILG_ATTENTION_KIND: () => ILG_ATTENTION_KIND,
66
+ ILG_BIZSTEP: () => ILG_BIZSTEP,
67
+ ILG_LOCATION_TYPES: () => ILG_LOCATION_TYPES,
68
+ ILG_ORDER_KIND: () => ILG_ORDER_KIND,
69
+ ILG_TASK_KIND: () => ILG_TASK_KIND,
70
+ ILG_TYPES: () => ILG_TYPES,
61
71
  ILMD_ATTR: () => ILMD_ATTR,
62
72
  LOCATION_SATURATION_NEAR: () => LOCATION_SATURATION_NEAR,
63
73
  MATERIAL_ACTUAL_USE: () => MATERIAL_ACTUAL_USE,
@@ -91,12 +101,22 @@ __export(index_exports, {
91
101
  RESOURCE_KIND: () => RESOURCE_KIND,
92
102
  RETIRED_VOCABULARY: () => RETIRED_VOCABULARY,
93
103
  RETURN_TO_SUPPLIER: () => RETURN_TO_SUPPLIER,
104
+ ROUTE_NETWORK_ISSUE: () => ROUTE_NETWORK_ISSUE,
105
+ ROUTING_RULE: () => ROUTING_RULE,
94
106
  SCHEDULE_STATUS: () => SCHEDULE_STATUS,
95
107
  SIGNATURE_REJECTED_REASONS: () => SIGNATURE_REJECTED_REASONS,
96
108
  SOURCE_DEST_PARTY_TYPE: () => SOURCE_DEST_PARTY_TYPE,
109
+ TARIFF_DAY_KINDS: () => TARIFF_DAY_KINDS,
110
+ TARIFF_ISSUE_CODES: () => TARIFF_ISSUE_CODES,
111
+ TARIFF_LOAD_CLASSES: () => TARIFF_LOAD_CLASSES,
97
112
  TASK_STATUS: () => TASK_STATUS,
98
113
  TASK_TERMINAL_STATUS: () => TASK_TERMINAL_STATUS,
114
+ TRAFFIC_CONFLICT_ACTION: () => TRAFFIC_CONFLICT_ACTION,
99
115
  TRAILER_LOAD: () => TRAILER_LOAD,
116
+ TRANSPORT_FAILURE_REASON: () => TRANSPORT_FAILURE_REASON,
117
+ TRANSPORT_POLICY_ISSUE: () => TRANSPORT_POLICY_ISSUE,
118
+ TRAVEL_LINK_JUDGED_BY: () => TRAVEL_LINK_JUDGED_BY,
119
+ TRAVEL_LINK_STATE: () => TRAVEL_LINK_STATE,
100
120
  TWIN_AXES: () => TWIN_AXES,
101
121
  TWIN_PROPERTIES: () => TWIN_PROPERTIES,
102
122
  TWIN_RELATIONS: () => TWIN_RELATIONS,
@@ -123,7 +143,9 @@ __export(index_exports, {
123
143
  YMS_ORDER_KIND: () => YMS_ORDER_KIND,
124
144
  YMS_TASK_KIND: () => YMS_TASK_KIND,
125
145
  YMS_TYPES: () => YMS_TYPES,
146
+ acceptsMaterial: () => acceptsMaterial,
126
147
  acceptsPerformance: () => acceptsPerformance,
148
+ activeBands: () => activeBands,
127
149
  activeShiftAt: () => activeShiftAt,
128
150
  activeShiftOf: () => activeShiftOf,
129
151
  aggregationEvent: () => aggregationEvent,
@@ -134,6 +156,7 @@ __export(index_exports, {
134
156
  axisAppliesTo: () => axisAppliesTo,
135
157
  axisInfo: () => axisInfo,
136
158
  axisSource: () => axisSource,
159
+ bandAt: () => bandAt,
137
160
  bizStepName: () => bizStepName,
138
161
  bizTransactionUri: () => bizTransactionUri,
139
162
  canPreview: () => canPreview,
@@ -152,8 +175,10 @@ __export(index_exports, {
152
175
  computeMtbf: () => computeMtbf,
153
176
  computeMttr: () => computeMttr,
154
177
  computeOee: () => computeOee,
178
+ connectionAdmits: () => connectionAdmits,
155
179
  conversionFactorOf: () => conversionFactorOf,
156
180
  criterionSaysNothing: () => criterionSaysNothing,
181
+ dayOfYearOf: () => dayOfYearOf,
157
182
  dispatchMoveFactOf: () => dispatchMoveFactOf,
158
183
  dockDoorCapacityOf: () => dockDoorCapacityOf,
159
184
  dockDoorStatusOf: () => dockDoorStatusOf,
@@ -196,6 +221,7 @@ __export(index_exports, {
196
221
  ingestOperationalRecords: () => ingestOperationalRecords,
197
222
  inheritedExpiry: () => inheritedExpiry,
198
223
  inheritedLotUse: () => inheritedLotUse,
224
+ intralogisticsTypeOf: () => intralogisticsTypeOf,
199
225
  isAggregationRecord: () => isAggregationRecord,
200
226
  isAppointmentClosed: () => isAppointmentClosed,
201
227
  isCacheableTense: () => isCacheableTense,
@@ -215,6 +241,8 @@ __export(index_exports, {
215
241
  isEquipmentStatus: () => isEquipmentStatus,
216
242
  isFailureStatus: () => isFailureStatus,
217
243
  isFlowOrder: () => isFlowOrder,
244
+ isHeading: () => isHeading,
245
+ isIso4217Code: () => isIso4217Code,
218
246
  isIsoDateTime: () => isIsoDateTime,
219
247
  isMasterDataRecord: () => isMasterDataRecord,
220
248
  isMaterialExecutionBasis: () => isMaterialExecutionBasis,
@@ -232,6 +260,7 @@ __export(index_exports, {
232
260
  isTaskTerminal: () => isTaskTerminal,
233
261
  isTestSpecificationBasis: () => isTestSpecificationBasis,
234
262
  isTransformationRecord: () => isTransformationRecord,
263
+ isTransportFailureReason: () => isTransportFailureReason,
235
264
  isWebhookDeliveryCode: () => isWebhookDeliveryCode,
236
265
  isWebhookSecretSegment: () => isWebhookSecretSegment,
237
266
  isWorkShiftExecutionBasis: () => isWorkShiftExecutionBasis,
@@ -245,6 +274,7 @@ __export(index_exports, {
245
274
  judgeAgainstSpec: () => judgeAgainstSpec,
246
275
  levelOfLocationType: () => levelOfLocationType,
247
276
  lgtinClass: () => lgtinClass,
277
+ linkStateAt: () => linkStateAt,
248
278
  localDayIndexAt: () => localDayIndexAt,
249
279
  localDayStartMs: () => localDayStartMs,
250
280
  locationStatusOf: () => locationStatusOf,
@@ -258,11 +288,11 @@ __export(index_exports, {
258
288
  materialMovementKey: () => materialMovementKey,
259
289
  meetsTests: () => meetsTests,
260
290
  minuteOfDayAt: () => minuteOfDayAt,
291
+ minutesOf: () => minutesOf,
261
292
  missingCommandPayload: () => missingCommandPayload,
262
293
  moveExpiryText: () => moveExpiryText,
263
294
  moveFactOf: () => moveFactOf,
264
295
  nextCommandState: () => nextCommandState,
265
- nonWorkingMsIn: () => nonWorkingMsIn,
266
296
  normalizeEquipmentStatus: () => normalizeEquipmentStatus,
267
297
  objectEvent: () => objectEvent,
268
298
  objectUri: () => objectUri,
@@ -316,6 +346,10 @@ __export(index_exports, {
316
346
  ssccUri: () => ssccUri,
317
347
  stateFieldsOf: () => stateFieldsOf,
318
348
  subLotIdOf: () => subLotIdOf,
349
+ tariffBandIssues: () => tariffBandIssues,
350
+ tariffCoverageIssues: () => tariffCoverageIssues,
351
+ tariffIssueText: () => tariffIssueText,
352
+ tariffIssues: () => tariffIssues,
319
353
  tenseOf: () => tenseOf,
320
354
  testEvidenceGaps: () => testEvidenceGaps,
321
355
  testPassedAt: () => testPassedAt,
@@ -327,7 +361,9 @@ __export(index_exports, {
327
361
  validateDomainDefinition: () => validateDomainDefinition,
328
362
  validateEpcisEvent: () => validateEpcisEvent,
329
363
  validatePerformance: () => validatePerformance,
364
+ validateRouteNetwork: () => validateRouteNetwork,
330
365
  validateScenario: () => validateScenario,
366
+ validateTransportPolicy: () => validateTransportPolicy,
331
367
  verdictOfAck: () => verdictOfAck,
332
368
  webhookLaneOf: () => webhookLaneOf,
333
369
  webhookSecretCandidates: () => webhookSecretCandidates,
@@ -337,8 +373,7 @@ __export(index_exports, {
337
373
  webhookSenderAction: () => webhookSenderAction,
338
374
  weekdayAt: () => weekdayAt,
339
375
  workShiftAttribution: () => workShiftAttribution,
340
- workingHoursBetween: () => workingHoursBetween,
341
- workingTimeOfWeek: () => workingTimeOfWeek
376
+ workingHoursBetween: () => workingHoursBetween
342
377
  });
343
378
  module.exports = __toCommonJS(index_exports);
344
379
 
@@ -467,9 +502,29 @@ var CAPABILITIES = {
467
502
  models: ["StoringState"],
468
503
  invariants: ["0 <= soc <= 100"],
469
504
  results: ["stored", "discharged"]
505
+ },
506
+ /*
507
+ * ── Guided — travels the route network under transport control (2026-12-03, operato-application ADR-0266) ──────────────
508
+ *
509
+ * `mobile` says a resource moves between locations; a forklift a person drives has it. Last location passed, reserved
510
+ * connections and link state mean something only for equipment under transport control, so they are a capability of their
511
+ * own, declared together with `mobile`. Battery is not repeated here: guided equipment declares `energyStoring` as well.
512
+ *
513
+ * No commands. The twin does not drive robots: dispatch, pause and resume are the transport control product's instructions
514
+ * to its equipment (VDA 5050 instant actions), not stimuli inside the kernel, so they do not belong in `CMD`.
515
+ */
516
+ guided: {
517
+ key: "guided",
518
+ label: "twin.capability.guided",
519
+ semantics: "\uACBD\uB85C\uB9DD \uC704\uB97C \uAD00\uC81C\uC5D0 \uB530\uB77C \uB2E4\uB2C8\uB294 \uC7A5\uBE44 \u2014 \uB9C8\uC9C0\uB9C9\uC73C\uB85C \uC9C0\uB09C \uC790\uB9AC \xB7 \uC9C4\uD589 \uBC29\uD5A5 \xB7 \uC608\uC57D \uAD6C\uAC04 \xB7 \uD1B5\uC2E0 \uC0C1\uD0DC \xB7 \uCE21\uC815 \uC704\uCE58. mobile \uACFC \uD568\uAED8 \uC120\uC5B8\uD55C\uB2E4.",
520
+ commands: [],
521
+ stateFields: ["travel"],
522
+ models: ["TravelState"],
523
+ invariants: ["guided => mobile", "0 <= heading < 360"],
524
+ results: ["passed", "reserved", "linkChanged", "poseReported"]
470
525
  }
471
526
  };
472
- var CAPABILITY_KEYS = ["operable", "storable", "mobile", "processable", "trackable", "switching", "metered", "curtailable", "energyGenerating", "energyStoring"];
527
+ var CAPABILITY_KEYS = ["operable", "storable", "mobile", "processable", "trackable", "switching", "metered", "curtailable", "energyGenerating", "energyStoring", "guided"];
473
528
  function stateFieldsOf(caps) {
474
529
  const out = /* @__PURE__ */ new Set();
475
530
  for (const c of caps) for (const f of CAPABILITIES[c]?.stateFields ?? []) out.add(f);
@@ -481,6 +536,14 @@ function commandsOf(caps) {
481
536
  return [...out];
482
537
  }
483
538
 
539
+ // src/capacity.ts
540
+ function isoDurationHours(iso) {
541
+ if (!iso) return 0;
542
+ const m = /^P(?:(\d+)D)?(?:T(?:(\d+)H)?(?:(\d+)M)?(?:([\d.]+)S)?)?$/.exec(iso);
543
+ if (!m) throw new Error(`\uAE30\uAC04 \uD45C\uAE30\uB97C \uC77D\uC744 \uC218 \uC5C6\uB2E4: ${iso}`);
544
+ return Number(m[1] ?? 0) * 24 + Number(m[2] ?? 0) + Number(m[3] ?? 0) / 60 + Number(m[4] ?? 0) / 3600;
545
+ }
546
+
484
547
  // src/rated-usage.ts
485
548
  var USE_UOM = "C62";
486
549
  var num = (n) => typeof n === "number" && Number.isFinite(n);
@@ -803,8 +866,8 @@ function convertQuantity(item, uom, definitions) {
803
866
  const factor = conversionFactorOf(def, uom);
804
867
  return factor === void 0 ? void 0 : item.qty * factor;
805
868
  }
806
- function minutesOfDay(hhmm) {
807
- const m = /^(\d{1,2}):(\d{2})$/.exec(hhmm ?? "");
869
+ function minutesOfDay(hhmm2) {
870
+ const m = /^(\d{1,2}):(\d{2})$/.exec(hhmm2 ?? "");
808
871
  if (!m) return void 0;
809
872
  const h = Number(m[1]);
810
873
  const mi = Number(m[2]);
@@ -1114,7 +1177,21 @@ var OP_EVENT = {
1114
1177
  * 이름을 `energy.measured` 와 같은 결로 둔다 — 그쪽이 에너지 계량의 도착이고 이쪽이 그 일반형이다.
1115
1178
  * 두 채널을 합치지 않는 이유는 에너지 쪽이 **구간에 누적되는 표본**이라 처리가 다르기 때문이다.
1116
1179
  */
1117
- observation: "location.measured"
1180
+ observation: "location.measured",
1181
+ /*
1182
+ * ── Travel of guided equipment (2026-12-03, operato-application ADR-0266 decision 8 ②, `travel.ts`) ────────────────────
1183
+ *
1184
+ * The four facts that carry `EquipmentState.travel` into the journal (state ⊆ events). Sent on change, never per tick.
1185
+ * Payloads: `TravelPassedFact` · `TravelReservationFact` · `TravelLinkFact` · `TravelPoseFact`.
1186
+ *
1187
+ * The transport control product sends them as canonical envelopes, so they need no connector mapping in
1188
+ * `operational-ingest`. Folding them into state is the kernel's next stage (ADR-0266 §5 stage 6); until then the mirror
1189
+ * does not show travel.
1190
+ */
1191
+ travelPassed: "equipment.passed",
1192
+ travelReservation: "equipment.reservation",
1193
+ travelLink: "equipment.link",
1194
+ travelPose: "equipment.pose"
1118
1195
  };
1119
1196
  var ENERGY_EVENT = {
1120
1197
  /** 계량 도착 — 그 시점의 유효전력·누적량. 15분 수요 구간에 누적된다. */
@@ -1302,37 +1379,6 @@ function gs1Namespaces(prefix) {
1302
1379
  return [`urn:epc:idpat:sgtin:${prefix}.`, `urn:epc:class:lgtin:${prefix}.`, `urn:epc:id:sgtin:${prefix}.`];
1303
1380
  }
1304
1381
 
1305
- // src/capacity.ts
1306
- function isoDurationHours(iso) {
1307
- if (!iso) return 0;
1308
- const m = /^P(?:(\d+)D)?(?:T(?:(\d+)H)?(?:(\d+)M)?(?:([\d.]+)S)?)?$/.exec(iso);
1309
- if (!m) throw new Error(`\uAE30\uAC04 \uD45C\uAE30\uB97C \uC77D\uC744 \uC218 \uC5C6\uB2E4: ${iso}`);
1310
- return Number(m[1] ?? 0) * 24 + Number(m[2] ?? 0) + Number(m[3] ?? 0) / 60 + Number(m[4] ?? 0) / 3600;
1311
- }
1312
- function workingTimeOfWeek(calendar, weekStartMs, utcOffsetMinutes) {
1313
- if (!calendar?.length) return { hoursPerWeek: 7 * 24, daysPerWeek: 7 };
1314
- let minutes = 0;
1315
- const touched = /* @__PURE__ */ new Set();
1316
- for (let m = 0; m < 7 * 24 * 60; m++) {
1317
- if (!inWorkCalendarAt(calendar, weekStartMs + m * 6e4, utcOffsetMinutes)) continue;
1318
- minutes++;
1319
- touched.add(Math.floor((m + (utcOffsetMinutes ?? 0)) / (24 * 60)));
1320
- }
1321
- const declared = /* @__PURE__ */ new Set();
1322
- for (const e of calendar) if (e.entryType !== "non-working") for (const d of e.daysOfWeek ?? []) declared.add(d);
1323
- return { hoursPerWeek: minutes / 60, daysPerWeek: declared.size || touched.size };
1324
- }
1325
- function nonWorkingMsIn(calendar, fromMs, toMs, utcOffsetMinutes) {
1326
- if (!calendar?.length) return void 0;
1327
- if (!Number.isFinite(fromMs) || !Number.isFinite(toMs) || toMs <= fromMs) return void 0;
1328
- const minutes = Math.floor((toMs - fromMs) / 6e4);
1329
- let closed = 0;
1330
- for (let m = 0; m < minutes; m++) {
1331
- if (!inWorkCalendarAt(calendar, fromMs + m * 6e4, utcOffsetMinutes)) closed++;
1332
- }
1333
- return closed * 6e4;
1334
- }
1335
-
1336
1382
  // src/epcis.ts
1337
1383
  var EPCIS_CONTEXT = "https://ref.gs1.org/standards/epcis/2.0.0/epcis-context.jsonld";
1338
1384
  var UTC_OFFSET = "+00:00";
@@ -1806,11 +1852,11 @@ function validateEpcisEvent(e) {
1806
1852
  }
1807
1853
  if (e.type === "ObjectEvent") {
1808
1854
  if (!ACTIONS.includes(e.action)) v.push(`\uC9C0\uC6D0\uD558\uC9C0 \uC54A\uB294 action \uAC12: ${e.action}`);
1809
- if (!Array.isArray(e.epcList)) v.push("ObjectEvent.epcList \uB204\uB77D");
1810
- else if (e.epcList.length === 0 && !e.quantityList?.length) v.push("ObjectEvent: epcList \uB610\uB294 quantityList\uC5D0 \uD56D\uBAA9\uC744 \uD558\uB098 \uC774\uC0C1 \uC9C0\uC815\uD558\uC138\uC694.");
1855
+ if (e.epcList !== void 0 && !Array.isArray(e.epcList)) v.push("ObjectEvent.epcList \uB294 \uBC30\uC5F4\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4");
1856
+ else if (!e.epcList?.length && !e.quantityList?.length) v.push("ObjectEvent: epcList \uB610\uB294 quantityList\uC5D0 \uD56D\uBAA9\uC744 \uD558\uB098 \uC774\uC0C1 \uC9C0\uC815\uD558\uC138\uC694.");
1811
1857
  } else if (e.type === "AggregationEvent") {
1812
1858
  if (!ACTIONS.includes(e.action)) v.push(`\uC9C0\uC6D0\uD558\uC9C0 \uC54A\uB294 action \uAC12: ${e.action}`);
1813
- if (!e.parentID) v.push("AggregationEvent.parentID \uB204\uB77D");
1859
+ if (!e.parentID && e.action !== "OBSERVE") v.push("AggregationEvent.parentID \uB204\uB77D \u2014 ADD \xB7 DELETE \uC5D0\uB294 \uD544\uC218\uC785\uB2C8\uB2E4");
1814
1860
  if (!e.childEPCs?.length && !e.childQuantityList?.length) v.push("AggregationEvent: childEPCs \uB610\uB294 childQuantityList\uC5D0 \uD56D\uBAA9\uC744 \uD558\uB098 \uC774\uC0C1 \uC9C0\uC815\uD558\uC138\uC694.");
1815
1861
  } else if (e.type === "TransactionEvent") {
1816
1862
  if (!ACTIONS.includes(e.action)) v.push(`\uC9C0\uC6D0\uD558\uC9C0 \uC54A\uB294 action \uAC12: ${e.action}`);
@@ -2007,7 +2053,7 @@ var TRAILER_LOAD = ["empty", "loaded"];
2007
2053
  var MES_BIZSTEP = {
2008
2054
  receiving: "urn:epcglobal:cbv:bizstep:receiving",
2009
2055
  // 원자재 수령
2010
- producing: "urn:epcglobal:cbv:bizstep:commissioning",
2056
+ producing: CBV_BIZSTEP.commissioning,
2011
2057
  // 생산(제품 최초 생성)
2012
2058
  storing: "urn:epcglobal:cbv:bizstep:storing"
2013
2059
  // 완제품 저장
@@ -2663,7 +2709,18 @@ var TWIN_AXES = [
2663
2709
  historical: true,
2664
2710
  standardClass: {},
2665
2711
  systems: ["ems"]
2666
- }
2712
+ },
2713
+ /*
2714
+ * ── Route network (2026-12-03, operato-application ADR-0266 decision 8 ①) ──────────────────────────
2715
+ *
2716
+ * The edges guided equipment travels between locations, and the ordered edge lists some equipment must follow.
2717
+ * No standard names them: ISA-95 and EPCIS have no route network, and VDA 5050 is a protocol, not an ontology this
2718
+ * catalogue projects to. So `standardClass` stays empty rather than borrowing a near name.
2719
+ *
2720
+ * An energy twin has no travelling equipment, so both axes are logistics-only (`LOGISTICS`).
2721
+ */
2722
+ { axis: "connections", path: "connections", label: "twin.axis.connections", kind: "instance", standardClass: {}, systems: LOGISTICS },
2723
+ { axis: "fixedRoutes", path: "fixedRoutes", label: "twin.axis.fixedRoutes", kind: "spec", standardClass: {}, systems: LOGISTICS }
2667
2724
  ];
2668
2725
  function isCacheableTense(t) {
2669
2726
  return t === "standing";
@@ -2762,7 +2819,20 @@ var TWIN_RELATIONS = [
2762
2819
  { from: "materialClasses", field: "testSpecificationIds[]", target: { kind: "axis", axis: "testSpecifications" }, via: "ops.rel.test", optional: true, tense: "standing" },
2763
2820
  /* 공정이 도는 자리·자원 — 항목이 아니라 **타입**을 가리킨다 */
2764
2821
  { from: "operations", field: "locationType", target: { kind: "type", role: "location" }, via: "ops.rel.at", optional: true, tense: "standing" },
2765
- { from: "operations", field: "resourceType", target: { kind: "type", role: "equipment" }, via: "ops.rel.by", optional: true, tense: "standing" }
2822
+ { from: "operations", field: "resourceType", target: { kind: "type", role: "equipment" }, via: "ops.rel.by", optional: true, tense: "standing" },
2823
+ /*
2824
+ * Route network (ADR-0266). A connection's ends are locations of this lens or referenced ones of another lens
2825
+ * (`referencedLocations`), so the target is the either-kind, like `locations.parentId`. Structure inside a published
2826
+ * edition has no time of its own - it holds for as long as the edition does - so these are `standing`, like a location's parent.
2827
+ */
2828
+ { from: "connections", field: "from", target: { kind: "axis-or-external", axis: "locations", entity: "lens.referencedLocation" }, via: "ops.rel.from", tense: "standing" },
2829
+ { from: "connections", field: "to", target: { kind: "axis-or-external", axis: "locations", entity: "lens.referencedLocation" }, via: "ops.rel.to", tense: "standing" },
2830
+ { from: "connections", field: "equipmentClassIds[]", target: { kind: "axis", axis: "equipmentClasses" }, via: "ops.rel.allows", optional: true, tense: "standing" },
2831
+ { from: "fixedRoutes", field: "connectionIds[]", target: { kind: "axis", axis: "connections" }, via: "ops.rel.along", tense: "standing" },
2832
+ { from: "fixedRoutes", field: "equipmentClassIds[]", target: { kind: "axis", axis: "equipmentClasses" }, via: "ops.rel.allows", optional: true, tense: "standing" },
2833
+ /* What a carrier accepts (ADR-0266 decision 8 ③) - a property of the asset class, so standing like the class itself. */
2834
+ { from: "assetClasses", field: "accepts.materialDefinitionIds[]", target: { kind: "axis", axis: "materialDefinitions" }, via: "ops.rel.accepts", optional: true, tense: "standing" },
2835
+ { from: "assetClasses", field: "accepts.materialClassIds[]", target: { kind: "axis", axis: "materialClasses" }, via: "ops.rel.accepts", optional: true, tense: "standing" }
2766
2836
  ];
2767
2837
  var TWIN_PROPERTIES = [
2768
2838
  /* 공정 — 선언(ISO 8601 기간)과 관측(저널에서 계산한 분포)이 둘 다 있는 유일한 짝. */
@@ -3492,6 +3562,255 @@ function ingestEnergyBillRecords(records, opts) {
3492
3562
  return { accepted, rejected };
3493
3563
  }
3494
3564
 
3565
+ // src/tariff.ts
3566
+ var TARIFF_LOAD_CLASSES = ["super-off-peak", "off-peak", "mid-peak", "on-peak"];
3567
+ var TARIFF_DAY_KINDS = ["all", "weekday", "saturday", "sunday", "holiday"];
3568
+ var CONCRETE_DAY_KINDS = ["weekday", "saturday", "sunday", "holiday"];
3569
+ var TARIFF_ISSUE_CODES = [
3570
+ /** A required field is empty. */
3571
+ "required",
3572
+ /** An amount is not a number. */
3573
+ "not-a-number",
3574
+ /** An amount is below zero. */
3575
+ "negative",
3576
+ /** A value is outside its vocabulary - `params.allowed`. */
3577
+ "not-in-vocabulary",
3578
+ /** A text is not in its format - `params.format`. */
3579
+ "format",
3580
+ /** An amount is written without a currency. */
3581
+ "currency-required",
3582
+ /** Season start and end must be written together or both left empty. */
3583
+ "season-pair",
3584
+ /** End time is not after the start - a band crossing midnight is two rows. */
3585
+ "end-not-after-start",
3586
+ /** The tariff has bands and a flat energy charge - which one prices an hour cannot be said. */
3587
+ "flat-and-bands",
3588
+ /** `params.count` bands break the row rules and were left out of the coverage check. */
3589
+ "broken-bands",
3590
+ /** No band covers `params.from`..`params.to` on `params.dayKind` days `params.days`. */
3591
+ "gap",
3592
+ /** Bands `params.bands` overlap `params.from`..`params.to` on `params.dayKind` days `params.days`. */
3593
+ "overlap"
3594
+ ];
3595
+ function tariffIssueText(issue) {
3596
+ const p = issue.params ?? {};
3597
+ switch (issue.code) {
3598
+ case "required":
3599
+ return `${issue.field}: required${p.because ? ` (${p.because})` : ""}`;
3600
+ case "not-a-number":
3601
+ return `${issue.field}: not a number (${p.value})`;
3602
+ case "negative":
3603
+ return `${issue.field}: must be 0 or more (${p.value})`;
3604
+ case "not-in-vocabulary":
3605
+ return `${issue.field}: must be one of ${p.allowed} ("${p.value}")`;
3606
+ case "format":
3607
+ return `${issue.field}: must be ${p.format} ("${p.value}")`;
3608
+ case "currency-required":
3609
+ return `${issue.field}: required when an amount is written`;
3610
+ case "season-pair":
3611
+ return `${issue.field}: seasonFrom and seasonTo go together, or both empty for all year`;
3612
+ case "end-not-after-start":
3613
+ return `${issue.field}: must be after fromTime (${p.from}~${p.to}); a band crossing midnight is two rows`;
3614
+ case "flat-and-bands":
3615
+ return `${issue.field}: the tariff has bands - leave its flat charge empty`;
3616
+ case "broken-bands":
3617
+ return `${issue.field}: ${p.count} band(s) break the row rules and were left out`;
3618
+ case "gap":
3619
+ return `${issue.field}: ${p.dayKind} ${p.days} - no band ${p.from}~${p.to}`;
3620
+ case "overlap":
3621
+ return `${issue.field}: ${p.dayKind} ${p.days} - ${p.bands} overlap ${p.from}~${p.to}`;
3622
+ }
3623
+ }
3624
+ var empty = (v) => v === void 0 || v === null || typeof v === "string" && v.trim() === "";
3625
+ function isIso4217Code(value) {
3626
+ return typeof value === "string" && /^[A-Z]{3}$/.test(value);
3627
+ }
3628
+ function amountOf(v, field, issues) {
3629
+ if (empty(v)) return void 0;
3630
+ const n = Number(v);
3631
+ if (!Number.isFinite(n)) {
3632
+ issues.push({ field, code: "not-a-number", params: { value: String(v) } });
3633
+ return void 0;
3634
+ }
3635
+ if (n < 0) {
3636
+ issues.push({ field, code: "negative", params: { value: n } });
3637
+ return void 0;
3638
+ }
3639
+ return n;
3640
+ }
3641
+ function minutesOf(text) {
3642
+ const m = /^(\d{2}):(\d{2})$/.exec(String(text ?? "").trim());
3643
+ if (!m) return void 0;
3644
+ const h = Number(m[1]);
3645
+ const min = Number(m[2]);
3646
+ if (min > 59) return void 0;
3647
+ if (h === 24 && min === 0) return 1440;
3648
+ if (h > 23) return void 0;
3649
+ return h * 60 + min;
3650
+ }
3651
+ var DAYS_IN_MONTH = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
3652
+ function dayOfYearOf(text) {
3653
+ const m = /^(\d{2})-(\d{2})$/.exec(String(text ?? "").trim());
3654
+ if (!m) return void 0;
3655
+ const month = Number(m[1]);
3656
+ const day = Number(m[2]);
3657
+ if (month < 1 || month > 12 || day < 1 || day > DAYS_IN_MONTH[month - 1]) return void 0;
3658
+ let n = 0;
3659
+ for (let i = 0; i < month - 1; i++) n += DAYS_IN_MONTH[i];
3660
+ return n + day - 1;
3661
+ }
3662
+ function tariffIssues(row) {
3663
+ const issues = [];
3664
+ const d = amountOf(row.demandChargePerKW, "demandChargePerKW", issues);
3665
+ const e = amountOf(row.energyChargePerKWh, "energyChargePerKWh", issues);
3666
+ const currency = String(row.currency ?? "").trim();
3667
+ if ((d !== void 0 || e !== void 0) && !currency) issues.push({ field: "currency", code: "currency-required" });
3668
+ if (currency && !isIso4217Code(currency)) issues.push({ field: "currency", code: "format", params: { format: "ISO 4217 (KRW, USD)", value: currency } });
3669
+ return issues;
3670
+ }
3671
+ function tariffBandIssues(row) {
3672
+ const issues = [];
3673
+ if (empty(row.tariffName)) issues.push({ field: "tariffName", code: "required" });
3674
+ if (empty(row.band)) issues.push({ field: "band", code: "required" });
3675
+ const loadClass = String(row.loadClass ?? "").trim();
3676
+ if (!loadClass) issues.push({ field: "loadClass", code: "required" });
3677
+ else if (!TARIFF_LOAD_CLASSES.includes(loadClass)) {
3678
+ issues.push({ field: "loadClass", code: "not-in-vocabulary", params: { allowed: TARIFF_LOAD_CLASSES.join("|"), value: loadClass } });
3679
+ }
3680
+ const dayKind = empty(row.dayKind) ? "all" : String(row.dayKind).trim();
3681
+ if (!TARIFF_DAY_KINDS.includes(dayKind)) {
3682
+ issues.push({ field: "dayKind", code: "not-in-vocabulary", params: { allowed: TARIFF_DAY_KINDS.join("|"), value: dayKind } });
3683
+ }
3684
+ const sFromEmpty = empty(row.seasonFrom);
3685
+ const sToEmpty = empty(row.seasonTo);
3686
+ if (sFromEmpty !== sToEmpty) issues.push({ field: sFromEmpty ? "seasonFrom" : "seasonTo", code: "season-pair" });
3687
+ if (!sFromEmpty && dayOfYearOf(row.seasonFrom) === void 0) issues.push({ field: "seasonFrom", code: "format", params: { format: "MM-DD", value: String(row.seasonFrom) } });
3688
+ if (!sToEmpty && dayOfYearOf(row.seasonTo) === void 0) issues.push({ field: "seasonTo", code: "format", params: { format: "MM-DD", value: String(row.seasonTo) } });
3689
+ const from = minutesOf(row.fromTime);
3690
+ const to = minutesOf(row.toTime);
3691
+ if (from === void 0 || from === 1440) issues.push({ field: "fromTime", code: "format", params: { format: "HH:mm 00:00..23:59", value: String(row.fromTime ?? "") } });
3692
+ if (to === void 0 || to === 0) issues.push({ field: "toTime", code: "format", params: { format: "HH:mm 00:01..24:00", value: String(row.toTime ?? "") } });
3693
+ if (from !== void 0 && to !== void 0 && from < 1440 && to > 0 && from >= to) {
3694
+ issues.push({ field: "toTime", code: "end-not-after-start", params: { from: String(row.fromTime), to: String(row.toTime) } });
3695
+ }
3696
+ if (empty(row.energyChargePerKWh)) issues.push({ field: "energyChargePerKWh", code: "required" });
3697
+ else amountOf(row.energyChargePerKWh, "energyChargePerKWh", issues);
3698
+ amountOf(row.demandChargePerKW, "demandChargePerKW", issues);
3699
+ return issues;
3700
+ }
3701
+ function seasonHas(band, dayOfYear) {
3702
+ if (empty(band.seasonFrom) && empty(band.seasonTo)) return true;
3703
+ const from = dayOfYearOf(band.seasonFrom);
3704
+ const to = dayOfYearOf(band.seasonTo);
3705
+ if (from === void 0 || to === void 0) return false;
3706
+ return from <= to ? dayOfYear >= from && dayOfYear <= to : dayOfYear >= from || dayOfYear <= to;
3707
+ }
3708
+ function pricesHolidays(bands) {
3709
+ return bands.some((b) => String(b.dayKind ?? "").trim() === "holiday");
3710
+ }
3711
+ function dayKindOf(at2, holidays, isHoliday) {
3712
+ if (holidays && isHoliday?.(at2.month, at2.day)) return "holiday";
3713
+ return at2.weekday === 0 ? "sunday" : at2.weekday === 6 ? "saturday" : "weekday";
3714
+ }
3715
+ function dayKindHas(band, kind) {
3716
+ const k = empty(band.dayKind) ? "all" : String(band.dayKind).trim();
3717
+ return k === "all" || k === kind;
3718
+ }
3719
+ function activeBands(bands, at2) {
3720
+ return bands.filter((b) => empty(b.effectiveEnd) || new Date(b.effectiveEnd).getTime() > at2.getTime());
3721
+ }
3722
+ var hhmm = (m) => `${String(Math.floor(m / 60)).padStart(2, "0")}:${String(m % 60).padStart(2, "0")}`;
3723
+ function mmdd(dayOfYear) {
3724
+ let month = 0;
3725
+ let rest = dayOfYear;
3726
+ while (rest >= DAYS_IN_MONTH[month]) rest -= DAYS_IN_MONTH[month++];
3727
+ return `${String(month + 1).padStart(2, "0")}-${String(rest + 1).padStart(2, "0")}`;
3728
+ }
3729
+ function tariffCoverageIssues(tariff, bands) {
3730
+ const issues = [];
3731
+ if (!bands.length) return issues;
3732
+ const usable = bands.filter((b) => tariffBandIssues(b).length === 0);
3733
+ if (!empty(tariff.energyChargePerKWh)) issues.push({ field: "energyChargePerKWh", code: "flat-and-bands" });
3734
+ if (!String(tariff.currency ?? "").trim()) issues.push({ field: "currency", code: "currency-required" });
3735
+ const holidays = pricesHolidays(usable);
3736
+ if (holidays && empty(tariff.holidayCalendar)) {
3737
+ issues.push({ field: "holidayCalendar", code: "required", params: { because: "the tariff has holiday bands" } });
3738
+ }
3739
+ const broken = bands.length - usable.length;
3740
+ if (broken) issues.push({ field: "bands", code: "broken-bands", params: { count: broken } });
3741
+ const seen = /* @__PURE__ */ new Map();
3742
+ const note = (kind, day, code, from, to, names) => {
3743
+ const key = [kind, code, from, to, names ?? ""].join("\0");
3744
+ const entry = seen.get(key);
3745
+ if (entry) entry.days.push(day);
3746
+ else {
3747
+ const params = { dayKind: kind, from: hhmm(from), to: hhmm(to) };
3748
+ if (names) params.bands = names;
3749
+ seen.set(key, { problem: { field: "bands", code, params }, days: [day] });
3750
+ }
3751
+ };
3752
+ for (const kind of CONCRETE_DAY_KINDS.filter((k) => k !== "holiday" || holidays)) {
3753
+ for (let day = 0; day < 366; day++) {
3754
+ const today = usable.filter((b) => seasonHas(b, day) && dayKindHas(b, kind)).map((b) => ({ name: String(b.name ?? ""), from: minutesOf(b.fromTime), to: minutesOf(b.toTime) })).sort((a, b) => a.from - b.from || a.to - b.to);
3755
+ let cursor = 0;
3756
+ let last;
3757
+ for (const b of today) {
3758
+ if (b.from > cursor) note(kind, day, "gap", cursor, b.from);
3759
+ if (last && b.from < last.to) note(kind, day, "overlap", b.from, Math.min(last.to, b.to), `${last.name}\xB7${b.name}`);
3760
+ if (b.to > cursor) {
3761
+ cursor = b.to;
3762
+ last = b;
3763
+ }
3764
+ }
3765
+ if (cursor < 1440) note(kind, day, "gap", cursor, 1440);
3766
+ }
3767
+ }
3768
+ for (const { problem, days } of seen.values()) {
3769
+ const spans = [];
3770
+ let start = days[0];
3771
+ let prev = days[0];
3772
+ for (const d of [...days.slice(1), Infinity]) {
3773
+ if (d === prev + 1) {
3774
+ prev = d;
3775
+ continue;
3776
+ }
3777
+ spans.push(start === prev ? mmdd(start) : `${mmdd(start)}~${mmdd(prev)}`);
3778
+ start = prev = d;
3779
+ }
3780
+ issues.push({ ...problem, params: { ...problem.params, days: spans.join(", ") } });
3781
+ }
3782
+ return issues;
3783
+ }
3784
+ function bandAt(tariff, bands, at2, isHoliday) {
3785
+ const currency = String(tariff.currency ?? "").trim() || void 0;
3786
+ const usable = bands.filter((b) => tariffBandIssues(b).length === 0);
3787
+ if (!usable.length) {
3788
+ const flat = empty(tariff.energyChargePerKWh) ? NaN : Number(tariff.energyChargePerKWh);
3789
+ if (!Number.isFinite(flat)) return { reason: "no-price" };
3790
+ return { energyChargePerKWh: flat, ...currency ? { currency } : {}, holidayKnown: true };
3791
+ }
3792
+ const day = dayOfYearOf(`${String(at2.month).padStart(2, "0")}-${String(at2.day).padStart(2, "0")}`);
3793
+ if (day === void 0) return { reason: "no-band" };
3794
+ const holidays = pricesHolidays(usable);
3795
+ const kind = dayKindOf(at2, holidays, isHoliday);
3796
+ const hits = usable.filter(
3797
+ (b) => seasonHas(b, day) && dayKindHas(b, kind) && minutesOf(b.fromTime) <= at2.minutes && at2.minutes < minutesOf(b.toTime)
3798
+ );
3799
+ if (!hits.length) return { reason: "no-band" };
3800
+ if (hits.length > 1) return { reason: "ambiguous", bands: hits.map((b) => String(b.name ?? "")) };
3801
+ const hit = hits[0];
3802
+ const demand = empty(hit.demandChargePerKW) ? void 0 : Number(hit.demandChargePerKW);
3803
+ return {
3804
+ bandName: String(hit.name ?? "") || void 0,
3805
+ band: String(hit.band).trim(),
3806
+ loadClass: String(hit.loadClass).trim(),
3807
+ energyChargePerKWh: Number(hit.energyChargePerKWh),
3808
+ ...demand !== void 0 ? { demandChargePerKW: demand } : {},
3809
+ ...currency ? { currency } : {},
3810
+ holidayKnown: !holidays || !!isHoliday
3811
+ };
3812
+ }
3813
+
3495
3814
  // src/gs1.ts
3496
3815
  var FNC1 = "";
3497
3816
  var FIXED_LENGTH = {
@@ -3784,6 +4103,279 @@ function partitionLensLocations(locations, lensSystem) {
3784
4103
  return { own, referenced };
3785
4104
  }
3786
4105
 
4106
+ // src/route-network.ts
4107
+ var CONNECTION_DIRECTION = ["one-way", "two-way"];
4108
+ var FIXED_ROUTE_BINDING = ["mandatory", "preferred"];
4109
+ var DEFAULT_CONNECTION_CAPACITY = 1;
4110
+ var ROUTE_NETWORK_ISSUE = {
4111
+ connectionDangling: "route-connection-dangling",
4112
+ connectionSelf: "route-connection-self",
4113
+ connectionLength: "route-connection-length",
4114
+ connectionSpeed: "route-connection-speed",
4115
+ connectionCapacity: "route-connection-capacity",
4116
+ connectionDirection: "route-connection-direction",
4117
+ connectionDuplicate: "route-connection-duplicate",
4118
+ connectionUnknownClass: "route-connection-unknown-class",
4119
+ fixedEmpty: "route-fixed-empty",
4120
+ fixedUnknownConnection: "route-fixed-unknown-connection",
4121
+ fixedBroken: "route-fixed-broken",
4122
+ fixedClass: "route-fixed-class",
4123
+ fixedBinding: "route-fixed-binding",
4124
+ duplicateId: "route-duplicate-id"
4125
+ };
4126
+ var positiveNumber = (v) => typeof v === "number" && Number.isFinite(v) && v > 0;
4127
+ function traversals(c) {
4128
+ return c.direction === "two-way" ? [{ from: c.from, to: c.to }, { from: c.to, to: c.from }] : [{ from: c.from, to: c.to }];
4129
+ }
4130
+ function admits(c, classIds, classes) {
4131
+ if (!c.equipmentClassIds || c.equipmentClassIds.length === 0) return true;
4132
+ const allowed = new Set(c.equipmentClassIds);
4133
+ return classIds.every((id) => [...classClosure([id], classes)].some((k) => allowed.has(k)));
4134
+ }
4135
+ function validateRouteNetwork(def) {
4136
+ const issues = [];
4137
+ const places = new Set([...def.locations ?? [], ...def.referencedLocations ?? []].map((l) => l.id));
4138
+ const connections = def.connections ?? [];
4139
+ const classIds = new Set((def.equipmentClasses ?? []).map((c) => c.id));
4140
+ const byId = /* @__PURE__ */ new Map();
4141
+ const seenEnds = /* @__PURE__ */ new Set();
4142
+ for (const c of connections) {
4143
+ if (byId.has(c.id)) issues.push({ code: ROUTE_NETWORK_ISSUE.duplicateId, subject: c.id, params: { kind: "connection" } });
4144
+ byId.set(c.id, c);
4145
+ for (const end of [c.from, c.to]) {
4146
+ if (!places.has(end)) issues.push({ code: ROUTE_NETWORK_ISSUE.connectionDangling, subject: c.id, params: { location: end } });
4147
+ }
4148
+ if (c.from === c.to) issues.push({ code: ROUTE_NETWORK_ISSUE.connectionSelf, subject: c.id, params: { location: c.from } });
4149
+ if (!CONNECTION_DIRECTION.includes(c.direction)) {
4150
+ issues.push({ code: ROUTE_NETWORK_ISSUE.connectionDirection, subject: c.id, params: { direction: String(c.direction) } });
4151
+ }
4152
+ if (!positiveNumber(c.lengthM)) issues.push({ code: ROUTE_NETWORK_ISSUE.connectionLength, subject: c.id, params: { lengthM: String(c.lengthM) } });
4153
+ if (c.maxSpeedMps !== void 0 && !positiveNumber(c.maxSpeedMps)) {
4154
+ issues.push({ code: ROUTE_NETWORK_ISSUE.connectionSpeed, subject: c.id, params: { maxSpeedMps: String(c.maxSpeedMps) } });
4155
+ }
4156
+ if (c.capacity !== void 0 && !(Number.isInteger(c.capacity) && c.capacity >= 1)) {
4157
+ issues.push({ code: ROUTE_NETWORK_ISSUE.connectionCapacity, subject: c.id, params: { capacity: String(c.capacity) } });
4158
+ }
4159
+ if (classIds.size > 0) {
4160
+ for (const id of c.equipmentClassIds ?? []) {
4161
+ if (!classIds.has(id)) issues.push({ code: ROUTE_NETWORK_ISSUE.connectionUnknownClass, subject: c.id, params: { equipmentClassId: id } });
4162
+ }
4163
+ }
4164
+ for (const t of traversals(c)) {
4165
+ const key = `${t.from}\0${t.to}`;
4166
+ if (seenEnds.has(key)) issues.push({ code: ROUTE_NETWORK_ISSUE.connectionDuplicate, subject: c.id, params: { from: t.from, to: t.to } });
4167
+ seenEnds.add(key);
4168
+ }
4169
+ }
4170
+ const routeIds = /* @__PURE__ */ new Set();
4171
+ for (const r of def.fixedRoutes ?? []) {
4172
+ if (routeIds.has(r.id)) issues.push({ code: ROUTE_NETWORK_ISSUE.duplicateId, subject: r.id, params: { kind: "fixed-route" } });
4173
+ routeIds.add(r.id);
4174
+ if (!FIXED_ROUTE_BINDING.includes(r.binding)) {
4175
+ issues.push({ code: ROUTE_NETWORK_ISSUE.fixedBinding, subject: r.id, params: { binding: String(r.binding) } });
4176
+ }
4177
+ if (!r.connectionIds || r.connectionIds.length === 0) {
4178
+ issues.push({ code: ROUTE_NETWORK_ISSUE.fixedEmpty, subject: r.id, params: {} });
4179
+ continue;
4180
+ }
4181
+ const legs = [];
4182
+ for (const id of r.connectionIds) {
4183
+ const c = byId.get(id);
4184
+ if (!c) issues.push({ code: ROUTE_NETWORK_ISSUE.fixedUnknownConnection, subject: r.id, params: { connection: id } });
4185
+ else legs.push(c);
4186
+ }
4187
+ if (legs.length !== r.connectionIds.length) continue;
4188
+ let at2 = new Set(traversals(legs[0]).map((t) => t.to));
4189
+ for (let i = 1; i < legs.length; i++) {
4190
+ const next = new Set(traversals(legs[i]).filter((t) => at2.has(t.from)).map((t) => t.to));
4191
+ if (next.size === 0) {
4192
+ issues.push({ code: ROUTE_NETWORK_ISSUE.fixedBroken, subject: r.id, params: { after: legs[i - 1].id, connection: legs[i].id } });
4193
+ break;
4194
+ }
4195
+ at2 = next;
4196
+ }
4197
+ for (const classId of r.equipmentClassIds ?? []) {
4198
+ const blocked = legs.find((c) => !admits(c, [classId], def.equipmentClasses));
4199
+ if (blocked) issues.push({ code: ROUTE_NETWORK_ISSUE.fixedClass, subject: r.id, params: { equipmentClassId: classId, connection: blocked.id } });
4200
+ }
4201
+ }
4202
+ return issues;
4203
+ }
4204
+ function connectionAdmits(c, equipmentClassIds, classes) {
4205
+ return admits(c, equipmentClassIds, classes);
4206
+ }
4207
+
4208
+ // src/travel.ts
4209
+ var TRAVEL_LINK_STATE = ["online", "stale", "lost"];
4210
+ var TRAVEL_LINK_JUDGED_BY = ["source", "derived"];
4211
+ function linkStateAt(link, nowTime, thresholds) {
4212
+ if (link.judgedBy === "source") return link;
4213
+ if (!nowTime) return void 0;
4214
+ const now = Date.parse(nowTime);
4215
+ const seen = Date.parse(link.lastSeenAt);
4216
+ const { staleAfterMs, lostAfterMs } = thresholds;
4217
+ if (!Number.isFinite(now) || !Number.isFinite(seen)) return void 0;
4218
+ if (!(staleAfterMs >= 0 && lostAfterMs >= staleAfterMs)) return void 0;
4219
+ const silentMs = now - seen;
4220
+ const state = silentMs > lostAfterMs ? "lost" : silentMs > staleAfterMs ? "stale" : "online";
4221
+ return { ...link, state, judgedBy: "derived" };
4222
+ }
4223
+ function isHeading(v) {
4224
+ return typeof v === "number" && Number.isFinite(v) && v >= 0 && v < 360;
4225
+ }
4226
+
4227
+ // src/intralogistics-profile.ts
4228
+ var ILG_BIZSTEP = {
4229
+ /** The carrier left a port. */
4230
+ departing: "urn:epcglobal:cbv:bizstep:departing",
4231
+ /** The carrier reached a port. */
4232
+ arriving: "urn:epcglobal:cbv:bizstep:arriving",
4233
+ /** The carrier is on its way. */
4234
+ transporting: "urn:epcglobal:cbv:bizstep:transporting"
4235
+ };
4236
+ var ILG_LOCATION_TYPES = ["waypoint", "port", "charger", "parking"];
4237
+ var ILG_LOCATION_LEVEL = {
4238
+ waypoint: "Other",
4239
+ port: "StorageUnit",
4240
+ charger: "Other",
4241
+ parking: "Other"
4242
+ };
4243
+ var ILG_LOCATION_CAPABILITIES = {
4244
+ waypoint: [],
4245
+ port: ["storable"],
4246
+ charger: [],
4247
+ parking: []
4248
+ };
4249
+ var ILG_TYPES = [
4250
+ ...ILG_LOCATION_TYPES.map((k) => ({
4251
+ key: k,
4252
+ role: "location",
4253
+ label: `twin.type.${k}`,
4254
+ standardClass: { epcis: "bizLocation" },
4255
+ identity: { scheme: "gs1:SGLN" },
4256
+ level: ILG_LOCATION_LEVEL[k],
4257
+ capabilities: ILG_LOCATION_CAPABILITIES[k]
4258
+ })),
4259
+ /* A forklift under transport control keeps the wms `forklift` type and adds `guided` in the site's own declaration. */
4260
+ { key: "amr", role: "equipment", label: "twin.type.amr", standardClass: { epcis: "object", iso55000: "Asset" }, identity: { scheme: "gs1:GIAI" }, capabilities: ["mobile", "guided", "operable", "energyStoring"] },
4261
+ { key: "agv", role: "equipment", label: "twin.type.agv", standardClass: { epcis: "object", iso55000: "Asset" }, identity: { scheme: "gs1:GIAI" }, capabilities: ["mobile", "guided", "operable", "energyStoring"] }
4262
+ ];
4263
+ function intralogisticsTypeOf(key) {
4264
+ return ILG_TYPES.find((t) => t.key === key);
4265
+ }
4266
+ var ILG_ORDER_KIND = {
4267
+ transport: "transport"
4268
+ };
4269
+ var ILG_TASK_KIND = {
4270
+ leg: "transport-leg",
4271
+ charge: "charge",
4272
+ park: "park"
4273
+ };
4274
+ var TRANSPORT_FAILURE_REASON = [
4275
+ "no-route",
4276
+ "destination-unavailable",
4277
+ "carrier-not-found",
4278
+ /** The carrier identified at pick-up is not the one the command named. */
4279
+ "carrier-mismatch",
4280
+ "cancelled-by-source",
4281
+ "equipment-fault"
4282
+ ];
4283
+ function isTransportFailureReason(v) {
4284
+ return typeof v === "string" && TRANSPORT_FAILURE_REASON.includes(v);
4285
+ }
4286
+ var ILG_ATTENTION_KIND = {
4287
+ deadlock: "intralogic.traffic-deadlock",
4288
+ blocked: "intralogic.traffic-blocked",
4289
+ lowCharge: "intralogic.low-charge",
4290
+ linkLost: "intralogic.link-lost",
4291
+ noRoute: "intralogic.no-route",
4292
+ rerouted: "intralogic.rerouted",
4293
+ carrierUnidentified: "intralogic.carrier-unidentified",
4294
+ carrierDuplicate: "intralogic.carrier-duplicate"
4295
+ };
4296
+
4297
+ // src/transport-policy.ts
4298
+ var DISPATCH_RULE = {
4299
+ /** The first available machine in the kernel's own order - what its assignment does today. */
4300
+ firstIdle: "firstIdle",
4301
+ /** The machine that reaches the pick-up soonest; ties by id. */
4302
+ minEta: "minEta"
4303
+ };
4304
+ var ROUTING_RULE = {
4305
+ /** Least travel time, reservations not considered. Connection time = length / effective speed. */
4306
+ shortestTime: "shortestTime",
4307
+ /** Least arrival time over time windows: a connection held past its capacity is waited for or avoided. */
4308
+ timeWindow: "timeWindow"
4309
+ };
4310
+ var TRAFFIC_CONFLICT_ACTION = ["wait", "replan", "yield"];
4311
+ var TRANSPORT_POLICY_ISSUE = {
4312
+ ruleMissing: "policy-rule-missing",
4313
+ ruleUnknown: "policy-rule-unknown",
4314
+ conflictAction: "policy-conflict-action",
4315
+ horizon: "policy-horizon",
4316
+ soc: "policy-soc",
4317
+ alternateUnknown: "policy-alternate-unknown",
4318
+ alternateSelf: "policy-alternate-self",
4319
+ alternateDuplicate: "policy-alternate-duplicate"
4320
+ };
4321
+ var isPercent = (v) => typeof v === "number" && Number.isFinite(v) && v >= 0 && v <= 100;
4322
+ function validateTransportPolicy(policy, locationIds) {
4323
+ const issues = [];
4324
+ const known = { dispatch: Object.values(DISPATCH_RULE), routing: Object.values(ROUTING_RULE) };
4325
+ for (const part of ["dispatch", "routing"]) {
4326
+ const rule = policy[part]?.rule;
4327
+ if (typeof rule !== "string" || rule.trim() === "") issues.push({ code: TRANSPORT_POLICY_ISSUE.ruleMissing, params: { part } });
4328
+ else if (!known[part].includes(rule)) issues.push({ code: TRANSPORT_POLICY_ISSUE.ruleUnknown, params: { part, rule } });
4329
+ }
4330
+ if (!TRAFFIC_CONFLICT_ACTION.includes(policy.traffic?.onConflict)) {
4331
+ issues.push({ code: TRANSPORT_POLICY_ISSUE.conflictAction, params: { onConflict: String(policy.traffic?.onConflict) } });
4332
+ }
4333
+ const horizon = policy.traffic?.horizonS;
4334
+ if (horizon !== void 0 && !(typeof horizon === "number" && Number.isFinite(horizon) && horizon > 0)) {
4335
+ issues.push({ code: TRANSPORT_POLICY_ISSUE.horizon, params: { horizonS: String(horizon) } });
4336
+ }
4337
+ const { lowSoc, targetSoc } = policy.charging ?? {};
4338
+ if (!isPercent(lowSoc) || !isPercent(targetSoc) || lowSoc >= targetSoc) {
4339
+ issues.push({ code: TRANSPORT_POLICY_ISSUE.soc, params: { lowSoc: String(lowSoc), targetSoc: String(targetSoc) } });
4340
+ }
4341
+ const seen = /* @__PURE__ */ new Set();
4342
+ for (const a of policy.alternates ?? []) {
4343
+ if (seen.has(a.destination)) issues.push({ code: TRANSPORT_POLICY_ISSUE.alternateDuplicate, params: { destination: a.destination } });
4344
+ seen.add(a.destination);
4345
+ if (a.alternatives.includes(a.destination)) issues.push({ code: TRANSPORT_POLICY_ISSUE.alternateSelf, params: { destination: a.destination } });
4346
+ if (locationIds) {
4347
+ for (const id of [a.destination, ...a.alternatives]) {
4348
+ if (!locationIds.has(id)) issues.push({ code: TRANSPORT_POLICY_ISSUE.alternateUnknown, params: { location: id } });
4349
+ }
4350
+ }
4351
+ }
4352
+ return issues;
4353
+ }
4354
+
4355
+ // src/asset-acceptance.ts
4356
+ function acceptsMaterial(accepts, query) {
4357
+ if (!accepts) return void 0;
4358
+ const defs = accepts.materialDefinitionIds ?? [];
4359
+ const classes = accepts.materialClassIds ?? [];
4360
+ const named = query.materialDefinitionId !== void 0 || (query.materialClassIds?.length ?? 0) > 0;
4361
+ if (!named) return void 0;
4362
+ let material;
4363
+ if (defs.length === 0 && classes.length === 0) material = void 0;
4364
+ else {
4365
+ const byDef = query.materialDefinitionId !== void 0 && defs.includes(query.materialDefinitionId);
4366
+ const byClass = (query.materialClassIds ?? []).some((id) => classes.includes(id));
4367
+ material = byDef || byClass;
4368
+ }
4369
+ if (material === false) return false;
4370
+ let quantity = true;
4371
+ if (query.quantity && accepts.maxQuantity) {
4372
+ quantity = query.quantity.uom === accepts.maxQuantity.uom ? query.quantity.value <= accepts.maxQuantity.value : void 0;
4373
+ }
4374
+ if (quantity === false) return false;
4375
+ if (material === void 0 || quantity === void 0) return void 0;
4376
+ return true;
4377
+ }
4378
+
3787
4379
  // src/face2-adapter.ts
3788
4380
  function isAggregationRecord(record) {
3789
4381
  if (!record || typeof record !== "object") return false;
@@ -4104,8 +4696,8 @@ function shapeErrors(where, row, shape) {
4104
4696
  const errors = [];
4105
4697
  for (const f of shape.required ?? []) {
4106
4698
  const v = row[f];
4107
- const empty = v === void 0 || v === null || typeof v === "string" && !v.trim();
4108
- if (empty) errors.push(`${where}.${f}: \uD544\uC218 \uD544\uB4DC \uB204\uB77D`);
4699
+ const empty2 = v === void 0 || v === null || typeof v === "string" && !v.trim();
4700
+ if (empty2) errors.push(`${where}.${f}: \uD544\uC218 \uD544\uB4DC \uB204\uB77D`);
4109
4701
  }
4110
4702
  for (const [f, t] of Object.entries(shape.fields ?? {})) {
4111
4703
  const v = row[f];
@@ -5511,6 +6103,9 @@ function shapedRecordsOf(event) {
5511
6103
  };
5512
6104
  }
5513
6105
  case "AggregationEvent":
6106
+ if (!event.parentID) {
6107
+ throw shapeError("aggregation-no-parent", { event: event.eventID }, "the aggregation names no parent: the canonical record is keyed by its parent");
6108
+ }
5514
6109
  return {
5515
6110
  records: [
5516
6111
  {
@@ -5887,7 +6482,10 @@ function inheritedExpiry(inputExpiries) {
5887
6482
  COMMAND_EVENT,
5888
6483
  COMMAND_ORIGIN,
5889
6484
  COMMAND_STATE,
6485
+ CONNECTION_DIRECTION,
6486
+ DEFAULT_CONNECTION_CAPACITY,
5890
6487
  DISP,
6488
+ DISPATCH_RULE,
5891
6489
  DISPOSITION_DECISION,
5892
6490
  DOCK_DOOR_STATUS,
5893
6491
  DOCK_FACT_KIND,
@@ -5908,9 +6506,16 @@ function inheritedExpiry(inputExpiries) {
5908
6506
  ERP_MASTER_AXIS,
5909
6507
  FIELDS_NOT_CARRIED,
5910
6508
  FIRST_PASS_RULE,
6509
+ FIXED_ROUTE_BINDING,
5911
6510
  GUARD_PRAGMA,
5912
6511
  HATIOLAB_VOCABULARY,
5913
6512
  HEADER_FIELDS_PARTITIONED,
6513
+ ILG_ATTENTION_KIND,
6514
+ ILG_BIZSTEP,
6515
+ ILG_LOCATION_TYPES,
6516
+ ILG_ORDER_KIND,
6517
+ ILG_TASK_KIND,
6518
+ ILG_TYPES,
5914
6519
  ILMD_ATTR,
5915
6520
  LOCATION_SATURATION_NEAR,
5916
6521
  MATERIAL_ACTUAL_USE,
@@ -5944,12 +6549,22 @@ function inheritedExpiry(inputExpiries) {
5944
6549
  RESOURCE_KIND,
5945
6550
  RETIRED_VOCABULARY,
5946
6551
  RETURN_TO_SUPPLIER,
6552
+ ROUTE_NETWORK_ISSUE,
6553
+ ROUTING_RULE,
5947
6554
  SCHEDULE_STATUS,
5948
6555
  SIGNATURE_REJECTED_REASONS,
5949
6556
  SOURCE_DEST_PARTY_TYPE,
6557
+ TARIFF_DAY_KINDS,
6558
+ TARIFF_ISSUE_CODES,
6559
+ TARIFF_LOAD_CLASSES,
5950
6560
  TASK_STATUS,
5951
6561
  TASK_TERMINAL_STATUS,
6562
+ TRAFFIC_CONFLICT_ACTION,
5952
6563
  TRAILER_LOAD,
6564
+ TRANSPORT_FAILURE_REASON,
6565
+ TRANSPORT_POLICY_ISSUE,
6566
+ TRAVEL_LINK_JUDGED_BY,
6567
+ TRAVEL_LINK_STATE,
5953
6568
  TWIN_AXES,
5954
6569
  TWIN_PROPERTIES,
5955
6570
  TWIN_RELATIONS,
@@ -5976,7 +6591,9 @@ function inheritedExpiry(inputExpiries) {
5976
6591
  YMS_ORDER_KIND,
5977
6592
  YMS_TASK_KIND,
5978
6593
  YMS_TYPES,
6594
+ acceptsMaterial,
5979
6595
  acceptsPerformance,
6596
+ activeBands,
5980
6597
  activeShiftAt,
5981
6598
  activeShiftOf,
5982
6599
  aggregationEvent,
@@ -5987,6 +6604,7 @@ function inheritedExpiry(inputExpiries) {
5987
6604
  axisAppliesTo,
5988
6605
  axisInfo,
5989
6606
  axisSource,
6607
+ bandAt,
5990
6608
  bizStepName,
5991
6609
  bizTransactionUri,
5992
6610
  canPreview,
@@ -6005,8 +6623,10 @@ function inheritedExpiry(inputExpiries) {
6005
6623
  computeMtbf,
6006
6624
  computeMttr,
6007
6625
  computeOee,
6626
+ connectionAdmits,
6008
6627
  conversionFactorOf,
6009
6628
  criterionSaysNothing,
6629
+ dayOfYearOf,
6010
6630
  dispatchMoveFactOf,
6011
6631
  dockDoorCapacityOf,
6012
6632
  dockDoorStatusOf,
@@ -6049,6 +6669,7 @@ function inheritedExpiry(inputExpiries) {
6049
6669
  ingestOperationalRecords,
6050
6670
  inheritedExpiry,
6051
6671
  inheritedLotUse,
6672
+ intralogisticsTypeOf,
6052
6673
  isAggregationRecord,
6053
6674
  isAppointmentClosed,
6054
6675
  isCacheableTense,
@@ -6068,6 +6689,8 @@ function inheritedExpiry(inputExpiries) {
6068
6689
  isEquipmentStatus,
6069
6690
  isFailureStatus,
6070
6691
  isFlowOrder,
6692
+ isHeading,
6693
+ isIso4217Code,
6071
6694
  isIsoDateTime,
6072
6695
  isMasterDataRecord,
6073
6696
  isMaterialExecutionBasis,
@@ -6085,6 +6708,7 @@ function inheritedExpiry(inputExpiries) {
6085
6708
  isTaskTerminal,
6086
6709
  isTestSpecificationBasis,
6087
6710
  isTransformationRecord,
6711
+ isTransportFailureReason,
6088
6712
  isWebhookDeliveryCode,
6089
6713
  isWebhookSecretSegment,
6090
6714
  isWorkShiftExecutionBasis,
@@ -6098,6 +6722,7 @@ function inheritedExpiry(inputExpiries) {
6098
6722
  judgeAgainstSpec,
6099
6723
  levelOfLocationType,
6100
6724
  lgtinClass,
6725
+ linkStateAt,
6101
6726
  localDayIndexAt,
6102
6727
  localDayStartMs,
6103
6728
  locationStatusOf,
@@ -6111,11 +6736,11 @@ function inheritedExpiry(inputExpiries) {
6111
6736
  materialMovementKey,
6112
6737
  meetsTests,
6113
6738
  minuteOfDayAt,
6739
+ minutesOf,
6114
6740
  missingCommandPayload,
6115
6741
  moveExpiryText,
6116
6742
  moveFactOf,
6117
6743
  nextCommandState,
6118
- nonWorkingMsIn,
6119
6744
  normalizeEquipmentStatus,
6120
6745
  objectEvent,
6121
6746
  objectUri,
@@ -6169,6 +6794,10 @@ function inheritedExpiry(inputExpiries) {
6169
6794
  ssccUri,
6170
6795
  stateFieldsOf,
6171
6796
  subLotIdOf,
6797
+ tariffBandIssues,
6798
+ tariffCoverageIssues,
6799
+ tariffIssueText,
6800
+ tariffIssues,
6172
6801
  tenseOf,
6173
6802
  testEvidenceGaps,
6174
6803
  testPassedAt,
@@ -6180,7 +6809,9 @@ function inheritedExpiry(inputExpiries) {
6180
6809
  validateDomainDefinition,
6181
6810
  validateEpcisEvent,
6182
6811
  validatePerformance,
6812
+ validateRouteNetwork,
6183
6813
  validateScenario,
6814
+ validateTransportPolicy,
6184
6815
  verdictOfAck,
6185
6816
  webhookLaneOf,
6186
6817
  webhookSecretCandidates,
@@ -6190,6 +6821,5 @@ function inheritedExpiry(inputExpiries) {
6190
6821
  webhookSenderAction,
6191
6822
  weekdayAt,
6192
6823
  workShiftAttribution,
6193
- workingHoursBetween,
6194
- workingTimeOfWeek
6824
+ workingHoursBetween
6195
6825
  });