@cratis/pi 7.51.2 → 7.51.4
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 +7 -1
- package/package/corpus/rules/authoring-skills.md +7 -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/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,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
|
+
```
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# Storage-backed query examples
|
|
2
|
+
|
|
3
|
+
This reference holds worked MongoDB, Drizzle and Chronicle read model query examples.
|
|
4
|
+
|
|
5
|
+
```typescript
|
|
6
|
+
// MongoDB — register with builder.withMongoDB({ ..., readModels: [TaskRecord] })
|
|
7
|
+
import { query, queryOptions, readModel, service, type QueryOptions } from '@cratis/arc.core';
|
|
8
|
+
import { mongoCollection, type MongoCollection } from '@cratis/arc.mongodb';
|
|
9
|
+
|
|
10
|
+
const tasks = mongoCollection(TaskRecord);
|
|
11
|
+
|
|
12
|
+
@readModel()
|
|
13
|
+
export class TaskQueries {
|
|
14
|
+
@query(service(tasks))
|
|
15
|
+
static async all(items: MongoCollection<TaskRecord>): Promise<TaskRecord[]> { return items.find(); }
|
|
16
|
+
|
|
17
|
+
@query(service(tasks), queryOptions())
|
|
18
|
+
static async page(items: MongoCollection<TaskRecord>, options: QueryOptions) { return items.queryPage({}, options); }
|
|
19
|
+
|
|
20
|
+
@query({ observable: true }, service(tasks))
|
|
21
|
+
static changes(items: MongoCollection<TaskRecord>) { return items.observe(); }
|
|
22
|
+
}
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
```typescript
|
|
26
|
+
// Drizzle — register with builder.withDrizzle({ dialect, database, readModels: [{ type: TaskRecord, table: tasks }] })
|
|
27
|
+
import { drizzleReadModel, type DrizzleReadModels } from '@cratis/arc.drizzle';
|
|
28
|
+
|
|
29
|
+
@readModel()
|
|
30
|
+
export class TaskQueries {
|
|
31
|
+
@query(service(drizzleReadModel(TaskRecord)), queryOptions())
|
|
32
|
+
static page(tasks: DrizzleReadModels<TaskRecord>, options: QueryOptions) { return tasks.queryPage(undefined, options); }
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
```typescript
|
|
37
|
+
// Chronicle (experimental) — Samples/Library/Features/Authors/Listing/Listing.ts
|
|
38
|
+
import { ChronicleReadModels } from '@cratis/arc.chronicle';
|
|
39
|
+
import { fromEvent } from '@cratis/chronicle/projections';
|
|
40
|
+
|
|
41
|
+
@readModel()
|
|
42
|
+
@fromEvent(AuthorRegistered)
|
|
43
|
+
export class Author {
|
|
44
|
+
@field(AuthorId) id!: AuthorId;
|
|
45
|
+
@field(AuthorName) name!: AuthorName;
|
|
46
|
+
|
|
47
|
+
@query({ observable: true }, service(ChronicleReadModels))
|
|
48
|
+
static allAuthors(models: ChronicleReadModels): Observable<Author[]> {
|
|
49
|
+
return models.observeAll(Author, author => author.id.toString());
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
```
|
|
@@ -50,13 +50,7 @@ import { DialogProps, DialogResult, useDialog } from '@cratis/arc.react/dialogs'
|
|
|
50
50
|
|
|
51
51
|
## Initial focus
|
|
52
52
|
|
|
53
|
-
`DialogInitialFocus.Confirm` is the default and
|
|
54
|
-
browser fires `click` from the `keydown` of Enter, so a held Enter confirms.
|
|
55
|
-
For a destructive dialog use `DialogInitialFocus.Cancel`, which focuses the
|
|
56
|
-
least destructive action and degrades to `Content` when the button set has
|
|
57
|
-
nothing to dismiss with. `DialogInitialFocus.Content` focuses the title so
|
|
58
|
-
nothing is armed. There is deliberately no "focus nothing" option — a modal
|
|
59
|
-
must move focus into itself.
|
|
53
|
+
`DialogInitialFocus.Confirm` is the default and arms the confirm button, so a destructive dialog uses `DialogInitialFocus.Cancel`. Read [dialogs.md](references/dialogs.md) for the three options.
|
|
60
54
|
|
|
61
55
|
## Step 1 — Prerequisites
|
|
62
56
|
|
|
@@ -213,65 +207,11 @@ validation never re-runs and the submit button stays disabled. Seed values that
|
|
|
213
207
|
|
|
214
208
|
## Step 6 — Confirming, and showing that work is in progress
|
|
215
209
|
|
|
216
|
-
Do not build a confirmation or busy dialog into a page
|
|
217
|
-
`BusyIndicatorDialog` are registered once at the app root through
|
|
218
|
-
`DialogComponents` and raised by hook, which is what keeps every one of them
|
|
219
|
-
identical:
|
|
220
|
-
|
|
221
|
-
```tsx
|
|
222
|
-
import { DialogComponents } from '@cratis/arc.react/dialogs';
|
|
223
|
-
import { BusyIndicatorDialog, ConfirmationDialog } from '@cratis/components/Dialogs';
|
|
224
|
-
|
|
225
|
-
<DialogComponents confirmation={ConfirmationDialog} busyIndicator={BusyIndicatorDialog}>
|
|
226
|
-
<YourApp />
|
|
227
|
-
</DialogComponents>
|
|
228
|
-
```
|
|
229
|
-
|
|
230
|
-
```tsx
|
|
231
|
-
import { DialogButtons, DialogResult, useBusyIndicator, useConfirmationDialog } from '@cratis/arc.react/dialogs';
|
|
232
|
-
|
|
233
|
-
const [confirm] = useConfirmationDialog();
|
|
234
|
-
if (await confirm('Delete this account?', `"${account.name}" disappears permanently.`, DialogButtons.YesNo) !== DialogResult.Yes) return;
|
|
235
|
-
```
|
|
236
|
-
|
|
237
|
-
A busy indicator is modal and deliberately non-dismissible, so reserve it for
|
|
238
|
-
work the user genuinely cannot proceed past — a multi-step import, a migration.
|
|
239
|
-
For an ordinary command behind a button, the in-flight disabled button is the
|
|
240
|
-
right control; a modal that flashes for 200 ms tells the user nothing. When you
|
|
241
|
-
do use one, pair it with the close call in a `finally`:
|
|
242
|
-
|
|
243
|
-
```tsx
|
|
244
|
-
const [showBusy, closeBusy] = useBusyIndicator('Importing', 'This takes a moment.');
|
|
245
|
-
showBusy();
|
|
246
|
-
try { await importEverything(); } finally { closeBusy(); }
|
|
247
|
-
```
|
|
210
|
+
Do not build a confirmation or busy dialog into a page: register `ConfirmationDialog` and `BusyIndicatorDialog` once at the app root through `DialogComponents` and raise them by hook (`useConfirmationDialog`, `useBusyIndicator`). A busy indicator is modal and non-dismissible, so reserve it for work the user cannot proceed past, and pair `showBusy()` with a close in a `finally`. Read [dialogs.md](references/dialogs.md) for the registration and hook examples.
|
|
248
211
|
|
|
249
212
|
## Step 7 — Row selection and a details pane
|
|
250
213
|
|
|
251
|
-
`selection` and `onSelectionChange` are controlled.
|
|
252
|
-
`value`, which is `null` when the selection is cleared.
|
|
253
|
-
|
|
254
|
-
```tsx
|
|
255
|
-
import type { DataTableSelectionChangeEvent } from '@cratis/components/DataTables';
|
|
256
|
-
|
|
257
|
-
const [selected, setSelected] = useState<AccountSummary | null>(null);
|
|
258
|
-
|
|
259
|
-
<DataPage
|
|
260
|
-
title='Accounts'
|
|
261
|
-
query={AllAccounts}
|
|
262
|
-
emptyMessage='No accounts yet.'
|
|
263
|
-
dataKey='id'
|
|
264
|
-
selection={selected}
|
|
265
|
-
onSelectionChange={(event: DataTableSelectionChangeEvent<AccountSummary>) => setSelected(event.value)}
|
|
266
|
-
detailsComponent={AccountDetails}>
|
|
267
|
-
<DataPage.Columns>
|
|
268
|
-
<Column field='name' header='Name' />
|
|
269
|
-
</DataPage.Columns>
|
|
270
|
-
</DataPage>
|
|
271
|
-
```
|
|
272
|
-
|
|
273
|
-
`detailsComponent` receives `IDetailsComponentProps<T>` — `{ item, onRefresh? }`
|
|
274
|
-
— and renders beside the table for the selected row.
|
|
214
|
+
`selection` and `onSelectionChange` are controlled (`value` is `null` when cleared), and `detailsComponent` receives `{ item, onRefresh? }` for the selected row. Read [data-page.md](references/data-page.md) for the controlled-selection example.
|
|
275
215
|
|
|
276
216
|
## Step 8 — Snapshot or observable query
|
|
277
217
|
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
- `Column`
|
|
11
11
|
- Type name caution
|
|
12
12
|
- Layout
|
|
13
|
+
- Step 7 — Row selection and a details pane
|
|
13
14
|
|
|
14
15
|
`DataPage` is the standard list page: an action menubar, a data table, and an
|
|
15
16
|
optional details pane in one component. Import from
|
|
@@ -148,3 +149,30 @@ DataPage subpath: it is the props type of the `DataPage.Columns` wrapper.
|
|
|
148
149
|
The details pane renders in a resizable split. Give the page a bounded height —
|
|
149
150
|
the stories wrap `DataPage` in a container with an explicit height — or the
|
|
150
151
|
split has nothing to size against.
|
|
152
|
+
|
|
153
|
+
## Step 7 — Row selection and a details pane
|
|
154
|
+
|
|
155
|
+
`selection` and `onSelectionChange` are controlled. The change event carries
|
|
156
|
+
`value`, which is `null` when the selection is cleared.
|
|
157
|
+
|
|
158
|
+
```tsx
|
|
159
|
+
import type { DataTableSelectionChangeEvent } from '@cratis/components/DataTables';
|
|
160
|
+
|
|
161
|
+
const [selected, setSelected] = useState<AccountSummary | null>(null);
|
|
162
|
+
|
|
163
|
+
<DataPage
|
|
164
|
+
title='Accounts'
|
|
165
|
+
query={AllAccounts}
|
|
166
|
+
emptyMessage='No accounts yet.'
|
|
167
|
+
dataKey='id'
|
|
168
|
+
selection={selected}
|
|
169
|
+
onSelectionChange={(event: DataTableSelectionChangeEvent<AccountSummary>) => setSelected(event.value)}
|
|
170
|
+
detailsComponent={AccountDetails}>
|
|
171
|
+
<DataPage.Columns>
|
|
172
|
+
<Column field='name' header='Name' />
|
|
173
|
+
</DataPage.Columns>
|
|
174
|
+
</DataPage>
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
`detailsComponent` receives `IDetailsComponentProps<T>` — `{ item, onRefresh? }`
|
|
178
|
+
— and renders beside the table for the selected row.
|
|
@@ -9,6 +9,8 @@
|
|
|
9
9
|
- `CommandForm` fields
|
|
10
10
|
- `Dialog` — data without a command
|
|
11
11
|
- Host-registered confirmation and busy indicators
|
|
12
|
+
- Step 6 — Confirming, and showing that work is in progress
|
|
13
|
+
- Initial focus
|
|
12
14
|
|
|
13
15
|
The Cratis dialog wrappers own command execution, validation timing, busy
|
|
14
16
|
state, and footer buttons. Never use a vendor or hand-rolled modal — dialogs are Components-owned.
|
|
@@ -253,3 +255,48 @@ buttons from the dialog request. `BusyIndicatorDialog` takes the busy-indicator
|
|
|
253
255
|
request. Register both once at the app root through `DialogComponents` and
|
|
254
256
|
raise them by hook — see the skill's Step 6. From a view model, use the
|
|
255
257
|
injectable `IDialogs` abstraction instead of the hooks.
|
|
258
|
+
|
|
259
|
+
## Step 6 — Confirming, and showing that work is in progress
|
|
260
|
+
|
|
261
|
+
Do not build a confirmation or busy dialog into a page. `ConfirmationDialog` and
|
|
262
|
+
`BusyIndicatorDialog` are registered once at the app root through
|
|
263
|
+
`DialogComponents` and raised by hook, which is what keeps every one of them
|
|
264
|
+
identical:
|
|
265
|
+
|
|
266
|
+
```tsx
|
|
267
|
+
import { DialogComponents } from '@cratis/arc.react/dialogs';
|
|
268
|
+
import { BusyIndicatorDialog, ConfirmationDialog } from '@cratis/components/Dialogs';
|
|
269
|
+
|
|
270
|
+
<DialogComponents confirmation={ConfirmationDialog} busyIndicator={BusyIndicatorDialog}>
|
|
271
|
+
<YourApp />
|
|
272
|
+
</DialogComponents>
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
```tsx
|
|
276
|
+
import { DialogButtons, DialogResult, useBusyIndicator, useConfirmationDialog } from '@cratis/arc.react/dialogs';
|
|
277
|
+
|
|
278
|
+
const [confirm] = useConfirmationDialog();
|
|
279
|
+
if (await confirm('Delete this account?', `"${account.name}" disappears permanently.`, DialogButtons.YesNo) !== DialogResult.Yes) return;
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
A busy indicator is modal and deliberately non-dismissible, so reserve it for
|
|
283
|
+
work the user genuinely cannot proceed past — a multi-step import, a migration.
|
|
284
|
+
For an ordinary command behind a button, the in-flight disabled button is the
|
|
285
|
+
right control; a modal that flashes for 200 ms tells the user nothing. When you
|
|
286
|
+
do use one, pair it with the close call in a `finally`:
|
|
287
|
+
|
|
288
|
+
```tsx
|
|
289
|
+
const [showBusy, closeBusy] = useBusyIndicator('Importing', 'This takes a moment.');
|
|
290
|
+
showBusy();
|
|
291
|
+
try { await importEverything(); } finally { closeBusy(); }
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
## Initial focus
|
|
295
|
+
|
|
296
|
+
`DialogInitialFocus.Confirm` is the default and *arms* the confirm button — a
|
|
297
|
+
browser fires `click` from the `keydown` of Enter, so a held Enter confirms.
|
|
298
|
+
For a destructive dialog use `DialogInitialFocus.Cancel`, which focuses the
|
|
299
|
+
least destructive action and degrades to `Content` when the button set has
|
|
300
|
+
nothing to dismiss with. `DialogInitialFocus.Content` focuses the title so
|
|
301
|
+
nothing is armed. There is deliberately no "focus nothing" option — a modal
|
|
302
|
+
must move focus into itself.
|
|
@@ -30,30 +30,7 @@ Take the version from nuget.org, not the placeholder version in the source.
|
|
|
30
30
|
|
|
31
31
|
## Lifecycle
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
`EventStore.RegisterAll` subscribes to `Connection.Lifecycle.OnConnected`
|
|
35
|
-
when `autoDiscoverAndRegister` is on; reconnect re-registers artifacts.
|
|
36
|
-
- `DiscoverAll()` does event types first, then constraints, reactors, reducers,
|
|
37
|
-
projections and seeding in parallel; registration is single-flighted with
|
|
38
|
-
jittered backoff/background retry (`EventStore.cs`).
|
|
39
|
-
- **Wait with `WaitForRegistration`, not by polling `IsConnected`.**
|
|
40
|
-
`RegistrationWaitExtensions.WaitForRegistration(this IEventStore, TimeSpan? timeout = default)`
|
|
41
|
-
returns `RegistrationOutcome`, including failed runs; its default 5-second
|
|
42
|
-
timeout is for a run that never finished. Inspect `IsSuccess`, `Failure`,
|
|
43
|
-
`Failures` and `IdentityDrift`. It reports projection registrations, not
|
|
44
|
-
reactor/reducer subscription readiness (use `WaitTillSubscribed` / `WaitTillActive`).
|
|
45
|
-
Successful active projection registration includes observer subscription, not
|
|
46
|
-
read-your-writes: inspect the append's `WaitForCompletion` result or read a
|
|
47
|
-
passive model. Source: `Registrations/RegistrationOutcome.cs`.
|
|
48
|
-
- **Keepalive is a bidirectional stream plus a watchdog.** The watchdog monitors
|
|
49
|
-
every `MonitorIntervalMilliseconds = 1000`
|
|
50
|
-
(`Source/Clients/Connections/ConnectionWatchdog.cs`) and a keepalive that
|
|
51
|
-
falls more than 5 seconds behind is treated as a lost connection, with
|
|
52
|
-
reconnect backoff capped at 30 seconds. **The failure mode is silence, not an
|
|
53
|
-
exception** — appends keep working while observers go quiet.
|
|
54
|
-
- `Dispose()` disposes read model reactors for created stores, cancels the owned
|
|
55
|
-
connection, and disposes the connection
|
|
56
|
-
(`Source/Clients/DotNET/ChronicleClient.cs`, `Dispose`).
|
|
33
|
+
Read [references/lifecycle.md](references/lifecycle.md) when waiting for registration (`WaitForRegistration`, not polling `IsConnected`), diagnosing quiet observers (keepalive loss fails silently, not with an exception), or disposing the client.
|
|
57
34
|
|
|
58
35
|
## What a standalone app owns that a host would have supplied
|
|
59
36
|
|
|
@@ -115,63 +92,9 @@ client snippets compile in product CI. Prefer them to untested prose examples.
|
|
|
115
92
|
instead of retaining sample defaults. Read [client construction](references/client-construction.md)
|
|
116
93
|
when choosing the constructor or passing a real container/logger.
|
|
117
94
|
|
|
118
|
-
### Options
|
|
95
|
+
### Options and connection strings
|
|
119
96
|
|
|
120
|
-
`ChronicleOptions`
|
|
121
|
-
`FromConnectionString(string)`, `FromConnectionString(ChronicleConnectionString)`,
|
|
122
|
-
`FromDevelopmentConnectionString()`. The parameterless constructor uses the
|
|
123
|
-
development connection string.
|
|
124
|
-
|
|
125
|
-
Options worth knowing: `AutoDiscoverAndRegister` (default `true`),
|
|
126
|
-
`ConnectTimeout` (5 seconds), `SkipKeepAlive` (short-lived clients),
|
|
127
|
-
`DefaultSinkTypeId` (`WellKnownSinkTypes.MongoDB`), `Tls`, `Authentication`,
|
|
128
|
-
`RegistrationRetry`, `SkipCompatibilityCheck`, `ArtifactIdentityDrift` (`Warn`),
|
|
129
|
-
`UnitOfWorkLifecyclePolicy` (`Compatibility`; `Strict` opts in to completion
|
|
130
|
-
checks), `EventGenerationDelivery`, `ExplicitArtifacts`, `ConcurrencyOptions`,
|
|
131
|
-
`ClaimsBasedNamespaceResolverClaimType` (`tenant_id`), and
|
|
132
|
-
`MaxReceiveMessageSize` / `MaxSendMessageSize` (100 MB each).
|
|
133
|
-
`EnableEventTypeGenerationValidation` opts into strict migration-chain checking
|
|
134
|
-
on development kernels; production always enforces it.
|
|
135
|
-
|
|
136
|
-
### Connection strings, not URLs
|
|
137
|
-
|
|
138
|
-
**There is no `ChronicleUrl` type and no microservice id.** The identity of a
|
|
139
|
-
connection is a connection string plus an event store name and optionally a
|
|
140
|
-
namespace. `ChronicleConnectionString` lives in `Cratis.Chronicle.Connections`
|
|
141
|
-
(`Source/Clients/Connections/ChronicleConnectionString.cs`):
|
|
142
|
-
|
|
143
|
-
```
|
|
144
|
-
chronicle://host[:port]/?opts
|
|
145
|
-
chronicle://user:pass@host[:port]/?opts
|
|
146
|
-
chronicle+srv://host/?opts
|
|
147
|
-
```
|
|
148
|
-
|
|
149
|
-
Default port `35000`. `Default` is `chronicle://localhost:35000`;
|
|
150
|
-
`Development` adds the `chronicle-dev-client` / `chronicle-dev-secret`
|
|
151
|
-
credentials. Query options: `apiKey`, `auth`, `skipTlsValidation`,
|
|
152
|
-
`skipCompatibilityCheck`, `loadBalancer`, `srvNameServer`, `certificatePath`,
|
|
153
|
-
`certificatePassword` (`ChronicleConnectionStringBuilder.cs`). There is an
|
|
154
|
-
implicit conversion from `string` and a `Redacted` form for logging.
|
|
155
|
-
|
|
156
|
-
With ClientCredentials auth and **both** username and password absent, the .NET
|
|
157
|
-
client also falls back to these development credentials, including through
|
|
158
|
-
`AddCratisChronicleConnection`. Only a `DEVELOPMENT`-compiled kernel creates the
|
|
159
|
-
application, directly in persistent storage. Switching that storage to a
|
|
160
|
-
production image does not remove it: remove the development application and any
|
|
161
|
-
configuration declaration that would recreate it. Do not infer other clients'
|
|
162
|
-
authentication behavior from this one. Source:
|
|
163
|
-
`Source/Clients/DotNET/ChronicleClient.cs`,
|
|
164
|
-
`Source/Clients/Connections/ServiceCollectionExtensions.cs`, and
|
|
165
|
-
`Source/Kernel/Core/Setup/Authentication/AuthenticationService.cs`.
|
|
166
|
-
Read [host wiring](references/hosting.md) for the deployment distinction.
|
|
167
|
-
|
|
168
|
-
> **Certificate validation is skipped by default, and that is deliberate.** The
|
|
169
|
-
> development Chronicle images (`latest-development` and `latest-development-slim`)
|
|
170
|
-
> generate a self-signed certificate on every start, so a development pair
|
|
171
|
-
> connects with no setup. The production image does not: it refuses to start with
|
|
172
|
-
> TLS enabled (the default) and no configured certificate. **A production connection string must set
|
|
173
|
-
> `skipTlsValidation=false`** (or `Tls.SkipCertificateValidation = false`)
|
|
174
|
-
> against a server whose certificate is actually verifiable.
|
|
97
|
+
Read [references/connection-options.md](references/connection-options.md) when setting `ChronicleOptions`, writing a connection string or choosing credentials. A production connection string must set `skipTlsValidation=false`; there is no `ChronicleUrl` type.
|
|
175
98
|
|
|
176
99
|
### In a host
|
|
177
100
|
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# Options and connection strings
|
|
2
|
+
|
|
3
|
+
This reference holds `ChronicleOptions`, connection string forms and parameters, development credential fallback and certificate validation.
|
|
4
|
+
|
|
5
|
+
### Options
|
|
6
|
+
|
|
7
|
+
`ChronicleOptions` — `Source/Clients/DotNET/ChronicleOptions.cs`. Statics:
|
|
8
|
+
`FromConnectionString(string)`, `FromConnectionString(ChronicleConnectionString)`,
|
|
9
|
+
`FromDevelopmentConnectionString()`. The parameterless constructor uses the
|
|
10
|
+
development connection string.
|
|
11
|
+
|
|
12
|
+
Options worth knowing: `AutoDiscoverAndRegister` (default `true`),
|
|
13
|
+
`ConnectTimeout` (5 seconds), `SkipKeepAlive` (short-lived clients),
|
|
14
|
+
`DefaultSinkTypeId` (`WellKnownSinkTypes.MongoDB`), `Tls`, `Authentication`,
|
|
15
|
+
`RegistrationRetry`, `SkipCompatibilityCheck`, `ArtifactIdentityDrift` (`Warn`),
|
|
16
|
+
`UnitOfWorkLifecyclePolicy` (`Compatibility`; `Strict` opts in to completion
|
|
17
|
+
checks), `EventGenerationDelivery`, `ExplicitArtifacts`, `ConcurrencyOptions`,
|
|
18
|
+
`ClaimsBasedNamespaceResolverClaimType` (`tenant_id`), and
|
|
19
|
+
`MaxReceiveMessageSize` / `MaxSendMessageSize` (100 MB each).
|
|
20
|
+
`EnableEventTypeGenerationValidation` opts into strict migration-chain checking
|
|
21
|
+
on development kernels; production always enforces it.
|
|
22
|
+
|
|
23
|
+
### Connection strings, not URLs
|
|
24
|
+
|
|
25
|
+
**There is no `ChronicleUrl` type and no microservice id.** The identity of a
|
|
26
|
+
connection is a connection string plus an event store name and optionally a
|
|
27
|
+
namespace. `ChronicleConnectionString` lives in `Cratis.Chronicle.Connections`
|
|
28
|
+
(`Source/Clients/Connections/ChronicleConnectionString.cs`):
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
chronicle://host[:port]/?opts
|
|
32
|
+
chronicle://user:pass@host[:port]/?opts
|
|
33
|
+
chronicle+srv://host/?opts
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Default port `35000`. `Default` is `chronicle://localhost:35000`;
|
|
37
|
+
`Development` adds the `chronicle-dev-client` / `chronicle-dev-secret`
|
|
38
|
+
credentials. Query options: `apiKey`, `auth`, `skipTlsValidation`,
|
|
39
|
+
`skipCompatibilityCheck`, `loadBalancer`, `srvNameServer`, `certificatePath`,
|
|
40
|
+
`certificatePassword` (`ChronicleConnectionStringBuilder.cs`). There is an
|
|
41
|
+
implicit conversion from `string` and a `Redacted` form for logging.
|
|
42
|
+
|
|
43
|
+
With ClientCredentials auth and **both** username and password absent, the .NET
|
|
44
|
+
client also falls back to these development credentials, including through
|
|
45
|
+
`AddCratisChronicleConnection`. Only a `DEVELOPMENT`-compiled kernel creates the
|
|
46
|
+
application, directly in persistent storage. Switching that storage to a
|
|
47
|
+
production image does not remove it: remove the development application and any
|
|
48
|
+
configuration declaration that would recreate it. Do not infer other clients'
|
|
49
|
+
authentication behavior from this one. Source:
|
|
50
|
+
`Source/Clients/DotNET/ChronicleClient.cs`,
|
|
51
|
+
`Source/Clients/Connections/ServiceCollectionExtensions.cs`, and
|
|
52
|
+
`Source/Kernel/Core/Setup/Authentication/AuthenticationService.cs`.
|
|
53
|
+
Read [host wiring](hosting.md) for the deployment distinction.
|
|
54
|
+
|
|
55
|
+
> **Certificate validation is skipped by default, and that is deliberate.** The
|
|
56
|
+
> development Chronicle images (`latest-development` and `latest-development-slim`)
|
|
57
|
+
> generate a self-signed certificate on every start, so a development pair
|
|
58
|
+
> connects with no setup. The production image does not: it refuses to start with
|
|
59
|
+
> TLS enabled (the default) and no configured certificate. **A production connection string must set
|
|
60
|
+
> `skipTlsValidation=false`** (or `Tls.SkipCertificateValidation = false`)
|
|
61
|
+
> against a server whose certificate is actually verifiable.
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Connection lifecycle
|
|
2
|
+
|
|
3
|
+
This reference holds registration wiring, the registration wait, keepalive and watchdog behavior, and disposal.
|
|
4
|
+
|
|
5
|
+
## Lifecycle
|
|
6
|
+
|
|
7
|
+
- **Registration is wired to the connection, not called by you.**
|
|
8
|
+
`EventStore.RegisterAll` subscribes to `Connection.Lifecycle.OnConnected`
|
|
9
|
+
when `autoDiscoverAndRegister` is on; reconnect re-registers artifacts.
|
|
10
|
+
- `DiscoverAll()` does event types first, then constraints, reactors, reducers,
|
|
11
|
+
projections and seeding in parallel; registration is single-flighted with
|
|
12
|
+
jittered backoff/background retry (`EventStore.cs`).
|
|
13
|
+
- **Wait with `WaitForRegistration`, not by polling `IsConnected`.**
|
|
14
|
+
`RegistrationWaitExtensions.WaitForRegistration(this IEventStore, TimeSpan? timeout = default)`
|
|
15
|
+
returns `RegistrationOutcome`, including failed runs; its default 5-second
|
|
16
|
+
timeout is for a run that never finished. Inspect `IsSuccess`, `Failure`,
|
|
17
|
+
`Failures` and `IdentityDrift`. It reports projection registrations, not
|
|
18
|
+
reactor/reducer subscription readiness (use `WaitTillSubscribed` / `WaitTillActive`).
|
|
19
|
+
Successful active projection registration includes observer subscription, not
|
|
20
|
+
read-your-writes: inspect the append's `WaitForCompletion` result or read a
|
|
21
|
+
passive model. Source: `Registrations/RegistrationOutcome.cs`.
|
|
22
|
+
- **Keepalive is a bidirectional stream plus a watchdog.** The watchdog monitors
|
|
23
|
+
every `MonitorIntervalMilliseconds = 1000`
|
|
24
|
+
(`Source/Clients/Connections/ConnectionWatchdog.cs`) and a keepalive that
|
|
25
|
+
falls more than 5 seconds behind is treated as a lost connection, with
|
|
26
|
+
reconnect backoff capped at 30 seconds. **The failure mode is silence, not an
|
|
27
|
+
exception** — appends keep working while observers go quiet.
|
|
28
|
+
- `Dispose()` disposes read model reactors for created stores, cancels the owned
|
|
29
|
+
connection, and disposes the connection
|
|
30
|
+
(`Source/Clients/DotNET/ChronicleClient.cs`, `Dispose`).
|
|
@@ -19,12 +19,7 @@ Source: `Cratis/Chronicle.Elixir` (Hex package `cratis_chronicle`). Source paths
|
|
|
19
19
|
|
|
20
20
|
Read [references/upgrading.md](references/upgrading.md) when moving an application from an older client; wire compatibility and corrected behavior both matter.
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
| --- | --- | --- |
|
|
24
|
-
| OTP app / Hex package | `:cratis_chronicle` | `Source/chronicle/mix.exs` |
|
|
25
|
-
| Published versions | Select the intended release from hex.pm; not every git tag is published to Hex | hex.pm |
|
|
26
|
-
| Elixir requirement | `~> 1.18` | `Source/chronicle/mix.exs` |
|
|
27
|
-
| Contracts dependency | `cratis_chronicle_contracts` as resolved in `mix.lock`; pair it with a compatible kernel | `Source/chronicle/mix.lock` |
|
|
22
|
+
Requires Elixir `~> 1.18`. Read [references/product-sources.md](references/product-sources.md) for the package and contracts dependency facts.
|
|
28
23
|
|
|
29
24
|
> **A git tag is not a Hex release.** `mix deps.get` fetches only published versions. The `Chronicle.Concept` macro
|
|
30
25
|
> (`use Chronicle.Concept, type: :string`, a single-value concept that carries its
|
|
@@ -80,45 +75,9 @@ defmodule MyApp.Application do
|
|
|
80
75
|
end
|
|
81
76
|
```
|
|
82
77
|
|
|
83
|
-
### Options
|
|
78
|
+
### Options, supervision and multiple clients
|
|
84
79
|
|
|
85
|
-
|
|
86
|
-
your app must read its own configuration and pass it in (`lib/chronicle/client.ex`).
|
|
87
|
-
|
|
88
|
-
| Option | Default |
|
|
89
|
-
| --- | --- |
|
|
90
|
-
| `:name` | `Chronicle.Client` |
|
|
91
|
-
| `:connection_string` | `ConnectionString.default/0` |
|
|
92
|
-
| `:event_store` | `"default"` |
|
|
93
|
-
| `:namespace` | `"Default"` — capital D |
|
|
94
|
-
| `:discover` | `true` |
|
|
95
|
-
| `:otp_app` | none; falls back to scanning loaded modules |
|
|
96
|
-
| `:event_types`, `:event_sources`, `:migrations`, `:reactors`, `:reducers`, `:read_models`, `:projections`, `:seeders`, `:webhooks`, `:event_store_subscriptions`, `:global_handlers` | `[]`, merged with discovered |
|
|
97
|
-
| `:default_sink_type_id` | `:mongodb`; accepts `:mongodb`, `:sql`, `:in_memory`, `:none` or a raw string |
|
|
98
|
-
| `:server_address` | alternative `"host:port"` address (connection option) |
|
|
99
|
-
| `:skip_tls_validation`, `:load_balancer`, `:grpc_options`, `:reconnect_base_delay`, `:reconnect_max_delay` | forwarded to the connection | — |
|
|
100
|
-
| `:retry_attempts` | accepted for compatibility, **ignored** |
|
|
101
|
-
|
|
102
|
-
> The moduledoc in `client.ex` says the namespace defaults to `"default"`.
|
|
103
|
-
> The code uses `"Default"`. **Trust the code.**
|
|
104
|
-
|
|
105
|
-
**Set `:otp_app`.** With it, discovery is scoped to your application's modules;
|
|
106
|
-
without it the client falls back to scanning every loaded module.
|
|
107
|
-
|
|
108
|
-
Configuration is stashed in `:persistent_term` and read back with
|
|
109
|
-
`Chronicle.Client.config/1` (`client.ex`). Its subset includes `event_sources`,
|
|
110
|
-
but not `read_models`, `projections`, or `migrations`.
|
|
111
|
-
|
|
112
|
-
### The supervision tree
|
|
113
|
-
|
|
114
|
-
`Supervisor.init(children, strategy: :rest_for_one)` — `client.ex`.
|
|
115
|
-
The lifecycle hub is the root dependency; restarting it restarts its subscribers.
|
|
116
|
-
The connection, session and registration precede observers.
|
|
117
|
-
|
|
118
|
-
### Multiple clients
|
|
119
|
-
|
|
120
|
-
Pass `name:` to `Chronicle.Client` and `client:` to every API call. Every public
|
|
121
|
-
function takes a `:client` option.
|
|
80
|
+
Read [references/client-options.md](references/client-options.md) when setting `Chronicle.Client` options (set `:otp_app`), its supervision tree, or multiple clients.
|
|
122
81
|
|
|
123
82
|
## Connecting is asynchronous — wait for the lifecycle
|
|
124
83
|
|
|
@@ -263,21 +222,7 @@ failure. Source/stream options apply to buffered appends too.
|
|
|
263
222
|
|
|
264
223
|
### Reactors
|
|
265
224
|
|
|
266
|
-
|
|
267
|
-
defmodule MyApp.Reactors.DepositLogger do
|
|
268
|
-
use Chronicle.Reactors.Reactor
|
|
269
|
-
require Logger
|
|
270
|
-
|
|
271
|
-
alias MyApp.Events.FundsDeposited
|
|
272
|
-
@handles FundsDeposited
|
|
273
|
-
|
|
274
|
-
@impl true
|
|
275
|
-
def handle(%FundsDeposited{}, %{sequence_number: number}) do
|
|
276
|
-
Logger.info("Deposit observed", sequence_number: number)
|
|
277
|
-
:ok
|
|
278
|
-
end
|
|
279
|
-
end
|
|
280
|
-
```
|
|
225
|
+
Read [references/reactor-example.md](references/reactor-example.md) when you need a worked reactor module.
|
|
281
226
|
|
|
282
227
|
This follows `Documentation/client-snippets/get-started/common/reactor.md`.
|
|
283
228
|
|
|
@@ -304,17 +249,7 @@ but **it is not in the map**. Reducer context differs: `event_source_id`,
|
|
|
304
249
|
|
|
305
250
|
### Read models and projections
|
|
306
251
|
|
|
307
|
-
|
|
308
|
-
defmodule MyApp.ReadModels.AccountBalance do
|
|
309
|
-
use Chronicle.ReadModels.ReadModel
|
|
310
|
-
defstruct id: "", balance: 0
|
|
311
|
-
|
|
312
|
-
from(MyApp.Events.FundsDeposited,
|
|
313
|
-
set: [id: :event_source_id],
|
|
314
|
-
add: [balance: :amount]
|
|
315
|
-
)
|
|
316
|
-
end
|
|
317
|
-
```
|
|
252
|
+
Read [references/reactor-example.md](references/reactor-example.md#read-model-example) for a worked model-bound read model.
|
|
318
253
|
|
|
319
254
|
This is the model-bound shape; use typed defaults for its registered schema.
|
|
320
255
|
|
|
@@ -364,37 +299,9 @@ registered definitions.
|
|
|
364
299
|
`{:chronicle_read_model_changed, module, %Changeset{}}` and
|
|
365
300
|
`{:chronicle_read_model_watch_error, module, reason}` to the calling process. The receiving process needs a `handle_info` for both.
|
|
366
301
|
|
|
367
|
-
##
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
orphaned observer across the store, refuses running/subscribed observers in any
|
|
371
|
-
namespace, and leaves read model data intact (`observers.ex`). Obtain
|
|
372
|
-
explicit authority before removal and inspect `RemovalResult.outcome` —
|
|
373
|
-
`{:ok, result}` alone does not mean removed. `Chronicle.FailedPartitions` and
|
|
374
|
-
`Chronicle.Jobs` provide failure/job inspection; `Jobs.get/2` lists then finds
|
|
375
|
-
client-side. Observer types include `:reactor`, `:projection`, `:reducer`,
|
|
376
|
-
`:external`; states include `:active`, `:suspended`, `:replaying`, `:disconnected`,
|
|
377
|
-
`:quarantined` and `:unknown`.
|
|
378
|
-
|
|
379
|
-
## Idioms worth knowing
|
|
380
|
-
|
|
381
|
-
- **Process-scoped context.** Correlation id, identity, and causation are held per
|
|
382
|
-
process: `Chronicle.current_correlation_id/0`, `set_correlation_id/1`,
|
|
383
|
-
`clear_correlation_id/0`; `current_identity/0`, `set_identity/1`,
|
|
384
|
-
`clear_identity/0`; `Chronicle.Auditing.CausationManager`. They are picked up
|
|
385
|
-
automatically on append. **A `Task` is a different process** and does not
|
|
386
|
-
inherit them.
|
|
387
|
-
- **Discovery is compile-time reflection.** The `use` macros generate
|
|
388
|
-
`__chronicle_*__/1` functions via `__before_compile__`, and discovery is
|
|
389
|
-
`function_exported?/3` over the application's modules — not runtime scanning.
|
|
390
|
-
- **No client-owned telemetry events.** `telemetry` is a direct dependency;
|
|
391
|
-
transport failure detection subscribes to grpc events. Logging is `Logger`.
|
|
392
|
-
- **No formatter export.** `.formatter.exs` declares no `locals_without_parens`
|
|
393
|
-
for `from`, `join`, `removed_with`, `from_every`, `pii`, `subject`, `unique`, or
|
|
394
|
-
`unique_event_type`, and there is no `import_deps: [:cratis_chronicle]` to
|
|
395
|
-
inherit. `mix format` will add parentheses to the DSL.
|
|
396
|
-
- **`ReadModels.watch/2` is unsupervised.** It uses `Task.start/1` and `unwatch/1`
|
|
397
|
-
is a raw `Process.exit(pid, :shutdown)`. Supervise it yourself if it matters.
|
|
302
|
+
## Idioms and operational inspection
|
|
303
|
+
|
|
304
|
+
Read [references/idioms-and-inspection.md](references/idioms-and-inspection.md) when carrying correlation or identity across a `Task`, formatting the DSL, supervising `ReadModels.watch/2`, or removing observers (obtain explicit authority first).
|
|
398
305
|
|
|
399
306
|
## Common pitfalls
|
|
400
307
|
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# Client options and supervision
|
|
2
|
+
|
|
3
|
+
This reference holds the `Chronicle.Client` child-spec options, its supervision tree and the multiple-client rule.
|
|
4
|
+
|
|
5
|
+
### Options
|
|
6
|
+
|
|
7
|
+
Pass **child-spec keyword options**. The client reads no application env;
|
|
8
|
+
your app must read its own configuration and pass it in (`lib/chronicle/client.ex`).
|
|
9
|
+
|
|
10
|
+
| Option | Default |
|
|
11
|
+
| --- | --- |
|
|
12
|
+
| `:name` | `Chronicle.Client` |
|
|
13
|
+
| `:connection_string` | `ConnectionString.default/0` |
|
|
14
|
+
| `:event_store` | `"default"` |
|
|
15
|
+
| `:namespace` | `"Default"` — capital D |
|
|
16
|
+
| `:discover` | `true` |
|
|
17
|
+
| `:otp_app` | none; falls back to scanning loaded modules |
|
|
18
|
+
| `:event_types`, `:event_sources`, `:migrations`, `:reactors`, `:reducers`, `:read_models`, `:projections`, `:seeders`, `:webhooks`, `:event_store_subscriptions`, `:global_handlers` | `[]`, merged with discovered |
|
|
19
|
+
| `:default_sink_type_id` | `:mongodb`; accepts `:mongodb`, `:sql`, `:in_memory`, `:none` or a raw string |
|
|
20
|
+
| `:server_address` | alternative `"host:port"` address (connection option) |
|
|
21
|
+
| `:skip_tls_validation`, `:load_balancer`, `:grpc_options`, `:reconnect_base_delay`, `:reconnect_max_delay` | forwarded to the connection | — |
|
|
22
|
+
| `:retry_attempts` | accepted for compatibility, **ignored** |
|
|
23
|
+
|
|
24
|
+
> The moduledoc in `client.ex` says the namespace defaults to `"default"`.
|
|
25
|
+
> The code uses `"Default"`. **Trust the code.**
|
|
26
|
+
|
|
27
|
+
**Set `:otp_app`.** With it, discovery is scoped to your application's modules;
|
|
28
|
+
without it the client falls back to scanning every loaded module.
|
|
29
|
+
|
|
30
|
+
Configuration is stashed in `:persistent_term` and read back with
|
|
31
|
+
`Chronicle.Client.config/1` (`client.ex`). Its subset includes `event_sources`,
|
|
32
|
+
but not `read_models`, `projections`, or `migrations`.
|
|
33
|
+
|
|
34
|
+
### The supervision tree
|
|
35
|
+
|
|
36
|
+
`Supervisor.init(children, strategy: :rest_for_one)` — `client.ex`.
|
|
37
|
+
The lifecycle hub is the root dependency; restarting it restarts its subscribers.
|
|
38
|
+
The connection, session and registration precede observers.
|
|
39
|
+
|
|
40
|
+
### Multiple clients
|
|
41
|
+
|
|
42
|
+
Pass `name:` to `Chronicle.Client` and `client:` to every API call. Every public
|
|
43
|
+
function takes a `:client` option.
|