@notis_ai/cli 0.2.30 → 0.2.32

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 (87) hide show
  1. package/README.md +15 -0
  2. package/config/notis_app_design_rules.json +22 -0
  3. package/dist/agent-hooks/notis-agent-hook.mjs +38244 -10823
  4. package/dist/base-skills/notis-cli/.notis-base-skill.json +1 -1
  5. package/dist/base-skills/notis-cli/references/native-databases.md +1 -1
  6. package/dist/base-skills/notis-query/.notis-base-skill.json +1 -1
  7. package/dist/base-skills/notis-query/references/query.md +6 -4
  8. package/dist/base-skills/notis-spaces/.notis-base-skill.json +1 -1
  9. package/dist/base-skills/notis-spaces/SKILL.md +12 -4
  10. package/dist/base-skills/notis-spaces/references/architecture.md +4 -1
  11. package/dist/base-skills/notis-spaces/references/design.md +7 -1
  12. package/dist/base-skills/notis-spaces/references/fixtures.md +29 -2
  13. package/dist/base-skills/notis-spaces/references/reading.md +3 -1
  14. package/dist/base-skills/notis-spaces/references/release.md +3 -1
  15. package/dist/base-skills/notis-spaces/references/sdk.md +112 -33
  16. package/dist/base-skills/notis-spaces/references/troubleshooting.md +3 -0
  17. package/dist/base-skills/notis-spaces/references/views.md +20 -0
  18. package/dist/sdk/src/hooks/useNativeDocuments.ts +50 -12
  19. package/dist/sdk/src/index.ts +1 -1
  20. package/dist/sdk/src/space.ts +3 -1
  21. package/dist/sdk/src/tailwind.ts +53 -3
  22. package/dist/sdk/src/ui/icons.tsx +18 -1
  23. package/dist/sdk/src/words/types.ts +28 -0
  24. package/dist/skill-sync/index.js +10 -90
  25. package/dist/skill-sync-worker.mjs +50 -93
  26. package/dist/space-harness/host.js +155 -82
  27. package/dist/space-sdk/dist/chunk-I4Z4UFGB.js +3 -0
  28. package/dist/space-sdk/dist/index.js +2 -2
  29. package/dist/space-sdk/dist/ui.js +12 -12
  30. package/dist/space-sdk/src/hooks/useNativeDocuments.d.ts +23 -0
  31. package/dist/space-sdk/src/index.d.ts +1 -1
  32. package/dist/space-sdk/src/space.ts +3 -1
  33. package/dist/space-sdk/src/tailwind-candidates.d.ts +315 -2
  34. package/dist/space-sdk/src/tailwind.ts +53 -3
  35. package/dist/space-sdk/src/ui/blocks/DataTable.d.ts +19 -4
  36. package/dist/space-sdk/src/ui/blocks/Meter.d.ts +12 -3
  37. package/dist/space-sdk/src/ui/blocks/Tabs.d.ts +7 -1
  38. package/dist/space-sdk/src/ui/blocks/blocks.d.ts +18 -0
  39. package/dist/space-sdk/src/ui/blocks/index.d.ts +3 -3
  40. package/dist/space-sdk/src/ui/charts/CalendarHeatmap.d.ts +69 -0
  41. package/dist/space-sdk/src/ui/charts/Chart.d.ts +18 -3
  42. package/dist/space-sdk/src/ui/charts/chartData.d.ts +19 -0
  43. package/dist/space-sdk/src/ui/charts/heatmapData.d.ts +81 -0
  44. package/dist/space-sdk/src/ui/icons.d.ts +6 -0
  45. package/dist/space-sdk/src/ui/index.d.ts +5 -3
  46. package/dist/space-sdk/src/ui/list/ListReader.d.ts +8 -0
  47. package/dist/space-sdk/src/ui/list/Row.d.ts +11 -1
  48. package/dist/space-sdk/src/ui/period/dateFormat.d.ts +2 -0
  49. package/dist/space-sdk/src/ui/period/dateWords.d.ts +9 -0
  50. package/dist/space-sdk/src/ui/period/periods.d.ts +15 -2
  51. package/dist/space-sdk/src/words/types.ts +28 -0
  52. package/dist/view-renderer/dist/host.js +224 -151
  53. package/dist/view-renderer/src/dom.js +3 -2
  54. package/dist/view-renderer/src/errors.js +9 -0
  55. package/dist/view-renderer/src/host.tsx +12 -5
  56. package/dist/view-renderer/src/remote-broker.js +3 -1
  57. package/dist/view-renderer/src/renderer.js +63 -16
  58. package/dist/view-renderer/src/skeleton.js +70 -18
  59. package/package.json +5 -4
  60. package/skills/notis-query/cli.md +3 -0
  61. package/skills/notis-spaces/cli.md +14 -0
  62. package/src/command-specs/spaces.js +138 -15
  63. package/src/command-specs/tools.js +3 -0
  64. package/src/runtime/api-hosts.generated.js +35 -0
  65. package/src/runtime/api-hosts.js +27 -10
  66. package/src/runtime/app-boundary-validator.js +248 -3
  67. package/src/runtime/app-data-literals.js +32 -23
  68. package/src/runtime/app-platform.js +68 -24
  69. package/src/runtime/http-agent.js +53 -0
  70. package/src/runtime/native-record-files.js +11 -0
  71. package/src/runtime/oauth.js +2 -1
  72. package/src/runtime/skill-sync/cloud-client.ts +0 -10
  73. package/src/runtime/skill-sync/index.ts +13 -15
  74. package/src/runtime/skill-sync/local-scanner.ts +0 -67
  75. package/src/runtime/skill-sync/types.ts +1 -0
  76. package/src/runtime/skill-sync/write-cloud-skill.ts +7 -23
  77. package/src/runtime/space-dependencies.js +66 -0
  78. package/src/runtime/space-fixture-broker.js +23 -8
  79. package/src/runtime/space-platform.js +47 -3
  80. package/src/runtime/space-source.js +10 -1
  81. package/src/runtime/space-test-server.js +124 -6
  82. package/src/runtime/space-verification.js +103 -43
  83. package/src/runtime/space-view-manifest.js +38 -5
  84. package/src/runtime/transport.js +19 -4
  85. package/src/runtime/view-render.js +4 -1
  86. package/template/tailwind.config.ts +2 -35
  87. package/dist/space-sdk/dist/chunk-6GJ2BS7B.js +0 -3
@@ -1 +1 @@
1
- {"schema":1,"stamp":1794658649,"commit":"c85c7d62766a6561de18ec338247843d089cadae"}
1
+ {"schema":1,"stamp":1794771946,"commit":"b5902cc7f64ba2ed2615c903c6e88a58d588bf5f"}
@@ -18,4 +18,4 @@ npx --package @notis_ai/cli@latest -- notis tools exec LOCAL_NOTIS_DATABASE_GET_
18
18
  npx --package @notis_ai/cli@latest -- notis tools exec LOCAL_NOTIS_DATABASE_QUERY --arguments '{"protocol":1,"target":{"space_id":"<space id>","binding":"<binding id>"},"input":{"mode":"rows","page_size":1}}'
19
19
  ```
20
20
 
21
- Most databases are used in Spaces. Such a database is read only through one of its links: `GET_DATABASE` with a bare `database_id` returns `resolved_target` (the main view's `{space_id, binding}`), and a bare-id `QUERY` answers `database_in_spaces` with every link. Reuse that exact target with `protocol: 1`. Every database lives in a Space; a `database_slug` resolves among every database you can reach, and a slug several of them share answers `database_slug_ambiguous` with each `database_id` and its Spaces.
21
+ Most databases are used in Spaces. Such a database is read through one of its links: `GET_DATABASE` and `QUERY` with a bare `database_id` run through your main view and return `resolved_target` (its `{space_id, binding}`); without a main view a bare-id `QUERY` answers `database_in_spaces` with every link. Reuse that exact target with `protocol: 1`, always for writes. Every database lives in a Space; a `database_slug` resolves among every database you can reach, and a slug several of them share answers `database_slug_ambiguous` with each `database_id` and its Spaces.
@@ -1 +1 @@
1
- {"schema":1,"stamp":1794225657,"commit":"c068b2d7889470bec2210030c1aac6770fb54382"}
1
+ {"schema":1,"stamp":1794771946,"commit":"b5902cc7f64ba2ed2615c903c6e88a58d588bf5f"}
@@ -20,9 +20,11 @@ The native query lives directly inside `input`, without another request/query wr
20
20
  ```
21
21
 
22
22
  Use the complete Space binding target returned by schema discovery. Every
23
- database lives in a Space: a bare `database_id` gets `resolved_target` from
24
- `LOCAL_NOTIS_DATABASE_GET_DATABASE`, and a bare-id query answers
25
- `database_in_spaces` with its links. Never remove its record context or substitute
23
+ database lives in a Space: `LOCAL_NOTIS_DATABASE_GET_DATABASE` and a query with a
24
+ bare `{"database_id": ...}` target run through your main view of it and return
25
+ `resolved_target`; reuse that target next, and for every write (writes never take
26
+ a bare ID). Without a main view the query answers `database_in_spaces` with its
27
+ links. Never remove its record context or substitute
26
28
  another database/owner after a denial. `action_id`, when present, retains the
27
29
  saved action's narrower authority rather than granting direct Editor access.
28
30
 
@@ -43,7 +45,7 @@ must be nonempty. Invalid conditions fail—they never become an unrestricted qu
43
45
  | Text/title/URL | `equals`, `not_equals`, `contains`, `not_contains`, `starts_with`, `ends_with`, empty checks |
44
46
  | Number | `equals`, `not_equals`, `greater_than`, `less_than`, inclusive variants, empty checks |
45
47
  | Checkbox | `equals`, `not_equals` with real booleans |
46
- | Select/status | `equals`, `not_equals`, empty checks; use a current option ID or unambiguous label |
48
+ | Select/status | `equals`, `not_equals`, `in` (any of up to 100 options), empty checks; use a current option ID or unambiguous label |
47
49
  | Multi-select/relation | `contains`, `does_not_contain`, empty checks |
48
50
  | Date | `equals`, `before`, `after`, `on_or_before`, `on_or_after`, empty checks; use ISO dates/timestamps |
49
51
 
@@ -1 +1 @@
1
- {"schema":1,"stamp":1794658649,"commit":"c85c7d62766a6561de18ec338247843d089cadae"}
1
+ {"schema":1,"stamp":1794969379,"commit":"73f9e76d42341e84ac32ae1a25ee7f2a8e51052e"}
@@ -87,11 +87,13 @@ user asked, and quote their words in `user_words`. The CLI equivalents are
87
87
 
88
88
  | Task | Read |
89
89
  | --- | --- |
90
- | Build or change a Space | [View authoring](references/views.md), [Design](references/design.md), then [Delivery](references/release.md) |
90
+ | Build or change a Space | [View authoring](references/views.md), [Design](references/design.md), then [Delivery](references/release.md); list filters (`in` for several options): [Params and declared lists](references/views.md#params-and-declared-lists) |
91
+ | Verification fixtures, one view in several states (`contexts`) | [Fixtures](references/fixtures.md): one verify draws every state in English and French |
91
92
  | Read a saved view, chart, report or HTML page | [Read and render](references/reading.md) |
93
+ | Check a view in a browser with `agent-browser` (open it, click, compare 390 and 1440 px) | The notis-browser-control skill (hosted guide: `notis://docs/notis-browser-control`): which runtime, the profile, the saved state |
92
94
  | Save or revise a Notes report or interactive report | [Reports](references/reports.md) |
93
95
  | Choose a memory policy | [Memory](references/memory.md) |
94
- | Data hooks, record pages and the toolkit pieces | [SDK](references/sdk.md) |
96
+ | Data hooks, record pages and the toolkit pieces | [SDK](references/sdk.md); rows and counts (`useNativeDocuments`, `useNativeCount`): [Records and declared reads](references/sdk.md#records-and-declared-reads) |
95
97
  | Explain resources, sharing and lifecycle | [Platform boundaries](references/architecture.md) |
96
98
  | Diagnose a failed check or release | [Troubleshooting](references/troubleshooting.md) |
97
99
  | Publish or share a Space or its update in the Store | [Store publishing](references/store.md): you only prepare the submission and send its page; the person publishes there. No tool publishes |
@@ -171,10 +173,12 @@ stops receiving that piece's fixes.
171
173
  3. Declare each view ([View authoring](references/views.md)) and write it on the
172
174
  pieces ([Design](references/design.md)).
173
175
  4. Build and verify the selected frozen source with fictional fixtures for every
174
- read. Look at EN and FR at 390 and 1440 px; fix failed reads, clipping, wrong
176
+ read ([Fixtures](references/fixtures.md)). Look at EN and FR at 390 and 1440 px; fix failed reads, clipping, wrong
175
177
  data and state transitions before release.
176
178
  5. Deploy within the user's authorization. Read back the exact published
177
- revision, render its live view link and inspect the affected interaction.
179
+ revision, render its live view link and inspect the affected interaction
180
+ (in a browser: the notis-browser-control skill, hosted guide
181
+ `notis://docs/notis-browser-control`).
178
182
  A successful local build is not proof of deployment or live data.
179
183
  6. Return the view-qualified link and distinguish local checks, publication to
180
184
  the installed Space, and Store publication. Reconcile uncertain outcomes with
@@ -196,6 +200,10 @@ tell them who gains or loses access and what happens to the data, using
196
200
  [Consequences](references/architecture.md#consequences-to-explain-before-acting).
197
201
 
198
202
  Skill content has one writer family: `notis skills list|read|create|update|links`.
203
+ `skills update` takes the `target` and `version` exactly as `skills read` printed
204
+ them, plus one of `skill_md` (replaces SKILL.md, keeps the other files) or
205
+ `files` (every file of the Skill, SKILL.md included, as base64 by path), and
206
+ optionally `name`, `description` or `links`.
199
207
  A failed Space target never falls back to another owner or a personal resource.
200
208
  Editing a linked Skill changes the shared resource wherever it remains reachable.
201
209
  Personal enabled/agent settings are separate; curated content is read-only.
@@ -31,7 +31,10 @@ A failed target never falls back to a different authority.
31
31
  The protected owner and Editors of a Space and its ancestors can reach it.
32
32
  Moving a subtree changes who can reach every child/resource; report the actual
33
33
  access delta before moving. Removing an Editor or unlinking a resource revokes
34
- future reads, writes and memory access through that path.
34
+ future reads, writes and memory access through that path. To see who a Space is
35
+ shared with (owner, Editors and how each reaches it, team access, pending
36
+ invitations), use `LOCAL_NOTIS_MANAGE_SPACE` `list_members`; it is read-only and
37
+ refused inside Space views.
35
38
 
36
39
  A Site is a scoped standalone website, not an Editor membership. Record Sites
37
40
  stay pinned to their record, including views whose record param is not the
@@ -3,7 +3,9 @@
3
3
  Decide what the view is for before choosing how to build it: what the person
4
4
  does there, what they look at first, how dense or calm it should be. Then take
5
5
  what fits from `@notis/sdk/ui` ([SDK](sdk.md#toolkit-pieces)). The host frame,
6
- theme tokens, keyboard engine and EN/FR words stay Notis's.
6
+ theme tokens, keyboard engine and EN/FR words stay Notis's. The theme colours
7
+ are Tailwind colours that take any opacity (`bg-accent/10`, `bg-chart-2/40`,
8
+ `text-foreground/60`).
7
9
 
8
10
  Floating UI comes from `Menu`, `Popover` and `Tooltip`; they open inside the
9
11
  Space and pick up its theme. Open as Side, Center or Full belongs to the list
@@ -61,6 +63,10 @@ ring on all four sides. Never restyle the pieces' states.
61
63
  locale (`useNotisRuntime()?.context.locale`). Format dates and numbers with
62
64
  that locale. French runs 15 to 30 percent longer: leave room in tabs, section
63
65
  titles, buttons, badges and table cells.
66
+ - A count in words takes its plural from the count, in each language:
67
+ `pluralWords(n, { one: { en: '{n} campaign', fr: '{n} campagne' }, other: {
68
+ en: '{n} campaigns', fr: '{n} campagnes' } })` from `@notis/sdk/words`
69
+ (French uses the singular for 0 and 1). Never write "1 campaigns" or "(s)".
64
70
 
65
71
  ## Loading, empty and error
66
72
 
@@ -1,7 +1,7 @@
1
1
  # Offline fixtures for Space views
2
2
 
3
3
  Declare a `verificationFixtures` JSON source with `actions` and optional `context`,
4
- `shown`, `viewerReads`, `documentBodies`, `recordViews`. Cases match exact action
4
+ `shown`, `viewerReads`, `documentBodies`, `recordViews`, `images`. Cases match exact action
5
5
  inputs/list params. Each `useShown` name maps to an array of `{params, result}` cases:
6
6
 
7
7
  ```json
@@ -14,7 +14,9 @@ inputs/list params. Each `useShown` name maps to an array of `{params, result}`
14
14
  ```
15
15
 
16
16
  Use your declared list names and exact initial params (including defaults); add a
17
- case for every load-time list read. Put fictional rows in `result.rows` to verify
17
+ case for every load-time list read. A `useNativeCount` read is an `actions` case of
18
+ the binding's query action: `{"inputs": {"request": {"filter": ..., "mode": "count"}},
19
+ "result": {"count": 3, "schema_revision": 1}}` (no `filter` key when it has none). Put fictional rows in `result.rows` to verify
18
20
  populated states. Record views use `{operation: 'record'|'html'|'report', record_key,
19
21
  result}`; native record snapshots require `writable: false` and no authoring target.
20
22
  A record view fixture needs a declared native database resource; a record param is
@@ -25,5 +27,30 @@ sandbox and viewer CSP, sized by its `className` (a 1920x1080 slide box shows th
25
27
  real slide in verify screenshots); popups and network stay blocked offline.
26
28
  When a view reads a record view its fixtures lack, verify names the view, the read,
27
29
  the record key and the missing field, and prints a valid entry to copy.
30
+ `context` sets how verify opens the view: `params` (the opening view params,
31
+ a flat object of text, numbers or true/false), `now` (an ISO time that pins the clock, so a view showing
32
+ how old its data is can be checked with a later `now`), `views` (other params,
33
+ each a state of its own with the same `now`, named `view-<place in the list>`;
34
+ verify checks the first 3 that open another link, the review deck draws all) and `skeletonParams`
35
+ (other params whose loading skeletons are measured too). Verify always draws
36
+ the view in English and in French, so `locale` no longer changes the
37
+ screenshots (still accepted). To check several states in one run, declare
38
+ `contexts` instead of `context`: 1 to 4 entries `{name, params, now, locale}`
39
+ with unique lowercase names (`a-z`, `0-9`, `-`, `_`), for example
40
+ `[{"name": "week", "params": {"period": "week"}}, {"name": "opened",
41
+ "params": {"open": "<row uuid>"}}]`. Verify renders each one at both widths
42
+ and languages (`.notis/view-<key>.<name>-<width>-<locale>.png`), measures the
43
+ loading skeleton of each, and for one whose params open a list item (`open`)
44
+ also saves the reader while the item loads
45
+ (`.notis/pending-<key>.<name>.reader-<width>-<locale>.png`); with one context
46
+ and no `views` the names leave out `.<name>`, and a `context` whose params open an item gets the
47
+ reader screenshot too. The `shown`, `actions` and other cases are shared by
48
+ every context.
49
+ A photo or cover shows in verify when `images` maps the exact URL a fixture
50
+ row holds to a picture next to the fixtures: `{"images":
51
+ {"https://example.com/meal.jpg": "./photos/meal.jpg"}}` (png, jpg, webp, gif
52
+ or avif, at most 32 of 2 MB each and 16 MB in all); an image it cannot load
53
+ fails verify with its URL. These pictures are published with the Space's
54
+ source, so use ones you may share.
28
55
  Keep every fixture fictional and include every load-time read. Failed or missing
29
56
  fixtures fail verification; there is no fallback to the user's real account.
@@ -58,7 +58,9 @@ cite the returned current link, not the historical memory URL or index excerpt.
58
58
  ## Browser interaction when rendering is insufficient
59
59
 
60
60
  Use an available isolated browser session for hover details, pagination, input
61
- changes or installed-host behavior. Reading does not authorize regenerating a
61
+ changes or installed-host behavior. Drive it as the notis-browser-control skill
62
+ says (hosted guide: `notis://docs/notis-browser-control`): which runtime, the
63
+ profile and the saved state. Reading does not authorize regenerating a
62
64
  historical report, modifying data, enabling sharing or deploying source.
63
65
 
64
66
  If sign-in is needed, discover `LOCAL_NOTIS_GET_PORTAL_URL`, inspect its schema
@@ -28,7 +28,9 @@ Ordinary data and resource edits apply immediately; only source needs a release.
28
28
  action/list/body/record fixtures. A denied read, write-on-load or failed width
29
29
  is a failure, not a passing empty page. Inspect both locales and intended states.
30
30
  Missing browser tooling blocks release: install `agent-browser` and make it
31
- available on PATH.
31
+ available on PATH. To drive it (check a live view, open a menu, compare
32
+ widths), follow the notis-browser-control skill (hosted guide:
33
+ `notis://docs/notis-browser-control`).
32
34
  4. **Publish source.** Deploy the frozen, verified snapshot, not edits made after
33
35
  verification: `spaces deploy <dir> --request-id <stable-id>`. Or `spaces preview` seals a candidate, and
34
36
  `spaces promote <release-id> <dir>` publishes that exact candidate. Preview
@@ -6,7 +6,7 @@ list-case format and every required initial-read fixture.
6
6
 
7
7
  | Import | Holds |
8
8
  | --- | --- |
9
- | `@notis/sdk` | Data hooks, navigation, host interactions and record components |
9
+ | `@notis/sdk` | Data hooks (rows with `useNativeDocuments`, how many rows with `useNativeCount`, writes with `useNativeMutation`: [Records and declared reads](#records-and-declared-reads)), navigation, host interactions and record components |
10
10
  | `@notis/sdk/ui` | The toolkit pieces and their hooks |
11
11
  | `@notis/sdk/config` | `defineSpace` and view declarations |
12
12
  | `@notis/sdk/words` | Pure action ids, EN and FR words and key specs |
@@ -49,16 +49,21 @@ rather than from a copy.
49
49
  `OpenAsMenu`, `Keycap`. `ListReader` draws the whole list chrome from props:
50
50
  `search` (the host top bar field), `tabs` (pills in one 44px row), `title`
51
51
  (a short status with its count at the start of that row, such as "23 to
52
- triage"), `create` (the "+" at its end), `viewMenu`, `infoLine`,
52
+ triage"), `create` (the "+" at its end), `viewMenu`, `infoLine`, `filters` (removable
53
+ `FilterChip`s, each `{ id, label, onClear }`, at the start of the info line),
53
54
  `readerLabel` and `readerActions` (the reader bar), `crumbLabel` (the open
54
55
  item in the top bar crumb), `crumbRecordKey` (its record key when the items
55
56
  are records of the Space's `collection`), `readerLayout` (`'fill'` lays a
56
57
  tool such as an editor or a `CloudComputerFrame` edge to edge at full height
57
58
  instead of the reading column), `onOpenChange(id, reason)` (`reason` is `user`,
58
59
  `auto` for a move the list makes itself, or `url`), `renderTile` (tiles), `look` (`two-tone` keeps
59
- the list tinted) and `autoOpen` (opens the first item). It has no toolbar or
60
- header slot. `Row` takes `wrap` (title lines) and `now` (a fixed clock for
61
- relative times); a `Row` drawn on its own (a short "Needs action" list)
60
+ the list tinted) and `autoOpen` (opens the first item; leave it off when the
61
+ page has sections above the list, which the open reader would cover). It has
62
+ no toolbar or header slot. `Row` takes `wrap` (title lines), `now` (a fixed
63
+ clock for relative times), `iconSize` (a lead larger than the 20 px icon, such
64
+ as a 40 px photo: pass an `<img>` as `icon`) and `keepLabels` (labels that say
65
+ where the row stands, such as a stage, keep their width and the meta start
66
+ truncates first; by default the labels give way first). A `Row` drawn on its own (a short "Needs action" list)
62
67
  takes `onPress` and `pressLabel` and opens something on press, so never wrap
63
68
  a row in a button of your own. A `labels` entry with a tone draws as a small
64
69
  tinted pill. Drag to select is automatic on a list that selects several
@@ -88,29 +93,8 @@ rather than from a copy.
88
93
  only reads. Use it rather than columns of your own.
89
94
  - **Time and numbers**: `PeriodPicker` with `usePeriod`, `DayPicker`,
90
95
  `CalendarView`, `TimelineView`, `Chart`, `StatRow`, `ChartTable`,
91
- `RenderChartData`, `Meter`, `DataTable`, `formatDuration`. `Chart` stacks
92
- bars or areas (`stacked`) and runs bars left to right (`horizontal`): each
93
- label on up to two lines before its bar in a measured axis, and its value after it; `labelFormat` gives that short
94
- value ("1.2k") while `format` stays the exact tooltip and table text. Draw
95
- category bars this way rather than with your own recharts. For a chart of
96
- your own, `ChartContainer` takes `aspect` or `height`; `ChartTooltipContent`
97
- and `ChartLegend` also work outside it; `<Bar shape={barShape}
98
- label={{ content: barLabel }} />` keeps zero bars and their value labels. A
99
- sparkline `null` is a gap. `domain={[min, max]}` fixes the value scale (a
100
- percentage on 0 to 100) and `valueAxis` draws it on the left through
101
- `labelFormat` (without a `domain` its top rises to a round quarter); x labels thin out with the room and never run off the edge. `PeriodPicker` without the `custom` preset offers
102
- presets only. `Meter` is a labelled capacity bar (`label`, `value`, `max`,
103
- `valueText`, `hint`); at or past `limit` (a tick named by `limitLabel`) it
104
- turns destructive. Set `limit` only to a threshold the data has (a memory
105
- reserve, a quota), never to `max`: a full meter is not red by itself. `DataTable` is a read-only table with the `ChartTable`
106
- look for rows that are not figures: `columns` (`id`, `label`, `cell`, `align`, `width`,
107
- `mono`, `primary`, `hideBelow`), `rows` or `groups` (`key`, `label`, `rows`),
108
- `rowKey`, and `onRowPress` with `rowLabel` to open a row (the primary cell
109
- then sits inside the row's button: text and icons only, no link). The primary
110
- column never gets under its `minWidth` (120 px by default): the last
111
- columns that do not fit hide on their own.
112
- `formatDuration(ms, locale, { units, smallest })` writes "1 h 31 min" (FR
113
- "4 j 6 h").
96
+ `CalendarHeatmap`, `RenderChartData`, `Meter`, `DataTable`, `formatDuration`; their options
97
+ are in [Charts, meters and tables](#charts-meters-and-tables).
114
98
  - **Floating**: `Menu`, `Popover`, `Tooltip`, `InfoTip`. `InfoTip` is the
115
99
  info button beside a label (a figure's `about`, a section heading, a meter):
116
100
  `label` names what it explains and the children are one or two sentences
@@ -142,13 +126,37 @@ rather than from a copy.
142
126
  previews, a timer). The browser asks once to place windows on screens; the
143
127
  desktop app never asks. Leaving the view closes the audience window.
144
128
  - **Blocks**: `Section`, `Badge`, `Button`, `ToggleGroup`, `SegmentedControl`,
145
- `NativeSelect`, `EmptyState`, `Notice`, `Metric`. A `Section`'s `kind`
129
+ `NativeSelect`, `EmptyState`, `Notice`, `Metric`, `FilterChip`. A `Section`'s `kind`
146
130
  is `bar` (period and filters), `stats`, `chart`, `data` (a table) or `form`,
147
131
  and its head takes `title`, `count`, `meta`, `tabs` and `actions`. There is no
148
132
  page heading: the host top bar shows the title. One toggle is a `Button` with
149
133
  `pressed`; several with any number on (filters, chart series) are a
150
134
  `ToggleGroup`; tabs and filters over a whole list or section are pills
151
- (`TabRow`); a `SegmentedControl` is only a mode switch inside a section.
135
+ (`TabRow`, which folds the pills that do not fit into More); a
136
+ `SegmentedControl` is only a mode switch inside a section. `Tabs` scroll
137
+ sideways on a phone; `wrap` puts the tabs that do not fit on a next line.
138
+ A removable filter that is not a tab (a contact, a tag) is a `FilterChip`
139
+ (`label`, `onClear`); over a list, pass them as `ListReader`'s `filters`.
140
+ `Icon` draws a toolkit icon by name, and every `icon` prop or field (a
141
+ `Button`, a reader action, a menu item) takes the same names.
142
+ `notis spaces build` refuses any other name written there as a string
143
+ and suggests the closest ones. The names: `archive`, `arrow-bend-up-right`,
144
+ `arrow-clockwise`, `arrow-counter-clockwise`, `arrow-left`,
145
+ `arrow-square-out`, `arrows-clockwise`, `arrows-left-right`, `arrows-out`,
146
+ `caret-down`, `caret-left`, `caret-right`, `caret-up`, `chart-line-up`,
147
+ `chat-circle-text`, `chats`, `check`, `check-circle`, `check-circle-fill`,
148
+ `circle`, `circle-dashed`, `circle-half`, `circle-three-quarter`,
149
+ `clipboard-text`, `clock`, `clock-countdown`, `copy`, `corners-out`,
150
+ `dots-three`, `download-simple`, `envelope-open`, `envelope-simple`, `file`,
151
+ `file-audio`, `file-image`, `file-text`, `file-video`, `flask`,
152
+ `fork-knife`, `funnel-simple`, `hourglass`, `info`, `kanban`, `link`,
153
+ `magnifying-glass-minus`, `magnifying-glass-plus`, `minus-circle`,
154
+ `paper-plane-right`, `paper-plane-tilt`, `paperclip`, `pause`,
155
+ `pencil-simple`, `play`, `plus`, `rocket-launch`, `sidebar-simple`,
156
+ `sparkle`, `square-center`, `star`, `star-fill`, `toggle-left`,
157
+ `toggle-right`, `trash`, `tray-arrow-up`, `user-plus`, `x`,
158
+ `x-circle-fill`. For any other icon, pass a `@phosphor-icons/react` element as the `icon` (the template depends on it),
159
+ never a second icon set.
152
160
  A `Notice` is read politely, danger too; pass `urgent` only for a problem the
153
161
  person must act on now (it becomes an alert that interrupts the screen reader).
154
162
  - **Fields**: `EditableFields` (a form; Save and Cancel show once something
@@ -178,6 +186,63 @@ A status maps to one of ten groups (`backlog`, `todo`, `active`, `review`,
178
186
  with its icon, words and the one status palette: pass the Space's own status to
179
187
  `Row` or `StatusIcon` (with `label` for its own name).
180
188
 
189
+ ## Charts, meters and tables
190
+
191
+ `Chart` stacks bars or areas (`stacked`) and runs bars left to right
192
+ (`horizontal`): each label on up to two lines before its bar in a measured axis,
193
+ and its value after it; `labelFormat` gives that short value ("1.2k") while
194
+ `format` stays the exact tooltip and table text. One series of bars draws the
195
+ bars other than the live one lighter until hovered; `dim={false}` draws every
196
+ bar full colour (months of a budget). `barColor(row, series, index)` colours one
197
+ bar by its row (a stage, over a budget); never fake it with stacked series.
198
+ Values under zero (no `domain`) reach below zero with a line at zero (a balance,
199
+ a net change); stacked values under zero stack under the axis. Series take
200
+ `--chart-1` to `--chart-5` in order, then again: give a sixth series its own
201
+ `color`. Draw category bars this way rather than with your own recharts. For a
202
+ chart of your own, `ChartContainer` takes `aspect` or `height`;
203
+ `ChartTooltipContent` and `ChartLegend` also work outside it; `<Bar
204
+ shape={barShape} label={{ content: barLabel }} />` keeps zero bars and their
205
+ value labels. A sparkline `null` is a gap. `domain={[min, max]}` fixes the value
206
+ scale (a percentage on 0 to 100) and `valueAxis` draws it on the left through
207
+ `labelFormat` (without a `domain` its top rises to a round quarter); x labels
208
+ thin out with the room and never run off the edge.
209
+
210
+ `PeriodPicker` without the `custom` preset offers presets only;
211
+ `presets={[...PRESETS.slice(0, -1), ...EXTRA_PRESETS, 'custom']}` adds Last 6
212
+ months and Last 12 months (this month and the 5 or 11 before it, binned by month
213
+ and compared with the same months before, like any range from the 1st spanning
214
+ six months or more).
215
+
216
+ `Meter` is a labelled capacity bar (`label`, `value`, `max`, `valueText`,
217
+ `hint`, `tone`: `success`, `warning`, `info` or `danger` colour the fill, such
218
+ as a goal met or near; `danger` looks like a reached limit, so keep it for a
219
+ value that is already bad); at or past `limit` (a tick named by `limitLabel`) it
220
+ turns destructive. Set `limit` only to a threshold the data has (a memory
221
+ reserve, a quota), never to `max`: a full meter is not red by itself.
222
+
223
+ `DataTable` is a read-only table with the `ChartTable` look for rows that are
224
+ not figures: `columns` (`id`, `label`, `cell`, `align`, `width`, `mono`,
225
+ `primary`, `hideBelow`, `wrap`), `rows` or `groups` (`key`, `label`, `rows`),
226
+ `rowKey`, and `onRowPress` with `rowLabel` to open a row (the primary cell then
227
+ sits inside the row's button: text and icons only, no link); `canPressRow(row)`
228
+ leaves a row that opens nothing plain. Cells truncate: a column with `wrap` (a
229
+ question, a note) wraps and its rows grow, and `wrapHeaders` puts long headers
230
+ (French ones over narrow figure columns) on two lines instead of an ellipsis.
231
+ The primary column never gets under its `minWidth` (120 px by default): the last
232
+ columns that do not fit hide on their own.
233
+
234
+ `formatDuration(ms, locale, { units, smallest })` writes "1 h 31 min" (FR "4 j 6
235
+ h").
236
+
237
+ `CalendarHeatmap` is a GitHub-style grid of days coloured by value (a habit,
238
+ journal entries, a mood): `data` rows with `dateKey` and `valueKey` (default
239
+ `date` and `value`; `valueKey={null}` counts rows), `from` and `to` (default
240
+ the last 12 months), `tone`, `scale="diverging"` with `domain` or `midpoint`
241
+ for good to bad data (`higherIsBetter={false}` swaps the colours), `levels`,
242
+ `format`, `onSelect(day)` (cells become buttons; `day` is `{ date, key }`
243
+ with `key` the ISO day, plus `value` and the day's `rows`), `title`, `legend`,
244
+ `weekStartsOn`. It brings its tooltips, keys and data table.
245
+
181
246
  ## Comments
182
247
 
183
248
  `useComments` with `CommentPane` and `CommentPins` give comment
@@ -256,6 +321,7 @@ from the `url` its query returns, or queries again for a fresh one.
256
321
  | `useShownAvailable(name)` | Check whether this host exposes the declared native list. A record Site can expose only its exact server-pinned row scope. |
257
322
  | `useAction<Inputs, Result>(name)` / `useActionQuery<Result>(name, inputs, options?)` | Call a declared action (`call(inputs, options)`); read the result of a declared read action. Never call account-wide tools from a Space. When a read action answers with native rows, pass `rows: { binding, at, query? }` (`at`: the answer field holding them, `''` for a bare list; `query`: the native query it runs) so native writes to that database show in it at once too; without it the read only refreshes after the write. A failed call throws a `SpaceActionError`; its `code` is `rate_limited` when the provider refused it for sending too fast (it did not run, and Notis already waited and retried safe calls), so offer a retry after a few seconds instead of adding your own limiter, and `read_timeout` when a read took too long. |
258
323
  | `useNativeMutation(binding, operation)` | Insert, update or delete one row of a linked database through the action that declares `LOCAL_NOTIS_DATABASE_INSERT`, `_UPDATE` or `_DELETE` on that binding with `request: { $input: 'request' }`. `mutate(input, {schemaRevision, requestId, showIn?})` returns the receipt (`record_key`, `revision`). The write shows in every list of that database at once, before the server answers: an edited row changes where it is (and moves to its sorted place, or leaves a `useNativeDocuments` read whose filter no longer keeps it), a new row joins the reads whose filter it passes and the `shows` lists named by `showIn` (by default the view's only list over that database), and a delete moves the record to the bin and leaves every list. A failed write puts the server's rows back. Do not keep your own copy of the change on top. One new request ID per effect. An insert action takes no `content_markdown`: insert, then save the body with `useNativeDocumentBody` and the record's revision. |
324
+ | `useNativeCount(binding, {query?, enabled?, staleTimeMs?, subscribe?})` | How many rows of a linked database match `query.filter` (and `include_archived`), through the same query action as `useNativeDocuments`, without loading any row. `count` (and `schemaRevision`) stay undefined until the first answer; `loading`, `error`, `refetch` and `live` work as in the other reads. When the filter changes it keeps the last count (`isPreviousData` true) until the new one arrives; a write refreshes it once confirmed, not optimistically. Use it for badges, tab totals and empty checks instead of reading every page. |
259
325
  | `useNativeDelete(binding)` | Trash many rows of one linked database (a deck and its slides, a multi-select). `deleteMany(inputs, {schemaRevision, requestId})` hides every row from the lists at once, runs the writes a few at a time, each with the request ID `${requestId}:${record_key}` (a retry with the same `requestId` replays instead of trashing twice), refreshes the lists once at the end and brings back the rows whose write failed. It never throws for a failed row: it resolves to `{done, failed}`; say how many failed. Use it rather than a loop of `mutate`. |
260
326
  | `useNativeDocumentBody(binding, recordKey, {readAction, writeAction?, enabled?})` | Markdown body adapter. Keep drafts in the view; save with the original content, record/schema revisions and stable request ID. Rich editing normally uses `DocumentEditor`. |
261
327
  | `useNotis()` | Host resource, Space labels, route and ready state. Use `resource.id` for the current Space identity. |
@@ -270,10 +336,23 @@ measured from the view at verify time and drawn from the release; `skeletonKey`
270
336
  (default `main`) names the region when a view has several separately loading
271
337
  parts, and `variant` only draws the fallback before the first measured release.
272
338
  A region that only shows on another tab or page is measured when the
273
- verification fixtures list that tab's params in `context.skeletonParams`. A Space
339
+ verification fixtures list that tab's params in `context.skeletonParams` or as
340
+ another of their `contexts` ([fixtures](fixtures.md)). A Space
274
341
  with editor-only parts gets the skeleton of its public view, the one visitors
275
342
  see: an editors' page that loads differently keeps a plain loading state of its own.
276
343
 
344
+ A PostHog read is a declared action on the connected PostHog server's EXEC
345
+ tool (`LOCAL_MCP_..._EXEC` or `CUSTOM_..._EXEC`) with no `inputs` and exactly
346
+ these `arguments`: `{project_id: <number>, query: 'SELECT ...', context: '<what
347
+ it answers>', llm_model: '<model name>'}`. The query is one fixed SELECT (no
348
+ `;`, at most 32 KB); Notis runs it read-only. Read it with `useActionQuery`.
349
+
350
+ A Supabase read is a declared action on the connected Supabase server's
351
+ EXECUTE_SQL tool whose only argument is `query`: the header line
352
+ `/* notis-postgres-read-v4 */` (30 seconds; `-v3` is 8, `-v5` admits CASE
353
+ indexes), then one schema-qualified SELECT, as text or `$sql` parts. Verify
354
+ compiles it into its guarded read and names any part the compiler refuses.
355
+
277
356
  For another explicitly idempotent read use `useActionQuery`, or
278
357
  `useQuery(keyArray, readCallback, { readOnly: true })` with every input in the
279
358
  key. Call declared read actions inside a custom read with
@@ -385,8 +464,8 @@ cloud computer.
385
464
 
386
465
  ## Visual data and Markdown
387
466
 
388
- Give a chart its numbers through `RenderChartData` (the toolkit's `Chart` and
389
- `ChartTable` already do): it adds a semantic table without a second visible one.
467
+ Give a chart its numbers through `RenderChartData` (the toolkit's `Chart`,
468
+ `ChartTable` and `CalendarHeatmap` already do): it adds a semantic table without a second visible one.
390
469
  The renderer never guesses exact numbers from SVG or canvas geometry; a chart
391
470
  without it contributes only its accessible name to the Markdown.
392
471
 
@@ -11,6 +11,7 @@ revision and current target. [Delivery](release.md) owns the release sequence.
11
11
  | Source creation fails | Check its canonical schema and same-view main record param. Verify creates no resource; promotion is atomic. |
12
12
  | View-link warning after a successful write | Use `FIND_VIEWS` with the returned record key. The write is already committed; do not insert again. |
13
13
  | Empty list or missing properties | Inspect the live schema, filter, authorized binding and returned projection. Distinguish a successful empty result from a denied/failed read. |
14
+ | A live read is refused: `connection_unavailable` in the page, or a render answers `render_read_unavailable` with that `reason` and the read's `action_id` | The connection the Space reads through is not usable as it was saved at publish. The Editor who published it reconnects that integration in Integrations; if it is already connected, they publish the Space again (`notis spaces deploy`) so the read is authorized with the connection as it is now. A re-render or a retry never clears it, and an agent never publishes another person's Space with its own connections. |
14
15
  | Verification fails on a read | Add the exact fictional case to the selected fixture file. Never fill missing fixtures with live private data. |
15
16
  | A caught write-on-load fails rendering | Remove the side effect from initial rendering. A read-only check cannot authorize writes. |
16
17
  | Stale binding/schema/record | Read current state, preserve the original receipt/intent and merge the intended edit. Do not overwrite concurrent changes. |
@@ -19,6 +20,8 @@ revision and current target. [Delivery](release.md) owns the release sequence.
19
20
  | `protocol_required`, `invalid_protocol` or another 400 naming a `field` | The call is malformed, not out of date. Fix the named field (native Space and database tools take `"protocol": 1`) and call again. |
20
21
  | Uncertain deployment | Run `notis doctor`, read the same Space and release/request identity, then reconcile before retrying. |
21
22
  | A tool call fails with `network_error`, `network_timeout` or a 502, 503 or 504 | The CLI already retried it where repeating is safe (`attempts` in its answer). Do not add your own retry loop: read back the same target, then run it again only if it did not happen, with the same `request_id`. |
23
+ | `notis spaces verify` or `deploy` fails with `network_error` or `network_timeout` | The message names the server step, the network cause (`ENOTFOUND`, `ECONNRESET`, ...) and the request. A verify published nothing: run it again. A deploy says which `--request-id` to reuse: run the same command with it, which resumes that release and never publishes it twice. A cause such as `ENOTFOUND` or `ECONNREFUSED` means this machine cannot reach Notis (a sandbox without network): run it where it can. |
24
+ | A render answers `render_timeout` or `render_temporarily_unavailable` | The view was slow or a read lost its connection (a busy machine or server). Its access did not change: render the same link again. Only `render_access_changed` means access changed. |
22
25
  | Screenshot misses content | Inspect actual inner scrolling, lazy data and frame layout; keep full-height limits and treat a failed capture as unverified. |
23
26
  | Site unexpectedly has editor controls | Recheck the anonymous scoped runtime. A Site cannot borrow an ambient signed-in session or another record's authority. |
24
27
  | Memory hit looks current but access/freshness is unknown | Render its current link and verify the relevant value. Do not release historical content from an unverified read set. |
@@ -84,6 +84,13 @@ The saved `read` action is deliberately constrained to one native record for
84
84
  body and record-Site reads; `shows.notes` owns the Editor's collection list. Keep
85
85
  both tied to the same declared resource.
86
86
 
87
+ A `shows` list's `where` is a native filter: `{field: {property}, op, value}`
88
+ conditions in `and` / `or` groups. For several options of one select or status,
89
+ write one `in`, never an `or` of `equals`: `{field: {property: 'Stage'}, op:
90
+ 'in', value: ['Lead', 'Won']}`. For "how many", use `useNativeCount` ([SDK](sdk.md#records-and-declared-reads)),
91
+ never a list paged to the end. Operators, limits and placeholders:
92
+ [Params and declared lists](#params-and-declared-lists).
93
+
87
94
  ## Records in the sidebar
88
95
 
89
96
  `collection` lists the database's records as rows under the Space in the
@@ -267,6 +274,19 @@ navigation and the toolkit pieces.
267
274
  - `shows` for native data is `{database, where, open?}`. `where` is the native filter
268
275
  grammar and is what `useShown` executes, not commentary beside a different query.
269
276
  `open` names a record param over the same database.
277
+ - `in` matches any of a list: up to 500 record keys on `record_key`/`id`, or up to
278
+ 100 options (labels or IDs) of a select or status property, such as
279
+ `{field: {property: 'Stage'}, op: 'in', value: ['Lead', 'Won']}`. Each option must
280
+ exist; a row with no option matches none. A list of several values costs one
281
+ condition per value toward the filter's 200 (a placeholder counts once bound). In
282
+ `shows`, the list may mix options and placeholders: bound values naming no option
283
+ are dropped (a fixed one is refused), repeats count once,
284
+ more than 100 refuses the read, and a list left empty (an unset param, or only
285
+ unknown options) matches no row; it is never dropped like a single condition.
286
+ - A `LOCAL_NOTIS_DATABASE_QUERY` read action's `request` may add `properties:
287
+ [{property: 'Name'}, ...]` (1 to 100) to return only those fields. For "how many",
288
+ use `useNativeCount(binding, {query: {filter}})` ([SDK](sdk.md)): it sends `mode:
289
+ 'count'` and loads no row, so never page through every row to count them.
270
290
  - A condition may add `when: 'late'`, naming a boolean param. It is included
271
291
  only when that setting is true; absent/false drops it before pagination.
272
292
  This also gates `is_empty` for unplanned tasks. `tasksViewFilter` pairs with
@@ -1,6 +1,6 @@
1
1
  'use client';
2
2
 
3
- import { useCallback, useEffect, useState } from 'react';
3
+ import { useCallback, useEffect, useRef, useState } from 'react';
4
4
  import { useNotisRuntime } from '../provider';
5
5
  import { normalizeDocumentRecord } from '../documents';
6
6
  import type { DocumentRecord, NotisRuntime } from '../runtime';
@@ -33,20 +33,11 @@ export function useNativeDocuments(binding: string, options: {
33
33
  query?: NativeQuery; fetchAll?: boolean; enabled?: boolean; staleTimeMs?: number; subscribe?: boolean;
34
34
  } = {}): UseQueryResult<{ documents: DocumentRecord[]; schemaRevision: number }> & { documents: DocumentRecord[]; schemaRevision?: number; live: boolean } {
35
35
  const runtime = useNotisRuntime();
36
- const [live, setLive] = useState(false);
37
- const follow = options.subscribe === true && options.enabled !== false;
38
- useEffect(() => {
39
- if (!follow || !runtime?.subscribeDatabase) { setLive(false); return; }
40
- let cancelled = false;
41
- // The Space host re-reads every query of the view when the database changes, so the
42
- // change callback has nothing left to do; the feed is a signal and never carries rows.
43
- const stop = runtime.subscribeDatabase(binding, () => {}, { onStatusChange: value => { if (!cancelled) setLive(value); } });
44
- return () => { cancelled = true; setLive(false); stop?.(); };
45
- }, [runtime, binding, follow]);
36
+ const live = useLiveBinding(runtime, binding, options.subscribe === true && options.enabled !== false);
46
37
  const locale = runtime?.context?.locale === 'fr' ? 'fr' : 'en';
47
38
  const query = useQuery<{ documents: DocumentRecord[]; schemaRevision: number }>(['native-documents', binding, options.query ?? {}, Boolean(options.fetchAll), locale], async (publish) => {
48
39
  const action = actionFor(runtime, binding, 'query');
49
- if (options.query?.mode && !['rows', 'search'].includes(options.query.mode)) throw new Error('Use useActionQuery for counts and aggregates.');
40
+ if (options.query?.mode && !['rows', 'search'].includes(options.query.mode)) throw new Error('Use useNativeCount for counts and useActionQuery for aggregates.');
50
41
  const rows: unknown[] = [];
51
42
  let offset = options.query?.offset ?? 0;
52
43
  let revision: number | undefined;
@@ -76,6 +67,53 @@ export function useNativeDocuments(binding: string, options: {
76
67
  return { ...query, documents: query.data?.documents ?? EMPTY_DOCUMENTS, schemaRevision: query.data?.schemaRevision, live };
77
68
  }
78
69
 
70
+ /** Whether the binding's live change feed is attached; the host re-reads the view's queries on a change. */
71
+ function useLiveBinding(runtime: NotisRuntime | null, binding: string, follow: boolean): boolean {
72
+ const [live, setLive] = useState(false);
73
+ useEffect(() => {
74
+ if (!follow || !runtime?.subscribeDatabase) { setLive(false); return; }
75
+ let cancelled = false;
76
+ // The Space host re-reads every query of the view when the database changes, so the
77
+ // change callback has nothing left to do; the feed is a signal and never carries rows.
78
+ const stop = runtime.subscribeDatabase(binding, () => {}, { onStatusChange: value => { if (!cancelled) setLive(value); } });
79
+ return () => { cancelled = true; setLive(false); stop?.(); };
80
+ }, [runtime, binding, follow]);
81
+ return live;
82
+ }
83
+
84
+ /** What a count reads: the rows its filter keeps, archived ones too when asked. */
85
+ export type NativeCountQuery = Pick<NativeQuery, 'filter' | 'include_archived'>;
86
+
87
+ /**
88
+ * How many rows of a database binding match `query.filter`, read with the native query's `mode: 'count'` through the
89
+ * same declared query action as `useNativeDocuments`: no row is loaded. `count` is undefined until the first answer;
90
+ * `loading`, `isFetching` and `error` behave as in every `useQuery` read. When the filter changes, the last count
91
+ * stays shown (`isPreviousData` true) until the new one is read; a new binding starts empty instead. A write
92
+ * refreshes it once confirmed, never before: an optimistic row does not move the count. `subscribe` follows the live
93
+ * change feed as in `useNativeDocuments`.
94
+ */
95
+ export function useNativeCount(binding: string, options: {
96
+ query?: NativeCountQuery; enabled?: boolean; staleTimeMs?: number; subscribe?: boolean;
97
+ } = {}): UseQueryResult<{ count: number; schemaRevision: number }> & { count?: number; schemaRevision?: number; live: boolean } {
98
+ const runtime = useNotisRuntime();
99
+ const live = useLiveBinding(runtime, binding, options.subscribe === true && options.enabled !== false);
100
+ const request = { ...(options.query?.filter ? { filter: options.query.filter } : {}),
101
+ ...(options.query?.include_archived === undefined ? {} : { include_archived: options.query.include_archived }), mode: 'count' as const };
102
+ // The last count stays shown only while the same binding reads a new filter: another database's count never does.
103
+ const shownBinding = useRef<string | null>(null);
104
+ const query = useQuery<{ count: number; schemaRevision: number }>(['native-count', binding, request], async () => {
105
+ const action = actionFor(runtime, binding, 'query');
106
+ const result = await runtime!.callAction!<{ count: number; schema_revision: number }>(
107
+ action, { request }, { readOnly: true, dedupe: true });
108
+ if (!result || !Number.isSafeInteger(result.count) || result.count < 0 || !Number.isSafeInteger(result.schema_revision)) {
109
+ throw new SdkQueryError('responseIncomplete', 'Native count must return a safe integer count and schema_revision.');
110
+ }
111
+ return { count: result.count, schemaRevision: result.schema_revision };
112
+ }, { readOnly: true, enabled: options.enabled, staleTimeMs: options.staleTimeMs, keepPrevious: shownBinding.current === binding });
113
+ if (query.data && !query.isPreviousData) shownBinding.current = binding;
114
+ return { ...query, count: query.data?.count, schemaRevision: query.data?.schemaRevision, live };
115
+ }
116
+
79
117
  /** Options of one native write. */
80
118
  export interface NativeMutationOptions {
81
119
  schemaRevision: number;
@@ -12,7 +12,7 @@ export { NotisProvider, useNotisRuntime } from './provider';
12
12
  // Hooks
13
13
  export { useAction, useActionQuery } from './hooks/useAction';
14
14
  export type { UseActionQueryOptions } from './hooks/useAction';
15
- export { useNativeDocuments, useNativeMutation, useNativeDelete, type NativeDeleteManyResult, type NativeMutationOptions } from './hooks/useNativeDocuments';
15
+ export { useNativeDocuments, useNativeCount, useNativeMutation, useNativeDelete, type NativeCountQuery, type NativeDeleteManyResult, type NativeMutationOptions } from './hooks/useNativeDocuments';
16
16
  export type { NativeField, NativeFilter, NativeQuery, NativeInsert, NativeUpdate, NativeDelete, NativeMutationReceipt } from './nativeData';
17
17
  export type { SpaceDatabaseCreate, SpaceResourceReference } from './space';
18
18
  export type { SpaceActionTemplate, SpaceActionDescriptor, SpaceRuntimeDescriptor, SpaceActionOptions } from './space';
@@ -897,7 +897,9 @@ export interface SpaceActionFailureDetails {
897
897
  pendingRequestIds?: string[];
898
898
  /**
899
899
  * Why a settled action failed, when the host knows a stable reason: `read_timeout` (a read its time limit stopped)
900
- * or `rate_limited` (the provider refused the call for sending too fast; it did not run, so retry after a few seconds).
900
+ * or `rate_limited` (the provider refused the call for sending too fast; it did not run, so retry after a few seconds)
901
+ * or `connection_unavailable` (the connection the action runs through is not usable as saved: a retry never clears it;
902
+ * the Editor who published the Space reconnects that integration, or publishes the Space again).
901
903
  */
902
904
  code?: string;
903
905
  }