@lotics/app-sdk 0.130.3 → 0.131.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +182 -133
- package/dist/overlay.d.ts +1 -1
- package/dist/queries.d.ts +5 -1
- package/dist/router.js +1 -1
- package/dist/row.d.ts +1 -1
- package/dist/shared_types.d.ts +8 -6
- package/docs/ai.md +1 -1
- package/docs/data_fetching.md +6 -5
- package/docs/members_and_options.md +11 -8
- package/docs/mutations.md +3 -3
- package/docs/queries.md +9 -13
- package/docs/recipes.md +2 -2
- package/docs/workflows.md +18 -18
- package/package.json +1 -1
- /package/dist/{chunk-GYTOFOC2.js → chunk-V4APGE4F.js} +0 -0
package/docs/mutations.md
CHANGED
|
@@ -231,7 +231,7 @@ Every declaration takes optional `description` and `required` (default **true**)
|
|
|
231
231
|
| `date` | — | `"YYYY-MM-DD"`, or a TZ-bearing ISO datetime (projected to the workspace day) | `string` |
|
|
232
232
|
| `datetime` | — | `"YYYY-MM-DDTHH:mm"` naive workspace wall-clock (what the platform DatePicker emits), or TZ-bearing ISO | `string` |
|
|
233
233
|
| `email` | — | a valid email | `string` |
|
|
234
|
-
| `select` | exactly one of `options: [{label, value}]` (min 1) **or** `field: "fld_…"`; `multi?` | an option
|
|
234
|
+
| `select` | exactly one of `options: [{label, value}]` (min 1) **or** `field: "fld_…"`; `multi?` | an option alias (array when `multi`; a key is still accepted) | union of the option `value`s (inline) or the field's current option aliases (`field`); `ReadonlyArray<…>` when `multi` |
|
|
235
235
|
| `record_link` | `table_id` (required), `multi?` | a record id — must exist **in the declared table** | `string` / `ReadonlyArray<string>` |
|
|
236
236
|
| `member` | `group?`, `multi?` | a member id — with `group`, must belong to that group | `string` / `ReadonlyArray<string>` |
|
|
237
237
|
| `file` | `multi?` | a file id from an upload — must live in the app's workspace | `string` / `ReadonlyArray<string>` |
|
|
@@ -417,7 +417,7 @@ Why a full-form snapshot save is a bug, not a style choice — three independent
|
|
|
417
417
|
// load: snapshot the editable fields from the row
|
|
418
418
|
const initial = useMemo(() => ({
|
|
419
419
|
title: row.text(r.title),
|
|
420
|
-
status:
|
|
420
|
+
status: row.optAlias(r.status) ?? "",
|
|
421
421
|
}), [r]);
|
|
422
422
|
|
|
423
423
|
// save: send only the diff
|
|
@@ -518,7 +518,7 @@ hands the app its **write model** (`GET /v1/apps/{app_id}/write_model`, read onc
|
|
|
518
518
|
bound workflow's record writes and the steps they depend on, where each query's columns and rows
|
|
519
519
|
come from, and the fields they name. `useWorkflow` walks the workflow's own steps against the rows
|
|
520
520
|
the app has already read, with the evaluator the engine runs, and stages what it will write over
|
|
521
|
-
every read before the request answers — a workflow's select options
|
|
521
|
+
every read before the request answers — a workflow's select options are named by alias, as the app's reads name them:
|
|
522
522
|
|
|
523
523
|
- **Cells.** A written cell redraws in every column that reads it: an option as its label, a member
|
|
524
524
|
as the face a read or `useMembers` drew, a link as its label — and a column reading the linked row beside it
|
package/docs/queries.md
CHANGED
|
@@ -23,7 +23,7 @@ several through `nodes`, each call a new version of the app:
|
|
|
23
23
|
"kind": "from_table",
|
|
24
24
|
"table_id": "tbl_orders",
|
|
25
25
|
"filter": { "node_type": "condition", "field_key": "status",
|
|
26
|
-
"operator": "has_any_of", "value": ["
|
|
26
|
+
"operator": "has_any_of", "value": ["open"] }
|
|
27
27
|
},
|
|
28
28
|
"columns": ["order_code", "customer", "total", "created"]
|
|
29
29
|
}
|
|
@@ -116,7 +116,7 @@ reading a column this query does not project is a `tsc` error.
|
|
|
116
116
|
|
|
117
117
|
**`source_fields_by_table_id` is always `{}`** — the key is part of the shape, the map is not
|
|
118
118
|
filled. **The complete option sets, with colors, are `useFieldOptions`**; a cell's own
|
|
119
|
-
`{ key, label }` comes down on the cell ([members_and_options.md](./members_and_options.md)).
|
|
119
|
+
`{ key, alias, label }` comes down on the cell ([members_and_options.md](./members_and_options.md)).
|
|
120
120
|
|
|
121
121
|
Delivery-layer enrichment (applied to the response, per request):
|
|
122
122
|
|
|
@@ -130,16 +130,12 @@ Delivery-layer enrichment (applied to the response, per request):
|
|
|
130
130
|
`{ id, name, email?, image?, groups? }[]`, the same shape `useMembers` returns. The last three
|
|
131
131
|
are org-internal and share one gate: present only for authenticated members of the app's own org,
|
|
132
132
|
and `image` arrives presigned.
|
|
133
|
-
- **`select` cells** — bare option-key arrays become `{ key, label }[]` (colors ride in
|
|
133
|
+
- **`select` cells** — bare option-key arrays become `{ key, alias, label }[]` (colors ride in
|
|
134
134
|
`useFieldOptions`, not the cell — see [members_and_options.md](./members_and_options.md)).
|
|
135
135
|
**Enrichment needs the column's source addressing**, which a passthrough projection carries, a
|
|
136
136
|
union carries when its arms agree (or per-row, when the compiler emits it), and a **link
|
|
137
|
-
extraction** carries as of the target field it reads.
|
|
138
|
-
|
|
139
|
-
not `select` — so the cell stays bare `opt_*` keys AND `useFieldOptions` omits the column
|
|
140
|
-
entirely, and reading `.label` off it renders the option KEY. Resolve the keys
|
|
141
|
-
(`readSelect(cell).map((o) => o.key)`) against any alias that projects the underlying field
|
|
142
|
-
DIRECTLY.
|
|
137
|
+
extraction** carries as of the target field it reads. A select reached through a **lookup
|
|
138
|
+
field** enriches the same way, its alias read from the select it looks up.
|
|
143
139
|
- **`number` columns** arrive as JS numbers (Postgres `numeric` strings are coerced; a
|
|
144
140
|
decimal with more digits than a double holds rounds to the double). **`date`/`datetime`** columns
|
|
145
141
|
arrive as canonical wall-clock strings (`YYYY-MM-DD` / `YYYY-MM-DDTHH:mm`).
|
|
@@ -416,7 +412,7 @@ on a link column costs a linked-record read per row. An `unpivot` reads its sour
|
|
|
416
412
|
|
|
417
413
|
An extracted column **is** addressed to the field it reads on the target table, so the delivery
|
|
418
414
|
layer treats it like any other field-backed column: an extracted `select` enriches to
|
|
419
|
-
`{key,label}` and appears in `useFieldOptions`, and an extracted date resolves relative-date
|
|
415
|
+
`{key,alias,label}` and appears in `useFieldOptions`, and an extracted date resolves relative-date
|
|
420
416
|
filters in the source field's timezone. It is still never **writable** — a read through a link is
|
|
421
417
|
not a write path, and `writable_target` rejects it. `link_agg` has the same parent and `source` rules,
|
|
422
418
|
carries no field addressing (an aggregate of many cells is no one field's value), and its `operation`
|
|
@@ -481,10 +477,10 @@ derived surfaces share one implementation.
|
|
|
481
477
|
| Field type | Column type | Source-layer operators | Derived-layer differences | Sort / group / aggregate notes |
|
|
482
478
|
| --- | --- | --- | --- | --- |
|
|
483
479
|
| text | `text` | `equals`, `not_equals`, `contains`, `does_not_contain`, `starts_with`, `ends_with`, `is_empty`, `is_not_empty`, `is_any_of`, `is_none_of`, `contains_any_of` | same set | Sort is lexicographic in the database's default collation — no locale control — over the trimmed, case-folded text, a column the query derives included; the value read stays as written. Text comparisons normalize both sides (trim + case-insensitive). The LIKE family (`contains`, `does_not_contain`, `starts_with`, `ends_with`, and `contains_any_of`, whose value is a list and which holds when ANY listed word is in the cell) keeps **accents** (`contains "cá"` matches `"Cá hồi"`, not `"Cà chua"`) unless the condition states `"ignore_accents": true`, which folds them, so `contains "ha noi"` matches `"Hà Nội"`; the identity operators (`equals`, `not_equals`, `is_any_of`, `is_none_of`) do **not** — they compare a stored value, and `mã` is not `ma`. |
|
|
484
|
-
| number | `number` | `equals`, `not_equals`, `greater_than`, `less_than`, `greater_than_or_equal_to`, `less_than_or_equal_to`, `is_empty`, `is_not_empty` | same set — except a figure read in each row's own unit or currency (a `notation` whose currency or unit is `per_row`, or a rollup totalling in its row's), which a comparison matches only at the source layer: a condition on a column passing it straight through moves there, anywhere else it is refused | Full numeric aggregate set (§8). A comparison on a figure read per row states `unit_option`, the key of the option of that select its value is in — `{ "field_key": "amount", "operator": "greater_than", "value": 100, "unit_option": "
|
|
480
|
+
| number | `number` | `equals`, `not_equals`, `greater_than`, `less_than`, `greater_than_or_equal_to`, `less_than_or_equal_to`, `is_empty`, `is_not_empty` | same set — except a figure read in each row's own unit or currency (a `notation` whose currency or unit is `per_row`, or a rollup totalling in its row's), which a comparison matches only at the source layer: a condition on a column passing it straight through moves there, anywhere else it is refused | Full numeric aggregate set (§8). A comparison on a figure read per row states `unit_option`, the alias (or key) of the option of that select its value is in — `{ "field_key": "amount", "operator": "greater_than", "value": 100, "unit_option": "usd" }` — and matches only rows holding that option; rows in a measured unit of the same dimension compare converted (`≥ 1` in `t` matches `1500` in `kg`), a counted unit or a currency never. One stating none is refused. |
|
|
485
481
|
| date / datetime | `date` / `datetime` (datetime when the field's format includes time) | `on`, `before`, `after`, `on_or_before`, `on_or_after`, `between`, `time_of_day`, `is_empty`, `is_not_empty` — values are `DateTimePoint`s (below) | same set | Day-level filters on datetime values expand to the full-day window; a `date` column compares on the day alone, so a time in the filter value is ignored. A reduced-precision value (`"2026-05"`) is its period start, and a value with no time is at `00:00` for `time_of_day`. Sortable; bucketable in `group.by` (§8); `earliest`/`latest`/`min`/`max`/`date_range` aggregate. |
|
|
486
482
|
| boolean | `boolean` | `equals` (value `true`/`false`; `false` matches NULL/missing) | same | `checked`/`unchecked`/`percent_*` aggregate (`unchecked` counts false **or** empty). |
|
|
487
|
-
| select (single & multi) | `select` | `has_any_of`, `has_none_of`, `has_all_of`, `is_empty`, `is_not_empty` — values are **option
|
|
483
|
+
| select (single & multi) | `select` | `has_any_of`, `has_none_of`, `has_all_of`, `is_empty`, `is_not_empty` — values are **option aliases** (`open`) or keys (`opt_*`), never labels; a count per value is keyed by alias | the **runtime** `filter` (§9) also takes option **names**, resolving each to its key — an unknown one is refused rather than matching nothing, and the value stays an array either way; a select column the query DERIVES instead of projecting from a field or a select literal carries no option set, so addressing one there is refused | Cells are arrays even for single-selects. Sorting a select column orders by its options' order (a multi-select by its first option), an empty cell last, on every page, keyset included; through a `union` whose arms project different selects, each row by its own select's order (§2 `union`); a select the query derives carries no options and orders by raw JSON. `unnest` fans option keys. |
|
|
488
484
|
| select_member | `select_member` | select ops + `is_current_member`, `is_not_current_member` (field-scoped, no value; `is_not_current_member` matches every cell not holding the requester, an empty one included) | same — `is_current_member` **works at the runtime layer** too | Sorting orders by the first member's name as a reader is shown it (the one the organization gave, else their profile's; a member it does not name reads as empty text), folded like text, then by member id; an empty cell last, on every page, keyset included. `unnest` fans member ids. Anonymous public request: current-member binds the app owner (§1). |
|
|
489
485
|
| select_record_link | `select_record_link` | membership by linked-record **id**: `has_any_of`, `has_none_of`, `has_all_of`; text over the cached **display** (deprecated — filter by id, and a linked record's field through a lookup): `contains`, `not_contains`, `starts_with`, `ends_with`; `is_empty`, `is_not_empty` | same — id-membership works at the runtime layer (converged `[{id}]` containment) | Sorting orders by the first linked record's display, folded like text, then by its id; an empty cell last, on every page, keyset included. `unnest` fans link ids (+ display). |
|
|
490
486
|
| files | `files` | `has_filename`, `has_mime_type` (substring), `has_file_count` (exact count), `is_empty`, `is_not_empty` | same | Presign-enriched at delivery (§1); `unnest` fans file ids. Only presence-counting aggregates. |
|
|
@@ -532,7 +528,7 @@ tree shape — `TableRecordFilters`:
|
|
|
532
528
|
|
|
533
529
|
```jsonc
|
|
534
530
|
// condition — one predicate
|
|
535
|
-
{ "node_type": "condition", "field_key": "status", "operator": "has_any_of", "value": ["
|
|
531
|
+
{ "node_type": "condition", "field_key": "status", "operator": "has_any_of", "value": ["open"] }
|
|
536
532
|
// group — AND/OR of children (conditions, traversals, nested groups)
|
|
537
533
|
{ "node_type": "group", "logic": "and", "children": [ … ] }
|
|
538
534
|
// traversal — a predicate on a record reachable through link hops
|
package/docs/recipes.md
CHANGED
|
@@ -112,8 +112,8 @@ Full pattern, including the date-param trick for range filters: [queries](./quer
|
|
|
112
112
|
A query cell is `unknown` with a per-type serialized shape, and the readers own it: `row.opt` /
|
|
113
113
|
`row.text` / `row.num` / `row.bool` / `row.date` / `row.datetime`, `readSelect`, `readMembers`,
|
|
114
114
|
`row.link` / `readLinks` ([data fetching](./data_fetching.md#the-readers)). A hand-rolled `firstOpt` /
|
|
115
|
-
`linkDisplay` re-implements that contract: a select cell is `[{key,label}]`, so a reader that grabs
|
|
116
|
-
the wrong half is *plausible and wrong* rather than broken.
|
|
115
|
+
`linkDisplay` re-implements that contract: a select cell is `[{key,alias,label}]`, so a reader that grabs
|
|
116
|
+
the wrong half is *plausible and wrong* rather than broken. Compare and key an option by its `alias` (`row.optAlias`, `counts`, a workflow's outputs): a `key` differs on a cloned table and a `label` changes on a rename.
|
|
117
117
|
|
|
118
118
|
## Set the icon and colour
|
|
119
119
|
|
package/docs/workflows.md
CHANGED
|
@@ -19,14 +19,14 @@ engine, no `eval`, no sandbox. Four consequences shape everything below:
|
|
|
19
19
|
- **One canonical form per concept.** Several JS spellings are accepted and *lowered* to one
|
|
20
20
|
stored form. The stored tree renders back to source when it is read (`get_workflow`), so a
|
|
21
21
|
read body shows the canonical spelling, not the sugar you typed (see *Round-tripping* below).
|
|
22
|
-
- **Opaque keys, never display names.** Fields are `fld_*`, select options are
|
|
22
|
+
- **Opaque keys, never display names.** Fields are `fld_*`, select options are named by their alias, tables
|
|
23
23
|
are `tbl_*`, groups are `grp_*`. A display name is rejected at save with an error pointing at
|
|
24
24
|
the right key. The generated types carry the human-readable name in a JSDoc comment; the
|
|
25
25
|
*value* is always the key.
|
|
26
26
|
|
|
27
27
|
```js
|
|
28
|
-
// A field read by its opaque key, compared against one of that field's option
|
|
29
|
-
if (order.data["fld_status"] == "
|
|
28
|
+
// A field read by its opaque key, compared against one of that field's option aliases:
|
|
29
|
+
if (order.data["fld_status"] == "open") { … }
|
|
30
30
|
```
|
|
31
31
|
|
|
32
32
|
## Where a body lives
|
|
@@ -88,11 +88,11 @@ because it is grammar rather than a helper — the path continues through it.
|
|
|
88
88
|
|
|
89
89
|
**A record reads in its declared shape, however it reached you.** Every row a records tool
|
|
90
90
|
returns, the trigger record and its diff, and every row `linked(...)` fetches arrive shaped as the
|
|
91
|
-
generated types declare them: a single select as its option
|
|
91
|
+
generated types declare them: a single select as its option alias or `null`, one member as its id
|
|
92
92
|
or `null`, a link as its ids. So a row read through a `let`, a ternary, a callback parameter, a
|
|
93
93
|
helper result, a table id held in a variable, or a value that waited through a pause reads the
|
|
94
94
|
same as one read straight off the call. (A record *tool* run from the CLI or chat serves what is
|
|
95
|
-
stored — a single select as `["opt_x"]
|
|
95
|
+
stored — a single select as `["opt_x"]`, a key — so take a field's shape from the generated types, never
|
|
96
96
|
from a transcript.)
|
|
97
97
|
|
|
98
98
|
**A link field reads as an array of ids, in every spelling.** `order.data["fld_link"]` is
|
|
@@ -512,7 +512,7 @@ Everything else does not — a lambda anywhere else is rejected.
|
|
|
512
512
|
- A body may read the reserved roots, the names in scope, enclosing `for-of` items, and an
|
|
513
513
|
enclosing lambda's parameters. A parameter spelled like an outer name shadows it inside the body.
|
|
514
514
|
- A callback's item reads in its declared shape (see *Path access*), so a callback over rows
|
|
515
|
-
reads `r.data["fld_status"]` as the option
|
|
515
|
+
reads `r.data["fld_status"]` as the option alias whatever the rows came from.
|
|
516
516
|
- `reduce` is callback-only and its **initial value is required** (it is what gives the
|
|
517
517
|
accumulator a type).
|
|
518
518
|
- Most of these also accept a **path-string** form instead of a callback, resolved with `get`
|
|
@@ -615,8 +615,8 @@ Value shapes, which the generated types enforce exactly:
|
|
|
615
615
|
|
|
616
616
|
| Field | Read | Write |
|
|
617
617
|
|---|---|---|
|
|
618
|
-
| single `select` | one
|
|
619
|
-
| multi `select` | array of
|
|
618
|
+
| single `select` | one option alias, or `null` | the alias: `fld_status: "open"` (a key is still accepted) |
|
|
619
|
+
| multi `select` | array of option aliases | array: `fld_tags: ["urgent"]` |
|
|
620
620
|
| single `select_member` | one member id, or `null` | the id |
|
|
621
621
|
| multi `select_member` | array of member ids | array |
|
|
622
622
|
| `select_record_link` | array of ids — `linked(...)` fetches the rows | array of ids: `fld_customer: [customer.id]`, or a link read fed straight back |
|
|
@@ -685,12 +685,12 @@ The catch is where you build that array, and it is not obvious. **Write the lite
|
|
|
685
685
|
call**, so it is typed by the `records` parameter:
|
|
686
686
|
|
|
687
687
|
```js
|
|
688
|
-
// ONE trip. The array literal is contextually typed by `records`, so "
|
|
688
|
+
// ONE trip. The array literal is contextually typed by `records`, so "vao_bai"
|
|
689
689
|
// stays the literal the table's write type wants.
|
|
690
690
|
await create_records({
|
|
691
691
|
records: concat(
|
|
692
|
-
coRaVao ? [{ fld_khoan: "
|
|
693
|
-
coVeSinh ? [{ fld_khoan: "
|
|
692
|
+
coRaVao ? [{ fld_khoan: "vao_bai", fld_tien: giaRaVao, fld_chuyen: [i.chuyen_id] }] : [],
|
|
693
|
+
coVeSinh ? [{ fld_khoan: "ve_sinh", fld_tien: giaVeSinh, fld_chuyen: [i.chuyen_id] }] : [],
|
|
694
694
|
),
|
|
695
695
|
table_id: "tbl_…",
|
|
696
696
|
});
|
|
@@ -702,14 +702,14 @@ from the fix:
|
|
|
702
702
|
```js
|
|
703
703
|
let rows = [];
|
|
704
704
|
for (const g of gia.records) {
|
|
705
|
-
rows = concat(rows, [{ fld_khoan: "
|
|
705
|
+
rows = concat(rows, [{ fld_khoan: "vao_bai", … }]); // widens to `string`
|
|
706
706
|
}
|
|
707
707
|
await create_records({ records: rows, … });
|
|
708
708
|
// TS2322: Type '{ fld_khoan: string; … }[]' is not assignable to 'readonly …RecordWrite[]'.
|
|
709
|
-
// Type 'string' is not assignable to '"
|
|
709
|
+
// Type 'string' is not assignable to '"vao_bai" | "ve_sinh" | … | null'.
|
|
710
710
|
```
|
|
711
711
|
|
|
712
|
-
`concat` widens a select's option
|
|
712
|
+
`concat` widens a select's option alias to `string` the moment it leaves the literal, and an
|
|
713
713
|
annotation is not in the subset. Let the call site supply the type: keep the loop for FINDING
|
|
714
714
|
values and put the writing after it.
|
|
715
715
|
|
|
@@ -761,17 +761,17 @@ The rules that are easy to get wrong because the failing code looks correct.
|
|
|
761
761
|
iteration 0 and silently skip every remaining iteration and its mutations. Move the wait out,
|
|
762
762
|
or split the loop into separately triggered runs.
|
|
763
763
|
- **String contexts coerce to display text.** A read inside a template or a string-typed argument
|
|
764
|
-
renders the *label*; everywhere else it is the raw
|
|
764
|
+
renders the *label*; everywhere else it is the raw alias. So
|
|
765
765
|
`` `Status: ${record["fld_status"]}` `` prints "Done" while
|
|
766
|
-
`record["fld_status"] == "
|
|
766
|
+
`record["fld_status"] == "done"` compares aliases — both correct, and neither substitutes for
|
|
767
767
|
the other. It holds on every route a record arrives by — a `let`, a callback parameter, a row
|
|
768
768
|
from a variable `table_id`.
|
|
769
769
|
- **Multi-select `==` quietly desugars.** On a multi-select field,
|
|
770
|
-
`record["fld_tags"] == "
|
|
770
|
+
`record["fld_tags"] == "urgent"` rewrites to `includes(…)` at save. Either spelling is
|
|
771
771
|
fine — but a `switch` on a multi-select discriminant is **rejected**, because its value is an
|
|
772
772
|
array and no string `case` could ever match. Use `if (includes(…))` branches. `switch` cases
|
|
773
773
|
must be string literals, each in its own `{ }` block; there is no fallthrough, and a case on a
|
|
774
|
-
single-select discriminant is option-
|
|
774
|
+
single-select discriminant is option-validated.
|
|
775
775
|
- **`let` survives a wait, so its values must survive JSON.** The binding stack is snapshotted at
|
|
776
776
|
the pause and hydrated on resume — no Dates, functions, or Maps in a `let` initializer.
|
|
777
777
|
- **An empty accumulator can't infer its element type.** `let xs = []` then
|
package/package.json
CHANGED
|
File without changes
|