@lssm/lib.overlay-engine 0.3.1 → 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.
package/README.md CHANGED
@@ -64,4 +64,9 @@ See `docs/tech/personalization/overlay-engine.md` for additional details.
64
64
 
65
65
 
66
66
 
67
+
68
+
69
+
70
+
71
+
67
72
 
package/dist/types.js ADDED
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lssm/lib.overlay-engine",
3
- "version": "0.3.1",
3
+ "version": "1.41.0",
4
4
  "description": "Runtime overlay engine for ContractSpec personalization and adaptive UI rendering.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -23,7 +23,7 @@
23
23
  "test": "bun run"
24
24
  },
25
25
  "dependencies": {
26
- "@lssm/lib.contracts": "1.11.1",
26
+ "@lssm/lib.contracts": "workspace:*",
27
27
  "fast-json-stable-stringify": "^2.1.0"
28
28
  },
29
29
  "peerDependencies": {
@@ -35,17 +35,36 @@
35
35
  }
36
36
  },
37
37
  "devDependencies": {
38
- "@lssm/tool.tsdown": "0.12.1",
39
- "@lssm/tool.typescript": "0.11.1",
40
- "tsdown": "^0.16.6",
38
+ "@lssm/tool.tsdown": "workspace:*",
39
+ "@lssm/tool.typescript": "workspace:*",
40
+ "tsdown": "^0.17.4",
41
41
  "typescript": "^5.9.3"
42
42
  },
43
43
  "exports": {
44
- ".": "./dist/index.js",
45
- "./react": "./dist/react.js",
44
+ ".": "./src/index.ts",
45
+ "./merger": "./src/merger.ts",
46
+ "./react": "./src/react.ts",
47
+ "./registry": "./src/registry.ts",
48
+ "./runtime": "./src/runtime.ts",
49
+ "./signer": "./src/signer.ts",
50
+ "./spec": "./src/spec.ts",
51
+ "./types": "./src/types.ts",
52
+ "./validator": "./src/validator.ts",
46
53
  "./*": "./*"
47
54
  },
48
55
  "publishConfig": {
49
- "access": "public"
56
+ "access": "public",
57
+ "exports": {
58
+ ".": "./dist/index.js",
59
+ "./merger": "./dist/merger.js",
60
+ "./react": "./dist/react.js",
61
+ "./registry": "./dist/registry.js",
62
+ "./runtime": "./dist/runtime.js",
63
+ "./signer": "./dist/signer.js",
64
+ "./spec": "./dist/spec.js",
65
+ "./types": "./dist/types.js",
66
+ "./validator": "./dist/validator.js",
67
+ "./*": "./*"
68
+ }
50
69
  }
51
70
  }
package/dist/index.d.ts DELETED
@@ -1,8 +0,0 @@
1
- import { AddHelpTextModification, HideFieldModification, MakeRequiredModification, OVERLAY_SCOPE_ORDER, OverlayAppliesTo, OverlayFieldModificationBase, OverlayInput, OverlayModification, OverlayScopeContext, OverlayScopeKey, OverlaySignatureAlgorithm, OverlaySignatureBlock, OverlaySpec, OverlayTargetRef, RenameLabelModification, ReorderFieldsModification, SetDefaultModification, SignedOverlaySpec, defineOverlay } from "./spec.js";
2
- import { OverlayAuditEvent, OverlayLayoutConfig, OverlayMatchContext, OverlayRenderable, OverlayRenderableField } from "./types.js";
3
- import { OverlayValidationIssue, OverlayValidationResult, OverlayValidator, assertOverlayValid, defaultOverlayValidator, validateOverlaySpec } from "./validator.js";
4
- import { OverlayLookup, OverlayRegistry, OverlayRegistryOptions } from "./registry.js";
5
- import { ApplyOverlayOptions, applyOverlayModifications } from "./merger.js";
6
- import { OverlayApplyParams, OverlayEngine, OverlayEngineOptions, OverlayRuntimeResult } from "./runtime.js";
7
- import { SignOverlayOptions, canonicalizeOverlay, signOverlay, stripSignature, verifyOverlaySignature } from "./signer.js";
8
- export { AddHelpTextModification, ApplyOverlayOptions, HideFieldModification, MakeRequiredModification, OVERLAY_SCOPE_ORDER, OverlayAppliesTo, OverlayApplyParams, OverlayAuditEvent, OverlayEngine, OverlayEngineOptions, OverlayFieldModificationBase, OverlayInput, OverlayLayoutConfig, OverlayLookup, OverlayMatchContext, OverlayModification, OverlayRegistry, OverlayRegistryOptions, OverlayRenderable, OverlayRenderableField, OverlayRuntimeResult, OverlayScopeContext, OverlayScopeKey, OverlaySignatureAlgorithm, OverlaySignatureBlock, OverlaySpec, OverlayTargetRef, OverlayValidationIssue, OverlayValidationResult, OverlayValidator, RenameLabelModification, ReorderFieldsModification, SetDefaultModification, SignOverlayOptions, SignedOverlaySpec, applyOverlayModifications, assertOverlayValid, canonicalizeOverlay, defaultOverlayValidator, defineOverlay, signOverlay, stripSignature, validateOverlaySpec, verifyOverlaySignature };
package/dist/merger.d.ts DELETED
@@ -1,10 +0,0 @@
1
- import { SignedOverlaySpec } from "./spec.js";
2
- import { OverlayRenderable } from "./types.js";
3
-
4
- //#region src/merger.d.ts
5
- interface ApplyOverlayOptions {
6
- strict?: boolean;
7
- }
8
- declare function applyOverlayModifications<T extends OverlayRenderable>(target: T, overlays: SignedOverlaySpec[], options?: ApplyOverlayOptions): T;
9
- //#endregion
10
- export { ApplyOverlayOptions, applyOverlayModifications };
package/dist/react.d.ts DELETED
@@ -1,9 +0,0 @@
1
- import { OverlayRenderable } from "./types.js";
2
- import { OverlayApplyParams, OverlayEngine, OverlayRuntimeResult } from "./runtime.js";
3
- import { DependencyList } from "react";
4
-
5
- //#region src/react.d.ts
6
- declare function useOverlay<T extends OverlayRenderable>(engine: OverlayEngine | undefined, params: OverlayApplyParams<T>, deps?: DependencyList): OverlayRuntimeResult<T>;
7
- declare function useOverlayFields<T extends OverlayRenderable>(engine: OverlayEngine | undefined, params: OverlayApplyParams<T>, deps?: DependencyList): T['fields'];
8
- //#endregion
9
- export { useOverlay, useOverlayFields };
@@ -1,27 +0,0 @@
1
- import { OverlayInput, OverlayScopeContext, OverlayTargetRef, SignedOverlaySpec } from "./spec.js";
2
- import { OverlayValidator } from "./validator.js";
3
-
4
- //#region src/registry.d.ts
5
- interface OverlayRegistryOptions {
6
- validator?: OverlayValidator;
7
- allowUnsigned?: boolean;
8
- }
9
- interface OverlayLookup extends OverlayScopeContext, OverlayTargetRef {}
10
- declare class OverlayRegistry {
11
- private readonly options;
12
- private readonly overlays;
13
- constructor(options?: OverlayRegistryOptions);
14
- register(overlay: OverlayInput, options?: {
15
- skipValidation?: boolean;
16
- }): SignedOverlaySpec;
17
- unregister(overlayId: string, version?: string): void;
18
- list(): SignedOverlaySpec[];
19
- get(overlayId: string, version: string): SignedOverlaySpec | undefined;
20
- forContext(query: OverlayLookup): SignedOverlaySpec[];
21
- clear(): void;
22
- size(): number;
23
- private ensureSigned;
24
- private getKey;
25
- }
26
- //#endregion
27
- export { OverlayLookup, OverlayRegistry, OverlayRegistryOptions };
package/dist/runtime.d.ts DELETED
@@ -1,27 +0,0 @@
1
- import { SignedOverlaySpec } from "./spec.js";
2
- import { OverlayAuditEvent, OverlayRenderable } from "./types.js";
3
- import { OverlayLookup, OverlayRegistry } from "./registry.js";
4
- import { ApplyOverlayOptions } from "./merger.js";
5
-
6
- //#region src/runtime.d.ts
7
- interface OverlayEngineOptions {
8
- registry: OverlayRegistry;
9
- audit?: (event: OverlayAuditEvent) => void;
10
- }
11
- interface OverlayApplyParams<T extends OverlayRenderable> extends OverlayLookup {
12
- target: T;
13
- overlays?: SignedOverlaySpec[];
14
- strict?: ApplyOverlayOptions['strict'];
15
- }
16
- interface OverlayRuntimeResult<T extends OverlayRenderable> {
17
- target: T;
18
- overlaysApplied: SignedOverlaySpec[];
19
- }
20
- declare class OverlayEngine {
21
- private readonly registry;
22
- private readonly audit?;
23
- constructor(options: OverlayEngineOptions);
24
- apply<T extends OverlayRenderable>(params: OverlayApplyParams<T>): OverlayRuntimeResult<T>;
25
- }
26
- //#endregion
27
- export { OverlayApplyParams, OverlayEngine, OverlayEngineOptions, OverlayRuntimeResult };
package/dist/signer.d.ts DELETED
@@ -1,18 +0,0 @@
1
- import { OverlaySignatureAlgorithm, OverlaySpec, SignedOverlaySpec } from "./spec.js";
2
- import { KeyLike } from "crypto";
3
-
4
- //#region src/signer.d.ts
5
- interface SignOverlayOptions {
6
- algorithm?: OverlaySignatureAlgorithm;
7
- keyId?: string;
8
- issuedAt?: Date | string;
9
- expiresAt?: Date | string;
10
- metadata?: Record<string, unknown>;
11
- publicKey?: string;
12
- }
13
- declare function signOverlay(spec: OverlaySpec, privateKey: KeyLike | string | Buffer, options?: SignOverlayOptions): SignedOverlaySpec;
14
- declare function verifyOverlaySignature(overlay: SignedOverlaySpec): boolean;
15
- declare function canonicalizeOverlay(spec: OverlaySpec | SignedOverlaySpec): string;
16
- declare function stripSignature<T extends OverlaySpec | SignedOverlaySpec>(spec: T): OverlaySpec;
17
- //#endregion
18
- export { SignOverlayOptions, canonicalizeOverlay, signOverlay, stripSignature, verifyOverlaySignature };
package/dist/spec.d.ts DELETED
@@ -1,82 +0,0 @@
1
- import { AnyContractSpec } from "@lssm/lib.contracts";
2
-
3
- //#region src/spec.d.ts
4
- type OverlayScopeKey = 'tenantId' | 'role' | 'userId' | 'device' | 'tags';
5
- interface OverlayScopeContext {
6
- tenantId?: string;
7
- role?: string;
8
- userId?: string;
9
- device?: string;
10
- tags?: string[];
11
- }
12
- interface OverlayTargetRef {
13
- capability?: string;
14
- workflow?: string;
15
- dataView?: string;
16
- presentation?: string;
17
- operation?: AnyContractSpec['meta']['name'];
18
- }
19
- interface OverlayAppliesTo extends OverlayScopeContext, OverlayTargetRef {
20
- /**
21
- * Optional label to describe why this overlay exists (displayed in tooling).
22
- */
23
- label?: string;
24
- }
25
- type OverlayModification = HideFieldModification | RenameLabelModification | ReorderFieldsModification | SetDefaultModification | AddHelpTextModification | MakeRequiredModification;
26
- interface OverlayFieldModificationBase {
27
- field: string;
28
- description?: string;
29
- }
30
- interface HideFieldModification extends OverlayFieldModificationBase {
31
- type: 'hideField';
32
- reason?: string;
33
- }
34
- interface RenameLabelModification extends OverlayFieldModificationBase {
35
- type: 'renameLabel';
36
- newLabel: string;
37
- }
38
- interface ReorderFieldsModification {
39
- type: 'reorderFields';
40
- fields: string[];
41
- description?: string;
42
- }
43
- interface SetDefaultModification extends OverlayFieldModificationBase {
44
- type: 'setDefault';
45
- value: unknown;
46
- }
47
- interface AddHelpTextModification extends OverlayFieldModificationBase {
48
- type: 'addHelpText';
49
- text: string;
50
- }
51
- interface MakeRequiredModification extends OverlayFieldModificationBase {
52
- type: 'makeRequired';
53
- required?: boolean;
54
- }
55
- interface OverlaySpec {
56
- overlayId: string;
57
- version: string;
58
- description?: string;
59
- appliesTo: OverlayAppliesTo;
60
- modifications: OverlayModification[];
61
- metadata?: Record<string, unknown>;
62
- createdBy?: string;
63
- createdAt?: string;
64
- }
65
- type OverlaySignatureAlgorithm = 'ed25519' | 'rsa-pss-sha256';
66
- interface OverlaySignatureBlock {
67
- algorithm: OverlaySignatureAlgorithm;
68
- signature: string;
69
- publicKey: string;
70
- keyId?: string;
71
- issuedAt?: string;
72
- expiresAt?: string;
73
- metadata?: Record<string, unknown>;
74
- }
75
- type SignedOverlaySpec = OverlaySpec & {
76
- signature: OverlaySignatureBlock;
77
- };
78
- type OverlayInput = OverlaySpec | SignedOverlaySpec;
79
- declare const OVERLAY_SCOPE_ORDER: OverlayScopeKey[];
80
- declare function defineOverlay<T extends OverlaySpec>(spec: T): T;
81
- //#endregion
82
- export { AddHelpTextModification, HideFieldModification, MakeRequiredModification, OVERLAY_SCOPE_ORDER, OverlayAppliesTo, OverlayFieldModificationBase, OverlayInput, OverlayModification, OverlayScopeContext, OverlayScopeKey, OverlaySignatureAlgorithm, OverlaySignatureBlock, OverlaySpec, OverlayTargetRef, RenameLabelModification, ReorderFieldsModification, SetDefaultModification, SignedOverlaySpec, defineOverlay };
package/dist/types.d.ts DELETED
@@ -1,32 +0,0 @@
1
- import { OverlayScopeContext, OverlayTargetRef, SignedOverlaySpec } from "./spec.js";
2
-
3
- //#region src/types.d.ts
4
- interface OverlayRenderableField {
5
- key: string;
6
- label?: string;
7
- visible?: boolean;
8
- required?: boolean;
9
- helpText?: string;
10
- defaultValue?: unknown;
11
- metadata?: Record<string, unknown>;
12
- order?: number;
13
- }
14
- interface OverlayLayoutConfig {
15
- kind?: 'form' | 'list' | 'table' | 'grid';
16
- columns?: number;
17
- density?: 'comfortable' | 'compact';
18
- [key: string]: unknown;
19
- }
20
- interface OverlayRenderable<TField extends OverlayRenderableField = OverlayRenderableField> {
21
- fields: TField[];
22
- layout?: OverlayLayoutConfig;
23
- metadata?: Record<string, unknown>;
24
- }
25
- interface OverlayMatchContext extends OverlayScopeContext, OverlayTargetRef {}
26
- interface OverlayAuditEvent {
27
- overlay: Pick<SignedOverlaySpec, 'overlayId' | 'version'>;
28
- context: OverlayScopeContext;
29
- timestamp: string;
30
- }
31
- //#endregion
32
- export { OverlayAuditEvent, OverlayLayoutConfig, OverlayMatchContext, OverlayRenderable, OverlayRenderableField };
@@ -1,18 +0,0 @@
1
- import { OverlaySpec } from "./spec.js";
2
-
3
- //#region src/validator.d.ts
4
- interface OverlayValidationIssue {
5
- code: string;
6
- message: string;
7
- path?: string[];
8
- }
9
- interface OverlayValidationResult {
10
- valid: boolean;
11
- issues: OverlayValidationIssue[];
12
- }
13
- type OverlayValidator = (spec: OverlaySpec) => OverlayValidationResult;
14
- declare const defaultOverlayValidator: OverlayValidator;
15
- declare function validateOverlaySpec(spec: OverlaySpec): OverlayValidationResult;
16
- declare function assertOverlayValid(spec: OverlaySpec, validator?: OverlayValidator): void;
17
- //#endregion
18
- export { OverlayValidationIssue, OverlayValidationResult, OverlayValidator, assertOverlayValid, defaultOverlayValidator, validateOverlaySpec };