@lotics/cli 0.321.59 → 0.321.61

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/docs/design.md CHANGED
@@ -486,7 +486,7 @@ keeps, a child List per child, the Acts at each one's foot. A register's `column
486
486
  default record: every field a person writes. Behaviour belongs in an Act.
487
487
 
488
488
  A Section of more than about six fields reads as Fieldsets of related facts: a patient's record holds "Contact" and
489
- "Insurance" rather than one run of nine, each Fieldset's `label` a few words. A gallery or prose Field stands beside the Fieldsets (`reference/fieldset-node`). Fields stand two
489
+ "Insurance" rather than one run of nine, each Fieldset's `label` a few words. A gallery or prose Field stands beside the Fieldsets (`reference/fieldset-node`). Fields in a part come first, a Fieldset where they need a heading. Only where the arrangement itself is the need does the Fieldset state `Line`s — two weights and their difference on one line — and `heads` where several Lines repeat the same columns, a fee's amount, its payment and its invoice button per row (`reference/line-node`). A figure only that screen shows is a `Value`; one a list, a report or an export reads is a formula field of the table. Fields stand two
490
490
  to a line in the order stated, and files, prose and a link to several rows take the whole line: stated after a lone
491
491
  short field, one leaves the half beside that field empty.
492
492
 
package/docs/workflows.md CHANGED
@@ -211,8 +211,12 @@ A body names a table or document template by its alias (`query_records({ table_i
211
211
  - A record reads in its declared shape wherever it comes from — the trigger, a tool result, a `let`, a
212
212
  callback parameter: a single select as its option alias or null, a member as its id, a link as its ids. A property read
213
213
  by alias (`x.order.quantity`, `xs[0]["quantity"]`, `y.quantity`) also names the record's field when the record is held in an
214
- object, a list or a spread (`{ order: record }`, `[record]`, `{ ...record }`); a helper's field-path text reads the
215
- rows of a records tool and a loop over them only. (The record tools called outside a workflow return the stored arrays instead.)
214
+ object, a list or a spread (`{ order: record }`, `[record]`, `{ ...record }`). A field is named by alias wherever the
215
+ row's table is known: also through `map`, `push`, a conditional or `??`, where a row's data is held on its own
216
+ (`{ item: row.data }`, read `p.item.state`), and where it is destructured (`const { state } = p.item.data`). It is not
217
+ known for rows of two tables, for rows of a call whose `table_id` is not written out, for `linked()` over a link read off
218
+ such a held row (read the link while the row is in hand), and a helper's field-path text reads the rows of a records
219
+ tool and a loop over them only (over rows held in objects, pass a callback). (The record tools called outside a workflow return the stored arrays instead.)
216
220
  - `linked(record["link"])[n]["x"]` fetches the n-th linked row and reads a field of it; bare
217
221
  `linked(record["link"])` is every linked row, one fetch per row. Its argument is a path ending on
218
222
  a link field and carries the guard: `linked(record?.["link"])[0]`.
@@ -238,8 +242,8 @@ prefix `! -`.
238
242
  `const`, `let` and `for (const { id } of rows)`. A tool result destructures directly:
239
243
  `const { records } = await query_records({...});`. `const a = 1, b = 2;` declares both. Nested
240
244
  patterns and rest are refused.
241
- - Spread — `[...a, b]` and `{ ...a, b: 1 }` (later keys win). Refused inside a tool input: bind the
242
- merged value first and pass the binding.
245
+ - Spread — `[...a, b]` and `{ ...a, b: 1 }` (later keys win), in a tool input's values too (`records: [{ a: 1, ...extra }]`);
246
+ at the top of a tool input each input is named, so a spread there is refused.
243
247
  - Shorthand — `{ table_id }` is `{ table_id: table_id }`.
244
248
  - `xs.push(a, b);` appends, also on a key (`o.items.push(v)`); `o.a.b = v;` sets a nested key;
245
249
  `x ??= v`, `x ||= v` and `x &&= v` assign. A `const` may be pushed to or have a key set, as in
@@ -277,7 +281,8 @@ the same block is refused; shadowing in a nested block is allowed. A `let` keeps
277
281
  `instanceof`, `delete`, `void`, rest elements, computed keys, classes, `throw`, `finally`, `import`,
278
282
  `export`, `eval`, labels, and a function as a value (`const f = (x) => ...`: pass the arrow to the helper
279
283
  that takes it). `xs.sort(...)` on a name or path is refused too, since a value is never changed in place:
280
- write `xs.toSorted(...)` or `[...xs].sort(...)`.
284
+ write `xs.toSorted(...)` or `[...xs].sort(...)`. Inside a callback's block a loop, `let`, a reassignment and a
285
+ destructuring pattern are refused: use a helper, or compute the value before the callback.
281
286
 
282
287
  ## Typing
283
288
 
@@ -354,8 +359,24 @@ writing it: `differenceInCalendarDays(a, b) ?? 0`.
354
359
  (`filter(record.items, x => x.Status == "open" && x.Amount > 100)`); `reduce` takes a callback and an
355
360
  initial value. A callback gets `(item, idx)` (`reduce`: `(acc, item, idx)`) and reads `record`,
356
361
  `runtime`, the names in scope, loop items and an enclosing callback's parameters. Its body is one
357
- expression — `(x) => <expr>`, `(x) => { return <expr>; }` or `function (x) { return <expr>; }`;
358
- several statements, `async` and named function expressions are refused.
362
+ expression — `(x) => <expr>` — or a block of `const` declarations, `if`/`else` and `return`, every path
363
+ ending in `return <expr>;` (`(x) => { … }` or `function (x) { … }`):
364
+
365
+ ```js
366
+ const orders = await query_records({ table_id: "orders" });
367
+ const customers = await query_records({ table_id: "customers" });
368
+ const rows = orders.records.map((o) => {
369
+ const c = find(customers.records, (x) => x.id == o.data.customer[0]);
370
+ if (c == null) { return null; }
371
+ return { name: c.data.name, total: o.data.qty * o.data.price };
372
+ });
373
+ return({ status: "success", message: text(rows.length) });
374
+ ```
375
+
376
+ A block's `const` behaves as a top-level `const` does. Inside a block a loop, `let`, a reassignment, a
377
+ destructuring pattern, `switch` and `try` are refused: use a helper (`map`, `filter`, `find`, `reduce`) or
378
+ compute the value before the callback. A declared `function` is one `return <expr>;`, and a table check
379
+ takes no block. `async` and named function expressions are refused.
359
380
 
360
381
  Look a row up by key rather than filtering for it: a `filter` inside a callback walks its whole list again
361
382
  for every item, so a thousand items against a few hundred rows is hundreds of thousands of calls. Group the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lotics/cli",
3
- "version": "0.321.59",
3
+ "version": "0.321.61",
4
4
  "description": "Lotics SDK and CLI for AI agents",
5
5
  "type": "module",
6
6
  "bin": {