@contractspec/example.personalization 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.
Files changed (46) hide show
  1. package/.turbo/turbo-build.log +37 -39
  2. package/.turbo/turbo-prebuild.log +1 -0
  3. package/CHANGELOG.md +31 -0
  4. package/dist/behavior-tracking.d.ts +1 -4
  5. package/dist/behavior-tracking.d.ts.map +1 -1
  6. package/dist/behavior-tracking.js +39 -42
  7. package/dist/browser/behavior-tracking.js +44 -0
  8. package/dist/browser/docs/index.js +40 -0
  9. package/dist/browser/docs/personalization.docblock.js +40 -0
  10. package/dist/browser/example.js +33 -0
  11. package/dist/browser/index.js +227 -0
  12. package/dist/browser/overlay-customization.js +53 -0
  13. package/dist/browser/workflow-extension.js +60 -0
  14. package/dist/docs/index.d.ts +2 -1
  15. package/dist/docs/index.d.ts.map +1 -0
  16. package/dist/docs/index.js +41 -1
  17. package/dist/docs/personalization.docblock.d.ts +2 -1
  18. package/dist/docs/personalization.docblock.d.ts.map +1 -0
  19. package/dist/docs/personalization.docblock.js +38 -27
  20. package/dist/example.d.ts +2 -6
  21. package/dist/example.d.ts.map +1 -1
  22. package/dist/example.js +32 -43
  23. package/dist/index.d.ts +6 -5
  24. package/dist/index.d.ts.map +1 -0
  25. package/dist/index.js +227 -6
  26. package/dist/node/behavior-tracking.js +44 -0
  27. package/dist/node/docs/index.js +40 -0
  28. package/dist/node/docs/personalization.docblock.js +40 -0
  29. package/dist/node/example.js +33 -0
  30. package/dist/node/index.js +227 -0
  31. package/dist/node/overlay-customization.js +53 -0
  32. package/dist/node/workflow-extension.js +60 -0
  33. package/dist/overlay-customization.d.ts +1 -4
  34. package/dist/overlay-customization.d.ts.map +1 -1
  35. package/dist/overlay-customization.js +49 -45
  36. package/dist/workflow-extension.d.ts +3 -7
  37. package/dist/workflow-extension.d.ts.map +1 -1
  38. package/dist/workflow-extension.js +53 -59
  39. package/package.json +80 -31
  40. package/tsdown.config.js +1 -2
  41. package/.turbo/turbo-build$colon$bundle.log +0 -38
  42. package/dist/behavior-tracking.js.map +0 -1
  43. package/dist/docs/personalization.docblock.js.map +0 -1
  44. package/dist/example.js.map +0 -1
  45. package/dist/overlay-customization.js.map +0 -1
  46. package/dist/workflow-extension.js.map +0 -1
@@ -1,40 +1,38 @@
1
- $ bun build:types && bun build:bundle
2
- $ tsc --noEmit
3
- $ tsdown
4
- ℹ tsdown v0.20.3 powered by rolldown v1.0.0-rc.3
5
- ℹ config file: /home/runner/work/contractspec/contractspec/packages/examples/personalization/tsdown.config.js
6
- ℹ entry: src/behavior-tracking.ts, src/example.ts, src/index.ts, src/overlay-customization.ts, src/workflow-extension.ts, src/docs/index.ts, src/docs/personalization.docblock.ts
7
- ℹ target: esnext
8
- ℹ tsconfig: tsconfig.json
9
- ℹ Build start
10
- ℹ Cleaning 1 files
11
- ℹ dist/workflow-extension.js 1.67 kB │ gzip: 0.71 kB
12
- ℹ dist/overlay-customization.js 1.57 kB │ gzip: 0.68 kB
13
- ℹ dist/docs/personalization.docblock.js 1.48 kB │ gzip: 0.70 kB
14
- ℹ dist/behavior-tracking.js 1.43 kB │ gzip: 0.62 kB
15
- ℹ dist/example.js 0.99 kB │ gzip: 0.52 kB
16
- ℹ dist/index.js 0.44 kB │ gzip: 0.19 kB
17
- ℹ dist/docs/index.js 0.04 kB │ gzip: 0.06 kB
18
- ℹ dist/workflow-extension.js.map 2.80 kB │ gzip: 1.16 kB
19
- ℹ dist/overlay-customization.js.map 2.55 kB │ gzip: 1.08 kB
20
- ℹ dist/behavior-tracking.js.map 2.23 kB │ gzip: 0.94 kB
21
- ℹ dist/docs/personalization.docblock.js.map 1.98 kB │ gzip: 0.89 kB
22
- ℹ dist/example.js.map 1.46 kB │ gzip: 0.71 kB
23
- ℹ dist/workflow-extension.d.ts.map 0.19 kB │ gzip: 0.16 kB
24
- ℹ dist/overlay-customization.d.ts.map 0.15 kB │ gzip: 0.14 kB
25
- ℹ dist/behavior-tracking.d.ts.map 0.14 kB │ gzip: 0.13 kB
26
- ℹ dist/example.d.ts.map 0.13 kB │ gzip: 0.13 kB
27
- ℹ dist/index.d.ts 0.41 kB │ gzip: 0.18 kB
28
- ℹ dist/workflow-extension.d.ts 0.37 kB │ gzip: 0.21 kB
29
- ℹ dist/example.d.ts 0.25 kB │ gzip: 0.17 kB
30
- ℹ dist/overlay-customization.d.ts 0.21 kB │ gzip: 0.15 kB
31
- ℹ dist/behavior-tracking.d.ts 0.20 kB │ gzip: 0.15 kB
32
- ℹ dist/docs/index.d.ts 0.01 kB │ gzip: 0.03 kB
33
- ℹ dist/docs/personalization.docblock.d.ts 0.01 kB │ gzip: 0.03 kB
34
- ℹ 23 files, total: 20.71 kB
35
- [PLUGIN_TIMINGS] Warning: Your build spent significant time in plugins. Here is a breakdown:
36
- - tsdown:external (59%)
37
- - rolldown-plugin-dts:generate (27%)
38
- See https://rolldown.rs/options/checks#plugintimings for more details.
1
+ $ contractspec-bun-build prebuild
2
+ $ bun run prebuild && bun run build:bundle && bun run build:types
3
+ $ contractspec-bun-build prebuild
4
+ $ contractspec-bun-build transpile
5
+ [contractspec-bun-build] transpile target=bun root=src entries=7
6
+ Bundled 7 modules in 47ms
39
7
 
40
- ✔ Build complete in 26223ms
8
+ ./behavior-tracking.js 1.33 KB (entry point)
9
+ ./index.js 6.90 KB (entry point)
10
+ docs/index.js 1.47 KB (entry point)
11
+ docs/personalization.docblock.js 1.47 KB (entry point)
12
+ ./example.js 0.99 KB (entry point)
13
+ ./overlay-customization.js 1.53 KB (entry point)
14
+ ./workflow-extension.js 1.58 KB (entry point)
15
+
16
+ [contractspec-bun-build] transpile target=node root=src entries=7
17
+ Bundled 7 modules in 24ms
18
+
19
+ ./behavior-tracking.js 1.32 KB (entry point)
20
+ ./index.js 6.89 KB (entry point)
21
+ docs/index.js 1.46 KB (entry point)
22
+ docs/personalization.docblock.js 1.46 KB (entry point)
23
+ ./example.js 0.98 KB (entry point)
24
+ ./overlay-customization.js 1.53 KB (entry point)
25
+ ./workflow-extension.js 1.58 KB (entry point)
26
+
27
+ [contractspec-bun-build] transpile target=browser root=src entries=7
28
+ Bundled 7 modules in 25ms
29
+
30
+ ./behavior-tracking.js 1.32 KB (entry point)
31
+ ./index.js 6.89 KB (entry point)
32
+ docs/index.js 1.46 KB (entry point)
33
+ docs/personalization.docblock.js 1.46 KB (entry point)
34
+ ./example.js 0.98 KB (entry point)
35
+ ./overlay-customization.js 1.53 KB (entry point)
36
+ ./workflow-extension.js 1.58 KB (entry point)
37
+
38
+ $ contractspec-bun-build types
@@ -0,0 +1 @@
1
+ $ contractspec-bun-build prebuild
package/CHANGELOG.md CHANGED
@@ -1,5 +1,36 @@
1
1
  # @contractspec/example.personalization
2
2
 
3
+ ## 1.59.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 1a0cf44: fix: publishConfig not supported by bun
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [1a0cf44]
12
+ - @contractspec/lib.workflow-composer@1.59.0
13
+ - @contractspec/lib.personalization@1.59.0
14
+ - @contractspec/lib.overlay-engine@1.59.0
15
+ - @contractspec/lib.contracts@1.59.0
16
+ - @contractspec/lib.logger@1.59.0
17
+
18
+ ## 1.58.0
19
+
20
+ ### Minor Changes
21
+
22
+ - d1f0fd0: chore: Migrate non-app package builds from tsdown to shared Bun tooling, add `@contractspec/tool.bun`, and standardize `prebuild`/`build`/`typecheck` with platform-aware exports and `tsc` declaration emission into `dist`.
23
+
24
+ ### Patch Changes
25
+
26
+ - Updated dependencies [d1f0fd0]
27
+ - Updated dependencies [4355a9e]
28
+ - @contractspec/lib.workflow-composer@1.58.0
29
+ - @contractspec/lib.personalization@1.58.0
30
+ - @contractspec/lib.overlay-engine@1.58.0
31
+ - @contractspec/lib.contracts@1.58.0
32
+ - @contractspec/lib.logger@1.58.0
33
+
3
34
  ## 1.57.0
4
35
 
5
36
  ### Minor Changes
@@ -1,5 +1,2 @@
1
- //#region src/behavior-tracking.d.ts
2
- declare function runBehaviorTrackingExample(): Promise<void>;
3
- //#endregion
4
- export { runBehaviorTrackingExample };
1
+ export declare function runBehaviorTrackingExample(): Promise<void>;
5
2
  //# sourceMappingURL=behavior-tracking.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"behavior-tracking.d.ts","names":[],"sources":["../src/behavior-tracking.ts"],"mappings":";iBAasB,0BAAA,CAAA,GAA8B,OAAA"}
1
+ {"version":3,"file":"behavior-tracking.d.ts","sourceRoot":"","sources":["../src/behavior-tracking.ts"],"names":[],"mappings":"AAaA,wBAAsB,0BAA0B,IAAI,OAAO,CAAC,IAAI,CAAC,CAiChE"}
@@ -1,48 +1,45 @@
1
+ // @bun
2
+ // src/behavior-tracking.ts
1
3
  import { createBehaviorTracker } from "@contractspec/lib.personalization/tracker";
2
4
  import { InMemoryBehaviorStore } from "@contractspec/lib.personalization/store";
3
5
  import { BehaviorAnalyzer } from "@contractspec/lib.personalization/analyzer";
4
- import { LogLevel, Logger } from "@contractspec/lib.logger";
5
-
6
- //#region src/behavior-tracking.ts
7
- const logger = new Logger({
8
- level: process.env.NODE_ENV === "production" ? LogLevel.INFO : LogLevel.DEBUG,
9
- environment: process.env.NODE_ENV || "development",
10
- enableColors: process.env.NODE_ENV !== "production"
6
+ import { Logger, LogLevel } from "@contractspec/lib.logger";
7
+ var logger = new Logger({
8
+ level: LogLevel.DEBUG,
9
+ environment: "development",
10
+ enableColors: true
11
11
  });
12
12
  async function runBehaviorTrackingExample() {
13
- const store = new InMemoryBehaviorStore();
14
- const tracker = createBehaviorTracker({
15
- store,
16
- context: {
17
- tenantId: "acme",
18
- userId: "user-123"
19
- }
20
- });
21
- tracker.trackFieldAccess({
22
- operation: "billing.createOrder",
23
- field: "internalNotes"
24
- });
25
- tracker.trackFieldAccess({
26
- operation: "billing.createOrder",
27
- field: "customerReference"
28
- });
29
- tracker.trackFeatureUsage({
30
- feature: "workflow-editor",
31
- action: "opened"
32
- });
33
- tracker.trackWorkflowStep({
34
- workflow: "invoice-approval",
35
- step: "review",
36
- status: "entered"
37
- });
38
- await tracker.flush();
39
- const insights = await new BehaviorAnalyzer(store).analyze({
40
- tenantId: "acme",
41
- userId: "user-123"
42
- });
43
- logger.info("Behavior insights computed", { insights });
13
+ const store = new InMemoryBehaviorStore;
14
+ const tracker = createBehaviorTracker({
15
+ store,
16
+ context: {
17
+ tenantId: "acme",
18
+ userId: "user-123"
19
+ }
20
+ });
21
+ tracker.trackFieldAccess({
22
+ operation: "billing.createOrder",
23
+ field: "internalNotes"
24
+ });
25
+ tracker.trackFieldAccess({
26
+ operation: "billing.createOrder",
27
+ field: "customerReference"
28
+ });
29
+ tracker.trackFeatureUsage({ feature: "workflow-editor", action: "opened" });
30
+ tracker.trackWorkflowStep({
31
+ workflow: "invoice-approval",
32
+ step: "review",
33
+ status: "entered"
34
+ });
35
+ await tracker.flush();
36
+ const analyzer = new BehaviorAnalyzer(store);
37
+ const insights = await analyzer.analyze({
38
+ tenantId: "acme",
39
+ userId: "user-123"
40
+ });
41
+ logger.info("Behavior insights computed", { insights });
44
42
  }
45
-
46
- //#endregion
47
- export { runBehaviorTrackingExample };
48
- //# sourceMappingURL=behavior-tracking.js.map
43
+ export {
44
+ runBehaviorTrackingExample
45
+ };
@@ -0,0 +1,44 @@
1
+ // src/behavior-tracking.ts
2
+ import { createBehaviorTracker } from "@contractspec/lib.personalization/tracker";
3
+ import { InMemoryBehaviorStore } from "@contractspec/lib.personalization/store";
4
+ import { BehaviorAnalyzer } from "@contractspec/lib.personalization/analyzer";
5
+ import { Logger, LogLevel } from "@contractspec/lib.logger";
6
+ var logger = new Logger({
7
+ level: LogLevel.DEBUG,
8
+ environment: "development",
9
+ enableColors: true
10
+ });
11
+ async function runBehaviorTrackingExample() {
12
+ const store = new InMemoryBehaviorStore;
13
+ const tracker = createBehaviorTracker({
14
+ store,
15
+ context: {
16
+ tenantId: "acme",
17
+ userId: "user-123"
18
+ }
19
+ });
20
+ tracker.trackFieldAccess({
21
+ operation: "billing.createOrder",
22
+ field: "internalNotes"
23
+ });
24
+ tracker.trackFieldAccess({
25
+ operation: "billing.createOrder",
26
+ field: "customerReference"
27
+ });
28
+ tracker.trackFeatureUsage({ feature: "workflow-editor", action: "opened" });
29
+ tracker.trackWorkflowStep({
30
+ workflow: "invoice-approval",
31
+ step: "review",
32
+ status: "entered"
33
+ });
34
+ await tracker.flush();
35
+ const analyzer = new BehaviorAnalyzer(store);
36
+ const insights = await analyzer.analyze({
37
+ tenantId: "acme",
38
+ userId: "user-123"
39
+ });
40
+ logger.info("Behavior insights computed", { insights });
41
+ }
42
+ export {
43
+ runBehaviorTrackingExample
44
+ };
@@ -0,0 +1,40 @@
1
+ // src/docs/personalization.docblock.ts
2
+ import { registerDocBlocks } from "@contractspec/lib.contracts/docs";
3
+ var blocks = [
4
+ {
5
+ id: "docs.examples.personalization",
6
+ title: "Personalization Patterns (example)",
7
+ summary: "Behavior tracking, overlay-driven UI tweaks, and tenant workflow extension patterns.",
8
+ kind: "reference",
9
+ visibility: "public",
10
+ route: "/docs/examples/personalization",
11
+ tags: ["personalization", "overlays", "workflows", "example"],
12
+ body: `## Includes
13
+ - Behavior tracking + insight analysis.
14
+ - Overlay customization (hide fields, rename labels).
15
+ - Workflow extension (inject tenant-specific steps).
16
+
17
+ ## Guardrails
18
+ - Keep tracking events structured and non-PII.
19
+ - Keep overlays signed and scoped.
20
+ - Keep workflow composition deterministic.`
21
+ },
22
+ {
23
+ id: "docs.examples.personalization.usage",
24
+ title: "Personalization — Usage",
25
+ summary: "How to run the small examples and swap adapters.",
26
+ kind: "usage",
27
+ visibility: "public",
28
+ route: "/docs/examples/personalization/usage",
29
+ tags: ["personalization", "usage"],
30
+ body: `## Usage
31
+ - Call \`runBehaviorTrackingExample()\` for insights.
32
+ - Call \`runOverlayCustomizationExample()\` to apply overlays.
33
+ - Call \`composeTenantWorkflowExample()\` and \`logTenantWorkflowSteps()\` to inspect steps.
34
+
35
+ ## Notes
36
+ - Replace in-memory stores with app-layer storage.
37
+ - Keep PII out of logs and markdown outputs.`
38
+ }
39
+ ];
40
+ registerDocBlocks(blocks);
@@ -0,0 +1,40 @@
1
+ // src/docs/personalization.docblock.ts
2
+ import { registerDocBlocks } from "@contractspec/lib.contracts/docs";
3
+ var blocks = [
4
+ {
5
+ id: "docs.examples.personalization",
6
+ title: "Personalization Patterns (example)",
7
+ summary: "Behavior tracking, overlay-driven UI tweaks, and tenant workflow extension patterns.",
8
+ kind: "reference",
9
+ visibility: "public",
10
+ route: "/docs/examples/personalization",
11
+ tags: ["personalization", "overlays", "workflows", "example"],
12
+ body: `## Includes
13
+ - Behavior tracking + insight analysis.
14
+ - Overlay customization (hide fields, rename labels).
15
+ - Workflow extension (inject tenant-specific steps).
16
+
17
+ ## Guardrails
18
+ - Keep tracking events structured and non-PII.
19
+ - Keep overlays signed and scoped.
20
+ - Keep workflow composition deterministic.`
21
+ },
22
+ {
23
+ id: "docs.examples.personalization.usage",
24
+ title: "Personalization — Usage",
25
+ summary: "How to run the small examples and swap adapters.",
26
+ kind: "usage",
27
+ visibility: "public",
28
+ route: "/docs/examples/personalization/usage",
29
+ tags: ["personalization", "usage"],
30
+ body: `## Usage
31
+ - Call \`runBehaviorTrackingExample()\` for insights.
32
+ - Call \`runOverlayCustomizationExample()\` to apply overlays.
33
+ - Call \`composeTenantWorkflowExample()\` and \`logTenantWorkflowSteps()\` to inspect steps.
34
+
35
+ ## Notes
36
+ - Replace in-memory stores with app-layer storage.
37
+ - Keep PII out of logs and markdown outputs.`
38
+ }
39
+ ];
40
+ registerDocBlocks(blocks);
@@ -0,0 +1,33 @@
1
+ // src/example.ts
2
+ import { defineExample } from "@contractspec/lib.contracts";
3
+ var example = defineExample({
4
+ meta: {
5
+ key: "personalization",
6
+ version: "1.0.0",
7
+ title: "Personalization Patterns",
8
+ description: "Small examples for behavior tracking, overlay-based UI customization, and tenant workflow extension.",
9
+ kind: "library",
10
+ visibility: "public",
11
+ stability: "experimental",
12
+ owners: ["@platform.core"],
13
+ tags: ["personalization", "overlays", "behavior", "workflows"]
14
+ },
15
+ docs: {
16
+ rootDocId: "docs.examples.personalization",
17
+ usageDocId: "docs.examples.personalization.usage"
18
+ },
19
+ entrypoints: {
20
+ packageName: "@contractspec/example.personalization",
21
+ docs: "./docs"
22
+ },
23
+ surfaces: {
24
+ templates: true,
25
+ sandbox: { enabled: true, modes: ["markdown", "specs"] },
26
+ studio: { enabled: true, installable: true },
27
+ mcp: { enabled: true }
28
+ }
29
+ });
30
+ var example_default = example;
31
+ export {
32
+ example_default as default
33
+ };
@@ -0,0 +1,227 @@
1
+ // src/behavior-tracking.ts
2
+ import { createBehaviorTracker } from "@contractspec/lib.personalization/tracker";
3
+ import { InMemoryBehaviorStore } from "@contractspec/lib.personalization/store";
4
+ import { BehaviorAnalyzer } from "@contractspec/lib.personalization/analyzer";
5
+ import { Logger, LogLevel } from "@contractspec/lib.logger";
6
+ var logger = new Logger({
7
+ level: LogLevel.DEBUG,
8
+ environment: "development",
9
+ enableColors: true
10
+ });
11
+ async function runBehaviorTrackingExample() {
12
+ const store = new InMemoryBehaviorStore;
13
+ const tracker = createBehaviorTracker({
14
+ store,
15
+ context: {
16
+ tenantId: "acme",
17
+ userId: "user-123"
18
+ }
19
+ });
20
+ tracker.trackFieldAccess({
21
+ operation: "billing.createOrder",
22
+ field: "internalNotes"
23
+ });
24
+ tracker.trackFieldAccess({
25
+ operation: "billing.createOrder",
26
+ field: "customerReference"
27
+ });
28
+ tracker.trackFeatureUsage({ feature: "workflow-editor", action: "opened" });
29
+ tracker.trackWorkflowStep({
30
+ workflow: "invoice-approval",
31
+ step: "review",
32
+ status: "entered"
33
+ });
34
+ await tracker.flush();
35
+ const analyzer = new BehaviorAnalyzer(store);
36
+ const insights = await analyzer.analyze({
37
+ tenantId: "acme",
38
+ userId: "user-123"
39
+ });
40
+ logger.info("Behavior insights computed", { insights });
41
+ }
42
+
43
+ // src/docs/personalization.docblock.ts
44
+ import { registerDocBlocks } from "@contractspec/lib.contracts/docs";
45
+ var blocks = [
46
+ {
47
+ id: "docs.examples.personalization",
48
+ title: "Personalization Patterns (example)",
49
+ summary: "Behavior tracking, overlay-driven UI tweaks, and tenant workflow extension patterns.",
50
+ kind: "reference",
51
+ visibility: "public",
52
+ route: "/docs/examples/personalization",
53
+ tags: ["personalization", "overlays", "workflows", "example"],
54
+ body: `## Includes
55
+ - Behavior tracking + insight analysis.
56
+ - Overlay customization (hide fields, rename labels).
57
+ - Workflow extension (inject tenant-specific steps).
58
+
59
+ ## Guardrails
60
+ - Keep tracking events structured and non-PII.
61
+ - Keep overlays signed and scoped.
62
+ - Keep workflow composition deterministic.`
63
+ },
64
+ {
65
+ id: "docs.examples.personalization.usage",
66
+ title: "Personalization — Usage",
67
+ summary: "How to run the small examples and swap adapters.",
68
+ kind: "usage",
69
+ visibility: "public",
70
+ route: "/docs/examples/personalization/usage",
71
+ tags: ["personalization", "usage"],
72
+ body: `## Usage
73
+ - Call \`runBehaviorTrackingExample()\` for insights.
74
+ - Call \`runOverlayCustomizationExample()\` to apply overlays.
75
+ - Call \`composeTenantWorkflowExample()\` and \`logTenantWorkflowSteps()\` to inspect steps.
76
+
77
+ ## Notes
78
+ - Replace in-memory stores with app-layer storage.
79
+ - Keep PII out of logs and markdown outputs.`
80
+ }
81
+ ];
82
+ registerDocBlocks(blocks);
83
+ // src/example.ts
84
+ import { defineExample } from "@contractspec/lib.contracts";
85
+ var example = defineExample({
86
+ meta: {
87
+ key: "personalization",
88
+ version: "1.0.0",
89
+ title: "Personalization Patterns",
90
+ description: "Small examples for behavior tracking, overlay-based UI customization, and tenant workflow extension.",
91
+ kind: "library",
92
+ visibility: "public",
93
+ stability: "experimental",
94
+ owners: ["@platform.core"],
95
+ tags: ["personalization", "overlays", "behavior", "workflows"]
96
+ },
97
+ docs: {
98
+ rootDocId: "docs.examples.personalization",
99
+ usageDocId: "docs.examples.personalization.usage"
100
+ },
101
+ entrypoints: {
102
+ packageName: "@contractspec/example.personalization",
103
+ docs: "./docs"
104
+ },
105
+ surfaces: {
106
+ templates: true,
107
+ sandbox: { enabled: true, modes: ["markdown", "specs"] },
108
+ studio: { enabled: true, installable: true },
109
+ mcp: { enabled: true }
110
+ }
111
+ });
112
+ var example_default = example;
113
+
114
+ // src/overlay-customization.ts
115
+ import { defineOverlay } from "@contractspec/lib.overlay-engine/spec";
116
+ import { signOverlay } from "@contractspec/lib.overlay-engine/signer";
117
+ import {
118
+ OverlayEngine,
119
+ OverlayRegistry
120
+ } from "@contractspec/lib.overlay-engine";
121
+ import { Logger as Logger2, LogLevel as LogLevel2 } from "@contractspec/lib.logger";
122
+ var logger2 = new Logger2({
123
+ level: LogLevel2.DEBUG,
124
+ environment: "development",
125
+ enableColors: true
126
+ });
127
+ async function runOverlayCustomizationExample() {
128
+ const registry = new OverlayRegistry({ allowUnsigned: true });
129
+ const engine = new OverlayEngine({ registry });
130
+ const overlay = defineOverlay({
131
+ overlayId: "demo-overlay",
132
+ version: "1.0.0",
133
+ appliesTo: {
134
+ capability: "billing.createOrder",
135
+ tenantId: "demo"
136
+ },
137
+ modifications: [
138
+ { type: "hideField", field: "internalNotes" },
139
+ {
140
+ type: "renameLabel",
141
+ field: "customerReference",
142
+ newLabel: "PO Number"
143
+ }
144
+ ]
145
+ });
146
+ const signed = await signOverlay(overlay, process.env.PRIVATE_KEY_PEM ?? "");
147
+ registry.register(signed);
148
+ const result = engine.apply({
149
+ target: {
150
+ fields: [
151
+ {
152
+ key: "customerReference",
153
+ label: "Customer Reference",
154
+ visible: true
155
+ },
156
+ { key: "internalNotes", label: "Internal Notes", visible: true }
157
+ ]
158
+ },
159
+ capability: "billing.createOrder",
160
+ tenantId: "demo"
161
+ });
162
+ logger2.info("Overlay applied", { fields: result.target.fields });
163
+ }
164
+
165
+ // src/workflow-extension.ts
166
+ import { StabilityEnum } from "@contractspec/lib.contracts";
167
+ import { WorkflowComposer } from "@contractspec/lib.workflow-composer";
168
+ import { Logger as Logger3, LogLevel as LogLevel3 } from "@contractspec/lib.logger";
169
+ var logger3 = new Logger3({
170
+ level: LogLevel3.DEBUG,
171
+ environment: "development",
172
+ enableColors: true
173
+ });
174
+ var BaseWorkflow = {
175
+ meta: {
176
+ key: "billing.invoiceApproval",
177
+ version: "1.0.0",
178
+ title: "Invoice Approval",
179
+ owners: [],
180
+ tags: [],
181
+ description: "",
182
+ domain: "billing",
183
+ stability: StabilityEnum.Stable
184
+ },
185
+ definition: {
186
+ steps: [
187
+ { id: "validate-invoice", type: "automation", label: "Validate Invoice" },
188
+ { id: "final-approval", type: "human", label: "Final Approval" }
189
+ ],
190
+ transitions: [{ from: "validate-invoice", to: "final-approval" }]
191
+ }
192
+ };
193
+ function composeTenantWorkflowExample() {
194
+ const composer = new WorkflowComposer;
195
+ composer.register({
196
+ workflow: "billing.invoiceApproval",
197
+ tenantId: "acme",
198
+ customSteps: [
199
+ {
200
+ after: "validate-invoice",
201
+ inject: {
202
+ id: "acme-legal",
203
+ type: "human",
204
+ label: "ACME Legal Review"
205
+ },
206
+ transitionTo: "final-approval"
207
+ }
208
+ ]
209
+ });
210
+ return composer.compose({
211
+ base: BaseWorkflow,
212
+ tenantId: "acme"
213
+ });
214
+ }
215
+ function logTenantWorkflowSteps(workflow) {
216
+ logger3.info("Tenant workflow composed", {
217
+ workflow: workflow.meta.key,
218
+ steps: workflow.definition.steps.map((step) => step.id)
219
+ });
220
+ }
221
+ export {
222
+ runOverlayCustomizationExample,
223
+ runBehaviorTrackingExample,
224
+ logTenantWorkflowSteps,
225
+ example_default as example,
226
+ composeTenantWorkflowExample
227
+ };
@@ -0,0 +1,53 @@
1
+ // src/overlay-customization.ts
2
+ import { defineOverlay } from "@contractspec/lib.overlay-engine/spec";
3
+ import { signOverlay } from "@contractspec/lib.overlay-engine/signer";
4
+ import {
5
+ OverlayEngine,
6
+ OverlayRegistry
7
+ } from "@contractspec/lib.overlay-engine";
8
+ import { Logger, LogLevel } from "@contractspec/lib.logger";
9
+ var logger = new Logger({
10
+ level: LogLevel.DEBUG,
11
+ environment: "development",
12
+ enableColors: true
13
+ });
14
+ async function runOverlayCustomizationExample() {
15
+ const registry = new OverlayRegistry({ allowUnsigned: true });
16
+ const engine = new OverlayEngine({ registry });
17
+ const overlay = defineOverlay({
18
+ overlayId: "demo-overlay",
19
+ version: "1.0.0",
20
+ appliesTo: {
21
+ capability: "billing.createOrder",
22
+ tenantId: "demo"
23
+ },
24
+ modifications: [
25
+ { type: "hideField", field: "internalNotes" },
26
+ {
27
+ type: "renameLabel",
28
+ field: "customerReference",
29
+ newLabel: "PO Number"
30
+ }
31
+ ]
32
+ });
33
+ const signed = await signOverlay(overlay, process.env.PRIVATE_KEY_PEM ?? "");
34
+ registry.register(signed);
35
+ const result = engine.apply({
36
+ target: {
37
+ fields: [
38
+ {
39
+ key: "customerReference",
40
+ label: "Customer Reference",
41
+ visible: true
42
+ },
43
+ { key: "internalNotes", label: "Internal Notes", visible: true }
44
+ ]
45
+ },
46
+ capability: "billing.createOrder",
47
+ tenantId: "demo"
48
+ });
49
+ logger.info("Overlay applied", { fields: result.target.fields });
50
+ }
51
+ export {
52
+ runOverlayCustomizationExample
53
+ };