@contractspec/lib.overlay-engine 1.57.0 → 1.59.0
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.d.ts +8 -8
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +535 -8
- package/dist/merger.d.ts +5 -9
- package/dist/merger.d.ts.map +1 -1
- package/dist/merger.js +120 -101
- package/dist/node/index.js +534 -0
- package/dist/node/merger.js +125 -0
- package/dist/node/react.js +21 -0
- package/dist/node/registry.js +262 -0
- package/dist/node/runtime.js +176 -0
- package/dist/node/signer.js +81 -0
- package/dist/node/spec.js +15 -0
- package/dist/node/types.js +0 -0
- package/dist/node/validator.js +131 -0
- package/dist/react.d.ts +6 -9
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +17 -18
- package/dist/registry.d.ts +22 -25
- package/dist/registry.d.ts.map +1 -1
- package/dist/registry.js +254 -98
- package/dist/runtime.d.ts +19 -23
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +174 -51
- package/dist/signer.d.ts +13 -17
- package/dist/signer.d.ts.map +1 -1
- package/dist/signer.js +71 -52
- package/dist/spec.d.ts +65 -69
- package/dist/spec.d.ts.map +1 -1
- package/dist/spec.js +13 -12
- package/dist/types.d.ts +25 -28
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -0
- package/dist/validator.d.ts +12 -16
- package/dist/validator.d.ts.map +1 -1
- package/dist/validator.js +123 -92
- package/package.json +75 -31
- package/dist/merger.js.map +0 -1
- package/dist/react.js.map +0 -1
- package/dist/registry.js.map +0 -1
- package/dist/runtime.js.map +0 -1
- package/dist/signer.js.map +0 -1
- package/dist/spec.js.map +0 -1
- package/dist/validator.js.map +0 -1
package/dist/react.js
CHANGED
|
@@ -1,23 +1,22 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// src/react.ts
|
|
1
3
|
import { useMemo } from "react";
|
|
2
|
-
|
|
3
|
-
//#region src/react.ts
|
|
4
4
|
function useOverlay(engine, params, deps = []) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
...deps
|
|
15
|
-
]);
|
|
5
|
+
return useMemo(() => {
|
|
6
|
+
if (!engine) {
|
|
7
|
+
return {
|
|
8
|
+
target: params.target,
|
|
9
|
+
overlaysApplied: []
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
return engine.apply(params);
|
|
13
|
+
}, [engine, params, ...deps]);
|
|
16
14
|
}
|
|
17
15
|
function useOverlayFields(engine, params, deps = []) {
|
|
18
|
-
|
|
16
|
+
const result = useOverlay(engine, params, deps);
|
|
17
|
+
return result.target.fields;
|
|
19
18
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
export {
|
|
20
|
+
useOverlayFields,
|
|
21
|
+
useOverlay
|
|
22
|
+
};
|
package/dist/registry.d.ts
CHANGED
|
@@ -1,28 +1,25 @@
|
|
|
1
|
-
import { OverlayInput, OverlayScopeContext, OverlayTargetRef, SignedOverlaySpec } from
|
|
2
|
-
import { OverlayValidator } from
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
validator?: OverlayValidator;
|
|
7
|
-
allowUnsigned?: boolean;
|
|
1
|
+
import type { OverlayInput, OverlayScopeContext, OverlayTargetRef, SignedOverlaySpec } from './spec';
|
|
2
|
+
import type { OverlayValidator } from './validator';
|
|
3
|
+
export interface OverlayRegistryOptions {
|
|
4
|
+
validator?: OverlayValidator;
|
|
5
|
+
allowUnsigned?: boolean;
|
|
8
6
|
}
|
|
9
|
-
interface OverlayLookup extends OverlayScopeContext, OverlayTargetRef {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
7
|
+
export interface OverlayLookup extends OverlayScopeContext, OverlayTargetRef {
|
|
8
|
+
}
|
|
9
|
+
export declare class OverlayRegistry {
|
|
10
|
+
private readonly options;
|
|
11
|
+
private readonly overlays;
|
|
12
|
+
constructor(options?: OverlayRegistryOptions);
|
|
13
|
+
register(overlay: OverlayInput, options?: {
|
|
14
|
+
skipValidation?: boolean;
|
|
15
|
+
}): SignedOverlaySpec;
|
|
16
|
+
unregister(overlayId: string, version?: string): void;
|
|
17
|
+
list(): SignedOverlaySpec[];
|
|
18
|
+
get(overlayId: string, version: string): SignedOverlaySpec | undefined;
|
|
19
|
+
forContext(query: OverlayLookup): SignedOverlaySpec[];
|
|
20
|
+
clear(): void;
|
|
21
|
+
size(): number;
|
|
22
|
+
private ensureSigned;
|
|
23
|
+
private getKey;
|
|
25
24
|
}
|
|
26
|
-
//#endregion
|
|
27
|
-
export { OverlayLookup, OverlayRegistry, OverlayRegistryOptions };
|
|
28
25
|
//# sourceMappingURL=registry.d.ts.map
|
package/dist/registry.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EAEZ,mBAAmB,EACnB,gBAAgB,EAChB,iBAAiB,EAClB,MAAM,QAAQ,CAAC;AAChB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAGpD,MAAM,WAAW,sBAAsB;IACrC,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAC7B,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,MAAM,WAAW,aAAc,SAAQ,mBAAmB,EAAE,gBAAgB;CAAG;AAwB/E,qBAAa,eAAe;IAGd,OAAO,CAAC,QAAQ,CAAC,OAAO;IAFpC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAoC;gBAEhC,OAAO,GAAE,sBAA2B;IAEjE,QAAQ,CACN,OAAO,EAAE,YAAY,EACrB,OAAO,CAAC,EAAE;QAAE,cAAc,CAAC,EAAE,OAAO,CAAA;KAAE,GACrC,iBAAiB;IAyBpB,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM;IAa9C,IAAI,IAAI,iBAAiB,EAAE;IAI3B,GAAG,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,iBAAiB,GAAG,SAAS;IAItE,UAAU,CAAC,KAAK,EAAE,aAAa,GAAG,iBAAiB,EAAE;IAYrD,KAAK;IAIL,IAAI,IAAI,MAAM;IAId,OAAO,CAAC,YAAY;IAiBpB,OAAO,CAAC,MAAM;CAGf"}
|
package/dist/registry.js
CHANGED
|
@@ -1,107 +1,263 @@
|
|
|
1
|
-
|
|
1
|
+
// @bun
|
|
2
|
+
// src/validator.ts
|
|
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
|
+
}
|
|
2
128
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
129
|
+
// src/registry.ts
|
|
130
|
+
var TARGET_KEYS2 = [
|
|
131
|
+
"capability",
|
|
132
|
+
"workflow",
|
|
133
|
+
"dataView",
|
|
134
|
+
"presentation",
|
|
135
|
+
"operation"
|
|
10
136
|
];
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
};
|
|
18
|
-
var OverlayRegistry = class {
|
|
19
|
-
overlays = /* @__PURE__ */ new Map();
|
|
20
|
-
constructor(options = {}) {
|
|
21
|
-
this.options = options;
|
|
22
|
-
}
|
|
23
|
-
register(overlay, options) {
|
|
24
|
-
if (!options?.skipValidation) {
|
|
25
|
-
const result = (this.options.validator ?? defaultOverlayValidator)(overlay);
|
|
26
|
-
if (!result.valid) {
|
|
27
|
-
const reason = result.issues.map((issue) => `${issue.code}: ${issue.message}`).join("; ");
|
|
28
|
-
throw new Error(`Overlay "${overlay.overlayId}" failed validation: ${reason}`);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
const normalized = this.ensureSigned(overlay);
|
|
32
|
-
const key = this.getKey(normalized.overlayId, normalized.version);
|
|
33
|
-
const stored = {
|
|
34
|
-
overlay: normalized,
|
|
35
|
-
specificity: computeSpecificity(normalized.appliesTo),
|
|
36
|
-
registeredAt: Date.now()
|
|
37
|
-
};
|
|
38
|
-
this.overlays.set(key, stored);
|
|
39
|
-
return normalized;
|
|
40
|
-
}
|
|
41
|
-
unregister(overlayId, version) {
|
|
42
|
-
if (version) {
|
|
43
|
-
this.overlays.delete(this.getKey(overlayId, version));
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
for (const key of Array.from(this.overlays.keys())) if (key.startsWith(`${overlayId}@`)) this.overlays.delete(key);
|
|
47
|
-
}
|
|
48
|
-
list() {
|
|
49
|
-
return Array.from(this.overlays.values()).map((entry) => entry.overlay);
|
|
50
|
-
}
|
|
51
|
-
get(overlayId, version) {
|
|
52
|
-
return this.overlays.get(this.getKey(overlayId, version))?.overlay;
|
|
53
|
-
}
|
|
54
|
-
forContext(query) {
|
|
55
|
-
return Array.from(this.overlays.values()).filter((entry) => matches(entry.overlay.appliesTo, query)).sort((a, b) => {
|
|
56
|
-
if (a.specificity !== b.specificity) return a.specificity - b.specificity;
|
|
57
|
-
return a.registeredAt - b.registeredAt;
|
|
58
|
-
}).map((entry) => entry.overlay);
|
|
59
|
-
}
|
|
60
|
-
clear() {
|
|
61
|
-
this.overlays.clear();
|
|
62
|
-
}
|
|
63
|
-
size() {
|
|
64
|
-
return this.overlays.size;
|
|
65
|
-
}
|
|
66
|
-
ensureSigned(input) {
|
|
67
|
-
if (isSignedOverlay(input)) {
|
|
68
|
-
if (!input.signature?.signature && !this.options.allowUnsigned) throw new Error(`Overlay "${input.overlayId}" is missing a signature.`);
|
|
69
|
-
return input;
|
|
70
|
-
}
|
|
71
|
-
if (!this.options.allowUnsigned) throw new Error(`Overlay "${input.overlayId}" must be signed before registration.`);
|
|
72
|
-
return input;
|
|
73
|
-
}
|
|
74
|
-
getKey(overlayId, version) {
|
|
75
|
-
return `${overlayId}@${version}`;
|
|
76
|
-
}
|
|
137
|
+
var SCOPE_WEIGHTS = {
|
|
138
|
+
tenantId: 8,
|
|
139
|
+
role: 4,
|
|
140
|
+
userId: 16,
|
|
141
|
+
device: 2,
|
|
142
|
+
tags: 1
|
|
77
143
|
};
|
|
144
|
+
|
|
145
|
+
class OverlayRegistry {
|
|
146
|
+
options;
|
|
147
|
+
overlays = new Map;
|
|
148
|
+
constructor(options = {}) {
|
|
149
|
+
this.options = options;
|
|
150
|
+
}
|
|
151
|
+
register(overlay, options) {
|
|
152
|
+
if (!options?.skipValidation) {
|
|
153
|
+
const validator = this.options.validator ?? defaultOverlayValidator;
|
|
154
|
+
const result = validator(overlay);
|
|
155
|
+
if (!result.valid) {
|
|
156
|
+
const reason = result.issues.map((issue) => `${issue.code}: ${issue.message}`).join("; ");
|
|
157
|
+
throw new Error(`Overlay "${overlay.overlayId}" failed validation: ${reason}`);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
const normalized = this.ensureSigned(overlay);
|
|
161
|
+
const key = this.getKey(normalized.overlayId, normalized.version);
|
|
162
|
+
const stored = {
|
|
163
|
+
overlay: normalized,
|
|
164
|
+
specificity: computeSpecificity(normalized.appliesTo),
|
|
165
|
+
registeredAt: Date.now()
|
|
166
|
+
};
|
|
167
|
+
this.overlays.set(key, stored);
|
|
168
|
+
return normalized;
|
|
169
|
+
}
|
|
170
|
+
unregister(overlayId, version) {
|
|
171
|
+
if (version) {
|
|
172
|
+
this.overlays.delete(this.getKey(overlayId, version));
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
for (const key of Array.from(this.overlays.keys())) {
|
|
176
|
+
if (key.startsWith(`${overlayId}@`)) {
|
|
177
|
+
this.overlays.delete(key);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
list() {
|
|
182
|
+
return Array.from(this.overlays.values()).map((entry) => entry.overlay);
|
|
183
|
+
}
|
|
184
|
+
get(overlayId, version) {
|
|
185
|
+
return this.overlays.get(this.getKey(overlayId, version))?.overlay;
|
|
186
|
+
}
|
|
187
|
+
forContext(query) {
|
|
188
|
+
return Array.from(this.overlays.values()).filter((entry) => matches(entry.overlay.appliesTo, query)).sort((a, b) => {
|
|
189
|
+
if (a.specificity !== b.specificity) {
|
|
190
|
+
return a.specificity - b.specificity;
|
|
191
|
+
}
|
|
192
|
+
return a.registeredAt - b.registeredAt;
|
|
193
|
+
}).map((entry) => entry.overlay);
|
|
194
|
+
}
|
|
195
|
+
clear() {
|
|
196
|
+
this.overlays.clear();
|
|
197
|
+
}
|
|
198
|
+
size() {
|
|
199
|
+
return this.overlays.size;
|
|
200
|
+
}
|
|
201
|
+
ensureSigned(input) {
|
|
202
|
+
if (isSignedOverlay(input)) {
|
|
203
|
+
if (!input.signature?.signature && !this.options.allowUnsigned) {
|
|
204
|
+
throw new Error(`Overlay "${input.overlayId}" is missing a signature.`);
|
|
205
|
+
}
|
|
206
|
+
return input;
|
|
207
|
+
}
|
|
208
|
+
if (!this.options.allowUnsigned) {
|
|
209
|
+
throw new Error(`Overlay "${input.overlayId}" must be signed before registration.`);
|
|
210
|
+
}
|
|
211
|
+
return input;
|
|
212
|
+
}
|
|
213
|
+
getKey(overlayId, version) {
|
|
214
|
+
return `${overlayId}@${version}`;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
78
217
|
function isSignedOverlay(spec) {
|
|
79
|
-
|
|
218
|
+
return Boolean(spec.signature);
|
|
80
219
|
}
|
|
81
220
|
function computeSpecificity(appliesTo) {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
221
|
+
let score = 0;
|
|
222
|
+
Object.keys(SCOPE_WEIGHTS).forEach((key) => {
|
|
223
|
+
const hasValue = key === "tags" ? Array.isArray(appliesTo.tags) && appliesTo.tags.length > 0 : Boolean(appliesTo[key]);
|
|
224
|
+
if (hasValue) {
|
|
225
|
+
score += SCOPE_WEIGHTS[key];
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
return score;
|
|
87
229
|
}
|
|
88
230
|
function matches(appliesTo, ctx) {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
231
|
+
for (const key of TARGET_KEYS2) {
|
|
232
|
+
const expected = appliesTo[key];
|
|
233
|
+
if (expected && expected !== ctx[key]) {
|
|
234
|
+
return false;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
if (appliesTo.tenantId && appliesTo.tenantId !== ctx.tenantId) {
|
|
238
|
+
return false;
|
|
239
|
+
}
|
|
240
|
+
if (appliesTo.role && appliesTo.role !== ctx.role) {
|
|
241
|
+
return false;
|
|
242
|
+
}
|
|
243
|
+
if (appliesTo.userId && appliesTo.userId !== ctx.userId) {
|
|
244
|
+
return false;
|
|
245
|
+
}
|
|
246
|
+
if (appliesTo.device && appliesTo.device !== ctx.device) {
|
|
247
|
+
return false;
|
|
248
|
+
}
|
|
249
|
+
if (appliesTo.tags?.length) {
|
|
250
|
+
if (!ctx.tags?.length) {
|
|
251
|
+
return false;
|
|
252
|
+
}
|
|
253
|
+
const ctxTags = new Set(ctx.tags);
|
|
254
|
+
const satisfies = appliesTo.tags.every((tag) => ctxTags.has(tag));
|
|
255
|
+
if (!satisfies) {
|
|
256
|
+
return false;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
return true;
|
|
103
260
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
//# sourceMappingURL=registry.js.map
|
|
261
|
+
export {
|
|
262
|
+
OverlayRegistry
|
|
263
|
+
};
|
package/dist/runtime.d.ts
CHANGED
|
@@ -1,28 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
registry: OverlayRegistry;
|
|
9
|
-
audit?: (event: OverlayAuditEvent) => void;
|
|
1
|
+
import { type ApplyOverlayOptions } from './merger';
|
|
2
|
+
import { OverlayRegistry, type OverlayLookup } from './registry';
|
|
3
|
+
import type { SignedOverlaySpec } from './spec';
|
|
4
|
+
import type { OverlayRenderable, OverlayAuditEvent } from './types';
|
|
5
|
+
export interface OverlayEngineOptions {
|
|
6
|
+
registry: OverlayRegistry;
|
|
7
|
+
audit?: (event: OverlayAuditEvent) => void;
|
|
10
8
|
}
|
|
11
|
-
interface OverlayApplyParams<T extends OverlayRenderable> extends OverlayLookup {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
export interface OverlayApplyParams<T extends OverlayRenderable> extends OverlayLookup {
|
|
10
|
+
target: T;
|
|
11
|
+
overlays?: SignedOverlaySpec[];
|
|
12
|
+
strict?: ApplyOverlayOptions['strict'];
|
|
15
13
|
}
|
|
16
|
-
interface OverlayRuntimeResult<T extends OverlayRenderable> {
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
export interface OverlayRuntimeResult<T extends OverlayRenderable> {
|
|
15
|
+
target: T;
|
|
16
|
+
overlaysApplied: SignedOverlaySpec[];
|
|
19
17
|
}
|
|
20
|
-
declare class OverlayEngine {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
18
|
+
export declare class OverlayEngine {
|
|
19
|
+
private readonly registry;
|
|
20
|
+
private readonly audit?;
|
|
21
|
+
constructor(options: OverlayEngineOptions);
|
|
22
|
+
apply<T extends OverlayRenderable>(params: OverlayApplyParams<T>): OverlayRuntimeResult<T>;
|
|
25
23
|
}
|
|
26
|
-
//#endregion
|
|
27
|
-
export { OverlayApplyParams, OverlayEngine, OverlayEngineOptions, OverlayRuntimeResult };
|
|
28
24
|
//# sourceMappingURL=runtime.d.ts.map
|
package/dist/runtime.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.ts","
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6B,KAAK,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAC/E,OAAO,EAAE,eAAe,EAAE,KAAK,aAAa,EAAE,MAAM,YAAY,CAAC;AACjE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAChD,OAAO,KAAK,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAEpE,MAAM,WAAW,oBAAoB;IACnC,QAAQ,EAAE,eAAe,CAAC;IAC1B,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,iBAAiB,KAAK,IAAI,CAAC;CAC5C;AAED,MAAM,WAAW,kBAAkB,CACjC,CAAC,SAAS,iBAAiB,CAC3B,SAAQ,aAAa;IACrB,MAAM,EAAE,CAAC,CAAC;IACV,QAAQ,CAAC,EAAE,iBAAiB,EAAE,CAAC;IAC/B,MAAM,CAAC,EAAE,mBAAmB,CAAC,QAAQ,CAAC,CAAC;CACxC;AAED,MAAM,WAAW,oBAAoB,CAAC,CAAC,SAAS,iBAAiB;IAC/D,MAAM,EAAE,CAAC,CAAC;IACV,eAAe,EAAE,iBAAiB,EAAE,CAAC;CACtC;AAED,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAkB;IAC3C,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAqC;gBAEhD,OAAO,EAAE,oBAAoB;IAKzC,KAAK,CAAC,CAAC,SAAS,iBAAiB,EAC/B,MAAM,EAAE,kBAAkB,CAAC,CAAC,CAAC,GAC5B,oBAAoB,CAAC,CAAC,CAAC;CAqC3B"}
|