@contractspec/lib.contracts 1.44.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/LICENSE +21 -0
- package/README.md +109 -0
- package/dist/_virtual/rolldown_runtime.js +37 -0
- package/dist/app-config/app-config.feature.d.ts +12 -0
- package/dist/app-config/app-config.feature.js +54 -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 +9 -0
- package/dist/app-config/index.js +8 -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 +173 -0
- package/dist/app-config/spec.js +36 -0
- package/dist/app-config/validation.d.ts +49 -0
- package/dist/app-config/validation.js +538 -0
- package/dist/capabilities/capabilities.d.ts +48 -0
- package/dist/capabilities/capabilities.js +50 -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 +298 -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 +4 -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 +51 -0
- package/dist/data-views/registry.js +82 -0
- package/dist/data-views/runtime.d.ts +28 -0
- package/dist/data-views/runtime.js +39 -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 +29 -0
- package/dist/docs/meta.docs.d.ts +6 -0
- package/dist/docs/meta.docs.js +29 -0
- package/dist/docs/presentations.d.ts +33 -0
- package/dist/docs/presentations.js +64 -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/contracts/README.docblock.d.ts +6 -0
- package/dist/docs/tech/contracts/README.docblock.js +21 -0
- package/dist/docs/tech/contracts/create-subscription.docblock.d.ts +6 -0
- package/dist/docs/tech/contracts/create-subscription.docblock.js +21 -0
- package/dist/docs/tech/contracts/graphql-typed-outputs.docblock.d.ts +6 -0
- package/dist/docs/tech/contracts/graphql-typed-outputs.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 +21 -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 +46 -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/templates/runtime.docblock.d.ts +6 -0
- package/dist/docs/tech/templates/runtime.docblock.js +21 -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/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 +82 -0
- package/dist/experiments/spec.js +33 -0
- package/dist/features/index.d.ts +5 -0
- package/dist/features/index.js +5 -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 +146 -0
- package/dist/forms/index.d.ts +2 -0
- package/dist/forms/index.js +3 -0
- package/dist/index.d.ts +147 -0
- package/dist/index.js +121 -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.feature.d.ts +12 -0
- package/dist/integrations/integrations.feature.js +60 -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.feature.d.ts +12 -0
- package/dist/integrations/openbanking/openbanking.feature.js +69 -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 +7 -0
- package/dist/integrations/providers/elevenlabs.js +55 -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 +7 -0
- package/dist/integrations/providers/gcs-storage.js +78 -0
- package/dist/integrations/providers/gmail.d.ts +7 -0
- package/dist/integrations/providers/gmail.js +90 -0
- package/dist/integrations/providers/google-calendar.d.ts +7 -0
- package/dist/integrations/providers/google-calendar.js +69 -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 +145 -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 +7 -0
- package/dist/integrations/providers/mistral.js +71 -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 +7 -0
- package/dist/integrations/providers/postmark.js +71 -0
- package/dist/integrations/providers/powens.d.ts +7 -0
- package/dist/integrations/providers/powens.js +119 -0
- package/dist/integrations/providers/qdrant.d.ts +7 -0
- package/dist/integrations/providers/qdrant.js +76 -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 +7 -0
- package/dist/integrations/providers/stripe.js +86 -0
- package/dist/integrations/providers/twilio-sms.d.ts +7 -0
- package/dist/integrations/providers/twilio-sms.js +64 -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 +75 -0
- package/dist/integrations/spec.js +39 -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 +27 -0
- package/dist/jsonschema.js +32 -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.feature.d.ts +12 -0
- package/dist/knowledge/knowledge.feature.js +61 -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 +48 -0
- package/dist/knowledge/spec.js +39 -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 +33 -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 +75 -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 +103 -0
- package/dist/operations/registry.js +252 -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 +223 -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 +60 -0
- package/dist/prompt.js +10 -0
- package/dist/promptRegistry.d.ts +15 -0
- package/dist/promptRegistry.js +34 -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 +31 -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 +63 -0
- package/dist/server/mcp/registerPrompts.d.ts +8 -0
- package/dist/server/mcp/registerPrompts.js +37 -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 +69 -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 +81 -0
- package/dist/tests/spec.js +33 -0
- package/dist/themes.d.ts +53 -0
- package/dist/themes.js +39 -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/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 +10 -0
- package/dist/workflow/index.js +9 -0
- package/dist/workflow/overview.docblock.d.ts +6 -0
- package/dist/workflow/overview.docblock.js +21 -0
- package/dist/workflow/runner.d.ts +75 -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 +106 -0
- package/dist/workflow/spec.js +55 -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 +862 -0
- package/dist/workspace-config/contractsrc-schema.js +281 -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 +598 -0
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { OwnerShipMeta } from "../ownership.js";
|
|
2
|
+
import { PolicyRef } from "../policy/spec.js";
|
|
3
|
+
import { ResourceRefDescriptor } from "../resources.js";
|
|
4
|
+
import { EventSpec } from "../events.js";
|
|
5
|
+
import { TestSpecRef } from "../tests/spec.js";
|
|
6
|
+
import { AnySchemaModel } from "@contractspec/lib.schema";
|
|
7
|
+
|
|
8
|
+
//#region src/operations/operation.d.ts
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Distinguishes between state-changing operations (command) and read-only operations (query).
|
|
12
|
+
*/
|
|
13
|
+
type OpKind = 'command' | 'query';
|
|
14
|
+
/**
|
|
15
|
+
* Type of implementation artifact.
|
|
16
|
+
*/
|
|
17
|
+
type ImplementationType = 'handler' | 'component' | 'form' | 'test' | 'service' | 'hook' | 'other';
|
|
18
|
+
/**
|
|
19
|
+
* Reference to an implementation file for a spec.
|
|
20
|
+
* Used for explicit implementation mapping.
|
|
21
|
+
*/
|
|
22
|
+
interface ImplementationRef {
|
|
23
|
+
/** Path to implementation file (relative to workspace root) */
|
|
24
|
+
path: string;
|
|
25
|
+
/** Type of implementation artifact */
|
|
26
|
+
type: ImplementationType;
|
|
27
|
+
/** Optional human-readable description */
|
|
28
|
+
description?: string;
|
|
29
|
+
}
|
|
30
|
+
interface EmitDeclRef {
|
|
31
|
+
ref: EventSpec<AnySchemaModel>['meta'];
|
|
32
|
+
when: string;
|
|
33
|
+
}
|
|
34
|
+
interface EmitDeclInline {
|
|
35
|
+
key: string;
|
|
36
|
+
version: number;
|
|
37
|
+
when: string;
|
|
38
|
+
payload: AnySchemaModel;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Declaration of an event that an operation may emit.
|
|
42
|
+
* Can be a reference to an `EventSpec` or an inline definition.
|
|
43
|
+
*/
|
|
44
|
+
type EmitDecl = EmitDeclRef | EmitDeclInline;
|
|
45
|
+
declare const isEmitDeclRef: (e: EmitDecl) => e is EmitDeclRef;
|
|
46
|
+
interface TelemetryTrigger {
|
|
47
|
+
event: {
|
|
48
|
+
key: string;
|
|
49
|
+
version?: number;
|
|
50
|
+
};
|
|
51
|
+
properties?: (args: {
|
|
52
|
+
input: unknown;
|
|
53
|
+
output?: unknown;
|
|
54
|
+
error?: unknown;
|
|
55
|
+
}) => Record<string, unknown>;
|
|
56
|
+
}
|
|
57
|
+
interface OperationSpecMeta extends OwnerShipMeta {
|
|
58
|
+
kind: OpKind;
|
|
59
|
+
/** Business goal: why this exists */
|
|
60
|
+
goal: string;
|
|
61
|
+
/** Background, constraints, scope edges (feeds docs & LLM context) */
|
|
62
|
+
context: string;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* The core specification interface for any operation (Command or Query).
|
|
66
|
+
*
|
|
67
|
+
* @template Input - The Zod-backed schema model for the input payload.
|
|
68
|
+
* @template Output - The Zod-backed schema model for the output payload, or a resource reference.
|
|
69
|
+
* @template Events - Tuple of events that this operation may emit.
|
|
70
|
+
*/
|
|
71
|
+
interface OperationSpec<Input extends AnySchemaModel, Output extends AnySchemaModel | ResourceRefDescriptor<boolean>, Events extends readonly EmitDecl[] | undefined = readonly EmitDecl[] | undefined> {
|
|
72
|
+
meta: OperationSpecMeta;
|
|
73
|
+
io: {
|
|
74
|
+
/** Zod schema for input body payload */
|
|
75
|
+
input: Input | null;
|
|
76
|
+
/** Zod schema for URL path parameters */
|
|
77
|
+
params?: AnySchemaModel;
|
|
78
|
+
/** Zod schema for query string parameters */
|
|
79
|
+
query?: AnySchemaModel;
|
|
80
|
+
/** Zod schema for HTTP headers */
|
|
81
|
+
headers?: AnySchemaModel;
|
|
82
|
+
/** Zod schema for output payload */
|
|
83
|
+
output: Output;
|
|
84
|
+
/** Named, typed errors this op may throw (optional) */
|
|
85
|
+
errors?: Record<string, {
|
|
86
|
+
description: string;
|
|
87
|
+
http?: number;
|
|
88
|
+
gqlCode?: string;
|
|
89
|
+
when: string;
|
|
90
|
+
}>;
|
|
91
|
+
};
|
|
92
|
+
policy: {
|
|
93
|
+
/** Minimal auth category allowed to call this op */
|
|
94
|
+
auth: 'anonymous' | 'user' | 'admin';
|
|
95
|
+
/** Idempotency hint. Queries default true; commands default false. */
|
|
96
|
+
idempotent?: boolean;
|
|
97
|
+
/** Soft rate limit suggestion; adapter enforces via limiter */
|
|
98
|
+
rateLimit?: {
|
|
99
|
+
rpm: number;
|
|
100
|
+
key: 'user' | 'org' | 'global';
|
|
101
|
+
};
|
|
102
|
+
/** Feature flags that must be ON for this op to run */
|
|
103
|
+
flags?: string[];
|
|
104
|
+
/** Whether a human must approve before action (e.g., risky commands) */
|
|
105
|
+
escalate?: 'human_review' | null;
|
|
106
|
+
/** JSONPath-like pointers to redact from logs/prompts */
|
|
107
|
+
pii?: string[];
|
|
108
|
+
/** Referenced policy specs governing access */
|
|
109
|
+
policies?: PolicyRef[];
|
|
110
|
+
/** Field-level overrides referencing policy specs */
|
|
111
|
+
fieldPolicies?: {
|
|
112
|
+
field: string;
|
|
113
|
+
actions: ('read' | 'write')[];
|
|
114
|
+
policy?: PolicyRef;
|
|
115
|
+
}[];
|
|
116
|
+
};
|
|
117
|
+
sideEffects?: {
|
|
118
|
+
/** Declared events this op may emit; runtime will guard against others */
|
|
119
|
+
emits?: Events;
|
|
120
|
+
/** Analytics intents (names); the service decides the sink */
|
|
121
|
+
analytics?: string[];
|
|
122
|
+
/** Audit intents (labels); the service decides storage */
|
|
123
|
+
audit?: string[];
|
|
124
|
+
};
|
|
125
|
+
telemetry?: {
|
|
126
|
+
success?: TelemetryTrigger;
|
|
127
|
+
failure?: TelemetryTrigger;
|
|
128
|
+
};
|
|
129
|
+
tests?: TestSpecRef[];
|
|
130
|
+
transport?: {
|
|
131
|
+
rest?: {
|
|
132
|
+
/** Override HTTP method (default: POST for commands, GET for queries) */
|
|
133
|
+
method?: 'GET' | 'POST';
|
|
134
|
+
/** Override path (default derived from meta.name/version) */
|
|
135
|
+
path?: string;
|
|
136
|
+
};
|
|
137
|
+
gql?: {
|
|
138
|
+
/** Override field name (default: dots→underscores + _vN) */
|
|
139
|
+
field?: string;
|
|
140
|
+
returns?: string;
|
|
141
|
+
};
|
|
142
|
+
mcp?: {
|
|
143
|
+
/** Override tool identifier (default: "<name>.v<version>") */
|
|
144
|
+
toolName?: string;
|
|
145
|
+
};
|
|
146
|
+
};
|
|
147
|
+
acceptance?: {
|
|
148
|
+
/** Gherkin-lite scenarios for docs & auto tests */
|
|
149
|
+
scenarios?: {
|
|
150
|
+
key: string;
|
|
151
|
+
given: string[];
|
|
152
|
+
when: string[];
|
|
153
|
+
then: string[];
|
|
154
|
+
}[];
|
|
155
|
+
/** Request/response examples (used for docs & snapshot tests) */
|
|
156
|
+
examples?: {
|
|
157
|
+
key: string;
|
|
158
|
+
input: unknown;
|
|
159
|
+
output: unknown;
|
|
160
|
+
}[];
|
|
161
|
+
};
|
|
162
|
+
/**
|
|
163
|
+
* Explicit implementation file mappings.
|
|
164
|
+
* Used for tracking and verifying that this spec is correctly implemented.
|
|
165
|
+
*/
|
|
166
|
+
implementations?: ImplementationRef[];
|
|
167
|
+
}
|
|
168
|
+
type AnyOperationSpec = OperationSpec<AnySchemaModel, AnySchemaModel | ResourceRefDescriptor<boolean>>;
|
|
169
|
+
/**
|
|
170
|
+
* Helper to define a Command (write operation).
|
|
171
|
+
* Sets `kind: 'command'` and defaults `idempotent: false`.
|
|
172
|
+
*/
|
|
173
|
+
declare const defineCommand: <I extends AnySchemaModel, O extends AnySchemaModel | ResourceRefDescriptor<boolean>, E extends readonly EmitDecl[] | undefined = undefined>(spec: Omit<OperationSpec<I, O, E>, "meta" | "policy"> & {
|
|
174
|
+
meta: Omit<OperationSpec<I, O, E>["meta"], "kind">;
|
|
175
|
+
policy: Omit<OperationSpec<I, O, E>["policy"], "idempotent">;
|
|
176
|
+
}) => OperationSpec<I, O, E>;
|
|
177
|
+
/**
|
|
178
|
+
* Helper to define a Query (read-only operation).
|
|
179
|
+
* Sets `kind: 'query'` and forces `idempotent: true`.
|
|
180
|
+
*/
|
|
181
|
+
declare const defineQuery: <I extends AnySchemaModel, O extends AnySchemaModel | ResourceRefDescriptor<boolean>, E extends readonly EmitDecl[] | undefined = undefined>(spec: Omit<OperationSpec<I, O, E>, "meta" | "policy"> & {
|
|
182
|
+
meta: Omit<OperationSpec<I, O, E>["meta"], "kind">;
|
|
183
|
+
policy: Omit<OperationSpec<I, O, E>["policy"], "idempotent">;
|
|
184
|
+
}) => OperationSpec<I, O, E>;
|
|
185
|
+
//#endregion
|
|
186
|
+
export { AnyOperationSpec, EmitDecl, EmitDeclInline, EmitDeclRef, ImplementationRef, ImplementationType, OpKind, OperationSpec, OperationSpecMeta, TelemetryTrigger, defineCommand, defineQuery, isEmitDeclRef };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
//#region src/operations/operation.ts
|
|
2
|
+
const isEmitDeclRef = (e) => "ref" in e;
|
|
3
|
+
/**
|
|
4
|
+
* Helper to define a Command (write operation).
|
|
5
|
+
* Sets `kind: 'command'` and defaults `idempotent: false`.
|
|
6
|
+
*/
|
|
7
|
+
const defineCommand = (spec) => ({
|
|
8
|
+
...spec,
|
|
9
|
+
meta: {
|
|
10
|
+
...spec.meta,
|
|
11
|
+
kind: "command"
|
|
12
|
+
},
|
|
13
|
+
policy: {
|
|
14
|
+
...spec.policy,
|
|
15
|
+
idempotent: spec.policy?.["policy"]?.idempotent ?? false
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
/**
|
|
19
|
+
* Helper to define a Query (read-only operation).
|
|
20
|
+
* Sets `kind: 'query'` and forces `idempotent: true`.
|
|
21
|
+
*/
|
|
22
|
+
const defineQuery = (spec) => ({
|
|
23
|
+
...spec,
|
|
24
|
+
meta: {
|
|
25
|
+
...spec.meta,
|
|
26
|
+
kind: "query"
|
|
27
|
+
},
|
|
28
|
+
policy: {
|
|
29
|
+
...spec.policy,
|
|
30
|
+
idempotent: true
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
//#endregion
|
|
35
|
+
export { defineCommand, defineQuery, isEmitDeclRef };
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { GroupKeyFn, RegistryFilter } from "../registry-utils.js";
|
|
2
|
+
import { ResourceRefDescriptor } from "../resources.js";
|
|
3
|
+
import { HandlerCtx } from "../types.js";
|
|
4
|
+
import { AnyOperationSpec, OperationSpec } from "./operation.js";
|
|
5
|
+
import { HandlerForOperationSpec } from "../install.js";
|
|
6
|
+
import { AnySchemaModel } from "@contractspec/lib.schema";
|
|
7
|
+
|
|
8
|
+
//#region src/operations/registry.d.ts
|
|
9
|
+
type OperationKey = `${string}.v${number}`;
|
|
10
|
+
declare function opKey(key: string, version: number): OperationKey;
|
|
11
|
+
type AnyOperationHandler = (args: unknown, ctx: HandlerCtx) => Promise<unknown>;
|
|
12
|
+
/**
|
|
13
|
+
* In-memory registry for ContractSpecs and their bound handlers.
|
|
14
|
+
* Provides validation, policy enforcement, and guarded event emission at execute time.
|
|
15
|
+
*/
|
|
16
|
+
declare class OperationSpecRegistry {
|
|
17
|
+
private specs;
|
|
18
|
+
private handlers;
|
|
19
|
+
/**
|
|
20
|
+
* Registers a OperationSpec definition.
|
|
21
|
+
*
|
|
22
|
+
* @param spec - The contract specification to register.
|
|
23
|
+
* @returns The registry instance for chaining.
|
|
24
|
+
* @throws If a spec with the same name and version is already registered.
|
|
25
|
+
*/
|
|
26
|
+
register<I extends AnySchemaModel, O extends AnySchemaModel | ResourceRefDescriptor<boolean>>(spec: OperationSpec<I, O>): this;
|
|
27
|
+
/**
|
|
28
|
+
* Binds a runtime handler implementation to a previously registered spec.
|
|
29
|
+
*
|
|
30
|
+
* @param spec - The spec to bind to.
|
|
31
|
+
* @param handler - The async function implementing the business logic.
|
|
32
|
+
* @returns The registry instance for chaining.
|
|
33
|
+
* @throws If the spec is not found or a handler is already bound.
|
|
34
|
+
*/
|
|
35
|
+
bind<I extends AnySchemaModel, O extends AnySchemaModel | ResourceRefDescriptor<boolean>>(spec: OperationSpec<I, O>, handler: HandlerForOperationSpec<OperationSpec<I, O>>): this;
|
|
36
|
+
/**
|
|
37
|
+
* Retrieves a registered spec by name and version.
|
|
38
|
+
* If version is omitted, returns the highest version found.
|
|
39
|
+
*
|
|
40
|
+
* @param name - Operation name.
|
|
41
|
+
* @param version - (Optional) Specific version.
|
|
42
|
+
*/
|
|
43
|
+
getSpec(key: string, version?: number): AnyOperationSpec | undefined;
|
|
44
|
+
/**
|
|
45
|
+
* Retrieves the bound handler for a spec.
|
|
46
|
+
*/
|
|
47
|
+
getHandler(key: string, version?: number): AnyOperationHandler | undefined;
|
|
48
|
+
/** Iterate all registered specs. */
|
|
49
|
+
listSpecs(): AnyOperationSpec[];
|
|
50
|
+
/** Iterate all bound operations (spec+handler). */
|
|
51
|
+
listBound(): {
|
|
52
|
+
spec: AnyOperationSpec;
|
|
53
|
+
handler: AnyOperationHandler;
|
|
54
|
+
}[];
|
|
55
|
+
/**
|
|
56
|
+
* Filter specs by criteria.
|
|
57
|
+
*/
|
|
58
|
+
filter(criteria: RegistryFilter): AnyOperationSpec[];
|
|
59
|
+
/**
|
|
60
|
+
* List specs with specific tag.
|
|
61
|
+
*/
|
|
62
|
+
listByTag(tag: string): AnyOperationSpec[];
|
|
63
|
+
/**
|
|
64
|
+
* List specs by owner.
|
|
65
|
+
*/
|
|
66
|
+
listByOwner(owner: string): AnyOperationSpec[];
|
|
67
|
+
/**
|
|
68
|
+
* Group specs by key function.
|
|
69
|
+
*/
|
|
70
|
+
groupBy(keyFn: GroupKeyFn<AnyOperationSpec>): Map<string, AnyOperationSpec[]>;
|
|
71
|
+
/**
|
|
72
|
+
* Group by domain (first segment of name).
|
|
73
|
+
*/
|
|
74
|
+
groupByDomain(): Map<string, AnyOperationSpec[]>;
|
|
75
|
+
/**
|
|
76
|
+
* Group by tag.
|
|
77
|
+
*/
|
|
78
|
+
groupByTag(): Map<string, AnyOperationSpec[]>;
|
|
79
|
+
/**
|
|
80
|
+
* Get unique tags from all specs.
|
|
81
|
+
*/
|
|
82
|
+
getUniqueTags(): string[];
|
|
83
|
+
/**
|
|
84
|
+
* Get unique owners from all specs.
|
|
85
|
+
*/
|
|
86
|
+
getUniqueOwners(): string[];
|
|
87
|
+
/**
|
|
88
|
+
* Execute an operation by name/version with full runtime protections:
|
|
89
|
+
* 1. Validates input against Zod schema.
|
|
90
|
+
* 2. Enforces policy (Auth, RBAC, Rate Limits) via PDP.
|
|
91
|
+
* 3. Guards event emission to ensure only declared events are sent.
|
|
92
|
+
* 4. Validates output against Zod schema (if applicable).
|
|
93
|
+
* 5. Tracks telemetry (success/failure).
|
|
94
|
+
*
|
|
95
|
+
* @param key - Operation key.
|
|
96
|
+
* @param version - Operation version (optional, defaults to latest).
|
|
97
|
+
* @param rawInput - The raw input payload (e.g. from JSON body).
|
|
98
|
+
* @param ctx - The runtime context (actor, tenant, etc.).
|
|
99
|
+
*/
|
|
100
|
+
execute(key: string, version: number | undefined, rawInput: unknown, ctx: HandlerCtx): Promise<unknown>;
|
|
101
|
+
}
|
|
102
|
+
//#endregion
|
|
103
|
+
export { OperationKey, OperationSpecRegistry, opKey };
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
import { GroupingStrategies, filterBy, getUniqueOwners, getUniqueTags, groupBy, init_registry_utils } from "../registry-utils.js";
|
|
2
|
+
import { eventKey } from "../events.js";
|
|
3
|
+
import { isEmitDeclRef } from "./operation.js";
|
|
4
|
+
|
|
5
|
+
//#region src/operations/registry.ts
|
|
6
|
+
init_registry_utils();
|
|
7
|
+
function opKey(key, version) {
|
|
8
|
+
return `${key}.v${version}`;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* In-memory registry for ContractSpecs and their bound handlers.
|
|
12
|
+
* Provides validation, policy enforcement, and guarded event emission at execute time.
|
|
13
|
+
*/
|
|
14
|
+
var OperationSpecRegistry = class {
|
|
15
|
+
specs = /* @__PURE__ */ new Map();
|
|
16
|
+
handlers = /* @__PURE__ */ new Map();
|
|
17
|
+
/**
|
|
18
|
+
* Registers a OperationSpec definition.
|
|
19
|
+
*
|
|
20
|
+
* @param spec - The contract specification to register.
|
|
21
|
+
* @returns The registry instance for chaining.
|
|
22
|
+
* @throws If a spec with the same name and version is already registered.
|
|
23
|
+
*/
|
|
24
|
+
register(spec) {
|
|
25
|
+
const key = opKey(spec.meta.key, spec.meta.version);
|
|
26
|
+
if (this.specs.has(key)) throw new Error(`Duplicate spec ${key}`);
|
|
27
|
+
this.specs.set(key, spec);
|
|
28
|
+
return this;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Binds a runtime handler implementation to a previously registered spec.
|
|
32
|
+
*
|
|
33
|
+
* @param spec - The spec to bind to.
|
|
34
|
+
* @param handler - The async function implementing the business logic.
|
|
35
|
+
* @returns The registry instance for chaining.
|
|
36
|
+
* @throws If the spec is not found or a handler is already bound.
|
|
37
|
+
*/
|
|
38
|
+
bind(spec, handler) {
|
|
39
|
+
const key = opKey(spec.meta.key, spec.meta.version);
|
|
40
|
+
if (!this.specs.has(key)) throw new Error(`Cannot bind; spec not found: ${key}`);
|
|
41
|
+
if (this.handlers.has(key)) throw new Error(`Handler already bound for ${key}`);
|
|
42
|
+
this.handlers.set(key, handler);
|
|
43
|
+
return this;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Retrieves a registered spec by name and version.
|
|
47
|
+
* If version is omitted, returns the highest version found.
|
|
48
|
+
*
|
|
49
|
+
* @param name - Operation name.
|
|
50
|
+
* @param version - (Optional) Specific version.
|
|
51
|
+
*/
|
|
52
|
+
getSpec(key, version) {
|
|
53
|
+
if (version != null) return this.specs.get(opKey(key, version));
|
|
54
|
+
let found;
|
|
55
|
+
let maxV = -Infinity;
|
|
56
|
+
for (const [k, s] of this.specs.entries()) {
|
|
57
|
+
if (!k.startsWith(`${key}.v`)) continue;
|
|
58
|
+
if (s.meta.version > maxV) {
|
|
59
|
+
maxV = s.meta.version;
|
|
60
|
+
found = s;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return found;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Retrieves the bound handler for a spec.
|
|
67
|
+
*/
|
|
68
|
+
getHandler(key, version) {
|
|
69
|
+
const spec = this.getSpec(key, version);
|
|
70
|
+
if (!spec) return void 0;
|
|
71
|
+
return this.handlers.get(opKey(spec.meta.key, spec.meta.version));
|
|
72
|
+
}
|
|
73
|
+
/** Iterate all registered specs. */
|
|
74
|
+
listSpecs() {
|
|
75
|
+
return [...this.specs.values()];
|
|
76
|
+
}
|
|
77
|
+
/** Iterate all bound operations (spec+handler). */
|
|
78
|
+
listBound() {
|
|
79
|
+
const out = [];
|
|
80
|
+
for (const [k, spec] of this.specs.entries()) {
|
|
81
|
+
const h = this.handlers.get(k);
|
|
82
|
+
if (h) out.push({
|
|
83
|
+
spec,
|
|
84
|
+
handler: h
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
return out;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Filter specs by criteria.
|
|
91
|
+
*/
|
|
92
|
+
filter(criteria) {
|
|
93
|
+
return filterBy(this.listSpecs(), criteria);
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* List specs with specific tag.
|
|
97
|
+
*/
|
|
98
|
+
listByTag(tag) {
|
|
99
|
+
return this.listSpecs().filter((s) => s.meta.tags?.includes(tag));
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* List specs by owner.
|
|
103
|
+
*/
|
|
104
|
+
listByOwner(owner) {
|
|
105
|
+
return this.listSpecs().filter((s) => s.meta.owners?.includes(owner));
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Group specs by key function.
|
|
109
|
+
*/
|
|
110
|
+
groupBy(keyFn) {
|
|
111
|
+
return groupBy(this.listSpecs(), keyFn);
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Group by domain (first segment of name).
|
|
115
|
+
*/
|
|
116
|
+
groupByDomain() {
|
|
117
|
+
return this.groupBy(GroupingStrategies.byDomain);
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Group by tag.
|
|
121
|
+
*/
|
|
122
|
+
groupByTag() {
|
|
123
|
+
return this.groupBy(GroupingStrategies.byTag);
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Get unique tags from all specs.
|
|
127
|
+
*/
|
|
128
|
+
getUniqueTags() {
|
|
129
|
+
return getUniqueTags(this.listSpecs());
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Get unique owners from all specs.
|
|
133
|
+
*/
|
|
134
|
+
getUniqueOwners() {
|
|
135
|
+
return getUniqueOwners(this.listSpecs());
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Execute an operation by name/version with full runtime protections:
|
|
139
|
+
* 1. Validates input against Zod schema.
|
|
140
|
+
* 2. Enforces policy (Auth, RBAC, Rate Limits) via PDP.
|
|
141
|
+
* 3. Guards event emission to ensure only declared events are sent.
|
|
142
|
+
* 4. Validates output against Zod schema (if applicable).
|
|
143
|
+
* 5. Tracks telemetry (success/failure).
|
|
144
|
+
*
|
|
145
|
+
* @param key - Operation key.
|
|
146
|
+
* @param version - Operation version (optional, defaults to latest).
|
|
147
|
+
* @param rawInput - The raw input payload (e.g. from JSON body).
|
|
148
|
+
* @param ctx - The runtime context (actor, tenant, etc.).
|
|
149
|
+
*/
|
|
150
|
+
async execute(key, version, rawInput, ctx) {
|
|
151
|
+
const baseSpec = this.getSpec(key, version);
|
|
152
|
+
if (!baseSpec) throw new Error(`Spec not found for ${key}${version ? `.v${version}` : ""}`);
|
|
153
|
+
const spec = await ctx.specVariantResolver?.resolve({
|
|
154
|
+
name: baseSpec.meta.key,
|
|
155
|
+
version: baseSpec.meta.version,
|
|
156
|
+
kind: baseSpec.meta.kind
|
|
157
|
+
}, ctx) ?? baseSpec;
|
|
158
|
+
let handlerKey = opKey(spec.meta.key, spec.meta.version);
|
|
159
|
+
let handler = this.handlers.get(handlerKey);
|
|
160
|
+
if (!handler) {
|
|
161
|
+
const fallbackKey = opKey(baseSpec.meta.key, baseSpec.meta.version);
|
|
162
|
+
handler = this.handlers.get(fallbackKey);
|
|
163
|
+
handlerKey = fallbackKey;
|
|
164
|
+
}
|
|
165
|
+
if (!handler) throw new Error(`No handler bound for ${handlerKey}`);
|
|
166
|
+
const parsedInput = spec.io.input?.getZod().parse(rawInput);
|
|
167
|
+
if (ctx.decide) {
|
|
168
|
+
const [service, command] = spec.meta.key.split(".");
|
|
169
|
+
if (!service || !command) throw new Error(`Invalid spec name: ${spec.meta.key}`);
|
|
170
|
+
const decision = await ctx.decide({
|
|
171
|
+
service,
|
|
172
|
+
command,
|
|
173
|
+
version: spec.meta.version,
|
|
174
|
+
actor: ctx.actor ?? "anonymous",
|
|
175
|
+
channel: ctx.channel,
|
|
176
|
+
roles: ctx.roles,
|
|
177
|
+
organizationId: ctx.organizationId,
|
|
178
|
+
userId: ctx.userId,
|
|
179
|
+
flags: []
|
|
180
|
+
});
|
|
181
|
+
if (decision.effect === "deny") throw new Error(`PolicyDenied: ${spec.meta.key}.v${spec.meta.version}`);
|
|
182
|
+
if (decision.rateLimit && ctx.rateLimit) {
|
|
183
|
+
const key$1 = decision.rateLimit.key ?? "default";
|
|
184
|
+
const rpm = decision.rateLimit.rpm ?? 60;
|
|
185
|
+
await ctx.rateLimit(key$1, 1, rpm);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
const allowedEvents = /* @__PURE__ */ new Map();
|
|
189
|
+
if (spec.sideEffects?.emits) for (const e of spec.sideEffects.emits) if (isEmitDeclRef(e)) {
|
|
190
|
+
const eventSpec = ctx.eventSpecResolver?.get(e.ref.key, e.ref.version);
|
|
191
|
+
if (eventSpec) allowedEvents.set(`${e.ref.key}.v${e.ref.version}`, eventSpec.payload);
|
|
192
|
+
} else allowedEvents.set(`${e.key}.v${e.version}`, e.payload);
|
|
193
|
+
const emitGuard = async (eventName, eventVersion, payload) => {
|
|
194
|
+
const key2 = eventKey(eventName, eventVersion);
|
|
195
|
+
const schema = allowedEvents.get(key2);
|
|
196
|
+
if (!schema) throw new Error(`UndeclaredEvent: ${key2} not allowed by ${opKey(spec.meta.key, spec.meta.version)}`);
|
|
197
|
+
const parsed = schema.getZod().parse(payload);
|
|
198
|
+
await ctx.eventPublisher?.({
|
|
199
|
+
key: eventName,
|
|
200
|
+
version: eventVersion,
|
|
201
|
+
payload: parsed,
|
|
202
|
+
traceId: ctx.traceId
|
|
203
|
+
});
|
|
204
|
+
};
|
|
205
|
+
if (ctx.appConfig) {
|
|
206
|
+
if (!ctx.branding) ctx.branding = ctx.appConfig.branding;
|
|
207
|
+
if (!ctx.translation) ctx.translation = { config: ctx.appConfig.translation };
|
|
208
|
+
else if (!ctx.translation.config) ctx.translation = {
|
|
209
|
+
...ctx.translation,
|
|
210
|
+
config: ctx.appConfig.translation
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
const telemetryContext = ctx.telemetry;
|
|
214
|
+
const trackTelemetry = async (trigger, details) => {
|
|
215
|
+
if (!telemetryContext || !trigger?.event) return;
|
|
216
|
+
try {
|
|
217
|
+
const props = trigger.properties?.(details) ?? {};
|
|
218
|
+
await telemetryContext.track(trigger.event.key, trigger.event.version ?? 1, props, {
|
|
219
|
+
tenantId: ctx.organizationId ?? void 0,
|
|
220
|
+
organizationId: ctx.organizationId,
|
|
221
|
+
userId: ctx.userId,
|
|
222
|
+
actor: ctx.actor,
|
|
223
|
+
channel: ctx.channel,
|
|
224
|
+
metadata: ctx.traceId ? { traceId: ctx.traceId } : void 0
|
|
225
|
+
});
|
|
226
|
+
} catch (_error) {}
|
|
227
|
+
};
|
|
228
|
+
let result;
|
|
229
|
+
try {
|
|
230
|
+
result = await handler(parsedInput, {
|
|
231
|
+
...ctx,
|
|
232
|
+
__emitGuard__: emitGuard
|
|
233
|
+
});
|
|
234
|
+
} catch (error) {
|
|
235
|
+
if (spec.telemetry?.failure) await trackTelemetry(spec.telemetry.failure, {
|
|
236
|
+
input: parsedInput ?? rawInput,
|
|
237
|
+
error
|
|
238
|
+
});
|
|
239
|
+
throw error;
|
|
240
|
+
}
|
|
241
|
+
if (spec.telemetry?.success) await trackTelemetry(spec.telemetry.success, {
|
|
242
|
+
input: parsedInput ?? rawInput,
|
|
243
|
+
output: result
|
|
244
|
+
});
|
|
245
|
+
const outputModel = spec.io.output;
|
|
246
|
+
if (outputModel?.getZod) return outputModel.getZod().parse(result);
|
|
247
|
+
return result;
|
|
248
|
+
}
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
//#endregion
|
|
252
|
+
export { OperationSpecRegistry, opKey };
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { DocId } from "./docs/registry.js";
|
|
2
|
+
import "./docs/index.js";
|
|
3
|
+
|
|
4
|
+
//#region src/ownership.d.ts
|
|
5
|
+
declare const StabilityEnum: {
|
|
6
|
+
readonly Idea: "idea";
|
|
7
|
+
readonly InCreation: "in_creation";
|
|
8
|
+
readonly Experimental: "experimental";
|
|
9
|
+
readonly Beta: "beta";
|
|
10
|
+
readonly Stable: "stable";
|
|
11
|
+
readonly Deprecated: "deprecated";
|
|
12
|
+
};
|
|
13
|
+
type Stability = (typeof StabilityEnum)[keyof typeof StabilityEnum];
|
|
14
|
+
declare const OwnersEnum: {
|
|
15
|
+
readonly PlatformCore: "platform.core";
|
|
16
|
+
readonly PlatformSigil: "platform.sigil";
|
|
17
|
+
readonly PlatformMarketplace: "platform.marketplace";
|
|
18
|
+
readonly PlatformMessaging: "platform.messaging";
|
|
19
|
+
readonly PlatformContent: "platform.content";
|
|
20
|
+
readonly PlatformFeatureFlags: "platform.featureflags";
|
|
21
|
+
readonly PlatformFinance: "platform.finance";
|
|
22
|
+
};
|
|
23
|
+
type Owner = (typeof OwnersEnum)[keyof typeof OwnersEnum] | (string & {});
|
|
24
|
+
declare const Owners: {
|
|
25
|
+
readonly PlatformCore: "platform.core";
|
|
26
|
+
readonly PlatformSigil: "platform.sigil";
|
|
27
|
+
readonly PlatformMarketplace: "platform.marketplace";
|
|
28
|
+
readonly PlatformMessaging: "platform.messaging";
|
|
29
|
+
readonly PlatformContent: "platform.content";
|
|
30
|
+
readonly PlatformFeatureFlags: "platform.featureflags";
|
|
31
|
+
readonly PlatformFinance: "platform.finance";
|
|
32
|
+
};
|
|
33
|
+
declare const TagsEnum: {
|
|
34
|
+
readonly Spots: "spots";
|
|
35
|
+
readonly Collectivity: "collectivity";
|
|
36
|
+
readonly Marketplace: "marketplace";
|
|
37
|
+
readonly Sellers: "sellers";
|
|
38
|
+
readonly Auth: "auth";
|
|
39
|
+
readonly Login: "login";
|
|
40
|
+
readonly Signup: "signup";
|
|
41
|
+
readonly Guide: "guide";
|
|
42
|
+
readonly Docs: "docs";
|
|
43
|
+
readonly I18n: "i18n";
|
|
44
|
+
readonly Incident: "incident";
|
|
45
|
+
readonly Automation: "automation";
|
|
46
|
+
readonly Hygiene: "hygiene";
|
|
47
|
+
};
|
|
48
|
+
type Tag = (typeof TagsEnum)[keyof typeof TagsEnum] | (string & {});
|
|
49
|
+
declare const Tags: {
|
|
50
|
+
readonly Spots: "spots";
|
|
51
|
+
readonly Collectivity: "collectivity";
|
|
52
|
+
readonly Marketplace: "marketplace";
|
|
53
|
+
readonly Sellers: "sellers";
|
|
54
|
+
readonly Auth: "auth";
|
|
55
|
+
readonly Login: "login";
|
|
56
|
+
readonly Signup: "signup";
|
|
57
|
+
readonly Guide: "guide";
|
|
58
|
+
readonly Docs: "docs";
|
|
59
|
+
readonly I18n: "i18n";
|
|
60
|
+
readonly Incident: "incident";
|
|
61
|
+
readonly Automation: "automation";
|
|
62
|
+
readonly Hygiene: "hygiene";
|
|
63
|
+
};
|
|
64
|
+
interface OwnerShipMeta {
|
|
65
|
+
/** Breaking changes => bump version */
|
|
66
|
+
version: number;
|
|
67
|
+
/** Fully-qualified spec key (e.g., "sigil.beginSignup") */
|
|
68
|
+
key: string;
|
|
69
|
+
/** Human-friendly spec title (e.g., "Signup begin") */
|
|
70
|
+
title?: string;
|
|
71
|
+
/** Short human-friendly summary */
|
|
72
|
+
description: string;
|
|
73
|
+
domain?: string;
|
|
74
|
+
/** Lifecycle marker for comms & tooling */
|
|
75
|
+
stability: Stability;
|
|
76
|
+
/** Owners for CODEOWNERS / on-call / approvals */
|
|
77
|
+
owners: Owner[];
|
|
78
|
+
/** Search tags, grouping, docs navigation */
|
|
79
|
+
tags: Tag[];
|
|
80
|
+
/** Doc block(s) for this operation. */
|
|
81
|
+
docId?: DocId[];
|
|
82
|
+
}
|
|
83
|
+
//#endregion
|
|
84
|
+
export { Owner, OwnerShipMeta, Owners, OwnersEnum, Stability, StabilityEnum, Tag, Tags, TagsEnum };
|