@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,225 @@
|
|
|
1
|
+
import "./registry.js";
|
|
2
|
+
|
|
3
|
+
//#region src/policy/engine.ts
|
|
4
|
+
var PolicyEngine = class {
|
|
5
|
+
constructor(registry) {
|
|
6
|
+
this.registry = registry;
|
|
7
|
+
}
|
|
8
|
+
decide(input) {
|
|
9
|
+
const policies = this.resolvePolicies(input.policies);
|
|
10
|
+
let allowReason;
|
|
11
|
+
let appliedRateLimit;
|
|
12
|
+
let escalate;
|
|
13
|
+
for (const policy of policies) {
|
|
14
|
+
const match = this.matchRuleSet(policy, input);
|
|
15
|
+
if (!match) continue;
|
|
16
|
+
if (match.rule.effect === "deny") return {
|
|
17
|
+
effect: "deny",
|
|
18
|
+
reason: match.rule.reason ?? policy.meta.key,
|
|
19
|
+
requiredConsents: match.missingConsents.length ? match.missingConsents : void 0,
|
|
20
|
+
evaluatedBy: "engine"
|
|
21
|
+
};
|
|
22
|
+
if (match.rule.effect === "allow") {
|
|
23
|
+
if (match.missingConsents.length) return {
|
|
24
|
+
effect: "deny",
|
|
25
|
+
reason: "consent_required",
|
|
26
|
+
requiredConsents: match.missingConsents,
|
|
27
|
+
evaluatedBy: "engine"
|
|
28
|
+
};
|
|
29
|
+
if (!allowReason) allowReason = match.rule.reason ?? policy.meta.key;
|
|
30
|
+
if (!appliedRateLimit && match.rateLimit) appliedRateLimit = match.rateLimit;
|
|
31
|
+
if (!escalate && match.rule.escalate) escalate = match.rule.escalate;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
const fieldDecisions = this.evaluateFields(policies, input);
|
|
35
|
+
const pii = policies.find((p) => p.pii)?.pii;
|
|
36
|
+
return {
|
|
37
|
+
effect: allowReason ? "allow" : "deny",
|
|
38
|
+
reason: allowReason,
|
|
39
|
+
rateLimit: appliedRateLimit,
|
|
40
|
+
escalate: typeof escalate === "undefined" ? void 0 : escalate,
|
|
41
|
+
fieldDecisions: fieldDecisions.length ? fieldDecisions : void 0,
|
|
42
|
+
pii,
|
|
43
|
+
evaluatedBy: "engine"
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
resolvePolicies(refs) {
|
|
47
|
+
const specs = [];
|
|
48
|
+
for (const ref of refs) {
|
|
49
|
+
const spec = this.registry.get(ref.key, ref.version);
|
|
50
|
+
if (!spec) throw new Error(`PolicyEngine: policy not found ${ref.key}.v${ref.version}`);
|
|
51
|
+
specs.push(spec);
|
|
52
|
+
}
|
|
53
|
+
return specs;
|
|
54
|
+
}
|
|
55
|
+
matchRuleSet(policy, input) {
|
|
56
|
+
let allowMatch;
|
|
57
|
+
for (const rule of policy.rules) {
|
|
58
|
+
if (!rule.actions.includes(input.action)) continue;
|
|
59
|
+
if (!matchesSubject(rule, input.subject)) continue;
|
|
60
|
+
if (!matchesResource(rule, input.resource)) continue;
|
|
61
|
+
if (!matchesFlags(rule, input)) continue;
|
|
62
|
+
if (!matchesRelationships(rule.relationships, input)) continue;
|
|
63
|
+
if (!matchesConditions(rule, input)) continue;
|
|
64
|
+
const evaluation = {
|
|
65
|
+
rule,
|
|
66
|
+
missingConsents: collectMissingConsents(rule, policy, input),
|
|
67
|
+
rateLimit: resolveRateLimit(rule, policy, input)
|
|
68
|
+
};
|
|
69
|
+
if (rule.effect === "deny") return evaluation;
|
|
70
|
+
if (rule.effect === "allow" && !allowMatch) allowMatch = evaluation;
|
|
71
|
+
}
|
|
72
|
+
return allowMatch;
|
|
73
|
+
}
|
|
74
|
+
evaluateFields(policies, input) {
|
|
75
|
+
const out = /* @__PURE__ */ new Map();
|
|
76
|
+
for (const policy of policies) {
|
|
77
|
+
if (!policy.fieldPolicies) continue;
|
|
78
|
+
for (const rule of policy.fieldPolicies) {
|
|
79
|
+
if (!rule.actions.includes(mapActionToFieldAction(input.action))) continue;
|
|
80
|
+
if (!matchesSubject(rule, input.subject)) continue;
|
|
81
|
+
if (!matchesResource(rule, input.resource)) continue;
|
|
82
|
+
if (!matchesConditions(rule, input)) continue;
|
|
83
|
+
const existing = out.get(rule.field);
|
|
84
|
+
if (rule.effect === "deny") out.set(rule.field, {
|
|
85
|
+
field: rule.field,
|
|
86
|
+
effect: "deny",
|
|
87
|
+
reason: rule.reason ?? policy.meta.key
|
|
88
|
+
});
|
|
89
|
+
else if (!existing) out.set(rule.field, {
|
|
90
|
+
field: rule.field,
|
|
91
|
+
effect: "allow",
|
|
92
|
+
reason: rule.reason ?? policy.meta.key
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return [...out.values()];
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
function mapActionToFieldAction(action) {
|
|
100
|
+
if (action.startsWith("write")) return "write";
|
|
101
|
+
return "read";
|
|
102
|
+
}
|
|
103
|
+
function matchesSubject(rule, subject) {
|
|
104
|
+
const matcher = rule.subject;
|
|
105
|
+
if (!matcher) return true;
|
|
106
|
+
if (matcher.roles?.length) {
|
|
107
|
+
const roles = subject.roles ?? [];
|
|
108
|
+
if (!matcher.roles.some((role) => roles.includes(role))) return false;
|
|
109
|
+
}
|
|
110
|
+
if (matcher.attributes) {
|
|
111
|
+
const attributes = subject.attributes ?? {};
|
|
112
|
+
if (!matchAttributes(matcher.attributes, attributes)) return false;
|
|
113
|
+
}
|
|
114
|
+
return true;
|
|
115
|
+
}
|
|
116
|
+
function matchesResource(rule, resource) {
|
|
117
|
+
const matcher = rule.resource;
|
|
118
|
+
if (!matcher) return true;
|
|
119
|
+
if (matcher.type && matcher.type !== resource.type) return false;
|
|
120
|
+
if (matcher.fields?.length) {
|
|
121
|
+
const targetFields = resource.fields ?? [];
|
|
122
|
+
if (!matcher.fields.some((field) => targetFields.includes(field))) return false;
|
|
123
|
+
}
|
|
124
|
+
if (matcher.attributes) {
|
|
125
|
+
const attributes = resource.attributes ?? {};
|
|
126
|
+
if (!matchAttributes(matcher.attributes, attributes)) return false;
|
|
127
|
+
}
|
|
128
|
+
return true;
|
|
129
|
+
}
|
|
130
|
+
function matchesFlags(rule, input) {
|
|
131
|
+
if (!rule.flags?.length) return true;
|
|
132
|
+
const available = /* @__PURE__ */ new Set();
|
|
133
|
+
if (input.flags) for (const flag of input.flags) available.add(flag);
|
|
134
|
+
const attributeFlags = input.subject.attributes?.featureFlags;
|
|
135
|
+
if (Array.isArray(attributeFlags)) for (const flag of attributeFlags) available.add(flag);
|
|
136
|
+
return rule.flags.every((flag) => available.has(flag));
|
|
137
|
+
}
|
|
138
|
+
function matchesRelationships(matchers, input) {
|
|
139
|
+
if (!matchers || matchers.length === 0) return true;
|
|
140
|
+
const relationships = input.subject.relationships ?? [];
|
|
141
|
+
const resourceId = getResourceId(input.resource);
|
|
142
|
+
const resourceType = input.resource.type;
|
|
143
|
+
return matchers.every((matcher) => relationships.some((relation) => {
|
|
144
|
+
if (relation.relation !== matcher.relation) return false;
|
|
145
|
+
if (!(!matcher.objectType || relation.objectType === matcher.objectType || matcher.objectType === resourceType)) return false;
|
|
146
|
+
if (!matcher.objectId) return true;
|
|
147
|
+
if (matcher.objectId === "$resource") {
|
|
148
|
+
if (resourceId) return relation.object === resourceId;
|
|
149
|
+
return relation.object === resourceType || relation.objectType === resourceType;
|
|
150
|
+
}
|
|
151
|
+
return relation.object === matcher.objectId;
|
|
152
|
+
}));
|
|
153
|
+
}
|
|
154
|
+
function matchesConditions(rule, input) {
|
|
155
|
+
if (!rule.conditions || rule.conditions.length === 0) return true;
|
|
156
|
+
return rule.conditions.every((condition) => evaluateCondition(condition.expression, input));
|
|
157
|
+
}
|
|
158
|
+
function matchAttributes(matcher, actual) {
|
|
159
|
+
for (const [key, attrMatcher] of Object.entries(matcher)) {
|
|
160
|
+
const value = actual[key];
|
|
161
|
+
if (attrMatcher.exists && typeof value === "undefined") return false;
|
|
162
|
+
if (typeof attrMatcher.equals !== "undefined") {
|
|
163
|
+
if (value !== attrMatcher.equals) return false;
|
|
164
|
+
}
|
|
165
|
+
if (attrMatcher.oneOf && !attrMatcher.oneOf.includes(value)) return false;
|
|
166
|
+
}
|
|
167
|
+
return true;
|
|
168
|
+
}
|
|
169
|
+
function collectMissingConsents(rule, policy, input) {
|
|
170
|
+
if (!rule.requiresConsent?.length) return [];
|
|
171
|
+
const granted = new Set(input.consents ?? []);
|
|
172
|
+
const missingIds = rule.requiresConsent.filter((id) => !granted.has(id));
|
|
173
|
+
if (missingIds.length === 0) return [];
|
|
174
|
+
return resolveConsentDefinitions(policy, missingIds);
|
|
175
|
+
}
|
|
176
|
+
function resolveConsentDefinitions(policy, ids) {
|
|
177
|
+
const catalog = policy.consents ?? [];
|
|
178
|
+
return ids.map((id) => {
|
|
179
|
+
return catalog.find((consent) => consent.id === id) ?? {
|
|
180
|
+
id,
|
|
181
|
+
scope: "unspecified",
|
|
182
|
+
purpose: "unspecified",
|
|
183
|
+
description: `Consent "${id}" required by ${policy.meta.key}`,
|
|
184
|
+
required: true
|
|
185
|
+
};
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
function resolveRateLimit(rule, policy, input) {
|
|
189
|
+
if (!rule.rateLimit) return void 0;
|
|
190
|
+
const definition = typeof rule.rateLimit === "string" ? (policy.rateLimits ?? []).find((item) => item.id === rule.rateLimit) : rule.rateLimit;
|
|
191
|
+
if (!definition) throw new Error(`PolicyEngine: rate limit "${String(rule.rateLimit)}" not declared in ${policy.meta.key}`);
|
|
192
|
+
return {
|
|
193
|
+
rpm: definition.rpm,
|
|
194
|
+
key: definition.key ?? input.resource.type,
|
|
195
|
+
windowSeconds: definition.windowSeconds,
|
|
196
|
+
burst: definition.burst
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
function evaluateCondition(expression, input) {
|
|
200
|
+
const trimmed = expression.trim();
|
|
201
|
+
if (!trimmed) return true;
|
|
202
|
+
const context = {
|
|
203
|
+
subject: input.subject,
|
|
204
|
+
resource: input.resource,
|
|
205
|
+
context: input.context ?? {}
|
|
206
|
+
};
|
|
207
|
+
try {
|
|
208
|
+
const result = new Function("subject", "resource", "context", `return (${transformExpression(trimmed)});`)(context.subject, context.resource, context.context);
|
|
209
|
+
return Boolean(result);
|
|
210
|
+
} catch (_error) {
|
|
211
|
+
return false;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
function transformExpression(expression) {
|
|
215
|
+
return expression.replace(/&&/g, "&&").replace(/\|\|/g, "||");
|
|
216
|
+
}
|
|
217
|
+
function getResourceId(resource) {
|
|
218
|
+
if (resource.id) return resource.id;
|
|
219
|
+
const candidate = resource.attributes?.id;
|
|
220
|
+
if (typeof candidate === "string") return candidate;
|
|
221
|
+
if (typeof candidate === "number") return String(candidate);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
//#endregion
|
|
225
|
+
export { PolicyEngine };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { AttributeMatcher, ConsentDefinition, FieldPolicyRule, PIIPolicy, PolicyCondition, PolicyEffect, PolicyMeta, PolicyOPAConfig, PolicyRef, PolicyRule, PolicySpec, RateLimitDefinition, RelationshipDefinition, RelationshipMatcher, ResourceMatcher, SubjectMatcher } from "./spec.js";
|
|
2
|
+
import { PolicyRegistry } from "./registry.js";
|
|
3
|
+
import { DecisionContext, PolicyEngine, ResourceContext, SubjectContext, SubjectRelationship } from "./engine.js";
|
|
4
|
+
import { OPAAdapterOptions, OPAClient, OPAEvaluationResult, OPAPolicyAdapter, buildOPAInput } from "./opa-adapter.js";
|
|
5
|
+
export { AttributeMatcher, ConsentDefinition, DecisionContext, FieldPolicyRule, OPAAdapterOptions, OPAClient, OPAEvaluationResult, OPAPolicyAdapter, PIIPolicy, PolicyCondition, PolicyEffect, PolicyEngine, PolicyMeta, PolicyOPAConfig, PolicyRef, PolicyRegistry, PolicyRule, PolicySpec, RateLimitDefinition, RelationshipDefinition, RelationshipMatcher, ResourceContext, ResourceMatcher, SubjectContext, SubjectMatcher, SubjectRelationship, buildOPAInput };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { ConsentDefinition, FieldPolicyRule, PIIPolicy, PolicyMeta, PolicyRule, PolicySpec, RateLimitDefinition, RelationshipDefinition } from "./spec.js";
|
|
2
|
+
import { PolicyDecision } from "../types.js";
|
|
3
|
+
import { DecisionContext } from "./engine.js";
|
|
4
|
+
|
|
5
|
+
//#region src/policy/opa-adapter.d.ts
|
|
6
|
+
interface OPAClient {
|
|
7
|
+
evaluate<T>(decisionPath: string, input: unknown): Promise<T>;
|
|
8
|
+
}
|
|
9
|
+
interface OPAEvaluationResult {
|
|
10
|
+
effect?: 'allow' | 'deny';
|
|
11
|
+
reason?: string;
|
|
12
|
+
fieldDecisions?: PolicyDecision['fieldDecisions'];
|
|
13
|
+
requiredConsents?: string[];
|
|
14
|
+
}
|
|
15
|
+
interface OPAAdapterOptions<Result = OPAEvaluationResult | null> {
|
|
16
|
+
/**
|
|
17
|
+
* Path fed to the OPA client (e.g., "sigil/authz/allow").
|
|
18
|
+
*/
|
|
19
|
+
decisionPath: string;
|
|
20
|
+
/**
|
|
21
|
+
* Optional mapper when the OPA client returns a non-standard payload.
|
|
22
|
+
*/
|
|
23
|
+
mapResult?: (value: unknown) => Result;
|
|
24
|
+
}
|
|
25
|
+
declare class OPAPolicyAdapter<Result = OPAEvaluationResult | null> {
|
|
26
|
+
private readonly client;
|
|
27
|
+
private readonly options;
|
|
28
|
+
constructor(client: OPAClient, options: OPAAdapterOptions<Result>);
|
|
29
|
+
evaluate(context: DecisionContext, policies: PolicySpec[], engineDecision: PolicyDecision): Promise<PolicyDecision>;
|
|
30
|
+
}
|
|
31
|
+
declare function buildOPAInput(context: DecisionContext, policies: PolicySpec[], engineDecision: PolicyDecision): {
|
|
32
|
+
context: DecisionContext;
|
|
33
|
+
decision: PolicyDecision;
|
|
34
|
+
policies: {
|
|
35
|
+
meta: PolicyMeta;
|
|
36
|
+
rules: PolicyRule[];
|
|
37
|
+
fieldPolicies: FieldPolicyRule[] | undefined;
|
|
38
|
+
pii: PIIPolicy | undefined;
|
|
39
|
+
relationships: RelationshipDefinition[] | undefined;
|
|
40
|
+
consents: ConsentDefinition[] | undefined;
|
|
41
|
+
rateLimits: RateLimitDefinition[] | undefined;
|
|
42
|
+
}[];
|
|
43
|
+
};
|
|
44
|
+
//#endregion
|
|
45
|
+
export { OPAAdapterOptions, OPAClient, OPAEvaluationResult, OPAPolicyAdapter, buildOPAInput };
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
//#region src/policy/opa-adapter.ts
|
|
2
|
+
var OPAPolicyAdapter = class {
|
|
3
|
+
constructor(client, options) {
|
|
4
|
+
this.client = client;
|
|
5
|
+
this.options = options;
|
|
6
|
+
}
|
|
7
|
+
async evaluate(context, policies, engineDecision) {
|
|
8
|
+
const input = buildOPAInput(context, policies, engineDecision);
|
|
9
|
+
const raw = await this.client.evaluate(this.options.decisionPath, input);
|
|
10
|
+
const resolved = this.options.mapResult ? this.options.mapResult(raw) : raw;
|
|
11
|
+
if (!resolved) return {
|
|
12
|
+
...engineDecision,
|
|
13
|
+
evaluatedBy: engineDecision.evaluatedBy ?? "engine"
|
|
14
|
+
};
|
|
15
|
+
const opaResult = resolved;
|
|
16
|
+
const mergedRequiredConsents = mergeRequiredConsents(policies, engineDecision.requiredConsents ?? [], opaResult.requiredConsents ?? []);
|
|
17
|
+
return {
|
|
18
|
+
...engineDecision,
|
|
19
|
+
effect: opaResult.effect ?? engineDecision.effect,
|
|
20
|
+
reason: opaResult.reason ?? engineDecision.reason,
|
|
21
|
+
fieldDecisions: opaResult.fieldDecisions ?? engineDecision.fieldDecisions,
|
|
22
|
+
requiredConsents: mergedRequiredConsents.length ? mergedRequiredConsents : void 0,
|
|
23
|
+
evaluatedBy: "opa"
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
function buildOPAInput(context, policies, engineDecision) {
|
|
28
|
+
return {
|
|
29
|
+
context,
|
|
30
|
+
decision: engineDecision,
|
|
31
|
+
policies: policies.map((policy) => ({
|
|
32
|
+
meta: policy.meta,
|
|
33
|
+
rules: policy.rules,
|
|
34
|
+
fieldPolicies: policy.fieldPolicies,
|
|
35
|
+
pii: policy.pii,
|
|
36
|
+
relationships: policy.relationships,
|
|
37
|
+
consents: policy.consents,
|
|
38
|
+
rateLimits: policy.rateLimits
|
|
39
|
+
}))
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
function mergeRequiredConsents(policies, existing, incomingIds) {
|
|
43
|
+
if (incomingIds.length === 0) return existing;
|
|
44
|
+
const existingIds = new Set(existing.map((consent) => consent.id));
|
|
45
|
+
const merged = [...existing];
|
|
46
|
+
for (const id of incomingIds) {
|
|
47
|
+
if (existingIds.has(id)) continue;
|
|
48
|
+
const resolved = resolveConsentAcrossPolicies(policies, id);
|
|
49
|
+
if (resolved) {
|
|
50
|
+
merged.push(resolved);
|
|
51
|
+
existingIds.add(resolved.id);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return merged;
|
|
55
|
+
}
|
|
56
|
+
function resolveConsentAcrossPolicies(policies, id) {
|
|
57
|
+
for (const policy of policies) {
|
|
58
|
+
const match = policy.consents?.find((consent) => consent.id === id);
|
|
59
|
+
if (match) return match;
|
|
60
|
+
}
|
|
61
|
+
return {
|
|
62
|
+
id,
|
|
63
|
+
scope: "unspecified",
|
|
64
|
+
purpose: "unspecified",
|
|
65
|
+
description: `Consent "${id}" returned by OPA`,
|
|
66
|
+
required: true
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
//#endregion
|
|
71
|
+
export { OPAPolicyAdapter, buildOPAInput };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { PolicySpec } from "./spec.js";
|
|
2
|
+
import { SpecContractRegistry } from "../registry.js";
|
|
3
|
+
|
|
4
|
+
//#region src/policy/registry.d.ts
|
|
5
|
+
declare class PolicyRegistry extends SpecContractRegistry<'policy', PolicySpec> {
|
|
6
|
+
constructor(items?: PolicySpec[]);
|
|
7
|
+
}
|
|
8
|
+
//#endregion
|
|
9
|
+
export { PolicyRegistry };
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { OwnerShipMeta } from "../ownership.js";
|
|
2
|
+
|
|
3
|
+
//#region src/policy/spec.d.ts
|
|
4
|
+
type PolicyEffect = 'allow' | 'deny';
|
|
5
|
+
interface RelationshipDefinition {
|
|
6
|
+
subjectType: string;
|
|
7
|
+
relation: string;
|
|
8
|
+
objectType: string;
|
|
9
|
+
description?: string;
|
|
10
|
+
transitive?: boolean;
|
|
11
|
+
}
|
|
12
|
+
interface RelationshipMatcher {
|
|
13
|
+
relation: string;
|
|
14
|
+
objectType?: string;
|
|
15
|
+
objectId?: string;
|
|
16
|
+
}
|
|
17
|
+
interface ConsentDefinition {
|
|
18
|
+
id: string;
|
|
19
|
+
scope: string;
|
|
20
|
+
purpose: string;
|
|
21
|
+
description?: string;
|
|
22
|
+
lawfulBasis?: 'consent' | 'contract' | 'legal_obligation' | 'legitimate_interest';
|
|
23
|
+
expiresInDays?: number;
|
|
24
|
+
required?: boolean;
|
|
25
|
+
}
|
|
26
|
+
interface RateLimitDefinition {
|
|
27
|
+
id: string;
|
|
28
|
+
rpm: number;
|
|
29
|
+
key?: string;
|
|
30
|
+
windowSeconds?: number;
|
|
31
|
+
burst?: number;
|
|
32
|
+
}
|
|
33
|
+
interface PolicyOPAConfig {
|
|
34
|
+
/** Fully-qualified package, e.g. "sigil.authz" */
|
|
35
|
+
package: string;
|
|
36
|
+
/** Optional rule within package (defaults to "allow") */
|
|
37
|
+
decision?: string;
|
|
38
|
+
}
|
|
39
|
+
interface PolicyMeta extends OwnerShipMeta {
|
|
40
|
+
/** Optional scope hint used for discovery. */
|
|
41
|
+
scope?: 'global' | 'feature' | 'operation';
|
|
42
|
+
}
|
|
43
|
+
interface AttributeMatcher {
|
|
44
|
+
equals?: unknown;
|
|
45
|
+
oneOf?: unknown[];
|
|
46
|
+
exists?: boolean;
|
|
47
|
+
}
|
|
48
|
+
interface SubjectMatcher {
|
|
49
|
+
roles?: string[];
|
|
50
|
+
attributes?: Record<string, AttributeMatcher>;
|
|
51
|
+
}
|
|
52
|
+
interface ResourceMatcher {
|
|
53
|
+
type: string;
|
|
54
|
+
fields?: string[];
|
|
55
|
+
attributes?: Record<string, AttributeMatcher>;
|
|
56
|
+
}
|
|
57
|
+
interface PolicyCondition {
|
|
58
|
+
/** Simple expression evaluated against { subject, resource, context }. */
|
|
59
|
+
expression: string;
|
|
60
|
+
}
|
|
61
|
+
interface PolicyRule {
|
|
62
|
+
effect: PolicyEffect;
|
|
63
|
+
actions: string[];
|
|
64
|
+
subject?: SubjectMatcher;
|
|
65
|
+
resource?: ResourceMatcher;
|
|
66
|
+
relationships?: RelationshipMatcher[];
|
|
67
|
+
requiresConsent?: string[];
|
|
68
|
+
flags?: string[];
|
|
69
|
+
rateLimit?: string | RateLimitDefinition;
|
|
70
|
+
escalate?: 'human_review' | null;
|
|
71
|
+
conditions?: PolicyCondition[];
|
|
72
|
+
reason?: string;
|
|
73
|
+
}
|
|
74
|
+
interface FieldPolicyRule {
|
|
75
|
+
effect: PolicyEffect;
|
|
76
|
+
field: string;
|
|
77
|
+
actions: ('read' | 'write')[];
|
|
78
|
+
subject?: SubjectMatcher;
|
|
79
|
+
resource?: ResourceMatcher;
|
|
80
|
+
conditions?: PolicyCondition[];
|
|
81
|
+
reason?: string;
|
|
82
|
+
}
|
|
83
|
+
interface PIIPolicy {
|
|
84
|
+
fields: string[];
|
|
85
|
+
consentRequired?: boolean;
|
|
86
|
+
retentionDays?: number;
|
|
87
|
+
}
|
|
88
|
+
interface PolicySpec {
|
|
89
|
+
meta: PolicyMeta;
|
|
90
|
+
rules: PolicyRule[];
|
|
91
|
+
fieldPolicies?: FieldPolicyRule[];
|
|
92
|
+
pii?: PIIPolicy;
|
|
93
|
+
relationships?: RelationshipDefinition[];
|
|
94
|
+
consents?: ConsentDefinition[];
|
|
95
|
+
rateLimits?: RateLimitDefinition[];
|
|
96
|
+
opa?: PolicyOPAConfig;
|
|
97
|
+
}
|
|
98
|
+
interface PolicyRef {
|
|
99
|
+
key: string;
|
|
100
|
+
version: string;
|
|
101
|
+
}
|
|
102
|
+
//#endregion
|
|
103
|
+
export { AttributeMatcher, ConsentDefinition, FieldPolicyRule, PIIPolicy, PolicyCondition, PolicyEffect, PolicyMeta, PolicyOPAConfig, PolicyRef, PolicyRule, PolicySpec, RateLimitDefinition, RelationshipDefinition, RelationshipMatcher, ResourceMatcher, SubjectMatcher };
|
|
File without changes
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { DocBlock } from "@contractspec/lib.contracts/docs";
|
|
2
|
+
|
|
3
|
+
//#region src/presentations/docs/presentations-conventions.docblock.d.ts
|
|
4
|
+
declare const tech_contracts_presentations_conventions_DocBlocks: DocBlock[];
|
|
5
|
+
//#endregion
|
|
6
|
+
export { tech_contracts_presentations_conventions_DocBlocks };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { registerDocBlocks } from "../../docs/registry.js";
|
|
2
|
+
|
|
3
|
+
//#region src/presentations/docs/presentations-conventions.docblock.ts
|
|
4
|
+
const tech_contracts_presentations_conventions_DocBlocks = [{
|
|
5
|
+
id: "docs.tech.contracts.presentations-conventions",
|
|
6
|
+
title: "Presentations Conventions (A11y & i18n)",
|
|
7
|
+
summary: "- Always provide `meta.description` (≥ 3 chars) — used by a11y/docs/agents.",
|
|
8
|
+
kind: "reference",
|
|
9
|
+
visibility: "public",
|
|
10
|
+
route: "/docs/tech/contracts/presentations-conventions",
|
|
11
|
+
tags: [
|
|
12
|
+
"tech",
|
|
13
|
+
"contracts",
|
|
14
|
+
"presentations-conventions"
|
|
15
|
+
],
|
|
16
|
+
body: "## Presentations Conventions (A11y & i18n)\n\n- Always provide `meta.description` (≥ 3 chars) — used by a11y/docs/agents.\n- Prefer source = BlockNote for rich guides; use component key for interactive flows.\n- i18n strings belong in host apps; descriptors carry keys/defaults only.\n- Target selection: include only what you intend to support to avoid drift.\n- PII: declare JSON-like paths under `policy.pii`; engine redacts in outputs.\n"
|
|
17
|
+
}];
|
|
18
|
+
registerDocBlocks(tech_contracts_presentations_conventions_DocBlocks);
|
|
19
|
+
|
|
20
|
+
//#endregion
|
|
21
|
+
export { tech_contracts_presentations_conventions_DocBlocks };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { PresentationSource, PresentationSourceBlocknotejs, PresentationSourceComponentReact, PresentationSpec, PresentationSpecMeta, PresentationTarget, definePresentation } from "./presentations.js";
|
|
2
|
+
import { ComponentMap, PresentationRenderer, PresentationValidator, ReactRenderDescriptor, RenderContext, TransformEngine, createDefaultTransformEngine, registerBasicValidation, registerDefaultReactRenderer, registerReactToMarkdownRenderer } from "./transform-engine.js";
|
|
3
|
+
import { PresentationRegistry } from "./registry.js";
|
|
4
|
+
export { ComponentMap, PresentationRegistry, PresentationRenderer, PresentationSource, PresentationSourceBlocknotejs, PresentationSourceComponentReact, PresentationSpec, PresentationSpecMeta, PresentationTarget, PresentationValidator, ReactRenderDescriptor, RenderContext, TransformEngine, createDefaultTransformEngine, definePresentation, registerBasicValidation, registerDefaultReactRenderer, registerReactToMarkdownRenderer };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { TransformEngine, createDefaultTransformEngine, registerBasicValidation, registerDefaultReactRenderer, registerReactToMarkdownRenderer } from "./transform-engine.js";
|
|
2
|
+
import { definePresentation } from "./presentations.js";
|
|
3
|
+
import { PresentationRegistry } from "./registry.js";
|
|
4
|
+
|
|
5
|
+
export { PresentationRegistry, TransformEngine, createDefaultTransformEngine, definePresentation, registerBasicValidation, registerDefaultReactRenderer, registerReactToMarkdownRenderer };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { OwnerShipMeta } from "../ownership.js";
|
|
2
|
+
import { AnySchemaModel } from "@contractspec/lib.schema";
|
|
3
|
+
import { BlockConfig } from "@blocknote/core";
|
|
4
|
+
|
|
5
|
+
//#region src/presentations/presentations.d.ts
|
|
6
|
+
/** Supported render targets for the transform engine and descriptors. */
|
|
7
|
+
type PresentationTarget = 'react' | 'markdown' | 'application/json' | 'application/xml';
|
|
8
|
+
interface PresentationSpecMeta extends OwnerShipMeta {
|
|
9
|
+
/** Business goal: why this exists */
|
|
10
|
+
goal: string;
|
|
11
|
+
/** Background, constraints, scope edges (feeds docs & LLM context) */
|
|
12
|
+
context: string;
|
|
13
|
+
}
|
|
14
|
+
/** React component presentation source. */
|
|
15
|
+
interface PresentationSourceComponentReact {
|
|
16
|
+
/** Source marker for React component presentations. */
|
|
17
|
+
type: 'component';
|
|
18
|
+
/** Framework for the component source (currently only 'react'). */
|
|
19
|
+
framework: 'react';
|
|
20
|
+
/** Component key resolved by host `componentMap`. */
|
|
21
|
+
componentKey: string;
|
|
22
|
+
/** Optional props schema to validate against. */
|
|
23
|
+
props?: AnySchemaModel;
|
|
24
|
+
}
|
|
25
|
+
/** BlockNoteJS document presentation source. */
|
|
26
|
+
interface PresentationSourceBlocknotejs {
|
|
27
|
+
/** Source marker for BlockNoteJS document presentations. */
|
|
28
|
+
type: 'blocknotejs';
|
|
29
|
+
/** BlockNoteJS JSON document. */
|
|
30
|
+
docJson: unknown;
|
|
31
|
+
/** Optional BlockNote config to guide rendering. */
|
|
32
|
+
blockConfig?: BlockConfig;
|
|
33
|
+
}
|
|
34
|
+
type PresentationSource = PresentationSourceComponentReact | PresentationSourceBlocknotejs;
|
|
35
|
+
/**
|
|
36
|
+
* Normalized presentation spec decoupled from framework/adapters.
|
|
37
|
+
* Renderers and validators are provided via TransformEngine.
|
|
38
|
+
*/
|
|
39
|
+
interface PresentationSpec {
|
|
40
|
+
meta: PresentationSpecMeta;
|
|
41
|
+
policy?: {
|
|
42
|
+
flags?: string[];
|
|
43
|
+
pii?: string[];
|
|
44
|
+
};
|
|
45
|
+
source: PresentationSource;
|
|
46
|
+
targets: PresentationTarget[];
|
|
47
|
+
}
|
|
48
|
+
declare const definePresentation: (spec: PresentationSpec) => PresentationSpec;
|
|
49
|
+
//#endregion
|
|
50
|
+
export { PresentationSource, PresentationSourceBlocknotejs, PresentationSourceComponentReact, PresentationSpec, PresentationSpecMeta, PresentationTarget, definePresentation };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { PresentationSpec } from "./presentations.js";
|
|
2
|
+
import { SpecContractRegistry } from "../registry.js";
|
|
3
|
+
|
|
4
|
+
//#region src/presentations/registry.d.ts
|
|
5
|
+
/** In-memory registry for PresentationSpec. */
|
|
6
|
+
declare class PresentationRegistry extends SpecContractRegistry<'presentation', PresentationSpec> {
|
|
7
|
+
constructor(items?: PresentationSpec[]);
|
|
8
|
+
}
|
|
9
|
+
//#endregion
|
|
10
|
+
export { PresentationRegistry };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { SpecContractRegistry } from "../registry.js";
|
|
2
|
+
|
|
3
|
+
//#region src/presentations/registry.ts
|
|
4
|
+
/** In-memory registry for PresentationSpec. */
|
|
5
|
+
var PresentationRegistry = class extends SpecContractRegistry {
|
|
6
|
+
constructor(items) {
|
|
7
|
+
super("presentation", items);
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
//#endregion
|
|
12
|
+
export { PresentationRegistry };
|