@cratis/pi 8.12.0 → 8.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package/corpus/skills/cratis-arc-localize-application/SKILL.md +50 -0
- package/package/corpus/skills/cratis-arc-localize-application/references/csharp.md +52 -0
- package/package/corpus/skills/cratis-arc-localize-application/references/go.md +44 -0
- package/package/corpus/skills/cratis-arc-localize-application/references/typescript-switcher.md +59 -0
- package/package/corpus/skills/cratis-arc-localize-application/references/typescript-tooling.md +82 -0
- package/package/corpus/skills/cratis-arc-localize-application/references/typescript.md +151 -0
- package/package/corpus/skills/cratis-arc-react-bind-slice/SKILL.md +1 -1
- package/package/corpus/skills/cratis-arc-react-bind-slice/references/typescript-localization.md +2 -0
- package/package/corpus/skills/cratis-code-review/SKILL.md +1 -1
- package/package/corpus/skills/cratis-components-diagnose-screen/SKILL.md +1 -1
- package/package/corpus/skills/cratis-components-theme-application/SKILL.md +5 -2
- package/package/corpus/skills/cratis-components-theme-application/references/localization.md +1 -0
- package/package/corpus/skills/cratis-migrate-arc-22-to-23/SKILL.md +59 -0
- package/package/corpus/skills/cratis-migrate-arc-22-to-23/references/csharp.md +121 -0
- package/package/corpus/skills/cratis-migrate-arc-23-to-24/SKILL.md +60 -0
- package/package/corpus/skills/cratis-migrate-arc-23-to-24/references/csharp.md +91 -0
- package/package/corpus/skills/cratis-migrate-arc-23-to-24/references/typescript.md +26 -0
- package/package/corpus/skills/cratis-migrate-components-3-to-4/SKILL.md +72 -0
- package/package/corpus/skills/cratis-migrate-components-3-to-4/references/typescript.md +137 -0
- package/package/corpus/skills/cratis-platform-upgrade-application/SKILL.md +2 -2
- package/package/corpus/skills/cratis-platform-upgrade-application/references/typescript.md +1 -1
- package/package/profile-catalog.json +113 -0
- package/package.json +1 -1
- package/package/corpus/skills/cratis-components-theme-application/references/upgrade-from-previous-major.md +0 -141
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
# Arc 22 to Arc 23 in a C# application
|
|
2
|
+
|
|
3
|
+
## Contents
|
|
4
|
+
|
|
5
|
+
- Pin the mode
|
|
6
|
+
- Adopt read protection
|
|
7
|
+
- Generated key metadata
|
|
8
|
+
- Composite key accessors
|
|
9
|
+
- Command specs
|
|
10
|
+
- MCP host
|
|
11
|
+
- Obsolete names
|
|
12
|
+
- Recovery
|
|
13
|
+
|
|
14
|
+
## Pin the mode
|
|
15
|
+
|
|
16
|
+
Prerequisite: the inventory from the skill is done and the packages are on the latest Arc 23 release, except for "Pin the mode", which is done on Arc 22.
|
|
17
|
+
|
|
18
|
+
Set the mode in the project file, or in a `Directory.Build.props` that covers the project:
|
|
19
|
+
|
|
20
|
+
```xml
|
|
21
|
+
<PropertyGroup>
|
|
22
|
+
<CratisReadProtection>Off</CratisReadProtection>
|
|
23
|
+
</PropertyGroup>
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
The value is `Off`, `Measure` or `On`; any other value fails the build. It applies to the commands declared in that project. A declaration on the command wins over the project: `[ReadProtection(ReadProtectionMode.Off)]`, `[ReadProtection(ReadProtectionMode.On)]`, or `[Unprotected("why")]`, which means `Off` for that command.
|
|
27
|
+
|
|
28
|
+
## Adopt read protection
|
|
29
|
+
|
|
30
|
+
Under `On`, Arc reads each supported read-model parameter fresh from its events, guards the append against what the command read, and refuses reads it cannot guard. A guarded read costs more for a key with a long history, because it folds that history instead of returning stored state.
|
|
31
|
+
|
|
32
|
+
1. Set `<CratisReadProtection>Measure</CratisReadProtection>` and run the specs and the application. `Measure` changes no outcome; it records what `On` would do.
|
|
33
|
+
2. Read the counter `cratis.arc.read_protection.events` on the meter `Cratis.Arc.ReadProtection`, grouped by its `category` and `command` tags. The same data appears as Warning log entries and as `read-protection.plan` span events.
|
|
34
|
+
3. Fix each category that needs it:
|
|
35
|
+
|
|
36
|
+
| Category | Fix |
|
|
37
|
+
| --- | --- |
|
|
38
|
+
| `refused_read` | The `reason` tag names the cause. Change the model to a shape that can be guarded (a flat projection keyed by the event source, or a reducer without an event filter or constructor dependencies), take the model as a parameter instead of calling `IReadModels`, or declare the read advisory |
|
|
39
|
+
| `redirect` | `On` would select a different key. Add `[LookUpBy(nameof(Command.Property))]` to the parameter |
|
|
40
|
+
| `immediate_append` | Return the event from `Handle()` instead of appending through `IEventLog` |
|
|
41
|
+
| `scope_refusal`, `displacement` | Widen or remove the explicit concurrency scope beside the read |
|
|
42
|
+
|
|
43
|
+
A read that may be stale is declared with `[Unprotected("why")]` on the parameter, the read-model type, or the `Handle()` or `Provide()` method whose body reads. Write the real reason; it is reported.
|
|
44
|
+
|
|
45
|
+
4. Build and clear the warnings ARCCHR0024 (shape cannot be protected), ARCCHR0028 (read not proven protected) and ARCCHR0033 (aggregate and read model on the same key).
|
|
46
|
+
5. Remove the property so the project takes `On`, and run the specs.
|
|
47
|
+
|
|
48
|
+
Under `On`, a required read-model parameter whose instance does not exist fails the command with a validation result (reason `rule`, message `{ReadModel} does not exist.`, HTTP 400). A nullable parameter receives `null`. A validator must be registered by convention discovery; one that Arc did not construct for the command is refused under `On`.
|
|
49
|
+
|
|
50
|
+
Startup checks the declared parameter shapes after the application has started and stops the host on a refusal under `On`. `ReadProtection:StartupAdmissionCheck` set to `Log` reports without stopping. To back out in production without a build, set `ReadProtection:MaximumMode` to `Measure` or `Off`; it only lowers the mode and is logged per command at startup. Both keys are also read under `Cratis:Arc:ReadProtection`.
|
|
51
|
+
|
|
52
|
+
## Generated key metadata
|
|
53
|
+
|
|
54
|
+
`CommandReadModelKeysMissing` names a command or read-model type for which the Arc source generator emitted no key metadata. At startup Arc checks every command whose mode is `On`, whether or not it takes a read model. The generator ships in the Arc packages as an analyzer, runs in the project that declares the type, and reaches a project through project references too. Check, in this order:
|
|
55
|
+
|
|
56
|
+
1. The named command is a non-partial, accessible type declared in the application's own project. The generator skips partial types, private and file-local types, generic definitions, types with a base type from another assembly, and commands with a public property whose getter is obsolete or experimental or whose type is inaccessible. The informational diagnostic ARC0031 marks each skipped command; raise its severity in `.editorconfig` to see it in the build output.
|
|
57
|
+
2. No package or project reference on the path to the Arc packages removes `analyzers` through `ExcludeAssets`, `IncludeAssets` or `PrivateAssets`.
|
|
58
|
+
3. The assembly is not marked with `System.Diagnostics.CodeAnalysis.ExperimentalAttribute`; the generator skips such an assembly.
|
|
59
|
+
|
|
60
|
+
Done when the host starts and the command runs. Only if the type must keep a skipped shape, keep the reflection lookup by setting `ReadProtection:RequireGeneratedMetadata` to `false` in configuration. Arc then logs one warning per type. The opt-out has no effect on a runtime without dynamic code, such as Native AOT.
|
|
61
|
+
|
|
62
|
+
## Composite key accessors
|
|
63
|
+
|
|
64
|
+
`ProtectedReadModelKeyAccessorMissing` names a key type made of several parts for which no accessors exist. The generator covers types it can see completely. The informational diagnostic ARC0030 marks the ones it cannot: partial types, types or base types from another assembly, and types with hidden or overridden members. Register those before the host is built, with every public readable instance property, inherited ones included:
|
|
65
|
+
|
|
66
|
+
```csharp
|
|
67
|
+
using Cratis.Arc.Chronicle.ReadModels;
|
|
68
|
+
|
|
69
|
+
ProtectedReadModelKeyAccessors.Register<WarehouseKey>(
|
|
70
|
+
new(nameof(WarehouseKey.Warehouse), key => key.Warehouse),
|
|
71
|
+
new(nameof(WarehouseKey.Section), key => key.Section));
|
|
72
|
+
|
|
73
|
+
public partial record WarehouseKey(string Warehouse, string Section);
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Register each concrete derived type separately. Registering a type twice throws `ProtectedReadModelKeyAccessorsAlreadyRegistered`. Done when the command that uses the key runs.
|
|
77
|
+
|
|
78
|
+
Only on a runtime that supports dynamic code can `Strict = false` restore the reflection fallback; under Native AOT, register the accessors. Use the fallback only when a key type cannot be registered; a property left out of a registration weakens the check, and so does the fallback:
|
|
79
|
+
|
|
80
|
+
```csharp
|
|
81
|
+
builder.Services.Configure<ProtectedReadModelKeyOptions>(options => options.Strict = false);
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Command specs
|
|
85
|
+
|
|
86
|
+
Replace state arranged through a replaced or substituted `IReadModels` with the command scenario's own `Given`:
|
|
87
|
+
|
|
88
|
+
```csharp
|
|
89
|
+
_scenario.Given.ForEventSource(id).ReadModel(instance);
|
|
90
|
+
_scenario.Given.ForEventSource(id).Events(new MoneyDeposited(100m));
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Use `ReadModel` when the case needs a known value and `Events` when the history matters. A plain `new CommandScenario<TCommand>()` selects the right log from the command's mode; an untyped `CommandScenario<object>` calls `EnableDecisionReads()`. Done when the spec passes without a replacement reader.
|
|
94
|
+
|
|
95
|
+
## MCP host
|
|
96
|
+
|
|
97
|
+
| Arc 22 | Arc 23 |
|
|
98
|
+
| --- | --- |
|
|
99
|
+
| `app.MapCratisArcMcp()` | `app.MapArcMcp()` |
|
|
100
|
+
| `ExposeQuery("Namespace.ReadModel.Method", name, description)` | `ExposeQuery<ReadModel>(nameof(ReadModel.Method), name, description)`, which throws `ArgumentException` when the read model has no such method, or `[ExposeOverMcp]` on the query |
|
|
101
|
+
| `McpToolCeiling` | `McpToolCatalog`, same members |
|
|
102
|
+
| `catch (McpRequiresGatedEndpoints)` | Remove; the type no longer exists |
|
|
103
|
+
|
|
104
|
+
The old `MapCratisArcMcp` and string `ExposeQuery` still work and only warn.
|
|
105
|
+
|
|
106
|
+
Arc 22 required `CapabilitiesOptions.GatedEndpoints` for MCP, so the host has a selection. Keep it and nothing changes: `WithMcp` adds the MCP endpoint to it. Remove it only if every route on the capabilities port may require a verified caller. With no selection, the whole port is gated and only the OAuth protected resource metadata route answers without one, so a health probe on that port starts returning 401. Move such a route to another port, or keep the selection.
|
|
107
|
+
|
|
108
|
+
## Obsolete names
|
|
109
|
+
|
|
110
|
+
| Obsolete | Use |
|
|
111
|
+
| --- | --- |
|
|
112
|
+
| `TenancyOptions.DevelopmentTenantId` | `TenancyOptions.FixedTenantId`, key `Cratis:Arc:Tenancy:FixedTenantId` |
|
|
113
|
+
| `IntrospectionOptions.TrustForwardedIdentityHeaders` | `ArcOptions.TrustForwardedIdentityHeaders`, key `Cratis:Arc:TrustForwardedIdentityHeaders`, which applies to every request |
|
|
114
|
+
| `Microsoft.Extensions.Hosting.HostBuilderExtensions.DefaultArcSectionPaths` | `Cratis.Arc.HostBuilderExtensions.DefaultSectionPaths` |
|
|
115
|
+
|
|
116
|
+
## Recovery
|
|
117
|
+
|
|
118
|
+
- A command is refused and the cause is unclear: set that project back to `Measure` and read the `reason` tag of its `refused_read` entries.
|
|
119
|
+
- Header tenancy resolves no tenant: make the ingress remove every incoming tenant header and set exactly one value. A tenant identifier that contains a comma cannot be sent in the header.
|
|
120
|
+
- Server-sent-event subscriptions return 404 for signed-in callers: issue a name identifier, subject or name claim to the principal.
|
|
121
|
+
- A form shows a message twice: remove the application's own summary, or pass `validationSummaryComponent={() => null}` to `CommandForm`.
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: cratis-migrate-arc-23-to-24
|
|
3
|
+
description: Use when upgrading a C# application, with or without a TypeScript frontend, from Cratis Arc 23 to Arc 24, including a build that no longer finds the `Cratis.Choreography.Availability` namespace or reports obsolete `[AvailableFor("...")]` and `[AvailableWith("...")]` after raising `Cratis.Arc.*`, and a client that reads `key` or `conflictingEvent...` from a refused command. Not for other Arc majors, new applications (`cratis-platform-start-application`) or the general upgrade loop of versions, kernel order and deployment (`cratis-platform-upgrade-application`).
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Move an application from Arc 23 to Arc 24
|
|
7
|
+
|
|
8
|
+
Temporary guidance for one upgrade. Reinstall the AI corpus without this profile once the upgrade is merged. Run it inside the loop of `cratis-platform-upgrade-application`, which owns version pairing, kernel order and deployment.
|
|
9
|
+
|
|
10
|
+
## What changed
|
|
11
|
+
|
|
12
|
+
Moving to the latest Arc 24 release brings two groups of changes that can break an application. The first applies to clients and specs that read the details of a command refused because a read it depended on changed. The second applies to hosts that reference `Cratis.Arc.Availability`.
|
|
13
|
+
|
|
14
|
+
| Symptom | Cause | Who is affected |
|
|
15
|
+
| --- | --- | --- |
|
|
16
|
+
| Client code or a spec finds no `key`, `conflictingEventTypeId`, `conflictingEventType` or `conflictingEventSequenceNumber` on a refused command, or a message no longer names an event type and sequence number | A validation result with reason `concurrencyViolation` and detail `ReadChanged` now carries only `readModel` in its `state`, and its message no longer names an event type or sequence number | Applications that use the Arc Chronicle integration with protected decision reads and read that state or assert on that message |
|
|
17
|
+
| The build reports that the namespace `Cratis.Choreography.Availability` does not exist, or that `ChoreographyContextValueSource` is not found | The availability engine moved into `Cratis.Arc.Availability`, which no longer depends on `Cratis.Choreography`. The engine types are in `Cratis.Arc.Availability`, `Cratis.Arc.Availability.Audiences` and `Cratis.Arc.Availability.Context`, and `ChoreographyContextValueSource` is `AvailabilityContextValueSource` | Hosts that reference `Cratis.Arc.Availability` |
|
|
18
|
+
| The build reports a type mismatch between `Cratis.Choreography.Availability` and `Cratis.Arc.Availability` types, or the application's audience source is never asked and every gated part is refused | The host also references `Cratis.Choreography` 2.10 or earlier, which has its own copy of the engine. Arc resolves only the Arc types | Hosts that reference both `Cratis.Arc.Availability` and `Cratis.Choreography` |
|
|
19
|
+
| Obsolete warnings, which fail a build that treats warnings as errors, on `[AvailableFor("...")]`, `[AvailableWith("...")]`, `AvailabilityExpression.For`, `With`, `When`, `AllOf`, `AnyOf` and `GateNamespace` | Availability is declared with types. The string forms still work in Arc 24 | Hosts that gate parts with the string forms |
|
|
20
|
+
| Parts that were served are refused as not available after the raise | Availability configured with `AddArcAvailability` was discarded when `AddCratis()` ran first, so gates were lost and parts were served. The configured gates now apply in either order | Hosts that call `AddCratis()` before `AddArcAvailability` |
|
|
21
|
+
| The host stops at startup on an undefined or circular availability | Startup now verifies that every block built on another is defined and that no blocks build on each other in a cycle | Hosts with such a block in their `AvailabilityCatalog` |
|
|
22
|
+
| A context value resolves for a part where it was absent, or another declaration of the same name wins | A part now runs in the context scope of its namespace by default. It ran in the application scope | Hosts that declare context values at a scope below the application and do not set `ScopeFor` |
|
|
23
|
+
| `IAvailabilityGate.IsGated` answers true for parts that carry no gate | Any part can be suspended, so every part has to be decided | Application code that calls `IsGated` to find the gated parts |
|
|
24
|
+
| A `switch` over `AvailabilityVerdict` is no longer exhaustive | The verdict `Suspended` was added, reported to clients with the reason `Suspended` next to `NotAvailable` | Application code that switches over the verdict or compares the reason |
|
|
25
|
+
|
|
26
|
+
Nothing is suspended until the application suspends a part, so the reason `Suspended` reaches a client only after the application starts using suspensions.
|
|
27
|
+
|
|
28
|
+
The `@cratis/arc`, `@cratis/arc.react`, `@cratis/arc.react.mvvm` and `@cratis/arc.vite` packages have no breaking change of their own in this move; the first row is a change in what the server sends. A host that does not reference `Cratis.Arc.Availability` and never reads the state or message of a `ReadChanged` refusal has nothing to change here beyond the version raise.
|
|
29
|
+
|
|
30
|
+
## Inventory before the bump
|
|
31
|
+
|
|
32
|
+
1. List the versions of `Cratis`, `Cratis.Arc.*` and `Cratis.Choreography` in every `.csproj` and `Directory.Packages.props`, and of `@cratis/arc*` in every `package.json`.
|
|
33
|
+
2. Search the frontend, the specs and every other consumer of command results for `conflictingEventTypeId`, `conflictingEventType`, `conflictingEventSequenceNumber` and for `key` read from the `state` of a validation result. List each use.
|
|
34
|
+
3. If a project references `Cratis.Arc.Availability`, list:
|
|
35
|
+
- every `using Cratis.Choreography.Availability...` and every use of `ChoreographyContextValueSource`
|
|
36
|
+
- every string form from the table above, with the audience and availability names it uses
|
|
37
|
+
- the registrations of `IAudienceSource`, `IDeclaredAudiences`, `AvailabilityCatalog` and `ContextValueCatalog`, and whether `AddCratis()` runs before `AddArcAvailability`
|
|
38
|
+
- every `ContextValueCatalog.Declare` with its scope, and whether `ScopeFor` is set
|
|
39
|
+
- every call to `IsGated` and every `switch` over `AvailabilityVerdict`
|
|
40
|
+
4. If availability is in use, start the application and save the answer of `GET /.cratis/availability` for one caller of each kind the application distinguishes, such as a tenant with and a tenant without a paid package. Done when each answer is on disk.
|
|
41
|
+
|
|
42
|
+
## Order
|
|
43
|
+
|
|
44
|
+
1. **Raise the packages.** Raise every Arc package, NuGet and npm, to the latest Arc 24 release in one change, as `cratis-platform-upgrade-application` describes. If the host references `Cratis.Choreography`, raise it to 2.11.0 or later in the same change; from that release it uses the engine in `Cratis.Arc.Availability`. Done when `dotnet restore` ends without a downgrade warning or error.
|
|
45
|
+
2. **Move to the Arc namespaces.** Read `references/<language>.md` for the application's backend (`.csproj` → csharp). Done when no file names `Cratis.Choreography.Availability` and the project compiles apart from obsolete warnings.
|
|
46
|
+
3. **Declare availability with types.** Follow the same reference. Done when the project builds with warnings as errors, or when every remaining string form is listed with the reason it stays.
|
|
47
|
+
4. **Stop reading the removed refusal details.** For each use from the inventory, read `readModel` and nothing else from the `state`. Read `references/typescript.md` for a TypeScript client. Change specs that assert on the event type or sequence number in the message. Done when the search from the inventory finds nothing.
|
|
48
|
+
5. **Rebuild and regenerate the proxies** as `cratis-platform-upgrade-application` describes. Regenerated command and query proxies carry the part they are, which the client needs to ask about one part.
|
|
49
|
+
|
|
50
|
+
## Verify
|
|
51
|
+
|
|
52
|
+
1. `dotnet restore`, then `dotnet build` with warnings as errors.
|
|
53
|
+
2. Run the specs.
|
|
54
|
+
3. If availability is in use, start the application and ask `GET /.cratis/availability` as the same callers as in the inventory. Each listed part now also carries a `reason`. Done when each answer lists the same parts as the saved one, or every difference is explained by a gate that was discarded before because `AddCratis()` ran first.
|
|
55
|
+
4. For one gated command and one gated query, call it as a caller the gate admits and as one it does not. Done when the first is served and the second is refused with HTTP status 403 and the reason `NotAvailable`.
|
|
56
|
+
5. No event, projection or read-model behavior changes in this move, so no replay is needed. The raise brings a newer Chronicle client; apply the kernel order from `cratis-platform-upgrade-application`.
|
|
57
|
+
|
|
58
|
+
## Finish
|
|
59
|
+
|
|
60
|
+
Merge the upgrade, then reinstall the AI corpus with the previous profile list: `cratis ai install --profiles <previous> --harnesses <previous> --languages <previous>`. Done when `.cratis/ai.json` no longer lists `cratis/migrate/arc-23-to-24` and this skill is gone.
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# Move availability to the Arc engine and to types
|
|
2
|
+
|
|
3
|
+
Prerequisite: a project references `Cratis.Arc.Availability` and the packages are on the latest Arc 24 release.
|
|
4
|
+
|
|
5
|
+
## Move to the Arc namespaces
|
|
6
|
+
|
|
7
|
+
Replace the namespaces. The type names are unchanged except for the last row.
|
|
8
|
+
|
|
9
|
+
| Before | After |
|
|
10
|
+
| --- | --- |
|
|
11
|
+
| `Cratis.Choreography.Availability` | `Cratis.Arc.Availability` |
|
|
12
|
+
| `Cratis.Choreography.Availability.Audiences` | `Cratis.Arc.Availability.Audiences` |
|
|
13
|
+
| `Cratis.Choreography.Availability.Context` | `Cratis.Arc.Availability.Context` |
|
|
14
|
+
| `Cratis.Choreography.Availability.Context.Providers` | `Cratis.Arc.Availability.Context.Providers` |
|
|
15
|
+
| `ChoreographyContextValueSource` | `AvailabilityContextValueSource` |
|
|
16
|
+
|
|
17
|
+
Remove a `Cratis.Choreography` package reference that existed only for availability. Keep it, at 2.11.0 or later, when the host uses state machines, jobs, workflows or workers.
|
|
18
|
+
|
|
19
|
+
Observe: the project compiles, with obsolete warnings for the string forms.
|
|
20
|
+
|
|
21
|
+
The existing registration keeps working after the namespace change:
|
|
22
|
+
|
|
23
|
+
```csharp
|
|
24
|
+
services.AddSingleton<IAudienceSource>(new InMemoryAudienceSource());
|
|
25
|
+
services.AddSingleton<IDeclaredAudiences>(new DeclaredAudiences("Plus", "Preview"));
|
|
26
|
+
services.AddSingleton(new AvailabilityCatalog());
|
|
27
|
+
services.AddSingleton(new ContextValueCatalog());
|
|
28
|
+
services.AddArcAvailability(options => options.GateNamespace("Fleet.DataQuality", AvailabilityExpression.For("Plus")));
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Declare availability with types
|
|
32
|
+
|
|
33
|
+
Each string form becomes a type or an attribute that names a type.
|
|
34
|
+
|
|
35
|
+
| Before | After |
|
|
36
|
+
| --- | --- |
|
|
37
|
+
| `[AvailableFor("Plus", "Preview")]` | `[AvailableFor<Plus, Preview>]`, with `public class Plus : Audience;` |
|
|
38
|
+
| `[AvailableWith("DataQuality")]` | `[Available<DataQuality>]`, with `public class DataQuality : AvailabilityBlock` |
|
|
39
|
+
| `AvailabilityExpression.For`, `With`, `When`, `AllOf`, `AnyOf` | `For<T>()`, `With<T>()`, `When`, `&` and `\|` in an `AvailabilityBlock` |
|
|
40
|
+
| `AvailabilityCatalog` and `AvailabilityDefinition` | an `AvailabilityBlock` type, which the catalog is built from |
|
|
41
|
+
| `options.GateNamespace("Fleet.DataQuality", expression)` | `[AvailableFor<Plus>] public class Feature : AvailabilityScope;` in that namespace |
|
|
42
|
+
| `ContextValueCatalog.Declare(...)` with a `ReadModelContextValueProvider` | `[ProvideContext<Vessel>(...)]` |
|
|
43
|
+
| `DeclaredAudiences` | audience types, which are discovered |
|
|
44
|
+
|
|
45
|
+
```csharp
|
|
46
|
+
using Cratis.Arc.Availability;
|
|
47
|
+
|
|
48
|
+
public class Plus : Audience;
|
|
49
|
+
|
|
50
|
+
public class Preview : Audience;
|
|
51
|
+
|
|
52
|
+
public class DataQuality : AvailabilityBlock
|
|
53
|
+
{
|
|
54
|
+
protected override IReadOnlyList<AvailabilityTerm> Lines =>
|
|
55
|
+
[
|
|
56
|
+
For<Plus>(),
|
|
57
|
+
When.On<Vessel>(_ => _.HasReported).IsTrue()
|
|
58
|
+
];
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
[Command]
|
|
62
|
+
[AvailableFor<Plus, Preview>]
|
|
63
|
+
public record ResetScore(VesselId Vessel);
|
|
64
|
+
|
|
65
|
+
[Available<DataQuality>]
|
|
66
|
+
public class Feature : AvailabilityScope;
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Rules that decide whether the result behaves as before:
|
|
70
|
+
|
|
71
|
+
- **The type name is the name.** An audience is known by the name of its type, and a block by the name of its type. Name each type exactly as the string it replaces, including letter case, because the grants your `IAudienceSource` returns are matched by that name. A name that is not a valid C# type name cannot become a type: keep its string form and suppress the warning at that place, or rename the audience in the stored grants first.
|
|
72
|
+
- **One attribute is one line, and every line must hold.** `[AvailableFor<Plus, Preview>]` is open to either audience, as `[AvailableFor("Plus", "Preview")]` was. `[AvailableFor<Plus>, AvailableFor<Preview>]` needs both. One attribute takes up to three audiences; use a block for more.
|
|
73
|
+
- **All the lines of a block hold.** Use `|` inside one line for alternatives of the same form. Different forms combined with `&` are separate lines.
|
|
74
|
+
- **A scope marker gates its namespace and the namespaces beneath it**, as `GateNamespace` did. Put the marker type in the namespace the string named.
|
|
75
|
+
- **A provided read model is named by its type in camelCase.** `[ProvideContext<Vessel>(nameof(Vessel.VesselByKey), "arguments.vesselId")]` provides `vessel` for the namespace of the type that carries the attribute. Conditions that read a value declared under another name have to read the new name. The host registers an `IReadModelQuery` that executes the query; without one the host fails when the context values are first built.
|
|
76
|
+
|
|
77
|
+
Then remove the registrations of `IDeclaredAudiences`, `AvailabilityCatalog` and `ContextValueCatalog`. Arc builds them from the types only when the host has not registered its own, so a registration left in place hides every audience and block that is declared as a type. Keep the `IAudienceSource` over your own storage.
|
|
78
|
+
|
|
79
|
+
```csharp
|
|
80
|
+
builder.AddCratisArc(configureBuilder: arc => arc
|
|
81
|
+
.WithAvailability());
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
`WithAvailability` takes the same two callbacks as `AddArcAvailability`, which a host without an Arc builder keeps calling.
|
|
85
|
+
|
|
86
|
+
Observe: the project builds with warnings as errors, and the host starts.
|
|
87
|
+
|
|
88
|
+
- The host stops at startup with `UndefinedAvailabilityException` or `CircularAvailabilityException`: a block uses `With<T>()` or `AvailabilityExpression.With("...")` on a block that is not in the catalog, or blocks build on each other in a cycle. Define the missing block, or remove the hand-registered `AvailabilityCatalog` that hides the typed blocks.
|
|
89
|
+
- A gated part is refused for a caller who holds the audience: the audience type is named differently from the stored grant, or a hand-registered `IDeclaredAudiences` does not list it.
|
|
90
|
+
- A value from `ContextValueCatalog.Declare` behaves differently: a part now runs in the scope made of the segments of its namespace, so a declaration whose scope path is the start of that namespace now applies to it, and the nearest one wins. Set `options.ScopeFor = _ => ContextScope.Application` to keep the previous behavior, or move the declaration to `[ProvideContext<T>]`.
|
|
91
|
+
- A `switch` over `AvailabilityVerdict` needs a case for `Suspended`. Code that used `IAvailabilityGate.IsGated` to find the gated parts reads `IAvailabilityGate.GatedParts` instead.
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Read a refused command without the removed details
|
|
2
|
+
|
|
3
|
+
Prerequisite: the application uses the Arc Chronicle integration with protected decision reads, and client code reads the `state` of a validation result on a refused command.
|
|
4
|
+
|
|
5
|
+
A command refused because a read it depended on changed arrives as a validation result with the reason `concurrencyViolation` and the detail `ReadChanged`. Its `state` holds `readModel` only. The server no longer sends `key`, `conflictingEventTypeId`, `conflictingEventType` or `conflictingEventSequenceNumber`, so code that reads them gets `undefined`; `state` is untyped, so the compiler does not report it.
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
import { ValidationResultReason } from '@cratis/arc/validation';
|
|
9
|
+
|
|
10
|
+
const result = await command.execute();
|
|
11
|
+
|
|
12
|
+
const conflict = result.validationResults.find(
|
|
13
|
+
(_) => _.reason === ValidationResultReason.ConcurrencyViolation && _.reasonDetail === 'ReadChanged',
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
if (conflict) {
|
|
17
|
+
const readModel = conflict.state.readModel as string;
|
|
18
|
+
// Keep the user's input, read fresh state and offer to submit again.
|
|
19
|
+
}
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Observe, in a spec or under a debugger: pause a protected command after its server-side read and before commit, commit a competing event covered by the guard, then resume the command. The result is `ReadChanged`, the form keeps its input, and the handler reads nothing but `readModel`.
|
|
23
|
+
|
|
24
|
+
- The client showed which record or which event caused the refusal: the server does not tell any more. Show that the named read model changed, read fresh state with the queries the screen already uses, and let the user compare.
|
|
25
|
+
- The client chose what to reload from `key`: reload from the identity the screen already holds, such as the route parameter or the command's own properties.
|
|
26
|
+
- The message text is shown to users and looks different: it names the read model and the command only, without an event type or sequence number.
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: cratis-migrate-components-3-to-4
|
|
3
|
+
description: Use when upgrading a TypeScript application from Cratis Components 3 to Cratis Components 4, including a frontend that no longer compiles or renders unstyled after raising `@cratis/components` (component namespaces missing from the package root, `styledMode` or `CratisPreset` gone, PrimeReact selectors and `pt` keys that match nothing), and running the `@cratis/components.migrator` codemods in order. Not for other Components majors, new applications (`cratis-platform-start-application`), replacing the application's own PrimeReact controls (`cratis-components-choose-control`) or the general upgrade loop of versions, order and deployment (`cratis-platform-upgrade-application`).
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Move a TypeScript application from Components 3 to Components 4
|
|
7
|
+
|
|
8
|
+
Temporary guidance for one upgrade. Reinstall the AI corpus without this profile once the upgrade is merged. Run it inside the loop of `cratis-platform-upgrade-application`, which owns version pairing and the order across products. Paths and names in examples are illustrative.
|
|
9
|
+
|
|
10
|
+
## What changed
|
|
11
|
+
|
|
12
|
+
Components 3 rendered through PrimeReact 11. Components 4 renders its own markup, with no PrimeReact, PrimeIcons or Prime theme dependency. Imports, provider configuration, CSS selectors and some callbacks change, so this is not a version bump.
|
|
13
|
+
|
|
14
|
+
| Symptom | Cause | Who is affected |
|
|
15
|
+
| --- | --- | --- |
|
|
16
|
+
| `@cratis/components` has no exported member `Canvas`, `Common`, `DataTables` or another component namespace | The package root is setup-only: provider, configuration, message and icon types. Every component comes from its own subpath | Applications that import a namespace from the package root, as `import { Canvas } from '@cratis/components'` |
|
|
17
|
+
| `@cratis/components/styled`, `@cratis/components/compatibility` or `@cratis/components/primereact-v10-palette` cannot be resolved; `styledMode`, `CratisPreset` or `primeReactStyles` is missing | The renderer subpaths and their symbols are removed, with no replacement package | Applications that configured a PrimeReact preset or used the pass-through compatibility contract |
|
|
18
|
+
| Type error on `license`, `theme`, `defaults`, `pt`, `ripple`, `unstyled` or a z-index setting in the `value` of `CratisComponentsProvider` | The provider configures locale, messages, icons, routing and dialog header actions, not a renderer | Applications that passed renderer settings to the provider |
|
|
19
|
+
| Components render without the product's look; selectors on PrimeReact markup (`.p-*` classes, `data-scope` and `data-part` attributes) match nothing; a `pt` key is rejected | Components owns the markup. Parts carry `data-cratis-part`; `pt` takes the component's own parts, with plain HTML attributes as values | Applications with their own CSS or `pt` configuration for Components |
|
|
20
|
+
| A `Dropdown` `onChange` handler reads `event.value` and gets nothing, or fails type checking | `onChange` receives the selected value itself, not an event object | Applications with such handlers |
|
|
21
|
+
| `RadioButtonField` fails type checking for a missing `name` | Options bound to one property must share an explicit `name` | Applications with `RadioButtonField` |
|
|
22
|
+
| An import from the `Canvas` or `PivotViewer` subpath cannot resolve `pixi.js`, or the install reports it as a missing peer | `pixi.js` is an optional peer, no longer a dependency of the package | Applications that use `Canvas` or `PivotViewer` |
|
|
23
|
+
| `PivotViewerOptimized`, `CommandStepperContent` or an internal helper of `Canvas` or `Filter` is missing | Exports that were never a contract are removed | Applications that imported them |
|
|
24
|
+
| The install no longer brings `primeicons` | A string icon is still rendered as a class on an `<i>` element, but `primeicons` is no longer a peer of Components | Applications that pass PrimeIcons class strings |
|
|
25
|
+
| Dates in `DatePickerInput` follow the locale and ignore `dateFormat`; `clientFiltering` on a query table changes nothing | Both props are still accepted and do nothing. Without `serverQuery`, table filtering applies only to the loaded page | Applications that set them |
|
|
26
|
+
|
|
27
|
+
Not a break in Components 4, and still worth doing now: the `Button` props `text`, `link`, `outlined`, `rounded` and `severity` are deprecated and still work. A codemod moves them to `variant`, `tone` and `shape`.
|
|
28
|
+
|
|
29
|
+
An application that imports every component from a subpath, configures no PrimeReact preset, and has no CSS, `pt` configuration or handler from the rows above has nothing to change here beyond the version raise.
|
|
30
|
+
|
|
31
|
+
## Inventory before the bump
|
|
32
|
+
|
|
33
|
+
Search the frontend source. Each list is done when it is written down, even if it is empty.
|
|
34
|
+
|
|
35
|
+
1. The version of `@cratis/components`, `@cratis/arc`, `@cratis/arc.react`, `pixi.js` and every PrimeReact, `@primereact/*`, `@primeuix/*` and `primeicons` package in `package.json`. Components 3 is required as the starting point: the codemods accept an installed Components 3 or 4 and refuse anything else.
|
|
36
|
+
2. Every import from `@cratis/components` (the package root) and from the three removed subpaths.
|
|
37
|
+
3. Every `CratisComponentsProvider` and the keys of its `value`.
|
|
38
|
+
4. Every `pt` and `ptOptions` prop on a Cratis component, and every stylesheet rule with a `.p-*` selector or a `data-scope` or `data-part` attribute.
|
|
39
|
+
5. Every direct import from a PrimeReact package. These imports are the application's own and stay until they are replaced (step 7).
|
|
40
|
+
6. Every `onChange` on `Dropdown`.
|
|
41
|
+
7. Every use of `Canvas`, `PivotViewer`, `AutoCommandForm`, `RadioButtonField`, a PrimeIcons class string, `dateFormat` and `clientFiltering`.
|
|
42
|
+
|
|
43
|
+
## Order
|
|
44
|
+
|
|
45
|
+
Work on a branch. A checkpoint is source, package manifest and lockfile together. Save one only when the application's lint, type check, specs and production build pass. Steps 3 to 6 share one checkpoint: the application does not compile between the package raise and the fixes that follow it, so the checks must pass only at step 6. To abandon a step, return source, manifest and lockfile to the previous checkpoint together, reinstall from that lockfile and rerun its checks.
|
|
46
|
+
|
|
47
|
+
Read `references/<language>.md` for the frontend (`package.json` with `@cratis/components` → typescript) for commands, codemod behavior and the mapping tables. This profile ships only the TypeScript reference.
|
|
48
|
+
|
|
49
|
+
1. **Baseline on Components 3.** Done when every check passes and the rollback checkpoint is saved.
|
|
50
|
+
2. **Root imports, still on Components 3.** Preview and apply `cratis-components-remove-root-namespace-imports`, then resolve what it reports. The subpaths it writes exist in both majors. Done when the checks pass on Components 3, no component is imported from the package root, and the import-only checkpoint is saved.
|
|
51
|
+
3. **Raise the packages.** Raise `@cratis/components` to the latest Components 4 release. Add `pixi.js` when the inventory lists `Canvas` or `PivotViewer`. With `AutoCommandForm`, raise `@cratis/arc` and `@cratis/arc.react` together to 22.16.0 or later, inside the range Components declares. Then change by hand: stylesheet imports, the provider, removed subpaths and symbols, `pt` keys and CSS selectors, and the remaining rows of What changed. Done when the install ends without an unmet-peer report for `@cratis/components` and every item of inventory lists 2 to 4 and 7 is changed or deliberately kept. Type errors remain; do not checkpoint.
|
|
52
|
+
4. **Button props.** Preview and apply `cratis-components-button-variant-tone`. Done when it reports nothing and its `TODO(cratis-codemod)` comments are resolved.
|
|
53
|
+
5. **Change handlers.** Preview and apply `cratis-components-change-handler`. Done when it reports nothing and its `TODO(cratis-codemod)` comments are resolved.
|
|
54
|
+
6. **Run the checks.** Done when lint, type check, specs and production build pass, no `TODO(cratis-codemod)` is left, and the upgrade checkpoint is saved.
|
|
55
|
+
7. **Replace the application's own PrimeReact usage** in separate batches, as `cratis-components-choose-control` describes (`references/from-primereact.md`). Remove a PrimeReact package only when no import, provider, theme or tool still uses it. This step may follow the upgrade in later changes.
|
|
56
|
+
|
|
57
|
+
Step 2 comes first because the two later codemods find components through their subpath imports. Steps 4 and 5 write source for Components 4, so they come after step 3.
|
|
58
|
+
|
|
59
|
+
## Verify
|
|
60
|
+
|
|
61
|
+
1. Install from the lockfile, then run lint, type check and the production build.
|
|
62
|
+
2. Run the specs.
|
|
63
|
+
3. Search the source: no import of a component from the package root, no import from a removed subpath, no `TODO(cratis-codemod)`.
|
|
64
|
+
4. Open a page with a field, a table and a dialog in every host entry. Done when each has layout, the product's colors and a visible focus indicator, in every color scheme the application supports.
|
|
65
|
+
5. With the keyboard only: open and dismiss a dialog, move through a stepper, filter and page a table, enter a date, pick a dropdown value and act on a toast. Done when each works and every changed handler receives the value it expects.
|
|
66
|
+
6. No event, projection, read model or HTTP contract changes in this move, so no replay and no document diff is needed.
|
|
67
|
+
|
|
68
|
+
If a changed control loses behavior the application needs, stay on the last passing checkpoint until it is resolved.
|
|
69
|
+
|
|
70
|
+
## Finish
|
|
71
|
+
|
|
72
|
+
Merge the upgrade, then reinstall the AI corpus with the previous profile list: `cratis ai install --profiles <previous> --harnesses <previous> --languages <previous>`. Done when `.cratis/ai.json` no longer lists `cratis/migrate/components-3-to-4` and this skill is gone.
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
# Components 3 to 4 in TypeScript: codemods and mappings
|
|
2
|
+
|
|
3
|
+
## Contents
|
|
4
|
+
|
|
5
|
+
- Run a codemod
|
|
6
|
+
- What each codemod does and refuses
|
|
7
|
+
- Dependencies
|
|
8
|
+
- Stylesheets
|
|
9
|
+
- Removed root namespaces
|
|
10
|
+
- Removed subpaths and symbols
|
|
11
|
+
- Provider
|
|
12
|
+
- Parts and selectors
|
|
13
|
+
- Controls that behave differently
|
|
14
|
+
- Avoid
|
|
15
|
+
|
|
16
|
+
## Run a codemod
|
|
17
|
+
|
|
18
|
+
Prerequisite: the application has `@cratis/components` 3 or 4 installed, and you are following Order in this skill. Paths and names in examples are illustrative.
|
|
19
|
+
|
|
20
|
+
All three commands ship in `@cratis/components.migrator`, which is released with the same version number as `@cratis/components`. Run them from the application directory whose installed Components package is being upgraded. Keep the migrator inside major 4; never use `latest`.
|
|
21
|
+
|
|
22
|
+
```sh
|
|
23
|
+
TOOLING_RANGE='^4.0.0'
|
|
24
|
+
|
|
25
|
+
# Preview: writes nothing.
|
|
26
|
+
npx --package "@cratis/components.migrator@$TOOLING_RANGE" \
|
|
27
|
+
cratis-components-remove-root-namespace-imports --check src
|
|
28
|
+
|
|
29
|
+
# Apply.
|
|
30
|
+
npx --package "@cratis/components.migrator@$TOOLING_RANGE" \
|
|
31
|
+
cratis-components-remove-root-namespace-imports src
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
- The other two commands, `cratis-components-button-variant-tone` and `cratis-components-change-handler`, take the same form. With pnpm use `pnpm dlx --package …`, with Yarn 2 or later `yarn dlx --package …`.
|
|
35
|
+
- The path argument (`src` here) only selects the files to scan. The installed `@cratis/components` is resolved from the working directory, so run from the application directory.
|
|
36
|
+
- `--check` exits non-zero when a rewrite is pending or a case needs manual review. That exit does not mean the tool failed.
|
|
37
|
+
- An apply run rewrites the safe cases, reports the rest and exits non-zero while any refused case remains.
|
|
38
|
+
- Before scanning, the migrator checks the installed `@cratis/components`. It accepts Components 3 or Components 4, and otherwise scans and writes nothing.
|
|
39
|
+
- Requires Node.js 20 or later. The codemods bring their own TypeScript, scan `.js`, `.jsx`, `.mjs`, `.cjs`, `.ts`, `.tsx`, `.mts` and `.cts` recursively, skip `node_modules` and `dist`, and are safe to rerun.
|
|
40
|
+
- A codemod does not remove imports it leaves unused. Run the formatter and lint afterwards.
|
|
41
|
+
- Pass `--package <name>` when the application installs Components under another package name.
|
|
42
|
+
|
|
43
|
+
**Coming from Components 2 or older (edge case):** the migrator refuses the installed package. Change the imports by hand, install Components 4, then run the codemods.
|
|
44
|
+
|
|
45
|
+
## What each codemod does and refuses
|
|
46
|
+
|
|
47
|
+
| Codemod | Rewrites | Leaves for you (reported) |
|
|
48
|
+
| --- | --- | --- |
|
|
49
|
+
| `cratis-components-remove-root-namespace-imports` | `import { X } from '@cratis/components'` to `import * as X from '@cratis/components/<subpath>'`, and `export { X } from '@cratis/components'` to `export * as X from '@cratis/components/<subpath>'`, for every root namespace. Aliases and type-only imports are kept; an import that mixes a setup symbol with a namespace is split. | Whole-package imports (`import * as`, default, `import = require`), dynamic `import()`, `require()`, `export *` re-exports, side-effect imports, unknown symbols, and the `Compatibility` namespace with its pass-through exports. A statement with one refused name is left whole. |
|
|
50
|
+
| `cratis-components-button-variant-tone` | Literal `Button` props: `text` → `variant='ghost'`, `link` → `variant='link'`, `outlined` → `variant='outline'`, `rounded` → `shape='pill'`, and `severity` → `tone` (`secondary`, `contrast` → `neutral`; `info`, `help` → `accent`; `success` → `positive`; `warn` → `caution`; `danger` → `critical`). With several old variant props, `link` wins over `text`, and `text` over `outlined`. `severity='contrast'` also adds `variant='solid'` when no other variant applies. A literal new prop that is already there wins. | Dynamic values, JSX spreads, duplicate props, and a new prop with a non-literal value beside the old prop it replaces. |
|
|
51
|
+
| `cratis-components-change-handler` | A callback that only forwards one event field, on a standalone `Dropdown` `onChange` and on a command form field's `onValueChange`: it now receives the value itself. The field is `event.value` for `Dropdown`, `DropdownField` and `MultiSelectField`, `target.value` for the text, password, text area and color fields, `target.checked` for the checkbox and toggle fields, and `target.valueAsNumber` for the number and slider fields (`currentTarget` likewise). | Callbacks with several statements, several uses of the event, or use of the native event. An `event.value` callback whose parameter is not typed as `DropdownChangeEvent`, because `.value` may belong to the selected value. `onChange` on a command form field. |
|
|
52
|
+
|
|
53
|
+
```tsx
|
|
54
|
+
// Before
|
|
55
|
+
<Button outlined rounded severity='warn'>Review</Button>
|
|
56
|
+
<Dropdown onChange={(event: DropdownChangeEvent<Role>) => setRole(event.value)} />
|
|
57
|
+
|
|
58
|
+
// After
|
|
59
|
+
<Button variant='outline' shape='pill' tone='caution'>Review</Button>
|
|
60
|
+
<Dropdown onChange={(value) => setRole(value)} />
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
- The first codemod keeps namespace access (`Canvas.Canvas` still resolves). Converting to named imports is optional cleanup by hand.
|
|
64
|
+
- The Button codemod removes an old prop only when discarding its value cannot change what runs: a bare prop or a literal value. When the value is an expression that would no longer be evaluated, as `text` in `<Button link text={record()} />`, the whole prop group stays unchanged and is reported for manual review.
|
|
65
|
+
- A refused case stays unchanged and is reported. The Button and change-handler codemods also mark it with one `TODO(cratis-codemod)` comment, with three exceptions that are reported only: a Button prop that is not safe to remove (above), an untyped `event.value` callback and `onChange` on a command form field.
|
|
66
|
+
- A command form field's `onValueChange` already receives the value on the latest Components 3 release, and `onChange` is not a prop of a field in either major. Expect no rewrite on fields. If the codemod reports a field `onChange`, move the side effect to the enclosing `CommandForm`'s `onFieldChange(command, fieldName, oldValue, newValue)`.
|
|
67
|
+
- After the change-handler codemod, remove every `DropdownChangeEvent` type import: Components 4 does not export the type.
|
|
68
|
+
|
|
69
|
+
## Dependencies
|
|
70
|
+
|
|
71
|
+
- Components 4 has no PrimeReact, PrimeIcons or Prime theme dependency. Uninstall those packages only when the application no longer imports them directly; otherwise keep them, with their provider, CSS and license, for the surfaces that still use them.
|
|
72
|
+
- `pixi.js` is an optional peer, `^8.20.0`. Install it when the application imports from the `Canvas` or `PivotViewer` subpath, and keep one resolution of it in the application.
|
|
73
|
+
- Components 4 declares `@cratis/arc` and `@cratis/arc.react` from 20.3.1 up to, not including, 26. `AutoCommandForm` needs 22.16.0 or later, which honors an explicit field name. Raise the two Arc packages together, to the same version.
|
|
74
|
+
- React 19 stays the required React major.
|
|
75
|
+
- Add the recommended config of `@cratis/eslint-plugin-components` (major 4, needs ESLint 9 or later) after `@cratis/eslint-config`. Its `no-root-barrel-import` rule keeps root namespace imports from returning.
|
|
76
|
+
|
|
77
|
+
## Stylesheets
|
|
78
|
+
|
|
79
|
+
Import `@cratis/components/tokens`, then `@cratis/components/styles`, once in every host entry. Add `@cratis/components/theme` for the Cratis baseline look, or leave it out and assign the `--cratis-*` tokens yourself. The setup, the tokens and the scheme selectors are in `cratis-components-theme-application`.
|
|
80
|
+
|
|
81
|
+
## Removed root namespaces
|
|
82
|
+
|
|
83
|
+
The package root exports the provider, its configuration, message and icon types, and their helpers. Every component comes from its subpath.
|
|
84
|
+
|
|
85
|
+
| Components 3 root namespace | Subpath |
|
|
86
|
+
| --- | --- |
|
|
87
|
+
| `Canvas`, `Chat`, `CommandDialog`, `CommandForm`, `Common`, `DataPage`, `DataTables`, `Dialogs`, `Display`, `Dropdown`, `Filter`, `Notifications`, `ObjectContentEditor`, `ObjectNavigationalBar`, `PivotViewer`, `SchemaEditor`, `TimeMachine`, `Toolbar` | `@cratis/components/<same name>` |
|
|
88
|
+
| `Types` | `@cratis/components/types` |
|
|
89
|
+
| `CommandStepper` | The codemod maps the namespace to `@cratis/components/CommandDialog`, because the old namespace was that whole module. In new code import the `CommandStepper` component from `@cratis/components/CommandStepper`. |
|
|
90
|
+
| `Compatibility` | None. Replace its contracts with the typed parts of each component, then delete the import. |
|
|
91
|
+
|
|
92
|
+
`@cratis/components/CommandForm/fields` and `@cratis/components/CommandForm` are the same module.
|
|
93
|
+
|
|
94
|
+
## Removed subpaths and symbols
|
|
95
|
+
|
|
96
|
+
| Removed | Do instead |
|
|
97
|
+
| --- | --- |
|
|
98
|
+
| `@cratis/components/styled`; `styledMode`, `StyledModeOptions`, `CratisPreset`, `primeReactStyles` | Remove the renderer configuration. Import `tokens`, `styles` and optionally `theme`; assign product values to `--cratis-*` tokens directly. |
|
|
99
|
+
| `@cratis/components/compatibility`; the `Compatibility` namespace and its pass-through contract, sentinel and assert helpers | Use each component's typed parts (`DialogParts`, `DataTableParts`, `TablePaginatorParts`, `StepperParts`, `ToolbarParts`) and `data-cratis-part` selectors. |
|
|
100
|
+
| `@cratis/components/primereact-v10-palette` | Map product tokens to `--cratis-*`, or use the baseline theme. |
|
|
101
|
+
| `primeReactCssLayer`, `primeReactCssLayerOrder` | Delete, unless the product still owns direct PrimeReact CSS. Layer order belongs in product CSS. |
|
|
102
|
+
| `cratisDarkModeSelector` | The product's own theme selector, with the matching `--cratis-*` values assigned under it. |
|
|
103
|
+
| `PivotViewerOptimized` | `PivotViewer`. |
|
|
104
|
+
| `CommandStepperContent` | No replacement. Use `CommandStepper` or `StepperCommandDialog`. |
|
|
105
|
+
| Internal helpers of `Canvas` (`getInitials`, `reactionsExcludingUser`, mention and emoji helpers) and `Filter` (`buildFilterValues`, `buildRangeValues`, `RenderedHistogramBucket`) | No replacement. Inline the logic the application needs. |
|
|
106
|
+
|
|
107
|
+
## Provider
|
|
108
|
+
|
|
109
|
+
- `CratisComponentsProvider` takes locale, messages, icons, routing, dialog header actions and the toast region. Its options are in `cratis-components-theme-application`.
|
|
110
|
+
- Renderer keys in `value` are type errors: `license`, `theme`, `defaults`, `pt`, `ripple`, `unstyled` and z-index settings. Remove them. Configure a PrimeReact provider that is still needed on its own.
|
|
111
|
+
- `value.locales` is still accepted for the old paginator and date labels, and deprecated. Move them to `value.messages`.
|
|
112
|
+
|
|
113
|
+
## Parts and selectors
|
|
114
|
+
|
|
115
|
+
- `pt` stays, with new keys and plain HTML attributes as values. `ptOptions` and `unstyled` are accepted and do nothing.
|
|
116
|
+
- Check every `pt` key against the component's part type; every part is listed in `cratis-components-theme-application`, `references/parts.md`. Known keys that are no longer parts: `popup` on a dialog, and `theadRow` and `theadCell` on a data table.
|
|
117
|
+
- Replace selectors on PrimeReact markup (`.p-*` classes, `[data-scope]` and `[data-part]` attributes) with `[data-cratis-part='…']` selectors and the state attributes listed there, as `[data-cratis-part='step'][data-active='true']`.
|
|
118
|
+
- `Dropdown` still accepts `inputId` for `id` and `panelClassName` for the class of the `popover` part. Prefer the new names.
|
|
119
|
+
|
|
120
|
+
## Controls that behave differently
|
|
121
|
+
|
|
122
|
+
| Control | Change | Do |
|
|
123
|
+
| --- | --- | --- |
|
|
124
|
+
| `DatePickerInput` | Still takes and returns `Date \| null`. Formatting follows the locale; `dateFormat` is accepted and ignored. | Set the locale on the provider and remove `dateFormat`. |
|
|
125
|
+
| `DataTableForQuery`, `DataTableForObservableQuery` | Without `serverQuery`, sorting and filtering apply to the loaded page; `clientFiltering` is accepted and does nothing. | Remove `clientFiltering`. Set `serverQuery` to pass filter arguments to the query and apply them before paging. |
|
|
126
|
+
| `RadioButtonField` | `name` is required. | Give every option bound to one property the same `name`. |
|
|
127
|
+
| An icon passed as a PrimeIcons class string | Still rendered as that class on an `<i>` element. `primeicons` is no longer a peer of Components. | Keep `primeicons` installed and its stylesheet imported in the application while class strings are in use, or pass a React icon component. |
|
|
128
|
+
|
|
129
|
+
## Avoid
|
|
130
|
+
|
|
131
|
+
- Raising the package before the root-import codemod has run and passed on Components 3.
|
|
132
|
+
- Running the Button or change-handler codemod before the raise.
|
|
133
|
+
- Fetching the migrator with `latest`.
|
|
134
|
+
- Treating a non-zero `--check` exit as a tool failure.
|
|
135
|
+
- Deleting a `TODO(cratis-codemod)` without resolving the case it marks.
|
|
136
|
+
- Uninstalling PrimeReact while a direct import of it remains.
|
|
137
|
+
- Recreating a product → PrimeReact → Cratis token chain. Map product values to `--cratis-*` directly.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: cratis-platform-upgrade-application
|
|
3
|
-
description: Use when moving an existing Cratis application to newer Cratis packages, tools or images, pinning Cratis package and image versions before a first production deployment, planning or reviewing a Cratis dependency upgrade (which package versions pair, and the order of the steps), or when a build or run breaks after such an update. Not for the
|
|
3
|
+
description: Use when moving an existing Cratis application to newer Cratis packages, tools or images, pinning Cratis package and image versions before a first production deployment, planning or reviewing a Cratis dependency upgrade (which package versions pair, and the order of the steps), or when a build or run breaks after such an update. Not for the codemods and the renderer and CSS migration of a Components major (the matching Components migration profile), upgrading the Chronicle kernel itself (`cratis-chronicle-deploy-kernel`) or scaffolding a new application (`cratis-platform-start-application`).
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Move an application to newer Cratis packages, tools and images
|
|
@@ -68,7 +68,7 @@ Compile-time and changed-default steps belong to the application. Stored-state,
|
|
|
68
68
|
| Chronicle kernel: order, backup, rollout, majors | `cratis-chronicle-deploy-kernel`, `references/upgrade-and-recovery.md` |
|
|
69
69
|
| Chronicle kernel that holds unique constraint claims | `cratis-chronicle-constrain-append`, `references/operations.md` |
|
|
70
70
|
| Arc on .NET: defaults that changed | `references/csharp.md` in this skill |
|
|
71
|
-
| Components across
|
|
71
|
+
| Components across a major | The matching `cratis/migrate/components-<from>-to-<to>` profile |
|
|
72
72
|
| Specifications across a major | `cratis-specifications-isolate-behavior`, `references/csharp-running.md` |
|
|
73
73
|
| AuthProxy | Read both its upgrade notes and the release notes of every version you cross: a change to what an unchanged configuration does can be described in only one of them. Settings are in `cratis-authproxy-configure` |
|
|
74
74
|
|
|
@@ -56,7 +56,7 @@ A Components major is not a version bump: imports, provider setup, styling selec
|
|
|
56
56
|
- The migrator refuses an installed version outside the majors it supports. On the direct path from an older major, no command runs on the old release: make the preparatory import changes by hand, and run every command, the import migration included, only after the new major is installed.
|
|
57
57
|
- After the bump, update the provider setup and the stylesheet imports and make the source changes the guide lists before expecting the frontend to build. A failing build between the bump and those changes is expected, not a defect.
|
|
58
58
|
|
|
59
|
-
Order, commands and what changes by hand: `cratis
|
|
59
|
+
Order, commands and what changes by hand: the matching `cratis/migrate/components-<from>-to-<to>` profile.
|
|
60
60
|
|
|
61
61
|
## Node backend and Chronicle client
|
|
62
62
|
|