@contractspec/example.personalization 3.7.17 → 3.7.19

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 +24 -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,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};
@@ -1,54 +1,2 @@
1
1
  // @bun
2
- // src/overlay-customization.ts
3
- import { Logger, LogLevel } from "@contractspec/lib.logger";
4
- import {
5
- OverlayEngine,
6
- OverlayRegistry
7
- } from "@contractspec/lib.overlay-engine";
8
- import { signOverlay } from "@contractspec/lib.overlay-engine/signer";
9
- import { defineOverlay } from "@contractspec/lib.overlay-engine/spec";
10
- var logger = new Logger({
11
- level: LogLevel.INFO,
12
- environment: "production",
13
- enableColors: false
14
- });
15
- async function runOverlayCustomizationExample() {
16
- const registry = new OverlayRegistry({ allowUnsigned: true });
17
- const engine = new OverlayEngine({ registry });
18
- const overlay = defineOverlay({
19
- overlayId: "demo-overlay",
20
- version: "1.0.0",
21
- appliesTo: {
22
- capability: "billing.createOrder",
23
- tenantId: "demo"
24
- },
25
- modifications: [
26
- { type: "hideField", field: "internalNotes" },
27
- {
28
- type: "renameLabel",
29
- field: "customerReference",
30
- newLabel: "PO Number"
31
- }
32
- ]
33
- });
34
- const signed = await signOverlay(overlay, process.env.PRIVATE_KEY_PEM ?? "");
35
- registry.register(signed);
36
- const result = engine.apply({
37
- target: {
38
- fields: [
39
- {
40
- key: "customerReference",
41
- label: "Customer Reference",
42
- visible: true
43
- },
44
- { key: "internalNotes", label: "Internal Notes", visible: true }
45
- ]
46
- },
47
- capability: "billing.createOrder",
48
- tenantId: "demo"
49
- });
50
- logger.info("Overlay applied", { fields: result.target.fields });
51
- }
52
- export {
53
- runOverlayCustomizationExample
54
- };
2
+ 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,63 +1,2 @@
1
1
  // @bun
2
- // src/personalization.experiment.ts
3
- import {
4
- OwnersEnum,
5
- StabilityEnum
6
- } from "@contractspec/lib.contracts-spec/ownership";
7
- var PersonalizationExperiment = {
8
- meta: {
9
- key: "personalization.experiment.overlay-copy",
10
- version: "1.0.0",
11
- title: "Personalization Overlay Copy Experiment",
12
- description: "Tests a control onboarding copy against a personalized overlay variant.",
13
- domain: "personalization",
14
- owners: [OwnersEnum.PlatformCore],
15
- tags: ["personalization", "experiment", "overlay"],
16
- stability: StabilityEnum.Experimental
17
- },
18
- controlVariant: "control",
19
- variants: [
20
- {
21
- id: "control",
22
- key: "control",
23
- description: "Default onboarding copy and standard workflow."
24
- },
25
- {
26
- id: "personalized-overlay",
27
- key: "personalized-overlay",
28
- description: "Personalized copy with a branded theme override.",
29
- overrides: [
30
- {
31
- type: "theme",
32
- target: "personalization.theme.guided-onboarding",
33
- version: "1.0.0"
34
- },
35
- {
36
- type: "workflow",
37
- target: "billing.invoiceApproval",
38
- version: "1.0.0"
39
- }
40
- ]
41
- }
42
- ],
43
- allocation: {
44
- type: "sticky",
45
- attribute: "userId",
46
- salt: "personalization-overlay-copy"
47
- },
48
- successMetrics: [
49
- {
50
- key: "checklist-completion-rate",
51
- telemetryEvent: {
52
- key: "personalization.assignment.completed",
53
- version: "1.0.0"
54
- },
55
- aggregation: "count",
56
- target: 1
57
- }
58
- ],
59
- tags: ["personalization", "experiment"]
60
- };
61
- export {
62
- PersonalizationExperiment
63
- };
2
+ 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,23 +1,2 @@
1
1
  // @bun
2
- // src/personalization.feature.ts
3
- import { defineFeature } from "@contractspec/lib.contracts-spec";
4
- var PersonalizationFeature = defineFeature({
5
- meta: {
6
- key: "personalization",
7
- version: "1.0.0",
8
- title: "Personalization Patterns",
9
- description: "Behavior tracking, overlay customization, and workflow extension patterns",
10
- domain: "personalization",
11
- owners: ["@examples"],
12
- tags: ["personalization", "behavior", "overlay", "workflow"],
13
- stability: "experimental"
14
- },
15
- telemetry: [{ key: "personalization.telemetry", version: "1.0.0" }],
16
- docs: [
17
- "docs.examples.personalization",
18
- "docs.examples.personalization.usage"
19
- ]
20
- });
21
- export {
22
- PersonalizationFeature
23
- };
2
+ 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,65 +1,2 @@
1
1
  // @bun
2
- // src/personalization.theme.ts
3
- import {
4
- OwnersEnum,
5
- StabilityEnum
6
- } from "@contractspec/lib.contracts-spec/ownership";
7
- var PersonalizationTheme = {
8
- meta: {
9
- key: "personalization.theme.guided-onboarding",
10
- version: "1.0.0",
11
- title: "Guided Onboarding Theme",
12
- description: "Theme tokens used when the personalized onboarding experience is active.",
13
- domain: "personalization",
14
- owners: [OwnersEnum.PlatformCore],
15
- tags: ["personalization", "theme", "onboarding"],
16
- stability: StabilityEnum.Experimental,
17
- scopes: ["tenant", "user"]
18
- },
19
- tokens: {
20
- colors: {
21
- surface: { value: "#FCF6E8" },
22
- accent: { value: "#C8742A" },
23
- text: { value: "#2F2419" }
24
- },
25
- radii: {
26
- card: { value: 18 }
27
- },
28
- space: {
29
- panel: { value: 24 }
30
- },
31
- typography: {
32
- body: { value: 16 },
33
- title: { value: 28 }
34
- },
35
- motion: {
36
- stagger: { value: "180ms" }
37
- }
38
- },
39
- components: [
40
- {
41
- component: "OnboardingChecklist",
42
- variants: {
43
- guided: {
44
- props: {
45
- emphasis: "warm"
46
- }
47
- }
48
- }
49
- }
50
- ],
51
- overrides: [
52
- {
53
- scope: "tenant",
54
- target: "tenant:acme",
55
- tokens: {
56
- colors: {
57
- accent: { value: "#8A4B12" }
58
- }
59
- }
60
- }
61
- ]
62
- };
63
- export {
64
- PersonalizationTheme
65
- };
2
+ 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,61 +1,2 @@
1
1
  // @bun
2
- // src/workflow-extension.ts
3
- import { StabilityEnum } from "@contractspec/lib.contracts-spec";
4
- import { Logger, LogLevel } from "@contractspec/lib.logger";
5
- import { WorkflowComposer } from "@contractspec/lib.workflow-composer";
6
- var logger = new Logger({
7
- level: LogLevel.INFO,
8
- environment: "production",
9
- enableColors: false
10
- });
11
- var BaseWorkflow = {
12
- meta: {
13
- key: "billing.invoiceApproval",
14
- version: "1.0.0",
15
- title: "Invoice Approval",
16
- owners: [],
17
- tags: [],
18
- description: "",
19
- domain: "billing",
20
- stability: StabilityEnum.Stable
21
- },
22
- definition: {
23
- steps: [
24
- { id: "validate-invoice", type: "automation", label: "Validate Invoice" },
25
- { id: "final-approval", type: "human", label: "Final Approval" }
26
- ],
27
- transitions: [{ from: "validate-invoice", to: "final-approval" }]
28
- }
29
- };
30
- function composeTenantWorkflowExample() {
31
- const composer = new WorkflowComposer;
32
- composer.register({
33
- workflow: "billing.invoiceApproval",
34
- tenantId: "acme",
35
- customSteps: [
36
- {
37
- after: "validate-invoice",
38
- inject: {
39
- id: "acme-legal",
40
- type: "human",
41
- label: "ACME Legal Review"
42
- },
43
- transitionTo: "final-approval"
44
- }
45
- ]
46
- });
47
- return composer.compose({
48
- base: BaseWorkflow,
49
- tenantId: "acme"
50
- });
51
- }
52
- function logTenantWorkflowSteps(workflow) {
53
- logger.info("Tenant workflow composed", {
54
- workflow: workflow.meta.key,
55
- steps: workflow.definition.steps.map((step) => step.id)
56
- });
57
- }
58
- export {
59
- logTenantWorkflowSteps,
60
- composeTenantWorkflowExample
61
- };
2
+ 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};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contractspec/example.personalization",
3
- "version": "3.7.17",
3
+ "version": "3.7.19",
4
4
  "description": "Personalization examples: behavior tracking, overlay customization, workflow extension.",
5
5
  "type": "module",
6
6
  "types": "./dist/index.d.ts",
@@ -85,23 +85,23 @@
85
85
  "dev": "contractspec-bun-build dev",
86
86
  "clean": "rimraf dist .turbo",
87
87
  "lint": "bun lint:fix",
88
- "lint:fix": "biome check --write --unsafe --only=nursery/useSortedClasses . && biome check --write .",
89
- "lint:check": "biome check .",
88
+ "lint:fix": "node ../../../scripts/biome.cjs check --write --unsafe --only=nursery/useSortedClasses . && node ../../../scripts/biome.cjs check --write .",
89
+ "lint:check": "node ../../../scripts/biome.cjs check .",
90
90
  "test": "bun test --pass-with-no-tests",
91
91
  "prebuild": "contractspec-bun-build prebuild",
92
92
  "typecheck": "tsc --noEmit"
93
93
  },
94
94
  "dependencies": {
95
- "@contractspec/lib.personalization": "6.0.17",
96
- "@contractspec/lib.overlay-engine": "3.7.17",
97
- "@contractspec/lib.workflow-composer": "3.7.17",
98
- "@contractspec/lib.contracts-spec": "5.1.0",
95
+ "@contractspec/lib.personalization": "6.0.19",
96
+ "@contractspec/lib.overlay-engine": "3.7.19",
97
+ "@contractspec/lib.workflow-composer": "3.7.19",
98
+ "@contractspec/lib.contracts-spec": "5.3.0",
99
99
  "@contractspec/lib.logger": "3.7.13"
100
100
  },
101
101
  "devDependencies": {
102
102
  "@contractspec/tool.typescript": "3.7.13",
103
103
  "typescript": "^5.9.3",
104
- "@contractspec/tool.bun": "3.7.13"
104
+ "@contractspec/tool.bun": "3.7.14"
105
105
  },
106
106
  "publishConfig": {
107
107
  "access": "public",