@cratis/pi 8.5.0 → 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/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/specs.csharp.instructions.md +6 -3
- package/package/corpus/harnesses/copilot/instructions/vertical-slices.instructions.md +5 -2
- 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/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 +0 -2
- 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 +2 -2
- package/package/corpus/skills/cratis-arc-authorize-request/references/authproxy.md +19 -0
- package/package/corpus/skills/cratis-arc-authorize-request/references/csharp-query-security.md +15 -0
- package/package/corpus/skills/cratis-arc-authorize-request/references/csharp.md +12 -3
- package/package/corpus/skills/cratis-arc-declare-command/SKILL.md +2 -0
- package/package/corpus/skills/cratis-arc-declare-command/references/csharp-chronicle.md +46 -7
- 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 +4 -1
- package/package/corpus/skills/cratis-arc-declare-command/references/csharp.md +31 -4
- package/package/corpus/skills/cratis-arc-declare-command/references/go.md +1 -1
- package/package/corpus/skills/cratis-arc-diagnose-live-query/references/csharp.md +24 -2
- package/package/corpus/skills/cratis-arc-expose-mcp-operation/references/csharp.md +49 -0
- package/package/corpus/skills/cratis-arc-expose-query/SKILL.md +3 -1
- package/package/corpus/skills/cratis-arc-expose-query/references/csharp.md +27 -4
- package/package/corpus/skills/cratis-arc-generate-proxies/SKILL.md +1 -0
- package/package/corpus/skills/cratis-arc-generate-proxies/references/csharp.md +49 -2
- 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 +84 -2
- package/package/corpus/skills/cratis-arc-host-application/references/csharp.md +2 -0
- package/package/corpus/skills/cratis-arc-invoke-command/references/csharp.md +2 -1
- package/package/corpus/skills/cratis-arc-isolate-tenant/SKILL.md +18 -1
- package/package/corpus/skills/cratis-arc-page-query/references/csharp.md +2 -0
- package/package/corpus/skills/cratis-arc-react-bind-slice/SKILL.md +18 -16
- package/package/corpus/skills/cratis-arc-react-bind-slice/references/typescript-commands.md +8 -3
- package/package/corpus/skills/cratis-arc-react-bind-slice/references/typescript-host.md +84 -16
- package/package/corpus/skills/cratis-arc-react-bind-slice/references/typescript-identity.md +22 -2
- 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 +40 -1
- 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 +7 -3
- 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-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-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 +2 -2
- package/package/corpus/skills/cratis-chronicle-cli-operations/references/project-tooling.md +28 -0
- 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/typescript.md +10 -1
- package/package/corpus/skills/cratis-chronicle-constrain-append/SKILL.md +8 -1
- 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 +2 -0
- package/package/corpus/skills/cratis-chronicle-deploy-kernel/references/configuration.md +27 -0
- 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 +13 -6
- package/package/corpus/skills/cratis-chronicle-deploy-kernel/references/network-and-tls.md +45 -0
- package/package/corpus/skills/cratis-chronicle-deploy-kernel/references/storage.md +91 -1
- package/package/corpus/skills/cratis-chronicle-deploy-kernel/references/upgrade-and-recovery.md +9 -0
- package/package/corpus/skills/cratis-chronicle-evolve-event/SKILL.md +12 -0
- package/package/corpus/skills/cratis-chronicle-inspect-observer/SKILL.md +11 -1
- package/package/corpus/skills/cratis-chronicle-inspect-observer/references/csharp.md +1 -1
- package/package/corpus/skills/cratis-chronicle-project-view/SKILL.md +1 -1
- package/package/corpus/skills/cratis-chronicle-project-view/references/csharp-fluent.md +14 -3
- package/package/corpus/skills/cratis-chronicle-project-view/references/csharp-model-bound.md +3 -0
- package/package/corpus/skills/cratis-chronicle-project-view/references/csharp-reading.md +3 -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 +2 -0
- package/package/corpus/skills/cratis-chronicle-project-view/references/kotlin.md +1 -0
- package/package/corpus/skills/cratis-chronicle-project-view/references/typescript.md +1 -1
- package/package/corpus/skills/cratis-chronicle-protect-decision/SKILL.md +2 -0
- package/package/corpus/skills/cratis-chronicle-protect-decision/references/csharp-scopes.md +40 -3
- package/package/corpus/skills/cratis-chronicle-protect-decision/references/csharp.md +20 -2
- 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/references/csharp.md +24 -1
- package/package/corpus/skills/cratis-chronicle-publish-contract/SKILL.md +1 -1
- package/package/corpus/skills/cratis-chronicle-publish-contract/references/csharp.md +41 -0
- 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 +17 -0
- 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.md +35 -2
- 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 +1 -0
- package/package/corpus/skills/cratis-chronicle-react-to-fact/references/kotlin.md +1 -0
- package/package/corpus/skills/cratis-chronicle-record-event/SKILL.md +1 -1
- 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-code-review/references/csharp-diagnostics.md +28 -2
- package/package/corpus/skills/cratis-code-review/references/csharp.md +1 -1
- 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/references/typescript-commandform.md +72 -2
- package/package/corpus/skills/cratis-components-submit-form/references/typescript.md +5 -3
- 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 +70 -0
- package/package/corpus/skills/cratis-fundamentals-concept/references/csharp.md +8 -0
- package/package/corpus/skills/cratis-fundamentals-concept/references/go.md +1 -0
- package/package/corpus/skills/cratis-fundamentals-concept/references/typescript-serialization.md +33 -0
- package/package/corpus/skills/cratis-fundamentals-name-value/references/csharp.md +2 -1
- package/package/corpus/skills/cratis-fundamentals-type-discovery/references/csharp-diagnostics.md +5 -0
- 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-diagnose-slice/SKILL.md +1 -1
- 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-screenplay-accept-model/references/csharp.md +29 -0
- package/package/corpus/skills/cratis-screenplay-accept-model/references/read-the-evidence.md +82 -1
- package/package/corpus/skills/cratis-screenplay-declare-slice/SKILL.md +1 -1
- package/package/corpus/skills/cratis-screenplay-declare-slice/references/structure-and-imports.md +10 -0
- package/package/corpus/skills/cratis-screenplay-onboard-workspace/SKILL.md +5 -4
- 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/typescript.md +13 -0
- package/package/corpus/skills/cratis-screenplay-onboard-workspace/references/workspace-mcp.md +5 -0
- 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 +3 -1
- 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 +1 -0
- package/package/corpus/skills/cratis-specifications-exercise-backend/references/csharp-integration.md +4 -2
- package/package/corpus/skills/cratis-specifications-exercise-backend/references/csharp-reactors.md +3 -3
- package/package/corpus/skills/cratis-specifications-exercise-backend/references/csharp.md +34 -1
- package/package/corpus/skills/cratis-specifications-exercise-backend/references/elixir.md +2 -0
- 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/profile-catalog.json +15 -0
- package/package.json +1 -1
|
@@ -25,25 +25,43 @@ Names are illustrative (a parking office issuing permits); use the application's
|
|
|
25
25
|
events, projections, reducers, reactors and read models, `Cratis.Concepts` and FluentValidation. Add
|
|
26
26
|
`using Cratis.Chronicle.Keys;` for `[Key]`, `using Cratis.Arc.Chronicle.Reactors;` for `Invoke`,
|
|
27
27
|
`Refused` and `[ExecuteCommandsAsSystem]`, and `using Cratis.Monads;` for `Result<,>`.
|
|
28
|
-
- Specifications
|
|
29
|
-
|
|
28
|
+
- Specifications have two placements. Use the one the application already has; never add a second.
|
|
29
|
+
- Default, for an application created from the template: a separate `<App>.Specs` project that
|
|
30
|
+
references the application, `Cratis.Arc.Chronicle.Testing` and `Cratis.Specifications.XUnit.v3`. Its
|
|
31
|
+
folders mirror the slice path. The template has no such project; add it.
|
|
32
|
+
- An application that already keeps specifications beside its slices (a Stage-rendered application
|
|
33
|
+
does): add the spec folder beside the slice and keep the project's Debug-only setup. See
|
|
34
|
+
`cratis-specifications-exercise-backend`, `references/csharp-colocated.md`.
|
|
30
35
|
|
|
31
36
|
## Layout
|
|
32
37
|
|
|
33
38
|
The slice folder sits under the application project and holds backend, generated client and screen
|
|
34
|
-
together
|
|
39
|
+
together. The namespace is the project's `RootNamespace` followed by the folder path; the project's
|
|
40
|
+
folder name plays no part. A shared identity lives at feature level.
|
|
35
41
|
|
|
36
42
|
```text
|
|
37
43
|
Permits/Issuing/PermitId.cs shared identity of the feature
|
|
38
44
|
Permits/Issuing/Issue/Issue.cs command, validator, event type
|
|
39
45
|
Permits/Issuing/Issue/Issue.ts generated from Issue.cs - never edit
|
|
40
46
|
Permits/Issuing/Issue/IssueDialog.tsx screen part of the slice
|
|
47
|
+
Permits/Issuing/Issue/index.ts exports the proxies (generated lines) and the screen (your line)
|
|
41
48
|
Permits/Issuing/Active/Active.cs read model, projection, query
|
|
42
49
|
Permits/Issuing/Active/Active.ts generated
|
|
43
50
|
Permits/Issuing/Active/ActivePage.tsx
|
|
44
51
|
Permits/Issuing/Issuing.tsx composition page mounting both screens
|
|
52
|
+
Permits/Issuing/index.ts exports the composition page
|
|
53
|
+
App.tsx one route per feature, to its composition page
|
|
45
54
|
```
|
|
46
55
|
|
|
56
|
+
- Name a screen for its role (`IssueDialog.tsx`, `ActivePage.tsx`), never `<Slice>.tsx`: `<Slice>.ts` is
|
|
57
|
+
the generated proxy, so `./Issue` would be ambiguous.
|
|
58
|
+
- The application shell lives in root-level `Layout/` and components used by several features in
|
|
59
|
+
`Components/<Group>/`. Neither holds a slice's behaviour.
|
|
60
|
+
- Where every frontend file goes, and how a screen is exported, mounted and routed:
|
|
61
|
+
`cratis-arc-react-bind-slice`, `references/typescript-structure.md`.
|
|
62
|
+
- The template's sample Registration slice contains a reactor that only logs, as a demonstration. Do not
|
|
63
|
+
copy it into a new slice: a state change needs no reactor.
|
|
64
|
+
|
|
47
65
|
The template configures this: proxies are written into the project directory, the root namespace is
|
|
48
66
|
skipped, one `.ts` is generated per `.cs` file, and existing files are not deleted. A folder's `index.ts`
|
|
49
67
|
is a merge target: the generator adds exports for generated files and keeps yours.
|
|
@@ -160,6 +178,152 @@ public class PermitNotifications : IReactor
|
|
|
160
178
|
- Received facts from another event store: `cratis-chronicle-publish-contract`. A job, import or webhook
|
|
161
179
|
executing an existing command: `cratis-arc-invoke-command`.
|
|
162
180
|
|
|
181
|
+
### Returning commands or injecting the pipeline
|
|
182
|
+
|
|
183
|
+
- Default: return the commands, as above. Chronicle tracks the delivery, and a failed command fails the
|
|
184
|
+
partition, which recovery retries within its retry budget.
|
|
185
|
+
- Inject `ICommandPipeline` only when the handler must act on each command's result, as when it drains a
|
|
186
|
+
list in which one refused item must not stop the others. A returned batch cannot do that: it stops at
|
|
187
|
+
the first refusal, including one that `.Acknowledge(...)` or `.OnRefused(...)` handled.
|
|
188
|
+
- With an injected pipeline the handler owns the outcome. Check every `CommandResult` and throw for a
|
|
189
|
+
result that must not pass silently; a result nobody checks is a lost failure.
|
|
190
|
+
|
|
191
|
+
### Draining a to-do list
|
|
192
|
+
|
|
193
|
+
An automation that acts on everything that is due keeps a read model of pending work and sweeps it when
|
|
194
|
+
its trigger arrives. `PermitValiditySet(DateTimeOffset ValidUntil)` is the event that gives a permit its
|
|
195
|
+
end date.
|
|
196
|
+
|
|
197
|
+
```csharp
|
|
198
|
+
[ReadModel]
|
|
199
|
+
[FromEvent<PermitValiditySet>]
|
|
200
|
+
[RemovedWith<PermitRevoked>]
|
|
201
|
+
[RemovedWith<PermitExpired>]
|
|
202
|
+
public record PermitDueForExpiry(PermitId Id, DateTimeOffset ValidUntil);
|
|
203
|
+
|
|
204
|
+
[ReadModel]
|
|
205
|
+
[Passive]
|
|
206
|
+
[FromEvent<PermitValiditySet>]
|
|
207
|
+
[RemovedWith<PermitRevoked>]
|
|
208
|
+
[RemovedWith<PermitExpired>]
|
|
209
|
+
public record PendingPermit(PermitId Id, DateTimeOffset ValidUntil);
|
|
210
|
+
|
|
211
|
+
[Command]
|
|
212
|
+
public record ExpirePermit(PermitId Permit, DateTimeOffset AsOf)
|
|
213
|
+
{
|
|
214
|
+
public const string NothingToExpire = nameof(NothingToExpire);
|
|
215
|
+
public const string StillValid = nameof(StillValid);
|
|
216
|
+
|
|
217
|
+
public Result<PermitExpired, ValidationResult> Handle(PendingPermit? permit)
|
|
218
|
+
{
|
|
219
|
+
if (permit is null)
|
|
220
|
+
return ValidationResult.Error("There is no permit to expire", reasonDetail: NothingToExpire);
|
|
221
|
+
if (permit.ValidUntil > AsOf)
|
|
222
|
+
return ValidationResult.Error("The permit is still valid", reasonDetail: StillValid);
|
|
223
|
+
return new PermitExpired();
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
public class PermitExpiry(IMongoCollection<PermitDueForExpiry> due, ICommandPipeline commands) : IReactor
|
|
228
|
+
{
|
|
229
|
+
[OnceOnly]
|
|
230
|
+
public async Task Sweep(DayStarted @event)
|
|
231
|
+
{
|
|
232
|
+
var permits = await due.Find(permit => permit.ValidUntil <= @event.OccurredAt).ToListAsync();
|
|
233
|
+
foreach (var permit in permits)
|
|
234
|
+
{
|
|
235
|
+
var result = await commands.Execute(new ExpirePermit(permit.Id, @event.OccurredAt));
|
|
236
|
+
if (!result.IsSuccess && !IsNoLongerDue(result)) throw new PermitExpiryFailed(permit.Id);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
static bool IsNoLongerDue(CommandResult result) =>
|
|
241
|
+
result.IsAuthorized && !result.HasExceptions &&
|
|
242
|
+
result.ValidationResults.All(validation =>
|
|
243
|
+
validation.Reason == ValidationResultReason.Rule &&
|
|
244
|
+
validation.ReasonDetail is ExpirePermit.NothingToExpire or ExpirePermit.StillValid);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
public class PermitExpiryFailed(PermitId permit) : Exception($"Could not expire permit '{permit}'.");
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
- The to-do read model is opened by one event and removed by every event that closes the work. Miss one
|
|
251
|
+
closing event and finished work stays on the list.
|
|
252
|
+
- The list only nominates candidates. It can lag, and a retried sweep meets items it already handled. The
|
|
253
|
+
command decides again from its own decision read (`PendingPermit`) and refuses what is gone or not due.
|
|
254
|
+
- The command takes the cutoff from the clock event (`AsOf`) and never reads the wall clock, so the list
|
|
255
|
+
and the decision use the same cutoff. A permit whose end date moved past that cutoff is refused on this
|
|
256
|
+
sweep even when the sweep runs late.
|
|
257
|
+
- A permit the list did not yet contain when the sweep ran is not expired by it. It waits for the next
|
|
258
|
+
clock event.
|
|
259
|
+
- Only those two refusals mean "nothing to do". The command marks each with its own `reasonDetail`, and
|
|
260
|
+
the reactor continues only when every validation result is one of them; it matches the marker, never the
|
|
261
|
+
message.
|
|
262
|
+
- Throw on every other unsuccessful result, so the partition fails and stays visible. That
|
|
263
|
+
includes a decision read that changed under the command, a constraint violation, a failed validator, an
|
|
264
|
+
unauthorized result and an exception. A changed read and a constraint violation arrive as validation
|
|
265
|
+
results too, so "not valid" alone does not mean stale.
|
|
266
|
+
- Recovery retries a failed sweep within its retry budget, and a retried sweep runs from the start.
|
|
267
|
+
Commands that already succeeded are not rolled back, which is why the recheck in the command is
|
|
268
|
+
required. A partition that keeps failing at the same event is quarantined and is not retried again
|
|
269
|
+
until an operator clears it (`cratis-chronicle-inspect-observer`).
|
|
270
|
+
- `[OnceOnly]` keeps a replay from sweeping again for every historical trigger.
|
|
271
|
+
- The reactor has no caller. If the command requires a role, an injected pipeline does not get one from
|
|
272
|
+
`[ExecuteCommandsAsSystem]`; give it a trusted principal as described in `cratis-arc-invoke-command`.
|
|
273
|
+
- The list is read from the store that holds the read model; use the application's own read for a store
|
|
274
|
+
other than MongoDB.
|
|
275
|
+
|
|
276
|
+
### Time
|
|
277
|
+
|
|
278
|
+
Time passing is not an event, and a reactor does not create a timer.
|
|
279
|
+
|
|
280
|
+
- Default: the host's scheduler (a hosted background service or an external job) appends an
|
|
281
|
+
application-owned clock event, an `[EventType]` such as `DayStarted(DateTimeOffset OccurredAt)`, and
|
|
282
|
+
the reactor handles it. Nothing runs until that event is appended.
|
|
283
|
+
- The reactor selects due work by comparing stored deadlines with the event's time, never with the wall
|
|
284
|
+
clock, and passes that same time to the command that decides, so a late or retried delivery uses the
|
|
285
|
+
same cutoff in both places.
|
|
286
|
+
- Work that became due between two clock events waits for the next one, and so does work a lagging list
|
|
287
|
+
did not yet show. Choose the interval from how late the work may be.
|
|
288
|
+
|
|
289
|
+
### Translation
|
|
290
|
+
|
|
291
|
+
A translation slice turns a fact owned by another system into a command in the application's own
|
|
292
|
+
language. It has its own folder, holding the outside event type and the translator.
|
|
293
|
+
|
|
294
|
+
```csharp
|
|
295
|
+
[EventType]
|
|
296
|
+
public record RegistryVehicleAdded(string RegistryNumber, string Plate, string Status);
|
|
297
|
+
|
|
298
|
+
public class VehicleImport(ICommandPipeline commands) : IReactor
|
|
299
|
+
{
|
|
300
|
+
[OnceOnly]
|
|
301
|
+
public async Task Translate(RegistryVehicleAdded @event)
|
|
302
|
+
{
|
|
303
|
+
if (@event.Status != "ACTIVE") return;
|
|
304
|
+
|
|
305
|
+
var result = await commands.Execute(new RegisterVehicle(@event.Plate));
|
|
306
|
+
if (!result.IsSuccess) throw new VehicleImportFailed();
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
public class VehicleImportFailed() : Exception("Vehicle registration failed.");
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
- The outside event type mirrors the payload with primitive fields. The slice is the only place that knows
|
|
314
|
+
the other system's names and codes: the event type carries them and the translator interprets them.
|
|
315
|
+
- Filter, map, execute the local command, and throw when the result is not successful: a refused import
|
|
316
|
+
must stay visible, not be acknowledged as done.
|
|
317
|
+
- Nothing else consumes the outside event. Read models project the application's own events, here the one
|
|
318
|
+
`RegisterVehicle` produces.
|
|
319
|
+
- Declaring the event type connects nothing. An adapter in the host (a webhook or a broker consumer)
|
|
320
|
+
receives the message, validates sender and payload, appends the outside event under a stable event
|
|
321
|
+
source id, checks the append result, and only then acknowledges upstream.
|
|
322
|
+
- A retry after a failure executes the command again. If the command creates a new identity on each
|
|
323
|
+
execution, the retry creates a second entity or is refused by a uniqueness constraint. Keep a durable
|
|
324
|
+
mapping from the outside key to the local identity, and decide what a repeated message means. Never
|
|
325
|
+
parse an outside key as the local identity or treat equal names as the same entity.
|
|
326
|
+
|
|
163
327
|
## Specifications
|
|
164
328
|
|
|
165
329
|
```csharp
|
package/package/corpus/skills/cratis-platform-deliver-slice/references/eventual-consistency.md
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
# Eventual consistency: what a read can rely on after a write
|
|
2
|
+
|
|
3
|
+
## Contents
|
|
4
|
+
|
|
5
|
+
- The rule
|
|
6
|
+
- Choose by who reads next
|
|
7
|
+
- A screen
|
|
8
|
+
- A command that decides
|
|
9
|
+
- Backend code that reads its own append
|
|
10
|
+
- A reactor
|
|
11
|
+
- Passive read models
|
|
12
|
+
- Avoid
|
|
13
|
+
|
|
14
|
+
This is the single guide for "the write succeeded, what can the next read rely on". It is language-neutral;
|
|
15
|
+
the skill named in each row gives the form for your SDK.
|
|
16
|
+
|
|
17
|
+
## The rule
|
|
18
|
+
|
|
19
|
+
A command that succeeded and committed has its events stored. It does not mean any read model contains
|
|
20
|
+
them.
|
|
21
|
+
|
|
22
|
+
- A command executed inside another command's handler joins the outer command's transaction (Arc in C#)
|
|
23
|
+
or batch (the Arc TypeScript backend) when it is eligible to share it. Its success then means the
|
|
24
|
+
events it returned are staged, not stored: they are stored when the outer command succeeds and commits,
|
|
25
|
+
and that commit can still fail. Only events the commands return are staged. An event a handler appends
|
|
26
|
+
directly through the Chronicle client is stored at once and is not part of it.
|
|
27
|
+
|
|
28
|
+
- Projections, reducers and reactors are observers. Each one handles a stored event on its own, after the
|
|
29
|
+
append, and there is no upper bound on the delay: a failed partition or a replay delays a view for as
|
|
30
|
+
long as it lasts.
|
|
31
|
+
- A stored read model has no synchronous or "immediate" mode. A read model that includes the latest event
|
|
32
|
+
is either computed when it is read (passive) or read after an explicit wait.
|
|
33
|
+
- Two stored read models are never guaranteed to reflect the same event at the same moment.
|
|
34
|
+
- A reactor and a projection that handle the same event run independently. Neither runs first.
|
|
35
|
+
|
|
36
|
+
## Choose by who reads next
|
|
37
|
+
|
|
38
|
+
| Who reads next | Default | Use instead when |
|
|
39
|
+
| --- | --- | --- |
|
|
40
|
+
| A screen | An observable query on the stored read model; the change is pushed when it lands | The gesture must show its result in the same frame: see A screen |
|
|
41
|
+
| The same screen, opening the item it just created | Return the identity from the command and bind an observable single-item query; no data is pending only until the item has first appeared | - |
|
|
42
|
+
| A following command that decides on that state | A decision read or a constraint | - |
|
|
43
|
+
| Backend code that appended through the Chronicle client | Wait for observer completion on the append result, check the outcome, then read | Almost every read needs the latest event: a passive read model |
|
|
44
|
+
| A reactor | The data of the event that triggered it | It needs state the event does not carry: a passive read model |
|
|
45
|
+
|
|
46
|
+
## A screen
|
|
47
|
+
|
|
48
|
+
- Submit the command once and render from the query. Do not insert the row into local state, and do not
|
|
49
|
+
re-query when the command returns: a snapshot taken then can still be the old state.
|
|
50
|
+
- Make the query observable when the screen must follow changes, in particular changes its own commands
|
|
51
|
+
cause (`cratis-arc-expose-query`). A report or a one-off read stays a snapshot.
|
|
52
|
+
- A screen that opens an item straight after creating it gets the identity from the command result and
|
|
53
|
+
observes that one item. The item is pushed when the projection has handled the event. Read the result
|
|
54
|
+
in this order:
|
|
55
|
+
- Not ready: the query has not answered yet. Show loading. A source that has emitted nothing is not
|
|
56
|
+
ready; it has not said "no data".
|
|
57
|
+
- Denied or unsuccessful: show the failure. Never read it as pending.
|
|
58
|
+
- Successful with no data: no row matches now. That is pending only while the screen has not yet seen
|
|
59
|
+
the item it just created. Remember when it has appeared; no data after that means the item was removed
|
|
60
|
+
or left the filter.
|
|
61
|
+
- When a screen needs several facts to agree, build one read model that carries them. Two queries on two
|
|
62
|
+
read models can show different moments.
|
|
63
|
+
- Edge case: a drop, paste or canvas gesture that must show its result in the same frame. See
|
|
64
|
+
`cratis-arc-react-bind-slice`, `references/typescript-instant-feedback.md`. A dialog that creates a
|
|
65
|
+
record does not qualify.
|
|
66
|
+
|
|
67
|
+
## A command that decides
|
|
68
|
+
|
|
69
|
+
Reading a read model and then appending leaves a gap in which another writer can change the state the
|
|
70
|
+
decision rested on. A wait or a passive read does not close that gap. Use the protection that matches the
|
|
71
|
+
rule:
|
|
72
|
+
|
|
73
|
+
- A unique value or a create-once rule: a constraint (`cratis-chronicle-constrain-append`).
|
|
74
|
+
- A rule over state, such as "only an open order can be cancelled": a decision read
|
|
75
|
+
(`cratis-chronicle-protect-decision`). That is a read the framework guards, so the append is refused when
|
|
76
|
+
the state changed after the read.
|
|
77
|
+
- A read model handed to the command is a decision read only where the SDK guards it, as Arc in C# does
|
|
78
|
+
with read protection on. Where it is a plain lookup (the Arc TypeScript backend, or C# with read
|
|
79
|
+
protection off) it is a snapshot and guards nothing: use a guarded read or an explicit append scope.
|
|
80
|
+
|
|
81
|
+
## Backend code that reads its own append
|
|
82
|
+
|
|
83
|
+
For a job, an import or a test against a running Chronicle kernel that appends through the Chronicle
|
|
84
|
+
client and then reads a stored read model:
|
|
85
|
+
|
|
86
|
+
1. Append.
|
|
87
|
+
2. Check that the append succeeded. A rejected append has nothing to wait for, and its completion can
|
|
88
|
+
report success.
|
|
89
|
+
3. Wait for observer completion on the append result, with a timeout.
|
|
90
|
+
4. Check the completion: it can report success, a timeout or failed observers, and in some clients a
|
|
91
|
+
timeout rejects the call instead of returning a result, so handle both. Only on success have the
|
|
92
|
+
observers the wait covers caught up for that append.
|
|
93
|
+
5. Read.
|
|
94
|
+
|
|
95
|
+
- An in-process test surface runs no observers, so there is nothing to wait for and the wait fails there.
|
|
96
|
+
Assert through that test surface directly; use a kernel-backed test to check observer completion.
|
|
97
|
+
|
|
98
|
+
- The wait exists in the .NET, TypeScript, Go and Elixir clients. The Kotlin and Java clients have none:
|
|
99
|
+
use an observable query or a passive read model.
|
|
100
|
+
- A timeout or a failed observer does not undo the append. The events are stored; do not repeat a
|
|
101
|
+
non-idempotent write because the wait failed.
|
|
102
|
+
- An Arc command in C# has no option that waits for read models before it answers. The Arc TypeScript
|
|
103
|
+
backend has one: a completion timeout set on the `withChronicle` registration, which applies to every
|
|
104
|
+
command, or on one command written with `defineChronicleCommand`. A model-bound command has no
|
|
105
|
+
setting of its own. A command whose wait fails reports an error although its events are stored. It
|
|
106
|
+
waits on the command's last append only.
|
|
107
|
+
Prefer the observable query in both.
|
|
108
|
+
- The wait is not limited to the read model you are about to read. The .NET client waits for the
|
|
109
|
+
observers that handle the appended event types; the TypeScript and Elixir clients wait for the tail of
|
|
110
|
+
the append without narrowing by event type, so an observer the read does not need can make the wait time
|
|
111
|
+
out.
|
|
112
|
+
- Which observers the wait covers and how to read its result: `cratis-chronicle-inspect-observer`.
|
|
113
|
+
|
|
114
|
+
## A reactor
|
|
115
|
+
|
|
116
|
+
- Decide from the triggering event. It is the one fact the reactor is certain to have.
|
|
117
|
+
- A stored read model that the same event updates may or may not contain the event when the handler runs.
|
|
118
|
+
When the reactor needs state, read a passive read model, or put the needed values on the event.
|
|
119
|
+
- A stored read model used as a to-do list only nominates candidates. The command the reactor issues
|
|
120
|
+
checks the state again and refuses what is no longer due (Reactions in your language reference).
|
|
121
|
+
- Rules for effects and redelivery: `cratis-chronicle-react-to-fact`.
|
|
122
|
+
|
|
123
|
+
## Passive read models
|
|
124
|
+
|
|
125
|
+
A passive read model is not stored. Each read replays, from the start, the events that the read model
|
|
126
|
+
handles for the requested key within its declared scope, so the result reflects every such event stored
|
|
127
|
+
so far. It does not reflect events of other keys or outside that scope (`cratis-chronicle-project-view`).
|
|
128
|
+
|
|
129
|
+
Use it when:
|
|
130
|
+
|
|
131
|
+
- the instance is read by the key that is its event source, and
|
|
132
|
+
- its history is short enough to replay on every read.
|
|
133
|
+
|
|
134
|
+
Keep the read model stored when:
|
|
135
|
+
|
|
136
|
+
- it joins events from other event sources or uses a key other than the event source: a passive read by
|
|
137
|
+
identity only sees the events of that one source;
|
|
138
|
+
- it backs a list, a search, paging or sorting;
|
|
139
|
+
- instances have long histories or are read often.
|
|
140
|
+
|
|
141
|
+
A passive read is still not a guard for a later append: see A command that decides.
|
|
142
|
+
|
|
143
|
+
## Avoid
|
|
144
|
+
|
|
145
|
+
- Sleeping, or polling with a fixed delay, after a command.
|
|
146
|
+
- Reading the stored read model in the same request that appended and trusting the result.
|
|
147
|
+
- Making a read model passive only to hide a slow or failing projection. Find out why it lags
|
|
148
|
+
(`cratis-chronicle-inspect-observer`).
|
|
149
|
+
- Checking a rule in a query on a stored read model and then sending the command.
|
|
150
|
+
- Building read-model state on the client to stand in for the server's.
|
|
@@ -168,7 +168,7 @@ Chronicle reads take `--server`; store-scoped reads use `-e|--event-store`, and
|
|
|
168
168
|
**Application (Arc)**
|
|
169
169
|
|
|
170
170
|
- `cratis arc commands list`: hints from `/.cratis/commands` when checking command discovery on a trusted development endpoint only.
|
|
171
|
-
- `cratis arc queries list`: hints from `/.cratis/queries` for query discovery under the same restriction. The CLI
|
|
171
|
+
- `cratis arc queries list`: hints from `/.cratis/queries` for query discovery under the same restriction. The CLI sends no credentials and accepts any server certificate: it works against a local development certificate, and a successful call does not prove the certificate is valid. Named groups or operations excluded from discovery can be callable; configured routes can differ. Catalog absence, including `401`, `403` or `404`, is not registration evidence.
|
|
172
172
|
- `--url <app-url>`: point Arc CLI at the specific dev host; otherwise it checks `ARC_URL`, launch settings, then the local default.
|
|
173
173
|
- Command result: read `isSuccess`, then `isAuthorized`/`authorizationFailureReason`, `isValid`/`validationResults`, `hasExceptions`/`exceptionMessages`, and `correlationId`. Correlate effects rather than inferring rollback.
|
|
174
174
|
|
|
@@ -27,6 +27,9 @@ directory.
|
|
|
27
27
|
- **No template for the chosen backend:** see Not supported in this SDK in your language reference,
|
|
28
28
|
then use `cratis-arc-host-application` to wire the service.
|
|
29
29
|
- **An existing host reads the wrong Chronicle data:** use `cratis-platform-configure-environment`.
|
|
30
|
+
- **The Cratis CLI cannot be installed:** the C# templates are also `dotnet new` templates in the
|
|
31
|
+
`Cratis.Templates` package. That path writes `.cratis/ai.json` but installs no AI content. See
|
|
32
|
+
Scaffolding with dotnet new in `references/csharp.md`.
|
|
30
33
|
|
|
31
34
|
Python has no application SDK: call the owning service through its authenticated HTTP API.
|
|
32
35
|
|
|
@@ -133,6 +136,24 @@ behavior (`SomeModule/SomeFeature/Registration`), with no `Features/` wrapper.
|
|
|
133
136
|
address than Vite's proxy targets; align them (see Run in your language reference).
|
|
134
137
|
- **The backend cannot reach Chronicle:** confirm the health check, then use
|
|
135
138
|
`cratis-platform-configure-environment`.
|
|
139
|
+
- **A local run breaks without a code change:** applies to the templates that generate a
|
|
140
|
+
`docker-compose.yml`. It uses the floating `cratis/chronicle:latest-development` tag and pulls it on
|
|
141
|
+
every `docker compose up`, so the local kernel moves forward independently of the Chronicle client
|
|
142
|
+
the application builds with. Read the kernel's version with
|
|
143
|
+
`cratis version --server chronicle://localhost:35000` while the active CLI context is the local
|
|
144
|
+
one. An explicit `--server` that is not the active context's server is sent without that context's
|
|
145
|
+
credentials, so with a remote context active a healthy local kernel can look unavailable; switch to
|
|
146
|
+
a local context or put the local credentials in the connection string. Without `--server` the CLI
|
|
147
|
+
uses `CHRONICLE_CONNECTION_STRING` when set, otherwise the active context, either of which can be
|
|
148
|
+
a remote server. It prints no server version when it cannot connect. A different number is not
|
|
149
|
+
proof by itself: only the .NET client shares the kernel's version, the Kotlin and Java clients are
|
|
150
|
+
versioned on their own. Confirm with the backend's connection error and the release notes. Then
|
|
151
|
+
move the application's Cratis packages forward with `cratis-platform-upgrade-application`. Do not
|
|
152
|
+
just swap in an older tag: a kernel migrates its storage at startup and never downgrades it, so an
|
|
153
|
+
older kernel needs fresh local storage (disposable data only) or a backup taken before the newer
|
|
154
|
+
kernel ran. A team that needs identical local kernels sets a fixed
|
|
155
|
+
`cratis/chronicle:<version>-development` tag
|
|
156
|
+
from the start and raises it together with the packages.
|
|
136
157
|
|
|
137
158
|
## Capability catalog
|
|
138
159
|
|
|
@@ -4,11 +4,13 @@
|
|
|
4
4
|
|
|
5
5
|
- Prerequisites
|
|
6
6
|
- What the cratis template generates
|
|
7
|
+
- Scaffolding with dotnet new
|
|
7
8
|
- Run
|
|
8
9
|
- Smoke check
|
|
9
10
|
- Databases
|
|
10
11
|
- Aspire
|
|
11
12
|
- Chronicle only
|
|
13
|
+
- When the repository grows beyond one project
|
|
12
14
|
- Gotchas
|
|
13
15
|
- Not supported in this SDK
|
|
14
16
|
|
|
@@ -19,7 +21,8 @@ C# offers all four templates. `MyApp`, `MyAppDbContext` and `OpenTicket` below a
|
|
|
19
21
|
|
|
20
22
|
- **.NET SDK** whose major version matches the generated `<TargetFramework>`. Before scaffolding,
|
|
21
23
|
`cratis new <template> --language csharp --parameters` shows it as the only `Framework` choice; check
|
|
22
|
-
`dotnet --list-sdks`.
|
|
24
|
+
`dotnet --list-sdks`. After scaffolding, the generated README names the SDK; for `cratis` and
|
|
25
|
+
`cratis-aspire` it also names the Node.js range.
|
|
23
26
|
- **Docker with the Compose plugin** for `cratis`, `cratis-chronicle-console` and `cratis-chronicle-web`.
|
|
24
27
|
`cratis-aspire` needs Docker only; its app host starts the containers.
|
|
25
28
|
- **Node.js and Yarn** for `cratis` and `cratis-aspire`: a Node.js release in the range the generated
|
|
@@ -41,7 +44,11 @@ C# offers all four templates. `MyApp`, `MyAppDbContext` and `OpenTicket` below a
|
|
|
41
44
|
| `SomeModule/SomeFeature/Listing` | Read model `Listing` projected from `Registered`, observable query `AllListings` |
|
|
42
45
|
| `SomeModule/SomeFeature/SomeId.cs`, `SomeName.cs` | The event source id and a `ConceptAs<string>` value |
|
|
43
46
|
| `*.ts` and `index.ts` beside the `.cs` files | Generated TypeScript proxies the frontend imports |
|
|
44
|
-
| `.frontend
|
|
47
|
+
| `.frontend/` | The frontend shell only: `index.html`, the entry module `main.tsx` (wraps `App` in the Arc and Components providers), `index.css`, `vite.config.ts` and the TypeScript configuration. No screens live here |
|
|
48
|
+
| `App.tsx` | The root component: the routes (`/` to `Home`, `/demo` to the sample feature) inside the dialog provider. Add a route here for each new page |
|
|
49
|
+
| `Home.tsx` | The landing page served at `/`; replace it with the application's own |
|
|
50
|
+
| `tsconfig.json` | Only extends `.frontend/tsconfig.json`, which includes every `.ts` and `.tsx` file under the project except `vite.config.ts`, `node_modules/` and `wwwroot/`. Change compiler settings in `.frontend/tsconfig.json` |
|
|
51
|
+
| `package.json`, `eslint.config.mjs` | Frontend dependencies, the `dev`, `build` and `lint` scripts, and the lint configuration; `yarn build` type-checks, then writes to `wwwroot/` |
|
|
45
52
|
| `docker-compose.yml` | Chronicle development image, Aspire dashboard, the database container of the choice |
|
|
46
53
|
|
|
47
54
|
`Program.cs` with the default MongoDB choice:
|
|
@@ -96,11 +103,49 @@ So `MyApp.SomeModule.SomeFeature.Registration.Register` is served at
|
|
|
96
103
|
`CratisProxiesOutputPath` (the project folder), `CratisProxiesUseSourceFileAsOutputFile` (`Registration.cs`
|
|
97
104
|
produces `Registration.ts`) and `CratisProxiesSkipOutputDeletion` (see Gotchas).
|
|
98
105
|
|
|
106
|
+
Where screens, composition pages and shared components go as the frontend grows is in
|
|
107
|
+
`cratis-arc-react-bind-slice`, `references/typescript-structure.md`.
|
|
108
|
+
|
|
99
109
|
`CratisReadProtection` is `On` in the scaffold. Supported decision reads, such as Chronicle read-model
|
|
100
110
|
parameters in a command handler, are read fresh and can guard the append: if an intervening event
|
|
101
111
|
matches the guard, the append is rejected and the command writes nothing. `Measure` records without
|
|
102
112
|
enforcing, `Off` leaves those parameters unguarded, and any other value fails the build.
|
|
103
113
|
|
|
114
|
+
## Scaffolding with dotnet new
|
|
115
|
+
|
|
116
|
+
`cratis new` is the default. Use the .NET template engine only when the Cratis CLI cannot be installed;
|
|
117
|
+
it instantiates the same templates, with the same short names:
|
|
118
|
+
|
|
119
|
+
```sh
|
|
120
|
+
dotnet new install Cratis.Templates
|
|
121
|
+
dotnet new cratis -n MyApp -o MyApp --allow-scripts yes
|
|
122
|
+
cd MyApp
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
What differs from `cratis new`:
|
|
126
|
+
|
|
127
|
+
- **No `--language` for C#.** C# is the default language of every template.
|
|
128
|
+
- **The database is a template parameter with exact names:** `--Database MongoDB`, `PostgreSQL`,
|
|
129
|
+
`MsSql` or `SQLite`. `dotnet new <template> --help` lists that template's parameters.
|
|
130
|
+
- **The `cratis` frontend install asks first.** `dotnet new cratis` prompts before running the install
|
|
131
|
+
step. In a script or an agent session always pass `--allow-scripts yes` (run it) or
|
|
132
|
+
`--allow-scripts no` (skip it, then run `yarn install` yourself). With `no`, `dotnet new` can report
|
|
133
|
+
a non-zero exit code for the skipped step although the project was created; check the output and
|
|
134
|
+
the created files. Pass the option to `cratis` only: the other templates run no script, and
|
|
135
|
+
`cratis-aspire` rejects it.
|
|
136
|
+
- **No AI content is installed.** The scaffold contains `.cratis/ai.json`, but nothing is synced.
|
|
137
|
+
Once the Cratis CLI is available, run `cratis ai update` in `MyApp` and commit the result.
|
|
138
|
+
- **Template updates** come from `dotnet new update`, not `cratis update`.
|
|
139
|
+
|
|
140
|
+
The NuGet references are added by `dotnet new` itself, and those steps continue on error. Do not
|
|
141
|
+
assume the result equals what `cratis new` writes: read the output, then open every generated
|
|
142
|
+
`.csproj`. Check the Cratis `PackageReference` entries that are active for the chosen database: each
|
|
143
|
+
must carry a release version. Where one still says `*`, set the version in place and keep the
|
|
144
|
+
`Condition` on its `ItemGroup`; a reference under a condition for a database you did not choose is
|
|
145
|
+
inactive and can keep `*`. Add a reference that is really missing with
|
|
146
|
+
`dotnet add <path to the owning .csproj> package <id>`: `cratis-aspire` has no project file at the
|
|
147
|
+
solution root. Everything else in this reference applies unchanged.
|
|
148
|
+
|
|
104
149
|
## Run
|
|
105
150
|
|
|
106
151
|
From `MyApp`, after Chronicle reports `Healthy`:
|
|
@@ -119,7 +164,8 @@ dotnet run
|
|
|
119
164
|
`/swagger` to `http://localhost:5000`. If the backend listens elsewhere, for example through `--urls`
|
|
120
165
|
or `ASPNETCORE_URLS`, change the proxy targets in `.frontend/vite.config.ts`.
|
|
121
166
|
- Without Vite: `yarn build` writes the frontend to `wwwroot/`, and the backend serves it on
|
|
122
|
-
`http://localhost:5000`.
|
|
167
|
+
`http://localhost:5000`. The scaffold's build is not minified (`build.minify` is `false` in
|
|
168
|
+
`.frontend/vite.config.ts`); turn minification on there before shipping a production build.
|
|
123
169
|
|
|
124
170
|
## Smoke check
|
|
125
171
|
|
|
@@ -219,8 +265,36 @@ path. Then run the smoke check for the template you selected:
|
|
|
219
265
|
projected `TestProjection` instances with `Hello, Chronicle!`. The demo appends on `GET` for
|
|
220
266
|
convenience; use `POST` for state-changing routes in the real application.
|
|
221
267
|
|
|
268
|
+
## When the repository grows beyond one project
|
|
269
|
+
|
|
270
|
+
The `cratis` scaffold is one project with its own solution file. When a second project joins it (a
|
|
271
|
+
specs project, a contracts project, another service), give each project its own folder beside the
|
|
272
|
+
others under the repository root, and move the shared settings to that root. The scaffold's project
|
|
273
|
+
compiles every `.cs` file below its own folder, so a project placed inside it is compiled twice; if it
|
|
274
|
+
must stay nested, exclude its folder with `DefaultItemExcludes` in the outer `.csproj`.
|
|
275
|
+
|
|
276
|
+
- **One place for package versions.** Add a `Directory.Packages.props` at the root with
|
|
277
|
+
`ManagePackageVersionsCentrally` and `CentralPackageTransitivePinningEnabled` set to `true`, move
|
|
278
|
+
the versions `cratis new` wrote into the `.csproj` to `PackageVersion` items there, and leave the
|
|
279
|
+
`PackageReference` items without a version. Every project then builds against the same version of
|
|
280
|
+
each listed package. Transitive pinning applies only to packages that have a `PackageVersion`
|
|
281
|
+
entry, so add one for every Cratis package that arrives transitively and must stay aligned
|
|
282
|
+
(`Cratis.Arc`, `Cratis.Chronicle`, `Cratis.Fundamentals`), not only for the ones referenced directly.
|
|
283
|
+
- **One SDK.** Add a `global.json` at the root that names the .NET SDK the scaffold targets, with
|
|
284
|
+
`rollForward` set to `latestFeature`, so every machine and the build server use the same SDK line.
|
|
285
|
+
- **One solution file at the root** that lists every project. `cratis-aspire` already has its solution
|
|
286
|
+
at the root, above its three projects.
|
|
287
|
+
|
|
288
|
+
Never keep a Cratis package version per project file; the projects drift apart.
|
|
289
|
+
|
|
222
290
|
## Gotchas
|
|
223
291
|
|
|
292
|
+
- **The scaffold has no launch profile.** Without `Properties/launchSettings.json`, `dotnet run` listens
|
|
293
|
+
on ASP.NET Core's default `http://localhost:5000`, which is what the Vite proxy targets. A launch
|
|
294
|
+
profile added later, by hand or by an IDE, takes over the listening address: set its
|
|
295
|
+
`applicationUrl` to `http://localhost:5000` or change the proxy targets in
|
|
296
|
+
`.frontend/vite.config.ts` to match. The scaffold needs neither a launch profile nor user secrets
|
|
297
|
+
to run locally.
|
|
224
298
|
- **Keep `CratisProxiesSkipOutputDeletion` set to `true`.** The proxy output folder is the project
|
|
225
299
|
folder, and without this setting the generator deletes its output folder before writing.
|
|
226
300
|
- Never edit the generated `.ts` and `index.ts` proxies; each build overwrites them.
|