@notis_ai/cli 0.2.24 → 0.2.26
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 +186 -5
- package/config/notis_app_design_rules.json +36 -14
- package/config/portal-route-roots.json +1 -0
- package/dist/agent-hooks/notis-agent-hook.mjs +2784 -541
- package/dist/base-skills/notis-cli/.notis-base-skill.json +1 -1
- package/dist/base-skills/notis-cli/references/intelligence.md +1 -1
- package/dist/base-skills/notis-query/.notis-base-skill.json +1 -1
- package/dist/base-skills/notis-query/SKILL.md +0 -1
- package/dist/base-skills/notis-query/references/documents.md +7 -0
- package/dist/base-skills/notis-query/references/query.md +1 -0
- package/dist/base-skills/notis-spaces/.notis-base-skill.json +1 -1
- package/dist/base-skills/notis-spaces/SKILL.md +96 -24
- package/dist/base-skills/notis-spaces/references/architecture.md +4 -3
- package/dist/base-skills/notis-spaces/references/design.md +37 -18
- package/dist/base-skills/notis-spaces/references/reading.md +8 -1
- package/dist/base-skills/notis-spaces/references/reports.md +6 -6
- package/dist/base-skills/notis-spaces/references/sdk.md +71 -7
- package/dist/base-skills/notis-spaces/references/store.md +22 -13
- package/dist/base-skills/notis-spaces/references/views.md +99 -6
- package/dist/sdk/package.json +3 -0
- package/dist/sdk/src/cloudComputerWords.ts +53 -0
- package/dist/sdk/src/components/Audience.tsx +76 -0
- package/dist/sdk/src/components/DocumentPage.tsx +15 -4
- package/dist/sdk/src/components/MarkdownEditor.tsx +44 -14
- package/dist/sdk/src/components/MultiSelectActionBar.tsx +16 -5
- package/dist/sdk/src/components/Skeleton.tsx +162 -6
- package/dist/sdk/src/hooks/useAction.ts +12 -2
- package/dist/sdk/src/hooks/useAgentQueue.ts +125 -0
- package/dist/sdk/src/hooks/useCloudComputerJob.ts +142 -0
- package/dist/sdk/src/hooks/useCloudComputerService.ts +388 -0
- package/dist/sdk/src/hooks/useCloudComputerShell.ts +95 -7
- package/dist/sdk/src/hooks/useCollectionInteractions.ts +40 -2
- package/dist/sdk/src/hooks/useItemThread.ts +58 -0
- package/dist/sdk/src/hooks/useMarqueeSelection.ts +6 -1
- package/dist/sdk/src/hooks/useNativeDocuments.ts +61 -8
- package/dist/sdk/src/hooks/useNotisNavigation.ts +31 -8
- package/dist/sdk/src/hooks/useQuery.ts +67 -10
- package/dist/sdk/src/hooks/useViewParams.ts +47 -11
- package/dist/sdk/src/index.ts +31 -4
- package/dist/sdk/src/interactions.ts +2 -0
- package/dist/sdk/src/nativeData.ts +2 -0
- package/dist/sdk/src/optimisticRows.ts +329 -0
- package/dist/sdk/src/perf.ts +188 -0
- package/dist/sdk/src/provider.tsx +2 -1
- package/dist/sdk/src/queryCache.ts +366 -17
- package/dist/sdk/src/runtime.ts +55 -4
- package/dist/sdk/src/skeleton.ts +103 -0
- package/dist/sdk/src/space.ts +662 -28
- package/dist/sdk/src/spacePublicUI.ts +36 -0
- package/dist/sdk/src/ui/engine/step.ts +54 -0
- package/dist/sdk/src/ui/icons.tsx +3 -1
- package/dist/sdk/src/words/shell.ts +1 -0
- package/dist/skill-sync/index.js +7 -2
- package/dist/skill-sync-worker.mjs +40 -26
- package/dist/space-harness/host.js +272 -105
- package/dist/space-sdk/dist/chunk-BWHAORT4.js +5 -0
- package/dist/space-sdk/dist/index.js +9 -4
- package/dist/space-sdk/dist/ui.js +12 -12
- package/dist/space-sdk/package.json +3 -0
- package/dist/space-sdk/src/cloudComputerWords.d.ts +34 -0
- package/dist/space-sdk/src/components/Audience.d.ts +46 -0
- package/dist/space-sdk/src/components/DocumentPage.d.ts +3 -1
- package/dist/space-sdk/src/components/MarkdownEditor.d.ts +21 -0
- package/dist/space-sdk/src/components/MultiSelectActionBar.d.ts +5 -1
- package/dist/space-sdk/src/components/Skeleton.d.ts +7 -2
- package/dist/space-sdk/src/hooks/useAction.d.ts +8 -1
- package/dist/space-sdk/src/hooks/useAgentQueue.d.ts +61 -0
- package/dist/space-sdk/src/hooks/useCloudComputerJob.d.ts +35 -0
- package/dist/space-sdk/src/hooks/useCloudComputerService.d.ts +75 -0
- package/dist/space-sdk/src/hooks/useCloudComputerShell.d.ts +36 -3
- package/dist/space-sdk/src/hooks/useCollectionInteractions.d.ts +6 -0
- package/dist/space-sdk/src/hooks/useItemThread.d.ts +32 -0
- package/dist/space-sdk/src/hooks/useMarqueeSelection.d.ts +2 -1
- package/dist/space-sdk/src/hooks/useNativeDocumentBody.d.ts +1 -0
- package/dist/space-sdk/src/hooks/useNativeDocuments.d.ts +20 -5
- package/dist/space-sdk/src/hooks/useNotisNavigation.d.ts +11 -2
- package/dist/space-sdk/src/hooks/useQuery.d.ts +24 -2
- package/dist/space-sdk/src/hooks/useViewParams.d.ts +2 -0
- package/dist/space-sdk/src/index.d.ts +24 -4
- package/dist/space-sdk/src/nativeData.d.ts +6 -0
- package/dist/space-sdk/src/queryCache.d.ts +97 -2
- package/dist/space-sdk/src/runtime.d.ts +53 -4
- package/dist/space-sdk/src/skeleton.d.ts +42 -0
- package/dist/space-sdk/src/space.ts +662 -28
- package/dist/space-sdk/src/tailwind-candidates.d.ts +754 -5
- package/dist/space-sdk/src/ui/cloud/CloudComputerFrame.d.ts +29 -0
- package/dist/space-sdk/src/ui/cloud/CloudComputerWaking.d.ts +20 -0
- package/dist/space-sdk/src/ui/comments/CommentPane.d.ts +15 -2
- package/dist/space-sdk/src/ui/comments/PassageComments.d.ts +50 -0
- package/dist/space-sdk/src/ui/comments/commentFiles.d.ts +64 -0
- package/dist/space-sdk/src/ui/comments/commentModel.d.ts +49 -1
- package/dist/space-sdk/src/ui/comments/commentWords.d.ts +26 -0
- package/dist/space-sdk/src/ui/comments/index.d.ts +4 -0
- package/dist/space-sdk/src/ui/comments/passageModel.d.ts +82 -0
- package/dist/space-sdk/src/ui/comments/useComments.d.ts +34 -4
- package/dist/space-sdk/src/ui/comments/usePassageComments.d.ts +67 -0
- package/dist/space-sdk/src/ui/engine/index.d.ts +2 -2
- package/dist/space-sdk/src/ui/engine/step.d.ts +9 -0
- package/dist/space-sdk/src/ui/fields/fields.d.ts +2 -1
- package/dist/space-sdk/src/ui/index.d.ts +4 -0
- package/dist/space-sdk/src/ui/layout/Panels.d.ts +9 -2
- package/dist/space-sdk/src/ui/layout/SidePane.d.ts +42 -0
- package/dist/space-sdk/src/ui/layout/index.d.ts +2 -1
- package/dist/space-sdk/src/ui/layout/panelMath.d.ts +11 -2
- package/dist/space-sdk/src/ui/list/ListReader.d.ts +38 -7
- package/dist/space-sdk/src/ui/list/Row.d.ts +4 -0
- package/dist/space-sdk/src/ui/list/SelectionBar.d.ts +9 -4
- package/dist/space-sdk/src/ui/list/useListKeys.d.ts +4 -0
- package/dist/space-sdk/src/words/shell.ts +1 -0
- package/dist/view-renderer/dist/host.js +355 -188
- package/dist/view-renderer/dist/theme.css +1 -1
- package/dist/view-renderer/src/host.tsx +4 -1
- package/dist/view-renderer/src/index.js +3 -0
- package/dist/view-renderer/src/pool.js +8 -4
- package/dist/view-renderer/src/renderer.js +92 -23
- package/dist/view-renderer/src/skeleton.js +450 -0
- package/package.json +4 -4
- package/skills/notis-cli/AGENT_INSTRUCTIONS.md +8 -4
- package/skills/notis-onboarding/BRIEF.md +15 -9
- package/skills/notis-spaces/cli.md +43 -4
- package/src/command-specs/auth.js +5 -3
- package/src/command-specs/cc.js +410 -0
- package/src/command-specs/computer.js +320 -0
- package/src/command-specs/diagnostics.js +2 -13
- package/src/command-specs/documents.js +22 -4
- package/src/command-specs/index.js +7 -0
- package/src/command-specs/onboarding.js +127 -7
- package/src/command-specs/skills.js +2 -2
- package/src/command-specs/spaces.js +162 -30
- package/src/command-specs/tools.js +26 -8
- package/src/command-specs/views.js +4 -1
- package/src/runtime/agent-setup.js +20 -2
- package/src/runtime/app-boundary-validator.js +2 -1
- package/src/runtime/app-platform.js +13 -0
- package/src/runtime/auth-recovery.js +5 -0
- package/src/runtime/channel.js +16 -2
- package/src/runtime/cloud-transfer.js +587 -0
- package/src/runtime/computer-ssh.js +127 -0
- package/src/runtime/oauth.js +50 -4
- package/src/runtime/skill-sync/index.ts +20 -1
- package/src/runtime/skill-sync/local-scanner.ts +1 -0
- package/src/runtime/skill-sync/types.ts +2 -0
- package/src/runtime/space-audience.js +94 -0
- package/src/runtime/space-collection-scaffold.js +2 -1
- package/src/runtime/space-fixture-broker.js +2 -1
- package/src/runtime/space-lock.js +1 -4
- package/src/runtime/space-platform.js +18 -2
- package/src/runtime/space-source.js +105 -7
- package/src/runtime/space-test-server.js +13 -2
- package/src/runtime/space-verification.js +99 -6
- package/src/runtime/space-view-manifest.js +22 -4
- package/src/runtime/sync-skills.js +24 -20
- package/src/runtime/transport.js +19 -0
- package/src/runtime/view-render.js +2 -2
- package/template/.harness/index.html.tmpl +1 -1
- package/dist/skill-sync/index.js.map +0 -7
- package/dist/space-sdk/dist/chunk-SVZATGZB.js +0 -5
|
@@ -13,14 +13,95 @@ export interface QuerySnapshot<T = unknown> {
|
|
|
13
13
|
export interface QueryFetchOptions {
|
|
14
14
|
staleTimeMs?: number;
|
|
15
15
|
force?: boolean;
|
|
16
|
+
/** What rows the read holds, so a write to that database shows in it at once (see `optimistic`). */
|
|
17
|
+
rows?: RowsDescriptor;
|
|
16
18
|
}
|
|
17
19
|
|
|
20
|
+
/** The rows a read holds: its database binding and where the rows sit in its answer. */
|
|
21
|
+
export interface RowsDescriptor {
|
|
22
|
+
binding: string;
|
|
23
|
+
/** The answer field holding the rows ('documents', 'rows'), or '' when the answer is the list itself. */
|
|
24
|
+
at: string;
|
|
25
|
+
/** 'native': rows as the native query returns them; 'document': normalized `DocumentRecord`s. */
|
|
26
|
+
shape: 'native' | 'document';
|
|
27
|
+
/** The query whose filter and sorts the rows follow, when the page sends it (never a Space's private filter). */
|
|
28
|
+
query?: unknown;
|
|
29
|
+
/** A Space `shows` list name: its filter stays on the server, so a new row shows there only when asked. */
|
|
30
|
+
list?: string;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** One read a change applies to: its descriptor and cache key. */
|
|
34
|
+
export interface RowsRead extends RowsDescriptor { key: string }
|
|
35
|
+
|
|
36
|
+
type Row = Record<string, unknown>;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* How one write changes the rows of one database binding, read by read. `project` returns the row as that read
|
|
40
|
+
* should show it, or `undefined` to leave the read alone; `keeps` says whether the read still holds it (else it
|
|
41
|
+
* leaves, and a later write to it can bring it back). `insert` asks for the row in reads that do not hold it yet
|
|
42
|
+
* (given `undefined`), placed where `position` puts it, else at the top. `related` gives every row the reads of the
|
|
43
|
+
* database returned, to learn property types and options from. `exact` says the row shows the whole write, so it
|
|
44
|
+
* can take the revision the write made.
|
|
45
|
+
*/
|
|
46
|
+
export interface RowChange {
|
|
47
|
+
binding: string;
|
|
48
|
+
/** The row's key; a temporary one for a row being created, replaced on `commit`. */
|
|
49
|
+
recordKey: string;
|
|
50
|
+
insert?: boolean;
|
|
51
|
+
project(row: Row | undefined, read: RowsRead, related: () => readonly Row[]): Row | undefined;
|
|
52
|
+
keeps?(row: Row, read: RowsRead, related: () => readonly Row[]): boolean;
|
|
53
|
+
exact?(row: Row): boolean;
|
|
54
|
+
/** Where the row goes among `rows` (without it): a sorted place, or -1 to keep its place. */
|
|
55
|
+
position?(rows: readonly Row[], row: Row, read: RowsRead, related: () => readonly Row[]): number;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* The native rows behind a read whose rows are reshaped (`useNativeDocuments` flattens them), kept on its answer
|
|
60
|
+
* under this symbol (never serialized) so writes learn property types and options from them.
|
|
61
|
+
*/
|
|
62
|
+
export const NATIVE_ROWS = Symbol.for('notis.nativeRows');
|
|
63
|
+
|
|
64
|
+
/** Marks a row shown ahead of the server while its write runs (a symbol: never sent, never serialized). */
|
|
65
|
+
export const OPTIMISTIC_ROW = Symbol.for('notis.optimisticRow');
|
|
66
|
+
export interface OptimisticRowState {
|
|
67
|
+
/** When the write started (ms, the client's clock). */
|
|
68
|
+
since: number;
|
|
69
|
+
/** A row being created: its key is temporary, so it cannot be opened or changed yet. */
|
|
70
|
+
creating: boolean;
|
|
71
|
+
}
|
|
72
|
+
/** The saving state of a row the cache shows ahead of the server, or null once confirmed. */
|
|
73
|
+
export function optimisticRowState(row: unknown): OptimisticRowState | null {
|
|
74
|
+
return row && typeof row === 'object' ? ((row as Record<symbol, unknown>)[OPTIMISTIC_ROW] as OptimisticRowState | undefined) ?? null : null;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** A write shown before the server answers. */
|
|
78
|
+
export interface OptimisticWrite {
|
|
79
|
+
/**
|
|
80
|
+
* It succeeded: the change stays shown until every read that could still hold older rows reads again. A new row's
|
|
81
|
+
* temporary key becomes `recordKey` (and its id `id`); the rows take the `revision` the write made.
|
|
82
|
+
*/
|
|
83
|
+
commit(confirmed?: { recordKey?: string; id?: string; revision?: number }): void;
|
|
84
|
+
/** It failed: only this write's change goes away. */
|
|
85
|
+
rollback(): void;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* A read. `publish` (given by current clients) shows a first part of the answer while the rest loads, such as the
|
|
90
|
+
* first page of a read of every page: the snapshot then holds it, still fetching, until the read answers.
|
|
91
|
+
*/
|
|
92
|
+
export type QueryRead<T> = (publish?: (partial: T) => void) => Promise<T>;
|
|
93
|
+
|
|
18
94
|
export interface NotisQueryClient {
|
|
19
95
|
getSnapshot<T>(key: string): QuerySnapshot<T>;
|
|
20
96
|
subscribe(key: string, listener: () => void): () => void;
|
|
21
|
-
fetch<T>(key: string, read:
|
|
22
|
-
prefetch<T>(key: string, read:
|
|
97
|
+
fetch<T>(key: string, read: QueryRead<T>, options?: QueryFetchOptions): Promise<T>;
|
|
98
|
+
prefetch<T>(key: string, read: QueryRead<T>, options?: QueryFetchOptions): Promise<T>;
|
|
23
99
|
invalidate(key?: string): void;
|
|
100
|
+
/**
|
|
101
|
+
* Host-only: takes one key's answer away and shows `error` instead, without reading it again (a host that showed
|
|
102
|
+
* an earlier answer ahead of its source, and the source then failed). The read's `refetch` asks again.
|
|
103
|
+
*/
|
|
104
|
+
fail?(key: string, error: Error): void;
|
|
24
105
|
clear(): void;
|
|
25
106
|
/** Host-only: permanently retire a revoked security scope. */
|
|
26
107
|
dispose?(): void;
|
|
@@ -31,6 +112,8 @@ export interface NotisQueryClient {
|
|
|
31
112
|
* holds them is read again; `restore` shows them again (a failed or undone delete).
|
|
32
113
|
*/
|
|
33
114
|
hideRecords?(recordKeys: readonly string[]): HiddenRecords;
|
|
115
|
+
/** Shows a write in every cached read of its database at once, layered over the server's rows (see `RowChange`). */
|
|
116
|
+
optimistic?(changes: readonly RowChange[]): OptimisticWrite;
|
|
34
117
|
}
|
|
35
118
|
|
|
36
119
|
export interface HiddenRecords {
|
|
@@ -38,7 +121,7 @@ export interface HiddenRecords {
|
|
|
38
121
|
restore(recordKeys?: readonly string[]): void;
|
|
39
122
|
}
|
|
40
123
|
|
|
41
|
-
function recordKeyOf(item: unknown): string | undefined {
|
|
124
|
+
export function recordKeyOf(item: unknown): string | undefined {
|
|
42
125
|
if (!item || typeof item !== 'object') return undefined;
|
|
43
126
|
const record = item as { record_key?: unknown; recordKey?: unknown };
|
|
44
127
|
const key = record.record_key ?? record.recordKey;
|
|
@@ -69,6 +152,48 @@ function withoutRecords(data: unknown, hides: (key: string) => boolean, removed:
|
|
|
69
152
|
return result;
|
|
70
153
|
}
|
|
71
154
|
|
|
155
|
+
/** The rows at `at` in `data`, or null when the answer has none there. */
|
|
156
|
+
function rowsAt(data: unknown, at: string): Row[] | null {
|
|
157
|
+
const list = at ? (data && typeof data === 'object' ? (data as Row)[at] : undefined) : data;
|
|
158
|
+
return Array.isArray(list) ? list as Row[] : null;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function withRowsAt(data: unknown, at: string, rows: Row[]): unknown {
|
|
162
|
+
return at ? { ...(data as Row), [at]: rows } : rows;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* The rows after `changes`, or the same array when none applies; `saving` marks the rows of a running write. `left`
|
|
167
|
+
* holds the rows earlier writes took out of this read, so a later write that brings one back finds it.
|
|
168
|
+
*/
|
|
169
|
+
function changedRows(rows: Row[], changes: readonly RowChange[], read: RowsRead, related: () => readonly Row[],
|
|
170
|
+
saving: OptimisticRowState | null, left: Map<string, Row>): Row[] {
|
|
171
|
+
let out = rows;
|
|
172
|
+
for (const change of changes) {
|
|
173
|
+
if (change.binding !== read.binding) continue;
|
|
174
|
+
const index = out.findIndex((row) => recordKeyOf(row) === change.recordKey);
|
|
175
|
+
const current = index === -1 ? left.get(change.recordKey) : out[index];
|
|
176
|
+
if (current === undefined && !change.insert) continue;
|
|
177
|
+
let next = change.project(current, read, related);
|
|
178
|
+
if (next === undefined) continue;
|
|
179
|
+
if (out === rows) out = rows.slice();
|
|
180
|
+
if (index !== -1) out.splice(index, 1);
|
|
181
|
+
left.delete(change.recordKey);
|
|
182
|
+
if (change.keeps && !change.keeps(next, read, related)) { left.set(change.recordKey, next); continue; }
|
|
183
|
+
if (next === current) next = { ...next };
|
|
184
|
+
if (saving) {
|
|
185
|
+
Object.defineProperty(next, OPTIMISTIC_ROW, { value: { ...saving, creating: saving.creating && !!change.insert },
|
|
186
|
+
enumerable: false, configurable: true });
|
|
187
|
+
} else if (OPTIMISTIC_ROW in next) {
|
|
188
|
+
next = { ...next };
|
|
189
|
+
}
|
|
190
|
+
let at = change.position ? change.position(out, next, read, related) : -1;
|
|
191
|
+
if (at < 0) at = index === -1 ? 0 : index;
|
|
192
|
+
out.splice(Math.min(at, out.length), 0, next);
|
|
193
|
+
}
|
|
194
|
+
return out;
|
|
195
|
+
}
|
|
196
|
+
|
|
72
197
|
const EMPTY: QuerySnapshot = Object.freeze({
|
|
73
198
|
data: undefined, hasData: false, isFetching: false, error: null, updatedAt: 0, invalidation: 0,
|
|
74
199
|
});
|
|
@@ -113,14 +238,51 @@ type Entry = {
|
|
|
113
238
|
pending?: Promise<unknown>;
|
|
114
239
|
/** When the in-flight read started, including a first read with no raw snapshot yet. */
|
|
115
240
|
pendingSeq?: number;
|
|
241
|
+
key: string;
|
|
242
|
+
rows?: RowsDescriptor;
|
|
243
|
+
/** The optimistic writes last applied, so a refresh only republishes reads they change. */
|
|
244
|
+
applied: string;
|
|
245
|
+
/** A read answered while a new row of its database was being saved: shown once that write settles. */
|
|
246
|
+
deferred?: { data: unknown; seq: number; updatedAt: number };
|
|
247
|
+
/** `raw.data` is an answer kept from an earlier visit (`seed`) that no read of this client confirmed yet. */
|
|
248
|
+
seeded?: boolean;
|
|
116
249
|
};
|
|
117
250
|
|
|
251
|
+
/** An answer a host kept from an earlier visit: shown at once, then read again on first use (it is never fresh). */
|
|
252
|
+
export interface QuerySeed { data: unknown; rows?: RowsDescriptor }
|
|
253
|
+
|
|
254
|
+
type Write = { id: number; changes: RowChange[]; bindings: Set<string>; committed: number | null; since: number;
|
|
255
|
+
/** When it was sent, on the client's `seq` clock. */
|
|
256
|
+
sent: number;
|
|
257
|
+
/** The revision the confirmed write made, when the server said. */
|
|
258
|
+
revision?: number };
|
|
259
|
+
|
|
260
|
+
/** Whether `rows` (a read's own answer) already hold a confirmed write: its new row, or its edit's revision. */
|
|
261
|
+
function holds(rows: readonly Row[], write: Write, binding: string): boolean {
|
|
262
|
+
return write.changes.every((change) => {
|
|
263
|
+
if (change.binding !== binding) return true;
|
|
264
|
+
const row = rows.find((candidate) => recordKeyOf(candidate) === change.recordKey);
|
|
265
|
+
if (change.insert) return !!row;
|
|
266
|
+
if (!row) return true;
|
|
267
|
+
return write.revision !== undefined && typeof row.revision === 'number' && row.revision >= write.revision;
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
|
|
118
271
|
export function createQueryClient(options: {
|
|
119
272
|
maxEntries?: number;
|
|
120
273
|
now?: () => number;
|
|
121
274
|
schedule?: ReturnType<typeof createPrefetchQueue>;
|
|
122
275
|
/** Bounds idempotent reads only; never retries the underlying callback. */
|
|
123
276
|
readTimeoutMs?: number;
|
|
277
|
+
/**
|
|
278
|
+
* Answers the host kept from an earlier visit of the same access scope, by key: shown at once and read again on
|
|
279
|
+
* first use. A read that fails takes its kept answer away instead of showing it with the error.
|
|
280
|
+
*/
|
|
281
|
+
seed?: ReadonlyMap<string, QuerySeed>;
|
|
282
|
+
/** Told every answer a read returned (the host may keep it for a later visit). */
|
|
283
|
+
onAnswer?: (key: string, data: unknown, rows?: RowsDescriptor) => void;
|
|
284
|
+
/** Told every read that failed (the host forgets what it kept for it). */
|
|
285
|
+
onFailure?: (key: string, error: Error) => void;
|
|
124
286
|
} = {}): NotisQueryClient {
|
|
125
287
|
const entries = new Map<string, Entry>();
|
|
126
288
|
const now = options.now ?? Date.now;
|
|
@@ -132,6 +294,9 @@ export function createQueryClient(options: {
|
|
|
132
294
|
let seq = 0;
|
|
133
295
|
// null while the delete runs; then the `seq` it committed at.
|
|
134
296
|
const hidden = new Map<string, number | null>();
|
|
297
|
+
// Writes shown before the server answers, oldest first.
|
|
298
|
+
let writes: Write[] = [];
|
|
299
|
+
let writeIds = 0;
|
|
135
300
|
|
|
136
301
|
function prune(keep?: string) {
|
|
137
302
|
for (const [oldKey, old] of entries) {
|
|
@@ -142,7 +307,7 @@ export function createQueryClient(options: {
|
|
|
142
307
|
function entry(key: string): Entry {
|
|
143
308
|
let value = entries.get(key);
|
|
144
309
|
if (!value) {
|
|
145
|
-
value = { raw: EMPTY, snapshot: EMPTY, removed: '', dataSeq: 0, listeners: new Set(), generation: 0 };
|
|
310
|
+
value = { raw: EMPTY, snapshot: EMPTY, removed: '', dataSeq: 0, listeners: new Set(), generation: 0, applied: '', key };
|
|
146
311
|
entries.set(key, value);
|
|
147
312
|
}
|
|
148
313
|
// Only operations, not getSnapshot during render, update the LRU.
|
|
@@ -151,21 +316,70 @@ export function createQueryClient(options: {
|
|
|
151
316
|
prune(key);
|
|
152
317
|
return value;
|
|
153
318
|
}
|
|
154
|
-
/**
|
|
319
|
+
/** The writes a read still needs layered over its rows: pending ones, and committed ones it read before. */
|
|
320
|
+
function writesFor(value: Entry): Write[] {
|
|
321
|
+
const rows = value.rows;
|
|
322
|
+
if (!rows || !writes.length || !value.raw.hasData) return [];
|
|
323
|
+
return writes.filter((write) => write.bindings.has(rows.binding)
|
|
324
|
+
&& (write.committed === null || (value.dataSeq < write.committed && !holdsWrite(value, write))));
|
|
325
|
+
}
|
|
326
|
+
/** A read that started before the write was confirmed may still have answered with it (the host reads again first). */
|
|
327
|
+
function holdsWrite(value: Entry, write: Write): boolean {
|
|
328
|
+
const list = value.rows && value.raw.hasData ? rowsAt(value.raw.data, value.rows.at) : null;
|
|
329
|
+
return !!list && holds(list, write, value.rows!.binding);
|
|
330
|
+
}
|
|
331
|
+
/** Recomputes the shown snapshot; without `rawChanged`, only when the hidden records or the writes changed for it. */
|
|
155
332
|
function view(value: Entry, rawChanged: boolean): boolean {
|
|
333
|
+
const layered = writesFor(value);
|
|
334
|
+
const applied = layered.map((write) => `${write.id}:${write.committed ?? ''}`).join(',');
|
|
335
|
+
let data = value.raw.data;
|
|
336
|
+
if (layered.length && value.rows) {
|
|
337
|
+
const read = { ...value.rows, key: value.key };
|
|
338
|
+
const list = rowsAt(data, read.at);
|
|
339
|
+
if (list) {
|
|
340
|
+
let next = list;
|
|
341
|
+
const related = () => relatedRows(read.binding);
|
|
342
|
+
const left = new Map<string, Row>();
|
|
343
|
+
for (const write of layered) {
|
|
344
|
+
next = changedRows(next, write.changes, read, related,
|
|
345
|
+
write.committed === null ? { since: write.since, creating: true } : null, left);
|
|
346
|
+
}
|
|
347
|
+
if (next !== list) data = withRowsAt(data, read.at, next);
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
// Hidden records are taken out after the writes, so a new row deleted before the reads hold it leaves too.
|
|
156
351
|
const removed: string[] = [];
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
352
|
+
if (hidden.size && value.raw.hasData) {
|
|
353
|
+
data = withoutRecords(data, (key) => {
|
|
354
|
+
if (!hidden.has(key)) return false;
|
|
355
|
+
const committed = hidden.get(key);
|
|
356
|
+
return committed === null || committed === undefined || value.dataSeq < committed;
|
|
357
|
+
}, removed);
|
|
358
|
+
}
|
|
162
359
|
const signature = removed.sort().join('\u0000');
|
|
163
|
-
if (!rawChanged && value.removed === signature) return false;
|
|
360
|
+
if (!rawChanged && value.removed === signature && value.applied === applied) return false;
|
|
164
361
|
value.removed = signature;
|
|
362
|
+
value.applied = applied;
|
|
165
363
|
value.snapshot = data === value.raw.data ? value.raw : { ...value.raw, data };
|
|
166
364
|
return true;
|
|
167
365
|
}
|
|
366
|
+
// Every row the reads of a database returned, for changes to learn its property types and options from.
|
|
367
|
+
const related = new Map<string, Row[]>();
|
|
368
|
+
function relatedRows(binding: string): Row[] {
|
|
369
|
+
let rows = related.get(binding);
|
|
370
|
+
if (!rows) {
|
|
371
|
+
rows = [];
|
|
372
|
+
for (const value of entries.values()) {
|
|
373
|
+
if (value.rows?.binding !== binding || !value.raw.hasData) continue;
|
|
374
|
+
const native = (value.raw.data as Record<symbol, unknown> | null)?.[NATIVE_ROWS];
|
|
375
|
+
rows.push(...(Array.isArray(native) ? native as Row[] : rowsAt(value.raw.data, value.rows.at) ?? []));
|
|
376
|
+
}
|
|
377
|
+
related.set(binding, rows);
|
|
378
|
+
}
|
|
379
|
+
return rows;
|
|
380
|
+
}
|
|
168
381
|
function publish(value: Entry, raw: QuerySnapshot) {
|
|
382
|
+
if (raw.data !== value.raw.data) related.clear();
|
|
169
383
|
value.raw = raw;
|
|
170
384
|
view(value, true);
|
|
171
385
|
for (const listener of value.listeners) listener();
|
|
@@ -174,7 +388,7 @@ export function createQueryClient(options: {
|
|
|
174
388
|
function sweep() {
|
|
175
389
|
for (const [key, committed] of hidden) {
|
|
176
390
|
if (committed === null) continue;
|
|
177
|
-
let held =
|
|
391
|
+
let held = writes.some((write) => write.changes.some((change) => change.insert && change.recordKey === key));
|
|
178
392
|
for (const value of entries.values()) {
|
|
179
393
|
if (value.pending && value.pendingSeq !== undefined && value.pendingSeq < committed) { held = true; break; }
|
|
180
394
|
if (value.dataSeq >= committed || !value.raw.hasData) continue;
|
|
@@ -184,6 +398,36 @@ export function createQueryClient(options: {
|
|
|
184
398
|
}
|
|
185
399
|
if (!held) hidden.delete(key);
|
|
186
400
|
}
|
|
401
|
+
const before = writes.length;
|
|
402
|
+
writes = writes.filter((write) => {
|
|
403
|
+
if (write.committed === null) return true;
|
|
404
|
+
for (const value of entries.values()) {
|
|
405
|
+
if (!value.rows || !write.bindings.has(value.rows.binding)) continue;
|
|
406
|
+
if (value.pending && value.pendingSeq !== undefined && value.pendingSeq < write.committed) return true;
|
|
407
|
+
if (value.raw.hasData && value.dataSeq < write.committed && !holdsWrite(value, write)) return true;
|
|
408
|
+
}
|
|
409
|
+
return false;
|
|
410
|
+
});
|
|
411
|
+
if (writes.length !== before) refresh();
|
|
412
|
+
}
|
|
413
|
+
/**
|
|
414
|
+
* A read that started after a new row was sent may already hold it under its real key, which only the receipt
|
|
415
|
+
* names: until then the shown row keeps its temporary key, and that read would list the row twice.
|
|
416
|
+
*/
|
|
417
|
+
function savingInsert(value: Entry, startSeq: number): boolean {
|
|
418
|
+
const binding = value.rows?.binding;
|
|
419
|
+
return !!binding && value.raw.hasData && writes.some((write) => write.committed === null && write.sent < startSeq
|
|
420
|
+
&& write.changes.some((change) => change.insert && change.binding === binding));
|
|
421
|
+
}
|
|
422
|
+
/** Shows the reads held back by `savingInsert` once no new row they could hold is still being saved. */
|
|
423
|
+
function release() {
|
|
424
|
+
for (const value of entries.values()) {
|
|
425
|
+
const deferred = value.deferred;
|
|
426
|
+
if (!deferred || savingInsert(value, deferred.seq)) continue;
|
|
427
|
+
value.deferred = undefined;
|
|
428
|
+
value.dataSeq = deferred.seq;
|
|
429
|
+
publish(value, { ...value.raw, data: deferred.data, hasData: true, updatedAt: deferred.updatedAt });
|
|
430
|
+
}
|
|
187
431
|
}
|
|
188
432
|
function refresh() {
|
|
189
433
|
for (const value of entries.values()) {
|
|
@@ -197,9 +441,10 @@ export function createQueryClient(options: {
|
|
|
197
441
|
value.listeners.add(listener);
|
|
198
442
|
return () => { value.listeners.delete(listener); prune(); };
|
|
199
443
|
},
|
|
200
|
-
fetch<T>(key: string, read:
|
|
444
|
+
fetch<T>(key: string, read: QueryRead<T>, fetchOptions: QueryFetchOptions = {}) {
|
|
201
445
|
if (disposed) return Promise.reject(new SdkQueryError('scopeUnavailable'));
|
|
202
446
|
const value = entry(key);
|
|
447
|
+
if (fetchOptions.rows) value.rows = fetchOptions.rows;
|
|
203
448
|
if (value.pending) return value.pending as Promise<T>;
|
|
204
449
|
if (!fetchOptions.force && value.snapshot.hasData && value.snapshot.updatedAt > 0
|
|
205
450
|
&& now() - value.snapshot.updatedAt < (fetchOptions.staleTimeMs ?? 30_000)) {
|
|
@@ -215,16 +460,45 @@ export function createQueryClient(options: {
|
|
|
215
460
|
// Node-based verification must not stay alive for a retired browser read.
|
|
216
461
|
if (typeof timeout === 'object' && 'unref' in timeout) timeout.unref();
|
|
217
462
|
});
|
|
218
|
-
|
|
219
|
-
|
|
463
|
+
// A first part shows only while this read is still the entry's own and the entry has no answer yet: a reread
|
|
464
|
+
// keeps every row it showed until the whole answer is back.
|
|
465
|
+
// Nor while a new row of its database sent before it is being saved: the part could hold it twice.
|
|
466
|
+
let settled = false;
|
|
467
|
+
let partShown = false;
|
|
468
|
+
const partial = (data: T) => {
|
|
469
|
+
if (settled || !canCommit() || value.pending !== request || (value.raw.hasData && !partShown)) return;
|
|
470
|
+
const binding = value.rows?.binding;
|
|
471
|
+
if (binding && writes.some((write) => write.committed === null && write.sent < startSeq
|
|
472
|
+
&& write.changes.some((change) => change.insert && change.binding === binding))) return;
|
|
473
|
+
partShown = true;
|
|
474
|
+
value.deferred = undefined;
|
|
475
|
+
value.dataSeq = startSeq;
|
|
476
|
+
publish(value, { ...value.raw, data, hasData: true, isFetching: true, error: null, updatedAt: 0 });
|
|
477
|
+
};
|
|
478
|
+
const request: Promise<T> = Promise.race([Promise.resolve().then(() => read(partial)), deadline]).then((data) => {
|
|
479
|
+
settled = true;
|
|
480
|
+
if (canCommit() && savingInsert(value, startSeq)) {
|
|
481
|
+
value.deferred = { data, seq: startSeq, updatedAt: now() };
|
|
482
|
+
publish(value, { ...value.raw, isFetching: false, error: null });
|
|
483
|
+
} else if (canCommit()) {
|
|
484
|
+
value.deferred = undefined;
|
|
220
485
|
value.dataSeq = startSeq;
|
|
486
|
+
value.seeded = false;
|
|
221
487
|
publish(value, { ...value.raw, data, hasData: true, isFetching: false, error: null, updatedAt: now() });
|
|
222
488
|
if (hidden.size) sweep();
|
|
489
|
+
options.onAnswer?.(key, data, value.rows);
|
|
223
490
|
}
|
|
224
491
|
return data;
|
|
225
492
|
}, (reason) => {
|
|
493
|
+
settled = true;
|
|
226
494
|
const error = reason instanceof Error ? reason : new Error(String(reason));
|
|
227
|
-
|
|
495
|
+
// A first part, or an answer kept from an earlier visit, never stands for an answer that failed.
|
|
496
|
+
if (canCommit()) {
|
|
497
|
+
publish(value, partShown || value.seeded ? { ...EMPTY, invalidation: value.raw.invalidation, error }
|
|
498
|
+
: { ...value.raw, isFetching: false, error });
|
|
499
|
+
value.seeded = false;
|
|
500
|
+
}
|
|
501
|
+
options.onFailure?.(key, error);
|
|
228
502
|
throw error;
|
|
229
503
|
}).finally(() => {
|
|
230
504
|
clearTimeout(timeout);
|
|
@@ -237,7 +511,7 @@ export function createQueryClient(options: {
|
|
|
237
511
|
publish(value, { ...value.raw, isFetching: true, error: null });
|
|
238
512
|
return request;
|
|
239
513
|
},
|
|
240
|
-
prefetch<T>(key: string, read:
|
|
514
|
+
prefetch<T>(key: string, read: QueryRead<T>, fetchOptions?: QueryFetchOptions) {
|
|
241
515
|
const requestEpoch = epoch;
|
|
242
516
|
return schedule(() => {
|
|
243
517
|
if (epoch !== requestEpoch) throw new SdkQueryError('scopeCleared');
|
|
@@ -252,9 +526,23 @@ export function createQueryClient(options: {
|
|
|
252
526
|
value.generation += 1;
|
|
253
527
|
value.pending = undefined;
|
|
254
528
|
value.pendingSeq = undefined;
|
|
529
|
+
if (value.deferred) value.deferred.updatedAt = 0;
|
|
255
530
|
publish(value, { ...value.raw, updatedAt: 0, isFetching: false, invalidation: value.raw.invalidation + 1 });
|
|
256
531
|
}
|
|
257
532
|
},
|
|
533
|
+
fail(key, error) {
|
|
534
|
+
const value = entries.get(key);
|
|
535
|
+
if (!value) return;
|
|
536
|
+
revision += 1;
|
|
537
|
+
value.generation += 1;
|
|
538
|
+
value.pending = undefined;
|
|
539
|
+
value.pendingSeq = undefined;
|
|
540
|
+
value.deferred = undefined;
|
|
541
|
+
value.seeded = false;
|
|
542
|
+
// The same invalidation count: the read shows the error and is not asked again on its own.
|
|
543
|
+
publish(value, { ...EMPTY, invalidation: value.raw.invalidation, error });
|
|
544
|
+
options.onFailure?.(key, error);
|
|
545
|
+
},
|
|
258
546
|
dispose() { disposed = true; client.clear(); },
|
|
259
547
|
clear() {
|
|
260
548
|
revision += 1;
|
|
@@ -264,11 +552,64 @@ export function createQueryClient(options: {
|
|
|
264
552
|
value.pending = undefined;
|
|
265
553
|
value.pendingSeq = undefined;
|
|
266
554
|
value.dataSeq = 0;
|
|
555
|
+
value.deferred = undefined;
|
|
267
556
|
publish(value, { ...EMPTY, invalidation: value.raw.invalidation + 1 });
|
|
268
557
|
}
|
|
558
|
+
writes = [];
|
|
269
559
|
for (const [key, value] of entries) if (!value.listeners.size) entries.delete(key);
|
|
270
560
|
sweep();
|
|
271
561
|
},
|
|
562
|
+
optimistic(changes) {
|
|
563
|
+
const write: Write = { id: ++writeIds, changes: [...changes], bindings: new Set(changes.map((change) => change.binding)),
|
|
564
|
+
committed: null, since: now(), sent: ++seq };
|
|
565
|
+
if (disposed || !write.changes.length) return { commit() {}, rollback() {} };
|
|
566
|
+
writes.push(write);
|
|
567
|
+
const startEpoch = epoch;
|
|
568
|
+
refresh();
|
|
569
|
+
let settled = false;
|
|
570
|
+
return {
|
|
571
|
+
commit(confirmed) {
|
|
572
|
+
if (settled || epoch !== startEpoch) return;
|
|
573
|
+
settled = true;
|
|
574
|
+
const { recordKey, revision } = confirmed ?? {};
|
|
575
|
+
write.changes = write.changes.map((change) => {
|
|
576
|
+
const project = change.project;
|
|
577
|
+
if (change.insert && recordKey) {
|
|
578
|
+
return { ...change, recordKey, project: (row, read, rows) => {
|
|
579
|
+
// Once the server's rows hold it, the new row is theirs.
|
|
580
|
+
if (row) return undefined;
|
|
581
|
+
const next = project(undefined, read, rows);
|
|
582
|
+
if (!next) return next;
|
|
583
|
+
const renamed: Row = { ...next, id: confirmed?.id ?? recordKey };
|
|
584
|
+
for (const field of ['recordKey', 'record_key'] as const) if (field in next) renamed[field] = recordKey;
|
|
585
|
+
if (revision !== undefined) renamed.revision = revision;
|
|
586
|
+
return renamed;
|
|
587
|
+
} };
|
|
588
|
+
}
|
|
589
|
+
// The next edit of a changed row must name the revision this write made.
|
|
590
|
+
if (change.insert || revision === undefined) return change;
|
|
591
|
+
return { ...change, project: (row, read, rows) => {
|
|
592
|
+
const next = project(row, read, rows);
|
|
593
|
+
// A row that could not show every written value keeps its revision: it is not the saved row yet.
|
|
594
|
+
return next && (change.exact?.(next) ?? true) ? { ...next, revision } : next;
|
|
595
|
+
} };
|
|
596
|
+
});
|
|
597
|
+
// Reads that started after this hold the write themselves; older ones keep it layered until their rows do.
|
|
598
|
+
write.revision = revision;
|
|
599
|
+
write.committed = ++seq;
|
|
600
|
+
release();
|
|
601
|
+
refresh();
|
|
602
|
+
sweep();
|
|
603
|
+
},
|
|
604
|
+
rollback() {
|
|
605
|
+
if (settled) return;
|
|
606
|
+
settled = true;
|
|
607
|
+
writes = writes.filter((candidate) => candidate !== write);
|
|
608
|
+
release();
|
|
609
|
+
refresh();
|
|
610
|
+
},
|
|
611
|
+
};
|
|
612
|
+
},
|
|
272
613
|
hideRecords(recordKeys) {
|
|
273
614
|
const own = [...new Set(recordKeys.filter((key) => typeof key === 'string' && key))];
|
|
274
615
|
for (const key of own) hidden.set(key, null);
|
|
@@ -288,5 +629,13 @@ export function createQueryClient(options: {
|
|
|
288
629
|
};
|
|
289
630
|
},
|
|
290
631
|
};
|
|
632
|
+
// Kept answers show at once. They carry no time (`updatedAt` 0), so their first use always reads again.
|
|
633
|
+
for (const [key, kept] of options.seed ?? []) {
|
|
634
|
+
if (entries.size >= maxEntries) break;
|
|
635
|
+
const value = entry(key);
|
|
636
|
+
if (kept.rows) value.rows = kept.rows;
|
|
637
|
+
value.seeded = true;
|
|
638
|
+
publish(value, { ...EMPTY, data: kept.data, hasData: true });
|
|
639
|
+
}
|
|
291
640
|
return client;
|
|
292
641
|
}
|
package/dist/sdk/src/runtime.ts
CHANGED
|
@@ -10,7 +10,8 @@ import type { AgentContextContent, AgentContextItem, AgentContextSource } from '
|
|
|
10
10
|
|
|
11
11
|
import type { ComponentType, ReactNode } from 'react';
|
|
12
12
|
import type { NotisQueryClient } from './queryCache';
|
|
13
|
-
import type {
|
|
13
|
+
import type { NotisSpaceSkeleton } from './skeleton';
|
|
14
|
+
import type { SpaceRuntimeDescriptor, SpaceActionOptions, SpaceDocumentBodyRequest, SpaceDocumentBodyResult, SpaceViewerReadOperation, SpaceShownOptions, SpaceCloudComputerTransport, SpaceFilesTransport, SpaceThreadsTransport } from './space';
|
|
14
15
|
|
|
15
16
|
// ---------------------------------------------------------------------------
|
|
16
17
|
// Database types
|
|
@@ -178,6 +179,18 @@ export interface QueryFilter {
|
|
|
178
179
|
page_size?: number;
|
|
179
180
|
}
|
|
180
181
|
|
|
182
|
+
/**
|
|
183
|
+
* The host's answer to `navigate`: nothing when it took the navigation, or a typed refusal when it did not
|
|
184
|
+
* (`context_inactive`: the view the call came from is retained, covered or pending, so its navigation is dropped).
|
|
185
|
+
* The hooks turn a refusal into a warned, settled rejection; it is never an uncaught error.
|
|
186
|
+
*/
|
|
187
|
+
export interface NotisNavigationRefusal { refused: 'context_inactive'; message: string }
|
|
188
|
+
export type NotisNavigationAnswer = void | NotisNavigationRefusal;
|
|
189
|
+
export function isNotisNavigationRefusal(value: unknown): value is NotisNavigationRefusal {
|
|
190
|
+
return typeof value === 'object' && value !== null && typeof (value as { refused?: unknown }).refused === 'string'
|
|
191
|
+
&& typeof (value as { message?: unknown }).message === 'string';
|
|
192
|
+
}
|
|
193
|
+
|
|
181
194
|
export interface NotisRuntimeContext {
|
|
182
195
|
/** Host UI language. */
|
|
183
196
|
locale?: 'en' | 'fr';
|
|
@@ -190,6 +203,8 @@ export interface NotisRuntimeContext {
|
|
|
190
203
|
collectionItem?: CollectionItemDetail | null;
|
|
191
204
|
/** App-owned resource requested through the route's `?resource=<id>` link. */
|
|
192
205
|
resourceId?: string | null;
|
|
206
|
+
/** Loading bones measured from this release at build time; `ViewSkeleton` draws them. Absent until the host has them. */
|
|
207
|
+
readonly skeleton?: NotisSpaceSkeleton;
|
|
193
208
|
}
|
|
194
209
|
|
|
195
210
|
// ---------------------------------------------------------------------------
|
|
@@ -446,8 +461,21 @@ export interface NotisRuntimeUI {
|
|
|
446
461
|
ReportFrame?: ComponentType<NotisReportFrameProps>;
|
|
447
462
|
ShareControl?: ComponentType<NotisShareControlProps>;
|
|
448
463
|
SpacePageFrame?: ComponentType<NotisSpacePageFrameProps>;
|
|
449
|
-
/**
|
|
450
|
-
|
|
464
|
+
/**
|
|
465
|
+
* Starts reading a record (and the page's code) before it opens, for example when a list row is hovered. Without
|
|
466
|
+
* `hint` (a Space's own call) the read always starts after a short hover delay; with it (the toolkit list does
|
|
467
|
+
* this for its rows) the host reads only where the Space opens records as document pages, at once for the
|
|
468
|
+
* cursor row and soon after for its neighbours, and may paint `title` while the record loads.
|
|
469
|
+
*/
|
|
470
|
+
prefetchRecord?: (recordKey: string, hint?: RecordPrefetchHint) => void;
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
/** Why the toolkit reads a record ahead (see `NotisRuntimeUI.prefetchRecord`). */
|
|
474
|
+
export interface RecordPrefetchHint {
|
|
475
|
+
/** 'cursor': the keyboard cursor is on its row; 'neighbour': next to it; 'hover': a pointer over it. */
|
|
476
|
+
intent: 'cursor' | 'neighbour' | 'hover';
|
|
477
|
+
/** The row's title, shown in the page while the record loads. */
|
|
478
|
+
title?: string | null;
|
|
451
479
|
}
|
|
452
480
|
|
|
453
481
|
// ---------------------------------------------------------------------------
|
|
@@ -488,11 +516,18 @@ export interface HandoverPayload {
|
|
|
488
516
|
* background calls still open an editable draft.
|
|
489
517
|
*/
|
|
490
518
|
autoSend?: boolean;
|
|
519
|
+
/**
|
|
520
|
+
* Space only: start a new chat instead of continuing the item's thread. By default the handover continues
|
|
521
|
+
* the thread the Space's thread rule matches (the same one the side chat and agent wake-ups use).
|
|
522
|
+
*/
|
|
523
|
+
newChat?: boolean;
|
|
491
524
|
}
|
|
492
525
|
|
|
493
526
|
export interface HandoverResult {
|
|
494
527
|
/** `drafted` when the user still has to press send, `sent` when it went straight through. */
|
|
495
528
|
status: 'drafted' | 'sent';
|
|
529
|
+
/** The thread the handover continued, when the host continued one. */
|
|
530
|
+
threadId?: string | null;
|
|
496
531
|
}
|
|
497
532
|
|
|
498
533
|
/**
|
|
@@ -567,6 +602,11 @@ export interface NotisRuntime {
|
|
|
567
602
|
* signed-in Editor. Absent on Sites and older hosts.
|
|
568
603
|
*/
|
|
569
604
|
shown?<TResult = unknown>(name: string, params?: Record<string, unknown>, options?: SpaceShownOptions): Promise<TResult>;
|
|
605
|
+
/**
|
|
606
|
+
* Space-only: an editor switches View as the public on (`'public'`) or off (`null`). The host repaints the Space
|
|
607
|
+
* with `space.viewAs` set; it never adds rights. Absent where the viewer is not an editor and on older hosts.
|
|
608
|
+
*/
|
|
609
|
+
setSpaceViewAs?(mode: 'public' | null): void;
|
|
570
610
|
/** Space-only unsent Manager draft; distinct from legacy App activation. */
|
|
571
611
|
draftHandover?(payload: HandoverPayload): Promise<HandoverResult>;
|
|
572
612
|
/**
|
|
@@ -574,6 +614,17 @@ export interface NotisRuntime {
|
|
|
574
614
|
* viewer allows it. Absent on Sites, links, verification harnesses and older hosts.
|
|
575
615
|
*/
|
|
576
616
|
spaceCloudComputer?: SpaceCloudComputerTransport;
|
|
617
|
+
/**
|
|
618
|
+
* Space-only files attached from a view to a database's files column (comment pictures): the signed-in Editor's
|
|
619
|
+
* own upload into Notis's private EU storage. Absent on Sites, previews, verification harnesses and older hosts.
|
|
620
|
+
*/
|
|
621
|
+
spaceFiles?: SpaceFilesTransport;
|
|
622
|
+
/**
|
|
623
|
+
* Space-only thread resolver and agents' queue: the thread an item continues (shared by the side chat,
|
|
624
|
+
* `useHandover` and agent wake-ups) and each declared agent's latest wake-up. Absent on Sites, links and
|
|
625
|
+
* older hosts.
|
|
626
|
+
*/
|
|
627
|
+
spaceThreads?: SpaceThreadsTransport;
|
|
577
628
|
/** Authenticated runtime identity; app below is presentation metadata only. */
|
|
578
629
|
resource?: RuntimeResource;
|
|
579
630
|
/** Optional host-scoped in-memory read cache. Older hosts remain supported. */
|
|
@@ -640,7 +691,7 @@ export interface NotisRuntime {
|
|
|
640
691
|
* `useViewParams().setParams` sends `view-params` (`{ params, replace? }`): the open Space's own URL params, with the
|
|
641
692
|
* Space and record kept and no destination lookup.
|
|
642
693
|
*/
|
|
643
|
-
navigate?: (payload: { kind: string; [key: string]: unknown }) =>
|
|
694
|
+
navigate?: (payload: { kind: string; [key: string]: unknown }) => NotisNavigationAnswer | Promise<NotisNavigationAnswer>;
|
|
644
695
|
|
|
645
696
|
registerTopBarSearch?: (
|
|
646
697
|
config:
|