@cratis/pi 8.0.2 → 8.1.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/package/corpus/harnesses/copilot/instructions/ai-distribution.instructions.md +9 -102
- package/package/corpus/harnesses/copilot/instructions/authoring-skills.instructions.md +3 -5
- package/package/corpus/harnesses/copilot/instructions/browser.instructions.md +8 -49
- package/package/corpus/harnesses/copilot/instructions/code-health.instructions.md +1 -1
- package/package/corpus/harnesses/copilot/instructions/code-quality.csharp.instructions.md +3 -84
- package/package/corpus/harnesses/copilot/instructions/code-quality.instructions.md +6 -51
- package/package/corpus/harnesses/copilot/instructions/code-quality.typescript.instructions.md +4 -81
- package/package/corpus/harnesses/copilot/instructions/codescene.instructions.md +5 -54
- package/package/corpus/harnesses/copilot/instructions/components.instructions.md +1 -1
- package/package/corpus/harnesses/copilot/instructions/cratis-folder-is-configuration.instructions.md +5 -22
- package/package/corpus/harnesses/copilot/instructions/csharp.instructions.md +7 -315
- package/package/corpus/harnesses/copilot/instructions/dialogs.instructions.md +1 -1
- package/package/corpus/harnesses/copilot/instructions/discoverability.instructions.md +3 -25
- package/package/corpus/harnesses/copilot/instructions/documentation-structure-and-formatting.instructions.md +5 -151
- package/package/corpus/harnesses/copilot/instructions/documentation.instructions.md +5 -104
- package/package/corpus/harnesses/copilot/instructions/editing-cratis-docs.instructions.md +5 -63
- package/package/corpus/harnesses/copilot/instructions/efcore.instructions.md +8 -55
- package/package/corpus/harnesses/copilot/instructions/efcore.specs.instructions.md +3 -33
- package/package/corpus/harnesses/copilot/instructions/elixir.instructions.md +6 -79
- package/package/corpus/harnesses/copilot/instructions/exit-codes-and-wrappers.instructions.md +4 -27
- package/package/corpus/harnesses/copilot/instructions/framework-dotnet.instructions.md +4 -6
- package/package/corpus/harnesses/copilot/instructions/framework.instructions.md +0 -2
- package/package/corpus/harnesses/copilot/instructions/frontend-quality.instructions.md +0 -1
- package/package/corpus/harnesses/copilot/instructions/frontend-testing.instructions.md +1 -1
- package/package/corpus/harnesses/copilot/instructions/github-actions.instructions.md +7 -138
- package/package/corpus/harnesses/copilot/instructions/glossary.instructions.md +19 -19
- package/package/corpus/harnesses/copilot/instructions/go-engineering.instructions.md +1 -4
- package/package/corpus/harnesses/copilot/instructions/go.instructions.md +2 -7
- package/package/corpus/harnesses/copilot/instructions/guards-and-fuses.instructions.md +5 -6
- package/package/corpus/harnesses/copilot/instructions/java.instructions.md +7 -129
- package/package/corpus/harnesses/copilot/instructions/kotlin.instructions.md +8 -165
- package/package/corpus/harnesses/copilot/instructions/orleans.instructions.md +5 -98
- package/package/corpus/harnesses/copilot/instructions/profiles.instructions.md +9 -63
- package/package/corpus/harnesses/copilot/instructions/scripting.instructions.md +1 -1
- package/package/corpus/harnesses/copilot/instructions/specs.csharp.instructions.md +8 -148
- package/package/corpus/harnesses/copilot/instructions/specs.elixir.instructions.md +4 -37
- package/package/corpus/harnesses/copilot/instructions/specs.typescript.instructions.md +3 -1
- package/package/corpus/harnesses/copilot/instructions/storybook.instructions.md +7 -70
- package/package/corpus/harnesses/copilot/instructions/typescript.instructions.md +8 -98
- package/package/corpus/harnesses/copilot/instructions/writing-correct-examples.instructions.md +3 -47
- package/package/corpus/harnesses/copilot/instructions/writing-cratis-docs.instructions.md +3 -65
- package/package/corpus/hooks/README.md +4 -7
- package/package/corpus/hooks/scripts/quality-gates.json +3 -5
- package/package/corpus/rules/ai-distribution.md +9 -102
- package/package/corpus/rules/authoring-skills.md +3 -5
- package/package/corpus/rules/browser.md +8 -49
- package/package/corpus/rules/code-health-policy.txt +4 -24
- package/package/corpus/rules/code-health.md +1 -1
- package/package/corpus/rules/code-quality.csharp.md +3 -84
- package/package/corpus/rules/code-quality.md +6 -51
- package/package/corpus/rules/code-quality.typescript.md +4 -81
- package/package/corpus/rules/codescene.md +5 -54
- package/package/corpus/rules/components.md +1 -1
- package/package/corpus/rules/cratis-folder-is-configuration.md +5 -22
- package/package/corpus/rules/csharp.md +7 -315
- package/package/corpus/rules/dialogs.md +1 -1
- package/package/corpus/rules/discoverability.md +3 -25
- package/package/corpus/rules/documentation-structure-and-formatting.md +5 -151
- package/package/corpus/rules/documentation.md +5 -104
- package/package/corpus/rules/editing-cratis-docs.md +5 -63
- package/package/corpus/rules/efcore.md +8 -55
- package/package/corpus/rules/efcore.specs.md +3 -33
- package/package/corpus/rules/elixir.md +6 -79
- package/package/corpus/rules/exit-codes-and-wrappers.md +4 -27
- package/package/corpus/rules/framework-dotnet.md +4 -6
- package/package/corpus/rules/framework.md +0 -2
- package/package/corpus/rules/frontend-quality.md +0 -1
- package/package/corpus/rules/frontend-testing.md +1 -1
- package/package/corpus/rules/general.md +2 -2
- package/package/corpus/rules/github-actions.md +7 -138
- package/package/corpus/rules/glossary.md +19 -19
- package/package/corpus/rules/go-engineering.md +1 -4
- package/package/corpus/rules/go.md +2 -7
- package/package/corpus/rules/guards-and-fuses.md +5 -6
- package/package/corpus/rules/java.md +7 -129
- package/package/corpus/rules/kotlin.md +8 -165
- package/package/corpus/rules/orleans.md +5 -98
- package/package/corpus/rules/profiles.md +9 -63
- package/package/corpus/rules/scripting.md +1 -1
- package/package/corpus/rules/specs.csharp.md +8 -148
- package/package/corpus/rules/specs.elixir.md +4 -37
- package/package/corpus/rules/specs.typescript.md +3 -1
- package/package/corpus/rules/storybook.md +7 -70
- package/package/corpus/rules/typescript.md +8 -98
- package/package/corpus/rules/writing-correct-examples.md +3 -47
- package/package/corpus/rules/writing-cratis-docs.md +3 -65
- package/package/corpus/skills/cratis-application-growth/SKILL.md +7 -54
- package/package/corpus/skills/cratis-application-growth/references/move-and-untangle.md +49 -0
- package/package/corpus/skills/cratis-application-growth/references/rename-window.md +12 -14
- package/package/corpus/skills/cratis-application-growth/references/stages.md +2 -2
- package/package/corpus/skills/cratis-arc-authorize-request/SKILL.md +2 -2
- package/package/corpus/skills/cratis-arc-authorize-request/references/csharp.md +3 -3
- package/package/corpus/skills/cratis-arc-authorize-request/references/kotlin.md +2 -2
- package/package/corpus/skills/cratis-arc-code-analysis-typescript/SKILL.md +10 -43
- package/package/corpus/skills/cratis-arc-code-analysis-typescript/references/rule-fixes.md +40 -0
- package/package/corpus/skills/cratis-arc-connect-storage/SKILL.md +1 -1
- package/package/corpus/skills/cratis-arc-connect-storage/references/csharp.md +1 -1
- package/package/corpus/skills/cratis-arc-declare-command/references/csharp.md +4 -4
- package/package/corpus/skills/cratis-arc-declare-command/references/go.md +1 -1
- package/package/corpus/skills/cratis-arc-declare-command/references/kotlin.md +6 -7
- package/package/corpus/skills/cratis-arc-declare-operation/SKILL.md +2 -8
- package/package/corpus/skills/cratis-arc-declare-operation/references/csharp.md +1 -1
- package/package/corpus/skills/cratis-arc-diagnose-live-query/SKILL.md +1 -1
- package/package/corpus/skills/cratis-arc-diagnose-live-query/references/csharp.md +1 -1
- package/package/corpus/skills/cratis-arc-expose-mcp-operation/SKILL.md +6 -12
- package/package/corpus/skills/cratis-arc-expose-mcp-operation/references/custom-exposure-and-audit.md +4 -0
- package/package/corpus/skills/cratis-arc-expose-query/SKILL.md +2 -2
- package/package/corpus/skills/cratis-arc-expose-query/references/csharp.md +11 -4
- package/package/corpus/skills/cratis-arc-expose-query/references/typescript.md +1 -1
- package/package/corpus/skills/cratis-arc-generate-proxies/SKILL.md +2 -2
- package/package/corpus/skills/cratis-arc-generate-proxies/references/csharp.md +1 -1
- package/package/corpus/skills/cratis-arc-generate-proxies/references/go.md +19 -2
- package/package/corpus/skills/cratis-arc-generate-proxies/references/typescript.md +1 -1
- package/package/corpus/skills/cratis-arc-host-application/SKILL.md +1 -1
- package/package/corpus/skills/cratis-arc-host-application/references/csharp.md +1 -2
- package/package/corpus/skills/cratis-arc-host-application/references/elixir.md +2 -2
- package/package/corpus/skills/cratis-arc-host-application/references/go.md +5 -1
- package/package/corpus/skills/cratis-arc-host-application/references/java.md +1 -1
- package/package/corpus/skills/cratis-arc-host-application/references/kotlin.md +1 -1
- package/package/corpus/skills/cratis-arc-host-application/references/typescript.md +1 -1
- package/package/corpus/skills/cratis-arc-identity-and-tenancy-kotlin/SKILL.md +4 -7
- package/package/corpus/skills/cratis-arc-invoke-command/SKILL.md +1 -1
- package/package/corpus/skills/cratis-arc-invoke-command/references/csharp.md +4 -4
- package/package/corpus/skills/cratis-arc-invoke-command/references/typescript.md +1 -1
- package/package/corpus/skills/cratis-arc-isolate-tenant/SKILL.md +2 -2
- package/package/corpus/skills/cratis-arc-isolate-tenant/references/csharp.md +2 -2
- package/package/corpus/skills/cratis-arc-isolate-tenant/references/elixir.md +1 -1
- package/package/corpus/skills/cratis-arc-isolate-tenant/references/java.md +1 -1
- package/package/corpus/skills/cratis-arc-isolate-tenant/references/kotlin.md +1 -1
- package/package/corpus/skills/cratis-arc-isolate-tenant/references/typescript.md +4 -2
- package/package/corpus/skills/cratis-arc-migrate-relational-schema/SKILL.md +6 -6
- package/package/corpus/skills/cratis-arc-page-query/SKILL.md +3 -3
- package/package/corpus/skills/cratis-arc-page-query/references/csharp.md +10 -6
- package/package/corpus/skills/cratis-arc-page-query/references/elixir.md +2 -2
- package/package/corpus/skills/cratis-arc-page-query/references/java.md +1 -1
- package/package/corpus/skills/cratis-arc-page-query/references/kotlin.md +1 -1
- package/package/corpus/skills/cratis-arc-react-bind-slice/SKILL.md +2 -2
- package/package/corpus/skills/cratis-arc-react-bind-slice/references/csharp.md +1 -1
- package/package/corpus/skills/cratis-arc-react-bind-slice/references/kotlin.md +1 -1
- package/package/corpus/skills/cratis-arc-react-separate-view-model/SKILL.md +7 -3
- package/package/corpus/skills/cratis-arc-react-separate-view-model/references/react-routing-and-messaging.md +1 -1
- package/package/corpus/skills/cratis-arc-select-backend-sdk/SKILL.md +2 -2
- package/package/corpus/skills/cratis-arc-select-backend-sdk/references/elixir.md +2 -4
- package/package/corpus/skills/cratis-arc-select-backend-sdk/references/go.md +2 -2
- package/package/corpus/skills/cratis-arc-select-backend-sdk/references/java.md +1 -1
- package/package/corpus/skills/cratis-arc-select-backend-sdk/references/kotlin.md +2 -2
- package/package/corpus/skills/cratis-arc-select-backend-sdk/references/typescript.md +1 -3
- package/package/corpus/skills/cratis-arc-spring-data-kotlin/SKILL.md +13 -51
- package/package/corpus/skills/cratis-arc-spring-data-kotlin/references/read-model-naming.md +9 -1
- package/package/corpus/skills/cratis-arc-spring-data-kotlin/references/storage-boundaries.md +40 -0
- package/package/corpus/skills/cratis-arc-storage-typescript/SKILL.md +19 -64
- package/package/corpus/skills/cratis-arc-storage-typescript/references/drizzle.md +62 -0
- package/package/corpus/skills/cratis-arc-tenancy-typescript/SKILL.md +24 -55
- package/package/corpus/skills/cratis-arc-tenancy-typescript/references/tenant-selection.md +49 -0
- package/package/corpus/skills/cratis-arc-testing-kotlin/SKILL.md +13 -31
- package/package/corpus/skills/cratis-arc-testing-kotlin/references/jvm-scenario-variants.md +25 -0
- package/package/corpus/skills/cratis-arc-testing-typescript/SKILL.md +24 -62
- package/package/corpus/skills/cratis-arc-testing-typescript/references/hosts-and-runners.md +51 -0
- package/package/corpus/skills/cratis-arc-validate-command/SKILL.md +4 -4
- package/package/corpus/skills/cratis-arc-validate-command/references/csharp.md +10 -12
- package/package/corpus/skills/cratis-arc-validate-command/references/elixir.md +16 -3
- package/package/corpus/skills/cratis-arc-validate-command/references/go.md +19 -2
- package/package/corpus/skills/cratis-arc-validate-command/references/java.md +20 -7
- package/package/corpus/skills/cratis-arc-validate-command/references/kotlin.md +22 -2
- package/package/corpus/skills/cratis-arc-validate-command/references/python.md +8 -2
- package/package/corpus/skills/cratis-arc-validate-command/references/typescript.md +22 -2
- package/package/corpus/skills/cratis-arc-validation-kotlin/SKILL.md +22 -248
- package/package/corpus/skills/cratis-arc-validation-kotlin/references/feature-filters.md +55 -0
- package/package/corpus/skills/cratis-arc-validation-kotlin/references/model-validation.md +72 -0
- package/package/corpus/skills/cratis-arc-validation-kotlin/references/server-validators.md +86 -0
- package/package/corpus/skills/cratis-arc-validation-typescript/SKILL.md +27 -275
- package/package/corpus/skills/cratis-arc-validation-typescript/references/models-and-queries.md +63 -0
- package/package/corpus/skills/cratis-arc-validation-typescript/references/rules-and-checks.md +46 -0
- package/package/corpus/skills/cratis-arc-validation-typescript/references/server-decisions.md +114 -0
- package/package/corpus/skills/cratis-chronicle-cli-operations/SKILL.md +15 -255
- package/package/corpus/skills/cratis-chronicle-cli-operations/references/command-effects.md +13 -6
- package/package/corpus/skills/cratis-chronicle-cli-operations/references/inspection.md +75 -0
- package/package/corpus/skills/cratis-chronicle-cli-operations/references/project-tooling.md +78 -13
- package/package/corpus/skills/cratis-chronicle-cli-operations/references/recovery-and-comparison.md +16 -14
- package/package/corpus/skills/cratis-chronicle-connect-application/SKILL.md +1 -1
- package/package/corpus/skills/cratis-chronicle-connect-application/references/csharp.md +10 -6
- package/package/corpus/skills/cratis-chronicle-connect-application/references/elixir.md +1 -1
- package/package/corpus/skills/cratis-chronicle-constrain-append/SKILL.md +2 -2
- package/package/corpus/skills/cratis-chronicle-constrain-append/references/csharp.md +8 -8
- package/package/corpus/skills/cratis-chronicle-deploy-kernel/SKILL.md +10 -8
- package/package/corpus/skills/cratis-chronicle-deploy-kernel/references/storage.md +8 -4
- package/package/corpus/skills/cratis-chronicle-evolve-event/SKILL.md +4 -4
- package/package/corpus/skills/cratis-chronicle-evolve-event/references/csharp.md +2 -2
- package/package/corpus/skills/cratis-chronicle-evolve-event/references/deployed-readers.md +21 -8
- package/package/corpus/skills/cratis-chronicle-evolve-event/references/elixir.md +1 -1
- package/package/corpus/skills/cratis-chronicle-inspect-observer/SKILL.md +1 -1
- package/package/corpus/skills/cratis-chronicle-inspect-observer/references/csharp.md +5 -7
- package/package/corpus/skills/cratis-chronicle-inspect-observer/references/elixir.md +3 -3
- package/package/corpus/skills/cratis-chronicle-mcp-inspection/SKILL.md +10 -80
- package/package/corpus/skills/cratis-chronicle-mcp-inspection/references/blocked-tools.md +2 -2
- package/package/corpus/skills/cratis-chronicle-mcp-inspection/references/deployment.md +9 -24
- package/package/corpus/skills/cratis-chronicle-mcp-inspection/references/observational-tools.md +10 -0
- package/package/corpus/skills/cratis-chronicle-project-view/SKILL.md +2 -2
- package/package/corpus/skills/cratis-chronicle-project-view/references/csharp.md +7 -6
- package/package/corpus/skills/cratis-chronicle-project-view/references/elixir.md +2 -2
- package/package/corpus/skills/cratis-chronicle-project-view/references/go.md +6 -0
- package/package/corpus/skills/cratis-chronicle-project-view/references/java.md +6 -0
- package/package/corpus/skills/cratis-chronicle-project-view/references/kotlin.md +6 -0
- package/package/corpus/skills/cratis-chronicle-project-view/references/typescript.md +11 -5
- package/package/corpus/skills/cratis-chronicle-protect-decision/SKILL.md +2 -2
- package/package/corpus/skills/cratis-chronicle-protect-decision/references/csharp.md +4 -4
- package/package/corpus/skills/cratis-chronicle-protect-decision/references/elixir.md +2 -2
- package/package/corpus/skills/cratis-chronicle-protect-decision/references/go.md +3 -1
- package/package/corpus/skills/cratis-chronicle-protect-personal-data/SKILL.md +1 -1
- package/package/corpus/skills/cratis-chronicle-protect-personal-data/references/csharp.md +1 -1
- package/package/corpus/skills/cratis-chronicle-publish-contract/SKILL.md +1 -1
- package/package/corpus/skills/cratis-chronicle-publish-contract/references/csharp.md +51 -40
- package/package/corpus/skills/cratis-chronicle-publish-contract/references/elixir.md +1 -1
- package/package/corpus/skills/cratis-chronicle-react-to-fact/SKILL.md +1 -1
- package/package/corpus/skills/cratis-chronicle-react-to-fact/references/{occurrences.md → csharp-occurrences.md} +2 -2
- package/package/corpus/skills/cratis-chronicle-react-to-fact/references/csharp.md +5 -6
- package/package/corpus/skills/cratis-chronicle-react-to-fact/references/go.md +1 -1
- package/package/corpus/skills/cratis-chronicle-react-to-fact/references/java.md +1 -1
- package/package/corpus/skills/cratis-chronicle-react-to-fact/references/kotlin.md +1 -1
- package/package/corpus/skills/cratis-chronicle-record-event/SKILL.md +1 -1
- package/package/corpus/skills/cratis-chronicle-record-event/references/csharp.md +21 -19
- package/package/corpus/skills/cratis-chronicle-record-event/references/elixir.md +3 -3
- package/package/corpus/skills/cratis-chronicle-record-event/references/go.md +1 -1
- package/package/corpus/skills/cratis-chronicle-record-event/references/java.md +3 -4
- package/package/corpus/skills/cratis-chronicle-record-event/references/kotlin.md +3 -4
- package/package/corpus/skills/cratis-chronicle-record-event/references/typescript.md +2 -2
- package/package/corpus/skills/cratis-chronicle-reduce-state/SKILL.md +1 -1
- package/package/corpus/skills/cratis-chronicle-reduce-state/references/csharp.md +7 -2
- package/package/corpus/skills/cratis-chronicle-reduce-state/references/typescript.md +1 -1
- package/package/corpus/skills/cratis-chronicle-select-client/SKILL.md +4 -4
- package/package/corpus/skills/cratis-chronicle-select-client/references/csharp.md +3 -3
- package/package/corpus/skills/cratis-chronicle-select-client/references/elixir.md +2 -6
- package/package/corpus/skills/cratis-chronicle-select-client/references/go.md +2 -2
- package/package/corpus/skills/cratis-chronicle-select-client/references/java.md +1 -1
- package/package/corpus/skills/cratis-chronicle-select-client/references/kotlin.md +1 -5
- package/package/corpus/skills/cratis-chronicle-select-client/references/python.md +3 -3
- package/package/corpus/skills/cratis-chronicle-select-client/references/typescript.md +2 -2
- package/package/corpus/skills/cratis-chronicle-web-workbench/SKILL.md +12 -201
- package/package/corpus/skills/cratis-chronicle-web-workbench/references/hosting.md +67 -0
- package/package/corpus/skills/cratis-chronicle-web-workbench/references/operations.md +88 -0
- package/package/corpus/skills/cratis-ci-pipeline-performance/SKILL.md +8 -4
- package/package/corpus/skills/cratis-ci-pipeline-performance/references/build-once-and-shard.md +13 -11
- package/package/corpus/skills/cratis-ci-pipeline-performance/references/caching.md +2 -2
- package/package/corpus/skills/cratis-ci-pipeline-performance/references/flaky-and-hung-jobs.md +6 -4
- package/package/corpus/skills/cratis-ci-pipeline-performance/references/required-checks-and-path-filters.md +20 -61
- package/package/corpus/skills/cratis-ci-pipeline-performance/references/security-and-pinning.md +1 -1
- package/package/corpus/skills/cratis-cli-terminal-workbench/SKILL.md +15 -26
- package/package/corpus/skills/cratis-code-review/SKILL.md +7 -6
- package/package/corpus/skills/cratis-commits-and-pull-requests/SKILL.md +1 -1
- package/package/corpus/skills/cratis-commits-and-pull-requests/references/pr-description.md +1 -1
- package/package/corpus/skills/cratis-components-accessibility/SKILL.md +14 -206
- package/package/corpus/skills/cratis-components-accessibility/references/control-labels.md +29 -0
- package/package/corpus/skills/cratis-components-accessibility/references/focus-and-announcements.md +8 -0
- package/package/corpus/skills/cratis-components-build-canvas/SKILL.md +7 -7
- package/package/corpus/skills/cratis-components-build-canvas/references/pixi-items.md +1 -1
- package/package/corpus/skills/cratis-components-choose-control/SKILL.md +7 -8
- package/package/corpus/skills/cratis-components-choose-control/references/collections.md +2 -2
- package/package/corpus/skills/cratis-components-choose-control/references/inputs.md +1 -1
- package/package/corpus/skills/cratis-components-compose-toolbar/SKILL.md +22 -27
- package/package/corpus/skills/cratis-components-compose-toolbar/references/contributed-tools.md +5 -0
- package/package/corpus/skills/cratis-components-coordinate-feedback/SKILL.md +19 -25
- package/package/corpus/skills/cratis-components-display-list/SKILL.md +26 -19
- package/package/corpus/skills/cratis-components-display-list/references/server-query.md +3 -3
- package/package/corpus/skills/cratis-components-edit-schema-data/SKILL.md +15 -12
- package/package/corpus/skills/cratis-components-edit-schema-data/references/controlled-editor.md +3 -3
- package/package/corpus/skills/cratis-components-explore-data/SKILL.md +7 -7
- package/package/corpus/skills/cratis-components-host-chat/SKILL.md +7 -7
- package/package/corpus/skills/cratis-components-submit-form/SKILL.md +9 -15
- package/package/corpus/skills/cratis-components-submit-form/references/confirmation.md +5 -5
- package/package/corpus/skills/cratis-components-submit-form/references/wizard.md +3 -3
- package/package/corpus/skills/cratis-components-theme-application/SKILL.md +7 -51
- package/package/corpus/skills/cratis-components-theme-application/references/palette.md +49 -0
- package/package/corpus/skills/cratis-components-theme-application/references/renderer-adapters.md +4 -2
- package/package/corpus/skills/cratis-content-length/SKILL.md +34 -46
- package/package/corpus/skills/cratis-content-length/references/length-evidence.md +26 -127
- package/package/corpus/skills/cratis-developer-marketing/SKILL.md +15 -27
- package/package/corpus/skills/cratis-developer-marketing/references/measurement.md +3 -19
- package/package/corpus/skills/cratis-developer-marketing/references/playbook-evidence.md +29 -224
- package/package/corpus/skills/cratis-discoverability/SKILL.md +11 -4
- package/package/corpus/skills/cratis-discoverability/references/package-metadata.md +2 -2
- package/package/corpus/skills/cratis-documentation-writing/SKILL.md +4 -3
- package/package/corpus/skills/cratis-engineering-ci-gates/SKILL.md +13 -129
- package/package/corpus/skills/cratis-engineering-ci-gates/references/gate-operation.md +132 -0
- package/package/corpus/skills/cratis-engineering-consolidation-guard/SKILL.md +11 -100
- package/package/corpus/skills/cratis-engineering-consolidation-guard/references/ci-required-check.md +55 -40
- package/package/corpus/skills/cratis-engineering-consolidation-guard/references/source-verification.md +68 -0
- package/package/corpus/skills/cratis-engineering-consolidation-guard/references/verification-details.md +38 -0
- package/package/corpus/skills/cratis-engineering-csharp-conventions/SKILL.md +14 -65
- package/package/corpus/skills/cratis-engineering-csharp-conventions/references/exceptions-logging-and-di.md +40 -174
- package/package/corpus/skills/cratis-engineering-decision-record/SKILL.md +8 -52
- package/package/corpus/skills/cratis-engineering-decision-record/references/decision-pitfalls.md +29 -0
- package/package/corpus/skills/cratis-engineering-decision-record/references/decision-scope.md +20 -0
- package/package/corpus/skills/cratis-engineering-decision-record/references/record-format.md +3 -4
- package/package/corpus/skills/cratis-engineering-docs-authoring/SKILL.md +7 -12
- package/package/corpus/skills/cratis-engineering-docs-authoring/references/site-format.md +5 -4
- package/package/corpus/skills/cratis-engineering-effect-boundaries/SKILL.md +6 -40
- package/package/corpus/skills/cratis-engineering-effect-boundaries/references/failure-archetypes.md +18 -151
- package/package/corpus/skills/cratis-engineering-inherited-work/SKILL.md +5 -21
- package/package/corpus/skills/cratis-engineering-inherited-work/references/continue-inherited-work.md +19 -0
- package/package/corpus/skills/cratis-engineering-issue-design-note/SKILL.md +3 -66
- package/package/corpus/skills/cratis-engineering-issue-design-note/references/design-note-format.md +68 -0
- package/package/corpus/skills/cratis-engineering-issue-hygiene/SKILL.md +2 -84
- package/package/corpus/skills/cratis-engineering-issue-hygiene/references/issue-disposition.md +87 -0
- package/package/corpus/skills/cratis-engineering-local-cross-repo-verification/SKILL.md +15 -263
- package/package/corpus/skills/cratis-engineering-local-cross-repo-verification/references/dependency-map.md +3 -3
- package/package/corpus/skills/cratis-engineering-local-cross-repo-verification/references/docker-images.md +28 -6
- package/package/corpus/skills/cratis-engineering-local-cross-repo-verification/references/dotnet-nuget.md +18 -14
- package/package/corpus/skills/cratis-engineering-local-cross-repo-verification/references/helper-runbook.md +231 -0
- package/package/corpus/skills/cratis-engineering-local-cross-repo-verification/references/other-environments.md +2 -3
- package/package/corpus/skills/cratis-engineering-local-cross-repo-verification/references/worked-examples.md +62 -77
- package/package/corpus/skills/cratis-engineering-post-mortem/SKILL.md +6 -39
- package/package/corpus/skills/cratis-engineering-post-mortem/references/proportionate-follow-up.md +36 -0
- package/package/corpus/skills/cratis-engineering-regression-cluster/SKILL.md +4 -4
- package/package/corpus/skills/cratis-engineering-release-trains/SKILL.md +8 -134
- package/package/corpus/skills/cratis-engineering-release-trains/references/candidate-assembly.md +139 -0
- package/package/corpus/skills/cratis-engineering-review-rounds/SKILL.md +3 -100
- package/package/corpus/skills/cratis-engineering-review-rounds/references/round-handoffs.md +109 -0
- package/package/corpus/skills/cratis-environments-and-secrets/SKILL.md +1 -5
- package/package/corpus/skills/cratis-environments-and-secrets/references/environment-file.md +1 -3
- package/package/corpus/skills/cratis-event-model-diagram/SKILL.md +11 -116
- package/package/corpus/skills/cratis-event-model-diagram/references/frame-patterns.md +93 -0
- package/package/corpus/skills/cratis-fundamentals-concept-go/SKILL.md +4 -15
- package/package/corpus/skills/cratis-fundamentals-name-value/SKILL.md +8 -8
- package/package/corpus/skills/cratis-fundamentals-name-value/references/csharp.md +4 -4
- package/package/corpus/skills/cratis-fundamentals-name-value/references/elixir.md +1 -1
- package/package/corpus/skills/cratis-fundamentals-name-value/references/go.md +1 -1
- package/package/corpus/skills/cratis-fundamentals-name-value/references/java.md +5 -5
- package/package/corpus/skills/cratis-fundamentals-name-value/references/kotlin.md +15 -2
- package/package/corpus/skills/cratis-fundamentals-name-value/references/python.md +1 -1
- package/package/corpus/skills/cratis-fundamentals-name-value/references/typescript.md +1 -1
- package/package/corpus/skills/cratis-fundamentals-telemetry/SKILL.md +10 -27
- package/package/corpus/skills/cratis-fundamentals-telemetry/references/otlp-export.md +16 -0
- package/package/corpus/skills/cratis-fundamentals-type-discovery/SKILL.md +26 -188
- package/package/corpus/skills/cratis-fundamentals-type-discovery/references/diagnostics.md +14 -0
- package/package/corpus/skills/cratis-governed-release-methodology/SKILL.md +7 -5
- package/package/corpus/skills/cratis-lens-browser-extension/SKILL.md +23 -157
- package/package/corpus/skills/cratis-lens-browser-extension/references/troubleshooting.md +139 -0
- package/package/corpus/skills/cratis-llm-friendly-documentation/SKILL.md +7 -5
- package/package/corpus/skills/cratis-modeling-design-event-model/SKILL.md +2 -4
- package/package/corpus/skills/cratis-modeling-design-event-model/references/model-first.md +7 -0
- package/package/corpus/skills/cratis-modeling-discover-timeline/SKILL.md +2 -2
- package/package/corpus/skills/cratis-modeling-discover-timeline/references/group-and-document-intake.md +1 -1
- package/package/corpus/skills/cratis-modeling-review-event-model/SKILL.md +2 -2
- package/package/corpus/skills/cratis-modeling-review-event-model/references/implementation-findings.md +2 -2
- package/package/corpus/skills/cratis-modeling-trace-existing-behavior/SKILL.md +5 -23
- package/package/corpus/skills/cratis-modeling-trace-existing-behavior/references/compare-evidence.md +20 -0
- package/package/corpus/skills/cratis-modeling-trace-existing-behavior/references/recovery-inputs.md +3 -3
- package/package/corpus/skills/cratis-multi-service-local-orchestration/SKILL.md +8 -63
- package/package/corpus/skills/cratis-multi-service-local-orchestration/references/aspire.md +52 -0
- package/package/corpus/skills/cratis-observability/SKILL.md +1 -1
- package/package/corpus/skills/cratis-observability/references/arc-and-chronicle-signals.md +9 -23
- package/package/corpus/skills/cratis-observability/references/chronicle-kernel-export.md +3 -14
- package/package/corpus/skills/cratis-observability/references/csharp.md +4 -6
- package/package/corpus/skills/cratis-observability/references/elixir.md +1 -1
- package/package/corpus/skills/cratis-observability/references/troubleshooting.md +4 -5
- package/package/corpus/skills/cratis-onboarding-runtime/SKILL.md +1 -4
- package/package/corpus/skills/cratis-onboarding-runtime/references/default-offering.md +0 -3
- package/package/corpus/skills/cratis-onboarding-runtime/references/sign-up-review.md +0 -4
- package/package/corpus/skills/cratis-orchestration-lanes/SKILL.md +7 -49
- package/package/corpus/skills/cratis-orchestration-lanes/references/escalation.md +22 -0
- package/package/corpus/skills/cratis-orchestration-lanes/references/inbox-and-handover.md +4 -4
- package/package/corpus/skills/cratis-orchestration-lanes/references/placeholders.md +1 -1
- package/package/corpus/skills/cratis-orchestration-lanes/references/roles.md +12 -0
- package/package/corpus/skills/cratis-orchestration-lanes/references/roll-call.md +12 -0
- package/package/corpus/skills/cratis-orchestration-lanes/references/worktrees.md +10 -0
- package/package/corpus/skills/cratis-orchestration-merge-gates/SKILL.md +14 -13
- package/package/corpus/skills/cratis-orchestration-merge-gates/references/merge-queue.md +51 -26
- package/package/corpus/skills/cratis-orchestration-merge-gates/references/unattended-guards.md +8 -14
- package/package/corpus/skills/cratis-orleans-jobs/SKILL.md +9 -65
- package/package/corpus/skills/cratis-orleans-jobs/references/activation-callbacks.md +5 -0
- package/package/corpus/skills/cratis-orleans-jobs/references/lifecycle-and-placement.md +11 -7
- package/package/corpus/skills/cratis-orleans-jobs/references/state-machines.md +1 -1
- package/package/corpus/skills/cratis-orleans-jobs/references/step-planning.md +27 -0
- package/package/corpus/skills/cratis-orleans-jobs/references/storage-and-options.md +35 -0
- package/package/corpus/skills/cratis-performance-review/SKILL.md +6 -76
- package/package/corpus/skills/cratis-performance-review/references/review-checklist.md +79 -0
- package/package/corpus/skills/cratis-platform-configure-environment/SKILL.md +19 -16
- package/package/corpus/skills/cratis-platform-contribute-change/SKILL.md +2 -2
- package/package/corpus/skills/cratis-platform-deliver-slice/SKILL.md +5 -5
- package/package/corpus/skills/cratis-platform-deliver-slice/references/coordinate-slices.md +1 -1
- package/package/corpus/skills/cratis-platform-diagnose-slice/SKILL.md +2 -3
- package/package/corpus/skills/cratis-platform-prepare-release-pr/SKILL.md +2 -2
- package/package/corpus/skills/cratis-platform-start-application/SKILL.md +10 -8
- package/package/corpus/skills/cratis-platform-start-application/references/csharp.md +6 -6
- package/package/corpus/skills/cratis-platform-start-application/references/java.md +4 -4
- package/package/corpus/skills/cratis-platform-start-application/references/kotlin.md +4 -4
- package/package/corpus/skills/cratis-platform-verify-service-handoff/SKILL.md +3 -3
- package/package/corpus/skills/cratis-release-notes/SKILL.md +9 -133
- package/package/corpus/skills/cratis-release-notes/references/channel-guidance.md +59 -0
- package/package/corpus/skills/cratis-release-notes/references/publish-repair.md +64 -0
- package/package/corpus/skills/cratis-rtk/SKILL.md +12 -18
- package/package/corpus/skills/cratis-screenplay-accept-model/SKILL.md +3 -3
- package/package/corpus/skills/cratis-screenplay-accept-model/references/capability-consumption.md +1 -1
- package/package/corpus/skills/cratis-screenplay-accept-model/references/coverage-obligations.md +1 -1
- package/package/corpus/skills/cratis-screenplay-authentication-and-onboarding/SKILL.md +25 -59
- package/package/corpus/skills/cratis-screenplay-authentication-and-onboarding/references/onboarding-directives.md +11 -10
- package/package/corpus/skills/cratis-screenplay-author-extension/SKILL.md +9 -6
- package/package/corpus/skills/cratis-screenplay-author-extension/references/consume.md +3 -3
- package/package/corpus/skills/cratis-screenplay-author-extension/references/stage-candidate.md +8 -0
- package/package/corpus/skills/cratis-screenplay-availability/SKILL.md +20 -167
- package/package/corpus/skills/cratis-screenplay-availability/references/complete-example.md +23 -47
- package/package/corpus/skills/cratis-screenplay-availability/references/review-checks.md +9 -10
- package/package/corpus/skills/cratis-screenplay-availability/references/runtime-ownership.md +26 -23
- package/package/corpus/skills/cratis-screenplay-declare-slice/SKILL.md +6 -14
- package/package/corpus/skills/cratis-screenplay-declare-slice/references/projection-replay.md +2 -2
- package/package/corpus/skills/cratis-screenplay-declare-slice/references/read-identity.md +1 -1
- package/package/corpus/skills/cratis-screenplay-edit-workspace/SKILL.md +7 -9
- package/package/corpus/skills/cratis-screenplay-edit-workspace/references/model-notes.md +1 -1
- package/package/corpus/skills/cratis-screenplay-handoff-slice/SKILL.md +10 -14
- package/package/corpus/skills/cratis-screenplay-model-automation/SKILL.md +1 -1
- package/package/corpus/skills/cratis-screenplay-model-automation/references/reaction-boundaries.md +1 -1
- package/package/corpus/skills/cratis-screenplay-model-interaction/SKILL.md +6 -31
- package/package/corpus/skills/cratis-screenplay-model-interaction/references/shell-and-data.md +22 -0
- package/package/corpus/skills/cratis-screenplay-model-translation/SKILL.md +5 -5
- package/package/corpus/skills/cratis-screenplay-onboard-workspace/SKILL.md +5 -5
- package/package/corpus/skills/cratis-screenplay-onboard-workspace/references/version-migration.md +4 -4
- package/package/corpus/skills/cratis-screenplay-recover-intent/SKILL.md +2 -2
- package/package/corpus/skills/cratis-screenplay-recover-intent/references/csharp.md +2 -2
- package/package/corpus/skills/cratis-screenplay-recover-intent/references/ground-truth-benchmark.md +1 -1
- package/package/corpus/skills/cratis-screenplay-specify-outcome/SKILL.md +4 -75
- package/package/corpus/skills/cratis-screenplay-specify-outcome/references/host-body-execution.md +0 -2
- package/package/corpus/skills/cratis-screenplay-specify-outcome/references/observable-result.md +85 -1
- package/package/corpus/skills/cratis-screenplay-specify-outcome/references/query-rejections.md +1 -1
- package/package/corpus/skills/cratis-screenplay-streams-and-consistency/SKILL.md +15 -133
- package/package/corpus/skills/cratis-screenplay-streams-and-consistency/references/boundaries.md +5 -5
- package/package/corpus/skills/cratis-screenplay-streams-and-consistency/references/chronicle-boundaries.md +4 -12
- package/package/corpus/skills/cratis-screenplay-streams-and-consistency/references/consistency-and-concurrency.md +28 -57
- package/package/corpus/skills/cratis-screenplay-streams-and-consistency/references/evolution-example.md +4 -5
- package/package/corpus/skills/cratis-screenplay-streams-and-consistency/references/evolution.md +13 -20
- package/package/corpus/skills/cratis-screenplay-streams-and-consistency/references/multi-service-models.md +1 -1
- package/package/corpus/skills/cratis-screenplay-streams-and-consistency/references/neighbouring-skills.md +1 -1
- package/package/corpus/skills/cratis-screenplay-streams-and-consistency/references/read-model-keys.md +3 -5
- package/package/corpus/skills/cratis-screenplay-streams-and-consistency/references/stream-id-rules.md +2 -0
- package/package/corpus/skills/cratis-screenplay-streams-and-consistency/references/stream-patterns.md +5 -5
- package/package/corpus/skills/cratis-screenplay-streams-and-consistency/references/streams-example.md +82 -71
- package/package/corpus/skills/cratis-security-review/SKILL.md +4 -73
- package/package/corpus/skills/cratis-security-review/references/arc-boundaries.md +24 -13
- package/package/corpus/skills/cratis-security-review/references/review-checklist.md +74 -0
- package/package/corpus/skills/cratis-session-handoff/SKILL.md +7 -32
- package/package/corpus/skills/cratis-session-handoff/references/handoff-template.md +2 -2
- package/package/corpus/skills/cratis-session-handoff/references/session-hygiene.md +20 -0
- package/package/corpus/skills/cratis-showrunner-herald/SKILL.md +9 -17
- package/package/corpus/skills/cratis-showrunner-herald/references/options.md +2 -2
- package/package/corpus/skills/cratis-showrunner-herald/references/templates-and-images.md +16 -10
- package/package/corpus/skills/cratis-social-feed-post/SKILL.md +9 -162
- package/package/corpus/skills/cratis-social-feed-post/references/asset-and-formatting.md +37 -0
- package/package/corpus/skills/cratis-social-feed-post/references/editorial-checks.md +40 -0
- package/package/corpus/skills/cratis-social-feed-post/references/engagement-evidence.md +39 -150
- package/package/corpus/skills/cratis-social-feed-post/references/linkedin-media.md +24 -0
- package/package/corpus/skills/cratis-social-feed-post/references/other-channels.md +23 -0
- package/package/corpus/skills/cratis-specifications-exercise-backend/SKILL.md +5 -5
- package/package/corpus/skills/cratis-specifications-exercise-backend/references/csharp-command-results.md +2 -2
- package/package/corpus/skills/cratis-specifications-exercise-backend/references/csharp-query-scenario.md +13 -5
- package/package/corpus/skills/cratis-specifications-exercise-backend/references/csharp.md +7 -4
- package/package/corpus/skills/cratis-specifications-exercise-backend/references/elixir.md +1 -1
- package/package/corpus/skills/cratis-specifications-exercise-backend/references/go.md +20 -4
- package/package/corpus/skills/cratis-specifications-exercise-backend/references/typescript.md +1 -1
- package/package/corpus/skills/cratis-specifications-isolate-behavior/SKILL.md +2 -2
- package/package/corpus/skills/cratis-specifications-observe-ui/SKILL.md +5 -5
- package/package/corpus/skills/cratis-specifications-test-application-ui/SKILL.md +2 -2
- package/package/corpus/skills/cratis-specifications-test-application-ui/references/typescript-command-results.md +2 -2
- package/package/corpus/skills/cratis-specifications-test-typescript-behavior/SKILL.md +2 -2
- package/package/corpus/skills/cratis-stage-render-slice/SKILL.md +10 -9
- package/package/corpus/skills/cratis-stage-run-sandbox/SKILL.md +3 -3
- package/package/corpus/skills/cratis-stage-run-sandbox/references/semantic-spec-runner.md +7 -6
- package/package/corpus/skills/cratis-studio-mcp-safety-guidance/SKILL.md +4 -6
- package/package/corpus/skills/cratis-technical-examples/SKILL.md +10 -106
- package/package/corpus/skills/cratis-technical-examples/references/csharp-package-checks.md +1 -1
- package/package/corpus/skills/cratis-technical-examples/references/source-and-format.md +42 -0
- package/package/corpus/skills/cratis-technical-examples/references/typescript-package-checks.md +2 -2
- package/package/corpus/skills/cratis-technical-examples/references/verification-scope.md +37 -0
- package/package/corpus/skills/cratis-ux-review/SKILL.md +8 -40
- package/package/corpus/skills/cratis-ux-review/references/capture-contract.md +24 -0
- package/package/corpus/skills/cratis-ux-review/references/checklist.md +1 -1
- package/package/corpus/skills/cratis-ux-review/references/report-template.md +2 -1
- package/package/corpus/skills/cratis-writing-voice-and-cadence/SKILL.md +19 -132
- package/package/corpus/skills/cratis-writing-voice-and-cadence/references/ai-tells.md +24 -97
- package/package/corpus/skills/cratis-writing-voice-and-cadence/references/author-and-batch.md +23 -0
- package/package/corpus/skills/cratis-writing-voice-and-cadence/references/documentation-evidence.md +25 -0
- package/package/corpus/skills/cratis-writing-voice-and-cadence/references/interpretation.md +17 -0
- package/package/corpus/skills/cratis-writing-voice-and-cadence/references/stock-constructions.md +23 -0
- package/package/corpus/skills/cratis-writing-voice-and-cadence/references/voice-guidance.md +8 -29
- package/package.json +1 -1
- /package/package/corpus/skills/cratis-chronicle-protect-decision/references/{standalone.md → csharp-standalone.md} +0 -0
- /package/package/corpus/skills/cratis-engineering-post-mortem/references/{examples/silent-backup-failure.md → silent-backup-failure.md} +0 -0
- /package/package/corpus/skills/cratis-engineering-post-mortem/references/{examples/unintended-release-regression.md → unintended-release-regression.md} +0 -0
|
@@ -1,61 +1,40 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: cratis-arc-validation-typescript
|
|
3
|
-
description: Use when adding rejection rules, state checks or validation assertions to an Arc Node.js server. Not for
|
|
3
|
+
description: Use when adding rejection rules, state checks or validation assertions to an Arc Node.js server. Not for an invariant that must hold at append (use cratis-chronicle-constrain-append).
|
|
4
4
|
license: MIT
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
# Validate an Arc command or query in TypeScript (Node.js server)
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
the
|
|
12
|
-
|
|
13
|
-
the member it concerns — never as a thrown error.
|
|
9
|
+
Attach an input rule to the existing command with a `CommandValidator`. Arc
|
|
10
|
+
checks it on execution and on `POST <command route>/validate`, which does not
|
|
11
|
+
execute the handler. The separate `@cratis/arc` client runs supported rules
|
|
12
|
+
copied into generated proxies; it does not replace server validation.
|
|
14
13
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
- **Default:** put field and cross-field checks in the command validator.
|
|
15
|
+
- **Choose reusable rules** when the same concept or model invariant belongs
|
|
16
|
+
wherever that type appears; see [values and query arguments](references/models-and-queries.md)
|
|
17
|
+
for that pattern and for validating query inputs.
|
|
18
|
+
- **Choose a server-only decision** when a rule needs services or state. See
|
|
19
|
+
[server decisions](references/server-decisions.md) for state in validators,
|
|
20
|
+
preparation-dependent decisions, and allowed-severity behavior.
|
|
19
21
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
## Choose where to reject
|
|
25
|
-
|
|
26
|
-
| The decision depends on | Put it in | Runs on `/validate` | Caller sees |
|
|
27
|
-
| --- | --- | --- | --- |
|
|
28
|
-
| The request's shape: types, required/optional fields | `@field` plus `@optional()`/`@nullable()`/`@defaultValue()` | Yes | 400 `malformedRequest`, no message or members |
|
|
29
|
-
| Who is calling | `@roles`, `@authorize`, a policy | Yes | 401 or 403 |
|
|
30
|
-
| One value, wherever it appears | `ConceptValidator` on the concept | Yes | 400 with your message and member |
|
|
31
|
-
| The command's own fields, or a service | `CommandValidator` | Yes | 400 with your message and member |
|
|
32
|
-
| Stored state for the command's key | `CommandValidator` rule calling `readModelForValidation` | Yes | 400 with your message and member |
|
|
33
|
-
| Data you load anyway to do the work | `provide()` returning `rejected(...)` or `denied(...)` | No | 400 or 403 |
|
|
34
|
-
| A decision only the handler can make | `handle()` returning `rejected(...)` or `denied(...)` | No | 400 or 403 |
|
|
35
|
-
|
|
36
|
-
- **Reject as early as the information allows.** Everything through the
|
|
37
|
-
`readModelForValidation` row answers on `/validate`.
|
|
38
|
-
- **Keep access control out of validators.** A trusted caller can lower the
|
|
39
|
-
blocking severity and let validation results through; nothing lowers
|
|
40
|
-
authorization or `denied(...)`.
|
|
41
|
-
- A stored-state check tells you what was true when it ran. A rule that must hold
|
|
42
|
-
under concurrency belongs at the storage boundary (for Chronicle, a constraint
|
|
43
|
-
or concurrency scope; see the `cratis-chronicle-constrain-append` skill (in `cratis/chronicle`)).
|
|
22
|
+
For decorators, conditions, generated rule coverage, and assertions, read
|
|
23
|
+
[rule vocabulary and checks](references/rules-and-checks.md) when a rule needs
|
|
24
|
+
more than a literal field check or its spec fails unexpectedly.
|
|
44
25
|
|
|
45
26
|
## Command rules — `CommandValidator`
|
|
46
27
|
|
|
47
|
-
|
|
48
|
-
in the slice file with its command:
|
|
28
|
+
Keep this validator in the slice with the already declared `RegisterTask` command:
|
|
49
29
|
|
|
50
30
|
```typescript
|
|
51
|
-
import {
|
|
31
|
+
import { CommandValidator, validator } from '@cratis/arc.core';
|
|
52
32
|
|
|
53
33
|
@validator(RegisterTask)
|
|
54
34
|
export class RegisterTaskValidator extends CommandValidator<RegisterTask> {
|
|
55
35
|
constructor() {
|
|
56
36
|
super();
|
|
57
|
-
this.ruleFor(command => command.title).notEmpty().
|
|
58
|
-
this.ruleFor(command => command.title).maxLength(100).withMessage('A title can have at most 100 characters');
|
|
37
|
+
this.ruleFor(command => command.title).notEmpty().maxLength(100);
|
|
59
38
|
}
|
|
60
39
|
}
|
|
61
40
|
```
|
|
@@ -71,241 +50,14 @@ export class RegisterTaskValidator extends CommandValidator<RegisterTask> {
|
|
|
71
50
|
- Every rule runs; a failure does not stop the others, so a form sees every
|
|
72
51
|
problem at once. Any result above the allowed severity blocks `handle()`.
|
|
73
52
|
|
|
74
|
-
## Value rules — `ConceptValidator`
|
|
75
|
-
|
|
76
|
-
A rule that belongs to the value goes on the concept, once.
|
|
77
|
-
Example:
|
|
78
|
-
|
|
79
|
-
```typescript
|
|
80
|
-
import { ConceptValidator, validator } from '@cratis/arc.core';
|
|
81
|
-
import { TaskTitle } from './TaskTitle.js';
|
|
82
|
-
|
|
83
|
-
@validator(TaskTitle)
|
|
84
|
-
export class TaskTitleValidator extends ConceptValidator<TaskTitle> {
|
|
85
|
-
constructor() {
|
|
86
|
-
super();
|
|
87
|
-
this.ruleFor(title => title.value).must(value => !value.startsWith('!'))
|
|
88
|
-
.withMessage('A title cannot begin with an exclamation mark');
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
Arc walks the declared `@field` members of commands, query arguments and nested
|
|
94
|
-
models, and runs the concept validator on every `TaskTitle` it meets, including
|
|
95
|
-
inside arrays. A failure inside `entries[]` reports `entries.title`, not an
|
|
96
|
-
index. The owner's own rules still run. To skip only the **direct** member's
|
|
97
|
-
concept rules, call `.ignoreConceptRules()` on the owner's `ruleFor(...)` chain;
|
|
98
|
-
descendants are still traversed. The Library sample keeps `AuthorName` and its
|
|
99
|
-
`AuthorNameValidator` together in `AuthorName.ts`.
|
|
100
|
-
|
|
101
|
-
`ModelValidator<T>` validates a nested model class the same way, wherever it
|
|
102
|
-
appears in a command or query-argument graph.
|
|
103
|
-
|
|
104
|
-
## Query rules — `QueryValidator`
|
|
105
|
-
|
|
106
|
-
A `QueryValidator` targets an explicit **arguments model** whose `@field`
|
|
107
|
-
declarations match the query's `argument(...)` descriptors:
|
|
108
|
-
|
|
109
|
-
```typescript
|
|
110
|
-
import { ConceptAs, field } from '@cratis/fundamentals';
|
|
111
|
-
import { QueryValidator, argument, query, readModel, validator } from '@cratis/arc.core';
|
|
112
|
-
|
|
113
|
-
export class Name extends ConceptAs<string> { static readonly valueType = String; }
|
|
114
|
-
|
|
115
|
-
export class SearchArguments {
|
|
116
|
-
@field(Name) term!: Name;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
@validator(SearchArguments)
|
|
120
|
-
export class SearchArgumentsValidator extends QueryValidator<SearchArguments> {
|
|
121
|
-
constructor() {
|
|
122
|
-
super();
|
|
123
|
-
this.ruleFor(arguments_ => arguments_.term).notEmpty().withMessage('Term required');
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
@readModel()
|
|
128
|
-
export class Search {
|
|
129
|
-
@query({ argumentsModel: SearchArguments }, argument('term', Name))
|
|
130
|
-
static byTerm(term: Name): string { return term.value; }
|
|
131
|
-
}
|
|
132
|
-
```
|
|
133
|
-
|
|
134
|
-
Without an arguments model, Arc still runs concept validators on each supplied,
|
|
135
|
-
non-null argument under that argument's name, but a `QueryValidator` has nothing
|
|
136
|
-
to target. Queries always use `Warning` as the allowed severity.
|
|
137
|
-
|
|
138
|
-
## Rules that read stored state — `readModelForValidation`
|
|
139
|
-
|
|
140
|
-
```typescript
|
|
141
|
-
import { field } from '@cratis/fundamentals';
|
|
142
|
-
import { command, CommandValidator, key, readModelForValidation, validator } from '@cratis/arc.core';
|
|
143
|
-
|
|
144
|
-
@command()
|
|
145
|
-
export class RenameTask {
|
|
146
|
-
@field(String) @key() id!: string;
|
|
147
|
-
@field(String) title!: string;
|
|
148
|
-
handle(): void { /* rename in storage */ }
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
@validator(RenameTask)
|
|
152
|
-
export class RenameTaskValidator extends CommandValidator<RenameTask> {
|
|
153
|
-
constructor() {
|
|
154
|
-
super();
|
|
155
|
-
this.ruleFor(command => command.title).mustAsync(async title => {
|
|
156
|
-
const current = await readModelForValidation(TaskView, { optional: true });
|
|
157
|
-
return current === null || current.title !== title;
|
|
158
|
-
}).withMessage('The task already has this title');
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
```
|
|
162
|
-
|
|
163
|
-
- Arc resolves the command key (`@key()`, `getKey()`, or a resolver) and asks the
|
|
164
|
-
resolver that owns `TaskView` — registered by MongoDB, Drizzle, experimental
|
|
165
|
-
Chronicle, or `builder.addReadModelForCommandResolver(token)`. The resolver
|
|
166
|
-
receives the caller's tenant.
|
|
167
|
-
- `{ optional: true }` returns `null` for a missing model. Without it, a missing
|
|
168
|
-
model makes the rule throw, and the caller gets `validatorFailed` instead of
|
|
169
|
-
your message.
|
|
170
|
-
- It works **only** inside a validator of a model-bound command, during
|
|
171
|
-
validation. Validators do not receive read models through their constructors.
|
|
172
|
-
- Reads are scoped to the current command/tenant and cancellation signal, on
|
|
173
|
-
both validate and execute routes; do not retain a validation read across calls.
|
|
174
|
-
|
|
175
|
-
## Rule vocabulary
|
|
176
|
-
|
|
177
|
-
| Rules | Where they run |
|
|
178
|
-
| --- | --- |
|
|
179
|
-
| `notNull`, `notEmpty`, `minLength`, `maxLength`, `length`, `emailAddress`, `phone`, `url`, `matches`, `greaterThan`, `greaterThanOrEqual`, `lessThan`, `lessThanOrEqual` | Server; literal, unconditional uses are also copied into generated proxies |
|
|
180
|
-
| `empty`, `null`, `equal`, `notEqual`, `inclusiveBetween`, `exclusiveBetween`, `must`, `mustAsync` | Server only |
|
|
181
|
-
|
|
182
|
-
- `withMessage`, `withSeverity(Severity.Warning)`, and `withState(value)`
|
|
183
|
-
decorate the most recent rule.
|
|
184
|
-
- `when(predicate)` / `unless(predicate)` condition **every rule on the chain**
|
|
185
|
-
by default; pass `ApplyConditionTo.CurrentValidator` to condition only the
|
|
186
|
-
latest. Conditions and predicates run on the server only.
|
|
187
|
-
- `must` and `mustAsync` receive `(value, model, signal)`; pass the signal to
|
|
188
|
-
cancelable I/O.
|
|
189
|
-
- String rules exist only for strings; comparison rules only for numbers and
|
|
190
|
-
temporal values. `notEmpty()` rejects `Guid.empty`.
|
|
191
|
-
- Email, phone, URL, regex and Unicode-length behavior is not guaranteed to match
|
|
192
|
-
the client or Arc on .NET exactly. Write an explicit message and specify the
|
|
193
|
-
inputs you accept.
|
|
194
|
-
- The generator copies rules for commands (including direct concept fields) and
|
|
195
|
-
for query arguments with an explicit `argumentsModel`. A rule that stays
|
|
196
|
-
server-only produces a source diagnostic. The server validates every request
|
|
197
|
-
regardless.
|
|
198
|
-
|
|
199
|
-
## Services in a validator
|
|
200
|
-
|
|
201
|
-
Declare constructor dependencies with `@injectable(Service)` or
|
|
202
|
-
`static inject = [Service] as const`, and register the service with
|
|
203
|
-
`builder.services`. Arc constructs each validator once during `build()` (catching
|
|
204
|
-
invalid selectors early), then resolves fresh validators per execution scope. A
|
|
205
|
-
validator that throws, or whose dependency cannot be resolved, never reports
|
|
206
|
-
success: the caller gets 400 with reason `validatorFailed` or
|
|
207
|
-
`dependencyUnavailable`, no exception text, and the error goes to the logger.
|
|
208
|
-
|
|
209
|
-
## Reject from `provide()` or `handle()`
|
|
210
|
-
|
|
211
|
-
```typescript
|
|
212
|
-
import { denied, rejected, validation, Severity, ValidationResult } from '@cratis/arc.core';
|
|
213
|
-
|
|
214
|
-
return rejected(ValidationResult.error('The task does not exist', { members: ['id'], reason: 'notFound' }));
|
|
215
|
-
return rejected(ValidationResult.warning('Unusually long title', { members: ['title'], reasonDetail: 'TitleLength' }));
|
|
216
|
-
return rejected(validation('Unusually long title', ['title'], 'rule', Severity.Warning));
|
|
217
|
-
return denied('Only the owner can rename a task');
|
|
218
|
-
```
|
|
219
|
-
|
|
220
|
-
- `ValidationResult.information/warning/error(message, options?)` (Requires Arc for
|
|
221
|
-
TypeScript 0.34.0) build a result at that severity; `options` sets
|
|
222
|
-
`members`, `state` (must be JSON-serializable), `reason` (default `rule`) and
|
|
223
|
-
`reasonDetail`. `members` defaults to `[]` and `reason` to `rule`; omitted
|
|
224
|
-
`state` and `reasonDetail` are left out of the result.
|
|
225
|
-
- `validation(message, members = [], reason = 'rule', severity = Severity.Error)`
|
|
226
|
-
builds a `ValidationResult` (`{ severity, message, members, reason }`) with
|
|
227
|
-
positional arguments; it cannot set `reasonDetail` or `state`.
|
|
228
|
-
- `rejected(...results)` answers 400; it throws when given no results, so an
|
|
229
|
-
empty rejection can never pass as success. `denied(reason?)` answers 403 with
|
|
230
|
-
`authorizationFailureReason`.
|
|
231
|
-
- Rejected results go through the same severity filter. When nothing above the
|
|
232
|
-
allowed severity remains, `handle()` runs (from `provide()`, with `undefined`
|
|
233
|
-
as the provided value) or the command succeeds without a response (from
|
|
234
|
-
`handle()`).
|
|
235
|
-
- Throwing is for failures, not decisions: a thrown error is a 500.
|
|
236
|
-
|
|
237
|
-
## Severity filtering
|
|
238
|
-
|
|
239
|
-
`Severity` is `Unknown` (0), `Information` (1), `Warning` (2), `Error` (3).
|
|
240
|
-
Results at or below the **allowed severity** are removed and do not block;
|
|
241
|
-
results above it block and are returned. The default is `Warning`, so only
|
|
242
|
-
errors block.
|
|
243
|
-
|
|
244
|
-
| Caller | Allowed severity |
|
|
245
|
-
| --- | --- |
|
|
246
|
-
| HTTP command | `X-Allowed-Severity` header `0`, `1` or `2`; missing or invalid means `2`; `3` is **capped** to `2`, so errors always block |
|
|
247
|
-
| HTTP query | Always `Warning`; the header is ignored |
|
|
248
|
-
| `executeCommand` from code, or `CommandScenario.withAllowedValidationSeverity(...)` | As given, including `Severity.Error` |
|
|
249
|
-
| `performQuery` from code | Always `Warning` |
|
|
250
|
-
|
|
251
|
-
The HTTP cap at `Warning` is a deliberate safety difference from Arc on .NET,
|
|
252
|
-
which lets `X-Allowed-Severity: 3` run a command whose only problems are
|
|
253
|
-
errors. Do not "fix" it toward .NET behavior. `@command({ treatWarningsAsErrors: true })`
|
|
254
|
-
and `@query({ treatWarningsAsErrors: true })` set the generated client's flag.
|
|
255
|
-
|
|
256
|
-
## Specify the rule
|
|
257
|
-
|
|
258
|
-
```typescript
|
|
259
|
-
import { given, type ScenarioCommandResult } from '@cratis/arc.testing';
|
|
260
|
-
|
|
261
|
-
describe('when validating a task with an empty title', given(a_task_registration, context => {
|
|
262
|
-
let result: ScenarioCommandResult;
|
|
263
|
-
beforeEach(async () => {
|
|
264
|
-
result = await context.scenario.validate({ id: TaskId.create(), title: new TaskTitle('') });
|
|
265
|
-
});
|
|
266
|
-
afterAll(async () => { await context.scenario.dispose(); });
|
|
267
|
-
it('should report the authored rule for title', () => {
|
|
268
|
-
result.shouldHaveValidationErrors().shouldHaveValidationErrorForMember('title');
|
|
269
|
-
});
|
|
270
|
-
it('should not invoke the handler', () => { context.tasks.all().should.have.lengthOf(0); });
|
|
271
|
-
}));
|
|
272
|
-
```
|
|
273
|
-
|
|
274
|
-
- Use `scenario.validate(...)` to prove the rule answers on `/validate`, and
|
|
275
|
-
`execute(...)` to prove `handle()` never ran.
|
|
276
|
-
- Assert the member with `shouldHaveValidationErrorForMember('title')` by
|
|
277
|
-
default, not presentation text. Assert exact wording only when it is the
|
|
278
|
-
specified behavior, and name that requirement in the fact.
|
|
279
|
-
`shouldHaveValidationErrorFor(text)` passes for any message **containing** the
|
|
280
|
-
text; even a full-message argument does not prove exact equality. Compare
|
|
281
|
-
the actual message for equality when exact wording is the requirement.
|
|
282
|
-
- `validatorFailed` and `dependencyUnavailable` never satisfy
|
|
283
|
-
`shouldHaveValidationErrors()` or the member assertion — they mean no authored
|
|
284
|
-
rule was established. Assert them explicitly with
|
|
285
|
-
`shouldHaveValidationErrorBecauseOf('validatorFailed')`.
|
|
286
|
-
`shouldHaveRuleFailure(result, { reason, member?, severity? })` from
|
|
287
|
-
`@cratis/arc.testing` asserts an authored rule on a plain result.
|
|
288
|
-
- For a query, `QueryScenario.perform(...)` returns a result whose
|
|
289
|
-
`validationResults` you assert the same way.
|
|
290
|
-
|
|
291
|
-
## Route near misses
|
|
292
|
-
|
|
293
|
-
- Defining the Node command or query: [declare the command](../cratis-arc-declare-command/references/typescript.md) and [cratis-arc-expose-query](../cratis-arc-expose-query/references/typescript.md).
|
|
294
|
-
- Append-time uniqueness or concurrency: the `cratis-chronicle-constrain-append` skill (in `cratis/chronicle`).
|
|
295
|
-
- The .NET validation shape: [cratis-arc-validate-command](../cratis-arc-validate-command/SKILL.md); Kotlin/Java:
|
|
296
|
-
`cratis-arc-validation-kotlin` in `cratis/arc/client-kotlin`.
|
|
297
|
-
|
|
298
53
|
## Verify
|
|
299
54
|
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
-
|
|
309
|
-
the client-copied rules match the server's.
|
|
310
|
-
- Specs assert the authored rule and member through `validate()` and prove
|
|
311
|
-
`handle()` did not run.
|
|
55
|
+
Register the exported validator with the app’s slice discovery (or add it
|
|
56
|
+
explicitly), and include it in `CommandScenario.for(...)`. Submit an empty title
|
|
57
|
+
through `validate()` and `execute()`; both should identify `title`, and neither
|
|
58
|
+
should write. Execute a valid title and verify the expected effect. If the rule
|
|
59
|
+
is missing, check exact target registration before editing the rule. Regenerate
|
|
60
|
+
metadata and proxies if the generated client uses the rules.
|
|
61
|
+
|
|
62
|
+
Use `cratis-arc-testing-typescript` for scenario setup or
|
|
63
|
+
`cratis-arc-declare-command` to declare the command itself.
|
package/package/corpus/skills/cratis-arc-validation-typescript/references/models-and-queries.md
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# Validate reusable values and query arguments
|
|
2
|
+
|
|
3
|
+
## Value rules — `ConceptValidator`
|
|
4
|
+
|
|
5
|
+
Define a rule that belongs to the value once. Put its validator in the same
|
|
6
|
+
module as the concept, here `TaskTitle`:
|
|
7
|
+
|
|
8
|
+
```typescript
|
|
9
|
+
import { ConceptValidator, validator } from '@cratis/arc.core';
|
|
10
|
+
|
|
11
|
+
@validator(TaskTitle)
|
|
12
|
+
export class TaskTitleValidator extends ConceptValidator<TaskTitle> {
|
|
13
|
+
constructor() {
|
|
14
|
+
super();
|
|
15
|
+
this.ruleFor(title => title.value).must(value => !value.startsWith('!'))
|
|
16
|
+
.withMessage('A title cannot begin with an exclamation mark');
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Arc walks the declared `@field` members of commands, query arguments and nested
|
|
22
|
+
models, and runs the concept validator on every `TaskTitle` it meets, including
|
|
23
|
+
inside arrays. A failure inside `entries[]` reports `entries.title`, not an
|
|
24
|
+
index. The owner's own rules still run. To skip only the **direct** member's
|
|
25
|
+
concept rules, call `.ignoreConceptRules()` on the owner's `ruleFor(...)` chain;
|
|
26
|
+
descendants are still traversed.
|
|
27
|
+
|
|
28
|
+
`ModelValidator<T>` validates a nested model class the same way, wherever it
|
|
29
|
+
appears in a command or query-argument graph.
|
|
30
|
+
|
|
31
|
+
## Query rules — `QueryValidator`
|
|
32
|
+
|
|
33
|
+
A `QueryValidator` targets an explicit **arguments model** whose `@field`
|
|
34
|
+
declarations match the query's `argument(...)` descriptors:
|
|
35
|
+
|
|
36
|
+
```typescript
|
|
37
|
+
import { ConceptAs, field } from '@cratis/fundamentals';
|
|
38
|
+
import { QueryValidator, argument, query, readModel, validator } from '@cratis/arc.core';
|
|
39
|
+
|
|
40
|
+
export class Name extends ConceptAs<string> { static readonly valueType = String; }
|
|
41
|
+
|
|
42
|
+
export class SearchArguments {
|
|
43
|
+
@field(Name) term!: Name;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
@validator(SearchArguments)
|
|
47
|
+
export class SearchArgumentsValidator extends QueryValidator<SearchArguments> {
|
|
48
|
+
constructor() {
|
|
49
|
+
super();
|
|
50
|
+
this.ruleFor(arguments_ => arguments_.term).notEmpty().withMessage('Term required');
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
@readModel()
|
|
55
|
+
export class Search {
|
|
56
|
+
@query({ argumentsModel: SearchArguments }, argument('term', Name))
|
|
57
|
+
static byTerm(term: Name): string { return term.value; }
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Without an arguments model, Arc still runs concept validators on each supplied,
|
|
62
|
+
non-null argument under that argument's name, but a `QueryValidator` has nothing
|
|
63
|
+
to target. Queries always use `Warning` as the allowed severity.
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# Choose a rule and assert the caller-visible result
|
|
2
|
+
|
|
3
|
+
## Rule vocabulary
|
|
4
|
+
|
|
5
|
+
| Rules | Where they run |
|
|
6
|
+
| --- | --- |
|
|
7
|
+
| `notNull`, `notEmpty`, `minLength`, `maxLength`, `length`, `emailAddress`, `phone`, `url`, `matches`, `greaterThan`, `greaterThanOrEqual`, `lessThan`, `lessThanOrEqual` | Server; literal, unconditional uses are also copied into generated proxies |
|
|
8
|
+
| `empty`, `null`, `equal`, `notEqual`, `inclusiveBetween`, `exclusiveBetween`, `must`, `mustAsync` | Server only |
|
|
9
|
+
|
|
10
|
+
- `withMessage`, `withSeverity(Severity.Warning)`, and `withState(value)`
|
|
11
|
+
decorate the most recent rule.
|
|
12
|
+
- `when(predicate)` / `unless(predicate)` condition **every rule on the chain**
|
|
13
|
+
by default; pass `ApplyConditionTo.CurrentValidator` to condition only the
|
|
14
|
+
latest. Conditions and predicates run on the server only.
|
|
15
|
+
- `must` and `mustAsync` receive `(value, model, signal)`; pass the signal to
|
|
16
|
+
cancelable I/O.
|
|
17
|
+
- String rules exist only for strings; comparison rules only for numbers and
|
|
18
|
+
temporal values. `notEmpty()` rejects `Guid.empty`.
|
|
19
|
+
- Email, phone, URL, regex and Unicode-length behavior is not guaranteed to match
|
|
20
|
+
the client or Arc on .NET exactly. Write an explicit message and specify the
|
|
21
|
+
inputs you accept.
|
|
22
|
+
- The generator copies rules for commands (including direct concept fields) and
|
|
23
|
+
for query arguments with an explicit `argumentsModel`. A rule that stays
|
|
24
|
+
server-only produces a source diagnostic. The server validates every request
|
|
25
|
+
regardless.
|
|
26
|
+
|
|
27
|
+
## Specify the rule
|
|
28
|
+
|
|
29
|
+
Call `scenario.validate(...)` for preflight feedback. Then use `execute(...)`
|
|
30
|
+
with the same invalid input and assert the rule and no handler effect. Only
|
|
31
|
+
execute can prove validation prevented a handler that would otherwise run.
|
|
32
|
+
|
|
33
|
+
- Assert the member with `shouldHaveValidationErrorForMember('title')` by
|
|
34
|
+
default, not presentation text. Assert exact wording only when it is the
|
|
35
|
+
specified behavior, and name that requirement in the fact.
|
|
36
|
+
`shouldHaveValidationErrorFor(text)` passes for any message **containing** the
|
|
37
|
+
text; even a full-message argument does not prove exact equality. Compare
|
|
38
|
+
the actual message for equality when exact wording is the requirement.
|
|
39
|
+
- `validatorFailed` and `dependencyUnavailable` never satisfy
|
|
40
|
+
`shouldHaveValidationErrors()` or the member assertion — they mean no authored
|
|
41
|
+
rule was established. Assert them explicitly with
|
|
42
|
+
`shouldHaveValidationErrorBecauseOf('validatorFailed')`.
|
|
43
|
+
`shouldHaveRuleFailure(result, { reason, member?, severity? })` from
|
|
44
|
+
`@cratis/arc.testing` asserts an authored rule on a plain result.
|
|
45
|
+
- For a query, `QueryScenario.perform(...)` returns a result whose
|
|
46
|
+
`validationResults` you assert the same way.
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
# Refuse a command using server state
|
|
2
|
+
|
|
3
|
+
## Contents
|
|
4
|
+
|
|
5
|
+
- Rules that read stored state — `readModelForValidation`
|
|
6
|
+
- Services in a validator
|
|
7
|
+
- Reject from `provide()` or `handle()`
|
|
8
|
+
- Severity filtering
|
|
9
|
+
|
|
10
|
+
Keep access decisions in authorization or `denied(...)`, not validators. A
|
|
11
|
+
trusted direct caller can raise the allowed severity. Malformed input is a
|
|
12
|
+
binding outcome, not an authored rule. Keep invariants that must survive
|
|
13
|
+
concurrency at the store boundary; a preflight read does not guard the append.
|
|
14
|
+
|
|
15
|
+
## Rules that read stored state — `readModelForValidation`
|
|
16
|
+
|
|
17
|
+
This excerpt assumes `TaskView` is a registered read model with a `title`.
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
import { field } from '@cratis/fundamentals';
|
|
21
|
+
import { command, CommandValidator, key, readModelForValidation, validator } from '@cratis/arc.core';
|
|
22
|
+
|
|
23
|
+
@command()
|
|
24
|
+
export class RenameTask {
|
|
25
|
+
@field(String) @key() id!: string;
|
|
26
|
+
@field(String) title!: string;
|
|
27
|
+
handle(): void { /* rename in storage */ }
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
@validator(RenameTask)
|
|
31
|
+
export class RenameTaskValidator extends CommandValidator<RenameTask> {
|
|
32
|
+
constructor() {
|
|
33
|
+
super();
|
|
34
|
+
this.ruleFor(command => command.title).mustAsync(async title => {
|
|
35
|
+
const current = await readModelForValidation(TaskView, { optional: true });
|
|
36
|
+
return current === null || current.title !== title;
|
|
37
|
+
}).withMessage('The task already has this title');
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
- Arc resolves the command key (`@key()`, `getKey()`, or a resolver) and asks the
|
|
43
|
+
resolver that owns `TaskView` — registered by MongoDB, Drizzle, the
|
|
44
|
+
experimental Chronicle integration, or `builder.addReadModelForCommandResolver(token)`. The resolver
|
|
45
|
+
receives the caller's tenant.
|
|
46
|
+
- `{ optional: true }` returns `null` for a missing model. Without it, a missing
|
|
47
|
+
model makes the rule throw, and the caller gets `validatorFailed` instead of
|
|
48
|
+
your message.
|
|
49
|
+
- It works **only** inside a validator of a model-bound command, during
|
|
50
|
+
validation. Validators do not receive read models through their constructors.
|
|
51
|
+
- Reads are scoped to the current command/tenant and cancellation signal, on
|
|
52
|
+
both validate and execute routes; do not retain a validation read across calls.
|
|
53
|
+
|
|
54
|
+
## Services in a validator
|
|
55
|
+
|
|
56
|
+
Declare constructor dependencies with `@injectable(Service)` or
|
|
57
|
+
`static inject = [Service] as const`, and register the service with
|
|
58
|
+
`builder.services`. Arc constructs each validator once during `build()` (catching
|
|
59
|
+
invalid selectors early), then resolves fresh validators per execution scope. A
|
|
60
|
+
validator that throws, or whose dependency cannot be resolved, never reports
|
|
61
|
+
success: the caller gets 400 with reason `validatorFailed` or
|
|
62
|
+
`dependencyUnavailable`, no exception text, and the error goes to the logger.
|
|
63
|
+
|
|
64
|
+
## Reject from `provide()` or `handle()`
|
|
65
|
+
|
|
66
|
+
This excerpt assumes the authorized caller’s non-null `principal` and a task
|
|
67
|
+
already resolved by your command. Keep access checks in authorization when
|
|
68
|
+
the policy can run without this state.
|
|
69
|
+
|
|
70
|
+
```typescript
|
|
71
|
+
import { denied, rejected, ValidationResult } from '@cratis/arc.core';
|
|
72
|
+
|
|
73
|
+
if (!task) return rejected(ValidationResult.error('The task does not exist', { members: ['id'], reason: 'notFound' }));
|
|
74
|
+
if (task.owner !== principal.id) return denied('Only the owner can rename a task');
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
- `ValidationResult.information/warning/error(message, options?)` builds a result
|
|
78
|
+
at that severity; `options` sets
|
|
79
|
+
`members`, `state` (must be JSON-serializable), `reason` (default `rule`) and
|
|
80
|
+
`reasonDetail`. `members` defaults to `[]` and `reason` to `rule`; omitted
|
|
81
|
+
`state` and `reasonDetail` are left out of the result.
|
|
82
|
+
- `validation(message, members = [], reason = 'rule', severity = Severity.Error)`
|
|
83
|
+
builds a `ValidationResult` (`{ severity, message, members, reason }`) with
|
|
84
|
+
positional arguments; it cannot set `reasonDetail` or `state`.
|
|
85
|
+
- `rejected(...results)` answers 400 when a finding blocks. It throws when
|
|
86
|
+
given no results. `denied(reason?)` answers 403 with
|
|
87
|
+
`authorizationFailureReason`.
|
|
88
|
+
- Rejected results go through the same severity filter. If all findings from
|
|
89
|
+
`provide()` are filtered out, a `defineCommand` handler receives `undefined`
|
|
90
|
+
as its provided value. A model-bound command instead fails before its user
|
|
91
|
+
`handle()` runs because its preparation is missing. For model-bound commands,
|
|
92
|
+
put findings callers may waive in a validator and return the actual prepared
|
|
93
|
+
value on the path that proceeds.
|
|
94
|
+
- If `handle()` returns only a rejection and all its findings are filtered
|
|
95
|
+
out, it contributes no response value and does not block success.
|
|
96
|
+
- Throwing is for failures, not decisions: a thrown error is a 500.
|
|
97
|
+
|
|
98
|
+
## Severity filtering
|
|
99
|
+
|
|
100
|
+
`Severity` is `Unknown` (0), `Information` (1), `Warning` (2), `Error` (3).
|
|
101
|
+
Results at or below the **allowed severity** are removed and do not block;
|
|
102
|
+
results above it block and are returned. The default is `Warning`, so only
|
|
103
|
+
errors block.
|
|
104
|
+
|
|
105
|
+
| Caller | Allowed severity |
|
|
106
|
+
| --- | --- |
|
|
107
|
+
| HTTP command | `X-Allowed-Severity` header `0`, `1` or `2`; missing or invalid means `2`; `3` is **capped** to `2`, so errors always block |
|
|
108
|
+
| HTTP query | Always `Warning`; the header is ignored |
|
|
109
|
+
| `executeCommand` from code, or `CommandScenario.withAllowedValidationSeverity(...)` | As given, including `Severity.Error` |
|
|
110
|
+
| `performQuery` from code | Always `Warning` |
|
|
111
|
+
|
|
112
|
+
`@command({ treatWarningsAsErrors: true })` and
|
|
113
|
+
`@query({ treatWarningsAsErrors: true })` set the generated client’s flag;
|
|
114
|
+
configure and test server policy independently.
|