@cratis/pi 8.4.1 → 8.6.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 +2 -1
- package/package/corpus/harnesses/copilot/instructions/exit-codes-and-wrappers.instructions.md +1 -1
- package/package/corpus/harnesses/copilot/instructions/glossary.instructions.md +5 -3
- package/package/corpus/harnesses/copilot/instructions/react.instructions.md +3 -1
- package/package/corpus/harnesses/copilot/instructions/reactors.instructions.md +3 -1
- package/package/corpus/harnesses/copilot/instructions/scripting.instructions.md +2 -1
- package/package/corpus/harnesses/copilot/instructions/specs.csharp.instructions.md +6 -3
- package/package/corpus/harnesses/copilot/instructions/vertical-slices.instructions.md +5 -2
- package/package/corpus/hooks/scripts/cratis-guard-secrets.sh +131 -9
- package/package/corpus/rules/ai-distribution.md +2 -1
- package/package/corpus/rules/exit-codes-and-wrappers.md +1 -1
- package/package/corpus/rules/glossary.md +5 -3
- package/package/corpus/rules/react.md +3 -1
- package/package/corpus/rules/reactors.md +3 -1
- package/package/corpus/rules/scripting.md +2 -1
- package/package/corpus/rules/specs.csharp.md +6 -3
- package/package/corpus/rules/vertical-slices.md +5 -2
- package/package/corpus/skills/cratis-application-growth/SKILL.md +1 -2
- package/package/corpus/skills/cratis-application-growth/references/csharp.md +1 -3
- package/package/corpus/skills/cratis-application-growth/references/move-and-untangle.md +1 -2
- package/package/corpus/skills/cratis-application-growth/references/rename-window.md +1 -3
- package/package/corpus/skills/cratis-application-growth/references/service-and-delivery.md +3 -2
- package/package/corpus/skills/cratis-application-growth/references/stages.md +2 -2
- package/package/corpus/skills/cratis-arc-authorize-request/SKILL.md +3 -3
- package/package/corpus/skills/cratis-arc-authorize-request/references/authproxy.md +47 -3
- package/package/corpus/skills/cratis-arc-authorize-request/references/csharp-query-security.md +18 -3
- package/package/corpus/skills/cratis-arc-authorize-request/references/csharp.md +12 -3
- package/package/corpus/skills/cratis-arc-authorize-request/references/typescript.md +2 -0
- package/package/corpus/skills/cratis-arc-connect-storage/references/csharp.md +1 -0
- package/package/corpus/skills/cratis-arc-connect-storage/references/elixir.md +9 -2
- package/package/corpus/skills/cratis-arc-declare-command/SKILL.md +2 -0
- package/package/corpus/skills/cratis-arc-declare-command/references/csharp-chronicle.md +47 -8
- package/package/corpus/skills/cratis-arc-declare-command/references/csharp-controller.md +3 -1
- package/package/corpus/skills/cratis-arc-declare-command/references/csharp-history.md +6 -3
- package/package/corpus/skills/cratis-arc-declare-command/references/csharp.md +38 -11
- package/package/corpus/skills/cratis-arc-declare-command/references/go.md +1 -1
- package/package/corpus/skills/cratis-arc-declare-operation/references/csharp-abilities.md +2 -2
- package/package/corpus/skills/cratis-arc-declare-operation/references/csharp-recovery.md +6 -4
- package/package/corpus/skills/cratis-arc-declare-operation/references/csharp.md +2 -2
- 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 +29 -7
- package/package/corpus/skills/cratis-arc-diagnose-live-query/references/java.md +1 -1
- package/package/corpus/skills/cratis-arc-diagnose-live-query/references/kotlin.md +1 -1
- package/package/corpus/skills/cratis-arc-expose-mcp-operation/references/csharp-diagnose-tool-call.md +9 -7
- package/package/corpus/skills/cratis-arc-expose-mcp-operation/references/csharp.md +52 -1
- package/package/corpus/skills/cratis-arc-expose-query/SKILL.md +4 -2
- package/package/corpus/skills/cratis-arc-expose-query/references/csharp.md +36 -10
- package/package/corpus/skills/cratis-arc-expose-query/references/go.md +2 -2
- package/package/corpus/skills/cratis-arc-expose-query/references/typescript.md +6 -3
- package/package/corpus/skills/cratis-arc-generate-proxies/SKILL.md +1 -0
- package/package/corpus/skills/cratis-arc-generate-proxies/references/csharp.md +55 -6
- package/package/corpus/skills/cratis-arc-generate-proxies/references/typescript.md +9 -0
- package/package/corpus/skills/cratis-arc-host-application/SKILL.md +1 -1
- package/package/corpus/skills/cratis-arc-host-application/references/csharp-configuration.md +54 -0
- package/package/corpus/skills/cratis-arc-host-application/references/csharp-deployment.md +98 -0
- package/package/corpus/skills/cratis-arc-host-application/references/csharp-http.md +9 -1
- package/package/corpus/skills/cratis-arc-host-application/references/csharp-identity.md +87 -4
- package/package/corpus/skills/cratis-arc-host-application/references/csharp.md +9 -0
- package/package/corpus/skills/cratis-arc-invoke-command/references/csharp-extensions.md +4 -0
- package/package/corpus/skills/cratis-arc-invoke-command/references/csharp.md +2 -1
- package/package/corpus/skills/cratis-arc-isolate-tenant/SKILL.md +19 -2
- package/package/corpus/skills/cratis-arc-isolate-tenant/references/csharp.md +4 -2
- package/package/corpus/skills/cratis-arc-page-query/references/csharp.md +2 -0
- package/package/corpus/skills/cratis-arc-react-bind-slice/SKILL.md +33 -36
- package/package/corpus/skills/cratis-arc-react-bind-slice/references/typescript-commands.md +18 -3
- package/package/corpus/skills/cratis-arc-react-bind-slice/references/typescript-host.md +94 -19
- package/package/corpus/skills/cratis-arc-react-bind-slice/references/typescript-identity.md +29 -5
- package/package/corpus/skills/cratis-arc-react-bind-slice/references/typescript-instant-feedback.md +81 -0
- package/package/corpus/skills/cratis-arc-react-bind-slice/references/typescript-localization.md +80 -0
- package/package/corpus/skills/cratis-arc-react-bind-slice/references/typescript-navigation.md +103 -0
- package/package/corpus/skills/cratis-arc-react-bind-slice/references/typescript-queries.md +41 -2
- package/package/corpus/skills/cratis-arc-react-bind-slice/references/typescript-structure.md +117 -0
- package/package/corpus/skills/cratis-arc-react-bind-slice/references/typescript.md +8 -4
- package/package/corpus/skills/cratis-arc-react-separate-view-model/SKILL.md +3 -3
- package/package/corpus/skills/cratis-arc-react-separate-view-model/references/typescript.md +27 -6
- package/package/corpus/skills/cratis-arc-testing-typescript/references/typescript.md +2 -2
- package/package/corpus/skills/cratis-arc-validate-command/references/csharp-rules.md +23 -2
- package/package/corpus/skills/cratis-arc-validate-command/references/csharp.md +28 -2
- package/package/corpus/skills/cratis-arc-validation-typescript/SKILL.md +1 -0
- package/package/corpus/skills/cratis-authproxy-configure/SKILL.md +136 -0
- package/package/corpus/skills/cratis-authproxy-configure/references/admission.md +125 -0
- package/package/corpus/skills/cratis-authproxy-configure/references/aspire.md +154 -0
- package/package/corpus/skills/cratis-authproxy-configure/references/operations.md +122 -0
- package/package/corpus/skills/cratis-authproxy-configure/references/services-and-routing.md +114 -0
- package/package/corpus/skills/cratis-authproxy-configure/references/sessions-and-logout.md +126 -0
- package/package/corpus/skills/cratis-authproxy-configure/references/sign-in-providers.md +116 -0
- package/package/corpus/skills/cratis-authproxy-configure/references/tenant-resolution.md +135 -0
- package/package/corpus/skills/cratis-choreography-run-workflow/SKILL.md +117 -0
- package/package/corpus/skills/cratis-choreography-run-workflow/references/csharp-chronicle.md +164 -0
- package/package/corpus/skills/cratis-choreography-run-workflow/references/csharp.md +354 -0
- package/package/corpus/skills/cratis-chronicle-cli-operations/SKILL.md +6 -6
- package/package/corpus/skills/cratis-chronicle-cli-operations/references/inspection.md +11 -3
- package/package/corpus/skills/cratis-chronicle-cli-operations/references/project-tooling.md +50 -0
- package/package/corpus/skills/cratis-chronicle-cli-operations/references/recovery-and-comparison.md +17 -3
- package/package/corpus/skills/cratis-chronicle-cli-operations/references/setup-and-target.md +8 -2
- package/package/corpus/skills/cratis-chronicle-connect-application/references/csharp-services.md +13 -2
- package/package/corpus/skills/cratis-chronicle-connect-application/references/csharp.md +12 -0
- package/package/corpus/skills/cratis-chronicle-connect-application/references/kotlin.md +2 -0
- package/package/corpus/skills/cratis-chronicle-connect-application/references/python.md +2 -2
- package/package/corpus/skills/cratis-chronicle-connect-application/references/typescript.md +10 -1
- package/package/corpus/skills/cratis-chronicle-constrain-append/SKILL.md +9 -2
- package/package/corpus/skills/cratis-chronicle-constrain-append/references/csharp.md +35 -3
- package/package/corpus/skills/cratis-chronicle-constrain-append/references/go.md +1 -1
- package/package/corpus/skills/cratis-chronicle-constrain-append/references/operations.md +70 -0
- package/package/corpus/skills/cratis-chronicle-deploy-kernel/SKILL.md +6 -3
- package/package/corpus/skills/cratis-chronicle-deploy-kernel/references/configuration.md +113 -16
- package/package/corpus/skills/cratis-chronicle-deploy-kernel/references/container-and-kubernetes.md +293 -0
- package/package/corpus/skills/cratis-chronicle-deploy-kernel/references/kernel-options.md +16 -9
- package/package/corpus/skills/cratis-chronicle-deploy-kernel/references/network-and-tls.md +60 -7
- package/package/corpus/skills/cratis-chronicle-deploy-kernel/references/storage.md +124 -2
- package/package/corpus/skills/cratis-chronicle-deploy-kernel/references/upgrade-and-recovery.md +36 -1
- package/package/corpus/skills/cratis-chronicle-evolve-event/SKILL.md +12 -0
- package/package/corpus/skills/cratis-chronicle-evolve-event/references/csharp.md +2 -2
- package/package/corpus/skills/cratis-chronicle-inspect-observer/SKILL.md +15 -5
- package/package/corpus/skills/cratis-chronicle-inspect-observer/references/csharp.md +9 -8
- package/package/corpus/skills/cratis-chronicle-inspect-observer/references/go.md +2 -2
- package/package/corpus/skills/cratis-chronicle-mcp-inspection/SKILL.md +1 -1
- package/package/corpus/skills/cratis-chronicle-mcp-inspection/references/deployment.md +1 -1
- package/package/corpus/skills/cratis-chronicle-project-view/SKILL.md +2 -2
- package/package/corpus/skills/cratis-chronicle-project-view/references/csharp-fluent.md +15 -4
- package/package/corpus/skills/cratis-chronicle-project-view/references/csharp-model-bound.md +4 -1
- package/package/corpus/skills/cratis-chronicle-project-view/references/csharp-reading.md +5 -2
- package/package/corpus/skills/cratis-chronicle-project-view/references/csharp.md +23 -0
- package/package/corpus/skills/cratis-chronicle-project-view/references/elixir.md +1 -0
- package/package/corpus/skills/cratis-chronicle-project-view/references/go.md +2 -1
- package/package/corpus/skills/cratis-chronicle-project-view/references/java.md +3 -1
- package/package/corpus/skills/cratis-chronicle-project-view/references/kotlin.md +4 -3
- package/package/corpus/skills/cratis-chronicle-project-view/references/typescript.md +3 -1
- package/package/corpus/skills/cratis-chronicle-protect-decision/SKILL.md +3 -1
- package/package/corpus/skills/cratis-chronicle-protect-decision/references/csharp-scopes.md +41 -4
- package/package/corpus/skills/cratis-chronicle-protect-decision/references/csharp.md +22 -4
- package/package/corpus/skills/cratis-chronicle-protect-decision/references/elixir.md +7 -0
- package/package/corpus/skills/cratis-chronicle-protect-decision/references/go.md +9 -1
- package/package/corpus/skills/cratis-chronicle-protect-decision/references/java.md +8 -0
- package/package/corpus/skills/cratis-chronicle-protect-decision/references/kotlin.md +9 -0
- package/package/corpus/skills/cratis-chronicle-protect-decision/references/typescript.md +7 -0
- 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 +28 -3
- package/package/corpus/skills/cratis-chronicle-publish-contract/SKILL.md +7 -6
- package/package/corpus/skills/cratis-chronicle-publish-contract/references/csharp.md +41 -0
- package/package/corpus/skills/cratis-chronicle-publish-contract/references/elixir-integrations.md +3 -3
- package/package/corpus/skills/cratis-chronicle-publish-contract/references/webhook-signature-wire-format.md +82 -0
- package/package/corpus/skills/cratis-chronicle-react-to-fact/SKILL.md +19 -1
- package/package/corpus/skills/cratis-chronicle-react-to-fact/references/csharp-outputs.md +3 -1
- package/package/corpus/skills/cratis-chronicle-react-to-fact/references/csharp-pages.md +1 -1
- package/package/corpus/skills/cratis-chronicle-react-to-fact/references/csharp.md +37 -4
- package/package/corpus/skills/cratis-chronicle-react-to-fact/references/elixir.md +11 -0
- package/package/corpus/skills/cratis-chronicle-react-to-fact/references/java.md +2 -1
- package/package/corpus/skills/cratis-chronicle-react-to-fact/references/kotlin.md +1 -0
- package/package/corpus/skills/cratis-chronicle-record-event/SKILL.md +3 -3
- package/package/corpus/skills/cratis-chronicle-record-event/references/csharp-coordination.md +31 -2
- package/package/corpus/skills/cratis-chronicle-record-event/references/csharp-history.md +21 -4
- package/package/corpus/skills/cratis-chronicle-record-event/references/csharp.md +20 -2
- package/package/corpus/skills/cratis-chronicle-record-event/references/go.md +1 -1
- package/package/corpus/skills/cratis-chronicle-record-event/references/java.md +1 -1
- package/package/corpus/skills/cratis-chronicle-record-event/references/kotlin.md +3 -0
- package/package/corpus/skills/cratis-chronicle-reduce-state/SKILL.md +2 -1
- package/package/corpus/skills/cratis-chronicle-reduce-state/references/csharp.md +3 -1
- package/package/corpus/skills/cratis-chronicle-reduce-state/references/java.md +10 -1
- package/package/corpus/skills/cratis-chronicle-reduce-state/references/kotlin.md +10 -1
- package/package/corpus/skills/cratis-chronicle-reduce-state/references/typescript.md +27 -5
- package/package/corpus/skills/cratis-chronicle-select-client/SKILL.md +18 -0
- package/package/corpus/skills/cratis-chronicle-select-client/references/elixir.md +21 -1
- package/package/corpus/skills/cratis-chronicle-select-client/references/go.md +13 -0
- package/package/corpus/skills/cratis-chronicle-select-client/references/java.md +15 -0
- package/package/corpus/skills/cratis-chronicle-select-client/references/kotlin.md +15 -0
- package/package/corpus/skills/cratis-chronicle-select-client/references/typescript.md +16 -0
- package/package/corpus/skills/cratis-chronicle-web-workbench/SKILL.md +1 -1
- package/package/corpus/skills/cratis-ci-pipeline-performance/SKILL.md +4 -3
- package/package/corpus/skills/cratis-ci-pipeline-performance/references/publish-pipelines.md +19 -4
- package/package/corpus/skills/cratis-code-review/SKILL.md +6 -2
- package/package/corpus/skills/cratis-code-review/references/csharp-diagnostics.md +28 -2
- package/package/corpus/skills/cratis-code-review/references/csharp.md +4 -4
- package/package/corpus/skills/cratis-commits-and-pull-requests/SKILL.md +6 -38
- package/package/corpus/skills/cratis-commits-and-pull-requests/references/pr-description.md +2 -0
- package/package/corpus/skills/cratis-commits-and-pull-requests/references/pr-labels-and-release.md +5 -4
- package/package/corpus/skills/cratis-commits-and-pull-requests/references/workflow-inputs.md +39 -0
- package/package/corpus/skills/cratis-components-accessibility/SKILL.md +6 -8
- package/package/corpus/skills/cratis-components-accessibility/references/typescript.md +32 -14
- package/package/corpus/skills/cratis-components-build-canvas/SKILL.md +4 -3
- package/package/corpus/skills/cratis-components-build-canvas/references/typescript-props.md +1 -1
- package/package/corpus/skills/cratis-components-build-canvas/references/typescript.md +4 -2
- package/package/corpus/skills/cratis-components-choose-control/SKILL.md +13 -7
- package/package/corpus/skills/cratis-components-choose-control/references/from-primereact.md +116 -0
- package/package/corpus/skills/cratis-components-choose-control/references/menu.md +90 -0
- package/package/corpus/skills/cratis-components-choose-control/references/typescript-composition.md +48 -0
- package/package/corpus/skills/cratis-components-choose-control/references/typescript.md +2 -2
- package/package/corpus/skills/cratis-components-compose-toolbar/SKILL.md +2 -1
- package/package/corpus/skills/cratis-components-compose-toolbar/references/floating-toolbar.md +146 -0
- package/package/corpus/skills/cratis-components-diagnose-screen/SKILL.md +102 -0
- package/package/corpus/skills/cratis-components-display-list/SKILL.md +10 -10
- package/package/corpus/skills/cratis-components-display-list/references/typescript-custom-panel.md +74 -0
- package/package/corpus/skills/cratis-components-display-list/references/typescript-datatables.md +2 -7
- package/package/corpus/skills/cratis-components-display-list/references/typescript.md +3 -2
- package/package/corpus/skills/cratis-components-submit-form/SKILL.md +6 -6
- package/package/corpus/skills/cratis-components-submit-form/references/typescript-commanddialog.md +21 -1
- package/package/corpus/skills/cratis-components-submit-form/references/typescript-commandform.md +72 -2
- package/package/corpus/skills/cratis-components-submit-form/references/typescript.md +7 -5
- package/package/corpus/skills/cratis-components-theme-application/SKILL.md +17 -15
- package/package/corpus/skills/cratis-components-theme-application/references/localization.md +166 -0
- package/package/corpus/skills/cratis-components-theme-application/references/typescript.md +18 -14
- package/package/corpus/skills/cratis-components-theme-application/references/upgrade-from-previous-major.md +141 -0
- package/package/corpus/skills/cratis-engineering-csharp-conventions/SKILL.md +2 -0
- package/package/corpus/skills/cratis-engineering-csharp-conventions/references/csharp-domain-philosophy.md +31 -3
- package/package/corpus/skills/cratis-engineering-csharp-conventions/references/csharp-fundamentals-helpers.md +119 -0
- package/package/corpus/skills/cratis-engineering-csharp-conventions/references/csharp.md +4 -0
- package/package/corpus/skills/cratis-fundamentals-concept/references/csharp-serialization.md +72 -1
- package/package/corpus/skills/cratis-fundamentals-concept/references/csharp.md +9 -0
- package/package/corpus/skills/cratis-fundamentals-concept/references/go.md +2 -1
- package/package/corpus/skills/cratis-fundamentals-concept/references/java-json.md +3 -2
- package/package/corpus/skills/cratis-fundamentals-concept/references/kotlin-json.md +3 -2
- package/package/corpus/skills/cratis-fundamentals-concept/references/typescript-serialization.md +41 -2
- package/package/corpus/skills/cratis-fundamentals-name-value/SKILL.md +8 -7
- package/package/corpus/skills/cratis-fundamentals-name-value/references/csharp.md +2 -1
- package/package/corpus/skills/cratis-fundamentals-type-discovery/SKILL.md +3 -3
- package/package/corpus/skills/cratis-fundamentals-type-discovery/references/csharp-diagnostics.md +8 -0
- package/package/corpus/skills/cratis-fundamentals-type-discovery/references/csharp.md +2 -2
- package/package/corpus/skills/cratis-fundamentals-type-discovery/references/go-dependency-injection.md +3 -0
- package/package/corpus/skills/cratis-modeling-design-event-model/SKILL.md +6 -4
- package/package/corpus/skills/cratis-modeling-design-event-model/references/command-inventory.md +7 -1
- package/package/corpus/skills/cratis-modeling-design-event-model/references/model-first.md +13 -1
- package/package/corpus/skills/cratis-modeling-design-event-model/references/review-one-slice.md +6 -0
- package/package/corpus/skills/cratis-multi-service-local-orchestration/SKILL.md +6 -6
- package/package/corpus/skills/cratis-multi-service-local-orchestration/references/csharp-aspire.md +116 -28
- package/package/corpus/skills/cratis-multi-service-local-orchestration/references/docker-compose.md +2 -2
- package/package/corpus/skills/cratis-observability/references/chronicle-kernel-export.md +46 -0
- package/package/corpus/skills/cratis-orleans-jobs/SKILL.md +4 -2
- package/package/corpus/skills/cratis-platform-build-application/SKILL.md +8 -0
- package/package/corpus/skills/cratis-platform-build-application/references/cratis-identity.md +71 -0
- package/package/corpus/skills/cratis-platform-build-application/references/studio-repository.md +96 -0
- package/package/corpus/skills/cratis-platform-deliver-slice/SKILL.md +14 -8
- package/package/corpus/skills/cratis-platform-deliver-slice/references/csharp.md +167 -3
- package/package/corpus/skills/cratis-platform-deliver-slice/references/eventual-consistency.md +150 -0
- package/package/corpus/skills/cratis-platform-deliver-slice/references/typescript.md +14 -1
- package/package/corpus/skills/cratis-platform-diagnose-slice/SKILL.md +1 -1
- package/package/corpus/skills/cratis-platform-prepare-release-pr/SKILL.md +8 -8
- package/package/corpus/skills/cratis-platform-prepare-release-pr/references/product-release-checks.md +16 -2
- package/package/corpus/skills/cratis-platform-start-application/SKILL.md +21 -0
- package/package/corpus/skills/cratis-platform-start-application/references/csharp.md +77 -3
- package/package/corpus/skills/cratis-platform-upgrade-application/SKILL.md +118 -0
- package/package/corpus/skills/cratis-platform-upgrade-application/references/csharp.md +117 -0
- package/package/corpus/skills/cratis-platform-upgrade-application/references/java.md +53 -0
- package/package/corpus/skills/cratis-platform-upgrade-application/references/kotlin.md +53 -0
- package/package/corpus/skills/cratis-platform-upgrade-application/references/typescript.md +71 -0
- package/package/corpus/skills/cratis-release-notes/SKILL.md +1 -1
- package/package/corpus/skills/cratis-release-notes/references/publish-repair.md +6 -3
- package/package/corpus/skills/cratis-screenplay-accept-model/references/csharp.md +34 -3
- package/package/corpus/skills/cratis-screenplay-accept-model/references/read-the-evidence.md +84 -3
- package/package/corpus/skills/cratis-screenplay-declare-slice/SKILL.md +7 -11
- package/package/corpus/skills/cratis-screenplay-declare-slice/references/commands.md +8 -4
- package/package/corpus/skills/cratis-screenplay-declare-slice/references/projections.md +2 -0
- package/package/corpus/skills/cratis-screenplay-declare-slice/references/structure-and-imports.md +29 -1
- package/package/corpus/skills/cratis-screenplay-edit-workspace/SKILL.md +2 -1
- package/package/corpus/skills/cratis-screenplay-edit-workspace/references/mcp-tools.md +1 -1
- package/package/corpus/skills/cratis-screenplay-handoff-slice/references/csharp.md +13 -1
- package/package/corpus/skills/cratis-screenplay-model-translation/SKILL.md +1 -1
- package/package/corpus/skills/cratis-screenplay-model-translation/references/boundary-diagnostics.md +1 -1
- package/package/corpus/skills/cratis-screenplay-onboard-workspace/SKILL.md +30 -51
- package/package/corpus/skills/cratis-screenplay-onboard-workspace/references/cli.md +19 -2
- package/package/corpus/skills/cratis-screenplay-onboard-workspace/references/smallest-model.md +87 -0
- package/package/corpus/skills/cratis-screenplay-onboard-workspace/references/studio.md +5 -0
- package/package/corpus/skills/cratis-screenplay-onboard-workspace/references/typescript.md +13 -0
- package/package/corpus/skills/cratis-screenplay-onboard-workspace/references/workspace-mcp.md +5 -0
- package/package/corpus/skills/cratis-screenplay-specify-outcome/SKILL.md +8 -12
- package/package/corpus/skills/cratis-screenplay-specify-outcome/references/running-mcp.md +12 -0
- package/package/corpus/skills/cratis-screenplay-specify-outcome/references/scenarios.md +2 -2
- package/package/corpus/skills/cratis-specifications-exercise-backend/SKILL.md +2 -0
- package/package/corpus/skills/cratis-specifications-exercise-backend/references/csharp-colocated.md +101 -0
- package/package/corpus/skills/cratis-specifications-exercise-backend/references/csharp-command-results.md +4 -2
- package/package/corpus/skills/cratis-specifications-exercise-backend/references/csharp-decision-reads.md +1 -0
- package/package/corpus/skills/cratis-specifications-exercise-backend/references/csharp-events.md +7 -0
- package/package/corpus/skills/cratis-specifications-exercise-backend/references/csharp-integration.md +7 -4
- package/package/corpus/skills/cratis-specifications-exercise-backend/references/csharp-reactors.md +18 -5
- package/package/corpus/skills/cratis-specifications-exercise-backend/references/csharp-read-models.md +4 -2
- package/package/corpus/skills/cratis-specifications-exercise-backend/references/csharp.md +35 -2
- package/package/corpus/skills/cratis-specifications-exercise-backend/references/elixir.md +2 -0
- package/package/corpus/skills/cratis-specifications-exercise-backend/references/typescript.md +4 -2
- package/package/corpus/skills/cratis-specifications-isolate-behavior/SKILL.md +1 -1
- package/package/corpus/skills/cratis-specifications-isolate-behavior/references/csharp-running.md +10 -3
- package/package/corpus/skills/cratis-specifications-test-application-ui/references/typescript.md +22 -4
- package/package/corpus/skills/cratis-specifications-test-typescript-behavior/SKILL.md +2 -1
- package/package/corpus/skills/cratis-specifications-test-typescript-behavior/references/typescript.md +40 -0
- package/package/corpus/skills/cratis-stage-render-slice/SKILL.md +6 -0
- package/package/corpus/skills/cratis-stage-render-slice/references/semantic-conformance.md +64 -0
- package/package/profile-catalog.json +15 -0
- package/package.json +1 -1
|
@@ -65,6 +65,9 @@ With the host's default route settings this maps `GET /api/parking/permits/listi
|
|
|
65
65
|
- The method is `public static` and non-generic. Internal and private methods are never exposed.
|
|
66
66
|
- The method returns the declaring read model in one of the supported shapes.
|
|
67
67
|
- The method has no parameter of the read model's own type (nullable or not). Such a method is a fold or helper, never a query.
|
|
68
|
+
- The method name is unique among the read model's queries. The name, not the parameter list, identifies the query, so do not overload.
|
|
69
|
+
|
|
70
|
+
The read-model type itself may be `internal`; its query methods must still be `public`.
|
|
68
71
|
|
|
69
72
|
Every eligible method is a query by convention. When the type also holds query-shaped helpers that must stay private to the server, switch to explicit selection:
|
|
70
73
|
|
|
@@ -80,7 +83,9 @@ public record ParkingPermit(PermitId Id, ZoneName Zone, DateOnly ValidUntil)
|
|
|
80
83
|
}
|
|
81
84
|
```
|
|
82
85
|
|
|
83
|
-
A marked method must be an ordinary method with value parameters (no `ref` or `out`); an invalid marker is an invalid declaration, not a way to expose an unsupported result. Adding `[Query]` to one method without `RequireQueryAttribute = true` does not hide its siblings.
|
|
86
|
+
A marked method must be an ordinary method with value parameters (no `ref` or `out`); an invalid marker is an invalid declaration, not a way to expose an unsupported result. Adding `[Query]` to one method without `RequireQueryAttribute = true` does not hide its siblings. Under explicit selection, two marked methods with the same name are an error: rename one, or remove its marker and keep it as a helper.
|
|
87
|
+
|
|
88
|
+
The nearest `[ReadModel]` supplies the setting: the type's own declaration, shared by all its partial declarations, otherwise the closest base type's. A derived type without its own `[ReadModel]` therefore inherits explicit selection, and one with its own `[ReadModel]` starts again from the default. A nested type does not inherit it from its enclosing type; set it on each type that needs it.
|
|
84
89
|
|
|
85
90
|
## Common mistakes
|
|
86
91
|
|
|
@@ -118,6 +123,8 @@ Arc classifies each parameter by its type:
|
|
|
118
123
|
- GET reads arguments from the query string, never from route values. QUERY reads them from `arguments` in the body.
|
|
119
124
|
- Optional: a parameter with a default value, a `Nullable<T>` value type, a concept annotated `T?`, and every reference type that is not a concept (such as `string` or a collection) whatever its nullable annotation. These receive their default or null when absent. Required: a non-nullable value type or concept without a default; when it is absent the query answers 400 with a validation error naming the argument, and the method does not run. Over HTTP an empty value (`?name=` on GET, `""` in QUERY `arguments`) is dropped and counts as omitted. To require text or a format on a string, add validation: DataAnnotations on the parameter (`[Required]`, `[RegularExpression]`), a `QueryValidator` over the query's argument model (see Query filters below), or a concept with a `ConceptValidator`.
|
|
120
125
|
- A supplied value that cannot convert answers 400 with a validation error naming the argument; the method does not run.
|
|
126
|
+
- DataAnnotations on a query parameter are enforced through metadata that Arc's source generator emits; the generator ships with the Arc package, so declare the query in a project that references it. In an assembly built without the generator they are not enforced. They check the bound value only and do not descend into the properties of an object; use a `QueryValidator` for whole-argument and cross-field rules. `[Display]` sets the argument's name in the message. `[Required]` rejects a null or omitted value, except that a non-nullable value parameter with a declared default (`[Required] int size = 10`) may be omitted: it takes its default and is not validated. The other attributes follow DataAnnotations null semantics, so an omitted nullable argument passes `[Range]`.
|
|
127
|
+
- Each validation entry carries `message`, `members` and `severity`. `members` holds camelCase paths such as `maximumBalance` or `items[0].name`; a failing concept is reported on the argument or member that holds it, never on `.value`.
|
|
121
128
|
- There is no nested-object binding. Flatten a search-criteria object into scalar parameters.
|
|
122
129
|
- `page`, `pageSize`, `sortBy`, `sortDirection` and the two first-result wait flags are reserved on GET (case-insensitive). Never give a caller argument one of these names: over GET it never binds, so a required parameter fails as a missing argument (400) and an optional one silently gets its default or null. Give business inputs a distinct name, and read real paging and sorting controls through `IQueryContextManager.Current`; `cratis-arc-page-query` covers paging.
|
|
123
130
|
- For `string[] zones`, use `?zones=north&zones=south`; GET splits delimited values. Use QUERY `{"arguments":{"zones":["North, Annex"]}}` for a literal comma. For `Dictionary<string,int> limits` send `{"arguments":{"limits":{"north":3}}}`, not `?north=3`.
|
|
@@ -182,16 +189,26 @@ MongoDB observation needs change streams: a replica set or sharded cluster. A st
|
|
|
182
189
|
|
|
183
190
|
A plain GET on an observable route is a snapshot. When the subject exposes no readable `Value` property the snapshot answers 202 with `isReady: false`; add `waitForFirstResult=true` to wait, and `waitForFirstResultTimeout=<seconds>` to bound the wait (default 30 seconds; 408 when it expires). An application-owned `BehaviorSubject<T>` has a current value and answers 200.
|
|
184
191
|
|
|
192
|
+
Always add `waitForFirstResult=true` to a plain GET on a MongoDB `Observe()` query. Without it the request answers 202, never an empty collection, and can leave the database watcher that `Observe()` started running, because nothing subscribes to the subject or disposes it. With it Arc subscribes, returns the first result that the emission guards allow and disposes the subscription. A suppressed emission is skipped and the wait continues until an allowed emission, a terminal verdict (403 or 503), the timeout (408), or the source failing or completing before any allowed result (500). This waiting applies to an observable subject; an `IAsyncEnumerable<T>` snapshot runs to completion instead, leaves out suppressed items and answers 200 with the allowed ones, even when that is none.
|
|
193
|
+
|
|
194
|
+
`ObserveSingle` and `ObserveById` emit `null` when no document matches: on the first read, after the document is deleted (including removal through `[RemovedWith<T>]` on a Chronicle read model), or when an update moves it out of the filter. That is neither an error nor the end of the subscription; a later match emits a value again. The client keeps the subscription and treats `null` as absence only in a successful result: loading and a failed result are separate states. Straight after a create-and-open flow, absence means the new item has not arrived yet, so show it as pending until the first value appears.
|
|
195
|
+
|
|
185
196
|
A plain `Subject<T>` has no readable current value, even after `OnNext`; use `new BehaviorSubject<T>(initial)` only when `initial` is a genuine answer. For joined streams observe each contributing collection, re-evaluate on changes to either, and dispose all source subscriptions when the consumer leaves. Do not keep a request-scoped context in a process-wide subject.
|
|
186
197
|
|
|
187
198
|
For one live query, request its URL with `Accept: text/event-stream` or upgrade to WebSocket. For multiplexing, connect to `/.cratis/queries/ws`, then send `{"type":"Subscribe","queryId":"zone-view","revision":1,"payload":{"queryName":"Parking.Permits.Listing.ParkingPermit.PermitsInZone","arguments":{"zone":"north"},"transferMode":"delta"}}`. Alternatively open GET `/.cratis/queries/sse`; use its Connected ID in a JSON POST to `/.cratis/queries/sse/subscribe` with `connectionId`, `queryId`, `revision`, and the same payload under `request`. POST those three identifiers without `request` to `/.cratis/queries/sse/unsubscribe`. Keep control requests on the same server instance. After reconnect, subscribe afresh; do not replay an old delta against stale state.
|
|
188
199
|
|
|
200
|
+
The two SSE control POSTs answer 400 for a missing required value or an invalid revision, 404 for a connection that is unknown or belongs to another caller or another endpoint group (the cases are indistinguishable on purpose) and 200 once processed; subscribe answers 401 when the query is refused while the subscription is being established. A denial at a later emission arrives on the stream, not as a status. 200 means the request was processed, not that data arrived: read the stream for results and errors.
|
|
201
|
+
|
|
202
|
+
A hand-written hub client that can retry opts in to `Unavailable` frames (see Emission guards) by adding `supportsUnavailable=true` to the WebSocket upgrade URL or to the SSE stream GET; the server confirms with `supportsUnavailable: true` in `Connected`. The SSE subscribe POST cannot opt in. The frame is sent only for a subscription whose subscribe carried a `revision`; it carries that revision and no data. Retry that subscription alone with a higher revision and backoff. Arc's own client does this already.
|
|
203
|
+
|
|
189
204
|
The WebSocket transports use ASP.NET Core's WebSocket middleware: add `app.UseWebSockets()` to the host ahead of the Arc call that maps endpoints. Server-sent events need no extra middleware.
|
|
190
205
|
|
|
191
206
|
## Chronicle-backed read models
|
|
192
207
|
|
|
193
208
|
`[ReadModel]` makes a type queryable through Arc. It does not make Chronicle maintain it; a projection or reducer does that and writes the instances to the read-model store.
|
|
194
209
|
|
|
210
|
+
The stored instances follow the events with no bound on delay, and an Arc C# command has no setting to wait for them. For data a screen's own commands change, return an observable query. `cratis-platform-deliver-slice`, `references/eventual-consistency.md`, covers the other readers.
|
|
211
|
+
|
|
195
212
|
Default: query the stored collection through the storage provider, exactly as above (`IMongoCollection<T>` with `AsQueryable()`, `FindByIdAsync` or `Observe()`). This gives filtering, sorting, paging and live updates in the database. Arc's Chronicle integration releases protected (encrypted or personal) values on the way out through its built-in read-model interceptor, so the query needs no release code.
|
|
196
213
|
|
|
197
214
|
Use `Cratis.Chronicle.ReadModels.IReadModels` when the read must go through Chronicle instead:
|
|
@@ -226,18 +243,19 @@ A filter runs before the query method, for snapshots and once when a subscriptio
|
|
|
226
243
|
| `IQueryFilter` | Last | Cross-cutting validation or preconditions |
|
|
227
244
|
|
|
228
245
|
```csharp
|
|
246
|
+
using Cratis.Arc.Authorization;
|
|
229
247
|
using Cratis.Arc.Queries;
|
|
230
248
|
|
|
231
|
-
public class RequireTenant : IAuthorizationQueryFilter
|
|
249
|
+
public class RequireTenant(ICurrentPrincipalAccessor principals) : IAuthorizationQueryFilter
|
|
232
250
|
{
|
|
233
251
|
public Task<QueryResult> OnPerform(QueryContext context) =>
|
|
234
|
-
Task.FromResult(
|
|
252
|
+
Task.FromResult(principals.Current?.HasClaim(claim => claim.Type == "tenant") == true
|
|
235
253
|
? QueryResult.Success(context.CorrelationId)
|
|
236
254
|
: QueryResult.Unauthorized(context.CorrelationId));
|
|
237
255
|
}
|
|
238
256
|
```
|
|
239
257
|
|
|
240
|
-
Return `QueryResult.Success(...)` to continue, `QueryResult.Unauthorized(...)` to deny (403), and `QueryResult.WithValidationError(correlationId, member, message)` to reject input (400). Built-in filters already cover availability, the query's `[Authorize]`/`[Roles]`/`[AllowAnonymous]` declarations, DataAnnotations on parameters, and FluentValidation validators.
|
|
258
|
+
Read the caller through an injected `ICurrentPrincipalAccessor` (`Cratis.Arc.Authorization`). Do not use `QueryContext.AuthorizedPrincipal`: it is set only when scheme authentication selected a different principal and is otherwise `null`, so a check on it denies ordinary callers. Return `QueryResult.Success(...)` to continue, `QueryResult.Unauthorized(...)` to deny (403), and `QueryResult.WithValidationError(correlationId, member, message)` to reject input (400). Built-in filters already cover availability, the query's `[Authorize]`/`[Roles]`/`[AllowAnonymous]` declarations, DataAnnotations on parameters, and FluentValidation validators.
|
|
241
259
|
|
|
242
260
|
With the availability integration configured, `[Available<PermitServiceOnline>]` gates the read model using an application `AvailabilityBlock`, not an authorization policy. For admission require a policy with `[Authorize(Policy = "permit-read")]`, opt a deliberately public query out with `[AllowAnonymous]`, or restrict the query with `[Roles("PermitInspector")]` from `Cratis.Arc.Authorization`. For local validation put `[StringLength(40)]` on `string text`. For a whole-argument rule on `Search(string text, IMongoCollection<ParkingPermit> collection)`, put this model and validator in the read model assembly:
|
|
243
261
|
|
|
@@ -270,7 +288,7 @@ public class PermitSearchRenderer : IQueryRendererFor<PermitSearch>
|
|
|
270
288
|
}
|
|
271
289
|
```
|
|
272
290
|
|
|
273
|
-
`PermitSearch` and its operations are provider-specific here: count the restricted selection, then sort it and page only if paging was requested. Implement `IQueryRendererFor<T>` for one query type only. The query method must still return a discovered shape for the generated endpoint; a custom provider type suits controller queries and `IQueryPipeline` callers.
|
|
291
|
+
`PermitSearch` and its operations are provider-specific here: count the restricted selection, then sort it and page only if paging was requested. Implement `IQueryRendererFor<T>` for one query type only. When a renderer throws inside `IQueryPipeline`, an exception type that implements `IValidationFailure` becomes a validation error and any other exception becomes a failed result. A non-streaming HTTP response reports the validation error as 400; a single-query SSE or WebSocket request receives the validation result on the stream. Do not rely on this conversion for a controller query. The query method must still return a discovered shape for the generated endpoint; a custom provider type suits controller queries and `IQueryPipeline` callers.
|
|
274
292
|
|
|
275
293
|
## Read-model interceptors
|
|
276
294
|
|
|
@@ -284,7 +302,7 @@ public class NormalizeZoneName : IInterceptReadModel<ParkingPermit>
|
|
|
284
302
|
}
|
|
285
303
|
```
|
|
286
304
|
|
|
287
|
-
Return a replacement; items in a collection can be intercepted concurrently. Do not rely on the order of several interceptors for one model. A failing interceptor fails the result; the raw value is never sent.
|
|
305
|
+
Return a replacement; items in a collection can be intercepted concurrently, so injected collaborators must be thread-safe. Do not rely on the order of several interceptors for one model. A failing interceptor fails the result; the raw value is never sent. When the hub diffs snapshots, it compares each intercepted item with the same item in the previous admitted snapshot: the same instance is unchanged; otherwise it uses the type's own `Equals` when the type overrides it (records do), else the serialized JSON. A field that changes on every emission, such as a value derived from the clock, makes the item differ each time, so every change set the hub computes lists it as `replaced`; deliver the stable input (such as a timestamp) and derive the changing value on the client. When an emission after the first is an `ObservedCollection<T>` whose `Changes` is set, the change set comes from the items it names instead; with `Changes` null the hub diffs as above. For an ordered query with `transferMode: "delta"`, the hub sends the full snapshot instead whenever the change set cannot reproduce the new order.
|
|
288
306
|
|
|
289
307
|
Interception runs wherever Arc processes the result: model-bound queries, ordinary controller GET actions Arc wraps, observable snapshots and each live emission.
|
|
290
308
|
|
|
@@ -312,8 +330,13 @@ public class RequireActiveSession(ISessions sessions) : IGuardObservableQueryEmi
|
|
|
312
330
|
| Verdict | Effect |
|
|
313
331
|
| --- | --- |
|
|
314
332
|
| `Allow` | Deliver the result |
|
|
315
|
-
| `Suppress` | Withhold this emission; the subscription stays open. A snapshot answers 202 |
|
|
333
|
+
| `Suppress` | Withhold this emission; the subscription stays open. A subject snapshot without `waitForFirstResult=true` answers 202; with it the snapshot skips the emission and keeps waiting for an allowed one, a terminal verdict, the timeout, or the source ending first (500). An `IAsyncEnumerable<T>` snapshot leaves the item out and answers 200 with the allowed items |
|
|
316
334
|
| `DenyAndTerminate` | Send nothing, report unauthorized, end the subscription. A snapshot answers 403 |
|
|
335
|
+
| `Unavailable` | The check could not complete right now. Send nothing and end the operation; only the callers named here see a retryable failure. A snapshot answers 503 with `Retry-After: 1` and a retryable result. On the hub, a connection that opted in gets a terminal `Unavailable` for a subscription that carries a revision, and retries that subscription with backoff. Every other path (hub without opt-in or revision, single-query SSE or WebSocket) reports unauthorized |
|
|
336
|
+
|
|
337
|
+
Return `DenyAndTerminate` when access is refused. Return `Unavailable` only when the guard's own dependency (a permission or session lookup) is temporarily unreachable and the caller should retry.
|
|
338
|
+
|
|
339
|
+
Several guards: the most restrictive verdict wins (`DenyAndTerminate`, then `Unavailable`, then `Suppress`, then `Allow`). A denial stops evaluation; `Unavailable` does not, so a later guard's denial still wins. Discovery order is not a contract, so keep guards independent. A non-fatal exception thrown while constructing or running a guard counts as `DenyAndTerminate` and is logged as an error; ordinary teardown of an ended subscription is the exception described next. Every registered guard applies to every guarded delivery of every query and runs in turn until one denies; a cancellation because the subscription ended also yields `DenyAndTerminate` but is not logged. Because guards are not scoped to a query, a guard that cannot be constructed denies every emission that reaches the guards, live or snapshot (a snapshot with no readable value answers 202 without running any guard): check that its constructor dependencies are registered. `Suppress` does not move the delta baseline: the next allowed emission is diffed against the last admitted snapshot, so its change set carries the net difference since then. A withheld change that has since been reverted is not sent. When the next allowed emission states its changes (`ObservedCollection<T>` with `Changes` set), its change set holds only the items it names, so a withheld change to another item can be lost; combine `Suppress` with stated changes only where that loss is acceptable.
|
|
317
340
|
|
|
318
341
|
When access depends on mutable state, `StateAwareEmissionGuard<TState>` supplies a fail-closed implementation: override `GetKey(context)`, `Read(key, cancellationToken)` and `Decide(principal, state)`. Missing keys, missing state, read failures and rejection terminate delivery; override `OnDenied` for diagnostics. For a decision tied to the opened subscription, a filter can set `QueryContext.SubscriptionScope`; the guard reads a snapshot via `context.SubscriptionScope`.
|
|
319
342
|
|
|
@@ -324,15 +347,15 @@ When access depends on mutable state, `StateAwareEmissionGuard<TState>` supplies
|
|
|
324
347
|
Row narrowing restricts which rows of a read model a caller can get, inside the provider query, so no query on that model can return a row the caller may not see. Derive from `QueryRowNarrowing<TReadModel, TKey>`:
|
|
325
348
|
|
|
326
349
|
```csharp
|
|
327
|
-
public class PermitsInOwnZones(IZoneAccess access) : QueryRowNarrowing<ParkingPermit, ZoneName>
|
|
350
|
+
public class PermitsInOwnZones(IZoneAccess access, ICurrentPrincipalAccessor principals) : QueryRowNarrowing<ParkingPermit, ZoneName>
|
|
328
351
|
{
|
|
329
352
|
protected override Expression<Func<ParkingPermit, ZoneName>> Key => permit => permit.Zone;
|
|
330
353
|
|
|
331
354
|
protected override bool AppliesTo(QueryContext context) =>
|
|
332
|
-
|
|
355
|
+
principals.Current?.IsInRole("inspector") != true;
|
|
333
356
|
|
|
334
357
|
protected override async ValueTask<IEnumerable<ZoneName>> GetAllowedKeys(QueryContext context) =>
|
|
335
|
-
await access.ZonesFor(
|
|
358
|
+
await access.ZonesFor(principals.Current);
|
|
336
359
|
}
|
|
337
360
|
```
|
|
338
361
|
|
|
@@ -352,6 +375,8 @@ Bind `Cratis:Arc:Query` or set `ArcOptions.Query`:
|
|
|
352
375
|
|
|
353
376
|
`ArcOptions.QueryHealth` (`Cratis:Arc:QueryHealth`) secures the live health feed at `/.cratis/queries/health` with `RequireAuthentication` and `Roles`. Outside Development the feed requires authentication by default.
|
|
354
377
|
|
|
378
|
+
`"AllowedWebSocketOrigins": []` in configuration leaves the option unset, so the check stays off. List at least one origin there, or assign an empty list in code to allow the application's own origin and requests without an `Origin` header, and nothing else. Arc takes the application's own origin from the `Host` header and the connection scheme as ASP.NET Core sees them: behind a reverse proxy that rewrites `Host` or terminates TLS, apply forwarded headers (`UseForwardedHeaders`) or list the public origin, otherwise the browser's own-origin connections get 403. Loopback gets no special treatment, so list a development proxy on another port. When cookie authentication is configured and the option is unset, the host logs a warning at startup; set the option in every application that authenticates browsers with cookies.
|
|
379
|
+
|
|
355
380
|
Origins must be valid origins or `*`; queue capacity must be positive. Health `Roles` accepts comma-separated alternatives and forces authentication in every environment.
|
|
356
381
|
|
|
357
382
|
`transferMode: "full"` sends full snapshots; `"delta"` sends a snapshot first and then changes; omission retains snapshots alongside subsequent changes. This contract is for subject-backed collections on the hub. Delta delivery is chosen by the subscriber, not the server: the hub compares consecutive collection results by each item's `Id` property and sends added, replaced and removed items. Give list read models a stable `Id`; without one every emission is a full list.
|
|
@@ -405,4 +430,5 @@ For example, `var result = await pipeline.Perform(queryName, arguments, Paging.N
|
|
|
405
430
|
- No presence-preserving flag on a model-bound parameter. Use a separate explicit criterion when “omitted” differs from “use this default”. No arbitrary nested DTO binding: use scalar arguments or an MVC action for that contract.
|
|
406
431
|
- No declarative watch/topic list on a query. Compose provider observations or return a subscription-owned subject that emits refreshed data on notifications.
|
|
407
432
|
- No model-bound attribute to force a transport independently of result type, or built-in counted-page return wrapper for these methods. Return a supported subject for live delivery or `IQueryable<T>` for provider paging.
|
|
433
|
+
- No observable query in an ahead-of-time compiled host unless its element type is registered. Arc's source generator (it ships with the Arc package) does that for each model-bound query returning `ISubject<T>` or `IAsyncEnumerable<T>` in the project it builds, and is the supported way to register. An unregistered element type fails there with `MissingObservableQueryElementType`, naming the type. The registration alone does not make the whole application ahead-of-time compatible.
|
|
408
434
|
- No per-caller hub quotas or frame-byte limits in `QueryOptions`. Bound emissions there and enforce additional connection and request limits at the host or gateway.
|
|
@@ -56,7 +56,7 @@ Query options (`queries.Register` and `queries.RegisterObservable`):
|
|
|
56
56
|
| `WithValidator[A](v)`, `WithScopedValidator[A](factory, keys...)` | Validation of the bound arguments |
|
|
57
57
|
| `WithoutModelValidation[A]()` | Skips the argument model's declared validation |
|
|
58
58
|
| `WithRenderer[A, Q, R](factory, keys...)` | A renderer for this query only |
|
|
59
|
-
| `WithCollectionIdentity[A, T](extract)` |
|
|
59
|
+
| `WithCollectionIdentity[A, T](extract)` | Overrides the server's item identity only; the JSON still needs a conventional `id` for the JavaScript client to apply replacements |
|
|
60
60
|
| `WithEnumerable[A]()` | Observable only: reject ordinary snapshots even with a current value |
|
|
61
61
|
| `WithExcludeFromDiscovery[A](true)` | Omits from discovery; not an access control |
|
|
62
62
|
| `WithDescriptor[A](metadata.Query{...})` | A complete explicit descriptor, for migrations |
|
|
@@ -135,7 +135,7 @@ Never share caller-specific state across tenants. Treat values as immutable afte
|
|
|
135
135
|
|
|
136
136
|
The performer runs once per subscription, after admission. `waitForFirstResult=true` (text `true`, not `1`) with `waitForFirstResultTimeout=<seconds>` waits for the first value; default wait 30 seconds, capped by `MaximumWait`; 408 when it expires. Transports: `Accept: text/event-stream` or a WebSocket upgrade on the route, and the hub at `/.cratis/queries/ws` or `/.cratis/queries/sse`. `Observable.AllowedOrigins` in the host options lists additional exact origins for WebSocket.
|
|
137
137
|
|
|
138
|
-
See [MongoDB and live hosting](go-live.md) for storage-backed observations, transfer modes and load limits. For delta transfer,
|
|
138
|
+
See [MongoDB and live hosting](go-live.md) for storage-backed observations, transfer modes and load limits. For delta transfer, the server keys each item by its exported `ID` or `Id` field (declared on the item or promoted from an embedded struct), or by the key `WithCollectionIdentity` extracts; the JavaScript client matches change-set items by the JSON `id` property, so that property must hold the same value. `WithCollectionIdentity` changes only the server's key; it does not rename JSON. For a generated observable collection whose item has a conventional `ID`/`Id`, the generator requires exactly one such field (embedded and JSON-hidden ones count), declared directly on the item and serialized as `id` (tag it `json:"id"`, without `omitempty` or `omitzero`); it rejects any other layout. When it emits TypeScript proxies, that `id` must also be a non-nullable scalar (string, number, UUID or enum). Without an `id` property the client can still drop a removed item whose JSON is unchanged, but cannot match replaced items reliably. A collection without a server identity always receives full snapshots, in every transfer mode. For optional change hints emit `queries.ObservedCollection[T]` from an `observable.Source[queries.ObservedCollection[T]]`.
|
|
139
139
|
|
|
140
140
|
## Filters, renderers, interceptors and guards
|
|
141
141
|
|
|
@@ -225,7 +225,9 @@ static allPermits(models: ChronicleReadModels): Observable<ParkingPermit[]> {
|
|
|
225
225
|
| `watch(Type)` / `watchIterable(Type)` | Individual changesets |
|
|
226
226
|
| `getStore()` | The tenant's event store |
|
|
227
227
|
|
|
228
|
-
An append acknowledges persistence, not projection catch-up; an active projection is eventually consistent. Pass `ChronicleReadConsistency.Immediate` to `getById`, `findInstanceById` or `getAll` only for a passive projection, which the kernel computes on demand
|
|
228
|
+
An append acknowledges persistence, not projection catch-up; an active projection is eventually consistent. Pass `ChronicleReadConsistency.Immediate` to `getById`, `findInstanceById` or `getAll` only for a `@passive` model-bound projection, which the kernel computes on demand; for an active projection the read throws. To make a write visible to the next query instead, set `completionTimeoutMs` on a `defineChronicleCommand` definition (which uses only its own value), or on `withChronicle` for events a command returns from `handle()` or applies through a command aggregate, which Arc appends as one batch after the command succeeds. An SDK `eventLog.append(...)` called inside `handle()` bypasses that batch and does not wait. After a successful append the command waits until the event log's observers have caught up to the appended tail. The wait does not name the appended event types, so an observer included in it that does not handle those types can hold it to the timeout; the command then reports an exception although its events are stored. Enable it only where you have confirmed no such observer delays the wait; otherwise let the client tolerate the lag.
|
|
229
|
+
|
|
230
|
+
When the application also uses `withMongoDB`, a projected read model can be read through `MongoCollection.queryPage` and `observe` only if Chronicle writes it where that integration reads. Arc aligns the collection name automatically only when `withChronicle` creates the Chronicle client from a `connectionString`, you pass no `readModelNamingPolicy`, and the model class is listed in `withMongoDB`'s `readModels`. The database must match as well: set `withMongoDB`'s `database` to the event store name, and append each tenant's events to the Chronicle namespace named by its tenant id, as `withChronicle` does (a `defineChronicleCommand` `namespaceForContext` must return the same). With your own Chronicle `client` or your own naming policy, align the collection names yourself (`resolveMongoCollectionName` from `@cratis/arc.mongodb` gives the name Arc reads).
|
|
229
231
|
|
|
230
232
|
## Protected MongoDB results
|
|
231
233
|
|
|
@@ -253,7 +255,8 @@ class TenantGate implements AuthorizationQueryFilter {
|
|
|
253
255
|
@queryPipelineFilter()
|
|
254
256
|
class RequireTerm implements QueryPipelineFilter {
|
|
255
257
|
onPerform(context: QueryContext): QueryResult | void {
|
|
256
|
-
|
|
258
|
+
const name = context.operationName;
|
|
259
|
+
if ((name === 'search' || name?.endsWith('.search')) && !(typeof context.query === 'object' && context.query && 'term' in context.query && context.query.term)) {
|
|
257
260
|
return queryFilterResult(context, { validationResults: [validation('Term is required', ['term'])] });
|
|
258
261
|
}
|
|
259
262
|
}
|
|
@@ -262,7 +265,7 @@ class RequireTerm implements QueryPipelineFilter {
|
|
|
262
265
|
builder.add(TenantGate, RequireTerm);
|
|
263
266
|
```
|
|
264
267
|
|
|
265
|
-
|
|
268
|
+
Arc first checks the query's declared authorization and parses its arguments; authorization filters run next (they see the raw input when parsing failed), then pipeline filters, all before validators and the query method are constructed. Over HTTP (a snapshot or a direct SSE request) a denial answers 403 with no data and a thrown filter answers 500; a subscription through the query hub receives an unauthorized or error frame instead. `operationName` is the namespace-qualified declaration name, or the bare name when the declaration has no namespace, so match both forms (or one exact name); `RequireTerm` may skip a context with no name, but a filter that gates access by name must deny when it is absent. Tokens can be registered instead with `builder.addAuthorizationQueryFilter(token)` and `builder.addQueryPipelineFilter(token)`; a token in both groups fails at `build()`. A thrown filter fails closed. There is no availability filter in this SDK.
|
|
266
269
|
|
|
267
270
|
## Renderers
|
|
268
271
|
|
|
@@ -60,6 +60,7 @@ Use only the controls listed in the project reference. The following choices are
|
|
|
60
60
|
- **Metadata check:** compare the server metadata module to current source without writing proxies.
|
|
61
61
|
- **Proxy check:** compare generated output without writing when checking committed artifacts.
|
|
62
62
|
- **Validation projection report:** inspect which rules travel to the client separately from drift checking.
|
|
63
|
+
- **Client validation mode:** stop emitting generated client rule validators when validation messages must be worded per request by the server's own validation.
|
|
63
64
|
- **Watch:** regenerate after relevant source edits during development.
|
|
64
65
|
- **Watch polling:** tune or disable periodic fallback scans when their cost matters.
|
|
65
66
|
- **Manifest input:** use the lower-level renderer only when build tooling already supplies a validated client description.
|
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# Generate TypeScript clients from a C# project
|
|
2
2
|
|
|
3
|
+
## Contents
|
|
4
|
+
|
|
5
|
+
- Generate and verify
|
|
6
|
+
- Match the running endpoints
|
|
7
|
+
- Choose outputs only when needed
|
|
8
|
+
- What the build owns in the output tree
|
|
9
|
+
- Map namespaces and types
|
|
10
|
+
- Compare output or inspect validation without publishing
|
|
11
|
+
- Not supported in this SDK
|
|
12
|
+
- Common mistakes
|
|
13
|
+
|
|
3
14
|
Build the project that owns the Arc endpoints. `Cratis` brings in `Cratis.Arc.ProxyGenerator.Build`; when using `Cratis.Arc` alone, reference the build package explicitly. Use the matching `@cratis/arc` client in the frontend. Names below are illustrative.
|
|
4
15
|
|
|
5
16
|
## Generate and verify
|
|
@@ -12,6 +23,8 @@ For an existing `ReserveRoom` command in `Venue.Rooms`, add this to `Venue.cspro
|
|
|
12
23
|
</PropertyGroup>
|
|
13
24
|
```
|
|
14
25
|
|
|
26
|
+
Set every `CratisProxies*` property in the project file, or in `Directory.Build.targets` to share it between projects. Never use `Directory.Build.props`: the build package assigns its defaults after that file is read, so the output path, segments to skip, API prefix, library mode, incremental reuse, output deletion and the two name-in-route switches set there are overwritten.
|
|
27
|
+
|
|
15
28
|
Run `dotnet build Venue.csproj`. The after-build target passes the compiled assembly to the generator; make its project dependencies available alongside the assembly. Normal discovery starts with commands, queries and typed identity details and follows referenced models. Under default conventions, import `ReserveRoom` from `./generated/Venue/Rooms/ReserveRoom` in a module beside `generated`. Inspect the payload, result and `/api/venue/rooms/reserve-room` route, then type-check the frontend. Snapshot and observable query methods generate different clients; generated React helpers follow the query kind and cardinality, not the read model's name.
|
|
16
29
|
|
|
17
30
|
## Match the running endpoints
|
|
@@ -30,6 +43,7 @@ Names are included by default and restored when skipping would cause conventiona
|
|
|
30
43
|
- **Transport:** `[QueryHttpMethod(QueryHttpMethod.Query)]` selects HTTP QUERY for a model-bound query; `Get` requests GET, `Auto` negotiates. A method overrides its read model. This selects the generated client default, not which verbs the host accepts; callers can use `setHttpMethod`.
|
|
31
44
|
- **Group:** for `[EndpointGroup("staff")]` endpoints set `CratisProxiesEndpointGroup=staff` and use the host port assigned to that group. By default only the default group is generated. Method overrides type, type overrides assembly. Give each generated group its own output tree.
|
|
32
45
|
- **Location:** in TypeScript read `ReserveRoom.sliceLocation`, or use `SliceLocation.ofType(ReserveRoom)` / `SliceLocation.of(command)` from `@cratis/arc/reflection`. The owning namespace after root matching or trimming supplies module / intervening feature segments / slice; short paths fill deepest first. An output folder alias does not become a module.
|
|
46
|
+
- **Backend location:** `CommandContext.SliceLocation` and `QueryContext.SliceLocation` (`SliceLocation` from `Cratis.Arc.Slices`, with `Module`, `Feature` and `Slice`) follow the same rules, with one exception: when a command's `Handle` method or a controller action is inherited, the proxy takes its location from the class that declares the method, while the runtime uses the concrete command or controller type. Declare such methods on the concrete type when both must agree. A multi-segment feature keeps its dots and `ToString()` joins the non-empty parts with `/`. While assembly-info generation is on (the default), the build writes a project's `NamespaceRoot` items and `CratisProxiesSegmentsToSkip` into assembly attributes; the skip count is written only when it is a non-negative whole number. Arc resolves the location from the command or read model type for model-bound endpoints and from the controller type for controller actions. It reads the attributes from the assembly that declares that type and falls back to the entry assembly only when that assembly declares neither. In a class library holding slices, set neither so the host's settings apply, or set exactly the host's roots and skip count. A `CommandContext` you construct resolves its location from the command type; a `QueryContext` you construct carries `SliceLocation.NotSet` until you set `SliceLocation = SliceLocation.For(readModelType)`.
|
|
33
47
|
|
|
34
48
|
## Choose outputs only when needed
|
|
35
49
|
|
|
@@ -37,16 +51,26 @@ These examples are MSBuild property assignments (e.g. `<CratisProxiesFramework>n
|
|
|
37
51
|
|
|
38
52
|
- `CratisProxiesSkip=true` or `DisableProxyGenerator=true`: skip generation even with a destination. Leaving `CratisProxiesOutputPath` empty disables generation; `CratisProxiesSuppressOutputPathMessage=true` silences the empty-path notice.
|
|
39
53
|
- `CratisProxiesIncremental=false`: force discovery instead of reusing the fingerprint and recorded outputs under `$(IntermediateOutputPath)`. It does not disable the per-file write shortcut. For a damaged file, remove that generated file and rebuild.
|
|
40
|
-
- `CratisProxiesSkipOutputDeletion=false`: **recursively delete the entire output tree** before generating; use only on a disposable directory, with incremental reuse disabled for a forced reset. Normally the build keeps the directory
|
|
54
|
+
- `CratisProxiesSkipOutputDeletion=false`: **recursively delete the entire output tree** before generating; use only on a disposable directory, with incremental reuse disabled for a forced reset. That removes every stale file, with or without a marker or a record of the previous build. Normally the build keeps the directory and removes a stale file only when it carries the generated marker and the previous build recorded it (see "What the build owns in the output tree"). `CratisProxiesSkipFileIndexTracking` is forwarded but not parsed; it cannot retain orphans.
|
|
41
55
|
- `CratisProxiesUseSourceFileAsOutputFile=true`: group by C# source filename instead of per type when method debug info in an embedded or adjacent portable PDB identifies the document. Unresolved types (often enums) keep separate files.
|
|
42
56
|
- `CratisProxiesUseProxyFileSuffix=true`: write `ReserveRoom.proxy.ts`; update handwritten direct imports. Generated imports and barrels follow the suffix.
|
|
43
57
|
- `CratisProxiesSkipIndexGeneration=true`: skip writing folder `index.ts` exports. Keep handwritten barrels outside the output tree: skipping writes does not prevent cleanup.
|
|
44
|
-
- `CratisProxiesFileHeader=Venue contracts\n{fileName}`: emit comment lines with the generated filename substituted. Unset
|
|
58
|
+
- `CratisProxiesFileHeader=Venue contracts\n{fileName}`: emit comment lines with the generated filename substituted. Unset or empty uses `file_header_template` from `.editorconfig`, read only from `[*]`, `[*.cs]` and `[*.{…}]` lists with an exact `cs` entry such as `[*.{ts,cs}]` (`[*.{ts, cs}]`, path-specific and TypeScript-only sections are ignored); otherwise no custom header. `none` (any case) suppresses the fallback, not tracking metadata. An existing `index.ts` updated in place keeps its comments and gets no new header; only newly created ones get it. Full output deletion removes existing indexes, and orphan-directory cleanup can too. After changing the header, edit the header comment in surviving `index.ts` files by hand; deleting them to get the new header loses any handwritten lines they hold.
|
|
45
59
|
- `CratisProxiesLibraryMode=true`: also collect public concrete types, interfaces and enums from project assemblies even without endpoint references. Open generic definitions are not concrete model roots.
|
|
46
60
|
- `CratisProxiesEmitInterfaces=true`: render plain model shapes rather than decorated classes. Use for data-only contracts, not where query/identity deserialization needs constructors. Command/query clients themselves remain classes.
|
|
61
|
+
- `CratisProxiesClientValidation=server`: emit no generated client rule validators, so a request that reaches the server gets its validation messages from the server, resolved for the request (language, tenant). The mode only suppresses generated validators; it adds no server validation, and a validator Arc does not discover still does not run there. Use it when messages are localized or come from a message lambda. The default `mirrored` emits validators for the projectable rules; a blocking one stops the request in the browser and shows the wording fixed at build time (a literal message, or the client rule's default when the server message is a lambda). Before switching, remove application imports of the generated validator classes, then rebuild. Required-property and required-query-parameter checks, route argument checks and handwritten client validators still run in both modes and can still stop a request in the browser. `mirrored` and `server` are the only values.
|
|
47
62
|
- `CratisProxiesFramework=none`: omit React helpers but retain executable Arc client classes; default is React.
|
|
48
63
|
- `CratisAvailabilityManifest=$(MSBuildProjectDirectory)/obj/availability.json`: export discovered command/read-model parts, slice locations and availability gates for tooling. This does not enforce access.
|
|
49
64
|
|
|
65
|
+
## What the build owns in the output tree
|
|
66
|
+
|
|
67
|
+
- **Generated files** carry a `// @generated by Cratis` marker line. When a command, query or type is renamed or removed, the next build deletes its stale file only when all of these hold: the file is a `.ts` file that still carries the marker, the previous successful build of the project recorded it as its output, and this build does not produce it. Files without the marker are never deleted as stale. With `CratisProxiesIncremental=false`, or after that record under `$(IntermediateOutputPath)` is lost (a cleaned `obj`, a fresh checkout), stale files stay: delete them by hand. These conditions apply while the build keeps the output tree, which is the default. With `CratisProxiesSkipOutputDeletion=false` the whole tree is deleted before generating, so stale files go with it whatever their marker or record. There is no separate tracking index in the frontend to create, commit or repair.
|
|
68
|
+
- **One output tree per generating build.** Give each generating project (and each endpoint group) its own output directory; a build that regenerates from scratch (`CratisProxiesSkipOutputDeletion=false`) deletes the whole tree, including another build's files.
|
|
69
|
+
- **`index.ts` is merged, not owned.** It carries no marker. Unless `CratisProxiesSkipIndexGeneration=true`, the build merges the `index.ts` of each folder it generates a file into, and of folders whose `index.ts` the previous build recorded; other folders are left alone. There it adds an `export * from './<file>'` line for every generated file in the folder, removes relative `export * from` lines whose target no longer exists, and keeps the rest: `export * from` lines for handwritten `.ts`/`.tsx` files, for a subfolder with its own `index.ts`/`index.tsx` and for packages, plus any other line (imports, comments, named exports). Kept lines that are not `export * from` are moved above the exports and blank lines are dropped. A relative target is checked by its name inside the index's own folder, whatever leading `./` or `../` it has: `export * from '../Shared'` is kept only if that folder itself holds `Shared.ts`, `Shared.tsx` or a `Shared` subfolder with its own index, and is removed otherwise. Re-export a parent or sibling folder from a barrel outside the output tree.
|
|
70
|
+
- A handwritten file is not exported automatically: add its `export * from` line yourself; the build then keeps it.
|
|
71
|
+
- **A handwritten barrel in a generated folder becomes recorded.** Unless `CratisProxiesSkipIndexGeneration=true`, each build records the `index.ts` of every folder it generates a file into, also one you wrote yourself before the first proxy landed there. When a stale generated file is deleted from a folder that then holds no other `.ts`/`.tsx` file and no subfolder, the build removes that folder's `index.ts` if the previous build recorded it, handwritten lines included, and then the folder when it is empty. An `index.ts` that was not recorded stays, and so does its folder. A barrel that must survive on its own belongs outside the output tree.
|
|
72
|
+
- **A surviving barrel can keep a stale export.** When the last generated file leaves a folder that a handwritten `.ts`/`.tsx` file or a subfolder keeps alive, the build deletes the stale file but does not rewrite that folder's `index.ts`: its `export * from` line for the removed file stays and breaks the TypeScript compile. Remove that line by hand.
|
|
73
|
+
|
|
50
74
|
## Map namespaces and types
|
|
51
75
|
|
|
52
76
|
Add only the needed MSBuild items. `Include` identifies the item; the named metadata configures generation.
|
|
@@ -62,18 +86,41 @@ Add only the needed MSBuild items. `Include` identifies the item; the named meta
|
|
|
62
86
|
</ItemGroup>
|
|
63
87
|
```
|
|
64
88
|
|
|
65
|
-
The longest matching namespace root redirects its subtree; `Folder=""` strips that prefix without replacing it.
|
|
89
|
+
The longest matching namespace root redirects its subtree; `Folder=""` strips that prefix without replacing it. A root's `Namespace` decides both the output folder and the slice location of commands and queries; its `Folder` changes only the output path. Roots never change URLs. A `TypeToTsType` mapping is checked ahead of the built-in mappings wherever a type goes through that lookup; it cannot target one property. Enums and dictionaries are resolved before the lookup, a concept is looked up by its underlying value type rather than its own name, and dictionary keys use only the built-in mappings. An item without `TypeName` or `TsType` is skipped with an "ignoring unusable --type-to-ts entry" warning in the build output. Map only to a compatible wire shape; omit `Package` for inline TypeScript types, supply it for imported names. A `ConceptAs` class hydrates itself. Any other imported class that wraps a scalar needs a `JsonConverter<T>` registered with `JsonSerializer.registerConverter` at client startup (see `cratis-fundamentals-concept`), unless one is already registered: Fundamentals ships converters for its own `Guid`, `DateOnly`, `TimeOnly` and `TimeSpan`. Without a converter, deserialization calls the class's no-argument constructor and ignores the wire value, so the result does not hold the sent value. Assembly mappings reuse exports from a client package rather than emitting copies. Exclusions remove unwanted types/subtrees; compile callers to catch missing dependencies. No special setting is needed for indirect scalar concepts: a record derived via an intermediate `ConceptAs<string>` record maps to the underlying string.
|
|
90
|
+
|
|
91
|
+
Built-in mappings, used unless a `TypeToTsType` item replaces them:
|
|
92
|
+
|
|
93
|
+
| C# type | TypeScript type |
|
|
94
|
+
| --- | --- |
|
|
95
|
+
| `byte`, `sbyte`, `short`, `ushort`, `int`, `uint`, `long`, `ulong`, `float`, `double`, `decimal` | `number`. A `long`, `ulong` or `decimal` beyond what a JavaScript number holds exactly loses precision in the browser; send such a value as a string concept. |
|
|
96
|
+
| `string`, `char`, `Uri` | `string` |
|
|
97
|
+
| `bool` | `boolean` |
|
|
98
|
+
| `DateTime`, `DateTimeOffset` | `Date` |
|
|
99
|
+
| `Guid`, `DateOnly`, `TimeOnly`, `TimeSpan` | The type of the same name from `@cratis/fundamentals` |
|
|
100
|
+
| `Point`, `LineString`, `Polygon` from `Cratis.Geospatial` | The type of the same name from `@cratis/fundamentals` |
|
|
101
|
+
| `object`, `JsonNode`, `JsonObject`, `JsonDocument` | `Record<string, unknown>` |
|
|
102
|
+
| `JsonArray` | `Record<string, unknown>[]` on a generated property: it is treated as a collection of that shape |
|
|
66
103
|
|
|
67
104
|
## Compare output or inspect validation without publishing
|
|
68
105
|
|
|
69
|
-
Use the packaged executable directly with the same compiled input and generation arguments as the build. In these shell examples `generator` is the absolute path to `Cratis.Arc.ProxyGenerator.Build.dll` from the build task directory; `assembly` and `
|
|
106
|
+
Use the packaged executable directly with the same compiled input and generation arguments as the build. In these shell examples `generator` is the absolute path to `Cratis.Arc.ProxyGenerator.Build.dll` from the build task directory; `assembly`, `out` and `scratch` are absolute paths, `scratch` being a disposable directory. This is not a globally installed CLI.
|
|
70
107
|
|
|
71
108
|
```sh
|
|
72
109
|
dotnet "$generator" "$assembly" "$out" --skip-output-deletion --check
|
|
73
|
-
dotnet "$generator" "$assembly" "$
|
|
110
|
+
dotnet "$generator" "$assembly" "$scratch" --validation-report=json --validation-report-file="$PWD/validation.json"
|
|
74
111
|
```
|
|
75
112
|
|
|
76
|
-
For a drift gate build the input with `-p:CratisProxiesSkip=true` first so the build does not repair the evidence.
|
|
113
|
+
For a drift gate build the input with `-p:CratisProxiesSkip=true` first so the build does not repair the evidence. That build runs no generator, so take the exact arguments from the generator command in a normal-verbosity log (`dotnet build -v:n`) of an earlier generation-enabled build, or of a separate build whose `CratisProxiesOutputPath` is a disposable directory. The build runs the generator from the build task directory, so make any relative paths in the logged command absolute (or replay from that directory). Pass the options the build passes, or the check compares against output the build never writes. `CratisProxiesSegmentsToSkip` is the optional third argument, directly after the output path and before any switch: `dotnet "$generator" "$assembly" "$out" 1 --check`. Everything else is a switch: `--project-directory=<project folder>` for header resolution, plus one for each setting you use, such as `--endpoint-group=<group>` (it changes which endpoints are discovered), `--file-header-base64=<Base64 of CratisProxiesFileHeader>`, `--use-proxy-file-suffix`, `--api-prefix=<prefix>`, `--framework=none`, `--client-validation=server` and repeated `--namespace-root=<Namespace>=<Folder>`. The usage text the generator prints without arguments is only a summary and omits some switches. `--check` writes and deletes nothing, including the availability manifest, but it is not a sandbox: it loads the assembly and runs validator constructors, so use only trusted inputs. It prints one `missing: <path>`, `changed: <path>` or `obsolete: <path>` line per finding (relative to the output, `/` separators) and then a summary line; a clean run prints `Proxies are up to date.`. Exit `0` is clean and `2` is drift. Exit `1` is a failure: with fewer than two positional arguments the generator prints its usage text on stdout; other usage, loading and comparison failures it handles print `error: <message>` on stderr. Treat only `2` as stale proxies and any other non-zero exit, whatever its output, as a failed check. Separately use `--validation-report=text` for human inspection or `json` for tooling; a report run still writes proxies to its output tree (and deletes that tree first unless `--skip-output-deletion` is passed), so point it at `scratch`, never at `out`. It also writes the availability manifest, so omit `--availability-manifest` or point it into `scratch`. A `--validation-report-file` inside the proxy output tree is rejected with exit 1, so write it elsewhere. Combining `--check` with a report option is a usage error (exit 1); run them as two invocations. Both ignore `--state-file`. For direct **writing** calls pass `--skip-output-deletion` to avoid wiping the destination and optionally `--state-file=/absolute/path/to/state.json` outside it for incremental generation.
|
|
114
|
+
|
|
115
|
+
Client rules for a command property or a model-bound query parameter come from, in order:
|
|
116
|
+
|
|
117
|
+
1. The rules of the model's validator.
|
|
118
|
+
2. Plus the rules of the member's concept validator (identical rules appear once).
|
|
119
|
+
3. Data annotations, only when neither of the above contributed a rule the generator can extract for that member. An annotation on a member that has such a rule is not projected; a validator rule that cannot be extracted does not displace it. For a model-bound query the annotations can sit on the property of the matching argument model or directly on the method parameter; when both yield a rule for the same member, the argument model's annotations are used and the parameter's are not.
|
|
120
|
+
|
|
121
|
+
The generator uses one validator per model, never a combination. Two validators deriving from `CommandValidator<T>`, `QueryValidator<T>` or another discoverable base for the same model fail generation with "Multiple validators for …": merge them into one. When the model has none of those, the generator falls back to a validator that is not discoverable, such as a bare FluentValidation `AbstractValidator<T>`. Arc does not discover that one on the server, so the client carries rules Arc never runs; such a rule stops the request in the browser when its severity is one the client blocks on. Derive from `CommandValidator<T>` or `QueryValidator<T>` so both sides agree (`cratis-arc-validate-command`). Edge case, controller queries: annotations placed directly on action parameters are a fallback for the whole query, not per parameter. They are projected only when everything else yields no rule at all: no rule from the matching argument model's validator, none from its annotations and none from the concept validators of the action's parameters. Concept rules are inferred only when a matching argument model exists, so without one the direct annotations are always the source.
|
|
122
|
+
|
|
123
|
+
A projection report lists what can be projected, also when `CratisProxiesClientValidation=server` suppresses the validators.
|
|
77
124
|
|
|
78
125
|
Projected literal rules (e.g. required, lengths, comparisons, regex) provide client feedback. Conditional rules, arbitrary predicates and injected-data checks remain server concerns. A clean projection report is not proof the command will execute. After changing a backend contract regenerate rather than patching the client.
|
|
79
126
|
|
|
@@ -89,3 +136,5 @@ Projected literal rules (e.g. required, lengths, comparisons, regex) provide cli
|
|
|
89
136
|
|
|
90
137
|
- Building only the frontend after changing a backend contract: rebuild the configured endpoint project first.
|
|
91
138
|
- Editing generated payloads or routes: correct the contract or generator settings and regenerate.
|
|
139
|
+
- Adding roll-forward or runtime settings because the backend targets a newer .NET than the generator was built for: none is needed. For a compatible newer target framework the build by default runs the generator with roll-forward to the latest installed major runtime; it is not pinned to the project's target runtime.
|
|
140
|
+
- Using two closed instantiations of one generic model, such as `Page<Order>` and `Page<Invoice>`: both generate as `Page` in the generic's folder. Generation fails with "Duplicate type names detected"; with `CratisProxiesUseSourceFileAsOutputFile=true` that check is skipped, but both declarations are combined into one file under the same name `Page`, so the TypeScript does not compile. Declare a non-generic type with its own properties for each shape; deriving from the closed generic still generates the generic.
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Generate clients from a Node backend
|
|
2
2
|
|
|
3
|
+
## Contents
|
|
4
|
+
|
|
5
|
+
- Generate before compiling the client
|
|
6
|
+
- Align routes and output
|
|
7
|
+
- Inspect the published contract
|
|
8
|
+
- Integrate with custom tooling
|
|
9
|
+
- Not supported in this SDK
|
|
10
|
+
|
|
3
11
|
Use source mode for decorated commands and queries. It reads the backend TypeScript program, not a running server. Names below are illustrative.
|
|
4
12
|
|
|
5
13
|
## Generate before compiling the client
|
|
@@ -66,5 +74,6 @@ For low-level `defineCommand` / `defineQuery` registrations, describe outputs wi
|
|
|
66
74
|
- No endpoint-group selector, namespace-root folder map, independent layout trim, source-file bundling, or custom header: select the correct artifacts and output roots; use generated imports as written.
|
|
67
75
|
- No package-wide mapping, type/namespace exclusion filters or extra model roots: map shared types individually and publish other shared contracts in a separate package.
|
|
68
76
|
- No response-override option or target-client compatibility profile: give the backend a statically resolvable return type and type-check against the installed client packages.
|
|
77
|
+
- No client validation mode: there is no switch that stops the generator emitting client validators so that only the server evaluates the rules (the C# build has one, `CratisProxiesClientValidation`). Server validation stays authoritative either way.
|
|
69
78
|
- No full proxy check or validation projection report: regenerate in a clean checkout and check generated changes (including new files); inspect diagnostics and generated validators. Metadata check alone does not verify clients.
|
|
70
79
|
- No availability manifest, adapter generator, endpoint-options resource, generated slice-location API, or OpenAPI/Screenplay companion output: register artifacts on the host, match routing explicitly and obtain any separate tooling contract from its owner.
|
|
@@ -33,7 +33,7 @@ Python has no Arc application SDK and cannot host operations: host them in a ser
|
|
|
33
33
|
- **Plain endpoint:** map a hand-written route such as a health check beside the generated ones, where the SDK offers it; it bypasses the command and query pipelines, so state its authentication requirement explicitly.
|
|
34
34
|
- **Endpoint groups:** bind groups to ports and optional prefixes when operators need separate listeners; decide explicitly whether ungrouped routes may share group ports.
|
|
35
35
|
- **Controllers:** omit conventional controller registration on a host serving only Arc endpoints.
|
|
36
|
-
- **Static assets and fallback:** serve the built frontend if it ships with the backend; use a fallback entry file for browser navigation, not as proof an API route exists.
|
|
36
|
+
- **Static assets and fallback:** serve the built frontend if it ships with the backend (C#: read `references/csharp-deployment.md` when shipping both as one deployable); use a fallback entry file for browser navigation, not as proof an API route exists.
|
|
37
37
|
- **Static file policy:** choose the served directory, mount path, default documents and content types. Keep directory browsing off unless listing files is intentional; allow well-known resources explicitly when needed.
|
|
38
38
|
|
|
39
39
|
## Request context and access catalog
|
package/package/corpus/skills/cratis-arc-host-application/references/csharp-configuration.md
CHANGED
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
- Where settings come from
|
|
6
6
|
- Core, commands and queries
|
|
7
|
+
- JSON serialization
|
|
8
|
+
- Request localization
|
|
7
9
|
- Routes
|
|
8
10
|
- Identity and discovery
|
|
9
11
|
- Tenancy
|
|
@@ -59,6 +61,58 @@ For example, these settings behind an HTTPS gateway keep a live-query backlog sm
|
|
|
59
61
|
|
|
60
62
|
For a cross-assembly query, call `options.Artifacts.Include(typeof(DepotStatus).Assembly)` and inspect `IncludedAssemblies` for explicit inclusions. To bound HTTP request bodies on ASP.NET Core use `builder.WebHost.ConfigureKestrel(k => k.Limits.MaxRequestBodySize = 1_048_576)`; verify oversized requests are rejected at the intended boundary.
|
|
61
63
|
|
|
64
|
+
## JSON serialization
|
|
65
|
+
|
|
66
|
+
`JsonSerializerOptions` in the options callback is the serializer for the generated command and query endpoints: add converters or change settings there. Other endpoint kinds have their own options:
|
|
67
|
+
|
|
68
|
+
| Endpoints | Configure | What Arc does to it |
|
|
69
|
+
| --- | --- | --- |
|
|
70
|
+
| Generated commands and queries | `options.JsonSerializerOptions` in `AddCratisArc` | Uses it as is. |
|
|
71
|
+
| Controllers | MVC's JSON options, after `AddCratisArc` returns: `builder.Services.PostConfigure<Microsoft.AspNetCore.Mvc.JsonOptions>(...)` | Still sets its own naming policy, removes the first `JsonStringEnumConverter` and appends its converters. Use it for other settings such as null omission and number handling. |
|
|
72
|
+
| Plain minimal APIs | ASP.NET Core's `ConfigureHttpJsonOptions` | Adds concept converters only; naming, enums and dates stay ASP.NET Core's. |
|
|
73
|
+
|
|
74
|
+
- `ConfigureHttpJsonOptions` never changes a generated command or query endpoint.
|
|
75
|
+
- Configure MVC after `AddCratisArc` returns, not inside its `configureBuilder` callback: settings made there run before Arc's own setup and are overridden.
|
|
76
|
+
|
|
77
|
+
## Request localization
|
|
78
|
+
|
|
79
|
+
Arc can pick the UI language per request, so validation messages and other resources come back in the caller's language. It is opt-in: without `Localization`, Arc negotiates nothing and adds no header. The client side is in `cratis-arc-react-bind-slice`, `references/typescript-localization.md`.
|
|
80
|
+
|
|
81
|
+
```csharp
|
|
82
|
+
builder.AddCratisArc(configureOptions: options =>
|
|
83
|
+
{
|
|
84
|
+
options.Localization = new()
|
|
85
|
+
{
|
|
86
|
+
SupportedUICultures = ["en", "nb-NO"],
|
|
87
|
+
DefaultUICulture = "en"
|
|
88
|
+
};
|
|
89
|
+
});
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
| Key under `Localization` | Default | Meaning |
|
|
93
|
+
| --- | --- | --- |
|
|
94
|
+
| `SupportedUICultures` | required | Distinct canonical .NET culture names such as `nb-NO`. |
|
|
95
|
+
| `DefaultUICulture` | required | Used when no provider selects a culture. Must be one of the supported names. |
|
|
96
|
+
| `Providers` | `AcceptLanguage` only | Where the language comes from, in priority order: `QueryString` (`?ui-culture=nb-NO`), `Cookie` (`.AspNetCore.Culture`) and `AcceptLanguage`. An unsupported value falls through to the next provider. |
|
|
97
|
+
| `FormattingCulture` | invariant | One fixed culture for number and date formatting in every request. |
|
|
98
|
+
|
|
99
|
+
- Invalid options stop startup: an empty list, a duplicate, a non-canonical name or a default outside the supported list. A `Providers` list that is set must be non-empty and without duplicates.
|
|
100
|
+
- Default: leave `Providers` unset and let `Accept-Language` decide. Set `Providers`, for example `["QueryString", "Cookie", "AcceptLanguage"]`, only when a user must be able to choose a language that differs from the browser's.
|
|
101
|
+
- A language tag matches a supported culture exactly, through a supported parent, or through its only supported regional variant: `nb` selects `nb-NO` when that is the only supported `nb` culture.
|
|
102
|
+
- The caller's language never selects the formatting culture or a time zone. JSON formats follow the serializer.
|
|
103
|
+
- Responses carry `Content-Language`, and `Vary: Accept-Language` when that provider is on. With the cookie provider on, responses are marked as not to be stored by caches.
|
|
104
|
+
- Observable-query streams carry the language in the reserved query parameter `_cratisUiCulture`, because browser stream APIs cannot set the header. The Arc client adds it only when the frontend has a language configured. On a stream request a value that exactly names a supported culture wins over the providers; otherwise the providers decide as usual. Do not name a query argument that.
|
|
105
|
+
- `UseCratisArc()` installs the middleware ahead of Arc's endpoints. Call `app.UseCratisRequestLocalization()` earlier only when middleware or routes before Arc need the culture; it is not installed twice. The self-hosted listener behaves the same and needs no call.
|
|
106
|
+
- One policy per pipeline: do not combine this with `app.UseInvariantCulture()` or ASP.NET Core's `UseRequestLocalization`. Arc throws an `InvalidOperationException` instead of running two policies.
|
|
107
|
+
- The selected language is `CultureInfo.CurrentUICulture` while the request runs. Arc restores the previous cultures afterwards and never changes the host-wide defaults. Work started from inside a request can inherit the request's culture: set the culture explicitly in background work whose output language matters.
|
|
108
|
+
- Give validation messages as lambdas, so a shared validator resolves them per request and not once:
|
|
109
|
+
|
|
110
|
+
```csharp
|
|
111
|
+
RuleFor(command => command.Name).NotEmpty().WithMessage(_ => ValidationMessages.NameRequired);
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
`ValidationMessages` stands for the application's resource class.
|
|
115
|
+
|
|
62
116
|
## Routes
|
|
63
117
|
|
|
64
118
|
Keys are under `GeneratedApis`. The MSBuild properties configure proxy generation and must describe the same routes; they do not configure the running host.
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# Deploy an Arc application (C#)
|
|
2
|
+
|
|
3
|
+
## Contents
|
|
4
|
+
|
|
5
|
+
- One deployable
|
|
6
|
+
- Build and publish
|
|
7
|
+
- Configure the deployed host
|
|
8
|
+
- Put the ingress in front
|
|
9
|
+
- Verify
|
|
10
|
+
- Alternative: a separately hosted frontend
|
|
11
|
+
- Anti-patterns
|
|
12
|
+
|
|
13
|
+
## One deployable
|
|
14
|
+
|
|
15
|
+
Default: ship the application as one process. The ASP.NET Core host serves the generated command and query endpoints and the built frontend from one origin, so the browser needs no cross-origin setup and the generated proxies call the API with relative URLs.
|
|
16
|
+
|
|
17
|
+
The host created by the `cratis` template already has this shape: the frontend build writes to the backend's `wwwroot`, and the host serves it with `UseDefaultFiles()`, `UseStaticFiles()` and `MapFallbackToFile("/index.html")`. For the middleware itself see [the C# host reference](csharp.md).
|
|
18
|
+
|
|
19
|
+
## Build and publish
|
|
20
|
+
|
|
21
|
+
1. Install the frontend dependencies with the package manager the scaffold chose, from its lockfile. A clean build workspace has none.
|
|
22
|
+
|
|
23
|
+
| Package manager | Frozen install |
|
|
24
|
+
| --- | --- |
|
|
25
|
+
| npm | `npm ci` |
|
|
26
|
+
| Yarn | `yarn install --immutable` |
|
|
27
|
+
| pnpm | `pnpm install --frozen-lockfile` |
|
|
28
|
+
|
|
29
|
+
These commands fail without a lockfile, and a project scaffolded without the install step has none. Run the manager's plain `install` once on a development machine, commit the lockfile it writes, and use the frozen install in every build after that.
|
|
30
|
+
2. Build the backend: `dotnet build --configuration Release`. This regenerates the TypeScript proxies, which the frontend build compiles against.
|
|
31
|
+
3. Build the frontend. In the template this is the `build` script in the root `package.json` (`npm run build`, `yarn build` or `pnpm build`); it type-checks and writes to `wwwroot`.
|
|
32
|
+
4. Publish the backend: `dotnet publish --configuration Release --output <folder>`. The publish output includes `wwwroot`.
|
|
33
|
+
5. Run the published output on an ASP.NET Core runtime image, as a non-root user.
|
|
34
|
+
|
|
35
|
+
- Keep this order. Without step 2 the frontend compiles against stale or missing proxies after a backend change. `wwwroot` is not committed in the template, so a publish without step 3 produces a host that answers the API but has no frontend.
|
|
36
|
+
- Build the image in two stages: an SDK stage that runs steps 1 to 4 (it needs Node.js and the .NET SDK), and a runtime stage that only copies the publish output.
|
|
37
|
+
- Pin the base images and the Cratis packages to released versions for anything other people reach. The template references Cratis packages with a floating version; replace it before shipping.
|
|
38
|
+
|
|
39
|
+
## Configure the deployed host
|
|
40
|
+
|
|
41
|
+
Supply environment-specific values as environment variables; `:` in a configuration key becomes `__`.
|
|
42
|
+
|
|
43
|
+
| Value | Key |
|
|
44
|
+
| --- | --- |
|
|
45
|
+
| Chronicle connection string | `Cratis__Chronicle__ConnectionString` |
|
|
46
|
+
| Event store name | `Cratis__Chronicle__EventStore` |
|
|
47
|
+
| Read models in MongoDB | `Cratis__MongoDB__Server`, `Cratis__MongoDB__Database` |
|
|
48
|
+
| Read models through Entity Framework Core | `ConnectionStrings__Cratis`, when the host reads its connection string from there as the template does |
|
|
49
|
+
| Arc options | `Cratis__Arc__...`; see [host configuration](csharp-configuration.md) |
|
|
50
|
+
|
|
51
|
+
- Take the Chronicle client credentials and database passwords from the platform's secret store. The client and passwords in the template's `appsettings.json` and `docker-compose.yml` are public development values: never deploy them.
|
|
52
|
+
- Give each service its own Chronicle client with access to only the event stores it uses. Registering clients on the kernel is in `cratis-chronicle-deploy-kernel`, `references/authentication.md`; connecting the application is in `cratis-chronicle-connect-application`.
|
|
53
|
+
- The listening address is ASP.NET Core's, not Arc's: set `ASPNETCORE_HTTP_PORTS` or `ASPNETCORE_URLS` to what the platform expects. The ASP.NET Core runtime images listen on port 8080 by default.
|
|
54
|
+
- Decide whether the deployed host serves the API description. The template serves Swagger for every environment; restrict it to Development or protect it. See [API description](csharp-http.md).
|
|
55
|
+
- Give the orchestrator separate liveness and readiness endpoints with ASP.NET Core health checks. Readiness runs the checks tagged `ready`. Liveness runs no dependency check: restarting the host does not bring Chronicle back. A `MapHealthChecks` without a predicate runs every check, so set one on both:
|
|
56
|
+
|
|
57
|
+
```csharp
|
|
58
|
+
builder.Services.AddHealthChecks();
|
|
59
|
+
|
|
60
|
+
// after builder.Build()
|
|
61
|
+
app.MapHealthChecks("/health/live", new HealthCheckOptions { Predicate = _ => false });
|
|
62
|
+
app.MapHealthChecks("/health/ready", new HealthCheckOptions
|
|
63
|
+
{
|
|
64
|
+
Predicate = registration => registration.Tags.Contains("ready")
|
|
65
|
+
});
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
- `AddHealthChecks()` is required before the endpoints are mapped. Call it yourself: a host that does not use Chronicle has no other registration, and calling it twice is harmless.
|
|
69
|
+
- Adding the Chronicle client to an ASP.NET Core host registers the Chronicle connection check and tags it `ready`, so readiness covers Chronicle without more code.
|
|
70
|
+
- Nothing else is tagged for you. For every other dependency the host cannot serve without, add a check with the `ready` tag (`.AddCheck<TCheck>("name", tags: ["ready"])`). A host with no `ready` check always reports ready.
|
|
71
|
+
|
|
72
|
+
## Put the ingress in front
|
|
73
|
+
|
|
74
|
+
An application with sign-in either validates tokens in the host itself or sits behind an authenticating ingress such as Cratis AuthProxy. Both are in [authentication and identity](csharp-identity.md).
|
|
75
|
+
|
|
76
|
+
When using Cratis AuthProxy, make it the only public entry: it signs people in and forwards the identity to the host. Configure it with `cratis-authproxy-configure`.
|
|
77
|
+
|
|
78
|
+
A host that trusts forwarded identity headers must be reachable only through that ingress. Anyone who reaches it directly chooses who they are.
|
|
79
|
+
|
|
80
|
+
## Verify
|
|
81
|
+
|
|
82
|
+
After each deployment follow `cratis-platform-verify-service-handoff`.
|
|
83
|
+
|
|
84
|
+
## Alternative: a separately hosted frontend
|
|
85
|
+
|
|
86
|
+
Host the frontend apart from the backend only when it needs a CDN or its own release cadence. Keep one origin for the browser by routing both through the ingress: the frontend at the root, and the host's own paths to the host. Those are the API prefix and Arc's endpoints under `/.cratis/`, such as `/.cratis/commands` and `/.cratis/queries`. The observable-query connections live there too (`/.cratis/queries/ws`, `/.cratis/queries/sse` and the paths below it), so the ingress must pass WebSocket and server-sent-event traffic on those paths to the host. Remove the static-file and fallback middleware from the host then.
|
|
87
|
+
|
|
88
|
+
When Cratis AuthProxy is the ingress, keep the one-deployable shape and declare the service with a backend only. A proxy service that declares both a frontend and a backend sends `/api/...` to the backend and every other path to the frontend. Arc's endpoints under `/.cratis/` then reach the frontend, which cannot answer them: observable queries never connect.
|
|
89
|
+
|
|
90
|
+
- Do not work around this by sending the whole `/.cratis/` prefix to the host. The proxy serves sign-in, sign-out, token and other paths under that prefix itself, and it answers `/.cratis/me` by asking the host.
|
|
91
|
+
- Do not let the frontend's server relay Arc's paths to the host either. That is a second way into a host that trusts forwarded identity headers.
|
|
92
|
+
- When the frontend still has to be hosted apart behind AuthProxy, treat it as a design decision to raise, not a configuration step: every request for Arc's own paths must reach the host through the proxy, with the proxy's own paths untouched. Service declarations are in `cratis-authproxy-configure`.
|
|
93
|
+
|
|
94
|
+
## Anti-patterns
|
|
95
|
+
|
|
96
|
+
- Do not run the frontend development server in a deployed environment.
|
|
97
|
+
- Do not expose the host directly next to the ingress "for debugging" while it trusts forwarded identity.
|
|
98
|
+
- Do not bake secrets or environment-specific settings into the image.
|