@craft-ts/mcp 0.8.6 → 0.8.8
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/content/agents.md +10 -1
- package/content/docs-index.json +74 -39
- package/package.json +2 -2
- package/skills/craft-ts/SKILL.md +5 -3
- package/skills/craft-ts-style/SKILL.md +62 -8
- package/skills/translate-spec-to-craft-ts/SKILL.md +7 -7
- package/skills/translate-spec-to-craft-ts/references/lexical-map.md +31 -83
- package/skills/translate-spec-to-craft-ts/references/pattern-recipes.md +17 -17
- package/skills/translate-spec-to-craft-ts/references/project-index.md +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@craft-ts/mcp",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.8",
|
|
4
4
|
"description": "MCP server, Agent Skills, and LLM files for coding agents using @craft-ts/core",
|
|
5
5
|
"author": "Romain Geffrault",
|
|
6
6
|
"license": "MIT",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"test": "vitest run --config vitest.config.mts"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@craft-ts/dev-tools": "^0.8.
|
|
38
|
+
"@craft-ts/dev-tools": "^0.8.8",
|
|
39
39
|
"@modelcontextprotocol/sdk": "1.26.0",
|
|
40
40
|
"zod": "4.3.6"
|
|
41
41
|
},
|
package/skills/craft-ts/SKILL.md
CHANGED
|
@@ -21,8 +21,8 @@ required and must not be introduced just to solve a Craft problem.
|
|
|
21
21
|
- `migrate-to-craft-ts` — run `craft-migrate`, then finish diagnostics
|
|
22
22
|
- `craft-ts-effect-v4` — use Effect v4 services, Layers, `queryEffect`, and
|
|
23
23
|
the synchronous-member declaration (`SyncOp` / `computedEffect`)
|
|
24
|
-
- `craft-ts-style` — the typed design system: sheets, axes,
|
|
25
|
-
matrix, context obligations
|
|
24
|
+
- `craft-ts-style` — the typed design system: sheets, axes, static text
|
|
25
|
+
contrast, the visual matrix, context obligations
|
|
26
26
|
- `craft-ts-i18n` — typed catalogues, locale parity, semantic tokens
|
|
27
27
|
|
|
28
28
|
For a project created by `craft create`, keep the generated development
|
|
@@ -57,7 +57,9 @@ If MCP is not configured, read https://ng-angular-stack.github.io/craft/llms.txt
|
|
|
57
57
|
Never assemble a class string at render time — the template sets one constant
|
|
58
58
|
class and a `data-*` attribute. `@craft-ts/style` is a **build step**: without
|
|
59
59
|
`craftStyle()` from `@craft-ts/style/vite` in the Vite config, the sheets
|
|
60
|
-
typecheck and emit nothing. Load `craft-ts-style` before touching one.
|
|
60
|
+
typecheck and emit nothing. Load `craft-ts-style` before touching one. When
|
|
61
|
+
the project exposes `npm run style:check`, run it after changing colours,
|
|
62
|
+
typography, template classes, themes, hover or another visual axis.
|
|
61
63
|
- Translations live in a `@craft-ts/i18n` catalogue: `defineCatalog` + `msg` for
|
|
62
64
|
the reference locale, `defineLocaleLike` for every other one, so a missing key
|
|
63
65
|
is a compile error. A token may validate or parse its parameter with a
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: craft-ts-style
|
|
3
|
-
description: Build and review the typed design system of a CraftTS project with @craft-ts/style — palettes, axes, typed custom properties, sheets, context obligations, the visual matrix, and
|
|
3
|
+
description: Build and review the typed design system of a CraftTS project with @craft-ts/style — palettes, axes, typed custom properties, sheets, static text-contrast checks, context obligations, the visual matrix, and style graph tools. Use when adding or changing visual rules, colours, typography, a variant, hover, a theme, dark mode, or a visual test.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# CraftTS typed styles
|
|
@@ -15,14 +15,17 @@ emitted from.
|
|
|
15
15
|
The system is a **build step**, not a runtime library. Before writing a rule,
|
|
16
16
|
confirm three things exist; without them the sheets typecheck and emit nothing.
|
|
17
17
|
|
|
18
|
-
1. `@craft-ts/style` in `dependencies
|
|
19
|
-
`devDependencies
|
|
18
|
+
1. `@craft-ts/style` in `dependencies`. Static contrast additionally needs
|
|
19
|
+
`@craft-ts/dev-tools` in `devDependencies`; `@craft-ts/style-testing` is
|
|
20
|
+
needed only for visual scenarios or attestation.
|
|
20
21
|
2. `craftStyle()` from `@craft-ts/style/vite` in the Vite `plugins` array, with
|
|
21
22
|
a `dumpPath`. The dump is what the graph and the MCP tools below read; no
|
|
22
23
|
`dumpPath`, no answers.
|
|
23
24
|
3. `import 'virtual:craft-style.css'` once, at the app entry.
|
|
24
25
|
|
|
25
|
-
A project created by `craft create` already has
|
|
26
|
+
A current project created by `craft create` with typed CSS already has the
|
|
27
|
+
required wiring. An older project must be migrated explicitly; do not assume
|
|
28
|
+
updating the package rewrites its Vite, ESLint or CI configuration.
|
|
26
29
|
|
|
27
30
|
## Hard rules
|
|
28
31
|
|
|
@@ -52,7 +55,7 @@ A project created by `craft create` already has all three.
|
|
|
52
55
|
|
|
53
56
|
| you need | call |
|
|
54
57
|
| --------------------- | ------------------------------------------- |
|
|
55
|
-
| colours | `definePalette({ group: { token: { light, dark } } })` |
|
|
58
|
+
| colours | `definePalette('ui', { group: { token: { light, dark } } })` |
|
|
56
59
|
| viewport breakpoints | `defineBreakpoints({ md: at.minInlineSize(unit.rem(48)) })` |
|
|
57
60
|
| a state variant | `defineStateAxis('tone', ['neutral', 'danger'])` |
|
|
58
61
|
| an axis that may only write one kind | `defineAxis(name, values, onlyVarsOfKind(kind.color))` |
|
|
@@ -60,8 +63,8 @@ A project created by `craft create` already has all three.
|
|
|
60
63
|
| typed custom properties | `cssVars('prefix', { ink: kind.color(token) })` |
|
|
61
64
|
| the rules themselves | `craftStyles('name', { root: [...] }, { axes: [...] })` |
|
|
62
65
|
|
|
63
|
-
`scheme`, `motion`, `forcedColors`, `contrast`, `
|
|
64
|
-
ship with the package and need no declaration.
|
|
66
|
+
`scheme`, `motion`, `forcedColors`, `contrast`, `interaction`, `scrollState`
|
|
67
|
+
and `descendant` ship with the package and need no declaration.
|
|
65
68
|
|
|
66
69
|
Two details the types cannot enforce and the browser does:
|
|
67
70
|
|
|
@@ -82,6 +85,56 @@ Level 3 is a **per-route** guarantee. One component in the path handing back a
|
|
|
82
85
|
loosely typed subtree stops the requirement travelling, and a partial adoption
|
|
83
86
|
gives zero of the guarantee, not most of it.
|
|
84
87
|
|
|
88
|
+
## Static text contrast
|
|
89
|
+
|
|
90
|
+
`npm run style:check` is the blocking WCAG 2.2 AA text-contrast proof. It builds
|
|
91
|
+
once so `craftStyle({ dumpPath: '.craft/style-graph.json' })` writes the style
|
|
92
|
+
dump, then runs:
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
craft-graph --style-contrast --style-dump .craft/style-graph.json --project tsconfig.app.json
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
It reads typed sheets and the TypeScript template graph; it does not need a
|
|
99
|
+
browser, screenshots or Playwright. It checks `4.5:1` for normal text and `3:1`
|
|
100
|
+
for text at least 24px, or at least 18.5px with weight 700 or above.
|
|
101
|
+
|
|
102
|
+
When changing a palette, `color`, `background-color`, font size/weight, a
|
|
103
|
+
template class, theme or visual axis, run `npm run style:check` after the
|
|
104
|
+
focused tests. A failure should be fixed at the named token or state, not hidden
|
|
105
|
+
with a local colour override.
|
|
106
|
+
|
|
107
|
+
Model hover through `when(interaction.hover, [...])`, nest it inside the tone
|
|
108
|
+
or other state it combines with, and add `interaction` to the sheet's `axes`
|
|
109
|
+
budget. A hand-written `:hover` emits CSS but is invisible to the scenario
|
|
110
|
+
contract. Enable `craftRules.configs.typedCss.rules` so raw hover and contrast
|
|
111
|
+
properties in component styles fail lint.
|
|
112
|
+
|
|
113
|
+
Indeterminate rows fail by default. `--allow-indeterminate` is only for the
|
|
114
|
+
first migration inventory; remove it before adding the check to CI. An empty
|
|
115
|
+
report also fails, because zero checked elements is normally broken wiring, not
|
|
116
|
+
a clean application.
|
|
117
|
+
|
|
118
|
+
Do not overstate coverage. Background images, alpha, unknown sizes, dynamic
|
|
119
|
+
classes and incomplete render contexts become indeterminate when they reach the
|
|
120
|
+
graph. External CSS, inline styles outside CraftTS, canvas/SVG text, generated
|
|
121
|
+
content, filters and blend modes may be invisible altogether. The ESLint
|
|
122
|
+
`uncovered` option only suppresses lint for a path; it does not add a gap to the
|
|
123
|
+
contrast report. Font-script and cap-height differences, including CJK, are not
|
|
124
|
+
detected from the CSS size/weight convention.
|
|
125
|
+
|
|
126
|
+
### Retrofitting an older project
|
|
127
|
+
|
|
128
|
+
1. Align installed `@craft-ts/*` packages on one current version.
|
|
129
|
+
2. Name palettes with `definePalette('name', spec)`.
|
|
130
|
+
3. Add the dump path to `craftStyle()` and keep
|
|
131
|
+
`virtual:craft-style.css` imported once at app entry.
|
|
132
|
+
4. Enable the `typedCss` ESLint preset and migrate hand-written hover to
|
|
133
|
+
`interaction.hover`.
|
|
134
|
+
5. Add the build-plus-`craft-graph --style-contrast` command as `style:check`.
|
|
135
|
+
6. Run once with `--allow-indeterminate`, close visible gaps, remove the flag,
|
|
136
|
+
then add `npm run style:check` to CI.
|
|
137
|
+
|
|
85
138
|
## Testing
|
|
86
139
|
|
|
87
140
|
```ts
|
|
@@ -113,4 +166,5 @@ Three MCP tools read the dump, so you do not have to write a script:
|
|
|
113
166
|
An empty `style_matrix` is the signature of a missing `dumpPath`.
|
|
114
167
|
|
|
115
168
|
Full guide: `/guide/style/setup`, `/guide/style/define`, `/guide/style/tokens`,
|
|
116
|
-
`/guide/style/variants`, `/guide/style/obligations`, `/guide/style/testing
|
|
169
|
+
`/guide/style/variants`, `/guide/style/obligations`, `/guide/style/testing`,
|
|
170
|
+
`/guide/style/contrast`.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: translate-spec-to-craft-ts
|
|
3
|
-
description: Translate functional specifications, user stories, page requirements, CRUD flows, list/detail screens, filters, pagination, bulk actions, optimistic updates, forms, and Angular feature
|
|
3
|
+
description: Translate functional specifications, user stories, page requirements, CRUD flows, list/detail screens, filters, pagination, bulk actions, optimistic updates, forms, and Angular feature architecture into @craft-ts/core primitives, insertions, services, and source helpers. Use when a request asks which craft-ts utility to choose, or when wording such as "afficher", "liste", "detail", "supprimer", "selection multiple", "pagination", "filtre URL", "formulaire", "recharger en cas d'erreur", or "feature" must be mapped to `query`, `mutation`, `state`, `queryParams`, `craftService`, form helpers, or entity helpers.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Translate Spec To Ng Craft
|
|
@@ -33,12 +33,12 @@ the published docs (MCP `search_documentation`, or https://ng-angular-stack.gith
|
|
|
33
33
|
- Match generic asynchronous client tasks to `asyncProcess`.
|
|
34
34
|
- Match local UI-only state to `state`.
|
|
35
35
|
- Match URL-backed state to `queryParams`.
|
|
36
|
-
- Match reusable, page-level, or global
|
|
36
|
+
- Match reusable, page-level, or global feature requirements to `craftService` plus the primitives it owns.
|
|
37
37
|
- Match event buses, resets, refreshes, and hidden triggers to `source$` and `on$`.
|
|
38
38
|
- Match list collection semantics to `insertEntities` and the entity helpers when the spec explicitly talks about add, remove, update, upsert, replace, or clear.
|
|
39
39
|
- Match nested sub-state behavior to `insertSelect`.
|
|
40
40
|
- Match forms to `insertForm`, `insertSelectFormTree`, `insertFormAttributes`, and `insertFormSubmit`.
|
|
41
|
-
- Treat `computedSource`, `toSource`, `signalSource`, `linkedSource`, `resourceById`,
|
|
41
|
+
- Treat `computedSource`, `toSource`, `signalSource`, `linkedSource`, `resourceById`, and other infra helpers as advanced choices. Do not choose them first unless the spec is about plumbing.
|
|
42
42
|
|
|
43
43
|
## Default Heuristics
|
|
44
44
|
|
|
@@ -49,8 +49,8 @@ the published docs (MCP `search_documentation`, or https://ng-angular-stack.gith
|
|
|
49
49
|
- When optimistic deletion can empty the current page, consider a second `insertReactOnMutation(..., { reload: { onMutationResolved: true } })`.
|
|
50
50
|
- When the spec mentions pagination or page transitions, consider `identifier` on the `query` and `insertPaginationPlaceholderData`.
|
|
51
51
|
- When the spec mentions remembered filters, remembered results, refresh survival, or lightweight cache, consider `insertLocalStoragePersister`.
|
|
52
|
-
- When the spec mentions parent-provided values or route or context values that are not URL query params, consider `
|
|
53
|
-
- When the spec mentions Angular services or a facade over a service, consider `
|
|
52
|
+
- When the spec mentions parent-provided values or route or context values that are not URL query params, consider `CraftServiceInput` in a `craftService` factory.
|
|
53
|
+
- When the spec mentions Angular services or a facade over a service, consider `craftService` and its generated dependency helpers.
|
|
54
54
|
|
|
55
55
|
## Output Contract
|
|
56
56
|
|
|
@@ -73,11 +73,11 @@ Spec: `Creer une page qui affiche une liste d'utilisateurs.`
|
|
|
73
73
|
Mapping: `query` for remote list loading. Add `queryParams` only if pagination, filters, sort, or shareable URL state are part of the spec.
|
|
74
74
|
|
|
75
75
|
Spec: `Creer une page qui affiche une liste d'utilisateurs. On peut supprimer un utilisateur via un bouton, ou en selectionner plusieurs pour en supprimer plusieurs.`
|
|
76
|
-
Mapping: `query` for the list, one `mutation` for single delete, one `mutation` for bulk delete, one selection `state`
|
|
76
|
+
Mapping: `query` for the list, one `mutation` for single delete, one `mutation` for bulk delete, one selection `state` for selected ids, and `insertReactOnMutation` on the `query` with optimistic removal plus `reload.onMutationError = true`. Use `removeOne` and `removeMany` for the optimistic transforms.
|
|
77
77
|
Baseline helper already covering this: `assertMutationHasReactOn` (and `assertHttpEndpointUnique` if the list HTTP is owned once). Do not add an architecture rule for the feature.
|
|
78
78
|
|
|
79
79
|
Spec: `Creer une page de recherche avec filtres dans l'URL et pagination sans flicker.`
|
|
80
|
-
Mapping: `queryParams` for filter and pagination state, `query` for results, `insertPaginationPlaceholderData` to keep previous page data visible during transitions
|
|
80
|
+
Mapping: `queryParams` for filter and pagination state, `query` for results, and `insertPaginationPlaceholderData` to keep previous page data visible during transitions.
|
|
81
81
|
|
|
82
82
|
## References
|
|
83
83
|
|
|
@@ -10,124 +10,78 @@ Prefer the documented APIs first. Use the advanced exports only when the request
|
|
|
10
10
|
### `query`
|
|
11
11
|
|
|
12
12
|
Match: `afficher`, `liste`, `tableau`, `detail`, `charger`, `recuperer`, `fetch`, `read`, `dashboard`, `feed`, `resultats`, `historique`, `stats`, `donnees serveur`, `recharger`, `rafraichir`.
|
|
13
|
-
Pair with: `queryParams`, `insertReactOnMutation`, `insertPaginationPlaceholderData`, `insertLocalStoragePersister
|
|
13
|
+
Pair with: `queryParams`, `insertReactOnMutation`, `insertPaginationPlaceholderData`, `insertLocalStoragePersister`.
|
|
14
14
|
Default: Use `params` for reactive inputs, `method` for explicit trigger flows, `identifier` for pagination or parallel instances, and `preservePreviousValue` or placeholder strategies when flicker matters.
|
|
15
15
|
|
|
16
16
|
### `mutation`
|
|
17
17
|
|
|
18
18
|
Match: `creer`, `ajouter`, `enregistrer`, `modifier`, `mettre a jour`, `editer`, `patcher`, `supprimer`, `archiver`, `activer`, `desactiver`, `publier`, `bulk action`, `submit`, `confirmer`.
|
|
19
|
-
Pair with: `insertReactOnMutation`, `insertFormSubmit`, `
|
|
19
|
+
Pair with: `insertReactOnMutation`, `insertFormSubmit`, `query`.
|
|
20
20
|
Default: Create one mutation per server intent. Add `identifier` when row-level actions need independent loading states or cancellation semantics.
|
|
21
21
|
|
|
22
22
|
### `asyncProcess`
|
|
23
23
|
|
|
24
24
|
Match: `debounce`, `temporiser`, `retarder`, `valider en asynchrone`, `autosave`, `partager`, `clipboard`, `native API`, `background task`, `processus asynchrone`, `polling`.
|
|
25
|
-
Pair with: `source$`, `afterRecomputation
|
|
25
|
+
Pair with: `source$`, `afterRecomputation`.
|
|
26
26
|
Default: Choose this when the flow is asynchronous but is not the canonical server read cache and is not a write that should drive query synchronization.
|
|
27
27
|
|
|
28
28
|
### `state`
|
|
29
29
|
|
|
30
30
|
Match: `etat local`, `selection`, `toggle`, `ouvert`, `ferme`, `modal`, `onglet actif`, `draft`, `brouillon`, `checkbox`, `expanded`, `wizard step`, `current tab`, `UI state`.
|
|
31
|
-
Pair with: `insertSelect`, `insertEntities`, `insertForm
|
|
31
|
+
Pair with: `insertSelect`, `insertEntities`, `insertForm`.
|
|
32
32
|
Default: Keep the state granular. Use it for client-only state and view state that should not live in the URL.
|
|
33
33
|
|
|
34
34
|
### `queryParams`
|
|
35
35
|
|
|
36
36
|
Match: `URL`, `query string`, `search params`, `filtre URL`, `pagination URL`, `tri dans l'URL`, `onglet partageable`, `deep link`, `etat partageable`, `back-forward`.
|
|
37
|
-
Pair with: `query
|
|
37
|
+
Pair with: `query`.
|
|
38
38
|
Default: Split URL concerns by group when useful. Put `page`, `pageSize`, `sort`, `search`, `filters`, `tab`, and similar shareable state here.
|
|
39
39
|
|
|
40
40
|
### `source$`
|
|
41
41
|
|
|
42
42
|
Match: `trigger`, `refresh`, `reset`, `bus evenementiel`, `broadcast`, `declencher`, `signal d'action`, `event stream`, `cross feature trigger`.
|
|
43
|
-
Pair with: `on$`, `afterRecomputation
|
|
43
|
+
Pair with: `on$`, `afterRecomputation`.
|
|
44
44
|
Default: Choose this when the spec describes an event, not a persistent state.
|
|
45
45
|
|
|
46
46
|
### `on$`
|
|
47
47
|
|
|
48
48
|
Match: `quand X arrive alors`, `react to`, `reset on`, `sync on`, `internal reaction`, `hidden binding`, `do not expose this method`.
|
|
49
|
-
Pair with: `source$`, `state`, `mutation`, `asyncProcess`, `
|
|
49
|
+
Pair with: `source$`, `state`, `mutation`, `asyncProcess`, `craftService`.
|
|
50
50
|
Default: Use this for hidden reactive wiring that should run from a source but should not become part of the public API.
|
|
51
51
|
|
|
52
|
-
### `
|
|
52
|
+
### `craftService` facade
|
|
53
53
|
|
|
54
54
|
Match: `facade`, `wrapper de service`, `exposer une petite API`, `renommer des methodes`, `derive from service signals`, `hide imperative router/service API`.
|
|
55
|
-
Pair with: `on$`, `
|
|
55
|
+
Pair with: `on$`, `craftComputed`, and generated service dependencies.
|
|
56
56
|
Default: Choose this outside store composition when the user wants a smaller typed service-facing API.
|
|
57
57
|
|
|
58
|
-
##
|
|
58
|
+
## Feature composition
|
|
59
59
|
|
|
60
|
-
### `
|
|
60
|
+
### `craftService`
|
|
61
61
|
|
|
62
|
-
Match: `feature
|
|
63
|
-
|
|
64
|
-
|
|
62
|
+
Match: `feature`, `page logic`, `reusable state module`, `providedIn`, `scope`,
|
|
63
|
+
`dependency injection`, or a domain facade shared by several components.
|
|
64
|
+
Pair with: `state`, `query`, `mutation`, `asyncProcess`, `queryParams`,
|
|
65
|
+
`source$`, and `craftYieldRecord`.
|
|
66
|
+
Default: use `craftService` as the named boundary and return the primitives or
|
|
67
|
+
facade methods that the feature actually exposes. Do not invent a separate
|
|
68
|
+
store wrapper around each primitive.
|
|
65
69
|
|
|
66
|
-
### `
|
|
70
|
+
### `CraftServiceInput`
|
|
67
71
|
|
|
68
|
-
Match: `
|
|
69
|
-
|
|
70
|
-
|
|
72
|
+
Match: `parent provides id`, `route provides id`, `component input`, `external
|
|
73
|
+
signal`, `context value`, or `page receives userId`.
|
|
74
|
+
Pair with: `craftService` and the primitive that consumes the value.
|
|
75
|
+
Default: declare changing service inputs as `CraftServiceInput<T>` and yield
|
|
76
|
+
`inputs.value()` inside the service factory. Use `queryParams` only when the
|
|
77
|
+
value belongs in the URL.
|
|
71
78
|
|
|
72
|
-
###
|
|
79
|
+
### Derived and injected service logic
|
|
73
80
|
|
|
74
|
-
Match: `
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
### `craftMutations`
|
|
79
|
-
|
|
80
|
-
Match: `actions serveur du store`, `store mutations`, `CRUD actions grouped in store`, `row actions in store`.
|
|
81
|
-
Pair with: `mutation`, `craftQuery`, `insertReactOnMutation`.
|
|
82
|
-
Default: Group server write actions here so the store gets prefixed trigger methods and typed state access.
|
|
83
|
-
|
|
84
|
-
### `craftAsyncProcesses`
|
|
85
|
-
|
|
86
|
-
Match: `async workflow in store`, `debounced action in store`, `delayed delete`, `background task in store`.
|
|
87
|
-
Pair with: `asyncProcess`, `craftSources`.
|
|
88
|
-
Default: Use when async client tasks belong to a `craft` store but are not the primary server-read/write state.
|
|
89
|
-
|
|
90
|
-
### `craftSources`
|
|
91
|
-
|
|
92
|
-
Match: `reset event`, `refresh event`, `select event`, `open modal event`, `trigger inside store`.
|
|
93
|
-
Pair with: `source$`, `on$`, `afterRecomputation`.
|
|
94
|
-
Default: Use this to define event channels inside a store and to auto-generate `emit*`, `set*`, or `next*` methods.
|
|
95
|
-
|
|
96
|
-
### `craftInputs`
|
|
97
|
-
|
|
98
|
-
Match: `parent provides id`, `route provides id`, `component input`, `external signal`, `context value`, `page receives userId`.
|
|
99
|
-
Pair with: `craftQuery`, `craftState`, `craftMutations`.
|
|
100
|
-
Default: Use this instead of `queryParams` when the value does not belong in the URL.
|
|
101
|
-
|
|
102
|
-
### `craftQueryParams`
|
|
103
|
-
|
|
104
|
-
Match: `one query param group in store`, `pagination in store`, `filters in store`, `search params in store`.
|
|
105
|
-
Pair with: `queryParams`, `craftQuery`, `craftSetAllQueriesParamsStandalone`.
|
|
106
|
-
Default: Use when one named query-params group should live inside a `craft` store.
|
|
107
|
-
|
|
108
|
-
### `craftQueryParams`
|
|
109
|
-
|
|
110
|
-
Match: `several URL state groups`, `pagination + filters + active tab`, `multiple query param groups`.
|
|
111
|
-
Pair with: `queryParams`, `craftSetAllQueriesParamsStandalone`.
|
|
112
|
-
Default: Use when the store needs several named query-params groups.
|
|
113
|
-
|
|
114
|
-
### `craftComputedStates`
|
|
115
|
-
|
|
116
|
-
Match: `derived store data`, `isAllSelected`, `count`, `filtered count`, `UI flags`, `aggregation`, `composed loading state`.
|
|
117
|
-
Pair with: `computed`, `craftState`, `craftQuery`.
|
|
118
|
-
Default: Use for derived store-level signals instead of duplicating state.
|
|
119
|
-
|
|
120
|
-
### `craftInject`
|
|
121
|
-
|
|
122
|
-
Match: `inject ApiService`, `inject Router`, `inject HttpClient`, `inject token`, `service dependency in store`.
|
|
123
|
-
Pair with: `craft`, `craftQuery`, `craftMutations`.
|
|
124
|
-
Default: Use inside `craft` when store factories need Angular services or tokens.
|
|
125
|
-
|
|
126
|
-
### `craftSetAllQueriesParamsStandalone`
|
|
127
|
-
|
|
128
|
-
Match: `generate URL`, `router navigate queryParams`, `shareable link`, `build full query string outside injection context`.
|
|
129
|
-
Pair with: `craftQueryParams`, `craftQueryParams`.
|
|
130
|
-
Default: Use when the spec mentions programmatic navigation or link generation from the current query-params model.
|
|
81
|
+
Match: `derived data`, `count`, `filtered count`, `UI flags`, or a service
|
|
82
|
+
dependency. Use `craftComputed` for derived values, and yield the generated
|
|
83
|
+
service dependency from a `craftService` generator. Use `on$` and `source$` for
|
|
84
|
+
internal event wiring rather than store-specific source helpers.
|
|
131
85
|
|
|
132
86
|
## Insertions
|
|
133
87
|
|
|
@@ -280,7 +234,7 @@ Default: Use when the spec is explicit about source transformation pipelines.
|
|
|
280
234
|
### `signalSource`
|
|
281
235
|
|
|
282
236
|
Match: `source with signal shape`, `event source with set`, `lazy event signal`, `source semantics with preserveLastValue`.
|
|
283
|
-
Pair with: `
|
|
237
|
+
Pair with: `source$`, `afterRecomputation`, `linkedSource`.
|
|
284
238
|
Default: Choose this only when the implementation specifically wants signal-like source behavior rather than `source$`.
|
|
285
239
|
|
|
286
240
|
### `linkedSource`
|
|
@@ -314,9 +268,3 @@ Default: Prefer the insertion for product specs. Use this lower-level factory on
|
|
|
314
268
|
Match: `low-level resource registry`, `resources keyed by identifier`, `manual per-id cache infrastructure`, `bind one resource-by-id to another`.
|
|
315
269
|
Pair with: `query.identifier`, `mutation.identifier`.
|
|
316
270
|
Default: Prefer ordinary `query` and `mutation` with `identifier` until the request explicitly asks for custom resource infrastructure.
|
|
317
|
-
|
|
318
|
-
### `toInject`
|
|
319
|
-
|
|
320
|
-
Match: `bind external signals into service entries`, `service ...Entry wiring`, `service adapter for signals`.
|
|
321
|
-
Pair with: Angular services exposing writable `...Entry` signals.
|
|
322
|
-
Default: Use only when the service API already follows the `...Entry` convention and the request is about service binding infrastructure.
|
|
@@ -27,7 +27,7 @@ Use:
|
|
|
27
27
|
- `query` for the entity detail.
|
|
28
28
|
- `mutation` for update or delete intents.
|
|
29
29
|
- `insertReactOnMutation` on the detail `query` when edits should be reflected immediately.
|
|
30
|
-
- `
|
|
30
|
+
- `CraftServiceInput` when the entity id comes from component or route context but does not belong in query params.
|
|
31
31
|
|
|
32
32
|
Default policy:
|
|
33
33
|
- Keep one detail `query` per detail intent.
|
|
@@ -39,7 +39,7 @@ Use:
|
|
|
39
39
|
- one `query` for the list.
|
|
40
40
|
- one `mutation` for single delete.
|
|
41
41
|
- one `mutation` for bulk delete.
|
|
42
|
-
- one selection `state`
|
|
42
|
+
- one selection `state` holding selected ids.
|
|
43
43
|
- `insertReactOnMutation` on the list `query` for each mutation.
|
|
44
44
|
|
|
45
45
|
Default policy:
|
|
@@ -67,35 +67,35 @@ Default policy:
|
|
|
67
67
|
## Search Page With URL Filters
|
|
68
68
|
|
|
69
69
|
Use:
|
|
70
|
-
- `queryParams`
|
|
70
|
+
- `queryParams` for the filters.
|
|
71
71
|
- `query` for the result list.
|
|
72
|
-
-
|
|
72
|
+
- the router service when links or navigation must be generated outside a component template.
|
|
73
73
|
|
|
74
74
|
Default policy:
|
|
75
75
|
- Reset `page` to `1` when a search term or filter changes.
|
|
76
76
|
- Keep URL parsing and serialization explicit for each field.
|
|
77
|
-
-
|
|
77
|
+
- Use separate named `queryParams` primitives when the page has several query-params groups.
|
|
78
78
|
|
|
79
|
-
## Feature Or Page
|
|
79
|
+
## Feature Or Page Service
|
|
80
80
|
|
|
81
81
|
Use:
|
|
82
|
-
- `
|
|
83
|
-
-
|
|
84
|
-
- `
|
|
85
|
-
- `
|
|
86
|
-
- `
|
|
87
|
-
- `
|
|
82
|
+
- `craftService` as the boundary.
|
|
83
|
+
- generated service dependencies for services and tokens.
|
|
84
|
+
- `CraftServiceInput` for non-URL external values.
|
|
85
|
+
- `queryParams` for URL-backed state.
|
|
86
|
+
- `source$` and `on$` for reset, refresh, and cross-entry triggers.
|
|
87
|
+
- `query`, `mutation`, `state`, and `craftComputed` for the actual feature logic.
|
|
88
88
|
|
|
89
89
|
Default policy:
|
|
90
|
-
- Choose
|
|
91
|
-
- Choose `providedIn: 'root'` for
|
|
92
|
-
- Keep remote state in `
|
|
90
|
+
- Choose a scoped `craftService` for page or route scoped logic.
|
|
91
|
+
- Choose `providedIn: 'root'` for globally shared services.
|
|
92
|
+
- Keep remote state in `query` and `mutation`, not in ad-hoc service fields.
|
|
93
93
|
|
|
94
94
|
## Smaller Facade Over An Angular Service
|
|
95
95
|
|
|
96
96
|
Use:
|
|
97
|
-
- `
|
|
98
|
-
-
|
|
97
|
+
- `craftService` when the facade needs to own primitives or dependencies.
|
|
98
|
+
- a plain adapter when no reactive service boundary is needed.
|
|
99
99
|
|
|
100
100
|
Default policy:
|
|
101
101
|
- Expose only the service surface the feature actually needs.
|
|
@@ -48,5 +48,5 @@ MCP `find_examples` searches the same Learn + examples corpus.
|
|
|
48
48
|
- Favor symbol names from the installed package over older or shorter doc titles.
|
|
49
49
|
- The public insertion name is `insertLocalStoragePersister`.
|
|
50
50
|
- Reach for advanced exports such as `toSource`, `computedSource`, `signalSource`,
|
|
51
|
-
`linkedSource`,
|
|
51
|
+
`linkedSource`, and `resourceById` only when the request is
|
|
52
52
|
explicitly about infrastructure or source plumbing.
|