@notis_ai/cli 0.2.30 → 0.2.31
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/README.md +1 -0
- package/dist/agent-hooks/notis-agent-hook.mjs +37890 -10794
- package/dist/base-skills/notis-cli/.notis-base-skill.json +1 -1
- package/dist/base-skills/notis-cli/references/native-databases.md +1 -1
- package/dist/base-skills/notis-query/.notis-base-skill.json +1 -1
- package/dist/base-skills/notis-query/references/query.md +6 -4
- package/dist/base-skills/notis-spaces/.notis-base-skill.json +1 -1
- package/dist/base-skills/notis-spaces/SKILL.md +8 -3
- package/dist/base-skills/notis-spaces/references/architecture.md +4 -1
- package/dist/base-skills/notis-spaces/references/design.md +7 -1
- package/dist/base-skills/notis-spaces/references/fixtures.md +27 -2
- package/dist/base-skills/notis-spaces/references/sdk.md +90 -31
- package/dist/base-skills/notis-spaces/references/troubleshooting.md +3 -0
- package/dist/base-skills/notis-spaces/references/views.md +20 -0
- package/dist/sdk/src/hooks/useNativeDocuments.ts +50 -12
- package/dist/sdk/src/index.ts +1 -1
- package/dist/sdk/src/space.ts +3 -1
- package/dist/sdk/src/tailwind.ts +53 -3
- package/dist/sdk/src/ui/icons.tsx +1 -0
- package/dist/sdk/src/words/types.ts +28 -0
- package/dist/skill-sync/index.js +10 -90
- package/dist/skill-sync-worker.mjs +50 -93
- package/dist/space-harness/host.js +150 -81
- package/dist/space-sdk/dist/chunk-3DFOGU26.js +3 -0
- package/dist/space-sdk/dist/index.js +2 -2
- package/dist/space-sdk/dist/ui.js +12 -12
- package/dist/space-sdk/src/hooks/useNativeDocuments.d.ts +23 -0
- package/dist/space-sdk/src/index.d.ts +1 -1
- package/dist/space-sdk/src/space.ts +3 -1
- package/dist/space-sdk/src/tailwind-candidates.d.ts +273 -2
- package/dist/space-sdk/src/tailwind.ts +53 -3
- package/dist/space-sdk/src/ui/blocks/DataTable.d.ts +19 -4
- package/dist/space-sdk/src/ui/blocks/Meter.d.ts +12 -3
- package/dist/space-sdk/src/ui/blocks/Tabs.d.ts +7 -1
- package/dist/space-sdk/src/ui/blocks/index.d.ts +1 -1
- package/dist/space-sdk/src/ui/charts/CalendarHeatmap.d.ts +69 -0
- package/dist/space-sdk/src/ui/charts/Chart.d.ts +18 -3
- package/dist/space-sdk/src/ui/charts/chartData.d.ts +19 -0
- package/dist/space-sdk/src/ui/charts/heatmapData.d.ts +81 -0
- package/dist/space-sdk/src/ui/index.d.ts +4 -2
- package/dist/space-sdk/src/ui/list/Row.d.ts +11 -1
- package/dist/space-sdk/src/ui/period/dateFormat.d.ts +2 -0
- package/dist/space-sdk/src/ui/period/dateWords.d.ts +9 -0
- package/dist/space-sdk/src/ui/period/periods.d.ts +15 -2
- package/dist/space-sdk/src/words/types.ts +28 -0
- package/dist/view-renderer/dist/host.js +219 -150
- package/dist/view-renderer/src/dom.js +3 -2
- package/dist/view-renderer/src/errors.js +9 -0
- package/dist/view-renderer/src/host.tsx +12 -5
- package/dist/view-renderer/src/remote-broker.js +3 -1
- package/dist/view-renderer/src/renderer.js +63 -16
- package/dist/view-renderer/src/skeleton.js +70 -18
- package/package.json +5 -4
- package/skills/notis-query/cli.md +3 -0
- package/src/command-specs/spaces.js +71 -15
- package/src/command-specs/tools.js +3 -0
- package/src/runtime/api-hosts.generated.js +35 -0
- package/src/runtime/api-hosts.js +27 -10
- package/src/runtime/app-platform.js +68 -24
- package/src/runtime/http-agent.js +53 -0
- package/src/runtime/native-record-files.js +11 -0
- package/src/runtime/oauth.js +2 -1
- package/src/runtime/skill-sync/cloud-client.ts +0 -10
- package/src/runtime/skill-sync/index.ts +13 -15
- package/src/runtime/skill-sync/local-scanner.ts +0 -67
- package/src/runtime/skill-sync/types.ts +1 -0
- package/src/runtime/skill-sync/write-cloud-skill.ts +7 -23
- package/src/runtime/space-dependencies.js +66 -0
- package/src/runtime/space-fixture-broker.js +23 -8
- package/src/runtime/space-platform.js +47 -3
- package/src/runtime/space-source.js +10 -1
- package/src/runtime/space-test-server.js +105 -6
- package/src/runtime/space-verification.js +103 -43
- package/src/runtime/space-view-manifest.js +38 -5
- package/src/runtime/transport.js +19 -4
- package/src/runtime/view-render.js +4 -1
- package/template/tailwind.config.ts +2 -35
- package/dist/space-sdk/dist/chunk-6GJ2BS7B.js +0 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"schema":1,"stamp":
|
|
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
|
|
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":
|
|
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:
|
|
24
|
-
`
|
|
25
|
-
`
|
|
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":
|
|
1
|
+
{"schema":1,"stamp":1794771946,"commit":"b5902cc7f64ba2ed2615c903c6e88a58d588bf5f"}
|
|
@@ -87,11 +87,12 @@ 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) |
|
|
92
93
|
| Save or revise a Notes report or interactive report | [Reports](references/reports.md) |
|
|
93
94
|
| Choose a memory policy | [Memory](references/memory.md) |
|
|
94
|
-
| Data hooks, record pages and the toolkit pieces | [SDK](references/sdk.md) |
|
|
95
|
+
| 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
96
|
| Explain resources, sharing and lifecycle | [Platform boundaries](references/architecture.md) |
|
|
96
97
|
| Diagnose a failed check or release | [Troubleshooting](references/troubleshooting.md) |
|
|
97
98
|
| 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,7 +172,7 @@ stops receiving that piece's fixes.
|
|
|
171
172
|
3. Declare each view ([View authoring](references/views.md)) and write it on the
|
|
172
173
|
pieces ([Design](references/design.md)).
|
|
173
174
|
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
|
|
175
|
+
read ([Fixtures](references/fixtures.md)). Look at EN and FR at 390 and 1440 px; fix failed reads, clipping, wrong
|
|
175
176
|
data and state transitions before release.
|
|
176
177
|
5. Deploy within the user's authorization. Read back the exact published
|
|
177
178
|
revision, render its live view link and inspect the affected interaction.
|
|
@@ -196,6 +197,10 @@ tell them who gains or loses access and what happens to the data, using
|
|
|
196
197
|
[Consequences](references/architecture.md#consequences-to-explain-before-acting).
|
|
197
198
|
|
|
198
199
|
Skill content has one writer family: `notis skills list|read|create|update|links`.
|
|
200
|
+
`skills update` takes the `target` and `version` exactly as `skills read` printed
|
|
201
|
+
them, plus one of `skill_md` (replaces SKILL.md, keeps the other files) or
|
|
202
|
+
`files` (every file of the Skill, SKILL.md included, as base64 by path), and
|
|
203
|
+
optionally `name`, `description` or `links`.
|
|
199
204
|
A failed Space target never falls back to another owner or a personal resource.
|
|
200
205
|
Editing a linked Skill changes the shared resource wherever it remains reachable.
|
|
201
206
|
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.
|
|
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,28 @@ 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`) and `skeletonParams`
|
|
33
|
+
(other params whose loading skeletons are measured too). Verify always draws
|
|
34
|
+
the view in English and in French, so `locale` no longer changes the
|
|
35
|
+
screenshots (still accepted). To check several states in one run, declare
|
|
36
|
+
`contexts` instead of `context`: 1 to 4 entries `{name, params, now, locale}`
|
|
37
|
+
with unique lowercase names (`a-z`, `0-9`, `-`, `_`), for example
|
|
38
|
+
`[{"name": "week", "params": {"period": "week"}}, {"name": "opened",
|
|
39
|
+
"params": {"open": "<row uuid>"}}]`. Verify renders each one at both widths
|
|
40
|
+
and languages (`.notis/view-<key>.<name>-<width>-<locale>.png`), measures the
|
|
41
|
+
loading skeleton of each, and for one whose params open a list item (`open`)
|
|
42
|
+
also saves the reader while the item loads
|
|
43
|
+
(`.notis/pending-<key>.<name>.reader-<width>-<locale>.png`); with one context
|
|
44
|
+
the names leave out `.<name>`, and a `context` whose params open an item gets the
|
|
45
|
+
reader screenshot too. The `shown`, `actions` and other cases are shared by
|
|
46
|
+
every context.
|
|
47
|
+
A photo or cover shows in verify when `images` maps the exact URL a fixture
|
|
48
|
+
row holds to a picture next to the fixtures: `{"images":
|
|
49
|
+
{"https://example.com/meal.jpg": "./photos/meal.jpg"}}` (png, jpg, webp, gif
|
|
50
|
+
or avif, at most 32 of 2 MB each and 16 MB in all); an image it cannot load
|
|
51
|
+
fails verify with its URL. These pictures are published with the Space's
|
|
52
|
+
source, so use ones you may share.
|
|
28
53
|
Keep every fixture fictional and include every load-time read. Failed or missing
|
|
29
54
|
fixtures fail verification; there is no fallback to the user's real account.
|
|
@@ -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 |
|
|
@@ -56,9 +56,13 @@ rather than from a copy.
|
|
|
56
56
|
tool such as an editor or a `CloudComputerFrame` edge to edge at full height
|
|
57
57
|
instead of the reading column), `onOpenChange(id, reason)` (`reason` is `user`,
|
|
58
58
|
`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
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
the list tinted) and `autoOpen` (opens the first item; leave it off when the
|
|
60
|
+
page has sections above the list, which the open reader would cover). It has
|
|
61
|
+
no toolbar or header slot. `Row` takes `wrap` (title lines), `now` (a fixed
|
|
62
|
+
clock for relative times), `iconSize` (a lead larger than the 20 px icon, such
|
|
63
|
+
as a 40 px photo: pass an `<img>` as `icon`) and `keepLabels` (labels that say
|
|
64
|
+
where the row stands, such as a stage, keep their width and the meta start
|
|
65
|
+
truncates first; by default the labels give way first). A `Row` drawn on its own (a short "Needs action" list)
|
|
62
66
|
takes `onPress` and `pressLabel` and opens something on press, so never wrap
|
|
63
67
|
a row in a button of your own. A `labels` entry with a tone draws as a small
|
|
64
68
|
tinted pill. Drag to select is automatic on a list that selects several
|
|
@@ -88,29 +92,8 @@ rather than from a copy.
|
|
|
88
92
|
only reads. Use it rather than columns of your own.
|
|
89
93
|
- **Time and numbers**: `PeriodPicker` with `usePeriod`, `DayPicker`,
|
|
90
94
|
`CalendarView`, `TimelineView`, `Chart`, `StatRow`, `ChartTable`,
|
|
91
|
-
`RenderChartData`, `Meter`, `DataTable`, `formatDuration
|
|
92
|
-
|
|
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").
|
|
95
|
+
`CalendarHeatmap`, `RenderChartData`, `Meter`, `DataTable`, `formatDuration`; their options
|
|
96
|
+
are in [Charts, meters and tables](#charts-meters-and-tables).
|
|
114
97
|
- **Floating**: `Menu`, `Popover`, `Tooltip`, `InfoTip`. `InfoTip` is the
|
|
115
98
|
info button beside a label (a figure's `about`, a section heading, a meter):
|
|
116
99
|
`label` names what it explains and the children are one or two sentences
|
|
@@ -148,7 +131,12 @@ rather than from a copy.
|
|
|
148
131
|
page heading: the host top bar shows the title. One toggle is a `Button` with
|
|
149
132
|
`pressed`; several with any number on (filters, chart series) are a
|
|
150
133
|
`ToggleGroup`; tabs and filters over a whole list or section are pills
|
|
151
|
-
(`TabRow
|
|
134
|
+
(`TabRow`, which folds the pills that do not fit into More); a
|
|
135
|
+
`SegmentedControl` is only a mode switch inside a section. `Tabs` scroll
|
|
136
|
+
sideways on a phone; `wrap` puts the tabs that do not fit on a next line.
|
|
137
|
+
`Icon` draws a toolkit icon by name (`fork-knife`, `clock`, `star`...);
|
|
138
|
+
for any other, pass a `@phosphor-icons/react` element as the `icon` (the
|
|
139
|
+
template depends on it), never a second icon set.
|
|
152
140
|
A `Notice` is read politely, danger too; pass `urgent` only for a problem the
|
|
153
141
|
person must act on now (it becomes an alert that interrupts the screen reader).
|
|
154
142
|
- **Fields**: `EditableFields` (a form; Save and Cancel show once something
|
|
@@ -178,6 +166,63 @@ A status maps to one of ten groups (`backlog`, `todo`, `active`, `review`,
|
|
|
178
166
|
with its icon, words and the one status palette: pass the Space's own status to
|
|
179
167
|
`Row` or `StatusIcon` (with `label` for its own name).
|
|
180
168
|
|
|
169
|
+
## Charts, meters and tables
|
|
170
|
+
|
|
171
|
+
`Chart` stacks bars or areas (`stacked`) and runs bars left to right
|
|
172
|
+
(`horizontal`): each label on up to two lines before its bar in a measured axis,
|
|
173
|
+
and its value after it; `labelFormat` gives that short value ("1.2k") while
|
|
174
|
+
`format` stays the exact tooltip and table text. One series of bars draws the
|
|
175
|
+
bars other than the live one lighter until hovered; `dim={false}` draws every
|
|
176
|
+
bar full colour (months of a budget). `barColor(row, series, index)` colours one
|
|
177
|
+
bar by its row (a stage, over a budget); never fake it with stacked series.
|
|
178
|
+
Values under zero (no `domain`) reach below zero with a line at zero (a balance,
|
|
179
|
+
a net change); stacked values under zero stack under the axis. Series take
|
|
180
|
+
`--chart-1` to `--chart-5` in order, then again: give a sixth series its own
|
|
181
|
+
`color`. Draw category bars this way rather than with your own recharts. For a
|
|
182
|
+
chart of your own, `ChartContainer` takes `aspect` or `height`;
|
|
183
|
+
`ChartTooltipContent` and `ChartLegend` also work outside it; `<Bar
|
|
184
|
+
shape={barShape} label={{ content: barLabel }} />` keeps zero bars and their
|
|
185
|
+
value labels. A sparkline `null` is a gap. `domain={[min, max]}` fixes the value
|
|
186
|
+
scale (a percentage on 0 to 100) and `valueAxis` draws it on the left through
|
|
187
|
+
`labelFormat` (without a `domain` its top rises to a round quarter); x labels
|
|
188
|
+
thin out with the room and never run off the edge.
|
|
189
|
+
|
|
190
|
+
`PeriodPicker` without the `custom` preset offers presets only;
|
|
191
|
+
`presets={[...PRESETS.slice(0, -1), ...EXTRA_PRESETS, 'custom']}` adds Last 6
|
|
192
|
+
months and Last 12 months (this month and the 5 or 11 before it, binned by month
|
|
193
|
+
and compared with the same months before, like any range from the 1st spanning
|
|
194
|
+
six months or more).
|
|
195
|
+
|
|
196
|
+
`Meter` is a labelled capacity bar (`label`, `value`, `max`, `valueText`,
|
|
197
|
+
`hint`, `tone`: `success`, `warning`, `info` or `danger` colour the fill, such
|
|
198
|
+
as a goal met or near; `danger` looks like a reached limit, so keep it for a
|
|
199
|
+
value that is already bad); at or past `limit` (a tick named by `limitLabel`) it
|
|
200
|
+
turns destructive. Set `limit` only to a threshold the data has (a memory
|
|
201
|
+
reserve, a quota), never to `max`: a full meter is not red by itself.
|
|
202
|
+
|
|
203
|
+
`DataTable` is a read-only table with the `ChartTable` look for rows that are
|
|
204
|
+
not figures: `columns` (`id`, `label`, `cell`, `align`, `width`, `mono`,
|
|
205
|
+
`primary`, `hideBelow`, `wrap`), `rows` or `groups` (`key`, `label`, `rows`),
|
|
206
|
+
`rowKey`, and `onRowPress` with `rowLabel` to open a row (the primary cell then
|
|
207
|
+
sits inside the row's button: text and icons only, no link); `canPressRow(row)`
|
|
208
|
+
leaves a row that opens nothing plain. Cells truncate: a column with `wrap` (a
|
|
209
|
+
question, a note) wraps and its rows grow, and `wrapHeaders` puts long headers
|
|
210
|
+
(French ones over narrow figure columns) on two lines instead of an ellipsis.
|
|
211
|
+
The primary column never gets under its `minWidth` (120 px by default): the last
|
|
212
|
+
columns that do not fit hide on their own.
|
|
213
|
+
|
|
214
|
+
`formatDuration(ms, locale, { units, smallest })` writes "1 h 31 min" (FR "4 j 6
|
|
215
|
+
h").
|
|
216
|
+
|
|
217
|
+
`CalendarHeatmap` is a GitHub-style grid of days coloured by value (a habit,
|
|
218
|
+
journal entries, a mood): `data` rows with `dateKey` and `valueKey` (default
|
|
219
|
+
`date` and `value`; `valueKey={null}` counts rows), `from` and `to` (default
|
|
220
|
+
the last 12 months), `tone`, `scale="diverging"` with `domain` or `midpoint`
|
|
221
|
+
for good to bad data (`higherIsBetter={false}` swaps the colours), `levels`,
|
|
222
|
+
`format`, `onSelect(day)` (cells become buttons; `day` is `{ date, key }`
|
|
223
|
+
with `key` the ISO day, plus `value` and the day's `rows`), `title`, `legend`,
|
|
224
|
+
`weekStartsOn`. It brings its tooltips, keys and data table.
|
|
225
|
+
|
|
181
226
|
## Comments
|
|
182
227
|
|
|
183
228
|
`useComments` with `CommentPane` and `CommentPins` give comment
|
|
@@ -256,6 +301,7 @@ from the `url` its query returns, or queries again for a fresh one.
|
|
|
256
301
|
| `useShownAvailable(name)` | Check whether this host exposes the declared native list. A record Site can expose only its exact server-pinned row scope. |
|
|
257
302
|
| `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
303
|
| `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. |
|
|
304
|
+
| `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
305
|
| `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
306
|
| `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
307
|
| `useNotis()` | Host resource, Space labels, route and ready state. Use `resource.id` for the current Space identity. |
|
|
@@ -270,10 +316,23 @@ measured from the view at verify time and drawn from the release; `skeletonKey`
|
|
|
270
316
|
(default `main`) names the region when a view has several separately loading
|
|
271
317
|
parts, and `variant` only draws the fallback before the first measured release.
|
|
272
318
|
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
|
|
319
|
+
verification fixtures list that tab's params in `context.skeletonParams` or as
|
|
320
|
+
another of their `contexts` ([fixtures](fixtures.md)). A Space
|
|
274
321
|
with editor-only parts gets the skeleton of its public view, the one visitors
|
|
275
322
|
see: an editors' page that loads differently keeps a plain loading state of its own.
|
|
276
323
|
|
|
324
|
+
A PostHog read is a declared action on the connected PostHog server's EXEC
|
|
325
|
+
tool (`LOCAL_MCP_..._EXEC` or `CUSTOM_..._EXEC`) with no `inputs` and exactly
|
|
326
|
+
these `arguments`: `{project_id: <number>, query: 'SELECT ...', context: '<what
|
|
327
|
+
it answers>', llm_model: '<model name>'}`. The query is one fixed SELECT (no
|
|
328
|
+
`;`, at most 32 KB); Notis runs it read-only. Read it with `useActionQuery`.
|
|
329
|
+
|
|
330
|
+
A Supabase read is a declared action on the connected Supabase server's
|
|
331
|
+
EXECUTE_SQL tool whose only argument is `query`: the header line
|
|
332
|
+
`/* notis-postgres-read-v4 */` (30 seconds; `-v3` is 8, `-v5` admits CASE
|
|
333
|
+
indexes), then one schema-qualified SELECT, as text or `$sql` parts. Verify
|
|
334
|
+
compiles it into its guarded read and names any part the compiler refuses.
|
|
335
|
+
|
|
277
336
|
For another explicitly idempotent read use `useActionQuery`, or
|
|
278
337
|
`useQuery(keyArray, readCallback, { readOnly: true })` with every input in the
|
|
279
338
|
key. Call declared read actions inside a custom read with
|
|
@@ -385,8 +444,8 @@ cloud computer.
|
|
|
385
444
|
|
|
386
445
|
## Visual data and Markdown
|
|
387
446
|
|
|
388
|
-
Give a chart its numbers through `RenderChartData` (the toolkit's `Chart
|
|
389
|
-
`ChartTable` already do): it adds a semantic table without a second visible one.
|
|
447
|
+
Give a chart its numbers through `RenderChartData` (the toolkit's `Chart`,
|
|
448
|
+
`ChartTable` and `CalendarHeatmap` already do): it adds a semantic table without a second visible one.
|
|
390
449
|
The renderer never guesses exact numbers from SVG or canvas geometry; a chart
|
|
391
450
|
without it contributes only its accessible name to the Markdown.
|
|
392
451
|
|
|
@@ -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
|
|
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
|
|
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;
|
package/dist/sdk/src/index.ts
CHANGED
|
@@ -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';
|
package/dist/sdk/src/space.ts
CHANGED
|
@@ -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
|
}
|
package/dist/sdk/src/tailwind.ts
CHANGED
|
@@ -1,9 +1,41 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* Build-only SDK content discovery and Notis theme colours. Author configuration and PostCSS plugins stay intact:
|
|
3
|
+
* a colour, theme value or opacity step the Space defines itself always wins over the defaults added here.
|
|
4
|
+
*/
|
|
2
5
|
import { existsSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';
|
|
3
6
|
import { tmpdir } from 'node:os';
|
|
4
7
|
import { dirname, join, relative, resolve } from 'node:path';
|
|
5
8
|
import { fileURLToPath } from 'node:url';
|
|
6
9
|
|
|
10
|
+
const tone = (name: string) => `hsl(var(--${name}))`;
|
|
11
|
+
const pair = (name: string) => ({ DEFAULT: tone(name), foreground: tone(`${name}-foreground`) });
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* The colours the Notis host sets on every Space page (light and dark), as Tailwind colours, so `bg-accent`,
|
|
15
|
+
* `text-chart-2` and opacity modifiers such as `bg-chart-2/40` or `bg-foreground/12` work in every Space.
|
|
16
|
+
*/
|
|
17
|
+
export const NOTIS_THEME_COLORS = {
|
|
18
|
+
border: tone('border'), input: tone('input'), ring: tone('ring'),
|
|
19
|
+
background: tone('background'), foreground: tone('foreground'),
|
|
20
|
+
primary: pair('primary'), secondary: pair('secondary'), destructive: pair('destructive'), muted: pair('muted'),
|
|
21
|
+
accent: pair('accent'), popover: pair('popover'), card: pair('card'),
|
|
22
|
+
chart: { 1: tone('chart-1'), 2: tone('chart-2'), 3: tone('chart-3'), 4: tone('chart-4'), 5: tone('chart-5') },
|
|
23
|
+
} as const;
|
|
24
|
+
|
|
25
|
+
/** Tailwind 4 theme block: `default` keeps every colour a Space sets in its own `@theme` or `@config` first. */
|
|
26
|
+
const THEME_MARK = '/* notis-theme-colors */';
|
|
27
|
+
const themeBlock = () => {
|
|
28
|
+
const lines: string[] = [];
|
|
29
|
+
for (const [name, value] of Object.entries(NOTIS_THEME_COLORS)) {
|
|
30
|
+
if (typeof value === 'string') { lines.push(` --color-${name}: ${value};`); continue; }
|
|
31
|
+
for (const [key, shade] of Object.entries(value)) lines.push(` --color-${name}${key === 'DEFAULT' ? '' : `-${key}`}: ${shade};`);
|
|
32
|
+
}
|
|
33
|
+
return `${THEME_MARK}\n@theme default inline {\n${lines.join('\n')}\n}`;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
/** Tailwind 3 only knows the opacity steps of its scale (5, 10, 15...): every whole percent works, as in Tailwind 4. */
|
|
37
|
+
const OPACITY_STEPS = Object.fromEntries(Array.from({ length: 101 }, (_, step) => [String(step), String(step / 100)]));
|
|
38
|
+
|
|
7
39
|
export function notisTailwindContent() {
|
|
8
40
|
let root = process.cwd();
|
|
9
41
|
let temporary: string | undefined;
|
|
@@ -26,7 +58,8 @@ export function notisTailwindContent() {
|
|
|
26
58
|
const sdkSource = dirname(fileURLToPath(import.meta.url));
|
|
27
59
|
const relativeSource = './' + relative(dirname(stylesheet), sdkSource).replaceAll('\\', '/');
|
|
28
60
|
const directive = `@source ${JSON.stringify(relativeSource)};`;
|
|
29
|
-
|
|
61
|
+
const added = [source.includes(directive) ? '' : `${directive}\n`, source.includes(THEME_MARK) ? '' : `${themeBlock()}\n`].join('');
|
|
62
|
+
return added ? { code: `${source}\n${added}`, map: null } : null;
|
|
30
63
|
}
|
|
31
64
|
if (!/@tailwind\s/.test(source)) return null;
|
|
32
65
|
const explicit = source.match(/@config\s+(['"])(.*?)\1\s*;/);
|
|
@@ -41,11 +74,28 @@ export function notisTailwindContent() {
|
|
|
41
74
|
const sdkGlob = join(dirname(fileURLToPath(import.meta.url)), '**/*.{ts,tsx}').replaceAll('\\', '/');
|
|
42
75
|
writeFileSync(wrapper, `import config from ${JSON.stringify(config)};
|
|
43
76
|
import { resolve } from 'node:path';
|
|
77
|
+
const defaults = ${JSON.stringify({ colors: NOTIS_THEME_COLORS, opacity: OPACITY_STEPS })};
|
|
78
|
+
const theme = config.theme || {};
|
|
79
|
+
const extend = theme.extend || {};
|
|
80
|
+
const presets = (config.presets || []).filter(preset => preset && typeof preset === 'object').map(preset => preset.theme || {});
|
|
81
|
+
// The Space's own colours and opacity steps win: a default fills only what the Space (or its presets) leaves unset,
|
|
82
|
+
// one level deep, so a Space's own card keeps the Notis card-foreground. A scale the Space replaces stays as it is.
|
|
83
|
+
const fill = (key) => {
|
|
84
|
+
if (typeof theme[key] === 'function' || (key === 'opacity' && theme.opacity)) return extend[key];
|
|
85
|
+
const own = [...presets.flatMap(t => [t[key], (t.extend || {})[key]]), theme[key], extend[key]].filter(v => v && typeof v === 'object');
|
|
86
|
+
const added = {};
|
|
87
|
+
for (const [name, value] of Object.entries(defaults[key])) {
|
|
88
|
+
const set = own.map(o => o[name]).filter(v => v !== undefined);
|
|
89
|
+
if (!set.length) added[name] = value;
|
|
90
|
+
else if (typeof value === 'object' && set.every(v => v && typeof v === 'object')) added[name] = Object.assign({}, value, ...set);
|
|
91
|
+
}
|
|
92
|
+
return typeof extend[key] === 'function' ? (utils) => ({ ...added, ...extend[key](utils) }) : { ...extend[key], ...added };
|
|
93
|
+
};
|
|
44
94
|
const content = config.content || [];
|
|
45
95
|
const files = Array.isArray(content) ? content : (content.files || []);
|
|
46
96
|
const base = ${JSON.stringify(root)};
|
|
47
97
|
const relativeBase = ${JSON.stringify(dirname(config))};
|
|
48
|
-
export default { ...config, content: {
|
|
98
|
+
export default { ...config, theme: { ...theme, extend: { ...extend, colors: fill('colors'), opacity: fill('opacity') } }, content: {
|
|
49
99
|
...(Array.isArray(content) ? {} : content),
|
|
50
100
|
relative: false,
|
|
51
101
|
files: [...files.map(file => typeof file !== 'string' ? file :
|
|
@@ -68,6 +68,7 @@ const SHAPES: Record<string, Shape> = {
|
|
|
68
68
|
'file-image': <g {...S}><path d="M9.5 2H4a.5.5 0 00-.5.5v11a.5.5 0 00.5.5h8a.5.5 0 00.5-.5V5zM9.5 2v3h3" /><path d="M3.5 12l3-3 2 2 1.5-1.5 2.5 2.5" /><circle cx="6.5" cy="6.75" r=".75" /></g>,
|
|
69
69
|
'file-video': <g {...S}><path d="M9.5 2H4a.5.5 0 00-.5.5v11a.5.5 0 00.5.5h8a.5.5 0 00.5-.5V5zM9.5 2v3h3" /><path d="M6.5 8v3.5L9.5 9.75z" /></g>,
|
|
70
70
|
'file-audio': <g {...S}><path d="M9.5 2H4a.5.5 0 00-.5.5v11a.5.5 0 00.5.5h8a.5.5 0 00.5-.5V5zM9.5 2v3h3" /><path d="M6 9.5v1.5h1.25L9 12.25v-4.5L7.25 9H6M10.5 8.5a1.8 1.8 0 010 2.5" /></g>,
|
|
71
|
+
'fork-knife': <path {...S} d="M3.5 2v3.5a1.5 1.5 0 003 0V2M5 2v12M11.5 14V2c-1.4.9-2.2 3-2.2 6.5h2.2" />,
|
|
71
72
|
};
|
|
72
73
|
|
|
73
74
|
export function hasIcon(name: string): boolean {
|