@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
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
# Upgrade Cratis Components from the previous major
|
|
2
|
+
|
|
3
|
+
## Contents
|
|
4
|
+
|
|
5
|
+
- When this applies
|
|
6
|
+
- Order
|
|
7
|
+
- Run a codemod
|
|
8
|
+
- What each codemod does and refuses
|
|
9
|
+
- Dependencies
|
|
10
|
+
- Removed root namespaces
|
|
11
|
+
- Removed subpaths and symbols
|
|
12
|
+
- Provider and pass-through changes
|
|
13
|
+
- Verify
|
|
14
|
+
- Avoid
|
|
15
|
+
|
|
16
|
+
A one-time task. General package upgrades are in `cratis-platform-upgrade-application`; this reference holds the Components-specific steps. Paths and names in examples are illustrative.
|
|
17
|
+
|
|
18
|
+
## When this applies
|
|
19
|
+
|
|
20
|
+
The application is on the major of `@cratis/components` that rendered through PrimeReact, and moves to the major that owns its own markup. You recognise the old major by any of these in the application:
|
|
21
|
+
|
|
22
|
+
- Component namespaces imported from the package root: `import { Canvas } from '@cratis/components'` used as `<Canvas.Canvas>`.
|
|
23
|
+
- `styledMode()`, `CratisPreset` or `primeReactStyles` in the provider setup.
|
|
24
|
+
- Imports from `@cratis/components/styled` or `@cratis/components/compatibility`.
|
|
25
|
+
|
|
26
|
+
This is not a version bump: imports, provider configuration, CSS selectors and some callbacks change. "Old major" and "new major" below mean these two.
|
|
27
|
+
|
|
28
|
+
## Order
|
|
29
|
+
|
|
30
|
+
Work on a branch. A checkpoint is source, package manifest and lockfile together. Save one only when the application's lint, type check, specs and production build pass. Steps 3 to 6 share one checkpoint: the application does not compile between the package upgrade and the fixes that follow it, so errors left by steps 3 to 5 are expected and the checks must pass only at step 6.
|
|
31
|
+
|
|
32
|
+
1. **Baseline.** Make every check pass on the old major. Save the rollback checkpoint.
|
|
33
|
+
2. **Root imports, still on the old major.** Preview and apply `cratis-components-remove-root-namespace-imports`. The subpaths it writes exist in both majors. Review the diff and every diagnostic, rerun the checks on the old major and save the import-only checkpoint.
|
|
34
|
+
3. **Upgrade the package** to the new major. Then, by hand: the stylesheet imports (Default path in this skill), the provider (below), removed presets and symbols (below), and part names in `pt` and CSS. Type errors remain until step 6 is done; do not checkpoint here.
|
|
35
|
+
4. **Button props.** Preview and apply `cratis-components-button-variant-tone`, then resolve its diagnostics and `TODO(cratis-codemod)` comments.
|
|
36
|
+
5. **Change handlers.** Preview and apply `cratis-components-change-handler`, then resolve its diagnostics and `TODO(cratis-codemod)` comments. A command form field's `onChange` stays a type error until you move it by hand (below).
|
|
37
|
+
6. **Run the checks.** When they pass with no diagnostic and no `TODO(cratis-codemod)` left, save the upgrade checkpoint.
|
|
38
|
+
7. **Replace remaining direct PrimeReact usage** in separate batches (see `cratis-components-choose-control`, `references/from-primereact.md`). Remove PrimeReact packages only when no import, provider, theme or tool still uses them.
|
|
39
|
+
|
|
40
|
+
Steps 4 and 5 produce source for the new major, so they come after step 3. Step 2 comes first because the two later codemods find components through their subpath imports.
|
|
41
|
+
|
|
42
|
+
To abandon a step, return source, manifest and lockfile to the previous checkpoint together, reinstall from that lockfile and rerun its checks.
|
|
43
|
+
|
|
44
|
+
## Run a codemod
|
|
45
|
+
|
|
46
|
+
All three commands ship in `@cratis/components.migrator`. Run them from the application directory whose installed Components package is being upgraded, with the migrator in the same major as the new Components major. Never use `latest`.
|
|
47
|
+
|
|
48
|
+
```sh
|
|
49
|
+
# The caret range of the Components major you are upgrading to.
|
|
50
|
+
TOOLING_RANGE='^<new major>.0.0'
|
|
51
|
+
|
|
52
|
+
npx --package "@cratis/components.migrator@$TOOLING_RANGE" \
|
|
53
|
+
cratis-components-remove-root-namespace-imports --check src
|
|
54
|
+
npx --package "@cratis/components.migrator@$TOOLING_RANGE" \
|
|
55
|
+
cratis-components-remove-root-namespace-imports src
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
- The path argument (`src` here) only selects the files to scan. The installed `@cratis/components` is resolved from the working directory, so run from the application directory rather than passing a path into the app from elsewhere.
|
|
59
|
+
- Replace `<new major>` with the number; the other two commands take the same form. With pnpm use `pnpm dlx --package …`, with Yarn 2 or later `yarn dlx --package …`.
|
|
60
|
+
- `--check` writes nothing. It exits non-zero when a rewrite is pending or a case needs manual review; that exit does not mean the tool failed.
|
|
61
|
+
- An apply run rewrites the safe cases, reports the rest and exits non-zero while any refused case remains.
|
|
62
|
+
- Before scanning, the migrator checks the installed `@cratis/components`. It accepts only the old major or the new major, and otherwise scans and writes nothing.
|
|
63
|
+
- Requires Node.js 20 or later. The codemods bring their own TypeScript, scan `.js`, `.jsx`, `.mjs`, `.cjs`, `.ts`, `.tsx`, `.mts` and `.cts` recursively, skip `node_modules` and `dist`, and are safe to rerun.
|
|
64
|
+
- A codemod does not remove imports it leaves unused. Run the formatter and lint afterwards.
|
|
65
|
+
|
|
66
|
+
**Coming from a major older than the old major (edge case):** the migrator refuses the installed package. Change the imports by hand, install the new major, then run the codemods.
|
|
67
|
+
|
|
68
|
+
## What each codemod does and refuses
|
|
69
|
+
|
|
70
|
+
| Codemod | Rewrites | Leaves for you (reported) |
|
|
71
|
+
| --- | --- | --- |
|
|
72
|
+
| `cratis-components-remove-root-namespace-imports` | `import { X } from '@cratis/components'` to `import * as X from '@cratis/components/<subpath>'`, and `export { X } from '@cratis/components'` to `export * as X from '@cratis/components/<subpath>'`, for every root namespace. Aliases and type-only imports are kept; mixed setup and namespace imports are split. | Whole-package imports (`import * as`, default, `import = require`), dynamic `import()`, `require()`, `export *` re-exports, side-effect imports, unknown symbols, and the `Compatibility` namespace. |
|
|
73
|
+
| `cratis-components-button-variant-tone` | Literal `Button` props: `text` → `variant='ghost'`, `link` → `variant='link'`, `outlined` → `variant='outline'`, `rounded` → `shape='pill'`, and `severity` → `tone` (`secondary`, `contrast` → `neutral`; `info`, `help` → `accent`; `success` → `positive`; `warn` → `caution`; `danger` → `critical`). | Dynamic values, JSX spreads, duplicate props, and a new prop with a non-literal value beside the old prop it replaces. |
|
|
74
|
+
| `cratis-components-change-handler` | A callback that only forwards one event field, on a standalone `Dropdown` `onChange` and on a command form field's `onValueChange`: it now receives the value itself. The field is `event.value` for `Dropdown`, `DropdownField` and `MultiSelectField`, `target.value` for the text, password, text area and color fields, `target.checked` for the checkbox and toggle fields, and `target.valueAsNumber` for the number and slider fields (`currentTarget` likewise). | Callbacks with several statements, several uses of the event, or use of the native event. An `event.value` callback whose parameter is not typed as the old change event, because `.value` may belong to the selected value. `onChange` on a command form field (see below). |
|
|
75
|
+
|
|
76
|
+
- The first codemod keeps namespace access (`Canvas.Canvas` still resolves). Converting to named imports is optional cleanup by hand.
|
|
77
|
+
- When several of `link`, `text` and `outlined` are set, the Button codemod keeps one variant in that order of precedence. A literal new prop (`variant`, `tone`, `shape`) wins over the old prop it replaces.
|
|
78
|
+
- The Button codemod removes an old prop only when discarding its value cannot change what runs: a bare prop or a literal value. When the value is an expression that would no longer be evaluated, as `text` in `<Button link text={record()} />`, the whole prop group stays unchanged and is reported for manual review.
|
|
79
|
+
- A refused case stays unchanged and is reported. The Button and change-handler codemods also mark it with one `TODO(cratis-codemod)` comment, with three exceptions that are reported only: a Button prop that is not safe to remove (above), an untyped `event.value` callback and `onChange` on a command form field.
|
|
80
|
+
- **`onChange` on a command form field** is no longer a prop and fails type checking. Move the side effect to the enclosing `CommandForm`'s `onFieldChange(command, fieldName, oldValue, newValue)`.
|
|
81
|
+
- After the change-handler codemod, remove a `DropdownChangeEvent` type import that is no longer used.
|
|
82
|
+
|
|
83
|
+
## Dependencies
|
|
84
|
+
|
|
85
|
+
- The new major has no PrimeReact, PrimeIcons or Prime theme dependency. Uninstall those packages only when the application no longer imports them directly; otherwise keep them, with their provider, CSS and license, for the surfaces that still use them.
|
|
86
|
+
- `pixi.js` is now an optional peer. Install it when the application imports from the `Canvas` or `PivotViewer` subpath; keep one resolution of it in the application.
|
|
87
|
+
- `AutoCommandForm` needs an Arc release that honours an explicit field name. Update `@cratis/arc` and `@cratis/arc.react` together, to the same version, inside the range the Components package declares.
|
|
88
|
+
- Add the recommended config of `@cratis/eslint-plugin-components` (same major as Components) after `@cratis/eslint-config`; its `no-root-barrel-import` rule keeps root namespace imports from returning.
|
|
89
|
+
|
|
90
|
+
## Removed root namespaces
|
|
91
|
+
|
|
92
|
+
The package root is setup-only: provider, configuration and message types. Every component comes from its subpath.
|
|
93
|
+
|
|
94
|
+
| Old root namespace | Subpath |
|
|
95
|
+
| --- | --- |
|
|
96
|
+
| `Canvas`, `Chat`, `CommandDialog`, `CommandForm`, `Common`, `DataPage`, `DataTables`, `Dialogs`, `Display`, `Dropdown`, `Filter`, `Notifications`, `ObjectContentEditor`, `ObjectNavigationalBar`, `PivotViewer`, `SchemaEditor`, `TimeMachine`, `Toolbar` | `@cratis/components/<same name>` |
|
|
97
|
+
| `Types` | `@cratis/components/types` |
|
|
98
|
+
| `CommandStepper` | The codemod maps the namespace to `@cratis/components/CommandDialog`, because the old namespace was that whole module. In new code import the `CommandStepper` component from `@cratis/components/CommandStepper`. |
|
|
99
|
+
| `Compatibility` | None. Replace its contracts with the typed parts of each component, then delete the import. |
|
|
100
|
+
|
|
101
|
+
`@cratis/components/CommandForm/fields` and `@cratis/components/CommandForm` are the same module.
|
|
102
|
+
|
|
103
|
+
## Removed subpaths and symbols
|
|
104
|
+
|
|
105
|
+
| Removed | Do instead |
|
|
106
|
+
| --- | --- |
|
|
107
|
+
| `@cratis/components/styled`; `styledMode`, `StyledModeOptions`, `CratisPreset`, `primeReactStyles` | Remove the renderer configuration. Import `tokens`, `styles` and optionally `theme`; assign product values to `--cratis-*` tokens directly. |
|
|
108
|
+
| `@cratis/components/compatibility`; the `Compatibility` namespace and its pass-through contract, sentinel and assert helpers | Use each component's typed parts (`DialogParts`, `DataTableParts`, `TablePaginatorParts`, `StepperParts`, `ToolbarParts`) and `data-cratis-part` selectors. |
|
|
109
|
+
| `@cratis/components/primereact-v10-palette` | Map product tokens to `--cratis-*`, or use the baseline theme. |
|
|
110
|
+
| `primeReactCssLayer`, `primeReactCssLayerOrder` | Delete, unless the product still owns direct PrimeReact CSS. Layer order belongs in product CSS. |
|
|
111
|
+
| `cratisDarkModeSelector` | The product's own theme selector, with the matching `--cratis-*` values assigned under it. |
|
|
112
|
+
| `PivotViewerOptimized` | `PivotViewer`. |
|
|
113
|
+
| `CommandStepperContent` | No replacement. Use `CommandStepper` or `StepperCommandDialog`. |
|
|
114
|
+
| Internal helpers that were exported by accident from `Canvas` (`getInitials`, `reactionsExcludingUser`, mention and emoji helpers) and `Filter` (`buildFilterValues`, `buildRangeValues`, `RenderedHistogramBucket`) | No replacement. Inline the logic the application needs. |
|
|
115
|
+
|
|
116
|
+
## Provider and pass-through changes
|
|
117
|
+
|
|
118
|
+
- `CratisComponentsProvider` takes locale, labels, icons, routing, dialog header actions and the toast region (Provider configuration in this skill). Renderer keys are type errors: `license`, `theme`, `defaults`, `pt`, `ripple`, `unstyled` and z-index settings. Remove them; configure a PrimeReact provider that is still needed on its own.
|
|
119
|
+
- `value.locales` is still accepted for the old paginator and date labels. Move them to `value.messages`.
|
|
120
|
+
- `pt` stays, with new keys and plain HTML attributes as values. `ptOptions` and `unstyled` are accepted and do nothing.
|
|
121
|
+
- Rename pass-through keys to Cratis parts. Dialog: `mask` → `backdrop`, `headerTitle` → `title`, `closeButton` → `close`. DataTable: `thead` → `head`, `tbody` → `body`, `bodyRow` → `row`. Every part is in [parts](parts.md).
|
|
122
|
+
- Replace `.p-*` selectors with `[data-cratis-part='…']` selectors and the state attributes in this skill.
|
|
123
|
+
|
|
124
|
+
## Verify
|
|
125
|
+
|
|
126
|
+
- No component is imported from the package root, and no `TODO(cratis-codemod)` remains.
|
|
127
|
+
- `tokens` and `styles` load in every host entry.
|
|
128
|
+
- `pt` keys and CSS selectors name Cratis parts.
|
|
129
|
+
- With the keyboard only: open and dismiss a dialog, move through a stepper, filter and page a table, enter a date, pick a dropdown value, act on a toast.
|
|
130
|
+
- Check each scheme the application supports, then run the checks in Verify in this skill.
|
|
131
|
+
- If a changed control loses behaviour the application needs, stay on the last passing checkpoint until it is resolved.
|
|
132
|
+
|
|
133
|
+
## Avoid
|
|
134
|
+
|
|
135
|
+
- Upgrading the package before the root-import codemod has run and passed on the old major.
|
|
136
|
+
- Running the Button or change-handler codemod before the upgrade.
|
|
137
|
+
- Fetching the migrator with `latest`.
|
|
138
|
+
- Treating a non-zero `--check` exit as a tool failure.
|
|
139
|
+
- Deleting a `TODO(cratis-codemod)` without resolving the case it marks.
|
|
140
|
+
- Uninstalling PrimeReact while a direct import of it remains.
|
|
141
|
+
- Recreating a product → PrimeReact → Cratis token chain. Map product values to `--cratis-*` directly.
|
|
@@ -25,6 +25,8 @@ Example names are illustrative.
|
|
|
25
25
|
4. Put expected outcomes in the signature; throw a named domain exception for an invariant breach or unrecoverable fault. Log through generated structured messages on the consuming type's logger. If both logging-container and static-class naming diagnostics apply, use the escalation in Logging; no compliant name satisfies both.
|
|
26
26
|
5. Document the public contract and verify a warning-free Release build for every declared target and passing affected specifications. Stop and report if applying a convention would break a published contract, such as renaming a public type or changing an event or concept shape.
|
|
27
27
|
|
|
28
|
+
In C#, read `references/csharp-fundamentals-helpers.md` when about to write a small utility (exception messages, casing, correlation, async gates, reflection, JSON nodes) or when unsure whether a `Cratis.Fundamentals` helper belongs in application code.
|
|
29
|
+
|
|
28
30
|
Use `cratis-platform-deliver-slice` for end-to-end slice placement, `cratis-fundamentals-concept` for typed domain values, `cratis-fundamentals-type-discovery` for discovered sets, `cratis-fundamentals-telemetry` for generated metrics and spans, or `cratis-observability` for service-wide observability.
|
|
29
31
|
|
|
30
32
|
## Capability catalog
|
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Domain philosophy
|
|
2
2
|
|
|
3
|
+
## Contents
|
|
4
|
+
|
|
5
|
+
- CUPID characteristics
|
|
6
|
+
- Cohesion over layers
|
|
7
|
+
- Ubiquitous language
|
|
8
|
+
- Pluralization
|
|
9
|
+
- Twelve-factor operability
|
|
10
|
+
- Frictionless dependencies
|
|
11
|
+
- Immutability and side effects
|
|
12
|
+
|
|
3
13
|
## CUPID characteristics
|
|
4
14
|
|
|
5
15
|
Cratis favors the CUPID characteristics over a strict SOLID reading:
|
|
@@ -36,13 +46,31 @@ wrapper.
|
|
|
36
46
|
# Preferred — cohesive by feature
|
|
37
47
|
<Feature>/
|
|
38
48
|
<Behavior>/
|
|
39
|
-
<Behavior>.cs
|
|
40
|
-
<Behavior>.
|
|
49
|
+
<Behavior>.cs ← the backend artifacts for this behavior
|
|
50
|
+
<Behavior>.ts ← generated from <Behavior>.cs; never edit
|
|
51
|
+
<Behavior>Dialog.tsx ← its screen, named for its role
|
|
41
52
|
<OtherBehavior>/
|
|
42
53
|
<OtherBehavior>.cs
|
|
43
|
-
<OtherBehavior>.
|
|
54
|
+
<OtherBehavior>.ts
|
|
55
|
+
<OtherBehavior>Page.tsx
|
|
44
56
|
```
|
|
45
57
|
|
|
58
|
+
Name the screen for what it renders: `<Behavior>Dialog.tsx` for a dialog that
|
|
59
|
+
submits a command, `<Behavior>Page.tsx` for a page that shows a query. Never
|
|
60
|
+
name it `<Behavior>.tsx`. In the application template's setup, proxy generation
|
|
61
|
+
names each generated `.ts` file after the `.cs` file that holds the owning
|
|
62
|
+
type, when the build's portable debug information resolves that file; an
|
|
63
|
+
artifact it cannot resolve gets a file named after the artifact instead. The
|
|
64
|
+
namespace, not the location of the `.cs` file, decides the folder. Artifacts
|
|
65
|
+
therefore share one `.ts` file only when both the resolved file name and the
|
|
66
|
+
namespace-derived folder match: a `.cs` file that declares types in two
|
|
67
|
+
namespaces produces two modules, and the `.ts` sits beside its `.cs` only while
|
|
68
|
+
the namespace matches the folder path. Keep a type in one `.cs` file; for a
|
|
69
|
+
type split across files the name comes from whichever file resolves first. With
|
|
70
|
+
both in place `<Behavior>.ts` already belongs to the generated client, and a
|
|
71
|
+
`.ts` and a `.tsx` file must not share a base name in one folder. `cratis-platform-deliver-slice`
|
|
72
|
+
(`references/csharp.md`, Layout) owns the full slice layout.
|
|
73
|
+
|
|
46
74
|
Frontend and backend concerns naturally separate into different projects, but
|
|
47
75
|
each project keeps the cohesive feature structure inside it.
|
|
48
76
|
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
# Fundamentals helpers
|
|
2
|
+
|
|
3
|
+
## Contents
|
|
4
|
+
|
|
5
|
+
- Default
|
|
6
|
+
- Use in application code
|
|
7
|
+
- Use only when the need applies
|
|
8
|
+
- Infrastructure only
|
|
9
|
+
- Never in application code
|
|
10
|
+
|
|
11
|
+
## Default
|
|
12
|
+
|
|
13
|
+
An application slice needs none of these helpers. Reach for one only when its
|
|
14
|
+
stated need applies, and never re-implement one that fits. All of them ship in
|
|
15
|
+
the `Cratis.Fundamentals` package; the namespace to import is given per group.
|
|
16
|
+
|
|
17
|
+
## Use in application code
|
|
18
|
+
|
|
19
|
+
| Need | Helper | Notes |
|
|
20
|
+
| --- | --- | --- |
|
|
21
|
+
| Report a failure with its chain of causes | `exception.GetAllMessages()` | Returns the messages along the `InnerException` chain, outermost first. Sibling causes of an `AggregateException` are omitted; only its first inner exception is followed. Global namespace: no `using`. |
|
|
22
|
+
| Read the correlation id of the current call | Inject `ICorrelationIdAccessor` and read `Current` (`Cratis.Execution`) | Arc and the Chronicle client register the accessor. The id is ambient to the current async flow and equals `CorrelationId.NotSet` until something sets it. |
|
|
23
|
+
| Camel-case a name the way Cratis JSON does | `name.ToCamelCase()` (`Cratis.Strings`) | A name that starts with two capitals is returned unchanged (`URLPath` stays `URLPath`); otherwise the leading capital is lowered. |
|
|
24
|
+
| Upper-case the first letter | `name.ToPascalCase()` (`Cratis.Strings`) | Changes the first character only. |
|
|
25
|
+
|
|
26
|
+
## Use only when the need applies
|
|
27
|
+
|
|
28
|
+
- **Correlation in a host with neither Arc nor Chronicle (`Cratis.Execution`):**
|
|
29
|
+
call `services.AddCorrelationIdSupport()`. It registers `ICorrelationIdAccessor`
|
|
30
|
+
and `ICorrelationIdModifier` as singletons. Set the id for the current async
|
|
31
|
+
flow with `ICorrelationIdModifier.Modify(id)`; create one with
|
|
32
|
+
`CorrelationId.New()`.
|
|
33
|
+
- **Hold work until a signal (`Cratis.Tasks`):** `AsyncManualResetEvent` has
|
|
34
|
+
`WaitAsync()`, `Set()` and `Reset()`. `WaitAsync()` completes once `Set()` has
|
|
35
|
+
been called and keeps completing until `Reset()`. Create it with `new`. Mainly
|
|
36
|
+
for infrastructure and specifications.
|
|
37
|
+
- **Substitutable delays and timers:** `ITaskFactory` (`Cratis.Tasks`: `Run`,
|
|
38
|
+
`Delay`) and `ITimerFactory` (`Cratis.Timers`: `Create`, returning a
|
|
39
|
+
disposable `ITimer`) let a specification replace background work, delays and
|
|
40
|
+
timers. The shipped implementations, `TaskFactory` and `TimerFactory`, wrap
|
|
41
|
+
`Task.Run`, `Task.Delay` and `System.Threading.Timer`. `Cratis.Tasks.TaskFactory`
|
|
42
|
+
shares its name with the one in `System.Threading.Tasks`; qualify it where both
|
|
43
|
+
namespaces are imported.
|
|
44
|
+
- **Reshape a live query result (`Cratis.Reactive`):** return the store's subject
|
|
45
|
+
unchanged by default. Only when each emission must be mapped to another shape:
|
|
46
|
+
- `TransformingSubject<TSource, TResult>.CreateSubscriberScoped(sourceFactory, transform)`
|
|
47
|
+
connects on the first subscriber and disconnects when the last one leaves;
|
|
48
|
+
concurrent subscribers share that one connection. Disposing the last
|
|
49
|
+
subscription returned by `Subscribe` therefore disposes the wrapper's
|
|
50
|
+
upstream subscription to the source; it does not dispose or complete the
|
|
51
|
+
source object itself, and the next subscriber calls the factory again. Use
|
|
52
|
+
it only when the factory returns a cold, restartable source, never an
|
|
53
|
+
already-running subject.
|
|
54
|
+
- `new TransformingSubject<TSource, TResult>(source, transform)` subscribes to
|
|
55
|
+
an existing subject immediately and emits every value transformed. It holds
|
|
56
|
+
its own subscription to the source until the source completes or the
|
|
57
|
+
wrapper is disposed; disposing a subscription returned by `Subscribe` does
|
|
58
|
+
not release it. Arc disposes only that returned subscription when a client
|
|
59
|
+
disconnects, so never return this form from a query on its own: the code
|
|
60
|
+
that creates it must also dispose it or complete the source, or the store
|
|
61
|
+
watcher keeps running.
|
|
62
|
+
- `subject.CompletedBy(cancellationToken)` completes the subject when the token
|
|
63
|
+
is cancelled, for every subscriber. Call it only on a subject that the
|
|
64
|
+
cancelled operation itself created and owns; on a shared subject one
|
|
65
|
+
caller's cancellation ends the stream for everyone.
|
|
66
|
+
|
|
67
|
+
Keep the query's shape either way: declare the return type as
|
|
68
|
+
`ISubject<TReadModel>` or `ISubject<IEnumerable<TReadModel>>`, not as
|
|
69
|
+
`TransformingSubject<,>`, and keep the method on the read model it returns.
|
|
70
|
+
That declared type satisfies only the return-shape check of model-bound query
|
|
71
|
+
discovery. The method must still be a public, static, non-generic method
|
|
72
|
+
without a parameter of the read model's own type, and it must carry `[Query]`
|
|
73
|
+
when the read model sets `RequireQueryAttribute = true`.
|
|
74
|
+
- **Merge lookups (`Cratis.Collections`):** `lookups.Combine()` turns a sequence
|
|
75
|
+
of `ILookup<TKey, TElement>` into one lookup.
|
|
76
|
+
- **Match an existing XOR-derived identity (`Cratis.Guids`):** `a.Xor(b)`
|
|
77
|
+
combines two GUIDs bytewise. Use it only to stay compatible with identities
|
|
78
|
+
already derived that way. For a new derived identity whose input is stable
|
|
79
|
+
and not sensitive, use the name-based UUID in `cratis-fundamentals-name-value`.
|
|
80
|
+
Anyone who knows the namespace and the name can recompute that id, so when
|
|
81
|
+
the input must stay private use an opaque, randomly generated id instead.
|
|
82
|
+
|
|
83
|
+
## Infrastructure only
|
|
84
|
+
|
|
85
|
+
These exist for framework, tooling and schemaless plumbing. An application slice
|
|
86
|
+
that needs one is usually missing a typed model or a discovered set.
|
|
87
|
+
|
|
88
|
+
- **Reflection (`Cratis.Reflection`):** `HasAttribute<T>()`, `HasInterface<T>()`,
|
|
89
|
+
`ImplementsOpenGeneric(type)`, `IsDerivedFromOpenGeneric(type)`, `IsRecord()`,
|
|
90
|
+
`IsNullable()`, `IsEnumerable()`, `GetEnumerableElementType()`,
|
|
91
|
+
`GetSettableProperties()` and the constructor lookups
|
|
92
|
+
(`HasDefaultConstructor()`, `GetNonDefaultConstructor()`). To find
|
|
93
|
+
implementations or marked types in a slice, use
|
|
94
|
+
`cratis-fundamentals-type-discovery` instead.
|
|
95
|
+
- **JSON nodes (`Cratis.Json`):** `JsonObject.AsExpandoObject()`,
|
|
96
|
+
`JsonValue.ToTargetTypeValue(type)`, `object.ToJsonValue()` and
|
|
97
|
+
`JsonElement.TryGetValue(out value)` map selected JSON nodes and plain
|
|
98
|
+
values onto each other for content without a schema. Each supports its own
|
|
99
|
+
set of types and they are not round-trip converters: `ToJsonValue()` writes a
|
|
100
|
+
boolean, for example, while `TryGetValue` returns `false` for one. A typed
|
|
101
|
+
model never needs them. To copy
|
|
102
|
+
a node, call the `DeepClone()` instance method that `System.Text.Json`
|
|
103
|
+
already provides.
|
|
104
|
+
- **Non-generic sequences (`Cratis.Collections`):** `CountElements()` and
|
|
105
|
+
`ToObjectArray()` work on an untyped `IEnumerable`.
|
|
106
|
+
- **A value that may be a task (`Cratis.Tasks`):**
|
|
107
|
+
`AwaitableHelpers.AwaitIfNeeded(value)` awaits a `Task`, `ValueTask` or their
|
|
108
|
+
generic forms held as `object` and returns `(IsAwaitable, Result)`. `Result` is
|
|
109
|
+
the awaited value, `null` when the task carries none, or the input itself when
|
|
110
|
+
it was not awaitable. For code that invokes methods by reflection.
|
|
111
|
+
|
|
112
|
+
## Never in application code
|
|
113
|
+
|
|
114
|
+
- **`ForEach` on a sequence (`Cratis.Collections`):** write a `foreach` loop for
|
|
115
|
+
effects.
|
|
116
|
+
- **`TimedLogging`:** writes timing to the console. Log through generated
|
|
117
|
+
messages (see Logging in `csharp-exceptions-logging-and-di.md`).
|
|
118
|
+
- **`AssemblyHelpers` (`Cratis.Types`):** resolves assemblies by name. Use
|
|
119
|
+
`cratis-fundamentals-type-discovery`.
|
|
@@ -49,6 +49,10 @@ See [Dependency injection](csharp-exceptions-logging-and-di.md#dependency-inject
|
|
|
49
49
|
|
|
50
50
|
Prefer abstractions in constructors. `CRARCH0018` exempts abstract classes, `*Options` and `*Settings`, Arc read models, special types (such as strings) and sealed System types; it does not require wrapping these legitimate inputs in interfaces.
|
|
51
51
|
|
|
52
|
+
## Fundamentals helpers
|
|
53
|
+
|
|
54
|
+
See [Fundamentals helpers](csharp-fundamentals-helpers.md) before writing a small utility (exception messages, casing, correlation, async gates, live-result reshaping, reflection, JSON nodes): it says which shipped helper to use and which ones are for infrastructure only.
|
|
55
|
+
|
|
52
56
|
## Alternate implementations
|
|
53
57
|
|
|
54
58
|
See [Alternate implementations and stubs](csharp-alternate-implementations.md) to preserve the real filter contract across storage engines and prove parity with a shared spec.
|
package/package/corpus/skills/cratis-fundamentals-concept/references/csharp-serialization.md
CHANGED
|
@@ -9,6 +9,8 @@
|
|
|
9
9
|
- Dictionaries keyed by an object
|
|
10
10
|
- Geospatial values
|
|
11
11
|
- Concepts by reflection
|
|
12
|
+
- Custom converters
|
|
13
|
+
- Custom naming policy
|
|
12
14
|
- Failures
|
|
13
15
|
|
|
14
16
|
How Cratis Fundamentals writes concepts and the other typed values to JSON, and what to do when a model is polymorphic, keyed by an object or geospatial.
|
|
@@ -63,7 +65,8 @@ public record CustomerName(string Value) : ConceptAs<string>(Value);
|
|
|
63
65
|
| `null` properties | Omitted | `JsonIgnoreCondition.WhenWritingNull` |
|
|
64
66
|
| Concept | Its wrapped value | `ConceptAsJsonConverterFactory` |
|
|
65
67
|
| Collection of concepts | Array of wrapped values | `EnumerableConceptAsJsonConverterFactory` |
|
|
66
|
-
| Enum | Number when written
|
|
68
|
+
| Enum | Number when written. When read, a number must be an integer that fits the enum's backing type and must be a defined value; for a `[Flags]` enum, any combination of declared bits passes, so `1` passes when the only member is `Both = 3`. A string may be a case-insensitive name, comma-separated names or a number, and is not checked against the defined values, so `"99"` binds; check membership in a validator when it matters | `EnumConverterFactory` |
|
|
69
|
+
| Concept wrapping an enum | Number when written. When read, a number must be an integer that fits the enum's backing type but need not be a defined value. A string may be a member name (case-sensitive), comma-separated names, or a number (`"99"`), none checked against the defined values. A string that does not parse throws `ArgumentException` (`OverflowException` for a number out of range), not `JsonException`. Reject undefined values in the concept's validator | `ConceptAsJsonConverterFactory` |
|
|
67
70
|
| `DateOnly`, `TimeOnly` | ISO text (`2025-03-01`, `13:45:00.0000000`) | `DateOnlyJsonConverter`, `TimeOnlyJsonConverter` |
|
|
68
71
|
| `Uri` | Text | `UriJsonConverter` |
|
|
69
72
|
| `Type` | `Full.Type.Name, AssemblyName` | `TypeJsonConverter` |
|
|
@@ -71,6 +74,8 @@ public record CustomerName(string Value) : ConceptAs<string>(Value);
|
|
|
71
74
|
| Dictionary with an object key | JSON object whose property names are the key as JSON text | `ComplexKeyDictionaryJsonConverterFactory` |
|
|
72
75
|
| Member declared as an interface or base class | Concrete object plus `_derivedTypeId` | `DerivedTypeJsonConverterFactory` (`Cratis.Serialization`) |
|
|
73
76
|
|
|
77
|
+
`DateOnly` also reads date-time text that the JSON reader itself accepts as ISO 8601, and keeps only the date as written, silently dropping the time and any offset: `2025-03-01T23:30:00+02:00` reads as `2025-03-01`. Any other text, including ISO-looking text the JSON reader rejects (for example one with more fractional-second digits than it allows), is parsed with the current culture, and when it carries an offset it is shifted to the machine's local time first, so the date can move by a day. Send ISO date-only text, and check upstream when a payload that carries a time must be rejected.
|
|
78
|
+
|
|
74
79
|
## Polymorphic members
|
|
75
80
|
|
|
76
81
|
When a member is declared as an interface or base class, mark each concrete class with `[DerivedType]` and a stable identifier. Nothing else is needed: the classes are discovered, the writer adds `_derivedTypeId`, and the reader uses it to pick the class.
|
|
@@ -164,9 +169,75 @@ For generic infrastructure that meets a concept only as `object` or `Type` (`Cra
|
|
|
164
169
|
| `ConceptFactory.CreateConceptInstance(type, value)` | Build a concept from a raw value, converting it to `T` first |
|
|
165
170
|
| `types.RegisterTypeConvertersForConcepts()`, `assembly.RegisterTypeConvertersForConcepts()` | Register a `TypeConverter` per concept so it binds from text. Arc and Chronicle already do this; call it only in a host that uses neither |
|
|
166
171
|
| `Cratis.Conversion.TypeConverters.Register()` | Register text `TypeConverter`s for `DateOnly` and `TimeOnly` |
|
|
172
|
+
| `"text".ParseTo(type)` | Turn text into a primitive or a concept |
|
|
173
|
+
| `Cratis.Types.TypeConversion.Convert(type, value)` | The loose converter that `CreateConceptInstance` applies to the raw value: turn it into the primitive type `type`, unwrapping a concept first |
|
|
167
174
|
|
|
168
175
|
Application code should use the concept's own constructor and `Value` instead.
|
|
169
176
|
|
|
177
|
+
The loose conversions hide bad input, so keep them in infrastructure and never use them to read an identity or a date from untrusted input:
|
|
178
|
+
|
|
179
|
+
- `ParseTo` turns text that is not a GUID into `Guid.Empty` (or a concept wrapping it) without an error. Every other target goes through `Convert.ChangeType` with the current culture, so it converts only to the targets that method supports for text; a target such as `DateOnly`, `TimeOnly`, `DateTimeOffset` or `TimeSpan` throws `InvalidCastException`.
|
|
180
|
+
- `TypeConversion.Convert`, and therefore `CreateConceptInstance`, first unwraps a concept and turns a `JsonElement` it cannot read as the target type into its text. When the target is `Guid`, a remaining value that is neither a GUID, text nor a byte array becomes `Guid.Empty`, while text that is not a GUID throws `FormatException`. Text that does not parse as `DateTimeOffset`, `DateOnly`, `TimeOnly` or `TimeSpan` becomes that type's default value.
|
|
181
|
+
- `Convert` returns `null` for a `null` value; `CreateConceptInstance` throws `ArgumentNullException` instead.
|
|
182
|
+
|
|
183
|
+
When the input is untrusted, parse it yourself (`Guid.TryParse`, `DateOnly.TryParseExact`) and construct the concept from the result.
|
|
184
|
+
|
|
185
|
+
## Custom converters
|
|
186
|
+
|
|
187
|
+
Edge cases; the defaults above cover concepts, enums, polymorphic members and object-keyed dictionaries without any of these.
|
|
188
|
+
|
|
189
|
+
- **Text binding for a value type of your own that is not a concept:** derive from `StringTypeConverterBase<T>` (`Cratis.Conversion`), implement `Parse(string)` and `ToString(T)`, and attach it with `[TypeConverter(typeof(PeriodTypeConverter))]` on the type, or with `TypeDescriptor.AddAttributes(typeof(Period), new TypeConverterAttribute(typeof(PeriodTypeConverter)))` at startup for a type you do not own. A concept never needs this.
|
|
190
|
+
- **A dictionary key with its own text form, in JSON you write and read yourself:** derive from `DictionaryJsonConverter<TKey, TValue>` (`Cratis.Json`), override `GetKeyFromString`, and override `GetKeyString` unless the key's `ToString()` is that text. It converts a member declared exactly as `IDictionary<TKey, TValue>`; attach it to that member with `[JsonConverter(typeof(...))]`. Give the key a delimiter that cannot occur inside a component and split on it when reading; slicing at fixed positions misreads a value wider than expected. Do not use it on commands, queries, events or read models: a key text of your own is known only to your converter, and no client reads it back as the key type. There, rely on the default in Dictionaries keyed by an object only where the serializer uses the full Cratis defaults and every client reads keys written as JSON text; anywhere else, such as an ASP.NET minimal API endpoint, which gets the concept converters but not the object-key one, expose a list of key and value pairs instead.
|
|
191
|
+
|
|
192
|
+
```csharp
|
|
193
|
+
using System.Globalization;
|
|
194
|
+
using System.Text.Json.Serialization;
|
|
195
|
+
using Cratis.Json;
|
|
196
|
+
|
|
197
|
+
public readonly record struct Period(int Year, int Month)
|
|
198
|
+
{
|
|
199
|
+
public override string ToString() => string.Create(CultureInfo.InvariantCulture, $"{Year}/{Month:D2}");
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
public class RevenueByPeriodConverter : DictionaryJsonConverter<Period, decimal>
|
|
203
|
+
{
|
|
204
|
+
protected override Period GetKeyFromString(string key)
|
|
205
|
+
{
|
|
206
|
+
var parts = key.Split('/');
|
|
207
|
+
return new(int.Parse(parts[0], CultureInfo.InvariantCulture), int.Parse(parts[1], CultureInfo.InvariantCulture));
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
public record RevenueReport([property: JsonConverter(typeof(RevenueByPeriodConverter))] IDictionary<Period, decimal> Revenue);
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
- **`TypeWithObjectPropertiesJsonConverter<T>`** (with `TypeWithObjectPropertiesJsonConverterFactory<TConverter, T>`) is infrastructure for a type with `object`-typed properties, named by its `ObjectProperties` override. It writes .NET type names into the JSON: `_type` for the object, and `_<name>Type` for each listed property that is serialized and not `null`, where `<name>` is the camel-cased property name. Reading resolves types from those names: an object without `_type`, or whose `_type` no longer resolves, reads as `null`, and a listed property whose tag is missing or no longer resolves is not restored to its original type; it keeps whatever the serializer reads for an `object` member, typically a `JsonElement`. Never use it for JSON from an untrusted source or for a contract a client reads, and expect a renamed or moved type to break stored data. For application models, type the member as an interface and use `[DerivedType]`.
|
|
215
|
+
- **`ICanCreateEnumConverters`** is implemented by the generated type discovery provider when the compilation has enums to generate converters for. Where dynamic code is unavailable (Native AOT), the enum converter factory asks it for the converter first, and constructs one through reflection only when the provider has none for that enum. Application code never implements or calls it.
|
|
216
|
+
|
|
217
|
+
## Custom naming policy
|
|
218
|
+
|
|
219
|
+
The naming policy names read-model containers and their properties. Which policy to use and where to set it is in `cratis-application-growth`, `references/csharp.md`, "Naming policy": in an Arc or Chronicle host it is set on their builders. Only the shape of a policy of your own is described here.
|
|
220
|
+
|
|
221
|
+
```csharp
|
|
222
|
+
using System.Text.Json;
|
|
223
|
+
using Cratis.Serialization;
|
|
224
|
+
|
|
225
|
+
public class SnakeCaseNamingPolicy : NamingPolicy
|
|
226
|
+
{
|
|
227
|
+
public override JsonNamingPolicy? JsonPropertyNamingPolicy => JsonNamingPolicy.SnakeCaseLower;
|
|
228
|
+
|
|
229
|
+
protected override string GetReadModelNameImplementation(Type readModelType) =>
|
|
230
|
+
JsonNamingPolicy.SnakeCaseLower.ConvertName(readModelType.Name);
|
|
231
|
+
|
|
232
|
+
protected override string GetPropertyNameImplementation(string name) =>
|
|
233
|
+
JsonNamingPolicy.SnakeCaseLower.ConvertName(name);
|
|
234
|
+
}
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
- Derive from `NamingPolicy` (`Cratis.Serialization`) and override the three members above. The base returns the name from `[ReadModelName]` (`Cratis.ReadModels`) when the attribute is applied directly to the type, and calls `GetReadModelNameImplementation` when neither the type nor a base class has it. Put the attribute on each read model class itself: a class that only inherits it from a base class makes `GetReadModelName` throw `NullReferenceException`.
|
|
238
|
+
- Implement `INamingPolicy` directly only when `[ReadModelName]` must not take precedence; then `GetReadModelName` and `GetPropertyName` are yours to implement in full.
|
|
239
|
+
- `services.AddDefaultNamingPolicy()`, `AddCamelCaseNamingPolicy()`, `AddNamespaceNamingPolicy(...)` and `AddNamingPolicy<T>()` register a singleton `INamingPolicy` for services of your own to inject in a host that uses neither Arc nor Chronicle. They do not set the policy of the Chronicle or Arc MongoDB builders; in such a host set it on the builder.
|
|
240
|
+
|
|
170
241
|
## Failures
|
|
171
242
|
|
|
172
243
|
| Exception | Cause | Fix |
|
|
@@ -26,9 +26,18 @@ public record PageCount(int Value) : ConceptAs<int>(Value);
|
|
|
26
26
|
```
|
|
27
27
|
|
|
28
28
|
- Declare it as a `record` with exactly one wrapped value; a second property is lost on every surface because only `Value` is serialized.
|
|
29
|
+
- Keep the constructor a plain wrapper. JSON, route and query binding, MongoDB and the EF Core converters from `BaseDbContext`, `ApplyConceptAsConversion` or `.AsConcept()` convert the incoming value to the backing type, call the constructor with it, and then set `Value` back to that converted value if the constructor changed it. The EF Core converter that `AddConceptAsSupport()` installs keeps what the constructor produced instead. A trim or case change in the constructor or base argument therefore applies on some paths and not others; a constructor that throws still rejects the value. To handle non-canonical input, reject it in a `ConceptValidator<>`, which Arc applies when it validates commands, queries and MVC models (reading JSON or storage does not validate), or normalize it in a named factory method that your boundary code calls.
|
|
29
30
|
- Add the `T` to concept implicit operator only when callers benefit; it is not required by any Cratis surface.
|
|
30
31
|
- Model absence as a nullable reference (`CustomerName?`). `ConceptAs<Guid?>` violates the `IComparable` constraint.
|
|
31
32
|
- Add a `NotSet` or `Empty` value only when the domain reserves that backing value.
|
|
33
|
+
- `ToString()` is sealed on the base, so a concept cannot override it. Format for display in the caller.
|
|
34
|
+
- Concepts order by their wrapped value: `<`, `>`, `CompareTo` and `OrderBy` work directly, and a null concept sorts before every value. `<=` and `>=` throw `NullReferenceException` when the left operand is null, so guard or compare `.Value` when a concept may be null. The non-generic `CompareTo(object)` takes a concept with the same wrapped type; a raw value such as a `string` throws `InvalidCastException`.
|
|
35
|
+
- Edge case, a nullable primitive assigned to an optional concept: the operator above throws `ArgumentNullException` for a null input. Declare it nullable-returning instead (it replaces the plain operator; a type cannot declare both) so null yields a null concept. Keep `[return: NotNullIfNotNull]`; without it every assignment of a non-null primitive to a non-nullable concept gets a nullable warning:
|
|
36
|
+
|
|
37
|
+
```csharp
|
|
38
|
+
[return: NotNullIfNotNull(nameof(value))] // System.Diagnostics.CodeAnalysis
|
|
39
|
+
public static implicit operator CustomerName?(string? value) => value is null ? null : new(value);
|
|
40
|
+
```
|
|
32
41
|
|
|
33
42
|
## Event-source identity
|
|
34
43
|
|
|
@@ -196,7 +196,7 @@ func (id *CustomerID) UnmarshalText(data []byte) error {
|
|
|
196
196
|
|
|
197
197
|
- **SQL (UUID only):** forward `func (id CustomerID) Value() (driver.Value, error) { return concepts.UUID(id).Value() }` and `func (id *CustomerID) Scan(src any) error { return (*concepts.UUID)(id).Scan(src) }`. `Value` writes canonical text, zero included, never NULL. `Scan` accepts dashed text or exactly 16 RFC-order bytes and rejects NULL: use `sql.Null[CustomerID]` or a pointer for a nullable column, and read a SQL Server `uniqueidentifier` as text. The other shared scalars have no SQL codecs.
|
|
198
198
|
- **Other UUID libraries:** a 16-byte RFC-order UUID type converts with a plain type conversion in both directions; no bytes are reordered.
|
|
199
|
-
- **Legacy .NET text:** `concepts.ParseDotNetGUID(text)` accepts the other .NET GUID text forms and returns a `concepts.UUID`. Use it only to import an existing .NET text contract, never from the forwarding codecs, and bound the input length first: it has no length cap.
|
|
199
|
+
- **Legacy .NET text:** `concepts.ParseDotNetGUID(text)` accepts the other .NET GUID text forms and returns a `concepts.UUID`. Use it only to import an existing .NET text contract, never from the forwarding codecs, and bound the input length first: it has no length cap. Empty or rejected input returns `UUID{}` and an error, so check `err` first. A valid all-zero input succeeds with the all-zero UUID, and in the legacy forms some components that hold nothing but a `+` or `0x` prefix read as zero, so then check `IsZero()` as in Validating decoders before you use the result as an identity.
|
|
200
200
|
|
|
201
201
|
## Recognize and check
|
|
202
202
|
|
|
@@ -256,6 +256,7 @@ if err == nil {
|
|
|
256
256
|
- No implicit conversion. The generators are `concepts.NewUUID` and `chronicle.NewEventSourceID`; strategies are in `cratis-fundamentals-name-value`.
|
|
257
257
|
- A concept carries no personal-data or encryption marking of its own: classify the event field with a tag, or the type with `events.WithProtection` when registering the event type.
|
|
258
258
|
- Relational storage is automatic for nothing: only a UUID concept has SQL codecs, and only once forwarded.
|
|
259
|
+
- No codec for map keys written as embedded JSON. A struct that implements the text marshalling methods, such as `concepts.DateOnly`, works as an ordinary text map key, but a C# dictionary with an object key travels as a JSON object whose property names are the keys as JSON text, and Go Fundamentals has nothing that reads or writes that shape. In a contract a Go client reads or writes, expose a list of key and value pairs instead.
|
|
259
260
|
|
|
260
261
|
## Done when
|
|
261
262
|
|
|
@@ -52,7 +52,7 @@ A concept is written as its bare value and read back through the concept's own c
|
|
|
52
52
|
- JSON `null` reads as `null`; a list of concepts is a list of bare values, `null` elements kept.
|
|
53
53
|
- Construction order: the canonical constructor of a one-component Java record, then a public static `of(value)`, then a public single-argument constructor. A private constructor with a public static `of(value)` works. In a named Java module, open the concept's package to reflection.
|
|
54
54
|
- A concept used as a map key is written as the value's text. `new ConceptsModule(ConceptKeyFormat.EMBEDDED_JSON)` writes the key as compact JSON instead, as the .NET serializer does for dictionaries (a string key then carries its quotes), and still reads plain keys. Module discovery always uses the plain form.
|
|
55
|
-
- Payloads shared with .NET
|
|
55
|
+
- Payloads shared with .NET are not identical. A JVM `Byte` holds -128 to 127, a .NET `byte` 0 to 255. Whole floating-point numbers keep `.0`. An `OffsetDateTime` keeps up to nine fraction digits where .NET keeps seven, while `LocalTime` and `TimeSpanModule` `Duration` values are truncated to 100 ns on write. Quotes inside an embedded-JSON key are escaped as `\"` where .NET usually writes `\u0022`. Never compare shared payloads as raw text or as parsed JSON trees: decode both sides into values, embedded-JSON keys included, and compare those under the agreed contract.
|
|
56
56
|
|
|
57
57
|
## Module catalog
|
|
58
58
|
|
|
@@ -94,7 +94,8 @@ var shape = mapper.readValue(json, Shape.class);
|
|
|
94
94
|
- Every superclass of your own is a target too, so a member declared as the base class resolves the same way.
|
|
95
95
|
- Annotate only concrete classes: not an interface, an abstract class, an enum or a concept.
|
|
96
96
|
- One module per mapper: a second `DerivedTypesModule` replaces the first, so put every family in the same registry. `DerivedTypes.EMPTY` registers nothing.
|
|
97
|
-
-
|
|
97
|
+
- Reading checks the declared type. When it has a derived class in the registry and no Jackson type information (`@JsonTypeInfo` or default typing) applies, a missing `_derivedTypeId` reads as `null` and an unknown, `null` or non-text identifier fails. Any other declared type gets plain Jackson handling, so reading it as an interface or abstract class fails unless your own Jackson setup handles it.
|
|
98
|
+
- Writing checks the runtime class. A registered class written by runtime value adds `_derivedTypeId` to its object, whatever the declared type, `Object` included; one whose body is not a JSON object fails to write. A writer fixed to an interface type is not covered. An annotated class that is not in the registry fails to write when it is assignable to a type that has a derived class in the registry. Any other class is written by plain Jackson, without `_derivedTypeId`.
|
|
98
99
|
- Property naming, creators and custom serializers of the body stay Jackson's. Serialize by runtime value (`writeValueAsString(value)`).
|
|
99
100
|
- Query the registry with `derivedTypeFor(target, new DerivedTypeId(id))`, `targetTypeFor(type)`, `isDerivedType(type)`, `hasDerivatives(type)` and `getTypesWithDerivatives()`.
|
|
100
101
|
|
|
@@ -52,7 +52,7 @@ A concept is written as its bare value and read back through the concept's own c
|
|
|
52
52
|
- JSON `null` reads as `null`; a list of concepts is a list of bare values, `null` elements kept.
|
|
53
53
|
- Construction order: the canonical constructor of a one-component Java record, then a public static `of(value)`, then a public single-argument constructor. A private constructor with a public `@JvmStatic` companion `of(value)` works. The Jackson Kotlin module is not needed for concepts.
|
|
54
54
|
- A concept used as a map key is written as the value's text. `ConceptsModule(ConceptKeyFormat.EMBEDDED_JSON)` writes the key as compact JSON instead, as the .NET serializer does for dictionaries (a string key then carries its quotes), and still reads plain keys. Module discovery always uses the plain form.
|
|
55
|
-
- Payloads shared with .NET
|
|
55
|
+
- Payloads shared with .NET are not identical. A JVM `Byte` holds -128 to 127, a .NET `byte` 0 to 255. Whole floating-point numbers keep `.0`. An `OffsetDateTime` keeps up to nine fraction digits where .NET keeps seven, while `LocalTime` and `TimeSpanModule` `Duration` values are truncated to 100 ns on write. Quotes inside an embedded-JSON key are escaped as `\"` where .NET usually writes `\u0022`. Never compare shared payloads as raw text or as parsed JSON trees: decode both sides into values, embedded-JSON keys included, and compare those under the agreed contract.
|
|
56
56
|
|
|
57
57
|
## Module catalog
|
|
58
58
|
|
|
@@ -96,7 +96,8 @@ val shape = mapper.readValue(json, Shape::class.java)
|
|
|
96
96
|
- Every superclass of your own is a target too, so a member declared as the base class resolves the same way.
|
|
97
97
|
- Annotate only concrete classes: not an interface, an abstract class, an enum or a concept.
|
|
98
98
|
- One module per mapper: a second `DerivedTypesModule` replaces the first, so put every family in the same registry. `DerivedTypes.EMPTY` registers nothing.
|
|
99
|
-
-
|
|
99
|
+
- Reading checks the declared type. When it has a derived class in the registry and no Jackson type information (`@JsonTypeInfo` or default typing) applies, a missing `_derivedTypeId` reads as `null` and an unknown, `null` or non-text identifier fails. Any other declared type gets plain Jackson handling, so reading it as an interface or abstract class fails unless your own Jackson setup handles it.
|
|
100
|
+
- Writing checks the runtime class. A registered class written by runtime value adds `_derivedTypeId` to its object, whatever the declared type, `Object` included; one whose body is not a JSON object fails to write. A writer fixed to an interface type is not covered. An annotated class that is not in the registry fails to write when it is assignable to a type that has a derived class in the registry. Any other class is written by plain Jackson, without `_derivedTypeId`.
|
|
100
101
|
- Property naming, creators and custom serializers of the body stay Jackson's. Serialize by runtime value (`writeValueAsString(value)`).
|
|
101
102
|
- Query the registry with `derivedTypeFor(target, DerivedTypeId(id))`, `targetTypeFor(type)`, `isDerivedType(type)`, `hasDerivatives(type)` and `typesWithDerivatives`.
|
|
102
103
|
|
package/package/corpus/skills/cratis-fundamentals-concept/references/typescript-serialization.md
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
- Maps keyed by an object
|
|
11
11
|
- Geospatial values
|
|
12
12
|
- Custom converters
|
|
13
|
+
- Selecting a property with a callback
|
|
13
14
|
- Failures
|
|
14
15
|
|
|
15
16
|
How `@cratis/fundamentals` turns JSON into class instances and back: field metadata, the value types it ships, polymorphic members, maps keyed by an object and geospatial shapes.
|
|
@@ -94,6 +95,7 @@ Never compare these with `===`: two instances with the same value are different
|
|
|
94
95
|
- **`Guid.equals(other)`** compares canonical text: a `Guid` is used as-is, any other argument is converted with `toString()`, so GUID text matches and non-GUID text returns `false`. It throws on `null` or `undefined`, so guard nullable values first. The parameter is typed `object`, so turn text you hold into a `Guid` with `Guid.as(text)` (or declare a typed `@field(Guid)` member) before comparing. `Guid.as` and `Guid.parse` throw on non-GUID text, so check untrusted text with `Guid.isGuid` first.
|
|
95
96
|
- **`TimeSpan` components and totals:** `days`, `hours`, `minutes`, `seconds` (and `milliseconds`, `microseconds`, `nanoseconds`) are components: `hours` is 0 to 23 and whole days sit in `days`. Components other than `days` are unsigned, so read the sign from `ticks` or a total. `ticks`, `totalDays`, `totalHours`, `totalMinutes`, `totalSeconds` and the other totals are signed aggregates, so compare and threshold on them. `parse` rejects hours above 23 and minutes or seconds above 59, so a duration of a day or more is written with a day part (`1.02:30:00`).
|
|
96
97
|
- **`TimeSpan` fields are plain and writable:** assigning one recalculates nothing, and the text (`toString()`, `toJSON()`) is formatted from `ticks`. Build a changed duration by parsing new text, never by assigning a field.
|
|
98
|
+
- **A value type of your own:** `IEquatable` (exported from `@cratis/fundamentals`) declares `equals(other: object): boolean`; `Guid` implements it. Implement it on a value type of your own that needs value equality. Nothing calls `equals` for you: `===`, `Array.includes`, `Set`, `Map` and `ValueMap` do not use it, so call it explicitly.
|
|
97
99
|
|
|
98
100
|
## Polymorphic members
|
|
99
101
|
|
|
@@ -158,7 +160,13 @@ const price = priceList.prices.get(key);
|
|
|
158
160
|
| `get(key)` | The value, or `undefined` |
|
|
159
161
|
| `entries()` | Iterates `[key, value]` pairs in insertion order |
|
|
160
162
|
|
|
161
|
-
|
|
163
|
+
Every `get` and `set` checks the stored keys in insertion order and uses the first one that equals the given key: strictly equal (`===`), or else, for two objects, the same `JSON.stringify` text. When either of two `Date` keys was read from text with nonzero digits finer than a millisecond, they match only if both have the same instant and the same extra digits, so a `Date` you create never matches such a key; reuse the key from `entries()`. It is not a deep-equality map:
|
|
164
|
+
|
|
165
|
+
- Decorate every key member with `@field`. Reading fills only declared fields (and keeps any `_derivedTypeId`), so keys that differ only in undecorated members read back equal.
|
|
166
|
+
- Property order is part of the text. Build a lookup key the way reading does: create it with `new` so the class's initializers run, then assign its members in declared order. Or reuse a key from `entries()`.
|
|
167
|
+
- A member that is `undefined` or absent writes no text; a .NET key omits a `null` member only when its serializer options do, as the Cratis defaults do. Reading leaves an absent member at what the constructor or its initializer gives it, except that an absent array member becomes `[]`; a member that is `null` in the text stays `null`. Give each member of a lookup key the value the read key has: leave an absent member unassigned, set an absent array member to `[]`, and set `null` only where the stored key holds `null`. Or reuse a key from `entries()`.
|
|
168
|
+
- Keys are stored by reference, not copied. Changing a key taken from `entries()` changes which lookups find its entry. There is no delete: to re-key an entry, build a new map.
|
|
169
|
+
- Without `genericArguments` the map is read back empty.
|
|
162
170
|
|
|
163
171
|
## Geospatial values
|
|
164
172
|
|
|
@@ -191,6 +199,37 @@ JsonSerializer.registerConverter(new MoneyJsonConverter());
|
|
|
191
199
|
|
|
192
200
|
A converter is chosen by exact type, and registering one for a type that already has one replaces it. Converters for the value types and geospatial shapes above are registered already. A concept is never offered to a converter: it is unwrapped to its value first.
|
|
193
201
|
|
|
202
|
+
## Selecting a property with a callback
|
|
203
|
+
|
|
204
|
+
Edge case, for a component or helper of your own that lets the caller name a field. Default to a string when the path is fixed.
|
|
205
|
+
|
|
206
|
+
`PropertyAccessor<T>` is the type of a callback from an instance to one of its properties: `(instance: T) => any`. It checks the property names the caller writes, not the property's type. To learn which property the callback reads, call it with a proxy and read the path from the handler:
|
|
207
|
+
|
|
208
|
+
```typescript
|
|
209
|
+
import { PropertyPathResolverProxyHandler } from '@cratis/fundamentals';
|
|
210
|
+
import type { PropertyAccessor } from '@cratis/fundamentals';
|
|
211
|
+
|
|
212
|
+
interface Customer {
|
|
213
|
+
name: string;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
interface Invoice {
|
|
217
|
+
customer: Customer;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
export function pathOf<T>(accessor: PropertyAccessor<T>): string {
|
|
221
|
+
const handler = new PropertyPathResolverProxyHandler();
|
|
222
|
+
accessor(new Proxy({}, handler) as T);
|
|
223
|
+
return handler.path;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
pathOf<Invoice>(invoice => invoice.customer.name); // 'customer.name'
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
- `handler.path` is the dotted path, `handler.segments` the names in order and `handler.property` the first name (`customer` above); take the last entry of `segments` for the leaf name.
|
|
230
|
+
- Create a new handler for every callback: segments accumulate on the handler.
|
|
231
|
+
- The callback must be a plain chain of property reads. The proxy holds no values, so a callback that computes, calls a method or branches on a value does not give a usable path.
|
|
232
|
+
|
|
194
233
|
## Failures
|
|
195
234
|
|
|
196
235
|
| Symptom | Cause | Fix |
|
|
@@ -199,5 +238,5 @@ A converter is chosen by exact type, and registering one for a type that already
|
|
|
199
238
|
| A polymorphic member comes back as the base type | The subclass module was not imported, the identifier differs from the backend's, or `derivatives` omits it | Import it, align the identifier, or list it |
|
|
200
239
|
| `Derived type identifier '…' is already registered for '…'` | Two different classes use one identifier under the same base | Give each a unique identifier |
|
|
201
240
|
| `Not a Guid.`, `Invalid DateOnly format`, `Invalid TimeOnly format`, `Invalid TimeSpan format` | The text is not the wire format in the Value types table | Fix the payload or the declared type |
|
|
202
|
-
| A `ValueMap` lookup returns `undefined` for a key that exists | The lookup key's members are in a different order, or the key class has no `@field` members |
|
|
241
|
+
| A `ValueMap` lookup returns `undefined` for a key that exists, or another key's value | The lookup key's members are in a different order, a member differs from what reading gives it (`null` versus absent, or an array member unset instead of `[]`), a read `Date` key kept sub-millisecond digits, a stored key was changed after insertion, or the key class has no `@field` members | Decorate every key member with `@field`; create lookup keys with `new`, assign members in declared order, give each member the value the read key has (absent stays unassigned, an absent array is `[]`, `null` only where the stored key is `null`), or reuse a key from `entries()`; never change a stored key |
|
|
203
242
|
| A console warning at load about more than one copy of the package | The package was loaded twice: two installs (even of the same release), or one install reached as both ESM and CommonJS. Converters registered on one copy do not reach the other | Deduplicate the dependency and load it through one module format |
|