@lssm/example.personalization 0.0.0-canary-20251217080011 → 1.41.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.
Files changed (70) hide show
  1. package/.turbo/turbo-build.log +18 -20
  2. package/dist/behavior-tracking.js +1 -49
  3. package/dist/docs/index.js +1 -1
  4. package/dist/docs/personalization.docblock.js +8 -29
  5. package/dist/example.js +1 -38
  6. package/dist/index.js +1 -7
  7. package/dist/overlay-customization.js +1 -53
  8. package/dist/workflow-extension.js +1 -67
  9. package/package.json +15 -18
  10. package/tsconfig.tsbuildinfo +1 -1
  11. package/.turbo/turbo-build$colon$bundle.log +0 -96
  12. package/CHANGELOG.md +0 -17
  13. package/dist/behavior-tracking.d.ts +0 -4
  14. package/dist/docs/index.d.ts +0 -1
  15. package/dist/docs/personalization.docblock.d.ts +0 -1
  16. package/dist/example.d.ts +0 -33
  17. package/dist/index.d.ts +0 -5
  18. package/dist/libs/contracts/dist/docs/PUBLISHING.docblock.js +0 -16
  19. package/dist/libs/contracts/dist/docs/accessibility_wcag_compliance_specs.docblock.js +0 -16
  20. package/dist/libs/contracts/dist/docs/index.js +0 -29
  21. package/dist/libs/contracts/dist/docs/presentations.js +0 -71
  22. package/dist/libs/contracts/dist/docs/registry.js +0 -44
  23. package/dist/libs/contracts/dist/docs/tech/PHASE_1_QUICKSTART.docblock.js +0 -16
  24. package/dist/libs/contracts/dist/docs/tech/PHASE_2_AI_NATIVE_OPERATIONS.docblock.js +0 -16
  25. package/dist/libs/contracts/dist/docs/tech/PHASE_3_AUTO_EVOLUTION.docblock.js +0 -16
  26. package/dist/libs/contracts/dist/docs/tech/PHASE_4_PERSONALIZATION_ENGINE.docblock.js +0 -16
  27. package/dist/libs/contracts/dist/docs/tech/PHASE_5_ZERO_TOUCH_OPERATIONS.docblock.js +0 -16
  28. package/dist/libs/contracts/dist/docs/tech/auth/better-auth-nextjs.docblock.js +0 -80
  29. package/dist/libs/contracts/dist/docs/tech/contracts/openapi-export.docblock.js +0 -57
  30. package/dist/libs/contracts/dist/docs/tech/lifecycle-stage-system.docblock.js +0 -16
  31. package/dist/libs/contracts/dist/docs/tech/llm/llm-integration.docblock.js +0 -357
  32. package/dist/libs/contracts/dist/docs/tech/mcp-endpoints.docblock.js +0 -37
  33. package/dist/libs/contracts/dist/docs/tech/presentation-runtime.docblock.js +0 -16
  34. package/dist/libs/contracts/dist/docs/tech/schema/README.docblock.js +0 -20
  35. package/dist/libs/contracts/dist/docs/tech/studio/learning-events.docblock.js +0 -48
  36. package/dist/libs/contracts/dist/docs/tech/studio/learning-journeys.docblock.js +0 -79
  37. package/dist/libs/contracts/dist/docs/tech/studio/platform-admin-panel.docblock.js +0 -84
  38. package/dist/libs/contracts/dist/docs/tech/studio/project-access-teams.docblock.js +0 -45
  39. package/dist/libs/contracts/dist/docs/tech/studio/project-routing.docblock.js +0 -67
  40. package/dist/libs/contracts/dist/docs/tech/studio/sandbox-unlogged.docblock.js +0 -40
  41. package/dist/libs/contracts/dist/docs/tech/studio/team-invitations.docblock.js +0 -69
  42. package/dist/libs/contracts/dist/docs/tech/studio/workspace-ops.docblock.js +0 -47
  43. package/dist/libs/contracts/dist/docs/tech/studio/workspaces.docblock.js +0 -62
  44. package/dist/libs/contracts/dist/docs/tech/telemetry-ingest.docblock.js +0 -155
  45. package/dist/libs/contracts/dist/docs/tech/templates/runtime.docblock.js +0 -20
  46. package/dist/libs/contracts/dist/docs/tech/vscode-extension.docblock.js +0 -101
  47. package/dist/libs/contracts/dist/docs/tech/workflows/overview.docblock.js +0 -20
  48. package/dist/libs/logger/dist/context.node.js +0 -78
  49. package/dist/libs/logger/dist/elysia-plugin.js +0 -3
  50. package/dist/libs/logger/dist/formatters.js +0 -163
  51. package/dist/libs/logger/dist/index.js +0 -7
  52. package/dist/libs/logger/dist/logger.node.js +0 -189
  53. package/dist/libs/logger/dist/timer.js +0 -126
  54. package/dist/libs/logger/dist/tracer.node.js +0 -115
  55. package/dist/libs/logger/dist/types.js +0 -13
  56. package/dist/libs/overlay-engine/dist/index.js +0 -6
  57. package/dist/libs/overlay-engine/dist/merger.js +0 -106
  58. package/dist/libs/overlay-engine/dist/registry.js +0 -106
  59. package/dist/libs/overlay-engine/dist/runtime.js +0 -53
  60. package/dist/libs/overlay-engine/dist/signer.js +0 -45
  61. package/dist/libs/overlay-engine/dist/spec.js +0 -7
  62. package/dist/libs/overlay-engine/dist/validator.js +0 -93
  63. package/dist/libs/personalization/dist/analyzer.js +0 -54
  64. package/dist/libs/personalization/dist/store.js +0 -58
  65. package/dist/libs/personalization/dist/tracker.js +0 -92
  66. package/dist/libs/workflow-composer/dist/composer.js +0 -28
  67. package/dist/libs/workflow-composer/dist/injector.js +0 -72
  68. package/dist/libs/workflow-composer/dist/validator.js +0 -36
  69. package/dist/overlay-customization.d.ts +0 -4
  70. package/dist/workflow-extension.d.ts +0 -7
@@ -1,126 +0,0 @@
1
- //#region ../../libs/logger/dist/timer.mjs
2
- var Timer = class {
3
- id;
4
- startTime;
5
- laps = [];
6
- stopped = false;
7
- stopTime;
8
- constructor(id) {
9
- this.id = id || crypto.randomUUID();
10
- this.startTime = performance.now();
11
- }
12
- /**
13
- * Stop the timer and return elapsed time in milliseconds
14
- */
15
- stop() {
16
- if (this.stopped) return this.getElapsed();
17
- this.stopTime = performance.now();
18
- this.stopped = true;
19
- const elapsed = this.stopTime - this.startTime;
20
- this.laps.push({
21
- label: "stop",
22
- time: this.stopTime,
23
- elapsed
24
- });
25
- return elapsed;
26
- }
27
- /**
28
- * Record a lap time and return elapsed time since start
29
- */
30
- lap(label) {
31
- if (this.stopped) return this.getElapsed();
32
- const now = performance.now();
33
- const elapsed = now - this.startTime;
34
- this.laps.push({
35
- label: label || `lap-${this.laps.length + 1}`,
36
- time: now,
37
- elapsed
38
- });
39
- return elapsed;
40
- }
41
- /**
42
- * Get elapsed time without stopping the timer
43
- */
44
- getElapsed() {
45
- if (this.stopped && this.stopTime) return this.stopTime - this.startTime;
46
- return performance.now() - this.startTime;
47
- }
48
- /**
49
- * Get all recorded laps
50
- */
51
- getLaps() {
52
- return [...this.laps];
53
- }
54
- /**
55
- * Get timer summary with total time and laps
56
- */
57
- getSummary() {
58
- return {
59
- id: this.id,
60
- totalTime: this.getElapsed(),
61
- isRunning: !this.stopped,
62
- laps: this.getLaps()
63
- };
64
- }
65
- /**
66
- * Reset the timer (starts a new timing session)
67
- */
68
- reset() {
69
- this.startTime = performance.now();
70
- this.laps = [];
71
- this.stopped = false;
72
- this.stopTime = void 0;
73
- }
74
- };
75
- /**
76
- * Utility class for managing multiple timers
77
- */
78
- var TimerManager = class {
79
- timers = /* @__PURE__ */ new Map();
80
- /**
81
- * Start a new timer
82
- */
83
- start(id) {
84
- const timer = new Timer(id);
85
- this.timers.set(timer.id, timer);
86
- return timer;
87
- }
88
- /**
89
- * Get an existing timer
90
- */
91
- get(id) {
92
- return this.timers.get(id);
93
- }
94
- /**
95
- * Stop and remove a timer
96
- */
97
- stop(id) {
98
- const timer = this.timers.get(id);
99
- if (timer) {
100
- const elapsed = timer.stop();
101
- this.timers.delete(id);
102
- return elapsed;
103
- }
104
- }
105
- /**
106
- * Get all active timers
107
- */
108
- getActive() {
109
- return Array.from(this.timers.values()).filter((timer) => !timer.getSummary().isRunning === false);
110
- }
111
- /**
112
- * Clear all timers
113
- */
114
- clear() {
115
- this.timers.clear();
116
- }
117
- /**
118
- * Get summary of all timers
119
- */
120
- getSummary() {
121
- return Array.from(this.timers.values()).map((timer) => timer.getSummary());
122
- }
123
- };
124
-
125
- //#endregion
126
- export { Timer, TimerManager };
@@ -1,115 +0,0 @@
1
- import { LogContext } from "./context.node.js";
2
- import { Timer } from "./timer.js";
3
-
4
- //#region ../../libs/logger/dist/tracer.node.mjs
5
- var Tracer = class {
6
- context;
7
- activeSpans = /* @__PURE__ */ new Map();
8
- constructor() {
9
- this.context = LogContext.getInstance();
10
- }
11
- /**
12
- * Start a new trace span
13
- */
14
- startSpan(options) {
15
- const parentTrace = this.context.getCurrentTrace();
16
- const span = {
17
- traceId: parentTrace?.traceId || this.generateTraceId(),
18
- parentId: parentTrace?.spanId,
19
- spanId: this.generateSpanId(),
20
- operationType: options.operationType,
21
- operationName: options.operationName,
22
- startTime: performance.now(),
23
- metadata: { ...options.metadata },
24
- tags: [...options.tags || []]
25
- };
26
- this.activeSpans.set(span.spanId, span);
27
- this.context.setTrace(span);
28
- return span;
29
- }
30
- /**
31
- * Finish a trace span
32
- */
33
- finishSpan(spanId) {
34
- const span = this.activeSpans.get(spanId);
35
- if (!span) return;
36
- const duration = performance.now() - span.startTime;
37
- this.activeSpans.delete(spanId);
38
- if (this.context.getCurrentTrace()?.spanId === spanId && span.parentId) {
39
- const parentSpan = this.findSpanById(span.parentId);
40
- if (parentSpan) this.context.setTrace(parentSpan);
41
- }
42
- return duration;
43
- }
44
- /**
45
- * Execute a function within a trace span
46
- */
47
- async trace(options, fn) {
48
- const span = this.startSpan(options);
49
- const timer = options.autoTiming !== false ? new Timer(`trace-${span.spanId}`) : void 0;
50
- try {
51
- const result = await fn();
52
- const duration = this.finishSpan(span.spanId);
53
- if (timer) timer.stop();
54
- if (duration !== void 0) span.metadata.duration = duration;
55
- return result;
56
- } catch (error) {
57
- span.metadata.error = {
58
- name: error.name || "Unknown",
59
- message: error.message || "Unknown error",
60
- stack: error.stack
61
- };
62
- const duration = this.finishSpan(span.spanId);
63
- span.metadata.duration = duration;
64
- if (timer) timer.stop();
65
- throw error;
66
- }
67
- }
68
- /**
69
- * Add metadata to current span
70
- */
71
- addMetadata(key, value) {
72
- const currentTrace = this.context.getCurrentTrace();
73
- if (currentTrace) currentTrace.metadata[key] = value;
74
- }
75
- /**
76
- * Add tags to current span
77
- */
78
- addTags(...tags) {
79
- const currentTrace = this.context.getCurrentTrace();
80
- if (currentTrace) currentTrace.tags.push(...tags);
81
- }
82
- /**
83
- * Get current trace context
84
- */
85
- getCurrentTrace() {
86
- return this.context.getCurrentTrace();
87
- }
88
- /**
89
- * Get all active spans
90
- */
91
- getActiveSpans() {
92
- return Array.from(this.activeSpans.values());
93
- }
94
- /**
95
- * Find a span by ID
96
- */
97
- findSpanById(spanId) {
98
- return this.activeSpans.get(spanId);
99
- }
100
- /**
101
- * Generate a unique trace ID
102
- */
103
- generateTraceId() {
104
- return crypto.randomUUID().replace(/-/g, "");
105
- }
106
- /**
107
- * Generate a unique span ID
108
- */
109
- generateSpanId() {
110
- return crypto.randomUUID().replace(/-/g, "").substring(0, 16);
111
- }
112
- };
113
-
114
- //#endregion
115
- export { Tracer };
@@ -1,13 +0,0 @@
1
- //#region ../../libs/logger/dist/types.mjs
2
- let LogLevel = /* @__PURE__ */ function(LogLevel$1) {
3
- LogLevel$1[LogLevel$1["TRACE"] = 0] = "TRACE";
4
- LogLevel$1[LogLevel$1["DEBUG"] = 1] = "DEBUG";
5
- LogLevel$1[LogLevel$1["INFO"] = 2] = "INFO";
6
- LogLevel$1[LogLevel$1["WARN"] = 3] = "WARN";
7
- LogLevel$1[LogLevel$1["ERROR"] = 4] = "ERROR";
8
- LogLevel$1[LogLevel$1["FATAL"] = 5] = "FATAL";
9
- return LogLevel$1;
10
- }({});
11
-
12
- //#endregion
13
- export { LogLevel };
@@ -1,6 +0,0 @@
1
- import { defineOverlay } from "./spec.js";
2
- import { canonicalizeOverlay, signOverlay } from "./signer.js";
3
- import { defaultOverlayValidator, validateOverlaySpec } from "./validator.js";
4
- import { OverlayRegistry } from "./registry.js";
5
- import { applyOverlayModifications } from "./merger.js";
6
- import { OverlayEngine } from "./runtime.js";
@@ -1,106 +0,0 @@
1
- //#region ../../libs/overlay-engine/dist/merger.js
2
- function applyOverlayModifications(target, overlays, options = {}) {
3
- if (!overlays.length) return target;
4
- const states = target.fields.map((field) => ({
5
- key: field.key,
6
- field: { ...field },
7
- hidden: field.visible === false
8
- }));
9
- const fieldMap = new Map(states.map((state) => [state.key, state]));
10
- let orderSequence = target.fields.map((field) => field.key);
11
- const handleMissing = (field, overlayId) => {
12
- if (options.strict) throw new Error(`Overlay "${overlayId}" referenced unknown field "${field}".`);
13
- };
14
- overlays.forEach((overlay) => {
15
- overlay.modifications.forEach((modification) => {
16
- switch (modification.type) {
17
- case "hideField": {
18
- const state = fieldMap.get(modification.field);
19
- if (!state) return handleMissing(modification.field, overlay.overlayId);
20
- state.hidden = true;
21
- state.field.visible = false;
22
- break;
23
- }
24
- case "renameLabel": {
25
- const state = fieldMap.get(modification.field);
26
- if (!state) return handleMissing(modification.field, overlay.overlayId);
27
- state.field.label = modification.newLabel;
28
- break;
29
- }
30
- case "setDefault": {
31
- const state = fieldMap.get(modification.field);
32
- if (!state) return handleMissing(modification.field, overlay.overlayId);
33
- state.field.defaultValue = modification.value;
34
- break;
35
- }
36
- case "addHelpText": {
37
- const state = fieldMap.get(modification.field);
38
- if (!state) return handleMissing(modification.field, overlay.overlayId);
39
- state.field.helpText = modification.text;
40
- break;
41
- }
42
- case "makeRequired": {
43
- const state = fieldMap.get(modification.field);
44
- if (!state) return handleMissing(modification.field, overlay.overlayId);
45
- state.field.required = modification.required ?? true;
46
- break;
47
- }
48
- case "reorderFields": {
49
- const { filtered, missing } = normalizeOrderList(modification.fields, fieldMap);
50
- if (missing.length && options.strict) missing.forEach((field) => handleMissing(field, overlay.overlayId));
51
- orderSequence = applyReorder(orderSequence, filtered);
52
- break;
53
- }
54
- default: break;
55
- }
56
- });
57
- });
58
- const visibleFields = [];
59
- const seen = /* @__PURE__ */ new Set();
60
- orderSequence.forEach((key) => {
61
- const state = fieldMap.get(key);
62
- if (!state || state.hidden) return;
63
- seen.add(key);
64
- visibleFields.push(state.field);
65
- });
66
- states.forEach((state) => {
67
- if (state.hidden || seen.has(state.key)) return;
68
- visibleFields.push(state.field);
69
- });
70
- visibleFields.forEach((field, index) => {
71
- field.order = index;
72
- field.visible = true;
73
- });
74
- return {
75
- ...target,
76
- fields: visibleFields
77
- };
78
- }
79
- function normalizeOrderList(fields, fieldMap) {
80
- const filtered = [];
81
- const missing = [];
82
- const seen = /* @__PURE__ */ new Set();
83
- fields.forEach((field) => {
84
- if (!field?.trim()) return;
85
- if (!fieldMap.has(field)) {
86
- missing.push(field);
87
- return;
88
- }
89
- if (seen.has(field)) return;
90
- seen.add(field);
91
- filtered.push(field);
92
- });
93
- return {
94
- filtered,
95
- missing
96
- };
97
- }
98
- function applyReorder(sequence, orderedFields) {
99
- if (!orderedFields.length) return sequence;
100
- const orderedSet = new Set(orderedFields);
101
- const remainder = sequence.filter((key) => !orderedSet.has(key));
102
- return [...orderedFields, ...remainder];
103
- }
104
-
105
- //#endregion
106
- export { applyOverlayModifications };
@@ -1,106 +0,0 @@
1
- import { defaultOverlayValidator } from "./validator.js";
2
-
3
- //#region ../../libs/overlay-engine/dist/registry.js
4
- const TARGET_KEYS = [
5
- "capability",
6
- "workflow",
7
- "dataView",
8
- "presentation",
9
- "operation"
10
- ];
11
- const SCOPE_WEIGHTS = {
12
- tenantId: 8,
13
- role: 4,
14
- userId: 16,
15
- device: 2,
16
- tags: 1
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
- }
77
- };
78
- function isSignedOverlay(spec) {
79
- return Boolean(spec.signature);
80
- }
81
- function computeSpecificity(appliesTo) {
82
- let score = 0;
83
- Object.keys(SCOPE_WEIGHTS).forEach((key) => {
84
- if (key === "tags" ? Array.isArray(appliesTo.tags) && appliesTo.tags.length > 0 : Boolean(appliesTo[key])) score += SCOPE_WEIGHTS[key];
85
- });
86
- return score;
87
- }
88
- function matches(appliesTo, ctx) {
89
- for (const key of TARGET_KEYS) {
90
- const expected = appliesTo[key];
91
- if (expected && expected !== ctx[key]) return false;
92
- }
93
- if (appliesTo.tenantId && appliesTo.tenantId !== ctx.tenantId) return false;
94
- if (appliesTo.role && appliesTo.role !== ctx.role) return false;
95
- if (appliesTo.userId && appliesTo.userId !== ctx.userId) return false;
96
- if (appliesTo.device && appliesTo.device !== ctx.device) return false;
97
- if (appliesTo.tags?.length) {
98
- if (!ctx.tags?.length) return false;
99
- const ctxTags = new Set(ctx.tags);
100
- if (!appliesTo.tags.every((tag) => ctxTags.has(tag))) return false;
101
- }
102
- return true;
103
- }
104
-
105
- //#endregion
106
- export { OverlayRegistry };
@@ -1,53 +0,0 @@
1
- import { applyOverlayModifications } from "./merger.js";
2
-
3
- //#region ../../libs/overlay-engine/dist/runtime.js
4
- var OverlayEngine = class {
5
- registry;
6
- audit;
7
- constructor(options) {
8
- this.registry = options.registry;
9
- this.audit = options.audit;
10
- }
11
- apply(params) {
12
- const overlays = params.overlays ?? this.registry.forContext({
13
- capability: params.capability,
14
- workflow: params.workflow,
15
- dataView: params.dataView,
16
- presentation: params.presentation,
17
- operation: params.operation,
18
- tenantId: params.tenantId,
19
- role: params.role,
20
- userId: params.userId,
21
- device: params.device,
22
- tags: params.tags
23
- });
24
- const merged = applyOverlayModifications(params.target, overlays, { strict: params.strict });
25
- const context = extractContext(params);
26
- overlays.forEach((overlay) => {
27
- this.audit?.({
28
- overlay: {
29
- overlayId: overlay.overlayId,
30
- version: overlay.version
31
- },
32
- context,
33
- timestamp: (/* @__PURE__ */ new Date()).toISOString()
34
- });
35
- });
36
- return {
37
- target: merged,
38
- overlaysApplied: overlays
39
- };
40
- }
41
- };
42
- function extractContext(params) {
43
- return {
44
- tenantId: params.tenantId,
45
- role: params.role,
46
- userId: params.userId,
47
- device: params.device,
48
- tags: params.tags
49
- };
50
- }
51
-
52
- //#endregion
53
- export { OverlayEngine };
@@ -1,45 +0,0 @@
1
- import stringify from "fast-json-stable-stringify";
2
- import { constants, createPrivateKey, createPublicKey, sign } from "crypto";
3
-
4
- //#region ../../libs/overlay-engine/dist/signer.js
5
- function signOverlay(spec, privateKey, options = {}) {
6
- const algorithm = options.algorithm ?? "ed25519";
7
- const keyObject = typeof privateKey === "string" || Buffer.isBuffer(privateKey) ? createPrivateKey(privateKey) : privateKey;
8
- const payload = Buffer.from(canonicalizeOverlay(spec), "utf8");
9
- let rawSignature;
10
- if (algorithm === "ed25519") rawSignature = sign(null, payload, keyObject);
11
- else if (algorithm === "rsa-pss-sha256") rawSignature = sign("sha256", payload, {
12
- key: keyObject,
13
- padding: constants.RSA_PKCS1_PSS_PADDING,
14
- saltLength: 32
15
- });
16
- else throw new Error(`Unsupported overlay signature algorithm: ${algorithm}`);
17
- const publicKey = options.publicKey ?? createPublicKey(keyObject).export({
18
- format: "pem",
19
- type: "spki"
20
- }).toString();
21
- return {
22
- ...spec,
23
- signature: {
24
- algorithm,
25
- signature: rawSignature.toString("base64"),
26
- publicKey,
27
- keyId: options.keyId,
28
- issuedAt: toIso(options.issuedAt) ?? (/* @__PURE__ */ new Date()).toISOString(),
29
- expiresAt: toIso(options.expiresAt),
30
- metadata: options.metadata
31
- }
32
- };
33
- }
34
- function canonicalizeOverlay(spec) {
35
- const { signature, ...rest } = spec;
36
- return stringify(rest);
37
- }
38
- function toIso(value) {
39
- if (!value) return;
40
- if (typeof value === "string") return new Date(value).toISOString();
41
- return value.toISOString();
42
- }
43
-
44
- //#endregion
45
- export { canonicalizeOverlay, signOverlay };
@@ -1,7 +0,0 @@
1
- //#region ../../libs/overlay-engine/dist/spec.js
2
- function defineOverlay(spec) {
3
- return spec;
4
- }
5
-
6
- //#endregion
7
- export { defineOverlay };
@@ -1,93 +0,0 @@
1
- //#region ../../libs/overlay-engine/dist/validator.js
2
- const TARGET_KEYS = [
3
- "capability",
4
- "workflow",
5
- "dataView",
6
- "presentation",
7
- "operation"
8
- ];
9
- const defaultOverlayValidator = (spec) => validateOverlaySpec(spec);
10
- function validateOverlaySpec(spec) {
11
- const issues = [];
12
- if (!spec.overlayId?.trim()) issues.push({
13
- code: "overlay.id",
14
- message: "overlayId is required",
15
- path: ["overlayId"]
16
- });
17
- if (!spec.version?.trim()) issues.push({
18
- code: "overlay.version",
19
- message: "version is required",
20
- path: ["version"]
21
- });
22
- if (!TARGET_KEYS.some((key) => {
23
- const value = spec.appliesTo?.[key];
24
- return typeof value === "string" && value.trim().length > 0;
25
- })) issues.push({
26
- code: "overlay.target",
27
- message: "Overlay must specify at least one target (capability, workflow, dataView, presentation, or operation).",
28
- path: ["appliesTo"]
29
- });
30
- if (!spec.modifications?.length) issues.push({
31
- code: "overlay.modifications.empty",
32
- message: "Overlay must include at least one modification.",
33
- path: ["modifications"]
34
- });
35
- else spec.modifications.forEach((mod, idx) => {
36
- validateModification(mod, ["modifications", String(idx)], issues);
37
- });
38
- return {
39
- valid: issues.length === 0,
40
- issues
41
- };
42
- }
43
- function validateModification(modification, path, issues) {
44
- const push = (code, message, extraPath) => {
45
- issues.push({
46
- code,
47
- message,
48
- path: extraPath ? [...path, ...extraPath] : path
49
- });
50
- };
51
- if (isFieldModification(modification)) {
52
- if (!modification.field?.trim()) push("overlay.mod.field", "field is required for this modification", ["field"]);
53
- }
54
- switch (modification.type) {
55
- case "renameLabel":
56
- if (!modification.newLabel?.trim()) push("overlay.mod.renameLabel.newLabel", "newLabel is required", ["newLabel"]);
57
- break;
58
- case "reorderFields": {
59
- if (!modification.fields?.length) push("overlay.mod.reorderFields.fields", "fields list cannot be empty", ["fields"]);
60
- const seen = /* @__PURE__ */ new Set();
61
- for (const field of modification.fields ?? []) {
62
- if (!field?.trim()) {
63
- push("overlay.mod.reorderFields.fields.blank", "fields entries must be non-empty");
64
- break;
65
- }
66
- if (seen.has(field)) {
67
- push("overlay.mod.reorderFields.fields.duplicate", `field "${field}" was listed multiple times`);
68
- break;
69
- }
70
- seen.add(field);
71
- }
72
- break;
73
- }
74
- case "setDefault":
75
- if (modification.value === void 0) push("overlay.mod.setDefault.value", "value is required", ["value"]);
76
- break;
77
- case "addHelpText":
78
- if (!modification.text?.trim()) push("overlay.mod.addHelpText.text", "text is required", ["text"]);
79
- break;
80
- case "makeRequired":
81
- case "hideField": break;
82
- default: {
83
- const exhaustive = modification;
84
- throw new Error(`Unsupported overlay modification ${exhaustive?.type ?? "unknown"}`);
85
- }
86
- }
87
- }
88
- function isFieldModification(mod) {
89
- return "field" in mod;
90
- }
91
-
92
- //#endregion
93
- export { defaultOverlayValidator, validateOverlaySpec };