@lotics/app-sdk 0.128.5 → 0.128.7
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/{chunk-ZMNW4WF6.js → chunk-GYTOFOC2.js} +3 -1
- package/dist/index.js +42 -23
- package/dist/router.js +1 -1
- package/package.json +1 -1
|
@@ -281,11 +281,13 @@ var MEMBER_ID_PATTERN = new RegExp(`^[${ID_ALPHABET}]{${ID_LENGTH},}$`);
|
|
|
281
281
|
var CPU_PROFILE_ID_PATTERN = new RegExp(`^cpf_[${ID_ALPHABET}]{${ID_LENGTH}}$`);
|
|
282
282
|
|
|
283
283
|
// ../shared/src/table_field_keys.ts
|
|
284
|
-
var
|
|
284
|
+
var KEY_LENGTH = 6;
|
|
285
|
+
var nanoid2 = customAlphabet(ID_ALPHABET, KEY_LENGTH);
|
|
285
286
|
var FIELD_KEY_PREFIX = "fld_";
|
|
286
287
|
function isFieldKey(value) {
|
|
287
288
|
return value.startsWith(FIELD_KEY_PREFIX);
|
|
288
289
|
}
|
|
290
|
+
var GENERATED_OPTION_KEY_PATTERN = new RegExp(`^opt_[${ID_ALPHABET}]{${KEY_LENGTH}}$`);
|
|
289
291
|
|
|
290
292
|
// ../shared/src/schemas/read_row.ts
|
|
291
293
|
var RECORD_ID_COLUMN = "__source_record_id";
|
package/dist/index.js
CHANGED
|
@@ -51,7 +51,7 @@ import {
|
|
|
51
51
|
subtractDecimal,
|
|
52
52
|
sumDecimal,
|
|
53
53
|
urlParam
|
|
54
|
-
} from "./chunk-
|
|
54
|
+
} from "./chunk-GYTOFOC2.js";
|
|
55
55
|
|
|
56
56
|
// src/mount.tsx
|
|
57
57
|
import { createRoot } from "react-dom/client";
|
|
@@ -921,8 +921,12 @@ function ownText(value) {
|
|
|
921
921
|
if (typeof value === "string") return value;
|
|
922
922
|
if (value instanceof Date) return Date.prototype.toString.call(value);
|
|
923
923
|
if (typeof value === "object" && value !== null) return Object.prototype.toString.call(value);
|
|
924
|
+
if (typeof value === "number") return numberText(value);
|
|
924
925
|
return String(value);
|
|
925
926
|
}
|
|
927
|
+
function numberText(value) {
|
|
928
|
+
return Number.isInteger(value) ? String(value) : String(Number(value.toPrecision(15)));
|
|
929
|
+
}
|
|
926
930
|
function walkJoined(array, write2) {
|
|
927
931
|
const joining = /* @__PURE__ */ new Set([array]);
|
|
928
932
|
const stack = [{ array, at: 0 }];
|
|
@@ -2663,6 +2667,7 @@ function sortText(value) {
|
|
|
2663
2667
|
if (typeof value === "string") return value;
|
|
2664
2668
|
if (Array.isArray(value)) return textOf(value);
|
|
2665
2669
|
if (typeof value === "object") return Object.prototype.toString.call(value);
|
|
2670
|
+
if (typeof value === "number") return numberText(value);
|
|
2666
2671
|
return String(value);
|
|
2667
2672
|
}
|
|
2668
2673
|
function compareSortText(a, b) {
|
|
@@ -3113,7 +3118,7 @@ function join(arr, separator = ",") {
|
|
|
3113
3118
|
if (typeof separator !== "string") {
|
|
3114
3119
|
throw new ExpressionArgumentError("join: separator must be a string");
|
|
3115
3120
|
}
|
|
3116
|
-
const parts = arr.map(String);
|
|
3121
|
+
const parts = arr.map((element) => typeof element === "number" ? numberText(element) : String(element));
|
|
3117
3122
|
const separatorsLength = Math.max(0, parts.length - 1) * separator.length;
|
|
3118
3123
|
assertStringLength("join", parts.reduce((total, part) => total + part.length, separatorsLength));
|
|
3119
3124
|
return parts.join(separator);
|
|
@@ -7276,7 +7281,8 @@ function figure2(name, args) {
|
|
|
7276
7281
|
function parsedText(name, value) {
|
|
7277
7282
|
if (value == null) return null;
|
|
7278
7283
|
if (typeof value === "string") return value;
|
|
7279
|
-
if (typeof value === "number"
|
|
7284
|
+
if (typeof value === "number") return numberText(value);
|
|
7285
|
+
if (typeof value === "boolean") return String(value);
|
|
7280
7286
|
if (Array.isArray(value)) return textOf(value);
|
|
7281
7287
|
throw new ExpressionArgumentError(`${name}: expected text or a number, got an object`);
|
|
7282
7288
|
}
|
|
@@ -7313,7 +7319,7 @@ function objectFromEntries(...args) {
|
|
|
7313
7319
|
for (const pair of pairs) {
|
|
7314
7320
|
if (!Array.isArray(pair)) throw new ExpressionArgumentError("Object.fromEntries: every entry must be a [key, value] pair");
|
|
7315
7321
|
const key = pair[0];
|
|
7316
|
-
const text2 = typeof key === "string" ? key : Array.isArray(key) ? textOf(key) : String(key);
|
|
7322
|
+
const text2 = typeof key === "string" ? key : Array.isArray(key) ? textOf(key) : typeof key === "number" ? numberText(key) : String(key);
|
|
7317
7323
|
if (isReservedObjectKey(text2)) throw new ExpressionArgumentError(`Object.fromEntries: a key cannot be "${text2}"`);
|
|
7318
7324
|
defineOwn(result, text2, pair[1] ?? null);
|
|
7319
7325
|
}
|
|
@@ -9421,20 +9427,23 @@ function resolveForeachFrame(ctx, name, at2) {
|
|
|
9421
9427
|
}
|
|
9422
9428
|
function evaluateRead(source, path, coerce, ctx) {
|
|
9423
9429
|
const root = source.from === "value" ? evaluateExpression(source.expr, ctx) : resolveReadRoot(source, ctx);
|
|
9424
|
-
return root instanceof Promise ? readAfter(root, source, path, coerce, ctx) : walkPath(path, coerce, ctx, readRecordAnchor(source, path, ctx.anchor_context), 0, root, null, void 0, void 0);
|
|
9430
|
+
return root instanceof Promise ? readAfter(root, source, path, coerce, ctx) : walkPath(path, coerce, ctx, readRecordAnchor(source, path, ctx.anchor_context), 0, root, null, void 0, void 0, NO_OWNERS);
|
|
9425
9431
|
}
|
|
9426
9432
|
async function readAfter(root, source, path, coerce, ctx) {
|
|
9427
9433
|
const value = await root;
|
|
9428
|
-
return walkPath(path, coerce, ctx, readRecordAnchor(source, path, ctx.anchor_context), 0, value, null, void 0, void 0);
|
|
9434
|
+
return walkPath(path, coerce, ctx, readRecordAnchor(source, path, ctx.anchor_context), 0, value, null, void 0, void 0, NO_OWNERS);
|
|
9429
9435
|
}
|
|
9430
9436
|
function knownTables(tables) {
|
|
9431
9437
|
return { current: tables, hold: (tableId) => tables.get(tableId) ?? null };
|
|
9432
9438
|
}
|
|
9433
|
-
|
|
9439
|
+
var NO_OWNERS = { prev: null, terminal: null };
|
|
9440
|
+
function walkPath(path, coerce, ctx, anchor, from, start, startTable, startField, startTerminal, startOwners, startCarried) {
|
|
9434
9441
|
let current = start;
|
|
9435
9442
|
let table = startTable;
|
|
9436
9443
|
let prevField = startField;
|
|
9437
9444
|
let terminalField = startTerminal;
|
|
9445
|
+
let prevOwner = startOwners.prev;
|
|
9446
|
+
let terminalOwner = startOwners.terminal;
|
|
9438
9447
|
for (let i = from; i < path.length; i++) {
|
|
9439
9448
|
const segment = path[i];
|
|
9440
9449
|
const isLast = i === path.length - 1;
|
|
@@ -9443,23 +9452,25 @@ function walkPath(path, coerce, ctx, anchor, from, start, startTable, startField
|
|
|
9443
9452
|
const carried = asked === void 0 ? carriedTable(current, ctx) : asked;
|
|
9444
9453
|
if (carried instanceof Promise) {
|
|
9445
9454
|
return carried.then(
|
|
9446
|
-
(settled) => walkPath(path, coerce, ctx, anchor, i, current, table, prevField, terminalField, settled)
|
|
9455
|
+
(settled) => walkPath(path, coerce, ctx, anchor, i, current, table, prevField, terminalField, { prev: prevOwner, terminal: terminalOwner }, settled)
|
|
9447
9456
|
);
|
|
9448
9457
|
}
|
|
9449
9458
|
if (carried?.at === "self") table = carried.table;
|
|
9450
9459
|
const field = (segment.at === "field" || segment.at === "key") && table ? findField(table, segment.key) : void 0;
|
|
9451
9460
|
if (isLast) {
|
|
9452
9461
|
terminalField = field ?? (segment.at === "key" && (segment.key === "next_value" || segment.key === "prev_value") ? prevField : void 0);
|
|
9462
|
+
terminalOwner = field === void 0 ? prevOwner : table;
|
|
9453
9463
|
}
|
|
9454
9464
|
const walked = walkSegment(current, segment, ctx);
|
|
9455
9465
|
if (walked instanceof Promise) {
|
|
9456
|
-
return walkPending({ path, coerce, ctx, anchor, table, carried, field, terminal_field: terminalField }, i, walked);
|
|
9466
|
+
return walkPending({ path, coerce, ctx, anchor, table, carried, field, terminal_field: terminalField, owners: { prev: prevOwner, terminal: terminalOwner } }, i, walked);
|
|
9457
9467
|
}
|
|
9458
9468
|
if (walked === void 0 || walked === null) return walked;
|
|
9459
9469
|
const next = tableAfter(segment, table, carried, ctx);
|
|
9460
9470
|
if (next instanceof Promise) {
|
|
9461
|
-
return next.then((advanced) => walkPath(path, coerce, ctx, anchor, i + 1, walked, advanced, field, terminalField));
|
|
9471
|
+
return next.then((advanced) => walkPath(path, coerce, ctx, anchor, i + 1, walked, advanced, field, terminalField, { prev: table, terminal: terminalOwner }));
|
|
9462
9472
|
}
|
|
9473
|
+
prevOwner = table;
|
|
9463
9474
|
table = next;
|
|
9464
9475
|
prevField = field;
|
|
9465
9476
|
current = walked;
|
|
@@ -9468,7 +9479,7 @@ function walkPath(path, coerce, ctx, anchor, from, start, startTable, startField
|
|
|
9468
9479
|
current = unwrapScalarField(current);
|
|
9469
9480
|
}
|
|
9470
9481
|
if (coerce.mode === "display" && terminalField) {
|
|
9471
|
-
return coerceFieldDisplay(current, terminalField, ctx);
|
|
9482
|
+
return coerceFieldDisplay(current, terminalField, terminalOwner, ctx);
|
|
9472
9483
|
}
|
|
9473
9484
|
if (coerce.mode === "alias") return coerceOptionAliases(current, coerce.of, ctx);
|
|
9474
9485
|
return current;
|
|
@@ -9490,9 +9501,10 @@ function coerceOptionAliases(value, of, ctx) {
|
|
|
9490
9501
|
const options = optionsBehind(of, heldTable(of.table_id, ctx), ctx, 0);
|
|
9491
9502
|
return options instanceof Promise ? options.then((held2) => aliasesOf(value, of, held2, ctx)) : aliasesOf(value, of, options, ctx);
|
|
9492
9503
|
}
|
|
9493
|
-
function optionsBehind(of, held2, ctx, hops) {
|
|
9494
|
-
if (held2 instanceof Promise) return held2.then((table) => optionsBehind(of, table, ctx, hops));
|
|
9504
|
+
function optionsBehind(of, held2, ctx, hops, unheld = "refuse") {
|
|
9505
|
+
if (held2 instanceof Promise) return held2.then((table) => optionsBehind(of, table, ctx, hops, unheld));
|
|
9495
9506
|
if (held2 === null) {
|
|
9507
|
+
if (unheld === "unknown") return void 0;
|
|
9496
9508
|
throw new WorkflowEvalError(`Reading "${of.field_key}" as its alias reads table ${of.table_id}, which this run does not hold.`, { kind: "unknown_table", extra: { table_id: of.table_id } });
|
|
9497
9509
|
}
|
|
9498
9510
|
const field = findField(held2, of.field_key);
|
|
@@ -9502,7 +9514,7 @@ function optionsBehind(of, held2, ctx, hops) {
|
|
|
9502
9514
|
const through = findField(held2, field.source_field_key);
|
|
9503
9515
|
if (through?.type !== "select_record_link") return void 0;
|
|
9504
9516
|
const next = { table_id: through.table_id, field_key: field.lookup_field_key };
|
|
9505
|
-
return optionsBehind(next, heldTable(next.table_id, ctx), ctx, hops + 1);
|
|
9517
|
+
return optionsBehind(next, heldTable(next.table_id, ctx), ctx, hops + 1, unheld);
|
|
9506
9518
|
}
|
|
9507
9519
|
function aliasesOf(value, of, options, ctx) {
|
|
9508
9520
|
if (options === void 0) {
|
|
@@ -9515,11 +9527,11 @@ function aliasesOf(value, of, options, ctx) {
|
|
|
9515
9527
|
return aliased;
|
|
9516
9528
|
}
|
|
9517
9529
|
async function walkPending(read2, at2, walked) {
|
|
9518
|
-
const { path, coerce, ctx, anchor, carried, field, terminal_field: terminalField } = read2;
|
|
9530
|
+
const { path, coerce, ctx, anchor, carried, field, terminal_field: terminalField, owners } = read2;
|
|
9519
9531
|
const current = await walked;
|
|
9520
9532
|
if (current === void 0 || current === null) return current;
|
|
9521
9533
|
const table = await tableAfter(path[at2], read2.table, carried, ctx);
|
|
9522
|
-
return walkPath(path, coerce, ctx, anchor, at2 + 1, current, table, field, terminalField);
|
|
9534
|
+
return walkPath(path, coerce, ctx, anchor, at2 + 1, current, table, field, terminalField, { prev: read2.table, terminal: owners.terminal });
|
|
9523
9535
|
}
|
|
9524
9536
|
function tableAfter(segment, table, carried, ctx) {
|
|
9525
9537
|
return carried?.at === "data" && isKeyNamed(segment, "data") ? carried.table : advanceTable(segment, table, ctx);
|
|
@@ -9550,7 +9562,7 @@ function isPlainObject(value) {
|
|
|
9550
9562
|
function isKeyNamed(segment, key) {
|
|
9551
9563
|
return (segment.at === "key" || segment.at === "field") && segment.key === key;
|
|
9552
9564
|
}
|
|
9553
|
-
async function coerceFieldDisplay(value, field, ctx) {
|
|
9565
|
+
async function coerceFieldDisplay(value, field, owner, ctx) {
|
|
9554
9566
|
if (value === null || value === void 0) return value;
|
|
9555
9567
|
switch (field.type) {
|
|
9556
9568
|
case "select":
|
|
@@ -9563,13 +9575,19 @@ async function coerceFieldDisplay(value, field, ctx) {
|
|
|
9563
9575
|
case "select_member":
|
|
9564
9576
|
return coerceMemberDisplay(value, ctx);
|
|
9565
9577
|
case "lookup":
|
|
9566
|
-
|
|
9578
|
+
if (field.lookup_field_type !== "select") return value;
|
|
9579
|
+
const behind = owner === null ? void 0 : await optionsBehind({ table_id: owner.id, field_key: field.key }, owner, ctx, 0, "unknown");
|
|
9580
|
+
const options = behind ?? field.lookup_field_options;
|
|
9581
|
+
return options ? coerceOptionKeysDeep(value, options, ctx) : value;
|
|
9567
9582
|
default:
|
|
9568
9583
|
return value;
|
|
9569
9584
|
}
|
|
9570
9585
|
}
|
|
9586
|
+
function optionNames(options) {
|
|
9587
|
+
return new Map(options.flatMap((o) => o.alias === void 0 ? [[o.key, o.name]] : [[o.key, o.name], [o.alias, o.name]]));
|
|
9588
|
+
}
|
|
9571
9589
|
function coerceSelectDisplay(value, options, ctx) {
|
|
9572
|
-
const optionMap =
|
|
9590
|
+
const optionMap = optionNames(options);
|
|
9573
9591
|
const resolve = (key) => {
|
|
9574
9592
|
if (typeof key !== "string") return "";
|
|
9575
9593
|
return optionMap.get(key) ?? key;
|
|
@@ -9582,7 +9600,7 @@ function coerceSelectDisplay(value, options, ctx) {
|
|
|
9582
9600
|
}
|
|
9583
9601
|
function coerceOptionKeysDeep(value, options, ctx) {
|
|
9584
9602
|
assertCheap(ctx.evaluation_budget, value);
|
|
9585
|
-
const optionMap =
|
|
9603
|
+
const optionMap = optionNames(options);
|
|
9586
9604
|
const resolve = (v) => {
|
|
9587
9605
|
if (Array.isArray(v)) {
|
|
9588
9606
|
const resolved = v.map(resolve);
|
|
@@ -9684,7 +9702,7 @@ function resolveObjectKeyExpression(expr2, ctx) {
|
|
|
9684
9702
|
}
|
|
9685
9703
|
function objectKey(value) {
|
|
9686
9704
|
if (typeof value === "string") return value;
|
|
9687
|
-
if (typeof value === "number" && Number.isFinite(value)) return
|
|
9705
|
+
if (typeof value === "number" && Number.isFinite(value)) return numberText(value);
|
|
9688
9706
|
throw new WorkflowEvalError(
|
|
9689
9707
|
`Computed object key must evaluate to a string, got ${describeValue(value)}`,
|
|
9690
9708
|
{ kind: "read", at: "index" }
|
|
@@ -10458,6 +10476,7 @@ async function predictWorkflowEffects(input) {
|
|
|
10458
10476
|
step_outputs: {},
|
|
10459
10477
|
runtime: clientRuntime(input),
|
|
10460
10478
|
helpers,
|
|
10479
|
+
body_spelling: "key",
|
|
10461
10480
|
record_cache: cache,
|
|
10462
10481
|
fetch_record: fetchRecord,
|
|
10463
10482
|
tables: knownTables(input.tables),
|
|
@@ -13436,14 +13455,14 @@ function referencedFieldKeys(expression, fields) {
|
|
|
13436
13455
|
}
|
|
13437
13456
|
|
|
13438
13457
|
// ../shared/src/formula.ts
|
|
13439
|
-
function
|
|
13458
|
+
function optionNames2(options) {
|
|
13440
13459
|
return Object.fromEntries(options.map((option) => [option.key, option.name]));
|
|
13441
13460
|
}
|
|
13442
13461
|
function optionNamesOf(fields) {
|
|
13443
13462
|
return Object.fromEntries(
|
|
13444
13463
|
fields.flatMap((field) => {
|
|
13445
13464
|
const options = effectiveSelectOptions(field);
|
|
13446
|
-
return options === null ? [] : [[field.key,
|
|
13465
|
+
return options === null ? [] : [[field.key, optionNames2(options)]];
|
|
13447
13466
|
})
|
|
13448
13467
|
);
|
|
13449
13468
|
}
|
package/dist/router.js
CHANGED
package/package.json
CHANGED