@cratis/pi 7.51.3 → 7.51.5
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/authoring-skills.instructions.md +1 -1
- package/package/corpus/rules/authoring-skills.md +1 -1
- package/package/corpus/skills/cratis-application-slice-specifications/SKILL.md +4 -55
- package/package/corpus/skills/cratis-application-slice-specifications/references/command-result-assertions.md +36 -0
- package/package/corpus/skills/cratis-application-slice-specifications/references/reading-play-specifications.md +30 -0
- package/package/corpus/skills/cratis-arc-authentication-authorization-and-identity/SKILL.md +4 -69
- package/package/corpus/skills/cratis-arc-authentication-authorization-and-identity/references/authentication.md +8 -0
- package/package/corpus/skills/cratis-arc-authentication-authorization-and-identity/references/authorization.md +9 -0
- package/package/corpus/skills/cratis-arc-authentication-authorization-and-identity/references/frontend.md +19 -0
- package/package/corpus/skills/cratis-arc-authentication-authorization-and-identity/references/identity-endpoints.md +40 -0
- package/package/corpus/skills/cratis-arc-authentication-authorization-and-identity/references/local-development.md +7 -0
- package/package/corpus/skills/cratis-arc-authentication-authorization-and-identity/references/product-sources.md +11 -0
- package/package/corpus/skills/cratis-arc-command/SKILL.md +8 -99
- package/package/corpus/skills/cratis-arc-command/references/causation-details.md +26 -0
- package/package/corpus/skills/cratis-arc-command/references/client-contract.md +16 -0
- package/package/corpus/skills/cratis-arc-command/references/event-source-id-details.md +13 -0
- package/package/corpus/skills/cratis-arc-command/references/generation-boundaries.md +8 -0
- package/package/corpus/skills/cratis-arc-command/references/product-sources.md +16 -0
- package/package/corpus/skills/cratis-arc-command/references/provide-example.md +19 -0
- package/package/corpus/skills/cratis-arc-command/references/proxy-generation.md +8 -0
- package/package/corpus/skills/cratis-arc-command/references/return-shape-examples.md +24 -0
- package/package/corpus/skills/cratis-arc-command-kotlin/SKILL.md +3 -61
- package/package/corpus/skills/cratis-arc-command-kotlin/references/artifacts.md +16 -0
- package/package/corpus/skills/cratis-arc-command-kotlin/references/authorization-override-example.md +17 -0
- package/package/corpus/skills/cratis-arc-command-kotlin/references/project-setup.md +40 -0
- package/package/corpus/skills/cratis-arc-command-typescript/SKILL.md +4 -105
- package/package/corpus/skills/cratis-arc-command-typescript/references/parameter-binding.md +26 -0
- package/package/corpus/skills/cratis-arc-command-typescript/references/project-setup.md +89 -0
- package/package/corpus/skills/cratis-arc-query-typescript/SKILL.md +3 -74
- package/package/corpus/skills/cratis-arc-query-typescript/references/product-sources.md +11 -0
- package/package/corpus/skills/cratis-arc-query-typescript/references/scenario-example.md +23 -0
- package/package/corpus/skills/cratis-arc-query-typescript/references/storage-examples.md +52 -0
- package/package/corpus/skills/cratis-arc-react-page/SKILL.md +3 -63
- package/package/corpus/skills/cratis-arc-react-page/references/data-page.md +28 -0
- package/package/corpus/skills/cratis-arc-react-page/references/dialogs.md +47 -0
- package/package/corpus/skills/cratis-chronicle-client-dotnet/SKILL.md +3 -80
- package/package/corpus/skills/cratis-chronicle-client-dotnet/references/connection-options.md +61 -0
- package/package/corpus/skills/cratis-chronicle-client-dotnet/references/lifecycle.md +30 -0
- package/package/corpus/skills/cratis-chronicle-client-elixir/SKILL.md +8 -101
- package/package/corpus/skills/cratis-chronicle-client-elixir/references/client-options.md +43 -0
- package/package/corpus/skills/cratis-chronicle-client-elixir/references/idioms-and-inspection.md +35 -0
- package/package/corpus/skills/cratis-chronicle-client-elixir/references/product-sources.md +10 -0
- package/package/corpus/skills/cratis-chronicle-client-elixir/references/reactor-example.md +33 -0
- package/package/corpus/skills/cratis-chronicle-client-kotlin/SKILL.md +7 -88
- package/package/corpus/skills/cratis-chronicle-client-kotlin/references/annotations-and-handlers.md +32 -0
- package/package/corpus/skills/cratis-chronicle-client-kotlin/references/append-concurrency.md +9 -0
- package/package/corpus/skills/cratis-chronicle-client-kotlin/references/connection-string.md +27 -0
- package/package/corpus/skills/cratis-chronicle-client-kotlin/references/event-type-annotations.md +9 -0
- package/package/corpus/skills/cratis-chronicle-client-kotlin/references/product-sources.md +13 -0
- package/package/corpus/skills/cratis-chronicle-client-kotlin/references/read-models-and-projections.md +29 -0
- package/package/corpus/skills/cratis-chronicle-client-typescript/SKILL.md +3 -103
- package/package/corpus/skills/cratis-chronicle-client-typescript/references/connection-options.md +52 -0
- package/package/corpus/skills/cratis-chronicle-client-typescript/references/lifecycle.md +31 -0
- package/package/corpus/skills/cratis-chronicle-client-typescript/references/project-setup.md +36 -0
- package/package/corpus/skills/cratis-chronicle-projection/SKILL.md +1 -21
- package/package/corpus/skills/cratis-chronicle-projection/references/definition-changes.md +27 -0
- package/package/corpus/skills/cratis-chronicle-reactor/SKILL.md +5 -110
- package/package/corpus/skills/cratis-chronicle-reactor/references/cross-service-events.md +13 -0
- package/package/corpus/skills/cratis-chronicle-reactor/references/filtering.md +34 -0
- package/package/corpus/skills/cratis-chronicle-reactor/references/read-model-injection.md +29 -0
- package/package/corpus/skills/cratis-chronicle-reactor/references/return-event-metadata.md +51 -0
- package/package/corpus/skills/cratis-chronicle-reducer/SKILL.md +7 -92
- package/package/corpus/skills/cratis-chronicle-reducer/references/filtering.md +36 -0
- package/package/corpus/skills/cratis-chronicle-reducer/references/instance-reducer-example.md +20 -0
- package/package/corpus/skills/cratis-chronicle-reducer/references/product-sources.md +8 -0
- package/package/corpus/skills/cratis-chronicle-reducer/references/replay-hooks-and-definition-changes.md +35 -0
- package/package/corpus/skills/cratis-chronicle-reducer/references/specification-example.md +15 -0
- package/package/corpus/skills/cratis-components-styling/SKILL.md +1 -15
- package/package/corpus/skills/cratis-components-styling/references/renderer-adapters.md +21 -0
- package/package/corpus/skills/cratis-governed-release-methodology/SKILL.md +1 -24
- package/package/corpus/skills/cratis-governed-release-methodology/references/lifecycle-phases.md +30 -0
- package/package/corpus/skills/cratis-screenplay-automations-and-translations/SKILL.md +2 -15
- package/package/corpus/skills/cratis-screenplay-automations-and-translations/references/neighbouring-skills.md +12 -0
- package/package/corpus/skills/cratis-screenplay-automations-and-translations/references/product-sources.md +11 -0
- package/package/corpus/skills/cratis-screenplay-captures-and-reactions/SKILL.md +3 -93
- package/package/corpus/skills/cratis-screenplay-captures-and-reactions/references/capture-map-and-example.md +37 -0
- package/package/corpus/skills/cratis-screenplay-captures-and-reactions/references/trigger-declaration.md +48 -0
- package/package/corpus/skills/cratis-screenplay-captures-and-reactions/references/trigger-reads-example.md +16 -0
- package/package/corpus/skills/cratis-screenplay-command-surface/SKILL.md +5 -97
- package/package/corpus/skills/cratis-screenplay-command-surface/references/compliance.md +9 -0
- package/package/corpus/skills/cratis-screenplay-command-surface/references/constraints-produces-concurrency.md +89 -0
- package/package/corpus/skills/cratis-screenplay-command-surface/references/routes-and-external-operations.md +21 -0
- package/package/corpus/skills/cratis-screenplay-discovery/SKILL.md +5 -38
- package/package/corpus/skills/cratis-screenplay-discovery/references/interview-questions.md +14 -0
- package/package/corpus/skills/cratis-screenplay-discovery/references/neighbouring-skills.md +14 -0
- package/package/corpus/skills/cratis-screenplay-discovery/references/plotting-and-handoff.md +9 -0
- package/package/corpus/skills/cratis-screenplay-discovery/references/product-sources.md +16 -0
- package/package/corpus/skills/cratis-screenplay-event-modeling/SKILL.md +6 -74
- package/package/corpus/skills/cratis-screenplay-event-modeling/references/facilitation-stance.md +12 -0
- package/package/corpus/skills/cratis-screenplay-event-modeling/references/file-layout.md +19 -0
- package/package/corpus/skills/cratis-screenplay-event-modeling/references/modeling-reasoning.md +13 -0
- package/package/corpus/skills/cratis-screenplay-event-modeling/references/neighbouring-skills.md +16 -0
- package/package/corpus/skills/cratis-screenplay-event-modeling/references/parsed-not-runnable.md +33 -0
- package/package/corpus/skills/cratis-screenplay-event-modeling/references/provenance.md +6 -0
- package/package/corpus/skills/cratis-screenplay-legacy-extraction/SKILL.md +2 -17
- package/package/corpus/skills/cratis-screenplay-legacy-extraction/references/generate-notes.md +12 -1
- package/package/corpus/skills/cratis-screenplay-legacy-extraction/references/interview-findings.md +18 -0
- package/package/corpus/skills/cratis-screenplay-legacy-extraction/references/neighbouring-skills.md +12 -0
- package/package/corpus/skills/cratis-screenplay-model-authoring/SKILL.md +5 -89
- package/package/corpus/skills/cratis-screenplay-model-authoring/references/language-reference.md +6 -0
- package/package/corpus/skills/cratis-screenplay-model-authoring/references/layout.md +30 -0
- package/package/corpus/skills/cratis-screenplay-model-authoring/references/repairs.md +42 -0
- package/package/corpus/skills/cratis-screenplay-model-authoring/references/state-and-recovery.md +30 -0
- package/package/corpus/skills/cratis-screenplay-model-review/SKILL.md +10 -42
- package/package/corpus/skills/cratis-screenplay-model-review/references/baseline-comparison.md +7 -0
- package/package/corpus/skills/cratis-screenplay-model-review/references/business-questions.md +11 -0
- package/package/corpus/skills/cratis-screenplay-model-review/references/interview-batch.md +14 -0
- package/package/corpus/skills/cratis-screenplay-model-review/references/model-inventory-report.md +8 -0
- package/package/corpus/skills/cratis-screenplay-model-review/references/neighbouring-skills.md +12 -0
- package/package/corpus/skills/cratis-screenplay-model-review/references/report-template.md +21 -0
- package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/SKILL.md +15 -68
- package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/references/completeness-self-check.md +12 -0
- package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/references/handoff-template.md +15 -0
- package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/references/identity-and-edits.md +9 -0
- package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/references/independent-review.md +10 -0
- package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/references/neighbouring-skills.md +10 -0
- package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/references/per-turn-protocol.md +5 -0
- package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/references/product-sources.md +9 -0
- package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/references/safety.md +12 -0
- package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/references/stop-or-assume.md +25 -0
- package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/references/verdicts-and-modes.md +8 -0
- package/package/corpus/skills/cratis-screenplay-projections/SKILL.md +3 -67
- package/package/corpus/skills/cratis-screenplay-projections/references/joins.md +41 -0
- package/package/corpus/skills/cratis-screenplay-projections/references/variants.md +41 -0
- package/package/corpus/skills/cratis-screenplay-render-and-gap-fill/SKILL.md +3 -31
- package/package/corpus/skills/cratis-screenplay-render-and-gap-fill/references/delivery-protocol.md +9 -0
- package/package/corpus/skills/cratis-screenplay-render-and-gap-fill/references/neighbouring-skills.md +11 -0
- package/package/corpus/skills/cratis-screenplay-render-and-gap-fill/references/product-sources.md +23 -0
- package/package/corpus/skills/cratis-screenplay-scenario-coverage/SKILL.md +11 -75
- package/package/corpus/skills/cratis-screenplay-scenario-coverage/references/interview-batch.md +16 -0
- package/package/corpus/skills/cratis-screenplay-scenario-coverage/references/neighbouring-skills.md +10 -0
- package/package/corpus/skills/cratis-screenplay-scenario-coverage/references/public-event-coverage.md +12 -0
- package/package/corpus/skills/cratis-screenplay-scenario-coverage/references/quality-checklist.md +17 -0
- package/package/corpus/skills/cratis-screenplay-scenario-coverage/references/review-questions.md +9 -0
- package/package/corpus/skills/cratis-screenplay-scenario-coverage/references/scenario-catalogue.md +28 -0
- package/package/corpus/skills/cratis-screenplay-scenario-coverage/references/version-skew.md +14 -0
- package/package/corpus/skills/cratis-screenplay-slice-design/SKILL.md +18 -94
- package/package/corpus/skills/cratis-screenplay-slice-design/references/command-inventory.md +25 -0
- package/package/corpus/skills/cratis-screenplay-slice-design/references/field-lineage.md +9 -0
- package/package/corpus/skills/cratis-screenplay-slice-design/references/identity-edits.md +14 -0
- package/package/corpus/skills/cratis-screenplay-slice-design/references/model-reasoning.md +9 -0
- package/package/corpus/skills/cratis-screenplay-slice-design/references/neighbouring-skills.md +10 -0
- package/package/corpus/skills/cratis-screenplay-slice-design/references/product-sources.md +9 -0
- package/package/corpus/skills/cratis-screenplay-slice-design/references/public-boundaries-and-keys.md +16 -0
- package/package/corpus/skills/cratis-screenplay-slice-design/references/read-model-design.md +36 -0
- package/package/corpus/skills/cratis-screenplay-slice-design/references/slicing.md +17 -0
- package/package/corpus/skills/cratis-screenplay-specifications/SKILL.md +5 -63
- package/package/corpus/skills/cratis-screenplay-specifications/references/examples-and-routes.md +6 -0
- package/package/corpus/skills/cratis-screenplay-specifications/references/outcome-comparison.md +33 -0
- package/package/corpus/skills/cratis-screenplay-specifications/references/vocabulary.md +40 -0
- package/package/corpus/skills/cratis-screenplay-streams-and-consistency/SKILL.md +11 -77
- package/package/corpus/skills/cratis-screenplay-streams-and-consistency/references/consistency-and-concurrency.md +21 -0
- package/package/corpus/skills/cratis-screenplay-streams-and-consistency/references/evolution.md +18 -0
- package/package/corpus/skills/cratis-screenplay-streams-and-consistency/references/interview-batch.md +20 -0
- package/package/corpus/skills/cratis-screenplay-streams-and-consistency/references/neighbouring-skills.md +12 -0
- package/package/corpus/skills/cratis-screenplay-streams-and-consistency/references/product-sources.md +12 -0
- package/package/corpus/skills/cratis-screenplay-streams-and-consistency/references/review-questions.md +13 -0
- package/package/corpus/skills/cratis-screenplay-streams-and-consistency/references/stream-id-rules.md +15 -0
- package/package/corpus/skills/cratis-screenplay-toolchain/SKILL.md +1 -8
- package/package/corpus/skills/cratis-screenplay-toolchain/references/neighbouring-skills.md +12 -0
- package/package/corpus/skills/cratis-screenplay-ui-composition/SKILL.md +6 -99
- package/package/corpus/skills/cratis-screenplay-ui-composition/references/file-references.md +38 -0
- package/package/corpus/skills/cratis-screenplay-ui-composition/references/layout-arrangement.md +31 -0
- package/package/corpus/skills/cratis-screenplay-ui-composition/references/localized-strings.md +15 -0
- package/package/corpus/skills/cratis-screenplay-ui-composition/references/screen-composition-contract.md +6 -0
- package/package/corpus/skills/cratis-screenplay-ui-composition/references/ui-profile-and-theme.md +34 -0
- package/package/corpus/skills/cratis-stage-rendering-and-sandbox/SKILL.md +1 -10
- package/package/corpus/skills/cratis-stage-rendering-and-sandbox/references/neighbouring-skills.md +14 -0
- package/package.json +1 -1
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Event source id details
|
|
2
|
+
|
|
3
|
+
This reference holds the `[Key]` attribute collision and the positional-record and source-type rules for event source id resolution.
|
|
4
|
+
|
|
5
|
+
`[Key]` on a positional record's primary-constructor parameter is recognized
|
|
6
|
+
and counted once. Child-only/nested read-model types are not standalone
|
|
7
|
+
command-scoped models. `[EventSource<TSource>(stream)]` supplies source type and
|
|
8
|
+
stream metadata on commands and aggregate roots.
|
|
9
|
+
|
|
10
|
+
Two attributes are spelled `[Key]`. Chronicle reads `Cratis.Chronicle.Keys.KeyAttribute`.
|
|
11
|
+
Marking `System.ComponentModel.DataAnnotations.KeyAttribute` in an application
|
|
12
|
+
that uses Chronicle compiles, resolves nothing, and silently invents a new event
|
|
13
|
+
source id for every command — `ARCCHR0008` reports it.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# When not to generate
|
|
2
|
+
|
|
3
|
+
This reference holds the cases where a value should not be generated by the server.
|
|
4
|
+
|
|
5
|
+
Keep client-owned IDs as inputs. Generation is not authorization, tenant
|
|
6
|
+
isolation, idempotency, freshness or gapless invoice numbering. Credentials need
|
|
7
|
+
explicit entropy, `[NotAudited]`, authorized delivery and hash storage; never
|
|
8
|
+
log captures or persist plaintext authentication keys. See [boundaries](shop-generation.md#when-not-to-generate).
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Product sources
|
|
2
|
+
|
|
3
|
+
This reference holds the packages and types the command guidance relies on.
|
|
4
|
+
|
|
5
|
+
| Package | Purpose |
|
|
6
|
+
| --- | --- |
|
|
7
|
+
| `Cratis.Arc.Core` | `Cratis.Arc.Commands.ModelBound.CommandAttribute`, `CommandResult`, `CommandValidator<T>` |
|
|
8
|
+
| `Cratis.Arc.Chronicle` | event append handling, `Cratis.Arc.Chronicle.Commands.NotAuditedAttribute` |
|
|
9
|
+
| `Cratis.Arc.ProxyGenerator.Build` | `CratisProxiesOutputPath` MSBuild integration |
|
|
10
|
+
| `Cratis.Fundamentals` | `Cratis.Monads.Result<TResult, TError>` |
|
|
11
|
+
| `Cratis.Chronicle` | `EventTypeAttribute`, `EventForEventSourceId`, `ICanProvideEventSourceId` |
|
|
12
|
+
| `@cratis/arc` | `ICommand`, `CommandResult`, `ValidationResult` |
|
|
13
|
+
|
|
14
|
+
Fundamentals:
|
|
15
|
+
[`Result<TResult, TError>`](https://github.com/Cratis/Fundamentals/blob/main/Source/DotNET/Fundamentals/Monads/Result%7BTResult,TError%7D.cs):
|
|
16
|
+
success is first, error second, with implicit conversions from both types.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Provide example
|
|
2
|
+
|
|
3
|
+
This reference holds a worked `Provide()` example that rejects with a validation result.
|
|
4
|
+
|
|
5
|
+
```csharp
|
|
6
|
+
[Command]
|
|
7
|
+
public record Open<Thing>(<ThingId> Id, <OwnerId> OwnerId)
|
|
8
|
+
{
|
|
9
|
+
public async Task<Result<<Owner>, ValidationResult>> Provide(IReadModels readModels)
|
|
10
|
+
{
|
|
11
|
+
var owner = await readModels.GetInstanceById<<Owner>>((EventSourceId)OwnerId);
|
|
12
|
+
return owner is null
|
|
13
|
+
? ValidationResult.Error("Owner must exist.")
|
|
14
|
+
: owner;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
public <ThingOpened> Handle(<Owner> owner) => new(owner.Id);
|
|
18
|
+
}
|
|
19
|
+
```
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
- MSBuild properties
|
|
7
7
|
- What the generator extracts for client-side validation
|
|
8
8
|
- Failure modes
|
|
9
|
+
- Blocking severity
|
|
9
10
|
|
|
10
11
|
Source: `Cratis.Arc.ProxyGenerator.Build`.
|
|
11
12
|
|
|
@@ -107,3 +108,10 @@ property.
|
|
|
107
108
|
| Files appear under an unexpected folder | The folder mirrors the namespace; change the namespace or use `NamespaceRoot`/`CratisProxiesSegmentsToSkip` |
|
|
108
109
|
| Stale proxies after a rename | `dotnet clean` then `dotnet build`; the generator does not delete by default |
|
|
109
110
|
| A rule validates on the server but not in the browser | The rule is not in the extractable set above |
|
|
111
|
+
|
|
112
|
+
## Blocking severity
|
|
113
|
+
|
|
114
|
+
`[BlockOnValidationSeverity(ValidationResultSeverity.Warning)]` declares the
|
|
115
|
+
lowest blocking severity for validation, `Provide` and execution. Caller
|
|
116
|
+
`allowedSeverity`/`X-Allowed-Severity` can only make it stricter; `Unknown` blocks.
|
|
117
|
+
The proxy carries `blockOnValidationSeverity` and honors it client-side.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Return shape examples
|
|
2
|
+
|
|
3
|
+
This reference holds worked return-shape examples for a create command and a cross-stream command.
|
|
4
|
+
|
|
5
|
+
```csharp
|
|
6
|
+
[Command]
|
|
7
|
+
public record Register<Thing>(<ConceptType> <Name>)
|
|
8
|
+
{
|
|
9
|
+
public (<ThingId>, <ThingRegistered>) Handle([GeneratedValue("thing")] <ThingId> id) =>
|
|
10
|
+
(id, new(<Name>));
|
|
11
|
+
}
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
```csharp
|
|
15
|
+
[Command]
|
|
16
|
+
public record Transfer(<AccountId> From, <AccountId> To, <Money> Amount)
|
|
17
|
+
{
|
|
18
|
+
public IEnumerable<object> Handle() =>
|
|
19
|
+
[
|
|
20
|
+
new EventForEventSourceId(From, new <Withdrawn>(Amount)),
|
|
21
|
+
new EventForEventSourceId(To, new <Deposited>(Amount)),
|
|
22
|
+
];
|
|
23
|
+
}
|
|
24
|
+
```
|
|
@@ -18,18 +18,7 @@ Sources include `ArcSymbolProcessor.kt`, `GradlePlugin/ArcExtension.kt` and
|
|
|
18
18
|
`Integrations/Cratis`/`Integrations/Chronicle` publishing blocks. Use a released
|
|
19
19
|
version from Maven Central, not the local `0.0.0-SNAPSHOT`.
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
| --- | --- |
|
|
23
|
-
| `io.cratis:arc` | `io.cratis.arc.artifacts.Command`, `CommandKey`, `FromServices` |
|
|
24
|
-
| `io.cratis:arc-ksp` | the KSP processor that generates the command handler |
|
|
25
|
-
| `io.cratis:arc-spring-boot-starter` | Spring Boot auto-configuration, the command pipeline host |
|
|
26
|
-
| `io.cratis:cratis` | recommended single dependency for an event-sourced app: Arc, Spring Boot wiring and Chronicle integration |
|
|
27
|
-
| `io.cratis:arc-chronicle-spring-boot-starter` | explicit alternative to `cratis`, same Arc version |
|
|
28
|
-
| `io.cratis:arc-testing` | in-process command and query scenarios (test scope) |
|
|
29
|
-
| `io.cratis:arc-spring-data-jpa`, `io.cratis:arc-spring-data-mongodb` | Spring Data read-model integrations |
|
|
30
|
-
| `io.cratis:arc-rxjava3` | RxJava 3 observable queries |
|
|
31
|
-
| `io.cratis:arc-observability-spring-boot-starter`, `io.cratis:arc-openapi-spring-boot-starter` | optional observability and OpenAPI |
|
|
32
|
-
| `io.cratis.arc` Gradle plugin | applies Kotlin/JVM + KSP, adds the dependencies, configures the module name and proxy output |
|
|
21
|
+
Read [references/artifacts.md](references/artifacts.md) when choosing `io.cratis` artifacts.
|
|
33
22
|
|
|
34
23
|
Requires Arc.Kotlin 7.5.0 for the single `io.cratis:cratis` dependency.
|
|
35
24
|
|
|
@@ -49,42 +38,7 @@ application source files differ (Java records instead of Kotlin data classes).
|
|
|
49
38
|
|
|
50
39
|
## Set up the project
|
|
51
40
|
|
|
52
|
-
|
|
53
|
-
// settings.gradle.kts
|
|
54
|
-
pluginManagement {
|
|
55
|
-
repositories {
|
|
56
|
-
mavenCentral()
|
|
57
|
-
gradlePluginPortal()
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
```kotlin
|
|
63
|
-
// build.gradle.kts
|
|
64
|
-
plugins {
|
|
65
|
-
id("io.cratis.arc") version "<version>"
|
|
66
|
-
kotlin("plugin.spring") version "2.4.20"
|
|
67
|
-
id("org.springframework.boot") version "4.1.1"
|
|
68
|
-
id("io.spring.dependency-management") version "1.1.7"
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
repositories {
|
|
72
|
-
mavenCentral()
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
cratisArc {
|
|
76
|
-
moduleName.set("<ModuleName>")
|
|
77
|
-
dependencyVersion.set("<version>")
|
|
78
|
-
endpoints {
|
|
79
|
-
segmentsToSkip.set(<packageSegmentsUnderModuleRoot>)
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
dependencies {
|
|
84
|
-
implementation("io.cratis:arc-spring-boot-starter:<version>")
|
|
85
|
-
implementation("org.springframework.boot:spring-boot-starter-webmvc")
|
|
86
|
-
}
|
|
87
|
-
```
|
|
41
|
+
Read [references/project-setup.md](references/project-setup.md) when writing the Gradle build for a new project.
|
|
88
42
|
|
|
89
43
|
The plugin applies Kotlin/JVM and KSP, targets JDK 17, and treats warnings as
|
|
90
44
|
errors. `moduleName` names the generated artifact module and manifest; every
|
|
@@ -305,19 +259,7 @@ operation on an `@Authorize`-protected class is reachable without
|
|
|
305
259
|
authentication — the shape a login-screen query needs on an otherwise
|
|
306
260
|
protected read model):
|
|
307
261
|
|
|
308
|
-
|
|
309
|
-
@ReadModel
|
|
310
|
-
@Authorize
|
|
311
|
-
data class AuthenticationQueryItem(val message: String) {
|
|
312
|
-
companion object {
|
|
313
|
-
// Overrides the class: anyone may subscribe to this one.
|
|
314
|
-
@JvmStatic
|
|
315
|
-
@AllowAnonymous
|
|
316
|
-
fun anonymous(@FromServices source: AuthenticationQuerySource): Flow<AuthenticationQueryItem> =
|
|
317
|
-
source.observeAnonymous()
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
```
|
|
262
|
+
Read [references/authorization-override-example.md](references/authorization-override-example.md) when you need the `@AllowAnonymous` operation-override example.
|
|
321
263
|
|
|
322
264
|
Combining `@AllowAnonymous` with `@Authorize`/`@Roles` is only ever a
|
|
323
265
|
contradiction — and only ever fails with `ARCKSP0108` — **on the exact same
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Arc.Kotlin artifacts
|
|
2
|
+
|
|
3
|
+
This reference holds the Arc.Kotlin artifacts and what each provides.
|
|
4
|
+
|
|
5
|
+
| Artifact | Purpose |
|
|
6
|
+
| --- | --- |
|
|
7
|
+
| `io.cratis:arc` | `io.cratis.arc.artifacts.Command`, `CommandKey`, `FromServices` |
|
|
8
|
+
| `io.cratis:arc-ksp` | the KSP processor that generates the command handler |
|
|
9
|
+
| `io.cratis:arc-spring-boot-starter` | Spring Boot auto-configuration, the command pipeline host |
|
|
10
|
+
| `io.cratis:cratis` | recommended single dependency for an event-sourced app: Arc, Spring Boot wiring and Chronicle integration |
|
|
11
|
+
| `io.cratis:arc-chronicle-spring-boot-starter` | explicit alternative to `cratis`, same Arc version |
|
|
12
|
+
| `io.cratis:arc-testing` | in-process command and query scenarios (test scope) |
|
|
13
|
+
| `io.cratis:arc-spring-data-jpa`, `io.cratis:arc-spring-data-mongodb` | Spring Data read-model integrations |
|
|
14
|
+
| `io.cratis:arc-rxjava3` | RxJava 3 observable queries |
|
|
15
|
+
| `io.cratis:arc-observability-spring-boot-starter`, `io.cratis:arc-openapi-spring-boot-starter` | optional observability and OpenAPI |
|
|
16
|
+
| `io.cratis.arc` Gradle plugin | applies Kotlin/JVM + KSP, adds the dependencies, configures the module name and proxy output |
|
package/package/corpus/skills/cratis-arc-command-kotlin/references/authorization-override-example.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Authorization override example
|
|
2
|
+
|
|
3
|
+
This reference holds a worked example of an operation that overrides its class authorization.
|
|
4
|
+
|
|
5
|
+
```kotlin
|
|
6
|
+
@ReadModel
|
|
7
|
+
@Authorize
|
|
8
|
+
data class AuthenticationQueryItem(val message: String) {
|
|
9
|
+
companion object {
|
|
10
|
+
// Overrides the class: anyone may subscribe to this one.
|
|
11
|
+
@JvmStatic
|
|
12
|
+
@AllowAnonymous
|
|
13
|
+
fun anonymous(@FromServices source: AuthenticationQuerySource): Flow<AuthenticationQueryItem> =
|
|
14
|
+
source.observeAnonymous()
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
```
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# Project setup
|
|
2
|
+
|
|
3
|
+
This reference holds the Gradle settings and build files for an Arc.Kotlin project.
|
|
4
|
+
|
|
5
|
+
```kotlin
|
|
6
|
+
// settings.gradle.kts
|
|
7
|
+
pluginManagement {
|
|
8
|
+
repositories {
|
|
9
|
+
mavenCentral()
|
|
10
|
+
gradlePluginPortal()
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
```kotlin
|
|
16
|
+
// build.gradle.kts
|
|
17
|
+
plugins {
|
|
18
|
+
id("io.cratis.arc") version "<version>"
|
|
19
|
+
kotlin("plugin.spring") version "2.4.20"
|
|
20
|
+
id("org.springframework.boot") version "4.1.1"
|
|
21
|
+
id("io.spring.dependency-management") version "1.1.7"
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
repositories {
|
|
25
|
+
mavenCentral()
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
cratisArc {
|
|
29
|
+
moduleName.set("<ModuleName>")
|
|
30
|
+
dependencyVersion.set("<version>")
|
|
31
|
+
endpoints {
|
|
32
|
+
segmentsToSkip.set(<packageSegmentsUnderModuleRoot>)
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
dependencies {
|
|
37
|
+
implementation("io.cratis:arc-spring-boot-starter:<version>")
|
|
38
|
+
implementation("org.springframework.boot:spring-boot-starter-webmvc")
|
|
39
|
+
}
|
|
40
|
+
```
|
|
@@ -53,93 +53,11 @@ when returning or specifying Chronicle events.
|
|
|
53
53
|
listing/watching and history beyond that boundary need `ChronicleKernelScenario`
|
|
54
54
|
against `ARC_CHRONICLE_TEST_URL`.
|
|
55
55
|
|
|
56
|
-
## Set up
|
|
57
|
-
|
|
58
|
-
Consume the preview in one of two ways:
|
|
59
|
-
|
|
60
|
-
| Path | How | Use when |
|
|
61
|
-
| --- | --- | --- |
|
|
62
|
-
| Inside a clone | Put the application under `Samples/<Name>` in a clone of `Cratis/Arc.TypeScript`; reference packages as `workspace:^` | Experimenting, or changing Arc while building on it |
|
|
63
|
-
| Packed tarballs | In the clone: `yarn install`, `yarn build`, then `yarn workspace @cratis/arc.core pack --out <file>` per package; `npm install <file>.tgz` in your project | A separate repository |
|
|
64
|
-
|
|
65
|
-
Use `yarn pack`, not `npm pack` — Yarn rewrites `workspace:^` dependencies to
|
|
66
|
-
version ranges; npm does not, and the tarball then fails to install. A
|
|
67
|
-
`workspace:^` dependency outside the clone fails at install.
|
|
68
|
-
|
|
69
|
-
- Node.js 22.19 or later (the core runs on 22; the workspace build needs 22.19;
|
|
70
|
-
24 LTS is recommended).
|
|
71
|
-
- ES modules only: `"type": "module"` in `package.json`.
|
|
72
|
-
- Peer dependencies of `@cratis/arc.core`: `@cratis/fundamentals`,
|
|
73
|
-
`@opentelemetry/api`; `rxjs` is an optional peer, needed for
|
|
74
|
-
RxJS observable queries.
|
|
75
|
-
- TypeScript: the repository and proxy generator use TypeScript 6
|
|
76
|
-
(`typescript@npm:@typescript/typescript6`, command `tsc6`).
|
|
77
|
-
|
|
78
|
-
```json
|
|
79
|
-
{
|
|
80
|
-
"compilerOptions": {
|
|
81
|
-
"target": "ES2022",
|
|
82
|
-
"module": "NodeNext",
|
|
83
|
-
"moduleResolution": "NodeNext",
|
|
84
|
-
"lib": ["ES2022", "ESNext.Decorators"],
|
|
85
|
-
"types": ["node"],
|
|
86
|
-
"strict": true,
|
|
87
|
-
"verbatimModuleSyntax": true,
|
|
88
|
-
"skipLibCheck": true,
|
|
89
|
-
"rootDir": ".",
|
|
90
|
-
"outDir": "dist"
|
|
91
|
-
},
|
|
92
|
-
"include": ["main.ts", "Features/**/*.ts"],
|
|
93
|
-
"exclude": ["Features/**/*.proxy.ts", "Features/**/*.tsx"]
|
|
94
|
-
}
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
- **No `experimentalDecorators`.** Arc's decorators compile as standard TC39
|
|
98
|
-
decorators, as the samples do; `ESNext.Decorators` declares `Symbol.metadata`.
|
|
99
|
-
Legacy `experimentalDecorators` also work. The Library sample compiles its
|
|
100
|
-
`@cratis/chronicle` 6.35 event types and projections under the same
|
|
101
|
-
standard-decorator settings. Generated frontend proxies are the exception:
|
|
102
|
-
they compile with `experimentalDecorators: true`.
|
|
103
|
-
- With `NodeNext`, relative imports carry a `.js` extension. `ESNext` +
|
|
104
|
-
`Bundler` (the samples' choice) also works.
|
|
105
|
-
- Node's own type stripping does not transform decorators — `node main.ts`
|
|
106
|
-
fails at the first `@`. Run source with `tsx watch main.ts` during
|
|
107
|
-
development and compile with `tsc6` for production.
|
|
108
|
-
- A Vitest/Vite transform must lower standard decorators with
|
|
109
|
-
`useDefineForClassFields: true` (`target: 'es2022'`,
|
|
110
|
-
`experimentalDecorators: false`), or decorators silently do nothing in specs.
|
|
111
|
-
|
|
112
|
-
## Bootstrap the application
|
|
113
|
-
|
|
114
|
-
`Samples/Tasks/main.ts`:
|
|
115
|
-
|
|
116
|
-
```typescript
|
|
117
|
-
import { ArcApplication } from '@cratis/arc.core';
|
|
118
|
-
import { Tasks } from './Features/Tasks/Tasks.js';
|
|
119
|
-
import { metadata } from './Features/generatedMetadata.js';
|
|
120
|
-
|
|
121
|
-
const builder = ArcApplication.createBuilder();
|
|
122
|
-
builder.useGeneratedMetadata(metadata);
|
|
123
|
-
builder.services.addSingleton(Tasks);
|
|
124
|
-
await builder.discover(new URL('./Features/', import.meta.url));
|
|
125
|
-
export const app = await builder.build();
|
|
126
|
-
await app.run({ port: Number(process.env.PORT ?? 3000) });
|
|
127
|
-
```
|
|
56
|
+
## Set up and bootstrap
|
|
128
57
|
|
|
129
|
-
|
|
130
|
-
| --- | --- |
|
|
131
|
-
| `ArcApplication.createBuilder(options?)` | Starts the application; the Node builder reads `appsettings.json` (`Cratis:Arc`) and `Cratis__...` environment variables |
|
|
132
|
-
| `useGeneratedMetadata(metadata)` | Installs parameter and return-type metadata extracted from source. Call it **before** `discover()`/`add()` |
|
|
133
|
-
| `services.addSingleton(Token)` | Registers a service; `addScoped`/`addTransient` take factories. Classes can also carry `@singleton()`, `@scoped()`, `@transient()` |
|
|
134
|
-
| `discover(folderUrl)` | Imports every module under the folder and registers **exported**, decorated artifacts. Skips `dist`, `node_modules`, `given`, `for_*`, `index.*`, declaration files and `*.proxy.ts/.tsx` |
|
|
135
|
-
| `add(...types)` | Registers artifacts explicitly — required on the Fetch entry, which cannot discover |
|
|
136
|
-
| `build()` | Validates the whole graph (missing services, lifetime mismatches, misplaced decorators, stale metadata) and throws before any listener opens |
|
|
137
|
-
| `app.run()` / `app.start()` | Standalone Node host. `app.dispose()` stops it and disposes services |
|
|
138
|
-
|
|
139
|
-
`discover()` refuses a folder containing the entry point; use `Features/`.
|
|
140
|
-
`Cratis:Arc:Development: true` is local-only.
|
|
58
|
+
Read [references/project-setup.md](references/project-setup.md) when consuming the source preview in a project, choosing compiler and decorator settings, or wiring `main.ts` and the builder calls (`useGeneratedMetadata` before `discover()`; `build()` validates the graph before any listener opens).
|
|
141
59
|
|
|
142
|
-
|
|
60
|
+
## Secure discovery defaults
|
|
143
61
|
|
|
144
62
|
Requires Arc for TypeScript 0.56.0 for these defaults.
|
|
145
63
|
|
|
@@ -223,26 +141,7 @@ class names in bundled builds (`keepNames` in esbuild).
|
|
|
223
141
|
|
|
224
142
|
## Bind parameters
|
|
225
143
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
- **Generated artifact metadata** (the samples): `arc-proxygenerator --metadata`
|
|
229
|
-
writes a module from source; `handle(tasks: Tasks)` then needs no decorator.
|
|
230
|
-
- **Explicit tokens**: `@inject(Tasks)` on `handle()` or `provide()`, one token
|
|
231
|
-
or marker per parameter, in order.
|
|
232
|
-
|
|
233
|
-
Built-in markers for `@inject(...)`:
|
|
234
|
-
|
|
235
|
-
| Marker | Binds |
|
|
236
|
-
| --- | --- |
|
|
237
|
-
| `abortSignal()` | The request's `AbortSignal` — pass it to cancelable I/O |
|
|
238
|
-
| `commandContext()` | The `CommandContext`: `key`, `values`, `correlationId`, `principal`, `tenantId`, `signal` |
|
|
239
|
-
| `provided(Type)` | A value from `provide()`, matched by runtime type |
|
|
240
|
-
| `commandReadModel(Type, { optional? })` | The read model for the command key, from a registered resolver (MongoDB, Drizzle, Chronicle) |
|
|
241
|
-
| `mongoCollection(Model)` / `drizzleDatabase()` | Storage handles from the optional integrations |
|
|
242
|
-
|
|
243
|
-
`build()` fails with `Unbound handle parameters on <Type>.handle` when neither
|
|
244
|
-
metadata nor tokens cover a parameter. Default and rest parameters always need
|
|
245
|
-
explicit tokens.
|
|
144
|
+
Read [references/parameter-binding.md](references/parameter-binding.md) when binding `handle()` or `provide()` parameters (generated metadata or `@inject(...)` markers); `build()` fails with `Unbound handle parameters on <Type>.handle` when neither metadata nor tokens cover a parameter.
|
|
246
145
|
|
|
247
146
|
## Prepare data with `provide()`
|
|
248
147
|
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Binding command parameters
|
|
2
|
+
|
|
3
|
+
This reference holds how Arc learns `handle()` and `provide()` parameter types and the built-in `@inject(...)` markers.
|
|
4
|
+
|
|
5
|
+
## Bind parameters
|
|
6
|
+
|
|
7
|
+
TypeScript erases parameter types, so Arc learns them one of two ways:
|
|
8
|
+
|
|
9
|
+
- **Generated artifact metadata** (the samples): `arc-proxygenerator --metadata`
|
|
10
|
+
writes a module from source; `handle(tasks: Tasks)` then needs no decorator.
|
|
11
|
+
- **Explicit tokens**: `@inject(Tasks)` on `handle()` or `provide()`, one token
|
|
12
|
+
or marker per parameter, in order.
|
|
13
|
+
|
|
14
|
+
Built-in markers for `@inject(...)`:
|
|
15
|
+
|
|
16
|
+
| Marker | Binds |
|
|
17
|
+
| --- | --- |
|
|
18
|
+
| `abortSignal()` | The request's `AbortSignal` — pass it to cancelable I/O |
|
|
19
|
+
| `commandContext()` | The `CommandContext`: `key`, `values`, `correlationId`, `principal`, `tenantId`, `signal` |
|
|
20
|
+
| `provided(Type)` | A value from `provide()`, matched by runtime type |
|
|
21
|
+
| `commandReadModel(Type, { optional? })` | The read model for the command key, from a registered resolver (MongoDB, Drizzle, Chronicle) |
|
|
22
|
+
| `mongoCollection(Model)` / `drizzleDatabase()` | Storage handles from the optional integrations |
|
|
23
|
+
|
|
24
|
+
`build()` fails with `Unbound handle parameters on <Type>.handle` when neither
|
|
25
|
+
metadata nor tokens cover a parameter. Default and rest parameters always need
|
|
26
|
+
explicit tokens.
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# Project setup and bootstrap for Arc for TypeScript
|
|
2
|
+
|
|
3
|
+
This reference holds the source-preview consumption paths, compiler and decorator settings, and the application bootstrap with its builder calls.
|
|
4
|
+
|
|
5
|
+
## Set up a project
|
|
6
|
+
|
|
7
|
+
Consume the preview in one of two ways:
|
|
8
|
+
|
|
9
|
+
| Path | How | Use when |
|
|
10
|
+
| --- | --- | --- |
|
|
11
|
+
| Inside a clone | Put the application under `Samples/<Name>` in a clone of `Cratis/Arc.TypeScript`; reference packages as `workspace:^` | Experimenting, or changing Arc while building on it |
|
|
12
|
+
| Packed tarballs | In the clone: `yarn install`, `yarn build`, then `yarn workspace @cratis/arc.core pack --out <file>` per package; `npm install <file>.tgz` in your project | A separate repository |
|
|
13
|
+
|
|
14
|
+
Use `yarn pack`, not `npm pack` — Yarn rewrites `workspace:^` dependencies to
|
|
15
|
+
version ranges; npm does not, and the tarball then fails to install. A
|
|
16
|
+
`workspace:^` dependency outside the clone fails at install.
|
|
17
|
+
|
|
18
|
+
- Node.js 22.19 or later (the core runs on 22; the workspace build needs 22.19;
|
|
19
|
+
24 LTS is recommended).
|
|
20
|
+
- ES modules only: `"type": "module"` in `package.json`.
|
|
21
|
+
- Peer dependencies of `@cratis/arc.core`: `@cratis/fundamentals`,
|
|
22
|
+
`@opentelemetry/api`; `rxjs` is an optional peer, needed for
|
|
23
|
+
RxJS observable queries.
|
|
24
|
+
- TypeScript: the repository and proxy generator use TypeScript 6
|
|
25
|
+
(`typescript@npm:@typescript/typescript6`, command `tsc6`).
|
|
26
|
+
|
|
27
|
+
```json
|
|
28
|
+
{
|
|
29
|
+
"compilerOptions": {
|
|
30
|
+
"target": "ES2022",
|
|
31
|
+
"module": "NodeNext",
|
|
32
|
+
"moduleResolution": "NodeNext",
|
|
33
|
+
"lib": ["ES2022", "ESNext.Decorators"],
|
|
34
|
+
"types": ["node"],
|
|
35
|
+
"strict": true,
|
|
36
|
+
"verbatimModuleSyntax": true,
|
|
37
|
+
"skipLibCheck": true,
|
|
38
|
+
"rootDir": ".",
|
|
39
|
+
"outDir": "dist"
|
|
40
|
+
},
|
|
41
|
+
"include": ["main.ts", "Features/**/*.ts"],
|
|
42
|
+
"exclude": ["Features/**/*.proxy.ts", "Features/**/*.tsx"]
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
- **No `experimentalDecorators`.** Arc's decorators compile as standard TC39
|
|
47
|
+
decorators, as the samples do; `ESNext.Decorators` declares `Symbol.metadata`.
|
|
48
|
+
Legacy `experimentalDecorators` also work. The Library sample compiles its
|
|
49
|
+
`@cratis/chronicle` 6.35 event types and projections under the same
|
|
50
|
+
standard-decorator settings. Generated frontend proxies are the exception:
|
|
51
|
+
they compile with `experimentalDecorators: true`.
|
|
52
|
+
- With `NodeNext`, relative imports carry a `.js` extension. `ESNext` +
|
|
53
|
+
`Bundler` (the samples' choice) also works.
|
|
54
|
+
- Node's own type stripping does not transform decorators — `node main.ts`
|
|
55
|
+
fails at the first `@`. Run source with `tsx watch main.ts` during
|
|
56
|
+
development and compile with `tsc6` for production.
|
|
57
|
+
- A Vitest/Vite transform must lower standard decorators with
|
|
58
|
+
`useDefineForClassFields: true` (`target: 'es2022'`,
|
|
59
|
+
`experimentalDecorators: false`), or decorators silently do nothing in specs.
|
|
60
|
+
|
|
61
|
+
## Bootstrap the application
|
|
62
|
+
|
|
63
|
+
`Samples/Tasks/main.ts`:
|
|
64
|
+
|
|
65
|
+
```typescript
|
|
66
|
+
import { ArcApplication } from '@cratis/arc.core';
|
|
67
|
+
import { Tasks } from './Features/Tasks/Tasks.js';
|
|
68
|
+
import { metadata } from './Features/generatedMetadata.js';
|
|
69
|
+
|
|
70
|
+
const builder = ArcApplication.createBuilder();
|
|
71
|
+
builder.useGeneratedMetadata(metadata);
|
|
72
|
+
builder.services.addSingleton(Tasks);
|
|
73
|
+
await builder.discover(new URL('./Features/', import.meta.url));
|
|
74
|
+
export const app = await builder.build();
|
|
75
|
+
await app.run({ port: Number(process.env.PORT ?? 3000) });
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
| Call | Effect |
|
|
79
|
+
| --- | --- |
|
|
80
|
+
| `ArcApplication.createBuilder(options?)` | Starts the application; the Node builder reads `appsettings.json` (`Cratis:Arc`) and `Cratis__...` environment variables |
|
|
81
|
+
| `useGeneratedMetadata(metadata)` | Installs parameter and return-type metadata extracted from source. Call it **before** `discover()`/`add()` |
|
|
82
|
+
| `services.addSingleton(Token)` | Registers a service; `addScoped`/`addTransient` take factories. Classes can also carry `@singleton()`, `@scoped()`, `@transient()` |
|
|
83
|
+
| `discover(folderUrl)` | Imports every module under the folder and registers **exported**, decorated artifacts. Skips `dist`, `node_modules`, `given`, `for_*`, `index.*`, declaration files and `*.proxy.ts/.tsx` |
|
|
84
|
+
| `add(...types)` | Registers artifacts explicitly — required on the Fetch entry, which cannot discover |
|
|
85
|
+
| `build()` | Validates the whole graph (missing services, lifetime mismatches, misplaced decorators, stale metadata) and throws before any listener opens |
|
|
86
|
+
| `app.run()` / `app.start()` | Standalone Node host. `app.dispose()` stops it and disposes services |
|
|
87
|
+
|
|
88
|
+
`discover()` refuses a folder containing the entry point; use `Features/`.
|
|
89
|
+
`Cratis:Arc:Development: true` is local-only.
|
|
@@ -19,13 +19,7 @@ frontend. Project setup, the builder, and hosts are in
|
|
|
19
19
|
|
|
20
20
|
## Verified product sources
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
server packages not on npm), reading
|
|
24
|
-
`Source/Core/queries/index.ts`, `Documentation/queries/**`,
|
|
25
|
-
`Documentation/mongodb/**`, `Documentation/sql/**`,
|
|
26
|
-
`Documentation/testing/queries.md` and `observable-queries.md`, and
|
|
27
|
-
`Samples/Tasks` / `Samples/Library`. RxJS is an optional peer of
|
|
28
|
-
`@cratis/arc.core`, required only for RxJS sources.
|
|
22
|
+
Read [references/product-sources.md](references/product-sources.md) for the source files; RxJS is an optional peer for RxJS sources.
|
|
29
23
|
|
|
30
24
|
## Declare a read model and its queries
|
|
31
25
|
|
|
@@ -238,54 +232,7 @@ false`).
|
|
|
238
232
|
The storage integrations register tenant-scoped service tokens; a query never
|
|
239
233
|
chooses a database itself.
|
|
240
234
|
|
|
241
|
-
|
|
242
|
-
// MongoDB — register with builder.withMongoDB({ ..., readModels: [TaskRecord] })
|
|
243
|
-
import { query, queryOptions, readModel, service, type QueryOptions } from '@cratis/arc.core';
|
|
244
|
-
import { mongoCollection, type MongoCollection } from '@cratis/arc.mongodb';
|
|
245
|
-
|
|
246
|
-
const tasks = mongoCollection(TaskRecord);
|
|
247
|
-
|
|
248
|
-
@readModel()
|
|
249
|
-
export class TaskQueries {
|
|
250
|
-
@query(service(tasks))
|
|
251
|
-
static async all(items: MongoCollection<TaskRecord>): Promise<TaskRecord[]> { return items.find(); }
|
|
252
|
-
|
|
253
|
-
@query(service(tasks), queryOptions())
|
|
254
|
-
static async page(items: MongoCollection<TaskRecord>, options: QueryOptions) { return items.queryPage({}, options); }
|
|
255
|
-
|
|
256
|
-
@query({ observable: true }, service(tasks))
|
|
257
|
-
static changes(items: MongoCollection<TaskRecord>) { return items.observe(); }
|
|
258
|
-
}
|
|
259
|
-
```
|
|
260
|
-
|
|
261
|
-
```typescript
|
|
262
|
-
// Drizzle — register with builder.withDrizzle({ dialect, database, readModels: [{ type: TaskRecord, table: tasks }] })
|
|
263
|
-
import { drizzleReadModel, type DrizzleReadModels } from '@cratis/arc.drizzle';
|
|
264
|
-
|
|
265
|
-
@readModel()
|
|
266
|
-
export class TaskQueries {
|
|
267
|
-
@query(service(drizzleReadModel(TaskRecord)), queryOptions())
|
|
268
|
-
static page(tasks: DrizzleReadModels<TaskRecord>, options: QueryOptions) { return tasks.queryPage(undefined, options); }
|
|
269
|
-
}
|
|
270
|
-
```
|
|
271
|
-
|
|
272
|
-
```typescript
|
|
273
|
-
// Chronicle (experimental) — Samples/Library/Features/Authors/Listing/Listing.ts
|
|
274
|
-
import { ChronicleReadModels } from '@cratis/arc.chronicle';
|
|
275
|
-
import { fromEvent } from '@cratis/chronicle/projections';
|
|
276
|
-
|
|
277
|
-
@readModel()
|
|
278
|
-
@fromEvent(AuthorRegistered)
|
|
279
|
-
export class Author {
|
|
280
|
-
@field(AuthorId) id!: AuthorId;
|
|
281
|
-
@field(AuthorName) name!: AuthorName;
|
|
282
|
-
|
|
283
|
-
@query({ observable: true }, service(ChronicleReadModels))
|
|
284
|
-
static allAuthors(models: ChronicleReadModels): Observable<Author[]> {
|
|
285
|
-
return models.observeAll(Author, author => author.id.toString());
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
```
|
|
235
|
+
Read [references/storage-examples.md](references/storage-examples.md) for worked MongoDB, Drizzle and Chronicle query examples.
|
|
289
236
|
|
|
290
237
|
- MongoDB: every injected model is listed in `withMongoDB`'s `readModels`;
|
|
291
238
|
`observe()` needs a replica set. Build owner filters from the verified
|
|
@@ -312,25 +259,7 @@ when implementing Drizzle observation or serving protected raw MongoDB documents
|
|
|
312
259
|
`@cratis/arc.testing` runs the real query pipeline in-process. From
|
|
313
260
|
`Samples/Tasks`:
|
|
314
261
|
|
|
315
|
-
|
|
316
|
-
import { ObservableQueryScenario, QueryScenario } from '@cratis/arc.testing';
|
|
317
|
-
import { Tasks } from '../../../Tasks.js';
|
|
318
|
-
import { TaskItem } from '../../Listing.js';
|
|
319
|
-
import { metadata } from '../../../../generatedMetadata.js';
|
|
320
|
-
|
|
321
|
-
export class a_task_listing {
|
|
322
|
-
tasks = new Tasks();
|
|
323
|
-
query = QueryScenario.for<{ id: string; title: string }[]>(TaskItem, 'allTasks');
|
|
324
|
-
observable = ObservableQueryScenario.for<{ id: string; title: string }[]>(TaskItem, 'observeAllTasks');
|
|
325
|
-
|
|
326
|
-
constructor() {
|
|
327
|
-
this.query.extend(builder => builder.useGeneratedMetadata(metadata));
|
|
328
|
-
this.observable.extend(builder => builder.useGeneratedMetadata(metadata));
|
|
329
|
-
this.query.services.addSingleton(Tasks, this.tasks);
|
|
330
|
-
this.observable.services.addSingleton(Tasks, this.tasks);
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
```
|
|
262
|
+
Read [references/scenario-example.md](references/scenario-example.md) when you need a worked scenario context class.
|
|
334
263
|
|
|
335
264
|
- `QueryScenario.for<T>(ReadModel, 'methodName', ...artifacts)` — `T` is the
|
|
336
265
|
**wire** shape (`data` is JSON-shaped; concepts arrive as strings), not a
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Product sources
|
|
2
|
+
|
|
3
|
+
This reference holds the source material behind the query guidance.
|
|
4
|
+
|
|
5
|
+
Source: `Cratis/Arc.TypeScript` (source preview;
|
|
6
|
+
server packages not on npm), reading
|
|
7
|
+
`Source/Core/queries/index.ts`, `Documentation/queries/**`,
|
|
8
|
+
`Documentation/mongodb/**`, `Documentation/sql/**`,
|
|
9
|
+
`Documentation/testing/queries.md` and `observable-queries.md`, and
|
|
10
|
+
`Samples/Tasks` / `Samples/Library`. RxJS is an optional peer of
|
|
11
|
+
`@cratis/arc.core`, required only for RxJS sources.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Query scenario example
|
|
2
|
+
|
|
3
|
+
This reference holds a worked scenario context for `QueryScenario` and `ObservableQueryScenario`.
|
|
4
|
+
|
|
5
|
+
```typescript
|
|
6
|
+
import { ObservableQueryScenario, QueryScenario } from '@cratis/arc.testing';
|
|
7
|
+
import { Tasks } from '../../../Tasks.js';
|
|
8
|
+
import { TaskItem } from '../../Listing.js';
|
|
9
|
+
import { metadata } from '../../../../generatedMetadata.js';
|
|
10
|
+
|
|
11
|
+
export class a_task_listing {
|
|
12
|
+
tasks = new Tasks();
|
|
13
|
+
query = QueryScenario.for<{ id: string; title: string }[]>(TaskItem, 'allTasks');
|
|
14
|
+
observable = ObservableQueryScenario.for<{ id: string; title: string }[]>(TaskItem, 'observeAllTasks');
|
|
15
|
+
|
|
16
|
+
constructor() {
|
|
17
|
+
this.query.extend(builder => builder.useGeneratedMetadata(metadata));
|
|
18
|
+
this.observable.extend(builder => builder.useGeneratedMetadata(metadata));
|
|
19
|
+
this.query.services.addSingleton(Tasks, this.tasks);
|
|
20
|
+
this.observable.services.addSingleton(Tasks, this.tasks);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
```
|