@lotics/app-sdk 0.133.17 → 0.133.18
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 +41 -8
- package/docs/workflows.md +8 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -8979,12 +8979,25 @@ function resolveLambdaItemFrame(frames, name) {
|
|
|
8979
8979
|
}
|
|
8980
8980
|
return void 0;
|
|
8981
8981
|
}
|
|
8982
|
-
function lambdaItemAnchor(ctx, name) {
|
|
8983
|
-
|
|
8982
|
+
function lambdaItemAnchor(ctx, name, path, seen) {
|
|
8983
|
+
const frame2 = resolveLambdaItemFrame(ctx.lambda_items, name);
|
|
8984
|
+
if (frame2?.bound === void 0) return frame2?.anchor ?? null;
|
|
8985
|
+
return boundValueAnchor(frame2.bound.expr, path, { ...ctx, lambda_items: frame2.bound.lambda_items }, seen);
|
|
8984
8986
|
}
|
|
8985
8987
|
function readRecordAnchor(source, path, ctx) {
|
|
8986
|
-
|
|
8987
|
-
return
|
|
8988
|
+
const traced = source.from === "lambda_param" ? lambdaItemAnchor(ctx, source.name, path, /* @__PURE__ */ new Set()) : anchorForRead(source, path, ctx, /* @__PURE__ */ new Set());
|
|
8989
|
+
return traced ?? statedAnchor(path, ctx);
|
|
8990
|
+
}
|
|
8991
|
+
function statedAnchor(path, ctx) {
|
|
8992
|
+
for (let i = 0; i < path.length; i++) {
|
|
8993
|
+
const segment = path[i];
|
|
8994
|
+
if (segment.at !== "field" || segment.table === void 0) continue;
|
|
8995
|
+
const previous = path[i - 1];
|
|
8996
|
+
if (previous?.at === "key" && previous.key === "display") continue;
|
|
8997
|
+
const table = ctx.tables.get(segment.table);
|
|
8998
|
+
if (table !== void 0) return { table, envelopeLen: i, hops: 0 };
|
|
8999
|
+
}
|
|
9000
|
+
return null;
|
|
8988
9001
|
}
|
|
8989
9002
|
function anchorForRead(source, path, ctx, seen) {
|
|
8990
9003
|
switch (source.from) {
|
|
@@ -8993,7 +9006,7 @@ function anchorForRead(source, path, ctx, seen) {
|
|
|
8993
9006
|
case "foreach_item":
|
|
8994
9007
|
return resolveNamedForeachFrame(ctx.foreach_items, source.name)?.anchor ?? null;
|
|
8995
9008
|
case "lambda_param":
|
|
8996
|
-
return lambdaItemAnchor(ctx, source.name);
|
|
9009
|
+
return lambdaItemAnchor(ctx, source.name, path, seen);
|
|
8997
9010
|
case "trigger_record":
|
|
8998
9011
|
return rootAnchor(ctx.trigger_record);
|
|
8999
9012
|
case "trigger_record_prev":
|
|
@@ -9049,7 +9062,7 @@ function boundValueAnchor(expression, path, ctx, seen) {
|
|
|
9049
9062
|
}
|
|
9050
9063
|
const bound = linkedSequenceAnchor(expression, ctx, new Set(seen));
|
|
9051
9064
|
if (bound) {
|
|
9052
|
-
return { table: bound.table, envelopeLen: bound.isFanOut ? 1 :
|
|
9065
|
+
return { table: bound.table, envelopeLen: bound.isFanOut ? 1 : bound.envelopeLen, hops: bound.hops };
|
|
9053
9066
|
}
|
|
9054
9067
|
if (expression.kind !== "read" || expression.source.from !== "step_output") return null;
|
|
9055
9068
|
const combined = [...expression.path, ...path];
|
|
@@ -9150,7 +9163,8 @@ function linkedSequenceAnchor(expr2, ctx, seen) {
|
|
|
9150
9163
|
let currentTable = root.table;
|
|
9151
9164
|
let fanOut = false;
|
|
9152
9165
|
let hops = root.hops;
|
|
9153
|
-
|
|
9166
|
+
const hopped = read2.path.slice(root.envelopeLen);
|
|
9167
|
+
for (const segment of hopped) {
|
|
9154
9168
|
if (segment.at !== "linked") return null;
|
|
9155
9169
|
const field = ctx.field_named?.(currentTable, segment.via) ?? currentTable.fields.find((f) => f.key === segment.via);
|
|
9156
9170
|
if (!field || field.type !== "select_record_link") return null;
|
|
@@ -9160,7 +9174,7 @@ function linkedSequenceAnchor(expr2, ctx, seen) {
|
|
|
9160
9174
|
fanOut = segment.index === "each";
|
|
9161
9175
|
hops++;
|
|
9162
9176
|
}
|
|
9163
|
-
return { table: currentTable, isFanOut: fanOut, hops };
|
|
9177
|
+
return { table: currentTable, isFanOut: fanOut, hops, envelopeLen: hopped.length > 0 ? 0 : Math.max(root.envelopeLen - read2.path.length, 0) };
|
|
9164
9178
|
}
|
|
9165
9179
|
function unwrapOptionalGuards(expr2) {
|
|
9166
9180
|
let current = expr2;
|
|
@@ -9462,6 +9476,10 @@ function evaluateExpression(expr2, ctx) {
|
|
|
9462
9476
|
return evaluateTemplate(expr2.parts, ctx);
|
|
9463
9477
|
case "lambda":
|
|
9464
9478
|
return evaluateLambda(expr2.params, expr2.body, ctx, []);
|
|
9479
|
+
case "let": {
|
|
9480
|
+
const value = evaluateExpression(expr2.value, ctx);
|
|
9481
|
+
return value instanceof Promise ? value.then((bound) => evaluateLetBody(expr2, bound, ctx)) : evaluateLetBody(expr2, value, ctx);
|
|
9482
|
+
}
|
|
9465
9483
|
case "array_literal":
|
|
9466
9484
|
return evaluateArrayLiteral(expr2.elements, ctx);
|
|
9467
9485
|
case "object_literal":
|
|
@@ -9559,6 +9577,21 @@ function evaluateLambda(params, body, ctx, items) {
|
|
|
9559
9577
|
};
|
|
9560
9578
|
return Object.assign(call, { workers: ctx.evaluation_budget.workers });
|
|
9561
9579
|
}
|
|
9580
|
+
function evaluateLetBody(expr2, bound, ctx) {
|
|
9581
|
+
const frame2 = /* @__PURE__ */ Object.create(null);
|
|
9582
|
+
frame2[expr2.name] = bound;
|
|
9583
|
+
const outer = ctx.lambda_items ?? [];
|
|
9584
|
+
const lambdaItems = [
|
|
9585
|
+
...outer,
|
|
9586
|
+
{ name: expr2.name, anchor: null, bound: { expr: expr2.value, lambda_items: outer } }
|
|
9587
|
+
];
|
|
9588
|
+
return evaluateExpression(expr2.body, {
|
|
9589
|
+
...ctx,
|
|
9590
|
+
lambda_params: [...ctx.lambda_params ?? [], frame2],
|
|
9591
|
+
lambda_items: lambdaItems,
|
|
9592
|
+
anchor_context: { ...ctx.anchor_context, lambda_items: lambdaItems }
|
|
9593
|
+
});
|
|
9594
|
+
}
|
|
9562
9595
|
function evalAnchorContext(ctx) {
|
|
9563
9596
|
return {
|
|
9564
9597
|
tables: ctx.tables.current,
|
package/docs/workflows.md
CHANGED
|
@@ -400,8 +400,8 @@ written keys (`o[k] = v` with a computed `k` is refused), and a loop item is rea
|
|
|
400
400
|
into a `let` first. Arrays and objects stay immutable underneath; each form rebuilds the value
|
|
401
401
|
and reassigns the name.
|
|
402
402
|
|
|
403
|
-
**Spread
|
|
404
|
-
|
|
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 `{ ...opts }` there is refused: write `table_id: opts.table_id`.
|
|
405
405
|
Computed property keys (`{ [k]: v }`) are rejected everywhere for the same reason; to write a
|
|
406
406
|
field chosen at runtime, use `field_edits` (below).
|
|
407
407
|
|
|
@@ -508,8 +508,12 @@ expected, so read that message rather than guessing.
|
|
|
508
508
|
Everything else does not — a lambda anywhere else is rejected.
|
|
509
509
|
|
|
510
510
|
- Both spellings lower to the same node: `(x) => <expr>`, `(x) => { return <expr>; }`, and
|
|
511
|
-
`function (x) { return <expr>; }`. A
|
|
512
|
-
|
|
511
|
+
`function (x) { return <expr>; }`. A body may also be a block of `const` declarations, `if`/`else`
|
|
512
|
+
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, a destructuring pattern, `switch` and `try` are rejected:
|
|
514
|
+
use a helper (`map`, `filter`, `find`, `reduce`) or compute the value before the callback. A declared
|
|
515
|
+
`function` is one `return <expr>;`, and a table check takes no block. `async`, a generator, and a
|
|
516
|
+
named function expression are rejected.
|
|
513
517
|
- Parameters are plain identifiers, positional per item — `(item, idx) => …`; `reduce` gets
|
|
514
518
|
`(acc, item, idx)`. No destructuring or defaults in a lambda parameter list.
|
|
515
519
|
- A body may read the reserved roots, the names in scope, enclosing `for-of` items, and an
|
package/package.json
CHANGED