@contractspec/lib.contracts 0.0.0-canary-20260113162409
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +109 -0
- package/dist/_virtual/rolldown_runtime.js +37 -0
- package/dist/app-config/app-config.capability.d.ts +7 -0
- package/dist/app-config/app-config.capability.js +23 -0
- package/dist/app-config/app-config.feature.d.ts +11 -0
- package/dist/app-config/app-config.feature.js +61 -0
- package/dist/app-config/branding.d.ts +55 -0
- package/dist/app-config/branding.js +0 -0
- package/dist/app-config/contracts.d.ts +245 -0
- package/dist/app-config/contracts.js +395 -0
- package/dist/app-config/docs/app-config.docblock.d.ts +6 -0
- package/dist/app-config/docs/app-config.docblock.js +21 -0
- package/dist/app-config/events.d.ts +122 -0
- package/dist/app-config/events.js +174 -0
- package/dist/app-config/index.d.ts +10 -0
- package/dist/app-config/index.js +9 -0
- package/dist/app-config/lifecycle-contracts.d.ts +273 -0
- package/dist/app-config/lifecycle-contracts.js +440 -0
- package/dist/app-config/lifecycle.d.ts +27 -0
- package/dist/app-config/lifecycle.js +0 -0
- package/dist/app-config/runtime.d.ts +120 -0
- package/dist/app-config/runtime.js +617 -0
- package/dist/app-config/spec.d.ts +175 -0
- package/dist/app-config/spec.js +19 -0
- package/dist/app-config/validation.d.ts +49 -0
- package/dist/app-config/validation.js +538 -0
- package/dist/capabilities/capabilities.d.ts +41 -0
- package/dist/capabilities/capabilities.js +48 -0
- package/dist/capabilities/docs/capabilities.docblock.d.ts +6 -0
- package/dist/capabilities/docs/capabilities.docblock.js +21 -0
- package/dist/capabilities/index.d.ts +3 -0
- package/dist/capabilities/index.js +4 -0
- package/dist/capabilities/openbanking.d.ts +10 -0
- package/dist/capabilities/openbanking.js +92 -0
- package/dist/client/index.d.ts +6 -0
- package/dist/client/index.js +9 -0
- package/dist/client/react/drivers/rn-reusables.d.ts +22 -0
- package/dist/client/react/drivers/rn-reusables.js +21 -0
- package/dist/client/react/drivers/shadcn.d.ts +12 -0
- package/dist/client/react/drivers/shadcn.js +11 -0
- package/dist/client/react/feature-render.d.ts +23 -0
- package/dist/client/react/feature-render.js +44 -0
- package/dist/client/react/form-render.d.ts +92 -0
- package/dist/client/react/form-render.js +301 -0
- package/dist/client/react/index.d.ts +5 -0
- package/dist/client/react/index.js +8 -0
- package/dist/contract-registry/index.d.ts +3 -0
- package/dist/contract-registry/index.js +3 -0
- package/dist/contract-registry/schemas.d.ts +124 -0
- package/dist/contract-registry/schemas.js +61 -0
- package/dist/contract-registry/types.d.ts +46 -0
- package/dist/contract-registry/types.js +0 -0
- package/dist/data-views/data-views.d.ts +5 -0
- package/dist/data-views/data-views.js +5 -0
- package/dist/data-views/docs/data-views.docblock.d.ts +6 -0
- package/dist/data-views/docs/data-views.docblock.js +21 -0
- package/dist/data-views/index.d.ts +4 -0
- package/dist/data-views/index.js +4 -0
- package/dist/data-views/query-generator.d.ts +40 -0
- package/dist/data-views/query-generator.js +48 -0
- package/dist/data-views/registry.d.ts +17 -0
- package/dist/data-views/registry.js +20 -0
- package/dist/data-views/runtime.d.ts +32 -0
- package/dist/data-views/runtime.js +68 -0
- package/dist/data-views/spec.d.ts +32 -0
- package/dist/data-views/spec.js +10 -0
- package/dist/data-views/types.d.ts +157 -0
- package/dist/data-views/types.js +0 -0
- package/dist/docs/accessibility_wcag_compliance_specs.docblock.d.ts +6 -0
- package/dist/docs/accessibility_wcag_compliance_specs.docblock.js +17 -0
- package/dist/docs/index.d.ts +6 -0
- package/dist/docs/index.js +30 -0
- package/dist/docs/meta.docs.d.ts +6 -0
- package/dist/docs/meta.docs.js +29 -0
- package/dist/docs/presentations.d.ts +31 -0
- package/dist/docs/presentations.js +57 -0
- package/dist/docs/registry.d.ts +23 -0
- package/dist/docs/registry.js +51 -0
- package/dist/docs/tech/auth/better-auth-nextjs.docblock.d.ts +6 -0
- package/dist/docs/tech/auth/better-auth-nextjs.docblock.js +81 -0
- package/dist/docs/tech/cli.docblock.d.ts +6 -0
- package/dist/docs/tech/cli.docblock.js +138 -0
- package/dist/docs/tech/contracts/README.docblock.d.ts +6 -0
- package/dist/docs/tech/contracts/README.docblock.js +21 -0
- package/dist/docs/tech/contracts/migrations.docblock.d.ts +6 -0
- package/dist/docs/tech/contracts/migrations.docblock.js +21 -0
- package/dist/docs/tech/contracts/openapi-export.docblock.d.ts +6 -0
- package/dist/docs/tech/contracts/openapi-export.docblock.js +58 -0
- package/dist/docs/tech/contracts/openapi-import.docblock.d.ts +6 -0
- package/dist/docs/tech/contracts/openapi-import.docblock.js +65 -0
- package/dist/docs/tech/contracts/ops-to-presentation-linking.docblock.d.ts +6 -0
- package/dist/docs/tech/contracts/ops-to-presentation-linking.docblock.js +21 -0
- package/dist/docs/tech/contracts/overlays.docblock.d.ts +6 -0
- package/dist/docs/tech/contracts/overlays.docblock.js +21 -0
- package/dist/docs/tech/contracts/tests.docblock.d.ts +6 -0
- package/dist/docs/tech/contracts/tests.docblock.js +21 -0
- package/dist/docs/tech/contracts/themes.docblock.d.ts +6 -0
- package/dist/docs/tech/contracts/themes.docblock.js +21 -0
- package/dist/docs/tech/contracts/vertical-pocket-family-office.docblock.d.ts +6 -0
- package/dist/docs/tech/contracts/vertical-pocket-family-office.docblock.js +126 -0
- package/dist/docs/tech/lifecycle-stage-system.docblock.d.ts +6 -0
- package/dist/docs/tech/lifecycle-stage-system.docblock.js +17 -0
- package/dist/docs/tech/llm/llm-integration.docblock.d.ts +7 -0
- package/dist/docs/tech/llm/llm-integration.docblock.js +358 -0
- package/dist/docs/tech/mcp-endpoints.docblock.d.ts +6 -0
- package/dist/docs/tech/mcp-endpoints.docblock.js +38 -0
- package/dist/docs/tech/presentation-runtime.docblock.d.ts +6 -0
- package/dist/docs/tech/presentation-runtime.docblock.js +17 -0
- package/dist/docs/tech/schema/README.docblock.d.ts +6 -0
- package/dist/docs/tech/schema/README.docblock.js +21 -0
- package/dist/docs/tech/studio/learning-events.docblock.d.ts +6 -0
- package/dist/docs/tech/studio/learning-events.docblock.js +49 -0
- package/dist/docs/tech/studio/learning-journeys.docblock.d.ts +6 -0
- package/dist/docs/tech/studio/learning-journeys.docblock.js +80 -0
- package/dist/docs/tech/studio/platform-admin-panel.docblock.d.ts +6 -0
- package/dist/docs/tech/studio/platform-admin-panel.docblock.js +85 -0
- package/dist/docs/tech/studio/project-access-teams.docblock.d.ts +6 -0
- package/dist/docs/tech/studio/project-access-teams.docblock.js +48 -0
- package/dist/docs/tech/studio/project-routing.docblock.d.ts +6 -0
- package/dist/docs/tech/studio/project-routing.docblock.js +68 -0
- package/dist/docs/tech/studio/sandbox-unlogged.docblock.d.ts +6 -0
- package/dist/docs/tech/studio/sandbox-unlogged.docblock.js +41 -0
- package/dist/docs/tech/studio/team-invitations.docblock.d.ts +6 -0
- package/dist/docs/tech/studio/team-invitations.docblock.js +70 -0
- package/dist/docs/tech/studio/workspace-ops.docblock.d.ts +6 -0
- package/dist/docs/tech/studio/workspace-ops.docblock.js +48 -0
- package/dist/docs/tech/studio/workspaces.docblock.d.ts +6 -0
- package/dist/docs/tech/studio/workspaces.docblock.js +63 -0
- package/dist/docs/tech/telemetry-ingest.docblock.d.ts +6 -0
- package/dist/docs/tech/telemetry-ingest.docblock.js +156 -0
- package/dist/docs/tech/vscode-extension.docblock.d.ts +6 -0
- package/dist/docs/tech/vscode-extension.docblock.js +102 -0
- package/dist/docs/tech-contracts.docs.d.ts +6 -0
- package/dist/docs/tech-contracts.docs.js +96 -0
- package/dist/docs/types.d.ts +41 -0
- package/dist/docs/types.js +0 -0
- package/dist/events.d.ts +47 -0
- package/dist/events.js +19 -0
- package/dist/examples/docs/examples.docblock.d.ts +6 -0
- package/dist/examples/docs/examples.docblock.js +165 -0
- package/dist/examples/index.d.ts +13 -0
- package/dist/examples/index.js +13 -0
- package/dist/examples/registry.d.ts +43 -0
- package/dist/examples/registry.js +88 -0
- package/dist/examples/schema.d.ts +282 -0
- package/dist/examples/schema.js +125 -0
- package/dist/examples/types.d.ts +167 -0
- package/dist/examples/types.js +43 -0
- package/dist/examples/validation.d.ts +65 -0
- package/dist/examples/validation.js +144 -0
- package/dist/experiments/docs/experiments.docblock.d.ts +6 -0
- package/dist/experiments/docs/experiments.docblock.js +21 -0
- package/dist/experiments/evaluator.d.ts +37 -0
- package/dist/experiments/evaluator.js +101 -0
- package/dist/experiments/spec-resolver.d.ts +17 -0
- package/dist/experiments/spec-resolver.js +0 -0
- package/dist/experiments/spec.d.ts +80 -0
- package/dist/experiments/spec.js +15 -0
- package/dist/features/index.d.ts +13 -0
- package/dist/features/index.js +12 -0
- package/dist/features/install.d.ts +22 -0
- package/dist/features/install.js +36 -0
- package/dist/features/registry.d.ts +26 -0
- package/dist/features/registry.js +49 -0
- package/dist/features/types.d.ts +88 -0
- package/dist/features/types.js +0 -0
- package/dist/features/validation.d.ts +8 -0
- package/dist/features/validation.js +14 -0
- package/dist/forms/docs/forms.docblock.d.ts +6 -0
- package/dist/forms/docs/forms.docblock.js +21 -0
- package/dist/forms/forms.d.ts +266 -0
- package/dist/forms/forms.js +143 -0
- package/dist/forms/index.d.ts +2 -0
- package/dist/forms/index.js +3 -0
- package/dist/index.d.ts +154 -0
- package/dist/index.js +132 -0
- package/dist/install.d.ts +77 -0
- package/dist/install.js +40 -0
- package/dist/integrations/binding.d.ts +17 -0
- package/dist/integrations/binding.js +0 -0
- package/dist/integrations/connection.d.ts +51 -0
- package/dist/integrations/connection.js +0 -0
- package/dist/integrations/docs/integrations.docblock.d.ts +6 -0
- package/dist/integrations/docs/integrations.docblock.js +94 -0
- package/dist/integrations/health.d.ts +21 -0
- package/dist/integrations/health.js +69 -0
- package/dist/integrations/index.d.ts +34 -0
- package/dist/integrations/index.js +23 -0
- package/dist/integrations/integrations.capability.d.ts +7 -0
- package/dist/integrations/integrations.capability.js +17 -0
- package/dist/integrations/integrations.feature.d.ts +11 -0
- package/dist/integrations/integrations.feature.js +67 -0
- package/dist/integrations/openbanking/contracts/accounts.d.ts +289 -0
- package/dist/integrations/openbanking/contracts/accounts.js +236 -0
- package/dist/integrations/openbanking/contracts/balances.d.ts +165 -0
- package/dist/integrations/openbanking/contracts/balances.js +166 -0
- package/dist/integrations/openbanking/contracts/index.d.ts +10 -0
- package/dist/integrations/openbanking/contracts/index.js +12 -0
- package/dist/integrations/openbanking/contracts/transactions.d.ts +213 -0
- package/dist/integrations/openbanking/contracts/transactions.js +217 -0
- package/dist/integrations/openbanking/guards.d.ts +12 -0
- package/dist/integrations/openbanking/guards.js +33 -0
- package/dist/integrations/openbanking/models.d.ts +228 -0
- package/dist/integrations/openbanking/models.js +240 -0
- package/dist/integrations/openbanking/openbanking.capability.d.ts +7 -0
- package/dist/integrations/openbanking/openbanking.capability.js +21 -0
- package/dist/integrations/openbanking/openbanking.feature.d.ts +11 -0
- package/dist/integrations/openbanking/openbanking.feature.js +76 -0
- package/dist/integrations/openbanking/telemetry.d.ts +15 -0
- package/dist/integrations/openbanking/telemetry.js +39 -0
- package/dist/integrations/operations.d.ts +437 -0
- package/dist/integrations/operations.js +392 -0
- package/dist/integrations/providers/calendar.d.ts +78 -0
- package/dist/integrations/providers/calendar.js +0 -0
- package/dist/integrations/providers/elevenlabs.d.ts +8 -0
- package/dist/integrations/providers/elevenlabs.js +56 -0
- package/dist/integrations/providers/email.d.ts +86 -0
- package/dist/integrations/providers/email.js +0 -0
- package/dist/integrations/providers/embedding.d.ts +24 -0
- package/dist/integrations/providers/embedding.js +0 -0
- package/dist/integrations/providers/gcs-storage.d.ts +8 -0
- package/dist/integrations/providers/gcs-storage.js +79 -0
- package/dist/integrations/providers/gmail.d.ts +8 -0
- package/dist/integrations/providers/gmail.js +91 -0
- package/dist/integrations/providers/google-calendar.d.ts +8 -0
- package/dist/integrations/providers/google-calendar.js +70 -0
- package/dist/integrations/providers/impls/elevenlabs-voice.d.ts +20 -0
- package/dist/integrations/providers/impls/elevenlabs-voice.js +95 -0
- package/dist/integrations/providers/impls/gcs-storage.d.ts +24 -0
- package/dist/integrations/providers/impls/gcs-storage.js +88 -0
- package/dist/integrations/providers/impls/gmail-inbound.d.ts +26 -0
- package/dist/integrations/providers/impls/gmail-inbound.js +200 -0
- package/dist/integrations/providers/impls/gmail-outbound.d.ts +18 -0
- package/dist/integrations/providers/impls/gmail-outbound.js +105 -0
- package/dist/integrations/providers/impls/google-calendar.d.ts +23 -0
- package/dist/integrations/providers/impls/google-calendar.js +154 -0
- package/dist/integrations/providers/impls/index.d.ts +15 -0
- package/dist/integrations/providers/impls/index.js +16 -0
- package/dist/integrations/providers/impls/mistral-embedding.d.ts +23 -0
- package/dist/integrations/providers/impls/mistral-embedding.js +41 -0
- package/dist/integrations/providers/impls/mistral-llm.d.ts +31 -0
- package/dist/integrations/providers/impls/mistral-llm.js +247 -0
- package/dist/integrations/providers/impls/postmark-email.d.ts +19 -0
- package/dist/integrations/providers/impls/postmark-email.js +55 -0
- package/dist/integrations/providers/impls/powens-client.d.ts +124 -0
- package/dist/integrations/providers/impls/powens-client.js +171 -0
- package/dist/integrations/providers/impls/powens-openbanking.d.ts +27 -0
- package/dist/integrations/providers/impls/powens-openbanking.js +218 -0
- package/dist/integrations/providers/impls/provider-factory.d.ts +26 -0
- package/dist/integrations/providers/impls/provider-factory.js +146 -0
- package/dist/integrations/providers/impls/qdrant-vector.d.ts +24 -0
- package/dist/integrations/providers/impls/qdrant-vector.js +69 -0
- package/dist/integrations/providers/impls/stripe-payments.d.ts +28 -0
- package/dist/integrations/providers/impls/stripe-payments.js +202 -0
- package/dist/integrations/providers/impls/twilio-sms.d.ts +20 -0
- package/dist/integrations/providers/impls/twilio-sms.js +58 -0
- package/dist/integrations/providers/index.d.ts +22 -0
- package/dist/integrations/providers/index.js +13 -0
- package/dist/integrations/providers/llm.d.ts +82 -0
- package/dist/integrations/providers/llm.js +0 -0
- package/dist/integrations/providers/mistral.d.ts +8 -0
- package/dist/integrations/providers/mistral.js +72 -0
- package/dist/integrations/providers/openbanking.d.ts +128 -0
- package/dist/integrations/providers/openbanking.js +0 -0
- package/dist/integrations/providers/payments.d.ts +109 -0
- package/dist/integrations/providers/payments.js +0 -0
- package/dist/integrations/providers/postmark.d.ts +8 -0
- package/dist/integrations/providers/postmark.js +72 -0
- package/dist/integrations/providers/powens.d.ts +8 -0
- package/dist/integrations/providers/powens.js +120 -0
- package/dist/integrations/providers/qdrant.d.ts +8 -0
- package/dist/integrations/providers/qdrant.js +77 -0
- package/dist/integrations/providers/registry.d.ts +11 -0
- package/dist/integrations/providers/registry.js +34 -0
- package/dist/integrations/providers/sms.d.ts +34 -0
- package/dist/integrations/providers/sms.js +0 -0
- package/dist/integrations/providers/storage.d.ts +60 -0
- package/dist/integrations/providers/storage.js +0 -0
- package/dist/integrations/providers/stripe.d.ts +8 -0
- package/dist/integrations/providers/stripe.js +87 -0
- package/dist/integrations/providers/twilio-sms.d.ts +8 -0
- package/dist/integrations/providers/twilio-sms.js +65 -0
- package/dist/integrations/providers/vector-store.d.ts +43 -0
- package/dist/integrations/providers/vector-store.js +0 -0
- package/dist/integrations/providers/voice.d.ts +34 -0
- package/dist/integrations/providers/voice.js +0 -0
- package/dist/integrations/runtime.d.ts +99 -0
- package/dist/integrations/runtime.js +186 -0
- package/dist/integrations/secrets/aws-secret-manager.d.ts +31 -0
- package/dist/integrations/secrets/aws-secret-manager.js +231 -0
- package/dist/integrations/secrets/env-secret-provider.d.ts +31 -0
- package/dist/integrations/secrets/env-secret-provider.js +81 -0
- package/dist/integrations/secrets/gcp-secret-manager.d.ts +32 -0
- package/dist/integrations/secrets/gcp-secret-manager.js +229 -0
- package/dist/integrations/secrets/index.d.ts +7 -0
- package/dist/integrations/secrets/index.js +8 -0
- package/dist/integrations/secrets/manager.d.ts +47 -0
- package/dist/integrations/secrets/manager.js +103 -0
- package/dist/integrations/secrets/provider.d.ts +52 -0
- package/dist/integrations/secrets/provider.js +58 -0
- package/dist/integrations/secrets/scaleway-secret-manager.d.ts +38 -0
- package/dist/integrations/secrets/scaleway-secret-manager.js +247 -0
- package/dist/integrations/secrets-types.d.ts +17 -0
- package/dist/integrations/secrets-types.js +0 -0
- package/dist/integrations/spec.d.ts +77 -0
- package/dist/integrations/spec.js +22 -0
- package/dist/jobs/define-job.d.ts +18 -0
- package/dist/jobs/define-job.js +16 -0
- package/dist/jobs/gcp-cloud-tasks.d.ts +41 -0
- package/dist/jobs/gcp-cloud-tasks.js +53 -0
- package/dist/jobs/gcp-pubsub.d.ts +25 -0
- package/dist/jobs/gcp-pubsub.js +39 -0
- package/dist/jobs/handlers/gmail-sync-handler.d.ts +9 -0
- package/dist/jobs/handlers/gmail-sync-handler.js +9 -0
- package/dist/jobs/handlers/index.d.ts +9 -0
- package/dist/jobs/handlers/index.js +12 -0
- package/dist/jobs/handlers/ping-handler.d.ts +10 -0
- package/dist/jobs/handlers/ping-handler.js +15 -0
- package/dist/jobs/handlers/storage-document-handler.d.ts +12 -0
- package/dist/jobs/handlers/storage-document-handler.js +14 -0
- package/dist/jobs/index.d.ts +3 -0
- package/dist/jobs/index.js +4 -0
- package/dist/jobs/memory-queue.d.ts +18 -0
- package/dist/jobs/memory-queue.js +71 -0
- package/dist/jobs/queue.d.ts +131 -0
- package/dist/jobs/queue.js +33 -0
- package/dist/jobs/scaleway-sqs-queue.d.ts +30 -0
- package/dist/jobs/scaleway-sqs-queue.js +153 -0
- package/dist/jsonschema.d.ts +42 -0
- package/dist/jsonschema.js +51 -0
- package/dist/knowledge/binding.d.ts +25 -0
- package/dist/knowledge/binding.js +0 -0
- package/dist/knowledge/docs/knowledge.docblock.d.ts +6 -0
- package/dist/knowledge/docs/knowledge.docblock.js +21 -0
- package/dist/knowledge/index.d.ts +11 -0
- package/dist/knowledge/index.js +10 -0
- package/dist/knowledge/ingestion/document-processor.d.ts +24 -0
- package/dist/knowledge/ingestion/document-processor.js +54 -0
- package/dist/knowledge/ingestion/embedding-service.d.ts +12 -0
- package/dist/knowledge/ingestion/embedding-service.js +25 -0
- package/dist/knowledge/ingestion/gmail-adapter.d.ts +18 -0
- package/dist/knowledge/ingestion/gmail-adapter.js +51 -0
- package/dist/knowledge/ingestion/index.d.ts +6 -0
- package/dist/knowledge/ingestion/index.js +7 -0
- package/dist/knowledge/ingestion/storage-adapter.d.ts +15 -0
- package/dist/knowledge/ingestion/storage-adapter.js +26 -0
- package/dist/knowledge/ingestion/vector-indexer.d.ts +18 -0
- package/dist/knowledge/ingestion/vector-indexer.js +32 -0
- package/dist/knowledge/knowledge.capability.d.ts +7 -0
- package/dist/knowledge/knowledge.capability.js +21 -0
- package/dist/knowledge/knowledge.feature.d.ts +11 -0
- package/dist/knowledge/knowledge.feature.js +68 -0
- package/dist/knowledge/operations.d.ts +318 -0
- package/dist/knowledge/operations.js +321 -0
- package/dist/knowledge/query/index.d.ts +2 -0
- package/dist/knowledge/query/index.js +3 -0
- package/dist/knowledge/query/service.d.ts +29 -0
- package/dist/knowledge/query/service.js +65 -0
- package/dist/knowledge/runtime.d.ts +32 -0
- package/dist/knowledge/runtime.js +49 -0
- package/dist/knowledge/source.d.ts +32 -0
- package/dist/knowledge/source.js +0 -0
- package/dist/knowledge/spaces/email-threads.d.ts +7 -0
- package/dist/knowledge/spaces/email-threads.js +37 -0
- package/dist/knowledge/spaces/financial-docs.d.ts +7 -0
- package/dist/knowledge/spaces/financial-docs.js +37 -0
- package/dist/knowledge/spaces/financial-overview.d.ts +7 -0
- package/dist/knowledge/spaces/financial-overview.js +41 -0
- package/dist/knowledge/spaces/index.d.ts +7 -0
- package/dist/knowledge/spaces/index.js +8 -0
- package/dist/knowledge/spaces/product-canon.d.ts +7 -0
- package/dist/knowledge/spaces/product-canon.js +37 -0
- package/dist/knowledge/spaces/support-faq.d.ts +7 -0
- package/dist/knowledge/spaces/support-faq.js +40 -0
- package/dist/knowledge/spaces/uploaded-docs.d.ts +7 -0
- package/dist/knowledge/spaces/uploaded-docs.js +37 -0
- package/dist/knowledge/spec.d.ts +46 -0
- package/dist/knowledge/spec.js +17 -0
- package/dist/llm/exporters.d.ts +70 -0
- package/dist/llm/exporters.js +542 -0
- package/dist/llm/index.d.ts +4 -0
- package/dist/llm/index.js +4 -0
- package/dist/llm/prompts.d.ts +52 -0
- package/dist/llm/prompts.js +410 -0
- package/dist/llm/types.d.ts +215 -0
- package/dist/llm/types.js +0 -0
- package/dist/markdown.d.ts +22 -0
- package/dist/markdown.js +119 -0
- package/dist/migrations.d.ts +52 -0
- package/dist/migrations.js +31 -0
- package/dist/model-registry.d.ts +13 -0
- package/dist/model-registry.js +33 -0
- package/dist/onboarding-base.d.ts +138 -0
- package/dist/onboarding-base.js +195 -0
- package/dist/openapi.d.ts +31 -0
- package/dist/openapi.js +82 -0
- package/dist/operations/index.d.ts +3 -0
- package/dist/operations/index.js +4 -0
- package/dist/operations/operation.d.ts +186 -0
- package/dist/operations/operation.js +35 -0
- package/dist/operations/registry.d.ts +54 -0
- package/dist/operations/registry.js +176 -0
- package/dist/ownership.d.ts +84 -0
- package/dist/ownership.js +38 -0
- package/dist/policy/docs/policy.docblock.d.ts +6 -0
- package/dist/policy/docs/policy.docblock.js +21 -0
- package/dist/policy/engine.d.ts +40 -0
- package/dist/policy/engine.js +225 -0
- package/dist/policy/index.d.ts +5 -0
- package/dist/policy/index.js +5 -0
- package/dist/policy/opa-adapter.d.ts +45 -0
- package/dist/policy/opa-adapter.js +71 -0
- package/dist/policy/registry.d.ts +9 -0
- package/dist/policy/registry.js +11 -0
- package/dist/policy/spec.d.ts +103 -0
- package/dist/policy/spec.js +0 -0
- package/dist/presentations/docs/presentations-conventions.docblock.d.ts +6 -0
- package/dist/presentations/docs/presentations-conventions.docblock.js +21 -0
- package/dist/presentations/index.d.ts +4 -0
- package/dist/presentations/index.js +5 -0
- package/dist/presentations/presentations.d.ts +50 -0
- package/dist/presentations/presentations.js +7 -0
- package/dist/presentations/registry.d.ts +10 -0
- package/dist/presentations/registry.js +12 -0
- package/dist/presentations/transform-engine.d.ts +66 -0
- package/dist/presentations/transform-engine.js +282 -0
- package/dist/prompt.d.ts +53 -0
- package/dist/prompt.js +10 -0
- package/dist/promptRegistry.d.ts +15 -0
- package/dist/promptRegistry.js +31 -0
- package/dist/regenerator/adapters.d.ts +19 -0
- package/dist/regenerator/adapters.js +0 -0
- package/dist/regenerator/docs/regenerator.docblock.d.ts +6 -0
- package/dist/regenerator/docs/regenerator.docblock.js +21 -0
- package/dist/regenerator/executor.d.ts +70 -0
- package/dist/regenerator/executor.js +86 -0
- package/dist/regenerator/index.d.ts +7 -0
- package/dist/regenerator/index.js +6 -0
- package/dist/regenerator/service.d.ts +33 -0
- package/dist/regenerator/service.js +93 -0
- package/dist/regenerator/sinks.d.ts +26 -0
- package/dist/regenerator/sinks.js +32 -0
- package/dist/regenerator/types.d.ts +107 -0
- package/dist/regenerator/types.js +0 -0
- package/dist/regenerator/utils.d.ts +9 -0
- package/dist/regenerator/utils.js +51 -0
- package/dist/registry-utils.d.ts +106 -0
- package/dist/registry-utils.js +122 -0
- package/dist/registry.d.ts +32 -0
- package/dist/registry.js +61 -0
- package/dist/resources.d.ts +64 -0
- package/dist/resources.js +50 -0
- package/dist/schema-to-markdown.d.ts +54 -0
- package/dist/schema-to-markdown.js +217 -0
- package/dist/server/contracts-adapter-hydration.d.ts +15 -0
- package/dist/server/contracts-adapter-hydration.js +41 -0
- package/dist/server/contracts-adapter-input.d.ts +9 -0
- package/dist/server/contracts-adapter-input.js +83 -0
- package/dist/server/graphql-pothos.d.ts +31 -0
- package/dist/server/graphql-pothos.js +134 -0
- package/dist/server/index.d.ts +9 -0
- package/dist/server/index.js +10 -0
- package/dist/server/mcp/createMcpServer.d.ts +15 -0
- package/dist/server/mcp/createMcpServer.js +27 -0
- package/dist/server/mcp/mcpTypes.d.ts +27 -0
- package/dist/server/mcp/mcpTypes.js +0 -0
- package/dist/server/mcp/registerPresentations.d.ts +7 -0
- package/dist/server/mcp/registerPresentations.js +54 -0
- package/dist/server/mcp/registerPrompts.d.ts +8 -0
- package/dist/server/mcp/registerPrompts.js +41 -0
- package/dist/server/mcp/registerResources.d.ts +8 -0
- package/dist/server/mcp/registerResources.js +35 -0
- package/dist/server/mcp/registerTools.d.ts +8 -0
- package/dist/server/mcp/registerTools.js +22 -0
- package/dist/server/provider-mcp.d.ts +2 -0
- package/dist/server/provider-mcp.js +3 -0
- package/dist/server/rest-elysia.d.ts +40 -0
- package/dist/server/rest-elysia.js +20 -0
- package/dist/server/rest-express.d.ts +16 -0
- package/dist/server/rest-express.js +36 -0
- package/dist/server/rest-generic.d.ts +32 -0
- package/dist/server/rest-generic.js +124 -0
- package/dist/server/rest-next-app.d.ts +35 -0
- package/dist/server/rest-next-app.js +38 -0
- package/dist/server/rest-next-mcp.d.ts +11 -0
- package/dist/server/rest-next-mcp.js +45 -0
- package/dist/server/rest-next-pages.d.ts +9 -0
- package/dist/server/rest-next-pages.js +22 -0
- package/dist/telemetry/anomaly.d.ts +27 -0
- package/dist/telemetry/anomaly.js +48 -0
- package/dist/telemetry/docs/telemetry.docblock.d.ts +6 -0
- package/dist/telemetry/docs/telemetry.docblock.js +21 -0
- package/dist/telemetry/index.d.ts +4 -0
- package/dist/telemetry/index.js +5 -0
- package/dist/telemetry/spec.d.ts +91 -0
- package/dist/telemetry/spec.js +42 -0
- package/dist/telemetry/tracker.d.ts +51 -0
- package/dist/telemetry/tracker.js +76 -0
- package/dist/tests/index.d.ts +3 -0
- package/dist/tests/index.js +4 -0
- package/dist/tests/runner.d.ts +43 -0
- package/dist/tests/runner.js +150 -0
- package/dist/tests/spec.d.ts +82 -0
- package/dist/tests/spec.js +34 -0
- package/dist/themes.d.ts +51 -0
- package/dist/themes.js +17 -0
- package/dist/translations/catalog.d.ts +28 -0
- package/dist/translations/catalog.js +0 -0
- package/dist/translations/tenant.d.ts +15 -0
- package/dist/translations/tenant.js +0 -0
- package/dist/types.d.ts +92 -0
- package/dist/types.js +0 -0
- package/dist/versioning/index.d.ts +3 -0
- package/dist/versioning/index.js +4 -0
- package/dist/versioning/types.d.ts +127 -0
- package/dist/versioning/types.js +24 -0
- package/dist/versioning/utils.d.ts +95 -0
- package/dist/versioning/utils.js +180 -0
- package/dist/workflow/adapters/db-adapter.d.ts +46 -0
- package/dist/workflow/adapters/db-adapter.js +83 -0
- package/dist/workflow/adapters/file-adapter.d.ts +14 -0
- package/dist/workflow/adapters/file-adapter.js +11 -0
- package/dist/workflow/adapters/index.d.ts +4 -0
- package/dist/workflow/adapters/index.js +5 -0
- package/dist/workflow/adapters/memory-store.d.ts +18 -0
- package/dist/workflow/adapters/memory-store.js +58 -0
- package/dist/workflow/expression.d.ts +9 -0
- package/dist/workflow/expression.js +99 -0
- package/dist/workflow/index.d.ts +17 -0
- package/dist/workflow/index.js +16 -0
- package/dist/workflow/overview.docblock.d.ts +6 -0
- package/dist/workflow/overview.docblock.js +21 -0
- package/dist/workflow/runner.d.ts +77 -0
- package/dist/workflow/runner.js +337 -0
- package/dist/workflow/sla-monitor.d.ts +20 -0
- package/dist/workflow/sla-monitor.js +47 -0
- package/dist/workflow/spec.d.ts +93 -0
- package/dist/workflow/spec.js +11 -0
- package/dist/workflow/state.d.ts +35 -0
- package/dist/workflow/state.js +0 -0
- package/dist/workflow/validation.d.ts +29 -0
- package/dist/workflow/validation.js +176 -0
- package/dist/workspace-config/contractsrc-schema.d.ts +1162 -0
- package/dist/workspace-config/contractsrc-schema.js +421 -0
- package/dist/workspace-config/index.d.ts +2 -0
- package/dist/workspace-config/index.js +3 -0
- package/dist/workspace-config/workspace-config.docblock.d.ts +6 -0
- package/dist/workspace-config/workspace-config.docblock.js +45 -0
- package/package.json +618 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { OwnerShipMeta } from "./ownership.js";
|
|
2
|
+
import { GroupKeyFn, RegistryFilter } from "./registry-utils.js";
|
|
3
|
+
import { ContractSpecType } from "./types.js";
|
|
4
|
+
|
|
5
|
+
//#region src/registry.d.ts
|
|
6
|
+
interface AnySpecContract {
|
|
7
|
+
meta: OwnerShipMeta;
|
|
8
|
+
}
|
|
9
|
+
declare const keyOfSpecContract: (spec: AnySpecContract) => string;
|
|
10
|
+
/** In-memory registry for PresentationSpec. */
|
|
11
|
+
declare abstract class SpecContractRegistry<ContractType extends ContractSpecType, SpecContract extends AnySpecContract> {
|
|
12
|
+
protected readonly contractType: ContractType;
|
|
13
|
+
protected items: Map<string, SpecContract>;
|
|
14
|
+
protected constructor(contractType: ContractType, items?: SpecContract[]);
|
|
15
|
+
register(p: SpecContract): this;
|
|
16
|
+
count(): number;
|
|
17
|
+
list(): SpecContract[];
|
|
18
|
+
get(key: string, version?: string): SpecContract | undefined;
|
|
19
|
+
has(key: string, version?: string): boolean;
|
|
20
|
+
/** Filter presentations by criteria. */
|
|
21
|
+
filter(criteria: RegistryFilter): SpecContract[];
|
|
22
|
+
/** List presentations with specific tag. */
|
|
23
|
+
listByTag(tag: string): SpecContract[];
|
|
24
|
+
/** List presentations by owner. */
|
|
25
|
+
listByOwner(owner: string): SpecContract[];
|
|
26
|
+
/** Group presentations by key function. */
|
|
27
|
+
groupBy(keyFn: GroupKeyFn<SpecContract>): Map<string, SpecContract[]>;
|
|
28
|
+
/** Get unique tags from all presentations. */
|
|
29
|
+
getUniqueTags(): string[];
|
|
30
|
+
}
|
|
31
|
+
//#endregion
|
|
32
|
+
export { AnySpecContract, SpecContractRegistry, keyOfSpecContract };
|
package/dist/registry.js
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { filterBy, getUniqueTags, groupBy, init_registry_utils } from "./registry-utils.js";
|
|
2
|
+
import { compareVersions } from "compare-versions";
|
|
3
|
+
|
|
4
|
+
//#region src/registry.ts
|
|
5
|
+
init_registry_utils();
|
|
6
|
+
const keyOfSpecContract = (spec) => `${spec.meta.key}.v${spec.meta.version}`;
|
|
7
|
+
/** In-memory registry for PresentationSpec. */
|
|
8
|
+
var SpecContractRegistry = class {
|
|
9
|
+
items = /* @__PURE__ */ new Map();
|
|
10
|
+
constructor(contractType, items) {
|
|
11
|
+
this.contractType = contractType;
|
|
12
|
+
if (items) items.forEach((p) => this.register(p));
|
|
13
|
+
}
|
|
14
|
+
register(p) {
|
|
15
|
+
const key = keyOfSpecContract(p);
|
|
16
|
+
if (this.items.has(key)) throw new Error(`Duplicate contract \`${this.contractType}\` ${key}`);
|
|
17
|
+
this.items.set(key, p);
|
|
18
|
+
return this;
|
|
19
|
+
}
|
|
20
|
+
count() {
|
|
21
|
+
return this.items.size;
|
|
22
|
+
}
|
|
23
|
+
list() {
|
|
24
|
+
return [...this.items.values()];
|
|
25
|
+
}
|
|
26
|
+
get(key, version) {
|
|
27
|
+
if (version != null) return this.items.get(`${key}.v${version}`);
|
|
28
|
+
let candidate;
|
|
29
|
+
for (const [k, p] of this.items.entries()) {
|
|
30
|
+
if (!k.startsWith(`${key}.v`)) continue;
|
|
31
|
+
if (!candidate || compareVersions(p.meta.version, candidate.meta.version) > 0) candidate = p;
|
|
32
|
+
}
|
|
33
|
+
return candidate;
|
|
34
|
+
}
|
|
35
|
+
has(key, version) {
|
|
36
|
+
return !!this.get(key, version);
|
|
37
|
+
}
|
|
38
|
+
/** Filter presentations by criteria. */
|
|
39
|
+
filter(criteria) {
|
|
40
|
+
return filterBy(this.list(), criteria);
|
|
41
|
+
}
|
|
42
|
+
/** List presentations with specific tag. */
|
|
43
|
+
listByTag(tag) {
|
|
44
|
+
return this.list().filter((p) => p.meta.tags?.includes(tag));
|
|
45
|
+
}
|
|
46
|
+
/** List presentations by owner. */
|
|
47
|
+
listByOwner(owner) {
|
|
48
|
+
return this.list().filter((p) => p.meta.owners?.includes(owner));
|
|
49
|
+
}
|
|
50
|
+
/** Group presentations by key function. */
|
|
51
|
+
groupBy(keyFn) {
|
|
52
|
+
return groupBy(this.list(), keyFn);
|
|
53
|
+
}
|
|
54
|
+
/** Get unique tags from all presentations. */
|
|
55
|
+
getUniqueTags() {
|
|
56
|
+
return getUniqueTags(this.list());
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
//#endregion
|
|
61
|
+
export { SpecContractRegistry, keyOfSpecContract };
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { Tag } from "./ownership.js";
|
|
2
|
+
import * as z$2 from "zod";
|
|
3
|
+
|
|
4
|
+
//#region src/resources.d.ts
|
|
5
|
+
interface ResourceMeta {
|
|
6
|
+
/** URI scheme, e.g. "content://doc/{id}" or "marketplace://offers/{city}/{tag}" */
|
|
7
|
+
uriTemplate: string;
|
|
8
|
+
/** Human title for discovery */
|
|
9
|
+
title: string;
|
|
10
|
+
/** Short description */
|
|
11
|
+
description?: string;
|
|
12
|
+
/** MIME type for resource body */
|
|
13
|
+
mimeType: string;
|
|
14
|
+
/** Tags for filtering/grouping */
|
|
15
|
+
tags?: Tag[];
|
|
16
|
+
}
|
|
17
|
+
interface ResourceTemplateSpec<I extends z$2.ZodType> {
|
|
18
|
+
meta: ResourceMeta;
|
|
19
|
+
/** Arguments to materialize the URI (zod validates input) */
|
|
20
|
+
input: I;
|
|
21
|
+
/**
|
|
22
|
+
* Resolve returns the resource body and a resolved URI.
|
|
23
|
+
* It MUST be read-only (no side effects).
|
|
24
|
+
*/
|
|
25
|
+
resolve: (args: z$2.infer<I>, ctx: {
|
|
26
|
+
userId?: string | null;
|
|
27
|
+
orgId?: string | null;
|
|
28
|
+
locale?: string;
|
|
29
|
+
}) => Promise<{
|
|
30
|
+
uri: string;
|
|
31
|
+
mimeType?: string;
|
|
32
|
+
data: Uint8Array | string;
|
|
33
|
+
}>;
|
|
34
|
+
}
|
|
35
|
+
declare function defineResourceTemplate<I extends z$2.ZodType>(spec: ResourceTemplateSpec<I>): ResourceTemplateSpec<I>;
|
|
36
|
+
declare class ResourceRegistry {
|
|
37
|
+
private templates;
|
|
38
|
+
register<I extends z$2.ZodType>(tmpl: ResourceTemplateSpec<I>): this;
|
|
39
|
+
listTemplates(): ResourceTemplateSpec<any>[];
|
|
40
|
+
/** Try to match a concrete URI to a template by naive pattern substitution */
|
|
41
|
+
match(uri: string): {
|
|
42
|
+
tmpl: ResourceTemplateSpec<any>;
|
|
43
|
+
params: Record<string, string>;
|
|
44
|
+
} | undefined;
|
|
45
|
+
}
|
|
46
|
+
interface ResourceRefDescriptor<Many extends boolean> {
|
|
47
|
+
kind: 'resource_ref';
|
|
48
|
+
/** URI template, e.g. 'strit://spot/{id}' */
|
|
49
|
+
uriTemplate: string;
|
|
50
|
+
/** Variable name inside result payload to substitute into template; defaults to 'id' */
|
|
51
|
+
varName?: string;
|
|
52
|
+
/** Optional GraphQL type name to use when exposing over GraphQL (e.g., 'Spot') */
|
|
53
|
+
graphQLType: string;
|
|
54
|
+
/** Cardinality: when present and true, the handler returns an array of resources */
|
|
55
|
+
many: Many;
|
|
56
|
+
}
|
|
57
|
+
declare function resourceRef<Many extends boolean>(uriTemplate: string, opts: {
|
|
58
|
+
varName?: string;
|
|
59
|
+
graphQLType: string;
|
|
60
|
+
many: Many;
|
|
61
|
+
}): ResourceRefDescriptor<Many>;
|
|
62
|
+
declare function isResourceRef(x: unknown): x is ResourceRefDescriptor<boolean>;
|
|
63
|
+
//#endregion
|
|
64
|
+
export { ResourceMeta, ResourceRefDescriptor, ResourceRegistry, ResourceTemplateSpec, defineResourceTemplate, isResourceRef, resourceRef };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import "zod";
|
|
2
|
+
|
|
3
|
+
//#region src/resources.ts
|
|
4
|
+
function defineResourceTemplate(spec) {
|
|
5
|
+
return spec;
|
|
6
|
+
}
|
|
7
|
+
var ResourceRegistry = class {
|
|
8
|
+
templates = [];
|
|
9
|
+
register(tmpl) {
|
|
10
|
+
this.templates.push(tmpl);
|
|
11
|
+
return this;
|
|
12
|
+
}
|
|
13
|
+
listTemplates() {
|
|
14
|
+
return [...this.templates];
|
|
15
|
+
}
|
|
16
|
+
/** Try to match a concrete URI to a template by naive pattern substitution */
|
|
17
|
+
match(uri) {
|
|
18
|
+
for (const tmpl of this.templates) {
|
|
19
|
+
const re = /* @__PURE__ */ new RegExp("^" + tmpl.meta.uriTemplate.replace(/\{[^}]+\}/g, "([^/]+)") + "$");
|
|
20
|
+
const m = uri.match(re);
|
|
21
|
+
if (!m) continue;
|
|
22
|
+
const names = [...tmpl.meta.uriTemplate.matchAll(/\{([^}]+)\}/g)].map((x) => x[1]);
|
|
23
|
+
const params = {};
|
|
24
|
+
names.forEach((n, i) => {
|
|
25
|
+
const val = m[i + 1];
|
|
26
|
+
if (n && val) params[n] = decodeURIComponent(val);
|
|
27
|
+
});
|
|
28
|
+
return {
|
|
29
|
+
tmpl,
|
|
30
|
+
params
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
function resourceRef(uriTemplate, opts) {
|
|
36
|
+
return {
|
|
37
|
+
kind: "resource_ref",
|
|
38
|
+
uriTemplate,
|
|
39
|
+
varName: opts.varName ?? "id",
|
|
40
|
+
graphQLType: opts.graphQLType,
|
|
41
|
+
many: opts.many
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
function isResourceRef(x) {
|
|
45
|
+
const o = x;
|
|
46
|
+
return !!o && o.kind === "resource_ref" && typeof o.uriTemplate === "string";
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
//#endregion
|
|
50
|
+
export { ResourceRegistry, defineResourceTemplate, isResourceRef, resourceRef };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { AnySchemaModel } from "@contractspec/lib.schema";
|
|
2
|
+
|
|
3
|
+
//#region src/schema-to-markdown.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Options for schema-to-markdown generation
|
|
7
|
+
*/
|
|
8
|
+
interface SchemaMarkdownOptions {
|
|
9
|
+
/** Title for the markdown section */
|
|
10
|
+
title?: string;
|
|
11
|
+
/** Description to include below the title */
|
|
12
|
+
description?: string;
|
|
13
|
+
/** Output format: table for lists, list for simple items, detail for single objects */
|
|
14
|
+
format?: 'table' | 'list' | 'detail' | 'auto';
|
|
15
|
+
/** Maximum number of items to render (for arrays) */
|
|
16
|
+
maxItems?: number;
|
|
17
|
+
/** Only include these fields (if not specified, all fields are included) */
|
|
18
|
+
includeFields?: string[];
|
|
19
|
+
/** Exclude these fields from output */
|
|
20
|
+
excludeFields?: string[];
|
|
21
|
+
/** Custom field labels (field name -> display label) */
|
|
22
|
+
fieldLabels?: Record<string, string>;
|
|
23
|
+
/** Fields to use for summary in list format */
|
|
24
|
+
summaryFields?: string[];
|
|
25
|
+
/** Nesting depth for nested schemas (default: 2) */
|
|
26
|
+
maxDepth?: number;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Generate markdown from a SchemaModel and data.
|
|
30
|
+
* Automatically detects array vs object data and formats accordingly.
|
|
31
|
+
*/
|
|
32
|
+
declare function schemaToMarkdown(schema: AnySchemaModel, data: unknown, options?: SchemaMarkdownOptions): string;
|
|
33
|
+
/**
|
|
34
|
+
* Generate a markdown table from array data using schema fields as columns.
|
|
35
|
+
*/
|
|
36
|
+
declare function schemaToMarkdownTable(schema: AnySchemaModel, items: unknown[], options?: SchemaMarkdownOptions): string;
|
|
37
|
+
/**
|
|
38
|
+
* Generate a markdown list from array data.
|
|
39
|
+
* Uses summaryFields to create concise list items.
|
|
40
|
+
*/
|
|
41
|
+
declare function schemaToMarkdownList(schema: AnySchemaModel, items: unknown[], options?: SchemaMarkdownOptions): string;
|
|
42
|
+
/**
|
|
43
|
+
* Generate a markdown detail view (key-value pairs) from object data.
|
|
44
|
+
*/
|
|
45
|
+
declare function schemaToMarkdownDetail(schema: AnySchemaModel, item: unknown, options?: SchemaMarkdownOptions): string;
|
|
46
|
+
/**
|
|
47
|
+
* Generate markdown summary statistics for numeric fields in array data.
|
|
48
|
+
*/
|
|
49
|
+
declare function schemaToMarkdownSummary(items: unknown[], options?: {
|
|
50
|
+
numericFields?: string[];
|
|
51
|
+
countByField?: string;
|
|
52
|
+
}): string;
|
|
53
|
+
//#endregion
|
|
54
|
+
export { SchemaMarkdownOptions, schemaToMarkdown, schemaToMarkdownDetail, schemaToMarkdownList, schemaToMarkdownSummary, schemaToMarkdownTable };
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import { isSchemaModel } from "@contractspec/lib.schema";
|
|
2
|
+
|
|
3
|
+
//#region src/schema-to-markdown.ts
|
|
4
|
+
/**
|
|
5
|
+
* Generate markdown from a SchemaModel and data.
|
|
6
|
+
* Automatically detects array vs object data and formats accordingly.
|
|
7
|
+
*/
|
|
8
|
+
function schemaToMarkdown(schema, data, options = {}) {
|
|
9
|
+
const { format = "auto", title, description, maxDepth = 2 } = options;
|
|
10
|
+
const lines = [];
|
|
11
|
+
if (title) lines.push(`# ${title}`, "");
|
|
12
|
+
if (description) lines.push(`> ${description}`, "");
|
|
13
|
+
const effectiveFormat = format === "auto" ? Array.isArray(data) ? "table" : "detail" : format;
|
|
14
|
+
if (effectiveFormat === "table" && Array.isArray(data)) lines.push(schemaToMarkdownTable(schema, data, options));
|
|
15
|
+
else if (effectiveFormat === "list" && Array.isArray(data)) lines.push(schemaToMarkdownList(schema, data, options));
|
|
16
|
+
else if (!Array.isArray(data) && data !== null && typeof data === "object") lines.push(schemaToMarkdownDetail(schema, data, {
|
|
17
|
+
...options,
|
|
18
|
+
maxDepth
|
|
19
|
+
}));
|
|
20
|
+
else lines.push(`**Data:** ${String(data)}`, "");
|
|
21
|
+
return lines.join("\n");
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Generate a markdown table from array data using schema fields as columns.
|
|
25
|
+
*/
|
|
26
|
+
function schemaToMarkdownTable(schema, items, options = {}) {
|
|
27
|
+
const { maxItems = 100, includeFields, excludeFields = [] } = options;
|
|
28
|
+
const fields = getFieldMeta(schema, includeFields, excludeFields);
|
|
29
|
+
if (fields.length === 0 || items.length === 0) return "_No data available_\n";
|
|
30
|
+
const limitedItems = items.slice(0, maxItems);
|
|
31
|
+
const lines = [];
|
|
32
|
+
const headers = fields.map((f) => f.label);
|
|
33
|
+
lines.push(`| ${headers.join(" | ")} |`);
|
|
34
|
+
lines.push(`| ${headers.map(() => "---").join(" | ")} |`);
|
|
35
|
+
for (const item of limitedItems) {
|
|
36
|
+
const row = fields.map((f) => formatCellValue(getFieldValue(item, f.name)));
|
|
37
|
+
lines.push(`| ${row.join(" | ")} |`);
|
|
38
|
+
}
|
|
39
|
+
if (items.length > maxItems) lines.push("", `_Showing ${maxItems} of ${items.length} items_`);
|
|
40
|
+
lines.push("");
|
|
41
|
+
return lines.join("\n");
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Generate a markdown list from array data.
|
|
45
|
+
* Uses summaryFields to create concise list items.
|
|
46
|
+
*/
|
|
47
|
+
function schemaToMarkdownList(schema, items, options = {}) {
|
|
48
|
+
const { maxItems = 50, summaryFields, includeFields, excludeFields = [] } = options;
|
|
49
|
+
const fields = getFieldMeta(schema, includeFields, excludeFields);
|
|
50
|
+
const displayFields = summaryFields ? fields.filter((f) => summaryFields.includes(f.name)) : fields.slice(0, 3);
|
|
51
|
+
if (displayFields.length === 0 || items.length === 0) return "_No data available_\n";
|
|
52
|
+
const limitedItems = items.slice(0, maxItems);
|
|
53
|
+
const lines = [];
|
|
54
|
+
for (const item of limitedItems) {
|
|
55
|
+
const primaryValue = formatCellValue(getFieldValue(item, displayFields[0]?.name ?? "id"));
|
|
56
|
+
const secondaryValues = displayFields.slice(1).map((f) => `${f.label}: ${formatCellValue(getFieldValue(item, f.name))}`).join(" · ");
|
|
57
|
+
const itemLine = secondaryValues ? `- **${primaryValue}** (${secondaryValues})` : `- **${primaryValue}**`;
|
|
58
|
+
lines.push(itemLine);
|
|
59
|
+
}
|
|
60
|
+
if (items.length > maxItems) lines.push("", `_Showing ${maxItems} of ${items.length} items_`);
|
|
61
|
+
lines.push("");
|
|
62
|
+
return lines.join("\n");
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Generate a markdown detail view (key-value pairs) from object data.
|
|
66
|
+
*/
|
|
67
|
+
function schemaToMarkdownDetail(schema, item, options = {}) {
|
|
68
|
+
const { includeFields, excludeFields = [], maxDepth = 2 } = options;
|
|
69
|
+
if (item === null || typeof item !== "object") return "_No data available_\n";
|
|
70
|
+
const fields = getFieldMeta(schema, includeFields, excludeFields);
|
|
71
|
+
if (fields.length === 0) return "_No fields to display_\n";
|
|
72
|
+
const lines = [];
|
|
73
|
+
for (const field of fields) {
|
|
74
|
+
const formattedValue = formatDetailValue(getFieldValue(item, field.name), maxDepth, 0);
|
|
75
|
+
lines.push(`**${field.label}:** ${formattedValue}`);
|
|
76
|
+
}
|
|
77
|
+
lines.push("");
|
|
78
|
+
return lines.join("\n");
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Generate markdown summary statistics for numeric fields in array data.
|
|
82
|
+
*/
|
|
83
|
+
function schemaToMarkdownSummary(items, options = {}) {
|
|
84
|
+
const { numericFields = [], countByField } = options;
|
|
85
|
+
const lines = [];
|
|
86
|
+
lines.push(`**Total Items:** ${items.length}`);
|
|
87
|
+
for (const fieldName of numericFields) {
|
|
88
|
+
const values = items.map((item) => getFieldValue(item, fieldName)).filter((v) => typeof v === "number");
|
|
89
|
+
if (values.length > 0) {
|
|
90
|
+
const sum = values.reduce((a, b) => a + b, 0);
|
|
91
|
+
const avg = sum / values.length;
|
|
92
|
+
const min = Math.min(...values);
|
|
93
|
+
const max = Math.max(...values);
|
|
94
|
+
lines.push(`**${formatFieldName(fieldName)}:** Sum: ${formatNumber(sum)}, Avg: ${formatNumber(avg)}, Min: ${formatNumber(min)}, Max: ${formatNumber(max)}`);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
if (countByField) {
|
|
98
|
+
const counts = {};
|
|
99
|
+
for (const item of items) {
|
|
100
|
+
const value = String(getFieldValue(item, countByField) ?? "Unknown");
|
|
101
|
+
counts[value] = (counts[value] ?? 0) + 1;
|
|
102
|
+
}
|
|
103
|
+
lines.push("", `**By ${formatFieldName(countByField)}:**`);
|
|
104
|
+
for (const [value, count] of Object.entries(counts)) lines.push(`- ${value}: ${count}`);
|
|
105
|
+
}
|
|
106
|
+
lines.push("");
|
|
107
|
+
return lines.join("\n");
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Get field metadata from schema, applying include/exclude filters
|
|
111
|
+
*/
|
|
112
|
+
function getFieldMeta(schema, includeFields, excludeFields = []) {
|
|
113
|
+
if (!isSchemaModel(schema)) return [];
|
|
114
|
+
const schemaFields = schema.config.fields;
|
|
115
|
+
return Object.keys(schemaFields).filter((name) => {
|
|
116
|
+
if (excludeFields.includes(name)) return false;
|
|
117
|
+
if (includeFields && !includeFields.includes(name)) return false;
|
|
118
|
+
return true;
|
|
119
|
+
}).map((name) => {
|
|
120
|
+
const fieldConfig = schemaFields[name];
|
|
121
|
+
const isNested = Boolean(fieldConfig?.type && typeof fieldConfig.type === "object" && "config" in fieldConfig.type && typeof fieldConfig.type.config?.fields === "object");
|
|
122
|
+
return {
|
|
123
|
+
name,
|
|
124
|
+
label: formatFieldName(name),
|
|
125
|
+
isOptional: fieldConfig?.isOptional ?? false,
|
|
126
|
+
isArray: fieldConfig?.isArray === true,
|
|
127
|
+
isNested
|
|
128
|
+
};
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Get value from object by field name (supports nested paths)
|
|
133
|
+
*/
|
|
134
|
+
function getFieldValue(item, fieldName) {
|
|
135
|
+
if (item === null || typeof item !== "object") return void 0;
|
|
136
|
+
const obj = item;
|
|
137
|
+
if (fieldName.includes(".")) {
|
|
138
|
+
const parts = fieldName.split(".");
|
|
139
|
+
let current = obj;
|
|
140
|
+
for (const part of parts) {
|
|
141
|
+
if (current === null || typeof current !== "object") return void 0;
|
|
142
|
+
current = current[part];
|
|
143
|
+
}
|
|
144
|
+
return current;
|
|
145
|
+
}
|
|
146
|
+
return obj[fieldName];
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Format a value for table cell display
|
|
150
|
+
*/
|
|
151
|
+
function formatCellValue(value) {
|
|
152
|
+
if (value === null || value === void 0) return "-";
|
|
153
|
+
if (typeof value === "boolean") return value ? "✓" : "✗";
|
|
154
|
+
if (typeof value === "number") return formatNumber(value);
|
|
155
|
+
if (value instanceof Date) return formatDate(value);
|
|
156
|
+
if (typeof value === "string" && isISODate(value)) return formatDate(new Date(value));
|
|
157
|
+
if (Array.isArray(value)) return `[${value.length} items]`;
|
|
158
|
+
if (typeof value === "object") return "[Object]";
|
|
159
|
+
const str = String(value);
|
|
160
|
+
return str.length > 50 ? `${str.slice(0, 47)}...` : str.replace(/\|/g, "\\|");
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Format a value for detail view (allows more space)
|
|
164
|
+
*/
|
|
165
|
+
function formatDetailValue(value, maxDepth, currentDepth) {
|
|
166
|
+
if (value === null || value === void 0) return "_none_";
|
|
167
|
+
if (typeof value === "boolean") return value ? "Yes" : "No";
|
|
168
|
+
if (typeof value === "number") return formatNumber(value);
|
|
169
|
+
if (value instanceof Date) return formatDate(value);
|
|
170
|
+
if (typeof value === "string" && isISODate(value)) return formatDate(new Date(value));
|
|
171
|
+
if (Array.isArray(value)) {
|
|
172
|
+
if (value.length === 0) return "_empty list_";
|
|
173
|
+
if (currentDepth >= maxDepth) return `[${value.length} items]`;
|
|
174
|
+
if (value.length <= 5 && value.every((v) => typeof v !== "object")) return value.map((v) => formatCellValue(v)).join(", ");
|
|
175
|
+
return `[${value.length} items]`;
|
|
176
|
+
}
|
|
177
|
+
if (typeof value === "object") {
|
|
178
|
+
if (currentDepth >= maxDepth) return "[Object]";
|
|
179
|
+
return `{${Object.keys(value).length} fields}`;
|
|
180
|
+
}
|
|
181
|
+
return String(value);
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Format field name to human-readable label
|
|
185
|
+
*/
|
|
186
|
+
function formatFieldName(name) {
|
|
187
|
+
return name.replace(/([a-z])([A-Z])/g, "$1 $2").replace(/_/g, " ").replace(/^\w/, (c) => c.toUpperCase());
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Format number with locale-aware formatting
|
|
191
|
+
*/
|
|
192
|
+
function formatNumber(value) {
|
|
193
|
+
if (Math.abs(value) >= 1e3) return new Intl.NumberFormat("en-US", { maximumFractionDigits: 2 }).format(value);
|
|
194
|
+
if (Number.isInteger(value)) return String(value);
|
|
195
|
+
return value.toFixed(2);
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Format date to readable string
|
|
199
|
+
*/
|
|
200
|
+
function formatDate(date) {
|
|
201
|
+
return date.toLocaleDateString("en-US", {
|
|
202
|
+
year: "numeric",
|
|
203
|
+
month: "short",
|
|
204
|
+
day: "numeric"
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Check if string is ISO date format
|
|
209
|
+
*/
|
|
210
|
+
function isISODate(str) {
|
|
211
|
+
if (!/^\d{4}-\d{2}-\d{2}/.test(str)) return false;
|
|
212
|
+
const date = new Date(str);
|
|
213
|
+
return !isNaN(date.getTime());
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
//#endregion
|
|
217
|
+
export { schemaToMarkdown, schemaToMarkdownDetail, schemaToMarkdownList, schemaToMarkdownSummary, schemaToMarkdownTable };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ResourceRegistry } from "../resources.js";
|
|
2
|
+
|
|
3
|
+
//#region src/server/contracts-adapter-hydration.d.ts
|
|
4
|
+
interface ReturnsDecl {
|
|
5
|
+
isList: boolean;
|
|
6
|
+
inner: string;
|
|
7
|
+
}
|
|
8
|
+
declare function parseReturns(returnsLike: string): ReturnsDecl;
|
|
9
|
+
declare function hydrateResourceIfNeeded(resources: ResourceRegistry | undefined, result: unknown, opts: {
|
|
10
|
+
template?: string;
|
|
11
|
+
varName?: string;
|
|
12
|
+
returns: ReturnsDecl;
|
|
13
|
+
}): Promise<unknown>;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { ReturnsDecl, hydrateResourceIfNeeded, parseReturns };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
//#region src/server/contracts-adapter-hydration.ts
|
|
2
|
+
function parseReturns(returnsLike) {
|
|
3
|
+
if (!returnsLike) return {
|
|
4
|
+
isList: false,
|
|
5
|
+
inner: "JSON"
|
|
6
|
+
};
|
|
7
|
+
const trimmed = String(returnsLike).trim();
|
|
8
|
+
if (trimmed.startsWith("[") && trimmed.endsWith("]")) return {
|
|
9
|
+
isList: true,
|
|
10
|
+
inner: trimmed.slice(1, -1).trim()
|
|
11
|
+
};
|
|
12
|
+
return {
|
|
13
|
+
isList: false,
|
|
14
|
+
inner: trimmed
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
async function hydrateResourceIfNeeded(resources, result, opts) {
|
|
18
|
+
if (!resources || !opts.template) return result;
|
|
19
|
+
const varName = opts.varName ?? "id";
|
|
20
|
+
const hydrateOne = async (item) => {
|
|
21
|
+
if (item && typeof item === "object" && varName in item) {
|
|
22
|
+
const key = String(item[varName]);
|
|
23
|
+
const uri = (opts.template ?? "").replace("{id}", key);
|
|
24
|
+
const match = resources.match(uri);
|
|
25
|
+
if (match) {
|
|
26
|
+
const resolved = await match.tmpl.resolve(match.params, {});
|
|
27
|
+
try {
|
|
28
|
+
return JSON.parse(String(resolved.data || "null"));
|
|
29
|
+
} catch {
|
|
30
|
+
return resolved.data;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return item;
|
|
35
|
+
};
|
|
36
|
+
if (opts.returns.isList && Array.isArray(result)) return await Promise.all(result.map((x) => hydrateOne(x)));
|
|
37
|
+
return await hydrateOne(result);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
//#endregion
|
|
41
|
+
export { hydrateResourceIfNeeded, parseReturns };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AnySchemaModel } from "@contractspec/lib.schema";
|
|
2
|
+
import { SchemaTypes } from "@pothos/core";
|
|
3
|
+
|
|
4
|
+
//#region src/server/contracts-adapter-input.d.ts
|
|
5
|
+
declare function createInputTypeBuilder<T extends SchemaTypes>(builder: PothosSchemaTypes.SchemaBuilder<T>): {
|
|
6
|
+
buildInputFieldArgs: (model: AnySchemaModel | null) => null;
|
|
7
|
+
};
|
|
8
|
+
//#endregion
|
|
9
|
+
export { createInputTypeBuilder };
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { isSchemaModel } from "@contractspec/lib.schema";
|
|
2
|
+
|
|
3
|
+
//#region src/server/contracts-adapter-input.ts
|
|
4
|
+
function isFieldType(x) {
|
|
5
|
+
return typeof x?.getPothos === "function";
|
|
6
|
+
}
|
|
7
|
+
function isEnumType(x) {
|
|
8
|
+
return typeof x?.getEnumValues === "function" && typeof x?.getPothos === "function";
|
|
9
|
+
}
|
|
10
|
+
function mapScalarName(name) {
|
|
11
|
+
if (name === "Boolean_unsecure") return "Boolean";
|
|
12
|
+
if (name === "ID_unsecure") return "ID";
|
|
13
|
+
if (name === "String_unsecure") return "String";
|
|
14
|
+
if (name === "Int_unsecure") return "Int";
|
|
15
|
+
if (name === "Float_unsecure") return "Float";
|
|
16
|
+
return name;
|
|
17
|
+
}
|
|
18
|
+
function createInputTypeBuilder(builder) {
|
|
19
|
+
const inputTypeCache = /* @__PURE__ */ new Map();
|
|
20
|
+
const enumTypeCache = /* @__PURE__ */ new Set();
|
|
21
|
+
function registerEnumsForModel(model) {
|
|
22
|
+
const entries = Object.entries(model.config.fields);
|
|
23
|
+
for (const [, field] of entries) {
|
|
24
|
+
const fieldType = field.type;
|
|
25
|
+
if (isSchemaModel(fieldType)) registerEnumsForModel(fieldType);
|
|
26
|
+
else if (isEnumType(field.type)) {
|
|
27
|
+
const enumObj = field.type;
|
|
28
|
+
const name = enumObj.getName?.() ?? enumObj.getPothos().name;
|
|
29
|
+
if (!enumTypeCache.has(name)) {
|
|
30
|
+
builder.enumType(name, { values: enumObj.getEnumValues() });
|
|
31
|
+
enumTypeCache.add(name);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function ensureInputTypeForModel(model) {
|
|
37
|
+
const typeName = String(model.config?.name ?? "Input");
|
|
38
|
+
const cached = inputTypeCache.get(typeName);
|
|
39
|
+
if (cached) return cached;
|
|
40
|
+
registerEnumsForModel(model);
|
|
41
|
+
const created = builder.inputType(model.getPothosInput(), { fields: (t) => {
|
|
42
|
+
const entries = Object.entries(model.config.fields);
|
|
43
|
+
const acc = {};
|
|
44
|
+
for (const [key, field] of entries) {
|
|
45
|
+
const fieldType = field.type;
|
|
46
|
+
if (isSchemaModel(fieldType)) {
|
|
47
|
+
const nested = ensureInputTypeForModel(fieldType);
|
|
48
|
+
const typeRef = field.isArray ? [nested] : nested;
|
|
49
|
+
acc[key] = t.field({
|
|
50
|
+
type: typeRef,
|
|
51
|
+
required: !field.isOptional
|
|
52
|
+
});
|
|
53
|
+
} else if (isFieldType(field.type)) {
|
|
54
|
+
const typeName$1 = mapScalarName(String(field.type.getPothos().name));
|
|
55
|
+
const typeRef = field.isArray ? [typeName$1] : typeName$1;
|
|
56
|
+
acc[key] = t.field({
|
|
57
|
+
type: typeRef,
|
|
58
|
+
required: !field.isOptional
|
|
59
|
+
});
|
|
60
|
+
} else {
|
|
61
|
+
const typeRef = field.isArray ? ["JSON"] : "JSON";
|
|
62
|
+
acc[key] = t.field({
|
|
63
|
+
type: typeRef,
|
|
64
|
+
required: !field.isOptional
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return acc;
|
|
69
|
+
} });
|
|
70
|
+
inputTypeCache.set(typeName, created);
|
|
71
|
+
return created;
|
|
72
|
+
}
|
|
73
|
+
function buildInputFieldArgs(model) {
|
|
74
|
+
if (!model) return null;
|
|
75
|
+
if (!isSchemaModel(model)) return null;
|
|
76
|
+
if (!model.config?.fields || Object.keys(model.config.fields).length === 0) return null;
|
|
77
|
+
return ensureInputTypeForModel(model);
|
|
78
|
+
}
|
|
79
|
+
return { buildInputFieldArgs };
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
//#endregion
|
|
83
|
+
export { createInputTypeBuilder };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ResourceRegistry } from "../resources.js";
|
|
2
|
+
import { OperationSpecRegistry } from "../operations/registry.js";
|
|
3
|
+
import "@pothos/plugin-prisma";
|
|
4
|
+
import "@pothos/plugin-complexity";
|
|
5
|
+
import "@pothos/plugin-relay";
|
|
6
|
+
import "@pothos/plugin-dataloader";
|
|
7
|
+
import "@pothos/plugin-tracing";
|
|
8
|
+
import { SchemaTypes } from "@pothos/core";
|
|
9
|
+
|
|
10
|
+
//#region src/server/graphql-pothos.d.ts
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Registers all ContractSpecs from a OperationSpecRegistry onto a Pothos SchemaBuilder.
|
|
14
|
+
*
|
|
15
|
+
* This adapter:
|
|
16
|
+
* 1. Discovers output types from specs and registers them as Pothos object types.
|
|
17
|
+
* 2. Maps `ContractSpec` (OperationSpec) inputs to Pothos input types.
|
|
18
|
+
* 3. Mounts `query` specs as `Query` fields and `command` specs as `Mutation` fields.
|
|
19
|
+
* 4. Wraps the resolver to:
|
|
20
|
+
* - Enforce auth policies (basic check).
|
|
21
|
+
* - Build a `HandlerCtx`.
|
|
22
|
+
* - Execute via `OperationSpecRegistry`.
|
|
23
|
+
* - Hydrate resource references if applicable.
|
|
24
|
+
*
|
|
25
|
+
* @param builder - The Pothos SchemaBuilder instance.
|
|
26
|
+
* @param reg - The OperationSpecRegistry containing operations.
|
|
27
|
+
* @param resources - (Optional) ResourceRegistry for hydrating resource references.
|
|
28
|
+
*/
|
|
29
|
+
declare function registerContractsOnBuilder<T extends SchemaTypes>(builder: PothosSchemaTypes.SchemaBuilder<T>, reg: OperationSpecRegistry, resources?: ResourceRegistry): void;
|
|
30
|
+
//#endregion
|
|
31
|
+
export { registerContractsOnBuilder };
|