@contractspec/example.personalization 3.7.17 → 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.
Files changed (33) hide show
  1. package/.turbo/turbo-build.log +33 -33
  2. package/CHANGELOG.md +14 -0
  3. package/dist/behavior-tracking.js +1 -44
  4. package/dist/browser/behavior-tracking.js +1 -44
  5. package/dist/browser/docs/index.js +2 -33
  6. package/dist/browser/docs/personalization.docblock.js +2 -33
  7. package/dist/browser/example.js +1 -33
  8. package/dist/browser/index.js +2 -365
  9. package/dist/browser/overlay-customization.js +1 -53
  10. package/dist/browser/personalization.experiment.js +1 -62
  11. package/dist/browser/personalization.feature.js +1 -22
  12. package/dist/browser/personalization.theme.js +1 -64
  13. package/dist/browser/workflow-extension.js +1 -60
  14. package/dist/docs/index.js +2 -33
  15. package/dist/docs/personalization.docblock.js +2 -33
  16. package/dist/example.js +1 -33
  17. package/dist/index.js +2 -365
  18. package/dist/node/behavior-tracking.js +1 -44
  19. package/dist/node/docs/index.js +2 -33
  20. package/dist/node/docs/personalization.docblock.js +2 -33
  21. package/dist/node/example.js +1 -33
  22. package/dist/node/index.js +2 -365
  23. package/dist/node/overlay-customization.js +1 -53
  24. package/dist/node/personalization.experiment.js +1 -62
  25. package/dist/node/personalization.feature.js +1 -22
  26. package/dist/node/personalization.theme.js +1 -64
  27. package/dist/node/workflow-extension.js +1 -60
  28. package/dist/overlay-customization.js +1 -53
  29. package/dist/personalization.experiment.js +1 -62
  30. package/dist/personalization.feature.js +1 -22
  31. package/dist/personalization.theme.js +1 -64
  32. package/dist/workflow-extension.js +1 -60
  33. package/package.json +8 -8
@@ -1,57 +1,4 @@
1
- // src/behavior-tracking.ts
2
- import { Logger, LogLevel } from "@contractspec/lib.logger";
3
- import { BehaviorAnalyzer } from "@contractspec/lib.personalization/analyzer";
4
- import { InMemoryBehaviorStore } from "@contractspec/lib.personalization/store";
5
- import { createBehaviorTracker } from "@contractspec/lib.personalization/tracker";
6
- var logger = new Logger({
7
- level: LogLevel.INFO,
8
- environment: "production",
9
- enableColors: false
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-spec/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
1
+ import{Logger as J,LogLevel as K}from"@contractspec/lib.logger";import{BehaviorAnalyzer as N}from"@contractspec/lib.personalization/analyzer";import{InMemoryBehaviorStore as P}from"@contractspec/lib.personalization/store";import{createBehaviorTracker as Q}from"@contractspec/lib.personalization/tracker";var U=new J({level:K.INFO,environment:"production",enableColors:!1});async function v(){let x=new P,j=Q({store:x,context:{tenantId:"acme",userId:"user-123"}});j.trackFieldAccess({operation:"billing.createOrder",field:"internalNotes"}),j.trackFieldAccess({operation:"billing.createOrder",field:"customerReference"}),j.trackFeatureUsage({feature:"workflow-editor",action:"opened"}),j.trackWorkflowStep({workflow:"invoice-approval",step:"review",status:"entered"}),await j.flush();let q=await new N(x).analyze({tenantId:"acme",userId:"user-123"});U.info("Behavior insights computed",{insights:q})}import{registerDocBlocks as V}from"@contractspec/lib.contracts-spec/docs";var X=[{id:"docs.examples.personalization",title:"Personalization Patterns (example)",summary:"Behavior tracking, overlay-driven UI tweaks, and tenant workflow extension patterns.",kind:"reference",visibility:"public",route:"/docs/examples/personalization",tags:["personalization","overlays","workflows","example"],body:`## Includes
55
2
  - Behavior tracking + insight analysis.
56
3
  - Overlay customization (hide fields, rename labels).
57
4
  - Workflow extension (inject tenant-specific steps).
@@ -59,314 +6,4 @@ var blocks = [
59
6
  ## Guardrails
60
7
  - Keep tracking events structured and non-PII.
61
8
  - 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-spec";
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 { Logger as Logger2, LogLevel as LogLevel2 } from "@contractspec/lib.logger";
116
- import {
117
- OverlayEngine,
118
- OverlayRegistry
119
- } from "@contractspec/lib.overlay-engine";
120
- import { signOverlay } from "@contractspec/lib.overlay-engine/signer";
121
- import { defineOverlay } from "@contractspec/lib.overlay-engine/spec";
122
- var logger2 = new Logger2({
123
- level: LogLevel2.INFO,
124
- environment: "production",
125
- enableColors: false
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/personalization.experiment.ts
166
- import {
167
- OwnersEnum,
168
- StabilityEnum
169
- } from "@contractspec/lib.contracts-spec/ownership";
170
- var PersonalizationExperiment = {
171
- meta: {
172
- key: "personalization.experiment.overlay-copy",
173
- version: "1.0.0",
174
- title: "Personalization Overlay Copy Experiment",
175
- description: "Tests a control onboarding copy against a personalized overlay variant.",
176
- domain: "personalization",
177
- owners: [OwnersEnum.PlatformCore],
178
- tags: ["personalization", "experiment", "overlay"],
179
- stability: StabilityEnum.Experimental
180
- },
181
- controlVariant: "control",
182
- variants: [
183
- {
184
- id: "control",
185
- key: "control",
186
- description: "Default onboarding copy and standard workflow."
187
- },
188
- {
189
- id: "personalized-overlay",
190
- key: "personalized-overlay",
191
- description: "Personalized copy with a branded theme override.",
192
- overrides: [
193
- {
194
- type: "theme",
195
- target: "personalization.theme.guided-onboarding",
196
- version: "1.0.0"
197
- },
198
- {
199
- type: "workflow",
200
- target: "billing.invoiceApproval",
201
- version: "1.0.0"
202
- }
203
- ]
204
- }
205
- ],
206
- allocation: {
207
- type: "sticky",
208
- attribute: "userId",
209
- salt: "personalization-overlay-copy"
210
- },
211
- successMetrics: [
212
- {
213
- key: "checklist-completion-rate",
214
- telemetryEvent: {
215
- key: "personalization.assignment.completed",
216
- version: "1.0.0"
217
- },
218
- aggregation: "count",
219
- target: 1
220
- }
221
- ],
222
- tags: ["personalization", "experiment"]
223
- };
224
-
225
- // src/personalization.feature.ts
226
- import { defineFeature } from "@contractspec/lib.contracts-spec";
227
- var PersonalizationFeature = defineFeature({
228
- meta: {
229
- key: "personalization",
230
- version: "1.0.0",
231
- title: "Personalization Patterns",
232
- description: "Behavior tracking, overlay customization, and workflow extension patterns",
233
- domain: "personalization",
234
- owners: ["@examples"],
235
- tags: ["personalization", "behavior", "overlay", "workflow"],
236
- stability: "experimental"
237
- },
238
- telemetry: [{ key: "personalization.telemetry", version: "1.0.0" }],
239
- docs: [
240
- "docs.examples.personalization",
241
- "docs.examples.personalization.usage"
242
- ]
243
- });
244
-
245
- // src/personalization.theme.ts
246
- import {
247
- OwnersEnum as OwnersEnum2,
248
- StabilityEnum as StabilityEnum2
249
- } from "@contractspec/lib.contracts-spec/ownership";
250
- var PersonalizationTheme = {
251
- meta: {
252
- key: "personalization.theme.guided-onboarding",
253
- version: "1.0.0",
254
- title: "Guided Onboarding Theme",
255
- description: "Theme tokens used when the personalized onboarding experience is active.",
256
- domain: "personalization",
257
- owners: [OwnersEnum2.PlatformCore],
258
- tags: ["personalization", "theme", "onboarding"],
259
- stability: StabilityEnum2.Experimental,
260
- scopes: ["tenant", "user"]
261
- },
262
- tokens: {
263
- colors: {
264
- surface: { value: "#FCF6E8" },
265
- accent: { value: "#C8742A" },
266
- text: { value: "#2F2419" }
267
- },
268
- radii: {
269
- card: { value: 18 }
270
- },
271
- space: {
272
- panel: { value: 24 }
273
- },
274
- typography: {
275
- body: { value: 16 },
276
- title: { value: 28 }
277
- },
278
- motion: {
279
- stagger: { value: "180ms" }
280
- }
281
- },
282
- components: [
283
- {
284
- component: "OnboardingChecklist",
285
- variants: {
286
- guided: {
287
- props: {
288
- emphasis: "warm"
289
- }
290
- }
291
- }
292
- }
293
- ],
294
- overrides: [
295
- {
296
- scope: "tenant",
297
- target: "tenant:acme",
298
- tokens: {
299
- colors: {
300
- accent: { value: "#8A4B12" }
301
- }
302
- }
303
- }
304
- ]
305
- };
306
-
307
- // src/workflow-extension.ts
308
- import { StabilityEnum as StabilityEnum3 } from "@contractspec/lib.contracts-spec";
309
- import { Logger as Logger3, LogLevel as LogLevel3 } from "@contractspec/lib.logger";
310
- import { WorkflowComposer } from "@contractspec/lib.workflow-composer";
311
- var logger3 = new Logger3({
312
- level: LogLevel3.INFO,
313
- environment: "production",
314
- enableColors: false
315
- });
316
- var BaseWorkflow = {
317
- meta: {
318
- key: "billing.invoiceApproval",
319
- version: "1.0.0",
320
- title: "Invoice Approval",
321
- owners: [],
322
- tags: [],
323
- description: "",
324
- domain: "billing",
325
- stability: StabilityEnum3.Stable
326
- },
327
- definition: {
328
- steps: [
329
- { id: "validate-invoice", type: "automation", label: "Validate Invoice" },
330
- { id: "final-approval", type: "human", label: "Final Approval" }
331
- ],
332
- transitions: [{ from: "validate-invoice", to: "final-approval" }]
333
- }
334
- };
335
- function composeTenantWorkflowExample() {
336
- const composer = new WorkflowComposer;
337
- composer.register({
338
- workflow: "billing.invoiceApproval",
339
- tenantId: "acme",
340
- customSteps: [
341
- {
342
- after: "validate-invoice",
343
- inject: {
344
- id: "acme-legal",
345
- type: "human",
346
- label: "ACME Legal Review"
347
- },
348
- transitionTo: "final-approval"
349
- }
350
- ]
351
- });
352
- return composer.compose({
353
- base: BaseWorkflow,
354
- tenantId: "acme"
355
- });
356
- }
357
- function logTenantWorkflowSteps(workflow) {
358
- logger3.info("Tenant workflow composed", {
359
- workflow: workflow.meta.key,
360
- steps: workflow.definition.steps.map((step) => step.id)
361
- });
362
- }
363
- export {
364
- runOverlayCustomizationExample,
365
- runBehaviorTrackingExample,
366
- logTenantWorkflowSteps,
367
- example_default as example,
368
- composeTenantWorkflowExample,
369
- PersonalizationTheme,
370
- PersonalizationFeature,
371
- PersonalizationExperiment
372
- };
9
+ - Keep workflow composition deterministic.`},{id:"docs.examples.personalization.usage",title:"Personalization — Usage",summary:"How to run the small examples and swap adapters.",kind:"usage",visibility:"public",route:"/docs/examples/personalization/usage",tags:["personalization","usage"],body:"## Usage\n- Call `runBehaviorTrackingExample()` for insights.\n- Call `runOverlayCustomizationExample()` to apply overlays.\n- Call `composeTenantWorkflowExample()` and `logTenantWorkflowSteps()` to inspect steps.\n\n## Notes\n- Replace in-memory stores with app-layer storage.\n- Keep PII out of logs and markdown outputs."}];V(X);import{defineExample as Y}from"@contractspec/lib.contracts-spec";var Z=Y({meta:{key:"personalization",version:"1.0.0",title:"Personalization Patterns",description:"Small examples for behavior tracking, overlay-based UI customization, and tenant workflow extension.",kind:"library",visibility:"public",stability:"experimental",owners:["@platform.core"],tags:["personalization","overlays","behavior","workflows"]},docs:{rootDocId:"docs.examples.personalization",usageDocId:"docs.examples.personalization.usage"},entrypoints:{packageName:"@contractspec/example.personalization",docs:"./docs"},surfaces:{templates:!0,sandbox:{enabled:!0,modes:["markdown","specs"]},studio:{enabled:!0,installable:!0},mcp:{enabled:!0}}}),_=Z;import{Logger as $,LogLevel as A}from"@contractspec/lib.logger";import{OverlayEngine as C,OverlayRegistry as D}from"@contractspec/lib.overlay-engine";import{signOverlay as F}from"@contractspec/lib.overlay-engine/signer";import{defineOverlay as I}from"@contractspec/lib.overlay-engine/spec";var M=new $({level:A.INFO,environment:"production",enableColors:!1});async function t(){let x=new D({allowUnsigned:!0}),j=new C({registry:x}),G=I({overlayId:"demo-overlay",version:"1.0.0",appliesTo:{capability:"billing.createOrder",tenantId:"demo"},modifications:[{type:"hideField",field:"internalNotes"},{type:"renameLabel",field:"customerReference",newLabel:"PO Number"}]}),q=await F(G,process.env.PRIVATE_KEY_PEM??"");x.register(q);let H=j.apply({target:{fields:[{key:"customerReference",label:"Customer Reference",visible:!0},{key:"internalNotes",label:"Internal Notes",visible:!0}]},capability:"billing.createOrder",tenantId:"demo"});M.info("Overlay applied",{fields:H.target.fields})}import{OwnersEnum as R,StabilityEnum as T}from"@contractspec/lib.contracts-spec/ownership";var c={meta:{key:"personalization.experiment.overlay-copy",version:"1.0.0",title:"Personalization Overlay Copy Experiment",description:"Tests a control onboarding copy against a personalized overlay variant.",domain:"personalization",owners:[R.PlatformCore],tags:["personalization","experiment","overlay"],stability:T.Experimental},controlVariant:"control",variants:[{id:"control",key:"control",description:"Default onboarding copy and standard workflow."},{id:"personalized-overlay",key:"personalized-overlay",description:"Personalized copy with a branded theme override.",overrides:[{type:"theme",target:"personalization.theme.guided-onboarding",version:"1.0.0"},{type:"workflow",target:"billing.invoiceApproval",version:"1.0.0"}]}],allocation:{type:"sticky",attribute:"userId",salt:"personalization-overlay-copy"},successMetrics:[{key:"checklist-completion-rate",telemetryEvent:{key:"personalization.assignment.completed",version:"1.0.0"},aggregation:"count",target:1}],tags:["personalization","experiment"]};import{defineFeature as f}from"@contractspec/lib.contracts-spec";var xx=f({meta:{key:"personalization",version:"1.0.0",title:"Personalization Patterns",description:"Behavior tracking, overlay customization, and workflow extension patterns",domain:"personalization",owners:["@examples"],tags:["personalization","behavior","overlay","workflow"],stability:"experimental"},telemetry:[{key:"personalization.telemetry",version:"1.0.0"}],docs:["docs.examples.personalization","docs.examples.personalization.usage"]});import{OwnersEnum as m,StabilityEnum as z}from"@contractspec/lib.contracts-spec/ownership";var Gx={meta:{key:"personalization.theme.guided-onboarding",version:"1.0.0",title:"Guided Onboarding Theme",description:"Theme tokens used when the personalized onboarding experience is active.",domain:"personalization",owners:[m.PlatformCore],tags:["personalization","theme","onboarding"],stability:z.Experimental,scopes:["tenant","user"]},tokens:{colors:{surface:{value:"#FCF6E8"},accent:{value:"#C8742A"},text:{value:"#2F2419"}},radii:{card:{value:18}},space:{panel:{value:24}},typography:{body:{value:16},title:{value:28}},motion:{stagger:{value:"180ms"}}},components:[{component:"OnboardingChecklist",variants:{guided:{props:{emphasis:"warm"}}}}],overrides:[{scope:"tenant",target:"tenant:acme",tokens:{colors:{accent:{value:"#8A4B12"}}}}]};import{StabilityEnum as W}from"@contractspec/lib.contracts-spec";import{Logger as d,LogLevel as S}from"@contractspec/lib.logger";import{WorkflowComposer as B}from"@contractspec/lib.workflow-composer";var h=new d({level:S.INFO,environment:"production",enableColors:!1}),u={meta:{key:"billing.invoiceApproval",version:"1.0.0",title:"Invoice Approval",owners:[],tags:[],description:"",domain:"billing",stability:W.Stable},definition:{steps:[{id:"validate-invoice",type:"automation",label:"Validate Invoice"},{id:"final-approval",type:"human",label:"Final Approval"}],transitions:[{from:"validate-invoice",to:"final-approval"}]}};function Px(){let x=new B;return x.register({workflow:"billing.invoiceApproval",tenantId:"acme",customSteps:[{after:"validate-invoice",inject:{id:"acme-legal",type:"human",label:"ACME Legal Review"},transitionTo:"final-approval"}]}),x.compose({base:u,tenantId:"acme"})}function Qx(x){h.info("Tenant workflow composed",{workflow:x.meta.key,steps:x.definition.steps.map((j)=>j.id)})}export{t as runOverlayCustomizationExample,v as runBehaviorTrackingExample,Qx as logTenantWorkflowSteps,_ as example,Px as composeTenantWorkflowExample,Gx as PersonalizationTheme,xx as PersonalizationFeature,c as PersonalizationExperiment};
@@ -1,53 +1 @@
1
- // src/overlay-customization.ts
2
- import { Logger, LogLevel } from "@contractspec/lib.logger";
3
- import {
4
- OverlayEngine,
5
- OverlayRegistry
6
- } from "@contractspec/lib.overlay-engine";
7
- import { signOverlay } from "@contractspec/lib.overlay-engine/signer";
8
- import { defineOverlay } from "@contractspec/lib.overlay-engine/spec";
9
- var logger = new Logger({
10
- level: LogLevel.INFO,
11
- environment: "production",
12
- enableColors: false
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
- };
1
+ import{Logger as w,LogLevel as x}from"@contractspec/lib.logger";import{OverlayEngine as z,OverlayRegistry as A}from"@contractspec/lib.overlay-engine";import{signOverlay as B}from"@contractspec/lib.overlay-engine/signer";import{defineOverlay as C}from"@contractspec/lib.overlay-engine/spec";var D=new w({level:x.INFO,environment:"production",enableColors:!1});async function J(){let h=new A({allowUnsigned:!0}),j=new z({registry:h}),k=C({overlayId:"demo-overlay",version:"1.0.0",appliesTo:{capability:"billing.createOrder",tenantId:"demo"},modifications:[{type:"hideField",field:"internalNotes"},{type:"renameLabel",field:"customerReference",newLabel:"PO Number"}]}),m=await B(k,process.env.PRIVATE_KEY_PEM??"");h.register(m);let q=j.apply({target:{fields:[{key:"customerReference",label:"Customer Reference",visible:!0},{key:"internalNotes",label:"Internal Notes",visible:!0}]},capability:"billing.createOrder",tenantId:"demo"});D.info("Overlay applied",{fields:q.target.fields})}export{J as runOverlayCustomizationExample};
@@ -1,62 +1 @@
1
- // src/personalization.experiment.ts
2
- import {
3
- OwnersEnum,
4
- StabilityEnum
5
- } from "@contractspec/lib.contracts-spec/ownership";
6
- var PersonalizationExperiment = {
7
- meta: {
8
- key: "personalization.experiment.overlay-copy",
9
- version: "1.0.0",
10
- title: "Personalization Overlay Copy Experiment",
11
- description: "Tests a control onboarding copy against a personalized overlay variant.",
12
- domain: "personalization",
13
- owners: [OwnersEnum.PlatformCore],
14
- tags: ["personalization", "experiment", "overlay"],
15
- stability: StabilityEnum.Experimental
16
- },
17
- controlVariant: "control",
18
- variants: [
19
- {
20
- id: "control",
21
- key: "control",
22
- description: "Default onboarding copy and standard workflow."
23
- },
24
- {
25
- id: "personalized-overlay",
26
- key: "personalized-overlay",
27
- description: "Personalized copy with a branded theme override.",
28
- overrides: [
29
- {
30
- type: "theme",
31
- target: "personalization.theme.guided-onboarding",
32
- version: "1.0.0"
33
- },
34
- {
35
- type: "workflow",
36
- target: "billing.invoiceApproval",
37
- version: "1.0.0"
38
- }
39
- ]
40
- }
41
- ],
42
- allocation: {
43
- type: "sticky",
44
- attribute: "userId",
45
- salt: "personalization-overlay-copy"
46
- },
47
- successMetrics: [
48
- {
49
- key: "checklist-completion-rate",
50
- telemetryEvent: {
51
- key: "personalization.assignment.completed",
52
- version: "1.0.0"
53
- },
54
- aggregation: "count",
55
- target: 1
56
- }
57
- ],
58
- tags: ["personalization", "experiment"]
59
- };
60
- export {
61
- PersonalizationExperiment
62
- };
1
+ import{OwnersEnum as d,StabilityEnum as f}from"@contractspec/lib.contracts-spec/ownership";var j={meta:{key:"personalization.experiment.overlay-copy",version:"1.0.0",title:"Personalization Overlay Copy Experiment",description:"Tests a control onboarding copy against a personalized overlay variant.",domain:"personalization",owners:[d.PlatformCore],tags:["personalization","experiment","overlay"],stability:f.Experimental},controlVariant:"control",variants:[{id:"control",key:"control",description:"Default onboarding copy and standard workflow."},{id:"personalized-overlay",key:"personalized-overlay",description:"Personalized copy with a branded theme override.",overrides:[{type:"theme",target:"personalization.theme.guided-onboarding",version:"1.0.0"},{type:"workflow",target:"billing.invoiceApproval",version:"1.0.0"}]}],allocation:{type:"sticky",attribute:"userId",salt:"personalization-overlay-copy"},successMetrics:[{key:"checklist-completion-rate",telemetryEvent:{key:"personalization.assignment.completed",version:"1.0.0"},aggregation:"count",target:1}],tags:["personalization","experiment"]};export{j as PersonalizationExperiment};
@@ -1,22 +1 @@
1
- // src/personalization.feature.ts
2
- import { defineFeature } from "@contractspec/lib.contracts-spec";
3
- var PersonalizationFeature = defineFeature({
4
- meta: {
5
- key: "personalization",
6
- version: "1.0.0",
7
- title: "Personalization Patterns",
8
- description: "Behavior tracking, overlay customization, and workflow extension patterns",
9
- domain: "personalization",
10
- owners: ["@examples"],
11
- tags: ["personalization", "behavior", "overlay", "workflow"],
12
- stability: "experimental"
13
- },
14
- telemetry: [{ key: "personalization.telemetry", version: "1.0.0" }],
15
- docs: [
16
- "docs.examples.personalization",
17
- "docs.examples.personalization.usage"
18
- ]
19
- });
20
- export {
21
- PersonalizationFeature
22
- };
1
+ import{defineFeature as g}from"@contractspec/lib.contracts-spec";var j=g({meta:{key:"personalization",version:"1.0.0",title:"Personalization Patterns",description:"Behavior tracking, overlay customization, and workflow extension patterns",domain:"personalization",owners:["@examples"],tags:["personalization","behavior","overlay","workflow"],stability:"experimental"},telemetry:[{key:"personalization.telemetry",version:"1.0.0"}],docs:["docs.examples.personalization","docs.examples.personalization.usage"]});export{j as PersonalizationFeature};
@@ -1,64 +1 @@
1
- // src/personalization.theme.ts
2
- import {
3
- OwnersEnum,
4
- StabilityEnum
5
- } from "@contractspec/lib.contracts-spec/ownership";
6
- var PersonalizationTheme = {
7
- meta: {
8
- key: "personalization.theme.guided-onboarding",
9
- version: "1.0.0",
10
- title: "Guided Onboarding Theme",
11
- description: "Theme tokens used when the personalized onboarding experience is active.",
12
- domain: "personalization",
13
- owners: [OwnersEnum.PlatformCore],
14
- tags: ["personalization", "theme", "onboarding"],
15
- stability: StabilityEnum.Experimental,
16
- scopes: ["tenant", "user"]
17
- },
18
- tokens: {
19
- colors: {
20
- surface: { value: "#FCF6E8" },
21
- accent: { value: "#C8742A" },
22
- text: { value: "#2F2419" }
23
- },
24
- radii: {
25
- card: { value: 18 }
26
- },
27
- space: {
28
- panel: { value: 24 }
29
- },
30
- typography: {
31
- body: { value: 16 },
32
- title: { value: 28 }
33
- },
34
- motion: {
35
- stagger: { value: "180ms" }
36
- }
37
- },
38
- components: [
39
- {
40
- component: "OnboardingChecklist",
41
- variants: {
42
- guided: {
43
- props: {
44
- emphasis: "warm"
45
- }
46
- }
47
- }
48
- }
49
- ],
50
- overrides: [
51
- {
52
- scope: "tenant",
53
- target: "tenant:acme",
54
- tokens: {
55
- colors: {
56
- accent: { value: "#8A4B12" }
57
- }
58
- }
59
- }
60
- ]
61
- };
62
- export {
63
- PersonalizationTheme
64
- };
1
+ import{OwnersEnum as d,StabilityEnum as f}from"@contractspec/lib.contracts-spec/ownership";var j={meta:{key:"personalization.theme.guided-onboarding",version:"1.0.0",title:"Guided Onboarding Theme",description:"Theme tokens used when the personalized onboarding experience is active.",domain:"personalization",owners:[d.PlatformCore],tags:["personalization","theme","onboarding"],stability:f.Experimental,scopes:["tenant","user"]},tokens:{colors:{surface:{value:"#FCF6E8"},accent:{value:"#C8742A"},text:{value:"#2F2419"}},radii:{card:{value:18}},space:{panel:{value:24}},typography:{body:{value:16},title:{value:28}},motion:{stagger:{value:"180ms"}}},components:[{component:"OnboardingChecklist",variants:{guided:{props:{emphasis:"warm"}}}}],overrides:[{scope:"tenant",target:"tenant:acme",tokens:{colors:{accent:{value:"#8A4B12"}}}}]};export{j as PersonalizationTheme};
@@ -1,60 +1 @@
1
- // src/workflow-extension.ts
2
- import { StabilityEnum } from "@contractspec/lib.contracts-spec";
3
- import { Logger, LogLevel } from "@contractspec/lib.logger";
4
- import { WorkflowComposer } from "@contractspec/lib.workflow-composer";
5
- var logger = new Logger({
6
- level: LogLevel.INFO,
7
- environment: "production",
8
- enableColors: false
9
- });
10
- var BaseWorkflow = {
11
- meta: {
12
- key: "billing.invoiceApproval",
13
- version: "1.0.0",
14
- title: "Invoice Approval",
15
- owners: [],
16
- tags: [],
17
- description: "",
18
- domain: "billing",
19
- stability: StabilityEnum.Stable
20
- },
21
- definition: {
22
- steps: [
23
- { id: "validate-invoice", type: "automation", label: "Validate Invoice" },
24
- { id: "final-approval", type: "human", label: "Final Approval" }
25
- ],
26
- transitions: [{ from: "validate-invoice", to: "final-approval" }]
27
- }
28
- };
29
- function composeTenantWorkflowExample() {
30
- const composer = new WorkflowComposer;
31
- composer.register({
32
- workflow: "billing.invoiceApproval",
33
- tenantId: "acme",
34
- customSteps: [
35
- {
36
- after: "validate-invoice",
37
- inject: {
38
- id: "acme-legal",
39
- type: "human",
40
- label: "ACME Legal Review"
41
- },
42
- transitionTo: "final-approval"
43
- }
44
- ]
45
- });
46
- return composer.compose({
47
- base: BaseWorkflow,
48
- tenantId: "acme"
49
- });
50
- }
51
- function logTenantWorkflowSteps(workflow) {
52
- logger.info("Tenant workflow composed", {
53
- workflow: workflow.meta.key,
54
- steps: workflow.definition.steps.map((step) => step.id)
55
- });
56
- }
57
- export {
58
- logTenantWorkflowSteps,
59
- composeTenantWorkflowExample
60
- };
1
+ import{StabilityEnum as j}from"@contractspec/lib.contracts-spec";import{Logger as q,LogLevel as x}from"@contractspec/lib.logger";import{WorkflowComposer as z}from"@contractspec/lib.workflow-composer";var A=new q({level:x.INFO,environment:"production",enableColors:!1}),D={meta:{key:"billing.invoiceApproval",version:"1.0.0",title:"Invoice Approval",owners:[],tags:[],description:"",domain:"billing",stability:j.Stable},definition:{steps:[{id:"validate-invoice",type:"automation",label:"Validate Invoice"},{id:"final-approval",type:"human",label:"Final Approval"}],transitions:[{from:"validate-invoice",to:"final-approval"}]}};function I(){let d=new z;return d.register({workflow:"billing.invoiceApproval",tenantId:"acme",customSteps:[{after:"validate-invoice",inject:{id:"acme-legal",type:"human",label:"ACME Legal Review"},transitionTo:"final-approval"}]}),d.compose({base:D,tenantId:"acme"})}function J(d){A.info("Tenant workflow composed",{workflow:d.meta.key,steps:d.definition.steps.map((h)=>h.id)})}export{J as logTenantWorkflowSteps,I as composeTenantWorkflowExample};