@operato/ops-contract 0.9.47 → 0.9.48
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -1
- package/dist/capacity.d.ts +1 -36
- package/dist/capacity.js +0 -80
- package/dist/epcis.d.ts +4 -2
- package/dist/epcis.js +12 -10
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/mes-profile.js +5 -1
- package/dist/records-of-event.d.ts +1 -1
- package/dist/records-of-event.js +5 -0
- package/dist/tariff.d.ts +163 -0
- package/dist/tariff.js +376 -0
- package/dist-cjs/index.cjs +294 -45
- package/package.json +1 -1
package/dist-cjs/index.cjs
CHANGED
|
@@ -94,6 +94,9 @@ __export(index_exports, {
|
|
|
94
94
|
SCHEDULE_STATUS: () => SCHEDULE_STATUS,
|
|
95
95
|
SIGNATURE_REJECTED_REASONS: () => SIGNATURE_REJECTED_REASONS,
|
|
96
96
|
SOURCE_DEST_PARTY_TYPE: () => SOURCE_DEST_PARTY_TYPE,
|
|
97
|
+
TARIFF_DAY_KINDS: () => TARIFF_DAY_KINDS,
|
|
98
|
+
TARIFF_ISSUE_CODES: () => TARIFF_ISSUE_CODES,
|
|
99
|
+
TARIFF_LOAD_CLASSES: () => TARIFF_LOAD_CLASSES,
|
|
97
100
|
TASK_STATUS: () => TASK_STATUS,
|
|
98
101
|
TASK_TERMINAL_STATUS: () => TASK_TERMINAL_STATUS,
|
|
99
102
|
TRAILER_LOAD: () => TRAILER_LOAD,
|
|
@@ -124,6 +127,7 @@ __export(index_exports, {
|
|
|
124
127
|
YMS_TASK_KIND: () => YMS_TASK_KIND,
|
|
125
128
|
YMS_TYPES: () => YMS_TYPES,
|
|
126
129
|
acceptsPerformance: () => acceptsPerformance,
|
|
130
|
+
activeBands: () => activeBands,
|
|
127
131
|
activeShiftAt: () => activeShiftAt,
|
|
128
132
|
activeShiftOf: () => activeShiftOf,
|
|
129
133
|
aggregationEvent: () => aggregationEvent,
|
|
@@ -134,6 +138,7 @@ __export(index_exports, {
|
|
|
134
138
|
axisAppliesTo: () => axisAppliesTo,
|
|
135
139
|
axisInfo: () => axisInfo,
|
|
136
140
|
axisSource: () => axisSource,
|
|
141
|
+
bandAt: () => bandAt,
|
|
137
142
|
bizStepName: () => bizStepName,
|
|
138
143
|
bizTransactionUri: () => bizTransactionUri,
|
|
139
144
|
canPreview: () => canPreview,
|
|
@@ -154,6 +159,7 @@ __export(index_exports, {
|
|
|
154
159
|
computeOee: () => computeOee,
|
|
155
160
|
conversionFactorOf: () => conversionFactorOf,
|
|
156
161
|
criterionSaysNothing: () => criterionSaysNothing,
|
|
162
|
+
dayOfYearOf: () => dayOfYearOf,
|
|
157
163
|
dispatchMoveFactOf: () => dispatchMoveFactOf,
|
|
158
164
|
dockDoorCapacityOf: () => dockDoorCapacityOf,
|
|
159
165
|
dockDoorStatusOf: () => dockDoorStatusOf,
|
|
@@ -215,6 +221,7 @@ __export(index_exports, {
|
|
|
215
221
|
isEquipmentStatus: () => isEquipmentStatus,
|
|
216
222
|
isFailureStatus: () => isFailureStatus,
|
|
217
223
|
isFlowOrder: () => isFlowOrder,
|
|
224
|
+
isIso4217Code: () => isIso4217Code,
|
|
218
225
|
isIsoDateTime: () => isIsoDateTime,
|
|
219
226
|
isMasterDataRecord: () => isMasterDataRecord,
|
|
220
227
|
isMaterialExecutionBasis: () => isMaterialExecutionBasis,
|
|
@@ -258,11 +265,11 @@ __export(index_exports, {
|
|
|
258
265
|
materialMovementKey: () => materialMovementKey,
|
|
259
266
|
meetsTests: () => meetsTests,
|
|
260
267
|
minuteOfDayAt: () => minuteOfDayAt,
|
|
268
|
+
minutesOf: () => minutesOf,
|
|
261
269
|
missingCommandPayload: () => missingCommandPayload,
|
|
262
270
|
moveExpiryText: () => moveExpiryText,
|
|
263
271
|
moveFactOf: () => moveFactOf,
|
|
264
272
|
nextCommandState: () => nextCommandState,
|
|
265
|
-
nonWorkingMsIn: () => nonWorkingMsIn,
|
|
266
273
|
normalizeEquipmentStatus: () => normalizeEquipmentStatus,
|
|
267
274
|
objectEvent: () => objectEvent,
|
|
268
275
|
objectUri: () => objectUri,
|
|
@@ -316,6 +323,10 @@ __export(index_exports, {
|
|
|
316
323
|
ssccUri: () => ssccUri,
|
|
317
324
|
stateFieldsOf: () => stateFieldsOf,
|
|
318
325
|
subLotIdOf: () => subLotIdOf,
|
|
326
|
+
tariffBandIssues: () => tariffBandIssues,
|
|
327
|
+
tariffCoverageIssues: () => tariffCoverageIssues,
|
|
328
|
+
tariffIssueText: () => tariffIssueText,
|
|
329
|
+
tariffIssues: () => tariffIssues,
|
|
319
330
|
tenseOf: () => tenseOf,
|
|
320
331
|
testEvidenceGaps: () => testEvidenceGaps,
|
|
321
332
|
testPassedAt: () => testPassedAt,
|
|
@@ -337,8 +348,7 @@ __export(index_exports, {
|
|
|
337
348
|
webhookSenderAction: () => webhookSenderAction,
|
|
338
349
|
weekdayAt: () => weekdayAt,
|
|
339
350
|
workShiftAttribution: () => workShiftAttribution,
|
|
340
|
-
workingHoursBetween: () => workingHoursBetween
|
|
341
|
-
workingTimeOfWeek: () => workingTimeOfWeek
|
|
351
|
+
workingHoursBetween: () => workingHoursBetween
|
|
342
352
|
});
|
|
343
353
|
module.exports = __toCommonJS(index_exports);
|
|
344
354
|
|
|
@@ -481,6 +491,14 @@ function commandsOf(caps) {
|
|
|
481
491
|
return [...out];
|
|
482
492
|
}
|
|
483
493
|
|
|
494
|
+
// src/capacity.ts
|
|
495
|
+
function isoDurationHours(iso) {
|
|
496
|
+
if (!iso) return 0;
|
|
497
|
+
const m = /^P(?:(\d+)D)?(?:T(?:(\d+)H)?(?:(\d+)M)?(?:([\d.]+)S)?)?$/.exec(iso);
|
|
498
|
+
if (!m) throw new Error(`\uAE30\uAC04 \uD45C\uAE30\uB97C \uC77D\uC744 \uC218 \uC5C6\uB2E4: ${iso}`);
|
|
499
|
+
return Number(m[1] ?? 0) * 24 + Number(m[2] ?? 0) + Number(m[3] ?? 0) / 60 + Number(m[4] ?? 0) / 3600;
|
|
500
|
+
}
|
|
501
|
+
|
|
484
502
|
// src/rated-usage.ts
|
|
485
503
|
var USE_UOM = "C62";
|
|
486
504
|
var num = (n) => typeof n === "number" && Number.isFinite(n);
|
|
@@ -803,8 +821,8 @@ function convertQuantity(item, uom, definitions) {
|
|
|
803
821
|
const factor = conversionFactorOf(def, uom);
|
|
804
822
|
return factor === void 0 ? void 0 : item.qty * factor;
|
|
805
823
|
}
|
|
806
|
-
function minutesOfDay(
|
|
807
|
-
const m = /^(\d{1,2}):(\d{2})$/.exec(
|
|
824
|
+
function minutesOfDay(hhmm2) {
|
|
825
|
+
const m = /^(\d{1,2}):(\d{2})$/.exec(hhmm2 ?? "");
|
|
808
826
|
if (!m) return void 0;
|
|
809
827
|
const h = Number(m[1]);
|
|
810
828
|
const mi = Number(m[2]);
|
|
@@ -1302,37 +1320,6 @@ function gs1Namespaces(prefix) {
|
|
|
1302
1320
|
return [`urn:epc:idpat:sgtin:${prefix}.`, `urn:epc:class:lgtin:${prefix}.`, `urn:epc:id:sgtin:${prefix}.`];
|
|
1303
1321
|
}
|
|
1304
1322
|
|
|
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
1323
|
// src/epcis.ts
|
|
1337
1324
|
var EPCIS_CONTEXT = "https://ref.gs1.org/standards/epcis/2.0.0/epcis-context.jsonld";
|
|
1338
1325
|
var UTC_OFFSET = "+00:00";
|
|
@@ -1806,11 +1793,11 @@ function validateEpcisEvent(e) {
|
|
|
1806
1793
|
}
|
|
1807
1794
|
if (e.type === "ObjectEvent") {
|
|
1808
1795
|
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 \
|
|
1810
|
-
else if (e.epcList
|
|
1796
|
+
if (e.epcList !== void 0 && !Array.isArray(e.epcList)) v.push("ObjectEvent.epcList \uB294 \uBC30\uC5F4\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4");
|
|
1797
|
+
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
1798
|
} else if (e.type === "AggregationEvent") {
|
|
1812
1799
|
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");
|
|
1800
|
+
if (!e.parentID && e.action !== "OBSERVE") v.push("AggregationEvent.parentID \uB204\uB77D \u2014 ADD \xB7 DELETE \uC5D0\uB294 \uD544\uC218\uC785\uB2C8\uB2E4");
|
|
1814
1801
|
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
1802
|
} else if (e.type === "TransactionEvent") {
|
|
1816
1803
|
if (!ACTIONS.includes(e.action)) v.push(`\uC9C0\uC6D0\uD558\uC9C0 \uC54A\uB294 action \uAC12: ${e.action}`);
|
|
@@ -2007,7 +1994,7 @@ var TRAILER_LOAD = ["empty", "loaded"];
|
|
|
2007
1994
|
var MES_BIZSTEP = {
|
|
2008
1995
|
receiving: "urn:epcglobal:cbv:bizstep:receiving",
|
|
2009
1996
|
// 원자재 수령
|
|
2010
|
-
producing:
|
|
1997
|
+
producing: CBV_BIZSTEP.commissioning,
|
|
2011
1998
|
// 생산(제품 최초 생성)
|
|
2012
1999
|
storing: "urn:epcglobal:cbv:bizstep:storing"
|
|
2013
2000
|
// 완제품 저장
|
|
@@ -3492,6 +3479,255 @@ function ingestEnergyBillRecords(records, opts) {
|
|
|
3492
3479
|
return { accepted, rejected };
|
|
3493
3480
|
}
|
|
3494
3481
|
|
|
3482
|
+
// src/tariff.ts
|
|
3483
|
+
var TARIFF_LOAD_CLASSES = ["super-off-peak", "off-peak", "mid-peak", "on-peak"];
|
|
3484
|
+
var TARIFF_DAY_KINDS = ["all", "weekday", "saturday", "sunday", "holiday"];
|
|
3485
|
+
var CONCRETE_DAY_KINDS = ["weekday", "saturday", "sunday", "holiday"];
|
|
3486
|
+
var TARIFF_ISSUE_CODES = [
|
|
3487
|
+
/** A required field is empty. */
|
|
3488
|
+
"required",
|
|
3489
|
+
/** An amount is not a number. */
|
|
3490
|
+
"not-a-number",
|
|
3491
|
+
/** An amount is below zero. */
|
|
3492
|
+
"negative",
|
|
3493
|
+
/** A value is outside its vocabulary - `params.allowed`. */
|
|
3494
|
+
"not-in-vocabulary",
|
|
3495
|
+
/** A text is not in its format - `params.format`. */
|
|
3496
|
+
"format",
|
|
3497
|
+
/** An amount is written without a currency. */
|
|
3498
|
+
"currency-required",
|
|
3499
|
+
/** Season start and end must be written together or both left empty. */
|
|
3500
|
+
"season-pair",
|
|
3501
|
+
/** End time is not after the start - a band crossing midnight is two rows. */
|
|
3502
|
+
"end-not-after-start",
|
|
3503
|
+
/** The tariff has bands and a flat energy charge - which one prices an hour cannot be said. */
|
|
3504
|
+
"flat-and-bands",
|
|
3505
|
+
/** `params.count` bands break the row rules and were left out of the coverage check. */
|
|
3506
|
+
"broken-bands",
|
|
3507
|
+
/** No band covers `params.from`..`params.to` on `params.dayKind` days `params.days`. */
|
|
3508
|
+
"gap",
|
|
3509
|
+
/** Bands `params.bands` overlap `params.from`..`params.to` on `params.dayKind` days `params.days`. */
|
|
3510
|
+
"overlap"
|
|
3511
|
+
];
|
|
3512
|
+
function tariffIssueText(issue) {
|
|
3513
|
+
const p = issue.params ?? {};
|
|
3514
|
+
switch (issue.code) {
|
|
3515
|
+
case "required":
|
|
3516
|
+
return `${issue.field}: required${p.because ? ` (${p.because})` : ""}`;
|
|
3517
|
+
case "not-a-number":
|
|
3518
|
+
return `${issue.field}: not a number (${p.value})`;
|
|
3519
|
+
case "negative":
|
|
3520
|
+
return `${issue.field}: must be 0 or more (${p.value})`;
|
|
3521
|
+
case "not-in-vocabulary":
|
|
3522
|
+
return `${issue.field}: must be one of ${p.allowed} ("${p.value}")`;
|
|
3523
|
+
case "format":
|
|
3524
|
+
return `${issue.field}: must be ${p.format} ("${p.value}")`;
|
|
3525
|
+
case "currency-required":
|
|
3526
|
+
return `${issue.field}: required when an amount is written`;
|
|
3527
|
+
case "season-pair":
|
|
3528
|
+
return `${issue.field}: seasonFrom and seasonTo go together, or both empty for all year`;
|
|
3529
|
+
case "end-not-after-start":
|
|
3530
|
+
return `${issue.field}: must be after fromTime (${p.from}~${p.to}); a band crossing midnight is two rows`;
|
|
3531
|
+
case "flat-and-bands":
|
|
3532
|
+
return `${issue.field}: the tariff has bands - leave its flat charge empty`;
|
|
3533
|
+
case "broken-bands":
|
|
3534
|
+
return `${issue.field}: ${p.count} band(s) break the row rules and were left out`;
|
|
3535
|
+
case "gap":
|
|
3536
|
+
return `${issue.field}: ${p.dayKind} ${p.days} - no band ${p.from}~${p.to}`;
|
|
3537
|
+
case "overlap":
|
|
3538
|
+
return `${issue.field}: ${p.dayKind} ${p.days} - ${p.bands} overlap ${p.from}~${p.to}`;
|
|
3539
|
+
}
|
|
3540
|
+
}
|
|
3541
|
+
var empty = (v) => v === void 0 || v === null || typeof v === "string" && v.trim() === "";
|
|
3542
|
+
function isIso4217Code(value) {
|
|
3543
|
+
return typeof value === "string" && /^[A-Z]{3}$/.test(value);
|
|
3544
|
+
}
|
|
3545
|
+
function amountOf(v, field, issues) {
|
|
3546
|
+
if (empty(v)) return void 0;
|
|
3547
|
+
const n = Number(v);
|
|
3548
|
+
if (!Number.isFinite(n)) {
|
|
3549
|
+
issues.push({ field, code: "not-a-number", params: { value: String(v) } });
|
|
3550
|
+
return void 0;
|
|
3551
|
+
}
|
|
3552
|
+
if (n < 0) {
|
|
3553
|
+
issues.push({ field, code: "negative", params: { value: n } });
|
|
3554
|
+
return void 0;
|
|
3555
|
+
}
|
|
3556
|
+
return n;
|
|
3557
|
+
}
|
|
3558
|
+
function minutesOf(text) {
|
|
3559
|
+
const m = /^(\d{2}):(\d{2})$/.exec(String(text ?? "").trim());
|
|
3560
|
+
if (!m) return void 0;
|
|
3561
|
+
const h = Number(m[1]);
|
|
3562
|
+
const min = Number(m[2]);
|
|
3563
|
+
if (min > 59) return void 0;
|
|
3564
|
+
if (h === 24 && min === 0) return 1440;
|
|
3565
|
+
if (h > 23) return void 0;
|
|
3566
|
+
return h * 60 + min;
|
|
3567
|
+
}
|
|
3568
|
+
var DAYS_IN_MONTH = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
3569
|
+
function dayOfYearOf(text) {
|
|
3570
|
+
const m = /^(\d{2})-(\d{2})$/.exec(String(text ?? "").trim());
|
|
3571
|
+
if (!m) return void 0;
|
|
3572
|
+
const month = Number(m[1]);
|
|
3573
|
+
const day = Number(m[2]);
|
|
3574
|
+
if (month < 1 || month > 12 || day < 1 || day > DAYS_IN_MONTH[month - 1]) return void 0;
|
|
3575
|
+
let n = 0;
|
|
3576
|
+
for (let i = 0; i < month - 1; i++) n += DAYS_IN_MONTH[i];
|
|
3577
|
+
return n + day - 1;
|
|
3578
|
+
}
|
|
3579
|
+
function tariffIssues(row) {
|
|
3580
|
+
const issues = [];
|
|
3581
|
+
const d = amountOf(row.demandChargePerKW, "demandChargePerKW", issues);
|
|
3582
|
+
const e = amountOf(row.energyChargePerKWh, "energyChargePerKWh", issues);
|
|
3583
|
+
const currency = String(row.currency ?? "").trim();
|
|
3584
|
+
if ((d !== void 0 || e !== void 0) && !currency) issues.push({ field: "currency", code: "currency-required" });
|
|
3585
|
+
if (currency && !isIso4217Code(currency)) issues.push({ field: "currency", code: "format", params: { format: "ISO 4217 (KRW, USD)", value: currency } });
|
|
3586
|
+
return issues;
|
|
3587
|
+
}
|
|
3588
|
+
function tariffBandIssues(row) {
|
|
3589
|
+
const issues = [];
|
|
3590
|
+
if (empty(row.tariffName)) issues.push({ field: "tariffName", code: "required" });
|
|
3591
|
+
if (empty(row.band)) issues.push({ field: "band", code: "required" });
|
|
3592
|
+
const loadClass = String(row.loadClass ?? "").trim();
|
|
3593
|
+
if (!loadClass) issues.push({ field: "loadClass", code: "required" });
|
|
3594
|
+
else if (!TARIFF_LOAD_CLASSES.includes(loadClass)) {
|
|
3595
|
+
issues.push({ field: "loadClass", code: "not-in-vocabulary", params: { allowed: TARIFF_LOAD_CLASSES.join("|"), value: loadClass } });
|
|
3596
|
+
}
|
|
3597
|
+
const dayKind = empty(row.dayKind) ? "all" : String(row.dayKind).trim();
|
|
3598
|
+
if (!TARIFF_DAY_KINDS.includes(dayKind)) {
|
|
3599
|
+
issues.push({ field: "dayKind", code: "not-in-vocabulary", params: { allowed: TARIFF_DAY_KINDS.join("|"), value: dayKind } });
|
|
3600
|
+
}
|
|
3601
|
+
const sFromEmpty = empty(row.seasonFrom);
|
|
3602
|
+
const sToEmpty = empty(row.seasonTo);
|
|
3603
|
+
if (sFromEmpty !== sToEmpty) issues.push({ field: sFromEmpty ? "seasonFrom" : "seasonTo", code: "season-pair" });
|
|
3604
|
+
if (!sFromEmpty && dayOfYearOf(row.seasonFrom) === void 0) issues.push({ field: "seasonFrom", code: "format", params: { format: "MM-DD", value: String(row.seasonFrom) } });
|
|
3605
|
+
if (!sToEmpty && dayOfYearOf(row.seasonTo) === void 0) issues.push({ field: "seasonTo", code: "format", params: { format: "MM-DD", value: String(row.seasonTo) } });
|
|
3606
|
+
const from = minutesOf(row.fromTime);
|
|
3607
|
+
const to = minutesOf(row.toTime);
|
|
3608
|
+
if (from === void 0 || from === 1440) issues.push({ field: "fromTime", code: "format", params: { format: "HH:mm 00:00..23:59", value: String(row.fromTime ?? "") } });
|
|
3609
|
+
if (to === void 0 || to === 0) issues.push({ field: "toTime", code: "format", params: { format: "HH:mm 00:01..24:00", value: String(row.toTime ?? "") } });
|
|
3610
|
+
if (from !== void 0 && to !== void 0 && from < 1440 && to > 0 && from >= to) {
|
|
3611
|
+
issues.push({ field: "toTime", code: "end-not-after-start", params: { from: String(row.fromTime), to: String(row.toTime) } });
|
|
3612
|
+
}
|
|
3613
|
+
if (empty(row.energyChargePerKWh)) issues.push({ field: "energyChargePerKWh", code: "required" });
|
|
3614
|
+
else amountOf(row.energyChargePerKWh, "energyChargePerKWh", issues);
|
|
3615
|
+
amountOf(row.demandChargePerKW, "demandChargePerKW", issues);
|
|
3616
|
+
return issues;
|
|
3617
|
+
}
|
|
3618
|
+
function seasonHas(band, dayOfYear) {
|
|
3619
|
+
if (empty(band.seasonFrom) && empty(band.seasonTo)) return true;
|
|
3620
|
+
const from = dayOfYearOf(band.seasonFrom);
|
|
3621
|
+
const to = dayOfYearOf(band.seasonTo);
|
|
3622
|
+
if (from === void 0 || to === void 0) return false;
|
|
3623
|
+
return from <= to ? dayOfYear >= from && dayOfYear <= to : dayOfYear >= from || dayOfYear <= to;
|
|
3624
|
+
}
|
|
3625
|
+
function pricesHolidays(bands) {
|
|
3626
|
+
return bands.some((b) => String(b.dayKind ?? "").trim() === "holiday");
|
|
3627
|
+
}
|
|
3628
|
+
function dayKindOf(at2, holidays, isHoliday) {
|
|
3629
|
+
if (holidays && isHoliday?.(at2.month, at2.day)) return "holiday";
|
|
3630
|
+
return at2.weekday === 0 ? "sunday" : at2.weekday === 6 ? "saturday" : "weekday";
|
|
3631
|
+
}
|
|
3632
|
+
function dayKindHas(band, kind) {
|
|
3633
|
+
const k = empty(band.dayKind) ? "all" : String(band.dayKind).trim();
|
|
3634
|
+
return k === "all" || k === kind;
|
|
3635
|
+
}
|
|
3636
|
+
function activeBands(bands, at2) {
|
|
3637
|
+
return bands.filter((b) => empty(b.effectiveEnd) || new Date(b.effectiveEnd).getTime() > at2.getTime());
|
|
3638
|
+
}
|
|
3639
|
+
var hhmm = (m) => `${String(Math.floor(m / 60)).padStart(2, "0")}:${String(m % 60).padStart(2, "0")}`;
|
|
3640
|
+
function mmdd(dayOfYear) {
|
|
3641
|
+
let month = 0;
|
|
3642
|
+
let rest = dayOfYear;
|
|
3643
|
+
while (rest >= DAYS_IN_MONTH[month]) rest -= DAYS_IN_MONTH[month++];
|
|
3644
|
+
return `${String(month + 1).padStart(2, "0")}-${String(rest + 1).padStart(2, "0")}`;
|
|
3645
|
+
}
|
|
3646
|
+
function tariffCoverageIssues(tariff, bands) {
|
|
3647
|
+
const issues = [];
|
|
3648
|
+
if (!bands.length) return issues;
|
|
3649
|
+
const usable = bands.filter((b) => tariffBandIssues(b).length === 0);
|
|
3650
|
+
if (!empty(tariff.energyChargePerKWh)) issues.push({ field: "energyChargePerKWh", code: "flat-and-bands" });
|
|
3651
|
+
if (!String(tariff.currency ?? "").trim()) issues.push({ field: "currency", code: "currency-required" });
|
|
3652
|
+
const holidays = pricesHolidays(usable);
|
|
3653
|
+
if (holidays && empty(tariff.holidayCalendar)) {
|
|
3654
|
+
issues.push({ field: "holidayCalendar", code: "required", params: { because: "the tariff has holiday bands" } });
|
|
3655
|
+
}
|
|
3656
|
+
const broken = bands.length - usable.length;
|
|
3657
|
+
if (broken) issues.push({ field: "bands", code: "broken-bands", params: { count: broken } });
|
|
3658
|
+
const seen = /* @__PURE__ */ new Map();
|
|
3659
|
+
const note = (kind, day, code, from, to, names) => {
|
|
3660
|
+
const key = [kind, code, from, to, names ?? ""].join("\0");
|
|
3661
|
+
const entry = seen.get(key);
|
|
3662
|
+
if (entry) entry.days.push(day);
|
|
3663
|
+
else {
|
|
3664
|
+
const params = { dayKind: kind, from: hhmm(from), to: hhmm(to) };
|
|
3665
|
+
if (names) params.bands = names;
|
|
3666
|
+
seen.set(key, { problem: { field: "bands", code, params }, days: [day] });
|
|
3667
|
+
}
|
|
3668
|
+
};
|
|
3669
|
+
for (const kind of CONCRETE_DAY_KINDS.filter((k) => k !== "holiday" || holidays)) {
|
|
3670
|
+
for (let day = 0; day < 366; day++) {
|
|
3671
|
+
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);
|
|
3672
|
+
let cursor = 0;
|
|
3673
|
+
let last;
|
|
3674
|
+
for (const b of today) {
|
|
3675
|
+
if (b.from > cursor) note(kind, day, "gap", cursor, b.from);
|
|
3676
|
+
if (last && b.from < last.to) note(kind, day, "overlap", b.from, Math.min(last.to, b.to), `${last.name}\xB7${b.name}`);
|
|
3677
|
+
if (b.to > cursor) {
|
|
3678
|
+
cursor = b.to;
|
|
3679
|
+
last = b;
|
|
3680
|
+
}
|
|
3681
|
+
}
|
|
3682
|
+
if (cursor < 1440) note(kind, day, "gap", cursor, 1440);
|
|
3683
|
+
}
|
|
3684
|
+
}
|
|
3685
|
+
for (const { problem, days } of seen.values()) {
|
|
3686
|
+
const spans = [];
|
|
3687
|
+
let start = days[0];
|
|
3688
|
+
let prev = days[0];
|
|
3689
|
+
for (const d of [...days.slice(1), Infinity]) {
|
|
3690
|
+
if (d === prev + 1) {
|
|
3691
|
+
prev = d;
|
|
3692
|
+
continue;
|
|
3693
|
+
}
|
|
3694
|
+
spans.push(start === prev ? mmdd(start) : `${mmdd(start)}~${mmdd(prev)}`);
|
|
3695
|
+
start = prev = d;
|
|
3696
|
+
}
|
|
3697
|
+
issues.push({ ...problem, params: { ...problem.params, days: spans.join(", ") } });
|
|
3698
|
+
}
|
|
3699
|
+
return issues;
|
|
3700
|
+
}
|
|
3701
|
+
function bandAt(tariff, bands, at2, isHoliday) {
|
|
3702
|
+
const currency = String(tariff.currency ?? "").trim() || void 0;
|
|
3703
|
+
const usable = bands.filter((b) => tariffBandIssues(b).length === 0);
|
|
3704
|
+
if (!usable.length) {
|
|
3705
|
+
const flat = empty(tariff.energyChargePerKWh) ? NaN : Number(tariff.energyChargePerKWh);
|
|
3706
|
+
if (!Number.isFinite(flat)) return { reason: "no-price" };
|
|
3707
|
+
return { energyChargePerKWh: flat, ...currency ? { currency } : {}, holidayKnown: true };
|
|
3708
|
+
}
|
|
3709
|
+
const day = dayOfYearOf(`${String(at2.month).padStart(2, "0")}-${String(at2.day).padStart(2, "0")}`);
|
|
3710
|
+
if (day === void 0) return { reason: "no-band" };
|
|
3711
|
+
const holidays = pricesHolidays(usable);
|
|
3712
|
+
const kind = dayKindOf(at2, holidays, isHoliday);
|
|
3713
|
+
const hits = usable.filter(
|
|
3714
|
+
(b) => seasonHas(b, day) && dayKindHas(b, kind) && minutesOf(b.fromTime) <= at2.minutes && at2.minutes < minutesOf(b.toTime)
|
|
3715
|
+
);
|
|
3716
|
+
if (!hits.length) return { reason: "no-band" };
|
|
3717
|
+
if (hits.length > 1) return { reason: "ambiguous", bands: hits.map((b) => String(b.name ?? "")) };
|
|
3718
|
+
const hit = hits[0];
|
|
3719
|
+
const demand = empty(hit.demandChargePerKW) ? void 0 : Number(hit.demandChargePerKW);
|
|
3720
|
+
return {
|
|
3721
|
+
bandName: String(hit.name ?? "") || void 0,
|
|
3722
|
+
band: String(hit.band).trim(),
|
|
3723
|
+
loadClass: String(hit.loadClass).trim(),
|
|
3724
|
+
energyChargePerKWh: Number(hit.energyChargePerKWh),
|
|
3725
|
+
...demand !== void 0 ? { demandChargePerKW: demand } : {},
|
|
3726
|
+
...currency ? { currency } : {},
|
|
3727
|
+
holidayKnown: !holidays || !!isHoliday
|
|
3728
|
+
};
|
|
3729
|
+
}
|
|
3730
|
+
|
|
3495
3731
|
// src/gs1.ts
|
|
3496
3732
|
var FNC1 = "";
|
|
3497
3733
|
var FIXED_LENGTH = {
|
|
@@ -4104,8 +4340,8 @@ function shapeErrors(where, row, shape) {
|
|
|
4104
4340
|
const errors = [];
|
|
4105
4341
|
for (const f of shape.required ?? []) {
|
|
4106
4342
|
const v = row[f];
|
|
4107
|
-
const
|
|
4108
|
-
if (
|
|
4343
|
+
const empty2 = v === void 0 || v === null || typeof v === "string" && !v.trim();
|
|
4344
|
+
if (empty2) errors.push(`${where}.${f}: \uD544\uC218 \uD544\uB4DC \uB204\uB77D`);
|
|
4109
4345
|
}
|
|
4110
4346
|
for (const [f, t] of Object.entries(shape.fields ?? {})) {
|
|
4111
4347
|
const v = row[f];
|
|
@@ -5511,6 +5747,9 @@ function shapedRecordsOf(event) {
|
|
|
5511
5747
|
};
|
|
5512
5748
|
}
|
|
5513
5749
|
case "AggregationEvent":
|
|
5750
|
+
if (!event.parentID) {
|
|
5751
|
+
throw shapeError("aggregation-no-parent", { event: event.eventID }, "the aggregation names no parent: the canonical record is keyed by its parent");
|
|
5752
|
+
}
|
|
5514
5753
|
return {
|
|
5515
5754
|
records: [
|
|
5516
5755
|
{
|
|
@@ -5947,6 +6186,9 @@ function inheritedExpiry(inputExpiries) {
|
|
|
5947
6186
|
SCHEDULE_STATUS,
|
|
5948
6187
|
SIGNATURE_REJECTED_REASONS,
|
|
5949
6188
|
SOURCE_DEST_PARTY_TYPE,
|
|
6189
|
+
TARIFF_DAY_KINDS,
|
|
6190
|
+
TARIFF_ISSUE_CODES,
|
|
6191
|
+
TARIFF_LOAD_CLASSES,
|
|
5950
6192
|
TASK_STATUS,
|
|
5951
6193
|
TASK_TERMINAL_STATUS,
|
|
5952
6194
|
TRAILER_LOAD,
|
|
@@ -5977,6 +6219,7 @@ function inheritedExpiry(inputExpiries) {
|
|
|
5977
6219
|
YMS_TASK_KIND,
|
|
5978
6220
|
YMS_TYPES,
|
|
5979
6221
|
acceptsPerformance,
|
|
6222
|
+
activeBands,
|
|
5980
6223
|
activeShiftAt,
|
|
5981
6224
|
activeShiftOf,
|
|
5982
6225
|
aggregationEvent,
|
|
@@ -5987,6 +6230,7 @@ function inheritedExpiry(inputExpiries) {
|
|
|
5987
6230
|
axisAppliesTo,
|
|
5988
6231
|
axisInfo,
|
|
5989
6232
|
axisSource,
|
|
6233
|
+
bandAt,
|
|
5990
6234
|
bizStepName,
|
|
5991
6235
|
bizTransactionUri,
|
|
5992
6236
|
canPreview,
|
|
@@ -6007,6 +6251,7 @@ function inheritedExpiry(inputExpiries) {
|
|
|
6007
6251
|
computeOee,
|
|
6008
6252
|
conversionFactorOf,
|
|
6009
6253
|
criterionSaysNothing,
|
|
6254
|
+
dayOfYearOf,
|
|
6010
6255
|
dispatchMoveFactOf,
|
|
6011
6256
|
dockDoorCapacityOf,
|
|
6012
6257
|
dockDoorStatusOf,
|
|
@@ -6068,6 +6313,7 @@ function inheritedExpiry(inputExpiries) {
|
|
|
6068
6313
|
isEquipmentStatus,
|
|
6069
6314
|
isFailureStatus,
|
|
6070
6315
|
isFlowOrder,
|
|
6316
|
+
isIso4217Code,
|
|
6071
6317
|
isIsoDateTime,
|
|
6072
6318
|
isMasterDataRecord,
|
|
6073
6319
|
isMaterialExecutionBasis,
|
|
@@ -6111,11 +6357,11 @@ function inheritedExpiry(inputExpiries) {
|
|
|
6111
6357
|
materialMovementKey,
|
|
6112
6358
|
meetsTests,
|
|
6113
6359
|
minuteOfDayAt,
|
|
6360
|
+
minutesOf,
|
|
6114
6361
|
missingCommandPayload,
|
|
6115
6362
|
moveExpiryText,
|
|
6116
6363
|
moveFactOf,
|
|
6117
6364
|
nextCommandState,
|
|
6118
|
-
nonWorkingMsIn,
|
|
6119
6365
|
normalizeEquipmentStatus,
|
|
6120
6366
|
objectEvent,
|
|
6121
6367
|
objectUri,
|
|
@@ -6169,6 +6415,10 @@ function inheritedExpiry(inputExpiries) {
|
|
|
6169
6415
|
ssccUri,
|
|
6170
6416
|
stateFieldsOf,
|
|
6171
6417
|
subLotIdOf,
|
|
6418
|
+
tariffBandIssues,
|
|
6419
|
+
tariffCoverageIssues,
|
|
6420
|
+
tariffIssueText,
|
|
6421
|
+
tariffIssues,
|
|
6172
6422
|
tenseOf,
|
|
6173
6423
|
testEvidenceGaps,
|
|
6174
6424
|
testPassedAt,
|
|
@@ -6190,6 +6440,5 @@ function inheritedExpiry(inputExpiries) {
|
|
|
6190
6440
|
webhookSenderAction,
|
|
6191
6441
|
weekdayAt,
|
|
6192
6442
|
workShiftAttribution,
|
|
6193
|
-
workingHoursBetween
|
|
6194
|
-
workingTimeOfWeek
|
|
6443
|
+
workingHoursBetween
|
|
6195
6444
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@operato/ops-contract",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.48",
|
|
4
4
|
"description": "Operations domain contract — what producers and readers agree on: the standard vocabulary (EPCIS 2.0/GS1, ISA-95, IEC 61850/ISO 50001) and the records operations products exchange with the twin and with each other. Types, guards, validation. No state, no engine.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist-cjs/index.cjs",
|