@collective-intelligence/extensions-sdk-frontend-react 0.11.0 → 0.13.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/AGENTS.md +29 -10
- package/README.md +20 -21
- package/dist/effect/effect-runtime/query-cache.d.ts +3 -146
- package/dist/effect.d.ts +1 -1
- package/dist/effect.js +1 -1
- package/dist/record-layer/collection-ids.d.ts +8 -0
- package/dist/record-layer/collections/id-reads.d.ts +26 -0
- package/dist/record-layer/collections/query.d.ts +55 -0
- package/dist/record-layer/collections/realtime.d.ts +124 -0
- package/dist/record-layer/errors.d.ts +64 -0
- package/dist/record-layer/identity.d.ts +57 -0
- package/dist/record-layer/index.d.ts +23 -0
- package/dist/record-layer/layer.d.ts +11 -0
- package/dist/record-layer/machines.d.ts +45 -0
- package/dist/record-layer/outbox.d.ts +141 -0
- package/dist/record-layer/outbox.test-support.d.ts +182 -0
- package/dist/record-layer/ports.d.ts +141 -0
- package/dist/record-layer/position.d.ts +12 -0
- package/dist/record-layer/seed/client.d.ts +38 -0
- package/dist/record-layer/seed/freshness.d.ts +19 -0
- package/dist/record-layer/seed/server.d.ts +77 -0
- package/dist/record-layer/server.d.ts +6 -0
- package/dist/record-layer/service.d.ts +48 -0
- package/dist/record-layer/targets.d.ts +50 -0
- package/dist/record-layer/write-lock.d.ts +23 -0
- package/dist/record-layer/writes.d.ts +85 -0
- package/dist/records/adapters.d.ts +37 -0
- package/dist/records/runtime-provider.d.ts +22 -0
- package/dist/records.d.ts +12 -0
- package/dist/records.js +2 -0
- package/dist/records.server.d.ts +4 -0
- package/dist/records.server.js +1 -0
- package/dist/studio-api/@tanstack/react-query.gen.d.ts +14 -14
- package/dist/workflow.js +2 -1
- package/dist/workflows/default-template-ui/inputs/default-input-details.d.ts +9 -0
- package/dist/workflows/default-template-ui/inputs/translations.d.ts +5 -0
- package/dist/workflows/field-editor/authored-value.d.ts +4 -0
- package/dist/workflows/workflow-runtime/read-only-saved-value-field.d.ts +10 -0
- package/dist/workflows/workflow-runtime/translations.d.ts +1 -0
- package/docs/effect.md +8 -90
- package/docs/guide/ai/index.md +1 -1
- package/docs/guide/develop/sdks.md +34 -16
- package/docs/guide/platform/entrypoints.md +13 -11
- package/docs/record-collections.md +147 -0
- package/docs/tanstack-skills.md +74 -0
- package/package.json +29 -7
- package/skills/extensions-sdk-frontend-react-move-to-record-collections/SKILL.md +54 -0
- package/skills/extensions-sdk-frontend-react-record-collections/SKILL.md +48 -0
- package/skills/extensions-sdk-frontend-react-tanstack-db-ssr/SKILL.md +34 -0
package/docs/effect.md
CHANGED
|
@@ -103,96 +103,14 @@ export const RowsWidget = (props: Readonly<{ name: string }>) => (
|
|
|
103
103
|
|
|
104
104
|
### Optimistic write
|
|
105
105
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
edit until a fetch gives it one.
|
|
115
|
-
- **Order.** The writes to one key go to the Studio API one at a time, in
|
|
116
|
-
call order. When the Studio API gets a write, the running fetch of the key
|
|
117
|
-
is cancelled.
|
|
118
|
-
- **Fetches.** A fetch that ends while writes are pending, for example after
|
|
119
|
-
another widget refreshes the key or a window focus, updates the confirmed
|
|
120
|
-
value, and the layers show over it again. Thus an edit must give the same
|
|
121
|
-
value for a value that already holds it: set fields, or replace or remove a
|
|
122
|
-
row by its id. To add a row, skip the add when the row is there.
|
|
123
|
-
- **Send-time payload.** Give `write` as a function to build the payload when
|
|
124
|
-
the Studio API gets the write. It gets `{ confirmed, optimistic }`: the
|
|
125
|
-
confirmed value with the answers of the writes before it, and that value
|
|
126
|
-
with this edit only. A refused write before it is not in either value.
|
|
127
|
-
- **Answer.** When the Studio API confirms the write, its layer goes, and the
|
|
128
|
-
confirmed value becomes `options.confirm(result, confirmed)`, for example
|
|
129
|
-
the stored row with its new revision. Without `confirm`, or when it gives
|
|
130
|
-
`undefined`, the confirmed value gets the edit. When `write` fails, is
|
|
131
|
-
interrupted or dies, only its own layer goes; the other layers show over
|
|
132
|
-
the confirmed value. When `confirm` throws, the write dies with its error,
|
|
133
|
-
the confirmed value stays, and its layer still goes. When the write ends,
|
|
134
|
-
the key is invalidated, so views read the stored value.
|
|
135
|
-
- **Other members.** A value that `setData`, `update` or `remove` puts while
|
|
136
|
-
writes are pending stays. The edits before it no longer show or roll back,
|
|
137
|
-
and their `confirm` does not run, so an older answer never replaces the
|
|
138
|
-
newer value.
|
|
139
|
-
- **Runs.** Each run of the effect that `optimisticUpdate` returns is one
|
|
140
|
-
write with its own layer, so an actor can run one save effect twice.
|
|
141
|
-
- **Pending.** `pending(queryKey)` gives the number of optimistic writes of
|
|
142
|
-
the key that wait for the Studio API or run, for example to show
|
|
143
|
-
"Saving…".
|
|
144
|
-
|
|
145
|
-
The writes of one key share their layers across every `QueryCache` over the
|
|
146
|
-
same `QueryClient`. The `QueryClient` holds them, so the writes of two
|
|
147
|
-
widgets to one key also show together and go one at a time, though each
|
|
148
|
-
widget bundles its own copy of `/effect`. Copies of releases with another
|
|
149
|
-
layout of these writes keep their own. The key is the entry that `getQueryData`
|
|
150
|
-
finds, also with a `queryKeyHashFn` of the Host's `QueryClient`. A write that
|
|
151
|
-
changes several keys does the steps itself: `cancel` the keys, `update` them,
|
|
152
|
-
run the write, and `invalidate` the keys when the actor ends.
|
|
153
|
-
|
|
154
|
-
```ts
|
|
155
|
-
type Row = Readonly<{ id: string; name: string; revision: string }>
|
|
156
|
-
type RenameInput = Readonly<{
|
|
157
|
-
id: string
|
|
158
|
-
name: string
|
|
159
|
-
runtime: EffectRunner<QueryCache>
|
|
160
|
-
}>
|
|
161
|
-
|
|
162
|
-
const rename = fromEffect((input: RenameInput) =>
|
|
163
|
-
QueryCache.use((cache) =>
|
|
164
|
-
cache.optimisticUpdate(
|
|
165
|
-
rowsKey,
|
|
166
|
-
// Replaces the row by its id, so a fetch under the layer keeps it.
|
|
167
|
-
(rows: ReadonlyArray<Row>) =>
|
|
168
|
-
rows.map((row) =>
|
|
169
|
-
row.id === input.id ? { ...row, name: input.name } : row
|
|
170
|
-
),
|
|
171
|
-
// Built when the Studio API gets the save: the revision of the save
|
|
172
|
-
// before it, and no change of a refused save.
|
|
173
|
-
({ optimistic }) => {
|
|
174
|
-
const row = optimistic?.find(({ id }) => id === input.id)
|
|
175
|
-
return row === undefined
|
|
176
|
-
? Effect.die("no row")
|
|
177
|
-
: writeName(input.id, { name: row.name, revision: row.revision })
|
|
178
|
-
},
|
|
179
|
-
// `writeName` answers the stored row with its new revision.
|
|
180
|
-
{
|
|
181
|
-
confirm: (stored: Row, confirmed) =>
|
|
182
|
-
confirmed?.map((row) => (row.id === stored.id ? stored : row))
|
|
183
|
-
}
|
|
184
|
-
)
|
|
185
|
-
)
|
|
186
|
-
)
|
|
187
|
-
|
|
188
|
-
const savingRows = fromEffect(
|
|
189
|
-
(input: Readonly<{ runtime: EffectRunner<QueryCache> }>) =>
|
|
190
|
-
QueryCache.use((cache) => cache.pending(rowsKey))
|
|
191
|
-
)
|
|
192
|
-
```
|
|
193
|
-
|
|
194
|
-
A `write` given as an Effect works as before: it is the same for each
|
|
195
|
-
confirmed value.
|
|
106
|
+
`QueryCache` has no optimistic write. An optimistic write of a record is a
|
|
107
|
+
Record Collection transaction: update a view data item with `RecordWrites`
|
|
108
|
+
and `studioViewWriteTarget` of `/records`; for an optimistic create or
|
|
109
|
+
delete, file an SDK gap ([record-collections.md](record-collections.md)).
|
|
110
|
+
A write that changes keys
|
|
111
|
+
of `QueryCache` does the steps itself:
|
|
112
|
+
`cancel` the keys, `update` them, run the write, and `invalidate` the keys
|
|
113
|
+
when the actor ends.
|
|
196
114
|
|
|
197
115
|
## Rules of the write parts
|
|
198
116
|
|
package/docs/guide/ai/index.md
CHANGED
|
@@ -226,7 +226,7 @@ Your server invokes an Agent with `agents.invoke({ agentId, input })`, which ret
|
|
|
226
226
|
|
|
227
227
|
For a multi-turn chat, use the shared chat. Start a Conversation with the Agent with `ci.chat.createConversation({ organizationId, payload: { agentId } })`, send each message with `createChatClient(ci, { organizationId }).send({ conversationId, message })` from `@collective-intelligence/external-apps-server-sdk/chat`, and read earlier turns with `ci.chat.getTranscript`. Each turn is an ordinary Agent run, and the earlier successful turns, with their saved Agent Output, become the model's conversation history. A message sent while a turn still runs steers that turn and starts no second turn, and a resend with the same message `id` adds nothing.
|
|
228
228
|
|
|
229
|
-
`send` resolves `{ ok: true, value, runId }`: `runId` is the id of the turn's run, which the answer message also carries as `metadata.invocationId`, and `turnRunId(message)` reads it from any answer message. `runs.get`, `runs.sources` and `runs.feedback` accept that id like the `runId` of `agents.invoke`. They answer only the caller that owns the Conversation (the member, the app server or the visitor) through the application where the Conversation started, and answer `not_found` to every other caller. As for any run, only a signed-in member reads `runs.sources` and gives `runs.feedback`. `runs.get` gives the status and `result: { message, output? }`, where `output` is the Agent Output that the turn saved. `runs.feedback` also rates a succeeded turn whose answer is only its Agent Output, with the Output's JSON text as the rated answer; a turn with neither text nor Output has no answer to rate and gets `not_found`. The member can also rate and clear the answer with `ci.chat.putAnswerFeedback` and `ci.chat.clearAnswerFeedback` (`params: { invocationId: runId }`); it is the same rating. Each completed Agent turn with an answer to rate (its text or its Agent Output) of `ci.chat.getTranscript` gives that member `feedbackTargetId` (the turn's run id) and `currentUserFeedback`, so the app shows a saved rating again after a reload. `runs.sources` gives the searched Document Versions with their pages and a download link. `runs.stream`
|
|
229
|
+
`send` resolves `{ ok: true, value, runId }`: `runId` is the id of the turn's run, which the answer message also carries as `metadata.invocationId`, and `turnRunId(message)` reads it from any answer message. `runs.get`, `runs.stream`, `runs.cancel`, `runs.sources` and `runs.feedback` accept that id like the `runId` of `agents.invoke`. They answer only the caller that owns the Conversation (the member, the app server or the visitor) through the application where the Conversation started, and answer `not_found` to every other caller. As for any run, only a signed-in member reads `runs.sources` and gives `runs.feedback`. `runs.get` gives the status and `result: { message, output? }`, where `output` is the Agent Output that the turn saved. `runs.feedback` also rates a succeeded turn whose answer is only its Agent Output, with the Output's JSON text as the rated answer; a turn with neither text nor Output has no answer to rate and gets `not_found`. The member can also rate and clear the answer with `ci.chat.putAnswerFeedback` and `ci.chat.clearAnswerFeedback` (`params: { invocationId: runId }`); it is the same rating. Each completed Agent turn with an answer to rate (its text or its Agent Output) of `ci.chat.getTranscript` gives that member `feedbackTargetId` (the turn's run id) and `currentUserFeedback`, so the app shows a saved rating again after a reload. `runs.sources` gives the searched Document Versions with their pages and a download link. `runs.stream` pages the turn's events as for `agents.invoke`: `accepted`, the `agent.*` events and the application events that its tools publish, then one terminal event with the `runs.get` result. `runs.cancel` stops the turn. The answer itself streams from `GET /runs/:runId/stream` of the chat mount.
|
|
230
230
|
|
|
231
231
|
Anonymous visitors can chat with an Agent only when its audience has `anonymous: [app]` for that application and the call passes `caller: { kind: "anonymous_visitor", visitor: { issuer, subjectId } }`. Their turns run with the Agent's own bindings, never with the application's grants, and visitors never see each other's conversations.
|
|
232
232
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Which @collective-intelligence package to import, from which subpath, with which Effect setup and which versions.
|
|
4
4
|
|
|
5
|
-
The SDK family splits by where your code runs. Code that you install into CI as part of a package uses the `@collective-intelligence/extensions-sdk*` packages. Code that you host yourself, such as a Next.js web app and its BFF, uses the `@collective-intelligence/external-apps-*` packages.
|
|
5
|
+
The SDK family splits by where your code runs. Code that you install into CI as part of a package uses the `@collective-intelligence/extensions-sdk*` packages. Code that you host yourself, such as a Next.js web app and its BFF, uses the `@collective-intelligence/external-apps-*` packages. A self-hosted content system, such as a Payload Site, uses a CMS SDK of that family.
|
|
6
6
|
|
|
7
7
|
The template keeps the families apart. Package code imports only `extensions-sdk*` and `ui-react`, browser code imports the client SDK, and confidential server code imports the server SDK.
|
|
8
8
|
|
|
@@ -38,19 +38,21 @@ The right side is `apps/web`. Its browser code talks to its own server through a
|
|
|
38
38
|
|
|
39
39
|
## The packages
|
|
40
40
|
|
|
41
|
-
| Package
|
|
42
|
-
|
|
|
43
|
-
| `@collective-intelligence/extensions-sdk`
|
|
44
|
-
| `@collective-intelligence/extensions-sdk-backend`
|
|
45
|
-
| `@collective-intelligence/extensions-sdk-frontend`
|
|
46
|
-
| `@collective-intelligence/extensions-sdk-frontend-react`
|
|
47
|
-
| `@collective-intelligence/external-apps-client-sdk`
|
|
48
|
-
| `@collective-intelligence/external-apps-client-sdk-react`
|
|
49
|
-
| `@collective-intelligence/external-apps-server-sdk`
|
|
50
|
-
| `@collective-intelligence/
|
|
51
|
-
| `@collective-intelligence/
|
|
52
|
-
| `@collective-intelligence/
|
|
53
|
-
| `@collective-intelligence/
|
|
41
|
+
| Package | Runs where | Main subpaths | Use it for |
|
|
42
|
+
| ----------------------------------------------------------- | ------------------------------- | --------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- |
|
|
43
|
+
| `@collective-intelligence/extensions-sdk` | Package build | `.`, `/effect` (empty) | Declare the package and its components with `declarePackage` and the other `declare*` functions |
|
|
44
|
+
| `@collective-intelligence/extensions-sdk-backend` | Inside CI, backend | `.`, `/effect` | Implement the code that tools, connectors and dataset providers run |
|
|
45
|
+
| `@collective-intelligence/extensions-sdk-frontend` | Inside CI, Studio and Dashboard | `.`, `/effect` (empty) | Declare the frontend catalog that a Host loads through `loadFrontendCatalog` |
|
|
46
|
+
| `@collective-intelligence/extensions-sdk-frontend-react` | Inside CI, Studio and Dashboard | `/studio`, `/studio-api`, `/dashboard`, `/workflow`, `/ui-react`, `/effect` | Write the React code of a Studio widget or Dashboard contribution |
|
|
47
|
+
| `@collective-intelligence/external-apps-client-sdk` | Your app, browser | `.`, `/resources`, `/effect` | Sign users in with CI and call CI operations without React |
|
|
48
|
+
| `@collective-intelligence/external-apps-client-sdk-react` | Your app, browser | `.`, `/resources`, `/effect` | Providers and entity hooks that read and write CI records |
|
|
49
|
+
| `@collective-intelligence/external-apps-server-sdk` | Your app, server only | `.`, `/auth/federated`, `/effect`, `/next`, `/admin` | BFF routes, sign-in and confidential calls to CI |
|
|
50
|
+
| `@collective-intelligence/external-apps-server-sdk-payload` | Your Payload Site, server only | `.`, `/package`, `/ci-generate` | Connect a Payload Site to CI: the Payload Plugin, and helpers for the site's CI package |
|
|
51
|
+
| `@collective-intelligence/external-apps-server-sdk-strapi` | Your Strapi 5 site, server only | `.` | Serve the documents of a Strapi 5 site to CI through a Gateway |
|
|
52
|
+
| `@collective-intelligence/ui-react` | Both sides | `/ui`, `/resources`, `/icons`, `/hooks`, `/tokens/theme` | CI design-system components that take display-ready props |
|
|
53
|
+
| `@collective-intelligence/cli` | Your machine or pipeline | `ci` binary | Sign in, build and deploy packages, enroll an app |
|
|
54
|
+
| `@collective-intelligence/lint` | Development | `recommended` | Oxlint rules that keep the solution layout and Effect imports correct |
|
|
55
|
+
| `@collective-intelligence/schema-codegen` | Development | `.` | Generate TypeScript, Zod or Effect Schema source from package schemas |
|
|
54
56
|
|
|
55
57
|
You rarely import `schema-codegen` yourself, because `ci package codegen --target zod|effect|types` calls it for you. Generated schemas describe the wire shape only, and the CI backend still validates every payload.
|
|
56
58
|
|
|
@@ -154,9 +156,22 @@ handlers: createExternalApplicationBffNextHandlers({
|
|
|
154
156
|
|
|
155
157
|
[External apps](external-apps.md) covers sign-in, the BFF and fixed workflow routes in detail.
|
|
156
158
|
|
|
159
|
+
### CMS SDKs for a self-hosted content system
|
|
160
|
+
|
|
161
|
+
A CMS SDK connects a self-hosted content system to CI. It serves the site's content through a Gateway, and CI reads it with its one built-in Knowledge Gateway connector, so CI needs no code for your content system. A CMS SDK depends on `external-apps-server-sdk` at the exact same version: install no other server SDK version next to it.
|
|
162
|
+
|
|
163
|
+
| Package | Subpath | What you get |
|
|
164
|
+
| ---------------------------------- | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
165
|
+
| `external-apps-server-sdk-payload` | `.` | `ciPayloadPlugin`, the Payload Plugin that serves the chosen collections and pushes each change |
|
|
166
|
+
| `external-apps-server-sdk-payload` | `/package` | The Payload Package Helpers `payloadGateway`, `payloadKnowledge`, `payloadGatewayPushGrant`, `payloadPageEditor`, `payloadPackageDependencies` and `payloadOperationContract`, for the site's CI package; it loads no Payload module |
|
|
167
|
+
| `external-apps-server-sdk-payload` | `/ci-generate` | The `payload ci-generate` command that the plugin adds; Payload loads it, so you do not import it |
|
|
168
|
+
| `external-apps-server-sdk-strapi` | `.` | `defineStrapiSource` and `defineStrapiGatewayPlugin`, which turn a Strapi Document Service into a Gateway resource |
|
|
169
|
+
|
|
170
|
+
The Payload SDK takes `extensions-sdk` as a peer at the exact version, so the helpers and your CI package share one copy. A hosted service, such as Notion, needs no CMS SDK: CI connects it with a built-in integration package.
|
|
171
|
+
|
|
157
172
|
## Effect
|
|
158
173
|
|
|
159
|
-
`effect` `^4.1.0` is a required peer of `extensions-sdk`, `extensions-sdk-backend`, both frontend extension packages and the
|
|
174
|
+
`effect` `^4.1.0` is a required peer of `extensions-sdk`, `extensions-sdk-backend`, both frontend extension packages, the client SDK, the client React SDK, the server SDK and the Payload SDK. The Strapi SDK needs it through the server SDK. The SDKs do not bundle it, so install it in your app and keep one version across the workspace.
|
|
160
175
|
|
|
161
176
|
Effect APIs always come from a `/effect` subpath, and the lint rule `effect-subpath` reports an Effect import from anywhere else.
|
|
162
177
|
|
|
@@ -206,7 +221,8 @@ Some names from older examples no longer exist. An old server SDK subpath fails
|
|
|
206
221
|
| `external-apps-server-sdk/runtime/effect` | `external-apps-server-sdk/effect` |
|
|
207
222
|
| `external-apps-server-sdk/persistence/drizzle/effect` | `external-apps-server-sdk/effect` plus `/effect/node-postgres` |
|
|
208
223
|
| `external-apps-server-sdk/runtime/next` | `external-apps-server-sdk/next` |
|
|
209
|
-
| `external-apps-server-sdk/knowledge-sources/payload` | `ciPayloadPlugin` from `external-apps-server-sdk
|
|
224
|
+
| `external-apps-server-sdk/knowledge-sources/payload` | `ciPayloadPlugin` from `external-apps-server-sdk-payload`, which serves the site's collections as a Gateway |
|
|
225
|
+
| `external-apps-server-sdk/knowledge-sources/strapi` | `external-apps-server-sdk-strapi`; take the resource types from `external-apps-server-sdk/resources` |
|
|
210
226
|
|
|
211
227
|
The two removed packages stopped at version 0.2.0, and npm marks them deprecated.
|
|
212
228
|
|
|
@@ -219,6 +235,8 @@ The two removed packages stopped at version 0.2.0, and npm marks them deprecated
|
|
|
219
235
|
| Render a custom widget in Studio | `extensions-sdk-frontend` for the catalog and `extensions-sdk-frontend-react` (`/studio`, `/studio-api`) |
|
|
220
236
|
| Sign users in with CI and proxy record reads and writes from a Next.js server | `external-apps-server-sdk` (`/auth/federated`, `/next`) |
|
|
221
237
|
| Call CI from server code with the application's credentials | `external-apps-server-sdk` root or `/effect` |
|
|
238
|
+
| Connect a Payload Site to CI | `external-apps-server-sdk-payload`, with `/package` in the site's CI package |
|
|
239
|
+
| Connect a Strapi 5 site to CI | `external-apps-server-sdk-strapi` |
|
|
222
240
|
| Show and edit CI records on a browser page | `external-apps-client-sdk-react` (`/resources`) |
|
|
223
241
|
| Call CI from a browser without React | `external-apps-client-sdk` |
|
|
224
242
|
| Reuse CI design-system components | `ui-react` |
|
|
@@ -256,17 +256,19 @@ Code in the template imports CI packages and its own workspaces by package name
|
|
|
256
256
|
|
|
257
257
|
The SDKs split by where the code runs. [SDKs](../develop/sdks.md) has the full map; these are the subpaths you meet most.
|
|
258
258
|
|
|
259
|
-
| Package
|
|
260
|
-
|
|
|
261
|
-
| `@collective-intelligence/extensions-sdk`
|
|
262
|
-
| `@collective-intelligence/extensions-sdk-backend`
|
|
263
|
-
| `@collective-intelligence/extensions-sdk-frontend`
|
|
264
|
-
| `@collective-intelligence/extensions-sdk-frontend-react`
|
|
265
|
-
| `@collective-intelligence/external-apps-server-sdk`
|
|
266
|
-
| `@collective-intelligence/external-apps-
|
|
267
|
-
| `@collective-intelligence/external-apps-
|
|
268
|
-
|
|
269
|
-
|
|
259
|
+
| Package | Runs | Holds | Main subpaths |
|
|
260
|
+
| ----------------------------------------------------------- | ------------------ | ------------------------------------------------------------------------ | ---------------------------------------------------------- |
|
|
261
|
+
| `@collective-intelligence/extensions-sdk` | Inside CI | Declarations such as `declarePackage`, `declareAgent`, `declareWorkflow` | `.`, `./effect` |
|
|
262
|
+
| `@collective-intelligence/extensions-sdk-backend` | Inside CI | Contracts for backend tools and connectors | `.`, `./effect` |
|
|
263
|
+
| `@collective-intelligence/extensions-sdk-frontend` | Inside CI | Framework-neutral frontend catalog | `.`, `./effect` |
|
|
264
|
+
| `@collective-intelligence/extensions-sdk-frontend-react` | Inside CI | React bindings for Studio and Dashboard contributions | `./studio`, `./dashboard`, `./studio-api`, `./effect` |
|
|
265
|
+
| `@collective-intelligence/external-apps-server-sdk` | Your server | Server client, BFF, authentication, Gateway | `.`, `./auth/federated`, `./effect`, `./next`, `./gateway` |
|
|
266
|
+
| `@collective-intelligence/external-apps-server-sdk-payload` | Your Payload Site | Payload Plugin, Payload Package Helpers, `payload ci-generate` | `.`, `./package`, `./ci-generate` |
|
|
267
|
+
| `@collective-intelligence/external-apps-server-sdk-strapi` | Your Strapi 5 site | Strapi 5 adapter that serves documents through a Gateway | `.` |
|
|
268
|
+
| `@collective-intelligence/external-apps-client-sdk` | Your browser | React-free client and Realtime | `.`, `./resources`, `./effect` |
|
|
269
|
+
| `@collective-intelligence/external-apps-client-sdk-react` | Your browser | React hooks, including the entity hooks in `./resources` | `.`, `./resources`, `./effect` |
|
|
270
|
+
|
|
271
|
+
Every SDK puts its Promise API at the root and its Effect services, Layers, errors and Schemas at `/effect`; the two CMS SDKs, the Payload SDK and the Strapi SDK, have no `/effect`. `effect` is a required peer of every SDK (the Strapi SDK gets it through the server SDK), so install it next to the SDK and keep one `effect` version in the app. Optional peers such as Next.js, Express, Drizzle, Better Auth and the AI SDK sit behind their own subpaths, so importing the server SDK root never loads them. In the template, `/next` is imported only inside `apps/web/src/server`, because `/next` loads Next.js and `/effect` does not.
|
|
270
272
|
|
|
271
273
|
### Template domain parts
|
|
272
274
|
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
# Record Collections
|
|
2
|
+
|
|
3
|
+
`./records` holds the record layer: Record Collections, `RecordWrites` and the
|
|
4
|
+
bridge to Business Logic Machines. A Record Collection is a TanStack DB
|
|
5
|
+
collection of CI records of one query. In a Studio Widget, the runtime of
|
|
6
|
+
`RecordRuntimeProvider` (`./records`) provides `QueryCache`,
|
|
7
|
+
`RecordCollections` and `RecordWrites`, over the Studio Host's `QueryClient`
|
|
8
|
+
and the Studio API client that the Host binds. A widget that uses Record
|
|
9
|
+
Collections mounts it at its root in place of `EffectRuntimeProvider` of
|
|
10
|
+
`/effect`, which provides only `QueryCache` and loads without TanStack DB.
|
|
11
|
+
|
|
12
|
+
Install the TanStack peers with the exact versions in the package's
|
|
13
|
+
`peerDependencies`: `@tanstack/db` and `@tanstack/react-db` `1.0.0-rc.1.5`,
|
|
14
|
+
`@tanstack/query-db-collection` `1.5.2`, `@tanstack/offline-transactions`
|
|
15
|
+
`1.2.1`, and `@tanstack/query-core`. Load the TanStack DB skills that
|
|
16
|
+
[tanstack-skills.md](tanstack-skills.md) names before you write a live query
|
|
17
|
+
or a collection.
|
|
18
|
+
|
|
19
|
+
## Which kind to use
|
|
20
|
+
|
|
21
|
+
| Data | Use |
|
|
22
|
+
| ------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- |
|
|
23
|
+
| Records of one Studio API query that the widget shows as a list or follows across views | Query Record Collection |
|
|
24
|
+
| A one-off read that is not a set of records you show or follow: a count, a search, a report | Plain TanStack Query (`useQuery`, `QueryCache.fetch`) |
|
|
25
|
+
| Records that other users change while the widget is open | A Query Record Collection, read again on a user action; Studio has no realtime source |
|
|
26
|
+
|
|
27
|
+
- **Query Record Collection**: `RecordCollections.query(options)`, with
|
|
28
|
+
`options` `{ queryKey, schema, load, target? }`. `load` is an Effect that returns every record of the query as
|
|
29
|
+
`{ id, revision, value }`. Its rows stay on the Studio Host's `QueryClient`,
|
|
30
|
+
which the Host and all widgets share, so start each `queryKey` with the
|
|
31
|
+
package name. Pass `target: studioViewWriteTarget(view)` when the query
|
|
32
|
+
holds a view's data items: an update of an item then shows in every
|
|
33
|
+
collection of that view that holds it.
|
|
34
|
+
- **Realtime Record Collection**: a realtime collection needs a source of
|
|
35
|
+
Change Hints, and the Studio Host gives none. `RecordCollections.realtime`
|
|
36
|
+
fails its sync in Studio with `RecordSyncFailed` (`retrying: false`).
|
|
37
|
+
- `schema` is an Effect `Schema` of the record value. A record that does not
|
|
38
|
+
decode fails the collection's sync with `RecordSyncFailed`.
|
|
39
|
+
- Provide the services that `load` needs where you call `query`, for example
|
|
40
|
+
`Effect.provide(layerStudioApi())`: the widget runtime provides only
|
|
41
|
+
`QueryCache`, `RecordCollections` and `RecordWrites`.
|
|
42
|
+
|
|
43
|
+
## Business Logic Machines
|
|
44
|
+
|
|
45
|
+
A Business Logic Machine reads records through a live query and keeps ids or
|
|
46
|
+
counts in its context, never rows. Pass `useRecordRuntime()` as `runtime` in
|
|
47
|
+
the machine input.
|
|
48
|
+
|
|
49
|
+
- `fromLiveQuery((input) => effect)` follows a Record Collection or a live
|
|
50
|
+
query collection over Record Collections. It sends the parent
|
|
51
|
+
`{ type: "records.rows", rows }` when the rows are ready and after each
|
|
52
|
+
change, and `{ type: "records.failed", error }` when the query or its first
|
|
53
|
+
load fails. A stop ends the subscription.
|
|
54
|
+
- Each row is `{ id, revision, value }`.
|
|
55
|
+
|
|
56
|
+
```tsx
|
|
57
|
+
import { layerStudioApi } from "@collective-intelligence/extensions-sdk-frontend-react/effect"
|
|
58
|
+
import {
|
|
59
|
+
fromLiveQuery,
|
|
60
|
+
RecordCollections,
|
|
61
|
+
useRecordRuntime
|
|
62
|
+
} from "@collective-intelligence/extensions-sdk-frontend-react/records"
|
|
63
|
+
import * as Effect from "effect/Effect"
|
|
64
|
+
|
|
65
|
+
const watchItems = fromLiveQuery(
|
|
66
|
+
(input: Readonly<{ runtime: ReturnType<typeof useRecordRuntime> }>) =>
|
|
67
|
+
RecordCollections.use((collections) =>
|
|
68
|
+
collections.query({
|
|
69
|
+
load: readViewItems, // an Effect on StudioApi that returns the records
|
|
70
|
+
queryKey: ["com.acme.crm", "view-items"],
|
|
71
|
+
schema: Item
|
|
72
|
+
})
|
|
73
|
+
).pipe(Effect.provide(layerStudioApi()))
|
|
74
|
+
)
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Writes
|
|
78
|
+
|
|
79
|
+
An update of a view data item is a Record Collection transaction:
|
|
80
|
+
`RecordWrites.update` (or `fromTransaction`) with
|
|
81
|
+
`studioViewWriteTarget({ organizationId, slug, viewId })`, `RecordId` and
|
|
82
|
+
`IdempotencyKey` of `./records`, on the widget's own Query Record
|
|
83
|
+
Collection. The item shows the change at once in every collection of the
|
|
84
|
+
view that holds it, CI's answer replaces it before the write settles, and a
|
|
85
|
+
refusal rolls back only that change.
|
|
86
|
+
|
|
87
|
+
```ts
|
|
88
|
+
import {
|
|
89
|
+
IdempotencyKey,
|
|
90
|
+
RecordId,
|
|
91
|
+
RecordWrites,
|
|
92
|
+
studioViewWriteTarget
|
|
93
|
+
} from "@collective-intelligence/extensions-sdk-frontend-react/records"
|
|
94
|
+
|
|
95
|
+
const markLost = (items: QueryRecordCollection<RecordRow<Item>>, id: string) =>
|
|
96
|
+
RecordWrites.use((writes) =>
|
|
97
|
+
writes.update({
|
|
98
|
+
change: { stage: "lost" },
|
|
99
|
+
collection: items,
|
|
100
|
+
id: RecordId.make(id),
|
|
101
|
+
idempotencyKey: IdempotencyKey.make(crypto.randomUUID()),
|
|
102
|
+
target: studioViewWriteTarget(view)
|
|
103
|
+
})
|
|
104
|
+
)
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
The Studio API write path covers updates of view data items only:
|
|
108
|
+
`RecordWrites.create` and `delete` are refused. For those writes:
|
|
109
|
+
|
|
110
|
+
- Run each write in a `fromEffect` actor through `StudioApi`, then refresh
|
|
111
|
+
the reads: `invalidate` the collection's `queryKey` with `QueryCache`.
|
|
112
|
+
- For an optimistic create or delete, file an SDK gap (see
|
|
113
|
+
[File an SDK gap](#file-an-sdk-gap)) and write no optimistic value, record
|
|
114
|
+
cache or write queue in the widget.
|
|
115
|
+
|
|
116
|
+
Writes to one record run one at a time across every widget bundle, through
|
|
117
|
+
one lock that each copy of the record layer shares. Studio starts no outbox:
|
|
118
|
+
a write still pending at a reload is not sent again.
|
|
119
|
+
|
|
120
|
+
## Server rendering
|
|
121
|
+
|
|
122
|
+
The Studio Host renders widgets in the browser. `seedRecords` and
|
|
123
|
+
`getRequestClients` exist in the `react-server` build of `./records` for
|
|
124
|
+
parity with the external-apps SDK; a widget does not use them. See the
|
|
125
|
+
[extensions-sdk-frontend-react-tanstack-db-ssr](../skills/extensions-sdk-frontend-react-tanstack-db-ssr/SKILL.md)
|
|
126
|
+
skill.
|
|
127
|
+
|
|
128
|
+
## Errors
|
|
129
|
+
|
|
130
|
+
| Error | Meaning |
|
|
131
|
+
| --------------------------- | ---------------------------------------------------------------------------- |
|
|
132
|
+
| `RecordSyncFailed` | A collection could not load or apply records; `retrying` tells if it retries |
|
|
133
|
+
| `RecordWriteRefused` | The Studio API refused the write; only that write rolls back |
|
|
134
|
+
| `RecordWriteConflict` | The record changed since the revision the write sent (Studio API 409) |
|
|
135
|
+
| `RecordWriteOutcomeUnknown` | No answer arrived within the 60-second resend window |
|
|
136
|
+
|
|
137
|
+
## File an SDK gap
|
|
138
|
+
|
|
139
|
+
When the record layer cannot express what a widget needs, stop and report it;
|
|
140
|
+
write no local optimistic code, record cache or write queue.
|
|
141
|
+
|
|
142
|
+
1. Write down the flow, the record type, and the `./records` call that is
|
|
143
|
+
missing.
|
|
144
|
+
2. Open an issue for `@collective-intelligence/extensions-sdk-frontend-react`
|
|
145
|
+
with that note, or tell the user that the SDK lacks it.
|
|
146
|
+
3. Until the SDK has it, keep the flow on `fromEffect` writes and
|
|
147
|
+
`QueryCache` refreshes, or leave it unbuilt.
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# TanStack skills
|
|
2
|
+
|
|
3
|
+
`@tanstack/db` and `@tanstack/react-db` ship their own agent skills, which
|
|
4
|
+
TanStack Intent loads by name. This SDK names the ones to load and adds the
|
|
5
|
+
rules of its record layer; it copies none of them.
|
|
6
|
+
|
|
7
|
+
## Allowlist the packages
|
|
8
|
+
|
|
9
|
+
Permit both packages in the extension's `package.json`, then run
|
|
10
|
+
`intent install` (`@tanstack/intent` as a devDependency) and commit what it
|
|
11
|
+
writes:
|
|
12
|
+
|
|
13
|
+
```json
|
|
14
|
+
{
|
|
15
|
+
"intent": {
|
|
16
|
+
"skills": ["@tanstack/db", "@tanstack/react-db"],
|
|
17
|
+
"exclude": ["@tanstack/db#meta-framework"]
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
`intent list` shows the permitted skills; `intent load <package>#<skill>`
|
|
23
|
+
prints one.
|
|
24
|
+
|
|
25
|
+
## Skills to load
|
|
26
|
+
|
|
27
|
+
| Task | Load |
|
|
28
|
+
| ------------------------------------------------------------------------------- | ------------------------------------------- |
|
|
29
|
+
| Any work on Record Collections: concepts, and the entry to the other skills | `@tanstack/db#db-core` |
|
|
30
|
+
| A live query: `from`, `where`, `join`, `select`, `orderBy`, `$hasPendingWrites` | `@tanstack/db#db-core/live-queries` |
|
|
31
|
+
| `useLiveQuery` and the other React hooks | `@tanstack/react-db#react-db` |
|
|
32
|
+
| What a pending write shows, and the transaction states | `@tanstack/db#db-core/mutations-optimistic` |
|
|
33
|
+
| The states of a collection (`loading`, `ready`, `error`) | `@tanstack/db#db-core/collection-setup` |
|
|
34
|
+
|
|
35
|
+
These skills teach TanStack DB itself. Where one of them makes a collection
|
|
36
|
+
(`createCollection`, `queryCollectionOptions`) or writes
|
|
37
|
+
(`collection.insert`, `collection.update`, `collection.delete`,
|
|
38
|
+
`createOptimisticAction`, `createTransaction`), use the SDK instead: open
|
|
39
|
+
collections with `RecordCollections`, and write as
|
|
40
|
+
[record-collections.md](record-collections.md) says.
|
|
41
|
+
|
|
42
|
+
The SDK owns two topics, so skip their skills:
|
|
43
|
+
`@tanstack/db#db-core/custom-adapter` (the SDK adapts the Studio API) and
|
|
44
|
+
`@tanstack/db#db-core/persistence` (a widget keeps no records across
|
|
45
|
+
reloads).
|
|
46
|
+
|
|
47
|
+
## The shipped server-rendering skill is out of date
|
|
48
|
+
|
|
49
|
+
`@tanstack/db#meta-framework` was written for TanStack DB 0.6 and says that
|
|
50
|
+
TanStack DB has no server rendering. TanStack DB `1.0.0-rc.1.5` has it, but a
|
|
51
|
+
Studio Widget renders in the browser, so neither applies to a widget. Run the
|
|
52
|
+
[extensions-sdk-frontend-react-tanstack-db-ssr](../skills/extensions-sdk-frontend-react-tanstack-db-ssr/SKILL.md)
|
|
53
|
+
skill in its place; the allowlist above excludes it.
|
|
54
|
+
|
|
55
|
+
## TanStack Query rules
|
|
56
|
+
|
|
57
|
+
Apply these rules on top of the repository `tanstack-query` skill; where they
|
|
58
|
+
differ, these win.
|
|
59
|
+
|
|
60
|
+
- Write in a `fromEffect` actor of `/effect`, through `StudioApi`, never with
|
|
61
|
+
`useMutation` or its "Optimistic Updates" patterns (`onMutate`,
|
|
62
|
+
`setQueryData` and a rollback). The `ci-solution/effect-writes` lint rule
|
|
63
|
+
reports `useMutation`. After the write, refresh the reads with
|
|
64
|
+
`QueryCache` (`invalidate`, `setData`, `update`, `remove`).
|
|
65
|
+
- An optimistic write of a CI record belongs to the record layer: file an SDK
|
|
66
|
+
gap when `./records` cannot make it, as
|
|
67
|
+
[record-collections.md](record-collections.md) says.
|
|
68
|
+
- Read one-off data with `useQuery`, or with `QueryCache.fetch` in a machine.
|
|
69
|
+
Records that the widget shows as a list or follows go in a Query Record
|
|
70
|
+
Collection.
|
|
71
|
+
- Start each query key with the package name: the Studio Host and all widgets
|
|
72
|
+
share one `QueryClient`.
|
|
73
|
+
- Skip the "SSR & Hydration" steps of the `tanstack-query` skill: the Studio
|
|
74
|
+
Host renders widgets in the browser.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@collective-intelligence/extensions-sdk-frontend-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"description": "Public hosted React contribution contracts for Collective Intelligence extensions.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -61,6 +61,18 @@
|
|
|
61
61
|
"types": "./dist/effect.d.ts",
|
|
62
62
|
"import": "./dist/effect.js",
|
|
63
63
|
"default": "./dist/effect.js"
|
|
64
|
+
},
|
|
65
|
+
"./records": {
|
|
66
|
+
"react-server": {
|
|
67
|
+
"ci-source": "./src/records.server.ts",
|
|
68
|
+
"types": "./dist/records.server.d.ts",
|
|
69
|
+
"import": "./dist/records.server.js",
|
|
70
|
+
"default": "./dist/records.server.js"
|
|
71
|
+
},
|
|
72
|
+
"ci-source": "./src/records.ts",
|
|
73
|
+
"types": "./dist/records.d.ts",
|
|
74
|
+
"import": "./dist/records.js",
|
|
75
|
+
"default": "./dist/records.js"
|
|
64
76
|
}
|
|
65
77
|
},
|
|
66
78
|
"scripts": {
|
|
@@ -80,12 +92,17 @@
|
|
|
80
92
|
"type-check": "bun check --no-script -p tsconfig.json && bun check --no-script -p tsconfig.type-tests.json"
|
|
81
93
|
},
|
|
82
94
|
"dependencies": {
|
|
83
|
-
"@collective-intelligence/effect-xstate": "0.
|
|
84
|
-
"@collective-intelligence/extensions-sdk": "0.
|
|
85
|
-
"@collective-intelligence/extensions-sdk-frontend": "0.
|
|
95
|
+
"@collective-intelligence/effect-xstate": "0.13.0",
|
|
96
|
+
"@collective-intelligence/extensions-sdk": "0.13.0",
|
|
97
|
+
"@collective-intelligence/extensions-sdk-frontend": "0.13.0"
|
|
86
98
|
},
|
|
87
99
|
"peerDependencies": {
|
|
88
|
-
"@collective-intelligence/ui-react": "0.
|
|
100
|
+
"@collective-intelligence/ui-react": "0.13.0",
|
|
101
|
+
"@tanstack/db": "1.0.0-rc.1.5",
|
|
102
|
+
"@tanstack/offline-transactions": "1.2.1",
|
|
103
|
+
"@tanstack/query-core": ">=5 <6",
|
|
104
|
+
"@tanstack/query-db-collection": "1.5.2",
|
|
105
|
+
"@tanstack/react-db": "1.0.0-rc.1.5",
|
|
89
106
|
"@tanstack/react-query": ">=5 <6",
|
|
90
107
|
"@xyflow/react": ">=12 <13",
|
|
91
108
|
"effect": "^4.1.0",
|
|
@@ -102,12 +119,17 @@
|
|
|
102
119
|
"access": "public"
|
|
103
120
|
},
|
|
104
121
|
"devDependencies": {
|
|
105
|
-
"@collective-intelligence/ui-react": "0.
|
|
122
|
+
"@collective-intelligence/ui-react": "0.13.0",
|
|
106
123
|
"@effect/eslint-plugin": "0.3.2",
|
|
107
124
|
"@effect/vitest": "4.1.4",
|
|
108
125
|
"@hey-api/openapi-ts": "^0.96.0",
|
|
109
126
|
"@oxlint/plugins": "1.94.0",
|
|
110
127
|
"@punks/lints": "0.2.0",
|
|
128
|
+
"@tanstack/db": "1.0.0-rc.1.5",
|
|
129
|
+
"@tanstack/offline-transactions": "1.2.1",
|
|
130
|
+
"@tanstack/query-core": "5.101.4",
|
|
131
|
+
"@tanstack/query-db-collection": "1.5.2",
|
|
132
|
+
"@tanstack/react-db": "1.0.0-rc.1.5",
|
|
111
133
|
"@tanstack/react-query": "5.101.4",
|
|
112
134
|
"@testing-library/react": "^16.3.2",
|
|
113
135
|
"@types/bun": "1.4.2",
|
|
@@ -130,5 +152,5 @@
|
|
|
130
152
|
"vitest": "5.0.2",
|
|
131
153
|
"xstate": "5.33.3"
|
|
132
154
|
},
|
|
133
|
-
"gitHead": "
|
|
155
|
+
"gitHead": "d3e93c4287307c474b0bf32c386a1471fe67ce2c"
|
|
134
156
|
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: extensions-sdk-frontend-react-move-to-record-collections
|
|
3
|
+
description: Move the optimistic writes of a Studio Widget on `@collective-intelligence/extensions-sdk-frontend-react` off `QueryCache.optimisticUpdate` and `optimistic-write` modules, toward the record layer of `./records`. Use when an SDK upgrade fails the type-check on `optimisticUpdate`, `pending`, `QueryCacheWriteValues` or `QueryCacheOptimisticOptions`, or code imports an `entities/optimistic-write` module.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Move optimistic writes to the record layer
|
|
7
|
+
|
|
8
|
+
Reference: [record-collections.md](../../docs/record-collections.md),
|
|
9
|
+
[effect.md](../../docs/effect.md).
|
|
10
|
+
|
|
11
|
+
The SDK release with `./records` removed `QueryCache.optimisticUpdate`,
|
|
12
|
+
`QueryCache.pending`, the types `QueryCacheWriteValues` and
|
|
13
|
+
`QueryCacheOptimisticOptions`, and the `optimistic-write` engine, with no
|
|
14
|
+
wrapper. Every optimistic write of a CI record is a Record Collection
|
|
15
|
+
transaction. A widget stays on the old SDK until this skill has moved every
|
|
16
|
+
call site.
|
|
17
|
+
|
|
18
|
+
## Steps
|
|
19
|
+
|
|
20
|
+
1. **Inventory.** Upgrade the SDK and run the type-check. Also search for
|
|
21
|
+
`optimisticUpdate(`, `.pending(`, `QueryCacheWriteValues`,
|
|
22
|
+
`QueryCacheOptimisticOptions`, `optimistic-write`, and `useMutation` with
|
|
23
|
+
`onMutate`. Done when you have a list of call sites, each with what it
|
|
24
|
+
writes.
|
|
25
|
+
2. **Sort each call site**: case **A** writes a CI record or a view data
|
|
26
|
+
item; case **B** edits a cache value that is not a CI record, such as a
|
|
27
|
+
preference or a computed list. Done when each call site has its case.
|
|
28
|
+
3. **Move view data item updates of case A to `RecordWrites`.** Run
|
|
29
|
+
`RecordWrites.update` or `fromTransaction` with
|
|
30
|
+
`studioViewWriteTarget(view)` on the widget's Query Record Collection, and
|
|
31
|
+
delete the old optimistic call. A create or a delete of case A has no
|
|
32
|
+
Studio write path: follow "File an SDK gap" in `record-collections.md`,
|
|
33
|
+
once per record type, and move it with step 4. Done when each update of
|
|
34
|
+
case A runs through `RecordWrites` and each other write of case A has a
|
|
35
|
+
filed gap.
|
|
36
|
+
4. **Move each call site to the `QueryCache` steps.** In its `fromEffect`
|
|
37
|
+
actor: `cancel` the keys, `update` them, run the write through
|
|
38
|
+
`StudioApi`, and `invalidate` the keys when the actor ends. Delete the
|
|
39
|
+
`confirm` option and the `{ confirmed, optimistic }` write function. Done
|
|
40
|
+
when no call site calls `optimisticUpdate` or an `optimistic-write`
|
|
41
|
+
module.
|
|
42
|
+
5. **Move lists to Query Record Collections** where the widget shows or
|
|
43
|
+
follows records, as the `extensions-sdk-frontend-react-record-collections`
|
|
44
|
+
skill says. Done when each such list reads through a live query.
|
|
45
|
+
6. **Replace the pending reads.** `pending(queryKey)` becomes the state of
|
|
46
|
+
the machine that runs the write, or `$hasPendingWrites` in a live query
|
|
47
|
+
over a Record Collection. Done when the search of step 1 finds nothing.
|
|
48
|
+
7. **Fix the tests.** Remove `optimisticUpdate` and `pending` from
|
|
49
|
+
`makeTestQueryCache` overrides and from `calls` assertions, and assert on
|
|
50
|
+
the `cancel`, `update` and `invalidate` calls and entries. Done when the
|
|
51
|
+
tests pass.
|
|
52
|
+
8. **Verify.** Run the type-check, the tests and oxlint with the
|
|
53
|
+
`recommended` config of `@collective-intelligence/lint`. Done when all
|
|
54
|
+
pass with no `ci-solution/effect-writes` finding.
|