@operato/ops-contract 0.9.32 → 0.9.34

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.
@@ -1967,6 +1967,7 @@ export interface WorkDirectiveRef {
1967
1967
  workMasterId?: string;
1968
1968
  }
1969
1969
  export interface TaskState {
1970
+ workShiftBasis?: import('./work-shift-basis.ts').WorkShiftExecutionBasis;
1970
1971
  id: string;
1971
1972
  kind: string;
1972
1973
  status: TaskStatus;
@@ -2051,7 +2052,20 @@ export interface RecipeExecutionBasis {
2051
2052
  };
2052
2053
  }
2053
2054
  export declare function isRecipeExecutionBasis(value: unknown): value is RecipeExecutionBasis;
2055
+ /** Source-pinned material definition; not a replacement of the Twin's current master projection. */
2056
+ export interface MaterialExecutionBasis {
2057
+ basisId: string;
2058
+ materialId: string;
2059
+ revisionId: string;
2060
+ revisionNumber: number;
2061
+ planId: string;
2062
+ contentHash: string;
2063
+ businessTime: ISOTime;
2064
+ material: MaterialDefinition;
2065
+ }
2066
+ export declare function isMaterialExecutionBasis(value: unknown): value is MaterialExecutionBasis;
2054
2067
  export interface OrderState {
2068
+ materialBasis?: MaterialExecutionBasis[];
2055
2069
  recipeBasis?: RecipeExecutionBasis;
2056
2070
  id: string;
2057
2071
  kind: string;
@@ -3463,6 +3477,7 @@ export declare function isFailureStatus(value: unknown): boolean;
3463
3477
  /** 계획정지였나 — 계획 조업 시간에서 빼는 것(§`OeeCounters.holdMs`). */
3464
3478
  export declare function isPlannedStopStatus(value: unknown): boolean;
3465
3479
  export interface EquipmentStatePeriodFact {
3480
+ workShiftBasis?: import('./work-shift-basis.ts').WorkShiftExecutionBasis;
3466
3481
  moverId: string;
3467
3482
  /**
3468
3483
  * 그 구간의 상태 — **선언된 다섯 중 하나**(§`EQUIPMENT_STATUS`).
@@ -3562,6 +3577,7 @@ export interface MaterialActual {
3562
3577
  lotId?: string;
3563
3578
  }
3564
3579
  export interface TaskStatusDelta {
3580
+ workShiftBasis?: import('./work-shift-basis.ts').WorkShiftExecutionBasis;
3565
3581
  taskId: string;
3566
3582
  /** 착수 시각(절대 sim-clock) — 보간 앵커. TaskState 와 같은 뜻. */
3567
3583
  startedAtSimMs?: number;
@@ -3695,6 +3711,7 @@ export interface ObservedOrderLine {
3695
3711
  allocated?: number;
3696
3712
  }
3697
3713
  export interface OrderStatusDelta {
3714
+ materialBasis?: MaterialExecutionBasis[];
3698
3715
  recipeBasis?: RecipeExecutionBasis;
3699
3716
  orderId: string;
3700
3717
  kind: string;
package/dist/contract.js CHANGED
@@ -1099,6 +1099,26 @@ export function isRecipeExecutionBasis(value) {
1099
1099
  v.route.key === v.recipe.route && Array.isArray(v.route.steps) && v.route.steps.every(text) &&
1100
1100
  v.recipe.inputs.every(line => !line.operation || v.route.steps.includes(line.operation)));
1101
1101
  }
1102
+ export function isMaterialExecutionBasis(value) {
1103
+ if (!value || typeof value !== 'object')
1104
+ return false;
1105
+ const v = value;
1106
+ const text = (x) => typeof x === 'string' && x.trim().length > 0;
1107
+ let count = 0;
1108
+ const properties = (rows, depth = 0) => rows === undefined ||
1109
+ (Array.isArray(rows) && depth <= 32 && rows.every(p => {
1110
+ if (++count > 1000 || !p || !text(p.id))
1111
+ return false;
1112
+ if (p.value != null && typeof p.value !== 'string' && (typeof p.value !== 'number' || !Number.isFinite(p.value)))
1113
+ return false;
1114
+ return properties(p.children, depth + 1);
1115
+ }));
1116
+ return [v.basisId, v.materialId, v.revisionId, v.planId, v.contentHash, v.businessTime].every(text) &&
1117
+ /(?:Z|[+-]\d{2}:\d{2})$/.test(v.businessTime) && Number.isFinite(Date.parse(v.businessTime)) &&
1118
+ Number.isInteger(v.revisionNumber) && v.revisionNumber > 0 && !!v.material && text(v.material.id) &&
1119
+ properties(v.material.properties) &&
1120
+ [v.material.materialClassIds, v.material.testSpecificationIds].every(ids => ids === undefined || Array.isArray(ids) && ids.every(text));
1121
+ }
1102
1122
  // ── 운영 델타(비-EPCIS) — State 채널의 나머지 절반 ──────────────────────────
1103
1123
  // EPCIS 이벤트는 재고/위치만 재구성 가능. tasks·equipment·orders 의 운영 상태는
1104
1124
  // 이 델타로 미러한다. envelope.eventType = 'task.status' | 'equipment.status' | 'order.status'.
package/dist/epcis.d.ts CHANGED
@@ -344,8 +344,10 @@ export interface ParsedEpc {
344
344
  instance: boolean;
345
345
  /** 품목 클래스 키 — `CompanyPrefix.ItemRef`(sgtin/lgtin/idpat 에서). */
346
346
  gtinKey?: string;
347
- /** 로트 번호(LGTIN 에만 있다). */
347
+ /** 로트 번호 — LGTIN 과, 선언된 이름공간의 로트 클래스(`<품번>;lot=<로트>`, §`lotClassUri`)에 있다. */
348
348
  lot?: string;
349
+ /** 사내 품번 — 선언된 이름공간의 로트 클래스에서만 뜯는다. 로트 없는 품목 클래스는 지금처럼 원문만 낸다. */
350
+ item?: string;
349
351
  /** 일련번호(SGTIN·SSCC 등 개체 식별자에만). */
350
352
  serial?: string;
351
353
  /** 원문 — 해석에 실패해도 잃지 않는다. */
@@ -411,6 +413,41 @@ export declare function objectUri(namespace: string, objId: string | number): st
411
413
  * 그래서 한 표준에 방언이 둘이 됐다. 문을 낸다.
412
414
  */
413
415
  export declare function classUri(namespace: string, classId: string | number): string | undefined;
416
+ /**
417
+ * **로트 클래스의 식별자** — 품번과 로트를 받아 class URI 하나를 낸다(ADR-0082 결정 2 · 2026-09-24 판정).
418
+ *
419
+ * ── 왜 계약이 갖는가 ──────────────────────────────────────────────────────
420
+ * plant 는 로트를 `${품번}-lot-${로트}` 로 적어 왔다(`epcis-genealogy.ts` 의 `lotClassOf`). 둘째 생산자
421
+ * (warehouse)와 커널의 시뮬이 같은 로트를 말하려면 **같은 글자**여야 하고, 그 글자를 정하는 곳은 하나여야 한다.
422
+ *
423
+ * ── 두 길 ──────────────────────────────────────────────────────────────────
424
+ * · GTIN 이 있으면 LGTIN(`lgtinClass`). `gtin` 은 파서의 `gtinKey` 와 같은 모양 `CompanyPrefix.ItemRefAndIndicator`
425
+ * 이다 — GTIN-14 만으로는 프리픽스 자리 수를 알 수 없어서 나눌 수 없다. 자리 수(`GS1_KEY_DIGITS`)가 틀리면
426
+ * **던진다.** 사내 철자로 떨어지면 같은 로트가 두 글자가 된다.
427
+ * · 없으면 `/class/` 뒤 **성분 하나** 안에서 가른다: `<품번>;lot=<로트>`(CBV 2.0 §8.3.4 — `/class/<품번>/lot/<로트>`
428
+ * 는 계약의 `CBV_URL_CLASS` 가 거절한다).
429
+ *
430
+ * ── 부호화 ─────────────────────────────────────────────────────────────────
431
+ * `classUri` 의 여섯 글자에 `;` 하나만 더한다. 값 안의 `;` 가 `%3B` 가 되므로 `;lot=` 는 성분 안에 정확히
432
+ * 한 번 나오고 파서는 그 자리에서 가른다. `=` 는 부호화하지 않는다 — 하면 `A=B` 라는 품번이 품목 클래스에서는
433
+ * `A=B`, 로트 클래스에서는 `A%3DB` 가 되어 같은 품번의 글자가 갈린다.
434
+ *
435
+ * `classUri(ns, 품번 + ';lot=' + …)` 로 부르지 않는다: `classUri` 가 `%` 를 다시 부호화하므로 미리 부호화한
436
+ * 값은 두 번 부호화되고(`A%2FB` → `A%252FB`), 원문을 넘기면 값 안의 `;` 가 남아 가르는 자리가 모호하다.
437
+ *
438
+ * ── 남는 것 ───────────────────────────────────────────────────────────────
439
+ * `;` 가 든 품번은 품목 클래스(`classUri` — `;` 를 그대로 둔다)와 로트 클래스의 품번 글자가 갈린다. `classUri`
440
+ * 를 바꾸면 저장된 정체성이 흔들리므로 두지 않는다. **「같은 품번인가」는 문자열 앞부분이 아니라 `parseEpc`
441
+ * 로 양쪽을 뜯어 품번을 견준다.**
442
+ *
443
+ * 이름공간이 없거나 GS1 공간이면 `undefined` 다(`classUri` 와 같다 — 부르는 쪽이 「선언 없음」으로 말한다).
444
+ */
445
+ export declare function lotClassUri(input: {
446
+ namespace: string;
447
+ item: string;
448
+ lot: string;
449
+ gtin?: string;
450
+ }): string | undefined;
414
451
  export declare function bizTransactionUri(namespace: string, transId: string | number): string | undefined;
415
452
  /** 모든 빌더가 공통으로 받는 표준 헤더 옵션(선택) — 방출부가 필요할 때 채운다. */
416
453
  export interface EpcisHeaderOptions {
package/dist/epcis.js CHANGED
@@ -190,8 +190,16 @@ export function parseEpc(uri) {
190
190
  */
191
191
  if (/(?:\/obj\/|:obj:)[^/:\s]+$/.test(raw))
192
192
  return { scheme: 'unknown', instance: true, uri: raw };
193
- if (/(?:\/class\/|:class:)[^/:\s]+$/.test(raw))
194
- return { scheme: 'unknown', instance: false, uri: raw };
193
+ const inHouseClass = raw.match(/(?:\/class\/|:class:)([^/:\s]+)$/);
194
+ if (inHouseClass) {
195
+ /*
196
+ * 로트 클래스면 `;lot=` 에서 가른다(§`lotClassUri`). 그 밖의 클래스는 **지금 답 그대로**다 — 저널에 남은
197
+ * 철자(plant 의 `-lot-` 포함)를 오늘 다르게 읽지 않는다(ADR-0038, 시험 `class-uri-regression`).
198
+ */
199
+ const at = inHouseClass[1].indexOf(LOT_SEPARATOR);
200
+ const split = at > 0 ? decodedPair(inHouseClass[1].slice(0, at), inHouseClass[1].slice(at + LOT_SEPARATOR.length)) : undefined;
201
+ return split ? { scheme: 'unknown', instance: false, item: split[0], lot: split[1], uri: raw } : { scheme: 'unknown', instance: false, uri: raw };
202
+ }
195
203
  const cls = raw.match(/^urn:epc:class:lgtin:(.+)$/);
196
204
  if (cls) {
197
205
  const seg = cls[1].split('.');
@@ -224,6 +232,17 @@ export function parseEpc(uri) {
224
232
  }
225
233
  return { scheme: 'unknown', instance: false, uri: raw };
226
234
  }
235
+ /** 로트 클래스의 두 마디를 한 번 복호화한다. 우리가 만든 글자가 아니어서 뜯을 수 없으면 가르지 않는다. */
236
+ function decodedPair(item, lot) {
237
+ if (!lot)
238
+ return undefined;
239
+ try {
240
+ return [decodeURIComponent(item), decodeURIComponent(lot)];
241
+ }
242
+ catch {
243
+ return undefined;
244
+ }
245
+ }
227
246
  /** 거래문서 식별자 = GDTI (PO/SO/WO/어포인트먼트 등). */
228
247
  export function gdtiUri(companyPrefix, docType, serial) {
229
248
  return `urn:epc:id:gdti:${companyPrefix}.${docType}.${serial}`;
@@ -283,6 +302,60 @@ export function objectUri(namespace, objId) {
283
302
  export function classUri(namespace, classId) {
284
303
  return underNamespace(namespace, 'class', classId);
285
304
  }
305
+ /**
306
+ * **로트 클래스의 식별자** — 품번과 로트를 받아 class URI 하나를 낸다(ADR-0082 결정 2 · 2026-09-24 판정).
307
+ *
308
+ * ── 왜 계약이 갖는가 ──────────────────────────────────────────────────────
309
+ * plant 는 로트를 `${품번}-lot-${로트}` 로 적어 왔다(`epcis-genealogy.ts` 의 `lotClassOf`). 둘째 생산자
310
+ * (warehouse)와 커널의 시뮬이 같은 로트를 말하려면 **같은 글자**여야 하고, 그 글자를 정하는 곳은 하나여야 한다.
311
+ *
312
+ * ── 두 길 ──────────────────────────────────────────────────────────────────
313
+ * · GTIN 이 있으면 LGTIN(`lgtinClass`). `gtin` 은 파서의 `gtinKey` 와 같은 모양 `CompanyPrefix.ItemRefAndIndicator`
314
+ * 이다 — GTIN-14 만으로는 프리픽스 자리 수를 알 수 없어서 나눌 수 없다. 자리 수(`GS1_KEY_DIGITS`)가 틀리면
315
+ * **던진다.** 사내 철자로 떨어지면 같은 로트가 두 글자가 된다.
316
+ * · 없으면 `/class/` 뒤 **성분 하나** 안에서 가른다: `<품번>;lot=<로트>`(CBV 2.0 §8.3.4 — `/class/<품번>/lot/<로트>`
317
+ * 는 계약의 `CBV_URL_CLASS` 가 거절한다).
318
+ *
319
+ * ── 부호화 ─────────────────────────────────────────────────────────────────
320
+ * `classUri` 의 여섯 글자에 `;` 하나만 더한다. 값 안의 `;` 가 `%3B` 가 되므로 `;lot=` 는 성분 안에 정확히
321
+ * 한 번 나오고 파서는 그 자리에서 가른다. `=` 는 부호화하지 않는다 — 하면 `A=B` 라는 품번이 품목 클래스에서는
322
+ * `A=B`, 로트 클래스에서는 `A%3DB` 가 되어 같은 품번의 글자가 갈린다.
323
+ *
324
+ * `classUri(ns, 품번 + ';lot=' + …)` 로 부르지 않는다: `classUri` 가 `%` 를 다시 부호화하므로 미리 부호화한
325
+ * 값은 두 번 부호화되고(`A%2FB` → `A%252FB`), 원문을 넘기면 값 안의 `;` 가 남아 가르는 자리가 모호하다.
326
+ *
327
+ * ── 남는 것 ───────────────────────────────────────────────────────────────
328
+ * `;` 가 든 품번은 품목 클래스(`classUri` — `;` 를 그대로 둔다)와 로트 클래스의 품번 글자가 갈린다. `classUri`
329
+ * 를 바꾸면 저장된 정체성이 흔들리므로 두지 않는다. **「같은 품번인가」는 문자열 앞부분이 아니라 `parseEpc`
330
+ * 로 양쪽을 뜯어 품번을 견준다.**
331
+ *
332
+ * 이름공간이 없거나 GS1 공간이면 `undefined` 다(`classUri` 와 같다 — 부르는 쪽이 「선언 없음」으로 말한다).
333
+ */
334
+ export function lotClassUri(input) {
335
+ const item = String(input.item ?? '');
336
+ const lot = String(input.lot ?? '');
337
+ if (!lot)
338
+ throw new Error(`lotClassUri: 로트가 비었다 — 로트 없는 품목은 classUri 로 부른다 (item=${item})`);
339
+ if (input.gtin !== undefined) {
340
+ const [prefix, ref, ...rest] = String(input.gtin).split('.');
341
+ if (!prefix || !ref || rest.length) {
342
+ throw new Error(`lotClassUri: gtin 은 'CompanyPrefix.ItemRefAndIndicator' 여야 한다: ${input.gtin}`);
343
+ }
344
+ const uri = lgtinClass(prefix, ref, lot);
345
+ const wrong = gs1KeyDigitViolation(uri);
346
+ if (wrong)
347
+ throw new Error(`lotClassUri: ${wrong}`);
348
+ return uri;
349
+ }
350
+ if (!item)
351
+ throw new Error(`lotClassUri: 품번이 비었다 (lot=${lot})`);
352
+ const enc = (v) => v.replace(LOT_COMPONENT_BREAKING, c => PERCENT_ENCODED[c]);
353
+ return joinUnderNamespace(input.namespace, 'class', `${enc(item)}${LOT_SEPARATOR}${enc(lot)}`);
354
+ }
355
+ /** 로트 클래스 성분에서 품번과 로트를 가르는 자리. 값 안의 `;` 는 부호화되므로 한 번만 나온다. */
356
+ const LOT_SEPARATOR = ';lot=';
357
+ /** `STRUCTURE_BREAKING` 에 `;` 하나를 더한 것. 부호는 같은 표(`PERCENT_ENCODED`)에서 온다. */
358
+ const LOT_COMPONENT_BREAKING = /[%/:?# ;]/g;
286
359
  export function bizTransactionUri(namespace, transId) {
287
360
  return underNamespace(namespace, 'bt', transId);
288
361
  }
@@ -319,16 +392,21 @@ const PERCENT_ENCODED = {
319
392
  ':': '%3A',
320
393
  '?': '%3F',
321
394
  '#': '%23',
322
- ' ': '%20'
395
+ ' ': '%20',
396
+ /* 로트 클래스의 가르는 글자 — `lotClassUri` 만 쓴다(§`LOT_COMPONENT_BREAKING`). 표는 한 벌이다. */
397
+ ';': '%3B'
323
398
  };
324
399
  function underNamespace(namespace, marker, id) {
325
- const ns = namespace?.trim();
326
- if (!ns)
327
- return undefined;
328
400
  const raw = String(id);
329
401
  if (!raw)
330
402
  return undefined;
331
- const v = raw.replace(STRUCTURE_BREAKING, c => PERCENT_ENCODED[c]);
403
+ return joinUnderNamespace(namespace, marker, raw.replace(STRUCTURE_BREAKING, c => PERCENT_ENCODED[c]));
404
+ }
405
+ /** 이미 부호화한 성분 하나를 이름공간 아래 표지 뒤에 붙인다 — 부호화는 부르는 쪽(이 파일 안)이 끝냈다. */
406
+ function joinUnderNamespace(namespace, marker, v) {
407
+ const ns = namespace?.trim();
408
+ if (!ns)
409
+ return undefined;
332
410
  if (/^https?:\/\/[^/\s]+/.test(ns))
333
411
  return `${ns.replace(/\/+$/, '')}/${marker}/${v}`;
334
412
  /*
package/dist/index.d.ts CHANGED
@@ -11,6 +11,7 @@ export * from './iso-duration.ts';
11
11
  export * from './master-data.ts';
12
12
  export * from './mes-profile.ts';
13
13
  export * from './operational-ingest.ts';
14
+ export * from './work-shift-basis.ts';
14
15
  export * from './operations-capability.ts';
15
16
  export * from './scenario-validate.ts';
16
17
  export * from './vocabulary.ts';
package/dist/index.js CHANGED
@@ -32,6 +32,7 @@ export * from "./iso-duration.js";
32
32
  export * from "./master-data.js";
33
33
  export * from "./mes-profile.js";
34
34
  export * from "./operational-ingest.js";
35
+ export * from "./work-shift-basis.js";
35
36
  export * from "./operations-capability.js";
36
37
  export * from "./scenario-validate.js";
37
38
  export * from "./vocabulary.js";
@@ -34,7 +34,8 @@
34
34
  * 모르는 필드는 **조용히 버리지 않고 거부한다.** `taskID` 처럼 한 글자 틀린 이름은 통과시키면 영원히
35
35
  * 보이지 않는 손실이 된다(이 문에는 아직 옛 발신자가 없어 호환 부담도 없다).
36
36
  */
37
- import { OP_EVENT, DISPOSITION_DECISION, MATERIAL_ACTUAL_USE, MATERIAL_LOT_USE, isTestSpecificationBasis, isRecipeExecutionBasis } from "./contract.js";
37
+ import { OP_EVENT, DISPOSITION_DECISION, MATERIAL_ACTUAL_USE, MATERIAL_LOT_USE, isTestSpecificationBasis, isRecipeExecutionBasis, isMaterialExecutionBasis } from "./contract.js";
38
+ import { isWorkShiftExecutionBasis } from "./work-shift-basis.js";
38
39
  /**
39
40
  * 객체 한 줄이 선언된 안쪽 모양을 지키나 — **선언하지 않은 자리는 보지 않는다.**
40
41
  *
@@ -122,7 +123,7 @@ const SPECS = {
122
123
  itemRefs: 'string[]', resourceRef: 'string', resources: 'string[]', personnel: 'string[]', assets: 'string[]',
123
124
  orderId: 'string', intent: 'string', progress: 'number', remainingMs: 'number', durationMs: 'number',
124
125
  startedAtSimMs: 'number', outcome: 'string', priority: 'number', startTime: 'string', endTime: 'string',
125
- materialActual: 'object[]', recordTime: 'string'
126
+ materialActual: 'object[]', recordTime: 'string', workShiftBasis: 'object'
126
127
  },
127
128
  /*
128
129
  * **자재 줄의 안쪽** — 계약의 `MaterialActual` 그대로다.
@@ -138,6 +139,11 @@ const SPECS = {
138
139
  * 물려받으면 단위를 모르는 현장의 사실이 통째로 거절된다.
139
140
  */
140
141
  shapes: {
142
+ workShiftBasis: {
143
+ required: ['basisId', 'arrangementId', 'revisionId', 'revisionNumber', 'planId', 'contentHash', 'businessTime', 'timezone', 'shifts', 'workDate'],
144
+ fields: { basisId: 'string', arrangementId: 'string', revisionId: 'string', revisionNumber: 'number', planId: 'string', contentHash: 'string', businessTime: 'string', timezone: 'string', workDate: 'string' }
145
+ // Full nested content and selected occurrence are checked by isWorkShiftExecutionBasis below.
146
+ },
141
147
  materialActual: {
142
148
  required: ['definitionId', 'use'],
143
149
  fields: { definitionId: 'string', lotId: 'string', quantity: 'number', uom: 'string' },
@@ -224,13 +230,18 @@ const SPECS = {
224
230
  *
225
231
  * 새 어휘가 아니다 — 계약이 `recipeKey` 를 네 자리에서 이미 쓴다. 오더 관측에만 자리가 없었다.
226
232
  */
227
- recipeKey: 'string', recipeBasis: 'object'
233
+ recipeKey: 'string', recipeBasis: 'object', materialBasis: 'object[]'
228
234
  },
229
235
  /*
230
236
  * 확보분의 안쪽을 본다 — 열쇠와 수 둘이다(§`AllocatedQuantity`). 안 보면 틀린 이름이 조용히
231
237
  * 지나가고(`epcs`·`quantity` 따위), 미러는 잡힌 수를 0 으로 읽는다.
232
238
  */
233
239
  shapes: {
240
+ materialBasis: {
241
+ required: ['basisId', 'materialId', 'revisionId', 'revisionNumber', 'planId', 'contentHash', 'businessTime', 'material'],
242
+ fields: { basisId: 'string', materialId: 'string', revisionId: 'string', revisionNumber: 'number', planId: 'string', contentHash: 'string', businessTime: 'string' }
243
+ // Recursive material properties and reference lists are checked by isMaterialExecutionBasis.
244
+ },
234
245
  recipeBasis: {
235
246
  required: ['basisId', 'recipeId', 'revisionId', 'planId', 'contentHash', 'businessTime', 'recipe'],
236
247
  fields: { basisId: 'string', recipeId: 'string', revisionId: 'string', planId: 'string', contentHash: 'string', businessTime: 'string' }
@@ -305,7 +316,13 @@ const SPECS = {
305
316
  fields: {
306
317
  moverId: 'string', status: 'string', from: 'string', to: 'string', // vocabulary-guard: allow
307
318
  /* 사람이 정한 사유 — 없을 수 있다(적지 않은 것과 사유가 없는 것은 다르므로 지어내지 않는다). */
308
- reasonCode: 'string', decidedBy: 'string', recordTime: 'string'
319
+ reasonCode: 'string', decidedBy: 'string', recordTime: 'string', workShiftBasis: 'object'
320
+ },
321
+ shapes: {
322
+ workShiftBasis: {
323
+ required: ['basisId', 'arrangementId', 'revisionId', 'revisionNumber', 'planId', 'contentHash', 'businessTime', 'timezone', 'shifts', 'workDate'],
324
+ fields: { basisId: 'string', arrangementId: 'string', revisionId: 'string', revisionNumber: 'number', planId: 'string', contentHash: 'string', businessTime: 'string', timezone: 'string', workDate: 'string' }
325
+ }
309
326
  },
310
327
  enums: { status: EQUIPMENT_STATUS }
311
328
  },
@@ -622,9 +639,26 @@ export function ingestOperationalRecords(records, opts) {
622
639
  * 사건 시각이 되고, 그러면 어제 있었던 정지가 오늘 일어난 것으로 저널에 적힌다. 적은 때는
623
640
  * `recordTime` 에 남는다.
624
641
  */
642
+ if ((kind === 'task' || kind === 'equipment-period') && r.workShiftBasis !== undefined) {
643
+ if (!isWorkShiftExecutionBasis(r.workShiftBasis) ||
644
+ (kind === 'equipment-period' && Date.parse(r.workShiftBasis.businessTime) !== Date.parse(String(r.from))) ||
645
+ (kind === 'task' && (r.startTime ?? r.endTime) !== undefined && Date.parse(r.workShiftBasis.businessTime) !== Date.parse(String(r.startTime ?? r.endTime)))) {
646
+ errors.push(kind + '.workShiftBasis: invalid pinned shift evidence');
647
+ }
648
+ else
649
+ data.workShiftBasis = structuredClone(r.workShiftBasis);
650
+ }
625
651
  if (kind === 'test' && r.specificationBasis !== undefined && !isTestSpecificationBasis(r.specificationBasis)) {
626
652
  errors.push('test.specificationBasis: invalid pinned specification evidence');
627
653
  }
654
+ if (kind === 'order' && r.materialBasis !== undefined) {
655
+ const bases = r.materialBasis;
656
+ if (!Array.isArray(bases) || !bases.length || bases.length > 1000 || !bases.every(isMaterialExecutionBasis) ||
657
+ new Set(bases.map(b => b.material.id)).size !== bases.length ||
658
+ (r.gtin !== undefined && !bases.some(b => b.material.id === r.gtin)) ||
659
+ (isRecipeExecutionBasis(r.recipeBasis) && [...r.recipeBasis.recipe.inputs, ...r.recipeBasis.recipe.outputs].some(line => !bases.some(b => b.material.id === line.material))))
660
+ errors.push('order.materialBasis: invalid pinned material evidence');
661
+ }
628
662
  if (kind === 'order' && r.recipeBasis !== undefined && (!isRecipeExecutionBasis(r.recipeBasis) ||
629
663
  (r.recipeKey !== undefined && r.recipeKey !== r.recipeBasis.recipe.key))) {
630
664
  errors.push('order.recipeBasis: invalid pinned recipe evidence');
@@ -0,0 +1,40 @@
1
+ /** Source-signed shift evidence, not a mutable calendar or an activation command. */
2
+ export interface WorkShiftExecutionBasis {
3
+ basisId: string;
4
+ arrangementId: string;
5
+ revisionId: string;
6
+ revisionNumber: number;
7
+ planId: string;
8
+ /** Opaque source digest. Authentication and digest verification belong to the producer/transport. */
9
+ contentHash: string;
10
+ businessTime: string;
11
+ timezone: string;
12
+ shifts: {
13
+ name: string;
14
+ description?: string;
15
+ fromDate: number;
16
+ fromTime: string;
17
+ toDate: number;
18
+ toTime: string;
19
+ daysOfWeek: string;
20
+ }[];
21
+ /** Attribution captured at businessTime; never recomputed against today's calendar. */
22
+ workDate: string;
23
+ shiftName?: string;
24
+ occurrence?: {
25
+ from: string;
26
+ to: string;
27
+ };
28
+ }
29
+ export declare function isWorkShiftExecutionBasis(value: unknown): value is WorkShiftExecutionBasis;
30
+ /** Journal readers can inspect the captured attribution without a current master lookup. */
31
+ export declare function workShiftAttribution(value: unknown): {
32
+ workDate: string;
33
+ shiftName: string | undefined;
34
+ timezone: string;
35
+ revisionNumber: number;
36
+ occurrence: {
37
+ from: string;
38
+ to: string;
39
+ } | undefined;
40
+ };
@@ -0,0 +1,49 @@
1
+ const instant = (value) => typeof value === 'string' && /(?:Z|[+-]\d{2}:\d{2})$/.test(value) && Number.isFinite(Date.parse(value));
2
+ const nonempty = (value) => typeof value === 'string' && !!value.trim();
3
+ const clock = (value) => typeof value === 'string' && /^(?:[01]\d|2[0-3]):[0-5]\d$/.test(value);
4
+ export function isWorkShiftExecutionBasis(value) {
5
+ if (!value || typeof value !== 'object' || Array.isArray(value))
6
+ return false;
7
+ const b = value;
8
+ if (![b.basisId, b.arrangementId, b.revisionId, b.planId, b.contentHash].every(nonempty) ||
9
+ !Number.isSafeInteger(b.revisionNumber) || b.revisionNumber < 1 || !instant(b.businessTime) || !nonempty(b.timezone))
10
+ return false;
11
+ try {
12
+ new Intl.DateTimeFormat('en', { timeZone: b.timezone }).format(0);
13
+ }
14
+ catch {
15
+ return false;
16
+ }
17
+ if (typeof b.workDate !== 'string' || !/^\d{4}-\d{2}-\d{2}$/.test(b.workDate) ||
18
+ !Number.isFinite(Date.parse(b.workDate)) || new Date(b.workDate).toISOString().slice(0, 10) !== b.workDate)
19
+ return false;
20
+ if (!Array.isArray(b.shifts) || !b.shifts.length || b.shifts.length > 64)
21
+ return false;
22
+ const names = new Set();
23
+ for (const s of b.shifts) {
24
+ if (!s || typeof s !== 'object' || !nonempty(s.name) || names.has(s.name) ||
25
+ (s.description !== undefined && typeof s.description !== 'string') ||
26
+ ![-1, 0, 1].includes(s.fromDate) || ![-1, 0, 1].includes(s.toDate) || !clock(s.fromTime) || !clock(s.toTime) ||
27
+ typeof s.daysOfWeek !== 'string' || !/^(?:[0-6](?:,[0-6])*)?$/.test(s.daysOfWeek))
28
+ return false;
29
+ const minutes = (time) => Number(time.slice(0, 2)) * 60 + Number(time.slice(3));
30
+ const duration = (s.toDate - s.fromDate) * 1440 + minutes(s.toTime) - minutes(s.fromTime);
31
+ if (duration <= 0 || duration > 1440)
32
+ return false;
33
+ names.add(s.name);
34
+ }
35
+ if (b.shiftName === undefined)
36
+ return b.occurrence === undefined;
37
+ if (!nonempty(b.shiftName) || !names.has(b.shiftName) || !b.occurrence ||
38
+ !instant(b.occurrence.from) || !instant(b.occurrence.to))
39
+ return false;
40
+ const at = Date.parse(b.businessTime);
41
+ return Date.parse(b.occurrence.from) <= at && at < Date.parse(b.occurrence.to);
42
+ }
43
+ /** Journal readers can inspect the captured attribution without a current master lookup. */
44
+ export function workShiftAttribution(value) {
45
+ if (!isWorkShiftExecutionBasis(value))
46
+ throw new Error('Invalid pinned work shift evidence');
47
+ return { workDate: value.workDate, shiftName: value.shiftName, timezone: value.timezone,
48
+ revisionNumber: value.revisionNumber, occurrence: value.occurrence ? { ...value.occurrence } : undefined };
49
+ }
@@ -170,6 +170,7 @@ __export(index_exports, {
170
170
  isFailureStatus: () => isFailureStatus,
171
171
  isFlowOrder: () => isFlowOrder,
172
172
  isMasterDataRecord: () => isMasterDataRecord,
173
+ isMaterialExecutionBasis: () => isMaterialExecutionBasis,
173
174
  isOperationalAttentionV1: () => isOperationalAttentionV1,
174
175
  isOperationalRecord: () => isOperationalRecord,
175
176
  isOrderTerminal: () => isOrderTerminal,
@@ -180,6 +181,7 @@ __export(index_exports, {
180
181
  isTransformationRecord: () => isTransformationRecord,
181
182
  isWebhookDeliveryCode: () => isWebhookDeliveryCode,
182
183
  isWebhookSecretSegment: () => isWebhookSecretSegment,
184
+ isWorkShiftExecutionBasis: () => isWorkShiftExecutionBasis,
183
185
  isoDurationHours: () => isoDurationHours,
184
186
  itemKeyOf: () => itemKeyOf,
185
187
  judgeAgainstSpec: () => judgeAgainstSpec,
@@ -188,6 +190,7 @@ __export(index_exports, {
188
190
  localDayIndexAt: () => localDayIndexAt,
189
191
  localDayStartMs: () => localDayStartMs,
190
192
  locationStatusOf: () => locationStatusOf,
193
+ lotClassUri: () => lotClassUri,
191
194
  lotFromAttributes: () => lotFromAttributes,
192
195
  mapRecord: () => mapRecord,
193
196
  mapRecordChecked: () => mapRecordChecked,
@@ -255,6 +258,7 @@ __export(index_exports, {
255
258
  webhookSecretMissingNote: () => webhookSecretMissingNote,
256
259
  webhookSenderAction: () => webhookSenderAction,
257
260
  weekdayAt: () => weekdayAt,
261
+ workShiftAttribution: () => workShiftAttribution,
258
262
  workingHoursBetween: () => workingHoursBetween,
259
263
  workingTimeOfWeek: () => workingTimeOfWeek
260
264
  });
@@ -898,6 +902,18 @@ function isRecipeExecutionBasis(value) {
898
902
  const lines = (x) => Array.isArray(x) && x.length > 0 && x.every((row) => row && text(row.material) && typeof row.qty === "number" && Number.isFinite(row.qty) && row.qty > 0 && (row.operation === void 0 || text(row.operation)));
899
903
  return [v.basisId, v.recipeId, v.revisionId, v.planId, v.contentHash, v.businessTime].every(text) && /(?:Z|[+-]\d{2}:\d{2})$/.test(v.businessTime) && Number.isFinite(Date.parse(v.businessTime)) && !!v.recipe && text(v.recipe.key) && text(v.recipe.label) && lines(v.recipe.inputs) && lines(v.recipe.outputs) && (v.recipe.route === void 0 ? v.route === void 0 && v.recipe.inputs.every((line) => !line.operation) : text(v.recipe.route) && !!v.route && v.route.key === v.recipe.route && Array.isArray(v.route.steps) && v.route.steps.every(text) && v.recipe.inputs.every((line) => !line.operation || v.route.steps.includes(line.operation)));
900
904
  }
905
+ function isMaterialExecutionBasis(value) {
906
+ if (!value || typeof value !== "object") return false;
907
+ const v = value;
908
+ const text = (x) => typeof x === "string" && x.trim().length > 0;
909
+ let count = 0;
910
+ const properties = (rows, depth = 0) => rows === void 0 || Array.isArray(rows) && depth <= 32 && rows.every((p) => {
911
+ if (++count > 1e3 || !p || !text(p.id)) return false;
912
+ if (p.value != null && typeof p.value !== "string" && (typeof p.value !== "number" || !Number.isFinite(p.value))) return false;
913
+ return properties(p.children, depth + 1);
914
+ });
915
+ return [v.basisId, v.materialId, v.revisionId, v.planId, v.contentHash, v.businessTime].every(text) && /(?:Z|[+-]\d{2}:\d{2})$/.test(v.businessTime) && Number.isFinite(Date.parse(v.businessTime)) && Number.isInteger(v.revisionNumber) && v.revisionNumber > 0 && !!v.material && text(v.material.id) && properties(v.material.properties) && [v.material.materialClassIds, v.material.testSpecificationIds].every((ids) => ids === void 0 || Array.isArray(ids) && ids.every(text));
916
+ }
901
917
  var OP_EVENT = {
902
918
  task: "task.status",
903
919
  equipment: "equipment.status",
@@ -2999,7 +3015,12 @@ function lgtinClass(companyPrefix, itemRefAndIndicator, lot) {
2999
3015
  function parseEpc(uri) {
3000
3016
  const raw = String(uri ?? "");
3001
3017
  if (/(?:\/obj\/|:obj:)[^/:\s]+$/.test(raw)) return { scheme: "unknown", instance: true, uri: raw };
3002
- if (/(?:\/class\/|:class:)[^/:\s]+$/.test(raw)) return { scheme: "unknown", instance: false, uri: raw };
3018
+ const inHouseClass = raw.match(/(?:\/class\/|:class:)([^/:\s]+)$/);
3019
+ if (inHouseClass) {
3020
+ const at2 = inHouseClass[1].indexOf(LOT_SEPARATOR);
3021
+ const split = at2 > 0 ? decodedPair(inHouseClass[1].slice(0, at2), inHouseClass[1].slice(at2 + LOT_SEPARATOR.length)) : void 0;
3022
+ return split ? { scheme: "unknown", instance: false, item: split[0], lot: split[1], uri: raw } : { scheme: "unknown", instance: false, uri: raw };
3023
+ }
3003
3024
  const cls = raw.match(/^urn:epc:class:lgtin:(.+)$/);
3004
3025
  if (cls) {
3005
3026
  const seg = cls[1].split(".");
@@ -3031,6 +3052,14 @@ function parseEpc(uri) {
3031
3052
  }
3032
3053
  return { scheme: "unknown", instance: false, uri: raw };
3033
3054
  }
3055
+ function decodedPair(item, lot) {
3056
+ if (!lot) return void 0;
3057
+ try {
3058
+ return [decodeURIComponent(item), decodeURIComponent(lot)];
3059
+ } catch {
3060
+ return void 0;
3061
+ }
3062
+ }
3034
3063
  function gdtiUri(companyPrefix, docType, serial) {
3035
3064
  return `urn:epc:id:gdti:${companyPrefix}.${docType}.${serial}`;
3036
3065
  }
@@ -3040,6 +3069,26 @@ function objectUri(namespace, objId) {
3040
3069
  function classUri(namespace, classId) {
3041
3070
  return underNamespace(namespace, "class", classId);
3042
3071
  }
3072
+ function lotClassUri(input) {
3073
+ const item = String(input.item ?? "");
3074
+ const lot = String(input.lot ?? "");
3075
+ if (!lot) throw new Error(`lotClassUri: \uB85C\uD2B8\uAC00 \uBE44\uC5C8\uB2E4 \u2014 \uB85C\uD2B8 \uC5C6\uB294 \uD488\uBAA9\uC740 classUri \uB85C \uBD80\uB978\uB2E4 (item=${item})`);
3076
+ if (input.gtin !== void 0) {
3077
+ const [prefix, ref, ...rest] = String(input.gtin).split(".");
3078
+ if (!prefix || !ref || rest.length) {
3079
+ throw new Error(`lotClassUri: gtin \uC740 'CompanyPrefix.ItemRefAndIndicator' \uC5EC\uC57C \uD55C\uB2E4: ${input.gtin}`);
3080
+ }
3081
+ const uri = lgtinClass(prefix, ref, lot);
3082
+ const wrong = gs1KeyDigitViolation(uri);
3083
+ if (wrong) throw new Error(`lotClassUri: ${wrong}`);
3084
+ return uri;
3085
+ }
3086
+ if (!item) throw new Error(`lotClassUri: \uD488\uBC88\uC774 \uBE44\uC5C8\uB2E4 (lot=${lot})`);
3087
+ const enc = (v) => v.replace(LOT_COMPONENT_BREAKING, (c) => PERCENT_ENCODED[c]);
3088
+ return joinUnderNamespace(input.namespace, "class", `${enc(item)}${LOT_SEPARATOR}${enc(lot)}`);
3089
+ }
3090
+ var LOT_SEPARATOR = ";lot=";
3091
+ var LOT_COMPONENT_BREAKING = /[%/:?# ;]/g;
3043
3092
  function bizTransactionUri(namespace, transId) {
3044
3093
  return underNamespace(namespace, "bt", transId);
3045
3094
  }
@@ -3050,14 +3099,18 @@ var PERCENT_ENCODED = {
3050
3099
  ":": "%3A",
3051
3100
  "?": "%3F",
3052
3101
  "#": "%23",
3053
- " ": "%20"
3102
+ " ": "%20",
3103
+ /* 로트 클래스의 가르는 글자 — `lotClassUri` 만 쓴다(§`LOT_COMPONENT_BREAKING`). 표는 한 벌이다. */
3104
+ ";": "%3B"
3054
3105
  };
3055
3106
  function underNamespace(namespace, marker, id) {
3056
- const ns = namespace?.trim();
3057
- if (!ns) return void 0;
3058
3107
  const raw = String(id);
3059
3108
  if (!raw) return void 0;
3060
- const v = raw.replace(STRUCTURE_BREAKING, (c) => PERCENT_ENCODED[c]);
3109
+ return joinUnderNamespace(namespace, marker, raw.replace(STRUCTURE_BREAKING, (c) => PERCENT_ENCODED[c]));
3110
+ }
3111
+ function joinUnderNamespace(namespace, marker, v) {
3112
+ const ns = namespace?.trim();
3113
+ if (!ns) return void 0;
3061
3114
  if (/^https?:\/\/[^/\s]+/.test(ns)) return `${ns.replace(/\/+$/, "")}/${marker}/${v}`;
3062
3115
  if (/^urn:epc(global)?:/.test(ns)) return void 0;
3063
3116
  if (/^urn:[^:\s]+/.test(ns)) return `${ns.replace(/:+$/, "")}:${marker}:${v}`;
@@ -3535,6 +3588,45 @@ function readEpochMs(raw) {
3535
3588
  return Number.isNaN(at2) ? void 0 : at2;
3536
3589
  }
3537
3590
 
3591
+ // src/work-shift-basis.ts
3592
+ var instant = (value) => typeof value === "string" && /(?:Z|[+-]\d{2}:\d{2})$/.test(value) && Number.isFinite(Date.parse(value));
3593
+ var nonempty = (value) => typeof value === "string" && !!value.trim();
3594
+ var clock = (value) => typeof value === "string" && /^(?:[01]\d|2[0-3]):[0-5]\d$/.test(value);
3595
+ function isWorkShiftExecutionBasis(value) {
3596
+ if (!value || typeof value !== "object" || Array.isArray(value)) return false;
3597
+ const b = value;
3598
+ if (![b.basisId, b.arrangementId, b.revisionId, b.planId, b.contentHash].every(nonempty) || !Number.isSafeInteger(b.revisionNumber) || b.revisionNumber < 1 || !instant(b.businessTime) || !nonempty(b.timezone)) return false;
3599
+ try {
3600
+ new Intl.DateTimeFormat("en", { timeZone: b.timezone }).format(0);
3601
+ } catch {
3602
+ return false;
3603
+ }
3604
+ if (typeof b.workDate !== "string" || !/^\d{4}-\d{2}-\d{2}$/.test(b.workDate) || !Number.isFinite(Date.parse(b.workDate)) || new Date(b.workDate).toISOString().slice(0, 10) !== b.workDate) return false;
3605
+ if (!Array.isArray(b.shifts) || !b.shifts.length || b.shifts.length > 64) return false;
3606
+ const names = /* @__PURE__ */ new Set();
3607
+ for (const s of b.shifts) {
3608
+ if (!s || typeof s !== "object" || !nonempty(s.name) || names.has(s.name) || s.description !== void 0 && typeof s.description !== "string" || ![-1, 0, 1].includes(s.fromDate) || ![-1, 0, 1].includes(s.toDate) || !clock(s.fromTime) || !clock(s.toTime) || typeof s.daysOfWeek !== "string" || !/^(?:[0-6](?:,[0-6])*)?$/.test(s.daysOfWeek)) return false;
3609
+ const minutes = (time) => Number(time.slice(0, 2)) * 60 + Number(time.slice(3));
3610
+ const duration = (s.toDate - s.fromDate) * 1440 + minutes(s.toTime) - minutes(s.fromTime);
3611
+ if (duration <= 0 || duration > 1440) return false;
3612
+ names.add(s.name);
3613
+ }
3614
+ if (b.shiftName === void 0) return b.occurrence === void 0;
3615
+ if (!nonempty(b.shiftName) || !names.has(b.shiftName) || !b.occurrence || !instant(b.occurrence.from) || !instant(b.occurrence.to)) return false;
3616
+ const at2 = Date.parse(b.businessTime);
3617
+ return Date.parse(b.occurrence.from) <= at2 && at2 < Date.parse(b.occurrence.to);
3618
+ }
3619
+ function workShiftAttribution(value) {
3620
+ if (!isWorkShiftExecutionBasis(value)) throw new Error("Invalid pinned work shift evidence");
3621
+ return {
3622
+ workDate: value.workDate,
3623
+ shiftName: value.shiftName,
3624
+ timezone: value.timezone,
3625
+ revisionNumber: value.revisionNumber,
3626
+ occurrence: value.occurrence ? { ...value.occurrence } : void 0
3627
+ };
3628
+ }
3629
+
3538
3630
  // src/operational-ingest.ts
3539
3631
  function shapeErrors(where, row, shape) {
3540
3632
  if (!shape) return [];
@@ -3603,7 +3695,8 @@ var SPECS = {
3603
3695
  startTime: "string",
3604
3696
  endTime: "string",
3605
3697
  materialActual: "object[]",
3606
- recordTime: "string"
3698
+ recordTime: "string",
3699
+ workShiftBasis: "object"
3607
3700
  },
3608
3701
  /*
3609
3702
  * **자재 줄의 안쪽** — 계약의 `MaterialActual` 그대로다.
@@ -3619,6 +3712,11 @@ var SPECS = {
3619
3712
  * 물려받으면 단위를 모르는 현장의 사실이 통째로 거절된다.
3620
3713
  */
3621
3714
  shapes: {
3715
+ workShiftBasis: {
3716
+ required: ["basisId", "arrangementId", "revisionId", "revisionNumber", "planId", "contentHash", "businessTime", "timezone", "shifts", "workDate"],
3717
+ fields: { basisId: "string", arrangementId: "string", revisionId: "string", revisionNumber: "number", planId: "string", contentHash: "string", businessTime: "string", timezone: "string", workDate: "string" }
3718
+ // Full nested content and selected occurrence are checked by isWorkShiftExecutionBasis below.
3719
+ },
3622
3720
  materialActual: {
3623
3721
  required: ["definitionId", "use"],
3624
3722
  fields: { definitionId: "string", lotId: "string", quantity: "number", uom: "string" },
@@ -3745,13 +3843,19 @@ var SPECS = {
3745
3843
  * 새 어휘가 아니다 — 계약이 `recipeKey` 를 네 자리에서 이미 쓴다. 오더 관측에만 자리가 없었다.
3746
3844
  */
3747
3845
  recipeKey: "string",
3748
- recipeBasis: "object"
3846
+ recipeBasis: "object",
3847
+ materialBasis: "object[]"
3749
3848
  },
3750
3849
  /*
3751
3850
  * 확보분의 안쪽을 본다 — 열쇠와 수 둘이다(§`AllocatedQuantity`). 안 보면 틀린 이름이 조용히
3752
3851
  * 지나가고(`epcs`·`quantity` 따위), 미러는 잡힌 수를 0 으로 읽는다.
3753
3852
  */
3754
3853
  shapes: {
3854
+ materialBasis: {
3855
+ required: ["basisId", "materialId", "revisionId", "revisionNumber", "planId", "contentHash", "businessTime", "material"],
3856
+ fields: { basisId: "string", materialId: "string", revisionId: "string", revisionNumber: "number", planId: "string", contentHash: "string", businessTime: "string" }
3857
+ // Recursive material properties and reference lists are checked by isMaterialExecutionBasis.
3858
+ },
3755
3859
  recipeBasis: {
3756
3860
  required: ["basisId", "recipeId", "revisionId", "planId", "contentHash", "businessTime", "recipe"],
3757
3861
  fields: { basisId: "string", recipeId: "string", revisionId: "string", planId: "string", contentHash: "string", businessTime: "string" }
@@ -3837,7 +3941,14 @@ var SPECS = {
3837
3941
  /* 사람이 정한 사유 — 없을 수 있다(적지 않은 것과 사유가 없는 것은 다르므로 지어내지 않는다). */
3838
3942
  reasonCode: "string",
3839
3943
  decidedBy: "string",
3840
- recordTime: "string"
3944
+ recordTime: "string",
3945
+ workShiftBasis: "object"
3946
+ },
3947
+ shapes: {
3948
+ workShiftBasis: {
3949
+ required: ["basisId", "arrangementId", "revisionId", "revisionNumber", "planId", "contentHash", "businessTime", "timezone", "shifts", "workDate"],
3950
+ fields: { basisId: "string", arrangementId: "string", revisionId: "string", revisionNumber: "number", planId: "string", contentHash: "string", businessTime: "string", timezone: "string", workDate: "string" }
3951
+ }
3841
3952
  },
3842
3953
  enums: { status: EQUIPMENT_STATUS2 }
3843
3954
  },
@@ -4103,9 +4214,19 @@ function ingestOperationalRecords(records, opts) {
4103
4214
  }
4104
4215
  }
4105
4216
  }
4217
+ if ((kind === "task" || kind === "equipment-period") && r.workShiftBasis !== void 0) {
4218
+ if (!isWorkShiftExecutionBasis(r.workShiftBasis) || kind === "equipment-period" && Date.parse(r.workShiftBasis.businessTime) !== Date.parse(String(r.from)) || kind === "task" && (r.startTime ?? r.endTime) !== void 0 && Date.parse(r.workShiftBasis.businessTime) !== Date.parse(String(r.startTime ?? r.endTime))) {
4219
+ errors.push(kind + ".workShiftBasis: invalid pinned shift evidence");
4220
+ } else data.workShiftBasis = structuredClone(r.workShiftBasis);
4221
+ }
4106
4222
  if (kind === "test" && r.specificationBasis !== void 0 && !isTestSpecificationBasis(r.specificationBasis)) {
4107
4223
  errors.push("test.specificationBasis: invalid pinned specification evidence");
4108
4224
  }
4225
+ if (kind === "order" && r.materialBasis !== void 0) {
4226
+ const bases = r.materialBasis;
4227
+ if (!Array.isArray(bases) || !bases.length || bases.length > 1e3 || !bases.every(isMaterialExecutionBasis) || new Set(bases.map((b) => b.material.id)).size !== bases.length || r.gtin !== void 0 && !bases.some((b) => b.material.id === r.gtin) || isRecipeExecutionBasis(r.recipeBasis) && [...r.recipeBasis.recipe.inputs, ...r.recipeBasis.recipe.outputs].some((line) => !bases.some((b) => b.material.id === line.material)))
4228
+ errors.push("order.materialBasis: invalid pinned material evidence");
4229
+ }
4109
4230
  if (kind === "order" && r.recipeBasis !== void 0 && (!isRecipeExecutionBasis(r.recipeBasis) || r.recipeKey !== void 0 && r.recipeKey !== r.recipeBasis.recipe.key)) {
4110
4231
  errors.push("order.recipeBasis: invalid pinned recipe evidence");
4111
4232
  }
@@ -4927,6 +5048,7 @@ function nonEmpty(value) {
4927
5048
  isFailureStatus,
4928
5049
  isFlowOrder,
4929
5050
  isMasterDataRecord,
5051
+ isMaterialExecutionBasis,
4930
5052
  isOperationalAttentionV1,
4931
5053
  isOperationalRecord,
4932
5054
  isOrderTerminal,
@@ -4937,6 +5059,7 @@ function nonEmpty(value) {
4937
5059
  isTransformationRecord,
4938
5060
  isWebhookDeliveryCode,
4939
5061
  isWebhookSecretSegment,
5062
+ isWorkShiftExecutionBasis,
4940
5063
  isoDurationHours,
4941
5064
  itemKeyOf,
4942
5065
  judgeAgainstSpec,
@@ -4945,6 +5068,7 @@ function nonEmpty(value) {
4945
5068
  localDayIndexAt,
4946
5069
  localDayStartMs,
4947
5070
  locationStatusOf,
5071
+ lotClassUri,
4948
5072
  lotFromAttributes,
4949
5073
  mapRecord,
4950
5074
  mapRecordChecked,
@@ -5012,6 +5136,7 @@ function nonEmpty(value) {
5012
5136
  webhookSecretMissingNote,
5013
5137
  webhookSenderAction,
5014
5138
  weekdayAt,
5139
+ workShiftAttribution,
5015
5140
  workingHoursBetween,
5016
5141
  workingTimeOfWeek
5017
5142
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@operato/ops-contract",
3
- "version": "0.9.32",
3
+ "version": "0.9.34",
4
4
  "description": "Operations domain contract — the standard vocabulary that producers and readers agree on (EPCIS 2.0/GS1, ISA-95, IEC 61850/ISO 50001). Types, guards, validation. No state, no engine.",
5
5
  "type": "module",
6
6
  "main": "./dist-cjs/index.cjs",