@operato/ops-contract 0.9.41 → 0.9.42
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/dist/epcis.d.ts +23 -0
- package/dist/epcis.js +47 -1
- package/dist/gs1.d.ts +69 -0
- package/dist/gs1.js +261 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/lot-lineage.d.ts +50 -0
- package/dist/lot-lineage.js +76 -0
- package/dist/wms-profile.d.ts +20 -0
- package/dist/wms-profile.js +21 -0
- package/dist-cjs/index.cjs +357 -95
- package/package.json +1 -1
package/dist/epcis.d.ts
CHANGED
|
@@ -67,6 +67,14 @@ export declare const DISP: {
|
|
|
67
67
|
*/
|
|
68
68
|
readonly conformant: "urn:epcglobal:cbv:disp:conformant";
|
|
69
69
|
readonly non_conformant: "urn:epcglobal:cbv:disp:non_conformant";
|
|
70
|
+
/**
|
|
71
|
+
* **Sent back** — CBV `returned`. Primary source: the CBV ontology (gs1/EPCIS `Ontology/CBV.ttl`, versionInfo 2.0,
|
|
72
|
+
* `cbv:Disp-returned`, read 2026-10-23): "Object has been sent or brought back for various reasons. It may or may not
|
|
73
|
+
* be sellable." It is what goods going back to their supplier carry when they leave (`RETURN_TO_SUPPLIER`), and what
|
|
74
|
+
* a customer's return may carry when it arrives. Added for the warehouse's return to supplier (operato-application
|
|
75
|
+
* ADR-0154 decision 2, ruled: the words before the document).
|
|
76
|
+
*/
|
|
77
|
+
readonly returned: "urn:epcglobal:cbv:disp:returned";
|
|
70
78
|
};
|
|
71
79
|
/**
|
|
72
80
|
* **The one namespace this contract's own vocabulary stands under** — for a term a standard does not have.
|
|
@@ -422,6 +430,21 @@ export declare function parseEpc(uri: string): ParsedEpc;
|
|
|
422
430
|
* 그 밖(품목 클래스 · 개체 · 모르는 모양) → 원문 그대로 — 추측해서 묶지 않는다
|
|
423
431
|
*/
|
|
424
432
|
export declare function itemClassOf(uri: string | undefined): string | undefined;
|
|
433
|
+
/**
|
|
434
|
+
* **이 클래스가 가리키는 품목의 이름** — ISA-95 `MaterialDefinition` 의 ID(기준정보 `ops-master` 의 품목 이름).
|
|
435
|
+
*
|
|
436
|
+
* ── 왜 `itemClassOf` 와 따로인가 (2026-10-23, ADR-0149 Q4) ─────────────────────
|
|
437
|
+
* `itemClassOf` 는 **클래스**를 낸다 — 사내 품목은 `<ns>/class/<품번>` 이다. 기준정보의 품목 이름은 GTIN 품목이면
|
|
438
|
+
* 그 패턴이지만 사내 품목이면 **품번**이다. 재고 클래스로 품목을 찾는 곳(plant 반납 · 인계의 `lotOfClass`, 창고
|
|
439
|
+
* 입고 검수)이 각자 이 규칙을 적으면 둘이 갈린다. 그래서 여기 한 곳.
|
|
440
|
+
*
|
|
441
|
+
* LGTIN → `urn:epc:idpat:sgtin:P.R.*` (GTIN 품목의 이름은 그 패턴)
|
|
442
|
+
* GTIN 품목 패턴 `urn:epc:idpat:sgtin:P.R.*` → 그대로
|
|
443
|
+
* 사내 로트 클래스 · 사내 품목 클래스 → 품번(한 번 복호화한 것)
|
|
444
|
+
* 개체(SGTIN · SSCC · `/obj/` …) → `undefined` — 개체는 품목이 아니다
|
|
445
|
+
* 그 밖(모르는 모양) → 원문 그대로 — 품목 이름이 그 글자일 수 있다(`itemClassOf` 와 같다)
|
|
446
|
+
*/
|
|
447
|
+
export declare function materialDefinitionIdOf(epcClass: string | undefined): string | undefined;
|
|
425
448
|
/**
|
|
426
449
|
* **이 품목 클래스의 그 로트** — `itemClassOf` 의 반대 방향. 시뮬의 도착 생성기처럼 품목 클래스만 들고 있는 곳이 부른다.
|
|
427
450
|
*
|
package/dist/epcis.js
CHANGED
|
@@ -75,7 +75,15 @@ export const DISP = {
|
|
|
75
75
|
* 그때 열되, **판정 자체는 여기서 끝난다.**
|
|
76
76
|
*/
|
|
77
77
|
conformant: 'urn:epcglobal:cbv:disp:conformant',
|
|
78
|
-
non_conformant: 'urn:epcglobal:cbv:disp:non_conformant'
|
|
78
|
+
non_conformant: 'urn:epcglobal:cbv:disp:non_conformant',
|
|
79
|
+
/**
|
|
80
|
+
* **Sent back** — CBV `returned`. Primary source: the CBV ontology (gs1/EPCIS `Ontology/CBV.ttl`, versionInfo 2.0,
|
|
81
|
+
* `cbv:Disp-returned`, read 2026-10-23): "Object has been sent or brought back for various reasons. It may or may not
|
|
82
|
+
* be sellable." It is what goods going back to their supplier carry when they leave (`RETURN_TO_SUPPLIER`), and what
|
|
83
|
+
* a customer's return may carry when it arrives. Added for the warehouse's return to supplier (operato-application
|
|
84
|
+
* ADR-0154 decision 2, ruled: the words before the document).
|
|
85
|
+
*/
|
|
86
|
+
returned: 'urn:epcglobal:cbv:disp:returned'
|
|
79
87
|
};
|
|
80
88
|
/**
|
|
81
89
|
* **The one namespace this contract's own vocabulary stands under** — for a term a standard does not have.
|
|
@@ -323,6 +331,44 @@ export function itemClassOf(uri) {
|
|
|
323
331
|
}
|
|
324
332
|
return parsed.uri;
|
|
325
333
|
}
|
|
334
|
+
/**
|
|
335
|
+
* **이 클래스가 가리키는 품목의 이름** — ISA-95 `MaterialDefinition` 의 ID(기준정보 `ops-master` 의 품목 이름).
|
|
336
|
+
*
|
|
337
|
+
* ── 왜 `itemClassOf` 와 따로인가 (2026-10-23, ADR-0149 Q4) ─────────────────────
|
|
338
|
+
* `itemClassOf` 는 **클래스**를 낸다 — 사내 품목은 `<ns>/class/<품번>` 이다. 기준정보의 품목 이름은 GTIN 품목이면
|
|
339
|
+
* 그 패턴이지만 사내 품목이면 **품번**이다. 재고 클래스로 품목을 찾는 곳(plant 반납 · 인계의 `lotOfClass`, 창고
|
|
340
|
+
* 입고 검수)이 각자 이 규칙을 적으면 둘이 갈린다. 그래서 여기 한 곳.
|
|
341
|
+
*
|
|
342
|
+
* LGTIN → `urn:epc:idpat:sgtin:P.R.*` (GTIN 품목의 이름은 그 패턴)
|
|
343
|
+
* GTIN 품목 패턴 `urn:epc:idpat:sgtin:P.R.*` → 그대로
|
|
344
|
+
* 사내 로트 클래스 · 사내 품목 클래스 → 품번(한 번 복호화한 것)
|
|
345
|
+
* 개체(SGTIN · SSCC · `/obj/` …) → `undefined` — 개체는 품목이 아니다
|
|
346
|
+
* 그 밖(모르는 모양) → 원문 그대로 — 품목 이름이 그 글자일 수 있다(`itemClassOf` 와 같다)
|
|
347
|
+
*/
|
|
348
|
+
export function materialDefinitionIdOf(epcClass) {
|
|
349
|
+
const raw = epcClass?.trim();
|
|
350
|
+
if (!raw)
|
|
351
|
+
return undefined;
|
|
352
|
+
const parsed = parseEpc(raw);
|
|
353
|
+
if (parsed.instance)
|
|
354
|
+
return undefined;
|
|
355
|
+
if (parsed.scheme === 'lgtin' && parsed.gtinKey) {
|
|
356
|
+
const [companyPrefix, itemRef] = parsed.gtinKey.split('.');
|
|
357
|
+
return sgtinClass(companyPrefix, itemRef);
|
|
358
|
+
}
|
|
359
|
+
if (parsed.item !== undefined)
|
|
360
|
+
return parsed.item;
|
|
361
|
+
const inHouse = /(?:\/class\/|:class:)([^/:\s]+)$/.exec(raw);
|
|
362
|
+
if (inHouse) {
|
|
363
|
+
try {
|
|
364
|
+
return decodeURIComponent(inHouse[1]);
|
|
365
|
+
}
|
|
366
|
+
catch {
|
|
367
|
+
/* 우리가 만든 글자가 아니어서 뜯을 수 없으면 원문 그대로 둔다. */
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
return raw;
|
|
371
|
+
}
|
|
326
372
|
/**
|
|
327
373
|
* **이 품목 클래스의 그 로트** — `itemClassOf` 의 반대 방향. 시뮬의 도착 생성기처럼 품목 클래스만 들고 있는 곳이 부른다.
|
|
328
374
|
*
|
package/dist/gs1.d.ts
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/** 우리가 쓰는 항목에 이름을 붙인다. 나머지는 코드 그대로 담는다. */
|
|
2
|
+
export interface Gs1Scan {
|
|
3
|
+
/** 물류단위 — AI 00, 검사 숫자를 포함한 18자리. */
|
|
4
|
+
sscc?: string;
|
|
5
|
+
/** 물리적 위치 — AI 414, 검사 숫자를 포함한 13자리. */
|
|
6
|
+
gln?: string;
|
|
7
|
+
/** 그 위치 안의 자리 — AI 254. */
|
|
8
|
+
glnExtension?: string;
|
|
9
|
+
/** 품목 — AI 01. `MaterialDefinition.name` 이 GTIN 이면 이 값으로 찾는다. */
|
|
10
|
+
gtin?: string;
|
|
11
|
+
/** 로트 — AI 10. */
|
|
12
|
+
lot?: string;
|
|
13
|
+
/** 일련번호 — AI 21. 있으면 낱개로 관리하는 품목이다. */
|
|
14
|
+
serial?: string;
|
|
15
|
+
/** 사용기한 — AI 17. `YYMMDD` 원문 그대로 둔다(날짜로 바꾸는 것은 읽는 쪽 일이다). */
|
|
16
|
+
useBy?: string;
|
|
17
|
+
/** 수량 — AI 30. */
|
|
18
|
+
count?: number;
|
|
19
|
+
/** 뜯은 모든 마디. 이름 붙인 것 말고도 온 것이 있으면 여기 남는다. */
|
|
20
|
+
elements: Record<string, string>;
|
|
21
|
+
/** 원문. 뜯기에 실패해도 잃지 않는다. */
|
|
22
|
+
raw: string;
|
|
23
|
+
}
|
|
24
|
+
export type Gs1Result = {
|
|
25
|
+
ok: true;
|
|
26
|
+
scan: Gs1Scan;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* 못 뜯었다. **짐작으로 채우지 않는다.**
|
|
30
|
+
*
|
|
31
|
+
* not-gs1 AI 로 시작하지 않는다. 사번이나 작업지시 라벨일 수 있다
|
|
32
|
+
* unterminated 가변 길이 마디 뒤에 남은 글자가 AI 가 아니다
|
|
33
|
+
* truncated 고정 길이 항목인데 자릿수가 모자란다
|
|
34
|
+
*/
|
|
35
|
+
| {
|
|
36
|
+
ok: false;
|
|
37
|
+
because: 'not-gs1' | 'unterminated' | 'truncated';
|
|
38
|
+
raw: string;
|
|
39
|
+
};
|
|
40
|
+
export declare function parseGs1(value: string): Gs1Result;
|
|
41
|
+
/**
|
|
42
|
+
* 라벨이 말하는 EPC 식별자의 **후보** — 뜯은 결과에서.
|
|
43
|
+
*
|
|
44
|
+
* AI 00 (SSCC) → `urn:epc:id:sscc:<프리픽스>.<확장+일련>`
|
|
45
|
+
* AI 01 + 10 (GTIN·로트) → `urn:epc:class:lgtin:<프리픽스>.<표시자+품목참조>.<로트>`
|
|
46
|
+
* AI 01 (GTIN) → `urn:epc:idpat:sgtin:<프리픽스>.<표시자+품목참조>.*`
|
|
47
|
+
* AI 414 (+254) → `urn:epc:id:sgln:<프리픽스>.<위치참조>.<확장, 없으면 0>`
|
|
48
|
+
*
|
|
49
|
+
* 검사 숫자가 틀린 값은 후보를 내지 않는다 — 깨진 라벨을 짐작으로 고치지 않는다. 후보는 **어느 것이 맞는지
|
|
50
|
+
* 말하지 않는다.** 저장된 식별자와 정확히 같은 것을 찾아 확정하는 일은 읽는 쪽 문이 한다(ADR-0133 2-1: GS1
|
|
51
|
+
* 결과는 보조 후보이고 그것만으로 대상을 확정하지 않는다).
|
|
52
|
+
*/
|
|
53
|
+
export declare function epcCandidatesOfGs1(scan: Pick<Gs1Scan, 'sscc' | 'gtin' | 'lot' | 'gln' | 'glnExtension'>): string[];
|
|
54
|
+
/**
|
|
55
|
+
* SSCC 식별자의 라벨 숫자 18자리(검사 숫자 포함) — 용기 라벨(AI 00)과 견줄 때. SSCC 가 아니면 `undefined`.
|
|
56
|
+
*
|
|
57
|
+
* TDS: 확장 숫자(일련 참조의 첫 자리) + 프리픽스 + 일련 참조의 나머지, 그리고 검사 숫자.
|
|
58
|
+
*/
|
|
59
|
+
export declare function ssccDigitsOf(uri: string): string | undefined;
|
|
60
|
+
/**
|
|
61
|
+
* 품목 클래스(`urn:epc:idpat:sgtin:<프리픽스>.<표시자+품목참조>.*`)의 GTIN-14 — 품목 라벨(AI 01)과 견줄 때.
|
|
62
|
+
* 그 모양이 아니면 `undefined`.
|
|
63
|
+
*/
|
|
64
|
+
export declare function gtin14OfItemClass(definitionId: string | null | undefined): string | undefined;
|
|
65
|
+
/**
|
|
66
|
+
* 품목 식별자가 말하는 GTIN-14 — 품목 클래스 모양이면 그 GTIN(`gtin14OfItemClass`), 품목 이름이 GTIN 그 자체(8 · 12 ·
|
|
67
|
+
* 13 · 14 자리)면 앞을 0 으로 채운 14자리. 라벨의 AI 01 과 견줄 때 쓴다. 어느 것도 아니면 `undefined`.
|
|
68
|
+
*/
|
|
69
|
+
export declare function gtin14OfItem(definitionId: string | null | undefined): string | undefined;
|
package/dist/gs1.js
ADDED
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
import { lgtinClass, sgtinClass } from "./epcis.js";
|
|
2
|
+
/**
|
|
3
|
+
* GS1 바코드가 낸 문자열을 뜯는다 — **순수 계산.**
|
|
4
|
+
*
|
|
5
|
+
* ── 왜 계약에 있나 (2026-10-23) ──────────────────────────────────────────────
|
|
6
|
+
* plant 의 현장 화면(스테이션)에만 있던 것을 옮겼다. 창고의 ID Lens(ADR-0133)도 라벨을 읽게 되면서 두
|
|
7
|
+
* 제품이 같은 것을 뜯게 됐고, 바코드 원문 → EPC 식별자는 `parseEpc` 와 한 줄로 이어지는 표준 지식이다
|
|
8
|
+
* (수석 아키텍트 판정). 두 방향 — 라벨 숫자 → 식별자 후보, 식별자 → 라벨 숫자 — 이 이 파일 한 곳에 있다.
|
|
9
|
+
*
|
|
10
|
+
* ── 왜 우리가 쓰나 ─────────────────────────────────────────────────────────
|
|
11
|
+
* 저장소를 다 뒤졌다. `barcode-base`·`barcode-ui` 는 바코드를 **만드는** 것이고 읽은 것을 뜯지 않는다.
|
|
12
|
+
* 계약에는 `parseEpc`(EPC URI 를 뜯는다)와 `lgtinClass`(식별자를 짓는다)가 있는데, 그 둘 사이의
|
|
13
|
+
* **바코드 원문 → 품번·로트** 자리가 비어 있다.
|
|
14
|
+
*
|
|
15
|
+
* ── 두 모양이 온다 ─────────────────────────────────────────────────────────
|
|
16
|
+
* 스캐너 설정에 따라 괄호가 붙거나 안 붙는다. 붙지 않으면 가변 길이 항목의 끝을 FNC1 이 말한다.
|
|
17
|
+
*
|
|
18
|
+
* (01)08801234567890(10)LOT-A 사람이 읽는 표기. 괄호가 마디를 가른다
|
|
19
|
+
* 0108801234567890⟨FNC1⟩10LOT-A 원문. 가변 길이 마디의 끝을 FNC1 이 알린다
|
|
20
|
+
*
|
|
21
|
+
* ── 모르면 모른다고 한다 ────────────────────────────────────────────────────
|
|
22
|
+
* 못 뜯은 것을 짐작으로 채우지 않는다. 엉뚱한 품번으로 자재가 투입되면 그 실적은 나중에 아무도 못
|
|
23
|
+
* 고치고, 계보가 조용히 틀린다. 못 뜯으면 **원문을 그대로 들고** 못 뜯었다고 말한다.
|
|
24
|
+
*/
|
|
25
|
+
/** 가변 길이 항목의 끝을 알리는 글자(그룹 구분자). */
|
|
26
|
+
const FNC1 = '\x1d';
|
|
27
|
+
/**
|
|
28
|
+
* 길이가 정해진 항목들 — 이것만 FNC1 없이 이어 붙일 수 있다.
|
|
29
|
+
*
|
|
30
|
+
* 여기 없는 AI 는 **가변 길이로 본다.** 반대로 하면(모르는 것을 고정으로 보면) 뒤엣것까지 함께 먹어
|
|
31
|
+
* 품번이 조용히 길어진다.
|
|
32
|
+
*/
|
|
33
|
+
const FIXED_LENGTH = {
|
|
34
|
+
'00': 18, // SSCC
|
|
35
|
+
'01': 14, // GTIN
|
|
36
|
+
'02': 14, // 포장 안 품목의 GTIN
|
|
37
|
+
'11': 6, // 생산일
|
|
38
|
+
'12': 6, // 지급기일
|
|
39
|
+
'13': 6, // 포장일
|
|
40
|
+
'15': 6, // 품질유지기한
|
|
41
|
+
'16': 6, // 판매기한
|
|
42
|
+
'17': 6, // 사용기한
|
|
43
|
+
'20': 2, // 제품 변형
|
|
44
|
+
'414': 13 // 물리적 위치의 GLN
|
|
45
|
+
};
|
|
46
|
+
/** 우리가 이름 붙인 가변 길이 항목들. `254` 는 GLN 확장(같은 GLN 안의 자리)이다. */
|
|
47
|
+
const KNOWN_VARIABLE = ['10', '21', '30', '254'];
|
|
48
|
+
/** 괄호 표기인가. `(01)…` 처럼 숫자 두 자리 이상을 괄호로 감쌌으면 그렇다. */
|
|
49
|
+
function isBracketed(value) {
|
|
50
|
+
return /^\(\d{2,4}\)/.test(value);
|
|
51
|
+
}
|
|
52
|
+
export function parseGs1(value) {
|
|
53
|
+
const raw = value;
|
|
54
|
+
if (!raw?.trim()) {
|
|
55
|
+
return { ok: false, because: 'not-gs1', raw };
|
|
56
|
+
}
|
|
57
|
+
const parsed = isBracketed(raw) ? fromBracketed(raw) : fromRaw(raw);
|
|
58
|
+
if (!parsed.ok) {
|
|
59
|
+
return parsed;
|
|
60
|
+
}
|
|
61
|
+
const found = parsed.elements;
|
|
62
|
+
const count = found['30'] !== undefined ? Number(found['30']) : undefined;
|
|
63
|
+
return {
|
|
64
|
+
ok: true,
|
|
65
|
+
scan: {
|
|
66
|
+
sscc: found['00'],
|
|
67
|
+
gln: found['414'],
|
|
68
|
+
glnExtension: found['254'],
|
|
69
|
+
gtin: found['01'],
|
|
70
|
+
lot: found['10'],
|
|
71
|
+
serial: found['21'],
|
|
72
|
+
useBy: found['17'],
|
|
73
|
+
/* 숫자가 아니면 담지 않는다 — `NaN` 을 수량으로 두면 더하는 쪽에서 합계가 통째로 사라진다. */
|
|
74
|
+
count: count !== undefined && Number.isFinite(count) ? count : undefined,
|
|
75
|
+
elements: found,
|
|
76
|
+
raw
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
/** `(01)08801234567890(10)LOT-A` — 괄호가 마디를 가르므로 길이표가 필요 없다. */
|
|
81
|
+
function fromBracketed(raw) {
|
|
82
|
+
const elements = {};
|
|
83
|
+
const pattern = /\((\d{2,4})\)([^(]*)/g;
|
|
84
|
+
let match;
|
|
85
|
+
let consumed = 0;
|
|
86
|
+
while ((match = pattern.exec(raw)) !== null) {
|
|
87
|
+
const ai = match[1];
|
|
88
|
+
const value = match[2].trim();
|
|
89
|
+
const fixed = FIXED_LENGTH[ai];
|
|
90
|
+
/*
|
|
91
|
+
* 길이를 아는 항목은 **정확히 그 길이여야 한다.** 괄호 표기에서는 마디의 끝을 다음 괄호가 정하므로,
|
|
92
|
+
* 값 뒤에 딴 글자가 붙어 있어도 그대로 들어온다 — `(01)08801234567890XYZ` 가 품번 17자리로 앉는다.
|
|
93
|
+
* 그러면 마스터에서 못 찾고 「모르는 품목」이 되는데, 진짜 원인은 라벨이 깨진 것이다.
|
|
94
|
+
*/
|
|
95
|
+
if (fixed !== undefined && value.length !== fixed) {
|
|
96
|
+
return { ok: false, because: value.length < fixed ? 'truncated' : 'unterminated', raw };
|
|
97
|
+
}
|
|
98
|
+
elements[ai] = value;
|
|
99
|
+
consumed = match.index + match[0].length;
|
|
100
|
+
}
|
|
101
|
+
if (!Object.keys(elements).length || consumed !== raw.length) {
|
|
102
|
+
/* 괄호 밖에 남은 글자가 있다. 어디에 붙는 값인지 모르므로 짐작하지 않는다. */
|
|
103
|
+
return { ok: false, because: 'not-gs1', raw };
|
|
104
|
+
}
|
|
105
|
+
return { ok: true, elements };
|
|
106
|
+
}
|
|
107
|
+
/** `0108801234567890` 에 FNC1 로 이어진 원문. 길이표가 마디를 가른다. */
|
|
108
|
+
function fromRaw(raw) {
|
|
109
|
+
const elements = {};
|
|
110
|
+
let rest = raw;
|
|
111
|
+
while (rest.length) {
|
|
112
|
+
/* FNC1 이 남아 있으면 버린다 — 앞 마디의 끝을 알린 것이고 그 일은 끝났다. */
|
|
113
|
+
if (rest.startsWith(FNC1)) {
|
|
114
|
+
rest = rest.slice(1);
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
const ai = aiAt(rest);
|
|
118
|
+
if (!ai) {
|
|
119
|
+
/* 뜯다가 막힌 것과 처음부터 GS1 이 아닌 것은 다른 일이다. */
|
|
120
|
+
return { ok: false, because: Object.keys(elements).length ? 'unterminated' : 'not-gs1', raw };
|
|
121
|
+
}
|
|
122
|
+
rest = rest.slice(ai.length);
|
|
123
|
+
const fixed = FIXED_LENGTH[ai];
|
|
124
|
+
if (fixed !== undefined) {
|
|
125
|
+
if (rest.length < fixed) {
|
|
126
|
+
return { ok: false, because: 'truncated', raw };
|
|
127
|
+
}
|
|
128
|
+
const value = rest.slice(0, fixed);
|
|
129
|
+
/*
|
|
130
|
+
* 길이만큼 떼었는데 그 안에 FNC1 이 들어 있다. 앞 마디가 선언한 길이보다 짧게 온 것이고, 그대로
|
|
131
|
+
* 쓰면 **구분자를 값의 일부로 삼아** 뒤엣것까지 밀린다.
|
|
132
|
+
*/
|
|
133
|
+
if (value.includes(FNC1)) {
|
|
134
|
+
return { ok: false, because: 'truncated', raw };
|
|
135
|
+
}
|
|
136
|
+
elements[ai] = value;
|
|
137
|
+
rest = rest.slice(fixed);
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
140
|
+
/*
|
|
141
|
+
* 가변 길이다. FNC1 까지가 값이고, 없으면 **끝까지**가 값이다 — 마지막 마디에는 FNC1 을 붙이지
|
|
142
|
+
* 않는 것이 표준이다. 뒤에 다른 마디가 이어졌는데 FNC1 이 없으면 우리가 가를 방법이 없고, 그때는
|
|
143
|
+
* 그 값이 길어진 채로 남는다. 스캐너가 FNC1 을 보내도록 맞추는 것이 답이다.
|
|
144
|
+
*/
|
|
145
|
+
const end = rest.indexOf(FNC1);
|
|
146
|
+
elements[ai] = end === -1 ? rest : rest.slice(0, end);
|
|
147
|
+
rest = end === -1 ? '' : rest.slice(end + 1);
|
|
148
|
+
}
|
|
149
|
+
return Object.keys(elements).length ? { ok: true, elements } : { ok: false, because: 'not-gs1', raw };
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* 맨 앞의 AI 를 집는다.
|
|
153
|
+
*
|
|
154
|
+
* AI 는 2~4 자리이고 어느 것인지는 **앞 두 자리가 정한다.** 두 자리로 아는 것을 먼저 보고, 그다음에
|
|
155
|
+
* 세 자리로 아는 것(`414` · `254`), 그다음에 네 자리를 본다. 늘리기만 하면 `30`(수량)을 `3010` 같은 것으로,
|
|
156
|
+
* `414`(위치)를 `4140` 으로 잘못 읽는다.
|
|
157
|
+
*/
|
|
158
|
+
function aiAt(rest) {
|
|
159
|
+
const two = rest.slice(0, 2);
|
|
160
|
+
if (!/^\d{2}$/.test(two)) {
|
|
161
|
+
return undefined;
|
|
162
|
+
}
|
|
163
|
+
if (FIXED_LENGTH[two] !== undefined || KNOWN_VARIABLE.includes(two)) {
|
|
164
|
+
return two;
|
|
165
|
+
}
|
|
166
|
+
const three = rest.slice(0, 3);
|
|
167
|
+
if (/^\d{3}$/.test(three) && (FIXED_LENGTH[three] !== undefined || KNOWN_VARIABLE.includes(three))) {
|
|
168
|
+
return three;
|
|
169
|
+
}
|
|
170
|
+
/* 나머지는 네 자리까지 본다 — 무게·부피처럼 마지막 자리가 소수점 자리인 것들이다. */
|
|
171
|
+
const four = rest.slice(0, 4);
|
|
172
|
+
return /^\d{4}$/.test(four) ? four : two;
|
|
173
|
+
}
|
|
174
|
+
// ── 라벨 숫자 ↔ EPC 식별자 ────────────────────────────────────────────────────
|
|
175
|
+
/** GS1 검사 숫자(mod 10, 오른쪽부터 3·1). `body` 는 검사 숫자를 뺀 숫자열. */
|
|
176
|
+
function checkDigitOf(body) {
|
|
177
|
+
const sum = [...body].reverse().reduce((total, digit, at) => total + Number(digit) * (at % 2 === 0 ? 3 : 1), 0);
|
|
178
|
+
return String((10 - (sum % 10)) % 10);
|
|
179
|
+
}
|
|
180
|
+
/** 검사 숫자까지 맞는 n 자리 숫자인가. */
|
|
181
|
+
function wellFormed(digits, length) {
|
|
182
|
+
return !!digits && digits.length === length && /^\d+$/.test(digits) && checkDigitOf(digits.slice(0, -1)) === digits.slice(-1);
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* 회사 프리픽스의 자리 수 — GS1 이 회사마다 6~12 자리로 배정하므로 **숫자만으로는 알 수 없다**(`gs1KeyDigitViolation`
|
|
186
|
+
* 이 합계만 보는 까닭과 같다). 그래서 라벨 숫자 하나는 식별자 하나가 아니라 **후보 일곱**이 된다.
|
|
187
|
+
*/
|
|
188
|
+
const PREFIX_LENGTHS = [6, 7, 8, 9, 10, 11, 12];
|
|
189
|
+
/**
|
|
190
|
+
* 라벨이 말하는 EPC 식별자의 **후보** — 뜯은 결과에서.
|
|
191
|
+
*
|
|
192
|
+
* AI 00 (SSCC) → `urn:epc:id:sscc:<프리픽스>.<확장+일련>`
|
|
193
|
+
* AI 01 + 10 (GTIN·로트) → `urn:epc:class:lgtin:<프리픽스>.<표시자+품목참조>.<로트>`
|
|
194
|
+
* AI 01 (GTIN) → `urn:epc:idpat:sgtin:<프리픽스>.<표시자+품목참조>.*`
|
|
195
|
+
* AI 414 (+254) → `urn:epc:id:sgln:<프리픽스>.<위치참조>.<확장, 없으면 0>`
|
|
196
|
+
*
|
|
197
|
+
* 검사 숫자가 틀린 값은 후보를 내지 않는다 — 깨진 라벨을 짐작으로 고치지 않는다. 후보는 **어느 것이 맞는지
|
|
198
|
+
* 말하지 않는다.** 저장된 식별자와 정확히 같은 것을 찾아 확정하는 일은 읽는 쪽 문이 한다(ADR-0133 2-1: GS1
|
|
199
|
+
* 결과는 보조 후보이고 그것만으로 대상을 확정하지 않는다).
|
|
200
|
+
*/
|
|
201
|
+
export function epcCandidatesOfGs1(scan) {
|
|
202
|
+
const out = [];
|
|
203
|
+
if (wellFormed(scan.sscc, 18)) {
|
|
204
|
+
const d = scan.sscc;
|
|
205
|
+
for (const l of PREFIX_LENGTHS)
|
|
206
|
+
out.push(`urn:epc:id:sscc:${d.slice(1, 1 + l)}.${d[0]}${d.slice(1 + l, 17)}`);
|
|
207
|
+
}
|
|
208
|
+
if (wellFormed(scan.gtin, 14)) {
|
|
209
|
+
const d = scan.gtin;
|
|
210
|
+
for (const l of PREFIX_LENGTHS) {
|
|
211
|
+
const prefix = d.slice(1, 1 + l);
|
|
212
|
+
const itemRefAndIndicator = d[0] + d.slice(1 + l, 13);
|
|
213
|
+
out.push(scan.lot ? lgtinClass(prefix, itemRefAndIndicator, scan.lot) : sgtinClass(prefix, itemRefAndIndicator));
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
if (wellFormed(scan.gln, 13)) {
|
|
217
|
+
const d = scan.gln;
|
|
218
|
+
for (const l of PREFIX_LENGTHS)
|
|
219
|
+
out.push(`urn:epc:id:sgln:${d.slice(0, l)}.${d.slice(l, 12)}.${scan.glnExtension || '0'}`);
|
|
220
|
+
}
|
|
221
|
+
return out;
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* SSCC 식별자의 라벨 숫자 18자리(검사 숫자 포함) — 용기 라벨(AI 00)과 견줄 때. SSCC 가 아니면 `undefined`.
|
|
225
|
+
*
|
|
226
|
+
* TDS: 확장 숫자(일련 참조의 첫 자리) + 프리픽스 + 일련 참조의 나머지, 그리고 검사 숫자.
|
|
227
|
+
*/
|
|
228
|
+
export function ssccDigitsOf(uri) {
|
|
229
|
+
const match = /^urn:epc:id:sscc:(\d+)\.(\d+)$/.exec(uri ?? '');
|
|
230
|
+
if (!match)
|
|
231
|
+
return undefined;
|
|
232
|
+
const [, prefix, reference] = match;
|
|
233
|
+
const body = reference[0] + prefix + reference.slice(1);
|
|
234
|
+
if (body.length !== 17)
|
|
235
|
+
return undefined;
|
|
236
|
+
return body + checkDigitOf(body);
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* 품목 클래스(`urn:epc:idpat:sgtin:<프리픽스>.<표시자+품목참조>.*`)의 GTIN-14 — 품목 라벨(AI 01)과 견줄 때.
|
|
240
|
+
* 그 모양이 아니면 `undefined`.
|
|
241
|
+
*/
|
|
242
|
+
export function gtin14OfItemClass(definitionId) {
|
|
243
|
+
const match = /^urn:epc:idpat:sgtin:(\d+)\.(\d+)\.\*$/.exec(definitionId ?? '');
|
|
244
|
+
if (!match)
|
|
245
|
+
return undefined;
|
|
246
|
+
const [, prefix, reference] = match;
|
|
247
|
+
const body = reference[0] + prefix + reference.slice(1);
|
|
248
|
+
if (body.length !== 13)
|
|
249
|
+
return undefined;
|
|
250
|
+
return body + checkDigitOf(body);
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* 품목 식별자가 말하는 GTIN-14 — 품목 클래스 모양이면 그 GTIN(`gtin14OfItemClass`), 품목 이름이 GTIN 그 자체(8 · 12 ·
|
|
254
|
+
* 13 · 14 자리)면 앞을 0 으로 채운 14자리. 라벨의 AI 01 과 견줄 때 쓴다. 어느 것도 아니면 `undefined`.
|
|
255
|
+
*/
|
|
256
|
+
export function gtin14OfItem(definitionId) {
|
|
257
|
+
const byClass = gtin14OfItemClass(definitionId);
|
|
258
|
+
if (byClass)
|
|
259
|
+
return byClass;
|
|
260
|
+
return /^(\d{8}|\d{12,14})$/.test(definitionId ?? '') ? definitionId.padStart(14, '0') : undefined;
|
|
261
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export * from './domain-definition.ts';
|
|
|
6
6
|
export * from './ems-profile.ts';
|
|
7
7
|
export * from './energy-ingest.ts';
|
|
8
8
|
export * from './epcis.ts';
|
|
9
|
+
export * from './gs1.ts';
|
|
9
10
|
export * from './order-fold.ts';
|
|
10
11
|
export * from './referenced-location.ts';
|
|
11
12
|
export * from './face2-adapter.ts';
|
|
@@ -31,3 +32,4 @@ export * from './reliability.ts';
|
|
|
31
32
|
export * from './erp.ts';
|
|
32
33
|
export * from './actuation.ts';
|
|
33
34
|
export * from './operational-attention.ts';
|
|
35
|
+
export * from './lot-lineage.ts';
|
package/dist/index.js
CHANGED
|
@@ -27,6 +27,7 @@ export * from "./domain-definition.js";
|
|
|
27
27
|
export * from "./ems-profile.js";
|
|
28
28
|
export * from "./energy-ingest.js";
|
|
29
29
|
export * from "./epcis.js";
|
|
30
|
+
export * from "./gs1.js";
|
|
30
31
|
export * from "./order-fold.js";
|
|
31
32
|
export * from "./referenced-location.js";
|
|
32
33
|
export * from "./face2-adapter.js";
|
|
@@ -54,3 +55,4 @@ export * from "./reliability.js";
|
|
|
54
55
|
export * from "./erp.js";
|
|
55
56
|
export * from "./actuation.js";
|
|
56
57
|
export * from "./operational-attention.js";
|
|
58
|
+
export * from "./lot-lineage.js";
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { MaterialLotUse } from './contract.ts';
|
|
2
|
+
import type { EpcisEvent } from './epcis.ts';
|
|
3
|
+
/** 계보 한 줄 — 나온 로트와, 들어간 로트 하나. 둘 다 클래스 식별자다. */
|
|
4
|
+
export interface LotLineageEdge {
|
|
5
|
+
lot: string;
|
|
6
|
+
input: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* 변환 사건 하나가 말하는 계보 줄. 변환이 아닌 사건은 계보를 말하지 않는다(빈 목록).
|
|
10
|
+
*
|
|
11
|
+
* - 다 쓴 입력은 **단위**로 온다(`inputEPCList`). 그 단위가 무슨 로트였는지는 사건이 아니라 그 단위를 든 쪽(재고)이
|
|
12
|
+
* 안다 — `classOfUnit` 으로 묻는다. 모르면 그 줄은 없다(지어내지 않는다).
|
|
13
|
+
* - 일부만 쓴 입력은 이미 클래스다(`inputQuantityList`).
|
|
14
|
+
* - 나온 로트는 `outputQuantityList` 의 클래스다. 산출 단위만 있고 클래스가 없으면 무엇이 생겼는지 말할 수 없다.
|
|
15
|
+
* - 같은 로트가 들어가고 나오면(재작업) 자기 자신에게 잇지 않는다.
|
|
16
|
+
*/
|
|
17
|
+
export declare function lotLineageOf(event: EpcisEvent, classOfUnit: (epc: string) => string | undefined): LotLineageEdge[];
|
|
18
|
+
/** 한 로트에 대해 아는 것 — 주인의 말이거나, 입력에서 물려받은 것. */
|
|
19
|
+
export interface InheritedLotUse {
|
|
20
|
+
use: MaterialLotUse;
|
|
21
|
+
/** 주인의 낱말 — 이 로트의 것이거나, 보류를 물려준 입력의 것. 입력이 전부 `allowed` 라 지어 낸 답이면 없다. */
|
|
22
|
+
status?: string;
|
|
23
|
+
/** 이 말이 이 로트의 것이 아니면, 물려준 입력 로트. */
|
|
24
|
+
from?: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* 한 로트를 쓸 수 있나 — 무엇으로 만들어졌는지를 걸어서.
|
|
28
|
+
*
|
|
29
|
+
* ```
|
|
30
|
+
* 주인이 이 로트를 막았다 blocked — 자기 말
|
|
31
|
+
* 입력 하나(어느 깊이든)가 막혔다 blocked — 그 입력의 말과, 어느 입력인지
|
|
32
|
+
* 주인이 다른 말을 했다 그 말
|
|
33
|
+
* 입력이 있고 전부 allowed allowed — 지어 낸 답, 주인의 낱말 없음
|
|
34
|
+
* 그 밖 undefined — 모름. allowed 로 읽지 않는다
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* 막힘이 주인의 `allowed` 보다 앞선다 — 주인은 이 로트를 낳을 때의 입력을 모를 수 있고, 그 입력이 뒤에 막혔을 수 있다.
|
|
38
|
+
* 기록된 순환(같은 길에서 이미 지난 로트)은 다시 걷지 않는다 — 더 말하는 것이 없다.
|
|
39
|
+
*/
|
|
40
|
+
export declare function inheritedLotUse(lot: string, said: ReadonlyMap<string, {
|
|
41
|
+
use: string;
|
|
42
|
+
status: string;
|
|
43
|
+
}>, inputsOf: ReadonlyMap<string, readonly string[]>, seen?: ReadonlySet<string>): InheritedLotUse | undefined;
|
|
44
|
+
/**
|
|
45
|
+
* 변환이 만든 로트의 기한 — 입력 기한 중 **가장 이른 것.** 산출은 가장 먼저 지나는 입력과 함께 지난다.
|
|
46
|
+
*
|
|
47
|
+
* 기한을 모르는 입력은 한계를 더하지 않는다(그 입력이 기한을 말하지 않은 것과 같다). 아무 입력도 기한이 없으면
|
|
48
|
+
* 산출도 없다 — 「지금」이나 0 으로 메우지 않는다(§`expiryFromAttributes` 와 같은 규율). 값은 밀리초다.
|
|
49
|
+
*/
|
|
50
|
+
export declare function inheritedExpiry(inputExpiries: readonly (number | undefined | null)[]): number | undefined;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 변환 사건 하나가 말하는 계보 줄. 변환이 아닌 사건은 계보를 말하지 않는다(빈 목록).
|
|
3
|
+
*
|
|
4
|
+
* - 다 쓴 입력은 **단위**로 온다(`inputEPCList`). 그 단위가 무슨 로트였는지는 사건이 아니라 그 단위를 든 쪽(재고)이
|
|
5
|
+
* 안다 — `classOfUnit` 으로 묻는다. 모르면 그 줄은 없다(지어내지 않는다).
|
|
6
|
+
* - 일부만 쓴 입력은 이미 클래스다(`inputQuantityList`).
|
|
7
|
+
* - 나온 로트는 `outputQuantityList` 의 클래스다. 산출 단위만 있고 클래스가 없으면 무엇이 생겼는지 말할 수 없다.
|
|
8
|
+
* - 같은 로트가 들어가고 나오면(재작업) 자기 자신에게 잇지 않는다.
|
|
9
|
+
*/
|
|
10
|
+
export function lotLineageOf(event, classOfUnit) {
|
|
11
|
+
if (event.type !== 'TransformationEvent')
|
|
12
|
+
return [];
|
|
13
|
+
const inputs = new Set();
|
|
14
|
+
for (const epc of event.inputEPCList ?? []) {
|
|
15
|
+
const lot = classOfUnit(epc);
|
|
16
|
+
if (lot)
|
|
17
|
+
inputs.add(lot);
|
|
18
|
+
}
|
|
19
|
+
for (const one of event.inputQuantityList ?? [])
|
|
20
|
+
if (one.epcClass)
|
|
21
|
+
inputs.add(one.epcClass);
|
|
22
|
+
const edges = [];
|
|
23
|
+
for (const lot of new Set((event.outputQuantityList ?? []).map(one => one.epcClass).filter(Boolean))) {
|
|
24
|
+
for (const input of inputs)
|
|
25
|
+
if (input !== lot)
|
|
26
|
+
edges.push({ lot, input });
|
|
27
|
+
}
|
|
28
|
+
return edges;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* 한 로트를 쓸 수 있나 — 무엇으로 만들어졌는지를 걸어서.
|
|
32
|
+
*
|
|
33
|
+
* ```
|
|
34
|
+
* 주인이 이 로트를 막았다 blocked — 자기 말
|
|
35
|
+
* 입력 하나(어느 깊이든)가 막혔다 blocked — 그 입력의 말과, 어느 입력인지
|
|
36
|
+
* 주인이 다른 말을 했다 그 말
|
|
37
|
+
* 입력이 있고 전부 allowed allowed — 지어 낸 답, 주인의 낱말 없음
|
|
38
|
+
* 그 밖 undefined — 모름. allowed 로 읽지 않는다
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* 막힘이 주인의 `allowed` 보다 앞선다 — 주인은 이 로트를 낳을 때의 입력을 모를 수 있고, 그 입력이 뒤에 막혔을 수 있다.
|
|
42
|
+
* 기록된 순환(같은 길에서 이미 지난 로트)은 다시 걷지 않는다 — 더 말하는 것이 없다.
|
|
43
|
+
*/
|
|
44
|
+
export function inheritedLotUse(lot, said, inputsOf, seen = new Set()) {
|
|
45
|
+
const own = said.get(lot);
|
|
46
|
+
if (own?.use === 'blocked')
|
|
47
|
+
return { use: 'blocked', status: own.status };
|
|
48
|
+
const along = new Set([...seen, lot]);
|
|
49
|
+
const words = (inputsOf.get(lot) ?? [])
|
|
50
|
+
.filter(input => !along.has(input))
|
|
51
|
+
.map(input => ({ input, word: inheritedLotUse(input, said, inputsOf, along) }));
|
|
52
|
+
const blocked = words.find(({ word }) => word?.use === 'blocked');
|
|
53
|
+
if (blocked)
|
|
54
|
+
return { use: 'blocked', ...(blocked.word.status !== undefined ? { status: blocked.word.status } : {}), from: blocked.word.from ?? blocked.input };
|
|
55
|
+
if (own?.use === 'allowed')
|
|
56
|
+
return { use: 'allowed', status: own.status };
|
|
57
|
+
if (!own && words.length && words.every(({ word }) => word?.use === 'allowed'))
|
|
58
|
+
return { use: 'allowed' };
|
|
59
|
+
return undefined;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* 변환이 만든 로트의 기한 — 입력 기한 중 **가장 이른 것.** 산출은 가장 먼저 지나는 입력과 함께 지난다.
|
|
63
|
+
*
|
|
64
|
+
* 기한을 모르는 입력은 한계를 더하지 않는다(그 입력이 기한을 말하지 않은 것과 같다). 아무 입력도 기한이 없으면
|
|
65
|
+
* 산출도 없다 — 「지금」이나 0 으로 메우지 않는다(§`expiryFromAttributes` 와 같은 규율). 값은 밀리초다.
|
|
66
|
+
*/
|
|
67
|
+
export function inheritedExpiry(inputExpiries) {
|
|
68
|
+
let earliest;
|
|
69
|
+
for (const at of inputExpiries) {
|
|
70
|
+
if (typeof at !== 'number' || !Number.isFinite(at))
|
|
71
|
+
continue;
|
|
72
|
+
if (earliest === undefined || at < earliest)
|
|
73
|
+
earliest = at;
|
|
74
|
+
}
|
|
75
|
+
return earliest;
|
|
76
|
+
}
|
package/dist/wms-profile.d.ts
CHANGED
|
@@ -41,6 +41,26 @@ export declare const BTT: {
|
|
|
41
41
|
/** Bill of Lading — the carrier's document, attached when shipping. */
|
|
42
42
|
readonly bol: "urn:epcglobal:cbv:btt:bol";
|
|
43
43
|
};
|
|
44
|
+
/**
|
|
45
|
+
* **Goods going back to their supplier** (return to vendor) — the CBV words, read in the CBV ontology itself (gs1/EPCIS
|
|
46
|
+
* `Ontology/CBV.ttl`, versionInfo 2.0, 2026-10-23), before any document of that kind was built (operato-application
|
|
47
|
+
* ADR-0154 decision 2, chief architect: the vocabulary first).
|
|
48
|
+
*
|
|
49
|
+
* - **Step: `shipping`.** CBV has no returning step. Of its 41 steps, the one for goods leaving to another party is
|
|
50
|
+
* `shipping` ("the overall process of staging_outbound, loading and departing … a final event from a shipping
|
|
51
|
+
* point"); where they go is the destination, not the step.
|
|
52
|
+
* - **Disposition: `returned`** — "Object has been sent or brought back for various reasons. It may or may not be
|
|
53
|
+
* sellable." Not `in_transit` (between two trading partners, said of goods on their way to be received) and not
|
|
54
|
+
* `disposed` (returned for disposal - a supplier that destroys them says so itself).
|
|
55
|
+
* - **Document: `rma`** — "A document issued by the seller that authorises a buyer to return merchandise". In a return
|
|
56
|
+
* to supplier the warehouse is the buyer and the supplier issues it - the same document a customer's return comes in
|
|
57
|
+
* under, seen from the other side.
|
|
58
|
+
*/
|
|
59
|
+
export declare const RETURN_TO_SUPPLIER: {
|
|
60
|
+
readonly bizStep: "urn:epcglobal:cbv:bizstep:shipping";
|
|
61
|
+
readonly disposition: "urn:epcglobal:cbv:disp:returned";
|
|
62
|
+
readonly bizTransactionType: "urn:epcglobal:cbv:btt:rma";
|
|
63
|
+
};
|
|
44
64
|
export declare const WMS_ORDER_KIND: {
|
|
45
65
|
/**
|
|
46
66
|
* Expected receipt (ASN) — what was promised to arrive, and how much of it has.
|
package/dist/wms-profile.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { DISP } from "./epcis.js";
|
|
1
2
|
// bizStep — CBV URN (wms.md §11 확정 어휘)
|
|
2
3
|
export const BIZSTEP = {
|
|
3
4
|
receiving: 'urn:epcglobal:cbv:bizstep:receiving',
|
|
@@ -53,6 +54,26 @@ export const BTT = {
|
|
|
53
54
|
/** Bill of Lading — the carrier's document, attached when shipping. */
|
|
54
55
|
bol: 'urn:epcglobal:cbv:btt:bol'
|
|
55
56
|
};
|
|
57
|
+
/**
|
|
58
|
+
* **Goods going back to their supplier** (return to vendor) — the CBV words, read in the CBV ontology itself (gs1/EPCIS
|
|
59
|
+
* `Ontology/CBV.ttl`, versionInfo 2.0, 2026-10-23), before any document of that kind was built (operato-application
|
|
60
|
+
* ADR-0154 decision 2, chief architect: the vocabulary first).
|
|
61
|
+
*
|
|
62
|
+
* - **Step: `shipping`.** CBV has no returning step. Of its 41 steps, the one for goods leaving to another party is
|
|
63
|
+
* `shipping` ("the overall process of staging_outbound, loading and departing … a final event from a shipping
|
|
64
|
+
* point"); where they go is the destination, not the step.
|
|
65
|
+
* - **Disposition: `returned`** — "Object has been sent or brought back for various reasons. It may or may not be
|
|
66
|
+
* sellable." Not `in_transit` (between two trading partners, said of goods on their way to be received) and not
|
|
67
|
+
* `disposed` (returned for disposal - a supplier that destroys them says so itself).
|
|
68
|
+
* - **Document: `rma`** — "A document issued by the seller that authorises a buyer to return merchandise". In a return
|
|
69
|
+
* to supplier the warehouse is the buyer and the supplier issues it - the same document a customer's return comes in
|
|
70
|
+
* under, seen from the other side.
|
|
71
|
+
*/
|
|
72
|
+
export const RETURN_TO_SUPPLIER = {
|
|
73
|
+
bizStep: BIZSTEP.shipping,
|
|
74
|
+
disposition: DISP.returned,
|
|
75
|
+
bizTransactionType: BTT.rma
|
|
76
|
+
};
|
|
56
77
|
/*
|
|
57
78
|
* What an order in a warehouse is for — `OrderState.kind`.
|
|
58
79
|
*
|
package/dist-cjs/index.cjs
CHANGED
|
@@ -77,6 +77,7 @@ __export(index_exports, {
|
|
|
77
77
|
REFUSED_WITHOUT_CODE: () => REFUSED_WITHOUT_CODE,
|
|
78
78
|
RESOURCE_KIND: () => RESOURCE_KIND,
|
|
79
79
|
RETIRED_VOCABULARY: () => RETIRED_VOCABULARY,
|
|
80
|
+
RETURN_TO_SUPPLIER: () => RETURN_TO_SUPPLIER,
|
|
80
81
|
SCHEDULE_STATUS: () => SCHEDULE_STATUS,
|
|
81
82
|
SIGNATURE_REJECTED_REASONS: () => SIGNATURE_REJECTED_REASONS,
|
|
82
83
|
TWIN_AXES: () => TWIN_AXES,
|
|
@@ -137,6 +138,7 @@ __export(index_exports, {
|
|
|
137
138
|
effectivityAt: () => effectivityAt,
|
|
138
139
|
electricalUpstreamOf: () => electricalUpstreamOf,
|
|
139
140
|
emptyFoldedOrders: () => emptyFoldedOrders,
|
|
141
|
+
epcCandidatesOfGs1: () => epcCandidatesOfGs1,
|
|
140
142
|
equipmentClassMembership: () => equipmentClassMembership,
|
|
141
143
|
erpCapabilityGaps: () => erpCapabilityGaps,
|
|
142
144
|
expiryFromAttributes: () => expiryFromAttributes,
|
|
@@ -148,6 +150,8 @@ __export(index_exports, {
|
|
|
148
150
|
generationFractionAt: () => generationFractionAt,
|
|
149
151
|
graiUri: () => graiUri,
|
|
150
152
|
gs1KeyDigitViolation: () => gs1KeyDigitViolation,
|
|
153
|
+
gtin14OfItem: () => gtin14OfItem,
|
|
154
|
+
gtin14OfItemClass: () => gtin14OfItemClass,
|
|
151
155
|
hierarchyOf: () => hierarchyOf,
|
|
152
156
|
homeOf: () => homeOf,
|
|
153
157
|
hourStartOf: () => hourStartOf,
|
|
@@ -165,6 +169,8 @@ __export(index_exports, {
|
|
|
165
169
|
ingestEnergyUsagePeriodRecords: () => ingestEnergyUsagePeriodRecords,
|
|
166
170
|
ingestMasterData: () => ingestMasterData,
|
|
167
171
|
ingestOperationalRecords: () => ingestOperationalRecords,
|
|
172
|
+
inheritedExpiry: () => inheritedExpiry,
|
|
173
|
+
inheritedLotUse: () => inheritedLotUse,
|
|
168
174
|
isAggregationRecord: () => isAggregationRecord,
|
|
169
175
|
isCacheableTense: () => isCacheableTense,
|
|
170
176
|
isCommandTerminal: () => isCommandTerminal,
|
|
@@ -207,8 +213,10 @@ __export(index_exports, {
|
|
|
207
213
|
lotClassOfItem: () => lotClassOfItem,
|
|
208
214
|
lotClassUri: () => lotClassUri,
|
|
209
215
|
lotFromAttributes: () => lotFromAttributes,
|
|
216
|
+
lotLineageOf: () => lotLineageOf,
|
|
210
217
|
mapRecord: () => mapRecord,
|
|
211
218
|
mapRecordChecked: () => mapRecordChecked,
|
|
219
|
+
materialDefinitionIdOf: () => materialDefinitionIdOf,
|
|
212
220
|
materialMovementKey: () => materialMovementKey,
|
|
213
221
|
meetsTests: () => meetsTests,
|
|
214
222
|
minuteOfDayAt: () => minuteOfDayAt,
|
|
@@ -227,6 +235,7 @@ __export(index_exports, {
|
|
|
227
235
|
orderFoldPolicyOf: () => orderFoldPolicyOf,
|
|
228
236
|
outsideLimit: () => outsideLimit,
|
|
229
237
|
parseEpc: () => parseEpc,
|
|
238
|
+
parseGs1: () => parseGs1,
|
|
230
239
|
parseIsoDuration: () => parseIsoDuration,
|
|
231
240
|
partitionLensLocations: () => partitionLensLocations,
|
|
232
241
|
passThroughReversible: () => passThroughReversible,
|
|
@@ -256,6 +265,7 @@ __export(index_exports, {
|
|
|
256
265
|
sgtinUri: () => sgtinUri,
|
|
257
266
|
splitFlowOrders: () => splitFlowOrders,
|
|
258
267
|
splitRelationIds: () => splitRelationIds,
|
|
268
|
+
ssccDigitsOf: () => ssccDigitsOf,
|
|
259
269
|
ssccUri: () => ssccUri,
|
|
260
270
|
standsNewOrderRow: () => standsNewOrderRow,
|
|
261
271
|
stateFieldsOf: () => stateFieldsOf,
|
|
@@ -1343,100 +1353,6 @@ function nonWorkingMsIn(calendar, fromMs, toMs, utcOffsetMinutes) {
|
|
|
1343
1353
|
return closed * 6e4;
|
|
1344
1354
|
}
|
|
1345
1355
|
|
|
1346
|
-
// src/wms-profile.ts
|
|
1347
|
-
var BIZSTEP = {
|
|
1348
|
-
receiving: "urn:epcglobal:cbv:bizstep:receiving",
|
|
1349
|
-
storing: "urn:epcglobal:cbv:bizstep:storing",
|
|
1350
|
-
picking: "urn:epcglobal:cbv:bizstep:picking",
|
|
1351
|
-
packing: "urn:epcglobal:cbv:bizstep:packing",
|
|
1352
|
-
staging_outbound: "urn:epcglobal:cbv:bizstep:staging_outbound",
|
|
1353
|
-
shipping: "urn:epcglobal:cbv:bizstep:shipping",
|
|
1354
|
-
/**
|
|
1355
|
-
* **Replenishment** — moving goods to where they are picked from. CBV has no `replenishing`; this contract
|
|
1356
|
-
* wrote one until 2026-09-24, and the closed-list test found it. CBV `stocking` is the step that means it:
|
|
1357
|
-
* "…within a location to make an object available to the customer or for order fulfilment within a DC"
|
|
1358
|
-
* (CBV ontology, `BizStep-stocking`). Ruled by the chief architect; no reader branches on the value, and
|
|
1359
|
-
* the journal keeps what it already wrote (ADR-0038).
|
|
1360
|
-
*/
|
|
1361
|
-
stocking: "urn:epcglobal:cbv:bizstep:stocking",
|
|
1362
|
-
/**
|
|
1363
|
-
* **Counted, and the book set to the count** — CBV `cycle_counting`. Primary source: the CBV ontology
|
|
1364
|
-
* (gs1/EPCIS `Ontology/CBV.ttl`, `cbv:BizStep-cycle_counting`, also served at ref.gs1.org/cbv): "Process of
|
|
1365
|
-
* counting objects within a location in order to obtain an accurate inventory for business needs other
|
|
1366
|
-
* than accounting purposes (e.g., replenishment and allocation)."
|
|
1367
|
-
*
|
|
1368
|
-
* **Only for an event somebody actually counted** (chief architect, 2026-09-24). A person correcting the
|
|
1369
|
-
* book without counting is `CBV_BIZSTEP.other` with the reason carried as a value — `epcis.ts` says why:
|
|
1370
|
-
* writing that as `cycle_counting` records a count that never happened. A count for the accounts is a
|
|
1371
|
-
* different CBV step (`stock_taking`) and is not this one.
|
|
1372
|
-
*/
|
|
1373
|
-
cycle_counting: "urn:epcglobal:cbv:bizstep:cycle_counting"
|
|
1374
|
-
};
|
|
1375
|
-
var BTT = {
|
|
1376
|
-
/** Purchase Order — the document an inbound receipt is made against. */
|
|
1377
|
-
po: "urn:epcglobal:cbv:btt:po",
|
|
1378
|
-
/** Purchase Order Confirmation — the seller's sales order. */
|
|
1379
|
-
poc: "urn:epcglobal:cbv:btt:poc",
|
|
1380
|
-
/** Despatch Advice (ASN) — announces an inbound delivery; also attached when shipping. */
|
|
1381
|
-
desadv: "urn:epcglobal:cbv:btt:desadv",
|
|
1382
|
-
/** Receiving Advice — the reply once an inbound receipt is complete. */
|
|
1383
|
-
recadv: "urn:epcglobal:cbv:btt:recadv",
|
|
1384
|
-
/** Return Merchandise Authorization — what a return is received against. */
|
|
1385
|
-
rma: "urn:epcglobal:cbv:btt:rma",
|
|
1386
|
-
/** Bill of Lading — the carrier's document, attached when shipping. */
|
|
1387
|
-
bol: "urn:epcglobal:cbv:btt:bol"
|
|
1388
|
-
};
|
|
1389
|
-
var WMS_ORDER_KIND = {
|
|
1390
|
-
/**
|
|
1391
|
-
* Expected receipt (ASN) — what was promised to arrive, and how much of it has.
|
|
1392
|
-
*
|
|
1393
|
-
* Flow metrics leave it out: the arrival both raises and fulfils it, so counting it would add a
|
|
1394
|
-
* completed order per arrival and never clear the backlog (`isFlowOrder`).
|
|
1395
|
-
*/
|
|
1396
|
-
inbound: "inbound",
|
|
1397
|
-
/** Outbound order — what the kernel's sales order is. */
|
|
1398
|
-
outbound: "outbound",
|
|
1399
|
-
/** Receipt of returned goods. */
|
|
1400
|
-
return: "return",
|
|
1401
|
-
/** Stock transfer between sites. CBV has no document type for it: carry the id without a type. */
|
|
1402
|
-
transfer: "transfer"
|
|
1403
|
-
};
|
|
1404
|
-
var WMS_RECEIVING_ORDER_KINDS = [WMS_ORDER_KIND.inbound, WMS_ORDER_KIND.return];
|
|
1405
|
-
function isFlowOrder(o) {
|
|
1406
|
-
const kind = String(o?.kind ?? "").trim();
|
|
1407
|
-
return !WMS_RECEIVING_ORDER_KINDS.includes(kind);
|
|
1408
|
-
}
|
|
1409
|
-
function splitFlowOrders(orders) {
|
|
1410
|
-
const flow = [];
|
|
1411
|
-
let receiving = 0;
|
|
1412
|
-
let kindless = 0;
|
|
1413
|
-
for (const o of orders ?? []) {
|
|
1414
|
-
const kind = String(o?.kind ?? "").trim();
|
|
1415
|
-
if (WMS_RECEIVING_ORDER_KINDS.includes(kind)) {
|
|
1416
|
-
receiving++;
|
|
1417
|
-
continue;
|
|
1418
|
-
}
|
|
1419
|
-
if (!kind) kindless++;
|
|
1420
|
-
flow.push(o);
|
|
1421
|
-
}
|
|
1422
|
-
return { flow, receiving, kindless };
|
|
1423
|
-
}
|
|
1424
|
-
var WMS_LOCATION_TYPES = ["dock", "storage", "staging", "dock-ship", "vas-station"];
|
|
1425
|
-
var WMS_LOCATION_LEVEL = {
|
|
1426
|
-
dock: "StorageZone",
|
|
1427
|
-
storage: "StorageUnit",
|
|
1428
|
-
staging: "StorageZone",
|
|
1429
|
-
"dock-ship": "StorageZone",
|
|
1430
|
-
"vas-station": "WorkCell"
|
|
1431
|
-
};
|
|
1432
|
-
var WMS_TYPES = [
|
|
1433
|
-
...WMS_LOCATION_TYPES.filter((k) => k !== "vas-station").map((k) => ({ key: k, role: "location", label: `twin.type.${k}`, standardClass: { epcis: "bizLocation" }, identity: { scheme: "gs1:SGLN" }, level: WMS_LOCATION_LEVEL[k], capabilities: ["storable"] })),
|
|
1434
|
-
{ key: "vas-station", role: "location", label: "twin.type.vas-station", standardClass: { epcis: "bizLocation", isa95: "WorkCenter" }, identity: { scheme: "gs1:SGLN" }, level: WMS_LOCATION_LEVEL["vas-station"], capabilities: ["storable", "processable"] },
|
|
1435
|
-
{ key: "forklift", role: "equipment", label: "twin.type.forklift", standardClass: { epcis: "object", iso55000: "Asset" }, identity: { scheme: "gs1:GIAI" }, capabilities: ["mobile", "operable"] },
|
|
1436
|
-
/** 유통가공 작업자·작업대 설비 — 가공을 수행하는 능동 자원(ISA-95 `Equipment`). */
|
|
1437
|
-
{ key: "packer", role: "equipment", label: "twin.type.packer", standardClass: { epcis: "object", isa95: "Equipment" }, identity: { scheme: "gs1:GIAI" }, capabilities: ["processable", "operable"] }
|
|
1438
|
-
];
|
|
1439
|
-
|
|
1440
1356
|
// src/epcis.ts
|
|
1441
1357
|
var EPCIS_CONTEXT = "https://ref.gs1.org/standards/epcis/2.0.0/epcis-context.jsonld";
|
|
1442
1358
|
var UTC_OFFSET = "+00:00";
|
|
@@ -1505,7 +1421,15 @@ var DISP = {
|
|
|
1505
1421
|
* 그때 열되, **판정 자체는 여기서 끝난다.**
|
|
1506
1422
|
*/
|
|
1507
1423
|
conformant: "urn:epcglobal:cbv:disp:conformant",
|
|
1508
|
-
non_conformant: "urn:epcglobal:cbv:disp:non_conformant"
|
|
1424
|
+
non_conformant: "urn:epcglobal:cbv:disp:non_conformant",
|
|
1425
|
+
/**
|
|
1426
|
+
* **Sent back** — CBV `returned`. Primary source: the CBV ontology (gs1/EPCIS `Ontology/CBV.ttl`, versionInfo 2.0,
|
|
1427
|
+
* `cbv:Disp-returned`, read 2026-10-23): "Object has been sent or brought back for various reasons. It may or may not
|
|
1428
|
+
* be sellable." It is what goods going back to their supplier carry when they leave (`RETURN_TO_SUPPLIER`), and what
|
|
1429
|
+
* a customer's return may carry when it arrives. Added for the warehouse's return to supplier (operato-application
|
|
1430
|
+
* ADR-0154 decision 2, ruled: the words before the document).
|
|
1431
|
+
*/
|
|
1432
|
+
returned: "urn:epcglobal:cbv:disp:returned"
|
|
1509
1433
|
};
|
|
1510
1434
|
var HATIOLAB_VOCABULARY = "https://hatiolab.com/voc/";
|
|
1511
1435
|
var PRIVATE_BIZSTEP = {
|
|
@@ -1631,6 +1555,25 @@ function itemClassOf(uri) {
|
|
|
1631
1555
|
}
|
|
1632
1556
|
return parsed.uri;
|
|
1633
1557
|
}
|
|
1558
|
+
function materialDefinitionIdOf(epcClass) {
|
|
1559
|
+
const raw = epcClass?.trim();
|
|
1560
|
+
if (!raw) return void 0;
|
|
1561
|
+
const parsed = parseEpc(raw);
|
|
1562
|
+
if (parsed.instance) return void 0;
|
|
1563
|
+
if (parsed.scheme === "lgtin" && parsed.gtinKey) {
|
|
1564
|
+
const [companyPrefix, itemRef] = parsed.gtinKey.split(".");
|
|
1565
|
+
return sgtinClass(companyPrefix, itemRef);
|
|
1566
|
+
}
|
|
1567
|
+
if (parsed.item !== void 0) return parsed.item;
|
|
1568
|
+
const inHouse = /(?:\/class\/|:class:)([^/:\s]+)$/.exec(raw);
|
|
1569
|
+
if (inHouse) {
|
|
1570
|
+
try {
|
|
1571
|
+
return decodeURIComponent(inHouse[1]);
|
|
1572
|
+
} catch {
|
|
1573
|
+
}
|
|
1574
|
+
}
|
|
1575
|
+
return raw;
|
|
1576
|
+
}
|
|
1634
1577
|
function lotClassOfItem(itemClass, lot) {
|
|
1635
1578
|
if (!itemClass) return void 0;
|
|
1636
1579
|
const idpat = /^urn:epc:idpat:sgtin:(\d+)\.(\d+)\.\*$/.exec(itemClass);
|
|
@@ -1906,6 +1849,105 @@ function validateEpcisEvent(e) {
|
|
|
1906
1849
|
return v;
|
|
1907
1850
|
}
|
|
1908
1851
|
|
|
1852
|
+
// src/wms-profile.ts
|
|
1853
|
+
var BIZSTEP = {
|
|
1854
|
+
receiving: "urn:epcglobal:cbv:bizstep:receiving",
|
|
1855
|
+
storing: "urn:epcglobal:cbv:bizstep:storing",
|
|
1856
|
+
picking: "urn:epcglobal:cbv:bizstep:picking",
|
|
1857
|
+
packing: "urn:epcglobal:cbv:bizstep:packing",
|
|
1858
|
+
staging_outbound: "urn:epcglobal:cbv:bizstep:staging_outbound",
|
|
1859
|
+
shipping: "urn:epcglobal:cbv:bizstep:shipping",
|
|
1860
|
+
/**
|
|
1861
|
+
* **Replenishment** — moving goods to where they are picked from. CBV has no `replenishing`; this contract
|
|
1862
|
+
* wrote one until 2026-09-24, and the closed-list test found it. CBV `stocking` is the step that means it:
|
|
1863
|
+
* "…within a location to make an object available to the customer or for order fulfilment within a DC"
|
|
1864
|
+
* (CBV ontology, `BizStep-stocking`). Ruled by the chief architect; no reader branches on the value, and
|
|
1865
|
+
* the journal keeps what it already wrote (ADR-0038).
|
|
1866
|
+
*/
|
|
1867
|
+
stocking: "urn:epcglobal:cbv:bizstep:stocking",
|
|
1868
|
+
/**
|
|
1869
|
+
* **Counted, and the book set to the count** — CBV `cycle_counting`. Primary source: the CBV ontology
|
|
1870
|
+
* (gs1/EPCIS `Ontology/CBV.ttl`, `cbv:BizStep-cycle_counting`, also served at ref.gs1.org/cbv): "Process of
|
|
1871
|
+
* counting objects within a location in order to obtain an accurate inventory for business needs other
|
|
1872
|
+
* than accounting purposes (e.g., replenishment and allocation)."
|
|
1873
|
+
*
|
|
1874
|
+
* **Only for an event somebody actually counted** (chief architect, 2026-09-24). A person correcting the
|
|
1875
|
+
* book without counting is `CBV_BIZSTEP.other` with the reason carried as a value — `epcis.ts` says why:
|
|
1876
|
+
* writing that as `cycle_counting` records a count that never happened. A count for the accounts is a
|
|
1877
|
+
* different CBV step (`stock_taking`) and is not this one.
|
|
1878
|
+
*/
|
|
1879
|
+
cycle_counting: "urn:epcglobal:cbv:bizstep:cycle_counting"
|
|
1880
|
+
};
|
|
1881
|
+
var BTT = {
|
|
1882
|
+
/** Purchase Order — the document an inbound receipt is made against. */
|
|
1883
|
+
po: "urn:epcglobal:cbv:btt:po",
|
|
1884
|
+
/** Purchase Order Confirmation — the seller's sales order. */
|
|
1885
|
+
poc: "urn:epcglobal:cbv:btt:poc",
|
|
1886
|
+
/** Despatch Advice (ASN) — announces an inbound delivery; also attached when shipping. */
|
|
1887
|
+
desadv: "urn:epcglobal:cbv:btt:desadv",
|
|
1888
|
+
/** Receiving Advice — the reply once an inbound receipt is complete. */
|
|
1889
|
+
recadv: "urn:epcglobal:cbv:btt:recadv",
|
|
1890
|
+
/** Return Merchandise Authorization — what a return is received against. */
|
|
1891
|
+
rma: "urn:epcglobal:cbv:btt:rma",
|
|
1892
|
+
/** Bill of Lading — the carrier's document, attached when shipping. */
|
|
1893
|
+
bol: "urn:epcglobal:cbv:btt:bol"
|
|
1894
|
+
};
|
|
1895
|
+
var RETURN_TO_SUPPLIER = {
|
|
1896
|
+
bizStep: BIZSTEP.shipping,
|
|
1897
|
+
disposition: DISP.returned,
|
|
1898
|
+
bizTransactionType: BTT.rma
|
|
1899
|
+
};
|
|
1900
|
+
var WMS_ORDER_KIND = {
|
|
1901
|
+
/**
|
|
1902
|
+
* Expected receipt (ASN) — what was promised to arrive, and how much of it has.
|
|
1903
|
+
*
|
|
1904
|
+
* Flow metrics leave it out: the arrival both raises and fulfils it, so counting it would add a
|
|
1905
|
+
* completed order per arrival and never clear the backlog (`isFlowOrder`).
|
|
1906
|
+
*/
|
|
1907
|
+
inbound: "inbound",
|
|
1908
|
+
/** Outbound order — what the kernel's sales order is. */
|
|
1909
|
+
outbound: "outbound",
|
|
1910
|
+
/** Receipt of returned goods. */
|
|
1911
|
+
return: "return",
|
|
1912
|
+
/** Stock transfer between sites. CBV has no document type for it: carry the id without a type. */
|
|
1913
|
+
transfer: "transfer"
|
|
1914
|
+
};
|
|
1915
|
+
var WMS_RECEIVING_ORDER_KINDS = [WMS_ORDER_KIND.inbound, WMS_ORDER_KIND.return];
|
|
1916
|
+
function isFlowOrder(o) {
|
|
1917
|
+
const kind = String(o?.kind ?? "").trim();
|
|
1918
|
+
return !WMS_RECEIVING_ORDER_KINDS.includes(kind);
|
|
1919
|
+
}
|
|
1920
|
+
function splitFlowOrders(orders) {
|
|
1921
|
+
const flow = [];
|
|
1922
|
+
let receiving = 0;
|
|
1923
|
+
let kindless = 0;
|
|
1924
|
+
for (const o of orders ?? []) {
|
|
1925
|
+
const kind = String(o?.kind ?? "").trim();
|
|
1926
|
+
if (WMS_RECEIVING_ORDER_KINDS.includes(kind)) {
|
|
1927
|
+
receiving++;
|
|
1928
|
+
continue;
|
|
1929
|
+
}
|
|
1930
|
+
if (!kind) kindless++;
|
|
1931
|
+
flow.push(o);
|
|
1932
|
+
}
|
|
1933
|
+
return { flow, receiving, kindless };
|
|
1934
|
+
}
|
|
1935
|
+
var WMS_LOCATION_TYPES = ["dock", "storage", "staging", "dock-ship", "vas-station"];
|
|
1936
|
+
var WMS_LOCATION_LEVEL = {
|
|
1937
|
+
dock: "StorageZone",
|
|
1938
|
+
storage: "StorageUnit",
|
|
1939
|
+
staging: "StorageZone",
|
|
1940
|
+
"dock-ship": "StorageZone",
|
|
1941
|
+
"vas-station": "WorkCell"
|
|
1942
|
+
};
|
|
1943
|
+
var WMS_TYPES = [
|
|
1944
|
+
...WMS_LOCATION_TYPES.filter((k) => k !== "vas-station").map((k) => ({ key: k, role: "location", label: `twin.type.${k}`, standardClass: { epcis: "bizLocation" }, identity: { scheme: "gs1:SGLN" }, level: WMS_LOCATION_LEVEL[k], capabilities: ["storable"] })),
|
|
1945
|
+
{ key: "vas-station", role: "location", label: "twin.type.vas-station", standardClass: { epcis: "bizLocation", isa95: "WorkCenter" }, identity: { scheme: "gs1:SGLN" }, level: WMS_LOCATION_LEVEL["vas-station"], capabilities: ["storable", "processable"] },
|
|
1946
|
+
{ key: "forklift", role: "equipment", label: "twin.type.forklift", standardClass: { epcis: "object", iso55000: "Asset" }, identity: { scheme: "gs1:GIAI" }, capabilities: ["mobile", "operable"] },
|
|
1947
|
+
/** 유통가공 작업자·작업대 설비 — 가공을 수행하는 능동 자원(ISA-95 `Equipment`). */
|
|
1948
|
+
{ key: "packer", role: "equipment", label: "twin.type.packer", standardClass: { epcis: "object", isa95: "Equipment" }, identity: { scheme: "gs1:GIAI" }, capabilities: ["processable", "operable"] }
|
|
1949
|
+
];
|
|
1950
|
+
|
|
1909
1951
|
// src/yms-profile.ts
|
|
1910
1952
|
var YARD_BIZSTEP = {
|
|
1911
1953
|
arriving: "urn:epcglobal:cbv:bizstep:arriving",
|
|
@@ -3413,6 +3455,181 @@ function ingestEnergyBillRecords(records, opts) {
|
|
|
3413
3455
|
return { accepted, rejected };
|
|
3414
3456
|
}
|
|
3415
3457
|
|
|
3458
|
+
// src/gs1.ts
|
|
3459
|
+
var FNC1 = "";
|
|
3460
|
+
var FIXED_LENGTH = {
|
|
3461
|
+
"00": 18,
|
|
3462
|
+
// SSCC
|
|
3463
|
+
"01": 14,
|
|
3464
|
+
// GTIN
|
|
3465
|
+
"02": 14,
|
|
3466
|
+
// 포장 안 품목의 GTIN
|
|
3467
|
+
"11": 6,
|
|
3468
|
+
// 생산일
|
|
3469
|
+
"12": 6,
|
|
3470
|
+
// 지급기일
|
|
3471
|
+
"13": 6,
|
|
3472
|
+
// 포장일
|
|
3473
|
+
"15": 6,
|
|
3474
|
+
// 품질유지기한
|
|
3475
|
+
"16": 6,
|
|
3476
|
+
// 판매기한
|
|
3477
|
+
"17": 6,
|
|
3478
|
+
// 사용기한
|
|
3479
|
+
"20": 2,
|
|
3480
|
+
// 제품 변형
|
|
3481
|
+
"414": 13
|
|
3482
|
+
// 물리적 위치의 GLN
|
|
3483
|
+
};
|
|
3484
|
+
var KNOWN_VARIABLE = ["10", "21", "30", "254"];
|
|
3485
|
+
function isBracketed(value) {
|
|
3486
|
+
return /^\(\d{2,4}\)/.test(value);
|
|
3487
|
+
}
|
|
3488
|
+
function parseGs1(value) {
|
|
3489
|
+
const raw = value;
|
|
3490
|
+
if (!raw?.trim()) {
|
|
3491
|
+
return { ok: false, because: "not-gs1", raw };
|
|
3492
|
+
}
|
|
3493
|
+
const parsed = isBracketed(raw) ? fromBracketed(raw) : fromRaw(raw);
|
|
3494
|
+
if (!parsed.ok) {
|
|
3495
|
+
return parsed;
|
|
3496
|
+
}
|
|
3497
|
+
const found = parsed.elements;
|
|
3498
|
+
const count = found["30"] !== void 0 ? Number(found["30"]) : void 0;
|
|
3499
|
+
return {
|
|
3500
|
+
ok: true,
|
|
3501
|
+
scan: {
|
|
3502
|
+
sscc: found["00"],
|
|
3503
|
+
gln: found["414"],
|
|
3504
|
+
glnExtension: found["254"],
|
|
3505
|
+
gtin: found["01"],
|
|
3506
|
+
lot: found["10"],
|
|
3507
|
+
serial: found["21"],
|
|
3508
|
+
useBy: found["17"],
|
|
3509
|
+
/* 숫자가 아니면 담지 않는다 — `NaN` 을 수량으로 두면 더하는 쪽에서 합계가 통째로 사라진다. */
|
|
3510
|
+
count: count !== void 0 && Number.isFinite(count) ? count : void 0,
|
|
3511
|
+
elements: found,
|
|
3512
|
+
raw
|
|
3513
|
+
}
|
|
3514
|
+
};
|
|
3515
|
+
}
|
|
3516
|
+
function fromBracketed(raw) {
|
|
3517
|
+
const elements = {};
|
|
3518
|
+
const pattern = /\((\d{2,4})\)([^(]*)/g;
|
|
3519
|
+
let match;
|
|
3520
|
+
let consumed = 0;
|
|
3521
|
+
while ((match = pattern.exec(raw)) !== null) {
|
|
3522
|
+
const ai = match[1];
|
|
3523
|
+
const value = match[2].trim();
|
|
3524
|
+
const fixed = FIXED_LENGTH[ai];
|
|
3525
|
+
if (fixed !== void 0 && value.length !== fixed) {
|
|
3526
|
+
return { ok: false, because: value.length < fixed ? "truncated" : "unterminated", raw };
|
|
3527
|
+
}
|
|
3528
|
+
elements[ai] = value;
|
|
3529
|
+
consumed = match.index + match[0].length;
|
|
3530
|
+
}
|
|
3531
|
+
if (!Object.keys(elements).length || consumed !== raw.length) {
|
|
3532
|
+
return { ok: false, because: "not-gs1", raw };
|
|
3533
|
+
}
|
|
3534
|
+
return { ok: true, elements };
|
|
3535
|
+
}
|
|
3536
|
+
function fromRaw(raw) {
|
|
3537
|
+
const elements = {};
|
|
3538
|
+
let rest = raw;
|
|
3539
|
+
while (rest.length) {
|
|
3540
|
+
if (rest.startsWith(FNC1)) {
|
|
3541
|
+
rest = rest.slice(1);
|
|
3542
|
+
continue;
|
|
3543
|
+
}
|
|
3544
|
+
const ai = aiAt(rest);
|
|
3545
|
+
if (!ai) {
|
|
3546
|
+
return { ok: false, because: Object.keys(elements).length ? "unterminated" : "not-gs1", raw };
|
|
3547
|
+
}
|
|
3548
|
+
rest = rest.slice(ai.length);
|
|
3549
|
+
const fixed = FIXED_LENGTH[ai];
|
|
3550
|
+
if (fixed !== void 0) {
|
|
3551
|
+
if (rest.length < fixed) {
|
|
3552
|
+
return { ok: false, because: "truncated", raw };
|
|
3553
|
+
}
|
|
3554
|
+
const value = rest.slice(0, fixed);
|
|
3555
|
+
if (value.includes(FNC1)) {
|
|
3556
|
+
return { ok: false, because: "truncated", raw };
|
|
3557
|
+
}
|
|
3558
|
+
elements[ai] = value;
|
|
3559
|
+
rest = rest.slice(fixed);
|
|
3560
|
+
continue;
|
|
3561
|
+
}
|
|
3562
|
+
const end = rest.indexOf(FNC1);
|
|
3563
|
+
elements[ai] = end === -1 ? rest : rest.slice(0, end);
|
|
3564
|
+
rest = end === -1 ? "" : rest.slice(end + 1);
|
|
3565
|
+
}
|
|
3566
|
+
return Object.keys(elements).length ? { ok: true, elements } : { ok: false, because: "not-gs1", raw };
|
|
3567
|
+
}
|
|
3568
|
+
function aiAt(rest) {
|
|
3569
|
+
const two = rest.slice(0, 2);
|
|
3570
|
+
if (!/^\d{2}$/.test(two)) {
|
|
3571
|
+
return void 0;
|
|
3572
|
+
}
|
|
3573
|
+
if (FIXED_LENGTH[two] !== void 0 || KNOWN_VARIABLE.includes(two)) {
|
|
3574
|
+
return two;
|
|
3575
|
+
}
|
|
3576
|
+
const three = rest.slice(0, 3);
|
|
3577
|
+
if (/^\d{3}$/.test(three) && (FIXED_LENGTH[three] !== void 0 || KNOWN_VARIABLE.includes(three))) {
|
|
3578
|
+
return three;
|
|
3579
|
+
}
|
|
3580
|
+
const four = rest.slice(0, 4);
|
|
3581
|
+
return /^\d{4}$/.test(four) ? four : two;
|
|
3582
|
+
}
|
|
3583
|
+
function checkDigitOf(body) {
|
|
3584
|
+
const sum = [...body].reverse().reduce((total, digit, at2) => total + Number(digit) * (at2 % 2 === 0 ? 3 : 1), 0);
|
|
3585
|
+
return String((10 - sum % 10) % 10);
|
|
3586
|
+
}
|
|
3587
|
+
function wellFormed(digits, length) {
|
|
3588
|
+
return !!digits && digits.length === length && /^\d+$/.test(digits) && checkDigitOf(digits.slice(0, -1)) === digits.slice(-1);
|
|
3589
|
+
}
|
|
3590
|
+
var PREFIX_LENGTHS = [6, 7, 8, 9, 10, 11, 12];
|
|
3591
|
+
function epcCandidatesOfGs1(scan) {
|
|
3592
|
+
const out = [];
|
|
3593
|
+
if (wellFormed(scan.sscc, 18)) {
|
|
3594
|
+
const d = scan.sscc;
|
|
3595
|
+
for (const l of PREFIX_LENGTHS) out.push(`urn:epc:id:sscc:${d.slice(1, 1 + l)}.${d[0]}${d.slice(1 + l, 17)}`);
|
|
3596
|
+
}
|
|
3597
|
+
if (wellFormed(scan.gtin, 14)) {
|
|
3598
|
+
const d = scan.gtin;
|
|
3599
|
+
for (const l of PREFIX_LENGTHS) {
|
|
3600
|
+
const prefix = d.slice(1, 1 + l);
|
|
3601
|
+
const itemRefAndIndicator = d[0] + d.slice(1 + l, 13);
|
|
3602
|
+
out.push(scan.lot ? lgtinClass(prefix, itemRefAndIndicator, scan.lot) : sgtinClass(prefix, itemRefAndIndicator));
|
|
3603
|
+
}
|
|
3604
|
+
}
|
|
3605
|
+
if (wellFormed(scan.gln, 13)) {
|
|
3606
|
+
const d = scan.gln;
|
|
3607
|
+
for (const l of PREFIX_LENGTHS) out.push(`urn:epc:id:sgln:${d.slice(0, l)}.${d.slice(l, 12)}.${scan.glnExtension || "0"}`);
|
|
3608
|
+
}
|
|
3609
|
+
return out;
|
|
3610
|
+
}
|
|
3611
|
+
function ssccDigitsOf(uri) {
|
|
3612
|
+
const match = /^urn:epc:id:sscc:(\d+)\.(\d+)$/.exec(uri ?? "");
|
|
3613
|
+
if (!match) return void 0;
|
|
3614
|
+
const [, prefix, reference] = match;
|
|
3615
|
+
const body = reference[0] + prefix + reference.slice(1);
|
|
3616
|
+
if (body.length !== 17) return void 0;
|
|
3617
|
+
return body + checkDigitOf(body);
|
|
3618
|
+
}
|
|
3619
|
+
function gtin14OfItemClass(definitionId) {
|
|
3620
|
+
const match = /^urn:epc:idpat:sgtin:(\d+)\.(\d+)\.\*$/.exec(definitionId ?? "");
|
|
3621
|
+
if (!match) return void 0;
|
|
3622
|
+
const [, prefix, reference] = match;
|
|
3623
|
+
const body = reference[0] + prefix + reference.slice(1);
|
|
3624
|
+
if (body.length !== 13) return void 0;
|
|
3625
|
+
return body + checkDigitOf(body);
|
|
3626
|
+
}
|
|
3627
|
+
function gtin14OfItem(definitionId) {
|
|
3628
|
+
const byClass = gtin14OfItemClass(definitionId);
|
|
3629
|
+
if (byClass) return byClass;
|
|
3630
|
+
return /^(\d{8}|\d{12,14})$/.test(definitionId ?? "") ? definitionId.padStart(14, "0") : void 0;
|
|
3631
|
+
}
|
|
3632
|
+
|
|
3416
3633
|
// src/order-fold.ts
|
|
3417
3634
|
var ORDER_FOLD_HOUR_MS = 60 * 60 * 1e3;
|
|
3418
3635
|
var ORDER_FOLD_DEFAULT = Object.freeze({ afterMs: 24 * 60 * 60 * 1e3, maxTerminal: 1e3 });
|
|
@@ -5143,6 +5360,41 @@ function isOperationalFactReference(value) {
|
|
|
5143
5360
|
function nonEmpty(value) {
|
|
5144
5361
|
return typeof value === "string" && value.trim().length > 0;
|
|
5145
5362
|
}
|
|
5363
|
+
|
|
5364
|
+
// src/lot-lineage.ts
|
|
5365
|
+
function lotLineageOf(event, classOfUnit) {
|
|
5366
|
+
if (event.type !== "TransformationEvent") return [];
|
|
5367
|
+
const inputs = /* @__PURE__ */ new Set();
|
|
5368
|
+
for (const epc of event.inputEPCList ?? []) {
|
|
5369
|
+
const lot = classOfUnit(epc);
|
|
5370
|
+
if (lot) inputs.add(lot);
|
|
5371
|
+
}
|
|
5372
|
+
for (const one of event.inputQuantityList ?? []) if (one.epcClass) inputs.add(one.epcClass);
|
|
5373
|
+
const edges = [];
|
|
5374
|
+
for (const lot of new Set((event.outputQuantityList ?? []).map((one) => one.epcClass).filter(Boolean))) {
|
|
5375
|
+
for (const input of inputs) if (input !== lot) edges.push({ lot, input });
|
|
5376
|
+
}
|
|
5377
|
+
return edges;
|
|
5378
|
+
}
|
|
5379
|
+
function inheritedLotUse(lot, said, inputsOf, seen = /* @__PURE__ */ new Set()) {
|
|
5380
|
+
const own = said.get(lot);
|
|
5381
|
+
if (own?.use === "blocked") return { use: "blocked", status: own.status };
|
|
5382
|
+
const along = /* @__PURE__ */ new Set([...seen, lot]);
|
|
5383
|
+
const words = (inputsOf.get(lot) ?? []).filter((input) => !along.has(input)).map((input) => ({ input, word: inheritedLotUse(input, said, inputsOf, along) }));
|
|
5384
|
+
const blocked = words.find(({ word }) => word?.use === "blocked");
|
|
5385
|
+
if (blocked) return { use: "blocked", ...blocked.word.status !== void 0 ? { status: blocked.word.status } : {}, from: blocked.word.from ?? blocked.input };
|
|
5386
|
+
if (own?.use === "allowed") return { use: "allowed", status: own.status };
|
|
5387
|
+
if (!own && words.length && words.every(({ word }) => word?.use === "allowed")) return { use: "allowed" };
|
|
5388
|
+
return void 0;
|
|
5389
|
+
}
|
|
5390
|
+
function inheritedExpiry(inputExpiries) {
|
|
5391
|
+
let earliest;
|
|
5392
|
+
for (const at2 of inputExpiries) {
|
|
5393
|
+
if (typeof at2 !== "number" || !Number.isFinite(at2)) continue;
|
|
5394
|
+
if (earliest === void 0 || at2 < earliest) earliest = at2;
|
|
5395
|
+
}
|
|
5396
|
+
return earliest;
|
|
5397
|
+
}
|
|
5146
5398
|
// Annotate the CommonJS export names for ESM import in node:
|
|
5147
5399
|
0 && (module.exports = {
|
|
5148
5400
|
ABSENCE,
|
|
@@ -5203,6 +5455,7 @@ function nonEmpty(value) {
|
|
|
5203
5455
|
REFUSED_WITHOUT_CODE,
|
|
5204
5456
|
RESOURCE_KIND,
|
|
5205
5457
|
RETIRED_VOCABULARY,
|
|
5458
|
+
RETURN_TO_SUPPLIER,
|
|
5206
5459
|
SCHEDULE_STATUS,
|
|
5207
5460
|
SIGNATURE_REJECTED_REASONS,
|
|
5208
5461
|
TWIN_AXES,
|
|
@@ -5263,6 +5516,7 @@ function nonEmpty(value) {
|
|
|
5263
5516
|
effectivityAt,
|
|
5264
5517
|
electricalUpstreamOf,
|
|
5265
5518
|
emptyFoldedOrders,
|
|
5519
|
+
epcCandidatesOfGs1,
|
|
5266
5520
|
equipmentClassMembership,
|
|
5267
5521
|
erpCapabilityGaps,
|
|
5268
5522
|
expiryFromAttributes,
|
|
@@ -5274,6 +5528,8 @@ function nonEmpty(value) {
|
|
|
5274
5528
|
generationFractionAt,
|
|
5275
5529
|
graiUri,
|
|
5276
5530
|
gs1KeyDigitViolation,
|
|
5531
|
+
gtin14OfItem,
|
|
5532
|
+
gtin14OfItemClass,
|
|
5277
5533
|
hierarchyOf,
|
|
5278
5534
|
homeOf,
|
|
5279
5535
|
hourStartOf,
|
|
@@ -5291,6 +5547,8 @@ function nonEmpty(value) {
|
|
|
5291
5547
|
ingestEnergyUsagePeriodRecords,
|
|
5292
5548
|
ingestMasterData,
|
|
5293
5549
|
ingestOperationalRecords,
|
|
5550
|
+
inheritedExpiry,
|
|
5551
|
+
inheritedLotUse,
|
|
5294
5552
|
isAggregationRecord,
|
|
5295
5553
|
isCacheableTense,
|
|
5296
5554
|
isCommandTerminal,
|
|
@@ -5333,8 +5591,10 @@ function nonEmpty(value) {
|
|
|
5333
5591
|
lotClassOfItem,
|
|
5334
5592
|
lotClassUri,
|
|
5335
5593
|
lotFromAttributes,
|
|
5594
|
+
lotLineageOf,
|
|
5336
5595
|
mapRecord,
|
|
5337
5596
|
mapRecordChecked,
|
|
5597
|
+
materialDefinitionIdOf,
|
|
5338
5598
|
materialMovementKey,
|
|
5339
5599
|
meetsTests,
|
|
5340
5600
|
minuteOfDayAt,
|
|
@@ -5353,6 +5613,7 @@ function nonEmpty(value) {
|
|
|
5353
5613
|
orderFoldPolicyOf,
|
|
5354
5614
|
outsideLimit,
|
|
5355
5615
|
parseEpc,
|
|
5616
|
+
parseGs1,
|
|
5356
5617
|
parseIsoDuration,
|
|
5357
5618
|
partitionLensLocations,
|
|
5358
5619
|
passThroughReversible,
|
|
@@ -5382,6 +5643,7 @@ function nonEmpty(value) {
|
|
|
5382
5643
|
sgtinUri,
|
|
5383
5644
|
splitFlowOrders,
|
|
5384
5645
|
splitRelationIds,
|
|
5646
|
+
ssccDigitsOf,
|
|
5385
5647
|
ssccUri,
|
|
5386
5648
|
standsNewOrderRow,
|
|
5387
5649
|
stateFieldsOf,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@operato/ops-contract",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.42",
|
|
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",
|