@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.
Files changed (49) hide show
  1. package/AGENTS.md +29 -10
  2. package/README.md +20 -21
  3. package/dist/effect/effect-runtime/query-cache.d.ts +3 -146
  4. package/dist/effect.d.ts +1 -1
  5. package/dist/effect.js +1 -1
  6. package/dist/record-layer/collection-ids.d.ts +8 -0
  7. package/dist/record-layer/collections/id-reads.d.ts +26 -0
  8. package/dist/record-layer/collections/query.d.ts +55 -0
  9. package/dist/record-layer/collections/realtime.d.ts +124 -0
  10. package/dist/record-layer/errors.d.ts +64 -0
  11. package/dist/record-layer/identity.d.ts +57 -0
  12. package/dist/record-layer/index.d.ts +23 -0
  13. package/dist/record-layer/layer.d.ts +11 -0
  14. package/dist/record-layer/machines.d.ts +45 -0
  15. package/dist/record-layer/outbox.d.ts +141 -0
  16. package/dist/record-layer/outbox.test-support.d.ts +182 -0
  17. package/dist/record-layer/ports.d.ts +141 -0
  18. package/dist/record-layer/position.d.ts +12 -0
  19. package/dist/record-layer/seed/client.d.ts +38 -0
  20. package/dist/record-layer/seed/freshness.d.ts +19 -0
  21. package/dist/record-layer/seed/server.d.ts +77 -0
  22. package/dist/record-layer/server.d.ts +6 -0
  23. package/dist/record-layer/service.d.ts +48 -0
  24. package/dist/record-layer/targets.d.ts +50 -0
  25. package/dist/record-layer/write-lock.d.ts +23 -0
  26. package/dist/record-layer/writes.d.ts +85 -0
  27. package/dist/records/adapters.d.ts +37 -0
  28. package/dist/records/runtime-provider.d.ts +22 -0
  29. package/dist/records.d.ts +12 -0
  30. package/dist/records.js +2 -0
  31. package/dist/records.server.d.ts +4 -0
  32. package/dist/records.server.js +1 -0
  33. package/dist/studio-api/@tanstack/react-query.gen.d.ts +14 -14
  34. package/dist/workflow.js +2 -1
  35. package/dist/workflows/default-template-ui/inputs/default-input-details.d.ts +9 -0
  36. package/dist/workflows/default-template-ui/inputs/translations.d.ts +5 -0
  37. package/dist/workflows/field-editor/authored-value.d.ts +4 -0
  38. package/dist/workflows/workflow-runtime/read-only-saved-value-field.d.ts +10 -0
  39. package/dist/workflows/workflow-runtime/translations.d.ts +1 -0
  40. package/docs/effect.md +8 -90
  41. package/docs/guide/ai/index.md +1 -1
  42. package/docs/guide/develop/sdks.md +34 -16
  43. package/docs/guide/platform/entrypoints.md +13 -11
  44. package/docs/record-collections.md +147 -0
  45. package/docs/tanstack-skills.md +74 -0
  46. package/package.json +29 -7
  47. package/skills/extensions-sdk-frontend-react-move-to-record-collections/SKILL.md +54 -0
  48. package/skills/extensions-sdk-frontend-react-record-collections/SKILL.md +48 -0
  49. package/skills/extensions-sdk-frontend-react-tanstack-db-ssr/SKILL.md +34 -0
@@ -0,0 +1,48 @@
1
+ ---
2
+ name: extensions-sdk-frontend-react-record-collections
3
+ description: Build Studio Widgets and their Business Logic Machines on the Record Collections of `@collective-intelligence/extensions-sdk-frontend-react/records`. Use when a widget shows or follows a list of records from the Studio API, code imports `@tanstack/db` or `@tanstack/react-db`, or lint reports `ci-solution/effect-writes`.
4
+ ---
5
+
6
+ # Build widgets on Record Collections
7
+
8
+ Reference: [record-collections.md](../../docs/record-collections.md),
9
+ [tanstack-skills.md](../../docs/tanstack-skills.md),
10
+ [effect.md](../../docs/effect.md).
11
+
12
+ ## Steps
13
+
14
+ 1. **Load the TanStack DB skills.** Check that the extension's
15
+ `package.json` permits `@tanstack/db` and `@tanstack/react-db` in
16
+ `intent.skills`, then load each skill that `tanstack-skills.md` names for
17
+ the task. Done when `intent list` shows them and you have read
18
+ `@tanstack/db#db-core`.
19
+ 2. **Choose the kind** for each data set with the table "Which kind to use"
20
+ in `record-collections.md`: a Query Record Collection for lists the widget
21
+ shows or follows, plain TanStack Query for one-off reads. Studio has no
22
+ Realtime Record Collection. Done when each data set has one kind.
23
+ 3. **Mount the runtime.** Put `RecordRuntimeProvider` of `/records` at the
24
+ root of each widget, in place of `EffectRuntimeProvider` of `/effect`, and
25
+ pass `useRecordRuntime()` to each machine in its input. Its runtime also
26
+ has `QueryCache`. Done when every machine that reads records gets that
27
+ runtime.
28
+ 4. **Open each collection** with `RecordCollections.query` (`queryKey`,
29
+ `schema`, `load`) in a `fromLiveQuery` actor, with the services of `load`
30
+ provided at the call. Start each `queryKey` with the package name, and keep the
31
+ keys and schemas in one module. Done when no module calls
32
+ `createCollection` or `queryCollectionOptions` itself.
33
+ 5. **Keep rows out of state.** The machine takes `records.rows` events and
34
+ keeps ids or counts; views read rows with `useLiveQuery` or from the
35
+ machine's events. Done when no React state or machine context holds a
36
+ copy of a row.
37
+ 6. **Write through the record layer.** Update a view data item with
38
+ `RecordWrites.update` or `fromTransaction` and
39
+ `studioViewWriteTarget(view)` on the widget's Query Record Collection.
40
+ Run a create or a delete in a `fromEffect` actor on `StudioApi`, then
41
+ `invalidate` the collection's key with `QueryCache`; for an optimistic
42
+ create or delete, follow "File an SDK gap" in `record-collections.md`.
43
+ Done when the widget has no `useMutation`, no hand-written record cache
44
+ and no write queue.
45
+ 7. **Verify.** Run the type-check, the machine tests (with
46
+ `makeTestQueryCache()`) and oxlint with the `recommended` config of
47
+ `@collective-intelligence/lint`. Done when all pass with no
48
+ `ci-solution/effect-writes` finding.
@@ -0,0 +1,34 @@
1
+ ---
2
+ name: extensions-sdk-frontend-react-tanstack-db-ssr
3
+ description: Decide how a Studio Widget on `@collective-intelligence/extensions-sdk-frontend-react/records` shows Record Collection rows on first render, given that the Studio Host renders widgets in the browser. Use when a widget asks for server rendering, prefetch or hydration of Record Collections, imports `seedRecords` or `getRequestClients`, or the `@tanstack/db#meta-framework` skill would apply.
4
+ ---
5
+
6
+ # First render of Record Collections in a widget
7
+
8
+ Reference: [record-collections.md](../../docs/record-collections.md),
9
+ [tanstack-skills.md](../../docs/tanstack-skills.md).
10
+
11
+ The Studio Host renders widgets in the browser and has no React Server
12
+ Components. The shipped `@tanstack/db#meta-framework` skill does not apply.
13
+
14
+ ## Steps
15
+
16
+ 1. **Check where the code renders.** A Studio or Dashboard contribution
17
+ renders in the Host's browser page. Code that also runs in a Next.js app
18
+ on `@collective-intelligence/external-apps-client-sdk-react` follows that
19
+ SDK's `client-sdk-react-tanstack-db-ssr` skill there. Done when you know
20
+ which host renders each component.
21
+ 2. **Drop the server seed from widgets.** Remove `seedRecords`,
22
+ `getRequestClients` and `<RecordSeedBoundary>` from widget code: the
23
+ Host makes no server render, so nothing seeds them. Done when no widget
24
+ module imports them.
25
+ 3. **Load in the browser.** Open the Query Record Collection in a
26
+ `fromLiveQuery` actor as soon as the widget mounts. Until the first
27
+ `records.rows` event, the machine is in a loading state and the view shows
28
+ it. Done when the widget renders a loading state, then the rows.
29
+ 4. **Reuse the Host's cache.** Give the collection the same `queryKey` in
30
+ every widget that reads the same records: the Host and all widgets share
31
+ one `QueryClient`, so those widgets share one cache entry. Done when
32
+ widgets that read the same records share one key.
33
+ 5. **Verify.** Open the widget in Studio and check the loading state, then the
34
+ rows, with no error in the console. Done when both show.