@operato/ops-contract 0.9.30 → 0.9.31
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/contract.d.ts +12 -1
- package/dist/contract.js +32 -2
- package/dist/operational-ingest.js +11 -2
- package/dist-cjs/index.cjs +31 -1
- package/package.json +1 -1
package/dist/contract.d.ts
CHANGED
|
@@ -405,6 +405,15 @@ export type TestSpecificationRefs = string[];
|
|
|
405
405
|
* 개명이 사는 값은 이 주석이 대신 낸다).
|
|
406
406
|
*/
|
|
407
407
|
export interface TestResult {
|
|
408
|
+
/** Source-pinned execution evidence, not a lookup of the current master. */
|
|
409
|
+
specificationBasis?: {
|
|
410
|
+
id: string;
|
|
411
|
+
revisionId: string;
|
|
412
|
+
planId: string;
|
|
413
|
+
contentHash: string;
|
|
414
|
+
businessTime: ISOTime;
|
|
415
|
+
criteria: TestSpecificationCriterion[];
|
|
416
|
+
};
|
|
408
417
|
/** 어느 시험인가 — `TestSpecification.id` 를 가리킨다. */
|
|
409
418
|
specId: string;
|
|
410
419
|
/**
|
|
@@ -749,7 +758,9 @@ export declare function testEvidenceGaps(spec: Pick<TestSpecification, 'criteria
|
|
|
749
758
|
*
|
|
750
759
|
* 커널은 `Expression` 을 **읽지 않는다**(문법이 정의되지 않은 자유 문자열). 판정은 숫자 한계로만 한다.
|
|
751
760
|
*/
|
|
752
|
-
|
|
761
|
+
/** Validate carried evidence before either ingestion or replay; malformed evidence is not a current-master lookup. */
|
|
762
|
+
export declare function isTestSpecificationBasis(value: unknown): value is NonNullable<TestResult['specificationBasis']>;
|
|
763
|
+
export declare function judgeAgainstSpec(spec: Pick<TestSpecification, 'criteria'> | undefined, result: Pick<TestResult, 'propertyMeasurements' | 'specificationBasis'> | undefined): 'pass' | 'fail' | undefined;
|
|
753
764
|
/**
|
|
754
765
|
* 유효 기간 — **ISA-95 `EffectiveStartDate` / `EffectiveEndDate`.**
|
|
755
766
|
*
|
package/dist/contract.js
CHANGED
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
* **「원본이 말하는 이 사실을 커널의 어휘로 어떻게 옮기나」**다. 컬럼 단위로 물으면 원본이 열이면
|
|
29
29
|
* 축도 열이 된다 — 2026-08-23 에 축 다섯을 열었다가 그 이유로 되돌렸다.
|
|
30
30
|
*
|
|
31
|
-
* 열지 않기로 한 것과 그 조건은 `
|
|
31
|
+
* 열지 않기로 한 것과 그 조건은 `operato-application/adr/ADR-0039.md` 에 있다. 넓히기 전에 그 표를 본다.
|
|
32
32
|
* 지키는 하네스: `derived-not-input` · `actuals-come-from-transitions` · `accumulators-survive-restart` ·
|
|
33
33
|
* `purpose-conformance`.
|
|
34
34
|
*/
|
|
@@ -407,9 +407,39 @@ export function testEvidenceGaps(spec, result) {
|
|
|
407
407
|
*
|
|
408
408
|
* 커널은 `Expression` 을 **읽지 않는다**(문법이 정의되지 않은 자유 문자열). 판정은 숫자 한계로만 한다.
|
|
409
409
|
*/
|
|
410
|
+
/** Validate carried evidence before either ingestion or replay; malformed evidence is not a current-master lookup. */
|
|
411
|
+
export function isTestSpecificationBasis(value) {
|
|
412
|
+
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
413
|
+
return false;
|
|
414
|
+
const basis = value;
|
|
415
|
+
if (!['id', 'revisionId', 'planId', 'contentHash', 'businessTime'].every(key => typeof basis[key] === 'string' && basis[key].trim()))
|
|
416
|
+
return false;
|
|
417
|
+
if (!Number.isFinite(Date.parse(basis.businessTime)))
|
|
418
|
+
return false;
|
|
419
|
+
return Array.isArray(basis.criteria) && basis.criteria.every(c => {
|
|
420
|
+
if (!c || typeof c !== 'object' || Array.isArray(c) || typeof c.id !== 'string' || !c.id.trim())
|
|
421
|
+
return false;
|
|
422
|
+
if (['description', 'expression', 'evaluatedPropertyId'].some(key => c[key] !== undefined && typeof c[key] !== 'string'))
|
|
423
|
+
return false;
|
|
424
|
+
if (c.limit === undefined)
|
|
425
|
+
return true;
|
|
426
|
+
const limit = c.limit;
|
|
427
|
+
if (!limit || typeof limit !== 'object' || Array.isArray(limit))
|
|
428
|
+
return false;
|
|
429
|
+
if (['minimum', 'maximum'].some(key => limit[key] !== undefined && (typeof limit[key] !== 'number' || !Number.isFinite(limit[key]))))
|
|
430
|
+
return false;
|
|
431
|
+
if (limit.uom !== undefined && typeof limit.uom !== 'string')
|
|
432
|
+
return false;
|
|
433
|
+
return !(limit.minimum !== undefined && limit.maximum !== undefined && limit.minimum > limit.maximum);
|
|
434
|
+
});
|
|
435
|
+
}
|
|
410
436
|
export function judgeAgainstSpec(spec, result) {
|
|
411
437
|
/* 판정할 기준만 남긴다 — 말하지 않는 기준은 이 답에 관여하지 않는다. */
|
|
412
|
-
const
|
|
438
|
+
const basis = result?.specificationBasis;
|
|
439
|
+
// A malformed carried basis is unknown. Never replace it with today's criteria.
|
|
440
|
+
if (basis !== undefined && !isTestSpecificationBasis(basis))
|
|
441
|
+
return undefined;
|
|
442
|
+
const criteria = (basis ? basis.criteria : spec?.criteria ?? []).filter(c => !criterionSaysNothing(c));
|
|
413
443
|
if (!criteria.length)
|
|
414
444
|
return undefined;
|
|
415
445
|
const measurements = result?.propertyMeasurements ?? [];
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
* 모르는 필드는 **조용히 버리지 않고 거부한다.** `taskID` 처럼 한 글자 틀린 이름은 통과시키면 영원히
|
|
35
35
|
* 보이지 않는 손실이 된다(이 문에는 아직 옛 발신자가 없어 호환 부담도 없다).
|
|
36
36
|
*/
|
|
37
|
-
import { OP_EVENT, DISPOSITION_DECISION, MATERIAL_ACTUAL_USE, MATERIAL_LOT_USE } from "./contract.js";
|
|
37
|
+
import { OP_EVENT, DISPOSITION_DECISION, MATERIAL_ACTUAL_USE, MATERIAL_LOT_USE, isTestSpecificationBasis } from "./contract.js";
|
|
38
38
|
/**
|
|
39
39
|
* 객체 한 줄이 선언된 안쪽 모양을 지키나 — **선언하지 않은 자리는 보지 않는다.**
|
|
40
40
|
*
|
|
@@ -370,7 +370,13 @@ const SPECS = {
|
|
|
370
370
|
required: ['testableObjectId', 'specId'],
|
|
371
371
|
fields: {
|
|
372
372
|
testableObjectId: 'string', specId: 'string', result: 'string', at: 'string', expiresAt: 'string',
|
|
373
|
-
derived: 'boolean', propertyMeasurements: 'object[]', recordTime: 'string'
|
|
373
|
+
derived: 'boolean', propertyMeasurements: 'object[]', specificationBasis: 'object', recordTime: 'string'
|
|
374
|
+
},
|
|
375
|
+
shapes: {
|
|
376
|
+
specificationBasis: {
|
|
377
|
+
required: ['id', 'revisionId', 'planId', 'contentHash', 'businessTime', 'criteria'],
|
|
378
|
+
fields: { id: 'string', revisionId: 'string', planId: 'string', contentHash: 'string', businessTime: 'string' }
|
|
379
|
+
}
|
|
374
380
|
},
|
|
375
381
|
enums: { result: ['pass', 'fail'] }
|
|
376
382
|
},
|
|
@@ -611,6 +617,9 @@ export function ingestOperationalRecords(records, opts) {
|
|
|
611
617
|
* 사건 시각이 되고, 그러면 어제 있었던 정지가 오늘 일어난 것으로 저널에 적힌다. 적은 때는
|
|
612
618
|
* `recordTime` 에 남는다.
|
|
613
619
|
*/
|
|
620
|
+
if (kind === 'test' && r.specificationBasis !== undefined && !isTestSpecificationBasis(r.specificationBasis)) {
|
|
621
|
+
errors.push('test.specificationBasis: invalid pinned specification evidence');
|
|
622
|
+
}
|
|
614
623
|
const closedPeriodEnd = kind === 'equipment-period' ? String(r.to ?? '').trim() : '';
|
|
615
624
|
const at = closedPeriodEnd || String(r.at ?? '').trim() || opts.defaultEventTime;
|
|
616
625
|
const atMs = at ? Date.parse(at) : Number.NaN;
|
package/dist-cjs/index.cjs
CHANGED
|
@@ -175,6 +175,7 @@ __export(index_exports, {
|
|
|
175
175
|
isOrderTerminal: () => isOrderTerminal,
|
|
176
176
|
isPlannedStopStatus: () => isPlannedStopStatus,
|
|
177
177
|
isResourceKind: () => isResourceKind,
|
|
178
|
+
isTestSpecificationBasis: () => isTestSpecificationBasis,
|
|
178
179
|
isTransformationRecord: () => isTransformationRecord,
|
|
179
180
|
isWebhookDeliveryCode: () => isWebhookDeliveryCode,
|
|
180
181
|
isWebhookSecretSegment: () => isWebhookSecretSegment,
|
|
@@ -588,8 +589,26 @@ function testEvidenceGaps(spec, result) {
|
|
|
588
589
|
unmatched: measurements.map((m) => m.testableObjectPropertyId).filter((k) => !!k && !wanted.has(k))
|
|
589
590
|
};
|
|
590
591
|
}
|
|
592
|
+
function isTestSpecificationBasis(value) {
|
|
593
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
594
|
+
const basis = value;
|
|
595
|
+
if (!["id", "revisionId", "planId", "contentHash", "businessTime"].every((key) => typeof basis[key] === "string" && basis[key].trim())) return false;
|
|
596
|
+
if (!Number.isFinite(Date.parse(basis.businessTime))) return false;
|
|
597
|
+
return Array.isArray(basis.criteria) && basis.criteria.every((c) => {
|
|
598
|
+
if (!c || typeof c !== "object" || Array.isArray(c) || typeof c.id !== "string" || !c.id.trim()) return false;
|
|
599
|
+
if (["description", "expression", "evaluatedPropertyId"].some((key) => c[key] !== void 0 && typeof c[key] !== "string")) return false;
|
|
600
|
+
if (c.limit === void 0) return true;
|
|
601
|
+
const limit = c.limit;
|
|
602
|
+
if (!limit || typeof limit !== "object" || Array.isArray(limit)) return false;
|
|
603
|
+
if (["minimum", "maximum"].some((key) => limit[key] !== void 0 && (typeof limit[key] !== "number" || !Number.isFinite(limit[key])))) return false;
|
|
604
|
+
if (limit.uom !== void 0 && typeof limit.uom !== "string") return false;
|
|
605
|
+
return !(limit.minimum !== void 0 && limit.maximum !== void 0 && limit.minimum > limit.maximum);
|
|
606
|
+
});
|
|
607
|
+
}
|
|
591
608
|
function judgeAgainstSpec(spec, result) {
|
|
592
|
-
const
|
|
609
|
+
const basis = result?.specificationBasis;
|
|
610
|
+
if (basis !== void 0 && !isTestSpecificationBasis(basis)) return void 0;
|
|
611
|
+
const criteria = (basis ? basis.criteria : spec?.criteria ?? []).filter((c) => !criterionSaysNothing(c));
|
|
593
612
|
if (!criteria.length) return void 0;
|
|
594
613
|
const measurements = result?.propertyMeasurements ?? [];
|
|
595
614
|
let allJudged = true;
|
|
@@ -3887,8 +3906,15 @@ var SPECS = {
|
|
|
3887
3906
|
expiresAt: "string",
|
|
3888
3907
|
derived: "boolean",
|
|
3889
3908
|
propertyMeasurements: "object[]",
|
|
3909
|
+
specificationBasis: "object",
|
|
3890
3910
|
recordTime: "string"
|
|
3891
3911
|
},
|
|
3912
|
+
shapes: {
|
|
3913
|
+
specificationBasis: {
|
|
3914
|
+
required: ["id", "revisionId", "planId", "contentHash", "businessTime", "criteria"],
|
|
3915
|
+
fields: { id: "string", revisionId: "string", planId: "string", contentHash: "string", businessTime: "string" }
|
|
3916
|
+
}
|
|
3917
|
+
},
|
|
3892
3918
|
enums: { result: ["pass", "fail"] }
|
|
3893
3919
|
},
|
|
3894
3920
|
/*
|
|
@@ -4063,6 +4089,9 @@ function ingestOperationalRecords(records, opts) {
|
|
|
4063
4089
|
}
|
|
4064
4090
|
}
|
|
4065
4091
|
}
|
|
4092
|
+
if (kind === "test" && r.specificationBasis !== void 0 && !isTestSpecificationBasis(r.specificationBasis)) {
|
|
4093
|
+
errors.push("test.specificationBasis: invalid pinned specification evidence");
|
|
4094
|
+
}
|
|
4066
4095
|
const closedPeriodEnd = kind === "equipment-period" ? String(r.to ?? "").trim() : "";
|
|
4067
4096
|
const at2 = closedPeriodEnd || String(r.at ?? "").trim() || opts.defaultEventTime;
|
|
4068
4097
|
const atMs = at2 ? Date.parse(at2) : Number.NaN;
|
|
@@ -4886,6 +4915,7 @@ function nonEmpty(value) {
|
|
|
4886
4915
|
isOrderTerminal,
|
|
4887
4916
|
isPlannedStopStatus,
|
|
4888
4917
|
isResourceKind,
|
|
4918
|
+
isTestSpecificationBasis,
|
|
4889
4919
|
isTransformationRecord,
|
|
4890
4920
|
isWebhookDeliveryCode,
|
|
4891
4921
|
isWebhookSecretSegment,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@operato/ops-contract",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.31",
|
|
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",
|