@operato/ops-contract 0.9.46 → 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/capability.d.ts +1 -1
- package/dist/capability.js +4 -4
- package/dist/capacity.d.ts +1 -36
- package/dist/capacity.js +0 -80
- package/dist/domain-definition.js +1 -1
- package/dist/epcis.d.ts +4 -2
- package/dist/epcis.js +15 -13
- package/dist/erp.js +1 -1
- 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 +302 -53
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@ IEC 61850 · ISO 50001 전기 계통과 성과지표
|
|
|
13
13
|
|
|
14
14
|
## 패키지의 책임
|
|
15
15
|
|
|
16
|
-
여기 있는 것은 **타입 · 판별 함수 · 정합 검증 · 어휘 상수**입니다.
|
|
16
|
+
여기 있는 것은 **타입 · 판별 함수 · 정합 검증 · 어휘 상수**입니다. **인자만 보고 답합니다** — 상태도 시계도 갖지 않습니다.
|
|
17
17
|
|
|
18
18
|
여기 없는 것은 **정책과 엔진**입니다. 그 사실로 무엇을 할지는 `@operato/twin-kernel` 이 정합니다.
|
|
19
19
|
|
|
@@ -94,6 +94,18 @@ assertOperationalAttentionV1(attention)
|
|
|
94
94
|
`locationStatusOf` · `dockDoorStatusOf`(도어의 동시 수용 한도 `dockDoorCapacityOf` — 정수, 최소 1, 1.5 는 1). 이 기준을 넘는 판정 — 예약 규칙 · 우선순위 ·
|
|
95
95
|
아래 생산자의 전이 판정 — 은 계약에 올리지 않습니다.
|
|
96
96
|
|
|
97
|
+
**전기 요금표 읽기**(`tariff.ts`, 2026-11-27) — 요금제와 시간대 구간은 ops-master 가 저장하고, 이 계약은 「이 순간의 단가」(`bandAt`)와
|
|
98
|
+
「구간이 하루를 빈틈없이 덮나」(`tariffCoverageIssues`)를 정합니다. 문제는 문장이 아니라 `{ field, code, params }` 로 냅니다(화면이 번역).
|
|
99
|
+
원천 사실의 단가(`EnergyUsagePeriodData.unitPrice`)가 마스터의 구간 단가를 이깁니다. 새 나라는 행으로 옵니다 — 구간 코드는 요금제의 것이고
|
|
100
|
+
견주기용 등급(`TARIFF_LOAD_CLASSES`)만 닫혀 있으며, 일요일과 공휴일은 따로(공휴일이 요일보다 앞섬), 공휴일 달력은 요금제가 이름으로 가리킵니다.
|
|
101
|
+
|
|
102
|
+
> **기준의 예외 하나 — 예정된 두 번째 소비처.** 지금 이 규칙을 부르는 곳은 ops-master 하나입니다. ems 커넥터가 붙으면
|
|
103
|
+
> (operato-application `design/charters/operato-energy.md` §4) 원천 사실에 단가가 없는 구간마다 `bandAt` 으로 단가를 구해 사용량 요금을 더하고,
|
|
104
|
+
> 그 합을 커널 `electricityCost({ energyChargeFromPeriods })` 에 넘깁니다 — 이것이 두 번째 소비처입니다. 나라별 요금을 행으로만 받는다는
|
|
105
|
+
> 결정(ADR-0239 결정 7)이 화면과 트윈의 같은 답을 요구하므로 먼저 두었습니다(2026-11-27 사용자 결정). 그 커넥터가 서지 않기로 하면 ops-master 로 돌립니다.
|
|
106
|
+
> **다시 보는 시점:** ems 커넥터를 세울지 정하는 자리에서 이 예외도 함께 닫습니다 — 서면 트윈이 실제로 부르는 것을 확인하고 이 문단을
|
|
107
|
+
> 지우고, 서지 않으면 `tariff.ts` 를 ops-master 로 돌립니다. 예외가 기한 없이 남지 않게 합니다.
|
|
108
|
+
|
|
97
109
|
**생산자가 전이를 어떻게 정하는지**(새 판정과 기존 항목의 대조, 판정으로 해소할 수 있는 항목 유형, 근거 지문 계산)는
|
|
98
110
|
생산자의 정책입니다. 데이터를 보내는 제품들이 공통으로 쓰는 구현은 `@things-factory/webhook` 의 `reconcileAttentions` · `attentionFingerprint`(SHA-256)에
|
|
99
111
|
있습니다 — 이 계약에 두었다가 옮겼습니다(정책은 이 층에 두지 않는다).
|
package/dist/capability.d.ts
CHANGED
|
@@ -36,7 +36,7 @@ export interface TrackableState {
|
|
|
36
36
|
held: boolean;
|
|
37
37
|
}
|
|
38
38
|
/**
|
|
39
|
-
* 계량 — 이 자원은 **자원의 에너지 소비를
|
|
39
|
+
* 계량 — 이 자원은 **자원의 에너지 소비를 계측합니다.**
|
|
40
40
|
*
|
|
41
41
|
* `kW` 는 그 계량 주기의 평균이고 순시값이 아니다(순시는 전력 품질의 영역이라 범위 밖).
|
|
42
42
|
* `kWh` 는 계기 누적값 — 차분은 소비처가 한다(계기 교체·리셋을 우리가 지어내지 않는다).
|
package/dist/capability.js
CHANGED
|
@@ -53,17 +53,17 @@ export const CAPABILITIES = {
|
|
|
53
53
|
* 대기전력을 쓴다.
|
|
54
54
|
*/
|
|
55
55
|
metered: {
|
|
56
|
-
key: 'metered', label: 'twin.capability.metered', semantics: '자원의 에너지
|
|
56
|
+
key: 'metered', label: 'twin.capability.metered', semantics: '자원의 유효전력·누적 에너지 소비량·역률을 계측합니다. 측정값이 없으면 미확인 상태로 처리하며 0으로 간주하지 않습니다.',
|
|
57
57
|
commands: [],
|
|
58
58
|
stateFields: ['kW', 'kWh', 'powerFactor'], models: ['MeteredState'], results: ['measured']
|
|
59
59
|
},
|
|
60
60
|
curtailable: {
|
|
61
|
-
key: 'curtailable', label: 'twin.capability.curtailable', semantics: '
|
|
61
|
+
key: 'curtailable', label: 'twin.capability.curtailable', semantics: '최소 유지 부하를 준수하는 범위에서 감축 가능 여부를 판정합니다. 실제 실행은 담당자와 연계 시스템에서 처리합니다.',
|
|
62
62
|
commands: [],
|
|
63
63
|
stateFields: ['curtailable', 'minKW'], models: ['CurtailableState'], invariants: ['minKW >= 0'], results: ['drSuggested']
|
|
64
64
|
},
|
|
65
65
|
energyGenerating: {
|
|
66
|
-
key: 'energyGenerating', label: 'twin.capability.energyGenerating', semantics: '
|
|
66
|
+
key: 'energyGenerating', label: 'twin.capability.energyGenerating', semantics: '전력 생산량을 관리합니다. 역송량은 소비량의 음수가 아닌 별도 항목으로 기록합니다.',
|
|
67
67
|
commands: [],
|
|
68
68
|
/*
|
|
69
69
|
* ── 적산을 더한다 (2026-08-26) ─────────────────────────────────────────────
|
|
@@ -85,7 +85,7 @@ export const CAPABILITIES = {
|
|
|
85
85
|
* `energyGenerating` 이다 — 능력은 도메인이 아니라 관측의 면이다(방언 없음).
|
|
86
86
|
*/
|
|
87
87
|
energyStoring: {
|
|
88
|
-
key: 'energyStoring', label: 'twin.capability.energyStoring', semantics: '전력을 저장하고 공급합니다.
|
|
88
|
+
key: 'energyStoring', label: 'twin.capability.energyStoring', semantics: '전력을 저장하고 공급합니다. 손실과 수명을 평가할 수 있도록 충전과 방전을 구분합니다.',
|
|
89
89
|
commands: [],
|
|
90
90
|
stateFields: ['soc', 'chargeKW', 'dischargeKW'], models: ['StoringState'], invariants: ['0 <= soc <= 100'], results: ['stored', 'discharged']
|
|
91
91
|
}
|
package/dist/capacity.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type WorkCalendarEntry } from './contract.ts';
|
|
2
1
|
import type { OperationDef } from './domain-definition.ts';
|
|
2
|
+
import type { WorkCalendarEntry } from './contract.ts';
|
|
3
3
|
/** 제약이 걸린 축 — 무엇을 늘려야 하는지가 여기서 갈린다. */
|
|
4
4
|
export type CapacityAxis = 'equipment' | 'personnel' | 'asset' | 'location';
|
|
5
5
|
export interface CapacityRequirement {
|
|
@@ -77,38 +77,3 @@ export interface CapacityInput {
|
|
|
77
77
|
}
|
|
78
78
|
/** ISO 8601 기간 → 시간. 명세가 쓰는 표기 그대로 읽는다(`PT1H40M`). */
|
|
79
79
|
export declare function isoDurationHours(iso: string | undefined): number;
|
|
80
|
-
/**
|
|
81
|
-
* 근무 캘린더에서 **가용 시간과 조업일**을 읽는다 — 1분 간격 샘플링.
|
|
82
|
-
*
|
|
83
|
-
* 교대·휴게·비근무 규칙을 여기 다시 적지 않는다. 규칙은 `inWorkCalendarAt` 한 곳에만 있고, 이 함수는
|
|
84
|
-
* 그것에 묻기만 한다. 두 벌이 되면 달력을 고칠 때 한쪽만 고쳐져 어긋난다.
|
|
85
|
-
*
|
|
86
|
-
* 캘린더가 없으면 **종일 가동**으로 본다(7일 × 24h) — 제약이 없는 것이 아니라 **선언되지 않은** 것이고,
|
|
87
|
-
* 선언이 없으면 커널은 멈출 이유를 모른다.
|
|
88
|
-
*/
|
|
89
|
-
export declare function workingTimeOfWeek(calendar: readonly WorkCalendarEntry[] | undefined, weekStartMs: number, utcOffsetMinutes?: number): {
|
|
90
|
-
hoursPerWeek: number;
|
|
91
|
-
daysPerWeek: number;
|
|
92
|
-
};
|
|
93
|
-
/**
|
|
94
|
-
* 이 창에서 **조업이 계획되지 않은 시간**(ms) — 없으면 `undefined`.
|
|
95
|
-
*
|
|
96
|
-
* ── 무엇에 쓰나 ─────────────────────────────────────────────────────────────
|
|
97
|
-
* ISO 22400 의 계획 조업 시간(PBT)에서 뺄 값이다(`OeeCounters.holdMs`). 커널의 PBT 가 「재기 시작한
|
|
98
|
-
* 뒤 흐른 시간 전부」였고, 그래서 주말·야간·휴일이 계획 조업으로 세어졌다.
|
|
99
|
-
*
|
|
100
|
-
* ── 선언이 없으면 `undefined` 다 ────────────────────────────────────────────
|
|
101
|
-
* **0 을 내지 않는다.** 0 은 「비근무 시간이 없다」는 주장이고, 그것은 24시간 365일 도는 현장에
|
|
102
|
-
* 대해서만 참이다. 선언이 없는 것은 **모르는 것**이고, 부르는 쪽이 그 둘을 갈라야 한다 — 0 을 받으면
|
|
103
|
-
* 「달력을 확인했고 쉬는 시간이 없었다」로 읽는다.
|
|
104
|
-
*
|
|
105
|
-
* `workingTimeOfWeek` 이 캘린더가 없을 때 종일 가동으로 보는 것과 방향이 반대로 보이지만, 그쪽은
|
|
106
|
-
* **능력**을 묻는 자리라 「최대 얼마나 돌 수 있나」에 답해야 하고, 이쪽은 **실적 지표**의 분모라
|
|
107
|
-
* 모르는 것을 채우면 그 수가 조용히 틀린다.
|
|
108
|
-
*
|
|
109
|
-
* ── 분 단위로 센다 ──────────────────────────────────────────────────────────
|
|
110
|
-
* `workingTimeOfWeek` 과 같은 방식이다(`inWorkCalendarAt` 을 분마다 묻는다). 구간 대수로 풀면
|
|
111
|
-
* 되풀이·요일·절대 구간이 겹칠 때의 규칙을 여기서 다시 적게 되고, 그 규칙은 이미 그 함수 안에 있다 —
|
|
112
|
-
* 두 곳이 다른 답을 내는 것이 이 저장소에서 여러 번 났다.
|
|
113
|
-
*/
|
|
114
|
-
export declare function nonWorkingMsIn(calendar: readonly WorkCalendarEntry[] | undefined, fromMs: number, toMs: number, utcOffsetMinutes?: number): number | undefined;
|
package/dist/capacity.js
CHANGED
|
@@ -1,13 +1,3 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* 용량 분석의 **입력 · 보고서 모양**과 근무 캘린더 읽기 — 계약 쪽.
|
|
3
|
-
*
|
|
4
|
-
* 분석 자체(`analyzeCapacity`)는 엔진의 판정이라 `@operato/twin-kernel` 의 `capacity.ts` 에 있다(2026-11-19 이동).
|
|
5
|
-
* 여기 남은 것은 두 가지다:
|
|
6
|
-
* · 보고서와 입력의 타입 — 커널 밖(호스트 · 화면 · 레퍼런스 마스터)이 그 모양을 읽는다.
|
|
7
|
-
* · 근무 캘린더 읽기(`workingTimeOfWeek` · `nonWorkingMsIn`) — 선언된 캘린더만 보고 답하고, 호스트와 커널이
|
|
8
|
-
* 같은 답을 내야 한다(`inWorkCalendarAt` 과 같은 결). README 「파생의 기준」.
|
|
9
|
-
*/
|
|
10
|
-
import { inWorkCalendarAt } from "./contract.js";
|
|
11
1
|
/** ISO 8601 기간 → 시간. 명세가 쓰는 표기 그대로 읽는다(`PT1H40M`). */
|
|
12
2
|
export function isoDurationHours(iso) {
|
|
13
3
|
if (!iso)
|
|
@@ -17,73 +7,3 @@ export function isoDurationHours(iso) {
|
|
|
17
7
|
throw new Error(`기간 표기를 읽을 수 없다: ${iso}`);
|
|
18
8
|
return Number(m[1] ?? 0) * 24 + Number(m[2] ?? 0) + Number(m[3] ?? 0) / 60 + Number(m[4] ?? 0) / 3600;
|
|
19
9
|
}
|
|
20
|
-
/**
|
|
21
|
-
* 근무 캘린더에서 **가용 시간과 조업일**을 읽는다 — 1분 간격 샘플링.
|
|
22
|
-
*
|
|
23
|
-
* 교대·휴게·비근무 규칙을 여기 다시 적지 않는다. 규칙은 `inWorkCalendarAt` 한 곳에만 있고, 이 함수는
|
|
24
|
-
* 그것에 묻기만 한다. 두 벌이 되면 달력을 고칠 때 한쪽만 고쳐져 어긋난다.
|
|
25
|
-
*
|
|
26
|
-
* 캘린더가 없으면 **종일 가동**으로 본다(7일 × 24h) — 제약이 없는 것이 아니라 **선언되지 않은** 것이고,
|
|
27
|
-
* 선언이 없으면 커널은 멈출 이유를 모른다.
|
|
28
|
-
*/
|
|
29
|
-
export function workingTimeOfWeek(calendar, weekStartMs, utcOffsetMinutes) {
|
|
30
|
-
if (!calendar?.length)
|
|
31
|
-
return { hoursPerWeek: 7 * 24, daysPerWeek: 7 };
|
|
32
|
-
let minutes = 0;
|
|
33
|
-
const touched = new Set();
|
|
34
|
-
for (let m = 0; m < 7 * 24 * 60; m++) {
|
|
35
|
-
if (!inWorkCalendarAt(calendar, weekStartMs + m * 60_000, utcOffsetMinutes))
|
|
36
|
-
continue;
|
|
37
|
-
minutes++;
|
|
38
|
-
touched.add(Math.floor((m + (utcOffsetMinutes ?? 0)) / (24 * 60)));
|
|
39
|
-
}
|
|
40
|
-
/*
|
|
41
|
-
* 조업일은 **선언이 말하는 것**이지 타임라인이 번진 자국이 아니다.
|
|
42
|
-
*
|
|
43
|
-
* 야간 교대는 자정을 넘는다 — 금요일 밤에 시작한 교대는 토요일 새벽에 끝난다. 샘플링한 분을
|
|
44
|
-
* 날짜로 세면 월~금 3교대가 **6일**로 나오고, 그러면 주간 수요가 20% 부풀어 필요 없는 설비를
|
|
45
|
-
* 사라고 답한다. 교대는 "월~금에 **시작한다**" 고 선언돼 있고(`daysOfWeek`), 그것이 조업일이다.
|
|
46
|
-
*
|
|
47
|
-
* 요일 선언이 아예 없는 달력(절대 구간만 쓰는 경우)에서는 셀 근거가 없으므로 번진 자국을 쓴다.
|
|
48
|
-
*/
|
|
49
|
-
const declared = new Set();
|
|
50
|
-
for (const e of calendar)
|
|
51
|
-
if (e.entryType !== 'non-working')
|
|
52
|
-
for (const d of e.daysOfWeek ?? [])
|
|
53
|
-
declared.add(d);
|
|
54
|
-
return { hoursPerWeek: minutes / 60, daysPerWeek: declared.size || touched.size };
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* 이 창에서 **조업이 계획되지 않은 시간**(ms) — 없으면 `undefined`.
|
|
58
|
-
*
|
|
59
|
-
* ── 무엇에 쓰나 ─────────────────────────────────────────────────────────────
|
|
60
|
-
* ISO 22400 의 계획 조업 시간(PBT)에서 뺄 값이다(`OeeCounters.holdMs`). 커널의 PBT 가 「재기 시작한
|
|
61
|
-
* 뒤 흐른 시간 전부」였고, 그래서 주말·야간·휴일이 계획 조업으로 세어졌다.
|
|
62
|
-
*
|
|
63
|
-
* ── 선언이 없으면 `undefined` 다 ────────────────────────────────────────────
|
|
64
|
-
* **0 을 내지 않는다.** 0 은 「비근무 시간이 없다」는 주장이고, 그것은 24시간 365일 도는 현장에
|
|
65
|
-
* 대해서만 참이다. 선언이 없는 것은 **모르는 것**이고, 부르는 쪽이 그 둘을 갈라야 한다 — 0 을 받으면
|
|
66
|
-
* 「달력을 확인했고 쉬는 시간이 없었다」로 읽는다.
|
|
67
|
-
*
|
|
68
|
-
* `workingTimeOfWeek` 이 캘린더가 없을 때 종일 가동으로 보는 것과 방향이 반대로 보이지만, 그쪽은
|
|
69
|
-
* **능력**을 묻는 자리라 「최대 얼마나 돌 수 있나」에 답해야 하고, 이쪽은 **실적 지표**의 분모라
|
|
70
|
-
* 모르는 것을 채우면 그 수가 조용히 틀린다.
|
|
71
|
-
*
|
|
72
|
-
* ── 분 단위로 센다 ──────────────────────────────────────────────────────────
|
|
73
|
-
* `workingTimeOfWeek` 과 같은 방식이다(`inWorkCalendarAt` 을 분마다 묻는다). 구간 대수로 풀면
|
|
74
|
-
* 되풀이·요일·절대 구간이 겹칠 때의 규칙을 여기서 다시 적게 되고, 그 규칙은 이미 그 함수 안에 있다 —
|
|
75
|
-
* 두 곳이 다른 답을 내는 것이 이 저장소에서 여러 번 났다.
|
|
76
|
-
*/
|
|
77
|
-
export function nonWorkingMsIn(calendar, fromMs, toMs, utcOffsetMinutes) {
|
|
78
|
-
if (!calendar?.length)
|
|
79
|
-
return undefined;
|
|
80
|
-
if (!Number.isFinite(fromMs) || !Number.isFinite(toMs) || toMs <= fromMs)
|
|
81
|
-
return undefined;
|
|
82
|
-
const minutes = Math.floor((toMs - fromMs) / 60_000);
|
|
83
|
-
let closed = 0;
|
|
84
|
-
for (let m = 0; m < minutes; m++) {
|
|
85
|
-
if (!inWorkCalendarAt(calendar, fromMs + m * 60_000, utcOffsetMinutes))
|
|
86
|
-
closed++;
|
|
87
|
-
}
|
|
88
|
-
return closed * 60_000;
|
|
89
|
-
}
|
|
@@ -44,7 +44,7 @@ export function procedureViolations(route) {
|
|
|
44
44
|
if (hasChild.has(n.key))
|
|
45
45
|
errors.push(`${n.key}: 하위 요소가 있는 노드에 실행 단계가 지정되었습니다. 실행 단계는 말단 노드에만 지정할 수 있습니다.`);
|
|
46
46
|
if (!stepSet.has(n.step))
|
|
47
|
-
errors.push(`${n.key}: 정의되지 않은
|
|
47
|
+
errors.push(`${n.key}: 단계 목록(steps)에 정의되지 않은 단계입니다: '${n.step}'`);
|
|
48
48
|
const already = seenStep.get(n.step);
|
|
49
49
|
if (already)
|
|
50
50
|
errors.push(`단계 '${n.step}' 가 '${already}' 와 '${n.key}' 두 곳에 중복 지정되었습니다. 한 위치에만 지정하세요.`);
|
package/dist/epcis.d.ts
CHANGED
|
@@ -338,12 +338,14 @@ interface EpcisActionEvent extends EpcisHeader {
|
|
|
338
338
|
}
|
|
339
339
|
export interface EpcisObjectEvent extends EpcisActionEvent {
|
|
340
340
|
type: 'ObjectEvent';
|
|
341
|
-
|
|
341
|
+
/** Optional as in EPCIS 2.0 §7.4.2 - an event may carry only `quantityList`; one of the two must have an entry. */
|
|
342
|
+
epcList?: string[];
|
|
342
343
|
quantityList?: QuantityElement[];
|
|
343
344
|
}
|
|
344
345
|
export interface EpcisAggregationEvent extends EpcisActionEvent {
|
|
345
346
|
type: 'AggregationEvent';
|
|
346
|
-
|
|
347
|
+
/** Optional when action is OBSERVE, required otherwise (EPCIS 2.0 §7.4.3). */
|
|
348
|
+
parentID?: string;
|
|
347
349
|
childEPCs?: string[];
|
|
348
350
|
childQuantityList?: QuantityElement[];
|
|
349
351
|
}
|
package/dist/epcis.js
CHANGED
|
@@ -887,14 +887,15 @@ export function validateEpcisEvent(e) {
|
|
|
887
887
|
v.push('eventTimeZoneOffset 형식 오류');
|
|
888
888
|
/*
|
|
889
889
|
* ── 표준보다 좁은 곳 (2026-11-19, EPCIS 2.0 원문과 대조) ─────────────────────────
|
|
890
|
-
* 이 검증기는 표준이 허용하는 것
|
|
890
|
+
* 이 검증기는 표준이 허용하는 것 둘을 **일부러** 거절한다. 둘 다 표준을 잘못 읽은 것이 아니라 이 트윈이
|
|
891
891
|
* 받는 입구의 선택이다 — 넓히려면 아래 「전제하는 곳」을 먼저 고쳐야 한다.
|
|
892
892
|
* · `bizStep` — 표준은 모든 이벤트에서 선택(§7.4.2–7.4.6). 우리 저널은 이 칸으로 사건 종류를 가르고
|
|
893
893
|
* (headless-twin `twin-event-keys` · `event-type-split`) 모든 생산자가 단계를 밝힌다.
|
|
894
|
-
*
|
|
895
|
-
*
|
|
896
|
-
* · `AggregationEvent
|
|
897
|
-
*
|
|
894
|
+
* (`ObjectEvent.epcList` 는 2026-11-27 표준 폭으로 넓혔다 — `quantityList` 만 있는 이벤트를 받는다. 커널 reducer 가
|
|
895
|
+
* 없는 목록을 빈 목록으로 읽게 먼저 고쳤다.)
|
|
896
|
+
* · `AggregationEvent` 의 자식 목록 — 표준은 DELETE 에서 비어도 된다(§7.4.3: 부모의 모든 담김 해체). 커널
|
|
897
|
+
* reducer 는 그 뜻을 이미 읽지만(저장한 담김을 모두 푼다) 검증기는 아직 넓히지 않았다.
|
|
898
|
+
* (`AggregationEvent.parentID` 는 2026-11-27 표준대로 OBSERVE 에서만 선택 — 커널은 부모 없는 관측을 세고 건너뛴다.)
|
|
898
899
|
*/
|
|
899
900
|
if (typeof e.bizStep !== 'string' || !e.bizStep)
|
|
900
901
|
v.push('bizStep 누락');
|
|
@@ -925,7 +926,7 @@ export function validateEpcisEvent(e) {
|
|
|
925
926
|
const set = e.persistentDisposition.set ?? [];
|
|
926
927
|
const unset = e.persistentDisposition.unset ?? [];
|
|
927
928
|
if (!set.length && !unset.length)
|
|
928
|
-
v.push('persistentDisposition
|
|
929
|
+
v.push('persistentDisposition의 set 또는 unset 중 하나 이상을 지정하세요.');
|
|
929
930
|
const both = set.filter(x => unset.includes(x));
|
|
930
931
|
if (both.length)
|
|
931
932
|
v.push(`persistentDisposition 이 같은 값을 set·unset 동시 지정: ${both.join(', ')}`);
|
|
@@ -953,18 +954,19 @@ export function validateEpcisEvent(e) {
|
|
|
953
954
|
if (e.type === 'ObjectEvent') {
|
|
954
955
|
if (!ACTIONS.includes(e.action))
|
|
955
956
|
v.push(`지원하지 않는 action 값: ${e.action}`);
|
|
956
|
-
if (!Array.isArray(e.epcList))
|
|
957
|
-
v.push('ObjectEvent.epcList
|
|
958
|
-
else if (e.epcList
|
|
959
|
-
v.push('ObjectEvent: epcList
|
|
957
|
+
if (e.epcList !== undefined && !Array.isArray(e.epcList))
|
|
958
|
+
v.push('ObjectEvent.epcList 는 배열이어야 합니다');
|
|
959
|
+
else if (!e.epcList?.length && !e.quantityList?.length)
|
|
960
|
+
v.push('ObjectEvent: epcList 또는 quantityList에 항목을 하나 이상 지정하세요.');
|
|
960
961
|
}
|
|
961
962
|
else if (e.type === 'AggregationEvent') {
|
|
962
963
|
if (!ACTIONS.includes(e.action))
|
|
963
964
|
v.push(`지원하지 않는 action 값: ${e.action}`);
|
|
964
|
-
|
|
965
|
-
|
|
965
|
+
/* 표준: OBSERVE 에서는 선택, ADD · DELETE 에서는 필수(EPCIS 2.0 §7.4.3). */
|
|
966
|
+
if (!e.parentID && e.action !== 'OBSERVE')
|
|
967
|
+
v.push('AggregationEvent.parentID 누락 — ADD · DELETE 에는 필수입니다');
|
|
966
968
|
if (!e.childEPCs?.length && !e.childQuantityList?.length)
|
|
967
|
-
v.push('AggregationEvent: childEPCs
|
|
969
|
+
v.push('AggregationEvent: childEPCs 또는 childQuantityList에 항목을 하나 이상 지정하세요.');
|
|
968
970
|
}
|
|
969
971
|
else if (e.type === 'TransactionEvent') {
|
|
970
972
|
if (!ACTIONS.includes(e.action))
|
package/dist/erp.js
CHANGED
|
@@ -63,7 +63,7 @@ export function validatePerformance(e, nowMs) {
|
|
|
63
63
|
if (!String(e?.orderId ?? '').trim())
|
|
64
64
|
errors.push('orderId 누락. 실적의 작업지시 ID를 지정하세요.');
|
|
65
65
|
if (!String(e?.uom ?? '').trim())
|
|
66
|
-
errors.push('
|
|
66
|
+
errors.push('생산 실적 수량의 단위(uom)를 지정하세요.');
|
|
67
67
|
for (const [name, v] of [
|
|
68
68
|
['goodQuantity', e?.goodQuantity],
|
|
69
69
|
['scrapQuantity', e?.scrapQuantity]
|
package/dist/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export * from './domain-catalog.ts';
|
|
|
5
5
|
export * from './domain-definition.ts';
|
|
6
6
|
export * from './ems-profile.ts';
|
|
7
7
|
export * from './energy-ingest.ts';
|
|
8
|
+
export * from './tariff.ts';
|
|
8
9
|
export * from './epcis.ts';
|
|
9
10
|
export * from './gs1.ts';
|
|
10
11
|
export * from './order-fold.ts';
|
package/dist/index.js
CHANGED
|
@@ -26,6 +26,7 @@ export * from "./domain-catalog.js";
|
|
|
26
26
|
export * from "./domain-definition.js";
|
|
27
27
|
export * from "./ems-profile.js";
|
|
28
28
|
export * from "./energy-ingest.js";
|
|
29
|
+
export * from "./tariff.js";
|
|
29
30
|
export * from "./epcis.js";
|
|
30
31
|
export * from "./gs1.js";
|
|
31
32
|
export * from "./order-fold.js";
|
package/dist/mes-profile.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
import { CBV_BIZSTEP } from "./epcis.js";
|
|
1
2
|
// MES bizStep — CBV 재사용. producing = commissioning(신규 제품 커미셔닝).
|
|
3
|
+
// producing 은 코어의 CBV_BIZSTEP.commissioning 을 가리킨다(값을 두 번 적지 않는다, 2026-11-27).
|
|
4
|
+
// receiving · storing 은 창고 프로파일(BIZSTEP)과 같은 CBV 값이지만 그쪽을 가져오지 않는다 — 프로파일끼리 기대면
|
|
5
|
+
// 한 업종의 어휘가 다른 업종에 새어 든다(§CBV_BIZSTEP 머리 주석). 철자는 cbv-bizstep-values-exist 시험이 지킨다.
|
|
2
6
|
export const MES_BIZSTEP = {
|
|
3
7
|
receiving: 'urn:epcglobal:cbv:bizstep:receiving', // 원자재 수령
|
|
4
|
-
producing:
|
|
8
|
+
producing: CBV_BIZSTEP.commissioning, // 생산(제품 최초 생성)
|
|
5
9
|
storing: 'urn:epcglobal:cbv:bizstep:storing' // 완제품 저장
|
|
6
10
|
};
|
|
7
11
|
/** 작업지시(Work Order) = 생산 오더 거래 유형. */
|
|
@@ -36,7 +36,7 @@ export interface RecordsOfEvent {
|
|
|
36
36
|
/** The fields this event carried that the records leave out - absent when none. */
|
|
37
37
|
notCarried?: FieldNotCarried[];
|
|
38
38
|
}
|
|
39
|
-
export type RecordShapeRefusal = 'nothing-observed' | 'quantity-across-many-units' | 'event-type-not-shaped' | 'correction-not-shaped' | 'event-invalid';
|
|
39
|
+
export type RecordShapeRefusal = 'nothing-observed' | 'aggregation-no-parent' | 'quantity-across-many-units' | 'event-type-not-shaped' | 'correction-not-shaped' | 'event-invalid';
|
|
40
40
|
/** Why an event cannot be shaped - an `Error` with a `code` and its `params`. A product turns it into its own refusal. */
|
|
41
41
|
export interface RecordShapeError extends Error {
|
|
42
42
|
code: RecordShapeRefusal;
|
package/dist/records-of-event.js
CHANGED
|
@@ -79,6 +79,11 @@ function shapedRecordsOf(event) {
|
|
|
79
79
|
};
|
|
80
80
|
}
|
|
81
81
|
case 'AggregationEvent':
|
|
82
|
+
/* EPCIS 2.0 lets an OBSERVE leave the parent unsaid (§7.4.3); the canonical aggregation record is keyed by its parent, so
|
|
83
|
+
* without one it would not read back as an aggregation - refused, not sent half-shaped. */
|
|
84
|
+
if (!event.parentID) {
|
|
85
|
+
throw shapeError('aggregation-no-parent', { event: event.eventID }, 'the aggregation names no parent: the canonical record is keyed by its parent');
|
|
86
|
+
}
|
|
82
87
|
return {
|
|
83
88
|
records: [
|
|
84
89
|
{
|
package/dist/tariff.d.ts
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* **Electricity tariff rules** — the words of a time-of-use tariff and how to read it.
|
|
3
|
+
*
|
|
4
|
+
* ── Why this is in the contract (2026-11-27) ────────────────────────────────────────────────────────────────────
|
|
5
|
+
* The tariff is site master data and is stored by ops-master (`ElectricityTariff` · `ElectricityTariffBand`). What
|
|
6
|
+
* lives here is the reading: which band applies at a moment, and whether a tariff's bands cover every day. Once the
|
|
7
|
+
* twin prices usage per band (the kernel's `electricityCost({ energyChargeFromPeriods })`), ops-master's screen and the
|
|
8
|
+
* twin must give the same answer for the same moment - a rule two implementations share belongs to the contract.
|
|
9
|
+
* Storage, approval and screens stay with ops-master.
|
|
10
|
+
*
|
|
11
|
+
* Field names are the declaration's (`EMS_DECLARATION` `tariff.*`): `demandChargePerKW`, `energyChargePerKWh`,
|
|
12
|
+
* `currency`. The contract power (`contract.kW`) and billing demand (`tariff.billingDemandKW`) are not tariff rows -
|
|
13
|
+
* one is a property of the supply point, the other a per-cycle fact from the supplier.
|
|
14
|
+
*
|
|
15
|
+
* ── Which price wins ────────────────────────────────────────────────────────────────────────────────────────────
|
|
16
|
+
* A source fact's own price (`EnergyUsagePeriodData.unitPrice`) is what was charged; it wins. A band price from the
|
|
17
|
+
* master is used only for a period whose fact carries no price. The master is a declaration, the fact an observation.
|
|
18
|
+
*
|
|
19
|
+
* ── Times are the site's wall clock ─────────────────────────────────────────────────────────────────────────────
|
|
20
|
+
* Bands are set in local time ("weekdays 09:00-10:00 are on-peak"). These functions do not know time zones: the
|
|
21
|
+
* caller converts an instant to the site's month, day, weekday and minute (`LocalMoment`). Cutting in UTC would make
|
|
22
|
+
* Seoul's 09:00 into 00:00.
|
|
23
|
+
*
|
|
24
|
+
* ── A band does not cross midnight ──────────────────────────────────────────────────────────────────────────────
|
|
25
|
+
* "22:00-08:00 off-peak" is written as two rows (22:00-24:00, 00:00-08:00). A single row would have to say which day
|
|
26
|
+
* it belongs to (does Saturday night run into Sunday morning?), and tariffs answer that differently.
|
|
27
|
+
*
|
|
28
|
+
* ── A new country is rows, not code (2026-11-27) ───────────────────────────────────────────────────────────────
|
|
29
|
+
* Tariff systems differ by country and supplier: how many bands and what they are called, whether a holiday is priced
|
|
30
|
+
* like Sunday, whether demand is charged per band, which days are holidays. A new country must be written as tariff,
|
|
31
|
+
* band and calendar rows - never as a change here, in the kernel or on a screen. So:
|
|
32
|
+
* · the band **code** is the tariff's own (`base` · `intermedia` · `punta`, `super-off-peak` …); only its
|
|
33
|
+
* **load class** - for comparing across tariffs - is a closed, ordered vocabulary (`TARIFF_LOAD_CLASSES`);
|
|
34
|
+
* · `sunday` and `holiday` are separate day kinds; a tariff pricing them alike writes two rows;
|
|
35
|
+
* · the tariff's `demandChargePerKW` is the facility demand charge (any time); a band may carry its own
|
|
36
|
+
* time-of-use `demandChargePerKW`;
|
|
37
|
+
* · the tariff names its holiday calendar (`holidayCalendar`); the calendar's days are not in the contract - the
|
|
38
|
+
* caller passes `isHoliday`.
|
|
39
|
+
* Season bounds are fixed `MM-DD`. A tariff whose season moves each year ("from the first Sunday of April") is written
|
|
40
|
+
* as one tariff per year with its effective dates - not yet seen to need more (to check against CFE tariffs).
|
|
41
|
+
*
|
|
42
|
+
* ── Issues are structured ───────────────────────────────────────────────────────────────────────────────────────
|
|
43
|
+
* Checks return `{ field, code, params }`, not sentences: a screen turns the code into its own language, and
|
|
44
|
+
* `tariffIssueText` gives the one-line English `field: reason` other contract checks use.
|
|
45
|
+
*/
|
|
46
|
+
/**
|
|
47
|
+
* Load class of a band - **ordered from lightest to heaviest load**, for comparing bands across tariffs
|
|
48
|
+
* ("how much is shifted out of the heaviest hours"). The band's own code is the tariff's: Mexico's `base` ·
|
|
49
|
+
* `intermedia` · `punta` are classed `off-peak` · `mid-peak` · `on-peak`; a US `super-off-peak` band is that class.
|
|
50
|
+
*/
|
|
51
|
+
export declare const TARIFF_LOAD_CLASSES: readonly ["super-off-peak", "off-peak", "mid-peak", "on-peak"];
|
|
52
|
+
export type TariffLoadClass = (typeof TARIFF_LOAD_CLASSES)[number];
|
|
53
|
+
/**
|
|
54
|
+
* Which days a band applies to. `all` ignores the day.
|
|
55
|
+
*
|
|
56
|
+
* `holiday` is a day of the tariff's holiday calendar (`holidayCalendar`) and **comes before the weekday**: a holiday
|
|
57
|
+
* falling on a Saturday is a holiday. A tariff that prices holidays like Sundays writes a `sunday` row and a `holiday`
|
|
58
|
+
* row. A tariff with no `holiday` row does not price holidays apart - its holidays are read as their weekday.
|
|
59
|
+
*/
|
|
60
|
+
export declare const TARIFF_DAY_KINDS: readonly ["all", "weekday", "saturday", "sunday", "holiday"];
|
|
61
|
+
export type TariffDayKind = (typeof TARIFF_DAY_KINDS)[number];
|
|
62
|
+
export interface TariffLike {
|
|
63
|
+
name?: string;
|
|
64
|
+
currency?: string | null;
|
|
65
|
+
/** Facility demand charge per kW of billing demand - whatever the hour. */
|
|
66
|
+
demandChargePerKW?: number | string | null;
|
|
67
|
+
/** Flat energy charge - only for a tariff without bands. */
|
|
68
|
+
energyChargePerKWh?: number | string | null;
|
|
69
|
+
/** The holiday calendar this tariff's `holiday` bands follow - a name; the days are the caller's. */
|
|
70
|
+
holidayCalendar?: string | null;
|
|
71
|
+
}
|
|
72
|
+
export interface TariffBandLike {
|
|
73
|
+
name?: string;
|
|
74
|
+
tariffName?: string;
|
|
75
|
+
/** The tariff's own band code (`punta`, `on-peak`, `super-off-peak` …). */
|
|
76
|
+
band?: string | null;
|
|
77
|
+
/** `TARIFF_LOAD_CLASSES` - for comparing across tariffs. */
|
|
78
|
+
loadClass?: string | null;
|
|
79
|
+
/** Season start `MM-DD`; empty together with `seasonTo` means all year. May wrap the year (11-01..02-28). */
|
|
80
|
+
seasonFrom?: string | null;
|
|
81
|
+
/** Season end `MM-DD`, inclusive. */
|
|
82
|
+
seasonTo?: string | null;
|
|
83
|
+
dayKind?: string | null;
|
|
84
|
+
/** `HH:mm`, inclusive. */
|
|
85
|
+
fromTime?: string | null;
|
|
86
|
+
/** `HH:mm`, exclusive; `24:00` ends the day. */
|
|
87
|
+
toTime?: string | null;
|
|
88
|
+
energyChargePerKWh?: number | string | null;
|
|
89
|
+
/** Time-of-use demand charge per kW in this band, on top of the tariff's facility charge. Optional. */
|
|
90
|
+
demandChargePerKW?: number | string | null;
|
|
91
|
+
effectiveEnd?: Date | string | null;
|
|
92
|
+
}
|
|
93
|
+
export declare const TARIFF_ISSUE_CODES: readonly ["required", "not-a-number", "negative", "not-in-vocabulary", "format", "currency-required", "season-pair", "end-not-after-start", "flat-and-bands", "broken-bands", "gap", "overlap"];
|
|
94
|
+
export type TariffIssueCode = (typeof TARIFF_ISSUE_CODES)[number];
|
|
95
|
+
export interface TariffIssue {
|
|
96
|
+
/** The field the issue is about (`currency`, `fromTime`, `bands` …). */
|
|
97
|
+
field: string;
|
|
98
|
+
code: TariffIssueCode;
|
|
99
|
+
params?: Record<string, string | number>;
|
|
100
|
+
}
|
|
101
|
+
/** One English line, `field: reason` - the form other contract checks use. */
|
|
102
|
+
export declare function tariffIssueText(issue: TariffIssue): string;
|
|
103
|
+
/** An ISO 4217 code - three upper-case letters (KRW, USD). */
|
|
104
|
+
export declare function isIso4217Code(value: unknown): value is string;
|
|
105
|
+
/** `HH:mm` → minutes from midnight. `24:00` is 1440 and is only an end. */
|
|
106
|
+
export declare function minutesOf(text: unknown): number | undefined;
|
|
107
|
+
/** `MM-DD` → day of a leap year (0..365). Takes 02-29 - that day too must fall in some season. */
|
|
108
|
+
export declare function dayOfYearOf(text: unknown): number | undefined;
|
|
109
|
+
/** One tariff row, before it is saved. Empty when it is sound. */
|
|
110
|
+
export declare function tariffIssues(row: TariffLike): TariffIssue[];
|
|
111
|
+
/** One band row, before it is saved. Whether bands cover the day cannot be seen from one row - `tariffCoverageIssues`. */
|
|
112
|
+
export declare function tariffBandIssues(row: TariffBandLike): TariffIssue[];
|
|
113
|
+
/** Bands still in force at `at` - a band whose end has passed was retired (rows are ended, not deleted). */
|
|
114
|
+
export declare function activeBands<T extends TariffBandLike>(bands: readonly T[], at: Date): T[];
|
|
115
|
+
/**
|
|
116
|
+
* Whether one tariff's bands cover **every minute of every day, once**.
|
|
117
|
+
*
|
|
118
|
+
* Looks at all 366 days of a leap year × the concrete day kinds (weekday, saturday, sunday, and holiday when the tariff
|
|
119
|
+
* prices holidays apart). An uncovered hour cannot be priced; an hour
|
|
120
|
+
* covered twice has two prices - either way its charge would be invented. The same problem over consecutive days is
|
|
121
|
+
* one issue (`params.days` like `06-01~08-31`).
|
|
122
|
+
*
|
|
123
|
+
* No bands is not an issue - it is a flat tariff (the tariff row's `energyChargePerKWh`). A tariff passes through
|
|
124
|
+
* wrong states while it is edited, so a screen shows this rather than refusing to save.
|
|
125
|
+
*/
|
|
126
|
+
export declare function tariffCoverageIssues(tariff: TariffLike, bands: readonly TariffBandLike[]): TariffIssue[];
|
|
127
|
+
/** A moment on the site's wall clock - the caller converts to the site's time zone. */
|
|
128
|
+
export interface LocalMoment {
|
|
129
|
+
/** 1..12 */
|
|
130
|
+
month: number;
|
|
131
|
+
/** 1..31 */
|
|
132
|
+
day: number;
|
|
133
|
+
/** 0 = Sunday … 6 = Saturday (as `Date.getDay`) */
|
|
134
|
+
weekday: number;
|
|
135
|
+
/** Minutes from midnight (0..1439) */
|
|
136
|
+
minutes: number;
|
|
137
|
+
}
|
|
138
|
+
export type BandAt = {
|
|
139
|
+
/** Band row name - absent for a flat tariff. */
|
|
140
|
+
bandName?: string;
|
|
141
|
+
/** The tariff's band code. */
|
|
142
|
+
band?: string;
|
|
143
|
+
loadClass?: TariffLoadClass;
|
|
144
|
+
energyChargePerKWh: number;
|
|
145
|
+
/** Time-of-use demand charge of the band, when it has one. The tariff's facility charge is not repeated here. */
|
|
146
|
+
demandChargePerKW?: number;
|
|
147
|
+
currency?: string;
|
|
148
|
+
/**
|
|
149
|
+
* False only when the tariff prices holidays apart and no `isHoliday` was given - a holiday may then have been
|
|
150
|
+
* priced as its weekday.
|
|
151
|
+
*/
|
|
152
|
+
holidayKnown: boolean;
|
|
153
|
+
} | {
|
|
154
|
+
reason: 'no-price' | 'no-band' | 'ambiguous';
|
|
155
|
+
bands?: string[];
|
|
156
|
+
};
|
|
157
|
+
/**
|
|
158
|
+
* The energy charge at this moment.
|
|
159
|
+
*
|
|
160
|
+
* Without bands the tariff's flat charge applies. With bands **exactly one** must match - none is `no-band`, more than
|
|
161
|
+
* one is `ambiguous`, and no price is picked (taking the first written would be chance).
|
|
162
|
+
*/
|
|
163
|
+
export declare function bandAt(tariff: TariffLike, bands: readonly TariffBandLike[], at: LocalMoment, isHoliday?: (month: number, day: number) => boolean): BandAt;
|