@contractspec/example.personalization 1.56.1 → 1.58.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/.turbo/turbo-build.log +38 -383
- package/.turbo/turbo-prebuild.log +1 -0
- package/CHANGELOG.md +36 -0
- package/dist/behavior-tracking.d.ts +1 -4
- package/dist/behavior-tracking.d.ts.map +1 -1
- package/dist/behavior-tracking.js +39 -42
- package/dist/browser/behavior-tracking.js +44 -0
- package/dist/browser/docs/index.js +40 -0
- package/dist/browser/docs/personalization.docblock.js +40 -0
- package/dist/browser/example.js +33 -0
- package/dist/browser/index.js +227 -0
- package/dist/browser/overlay-customization.js +53 -0
- package/dist/browser/workflow-extension.js +60 -0
- package/dist/docs/index.d.ts +2 -1
- package/dist/docs/index.d.ts.map +1 -0
- package/dist/docs/index.js +41 -1
- package/dist/docs/personalization.docblock.d.ts +2 -1
- package/dist/docs/personalization.docblock.d.ts.map +1 -0
- package/dist/docs/personalization.docblock.js +38 -27
- package/dist/example.d.ts +2 -7
- package/dist/example.d.ts.map +1 -1
- package/dist/example.js +31 -43
- package/dist/index.d.ts +6 -5
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +227 -6
- package/dist/node/behavior-tracking.js +44 -0
- package/dist/node/docs/index.js +40 -0
- package/dist/node/docs/personalization.docblock.js +40 -0
- package/dist/node/example.js +33 -0
- package/dist/node/index.js +227 -0
- package/dist/node/overlay-customization.js +53 -0
- package/dist/node/workflow-extension.js +60 -0
- package/dist/overlay-customization.d.ts +1 -4
- package/dist/overlay-customization.d.ts.map +1 -1
- package/dist/overlay-customization.js +49 -45
- package/dist/workflow-extension.d.ts +3 -7
- package/dist/workflow-extension.d.ts.map +1 -1
- package/dist/workflow-extension.js +53 -59
- package/package.json +80 -31
- package/tsdown.config.js +1 -2
- package/.turbo/turbo-build$colon$bundle.log +0 -385
- package/dist/behavior-tracking.js.map +0 -1
- package/dist/docs/personalization.docblock.js.map +0 -1
- package/dist/example.js.map +0 -1
- package/dist/libs/contracts/src/app-config/branding.d.ts +0 -20
- package/dist/libs/contracts/src/app-config/branding.d.ts.map +0 -1
- package/dist/libs/contracts/src/app-config/lifecycle.d.ts +0 -1
- package/dist/libs/contracts/src/app-config/runtime.d.ts +0 -10
- package/dist/libs/contracts/src/app-config/spec.d.ts +0 -93
- package/dist/libs/contracts/src/app-config/spec.d.ts.map +0 -1
- package/dist/libs/contracts/src/app-config/validation.d.ts +0 -8
- package/dist/libs/contracts/src/capabilities/capabilities.d.ts +0 -30
- package/dist/libs/contracts/src/capabilities/capabilities.d.ts.map +0 -1
- package/dist/libs/contracts/src/capabilities/context.d.ts +0 -1
- package/dist/libs/contracts/src/capabilities/guards.d.ts +0 -3
- package/dist/libs/contracts/src/capabilities/index.d.ts +0 -5
- package/dist/libs/contracts/src/capabilities/openbanking.d.ts +0 -1
- package/dist/libs/contracts/src/capabilities/validation.d.ts +0 -4
- package/dist/libs/contracts/src/client/index.d.ts +0 -1
- package/dist/libs/contracts/src/client/react/drivers/rn-reusables.d.ts +0 -1
- package/dist/libs/contracts/src/client/react/drivers/shadcn.d.ts +0 -1
- package/dist/libs/contracts/src/client/react/feature-render.d.ts +0 -3
- package/dist/libs/contracts/src/client/react/form-render.d.ts +0 -3
- package/dist/libs/contracts/src/client/react/index.d.ts +0 -4
- package/dist/libs/contracts/src/contract-registry/index.d.ts +0 -2
- package/dist/libs/contracts/src/contract-registry/schemas.d.ts +0 -2
- package/dist/libs/contracts/src/contract-registry/types.d.ts +0 -1
- package/dist/libs/contracts/src/data-views/index.d.ts +0 -4
- package/dist/libs/contracts/src/data-views/registry.d.ts +0 -2
- package/dist/libs/contracts/src/data-views/report/contractVerificationTable.d.ts +0 -1
- package/dist/libs/contracts/src/data-views/spec.d.ts +0 -2
- package/dist/libs/contracts/src/data-views/types.d.ts +0 -2
- package/dist/libs/contracts/src/docs/accessibility_wcag_compliance_specs.docblock.d.ts +0 -1
- package/dist/libs/contracts/src/docs/capabilities/documentationSystem.capability.d.ts +0 -1
- package/dist/libs/contracts/src/docs/capabilities/index.d.ts +0 -1
- package/dist/libs/contracts/src/docs/commands/docsGenerate.command.d.ts +0 -1
- package/dist/libs/contracts/src/docs/commands/docsPublish.command.d.ts +0 -1
- package/dist/libs/contracts/src/docs/commands/index.d.ts +0 -2
- package/dist/libs/contracts/src/docs/contracts.d.ts +0 -6
- package/dist/libs/contracts/src/docs/events/docsGenerated.event.d.ts +0 -1
- package/dist/libs/contracts/src/docs/events/docsPublished.event.d.ts +0 -1
- package/dist/libs/contracts/src/docs/events/index.d.ts +0 -2
- package/dist/libs/contracts/src/docs/forms/docsSearch.form.d.ts +0 -1
- package/dist/libs/contracts/src/docs/forms/index.d.ts +0 -1
- package/dist/libs/contracts/src/docs/index.d.ts +0 -32
- package/dist/libs/contracts/src/docs/presentations/docsLayout.presentation.d.ts +0 -1
- package/dist/libs/contracts/src/docs/presentations/docsReferencePage.presentation.d.ts +0 -1
- package/dist/libs/contracts/src/docs/presentations/index.d.ts +0 -2
- package/dist/libs/contracts/src/docs/queries/contractReference.query.d.ts +0 -1
- package/dist/libs/contracts/src/docs/queries/docsIndex.query.d.ts +0 -1
- package/dist/libs/contracts/src/docs/queries/index.d.ts +0 -2
- package/dist/libs/contracts/src/docs/registry.d.ts +0 -8
- package/dist/libs/contracts/src/docs/registry.d.ts.map +0 -1
- package/dist/libs/contracts/src/docs/tech/auth/better-auth-nextjs.docblock.d.ts +0 -1
- package/dist/libs/contracts/src/docs/tech/contracts/README.docblock.d.ts +0 -1
- package/dist/libs/contracts/src/docs/tech/contracts/openapi-export.docblock.d.ts +0 -1
- package/dist/libs/contracts/src/docs/tech/contracts/openapi-import.docblock.d.ts +0 -1
- package/dist/libs/contracts/src/docs/tech/lifecycle-stage-system.docblock.d.ts +0 -1
- package/dist/libs/contracts/src/docs/tech/llm/llm-integration.docblock.d.ts +0 -1
- package/dist/libs/contracts/src/docs/tech/mcp-endpoints.docblock.d.ts +0 -1
- package/dist/libs/contracts/src/docs/tech/presentation-runtime.docblock.d.ts +0 -1
- package/dist/libs/contracts/src/docs/tech/schema/README.docblock.d.ts +0 -1
- package/dist/libs/contracts/src/docs/tech/studio/learning-events.docblock.d.ts +0 -1
- package/dist/libs/contracts/src/docs/tech/studio/learning-journeys.docblock.d.ts +0 -1
- package/dist/libs/contracts/src/docs/tech/studio/platform-admin-panel.docblock.d.ts +0 -1
- package/dist/libs/contracts/src/docs/tech/studio/project-access-teams.docblock.d.ts +0 -1
- package/dist/libs/contracts/src/docs/tech/studio/project-routing.docblock.d.ts +0 -1
- package/dist/libs/contracts/src/docs/tech/studio/sandbox-unlogged.docblock.d.ts +0 -1
- package/dist/libs/contracts/src/docs/tech/studio/team-invitations.docblock.d.ts +0 -1
- package/dist/libs/contracts/src/docs/tech/studio/workspace-ops.docblock.d.ts +0 -1
- package/dist/libs/contracts/src/docs/tech/studio/workspaces.docblock.d.ts +0 -1
- package/dist/libs/contracts/src/docs/tech/telemetry-ingest.docblock.d.ts +0 -1
- package/dist/libs/contracts/src/docs/tech/vscode-extension.docblock.d.ts +0 -1
- package/dist/libs/contracts/src/docs/views/contractReference.dataView.d.ts +0 -1
- package/dist/libs/contracts/src/docs/views/docsIndex.dataView.d.ts +0 -1
- package/dist/libs/contracts/src/docs/views/exampleCatalog.dataView.d.ts +0 -1
- package/dist/libs/contracts/src/docs/views/index.d.ts +0 -3
- package/dist/libs/contracts/src/events.d.ts +0 -3
- package/dist/libs/contracts/src/examples/index.d.ts +0 -4
- package/dist/libs/contracts/src/examples/registry.d.ts +0 -2
- package/dist/libs/contracts/src/examples/schema.d.ts +0 -2
- package/dist/libs/contracts/src/examples/types.d.ts +0 -138
- package/dist/libs/contracts/src/examples/types.d.ts.map +0 -1
- package/dist/libs/contracts/src/examples/validation.d.ts +0 -1
- package/dist/libs/contracts/src/experiments/spec-resolver.d.ts +0 -3
- package/dist/libs/contracts/src/experiments/spec.d.ts +0 -14
- package/dist/libs/contracts/src/experiments/spec.d.ts.map +0 -1
- package/dist/libs/contracts/src/features/index.d.ts +0 -4
- package/dist/libs/contracts/src/features/install.d.ts +0 -5
- package/dist/libs/contracts/src/features/registry.d.ts +0 -1
- package/dist/libs/contracts/src/features/types.d.ts +0 -85
- package/dist/libs/contracts/src/features/types.d.ts.map +0 -1
- package/dist/libs/contracts/src/features/validation.d.ts +0 -1
- package/dist/libs/contracts/src/forms/forms.d.ts +0 -1
- package/dist/libs/contracts/src/forms/index.d.ts +0 -1
- package/dist/libs/contracts/src/index.d.ts +0 -49
- package/dist/libs/contracts/src/install.d.ts +0 -6
- package/dist/libs/contracts/src/integrations/connection.d.ts +0 -1
- package/dist/libs/contracts/src/integrations/index.d.ts +0 -5
- package/dist/libs/contracts/src/integrations/openbanking/contracts/accounts.d.ts +0 -3
- package/dist/libs/contracts/src/integrations/openbanking/contracts/balances.d.ts +0 -3
- package/dist/libs/contracts/src/integrations/openbanking/contracts/index.d.ts +0 -5
- package/dist/libs/contracts/src/integrations/openbanking/contracts/transactions.d.ts +0 -3
- package/dist/libs/contracts/src/integrations/openbanking/guards.d.ts +0 -1
- package/dist/libs/contracts/src/integrations/openbanking/openbanking.feature.d.ts +0 -1
- package/dist/libs/contracts/src/integrations/operations.d.ts +0 -3
- package/dist/libs/contracts/src/integrations/providers/elevenlabs.d.ts +0 -2
- package/dist/libs/contracts/src/integrations/providers/gcs-storage.d.ts +0 -2
- package/dist/libs/contracts/src/integrations/providers/gmail.d.ts +0 -2
- package/dist/libs/contracts/src/integrations/providers/google-calendar.d.ts +0 -2
- package/dist/libs/contracts/src/integrations/providers/index.d.ts +0 -11
- package/dist/libs/contracts/src/integrations/providers/mistral.d.ts +0 -2
- package/dist/libs/contracts/src/integrations/providers/postmark.d.ts +0 -2
- package/dist/libs/contracts/src/integrations/providers/powens.d.ts +0 -2
- package/dist/libs/contracts/src/integrations/providers/qdrant.d.ts +0 -2
- package/dist/libs/contracts/src/integrations/providers/registry.d.ts +0 -1
- package/dist/libs/contracts/src/integrations/providers/stripe.d.ts +0 -2
- package/dist/libs/contracts/src/integrations/providers/twilio-sms.d.ts +0 -2
- package/dist/libs/contracts/src/integrations/spec.d.ts +0 -10
- package/dist/libs/contracts/src/integrations/spec.d.ts.map +0 -1
- package/dist/libs/contracts/src/jsonschema.d.ts +0 -3
- package/dist/libs/contracts/src/knowledge/index.d.ts +0 -2
- package/dist/libs/contracts/src/knowledge/operations.d.ts +0 -3
- package/dist/libs/contracts/src/knowledge/spaces/email-threads.d.ts +0 -1
- package/dist/libs/contracts/src/knowledge/spaces/financial-docs.d.ts +0 -1
- package/dist/libs/contracts/src/knowledge/spaces/financial-overview.d.ts +0 -1
- package/dist/libs/contracts/src/knowledge/spaces/index.d.ts +0 -6
- package/dist/libs/contracts/src/knowledge/spaces/product-canon.d.ts +0 -1
- package/dist/libs/contracts/src/knowledge/spaces/support-faq.d.ts +0 -1
- package/dist/libs/contracts/src/knowledge/spaces/uploaded-docs.d.ts +0 -1
- package/dist/libs/contracts/src/knowledge/spec.d.ts +0 -2
- package/dist/libs/contracts/src/llm/exporters.d.ts +0 -6
- package/dist/libs/contracts/src/llm/index.d.ts +0 -3
- package/dist/libs/contracts/src/llm/prompts.d.ts +0 -2
- package/dist/libs/contracts/src/llm/types.d.ts +0 -3
- package/dist/libs/contracts/src/migrations.d.ts +0 -1
- package/dist/libs/contracts/src/onboarding-base.d.ts +0 -1
- package/dist/libs/contracts/src/openapi.d.ts +0 -1
- package/dist/libs/contracts/src/operations/index.d.ts +0 -3
- package/dist/libs/contracts/src/operations/operation.d.ts +0 -27
- package/dist/libs/contracts/src/operations/operation.d.ts.map +0 -1
- package/dist/libs/contracts/src/operations/registry.d.ts +0 -5
- package/dist/libs/contracts/src/operations/report/getContractVerificationStatus.d.ts +0 -2
- package/dist/libs/contracts/src/operations/report/index.d.ts +0 -4
- package/dist/libs/contracts/src/ownership.d.ts +0 -164
- package/dist/libs/contracts/src/ownership.d.ts.map +0 -1
- package/dist/libs/contracts/src/policy/engine.d.ts +0 -2
- package/dist/libs/contracts/src/policy/guards.d.ts +0 -1
- package/dist/libs/contracts/src/policy/index.d.ts +0 -6
- package/dist/libs/contracts/src/policy/opa-adapter.d.ts +0 -2
- package/dist/libs/contracts/src/policy/registry.d.ts +0 -1
- package/dist/libs/contracts/src/policy/spec.d.ts +0 -13
- package/dist/libs/contracts/src/policy/spec.d.ts.map +0 -1
- package/dist/libs/contracts/src/policy/validation.d.ts +0 -2
- package/dist/libs/contracts/src/presentations/index.d.ts +0 -3
- package/dist/libs/contracts/src/presentations/presentations.d.ts +0 -10
- package/dist/libs/contracts/src/presentations/presentations.d.ts.map +0 -1
- package/dist/libs/contracts/src/presentations/registry.d.ts +0 -1
- package/dist/libs/contracts/src/presentations/transform-engine.d.ts +0 -1
- package/dist/libs/contracts/src/prompt.d.ts +0 -2
- package/dist/libs/contracts/src/promptRegistry.d.ts +0 -2
- package/dist/libs/contracts/src/regenerator/adapters.d.ts +0 -1
- package/dist/libs/contracts/src/regenerator/executor.d.ts +0 -1
- package/dist/libs/contracts/src/regenerator/index.d.ts +0 -6
- package/dist/libs/contracts/src/regenerator/service.d.ts +0 -2
- package/dist/libs/contracts/src/regenerator/sinks.d.ts +0 -2
- package/dist/libs/contracts/src/regenerator/types.d.ts +0 -2
- package/dist/libs/contracts/src/regenerator/utils.d.ts +0 -1
- package/dist/libs/contracts/src/registry.d.ts +0 -2
- package/dist/libs/contracts/src/resources.d.ts +0 -2
- package/dist/libs/contracts/src/serialization/index.d.ts +0 -1
- package/dist/libs/contracts/src/serialization/serializers.d.ts +0 -6
- package/dist/libs/contracts/src/server/graphql-pothos.d.ts +0 -7
- package/dist/libs/contracts/src/server/index.d.ts +0 -7
- package/dist/libs/contracts/src/server/mcp/createMcpServer.d.ts +0 -5
- package/dist/libs/contracts/src/server/mcp/mcpTypes.d.ts +0 -3
- package/dist/libs/contracts/src/server/provider-mcp.d.ts +0 -1
- package/dist/libs/contracts/src/server/rest-elysia.d.ts +0 -3
- package/dist/libs/contracts/src/server/rest-express.d.ts +0 -3
- package/dist/libs/contracts/src/server/rest-generic.d.ts +0 -2
- package/dist/libs/contracts/src/server/rest-next-app.d.ts +0 -3
- package/dist/libs/contracts/src/server/rest-next-pages.d.ts +0 -3
- package/dist/libs/contracts/src/tests/index.d.ts +0 -2
- package/dist/libs/contracts/src/tests/runner.d.ts +0 -3
- package/dist/libs/contracts/src/tests/spec.d.ts +0 -1
- package/dist/libs/contracts/src/themes.d.ts +0 -14
- package/dist/libs/contracts/src/themes.d.ts.map +0 -1
- package/dist/libs/contracts/src/types.d.ts +0 -3
- package/dist/libs/contracts/src/versioning/refs.d.ts +0 -60
- package/dist/libs/contracts/src/versioning/refs.d.ts.map +0 -1
- package/dist/libs/contracts/src/workflow/adapters/db-adapter.d.ts +0 -1
- package/dist/libs/contracts/src/workflow/adapters/file-adapter.d.ts +0 -1
- package/dist/libs/contracts/src/workflow/adapters/index.d.ts +0 -3
- package/dist/libs/contracts/src/workflow/adapters/memory-store.d.ts +0 -1
- package/dist/libs/contracts/src/workflow/context.d.ts +0 -2
- package/dist/libs/contracts/src/workflow/index.d.ts +0 -8
- package/dist/libs/contracts/src/workflow/overview.docblock.d.ts +0 -1
- package/dist/libs/contracts/src/workflow/runner.d.ts +0 -5
- package/dist/libs/contracts/src/workflow/sla-monitor.d.ts +0 -2
- package/dist/libs/contracts/src/workflow/spec.d.ts +0 -83
- package/dist/libs/contracts/src/workflow/spec.d.ts.map +0 -1
- package/dist/libs/contracts/src/workflow/state.d.ts +0 -1
- package/dist/libs/contracts/src/workflow/validation.d.ts +0 -5
- package/dist/libs/contracts/src/workspace-config/contractsrc-schema.d.ts +0 -1
- package/dist/libs/contracts/src/workspace-config/index.d.ts +0 -1
- package/dist/libs/contracts/src/workspace-config/workspace-config.docblock.d.ts +0 -1
- package/dist/overlay-customization.js.map +0 -1
- package/dist/workflow-extension.js.map +0 -1
|
@@ -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
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// src/workflow-extension.ts
|
|
2
|
+
import { StabilityEnum } from "@contractspec/lib.contracts";
|
|
3
|
+
import { WorkflowComposer } from "@contractspec/lib.workflow-composer";
|
|
4
|
+
import { Logger, LogLevel } from "@contractspec/lib.logger";
|
|
5
|
+
var logger = new Logger({
|
|
6
|
+
level: LogLevel.DEBUG,
|
|
7
|
+
environment: "development",
|
|
8
|
+
enableColors: true
|
|
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,5 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
declare function runOverlayCustomizationExample(): Promise<void>;
|
|
3
|
-
//#endregion
|
|
4
|
-
export { runOverlayCustomizationExample };
|
|
1
|
+
export declare function runOverlayCustomizationExample(): Promise<void>;
|
|
5
2
|
//# sourceMappingURL=overlay-customization.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"overlay-customization.d.ts","
|
|
1
|
+
{"version":3,"file":"overlay-customization.d.ts","sourceRoot":"","sources":["../src/overlay-customization.ts"],"names":[],"mappings":"AAgBA,wBAAsB,8BAA8B,IAAI,OAAO,CAAC,IAAI,CAAC,CAwCpE"}
|
|
@@ -1,50 +1,54 @@
|
|
|
1
|
-
|
|
1
|
+
// @bun
|
|
2
|
+
// src/overlay-customization.ts
|
|
2
3
|
import { defineOverlay } from "@contractspec/lib.overlay-engine/spec";
|
|
3
4
|
import { signOverlay } from "@contractspec/lib.overlay-engine/signer";
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
import {
|
|
6
|
+
OverlayEngine,
|
|
7
|
+
OverlayRegistry
|
|
8
|
+
} from "@contractspec/lib.overlay-engine";
|
|
9
|
+
import { Logger, LogLevel } from "@contractspec/lib.logger";
|
|
10
|
+
var logger = new Logger({
|
|
11
|
+
level: LogLevel.DEBUG,
|
|
12
|
+
environment: "development",
|
|
13
|
+
enableColors: true
|
|
11
14
|
});
|
|
12
15
|
async function runOverlayCustomizationExample() {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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 });
|
|
46
51
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
//# sourceMappingURL=overlay-customization.js.map
|
|
52
|
+
export {
|
|
53
|
+
runOverlayCustomizationExample
|
|
54
|
+
};
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import { WorkflowSpec } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
declare function composeTenantWorkflowExample(): WorkflowSpec;
|
|
5
|
-
declare function logTenantWorkflowSteps(workflow: WorkflowSpec): void;
|
|
6
|
-
//#endregion
|
|
7
|
-
export { composeTenantWorkflowExample, logTenantWorkflowSteps };
|
|
1
|
+
import type { WorkflowSpec } from '@contractspec/lib.contracts/workflow/spec';
|
|
2
|
+
export declare function composeTenantWorkflowExample(): WorkflowSpec;
|
|
3
|
+
export declare function logTenantWorkflowSteps(workflow: WorkflowSpec): void;
|
|
8
4
|
//# sourceMappingURL=workflow-extension.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow-extension.d.ts","
|
|
1
|
+
{"version":3,"file":"workflow-extension.d.ts","sourceRoot":"","sources":["../src/workflow-extension.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2CAA2C,CAAC;AAgC9E,wBAAgB,4BAA4B,IAAI,YAAY,CAsB3D;AAED,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,YAAY,GAAG,IAAI,CAKnE"}
|
|
@@ -1,67 +1,61 @@
|
|
|
1
|
-
|
|
1
|
+
// @bun
|
|
2
|
+
// src/workflow-extension.ts
|
|
2
3
|
import { StabilityEnum } from "@contractspec/lib.contracts";
|
|
3
4
|
import { WorkflowComposer } from "@contractspec/lib.workflow-composer";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
enableColors: process.env.NODE_ENV !== "production"
|
|
5
|
+
import { Logger, LogLevel } from "@contractspec/lib.logger";
|
|
6
|
+
var logger = new Logger({
|
|
7
|
+
level: LogLevel.DEBUG,
|
|
8
|
+
environment: "development",
|
|
9
|
+
enableColors: true
|
|
10
10
|
});
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
type: "human",
|
|
30
|
-
label: "Final Approval"
|
|
31
|
-
}],
|
|
32
|
-
transitions: [{
|
|
33
|
-
from: "validate-invoice",
|
|
34
|
-
to: "final-approval"
|
|
35
|
-
}]
|
|
36
|
-
}
|
|
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
|
+
}
|
|
37
29
|
};
|
|
38
30
|
function composeTenantWorkflowExample() {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
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
|
+
});
|
|
57
51
|
}
|
|
58
52
|
function logTenantWorkflowSteps(workflow) {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
53
|
+
logger.info("Tenant workflow composed", {
|
|
54
|
+
workflow: workflow.meta.key,
|
|
55
|
+
steps: workflow.definition.steps.map((step) => step.id)
|
|
56
|
+
});
|
|
63
57
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
58
|
+
export {
|
|
59
|
+
logTenantWorkflowSteps,
|
|
60
|
+
composeTenantWorkflowExample
|
|
61
|
+
};
|