@lotics/app-sdk 0.133.45 → 0.133.48
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +1 -1
- package/dist/{chunk-WW2P5AH3.js → chunk-NS3BIL73.js} +28 -4
- package/dist/index.js +309 -149
- package/dist/queries.d.ts +13 -0
- package/dist/router.js +1 -1
- package/dist/rpc.d.ts +7 -3
- package/dist/shared_types.d.ts +2 -2
- package/dist/store.d.ts +10 -2
- package/dist/viewer.d.ts +2 -0
- package/docs/data_fetching.md +6 -4
- package/docs/members_and_options.md +5 -1
- package/docs/queries.md +8 -8
- package/package.json +1 -1
package/dist/store.d.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
|
+
import { type QueryChanges } from "./rpc.js";
|
|
1
2
|
/** How a key is read: from when the request was sent and the answer it holds now (a feed grows from it). */
|
|
2
3
|
export type Fetcher<T> = (askedAt: number, current: T | undefined) => Promise<T>;
|
|
4
|
+
/**
|
|
5
|
+
* How a key opted in to partial refresh answers a push: the fetcher that re-reads only what `changes` touched of the
|
|
6
|
+
* answer held (asked at `heldAskedAt`), or `null` where this push must be asked whole.
|
|
7
|
+
*/
|
|
8
|
+
export type Patcher<T> = (held: T | undefined, changes: QueryChanges, heldAskedAt: number) => Fetcher<T> | null;
|
|
3
9
|
/**
|
|
4
10
|
* A focus or reconnect within this long of a key's last ask asks nothing: returns to the tab a minute apart are one
|
|
5
11
|
* visit. A push asks at once whatever this says, so what this bounds is only what no push carries — a dead channel, a
|
|
@@ -13,8 +19,8 @@ export declare function refetchReads(aliases: readonly string[] | undefined): vo
|
|
|
13
19
|
/** `refetchReads`, settled once every key a screen reads now holds an answer asked after this call — or its refusal. */
|
|
14
20
|
export declare function readsAnswered(aliases: readonly string[]): Promise<void>;
|
|
15
21
|
/** The host's push, naming the aliases whose tables moved: each key reading one asked again (`refetchReads`), in one
|
|
16
|
-
* paint. */
|
|
17
|
-
export declare function refetchPushed(aliases: readonly string[]): void;
|
|
22
|
+
* paint — a key that opted in to partial refresh re-reading only what `changes` names of it, where that applies. */
|
|
23
|
+
export declare function refetchPushed(aliases: readonly string[], changes?: QueryChanges): void;
|
|
18
24
|
export interface Held<T> {
|
|
19
25
|
/** The answer shown: each staged value over it, else the answer; the last key's while a new key is first asked. */
|
|
20
26
|
data: T | undefined;
|
|
@@ -40,6 +46,8 @@ export interface KeyOptions<T> {
|
|
|
40
46
|
arrival?: boolean;
|
|
41
47
|
/** The query aliases the key reads. */
|
|
42
48
|
aliases?: readonly string[];
|
|
49
|
+
/** Where a push names only the records it changed, the fetcher re-reading just those of the answer held. */
|
|
50
|
+
patch?: Patcher<T>;
|
|
43
51
|
/** An answer known without asking — a design-time fixture's — shown from the first render. */
|
|
44
52
|
known?: (askedAt: number) => T | undefined;
|
|
45
53
|
}
|
package/dist/viewer.d.ts
CHANGED
|
@@ -17,6 +17,8 @@ export declare function useAppContext(): {
|
|
|
17
17
|
insider: boolean;
|
|
18
18
|
/** The viewer's member groups, by id; `null` where the host did not say. */
|
|
19
19
|
groupIds: readonly string[] | null;
|
|
20
|
+
/** The viewer administers the app's workspace: false where the host did not say. */
|
|
21
|
+
admin: boolean;
|
|
20
22
|
/** Who in the organization is away, or will be, and who stands in; `null` where the host did not say. */
|
|
21
23
|
absences: readonly AppAbsence[] | null;
|
|
22
24
|
commentsEnabled: boolean;
|
package/docs/data_fetching.md
CHANGED
|
@@ -22,7 +22,7 @@ untyped. It is written from the app's live bindings by `lotics app deploy` and
|
|
|
22
22
|
| `useQuery(alias, params?, { page: n })` | one numbered page of `n` rows, `total`, `pageCount`, `setPage` | numbered, jumpable pages |
|
|
23
23
|
| `useQuery(alias, params?, { more: n })` | accumulated `rows` + `loadMore` | infinite scroll / "load more" feeds |
|
|
24
24
|
| `useQuery(alias, params?, { rows: false, total: true })` | `total` only, no rows (`total: { by: column }` or `total: { where: { name: filter } }` adds `counts`) | a facet chip, a queue badge, an "N awaiting approval" tile — the size of a set you are not listing |
|
|
25
|
-
| `useQueries(calls, opts?)` | one state per `{ alias, params?, filter?, sort?, aggregate?, total?, rows? }`, in order — a `sort` orders that call's rows before the cap cuts them | reads that are DATA — a list known only at render, one read per item, or one count per stage (`rows: false, total: true`, each state's `.total`); the deploy's alias scan reads a list as dynamic, so every alias in it is still declared. With `aggregate` a call answers the groups of its filtered rows instead of the rows ([queries](./queries.md)) |
|
|
25
|
+
| `useQueries(calls, opts?)` | one state per `{ alias, params?, filter?, sort?, aggregate?, total?, rows?, fields? }`, in order — a `sort` orders that call's rows before the cap cuts them | reads that are DATA — a list known only at render, one read per item, or one count per stage (`rows: false, total: true`, each state's `.total`); the deploy's alias scan reads a list as dynamic, so every alias in it is still declared. With `aggregate` a call answers the groups of its filtered rows instead of the rows ([queries](./queries.md)) |
|
|
26
26
|
| `queryAll(alias, params?, { filter, sort })` | a promise of every row | outside React, for a job that must hold the whole narrowed set in the browser (the ids an act runs on): it asks page after page until the server says the set ended, never stopping at the 10,000-row cap. The server's rows as stored — no write of this app is drawn over them |
|
|
27
27
|
| `exportQuery(alias, { params, filter, sort, tabs?, report, file, labels? })` | a promise of an `ExportedFile`: `{ filename, mime_type, url, size, created_at }` | every row the narrowed set holds, made into one file by the server — no row reaches the browser. `tabs` (2 to 5, each `{ tab, label, filter?, sort?, totals? }`; `totals` is `{ query, params, via, columns }`, the read of a totals tab beside its rows, joined on the link column `via`, refused where that read lacks `via` or a column or a group links several rows; the groups naming one row, one per kind of row a totals tab adds, are added up) are each read as the export's own rows are — same query and params, under the tab's own filter and sort (absent, the declared order). `report` is `{ title, lines, readings }`; `file` is `{ kind: "workbook", language, sheet, columns }` (the report workbook, its head closing with the moment the server made it, each column `{ key, header, type }` an output column of the query — a `number` one on a number column, a `date` one on a date or datetime; with `tabs`, one sheet per tab named by its `label` in place of `sheet`). `labels`, by `select` output column, the words each option key prints as in the file — a cell no field of the query names (a union's literal column) arrives as its bare key; a cell its field's option names prints as that, a key the map lacks as itself, and a column no select of the query holds as it is. Past 20,000 rows, in any tab, it rejects, never cuts; each caller makes at most 60 exports a minute. The file has no `id` — it is a download, not a workspace file a workflow or a field takes: its `url` is signed for the caller for at most an hour, so download it with `downloadFileFromUrl(url, filename)` (`@lotics/ui/download`) when the promise resolves — a tab `openExternal` opens seconds after the click is a pop-up the browser blocks; the server deletes the file a day after it is made |
|
|
28
28
|
| `exportApp(list, narrowing)` | a promise of an `ExportedFile`, as `exportQuery`'s | the workbook the server makes of a List of a JSON app that states `export: true`, named by its View id (a root List's key; `<page entity>.<key>` for a List on a page; a custom-code app makes its files with `exportQuery`), over the rows as `narrowing` states it (`tab`, `status`, `filters`, `search`, `overdue`, `waiting`, `period`, `window`, `sort`, `group`, `folder`, `row`; a `filters` entry `null` clears the chip the register opens on; `row` is the id of the row a List below a Record page hangs from, required there and refused elsewhere): the server reads the rows, the band's readings and the names under the caller's own access. Download it as `exportQuery`'s |
|
|
@@ -88,7 +88,7 @@ rows (below) — but a count over the whole set is `total`, not a length.
|
|
|
88
88
|
## Options
|
|
89
89
|
|
|
90
90
|
`useQuery` takes these (`QueryOptions`); `useQueries` takes `enabled` and `revalidateOnFocus` for
|
|
91
|
-
all its calls, and each call states its own `filter`, `sort`, `total` and `
|
|
91
|
+
all its calls, and each call states its own `filter`, `sort`, `total`, `rows` and `fields`:
|
|
92
92
|
|
|
93
93
|
| Option | Type | Default | Effect |
|
|
94
94
|
|---|---|---|---|
|
|
@@ -103,6 +103,8 @@ all its calls, and each call states its own `filter`, `sort`, `total` and `rows`
|
|
|
103
103
|
| `more` | `number` | — | A keyset feed read `more` rows at a time: `loadMore`, `hasMore`, `loadingMore`. |
|
|
104
104
|
| `total` | `boolean \| { by: column } \| { where: { name: filter } }` | `true` with `page`, else `false` | The whole set's count, its own request (`total`); with `by`, a count per value of that column, or with `where`, a count per named filter within `filter`, from the same scan (`counts`). |
|
|
105
105
|
| `rows` | `boolean` | `true` | `false` reads no rows — a total alone. |
|
|
106
|
+
| `fields` | `column[]` | every column | The columns each row is read with, beside its addressing columns: a screen drawing three columns of a wide query names those three, and `[]` reads which rows the set holds and nothing of them. A name the query does not answer is refused. Not with `total` alone or `aggregate`. Part of the read's key. |
|
|
107
|
+
| `refresh` | `"changed"` | whole re-read | A realtime push re-reads only the records it changed, where the server states the rows can be answered so: a row keeps its place, a new row lands last. Any other change, a capped read (`limit`, `page`, `more`) or a read the server cut asks the whole read again. Part of the read's key; also a key of a `useQueries` call. |
|
|
106
108
|
|
|
107
109
|
Runtime `sort`/`filter` are **bounded to the named query's output columns**, twice over. At
|
|
108
110
|
compile time, `field_key` on a typed alias is the literal union of the columns the query projects —
|
|
@@ -170,6 +172,7 @@ write it as `{ node_type: "condition", type: "record_id", operator, value }`.
|
|
|
170
172
|
changes only (a schema edit does not push), and a **standalone/public app has no host**, so
|
|
171
173
|
those apps keep focus/reconnect freshness alone. Push is absent whenever the channel cannot
|
|
172
174
|
connect, so never treat it as a replacement for pull.
|
|
175
|
+
A read with `refresh: "changed"` re-reads only the records a push names (rows that share a group with them, for a read the server partitions by a link) instead of the whole read.
|
|
173
176
|
- **A `more` feed does not re-read on arrival** — the one exception. A warm feed re-mounted
|
|
174
177
|
reads nothing, because re-reading it would reshuffle the feed under a reader scrolling it; a cold
|
|
175
178
|
key still reads, and focus / reconnect / a realtime push / this app's own write still refresh.
|
|
@@ -385,8 +388,7 @@ Wire shapes per output column type:
|
|
|
385
388
|
|
|
386
389
|
Row-level (non-grouped) queries additionally carry system columns: `__source_record_id` /
|
|
387
390
|
`__source_table_id` / `__source_locked` (source addressing — pass `__source_record_id` to
|
|
388
|
-
workflows), `__created_at` / `__updated_at` (record timestamps)
|
|
389
|
-
metadata. A grouped query collapses rows and answers each of these as `null`. Details:
|
|
391
|
+
workflows), and `__created_at` / `__updated_at` (record timestamps). A grouped query collapses rows and answers each of these as `null`. Details:
|
|
390
392
|
[./queries.md](./queries.md).
|
|
391
393
|
|
|
392
394
|
A row is typed from the alias's own projection (`AppQueryColumns` in `.lotics/app_queries.d.ts`),
|
|
@@ -264,7 +264,7 @@ failure is logged to the console.
|
|
|
264
264
|
## `useAppContext()` — the host's context, and whether it could be read
|
|
265
265
|
|
|
266
266
|
`useAppContext()` (`dist/viewer.d.ts`) is the one read every hook above is a view of: the
|
|
267
|
-
signed-in member, whether comments are enabled, the workspace's zone, language and currency, and three
|
|
267
|
+
signed-in member and whether they administer the workspace (`admin`), whether comments are enabled, the workspace's zone, language and currency, and three
|
|
268
268
|
states — `resolved` once it answered, `settled` once it answered OR failed, and `failure` —
|
|
269
269
|
`{ message, retry }`, `null` unless the read failed. Where it failed every fact is unknown, so a
|
|
270
270
|
surface that dates or counts by them draws the failure rather than guessing the reader's zone.
|
|
@@ -280,6 +280,10 @@ host did not say (a visitor from outside the organization, an older host). Both
|
|
|
280
280
|
context, read once as the app opens. Display only: the workflow body re-checks who may act
|
|
281
281
|
(`current_member_stands_in_for(...)`).
|
|
282
282
|
|
|
283
|
+
`admin` is `true` where the viewer administers the app's workspace, `false` where the host did not say
|
|
284
|
+
(a visitor, a standalone page, an older host). A display fact, like `groupIds`: show an admin's
|
|
285
|
+
controls by it, and let the server decide every write.
|
|
286
|
+
|
|
283
287
|
## The workspace's zone at the root
|
|
284
288
|
|
|
285
289
|
An app's root draws nothing until `useAppContext()` has `settled` — where it failed, it draws
|
package/docs/queries.md
CHANGED
|
@@ -136,17 +136,17 @@ Delivery-layer enrichment (applied to the response, per request):
|
|
|
136
136
|
|
|
137
137
|
Every row-level query carries auto-injected addressing columns alongside your output columns:
|
|
138
138
|
`__source_record_id`, `__source_table_id`, `__source_locked` (decode with `readLocked`),
|
|
139
|
-
`__created_at
|
|
139
|
+
`__created_at` and `__updated_at`. You never
|
|
140
140
|
declare these; output names starting with `__source_` / `__src_field_`, or equal to
|
|
141
141
|
`__created_at` / `__updated_at`, are **reserved** and rejected. A `group` collapses rows and
|
|
142
142
|
answers its addressing as `null` (grouped results can't be written through or matched by `record_id`); a `join`
|
|
143
143
|
keeps the **left** side's addressing.
|
|
144
144
|
|
|
145
|
-
A
|
|
146
|
-
organization
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
`
|
|
145
|
+
A row holds your output columns and the five addressing columns above, and nothing else; a member
|
|
146
|
+
of the app's organization also reads who may change a locked row (`readLockedBy`). For a caller
|
|
147
|
+
outside the app's organization — a public-app visitor, or a member of another organization —
|
|
148
|
+
`columns` carries each column's `name`, `type` and `nullable` only. Read what a row holds through
|
|
149
|
+
your projection and the `read*` helpers.
|
|
150
150
|
|
|
151
151
|
`__created_at` / `__updated_at` arrive as ISO-8601 **instants** with an offset
|
|
152
152
|
(`"2026-07-05T09:00:00.000Z"`), not a wall-clock — read them with `readCreatedAt(row)` /
|
|
@@ -248,8 +248,8 @@ right-side column nullable. Addressing (write-through, `record_id` filtering) fo
|
|
|
248
248
|
column name *and* type (column j of every source must have the same name and type). Use
|
|
249
249
|
`project` with `{ "literal": null }` fills (typed by the column's declared `type`) to align
|
|
250
250
|
heterogeneous tables. Source addressing survives per column only when every arm agrees on the
|
|
251
|
-
source table/field;
|
|
252
|
-
came from.
|
|
251
|
+
source table/field; a select column whose arms take different fields still answers each row's
|
|
252
|
+
options by name, read from the field that row's cell came from.
|
|
253
253
|
|
|
254
254
|
A select column whose arms project different selects takes every arm's options: a filter value
|
|
255
255
|
matches the arm whose select holds that key, and an option **name** stands for each arm's key
|
package/package.json
CHANGED