@lotics/app-sdk 0.133.19 → 0.133.21
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 +7 -1
- package/docs/workflows.md +32 -23
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -8790,7 +8790,7 @@ var CALLBACK_HELPERS = /* @__PURE__ */ new Set([
|
|
|
8790
8790
|
"intersectionBy",
|
|
8791
8791
|
"reduce"
|
|
8792
8792
|
]);
|
|
8793
|
-
var LAMBDA_POSITION_HINT = `
|
|
8793
|
+
var LAMBDA_POSITION_HINT = `A function is not a value here. A callback is written inline as an argument to ${[...CALLBACK_HELPERS].sort().join(" / ")}, e.g. pluck(rows, (r) => r.qty * r.price); a named function is declared at the top level, as \`function toLine(l = {}) { \u2026 }\` or \`const toLine = (l = {}) => \u2026\`, and inlined at each call; \`(() => <expr>)()\` computes in place.`;
|
|
8794
8794
|
var HELPER_ALIASES = /* @__PURE__ */ new Map([
|
|
8795
8795
|
["String", "toString"],
|
|
8796
8796
|
["Number", "toNumber"],
|
|
@@ -8889,6 +8889,12 @@ var LINKED_OPTIONAL_RESULT = `${LINKED_CALL}(...) always returns an array, never
|
|
|
8889
8889
|
var LINKED_METHOD_FORM = `${LINKED_CALL} has no method form \u2014 write ${LINKED_CALL}(record["fld_link"])[0], with the link read as the argument.`;
|
|
8890
8890
|
var LINKED_ON_NON_RECORD = `${LINKED_CALL}(...) follows a link field on a record, and this value is not one. Read the record first, then follow the link: ${LINKED_CALL}(record["fld_link"])[0].`;
|
|
8891
8891
|
var LINKED_ON_CHANGES = `A change diff is not a record, so ${LINKED_CALL}(...) cannot follow a link off it. Read the post-state with ${LINKED_CALL}(record["fld_link"]) or the pre-state with ${LINKED_CALL}(prev_record["fld_link"]).`;
|
|
8892
|
+
var MAX_EXPRESSION_DEPTH = 500;
|
|
8893
|
+
var MAX_BLOCK_NODES = 2e4;
|
|
8894
|
+
var TOO_LARGE = `A block of more than ${MAX_BLOCK_NODES} nodes once its branches and the values it reads are spelled out`;
|
|
8895
|
+
var TOO_DEEP = `A block nested more than ${MAX_EXPRESSION_DEPTH} levels deep once its branches and the values it reads are spelled out`;
|
|
8896
|
+
var BIND_ONCE = "Bind it once in a `const` at the top level of the workflow and pass it in.";
|
|
8897
|
+
var PATTERN_OF_NON_DETERMINISTIC = `A pattern that binds several names reads its value once per name, and this value differs each time it is computed (a random draw, the clock). ${BIND_ONCE}`;
|
|
8892
8898
|
|
|
8893
8899
|
// ../shared/src/resolve_record_anchor.ts
|
|
8894
8900
|
var checkLookupStepId = (name) => `table_check_lookup_${name}`;
|
package/docs/workflows.md
CHANGED
|
@@ -401,7 +401,9 @@ into a `let` first. Arrays and objects stay immutable underneath; each form rebu
|
|
|
401
401
|
and reassigns the name.
|
|
402
402
|
|
|
403
403
|
**Spread works inside a tool input's values** (`records: [{ a: 1, ...extra }]`, `records: [...rows, one]`).
|
|
404
|
-
At the top of a tool input each input is named, so
|
|
404
|
+
At the top of a tool input each input is named, so a spread there reads a `const` bound to an object written in the
|
|
405
|
+
body (`const common = { table_id: "tbl_orders" }; await update_records({ ...common, set: { … } });`); any other
|
|
406
|
+
`{ ...opts }` there is refused: write `table_id: opts.table_id`.
|
|
405
407
|
Computed property keys (`{ [k]: v }`) are rejected everywhere for the same reason; to write a
|
|
406
408
|
field chosen at runtime, use `field_edits` (below).
|
|
407
409
|
|
|
@@ -418,9 +420,10 @@ Object and array patterns work on `const`, `let`, and `for-of`, with rename, str
|
|
|
418
420
|
array holes (`const [head, , third] = records;`), and defaults. A default lowers to `coalesce`,
|
|
419
421
|
so it fires on **null** as well as undefined. The right-hand side must be **read-shaped** — a
|
|
420
422
|
root, a step output, or a binding; compute first, then destructure (`const [a] = [1, 2];` is
|
|
421
|
-
rejected). Nested patterns and rest (`...rest`) are not supported.
|
|
423
|
+
rejected). Nested patterns and rest (`...rest`) are not supported. A `const` inside a block
|
|
424
|
+
destructures the same way, off any value.
|
|
422
425
|
|
|
423
|
-
### Top-level
|
|
426
|
+
### Top-level functions
|
|
424
427
|
|
|
425
428
|
```js
|
|
426
429
|
const q = await query_records({ table_id: "tbl_lines", filters: { … } });
|
|
@@ -430,24 +433,30 @@ function lineTotal(l = {}) { return l.data["fld_qty"] * l.data["fld_price"]; }
|
|
|
430
433
|
const subtotal = sumBy(q.records, (l) => lineTotal(l));
|
|
431
434
|
```
|
|
432
435
|
|
|
433
|
-
A
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
436
|
+
A helper, **top level only**, inlined at every call site. `const lineTotal = (l = {}) => …;` declares
|
|
437
|
+
the same thing.
|
|
438
|
+
|
|
439
|
+
- **A parameter takes its type from a default or an annotation** (`l = {}`, `qty: number`); a bare
|
|
440
|
+
parameter is rejected at parse.
|
|
441
|
+
- The body is an expression, or a block of `const` declarations, `if`/`else` and `return`, every path
|
|
442
|
+
ending in `return <expr>;`. It sees only its own parameters, helpers, and the reserved roots — never
|
|
443
|
+
the caller's bindings, and never `index` (it is loop-local, so an inlined body would mean something
|
|
444
|
+
different at each call site).
|
|
445
|
+
- **A parameter and a block's `const` are written out where they are read.** A value read on no path
|
|
446
|
+
is not computed, a `const` nothing reads is rejected, and a value from `now()` or a random helper is
|
|
447
|
+
read once: bind it in a `const` before the call to read it more.
|
|
448
|
+
- A call may precede a `function` declaration (declarations are collected first); a `const` function
|
|
449
|
+
is declared above the statement that first calls it. Recursion, the method form (`x.fn()`), a bare
|
|
450
|
+
reference (`const g = fn`), a name that shadows a helper/tool/reserved root, and a declaration that
|
|
451
|
+
is **never called** are all rejected.
|
|
443
452
|
- An omitted argument uses the default; a provided one wins outright (presence is syntactic —
|
|
444
453
|
unlike a destructuring default, there is no null guard here).
|
|
445
|
-
- **A parameter you read a property off must be handed a record or a binding**, not a computed
|
|
446
|
-
value: `lineTotal({ qty: 1, price: 2 })` is rejected because inlining would splice a path onto
|
|
447
|
-
an object literal. Bind it first (`const l = { … };` then `lineTotal(l)`), or pass a row.
|
|
448
454
|
|
|
449
|
-
|
|
450
|
-
|
|
455
|
+
`(() => { … })()`, an arrow called where it is written with no parameters, takes the same block and is
|
|
456
|
+
inlined in place; it reads the names in scope there.
|
|
457
|
+
|
|
458
|
+
**A declared function does not survive a read.** Inlining erases it: `get_workflow` returns
|
|
459
|
+
the body repeated at each call site and no function at all. Reach for one when the *saved* logic
|
|
451
460
|
is what matters, and expect to re-extract it if you edit the source read back.
|
|
452
461
|
|
|
453
462
|
### Round-tripping
|
|
@@ -505,15 +514,15 @@ expected, so read that message rather than guessing.
|
|
|
505
514
|
|
|
506
515
|
`filter`, `find`, `some`, `every`, `pluck`, `sortBy`, `sumBy`, `meanBy`, `minBy`, `maxBy`,
|
|
507
516
|
`groupBy`, `countBy`, `uniqueBy`, `differenceBy`, `intersectionBy`, and `reduce` take a callback.
|
|
508
|
-
Everything else does not — a lambda anywhere else is rejected
|
|
517
|
+
Everything else does not — a lambda anywhere else is rejected, but for a top-level function and an
|
|
518
|
+
arrow called where it is written (Top-level functions, above).
|
|
509
519
|
|
|
510
520
|
- Both spellings lower to the same node: `(x) => <expr>`, `(x) => { return <expr>; }`, and
|
|
511
521
|
`function (x) { return <expr>; }`. A body may also be a block of `const` declarations, `if`/`else`
|
|
512
522
|
and `return`, every path ending in `return <expr>;`; a block's `const` behaves as a top-level `const`
|
|
513
|
-
does. Inside one, a loop, `let`, a reassignment,
|
|
514
|
-
use a helper (`map`, `filter`, `find`, `reduce`) or compute the value before the callback. A
|
|
515
|
-
|
|
516
|
-
named function expression are rejected.
|
|
523
|
+
does. Inside one, a loop, `let`, a reassignment, `switch` and `try` are rejected:
|
|
524
|
+
use a helper (`map`, `filter`, `find`, `reduce`) or compute the value before the callback. A table
|
|
525
|
+
check takes no block. `async`, a generator, and a named function expression are rejected.
|
|
517
526
|
- Parameters are plain identifiers, positional per item — `(item, idx) => …`; `reduce` gets
|
|
518
527
|
`(acc, item, idx)`. No destructuring or defaults in a lambda parameter list.
|
|
519
528
|
- A body may read the reserved roots, the names in scope, enclosing `for-of` items, and an
|
package/package.json
CHANGED