@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,36 @@
|
|
|
1
|
+
import { createFetchHandler } from "./rest-generic.js";
|
|
2
|
+
|
|
3
|
+
//#region src/server/rest-express.ts
|
|
4
|
+
/**
|
|
5
|
+
* Build an Express Router that proxies to the Fetch-style handler.
|
|
6
|
+
* You can mount it at any base path; pass the same basePath in options.
|
|
7
|
+
*/
|
|
8
|
+
function expressRouter(express, reg, ctxFactory, options) {
|
|
9
|
+
const router = express.Router();
|
|
10
|
+
for (const spec of reg.listSpecs()) {
|
|
11
|
+
const method = spec.transport?.rest?.method ?? (spec.meta.kind === "query" ? "GET" : "POST");
|
|
12
|
+
const path = (options?.basePath ?? "") + (spec.transport?.rest?.path ?? `/${spec.meta.key.replace(/\./g, "/")}/v${spec.meta.version}`);
|
|
13
|
+
router[method.toLowerCase()](path, async (req, res) => {
|
|
14
|
+
const url = new URL(`${req.protocol}://${req.get("host")}${req.originalUrl}`);
|
|
15
|
+
const request = new Request(url.toString(), {
|
|
16
|
+
method,
|
|
17
|
+
headers: Object.fromEntries(Object.entries(req.headers).map(([k, v]) => [k, String(v)])),
|
|
18
|
+
body: method === "POST" ? JSON.stringify(req.body ?? {}) : void 0
|
|
19
|
+
});
|
|
20
|
+
const response = await createFetchHandler(reg, () => ctxFactory(req), options)(request);
|
|
21
|
+
res.status(response.status);
|
|
22
|
+
response.headers.forEach((v, k) => res.setHeader(k, v));
|
|
23
|
+
const text = await response.text();
|
|
24
|
+
res.send(text);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
if (options?.cors) router.options("*", (_req, res) => {
|
|
28
|
+
const h = new Headers();
|
|
29
|
+
new Response(null, { status: 204 }).headers.forEach((v, k) => h.set(k, v));
|
|
30
|
+
res.status(204).send();
|
|
31
|
+
});
|
|
32
|
+
return router;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
//#endregion
|
|
36
|
+
export { expressRouter };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { HandlerCtx } from "../types.js";
|
|
2
|
+
import { OperationSpecRegistry } from "../operations/registry.js";
|
|
3
|
+
|
|
4
|
+
//#region src/server/rest-generic.d.ts
|
|
5
|
+
interface RestOptions {
|
|
6
|
+
/** Prefix all routes, e.g. "/api" */
|
|
7
|
+
basePath?: string;
|
|
8
|
+
/** If true, handle OPTIONS and set CORS headers */
|
|
9
|
+
cors?: boolean | {
|
|
10
|
+
origin?: string | '*';
|
|
11
|
+
methods?: string[];
|
|
12
|
+
headers?: string[];
|
|
13
|
+
credentials?: boolean;
|
|
14
|
+
maxAge?: number;
|
|
15
|
+
};
|
|
16
|
+
/** JSON spacing in responses (dev only ideally) */
|
|
17
|
+
prettyJson?: number | false;
|
|
18
|
+
/** Map thrown errors to {status, body} */
|
|
19
|
+
onError?: (err: unknown) => {
|
|
20
|
+
status: number;
|
|
21
|
+
body: unknown;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Build a single Fetch-style handler: (req) => Response
|
|
26
|
+
* - Discovers routes from OperationSpecRegistry
|
|
27
|
+
* - Validates with zod via registry.execute()
|
|
28
|
+
* - Handles CORS (optional)
|
|
29
|
+
*/
|
|
30
|
+
declare function createFetchHandler(reg: OperationSpecRegistry, ctxFactory: (req: Request) => HandlerCtx, options?: RestOptions): (req: Request) => Promise<Response>;
|
|
31
|
+
//#endregion
|
|
32
|
+
export { RestOptions, createFetchHandler };
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { defaultRestPath } from "../jsonschema.js";
|
|
2
|
+
|
|
3
|
+
//#region src/server/rest-generic.ts
|
|
4
|
+
/** Minimal WHATWG Response polyfill util for Node < 18 (if needed) */
|
|
5
|
+
function corsHeaders(opt) {
|
|
6
|
+
const h = {};
|
|
7
|
+
h["access-control-allow-origin"] = typeof opt === "object" ? opt.origin ?? "*" : "*";
|
|
8
|
+
h["vary"] = "Origin";
|
|
9
|
+
if (typeof opt === "object") {
|
|
10
|
+
if (opt.methods) h["access-control-allow-methods"] = opt.methods.join(", ");
|
|
11
|
+
if (opt.headers) h["access-control-allow-headers"] = opt.headers.join(", ");
|
|
12
|
+
if (opt.credentials) h["access-control-allow-credentials"] = "true";
|
|
13
|
+
if (typeof opt.maxAge === "number") h["access-control-max-age"] = String(opt.maxAge);
|
|
14
|
+
} else {
|
|
15
|
+
h["access-control-allow-methods"] = "GET,POST,OPTIONS";
|
|
16
|
+
h["access-control-allow-headers"] = "content-type,x-idempotency-key,x-trace-id";
|
|
17
|
+
}
|
|
18
|
+
return h;
|
|
19
|
+
}
|
|
20
|
+
function joinPath(a, b) {
|
|
21
|
+
return `${(a ?? "").replace(/\/+$/g, "")}/${b.replace(/^\/+/g, "")}`.replace(/\/{2,}/g, "/");
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Build a single Fetch-style handler: (req) => Response
|
|
25
|
+
* - Discovers routes from OperationSpecRegistry
|
|
26
|
+
* - Validates with zod via registry.execute()
|
|
27
|
+
* - Handles CORS (optional)
|
|
28
|
+
*/
|
|
29
|
+
function createFetchHandler(reg, ctxFactory, options) {
|
|
30
|
+
const opts = {
|
|
31
|
+
basePath: options?.basePath ?? "",
|
|
32
|
+
cors: options?.cors ?? false,
|
|
33
|
+
prettyJson: options?.prettyJson ?? false,
|
|
34
|
+
onError: options?.onError
|
|
35
|
+
};
|
|
36
|
+
const routes = reg.listSpecs().map((spec) => ({
|
|
37
|
+
method: spec.transport?.rest?.method ?? (spec.meta.kind === "query" ? "GET" : "POST"),
|
|
38
|
+
path: joinPath(opts.basePath, spec.transport?.rest?.path ?? defaultRestPath(spec.meta.key, spec.meta.version)),
|
|
39
|
+
name: spec.meta.key,
|
|
40
|
+
version: spec.meta.version
|
|
41
|
+
}));
|
|
42
|
+
const routeTable = /* @__PURE__ */ new Map();
|
|
43
|
+
for (const r of routes) routeTable.set(`${r.method} ${r.path}`, r);
|
|
44
|
+
const makeJson = (status, data, extraHeaders) => {
|
|
45
|
+
const body = opts.prettyJson ? JSON.stringify(data, null, opts.prettyJson) : JSON.stringify(data);
|
|
46
|
+
const base = { "content-type": "application/json; charset=utf-8" };
|
|
47
|
+
return new Response(body, {
|
|
48
|
+
status,
|
|
49
|
+
headers: extraHeaders ? {
|
|
50
|
+
...base,
|
|
51
|
+
...extraHeaders
|
|
52
|
+
} : base
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
return async function handle(req) {
|
|
56
|
+
const url = new URL(req.url);
|
|
57
|
+
const key = `${req.method.toUpperCase()} ${url.pathname}`;
|
|
58
|
+
if (opts.cors && req.method.toUpperCase() === "OPTIONS") {
|
|
59
|
+
const h = corsHeaders(opts.cors === true ? {} : opts.cors);
|
|
60
|
+
return new Response(null, {
|
|
61
|
+
status: 204,
|
|
62
|
+
headers: {
|
|
63
|
+
...h,
|
|
64
|
+
"content-length": "0"
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
const route = routeTable.get(key);
|
|
69
|
+
if (!route) {
|
|
70
|
+
const headers = {};
|
|
71
|
+
if (opts.cors) Object.assign(headers, corsHeaders(opts.cors === true ? {} : opts.cors));
|
|
72
|
+
return makeJson(404, {
|
|
73
|
+
error: "NotFound",
|
|
74
|
+
path: url.pathname
|
|
75
|
+
}, headers);
|
|
76
|
+
}
|
|
77
|
+
try {
|
|
78
|
+
let input = {};
|
|
79
|
+
if (route.method === "GET") if (url.searchParams.has("input")) {
|
|
80
|
+
const raw = url.searchParams.get("input");
|
|
81
|
+
input = raw ? JSON.parse(raw) : {};
|
|
82
|
+
} else {
|
|
83
|
+
const obj = {};
|
|
84
|
+
for (const [k, v] of url.searchParams.entries()) obj[k] = v;
|
|
85
|
+
input = obj;
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
const contentType = req.headers.get("content-type") || "";
|
|
89
|
+
if (contentType.includes("application/json")) input = await req.json();
|
|
90
|
+
else if (contentType.includes("application/x-www-form-urlencoded")) {
|
|
91
|
+
const form = await req.formData();
|
|
92
|
+
input = Object.fromEntries(form.entries());
|
|
93
|
+
} else if (!contentType) input = {};
|
|
94
|
+
else return makeJson(415, {
|
|
95
|
+
error: "UnsupportedMediaType",
|
|
96
|
+
contentType
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
const ctx = ctxFactory(req);
|
|
100
|
+
const result = await reg.execute(route.name, route.version, input, ctx);
|
|
101
|
+
const headers = {};
|
|
102
|
+
if (opts.cors) Object.assign(headers, corsHeaders(opts.cors === true ? {} : opts.cors));
|
|
103
|
+
return makeJson(200, result, headers);
|
|
104
|
+
} catch (err) {
|
|
105
|
+
if (opts.onError) {
|
|
106
|
+
const mapped = opts.onError(err);
|
|
107
|
+
const headers$1 = {};
|
|
108
|
+
if (opts.cors) Object.assign(headers$1, corsHeaders(opts.cors === true ? {} : opts.cors));
|
|
109
|
+
return makeJson(mapped.status, mapped.body, headers$1);
|
|
110
|
+
}
|
|
111
|
+
const headers = {};
|
|
112
|
+
if (opts.cors) Object.assign(headers, corsHeaders(opts.cors === true ? {} : opts.cors));
|
|
113
|
+
if (err?.issues) return makeJson(400, {
|
|
114
|
+
error: "ValidationError",
|
|
115
|
+
issues: err.issues
|
|
116
|
+
}, headers);
|
|
117
|
+
if (typeof err?.message === "string" && err.message.startsWith("PolicyDenied")) return makeJson(403, { error: "PolicyDenied" }, headers);
|
|
118
|
+
return makeJson(500, { error: "InternalError" }, headers);
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
//#endregion
|
|
124
|
+
export { createFetchHandler };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { HandlerCtx } from "../types.js";
|
|
2
|
+
import { OperationSpecRegistry } from "../operations/registry.js";
|
|
3
|
+
import { RestOptions } from "./rest-generic.js";
|
|
4
|
+
|
|
5
|
+
//#region src/server/rest-next-app.d.ts
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Creates a Next.js App Router route handler for ContractSpec operations.
|
|
9
|
+
*
|
|
10
|
+
* This function returns a handler suitable for `export const { GET, POST }` in a `route.ts` file.
|
|
11
|
+
* It handles:
|
|
12
|
+
* - Path parsing to determine the operation name and version.
|
|
13
|
+
* - Body parsing (JSON).
|
|
14
|
+
* - Context creation via `ctxFactory`.
|
|
15
|
+
* - Execution via `OperationSpecRegistry`.
|
|
16
|
+
* - Response formatting (JSON success/error).
|
|
17
|
+
*
|
|
18
|
+
* @param reg - The OperationSpecRegistry containing the operations.
|
|
19
|
+
* @param ctxFactory - A factory function to build the `HandlerCtx` (e.g., auth, tenant) from the request.
|
|
20
|
+
* @param options - Optional configuration for the REST handler.
|
|
21
|
+
* @returns A function `(req: Request) => Promise<Response>`.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts
|
|
25
|
+
* // app/api/[...route]/route.ts
|
|
26
|
+
* import { makeNextAppHandler } from '@contractspec/lib.contracts/server/rest-next-app';
|
|
27
|
+
* import { registry } from '@/lib/registry';
|
|
28
|
+
*
|
|
29
|
+
* const handler = makeNextAppHandler(registry, (req) => ({ actor: 'anonymous' }));
|
|
30
|
+
* export { handler as GET, handler as POST };
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
declare function makeNextAppHandler(reg: OperationSpecRegistry, ctxFactory: (req: Request) => HandlerCtx, options?: RestOptions): (req: Request) => Promise<Response>;
|
|
34
|
+
//#endregion
|
|
35
|
+
export { makeNextAppHandler };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { createFetchHandler } from "./rest-generic.js";
|
|
2
|
+
|
|
3
|
+
//#region src/server/rest-next-app.ts
|
|
4
|
+
/**
|
|
5
|
+
* Creates a Next.js App Router route handler for ContractSpec operations.
|
|
6
|
+
*
|
|
7
|
+
* This function returns a handler suitable for `export const { GET, POST }` in a `route.ts` file.
|
|
8
|
+
* It handles:
|
|
9
|
+
* - Path parsing to determine the operation name and version.
|
|
10
|
+
* - Body parsing (JSON).
|
|
11
|
+
* - Context creation via `ctxFactory`.
|
|
12
|
+
* - Execution via `OperationSpecRegistry`.
|
|
13
|
+
* - Response formatting (JSON success/error).
|
|
14
|
+
*
|
|
15
|
+
* @param reg - The OperationSpecRegistry containing the operations.
|
|
16
|
+
* @param ctxFactory - A factory function to build the `HandlerCtx` (e.g., auth, tenant) from the request.
|
|
17
|
+
* @param options - Optional configuration for the REST handler.
|
|
18
|
+
* @returns A function `(req: Request) => Promise<Response>`.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* // app/api/[...route]/route.ts
|
|
23
|
+
* import { makeNextAppHandler } from '@contractspec/lib.contracts/server/rest-next-app';
|
|
24
|
+
* import { registry } from '@/lib/registry';
|
|
25
|
+
*
|
|
26
|
+
* const handler = makeNextAppHandler(registry, (req) => ({ actor: 'anonymous' }));
|
|
27
|
+
* export { handler as GET, handler as POST };
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
function makeNextAppHandler(reg, ctxFactory, options) {
|
|
31
|
+
const handler = createFetchHandler(reg, ctxFactory, options);
|
|
32
|
+
return async function requestHandler(req) {
|
|
33
|
+
return handler(req);
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
//#endregion
|
|
38
|
+
export { makeNextAppHandler };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { HandlerCtx } from "../types.js";
|
|
2
|
+
import { OperationSpecRegistry } from "../operations/registry.js";
|
|
3
|
+
|
|
4
|
+
//#region src/server/rest-next-mcp.d.ts
|
|
5
|
+
declare function makeNextMcpServerFromRegistry(reg: OperationSpecRegistry, ctxFactory: () => HandlerCtx): {
|
|
6
|
+
GET: (request: Request) => Promise<Response>;
|
|
7
|
+
POST: (request: Request) => Promise<Response>;
|
|
8
|
+
DELETE: (request: Request) => Promise<Response>;
|
|
9
|
+
};
|
|
10
|
+
//#endregion
|
|
11
|
+
export { makeNextMcpServerFromRegistry };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { defaultMcpTool, jsonSchemaForSpec } from "../jsonschema.js";
|
|
2
|
+
import { ResourceTemplate } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
3
|
+
import { createMcpHandler } from "mcp-handler";
|
|
4
|
+
|
|
5
|
+
//#region src/server/rest-next-mcp.ts
|
|
6
|
+
function makeNextMcpServerFromRegistry(reg, ctxFactory) {
|
|
7
|
+
const handler = createMcpHandler((server) => {
|
|
8
|
+
for (const spec of reg.listSpecs()) {
|
|
9
|
+
const { input, meta } = jsonSchemaForSpec(spec);
|
|
10
|
+
if (meta.kind === "query") {
|
|
11
|
+
const resourceName = spec.transport?.mcp?.toolName ?? defaultMcpTool(spec.meta.key, spec.meta.version);
|
|
12
|
+
server.registerResource(resourceName, new ResourceTemplate("users://{userId}/profile", { list: void 0 }), {
|
|
13
|
+
description: spec.meta.description,
|
|
14
|
+
inputSchema: input
|
|
15
|
+
}, (async (uri, args, _req) => {
|
|
16
|
+
const result = await reg.execute(spec.meta.key, spec.meta.version, args ?? {}, ctxFactory());
|
|
17
|
+
return { contents: [{
|
|
18
|
+
uri: uri.href,
|
|
19
|
+
text: String(result)
|
|
20
|
+
}] };
|
|
21
|
+
}));
|
|
22
|
+
} else if (meta.kind === "command") {
|
|
23
|
+
const toolName = spec.transport?.mcp?.toolName ?? defaultMcpTool(spec.meta.key, spec.meta.version);
|
|
24
|
+
server.registerTool(toolName, {
|
|
25
|
+
description: spec.meta.description,
|
|
26
|
+
inputSchema: input
|
|
27
|
+
}, (async (args, _req) => {
|
|
28
|
+
const result = await reg.execute(spec.meta.key, spec.meta.version, args ?? {}, ctxFactory());
|
|
29
|
+
return { content: [{
|
|
30
|
+
type: "text",
|
|
31
|
+
text: String(result)
|
|
32
|
+
}] };
|
|
33
|
+
}));
|
|
34
|
+
} else throw new Error(`Unsupported kind: ${meta.kind}`);
|
|
35
|
+
}
|
|
36
|
+
}, {}, { basePath: "/api" });
|
|
37
|
+
return {
|
|
38
|
+
GET: handler,
|
|
39
|
+
POST: handler,
|
|
40
|
+
DELETE: handler
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
//#endregion
|
|
45
|
+
export { makeNextMcpServerFromRegistry };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { HandlerCtx } from "../types.js";
|
|
2
|
+
import { OperationSpecRegistry } from "../operations/registry.js";
|
|
3
|
+
import { RestOptions } from "./rest-generic.js";
|
|
4
|
+
import { NextApiRequest, NextApiResponse } from "next";
|
|
5
|
+
|
|
6
|
+
//#region src/server/rest-next-pages.d.ts
|
|
7
|
+
declare function makeNextPagesHandler(reg: OperationSpecRegistry, ctxFactory: (req: NextApiRequest) => HandlerCtx, options?: RestOptions): (req: NextApiRequest, res: NextApiResponse) => Promise<void>;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { makeNextPagesHandler };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { createFetchHandler } from "./rest-generic.js";
|
|
2
|
+
|
|
3
|
+
//#region src/server/rest-next-pages.ts
|
|
4
|
+
function makeNextPagesHandler(reg, ctxFactory, options) {
|
|
5
|
+
return async function handler(req, res) {
|
|
6
|
+
const url = `${req.headers["x-forwarded-proto"] ?? "http"}://${req.headers.host}${req.url}`;
|
|
7
|
+
const method = req.method?.toUpperCase() || "GET";
|
|
8
|
+
const request = new Request(url, {
|
|
9
|
+
method,
|
|
10
|
+
headers: Object.fromEntries(Object.entries(req.headers).map(([k, v]) => [k, String(v)])),
|
|
11
|
+
body: method === "POST" ? JSON.stringify(req.body ?? {}) : void 0
|
|
12
|
+
});
|
|
13
|
+
const response = await createFetchHandler(reg, () => ctxFactory(req), options)(request);
|
|
14
|
+
res.status(response.status);
|
|
15
|
+
response.headers.forEach((v, k) => res.setHeader(k, v));
|
|
16
|
+
const text = await response.text();
|
|
17
|
+
res.send(text);
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
//#endregion
|
|
22
|
+
export { makeNextPagesHandler };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { TelemetryAnomalyDetectionConfig } from "./spec.js";
|
|
2
|
+
import { TelemetryDispatch } from "./tracker.js";
|
|
3
|
+
|
|
4
|
+
//#region src/telemetry/anomaly.d.ts
|
|
5
|
+
interface TelemetryAnomalyEvent {
|
|
6
|
+
dispatch: TelemetryDispatch;
|
|
7
|
+
threshold: TelemetryAnomalyDetectionConfig;
|
|
8
|
+
metric: string;
|
|
9
|
+
value: number | undefined;
|
|
10
|
+
type: 'min' | 'max';
|
|
11
|
+
}
|
|
12
|
+
interface TelemetryAnomalyMonitorOptions {
|
|
13
|
+
onAnomaly?: (event: TelemetryAnomalyEvent) => void;
|
|
14
|
+
now?: () => Date;
|
|
15
|
+
}
|
|
16
|
+
declare class TelemetryAnomalyMonitor {
|
|
17
|
+
private readonly onAnomaly?;
|
|
18
|
+
private readonly now;
|
|
19
|
+
private readonly samples;
|
|
20
|
+
constructor(options?: TelemetryAnomalyMonitorOptions);
|
|
21
|
+
observe(dispatch: TelemetryDispatch): void;
|
|
22
|
+
private extractMetric;
|
|
23
|
+
private emit;
|
|
24
|
+
reset(): void;
|
|
25
|
+
}
|
|
26
|
+
//#endregion
|
|
27
|
+
export { TelemetryAnomalyEvent, TelemetryAnomalyMonitor, TelemetryAnomalyMonitorOptions };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
//#region src/telemetry/anomaly.ts
|
|
2
|
+
var TelemetryAnomalyMonitor = class {
|
|
3
|
+
onAnomaly;
|
|
4
|
+
now;
|
|
5
|
+
samples = /* @__PURE__ */ new Map();
|
|
6
|
+
constructor(options = {}) {
|
|
7
|
+
this.onAnomaly = options.onAnomaly;
|
|
8
|
+
this.now = options.now ?? (() => /* @__PURE__ */ new Date());
|
|
9
|
+
}
|
|
10
|
+
observe(dispatch) {
|
|
11
|
+
const anomalyConfig = dispatch.definition.anomalyDetection;
|
|
12
|
+
if (!anomalyConfig?.enabled) return;
|
|
13
|
+
if (!anomalyConfig.thresholds?.length) return;
|
|
14
|
+
const eventKey = `${dispatch.name}.v${dispatch.version}`;
|
|
15
|
+
const newCount = (this.samples.get(eventKey) ?? 0) + 1;
|
|
16
|
+
this.samples.set(eventKey, newCount);
|
|
17
|
+
if (typeof anomalyConfig.minimumSample === "number" && newCount < anomalyConfig.minimumSample) return;
|
|
18
|
+
for (const threshold of anomalyConfig.thresholds) {
|
|
19
|
+
const value = this.extractMetric(dispatch, threshold.metric);
|
|
20
|
+
if (typeof value !== "number") continue;
|
|
21
|
+
if (typeof threshold.min === "number" && value < threshold.min) this.emit(dispatch, anomalyConfig, threshold.metric, value, "min");
|
|
22
|
+
if (typeof threshold.max === "number" && value > threshold.max) this.emit(dispatch, anomalyConfig, threshold.metric, value, "max");
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
extractMetric(dispatch, metric) {
|
|
26
|
+
const value = dispatch.properties[metric];
|
|
27
|
+
if (typeof value === "number") return value;
|
|
28
|
+
if (typeof value === "object" && value !== null && "value" in value) {
|
|
29
|
+
const maybeNumber = value.value;
|
|
30
|
+
return typeof maybeNumber === "number" ? maybeNumber : void 0;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
emit(dispatch, threshold, metric, value, type) {
|
|
34
|
+
this.onAnomaly?.({
|
|
35
|
+
dispatch,
|
|
36
|
+
threshold,
|
|
37
|
+
metric,
|
|
38
|
+
value,
|
|
39
|
+
type
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
reset() {
|
|
43
|
+
this.samples.clear();
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
//#endregion
|
|
48
|
+
export { TelemetryAnomalyMonitor };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { registerDocBlocks } from "../../docs/registry.js";
|
|
2
|
+
|
|
3
|
+
//#region src/telemetry/docs/telemetry.docblock.ts
|
|
4
|
+
const tech_contracts_telemetry_DocBlocks = [{
|
|
5
|
+
id: "docs.tech.contracts.telemetry",
|
|
6
|
+
title: "TelemetrySpec",
|
|
7
|
+
summary: "Telemetry specs describe product analytics in a durable, type-safe way. They reference existing `EventSpec`s (same name/version) but layer on privacy classification, retention, sampling, and anomaly detection so instrumentation stays compliant and observable.",
|
|
8
|
+
kind: "reference",
|
|
9
|
+
visibility: "public",
|
|
10
|
+
route: "/docs/tech/contracts/telemetry",
|
|
11
|
+
tags: [
|
|
12
|
+
"tech",
|
|
13
|
+
"contracts",
|
|
14
|
+
"telemetry"
|
|
15
|
+
],
|
|
16
|
+
body: "## TelemetrySpec\n\nTelemetry specs describe product analytics in a durable, type-safe way. They reference existing `EventSpec`s (same name/version) but layer on privacy classification, retention, sampling, and anomaly detection so instrumentation stays compliant and observable.\n\n- **File location**: `packages/libs/contracts/src/telemetry/spec.ts`\n- **Runtime tracker**: `packages/libs/contracts/src/telemetry/tracker.ts`\n- **Anomaly monitor**: `packages/libs/contracts/src/telemetry/anomaly.ts`\n\n### Core concepts\n\n```ts\nexport interface TelemetrySpec {\n meta: TelemetryMeta;\n events: TelemetryEventDef[];\n config?: TelemetryConfig;\n}\n```\n\n- `meta`: ownership + identifiers (`name`, `version`, `domain`)\n- `events`: per-event semantics, property definitions, privacy level, retention, sampling, anomaly rules\n- `config`: defaults and provider configuration\n- `TelemetryRegistry`: registers specs, resolves latest version, finds event definitions by name/version\n\n### An example\n\n```ts\nexport const SigilTelemetry: TelemetrySpec = {\n meta: {\n name: 'sigil.telemetry',\n version: 1,\n title: 'Sigil telemetry',\n description: 'Core Sigil product telemetry',\n domain: 'sigil',\n owners: ['@team.analytics'],\n tags: ['telemetry'],\n stability: StabilityEnum.Experimental,\n },\n config: {\n defaultRetentionDays: 30,\n defaultSamplingRate: 1,\n providers: [\n { type: 'posthog', config: { projectApiKey: process.env.POSTHOG_KEY } },\n ],\n },\n events: [\n {\n name: 'sigil.telemetry.workflow_step',\n version: 1,\n semantics: {\n what: 'Workflow step executed',\n who: 'Actor executing the workflow',\n },\n privacy: 'internal',\n properties: {\n workflow: { type: 'string', required: true },\n step: { type: 'string', required: true },\n durationMs: { type: 'number' },\n userId: { type: 'string', pii: true, redact: true },\n },\n anomalyDetection: {\n enabled: true,\n minimumSample: 10,\n thresholds: [\n { metric: 'durationMs', max: 1500 },\n ],\n actions: ['alert', 'trigger_regen'],\n },\n },\n ],\n};\n```\n\n### Tracking events at runtime\n\n`TelemetryTracker` performs sampling, PII redaction, provider dispatch, and anomaly detection.\n\n```ts\nconst tracker = new TelemetryTracker({\n registry: telemetryRegistry,\n providers: [\n {\n id: 'posthog',\n async send(dispatch) {\n posthog.capture({\n event: dispatch.name,\n properties: dispatch.properties,\n distinctId: dispatch.context.userId ?? dispatch.context.sessionId,\n });\n },\n },\n ],\n anomalyMonitor: new TelemetryAnomalyMonitor({\n onAnomaly(event) {\n console.warn('Telemetry anomaly detected', event);\n },\n }),\n});\n\nawait tracker.track('sigil.telemetry.workflow_step', 1, {\n workflow: 'onboarding',\n step: 'verify_email',\n durationMs: 2100,\n userId: 'user-123',\n});\n```\n\n- Sampling obeys the event-specific rate (fallback to spec defaults)\n- Properties flagged with `pii` or `redact` are masked before dispatch\n- Anomaly monitor evaluates thresholds and triggers actions (e.g., log, alert, regeneration)\n\n### Spec integration\n\n- `ContractSpec.telemetry` allows operations to emit success/failure events automatically\n- `OperationSpecRegistry.execute()` uses the tracker when `ctx.telemetry` is provided\n- `WorkflowRunner` (Phase 4 follow-up) will emit telemetry during step transitions\n- `TelemetrySpec` events should reuse `EventSpec` names/versions to keep analytics/contract parity\n\n### CLI workflow\n\n```\ncontracts-cli create telemetry\n```\n\n- Interactive wizard prompts for meta, providers, events, properties, retention, anomaly rules\n- Output: `*.telemetry.ts` file using `TelemetrySpec`\n\n### Best practices\n\n- Prefer `internal` privacy for non-PII; mark PII properties explicitly with `pii` + `redact`\n- Keep sampling ≥0.05 except for high-volume events\n- Configure anomaly detection on key metrics (duration, error count, conversion)\n- Check telemetry into source control alongside contracts; regenerate via CLI when specs change\n\n### Next steps\n\n- Phase 5: Regenerator monitors telemetry anomalies to propose spec improvements\n- Phase 6: Studio surfaces telemetry controls per tenant via `TenantAppConfig`\n\n"
|
|
17
|
+
}];
|
|
18
|
+
registerDocBlocks(tech_contracts_telemetry_DocBlocks);
|
|
19
|
+
|
|
20
|
+
//#endregion
|
|
21
|
+
export { tech_contracts_telemetry_DocBlocks };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { TelemetryAnomalyAction, TelemetryAnomalyDetectionConfig, TelemetryAnomalyThreshold, TelemetryConfig, TelemetryEventDef, TelemetryMeta, TelemetryPrivacyLevel, TelemetryPropertyDef, TelemetryProviderConfig, TelemetryRegistry, TelemetryRetentionConfig, TelemetrySamplingConfig, TelemetrySpec, makeTelemetryKey } from "./spec.js";
|
|
2
|
+
import { TelemetryAnomalyEvent, TelemetryAnomalyMonitor, TelemetryAnomalyMonitorOptions } from "./anomaly.js";
|
|
3
|
+
import { RuntimeTelemetryProvider, TelemetryDispatch, TelemetryEventContext, TelemetryTracker, TelemetryTrackerOptions } from "./tracker.js";
|
|
4
|
+
export { RuntimeTelemetryProvider, TelemetryAnomalyAction, TelemetryAnomalyDetectionConfig, TelemetryAnomalyEvent, TelemetryAnomalyMonitor, TelemetryAnomalyMonitorOptions, TelemetryAnomalyThreshold, TelemetryConfig, TelemetryDispatch, TelemetryEventContext, TelemetryEventDef, TelemetryMeta, TelemetryPrivacyLevel, TelemetryPropertyDef, TelemetryProviderConfig, TelemetryRegistry, TelemetryRetentionConfig, TelemetrySamplingConfig, TelemetrySpec, TelemetryTracker, TelemetryTrackerOptions, makeTelemetryKey };
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { OwnerShipMeta } from "../ownership.js";
|
|
2
|
+
|
|
3
|
+
//#region src/telemetry/spec.d.ts
|
|
4
|
+
type TelemetryPrivacyLevel = 'public' | 'internal' | 'pii' | 'sensitive';
|
|
5
|
+
type TelemetryMeta = OwnerShipMeta;
|
|
6
|
+
interface TelemetryPropertyDef {
|
|
7
|
+
type: 'string' | 'number' | 'boolean' | 'timestamp' | 'json';
|
|
8
|
+
required?: boolean;
|
|
9
|
+
pii?: boolean;
|
|
10
|
+
redact?: boolean;
|
|
11
|
+
description?: string;
|
|
12
|
+
}
|
|
13
|
+
interface TelemetryAnomalyThreshold {
|
|
14
|
+
metric: string;
|
|
15
|
+
min?: number;
|
|
16
|
+
max?: number;
|
|
17
|
+
}
|
|
18
|
+
type TelemetryAnomalyAction = 'alert' | 'log' | 'trigger_regen';
|
|
19
|
+
interface TelemetryAnomalyDetectionConfig {
|
|
20
|
+
enabled: boolean;
|
|
21
|
+
thresholds?: TelemetryAnomalyThreshold[];
|
|
22
|
+
actions?: TelemetryAnomalyAction[];
|
|
23
|
+
/**
|
|
24
|
+
* Minimum sample size before evaluating thresholds.
|
|
25
|
+
* Helps avoid false positives on small sample sizes.
|
|
26
|
+
*/
|
|
27
|
+
minimumSample?: number;
|
|
28
|
+
}
|
|
29
|
+
interface TelemetrySamplingConfig {
|
|
30
|
+
rate: number;
|
|
31
|
+
conditions?: string[];
|
|
32
|
+
}
|
|
33
|
+
interface TelemetryRetentionConfig {
|
|
34
|
+
days: number;
|
|
35
|
+
policy?: 'archive' | 'delete';
|
|
36
|
+
}
|
|
37
|
+
interface TelemetryEventDef {
|
|
38
|
+
/** Name of the event (should match EventSpec.key for cross-reference). */
|
|
39
|
+
key: string;
|
|
40
|
+
/** Version of the underlying event. */
|
|
41
|
+
version: number;
|
|
42
|
+
/** High-level semantics for docs/analyzers. */
|
|
43
|
+
semantics: {
|
|
44
|
+
who?: string;
|
|
45
|
+
what: string;
|
|
46
|
+
why?: string;
|
|
47
|
+
};
|
|
48
|
+
/** Detailed property metadata keyed by property name. */
|
|
49
|
+
properties: Record<string, TelemetryPropertyDef>;
|
|
50
|
+
/** Privacy level for the entire event. */
|
|
51
|
+
privacy: TelemetryPrivacyLevel;
|
|
52
|
+
/** Retention policy overrides. */
|
|
53
|
+
retention?: TelemetryRetentionConfig;
|
|
54
|
+
/** Sampling rules, defaulting to spec.config defaults. */
|
|
55
|
+
sampling?: TelemetrySamplingConfig;
|
|
56
|
+
/** Anomaly detection overrides. */
|
|
57
|
+
anomalyDetection?: TelemetryAnomalyDetectionConfig;
|
|
58
|
+
/** Optional tags for analytics/AI hints. */
|
|
59
|
+
tags?: string[];
|
|
60
|
+
}
|
|
61
|
+
interface TelemetryProviderConfig {
|
|
62
|
+
type: 'posthog' | 'segment' | 'opentelemetry' | 'internal';
|
|
63
|
+
config: Record<string, unknown>;
|
|
64
|
+
}
|
|
65
|
+
interface TelemetryConfig {
|
|
66
|
+
defaultRetentionDays?: number;
|
|
67
|
+
defaultSamplingRate?: number;
|
|
68
|
+
providers?: TelemetryProviderConfig[];
|
|
69
|
+
anomalyDetection?: {
|
|
70
|
+
enabled: boolean;
|
|
71
|
+
checkIntervalMs?: number;
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
interface TelemetrySpec {
|
|
75
|
+
meta: TelemetryMeta;
|
|
76
|
+
events: TelemetryEventDef[];
|
|
77
|
+
config?: TelemetryConfig;
|
|
78
|
+
}
|
|
79
|
+
declare class TelemetryRegistry {
|
|
80
|
+
private readonly items;
|
|
81
|
+
private readonly eventsByKey;
|
|
82
|
+
private readonly specByEventKey;
|
|
83
|
+
register(spec: TelemetrySpec): this;
|
|
84
|
+
list(): TelemetrySpec[];
|
|
85
|
+
get(key: string, version?: number): TelemetrySpec | undefined;
|
|
86
|
+
findEventDef(name: string, version?: number): TelemetryEventDef | undefined;
|
|
87
|
+
getSpecForEvent(name: string, version?: number): TelemetrySpec | undefined;
|
|
88
|
+
}
|
|
89
|
+
declare function makeTelemetryKey(meta: TelemetryMeta): string;
|
|
90
|
+
//#endregion
|
|
91
|
+
export { TelemetryAnomalyAction, TelemetryAnomalyDetectionConfig, TelemetryAnomalyThreshold, TelemetryConfig, TelemetryEventDef, TelemetryMeta, TelemetryPrivacyLevel, TelemetryPropertyDef, TelemetryProviderConfig, TelemetryRegistry, TelemetryRetentionConfig, TelemetrySamplingConfig, TelemetrySpec, makeTelemetryKey };
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
//#region src/telemetry/spec.ts
|
|
2
|
+
const telemetryKey = (meta) => `${meta.key}.v${meta.version}`;
|
|
3
|
+
var TelemetryRegistry = class {
|
|
4
|
+
items = /* @__PURE__ */ new Map();
|
|
5
|
+
eventsByKey = /* @__PURE__ */ new Map();
|
|
6
|
+
specByEventKey = /* @__PURE__ */ new Map();
|
|
7
|
+
register(spec) {
|
|
8
|
+
const key = telemetryKey(spec.meta);
|
|
9
|
+
if (this.items.has(key)) throw new Error(`Duplicate TelemetrySpec registration for ${key}`);
|
|
10
|
+
this.items.set(key, spec);
|
|
11
|
+
for (const event of spec.events) {
|
|
12
|
+
this.eventsByKey.set(`${event.key}.v${event.version}`, event);
|
|
13
|
+
this.specByEventKey.set(`${event.key}.v${event.version}`, spec);
|
|
14
|
+
}
|
|
15
|
+
return this;
|
|
16
|
+
}
|
|
17
|
+
list() {
|
|
18
|
+
return [...this.items.values()];
|
|
19
|
+
}
|
|
20
|
+
get(key, version) {
|
|
21
|
+
if (version != null) return this.items.get(`${key}.v${version}`);
|
|
22
|
+
let latest;
|
|
23
|
+
let maxVersion = -Infinity;
|
|
24
|
+
for (const item of this.items.values()) {
|
|
25
|
+
if (item.meta.key !== key) continue;
|
|
26
|
+
if (item.meta.version > maxVersion) {
|
|
27
|
+
maxVersion = item.meta.version;
|
|
28
|
+
latest = item;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return latest;
|
|
32
|
+
}
|
|
33
|
+
findEventDef(name, version) {
|
|
34
|
+
if (version != null) return this.eventsByKey.get(`${name}.v${version}`);
|
|
35
|
+
let latest;
|
|
36
|
+
let maxVersion = -Infinity;
|
|
37
|
+
for (const [key, event] of this.eventsByKey.entries()) {
|
|
38
|
+
const [eventName, versionPart] = key.split(".v");
|
|
39
|
+
if (eventName !== name) continue;
|
|
40
|
+
const ver = Number(versionPart);
|
|
41
|
+
if (Number.isFinite(ver) && ver > maxVersion) {
|
|
42
|
+
maxVersion = ver;
|
|
43
|
+
latest = event;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return latest;
|
|
47
|
+
}
|
|
48
|
+
getSpecForEvent(name, version) {
|
|
49
|
+
if (version != null) return this.specByEventKey.get(`${name}.v${version}`);
|
|
50
|
+
let latest;
|
|
51
|
+
let maxVersion = -Infinity;
|
|
52
|
+
for (const [key, spec] of this.specByEventKey.entries()) {
|
|
53
|
+
const [eventName, versionPart] = key.split(".v");
|
|
54
|
+
if (eventName !== name) continue;
|
|
55
|
+
const ver = Number(versionPart);
|
|
56
|
+
if (Number.isFinite(ver) && ver > maxVersion) {
|
|
57
|
+
maxVersion = ver;
|
|
58
|
+
latest = spec;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return latest;
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
function makeTelemetryKey(meta) {
|
|
65
|
+
return telemetryKey(meta);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
//#endregion
|
|
69
|
+
export { TelemetryRegistry, makeTelemetryKey };
|