@contractspec/lib.overlay-engine 3.7.16 → 3.7.18
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/index.js +2 -550
- package/dist/merger.js +1 -125
- package/dist/node/index.js +2 -550
- package/dist/node/merger.js +1 -125
- package/dist/node/react.js +1 -21
- package/dist/node/registry.js +1 -262
- package/dist/node/runtime.js +1 -176
- package/dist/node/signer.js +1 -81
- package/dist/node/spec.js +1 -15
- package/dist/node/validator.js +1 -131
- package/dist/react.js +1 -21
- package/dist/registry.js +1 -262
- package/dist/runtime.js +1 -176
- package/dist/signer.js +1 -81
- package/dist/spec.js +1 -15
- package/dist/validator.js +1 -131
- package/package.json +6 -6
package/dist/spec.js
CHANGED
|
@@ -1,16 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
|
|
3
|
-
var OVERLAY_SCOPE_ORDER = [
|
|
4
|
-
"tenantId",
|
|
5
|
-
"role",
|
|
6
|
-
"userId",
|
|
7
|
-
"device",
|
|
8
|
-
"tags"
|
|
9
|
-
];
|
|
10
|
-
function defineOverlay(spec) {
|
|
11
|
-
return spec;
|
|
12
|
-
}
|
|
13
|
-
export {
|
|
14
|
-
defineOverlay,
|
|
15
|
-
OVERLAY_SCOPE_ORDER
|
|
16
|
-
};
|
|
2
|
+
var j=["tenantId","role","userId","device","tags"];function k(f){return f}export{k as defineOverlay,j as OVERLAY_SCOPE_ORDER};
|
package/dist/validator.js
CHANGED
|
@@ -1,132 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
|
|
3
|
-
var TARGET_KEYS = [
|
|
4
|
-
"capability",
|
|
5
|
-
"workflow",
|
|
6
|
-
"dataView",
|
|
7
|
-
"presentation",
|
|
8
|
-
"operation"
|
|
9
|
-
];
|
|
10
|
-
var defaultOverlayValidator = (spec) => validateOverlaySpec(spec);
|
|
11
|
-
function validateOverlaySpec(spec) {
|
|
12
|
-
const issues = [];
|
|
13
|
-
if (!spec.overlayId?.trim()) {
|
|
14
|
-
issues.push({
|
|
15
|
-
code: "overlay.id",
|
|
16
|
-
message: "overlayId is required",
|
|
17
|
-
path: ["overlayId"]
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
if (!spec.version?.trim()) {
|
|
21
|
-
issues.push({
|
|
22
|
-
code: "overlay.version",
|
|
23
|
-
message: "version is required",
|
|
24
|
-
path: ["version"]
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
const hasTarget = TARGET_KEYS.some((key) => {
|
|
28
|
-
const value = spec.appliesTo?.[key];
|
|
29
|
-
return typeof value === "string" && value.trim().length > 0;
|
|
30
|
-
});
|
|
31
|
-
if (!hasTarget) {
|
|
32
|
-
issues.push({
|
|
33
|
-
code: "overlay.target",
|
|
34
|
-
message: "Overlay must specify at least one target (capability, workflow, dataView, presentation, or operation).",
|
|
35
|
-
path: ["appliesTo"]
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
if (!spec.modifications?.length) {
|
|
39
|
-
issues.push({
|
|
40
|
-
code: "overlay.modifications.empty",
|
|
41
|
-
message: "Overlay must include at least one modification.",
|
|
42
|
-
path: ["modifications"]
|
|
43
|
-
});
|
|
44
|
-
} else {
|
|
45
|
-
spec.modifications.forEach((mod, idx) => {
|
|
46
|
-
const path = ["modifications", String(idx)];
|
|
47
|
-
validateModification(mod, path, issues);
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
return {
|
|
51
|
-
valid: issues.length === 0,
|
|
52
|
-
issues
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
function validateModification(modification, path, issues) {
|
|
56
|
-
const push = (code, message, extraPath) => {
|
|
57
|
-
issues.push({
|
|
58
|
-
code,
|
|
59
|
-
message,
|
|
60
|
-
path: extraPath ? [...path, ...extraPath] : path
|
|
61
|
-
});
|
|
62
|
-
};
|
|
63
|
-
if (isFieldModification(modification)) {
|
|
64
|
-
if (!modification.field?.trim()) {
|
|
65
|
-
push("overlay.mod.field", "field is required for this modification", [
|
|
66
|
-
"field"
|
|
67
|
-
]);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
switch (modification.type) {
|
|
71
|
-
case "renameLabel": {
|
|
72
|
-
if (!modification.newLabel?.trim()) {
|
|
73
|
-
push("overlay.mod.renameLabel.newLabel", "newLabel is required", [
|
|
74
|
-
"newLabel"
|
|
75
|
-
]);
|
|
76
|
-
}
|
|
77
|
-
break;
|
|
78
|
-
}
|
|
79
|
-
case "reorderFields": {
|
|
80
|
-
if (!modification.fields?.length) {
|
|
81
|
-
push("overlay.mod.reorderFields.fields", "fields list cannot be empty", ["fields"]);
|
|
82
|
-
}
|
|
83
|
-
const seen = new Set;
|
|
84
|
-
for (const field of modification.fields ?? []) {
|
|
85
|
-
if (!field?.trim()) {
|
|
86
|
-
push("overlay.mod.reorderFields.fields.blank", "fields entries must be non-empty");
|
|
87
|
-
break;
|
|
88
|
-
}
|
|
89
|
-
if (seen.has(field)) {
|
|
90
|
-
push("overlay.mod.reorderFields.fields.duplicate", `field "${field}" was listed multiple times`);
|
|
91
|
-
break;
|
|
92
|
-
}
|
|
93
|
-
seen.add(field);
|
|
94
|
-
}
|
|
95
|
-
break;
|
|
96
|
-
}
|
|
97
|
-
case "setDefault": {
|
|
98
|
-
if (modification.value === undefined) {
|
|
99
|
-
push("overlay.mod.setDefault.value", "value is required", ["value"]);
|
|
100
|
-
}
|
|
101
|
-
break;
|
|
102
|
-
}
|
|
103
|
-
case "addHelpText": {
|
|
104
|
-
if (!modification.text?.trim()) {
|
|
105
|
-
push("overlay.mod.addHelpText.text", "text is required", ["text"]);
|
|
106
|
-
}
|
|
107
|
-
break;
|
|
108
|
-
}
|
|
109
|
-
case "makeRequired":
|
|
110
|
-
case "hideField":
|
|
111
|
-
break;
|
|
112
|
-
default: {
|
|
113
|
-
const exhaustive = modification;
|
|
114
|
-
throw new Error(`Unsupported overlay modification ${exhaustive?.type ?? "unknown"}`);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
function isFieldModification(mod) {
|
|
119
|
-
return "field" in mod;
|
|
120
|
-
}
|
|
121
|
-
function assertOverlayValid(spec, validator = defaultOverlayValidator) {
|
|
122
|
-
const result = validator(spec);
|
|
123
|
-
if (!result.valid) {
|
|
124
|
-
const message = result.issues.map((issue) => `${issue.code}: ${issue.message}`).join("; ");
|
|
125
|
-
throw new Error(`Invalid OverlaySpec "${spec.overlayId}": ${message}`);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
export {
|
|
129
|
-
validateOverlaySpec,
|
|
130
|
-
defaultOverlayValidator,
|
|
131
|
-
assertOverlayValid
|
|
132
|
-
};
|
|
2
|
+
var o=["capability","workflow","dataView","presentation","operation"],n=(e)=>d(e);function d(e){let t=[];if(!e.overlayId?.trim())t.push({code:"overlay.id",message:"overlayId is required",path:["overlayId"]});if(!e.version?.trim())t.push({code:"overlay.version",message:"version is required",path:["version"]});if(!o.some((a)=>{let i=e.appliesTo?.[a];return typeof i==="string"&&i.trim().length>0}))t.push({code:"overlay.target",message:"Overlay must specify at least one target (capability, workflow, dataView, presentation, or operation).",path:["appliesTo"]});if(!e.modifications?.length)t.push({code:"overlay.modifications.empty",message:"Overlay must include at least one modification.",path:["modifications"]});else e.modifications.forEach((a,i)=>{let r=["modifications",String(i)];v(a,r,t)});return{valid:t.length===0,issues:t}}function v(e,t,s){let a=(i,r,l)=>{s.push({code:i,message:r,path:l?[...t,...l]:t})};if(f(e)){if(!e.field?.trim())a("overlay.mod.field","field is required for this modification",["field"])}switch(e.type){case"renameLabel":{if(!e.newLabel?.trim())a("overlay.mod.renameLabel.newLabel","newLabel is required",["newLabel"]);break}case"reorderFields":{if(!e.fields?.length)a("overlay.mod.reorderFields.fields","fields list cannot be empty",["fields"]);let i=new Set;for(let r of e.fields??[]){if(!r?.trim()){a("overlay.mod.reorderFields.fields.blank","fields entries must be non-empty");break}if(i.has(r)){a("overlay.mod.reorderFields.fields.duplicate",`field "${r}" was listed multiple times`);break}i.add(r)}break}case"setDefault":{if(e.value===void 0)a("overlay.mod.setDefault.value","value is required",["value"]);break}case"addHelpText":{if(!e.text?.trim())a("overlay.mod.addHelpText.text","text is required",["text"]);break}case"makeRequired":case"hideField":break;default:throw Error(`Unsupported overlay modification ${e?.type??"unknown"}`)}}function f(e){return"field"in e}function y(e,t=n){let s=t(e);if(!s.valid){let a=s.issues.map((i)=>`${i.code}: ${i.message}`).join("; ");throw Error(`Invalid OverlaySpec "${e.overlayId}": ${a}`)}}export{d as validateOverlaySpec,n as defaultOverlayValidator,y as assertOverlayValid};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contractspec/lib.overlay-engine",
|
|
3
|
-
"version": "3.7.
|
|
3
|
+
"version": "3.7.18",
|
|
4
4
|
"description": "Runtime overlay engine for ContractSpec personalization and adaptive UI rendering.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"contractspec",
|
|
@@ -25,14 +25,14 @@
|
|
|
25
25
|
"dev": "contractspec-bun-build dev",
|
|
26
26
|
"clean": "rimraf dist .turbo",
|
|
27
27
|
"lint": "bun lint:fix",
|
|
28
|
-
"lint:fix": "biome check --write --unsafe --only=nursery/useSortedClasses . && biome check --write .",
|
|
29
|
-
"lint:check": "biome check .",
|
|
28
|
+
"lint:fix": "node ../../../scripts/biome.cjs check --write --unsafe --only=nursery/useSortedClasses . && node ../../../scripts/biome.cjs check --write .",
|
|
29
|
+
"lint:check": "node ../../../scripts/biome.cjs check .",
|
|
30
30
|
"test": "bun test --pass-with-no-tests",
|
|
31
31
|
"prebuild": "contractspec-bun-build prebuild",
|
|
32
32
|
"typecheck": "tsc --noEmit"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@contractspec/lib.contracts-spec": "5.0
|
|
35
|
+
"@contractspec/lib.contracts-spec": "5.2.0",
|
|
36
36
|
"fast-json-stable-stringify": "^2.1.0"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
@@ -44,9 +44,9 @@
|
|
|
44
44
|
}
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@contractspec/tool.typescript": "3.7.
|
|
47
|
+
"@contractspec/tool.typescript": "3.7.13",
|
|
48
48
|
"typescript": "^5.9.3",
|
|
49
|
-
"@contractspec/tool.bun": "3.7.
|
|
49
|
+
"@contractspec/tool.bun": "3.7.14"
|
|
50
50
|
},
|
|
51
51
|
"exports": {
|
|
52
52
|
".": {
|