@operato/twin-kernel 0.11.20 → 0.11.21

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.
Files changed (2) hide show
  1. package/dist-cjs/index.cjs +36 -1
  2. package/package.json +2 -2
@@ -328,8 +328,36 @@ function outsideLimit(criterion, observed) {
328
328
  return true;
329
329
  return false;
330
330
  }
331
+ function isTestSpecificationBasis(value) {
332
+ if (!value || typeof value !== "object" || Array.isArray(value))
333
+ return false;
334
+ const basis = value;
335
+ if (!["id", "revisionId", "planId", "contentHash", "businessTime"].every((key) => typeof basis[key] === "string" && basis[key].trim()))
336
+ return false;
337
+ if (!Number.isFinite(Date.parse(basis.businessTime)))
338
+ return false;
339
+ return Array.isArray(basis.criteria) && basis.criteria.every((c) => {
340
+ if (!c || typeof c !== "object" || Array.isArray(c) || typeof c.id !== "string" || !c.id.trim())
341
+ return false;
342
+ if (["description", "expression", "evaluatedPropertyId"].some((key) => c[key] !== void 0 && typeof c[key] !== "string"))
343
+ return false;
344
+ if (c.limit === void 0)
345
+ return true;
346
+ const limit = c.limit;
347
+ if (!limit || typeof limit !== "object" || Array.isArray(limit))
348
+ return false;
349
+ if (["minimum", "maximum"].some((key) => limit[key] !== void 0 && (typeof limit[key] !== "number" || !Number.isFinite(limit[key]))))
350
+ return false;
351
+ if (limit.uom !== void 0 && typeof limit.uom !== "string")
352
+ return false;
353
+ return !(limit.minimum !== void 0 && limit.maximum !== void 0 && limit.minimum > limit.maximum);
354
+ });
355
+ }
331
356
  function judgeAgainstSpec(spec, result) {
332
- const criteria = (spec?.criteria ?? []).filter((c) => !criterionSaysNothing(c));
357
+ const basis = result?.specificationBasis;
358
+ if (basis !== void 0 && !isTestSpecificationBasis(basis))
359
+ return void 0;
360
+ const criteria = (basis ? basis.criteria : spec?.criteria ?? []).filter((c) => !criterionSaysNothing(c));
333
361
  if (!criteria.length)
334
362
  return void 0;
335
363
  const measurements = result?.propertyMeasurements ?? [];
@@ -2156,8 +2184,15 @@ var SPECS = {
2156
2184
  expiresAt: "string",
2157
2185
  derived: "boolean",
2158
2186
  propertyMeasurements: "object[]",
2187
+ specificationBasis: "object",
2159
2188
  recordTime: "string"
2160
2189
  },
2190
+ shapes: {
2191
+ specificationBasis: {
2192
+ required: ["id", "revisionId", "planId", "contentHash", "businessTime", "criteria"],
2193
+ fields: { id: "string", revisionId: "string", planId: "string", contentHash: "string", businessTime: "string" }
2194
+ }
2195
+ },
2161
2196
  enums: { result: ["pass", "fail"] }
2162
2197
  },
2163
2198
  /*
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@operato/twin-kernel",
3
- "version": "0.11.20",
3
+ "version": "0.11.21",
4
4
  "type": "module",
5
5
  "description": "Twin Domain Kernel — framework-agnostic, zero-dep (domain + sim + 3-channel contract). WMS/YMS/MES, EPCIS 2.0 · ISA-95.",
6
6
  "publishConfig": {
@@ -28,6 +28,6 @@
28
28
  "test": "node --test test/*.test.ts"
29
29
  },
30
30
  "dependencies": {
31
- "@operato/ops-contract": "^0.9.30"
31
+ "@operato/ops-contract": "^0.9.31"
32
32
  }
33
33
  }