@contractspec/lib.contracts-spec 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/dist/app-config/app-config.capability.d.ts +1 -0
- package/dist/app-config/app-config.capability.js +730 -0
- package/dist/app-config/app-config.contracts.d.ts +239 -0
- package/dist/app-config/app-config.contracts.js +713 -0
- package/dist/app-config/app-config.contracts.test.d.ts +1 -0
- package/dist/app-config/app-config.feature.d.ts +5 -0
- package/dist/app-config/app-config.feature.js +255 -0
- package/dist/app-config/branding.d.ts +52 -0
- package/dist/app-config/branding.js +1 -0
- package/dist/app-config/branding.test.d.ts +1 -0
- package/dist/app-config/docs/app-config.docblock.d.ts +2 -0
- package/dist/app-config/docs/app-config.docblock.js +383 -0
- package/dist/app-config/events.d.ts +115 -0
- package/dist/app-config/events.js +386 -0
- package/dist/app-config/events.test.d.ts +1 -0
- package/dist/app-config/index.d.ts +9 -0
- package/dist/app-config/index.js +2899 -0
- package/dist/app-config/lifecycle-contracts.d.ts +265 -0
- package/dist/app-config/lifecycle-contracts.js +870 -0
- package/dist/app-config/lifecycle-contracts.test.d.ts +1 -0
- package/dist/app-config/lifecycle.d.ts +23 -0
- package/dist/app-config/lifecycle.js +1 -0
- package/dist/app-config/lifecycle.test.d.ts +1 -0
- package/dist/app-config/runtime.d.ts +111 -0
- package/dist/app-config/runtime.js +734 -0
- package/dist/app-config/runtime.test.d.ts +1 -0
- package/dist/app-config/spec.d.ts +169 -0
- package/dist/app-config/spec.js +229 -0
- package/dist/app-config/spec.test.d.ts +1 -0
- package/dist/app-config/validation.d.ts +43 -0
- package/dist/app-config/validation.js +650 -0
- package/dist/app-config/validation.test.d.ts +1 -0
- package/dist/capabilities/capabilities.d.ts +96 -0
- package/dist/capabilities/capabilities.js +217 -0
- package/dist/capabilities/capabilities.test.d.ts +1 -0
- package/dist/capabilities/context.d.ts +110 -0
- package/dist/capabilities/context.js +101 -0
- package/dist/capabilities/context.test.d.ts +1 -0
- package/dist/capabilities/docs/capabilities.docblock.d.ts +2 -0
- package/dist/capabilities/docs/capabilities.docblock.js +353 -0
- package/dist/capabilities/guards.d.ts +121 -0
- package/dist/capabilities/guards.js +177 -0
- package/dist/capabilities/index.d.ts +6 -0
- package/dist/capabilities/index.js +739 -0
- package/dist/capabilities/meeting-recorder.d.ts +5 -0
- package/dist/capabilities/meeting-recorder.js +154 -0
- package/dist/capabilities/openbanking.d.ts +5 -0
- package/dist/capabilities/openbanking.js +166 -0
- package/dist/capabilities/validation.d.ts +79 -0
- package/dist/capabilities/validation.js +185 -0
- package/dist/capabilities/validation.test.d.ts +1 -0
- package/dist/contract-registry/index.d.ts +3 -0
- package/dist/contract-registry/index.js +129 -0
- package/dist/contract-registry/schemas.d.ts +120 -0
- package/dist/contract-registry/schemas.js +129 -0
- package/dist/contract-registry/schemas.test.d.ts +1 -0
- package/dist/contract-registry/types.d.ts +42 -0
- package/dist/contract-registry/types.js +1 -0
- package/dist/data-views/data-views.d.ts +4 -0
- package/dist/data-views/data-views.js +232 -0
- package/dist/data-views/data-views.test.d.ts +1 -0
- package/dist/data-views/docs/data-views.docblock.d.ts +2 -0
- package/dist/data-views/docs/data-views.docblock.js +164 -0
- package/dist/data-views/index.d.ts +4 -0
- package/dist/data-views/index.js +232 -0
- package/dist/data-views/query-generator.d.ts +35 -0
- package/dist/data-views/query-generator.js +89 -0
- package/dist/data-views/registry.d.ts +12 -0
- package/dist/data-views/registry.js +226 -0
- package/dist/data-views/registry.test.d.ts +1 -0
- package/dist/data-views/report/contractVerificationTable.d.ts +4 -0
- package/dist/data-views/report/contractVerificationTable.js +240 -0
- package/dist/data-views/report/contractVerificationTable.test.d.ts +1 -0
- package/dist/data-views/runtime.d.ts +25 -0
- package/dist/data-views/runtime.js +108 -0
- package/dist/data-views/runtime.test.d.ts +1 -0
- package/dist/data-views/spec.d.ts +22 -0
- package/dist/data-views/spec.js +38 -0
- package/dist/data-views/spec.test.d.ts +1 -0
- package/dist/data-views/types.d.ts +152 -0
- package/dist/data-views/types.js +1 -0
- package/dist/data-views/types.test.d.ts +1 -0
- package/dist/docs/accessibility_wcag_compliance_specs.docblock.d.ts +2 -0
- package/dist/docs/accessibility_wcag_compliance_specs.docblock.js +513 -0
- package/dist/docs/capabilities/documentationSystem.capability.d.ts +1 -0
- package/dist/docs/capabilities/documentationSystem.capability.js +784 -0
- package/dist/docs/capabilities/index.d.ts +1 -0
- package/dist/docs/capabilities/index.js +784 -0
- package/dist/docs/commands/docsGenerate.command.d.ts +88 -0
- package/dist/docs/commands/docsGenerate.command.js +802 -0
- package/dist/docs/commands/docsPublish.command.d.ts +57 -0
- package/dist/docs/commands/docsPublish.command.js +781 -0
- package/dist/docs/commands/index.d.ts +2 -0
- package/dist/docs/commands/index.js +906 -0
- package/dist/docs/constants.d.ts +4 -0
- package/dist/docs/constants.js +78 -0
- package/dist/docs/contracts.d.ts +430 -0
- package/dist/docs/contracts.js +1611 -0
- package/dist/docs/ensure-docblocks.d.ts +1 -0
- package/dist/docs/ensure-docblocks.js +264 -0
- package/dist/docs/events/docsGenerated.event.d.ts +56 -0
- package/dist/docs/events/docsGenerated.event.js +533 -0
- package/dist/docs/events/docsPublished.event.d.ts +64 -0
- package/dist/docs/events/docsPublished.event.js +534 -0
- package/dist/docs/events/index.d.ts +2 -0
- package/dist/docs/events/index.js +567 -0
- package/dist/docs/forms/docsSearch.form.d.ts +16 -0
- package/dist/docs/forms/docsSearch.form.js +676 -0
- package/dist/docs/forms/index.d.ts +1 -0
- package/dist/docs/forms/index.js +676 -0
- package/dist/docs/index.d.ts +40 -0
- package/dist/docs/index.js +4719 -0
- package/dist/docs/meta.docs.d.ts +2 -0
- package/dist/docs/meta.docs.js +176 -0
- package/dist/docs/presentations/docsLayout.presentation.d.ts +2 -0
- package/dist/docs/presentations/docsLayout.presentation.js +527 -0
- package/dist/docs/presentations/docsReferencePage.presentation.d.ts +2 -0
- package/dist/docs/presentations/docsReferencePage.presentation.js +527 -0
- package/dist/docs/presentations/index.d.ts +2 -0
- package/dist/docs/presentations/index.js +555 -0
- package/dist/docs/presentations.d.ts +27 -0
- package/dist/docs/presentations.js +97 -0
- package/dist/docs/presentations.test.d.ts +1 -0
- package/dist/docs/queries/contractReference.query.d.ts +211 -0
- package/dist/docs/queries/contractReference.query.js +752 -0
- package/dist/docs/queries/docsIndex.query.d.ts +266 -0
- package/dist/docs/queries/docsIndex.query.js +752 -0
- package/dist/docs/queries/index.d.ts +2 -0
- package/dist/docs/queries/index.js +827 -0
- package/dist/docs/registry.d.ts +19 -0
- package/dist/docs/registry.js +153 -0
- package/dist/docs/registry.test.d.ts +1 -0
- package/dist/docs/tech/auth/better-auth-nextjs.docblock.d.ts +2 -0
- package/dist/docs/tech/auth/better-auth-nextjs.docblock.js +221 -0
- package/dist/docs/tech/cli.docblock.d.ts +2 -0
- package/dist/docs/tech/cli.docblock.js +291 -0
- package/dist/docs/tech/contracts/README.docblock.d.ts +2 -0
- package/dist/docs/tech/contracts/README.docblock.js +164 -0
- package/dist/docs/tech/contracts/migrations.docblock.d.ts +2 -0
- package/dist/docs/tech/contracts/migrations.docblock.js +164 -0
- package/dist/docs/tech/contracts/openapi-export.docblock.d.ts +2 -0
- package/dist/docs/tech/contracts/openapi-export.docblock.js +201 -0
- package/dist/docs/tech/contracts/openapi-import.docblock.d.ts +2 -0
- package/dist/docs/tech/contracts/openapi-import.docblock.js +207 -0
- package/dist/docs/tech/contracts/ops-to-presentation-linking.docblock.d.ts +2 -0
- package/dist/docs/tech/contracts/ops-to-presentation-linking.docblock.js +225 -0
- package/dist/docs/tech/contracts/overlays.docblock.d.ts +2 -0
- package/dist/docs/tech/contracts/overlays.docblock.js +231 -0
- package/dist/docs/tech/contracts/tests.docblock.d.ts +2 -0
- package/dist/docs/tech/contracts/tests.docblock.js +164 -0
- package/dist/docs/tech/contracts/themes.docblock.d.ts +2 -0
- package/dist/docs/tech/contracts/themes.docblock.js +257 -0
- package/dist/docs/tech/contracts/vertical-pocket-family-office.docblock.d.ts +2 -0
- package/dist/docs/tech/contracts/vertical-pocket-family-office.docblock.js +269 -0
- package/dist/docs/tech/docs-system.docblock.d.ts +1 -0
- package/dist/docs/tech/docs-system.docblock.js +264 -0
- package/dist/docs/tech/lifecycle-stage-system.docblock.d.ts +2 -0
- package/dist/docs/tech/lifecycle-stage-system.docblock.js +376 -0
- package/dist/docs/tech/llm/llm-integration.docblock.d.ts +7 -0
- package/dist/docs/tech/llm/llm-integration.docblock.js +482 -0
- package/dist/docs/tech/mcp-endpoints.docblock.d.ts +2 -0
- package/dist/docs/tech/mcp-endpoints.docblock.js +185 -0
- package/dist/docs/tech/presentation-runtime.docblock.d.ts +2 -0
- package/dist/docs/tech/presentation-runtime.docblock.js +221 -0
- package/dist/docs/tech/report-verification-table.docblock.d.ts +1 -0
- package/dist/docs/tech/report-verification-table.docblock.js +191 -0
- package/dist/docs/tech/report-verification-table.test.d.ts +1 -0
- package/dist/docs/tech/schema/README.docblock.d.ts +2 -0
- package/dist/docs/tech/schema/README.docblock.js +164 -0
- package/dist/docs/tech/studio/learning-events.docblock.d.ts +2 -0
- package/dist/docs/tech/studio/learning-events.docblock.js +190 -0
- package/dist/docs/tech/studio/learning-journeys.docblock.d.ts +2 -0
- package/dist/docs/tech/studio/learning-journeys.docblock.js +227 -0
- package/dist/docs/tech/studio/platform-admin-panel.docblock.d.ts +2 -0
- package/dist/docs/tech/studio/platform-admin-panel.docblock.js +226 -0
- package/dist/docs/tech/studio/project-access-teams.docblock.d.ts +2 -0
- package/dist/docs/tech/studio/project-access-teams.docblock.js +200 -0
- package/dist/docs/tech/studio/project-routing.docblock.d.ts +2 -0
- package/dist/docs/tech/studio/project-routing.docblock.js +209 -0
- package/dist/docs/tech/studio/sandbox-unlogged.docblock.d.ts +2 -0
- package/dist/docs/tech/studio/sandbox-unlogged.docblock.js +183 -0
- package/dist/docs/tech/studio/team-invitations.docblock.d.ts +2 -0
- package/dist/docs/tech/studio/team-invitations.docblock.js +228 -0
- package/dist/docs/tech/studio/workspace-ops.docblock.d.ts +2 -0
- package/dist/docs/tech/studio/workspace-ops.docblock.js +189 -0
- package/dist/docs/tech/studio/workspaces.docblock.d.ts +2 -0
- package/dist/docs/tech/studio/workspaces.docblock.js +204 -0
- package/dist/docs/tech/telemetry-ingest.docblock.d.ts +2 -0
- package/dist/docs/tech/telemetry-ingest.docblock.js +305 -0
- package/dist/docs/tech/vscode-extension.docblock.d.ts +2 -0
- package/dist/docs/tech/vscode-extension.docblock.js +241 -0
- package/dist/docs/tech-contracts.docs.d.ts +2 -0
- package/dist/docs/tech-contracts.docs.js +239 -0
- package/dist/docs/types.d.ts +37 -0
- package/dist/docs/types.js +1 -0
- package/dist/docs/views/contractReference.dataView.d.ts +2 -0
- package/dist/docs/views/contractReference.dataView.js +838 -0
- package/dist/docs/views/docsIndex.dataView.d.ts +2 -0
- package/dist/docs/views/docsIndex.dataView.js +832 -0
- package/dist/docs/views/exampleCatalog.dataView.d.ts +2 -0
- package/dist/docs/views/exampleCatalog.dataView.js +816 -0
- package/dist/docs/views/index.d.ts +3 -0
- package/dist/docs/views/index.js +1031 -0
- package/dist/events.d.ts +142 -0
- package/dist/events.js +228 -0
- package/dist/events.test.d.ts +1 -0
- package/dist/examples/define.d.ts +5 -0
- package/dist/examples/define.js +36 -0
- package/dist/examples/docs/examples.docblock.d.ts +2 -0
- package/dist/examples/docs/examples.docblock.js +307 -0
- package/dist/examples/index.d.ts +7 -0
- package/dist/examples/index.js +604 -0
- package/dist/examples/registry.d.ts +38 -0
- package/dist/examples/registry.js +286 -0
- package/dist/examples/registry.test.d.ts +1 -0
- package/dist/examples/schema.d.ts +278 -0
- package/dist/examples/schema.js +166 -0
- package/dist/examples/schema.test.d.ts +1 -0
- package/dist/examples/types.d.ts +162 -0
- package/dist/examples/types.js +77 -0
- package/dist/examples/types.test.d.ts +1 -0
- package/dist/examples/validation.d.ts +61 -0
- package/dist/examples/validation.js +287 -0
- package/dist/examples/validation.test.d.ts +1 -0
- package/dist/experiments/docs/experiments.docblock.d.ts +2 -0
- package/dist/experiments/docs/experiments.docblock.js +291 -0
- package/dist/experiments/evaluator.d.ts +33 -0
- package/dist/experiments/evaluator.js +155 -0
- package/dist/experiments/evaluator.test.d.ts +1 -0
- package/dist/experiments/spec-resolver.d.ts +12 -0
- package/dist/experiments/spec-resolver.js +1 -0
- package/dist/experiments/spec.d.ts +79 -0
- package/dist/experiments/spec.js +227 -0
- package/dist/experiments/spec.test.d.ts +1 -0
- package/dist/features/index.d.ts +5 -0
- package/dist/features/index.js +275 -0
- package/dist/features/install.d.ts +14 -0
- package/dist/features/install.js +95 -0
- package/dist/features/install.test.d.ts +1 -0
- package/dist/features/registry.d.ts +21 -0
- package/dist/features/registry.js +192 -0
- package/dist/features/registry.test.d.ts +1 -0
- package/dist/features/types.d.ts +82 -0
- package/dist/features/types.js +36 -0
- package/dist/features/types.test.d.ts +1 -0
- package/dist/features/validation.d.ts +4 -0
- package/dist/features/validation.js +48 -0
- package/dist/features/validation.test.d.ts +1 -0
- package/dist/features.capabilities.test.d.ts +1 -0
- package/dist/forms/docs/forms.docblock.d.ts +2 -0
- package/dist/forms/docs/forms.docblock.js +164 -0
- package/dist/forms/forms.d.ts +264 -0
- package/dist/forms/forms.js +332 -0
- package/dist/forms/index.d.ts +1 -0
- package/dist/forms/index.js +332 -0
- package/dist/index.d.ts +36 -0
- package/dist/index.js +2195 -0
- package/dist/install.d.ts +75 -0
- package/dist/install.js +60 -0
- package/dist/integrations/binding.d.ts +14 -0
- package/dist/integrations/binding.js +1 -0
- package/dist/integrations/connection.d.ts +47 -0
- package/dist/integrations/connection.js +1 -0
- package/dist/integrations/docs/integrations.docblock.d.ts +2 -0
- package/dist/integrations/docs/integrations.docblock.js +140 -0
- package/dist/integrations/health.d.ts +17 -0
- package/dist/integrations/health.js +103 -0
- package/dist/integrations/health.test.d.ts +1 -0
- package/dist/integrations/index.d.ts +11 -0
- package/dist/integrations/index.js +3293 -0
- package/dist/integrations/integrations.capability.d.ts +1 -0
- package/dist/integrations/integrations.capability.js +48 -0
- package/dist/integrations/integrations.feature.d.ts +5 -0
- package/dist/integrations/integrations.feature.js +63 -0
- package/dist/integrations/meeting-recorder/contracts/index.d.ts +7 -0
- package/dist/integrations/meeting-recorder/contracts/index.js +504 -0
- package/dist/integrations/meeting-recorder/contracts/meetings.d.ts +451 -0
- package/dist/integrations/meeting-recorder/contracts/meetings.js +249 -0
- package/dist/integrations/meeting-recorder/contracts/transcripts.d.ts +166 -0
- package/dist/integrations/meeting-recorder/contracts/transcripts.js +317 -0
- package/dist/integrations/meeting-recorder/contracts/webhooks.d.ts +85 -0
- package/dist/integrations/meeting-recorder/contracts/webhooks.js +202 -0
- package/dist/integrations/meeting-recorder/meeting-recorder.capability.d.ts +1 -0
- package/dist/integrations/meeting-recorder/meeting-recorder.capability.js +48 -0
- package/dist/integrations/meeting-recorder/meeting-recorder.feature.d.ts +5 -0
- package/dist/integrations/meeting-recorder/meeting-recorder.feature.js +63 -0
- package/dist/integrations/meeting-recorder/models.d.ts +402 -0
- package/dist/integrations/meeting-recorder/models.js +152 -0
- package/dist/integrations/meeting-recorder/telemetry.d.ts +13 -0
- package/dist/integrations/meeting-recorder/telemetry.js +84 -0
- package/dist/integrations/openbanking/contracts/accounts.d.ts +282 -0
- package/dist/integrations/openbanking/contracts/accounts.js +358 -0
- package/dist/integrations/openbanking/contracts/balances.d.ts +158 -0
- package/dist/integrations/openbanking/contracts/balances.js +322 -0
- package/dist/integrations/openbanking/contracts/index.d.ts +7 -0
- package/dist/integrations/openbanking/contracts/index.js +674 -0
- package/dist/integrations/openbanking/contracts/transactions.d.ts +206 -0
- package/dist/integrations/openbanking/contracts/transactions.js +328 -0
- package/dist/integrations/openbanking/guards.d.ts +8 -0
- package/dist/integrations/openbanking/guards.js +72 -0
- package/dist/integrations/openbanking/guards.test.d.ts +1 -0
- package/dist/integrations/openbanking/models.d.ts +223 -0
- package/dist/integrations/openbanking/models.js +140 -0
- package/dist/integrations/openbanking/openbanking.capability.d.ts +1 -0
- package/dist/integrations/openbanking/openbanking.capability.js +48 -0
- package/dist/integrations/openbanking/openbanking.feature.d.ts +5 -0
- package/dist/integrations/openbanking/openbanking.feature.js +65 -0
- package/dist/integrations/openbanking/telemetry.d.ts +12 -0
- package/dist/integrations/openbanking/telemetry.js +81 -0
- package/dist/integrations/operations.d.ts +430 -0
- package/dist/integrations/operations.js +327 -0
- package/dist/integrations/operations.test.d.ts +1 -0
- package/dist/integrations/providers/analytics-reader.d.ts +103 -0
- package/dist/integrations/providers/analytics-reader.js +1 -0
- package/dist/integrations/providers/analytics-writer.d.ts +6 -0
- package/dist/integrations/providers/analytics-writer.js +1 -0
- package/dist/integrations/providers/analytics.d.ts +47 -0
- package/dist/integrations/providers/analytics.js +1 -0
- package/dist/integrations/providers/calendar.d.ts +75 -0
- package/dist/integrations/providers/calendar.js +1 -0
- package/dist/integrations/providers/database.d.ts +12 -0
- package/dist/integrations/providers/database.js +1 -0
- package/dist/integrations/providers/elevenlabs.d.ts +3 -0
- package/dist/integrations/providers/elevenlabs.js +116 -0
- package/dist/integrations/providers/email.d.ts +83 -0
- package/dist/integrations/providers/email.js +1 -0
- package/dist/integrations/providers/embedding.d.ts +21 -0
- package/dist/integrations/providers/embedding.js +1 -0
- package/dist/integrations/providers/fal.d.ts +3 -0
- package/dist/integrations/providers/fal.js +142 -0
- package/dist/integrations/providers/fathom.d.ts +3 -0
- package/dist/integrations/providers/fathom.js +156 -0
- package/dist/integrations/providers/fireflies.d.ts +3 -0
- package/dist/integrations/providers/fireflies.js +136 -0
- package/dist/integrations/providers/gcs-storage.d.ts +3 -0
- package/dist/integrations/providers/gcs-storage.js +127 -0
- package/dist/integrations/providers/gmail.d.ts +3 -0
- package/dist/integrations/providers/gmail.js +139 -0
- package/dist/integrations/providers/google-calendar.d.ts +3 -0
- package/dist/integrations/providers/google-calendar.js +122 -0
- package/dist/integrations/providers/gradium.d.ts +3 -0
- package/dist/integrations/providers/gradium.js +140 -0
- package/dist/integrations/providers/granola.d.ts +3 -0
- package/dist/integrations/providers/granola.js +137 -0
- package/dist/integrations/providers/index.d.ts +38 -0
- package/dist/integrations/providers/index.js +2124 -0
- package/dist/integrations/providers/jira.d.ts +3 -0
- package/dist/integrations/providers/jira.js +138 -0
- package/dist/integrations/providers/linear.d.ts +3 -0
- package/dist/integrations/providers/linear.js +137 -0
- package/dist/integrations/providers/llm.d.ts +79 -0
- package/dist/integrations/providers/llm.js +1 -0
- package/dist/integrations/providers/meeting-recorder.d.ts +129 -0
- package/dist/integrations/providers/meeting-recorder.js +1 -0
- package/dist/integrations/providers/mistral.d.ts +3 -0
- package/dist/integrations/providers/mistral.js +124 -0
- package/dist/integrations/providers/notion.d.ts +3 -0
- package/dist/integrations/providers/notion.js +143 -0
- package/dist/integrations/providers/openbanking.d.ts +125 -0
- package/dist/integrations/providers/openbanking.js +1 -0
- package/dist/integrations/providers/payments.d.ts +106 -0
- package/dist/integrations/providers/payments.js +1 -0
- package/dist/integrations/providers/posthog-llm-telemetry.d.ts +51 -0
- package/dist/integrations/providers/posthog-llm-telemetry.js +206 -0
- package/dist/integrations/providers/posthog.d.ts +3 -0
- package/dist/integrations/providers/posthog.js +136 -0
- package/dist/integrations/providers/postmark.d.ts +3 -0
- package/dist/integrations/providers/postmark.js +128 -0
- package/dist/integrations/providers/powens.d.ts +3 -0
- package/dist/integrations/providers/powens.js +154 -0
- package/dist/integrations/providers/project-management.d.ts +32 -0
- package/dist/integrations/providers/project-management.js +1 -0
- package/dist/integrations/providers/providers.test.d.ts +1 -0
- package/dist/integrations/providers/qdrant.d.ts +3 -0
- package/dist/integrations/providers/qdrant.js +131 -0
- package/dist/integrations/providers/registry.d.ts +6 -0
- package/dist/integrations/providers/registry.js +1908 -0
- package/dist/integrations/providers/sms.d.ts +31 -0
- package/dist/integrations/providers/sms.js +1 -0
- package/dist/integrations/providers/storage.d.ts +57 -0
- package/dist/integrations/providers/storage.js +1 -0
- package/dist/integrations/providers/stripe.d.ts +3 -0
- package/dist/integrations/providers/stripe.js +135 -0
- package/dist/integrations/providers/supabase-postgres.d.ts +3 -0
- package/dist/integrations/providers/supabase-postgres.js +117 -0
- package/dist/integrations/providers/supabase-vector.d.ts +3 -0
- package/dist/integrations/providers/supabase-vector.js +137 -0
- package/dist/integrations/providers/tldv.d.ts +3 -0
- package/dist/integrations/providers/tldv.js +136 -0
- package/dist/integrations/providers/twilio-sms.d.ts +3 -0
- package/dist/integrations/providers/twilio-sms.js +121 -0
- package/dist/integrations/providers/vector-store.d.ts +39 -0
- package/dist/integrations/providers/vector-store.js +1 -0
- package/dist/integrations/providers/voice.d.ts +31 -0
- package/dist/integrations/providers/voice.js +1 -0
- package/dist/integrations/runtime.d.ts +95 -0
- package/dist/integrations/runtime.js +239 -0
- package/dist/integrations/runtime.test.d.ts +1 -0
- package/dist/integrations/secrets/aws-secret-manager.d.ts +28 -0
- package/dist/integrations/secrets/aws-secret-manager.js +376 -0
- package/dist/integrations/secrets/env-secret-provider.d.ts +28 -0
- package/dist/integrations/secrets/env-secret-provider.js +189 -0
- package/dist/integrations/secrets/gcp-secret-manager.d.ts +29 -0
- package/dist/integrations/secrets/gcp-secret-manager.js +377 -0
- package/dist/integrations/secrets/index.d.ts +6 -0
- package/dist/integrations/secrets/index.js +1159 -0
- package/dist/integrations/secrets/manager.d.ts +44 -0
- package/dist/integrations/secrets/manager.js +213 -0
- package/dist/integrations/secrets/provider.d.ts +49 -0
- package/dist/integrations/secrets/provider.js +104 -0
- package/dist/integrations/secrets/provider.test.d.ts +1 -0
- package/dist/integrations/secrets/scaleway-secret-manager.d.ts +35 -0
- package/dist/integrations/secrets/scaleway-secret-manager.js +405 -0
- package/dist/integrations/secrets-types.d.ts +14 -0
- package/dist/integrations/secrets-types.js +1 -0
- package/dist/integrations/spec.d.ts +72 -0
- package/dist/integrations/spec.js +52 -0
- package/dist/integrations/spec.test.d.ts +1 -0
- package/dist/jobs/define-job.d.ts +15 -0
- package/dist/jobs/define-job.js +41 -0
- package/dist/jobs/gcp-cloud-tasks.d.ts +38 -0
- package/dist/jobs/gcp-cloud-tasks.js +103 -0
- package/dist/jobs/gcp-pubsub.d.ts +22 -0
- package/dist/jobs/gcp-pubsub.js +91 -0
- package/dist/jobs/handlers/gmail-sync-handler.d.ts +5 -0
- package/dist/jobs/handlers/gmail-sync-handler.js +40 -0
- package/dist/jobs/handlers/handlers.test.d.ts +1 -0
- package/dist/jobs/handlers/index.d.ts +5 -0
- package/dist/jobs/handlers/index.js +83 -0
- package/dist/jobs/handlers/ping-handler.d.ts +6 -0
- package/dist/jobs/handlers/ping-handler.js +47 -0
- package/dist/jobs/handlers/storage-document-handler.d.ts +8 -0
- package/dist/jobs/handlers/storage-document-handler.js +47 -0
- package/dist/jobs/index.d.ts +2 -0
- package/dist/jobs/index.js +64 -0
- package/dist/jobs/memory-queue.d.ts +14 -0
- package/dist/jobs/memory-queue.js +129 -0
- package/dist/jobs/queue.d.ts +126 -0
- package/dist/jobs/queue.js +55 -0
- package/dist/jobs/queue.test.d.ts +1 -0
- package/dist/jobs/scaleway-sqs-queue.d.ts +27 -0
- package/dist/jobs/scaleway-sqs-queue.js +222 -0
- package/dist/jsonschema.d.ts +39 -0
- package/dist/jsonschema.js +73 -0
- package/dist/jsonschema.test.d.ts +1 -0
- package/dist/knowledge/binding.d.ts +22 -0
- package/dist/knowledge/binding.js +1 -0
- package/dist/knowledge/docs/knowledge.docblock.d.ts +2 -0
- package/dist/knowledge/docs/knowledge.docblock.js +301 -0
- package/dist/knowledge/index.d.ts +4 -0
- package/dist/knowledge/index.js +467 -0
- package/dist/knowledge/ingestion/document-processor.d.ts +22 -0
- package/dist/knowledge/ingestion/document-processor.js +95 -0
- package/dist/knowledge/ingestion/embedding-service.d.ts +8 -0
- package/dist/knowledge/ingestion/embedding-service.js +57 -0
- package/dist/knowledge/ingestion/gmail-adapter.d.ts +14 -0
- package/dist/knowledge/ingestion/gmail-adapter.js +103 -0
- package/dist/knowledge/ingestion/index.d.ts +5 -0
- package/dist/knowledge/ingestion/index.js +252 -0
- package/dist/knowledge/ingestion/ingestion.test.d.ts +1 -0
- package/dist/knowledge/ingestion/storage-adapter.d.ts +11 -0
- package/dist/knowledge/ingestion/storage-adapter.js +62 -0
- package/dist/knowledge/ingestion/vector-indexer.d.ts +14 -0
- package/dist/knowledge/ingestion/vector-indexer.js +63 -0
- package/dist/knowledge/knowledge.capability.d.ts +1 -0
- package/dist/knowledge/knowledge.capability.js +726 -0
- package/dist/knowledge/knowledge.feature.d.ts +5 -0
- package/dist/knowledge/knowledge.feature.js +300 -0
- package/dist/knowledge/operations.d.ts +311 -0
- package/dist/knowledge/operations.js +619 -0
- package/dist/knowledge/operations.test.d.ts +1 -0
- package/dist/knowledge/query/index.d.ts +1 -0
- package/dist/knowledge/query/index.js +110 -0
- package/dist/knowledge/query/service.d.ts +25 -0
- package/dist/knowledge/query/service.js +110 -0
- package/dist/knowledge/query/service.test.d.ts +1 -0
- package/dist/knowledge/runtime.d.ts +28 -0
- package/dist/knowledge/runtime.js +91 -0
- package/dist/knowledge/runtime.test.d.ts +1 -0
- package/dist/knowledge/source.d.ts +29 -0
- package/dist/knowledge/source.js +1 -0
- package/dist/knowledge/spaces/email-threads.d.ts +3 -0
- package/dist/knowledge/spaces/email-threads.js +102 -0
- package/dist/knowledge/spaces/financial-docs.d.ts +3 -0
- package/dist/knowledge/spaces/financial-docs.js +102 -0
- package/dist/knowledge/spaces/financial-overview.d.ts +3 -0
- package/dist/knowledge/spaces/financial-overview.js +102 -0
- package/dist/knowledge/spaces/index.d.ts +6 -0
- package/dist/knowledge/spaces/index.js +273 -0
- package/dist/knowledge/spaces/product-canon.d.ts +3 -0
- package/dist/knowledge/spaces/product-canon.js +102 -0
- package/dist/knowledge/spaces/spaces.test.d.ts +1 -0
- package/dist/knowledge/spaces/support-faq.d.ts +3 -0
- package/dist/knowledge/spaces/support-faq.js +103 -0
- package/dist/knowledge/spaces/uploaded-docs.d.ts +3 -0
- package/dist/knowledge/spaces/uploaded-docs.js +102 -0
- package/dist/knowledge/spec.d.ts +42 -0
- package/dist/knowledge/spec.js +228 -0
- package/dist/knowledge/spec.test.d.ts +1 -0
- package/dist/llm/exporters.d.ts +68 -0
- package/dist/llm/exporters.js +1011 -0
- package/dist/llm/index.d.ts +12 -0
- package/dist/llm/index.js +1465 -0
- package/dist/llm/prompts.d.ts +53 -0
- package/dist/llm/prompts.js +1456 -0
- package/dist/llm/types.d.ts +212 -0
- package/dist/llm/types.js +1 -0
- package/dist/markdown.d.ts +16 -0
- package/dist/markdown.js +529 -0
- package/dist/migrations.d.ts +48 -0
- package/dist/migrations.js +67 -0
- package/dist/migrations.test.d.ts +1 -0
- package/dist/model-registry.d.ts +9 -0
- package/dist/model-registry.js +64 -0
- package/dist/model-registry.test.d.ts +1 -0
- package/dist/node/app-config/app-config.capability.js +730 -0
- package/dist/node/app-config/app-config.contracts.js +713 -0
- package/dist/node/app-config/app-config.feature.js +255 -0
- package/dist/node/app-config/branding.js +0 -0
- package/dist/node/app-config/docs/app-config.docblock.js +383 -0
- package/dist/node/app-config/events.js +386 -0
- package/dist/node/app-config/index.js +2899 -0
- package/dist/node/app-config/lifecycle-contracts.js +870 -0
- package/dist/node/app-config/lifecycle.js +0 -0
- package/dist/node/app-config/runtime.js +734 -0
- package/dist/node/app-config/spec.js +229 -0
- package/dist/node/app-config/validation.js +650 -0
- package/dist/node/capabilities/capabilities.js +217 -0
- package/dist/node/capabilities/context.js +101 -0
- package/dist/node/capabilities/docs/capabilities.docblock.js +353 -0
- package/dist/node/capabilities/guards.js +177 -0
- package/dist/node/capabilities/index.js +739 -0
- package/dist/node/capabilities/meeting-recorder.js +154 -0
- package/dist/node/capabilities/openbanking.js +166 -0
- package/dist/node/capabilities/validation.js +185 -0
- package/dist/node/contract-registry/index.js +129 -0
- package/dist/node/contract-registry/schemas.js +129 -0
- package/dist/node/contract-registry/types.js +0 -0
- package/dist/node/data-views/data-views.js +232 -0
- package/dist/node/data-views/docs/data-views.docblock.js +164 -0
- package/dist/node/data-views/index.js +232 -0
- package/dist/node/data-views/query-generator.js +89 -0
- package/dist/node/data-views/registry.js +226 -0
- package/dist/node/data-views/report/contractVerificationTable.js +240 -0
- package/dist/node/data-views/runtime.js +108 -0
- package/dist/node/data-views/spec.js +38 -0
- package/dist/node/data-views/types.js +0 -0
- package/dist/node/docs/accessibility_wcag_compliance_specs.docblock.js +513 -0
- package/dist/node/docs/capabilities/documentationSystem.capability.js +784 -0
- package/dist/node/docs/capabilities/index.js +784 -0
- package/dist/node/docs/commands/docsGenerate.command.js +802 -0
- package/dist/node/docs/commands/docsPublish.command.js +781 -0
- package/dist/node/docs/commands/index.js +906 -0
- package/dist/node/docs/constants.js +78 -0
- package/dist/node/docs/contracts.js +1611 -0
- package/dist/node/docs/ensure-docblocks.js +264 -0
- package/dist/node/docs/events/docsGenerated.event.js +533 -0
- package/dist/node/docs/events/docsPublished.event.js +534 -0
- package/dist/node/docs/events/index.js +567 -0
- package/dist/node/docs/forms/docsSearch.form.js +676 -0
- package/dist/node/docs/forms/index.js +676 -0
- package/dist/node/docs/index.js +4719 -0
- package/dist/node/docs/meta.docs.js +176 -0
- package/dist/node/docs/presentations/docsLayout.presentation.js +527 -0
- package/dist/node/docs/presentations/docsReferencePage.presentation.js +527 -0
- package/dist/node/docs/presentations/index.js +555 -0
- package/dist/node/docs/presentations.js +97 -0
- package/dist/node/docs/queries/contractReference.query.js +752 -0
- package/dist/node/docs/queries/docsIndex.query.js +752 -0
- package/dist/node/docs/queries/index.js +827 -0
- package/dist/node/docs/registry.js +153 -0
- package/dist/node/docs/tech/auth/better-auth-nextjs.docblock.js +221 -0
- package/dist/node/docs/tech/cli.docblock.js +291 -0
- package/dist/node/docs/tech/contracts/README.docblock.js +164 -0
- package/dist/node/docs/tech/contracts/migrations.docblock.js +164 -0
- package/dist/node/docs/tech/contracts/openapi-export.docblock.js +201 -0
- package/dist/node/docs/tech/contracts/openapi-import.docblock.js +207 -0
- package/dist/node/docs/tech/contracts/ops-to-presentation-linking.docblock.js +225 -0
- package/dist/node/docs/tech/contracts/overlays.docblock.js +231 -0
- package/dist/node/docs/tech/contracts/tests.docblock.js +164 -0
- package/dist/node/docs/tech/contracts/themes.docblock.js +257 -0
- package/dist/node/docs/tech/contracts/vertical-pocket-family-office.docblock.js +269 -0
- package/dist/node/docs/tech/docs-system.docblock.js +264 -0
- package/dist/node/docs/tech/lifecycle-stage-system.docblock.js +376 -0
- package/dist/node/docs/tech/llm/llm-integration.docblock.js +482 -0
- package/dist/node/docs/tech/mcp-endpoints.docblock.js +185 -0
- package/dist/node/docs/tech/presentation-runtime.docblock.js +221 -0
- package/dist/node/docs/tech/report-verification-table.docblock.js +191 -0
- package/dist/node/docs/tech/schema/README.docblock.js +164 -0
- package/dist/node/docs/tech/studio/learning-events.docblock.js +190 -0
- package/dist/node/docs/tech/studio/learning-journeys.docblock.js +227 -0
- package/dist/node/docs/tech/studio/platform-admin-panel.docblock.js +226 -0
- package/dist/node/docs/tech/studio/project-access-teams.docblock.js +200 -0
- package/dist/node/docs/tech/studio/project-routing.docblock.js +209 -0
- package/dist/node/docs/tech/studio/sandbox-unlogged.docblock.js +183 -0
- package/dist/node/docs/tech/studio/team-invitations.docblock.js +228 -0
- package/dist/node/docs/tech/studio/workspace-ops.docblock.js +189 -0
- package/dist/node/docs/tech/studio/workspaces.docblock.js +204 -0
- package/dist/node/docs/tech/telemetry-ingest.docblock.js +305 -0
- package/dist/node/docs/tech/vscode-extension.docblock.js +241 -0
- package/dist/node/docs/tech-contracts.docs.js +239 -0
- package/dist/node/docs/types.js +0 -0
- package/dist/node/docs/views/contractReference.dataView.js +838 -0
- package/dist/node/docs/views/docsIndex.dataView.js +832 -0
- package/dist/node/docs/views/exampleCatalog.dataView.js +816 -0
- package/dist/node/docs/views/index.js +1031 -0
- package/dist/node/events.js +228 -0
- package/dist/node/examples/define.js +36 -0
- package/dist/node/examples/docs/examples.docblock.js +307 -0
- package/dist/node/examples/index.js +604 -0
- package/dist/node/examples/registry.js +286 -0
- package/dist/node/examples/schema.js +166 -0
- package/dist/node/examples/types.js +77 -0
- package/dist/node/examples/validation.js +287 -0
- package/dist/node/experiments/docs/experiments.docblock.js +291 -0
- package/dist/node/experiments/evaluator.js +155 -0
- package/dist/node/experiments/spec-resolver.js +0 -0
- package/dist/node/experiments/spec.js +227 -0
- package/dist/node/features/index.js +275 -0
- package/dist/node/features/install.js +95 -0
- package/dist/node/features/registry.js +192 -0
- package/dist/node/features/types.js +36 -0
- package/dist/node/features/validation.js +48 -0
- package/dist/node/forms/docs/forms.docblock.js +164 -0
- package/dist/node/forms/forms.js +332 -0
- package/dist/node/forms/index.js +332 -0
- package/dist/node/index.js +2195 -0
- package/dist/node/install.js +60 -0
- package/dist/node/integrations/binding.js +0 -0
- package/dist/node/integrations/connection.js +0 -0
- package/dist/node/integrations/docs/integrations.docblock.js +140 -0
- package/dist/node/integrations/health.js +103 -0
- package/dist/node/integrations/index.js +3293 -0
- package/dist/node/integrations/integrations.capability.js +48 -0
- package/dist/node/integrations/integrations.feature.js +63 -0
- package/dist/node/integrations/meeting-recorder/contracts/index.js +504 -0
- package/dist/node/integrations/meeting-recorder/contracts/meetings.js +249 -0
- package/dist/node/integrations/meeting-recorder/contracts/transcripts.js +317 -0
- package/dist/node/integrations/meeting-recorder/contracts/webhooks.js +202 -0
- package/dist/node/integrations/meeting-recorder/meeting-recorder.capability.js +48 -0
- package/dist/node/integrations/meeting-recorder/meeting-recorder.feature.js +63 -0
- package/dist/node/integrations/meeting-recorder/models.js +152 -0
- package/dist/node/integrations/meeting-recorder/telemetry.js +84 -0
- package/dist/node/integrations/openbanking/contracts/accounts.js +358 -0
- package/dist/node/integrations/openbanking/contracts/balances.js +322 -0
- package/dist/node/integrations/openbanking/contracts/index.js +674 -0
- package/dist/node/integrations/openbanking/contracts/transactions.js +328 -0
- package/dist/node/integrations/openbanking/guards.js +72 -0
- package/dist/node/integrations/openbanking/models.js +140 -0
- package/dist/node/integrations/openbanking/openbanking.capability.js +48 -0
- package/dist/node/integrations/openbanking/openbanking.feature.js +65 -0
- package/dist/node/integrations/openbanking/telemetry.js +81 -0
- package/dist/node/integrations/operations.js +327 -0
- package/dist/node/integrations/providers/analytics-reader.js +0 -0
- package/dist/node/integrations/providers/analytics-writer.js +0 -0
- package/dist/node/integrations/providers/analytics.js +0 -0
- package/dist/node/integrations/providers/calendar.js +0 -0
- package/dist/node/integrations/providers/database.js +0 -0
- package/dist/node/integrations/providers/elevenlabs.js +116 -0
- package/dist/node/integrations/providers/email.js +0 -0
- package/dist/node/integrations/providers/embedding.js +0 -0
- package/dist/node/integrations/providers/fal.js +142 -0
- package/dist/node/integrations/providers/fathom.js +156 -0
- package/dist/node/integrations/providers/fireflies.js +136 -0
- package/dist/node/integrations/providers/gcs-storage.js +127 -0
- package/dist/node/integrations/providers/gmail.js +139 -0
- package/dist/node/integrations/providers/google-calendar.js +122 -0
- package/dist/node/integrations/providers/gradium.js +140 -0
- package/dist/node/integrations/providers/granola.js +137 -0
- package/dist/node/integrations/providers/index.js +2124 -0
- package/dist/node/integrations/providers/jira.js +138 -0
- package/dist/node/integrations/providers/linear.js +137 -0
- package/dist/node/integrations/providers/llm.js +0 -0
- package/dist/node/integrations/providers/meeting-recorder.js +0 -0
- package/dist/node/integrations/providers/mistral.js +124 -0
- package/dist/node/integrations/providers/notion.js +143 -0
- package/dist/node/integrations/providers/openbanking.js +0 -0
- package/dist/node/integrations/providers/payments.js +0 -0
- package/dist/node/integrations/providers/posthog-llm-telemetry.js +206 -0
- package/dist/node/integrations/providers/posthog.js +136 -0
- package/dist/node/integrations/providers/postmark.js +128 -0
- package/dist/node/integrations/providers/powens.js +154 -0
- package/dist/node/integrations/providers/project-management.js +0 -0
- package/dist/node/integrations/providers/qdrant.js +131 -0
- package/dist/node/integrations/providers/registry.js +1908 -0
- package/dist/node/integrations/providers/sms.js +0 -0
- package/dist/node/integrations/providers/storage.js +0 -0
- package/dist/node/integrations/providers/stripe.js +135 -0
- package/dist/node/integrations/providers/supabase-postgres.js +117 -0
- package/dist/node/integrations/providers/supabase-vector.js +137 -0
- package/dist/node/integrations/providers/tldv.js +136 -0
- package/dist/node/integrations/providers/twilio-sms.js +121 -0
- package/dist/node/integrations/providers/vector-store.js +0 -0
- package/dist/node/integrations/providers/voice.js +0 -0
- package/dist/node/integrations/runtime.js +239 -0
- package/dist/node/integrations/secrets/aws-secret-manager.js +376 -0
- package/dist/node/integrations/secrets/env-secret-provider.js +189 -0
- package/dist/node/integrations/secrets/gcp-secret-manager.js +377 -0
- package/dist/node/integrations/secrets/index.js +1159 -0
- package/dist/node/integrations/secrets/manager.js +213 -0
- package/dist/node/integrations/secrets/provider.js +104 -0
- package/dist/node/integrations/secrets/scaleway-secret-manager.js +405 -0
- package/dist/node/integrations/secrets-types.js +0 -0
- package/dist/node/integrations/spec.js +52 -0
- package/dist/node/jobs/define-job.js +41 -0
- package/dist/node/jobs/gcp-cloud-tasks.js +103 -0
- package/dist/node/jobs/gcp-pubsub.js +91 -0
- package/dist/node/jobs/handlers/gmail-sync-handler.js +40 -0
- package/dist/node/jobs/handlers/index.js +83 -0
- package/dist/node/jobs/handlers/ping-handler.js +47 -0
- package/dist/node/jobs/handlers/storage-document-handler.js +47 -0
- package/dist/node/jobs/index.js +64 -0
- package/dist/node/jobs/memory-queue.js +129 -0
- package/dist/node/jobs/queue.js +55 -0
- package/dist/node/jobs/scaleway-sqs-queue.js +222 -0
- package/dist/node/jsonschema.js +73 -0
- package/dist/node/knowledge/binding.js +0 -0
- package/dist/node/knowledge/docs/knowledge.docblock.js +301 -0
- package/dist/node/knowledge/index.js +467 -0
- package/dist/node/knowledge/ingestion/document-processor.js +95 -0
- package/dist/node/knowledge/ingestion/embedding-service.js +57 -0
- package/dist/node/knowledge/ingestion/gmail-adapter.js +103 -0
- package/dist/node/knowledge/ingestion/index.js +252 -0
- package/dist/node/knowledge/ingestion/storage-adapter.js +62 -0
- package/dist/node/knowledge/ingestion/vector-indexer.js +63 -0
- package/dist/node/knowledge/knowledge.capability.js +726 -0
- package/dist/node/knowledge/knowledge.feature.js +300 -0
- package/dist/node/knowledge/operations.js +619 -0
- package/dist/node/knowledge/query/index.js +110 -0
- package/dist/node/knowledge/query/service.js +110 -0
- package/dist/node/knowledge/runtime.js +91 -0
- package/dist/node/knowledge/source.js +0 -0
- package/dist/node/knowledge/spaces/email-threads.js +102 -0
- package/dist/node/knowledge/spaces/financial-docs.js +102 -0
- package/dist/node/knowledge/spaces/financial-overview.js +102 -0
- package/dist/node/knowledge/spaces/index.js +273 -0
- package/dist/node/knowledge/spaces/product-canon.js +102 -0
- package/dist/node/knowledge/spaces/support-faq.js +103 -0
- package/dist/node/knowledge/spaces/uploaded-docs.js +102 -0
- package/dist/node/knowledge/spec.js +228 -0
- package/dist/node/llm/exporters.js +1011 -0
- package/dist/node/llm/index.js +1465 -0
- package/dist/node/llm/prompts.js +1456 -0
- package/dist/node/llm/types.js +0 -0
- package/dist/node/markdown.js +529 -0
- package/dist/node/migrations.js +67 -0
- package/dist/node/model-registry.js +64 -0
- package/dist/node/onboarding-base.js +597 -0
- package/dist/node/openapi.js +151 -0
- package/dist/node/operations/index.js +408 -0
- package/dist/node/operations/operation.js +51 -0
- package/dist/node/operations/registry.js +405 -0
- package/dist/node/operations/report/getContractVerificationStatus.js +170 -0
- package/dist/node/operations/report/index.js +305 -0
- package/dist/node/ownership.js +73 -0
- package/dist/node/policy/context.js +206 -0
- package/dist/node/policy/docs/policy.docblock.js +313 -0
- package/dist/node/policy/engine.js +325 -0
- package/dist/node/policy/guards.js +387 -0
- package/dist/node/policy/index.js +1313 -0
- package/dist/node/policy/opa-adapter.js +110 -0
- package/dist/node/policy/registry.js +221 -0
- package/dist/node/policy/spec.js +0 -0
- package/dist/node/policy/validation.js +391 -0
- package/dist/node/presentations/docs/presentations-conventions.docblock.js +171 -0
- package/dist/node/presentations/index.js +227 -0
- package/dist/node/presentations/presentations.js +38 -0
- package/dist/node/presentations/registry.js +221 -0
- package/dist/node/presentations/transform-engine.js +600 -0
- package/dist/node/product-intent/contract-patch-intent.js +68 -0
- package/dist/node/product-intent/contract-spec-patch.js +75 -0
- package/dist/node/product-intent/evidence.js +45 -0
- package/dist/node/product-intent/findings.js +81 -0
- package/dist/node/product-intent/impact-report.js +62 -0
- package/dist/node/product-intent/index.js +742 -0
- package/dist/node/product-intent/insights.js +63 -0
- package/dist/node/product-intent/opportunity-brief.js +106 -0
- package/dist/node/product-intent/problems.js +55 -0
- package/dist/node/product-intent/registry.js +242 -0
- package/dist/node/product-intent/runtime.js +320 -0
- package/dist/node/product-intent/spec.js +425 -0
- package/dist/node/product-intent/task-pack.js +69 -0
- package/dist/node/product-intent/tickets.js +57 -0
- package/dist/node/product-intent/types.js +378 -0
- package/dist/node/product-intent/ui-wireframe.js +73 -0
- package/dist/node/prompt.js +38 -0
- package/dist/node/promptRegistry.js +63 -0
- package/dist/node/regenerator/adapters.js +0 -0
- package/dist/node/regenerator/docs/regenerator.docblock.js +164 -0
- package/dist/node/regenerator/executor.js +157 -0
- package/dist/node/regenerator/index.js +341 -0
- package/dist/node/regenerator/service.js +183 -0
- package/dist/node/regenerator/sinks.js +64 -0
- package/dist/node/regenerator/types.js +0 -0
- package/dist/node/regenerator/utils.js +87 -0
- package/dist/node/registry-utils.js +163 -0
- package/dist/node/registry.js +215 -0
- package/dist/node/resources.js +83 -0
- package/dist/node/schema-to-markdown.js +278 -0
- package/dist/node/serialization/index.js +179 -0
- package/dist/node/serialization/serializers.js +180 -0
- package/dist/node/serialization/types.js +0 -0
- package/dist/node/telemetry/anomaly.js +91 -0
- package/dist/node/telemetry/docs/telemetry.docblock.js +164 -0
- package/dist/node/telemetry/index.js +417 -0
- package/dist/node/telemetry/spec.js +261 -0
- package/dist/node/telemetry/tracker.js +129 -0
- package/dist/node/tests/index.js +231 -0
- package/dist/node/tests/runner.js +189 -0
- package/dist/node/tests/spec.js +74 -0
- package/dist/node/themes.js +225 -0
- package/dist/node/translations/catalog.js +0 -0
- package/dist/node/translations/index.js +533 -0
- package/dist/node/translations/registry.js +170 -0
- package/dist/node/translations/spec.js +36 -0
- package/dist/node/translations/tenant.js +0 -0
- package/dist/node/translations/validation.js +392 -0
- package/dist/node/types.js +0 -0
- package/dist/node/versioning/index.js +274 -0
- package/dist/node/versioning/refs.js +99 -0
- package/dist/node/versioning/types.js +55 -0
- package/dist/node/versioning/utils.js +184 -0
- package/dist/node/workflow/adapters/db-adapter.js +127 -0
- package/dist/node/workflow/adapters/file-adapter.js +38 -0
- package/dist/node/workflow/adapters/index.js +194 -0
- package/dist/node/workflow/adapters/memory-store.js +93 -0
- package/dist/node/workflow/context.js +247 -0
- package/dist/node/workflow/expression.js +157 -0
- package/dist/node/workflow/index.js +1546 -0
- package/dist/node/workflow/overview.docblock.js +164 -0
- package/dist/node/workflow/runner.js +532 -0
- package/dist/node/workflow/sla-monitor.js +84 -0
- package/dist/node/workflow/spec.js +221 -0
- package/dist/node/workflow/state.js +0 -0
- package/dist/node/workflow/validation.js +425 -0
- package/dist/node/workspace-config/contractsrc-schema.js +344 -0
- package/dist/node/workspace-config/contractsrc-types.js +0 -0
- package/dist/node/workspace-config/index.js +325 -0
- package/dist/node/workspace-config/workspace-config.docblock.js +188 -0
- package/dist/onboarding-base.d.ts +131 -0
- package/dist/onboarding-base.js +597 -0
- package/dist/openapi.d.ts +33 -0
- package/dist/openapi.js +151 -0
- package/dist/operations/index.d.ts +2 -0
- package/dist/operations/index.js +408 -0
- package/dist/operations/operation.d.ts +191 -0
- package/dist/operations/operation.js +51 -0
- package/dist/operations/registry.d.ts +58 -0
- package/dist/operations/registry.js +405 -0
- package/dist/operations/report/getContractVerificationStatus.d.ts +68 -0
- package/dist/operations/report/getContractVerificationStatus.js +170 -0
- package/dist/operations/report/getContractVerificationStatus.test.d.ts +1 -0
- package/dist/operations/report/index.d.ts +10 -0
- package/dist/operations/report/index.js +305 -0
- package/dist/operations/report/index.test.d.ts +1 -0
- package/dist/ownership.d.ts +211 -0
- package/dist/ownership.js +73 -0
- package/dist/ownership.test.d.ts +1 -0
- package/dist/policy/context.d.ts +234 -0
- package/dist/policy/context.js +206 -0
- package/dist/policy/context.test.d.ts +1 -0
- package/dist/policy/docs/policy.docblock.d.ts +2 -0
- package/dist/policy/docs/policy.docblock.js +313 -0
- package/dist/policy/engine.d.ts +36 -0
- package/dist/policy/engine.js +325 -0
- package/dist/policy/engine.test.d.ts +1 -0
- package/dist/policy/guards.d.ts +156 -0
- package/dist/policy/guards.js +387 -0
- package/dist/policy/guards.test.d.ts +1 -0
- package/dist/policy/index.d.ts +12 -0
- package/dist/policy/index.js +1313 -0
- package/dist/policy/opa-adapter.d.ts +41 -0
- package/dist/policy/opa-adapter.js +110 -0
- package/dist/policy/opa-adapter.test.d.ts +1 -0
- package/dist/policy/registry.d.ts +5 -0
- package/dist/policy/registry.js +221 -0
- package/dist/policy/spec.d.ts +102 -0
- package/dist/policy/spec.js +1 -0
- package/dist/policy/validation.d.ts +84 -0
- package/dist/policy/validation.js +391 -0
- package/dist/policy/validation.test.d.ts +1 -0
- package/dist/presentations/docs/presentations-conventions.docblock.d.ts +2 -0
- package/dist/presentations/docs/presentations-conventions.docblock.js +171 -0
- package/dist/presentations/index.d.ts +2 -0
- package/dist/presentations/index.js +227 -0
- package/dist/presentations/presentations.d.ts +52 -0
- package/dist/presentations/presentations.js +38 -0
- package/dist/presentations/registry.d.ts +6 -0
- package/dist/presentations/registry.js +221 -0
- package/dist/presentations/transform-engine.d.ts +62 -0
- package/dist/presentations/transform-engine.js +600 -0
- package/dist/presentations/transform-engine.test.d.ts +1 -0
- package/dist/product-intent/contract-patch-intent.d.ts +100 -0
- package/dist/product-intent/contract-patch-intent.js +68 -0
- package/dist/product-intent/contract-spec-patch.d.ts +86 -0
- package/dist/product-intent/contract-spec-patch.js +75 -0
- package/dist/product-intent/evidence.d.ts +14 -0
- package/dist/product-intent/evidence.js +45 -0
- package/dist/product-intent/findings.d.ts +57 -0
- package/dist/product-intent/findings.js +81 -0
- package/dist/product-intent/impact-report.d.ts +57 -0
- package/dist/product-intent/impact-report.js +62 -0
- package/dist/product-intent/index.d.ts +13 -0
- package/dist/product-intent/index.js +742 -0
- package/dist/product-intent/insights.d.ts +62 -0
- package/dist/product-intent/insights.js +63 -0
- package/dist/product-intent/opportunity-brief.d.ts +192 -0
- package/dist/product-intent/opportunity-brief.js +106 -0
- package/dist/product-intent/problems.d.ts +59 -0
- package/dist/product-intent/problems.js +55 -0
- package/dist/product-intent/registry.d.ts +28 -0
- package/dist/product-intent/registry.js +242 -0
- package/dist/product-intent/registry.test.d.ts +1 -0
- package/dist/product-intent/runtime.d.ts +92 -0
- package/dist/product-intent/runtime.js +320 -0
- package/dist/product-intent/runtime.test.d.ts +1 -0
- package/dist/product-intent/spec.d.ts +664 -0
- package/dist/product-intent/spec.js +425 -0
- package/dist/product-intent/task-pack.d.ts +98 -0
- package/dist/product-intent/task-pack.js +69 -0
- package/dist/product-intent/tickets.d.ts +67 -0
- package/dist/product-intent/tickets.js +57 -0
- package/dist/product-intent/types.d.ts +11 -0
- package/dist/product-intent/types.js +378 -0
- package/dist/product-intent/ui-wireframe.d.ts +100 -0
- package/dist/product-intent/ui-wireframe.js +73 -0
- package/dist/prompt.d.ts +49 -0
- package/dist/prompt.js +38 -0
- package/dist/prompt.test.d.ts +1 -0
- package/dist/promptRegistry.d.ts +11 -0
- package/dist/promptRegistry.js +63 -0
- package/dist/promptRegistry.test.d.ts +1 -0
- package/dist/regenerator/adapters.d.ts +15 -0
- package/dist/regenerator/adapters.js +1 -0
- package/dist/regenerator/docs/regenerator.docblock.d.ts +2 -0
- package/dist/regenerator/docs/regenerator.docblock.js +164 -0
- package/dist/regenerator/executor.d.ts +66 -0
- package/dist/regenerator/executor.js +157 -0
- package/dist/regenerator/executor.test.d.ts +1 -0
- package/dist/regenerator/index.d.ts +6 -0
- package/dist/regenerator/index.js +341 -0
- package/dist/regenerator/service.d.ts +29 -0
- package/dist/regenerator/service.js +183 -0
- package/dist/regenerator/service.test.d.ts +1 -0
- package/dist/regenerator/sinks.d.ts +23 -0
- package/dist/regenerator/sinks.js +64 -0
- package/dist/regenerator/sinks.test.d.ts +1 -0
- package/dist/regenerator/types.d.ts +103 -0
- package/dist/regenerator/types.js +1 -0
- package/dist/regenerator/utils.d.ts +6 -0
- package/dist/regenerator/utils.js +87 -0
- package/dist/registry-utils.d.ts +105 -0
- package/dist/registry-utils.js +163 -0
- package/dist/registry-utils.test.d.ts +1 -0
- package/dist/registry.d.ts +27 -0
- package/dist/registry.js +215 -0
- package/dist/resources.d.ts +60 -0
- package/dist/resources.js +83 -0
- package/dist/schema-to-markdown.d.ts +56 -0
- package/dist/schema-to-markdown.js +278 -0
- package/dist/serialization/index.d.ts +10 -0
- package/dist/serialization/index.js +179 -0
- package/dist/serialization/serializers.d.ts +35 -0
- package/dist/serialization/serializers.js +180 -0
- package/dist/serialization/types.d.ts +100 -0
- package/dist/serialization/types.js +1 -0
- package/dist/telemetry/anomaly.d.ts +23 -0
- package/dist/telemetry/anomaly.js +91 -0
- package/dist/telemetry/anomaly.test.d.ts +1 -0
- package/dist/telemetry/docs/telemetry.docblock.d.ts +2 -0
- package/dist/telemetry/docs/telemetry.docblock.js +164 -0
- package/dist/telemetry/index.d.ts +3 -0
- package/dist/telemetry/index.js +417 -0
- package/dist/telemetry/spec.d.ts +87 -0
- package/dist/telemetry/spec.js +261 -0
- package/dist/telemetry/spec.test.d.ts +1 -0
- package/dist/telemetry/tracker.d.ts +48 -0
- package/dist/telemetry/tracker.js +129 -0
- package/dist/telemetry/tracker.test.d.ts +1 -0
- package/dist/tests/index.d.ts +2 -0
- package/dist/tests/index.js +231 -0
- package/dist/tests/runner.d.ts +38 -0
- package/dist/tests/runner.js +189 -0
- package/dist/tests/runner.test.d.ts +1 -0
- package/dist/tests/spec.d.ts +82 -0
- package/dist/tests/spec.js +74 -0
- package/dist/tests/spec.test.d.ts +1 -0
- package/dist/themes.d.ts +50 -0
- package/dist/themes.js +225 -0
- package/dist/themes.test.d.ts +1 -0
- package/dist/translations/catalog.d.ts +25 -0
- package/dist/translations/catalog.js +1 -0
- package/dist/translations/index.d.ts +44 -0
- package/dist/translations/index.js +533 -0
- package/dist/translations/registry.d.ts +172 -0
- package/dist/translations/registry.js +170 -0
- package/dist/translations/registry.test.d.ts +1 -0
- package/dist/translations/spec.d.ts +153 -0
- package/dist/translations/spec.js +36 -0
- package/dist/translations/spec.test.d.ts +1 -0
- package/dist/translations/tenant.d.ts +11 -0
- package/dist/translations/tenant.js +1 -0
- package/dist/translations/validation.d.ts +106 -0
- package/dist/translations/validation.js +392 -0
- package/dist/translations/validation.test.d.ts +1 -0
- package/dist/types.d.ts +212 -0
- package/dist/types.js +1 -0
- package/dist/versioning/index.d.ts +9 -0
- package/dist/versioning/index.js +274 -0
- package/dist/versioning/refs.d.ts +176 -0
- package/dist/versioning/refs.js +99 -0
- package/dist/versioning/refs.test.d.ts +4 -0
- package/dist/versioning/types.d.ts +130 -0
- package/dist/versioning/types.js +55 -0
- package/dist/versioning/utils.d.ts +93 -0
- package/dist/versioning/utils.js +184 -0
- package/dist/versioning/utils.test.d.ts +4 -0
- package/dist/workflow/adapters/db-adapter.d.ts +43 -0
- package/dist/workflow/adapters/db-adapter.js +127 -0
- package/dist/workflow/adapters/file-adapter.d.ts +10 -0
- package/dist/workflow/adapters/file-adapter.js +38 -0
- package/dist/workflow/adapters/index.d.ts +3 -0
- package/dist/workflow/adapters/index.js +194 -0
- package/dist/workflow/adapters/memory-store.d.ts +13 -0
- package/dist/workflow/adapters/memory-store.js +93 -0
- package/dist/workflow/context.d.ts +217 -0
- package/dist/workflow/context.js +247 -0
- package/dist/workflow/context.test.d.ts +1 -0
- package/dist/workflow/expression.d.ts +6 -0
- package/dist/workflow/expression.js +157 -0
- package/dist/workflow/expression.test.d.ts +1 -0
- package/dist/workflow/index.d.ts +13 -0
- package/dist/workflow/index.js +1546 -0
- package/dist/workflow/overview.docblock.d.ts +2 -0
- package/dist/workflow/overview.docblock.js +164 -0
- package/dist/workflow/runner.d.ts +71 -0
- package/dist/workflow/runner.js +532 -0
- package/dist/workflow/runner.test.d.ts +1 -0
- package/dist/workflow/sla-monitor.d.ts +16 -0
- package/dist/workflow/sla-monitor.js +84 -0
- package/dist/workflow/spec.d.ts +81 -0
- package/dist/workflow/spec.js +221 -0
- package/dist/workflow/state.d.ts +31 -0
- package/dist/workflow/state.js +1 -0
- package/dist/workflow/validation.d.ts +87 -0
- package/dist/workflow/validation.js +425 -0
- package/dist/workflow/validation.test.d.ts +1 -0
- package/dist/workspace-config/contractsrc-schema.d.ts +144 -0
- package/dist/workspace-config/contractsrc-schema.js +344 -0
- package/dist/workspace-config/contractsrc-schema.test.d.ts +1 -0
- package/dist/workspace-config/contractsrc-types.d.ts +342 -0
- package/dist/workspace-config/contractsrc-types.js +1 -0
- package/dist/workspace-config/index.d.ts +5 -0
- package/dist/workspace-config/index.js +325 -0
- package/dist/workspace-config/workspace-config.docblock.d.ts +2 -0
- package/dist/workspace-config/workspace-config.docblock.js +188 -0
- package/package.json +4426 -0
|
@@ -0,0 +1,1313 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __moduleCache = /* @__PURE__ */ new WeakMap;
|
|
7
|
+
var __toCommonJS = (from) => {
|
|
8
|
+
var entry = __moduleCache.get(from), desc;
|
|
9
|
+
if (entry)
|
|
10
|
+
return entry;
|
|
11
|
+
entry = __defProp({}, "__esModule", { value: true });
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function")
|
|
13
|
+
__getOwnPropNames(from).map((key) => !__hasOwnProp.call(entry, key) && __defProp(entry, key, {
|
|
14
|
+
get: () => from[key],
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
}));
|
|
17
|
+
__moduleCache.set(from, entry);
|
|
18
|
+
return entry;
|
|
19
|
+
};
|
|
20
|
+
var __export = (target, all) => {
|
|
21
|
+
for (var name in all)
|
|
22
|
+
__defProp(target, name, {
|
|
23
|
+
get: all[name],
|
|
24
|
+
enumerable: true,
|
|
25
|
+
configurable: true,
|
|
26
|
+
set: (newValue) => all[name] = () => newValue
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
30
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
31
|
+
|
|
32
|
+
// src/registry-utils.ts
|
|
33
|
+
var exports_registry_utils = {};
|
|
34
|
+
__export(exports_registry_utils, {
|
|
35
|
+
groupByToArray: () => groupByToArray,
|
|
36
|
+
groupByMultiple: () => groupByMultiple,
|
|
37
|
+
groupBy: () => groupBy,
|
|
38
|
+
getUniqueTags: () => getUniqueTags,
|
|
39
|
+
getUniqueOwners: () => getUniqueOwners,
|
|
40
|
+
getUniqueDomains: () => getUniqueDomains,
|
|
41
|
+
filterBy: () => filterBy,
|
|
42
|
+
GroupingStrategies: () => GroupingStrategies
|
|
43
|
+
});
|
|
44
|
+
function filterBy(items, filter) {
|
|
45
|
+
return items.filter((item) => {
|
|
46
|
+
if (filter.tags?.length) {
|
|
47
|
+
const hasMatchingTag = filter.tags.some((tag) => item.meta.tags?.includes(tag));
|
|
48
|
+
if (!hasMatchingTag)
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
if (filter.owners?.length) {
|
|
52
|
+
const hasMatchingOwner = filter.owners.some((owner) => item.meta.owners?.includes(owner));
|
|
53
|
+
if (!hasMatchingOwner)
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
if (filter.stability?.length) {
|
|
57
|
+
if (!filter.stability.includes(item.meta.stability ?? "stable")) {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
if (filter.domain) {
|
|
62
|
+
const itemDomain = GroupingStrategies.byDomain(item);
|
|
63
|
+
if (itemDomain !== filter.domain)
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
if (filter.keyPattern) {
|
|
67
|
+
const name = item.meta.key ?? item.meta.key ?? "";
|
|
68
|
+
const pattern = filter.keyPattern.replace(/\*/g, ".*").replace(/\?/g, ".");
|
|
69
|
+
const regex = new RegExp(`^${pattern}$`, "i");
|
|
70
|
+
if (!regex.test(name))
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
return true;
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
function groupBy(items, keyFn) {
|
|
77
|
+
const groups = new Map;
|
|
78
|
+
for (const item of items) {
|
|
79
|
+
const key = keyFn(item);
|
|
80
|
+
const existing = groups.get(key);
|
|
81
|
+
if (existing) {
|
|
82
|
+
existing.push(item);
|
|
83
|
+
} else {
|
|
84
|
+
groups.set(key, [item]);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return groups;
|
|
88
|
+
}
|
|
89
|
+
function groupByToArray(items, keyFn) {
|
|
90
|
+
const map = groupBy(items, keyFn);
|
|
91
|
+
return Array.from(map.entries()).map(([key, items2]) => ({ key, items: items2 }));
|
|
92
|
+
}
|
|
93
|
+
function groupByMultiple(items, keysFn) {
|
|
94
|
+
const groups = new Map;
|
|
95
|
+
for (const item of items) {
|
|
96
|
+
const keys = keysFn(item);
|
|
97
|
+
for (const key of keys) {
|
|
98
|
+
const existing = groups.get(key);
|
|
99
|
+
if (existing) {
|
|
100
|
+
existing.push(item);
|
|
101
|
+
} else {
|
|
102
|
+
groups.set(key, [item]);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return groups;
|
|
107
|
+
}
|
|
108
|
+
function getUniqueTags(items) {
|
|
109
|
+
const tags = new Set;
|
|
110
|
+
for (const item of items) {
|
|
111
|
+
for (const tag of item.meta.tags ?? []) {
|
|
112
|
+
tags.add(tag);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return Array.from(tags).sort();
|
|
116
|
+
}
|
|
117
|
+
function getUniqueOwners(items) {
|
|
118
|
+
const owners = new Set;
|
|
119
|
+
for (const item of items) {
|
|
120
|
+
for (const owner of item.meta.owners ?? []) {
|
|
121
|
+
owners.add(owner);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return Array.from(owners).sort();
|
|
125
|
+
}
|
|
126
|
+
function getUniqueDomains(items) {
|
|
127
|
+
const domains = new Set;
|
|
128
|
+
for (const item of items) {
|
|
129
|
+
domains.add(GroupingStrategies.byDomain(item));
|
|
130
|
+
}
|
|
131
|
+
return Array.from(domains).sort();
|
|
132
|
+
}
|
|
133
|
+
var GroupingStrategies;
|
|
134
|
+
var init_registry_utils = __esm(() => {
|
|
135
|
+
GroupingStrategies = {
|
|
136
|
+
byTag: (item) => item.meta.tags?.[0] ?? "untagged",
|
|
137
|
+
byAllTags: (item) => item.meta.tags?.length ? item.meta.tags : ["untagged"],
|
|
138
|
+
byOwner: (item) => item.meta.owners?.[0] ?? "unowned",
|
|
139
|
+
byDomain: (item) => {
|
|
140
|
+
const name = item.meta.key ?? item.meta.key ?? "";
|
|
141
|
+
return name.split(".")[0] ?? "default";
|
|
142
|
+
},
|
|
143
|
+
byStability: (item) => item.meta.stability ?? "stable",
|
|
144
|
+
byUrlPath: (level) => (item) => {
|
|
145
|
+
if (!item.path)
|
|
146
|
+
return "root";
|
|
147
|
+
const segments = item.path.split("/").filter(Boolean);
|
|
148
|
+
return segments.slice(0, level).join("/") || "root";
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
// src/registry.ts
|
|
154
|
+
init_registry_utils();
|
|
155
|
+
import { compareVersions } from "compare-versions";
|
|
156
|
+
var keyOfSpecContract = (spec) => `${spec.meta.key}.v${spec.meta.version}`;
|
|
157
|
+
|
|
158
|
+
class SpecContractRegistry {
|
|
159
|
+
contractType;
|
|
160
|
+
items = new Map;
|
|
161
|
+
constructor(contractType, items) {
|
|
162
|
+
this.contractType = contractType;
|
|
163
|
+
if (items) {
|
|
164
|
+
items.forEach((p) => this.register(p));
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
register(p) {
|
|
168
|
+
const key = keyOfSpecContract(p);
|
|
169
|
+
if (this.items.has(key))
|
|
170
|
+
throw new Error(`Duplicate contract \`${this.contractType}\` ${key}`);
|
|
171
|
+
this.items.set(key, p);
|
|
172
|
+
return this;
|
|
173
|
+
}
|
|
174
|
+
count() {
|
|
175
|
+
return this.items.size;
|
|
176
|
+
}
|
|
177
|
+
list() {
|
|
178
|
+
return [...this.items.values()];
|
|
179
|
+
}
|
|
180
|
+
get(key, version) {
|
|
181
|
+
if (version != null)
|
|
182
|
+
return this.items.get(`${key}.v${version}`);
|
|
183
|
+
let candidate;
|
|
184
|
+
for (const [k, p] of this.items.entries()) {
|
|
185
|
+
if (!k.startsWith(`${key}.v`))
|
|
186
|
+
continue;
|
|
187
|
+
if (!candidate || compareVersions(p.meta.version, candidate.meta.version) > 0) {
|
|
188
|
+
candidate = p;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
return candidate;
|
|
192
|
+
}
|
|
193
|
+
has(key, version) {
|
|
194
|
+
return !!this.get(key, version);
|
|
195
|
+
}
|
|
196
|
+
filter(criteria) {
|
|
197
|
+
return filterBy(this.list(), criteria);
|
|
198
|
+
}
|
|
199
|
+
listByTag(tag) {
|
|
200
|
+
return this.list().filter((p) => p.meta.tags?.includes(tag));
|
|
201
|
+
}
|
|
202
|
+
listByOwner(owner) {
|
|
203
|
+
return this.list().filter((p) => p.meta.owners?.includes(owner));
|
|
204
|
+
}
|
|
205
|
+
groupBy(keyFn) {
|
|
206
|
+
return groupBy(this.list(), keyFn);
|
|
207
|
+
}
|
|
208
|
+
getUniqueTags() {
|
|
209
|
+
return getUniqueTags(this.list());
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
// src/policy/context.ts
|
|
214
|
+
class PolicyViolationError extends Error {
|
|
215
|
+
violationType;
|
|
216
|
+
details;
|
|
217
|
+
constructor(type, details) {
|
|
218
|
+
const message = formatPolicyViolationMessage(type, details);
|
|
219
|
+
super(message);
|
|
220
|
+
this.name = "PolicyViolationError";
|
|
221
|
+
this.violationType = type;
|
|
222
|
+
this.details = details;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
function formatPolicyViolationMessage(type, details) {
|
|
226
|
+
const prefix = details.operation ? `Policy violation for "${details.operation}": ` : "Policy violation: ";
|
|
227
|
+
switch (type) {
|
|
228
|
+
case "missing_role":
|
|
229
|
+
return `${prefix}Missing required role "${details.requiredRole}"`;
|
|
230
|
+
case "missing_permission":
|
|
231
|
+
return `${prefix}Missing required permission "${details.requiredPermission}"`;
|
|
232
|
+
case "missing_attribute":
|
|
233
|
+
return `${prefix}Missing or invalid attribute "${details.requiredAttribute?.key}"`;
|
|
234
|
+
case "rate_limit_exceeded":
|
|
235
|
+
return `${prefix}Rate limit exceeded for key "${details.rateLimitKey}"`;
|
|
236
|
+
case "consent_required":
|
|
237
|
+
return `${prefix}Consent required: ${details.consentIds?.join(", ")}`;
|
|
238
|
+
case "access_denied":
|
|
239
|
+
return `${prefix}${details.reason ?? "Access denied"}`;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
class PolicyContextImpl {
|
|
244
|
+
user;
|
|
245
|
+
roles;
|
|
246
|
+
permissions;
|
|
247
|
+
rateLimitStates = new Map;
|
|
248
|
+
rateLimitConfigs;
|
|
249
|
+
auditHandler;
|
|
250
|
+
constructor(user, options = {}) {
|
|
251
|
+
this.user = user;
|
|
252
|
+
this.roles = new Set(user.roles);
|
|
253
|
+
this.permissions = new Set(user.permissions);
|
|
254
|
+
this.rateLimitConfigs = options.rateLimits ?? {};
|
|
255
|
+
this.auditHandler = options.auditHandler;
|
|
256
|
+
}
|
|
257
|
+
hasRole(role) {
|
|
258
|
+
return this.roles.has(role);
|
|
259
|
+
}
|
|
260
|
+
hasAnyRole(roles) {
|
|
261
|
+
return roles.some((r) => this.roles.has(r));
|
|
262
|
+
}
|
|
263
|
+
hasAllRoles(roles) {
|
|
264
|
+
return roles.every((r) => this.roles.has(r));
|
|
265
|
+
}
|
|
266
|
+
requireRole(role) {
|
|
267
|
+
if (!this.hasRole(role)) {
|
|
268
|
+
throw new PolicyViolationError("missing_role", { requiredRole: role });
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
hasPermission(permission) {
|
|
272
|
+
return this.permissions.has(permission);
|
|
273
|
+
}
|
|
274
|
+
hasAnyPermission(permissions) {
|
|
275
|
+
return permissions.some((p) => this.permissions.has(p));
|
|
276
|
+
}
|
|
277
|
+
hasAllPermissions(permissions) {
|
|
278
|
+
return permissions.every((p) => this.permissions.has(p));
|
|
279
|
+
}
|
|
280
|
+
requirePermission(permission) {
|
|
281
|
+
if (!this.hasPermission(permission)) {
|
|
282
|
+
throw new PolicyViolationError("missing_permission", {
|
|
283
|
+
requiredPermission: permission
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
getAttribute(key) {
|
|
288
|
+
return this.user.attributes[key];
|
|
289
|
+
}
|
|
290
|
+
checkAttribute(key, expected) {
|
|
291
|
+
return this.user.attributes[key] === expected;
|
|
292
|
+
}
|
|
293
|
+
checkAttributeOneOf(key, allowedValues) {
|
|
294
|
+
return allowedValues.includes(this.user.attributes[key]);
|
|
295
|
+
}
|
|
296
|
+
checkRateLimit(key) {
|
|
297
|
+
const config = this.rateLimitConfigs[key];
|
|
298
|
+
if (!config) {
|
|
299
|
+
return { allowed: true, remaining: Infinity };
|
|
300
|
+
}
|
|
301
|
+
const now = Date.now();
|
|
302
|
+
const state = this.rateLimitStates.get(key);
|
|
303
|
+
if (!state || now - state.windowStart >= config.windowMs) {
|
|
304
|
+
return { allowed: true, remaining: config.limit };
|
|
305
|
+
}
|
|
306
|
+
const remaining = Math.max(0, config.limit - state.count);
|
|
307
|
+
if (remaining <= 0) {
|
|
308
|
+
const resetAt = new Date(state.windowStart + config.windowMs);
|
|
309
|
+
const retryAfterMs = state.windowStart + config.windowMs - now;
|
|
310
|
+
return { allowed: false, remaining: 0, resetAt, retryAfterMs };
|
|
311
|
+
}
|
|
312
|
+
return { allowed: true, remaining };
|
|
313
|
+
}
|
|
314
|
+
consumeRateLimit(key, cost = 1) {
|
|
315
|
+
const config = this.rateLimitConfigs[key];
|
|
316
|
+
if (!config) {
|
|
317
|
+
return { allowed: true, remaining: Infinity };
|
|
318
|
+
}
|
|
319
|
+
const now = Date.now();
|
|
320
|
+
let state = this.rateLimitStates.get(key);
|
|
321
|
+
if (!state || now - state.windowStart >= config.windowMs) {
|
|
322
|
+
state = {
|
|
323
|
+
key,
|
|
324
|
+
count: 0,
|
|
325
|
+
windowStart: now,
|
|
326
|
+
windowMs: config.windowMs,
|
|
327
|
+
limit: config.limit
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
if (state.count + cost > config.limit) {
|
|
331
|
+
const resetAt = new Date(state.windowStart + config.windowMs);
|
|
332
|
+
const retryAfterMs = state.windowStart + config.windowMs - now;
|
|
333
|
+
this.rateLimitStates.set(key, state);
|
|
334
|
+
return {
|
|
335
|
+
allowed: false,
|
|
336
|
+
remaining: Math.max(0, config.limit - state.count),
|
|
337
|
+
resetAt,
|
|
338
|
+
retryAfterMs
|
|
339
|
+
};
|
|
340
|
+
}
|
|
341
|
+
state.count += cost;
|
|
342
|
+
this.rateLimitStates.set(key, state);
|
|
343
|
+
return {
|
|
344
|
+
allowed: true,
|
|
345
|
+
remaining: Math.max(0, config.limit - state.count)
|
|
346
|
+
};
|
|
347
|
+
}
|
|
348
|
+
auditAccess(operation, result, reason) {
|
|
349
|
+
if (!this.auditHandler)
|
|
350
|
+
return;
|
|
351
|
+
const entry = {
|
|
352
|
+
timestamp: new Date,
|
|
353
|
+
operation,
|
|
354
|
+
result,
|
|
355
|
+
reason,
|
|
356
|
+
userId: this.user.id,
|
|
357
|
+
tenantId: this.user.tenantId,
|
|
358
|
+
attributes: this.user.attributes
|
|
359
|
+
};
|
|
360
|
+
Promise.resolve(this.auditHandler(entry)).catch(() => {});
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
function createPolicyContext(user, options) {
|
|
364
|
+
return new PolicyContextImpl(user, options);
|
|
365
|
+
}
|
|
366
|
+
function createAnonymousPolicyContext(options) {
|
|
367
|
+
return new PolicyContextImpl({
|
|
368
|
+
id: "anonymous",
|
|
369
|
+
roles: [],
|
|
370
|
+
permissions: [],
|
|
371
|
+
attributes: {}
|
|
372
|
+
}, options);
|
|
373
|
+
}
|
|
374
|
+
function createBypassPolicyContext(allRoles, allPermissions, options) {
|
|
375
|
+
return new PolicyContextImpl({
|
|
376
|
+
id: "system",
|
|
377
|
+
roles: allRoles,
|
|
378
|
+
permissions: allPermissions,
|
|
379
|
+
attributes: { bypass: true }
|
|
380
|
+
}, options);
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
// src/policy/engine.ts
|
|
384
|
+
class PolicyEngine {
|
|
385
|
+
registry;
|
|
386
|
+
constructor(registry) {
|
|
387
|
+
this.registry = registry;
|
|
388
|
+
}
|
|
389
|
+
decide(input) {
|
|
390
|
+
const policies = this.resolvePolicies(input.policies);
|
|
391
|
+
let allowReason;
|
|
392
|
+
let appliedRateLimit;
|
|
393
|
+
let escalate;
|
|
394
|
+
for (const policy of policies) {
|
|
395
|
+
const match = this.matchRuleSet(policy, input);
|
|
396
|
+
if (!match)
|
|
397
|
+
continue;
|
|
398
|
+
if (match.rule.effect === "deny") {
|
|
399
|
+
return {
|
|
400
|
+
effect: "deny",
|
|
401
|
+
reason: match.rule.reason ?? policy.meta.key,
|
|
402
|
+
requiredConsents: match.missingConsents.length ? match.missingConsents : undefined,
|
|
403
|
+
evaluatedBy: "engine"
|
|
404
|
+
};
|
|
405
|
+
}
|
|
406
|
+
if (match.rule.effect === "allow") {
|
|
407
|
+
if (match.missingConsents.length) {
|
|
408
|
+
return {
|
|
409
|
+
effect: "deny",
|
|
410
|
+
reason: "consent_required",
|
|
411
|
+
requiredConsents: match.missingConsents,
|
|
412
|
+
evaluatedBy: "engine"
|
|
413
|
+
};
|
|
414
|
+
}
|
|
415
|
+
if (!allowReason) {
|
|
416
|
+
allowReason = match.rule.reason ?? policy.meta.key;
|
|
417
|
+
}
|
|
418
|
+
if (!appliedRateLimit && match.rateLimit) {
|
|
419
|
+
appliedRateLimit = match.rateLimit;
|
|
420
|
+
}
|
|
421
|
+
if (!escalate && match.rule.escalate) {
|
|
422
|
+
escalate = match.rule.escalate;
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
const fieldDecisions = this.evaluateFields(policies, input);
|
|
427
|
+
const pii = policies.find((p) => p.pii)?.pii;
|
|
428
|
+
const escalateValue = typeof escalate === "undefined" ? undefined : escalate;
|
|
429
|
+
return {
|
|
430
|
+
effect: allowReason ? "allow" : "deny",
|
|
431
|
+
reason: allowReason,
|
|
432
|
+
rateLimit: appliedRateLimit,
|
|
433
|
+
escalate: escalateValue,
|
|
434
|
+
fieldDecisions: fieldDecisions.length ? fieldDecisions : undefined,
|
|
435
|
+
pii,
|
|
436
|
+
evaluatedBy: "engine"
|
|
437
|
+
};
|
|
438
|
+
}
|
|
439
|
+
resolvePolicies(refs) {
|
|
440
|
+
const specs = [];
|
|
441
|
+
for (const ref of refs) {
|
|
442
|
+
const spec = this.registry.get(ref.key, ref.version);
|
|
443
|
+
if (!spec)
|
|
444
|
+
throw new Error(`PolicyEngine: policy not found ${ref.key}.v${ref.version}`);
|
|
445
|
+
specs.push(spec);
|
|
446
|
+
}
|
|
447
|
+
return specs;
|
|
448
|
+
}
|
|
449
|
+
matchRuleSet(policy, input) {
|
|
450
|
+
let allowMatch;
|
|
451
|
+
for (const rule of policy.rules) {
|
|
452
|
+
if (!rule.actions.includes(input.action))
|
|
453
|
+
continue;
|
|
454
|
+
if (!matchesSubject(rule, input.subject))
|
|
455
|
+
continue;
|
|
456
|
+
if (!matchesResource(rule, input.resource))
|
|
457
|
+
continue;
|
|
458
|
+
if (!matchesFlags(rule, input))
|
|
459
|
+
continue;
|
|
460
|
+
if (!matchesRelationships(rule.relationships, input))
|
|
461
|
+
continue;
|
|
462
|
+
if (!matchesConditions(rule, input))
|
|
463
|
+
continue;
|
|
464
|
+
const missingConsents = collectMissingConsents(rule, policy, input);
|
|
465
|
+
const rateLimit = resolveRateLimit(rule, policy, input);
|
|
466
|
+
const evaluation = {
|
|
467
|
+
rule,
|
|
468
|
+
missingConsents,
|
|
469
|
+
rateLimit
|
|
470
|
+
};
|
|
471
|
+
if (rule.effect === "deny")
|
|
472
|
+
return evaluation;
|
|
473
|
+
if (rule.effect === "allow" && !allowMatch)
|
|
474
|
+
allowMatch = evaluation;
|
|
475
|
+
}
|
|
476
|
+
return allowMatch;
|
|
477
|
+
}
|
|
478
|
+
evaluateFields(policies, input) {
|
|
479
|
+
const out = new Map;
|
|
480
|
+
for (const policy of policies) {
|
|
481
|
+
if (!policy.fieldPolicies)
|
|
482
|
+
continue;
|
|
483
|
+
for (const rule of policy.fieldPolicies) {
|
|
484
|
+
if (!rule.actions.includes(mapActionToFieldAction(input.action)))
|
|
485
|
+
continue;
|
|
486
|
+
if (!matchesSubject(rule, input.subject))
|
|
487
|
+
continue;
|
|
488
|
+
if (!matchesResource(rule, input.resource))
|
|
489
|
+
continue;
|
|
490
|
+
if (!matchesConditions(rule, input))
|
|
491
|
+
continue;
|
|
492
|
+
const existing = out.get(rule.field);
|
|
493
|
+
if (rule.effect === "deny") {
|
|
494
|
+
out.set(rule.field, {
|
|
495
|
+
field: rule.field,
|
|
496
|
+
effect: "deny",
|
|
497
|
+
reason: rule.reason ?? policy.meta.key
|
|
498
|
+
});
|
|
499
|
+
} else if (!existing) {
|
|
500
|
+
out.set(rule.field, {
|
|
501
|
+
field: rule.field,
|
|
502
|
+
effect: "allow",
|
|
503
|
+
reason: rule.reason ?? policy.meta.key
|
|
504
|
+
});
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
return [...out.values()];
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
function mapActionToFieldAction(action) {
|
|
512
|
+
if (action.startsWith("write"))
|
|
513
|
+
return "write";
|
|
514
|
+
return "read";
|
|
515
|
+
}
|
|
516
|
+
function matchesSubject(rule, subject) {
|
|
517
|
+
const matcher = rule.subject;
|
|
518
|
+
if (!matcher)
|
|
519
|
+
return true;
|
|
520
|
+
if (matcher.roles?.length) {
|
|
521
|
+
const roles = subject.roles ?? [];
|
|
522
|
+
const hasRole = matcher.roles.some((role) => roles.includes(role));
|
|
523
|
+
if (!hasRole)
|
|
524
|
+
return false;
|
|
525
|
+
}
|
|
526
|
+
if (matcher.attributes) {
|
|
527
|
+
const attributes = subject.attributes ?? {};
|
|
528
|
+
if (!matchAttributes(matcher.attributes, attributes))
|
|
529
|
+
return false;
|
|
530
|
+
}
|
|
531
|
+
return true;
|
|
532
|
+
}
|
|
533
|
+
function matchesResource(rule, resource) {
|
|
534
|
+
const matcher = rule.resource;
|
|
535
|
+
if (!matcher)
|
|
536
|
+
return true;
|
|
537
|
+
if (matcher.type && matcher.type !== resource.type)
|
|
538
|
+
return false;
|
|
539
|
+
if (matcher.fields?.length) {
|
|
540
|
+
const targetFields = resource.fields ?? [];
|
|
541
|
+
if (!matcher.fields.some((field) => targetFields.includes(field)))
|
|
542
|
+
return false;
|
|
543
|
+
}
|
|
544
|
+
if (matcher.attributes) {
|
|
545
|
+
const attributes = resource.attributes ?? {};
|
|
546
|
+
if (!matchAttributes(matcher.attributes, attributes))
|
|
547
|
+
return false;
|
|
548
|
+
}
|
|
549
|
+
return true;
|
|
550
|
+
}
|
|
551
|
+
function matchesFlags(rule, input) {
|
|
552
|
+
if (!rule.flags?.length)
|
|
553
|
+
return true;
|
|
554
|
+
const available = new Set;
|
|
555
|
+
if (input.flags) {
|
|
556
|
+
for (const flag of input.flags)
|
|
557
|
+
available.add(flag);
|
|
558
|
+
}
|
|
559
|
+
const attributeFlags = input.subject.attributes?.featureFlags;
|
|
560
|
+
if (Array.isArray(attributeFlags)) {
|
|
561
|
+
for (const flag of attributeFlags)
|
|
562
|
+
available.add(flag);
|
|
563
|
+
}
|
|
564
|
+
return rule.flags.every((flag) => available.has(flag));
|
|
565
|
+
}
|
|
566
|
+
function matchesRelationships(matchers, input) {
|
|
567
|
+
if (!matchers || matchers.length === 0)
|
|
568
|
+
return true;
|
|
569
|
+
const relationships = input.subject.relationships ?? [];
|
|
570
|
+
const resourceId = getResourceId(input.resource);
|
|
571
|
+
const resourceType = input.resource.type;
|
|
572
|
+
return matchers.every((matcher) => relationships.some((relation) => {
|
|
573
|
+
if (relation.relation !== matcher.relation)
|
|
574
|
+
return false;
|
|
575
|
+
const typeMatches = !matcher.objectType || relation.objectType === matcher.objectType || matcher.objectType === resourceType;
|
|
576
|
+
if (!typeMatches)
|
|
577
|
+
return false;
|
|
578
|
+
if (!matcher.objectId)
|
|
579
|
+
return true;
|
|
580
|
+
if (matcher.objectId === "$resource") {
|
|
581
|
+
if (resourceId) {
|
|
582
|
+
return relation.object === resourceId;
|
|
583
|
+
}
|
|
584
|
+
return relation.object === resourceType || relation.objectType === resourceType;
|
|
585
|
+
}
|
|
586
|
+
return relation.object === matcher.objectId;
|
|
587
|
+
}));
|
|
588
|
+
}
|
|
589
|
+
function matchesConditions(rule, input) {
|
|
590
|
+
if (!rule.conditions || rule.conditions.length === 0)
|
|
591
|
+
return true;
|
|
592
|
+
return rule.conditions.every((condition) => evaluateCondition(condition.expression, input));
|
|
593
|
+
}
|
|
594
|
+
function matchAttributes(matcher, actual) {
|
|
595
|
+
for (const [key, attrMatcher] of Object.entries(matcher)) {
|
|
596
|
+
const value = actual[key];
|
|
597
|
+
if (attrMatcher.exists && typeof value === "undefined")
|
|
598
|
+
return false;
|
|
599
|
+
if (typeof attrMatcher.equals !== "undefined") {
|
|
600
|
+
if (value !== attrMatcher.equals)
|
|
601
|
+
return false;
|
|
602
|
+
}
|
|
603
|
+
if (attrMatcher.oneOf && !attrMatcher.oneOf.includes(value))
|
|
604
|
+
return false;
|
|
605
|
+
}
|
|
606
|
+
return true;
|
|
607
|
+
}
|
|
608
|
+
function collectMissingConsents(rule, policy, input) {
|
|
609
|
+
if (!rule.requiresConsent?.length)
|
|
610
|
+
return [];
|
|
611
|
+
const granted = new Set(input.consents ?? []);
|
|
612
|
+
const missingIds = rule.requiresConsent.filter((id) => !granted.has(id));
|
|
613
|
+
if (missingIds.length === 0)
|
|
614
|
+
return [];
|
|
615
|
+
return resolveConsentDefinitions(policy, missingIds);
|
|
616
|
+
}
|
|
617
|
+
function resolveConsentDefinitions(policy, ids) {
|
|
618
|
+
const catalog = policy.consents ?? [];
|
|
619
|
+
return ids.map((id) => {
|
|
620
|
+
const found = catalog.find((consent) => consent.id === id);
|
|
621
|
+
return found ?? {
|
|
622
|
+
id,
|
|
623
|
+
scope: "unspecified",
|
|
624
|
+
purpose: "unspecified",
|
|
625
|
+
description: `Consent "${id}" required by ${policy.meta.key}`,
|
|
626
|
+
required: true
|
|
627
|
+
};
|
|
628
|
+
});
|
|
629
|
+
}
|
|
630
|
+
function resolveRateLimit(rule, policy, input) {
|
|
631
|
+
if (!rule.rateLimit)
|
|
632
|
+
return;
|
|
633
|
+
const definition = typeof rule.rateLimit === "string" ? (policy.rateLimits ?? []).find((item) => item.id === rule.rateLimit) : rule.rateLimit;
|
|
634
|
+
if (!definition) {
|
|
635
|
+
throw new Error(`PolicyEngine: rate limit "${String(rule.rateLimit)}" not declared in ${policy.meta.key}`);
|
|
636
|
+
}
|
|
637
|
+
return {
|
|
638
|
+
rpm: definition.rpm,
|
|
639
|
+
key: definition.key ?? input.resource.type,
|
|
640
|
+
windowSeconds: definition.windowSeconds,
|
|
641
|
+
burst: definition.burst
|
|
642
|
+
};
|
|
643
|
+
}
|
|
644
|
+
function evaluateCondition(expression, input) {
|
|
645
|
+
const trimmed = expression.trim();
|
|
646
|
+
if (!trimmed)
|
|
647
|
+
return true;
|
|
648
|
+
const context = {
|
|
649
|
+
subject: input.subject,
|
|
650
|
+
resource: input.resource,
|
|
651
|
+
context: input.context ?? {}
|
|
652
|
+
};
|
|
653
|
+
try {
|
|
654
|
+
const fn = new Function("subject", "resource", "context", `return (${transformExpression(trimmed)});`);
|
|
655
|
+
const result = fn(context.subject, context.resource, context.context);
|
|
656
|
+
return Boolean(result);
|
|
657
|
+
} catch (_error) {
|
|
658
|
+
return false;
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
function transformExpression(expression) {
|
|
662
|
+
return expression.replace(/&&/g, "&&").replace(/\|\|/g, "||");
|
|
663
|
+
}
|
|
664
|
+
function getResourceId(resource) {
|
|
665
|
+
if (resource.id)
|
|
666
|
+
return resource.id;
|
|
667
|
+
const candidate = resource.attributes?.id;
|
|
668
|
+
if (typeof candidate === "string")
|
|
669
|
+
return candidate;
|
|
670
|
+
if (typeof candidate === "number")
|
|
671
|
+
return String(candidate);
|
|
672
|
+
return;
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
// src/policy/guards.ts
|
|
676
|
+
function checkAuthLevel(ctx, required) {
|
|
677
|
+
if (required === "anonymous")
|
|
678
|
+
return true;
|
|
679
|
+
if (required === "user") {
|
|
680
|
+
return ctx.user.id !== "anonymous";
|
|
681
|
+
}
|
|
682
|
+
if (required === "admin") {
|
|
683
|
+
return ctx.hasRole("admin");
|
|
684
|
+
}
|
|
685
|
+
return false;
|
|
686
|
+
}
|
|
687
|
+
function checkPolicyForOperation(ctx, operation, flags = []) {
|
|
688
|
+
const { policy } = operation;
|
|
689
|
+
const operationName = `${operation.meta.key}.v${operation.meta.version}`;
|
|
690
|
+
const missing = {};
|
|
691
|
+
if (!checkAuthLevel(ctx, policy.auth)) {
|
|
692
|
+
return {
|
|
693
|
+
allowed: false,
|
|
694
|
+
reason: `Operation "${operationName}" requires "${policy.auth}" auth level`,
|
|
695
|
+
missing: {
|
|
696
|
+
roles: policy.auth === "admin" ? ["admin"] : undefined
|
|
697
|
+
}
|
|
698
|
+
};
|
|
699
|
+
}
|
|
700
|
+
if (policy.flags?.length) {
|
|
701
|
+
const availableFlags = new Set(flags);
|
|
702
|
+
const missingFlags = policy.flags.filter((f) => !availableFlags.has(f));
|
|
703
|
+
if (missingFlags.length > 0) {
|
|
704
|
+
missing.flags = missingFlags;
|
|
705
|
+
return {
|
|
706
|
+
allowed: false,
|
|
707
|
+
reason: `Operation "${operationName}" requires feature flags: ${missingFlags.join(", ")}`,
|
|
708
|
+
missing
|
|
709
|
+
};
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
return { allowed: true };
|
|
713
|
+
}
|
|
714
|
+
function assertPolicyForOperation(ctx, operation, flags = []) {
|
|
715
|
+
const result = checkPolicyForOperation(ctx, operation, flags);
|
|
716
|
+
if (!result.allowed) {
|
|
717
|
+
const operationName2 = `${operation.meta.key}.v${operation.meta.version}`;
|
|
718
|
+
ctx.auditAccess(operationName2, "denied", result.reason);
|
|
719
|
+
throw new PolicyViolationError("access_denied", {
|
|
720
|
+
operation: operationName2,
|
|
721
|
+
reason: result.reason
|
|
722
|
+
});
|
|
723
|
+
}
|
|
724
|
+
const operationName = `${operation.meta.key}.v${operation.meta.version}`;
|
|
725
|
+
ctx.auditAccess(operationName, "allowed");
|
|
726
|
+
}
|
|
727
|
+
function filterOperationsByPolicy(ctx, operations, flags = []) {
|
|
728
|
+
return operations.filter((op) => checkPolicyForOperation(ctx, op, flags).allowed);
|
|
729
|
+
}
|
|
730
|
+
function checkRole(ctx, requiredRole, operation) {
|
|
731
|
+
if (ctx.hasRole(requiredRole)) {
|
|
732
|
+
return { allowed: true };
|
|
733
|
+
}
|
|
734
|
+
return {
|
|
735
|
+
allowed: false,
|
|
736
|
+
reason: operation ? `Operation "${operation}" requires role "${requiredRole}"` : `Missing required role "${requiredRole}"`,
|
|
737
|
+
missing: { roles: [requiredRole] }
|
|
738
|
+
};
|
|
739
|
+
}
|
|
740
|
+
function assertRole(ctx, requiredRole, operation) {
|
|
741
|
+
const result = checkRole(ctx, requiredRole, operation);
|
|
742
|
+
if (!result.allowed) {
|
|
743
|
+
throw new PolicyViolationError("missing_role", {
|
|
744
|
+
operation,
|
|
745
|
+
requiredRole
|
|
746
|
+
});
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
function checkAnyRole(ctx, requiredRoles, operation) {
|
|
750
|
+
if (ctx.hasAnyRole(requiredRoles)) {
|
|
751
|
+
return { allowed: true };
|
|
752
|
+
}
|
|
753
|
+
return {
|
|
754
|
+
allowed: false,
|
|
755
|
+
reason: operation ? `Operation "${operation}" requires one of roles: ${requiredRoles.join(", ")}` : `Missing required role (need one of: ${requiredRoles.join(", ")})`,
|
|
756
|
+
missing: { roles: requiredRoles }
|
|
757
|
+
};
|
|
758
|
+
}
|
|
759
|
+
function checkPermission(ctx, requiredPermission, operation) {
|
|
760
|
+
if (ctx.hasPermission(requiredPermission)) {
|
|
761
|
+
return { allowed: true };
|
|
762
|
+
}
|
|
763
|
+
return {
|
|
764
|
+
allowed: false,
|
|
765
|
+
reason: operation ? `Operation "${operation}" requires permission "${requiredPermission}"` : `Missing required permission "${requiredPermission}"`,
|
|
766
|
+
missing: { permissions: [requiredPermission] }
|
|
767
|
+
};
|
|
768
|
+
}
|
|
769
|
+
function assertPermission(ctx, requiredPermission, operation) {
|
|
770
|
+
const result = checkPermission(ctx, requiredPermission, operation);
|
|
771
|
+
if (!result.allowed) {
|
|
772
|
+
throw new PolicyViolationError("missing_permission", {
|
|
773
|
+
operation,
|
|
774
|
+
requiredPermission
|
|
775
|
+
});
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
function checkAllPermissions(ctx, requiredPermissions, operation) {
|
|
779
|
+
const missing = requiredPermissions.filter((p) => !ctx.hasPermission(p));
|
|
780
|
+
if (missing.length === 0) {
|
|
781
|
+
return { allowed: true };
|
|
782
|
+
}
|
|
783
|
+
return {
|
|
784
|
+
allowed: false,
|
|
785
|
+
reason: operation ? `Operation "${operation}" requires permissions: ${missing.join(", ")}` : `Missing required permissions: ${missing.join(", ")}`,
|
|
786
|
+
missing: { permissions: missing }
|
|
787
|
+
};
|
|
788
|
+
}
|
|
789
|
+
function checkCombinedPolicy(ctx, requirements, flags = [], operation) {
|
|
790
|
+
const missing = {};
|
|
791
|
+
const reasons = [];
|
|
792
|
+
if (requirements.roles?.length) {
|
|
793
|
+
const missingRoles = requirements.roles.filter((r) => !ctx.hasRole(r));
|
|
794
|
+
if (missingRoles.length > 0) {
|
|
795
|
+
missing.roles = missingRoles;
|
|
796
|
+
reasons.push(`Missing roles: ${missingRoles.join(", ")}`);
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
if (requirements.anyRole?.length) {
|
|
800
|
+
if (!ctx.hasAnyRole(requirements.anyRole)) {
|
|
801
|
+
missing.roles = [...missing.roles ?? [], ...requirements.anyRole];
|
|
802
|
+
reasons.push(`Need one of roles: ${requirements.anyRole.join(", ")}`);
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
if (requirements.permissions?.length) {
|
|
806
|
+
const missingPerms = requirements.permissions.filter((p) => !ctx.hasPermission(p));
|
|
807
|
+
if (missingPerms.length > 0) {
|
|
808
|
+
missing.permissions = missingPerms;
|
|
809
|
+
reasons.push(`Missing permissions: ${missingPerms.join(", ")}`);
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
if (requirements.anyPermission?.length) {
|
|
813
|
+
if (!ctx.hasAnyPermission(requirements.anyPermission)) {
|
|
814
|
+
missing.permissions = [
|
|
815
|
+
...missing.permissions ?? [],
|
|
816
|
+
...requirements.anyPermission
|
|
817
|
+
];
|
|
818
|
+
reasons.push(`Need one of permissions: ${requirements.anyPermission.join(", ")}`);
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
if (requirements.flags?.length) {
|
|
822
|
+
const availableFlags = new Set(flags);
|
|
823
|
+
const missingFlags = requirements.flags.filter((f) => !availableFlags.has(f));
|
|
824
|
+
if (missingFlags.length > 0) {
|
|
825
|
+
missing.flags = missingFlags;
|
|
826
|
+
reasons.push(`Missing feature flags: ${missingFlags.join(", ")}`);
|
|
827
|
+
}
|
|
828
|
+
}
|
|
829
|
+
if (reasons.length > 0) {
|
|
830
|
+
const prefix = operation ? `Operation "${operation}": ` : "";
|
|
831
|
+
return {
|
|
832
|
+
allowed: false,
|
|
833
|
+
reason: prefix + reasons.join("; "),
|
|
834
|
+
missing
|
|
835
|
+
};
|
|
836
|
+
}
|
|
837
|
+
return { allowed: true };
|
|
838
|
+
}
|
|
839
|
+
function assertCombinedPolicy(ctx, requirements, flags = [], operation) {
|
|
840
|
+
const result = checkCombinedPolicy(ctx, requirements, flags, operation);
|
|
841
|
+
if (!result.allowed) {
|
|
842
|
+
throw new PolicyViolationError("access_denied", {
|
|
843
|
+
operation,
|
|
844
|
+
reason: result.reason
|
|
845
|
+
});
|
|
846
|
+
}
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
// src/policy/opa-adapter.ts
|
|
850
|
+
class OPAPolicyAdapter {
|
|
851
|
+
client;
|
|
852
|
+
options;
|
|
853
|
+
constructor(client, options) {
|
|
854
|
+
this.client = client;
|
|
855
|
+
this.options = options;
|
|
856
|
+
}
|
|
857
|
+
async evaluate(context, policies, engineDecision) {
|
|
858
|
+
const input = buildOPAInput(context, policies, engineDecision);
|
|
859
|
+
const raw = await this.client.evaluate(this.options.decisionPath, input);
|
|
860
|
+
const resolved = this.options.mapResult ? this.options.mapResult(raw) : raw;
|
|
861
|
+
if (!resolved) {
|
|
862
|
+
return {
|
|
863
|
+
...engineDecision,
|
|
864
|
+
evaluatedBy: engineDecision.evaluatedBy ?? "engine"
|
|
865
|
+
};
|
|
866
|
+
}
|
|
867
|
+
const opaResult = resolved;
|
|
868
|
+
const mergedRequiredConsents = mergeRequiredConsents(policies, engineDecision.requiredConsents ?? [], opaResult.requiredConsents ?? []);
|
|
869
|
+
return {
|
|
870
|
+
...engineDecision,
|
|
871
|
+
effect: opaResult.effect ?? engineDecision.effect,
|
|
872
|
+
reason: opaResult.reason ?? engineDecision.reason,
|
|
873
|
+
fieldDecisions: opaResult.fieldDecisions ?? engineDecision.fieldDecisions,
|
|
874
|
+
requiredConsents: mergedRequiredConsents.length ? mergedRequiredConsents : undefined,
|
|
875
|
+
evaluatedBy: "opa"
|
|
876
|
+
};
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
function buildOPAInput(context, policies, engineDecision) {
|
|
880
|
+
return {
|
|
881
|
+
context,
|
|
882
|
+
decision: engineDecision,
|
|
883
|
+
policies: policies.map((policy) => ({
|
|
884
|
+
meta: policy.meta,
|
|
885
|
+
rules: policy.rules,
|
|
886
|
+
fieldPolicies: policy.fieldPolicies,
|
|
887
|
+
pii: policy.pii,
|
|
888
|
+
relationships: policy.relationships,
|
|
889
|
+
consents: policy.consents,
|
|
890
|
+
rateLimits: policy.rateLimits
|
|
891
|
+
}))
|
|
892
|
+
};
|
|
893
|
+
}
|
|
894
|
+
function mergeRequiredConsents(policies, existing, incomingIds) {
|
|
895
|
+
if (incomingIds.length === 0)
|
|
896
|
+
return existing;
|
|
897
|
+
const existingIds = new Set(existing.map((consent) => consent.id));
|
|
898
|
+
const merged = [...existing];
|
|
899
|
+
for (const id of incomingIds) {
|
|
900
|
+
if (existingIds.has(id))
|
|
901
|
+
continue;
|
|
902
|
+
const resolved = resolveConsentAcrossPolicies(policies, id);
|
|
903
|
+
if (resolved) {
|
|
904
|
+
merged.push(resolved);
|
|
905
|
+
existingIds.add(resolved.id);
|
|
906
|
+
}
|
|
907
|
+
}
|
|
908
|
+
return merged;
|
|
909
|
+
}
|
|
910
|
+
function resolveConsentAcrossPolicies(policies, id) {
|
|
911
|
+
for (const policy of policies) {
|
|
912
|
+
const match = policy.consents?.find((consent) => consent.id === id);
|
|
913
|
+
if (match)
|
|
914
|
+
return match;
|
|
915
|
+
}
|
|
916
|
+
return {
|
|
917
|
+
id,
|
|
918
|
+
scope: "unspecified",
|
|
919
|
+
purpose: "unspecified",
|
|
920
|
+
description: `Consent "${id}" returned by OPA`,
|
|
921
|
+
required: true
|
|
922
|
+
};
|
|
923
|
+
}
|
|
924
|
+
// src/policy/registry.ts
|
|
925
|
+
class PolicyRegistry extends SpecContractRegistry {
|
|
926
|
+
constructor(items) {
|
|
927
|
+
super("policy", items);
|
|
928
|
+
}
|
|
929
|
+
}
|
|
930
|
+
|
|
931
|
+
// src/policy/validation.ts
|
|
932
|
+
function validatePolicySpec(spec) {
|
|
933
|
+
const issues = [];
|
|
934
|
+
validateMeta(spec, issues);
|
|
935
|
+
validateRules(spec, issues);
|
|
936
|
+
validateFieldPolicies(spec, issues);
|
|
937
|
+
validateRateLimits(spec, issues);
|
|
938
|
+
validateConsents(spec, issues);
|
|
939
|
+
validateRelationships(spec, issues);
|
|
940
|
+
return {
|
|
941
|
+
valid: issues.filter((i) => i.level === "error").length === 0,
|
|
942
|
+
issues
|
|
943
|
+
};
|
|
944
|
+
}
|
|
945
|
+
function validateMeta(spec, issues) {
|
|
946
|
+
const { meta } = spec;
|
|
947
|
+
if (!meta.key?.trim()) {
|
|
948
|
+
issues.push({
|
|
949
|
+
level: "error",
|
|
950
|
+
message: "Policy must have a non-empty key",
|
|
951
|
+
path: "meta.key"
|
|
952
|
+
});
|
|
953
|
+
}
|
|
954
|
+
if (!meta.version?.trim()) {
|
|
955
|
+
issues.push({
|
|
956
|
+
level: "error",
|
|
957
|
+
message: "Policy must have a non-empty version",
|
|
958
|
+
path: "meta.version"
|
|
959
|
+
});
|
|
960
|
+
}
|
|
961
|
+
if (!meta.owners?.length) {
|
|
962
|
+
issues.push({
|
|
963
|
+
level: "warning",
|
|
964
|
+
message: "Policy should specify owners",
|
|
965
|
+
path: "meta.owners"
|
|
966
|
+
});
|
|
967
|
+
}
|
|
968
|
+
}
|
|
969
|
+
function validateRules(spec, issues) {
|
|
970
|
+
if (!spec.rules?.length) {
|
|
971
|
+
issues.push({
|
|
972
|
+
level: "warning",
|
|
973
|
+
message: "Policy has no rules defined",
|
|
974
|
+
path: "rules"
|
|
975
|
+
});
|
|
976
|
+
return;
|
|
977
|
+
}
|
|
978
|
+
const seenRateRefs = new Set;
|
|
979
|
+
spec.rules.forEach((rule, index) => {
|
|
980
|
+
const path = `rules[${index}]`;
|
|
981
|
+
if (!rule.actions?.length) {
|
|
982
|
+
issues.push({
|
|
983
|
+
level: "error",
|
|
984
|
+
message: "Rule must specify at least one action",
|
|
985
|
+
path: `${path}.actions`
|
|
986
|
+
});
|
|
987
|
+
}
|
|
988
|
+
if (!["allow", "deny"].includes(rule.effect)) {
|
|
989
|
+
issues.push({
|
|
990
|
+
level: "error",
|
|
991
|
+
message: `Invalid rule effect: ${rule.effect}`,
|
|
992
|
+
path: `${path}.effect`
|
|
993
|
+
});
|
|
994
|
+
}
|
|
995
|
+
if (typeof rule.rateLimit === "string") {
|
|
996
|
+
seenRateRefs.add(rule.rateLimit);
|
|
997
|
+
if (!spec.rateLimits?.some((rl) => rl.id === rule.rateLimit)) {
|
|
998
|
+
issues.push({
|
|
999
|
+
level: "error",
|
|
1000
|
+
message: `Rate limit "${rule.rateLimit}" referenced but not defined`,
|
|
1001
|
+
path: `${path}.rateLimit`
|
|
1002
|
+
});
|
|
1003
|
+
}
|
|
1004
|
+
}
|
|
1005
|
+
if (rule.requiresConsent?.length) {
|
|
1006
|
+
for (const consentId of rule.requiresConsent) {
|
|
1007
|
+
if (!spec.consents?.some((c) => c.id === consentId)) {
|
|
1008
|
+
issues.push({
|
|
1009
|
+
level: "error",
|
|
1010
|
+
message: `Consent "${consentId}" referenced but not defined`,
|
|
1011
|
+
path: `${path}.requiresConsent`
|
|
1012
|
+
});
|
|
1013
|
+
}
|
|
1014
|
+
}
|
|
1015
|
+
}
|
|
1016
|
+
validateConditions(rule.conditions, `${path}.conditions`, issues);
|
|
1017
|
+
});
|
|
1018
|
+
if (spec.rateLimits?.length) {
|
|
1019
|
+
for (const rl of spec.rateLimits) {
|
|
1020
|
+
if (!seenRateRefs.has(rl.id)) {
|
|
1021
|
+
const hasInline = spec.rules.some((r) => typeof r.rateLimit === "object" && r.rateLimit.id === rl.id);
|
|
1022
|
+
if (!hasInline) {
|
|
1023
|
+
issues.push({
|
|
1024
|
+
level: "info",
|
|
1025
|
+
message: `Rate limit "${rl.id}" is defined but not referenced`,
|
|
1026
|
+
path: `rateLimits`
|
|
1027
|
+
});
|
|
1028
|
+
}
|
|
1029
|
+
}
|
|
1030
|
+
}
|
|
1031
|
+
}
|
|
1032
|
+
}
|
|
1033
|
+
function validateFieldPolicies(spec, issues) {
|
|
1034
|
+
if (!spec.fieldPolicies?.length)
|
|
1035
|
+
return;
|
|
1036
|
+
const seenFields = new Map;
|
|
1037
|
+
spec.fieldPolicies.forEach((rule, index) => {
|
|
1038
|
+
const path = `fieldPolicies[${index}]`;
|
|
1039
|
+
if (!rule.field?.trim()) {
|
|
1040
|
+
issues.push({
|
|
1041
|
+
level: "error",
|
|
1042
|
+
message: "Field policy must specify a field",
|
|
1043
|
+
path: `${path}.field`
|
|
1044
|
+
});
|
|
1045
|
+
}
|
|
1046
|
+
if (!rule.actions?.length) {
|
|
1047
|
+
issues.push({
|
|
1048
|
+
level: "error",
|
|
1049
|
+
message: "Field policy must specify at least one action",
|
|
1050
|
+
path: `${path}.actions`
|
|
1051
|
+
});
|
|
1052
|
+
}
|
|
1053
|
+
for (const action of rule.actions) {
|
|
1054
|
+
if (!["read", "write"].includes(action)) {
|
|
1055
|
+
issues.push({
|
|
1056
|
+
level: "error",
|
|
1057
|
+
message: `Invalid field action: ${action}`,
|
|
1058
|
+
path: `${path}.actions`
|
|
1059
|
+
});
|
|
1060
|
+
}
|
|
1061
|
+
}
|
|
1062
|
+
const existing = seenFields.get(rule.field) ?? [];
|
|
1063
|
+
existing.push(rule);
|
|
1064
|
+
seenFields.set(rule.field, existing);
|
|
1065
|
+
validateConditions(rule.conditions, `${path}.conditions`, issues);
|
|
1066
|
+
});
|
|
1067
|
+
for (const [field, rules] of seenFields.entries()) {
|
|
1068
|
+
if (rules.length > 1) {
|
|
1069
|
+
const hasConflict = rules.some((r) => r.effect === "allow") && rules.some((r) => r.effect === "deny");
|
|
1070
|
+
if (hasConflict) {
|
|
1071
|
+
issues.push({
|
|
1072
|
+
level: "warning",
|
|
1073
|
+
message: `Field "${field}" has potentially conflicting allow/deny policies`,
|
|
1074
|
+
path: "fieldPolicies",
|
|
1075
|
+
context: { field, ruleCount: rules.length }
|
|
1076
|
+
});
|
|
1077
|
+
}
|
|
1078
|
+
}
|
|
1079
|
+
}
|
|
1080
|
+
}
|
|
1081
|
+
function validateRateLimits(spec, issues) {
|
|
1082
|
+
if (!spec.rateLimits?.length)
|
|
1083
|
+
return;
|
|
1084
|
+
const seenIds = new Set;
|
|
1085
|
+
spec.rateLimits.forEach((rl, index) => {
|
|
1086
|
+
const path = `rateLimits[${index}]`;
|
|
1087
|
+
if (!rl.id?.trim()) {
|
|
1088
|
+
issues.push({
|
|
1089
|
+
level: "error",
|
|
1090
|
+
message: "Rate limit must have an id",
|
|
1091
|
+
path: `${path}.id`
|
|
1092
|
+
});
|
|
1093
|
+
} else if (seenIds.has(rl.id)) {
|
|
1094
|
+
issues.push({
|
|
1095
|
+
level: "error",
|
|
1096
|
+
message: `Duplicate rate limit id: ${rl.id}`,
|
|
1097
|
+
path: `${path}.id`
|
|
1098
|
+
});
|
|
1099
|
+
} else {
|
|
1100
|
+
seenIds.add(rl.id);
|
|
1101
|
+
}
|
|
1102
|
+
if (typeof rl.rpm !== "number" || rl.rpm <= 0) {
|
|
1103
|
+
issues.push({
|
|
1104
|
+
level: "error",
|
|
1105
|
+
message: "Rate limit rpm must be a positive number",
|
|
1106
|
+
path: `${path}.rpm`
|
|
1107
|
+
});
|
|
1108
|
+
}
|
|
1109
|
+
if (rl.windowSeconds !== undefined && rl.windowSeconds <= 0) {
|
|
1110
|
+
issues.push({
|
|
1111
|
+
level: "error",
|
|
1112
|
+
message: "Rate limit windowSeconds must be positive if specified",
|
|
1113
|
+
path: `${path}.windowSeconds`
|
|
1114
|
+
});
|
|
1115
|
+
}
|
|
1116
|
+
if (rl.burst !== undefined && rl.burst < 0) {
|
|
1117
|
+
issues.push({
|
|
1118
|
+
level: "error",
|
|
1119
|
+
message: "Rate limit burst must be non-negative if specified",
|
|
1120
|
+
path: `${path}.burst`
|
|
1121
|
+
});
|
|
1122
|
+
}
|
|
1123
|
+
});
|
|
1124
|
+
}
|
|
1125
|
+
function validateConsents(spec, issues) {
|
|
1126
|
+
if (!spec.consents?.length)
|
|
1127
|
+
return;
|
|
1128
|
+
const seenIds = new Set;
|
|
1129
|
+
spec.consents.forEach((consent, index) => {
|
|
1130
|
+
const path = `consents[${index}]`;
|
|
1131
|
+
if (!consent.id?.trim()) {
|
|
1132
|
+
issues.push({
|
|
1133
|
+
level: "error",
|
|
1134
|
+
message: "Consent must have an id",
|
|
1135
|
+
path: `${path}.id`
|
|
1136
|
+
});
|
|
1137
|
+
} else if (seenIds.has(consent.id)) {
|
|
1138
|
+
issues.push({
|
|
1139
|
+
level: "error",
|
|
1140
|
+
message: `Duplicate consent id: ${consent.id}`,
|
|
1141
|
+
path: `${path}.id`
|
|
1142
|
+
});
|
|
1143
|
+
} else {
|
|
1144
|
+
seenIds.add(consent.id);
|
|
1145
|
+
}
|
|
1146
|
+
if (!consent.scope?.trim()) {
|
|
1147
|
+
issues.push({
|
|
1148
|
+
level: "error",
|
|
1149
|
+
message: "Consent must specify a scope",
|
|
1150
|
+
path: `${path}.scope`
|
|
1151
|
+
});
|
|
1152
|
+
}
|
|
1153
|
+
if (!consent.purpose?.trim()) {
|
|
1154
|
+
issues.push({
|
|
1155
|
+
level: "error",
|
|
1156
|
+
message: "Consent must specify a purpose",
|
|
1157
|
+
path: `${path}.purpose`
|
|
1158
|
+
});
|
|
1159
|
+
}
|
|
1160
|
+
if (consent.expiresInDays !== undefined && consent.expiresInDays <= 0) {
|
|
1161
|
+
issues.push({
|
|
1162
|
+
level: "error",
|
|
1163
|
+
message: "Consent expiresInDays must be positive if specified",
|
|
1164
|
+
path: `${path}.expiresInDays`
|
|
1165
|
+
});
|
|
1166
|
+
}
|
|
1167
|
+
});
|
|
1168
|
+
}
|
|
1169
|
+
function validateRelationships(spec, issues) {
|
|
1170
|
+
if (!spec.relationships?.length)
|
|
1171
|
+
return;
|
|
1172
|
+
const seenRelations = new Set;
|
|
1173
|
+
spec.relationships.forEach((rel, index) => {
|
|
1174
|
+
const path = `relationships[${index}]`;
|
|
1175
|
+
const key = `${rel.subjectType}:${rel.relation}:${rel.objectType}`;
|
|
1176
|
+
if (!rel.subjectType?.trim()) {
|
|
1177
|
+
issues.push({
|
|
1178
|
+
level: "error",
|
|
1179
|
+
message: "Relationship must specify subjectType",
|
|
1180
|
+
path: `${path}.subjectType`
|
|
1181
|
+
});
|
|
1182
|
+
}
|
|
1183
|
+
if (!rel.relation?.trim()) {
|
|
1184
|
+
issues.push({
|
|
1185
|
+
level: "error",
|
|
1186
|
+
message: "Relationship must specify relation",
|
|
1187
|
+
path: `${path}.relation`
|
|
1188
|
+
});
|
|
1189
|
+
}
|
|
1190
|
+
if (!rel.objectType?.trim()) {
|
|
1191
|
+
issues.push({
|
|
1192
|
+
level: "error",
|
|
1193
|
+
message: "Relationship must specify objectType",
|
|
1194
|
+
path: `${path}.objectType`
|
|
1195
|
+
});
|
|
1196
|
+
}
|
|
1197
|
+
if (seenRelations.has(key)) {
|
|
1198
|
+
issues.push({
|
|
1199
|
+
level: "warning",
|
|
1200
|
+
message: `Duplicate relationship definition: ${key}`,
|
|
1201
|
+
path
|
|
1202
|
+
});
|
|
1203
|
+
} else {
|
|
1204
|
+
seenRelations.add(key);
|
|
1205
|
+
}
|
|
1206
|
+
});
|
|
1207
|
+
}
|
|
1208
|
+
function validateConditions(conditions, path, issues) {
|
|
1209
|
+
if (!conditions?.length)
|
|
1210
|
+
return;
|
|
1211
|
+
conditions.forEach((cond, index) => {
|
|
1212
|
+
if (!cond.expression?.trim()) {
|
|
1213
|
+
issues.push({
|
|
1214
|
+
level: "error",
|
|
1215
|
+
message: "Condition must have a non-empty expression",
|
|
1216
|
+
path: `${path}[${index}].expression`
|
|
1217
|
+
});
|
|
1218
|
+
}
|
|
1219
|
+
});
|
|
1220
|
+
}
|
|
1221
|
+
function validatePolicyConsistency(deps) {
|
|
1222
|
+
const issues = [];
|
|
1223
|
+
for (const policy of deps.policies.list()) {
|
|
1224
|
+
const specResult = validatePolicySpec(policy);
|
|
1225
|
+
issues.push(...specResult.issues.map((i) => ({
|
|
1226
|
+
...i,
|
|
1227
|
+
path: `${policy.meta.key}.v${policy.meta.version}${i.path ? `.${i.path}` : ""}`
|
|
1228
|
+
})));
|
|
1229
|
+
}
|
|
1230
|
+
if (deps.operations) {
|
|
1231
|
+
for (const operation of deps.operations.list()) {
|
|
1232
|
+
const policyRefs = operation.policy.policies ?? [];
|
|
1233
|
+
for (const ref of policyRefs) {
|
|
1234
|
+
const policy = deps.policies.get(ref.key, ref.version);
|
|
1235
|
+
if (!policy) {
|
|
1236
|
+
issues.push({
|
|
1237
|
+
level: "error",
|
|
1238
|
+
message: `Operation "${operation.meta.key}.v${operation.meta.version}" references unknown policy "${ref.key}.v${ref.version}"`,
|
|
1239
|
+
path: `operations.${operation.meta.key}.policy.policies`
|
|
1240
|
+
});
|
|
1241
|
+
}
|
|
1242
|
+
}
|
|
1243
|
+
const fieldPolicies = operation.policy.fieldPolicies ?? [];
|
|
1244
|
+
for (const fp of fieldPolicies) {
|
|
1245
|
+
if (fp.policy) {
|
|
1246
|
+
const policy = deps.policies.get(fp.policy.key, fp.policy.version);
|
|
1247
|
+
if (!policy) {
|
|
1248
|
+
issues.push({
|
|
1249
|
+
level: "error",
|
|
1250
|
+
message: `Operation "${operation.meta.key}.v${operation.meta.version}" references unknown field policy "${fp.policy.key}.v${fp.policy.version}"`,
|
|
1251
|
+
path: `operations.${operation.meta.key}.policy.fieldPolicies`
|
|
1252
|
+
});
|
|
1253
|
+
}
|
|
1254
|
+
}
|
|
1255
|
+
}
|
|
1256
|
+
}
|
|
1257
|
+
}
|
|
1258
|
+
return {
|
|
1259
|
+
valid: issues.filter((i) => i.level === "error").length === 0,
|
|
1260
|
+
issues
|
|
1261
|
+
};
|
|
1262
|
+
}
|
|
1263
|
+
|
|
1264
|
+
class PolicyValidationError extends Error {
|
|
1265
|
+
issues;
|
|
1266
|
+
constructor(message, issues) {
|
|
1267
|
+
super(message);
|
|
1268
|
+
this.issues = issues;
|
|
1269
|
+
this.name = "PolicyValidationError";
|
|
1270
|
+
}
|
|
1271
|
+
}
|
|
1272
|
+
function assertPolicySpecValid(spec) {
|
|
1273
|
+
const result = validatePolicySpec(spec);
|
|
1274
|
+
if (!result.valid) {
|
|
1275
|
+
throw new PolicyValidationError(`Policy ${spec.meta.key}.v${spec.meta.version} is invalid`, result.issues);
|
|
1276
|
+
}
|
|
1277
|
+
}
|
|
1278
|
+
function assertPolicyConsistency(deps) {
|
|
1279
|
+
const result = validatePolicyConsistency(deps);
|
|
1280
|
+
if (!result.valid) {
|
|
1281
|
+
throw new PolicyValidationError("Policy consistency check failed", result.issues);
|
|
1282
|
+
}
|
|
1283
|
+
}
|
|
1284
|
+
|
|
1285
|
+
// src/policy/index.ts
|
|
1286
|
+
var definePolicy = (spec2) => spec2;
|
|
1287
|
+
export {
|
|
1288
|
+
validatePolicySpec,
|
|
1289
|
+
validatePolicyConsistency,
|
|
1290
|
+
filterOperationsByPolicy,
|
|
1291
|
+
definePolicy,
|
|
1292
|
+
createPolicyContext,
|
|
1293
|
+
createBypassPolicyContext,
|
|
1294
|
+
createAnonymousPolicyContext,
|
|
1295
|
+
checkRole,
|
|
1296
|
+
checkPolicyForOperation,
|
|
1297
|
+
checkPermission,
|
|
1298
|
+
checkCombinedPolicy,
|
|
1299
|
+
checkAnyRole,
|
|
1300
|
+
checkAllPermissions,
|
|
1301
|
+
buildOPAInput,
|
|
1302
|
+
assertRole,
|
|
1303
|
+
assertPolicySpecValid,
|
|
1304
|
+
assertPolicyForOperation,
|
|
1305
|
+
assertPolicyConsistency,
|
|
1306
|
+
assertPermission,
|
|
1307
|
+
assertCombinedPolicy,
|
|
1308
|
+
PolicyViolationError,
|
|
1309
|
+
PolicyValidationError,
|
|
1310
|
+
PolicyRegistry,
|
|
1311
|
+
PolicyEngine,
|
|
1312
|
+
OPAPolicyAdapter
|
|
1313
|
+
};
|