@contractspec/lib.contracts 0.0.0-canary-20260113162409
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/LICENSE +21 -0
- package/README.md +109 -0
- package/dist/_virtual/rolldown_runtime.js +37 -0
- package/dist/app-config/app-config.capability.d.ts +7 -0
- package/dist/app-config/app-config.capability.js +23 -0
- package/dist/app-config/app-config.feature.d.ts +11 -0
- package/dist/app-config/app-config.feature.js +61 -0
- package/dist/app-config/branding.d.ts +55 -0
- package/dist/app-config/branding.js +0 -0
- package/dist/app-config/contracts.d.ts +245 -0
- package/dist/app-config/contracts.js +395 -0
- package/dist/app-config/docs/app-config.docblock.d.ts +6 -0
- package/dist/app-config/docs/app-config.docblock.js +21 -0
- package/dist/app-config/events.d.ts +122 -0
- package/dist/app-config/events.js +174 -0
- package/dist/app-config/index.d.ts +10 -0
- package/dist/app-config/index.js +9 -0
- package/dist/app-config/lifecycle-contracts.d.ts +273 -0
- package/dist/app-config/lifecycle-contracts.js +440 -0
- package/dist/app-config/lifecycle.d.ts +27 -0
- package/dist/app-config/lifecycle.js +0 -0
- package/dist/app-config/runtime.d.ts +120 -0
- package/dist/app-config/runtime.js +617 -0
- package/dist/app-config/spec.d.ts +175 -0
- package/dist/app-config/spec.js +19 -0
- package/dist/app-config/validation.d.ts +49 -0
- package/dist/app-config/validation.js +538 -0
- package/dist/capabilities/capabilities.d.ts +41 -0
- package/dist/capabilities/capabilities.js +48 -0
- package/dist/capabilities/docs/capabilities.docblock.d.ts +6 -0
- package/dist/capabilities/docs/capabilities.docblock.js +21 -0
- package/dist/capabilities/index.d.ts +3 -0
- package/dist/capabilities/index.js +4 -0
- package/dist/capabilities/openbanking.d.ts +10 -0
- package/dist/capabilities/openbanking.js +92 -0
- package/dist/client/index.d.ts +6 -0
- package/dist/client/index.js +9 -0
- package/dist/client/react/drivers/rn-reusables.d.ts +22 -0
- package/dist/client/react/drivers/rn-reusables.js +21 -0
- package/dist/client/react/drivers/shadcn.d.ts +12 -0
- package/dist/client/react/drivers/shadcn.js +11 -0
- package/dist/client/react/feature-render.d.ts +23 -0
- package/dist/client/react/feature-render.js +44 -0
- package/dist/client/react/form-render.d.ts +92 -0
- package/dist/client/react/form-render.js +301 -0
- package/dist/client/react/index.d.ts +5 -0
- package/dist/client/react/index.js +8 -0
- package/dist/contract-registry/index.d.ts +3 -0
- package/dist/contract-registry/index.js +3 -0
- package/dist/contract-registry/schemas.d.ts +124 -0
- package/dist/contract-registry/schemas.js +61 -0
- package/dist/contract-registry/types.d.ts +46 -0
- package/dist/contract-registry/types.js +0 -0
- package/dist/data-views/data-views.d.ts +5 -0
- package/dist/data-views/data-views.js +5 -0
- package/dist/data-views/docs/data-views.docblock.d.ts +6 -0
- package/dist/data-views/docs/data-views.docblock.js +21 -0
- package/dist/data-views/index.d.ts +4 -0
- package/dist/data-views/index.js +4 -0
- package/dist/data-views/query-generator.d.ts +40 -0
- package/dist/data-views/query-generator.js +48 -0
- package/dist/data-views/registry.d.ts +17 -0
- package/dist/data-views/registry.js +20 -0
- package/dist/data-views/runtime.d.ts +32 -0
- package/dist/data-views/runtime.js +68 -0
- package/dist/data-views/spec.d.ts +32 -0
- package/dist/data-views/spec.js +10 -0
- package/dist/data-views/types.d.ts +157 -0
- package/dist/data-views/types.js +0 -0
- package/dist/docs/accessibility_wcag_compliance_specs.docblock.d.ts +6 -0
- package/dist/docs/accessibility_wcag_compliance_specs.docblock.js +17 -0
- package/dist/docs/index.d.ts +6 -0
- package/dist/docs/index.js +30 -0
- package/dist/docs/meta.docs.d.ts +6 -0
- package/dist/docs/meta.docs.js +29 -0
- package/dist/docs/presentations.d.ts +31 -0
- package/dist/docs/presentations.js +57 -0
- package/dist/docs/registry.d.ts +23 -0
- package/dist/docs/registry.js +51 -0
- package/dist/docs/tech/auth/better-auth-nextjs.docblock.d.ts +6 -0
- package/dist/docs/tech/auth/better-auth-nextjs.docblock.js +81 -0
- package/dist/docs/tech/cli.docblock.d.ts +6 -0
- package/dist/docs/tech/cli.docblock.js +138 -0
- package/dist/docs/tech/contracts/README.docblock.d.ts +6 -0
- package/dist/docs/tech/contracts/README.docblock.js +21 -0
- package/dist/docs/tech/contracts/migrations.docblock.d.ts +6 -0
- package/dist/docs/tech/contracts/migrations.docblock.js +21 -0
- package/dist/docs/tech/contracts/openapi-export.docblock.d.ts +6 -0
- package/dist/docs/tech/contracts/openapi-export.docblock.js +58 -0
- package/dist/docs/tech/contracts/openapi-import.docblock.d.ts +6 -0
- package/dist/docs/tech/contracts/openapi-import.docblock.js +65 -0
- package/dist/docs/tech/contracts/ops-to-presentation-linking.docblock.d.ts +6 -0
- package/dist/docs/tech/contracts/ops-to-presentation-linking.docblock.js +21 -0
- package/dist/docs/tech/contracts/overlays.docblock.d.ts +6 -0
- package/dist/docs/tech/contracts/overlays.docblock.js +21 -0
- package/dist/docs/tech/contracts/tests.docblock.d.ts +6 -0
- package/dist/docs/tech/contracts/tests.docblock.js +21 -0
- package/dist/docs/tech/contracts/themes.docblock.d.ts +6 -0
- package/dist/docs/tech/contracts/themes.docblock.js +21 -0
- package/dist/docs/tech/contracts/vertical-pocket-family-office.docblock.d.ts +6 -0
- package/dist/docs/tech/contracts/vertical-pocket-family-office.docblock.js +126 -0
- package/dist/docs/tech/lifecycle-stage-system.docblock.d.ts +6 -0
- package/dist/docs/tech/lifecycle-stage-system.docblock.js +17 -0
- package/dist/docs/tech/llm/llm-integration.docblock.d.ts +7 -0
- package/dist/docs/tech/llm/llm-integration.docblock.js +358 -0
- package/dist/docs/tech/mcp-endpoints.docblock.d.ts +6 -0
- package/dist/docs/tech/mcp-endpoints.docblock.js +38 -0
- package/dist/docs/tech/presentation-runtime.docblock.d.ts +6 -0
- package/dist/docs/tech/presentation-runtime.docblock.js +17 -0
- package/dist/docs/tech/schema/README.docblock.d.ts +6 -0
- package/dist/docs/tech/schema/README.docblock.js +21 -0
- package/dist/docs/tech/studio/learning-events.docblock.d.ts +6 -0
- package/dist/docs/tech/studio/learning-events.docblock.js +49 -0
- package/dist/docs/tech/studio/learning-journeys.docblock.d.ts +6 -0
- package/dist/docs/tech/studio/learning-journeys.docblock.js +80 -0
- package/dist/docs/tech/studio/platform-admin-panel.docblock.d.ts +6 -0
- package/dist/docs/tech/studio/platform-admin-panel.docblock.js +85 -0
- package/dist/docs/tech/studio/project-access-teams.docblock.d.ts +6 -0
- package/dist/docs/tech/studio/project-access-teams.docblock.js +48 -0
- package/dist/docs/tech/studio/project-routing.docblock.d.ts +6 -0
- package/dist/docs/tech/studio/project-routing.docblock.js +68 -0
- package/dist/docs/tech/studio/sandbox-unlogged.docblock.d.ts +6 -0
- package/dist/docs/tech/studio/sandbox-unlogged.docblock.js +41 -0
- package/dist/docs/tech/studio/team-invitations.docblock.d.ts +6 -0
- package/dist/docs/tech/studio/team-invitations.docblock.js +70 -0
- package/dist/docs/tech/studio/workspace-ops.docblock.d.ts +6 -0
- package/dist/docs/tech/studio/workspace-ops.docblock.js +48 -0
- package/dist/docs/tech/studio/workspaces.docblock.d.ts +6 -0
- package/dist/docs/tech/studio/workspaces.docblock.js +63 -0
- package/dist/docs/tech/telemetry-ingest.docblock.d.ts +6 -0
- package/dist/docs/tech/telemetry-ingest.docblock.js +156 -0
- package/dist/docs/tech/vscode-extension.docblock.d.ts +6 -0
- package/dist/docs/tech/vscode-extension.docblock.js +102 -0
- package/dist/docs/tech-contracts.docs.d.ts +6 -0
- package/dist/docs/tech-contracts.docs.js +96 -0
- package/dist/docs/types.d.ts +41 -0
- package/dist/docs/types.js +0 -0
- package/dist/events.d.ts +47 -0
- package/dist/events.js +19 -0
- package/dist/examples/docs/examples.docblock.d.ts +6 -0
- package/dist/examples/docs/examples.docblock.js +165 -0
- package/dist/examples/index.d.ts +13 -0
- package/dist/examples/index.js +13 -0
- package/dist/examples/registry.d.ts +43 -0
- package/dist/examples/registry.js +88 -0
- package/dist/examples/schema.d.ts +282 -0
- package/dist/examples/schema.js +125 -0
- package/dist/examples/types.d.ts +167 -0
- package/dist/examples/types.js +43 -0
- package/dist/examples/validation.d.ts +65 -0
- package/dist/examples/validation.js +144 -0
- package/dist/experiments/docs/experiments.docblock.d.ts +6 -0
- package/dist/experiments/docs/experiments.docblock.js +21 -0
- package/dist/experiments/evaluator.d.ts +37 -0
- package/dist/experiments/evaluator.js +101 -0
- package/dist/experiments/spec-resolver.d.ts +17 -0
- package/dist/experiments/spec-resolver.js +0 -0
- package/dist/experiments/spec.d.ts +80 -0
- package/dist/experiments/spec.js +15 -0
- package/dist/features/index.d.ts +13 -0
- package/dist/features/index.js +12 -0
- package/dist/features/install.d.ts +22 -0
- package/dist/features/install.js +36 -0
- package/dist/features/registry.d.ts +26 -0
- package/dist/features/registry.js +49 -0
- package/dist/features/types.d.ts +88 -0
- package/dist/features/types.js +0 -0
- package/dist/features/validation.d.ts +8 -0
- package/dist/features/validation.js +14 -0
- package/dist/forms/docs/forms.docblock.d.ts +6 -0
- package/dist/forms/docs/forms.docblock.js +21 -0
- package/dist/forms/forms.d.ts +266 -0
- package/dist/forms/forms.js +143 -0
- package/dist/forms/index.d.ts +2 -0
- package/dist/forms/index.js +3 -0
- package/dist/index.d.ts +154 -0
- package/dist/index.js +132 -0
- package/dist/install.d.ts +77 -0
- package/dist/install.js +40 -0
- package/dist/integrations/binding.d.ts +17 -0
- package/dist/integrations/binding.js +0 -0
- package/dist/integrations/connection.d.ts +51 -0
- package/dist/integrations/connection.js +0 -0
- package/dist/integrations/docs/integrations.docblock.d.ts +6 -0
- package/dist/integrations/docs/integrations.docblock.js +94 -0
- package/dist/integrations/health.d.ts +21 -0
- package/dist/integrations/health.js +69 -0
- package/dist/integrations/index.d.ts +34 -0
- package/dist/integrations/index.js +23 -0
- package/dist/integrations/integrations.capability.d.ts +7 -0
- package/dist/integrations/integrations.capability.js +17 -0
- package/dist/integrations/integrations.feature.d.ts +11 -0
- package/dist/integrations/integrations.feature.js +67 -0
- package/dist/integrations/openbanking/contracts/accounts.d.ts +289 -0
- package/dist/integrations/openbanking/contracts/accounts.js +236 -0
- package/dist/integrations/openbanking/contracts/balances.d.ts +165 -0
- package/dist/integrations/openbanking/contracts/balances.js +166 -0
- package/dist/integrations/openbanking/contracts/index.d.ts +10 -0
- package/dist/integrations/openbanking/contracts/index.js +12 -0
- package/dist/integrations/openbanking/contracts/transactions.d.ts +213 -0
- package/dist/integrations/openbanking/contracts/transactions.js +217 -0
- package/dist/integrations/openbanking/guards.d.ts +12 -0
- package/dist/integrations/openbanking/guards.js +33 -0
- package/dist/integrations/openbanking/models.d.ts +228 -0
- package/dist/integrations/openbanking/models.js +240 -0
- package/dist/integrations/openbanking/openbanking.capability.d.ts +7 -0
- package/dist/integrations/openbanking/openbanking.capability.js +21 -0
- package/dist/integrations/openbanking/openbanking.feature.d.ts +11 -0
- package/dist/integrations/openbanking/openbanking.feature.js +76 -0
- package/dist/integrations/openbanking/telemetry.d.ts +15 -0
- package/dist/integrations/openbanking/telemetry.js +39 -0
- package/dist/integrations/operations.d.ts +437 -0
- package/dist/integrations/operations.js +392 -0
- package/dist/integrations/providers/calendar.d.ts +78 -0
- package/dist/integrations/providers/calendar.js +0 -0
- package/dist/integrations/providers/elevenlabs.d.ts +8 -0
- package/dist/integrations/providers/elevenlabs.js +56 -0
- package/dist/integrations/providers/email.d.ts +86 -0
- package/dist/integrations/providers/email.js +0 -0
- package/dist/integrations/providers/embedding.d.ts +24 -0
- package/dist/integrations/providers/embedding.js +0 -0
- package/dist/integrations/providers/gcs-storage.d.ts +8 -0
- package/dist/integrations/providers/gcs-storage.js +79 -0
- package/dist/integrations/providers/gmail.d.ts +8 -0
- package/dist/integrations/providers/gmail.js +91 -0
- package/dist/integrations/providers/google-calendar.d.ts +8 -0
- package/dist/integrations/providers/google-calendar.js +70 -0
- package/dist/integrations/providers/impls/elevenlabs-voice.d.ts +20 -0
- package/dist/integrations/providers/impls/elevenlabs-voice.js +95 -0
- package/dist/integrations/providers/impls/gcs-storage.d.ts +24 -0
- package/dist/integrations/providers/impls/gcs-storage.js +88 -0
- package/dist/integrations/providers/impls/gmail-inbound.d.ts +26 -0
- package/dist/integrations/providers/impls/gmail-inbound.js +200 -0
- package/dist/integrations/providers/impls/gmail-outbound.d.ts +18 -0
- package/dist/integrations/providers/impls/gmail-outbound.js +105 -0
- package/dist/integrations/providers/impls/google-calendar.d.ts +23 -0
- package/dist/integrations/providers/impls/google-calendar.js +154 -0
- package/dist/integrations/providers/impls/index.d.ts +15 -0
- package/dist/integrations/providers/impls/index.js +16 -0
- package/dist/integrations/providers/impls/mistral-embedding.d.ts +23 -0
- package/dist/integrations/providers/impls/mistral-embedding.js +41 -0
- package/dist/integrations/providers/impls/mistral-llm.d.ts +31 -0
- package/dist/integrations/providers/impls/mistral-llm.js +247 -0
- package/dist/integrations/providers/impls/postmark-email.d.ts +19 -0
- package/dist/integrations/providers/impls/postmark-email.js +55 -0
- package/dist/integrations/providers/impls/powens-client.d.ts +124 -0
- package/dist/integrations/providers/impls/powens-client.js +171 -0
- package/dist/integrations/providers/impls/powens-openbanking.d.ts +27 -0
- package/dist/integrations/providers/impls/powens-openbanking.js +218 -0
- package/dist/integrations/providers/impls/provider-factory.d.ts +26 -0
- package/dist/integrations/providers/impls/provider-factory.js +146 -0
- package/dist/integrations/providers/impls/qdrant-vector.d.ts +24 -0
- package/dist/integrations/providers/impls/qdrant-vector.js +69 -0
- package/dist/integrations/providers/impls/stripe-payments.d.ts +28 -0
- package/dist/integrations/providers/impls/stripe-payments.js +202 -0
- package/dist/integrations/providers/impls/twilio-sms.d.ts +20 -0
- package/dist/integrations/providers/impls/twilio-sms.js +58 -0
- package/dist/integrations/providers/index.d.ts +22 -0
- package/dist/integrations/providers/index.js +13 -0
- package/dist/integrations/providers/llm.d.ts +82 -0
- package/dist/integrations/providers/llm.js +0 -0
- package/dist/integrations/providers/mistral.d.ts +8 -0
- package/dist/integrations/providers/mistral.js +72 -0
- package/dist/integrations/providers/openbanking.d.ts +128 -0
- package/dist/integrations/providers/openbanking.js +0 -0
- package/dist/integrations/providers/payments.d.ts +109 -0
- package/dist/integrations/providers/payments.js +0 -0
- package/dist/integrations/providers/postmark.d.ts +8 -0
- package/dist/integrations/providers/postmark.js +72 -0
- package/dist/integrations/providers/powens.d.ts +8 -0
- package/dist/integrations/providers/powens.js +120 -0
- package/dist/integrations/providers/qdrant.d.ts +8 -0
- package/dist/integrations/providers/qdrant.js +77 -0
- package/dist/integrations/providers/registry.d.ts +11 -0
- package/dist/integrations/providers/registry.js +34 -0
- package/dist/integrations/providers/sms.d.ts +34 -0
- package/dist/integrations/providers/sms.js +0 -0
- package/dist/integrations/providers/storage.d.ts +60 -0
- package/dist/integrations/providers/storage.js +0 -0
- package/dist/integrations/providers/stripe.d.ts +8 -0
- package/dist/integrations/providers/stripe.js +87 -0
- package/dist/integrations/providers/twilio-sms.d.ts +8 -0
- package/dist/integrations/providers/twilio-sms.js +65 -0
- package/dist/integrations/providers/vector-store.d.ts +43 -0
- package/dist/integrations/providers/vector-store.js +0 -0
- package/dist/integrations/providers/voice.d.ts +34 -0
- package/dist/integrations/providers/voice.js +0 -0
- package/dist/integrations/runtime.d.ts +99 -0
- package/dist/integrations/runtime.js +186 -0
- package/dist/integrations/secrets/aws-secret-manager.d.ts +31 -0
- package/dist/integrations/secrets/aws-secret-manager.js +231 -0
- package/dist/integrations/secrets/env-secret-provider.d.ts +31 -0
- package/dist/integrations/secrets/env-secret-provider.js +81 -0
- package/dist/integrations/secrets/gcp-secret-manager.d.ts +32 -0
- package/dist/integrations/secrets/gcp-secret-manager.js +229 -0
- package/dist/integrations/secrets/index.d.ts +7 -0
- package/dist/integrations/secrets/index.js +8 -0
- package/dist/integrations/secrets/manager.d.ts +47 -0
- package/dist/integrations/secrets/manager.js +103 -0
- package/dist/integrations/secrets/provider.d.ts +52 -0
- package/dist/integrations/secrets/provider.js +58 -0
- package/dist/integrations/secrets/scaleway-secret-manager.d.ts +38 -0
- package/dist/integrations/secrets/scaleway-secret-manager.js +247 -0
- package/dist/integrations/secrets-types.d.ts +17 -0
- package/dist/integrations/secrets-types.js +0 -0
- package/dist/integrations/spec.d.ts +77 -0
- package/dist/integrations/spec.js +22 -0
- package/dist/jobs/define-job.d.ts +18 -0
- package/dist/jobs/define-job.js +16 -0
- package/dist/jobs/gcp-cloud-tasks.d.ts +41 -0
- package/dist/jobs/gcp-cloud-tasks.js +53 -0
- package/dist/jobs/gcp-pubsub.d.ts +25 -0
- package/dist/jobs/gcp-pubsub.js +39 -0
- package/dist/jobs/handlers/gmail-sync-handler.d.ts +9 -0
- package/dist/jobs/handlers/gmail-sync-handler.js +9 -0
- package/dist/jobs/handlers/index.d.ts +9 -0
- package/dist/jobs/handlers/index.js +12 -0
- package/dist/jobs/handlers/ping-handler.d.ts +10 -0
- package/dist/jobs/handlers/ping-handler.js +15 -0
- package/dist/jobs/handlers/storage-document-handler.d.ts +12 -0
- package/dist/jobs/handlers/storage-document-handler.js +14 -0
- package/dist/jobs/index.d.ts +3 -0
- package/dist/jobs/index.js +4 -0
- package/dist/jobs/memory-queue.d.ts +18 -0
- package/dist/jobs/memory-queue.js +71 -0
- package/dist/jobs/queue.d.ts +131 -0
- package/dist/jobs/queue.js +33 -0
- package/dist/jobs/scaleway-sqs-queue.d.ts +30 -0
- package/dist/jobs/scaleway-sqs-queue.js +153 -0
- package/dist/jsonschema.d.ts +42 -0
- package/dist/jsonschema.js +51 -0
- package/dist/knowledge/binding.d.ts +25 -0
- package/dist/knowledge/binding.js +0 -0
- package/dist/knowledge/docs/knowledge.docblock.d.ts +6 -0
- package/dist/knowledge/docs/knowledge.docblock.js +21 -0
- package/dist/knowledge/index.d.ts +11 -0
- package/dist/knowledge/index.js +10 -0
- package/dist/knowledge/ingestion/document-processor.d.ts +24 -0
- package/dist/knowledge/ingestion/document-processor.js +54 -0
- package/dist/knowledge/ingestion/embedding-service.d.ts +12 -0
- package/dist/knowledge/ingestion/embedding-service.js +25 -0
- package/dist/knowledge/ingestion/gmail-adapter.d.ts +18 -0
- package/dist/knowledge/ingestion/gmail-adapter.js +51 -0
- package/dist/knowledge/ingestion/index.d.ts +6 -0
- package/dist/knowledge/ingestion/index.js +7 -0
- package/dist/knowledge/ingestion/storage-adapter.d.ts +15 -0
- package/dist/knowledge/ingestion/storage-adapter.js +26 -0
- package/dist/knowledge/ingestion/vector-indexer.d.ts +18 -0
- package/dist/knowledge/ingestion/vector-indexer.js +32 -0
- package/dist/knowledge/knowledge.capability.d.ts +7 -0
- package/dist/knowledge/knowledge.capability.js +21 -0
- package/dist/knowledge/knowledge.feature.d.ts +11 -0
- package/dist/knowledge/knowledge.feature.js +68 -0
- package/dist/knowledge/operations.d.ts +318 -0
- package/dist/knowledge/operations.js +321 -0
- package/dist/knowledge/query/index.d.ts +2 -0
- package/dist/knowledge/query/index.js +3 -0
- package/dist/knowledge/query/service.d.ts +29 -0
- package/dist/knowledge/query/service.js +65 -0
- package/dist/knowledge/runtime.d.ts +32 -0
- package/dist/knowledge/runtime.js +49 -0
- package/dist/knowledge/source.d.ts +32 -0
- package/dist/knowledge/source.js +0 -0
- package/dist/knowledge/spaces/email-threads.d.ts +7 -0
- package/dist/knowledge/spaces/email-threads.js +37 -0
- package/dist/knowledge/spaces/financial-docs.d.ts +7 -0
- package/dist/knowledge/spaces/financial-docs.js +37 -0
- package/dist/knowledge/spaces/financial-overview.d.ts +7 -0
- package/dist/knowledge/spaces/financial-overview.js +41 -0
- package/dist/knowledge/spaces/index.d.ts +7 -0
- package/dist/knowledge/spaces/index.js +8 -0
- package/dist/knowledge/spaces/product-canon.d.ts +7 -0
- package/dist/knowledge/spaces/product-canon.js +37 -0
- package/dist/knowledge/spaces/support-faq.d.ts +7 -0
- package/dist/knowledge/spaces/support-faq.js +40 -0
- package/dist/knowledge/spaces/uploaded-docs.d.ts +7 -0
- package/dist/knowledge/spaces/uploaded-docs.js +37 -0
- package/dist/knowledge/spec.d.ts +46 -0
- package/dist/knowledge/spec.js +17 -0
- package/dist/llm/exporters.d.ts +70 -0
- package/dist/llm/exporters.js +542 -0
- package/dist/llm/index.d.ts +4 -0
- package/dist/llm/index.js +4 -0
- package/dist/llm/prompts.d.ts +52 -0
- package/dist/llm/prompts.js +410 -0
- package/dist/llm/types.d.ts +215 -0
- package/dist/llm/types.js +0 -0
- package/dist/markdown.d.ts +22 -0
- package/dist/markdown.js +119 -0
- package/dist/migrations.d.ts +52 -0
- package/dist/migrations.js +31 -0
- package/dist/model-registry.d.ts +13 -0
- package/dist/model-registry.js +33 -0
- package/dist/onboarding-base.d.ts +138 -0
- package/dist/onboarding-base.js +195 -0
- package/dist/openapi.d.ts +31 -0
- package/dist/openapi.js +82 -0
- package/dist/operations/index.d.ts +3 -0
- package/dist/operations/index.js +4 -0
- package/dist/operations/operation.d.ts +186 -0
- package/dist/operations/operation.js +35 -0
- package/dist/operations/registry.d.ts +54 -0
- package/dist/operations/registry.js +176 -0
- package/dist/ownership.d.ts +84 -0
- package/dist/ownership.js +38 -0
- package/dist/policy/docs/policy.docblock.d.ts +6 -0
- package/dist/policy/docs/policy.docblock.js +21 -0
- package/dist/policy/engine.d.ts +40 -0
- package/dist/policy/engine.js +225 -0
- package/dist/policy/index.d.ts +5 -0
- package/dist/policy/index.js +5 -0
- package/dist/policy/opa-adapter.d.ts +45 -0
- package/dist/policy/opa-adapter.js +71 -0
- package/dist/policy/registry.d.ts +9 -0
- package/dist/policy/registry.js +11 -0
- package/dist/policy/spec.d.ts +103 -0
- package/dist/policy/spec.js +0 -0
- package/dist/presentations/docs/presentations-conventions.docblock.d.ts +6 -0
- package/dist/presentations/docs/presentations-conventions.docblock.js +21 -0
- package/dist/presentations/index.d.ts +4 -0
- package/dist/presentations/index.js +5 -0
- package/dist/presentations/presentations.d.ts +50 -0
- package/dist/presentations/presentations.js +7 -0
- package/dist/presentations/registry.d.ts +10 -0
- package/dist/presentations/registry.js +12 -0
- package/dist/presentations/transform-engine.d.ts +66 -0
- package/dist/presentations/transform-engine.js +282 -0
- package/dist/prompt.d.ts +53 -0
- package/dist/prompt.js +10 -0
- package/dist/promptRegistry.d.ts +15 -0
- package/dist/promptRegistry.js +31 -0
- package/dist/regenerator/adapters.d.ts +19 -0
- package/dist/regenerator/adapters.js +0 -0
- package/dist/regenerator/docs/regenerator.docblock.d.ts +6 -0
- package/dist/regenerator/docs/regenerator.docblock.js +21 -0
- package/dist/regenerator/executor.d.ts +70 -0
- package/dist/regenerator/executor.js +86 -0
- package/dist/regenerator/index.d.ts +7 -0
- package/dist/regenerator/index.js +6 -0
- package/dist/regenerator/service.d.ts +33 -0
- package/dist/regenerator/service.js +93 -0
- package/dist/regenerator/sinks.d.ts +26 -0
- package/dist/regenerator/sinks.js +32 -0
- package/dist/regenerator/types.d.ts +107 -0
- package/dist/regenerator/types.js +0 -0
- package/dist/regenerator/utils.d.ts +9 -0
- package/dist/regenerator/utils.js +51 -0
- package/dist/registry-utils.d.ts +106 -0
- package/dist/registry-utils.js +122 -0
- package/dist/registry.d.ts +32 -0
- package/dist/registry.js +61 -0
- package/dist/resources.d.ts +64 -0
- package/dist/resources.js +50 -0
- package/dist/schema-to-markdown.d.ts +54 -0
- package/dist/schema-to-markdown.js +217 -0
- package/dist/server/contracts-adapter-hydration.d.ts +15 -0
- package/dist/server/contracts-adapter-hydration.js +41 -0
- package/dist/server/contracts-adapter-input.d.ts +9 -0
- package/dist/server/contracts-adapter-input.js +83 -0
- package/dist/server/graphql-pothos.d.ts +31 -0
- package/dist/server/graphql-pothos.js +134 -0
- package/dist/server/index.d.ts +9 -0
- package/dist/server/index.js +10 -0
- package/dist/server/mcp/createMcpServer.d.ts +15 -0
- package/dist/server/mcp/createMcpServer.js +27 -0
- package/dist/server/mcp/mcpTypes.d.ts +27 -0
- package/dist/server/mcp/mcpTypes.js +0 -0
- package/dist/server/mcp/registerPresentations.d.ts +7 -0
- package/dist/server/mcp/registerPresentations.js +54 -0
- package/dist/server/mcp/registerPrompts.d.ts +8 -0
- package/dist/server/mcp/registerPrompts.js +41 -0
- package/dist/server/mcp/registerResources.d.ts +8 -0
- package/dist/server/mcp/registerResources.js +35 -0
- package/dist/server/mcp/registerTools.d.ts +8 -0
- package/dist/server/mcp/registerTools.js +22 -0
- package/dist/server/provider-mcp.d.ts +2 -0
- package/dist/server/provider-mcp.js +3 -0
- package/dist/server/rest-elysia.d.ts +40 -0
- package/dist/server/rest-elysia.js +20 -0
- package/dist/server/rest-express.d.ts +16 -0
- package/dist/server/rest-express.js +36 -0
- package/dist/server/rest-generic.d.ts +32 -0
- package/dist/server/rest-generic.js +124 -0
- package/dist/server/rest-next-app.d.ts +35 -0
- package/dist/server/rest-next-app.js +38 -0
- package/dist/server/rest-next-mcp.d.ts +11 -0
- package/dist/server/rest-next-mcp.js +45 -0
- package/dist/server/rest-next-pages.d.ts +9 -0
- package/dist/server/rest-next-pages.js +22 -0
- package/dist/telemetry/anomaly.d.ts +27 -0
- package/dist/telemetry/anomaly.js +48 -0
- package/dist/telemetry/docs/telemetry.docblock.d.ts +6 -0
- package/dist/telemetry/docs/telemetry.docblock.js +21 -0
- package/dist/telemetry/index.d.ts +4 -0
- package/dist/telemetry/index.js +5 -0
- package/dist/telemetry/spec.d.ts +91 -0
- package/dist/telemetry/spec.js +42 -0
- package/dist/telemetry/tracker.d.ts +51 -0
- package/dist/telemetry/tracker.js +76 -0
- package/dist/tests/index.d.ts +3 -0
- package/dist/tests/index.js +4 -0
- package/dist/tests/runner.d.ts +43 -0
- package/dist/tests/runner.js +150 -0
- package/dist/tests/spec.d.ts +82 -0
- package/dist/tests/spec.js +34 -0
- package/dist/themes.d.ts +51 -0
- package/dist/themes.js +17 -0
- package/dist/translations/catalog.d.ts +28 -0
- package/dist/translations/catalog.js +0 -0
- package/dist/translations/tenant.d.ts +15 -0
- package/dist/translations/tenant.js +0 -0
- package/dist/types.d.ts +92 -0
- package/dist/types.js +0 -0
- package/dist/versioning/index.d.ts +3 -0
- package/dist/versioning/index.js +4 -0
- package/dist/versioning/types.d.ts +127 -0
- package/dist/versioning/types.js +24 -0
- package/dist/versioning/utils.d.ts +95 -0
- package/dist/versioning/utils.js +180 -0
- package/dist/workflow/adapters/db-adapter.d.ts +46 -0
- package/dist/workflow/adapters/db-adapter.js +83 -0
- package/dist/workflow/adapters/file-adapter.d.ts +14 -0
- package/dist/workflow/adapters/file-adapter.js +11 -0
- package/dist/workflow/adapters/index.d.ts +4 -0
- package/dist/workflow/adapters/index.js +5 -0
- package/dist/workflow/adapters/memory-store.d.ts +18 -0
- package/dist/workflow/adapters/memory-store.js +58 -0
- package/dist/workflow/expression.d.ts +9 -0
- package/dist/workflow/expression.js +99 -0
- package/dist/workflow/index.d.ts +17 -0
- package/dist/workflow/index.js +16 -0
- package/dist/workflow/overview.docblock.d.ts +6 -0
- package/dist/workflow/overview.docblock.js +21 -0
- package/dist/workflow/runner.d.ts +77 -0
- package/dist/workflow/runner.js +337 -0
- package/dist/workflow/sla-monitor.d.ts +20 -0
- package/dist/workflow/sla-monitor.js +47 -0
- package/dist/workflow/spec.d.ts +93 -0
- package/dist/workflow/spec.js +11 -0
- package/dist/workflow/state.d.ts +35 -0
- package/dist/workflow/state.js +0 -0
- package/dist/workflow/validation.d.ts +29 -0
- package/dist/workflow/validation.js +176 -0
- package/dist/workspace-config/contractsrc-schema.d.ts +1162 -0
- package/dist/workspace-config/contractsrc-schema.js +421 -0
- package/dist/workspace-config/index.d.ts +2 -0
- package/dist/workspace-config/index.js +3 -0
- package/dist/workspace-config/workspace-config.docblock.d.ts +6 -0
- package/dist/workspace-config/workspace-config.docblock.js +45 -0
- package/package.json +618 -0
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { OwnerShipMeta } from "../ownership.js";
|
|
2
|
+
import { FeatureModuleSpec, FeatureRef } from "../features/types.js";
|
|
3
|
+
import "../features/index.js";
|
|
4
|
+
import { AppBlueprintSpec, SpecPointer } from "../app-config/spec.js";
|
|
5
|
+
|
|
6
|
+
//#region src/examples/types.d.ts
|
|
7
|
+
/** Kind of example - determines how it's presented in catalogs */
|
|
8
|
+
type ExampleKind = 'template' | 'workflow' | 'integration' | 'knowledge' | 'blueprint' | 'ui' | 'script' | 'library';
|
|
9
|
+
declare const ExampleKindEnum: {
|
|
10
|
+
readonly Template: "template";
|
|
11
|
+
readonly Workflow: "workflow";
|
|
12
|
+
readonly Integration: "integration";
|
|
13
|
+
readonly Knowledge: "knowledge";
|
|
14
|
+
readonly Blueprint: "blueprint";
|
|
15
|
+
readonly UI: "ui";
|
|
16
|
+
readonly Script: "script";
|
|
17
|
+
readonly Library: "library";
|
|
18
|
+
};
|
|
19
|
+
/** Visibility level for examples */
|
|
20
|
+
type ExampleVisibility = 'public' | 'internal' | 'experimental';
|
|
21
|
+
declare const ExampleVisibilityEnum: {
|
|
22
|
+
readonly Public: "public";
|
|
23
|
+
readonly Internal: "internal";
|
|
24
|
+
readonly Experimental: "experimental";
|
|
25
|
+
};
|
|
26
|
+
/** Sandbox modes supported by examples */
|
|
27
|
+
type ExampleSandboxMode = 'playground' | 'specs' | 'builder' | 'markdown' | 'evolution';
|
|
28
|
+
declare const ExampleSandboxModeEnum: {
|
|
29
|
+
readonly Playground: "playground";
|
|
30
|
+
readonly Specs: "specs";
|
|
31
|
+
readonly Builder: "builder";
|
|
32
|
+
readonly Markdown: "markdown";
|
|
33
|
+
readonly Evolution: "evolution";
|
|
34
|
+
};
|
|
35
|
+
/** Documentation references for the example */
|
|
36
|
+
interface ExampleDocumentation {
|
|
37
|
+
/** Root documentation block ID */
|
|
38
|
+
rootDocId?: string;
|
|
39
|
+
/** Goal/purpose documentation */
|
|
40
|
+
goalDocId?: string;
|
|
41
|
+
/** Usage/quickstart documentation */
|
|
42
|
+
usageDocId?: string;
|
|
43
|
+
/** API/reference documentation */
|
|
44
|
+
referenceDocId?: string;
|
|
45
|
+
/** Constraints/limitations documentation */
|
|
46
|
+
constraintsDocId?: string;
|
|
47
|
+
}
|
|
48
|
+
/** Surface support configuration for sandbox */
|
|
49
|
+
interface ExampleSandboxSupport {
|
|
50
|
+
enabled: boolean;
|
|
51
|
+
modes: readonly ExampleSandboxMode[];
|
|
52
|
+
}
|
|
53
|
+
/** Surface support configuration for Studio */
|
|
54
|
+
interface ExampleStudioSupport {
|
|
55
|
+
enabled: boolean;
|
|
56
|
+
/** If true, Studio can create a real project from this example via API. */
|
|
57
|
+
installable: boolean;
|
|
58
|
+
}
|
|
59
|
+
/** Surface support configuration for MCP */
|
|
60
|
+
interface ExampleMcpSupport {
|
|
61
|
+
enabled: boolean;
|
|
62
|
+
}
|
|
63
|
+
/** Surface support configuration - where the example can be used */
|
|
64
|
+
interface ExampleSurfaces {
|
|
65
|
+
/** Available as a template for new projects */
|
|
66
|
+
templates: boolean;
|
|
67
|
+
/** Sandbox/playground support */
|
|
68
|
+
sandbox: ExampleSandboxSupport;
|
|
69
|
+
/** ContractSpec Studio support */
|
|
70
|
+
studio: ExampleStudioSupport;
|
|
71
|
+
/** MCP (Model Context Protocol) support */
|
|
72
|
+
mcp: ExampleMcpSupport;
|
|
73
|
+
}
|
|
74
|
+
/** Package entrypoints for the example - maps to package.json exports */
|
|
75
|
+
interface ExampleEntrypoints {
|
|
76
|
+
/** Package name in the workspace (e.g., @contractspec/example.saas-boilerplate) */
|
|
77
|
+
packageName: string;
|
|
78
|
+
/** Feature module entrypoint (e.g., ./saas-boilerplate.feature) */
|
|
79
|
+
feature?: string;
|
|
80
|
+
/** Blueprint entrypoint (e.g., ./blueprint) */
|
|
81
|
+
blueprint?: string;
|
|
82
|
+
/** Presentations entrypoint (e.g., ./presentations) */
|
|
83
|
+
presentations?: string;
|
|
84
|
+
/** Contracts/operations entrypoint (e.g., ./contracts) */
|
|
85
|
+
contracts?: string;
|
|
86
|
+
/** Handlers entrypoint (e.g., ./handlers) */
|
|
87
|
+
handlers?: string;
|
|
88
|
+
/** UI components entrypoint (e.g., ./ui) */
|
|
89
|
+
ui?: string;
|
|
90
|
+
/** Documentation entrypoint (e.g., ./docs) */
|
|
91
|
+
docs?: string;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Example metadata extending OwnerShipMeta.
|
|
95
|
+
* Provides standard spec identification plus example-specific fields.
|
|
96
|
+
*/
|
|
97
|
+
interface ExampleMeta extends OwnerShipMeta {
|
|
98
|
+
/** Example kind for categorization */
|
|
99
|
+
kind: ExampleKind;
|
|
100
|
+
/** Visibility level */
|
|
101
|
+
visibility: ExampleVisibility;
|
|
102
|
+
/** Short marketing summary (distinct from technical description) */
|
|
103
|
+
summary?: string;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* ExampleSpec - Complete specification for a ContractSpec example.
|
|
107
|
+
*
|
|
108
|
+
* Integrates with AppBlueprintSpec for app configuration and
|
|
109
|
+
* FeatureModuleSpec for feature definitions.
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* ```typescript
|
|
113
|
+
* const example: ExampleSpec = {
|
|
114
|
+
* meta: {
|
|
115
|
+
* key: 'saas-boilerplate',
|
|
116
|
+
* version: '1.0.0',
|
|
117
|
+
* title: 'SaaS Boilerplate',
|
|
118
|
+
* description: 'Multi-tenant SaaS foundation.',
|
|
119
|
+
* kind: 'template',
|
|
120
|
+
* visibility: 'public',
|
|
121
|
+
* stability: 'experimental',
|
|
122
|
+
* owners: ['@saas-team'],
|
|
123
|
+
* tags: ['saas', 'multi-tenant'],
|
|
124
|
+
* },
|
|
125
|
+
* surfaces: {
|
|
126
|
+
* templates: true,
|
|
127
|
+
* sandbox: { enabled: true, modes: ['playground', 'specs'] },
|
|
128
|
+
* studio: { enabled: true, installable: true },
|
|
129
|
+
* mcp: { enabled: true },
|
|
130
|
+
* },
|
|
131
|
+
* entrypoints: {
|
|
132
|
+
* packageName: '@contractspec/example.saas-boilerplate',
|
|
133
|
+
* feature: './saas-boilerplate.feature',
|
|
134
|
+
* },
|
|
135
|
+
* };
|
|
136
|
+
* ```
|
|
137
|
+
*/
|
|
138
|
+
interface ExampleSpec {
|
|
139
|
+
/** Example metadata (identification, ownership, categorization) */
|
|
140
|
+
meta: ExampleMeta;
|
|
141
|
+
/** Documentation references */
|
|
142
|
+
docs?: ExampleDocumentation;
|
|
143
|
+
/** Surface support configuration */
|
|
144
|
+
surfaces: ExampleSurfaces;
|
|
145
|
+
/** Package entrypoints */
|
|
146
|
+
entrypoints: ExampleEntrypoints;
|
|
147
|
+
/**
|
|
148
|
+
* Inline or referenced AppBlueprintSpec.
|
|
149
|
+
* Use SpecPointer for external reference to a registered blueprint.
|
|
150
|
+
*/
|
|
151
|
+
blueprint?: AppBlueprintSpec | SpecPointer;
|
|
152
|
+
/**
|
|
153
|
+
* Features included in this example.
|
|
154
|
+
* Can be inline FeatureModuleSpec objects or FeatureRef references.
|
|
155
|
+
*/
|
|
156
|
+
features?: (FeatureModuleSpec | FeatureRef)[];
|
|
157
|
+
}
|
|
158
|
+
/** Check if a blueprint reference is a SpecPointer (external reference) */
|
|
159
|
+
declare function isSpecPointer(ref: AppBlueprintSpec | SpecPointer | undefined): ref is SpecPointer;
|
|
160
|
+
/** Check if a feature reference is a FeatureRef (external reference) */
|
|
161
|
+
declare function isFeatureRef(ref: FeatureModuleSpec | FeatureRef): ref is FeatureRef;
|
|
162
|
+
/** Check if a value is a valid ExampleKind */
|
|
163
|
+
declare function isExampleKind(value: unknown): value is ExampleKind;
|
|
164
|
+
/** Check if a value is a valid ExampleVisibility */
|
|
165
|
+
declare function isExampleVisibility(value: unknown): value is ExampleVisibility;
|
|
166
|
+
//#endregion
|
|
167
|
+
export { ExampleDocumentation, ExampleEntrypoints, ExampleKind, ExampleKindEnum, ExampleMcpSupport, ExampleMeta, ExampleSandboxMode, ExampleSandboxModeEnum, ExampleSandboxSupport, ExampleSpec, ExampleStudioSupport, ExampleSurfaces, ExampleVisibility, ExampleVisibilityEnum, isExampleKind, isExampleVisibility, isFeatureRef, isSpecPointer };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
//#region src/examples/types.ts
|
|
2
|
+
const ExampleKindEnum = {
|
|
3
|
+
Template: "template",
|
|
4
|
+
Workflow: "workflow",
|
|
5
|
+
Integration: "integration",
|
|
6
|
+
Knowledge: "knowledge",
|
|
7
|
+
Blueprint: "blueprint",
|
|
8
|
+
UI: "ui",
|
|
9
|
+
Script: "script",
|
|
10
|
+
Library: "library"
|
|
11
|
+
};
|
|
12
|
+
const ExampleVisibilityEnum = {
|
|
13
|
+
Public: "public",
|
|
14
|
+
Internal: "internal",
|
|
15
|
+
Experimental: "experimental"
|
|
16
|
+
};
|
|
17
|
+
const ExampleSandboxModeEnum = {
|
|
18
|
+
Playground: "playground",
|
|
19
|
+
Specs: "specs",
|
|
20
|
+
Builder: "builder",
|
|
21
|
+
Markdown: "markdown",
|
|
22
|
+
Evolution: "evolution"
|
|
23
|
+
};
|
|
24
|
+
/** Check if a blueprint reference is a SpecPointer (external reference) */
|
|
25
|
+
function isSpecPointer(ref) {
|
|
26
|
+
if (!ref) return false;
|
|
27
|
+
return "key" in ref && !("meta" in ref);
|
|
28
|
+
}
|
|
29
|
+
/** Check if a feature reference is a FeatureRef (external reference) */
|
|
30
|
+
function isFeatureRef(ref) {
|
|
31
|
+
return "key" in ref && !("meta" in ref);
|
|
32
|
+
}
|
|
33
|
+
/** Check if a value is a valid ExampleKind */
|
|
34
|
+
function isExampleKind(value) {
|
|
35
|
+
return typeof value === "string" && Object.values(ExampleKindEnum).includes(value);
|
|
36
|
+
}
|
|
37
|
+
/** Check if a value is a valid ExampleVisibility */
|
|
38
|
+
function isExampleVisibility(value) {
|
|
39
|
+
return typeof value === "string" && Object.values(ExampleVisibilityEnum).includes(value);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
//#endregion
|
|
43
|
+
export { ExampleKindEnum, ExampleSandboxModeEnum, ExampleVisibilityEnum, isExampleKind, isExampleVisibility, isFeatureRef, isSpecPointer };
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { ExampleSpec } from "./types.js";
|
|
2
|
+
|
|
3
|
+
//#region src/examples/validation.d.ts
|
|
4
|
+
interface ExampleValidationError {
|
|
5
|
+
/** Example key if available */
|
|
6
|
+
exampleKey?: string;
|
|
7
|
+
/** Error message */
|
|
8
|
+
message: string;
|
|
9
|
+
/** Path within the spec where error occurred */
|
|
10
|
+
path?: string;
|
|
11
|
+
/** Error code for programmatic handling */
|
|
12
|
+
code?: string;
|
|
13
|
+
}
|
|
14
|
+
interface ExampleValidationWarning {
|
|
15
|
+
/** Example key if available */
|
|
16
|
+
exampleKey?: string;
|
|
17
|
+
/** Warning message */
|
|
18
|
+
message: string;
|
|
19
|
+
/** Path within the spec where warning applies */
|
|
20
|
+
path?: string;
|
|
21
|
+
}
|
|
22
|
+
type ValidateExamplesResult = {
|
|
23
|
+
ok: true;
|
|
24
|
+
examples: ExampleSpec[];
|
|
25
|
+
} | {
|
|
26
|
+
ok: false;
|
|
27
|
+
errors: ExampleValidationError[];
|
|
28
|
+
};
|
|
29
|
+
interface ValidateExampleResult {
|
|
30
|
+
valid: boolean;
|
|
31
|
+
errors: ExampleValidationError[];
|
|
32
|
+
warnings: ExampleValidationWarning[];
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Validate a single ExampleSpec.
|
|
36
|
+
*
|
|
37
|
+
* @param example - The example to validate
|
|
38
|
+
* @returns Validation result with errors and warnings
|
|
39
|
+
*/
|
|
40
|
+
declare function validateExample(example: unknown): ValidateExampleResult;
|
|
41
|
+
/**
|
|
42
|
+
* Validate multiple examples, checking for duplicates.
|
|
43
|
+
*
|
|
44
|
+
* @param examples - Array of examples to validate
|
|
45
|
+
* @returns Validation result with all valid examples or errors
|
|
46
|
+
*/
|
|
47
|
+
declare function validateExamples(examples: ExampleSpec[]): ValidateExamplesResult;
|
|
48
|
+
interface CrossValidationContext {
|
|
49
|
+
/** Available feature keys */
|
|
50
|
+
featureKeys?: Set<string>;
|
|
51
|
+
/** Available blueprint keys */
|
|
52
|
+
blueprintKeys?: Set<string>;
|
|
53
|
+
/** Available package names in workspace */
|
|
54
|
+
packageNames?: Set<string>;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Validate example references against external registries.
|
|
58
|
+
*
|
|
59
|
+
* @param example - Example to validate
|
|
60
|
+
* @param context - External context for cross-reference validation
|
|
61
|
+
* @returns Validation result with errors and warnings
|
|
62
|
+
*/
|
|
63
|
+
declare function validateExampleReferences(example: ExampleSpec, context: CrossValidationContext): ValidateExampleResult;
|
|
64
|
+
//#endregion
|
|
65
|
+
export { CrossValidationContext, ExampleValidationError, ExampleValidationWarning, ValidateExampleResult, ValidateExamplesResult, validateExample, validateExampleReferences, validateExamples };
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { safeParseExampleSpec } from "./schema.js";
|
|
2
|
+
|
|
3
|
+
//#region src/examples/validation.ts
|
|
4
|
+
/**
|
|
5
|
+
* Validate a single ExampleSpec.
|
|
6
|
+
*
|
|
7
|
+
* @param example - The example to validate
|
|
8
|
+
* @returns Validation result with errors and warnings
|
|
9
|
+
*/
|
|
10
|
+
function validateExample(example) {
|
|
11
|
+
const errors = [];
|
|
12
|
+
const warnings = [];
|
|
13
|
+
const parsed = safeParseExampleSpec(example);
|
|
14
|
+
if (!parsed.success) {
|
|
15
|
+
for (const issue of parsed.error.issues) errors.push({
|
|
16
|
+
exampleKey: example?.meta?.key,
|
|
17
|
+
message: issue.message,
|
|
18
|
+
path: issue.path.join("."),
|
|
19
|
+
code: issue.code
|
|
20
|
+
});
|
|
21
|
+
return {
|
|
22
|
+
valid: false,
|
|
23
|
+
errors,
|
|
24
|
+
warnings
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
const spec = parsed.data;
|
|
28
|
+
validateSemantics(spec, errors, warnings);
|
|
29
|
+
return {
|
|
30
|
+
valid: errors.length === 0,
|
|
31
|
+
errors,
|
|
32
|
+
warnings
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
function validateSemantics(spec, errors, warnings) {
|
|
36
|
+
const key = spec.meta.key;
|
|
37
|
+
if (!spec.entrypoints.packageName.startsWith("@")) warnings.push({
|
|
38
|
+
exampleKey: key,
|
|
39
|
+
message: "Package name should be scoped (e.g., @contractspec/example.name)",
|
|
40
|
+
path: "entrypoints.packageName"
|
|
41
|
+
});
|
|
42
|
+
if (spec.surfaces.studio.installable && !spec.surfaces.studio.enabled) errors.push({
|
|
43
|
+
exampleKey: key,
|
|
44
|
+
message: "Studio installable requires studio.enabled to be true",
|
|
45
|
+
path: "surfaces.studio",
|
|
46
|
+
code: "STUDIO_INSTALLABLE_REQUIRES_ENABLED"
|
|
47
|
+
});
|
|
48
|
+
if (spec.surfaces.sandbox.enabled && spec.surfaces.sandbox.modes.length === 0) warnings.push({
|
|
49
|
+
exampleKey: key,
|
|
50
|
+
message: "Sandbox is enabled but has no modes configured",
|
|
51
|
+
path: "surfaces.sandbox.modes"
|
|
52
|
+
});
|
|
53
|
+
if (spec.features && spec.features.length > 0 && !spec.entrypoints.feature) warnings.push({
|
|
54
|
+
exampleKey: key,
|
|
55
|
+
message: "Example has features but no feature entrypoint in entrypoints.feature",
|
|
56
|
+
path: "entrypoints.feature"
|
|
57
|
+
});
|
|
58
|
+
if (spec.blueprint && !spec.entrypoints.blueprint) warnings.push({
|
|
59
|
+
exampleKey: key,
|
|
60
|
+
message: "Example has blueprint but no blueprint entrypoint in entrypoints.blueprint",
|
|
61
|
+
path: "entrypoints.blueprint"
|
|
62
|
+
});
|
|
63
|
+
if (spec.meta.visibility === "public" && spec.meta.stability === "idea") warnings.push({
|
|
64
|
+
exampleKey: key,
|
|
65
|
+
message: "Public examples should not be in \"idea\" stability",
|
|
66
|
+
path: "meta.stability"
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Validate multiple examples, checking for duplicates.
|
|
71
|
+
*
|
|
72
|
+
* @param examples - Array of examples to validate
|
|
73
|
+
* @returns Validation result with all valid examples or errors
|
|
74
|
+
*/
|
|
75
|
+
function validateExamples(examples) {
|
|
76
|
+
const errors = [];
|
|
77
|
+
const seen = /* @__PURE__ */ new Set();
|
|
78
|
+
const validExamples = [];
|
|
79
|
+
for (const example of examples) {
|
|
80
|
+
if (seen.has(example.meta.key)) {
|
|
81
|
+
errors.push({
|
|
82
|
+
exampleKey: example.meta.key,
|
|
83
|
+
message: `Duplicate example key: ${example.meta.key}`,
|
|
84
|
+
code: "DUPLICATE_KEY"
|
|
85
|
+
});
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
seen.add(example.meta.key);
|
|
89
|
+
const result = validateExample(example);
|
|
90
|
+
if (!result.valid) errors.push(...result.errors);
|
|
91
|
+
else validExamples.push(example);
|
|
92
|
+
}
|
|
93
|
+
if (errors.length > 0) return {
|
|
94
|
+
ok: false,
|
|
95
|
+
errors
|
|
96
|
+
};
|
|
97
|
+
return {
|
|
98
|
+
ok: true,
|
|
99
|
+
examples: validExamples
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Validate example references against external registries.
|
|
104
|
+
*
|
|
105
|
+
* @param example - Example to validate
|
|
106
|
+
* @param context - External context for cross-reference validation
|
|
107
|
+
* @returns Validation result with errors and warnings
|
|
108
|
+
*/
|
|
109
|
+
function validateExampleReferences(example, context) {
|
|
110
|
+
const errors = [];
|
|
111
|
+
const warnings = [];
|
|
112
|
+
const key = example.meta.key;
|
|
113
|
+
if (context.packageNames && !context.packageNames.has(example.entrypoints.packageName)) warnings.push({
|
|
114
|
+
exampleKey: key,
|
|
115
|
+
message: `Package "${example.entrypoints.packageName}" not found in workspace`,
|
|
116
|
+
path: "entrypoints.packageName"
|
|
117
|
+
});
|
|
118
|
+
if (example.features && context.featureKeys) {
|
|
119
|
+
for (const feature of example.features) if ("key" in feature && !("meta" in feature)) {
|
|
120
|
+
if (!context.featureKeys.has(feature.key)) warnings.push({
|
|
121
|
+
exampleKey: key,
|
|
122
|
+
message: `Feature "${feature.key}" not found in registry`,
|
|
123
|
+
path: "features"
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
if (example.blueprint && context.blueprintKeys) {
|
|
128
|
+
if ("key" in example.blueprint && !("meta" in example.blueprint)) {
|
|
129
|
+
if (!context.blueprintKeys.has(example.blueprint.key)) warnings.push({
|
|
130
|
+
exampleKey: key,
|
|
131
|
+
message: `Blueprint "${example.blueprint.key}" not found in registry`,
|
|
132
|
+
path: "blueprint"
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return {
|
|
137
|
+
valid: errors.length === 0,
|
|
138
|
+
errors,
|
|
139
|
+
warnings
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
//#endregion
|
|
144
|
+
export { validateExample, validateExampleReferences, validateExamples };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { registerDocBlocks } from "../../docs/registry.js";
|
|
2
|
+
|
|
3
|
+
//#region src/experiments/docs/experiments.docblock.ts
|
|
4
|
+
const tech_contracts_experiments_DocBlocks = [{
|
|
5
|
+
id: "docs.tech.contracts.experiments",
|
|
6
|
+
title: "ExperimentSpec & ExperimentEvaluator",
|
|
7
|
+
summary: "Use experiments to test alternative workflows, data views, or themes with controlled allocations and measurable outcomes.",
|
|
8
|
+
kind: "reference",
|
|
9
|
+
visibility: "public",
|
|
10
|
+
route: "/docs/tech/contracts/experiments",
|
|
11
|
+
tags: [
|
|
12
|
+
"tech",
|
|
13
|
+
"contracts",
|
|
14
|
+
"experiments"
|
|
15
|
+
],
|
|
16
|
+
body: "# ExperimentSpec & ExperimentEvaluator\n\nUse experiments to test alternative workflows, data views, or themes with controlled allocations and measurable outcomes.\n\n- Types & registry: `packages/libs/contracts/src/experiments/spec.ts`\n- Runtime evaluator: `packages/libs/contracts/src/experiments/evaluator.ts`\n- CLI wizard/template: `contractspec create experiment`\n\n## Structure\n\n```ts\nexport interface ExperimentSpec {\n meta: ExperimentMeta;\n controlVariant: string;\n variants: ExperimentVariant[];\n allocation: AllocationStrategy;\n successMetrics?: SuccessMetric[];\n}\n```\n\n- `variants`: define UI/behavior overrides (data views, workflows, themes, policies)\n- `allocation`:\n - `random`: 50/50 or weighted via `weight`\n - `sticky`: deterministic hash on user/organization/session\n - `targeted`: rule-based (policy + expression + optional percentage)\n- `successMetrics`: telemetry events + aggregation (count/avg/p95) to track outcomes\n\n### Example\n\n```ts\nexport const OnboardingSplitFormExperiment: ExperimentSpec = {\n meta: {\n name: 'sigil.onboarding.split_form',\n version: '1.0.0',\n title: 'Split onboarding form',\n description: 'Compare single vs multi-step onboarding',\n domain: 'onboarding',\n owners: ['@team.onboarding'],\n tags: ['experiment'],\n stability: StabilityEnum.Experimental,\n },\n controlVariant: 'control',\n variants: [\n { id: 'control', name: 'Single-step form' },\n {\n id: 'multi_step',\n name: 'Multi-step form',\n overrides: [\n { type: 'workflow', target: 'sigil.onboarding.workflow.multi_step' },\n ],\n },\n ],\n allocation: {\n type: 'targeted',\n rules: [\n {\n variantId: 'multi_step',\n expression: \"context.attributes?.segment === 'vip'\",\n },\n ],\n fallback: 'random',\n },\n successMetrics: [\n {\n name: 'Completion rate',\n telemetryEvent: { name: 'sigil.telemetry.onboarding_completed', version: '1.0.0' },\n aggregation: 'count',\n },\n ],\n};\n```\n\n## Variant evaluation\n\n```ts\nconst evaluator = new ExperimentEvaluator({\n registry: experimentRegistry,\n policyChecker: (policyRef, context) =>\n policyEngine.decide({\n action: 'experiment_targeting',\n subject: { roles: context.flags },\n resource: { type: 'experiment', attributes: { name: context.experiment } },\n policies: [policyRef],\n }).effect === 'allow',\n});\n\nconst assignment = await evaluator.chooseVariant({\n experiment: 'sigil.onboarding.split_form',\n userId: ctx.userId,\n organizationId: ctx.organizationId,\n attributes: ctx.attributes,\n});\n\nif (assignment) {\n // Apply overrides for the chosen variant\n applyExperimentOverrides(assignment.variant);\n}\n```\n\n- `random` uses deterministic hashing (`salt` optional) for stable splits\n- `sticky` hashes a specified attribute (userId/orgId/sessionId)\n- `targeted` evaluates rules in order; each rule can reference a PolicySpec and simple JS expressions (`context` input)\n\n## Integrations\n\n- **Feature modules**: `FeatureModuleSpec.experiments` references experiments owned by a module\n- **DataViewSpec / WorkflowSpec**: `experiments?: ExperimentRef[]` indicate which experiments modify the spec\n- **Telemetry**: success metrics reference `TelemetrySpec` events to ensure compliant tracking\n- **Policy**: targeting rules call into `PolicyEngine` via the evaluator callback to respect privacy/security\n\n## CLI workflow\n\n```\ncontractspec create experiment\n```\n\n- Prompts for control/variants, allocation strategy, targeting rules, success metrics\n- Outputs a typed `ExperimentSpec` file alongside your contracts\n\n## Best practices\n\n1. Keep experiments short-lived; increment `meta.version` when changing allocation or variants.\n2. Always declare a control variant and ensure overrides are reversible.\n3. Tie success metrics to privacy-reviewed telemetry events.\n4. Use targeting rules sparingly; combine with PolicySpec to avoid exposing experiments to unauthorized users.\n5. When an experiment wins, promote the variant to the canonical spec and retire the experiment.\n\n"
|
|
17
|
+
}];
|
|
18
|
+
registerDocBlocks(tech_contracts_experiments_DocBlocks);
|
|
19
|
+
|
|
20
|
+
//#endregion
|
|
21
|
+
export { tech_contracts_experiments_DocBlocks };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { PolicyRef } from "../policy/spec.js";
|
|
2
|
+
import { ExperimentRegistry, ExperimentVariant } from "./spec.js";
|
|
3
|
+
|
|
4
|
+
//#region src/experiments/evaluator.d.ts
|
|
5
|
+
interface ExperimentContext {
|
|
6
|
+
experiment: string;
|
|
7
|
+
version?: string;
|
|
8
|
+
userId?: string | null;
|
|
9
|
+
organizationId?: string | null;
|
|
10
|
+
sessionId?: string | null;
|
|
11
|
+
attributes?: Record<string, unknown>;
|
|
12
|
+
flags?: string[];
|
|
13
|
+
}
|
|
14
|
+
interface ExperimentEvaluation {
|
|
15
|
+
variant: ExperimentVariant;
|
|
16
|
+
reason: 'control' | 'random' | 'sticky' | 'targeted';
|
|
17
|
+
}
|
|
18
|
+
interface ExperimentEvaluatorConfig {
|
|
19
|
+
registry: ExperimentRegistry;
|
|
20
|
+
policyChecker?: (policy: PolicyRef, context: ExperimentContext) => Promise<boolean> | boolean;
|
|
21
|
+
expressionEvaluator?: (expression: string, context: ExperimentContext) => boolean;
|
|
22
|
+
}
|
|
23
|
+
declare class ExperimentEvaluator {
|
|
24
|
+
private readonly registry;
|
|
25
|
+
private readonly policyChecker?;
|
|
26
|
+
private readonly expressionEvaluator?;
|
|
27
|
+
constructor(config: ExperimentEvaluatorConfig);
|
|
28
|
+
chooseVariant(context: ExperimentContext): Promise<ExperimentEvaluation | null>;
|
|
29
|
+
private pickByWeight;
|
|
30
|
+
private randomSeed;
|
|
31
|
+
private stickySeed;
|
|
32
|
+
private hashToUnitInterval;
|
|
33
|
+
private evaluateTargeting;
|
|
34
|
+
private matchesRule;
|
|
35
|
+
}
|
|
36
|
+
//#endregion
|
|
37
|
+
export { ExperimentContext, ExperimentEvaluation, ExperimentEvaluator, ExperimentEvaluatorConfig };
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
|
|
3
|
+
//#region src/experiments/evaluator.ts
|
|
4
|
+
var ExperimentEvaluator = class {
|
|
5
|
+
registry;
|
|
6
|
+
policyChecker;
|
|
7
|
+
expressionEvaluator;
|
|
8
|
+
constructor(config) {
|
|
9
|
+
this.registry = config.registry;
|
|
10
|
+
this.policyChecker = config.policyChecker;
|
|
11
|
+
this.expressionEvaluator = config.expressionEvaluator;
|
|
12
|
+
}
|
|
13
|
+
async chooseVariant(context) {
|
|
14
|
+
const experiment = this.registry.get(context.experiment, context.version);
|
|
15
|
+
if (!experiment) return null;
|
|
16
|
+
const control = experiment.variants.find((variant) => variant.id === experiment.controlVariant);
|
|
17
|
+
if (!control) throw new Error(`Experiment ${experiment.meta.key} missing control variant ${experiment.controlVariant}`);
|
|
18
|
+
switch (experiment.allocation.type) {
|
|
19
|
+
case "random": return {
|
|
20
|
+
variant: this.pickByWeight(experiment, this.randomSeed(context, experiment.allocation.salt)),
|
|
21
|
+
reason: "random"
|
|
22
|
+
};
|
|
23
|
+
case "sticky": return {
|
|
24
|
+
variant: this.pickByWeight(experiment, this.stickySeed(context, experiment.allocation.attribute, experiment.allocation.salt)),
|
|
25
|
+
reason: "sticky"
|
|
26
|
+
};
|
|
27
|
+
case "targeted": {
|
|
28
|
+
const targeted = await this.evaluateTargeting(experiment, context, experiment.allocation.rules);
|
|
29
|
+
if (targeted) return {
|
|
30
|
+
variant: targeted,
|
|
31
|
+
reason: "targeted"
|
|
32
|
+
};
|
|
33
|
+
if (experiment.allocation.fallback === "random") return {
|
|
34
|
+
variant: this.pickByWeight(experiment, this.randomSeed(context)),
|
|
35
|
+
reason: "random"
|
|
36
|
+
};
|
|
37
|
+
return {
|
|
38
|
+
variant: control,
|
|
39
|
+
reason: "control"
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
default: return {
|
|
43
|
+
variant: control,
|
|
44
|
+
reason: "control"
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
pickByWeight(experiment, seed) {
|
|
49
|
+
const variants = experiment.variants;
|
|
50
|
+
const target = seed * variants.reduce((sum, variant) => sum + (variant.weight ?? 1), 0);
|
|
51
|
+
let cumulative = 0;
|
|
52
|
+
for (const variant of variants) {
|
|
53
|
+
cumulative += variant.weight ?? 1;
|
|
54
|
+
if (target <= cumulative) return variant;
|
|
55
|
+
}
|
|
56
|
+
return variants[variants.length - 1];
|
|
57
|
+
}
|
|
58
|
+
randomSeed(context, salt = "") {
|
|
59
|
+
const base = context.sessionId ?? context.userId ?? context.organizationId ?? `${Date.now()}-${Math.random()}`;
|
|
60
|
+
return this.hashToUnitInterval(base + salt);
|
|
61
|
+
}
|
|
62
|
+
stickySeed(context, attribute, salt = "") {
|
|
63
|
+
const value = context[attribute];
|
|
64
|
+
if (!value) return this.randomSeed(context, salt);
|
|
65
|
+
return this.hashToUnitInterval(`${value}-${salt}`);
|
|
66
|
+
}
|
|
67
|
+
hashToUnitInterval(value) {
|
|
68
|
+
const hash = createHash("sha256").update(value).digest("hex").slice(0, 15);
|
|
69
|
+
return parseInt(hash, 16) % 1e6 / 1e6;
|
|
70
|
+
}
|
|
71
|
+
async evaluateTargeting(experiment, context, rules) {
|
|
72
|
+
for (const rule of rules) {
|
|
73
|
+
if (!await this.matchesRule(rule, context)) continue;
|
|
74
|
+
const variant = experiment.variants.find((v) => v.id === rule.variantId);
|
|
75
|
+
if (!variant) continue;
|
|
76
|
+
if (typeof rule.percentage === "number") {
|
|
77
|
+
if (this.randomSeed(context, `rule-${rule.variantId}`) > rule.percentage) continue;
|
|
78
|
+
}
|
|
79
|
+
return variant;
|
|
80
|
+
}
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
async matchesRule(rule, context) {
|
|
84
|
+
if (rule.policy && this.policyChecker) {
|
|
85
|
+
if (!await this.policyChecker(rule.policy, context)) return false;
|
|
86
|
+
}
|
|
87
|
+
if (rule.expression) {
|
|
88
|
+
if (this.expressionEvaluator) return Boolean(this.expressionEvaluator(rule.expression, context));
|
|
89
|
+
try {
|
|
90
|
+
const fn = new Function("context", `return (${rule.expression});`);
|
|
91
|
+
return Boolean(fn(context));
|
|
92
|
+
} catch (_error) {
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return true;
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
//#endregion
|
|
101
|
+
export { ExperimentEvaluator };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ResourceRefDescriptor } from "../resources.js";
|
|
2
|
+
import { OpKind, OperationSpec } from "../operations/operation.js";
|
|
3
|
+
import "../operations/index.js";
|
|
4
|
+
import { HandlerCtx } from "../types.js";
|
|
5
|
+
import { AnySchemaModel } from "@contractspec/lib.schema";
|
|
6
|
+
|
|
7
|
+
//#region src/experiments/spec-resolver.d.ts
|
|
8
|
+
type RuntimeContract = OperationSpec<AnySchemaModel, AnySchemaModel | ResourceRefDescriptor<boolean>>;
|
|
9
|
+
interface SpecVariantResolver {
|
|
10
|
+
resolve(operation: {
|
|
11
|
+
name: string;
|
|
12
|
+
version: string;
|
|
13
|
+
kind: OpKind;
|
|
14
|
+
}, ctx: HandlerCtx): Promise<RuntimeContract | undefined> | RuntimeContract | undefined;
|
|
15
|
+
}
|
|
16
|
+
//#endregion
|
|
17
|
+
export { RuntimeContract, SpecVariantResolver };
|
|
File without changes
|