@lotics/app-sdk 0.128.0 → 0.128.1

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.
Files changed (2) hide show
  1. package/dist/index.js +18 -6
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -802,6 +802,9 @@ function setKey(key, answer) {
802
802
  // src/written.ts
803
803
  import { useSyncExternalStore as useSyncExternalStore2 } from "react";
804
804
 
805
+ // ../shared/src/result_hops.ts
806
+ var RESULT_HOPS = 8;
807
+
805
808
  // ../shared/src/expression_limits.ts
806
809
  var MAX_RESULT_LENGTH = 1e5;
807
810
  var MAX_STRING_LENGTH = 1e7;
@@ -9411,15 +9414,24 @@ function optionAliases(value, field) {
9411
9414
  return resolve(value);
9412
9415
  }
9413
9416
  function coerceOptionAliases(value, of, ctx) {
9414
- const held2 = heldTable(of.table_id, ctx);
9415
- return held2 instanceof Promise ? held2.then((table) => aliasesOf(value, of, table, ctx)) : aliasesOf(value, of, held2, ctx);
9417
+ const options = optionsBehind(of, heldTable(of.table_id, ctx), ctx, 0);
9418
+ return options instanceof Promise ? options.then((held2) => aliasesOf(value, of, held2, ctx)) : aliasesOf(value, of, options, ctx);
9416
9419
  }
9417
- function aliasesOf(value, of, table, ctx) {
9418
- if (table === null) {
9420
+ function optionsBehind(of, held2, ctx, hops) {
9421
+ if (held2 instanceof Promise) return held2.then((table) => optionsBehind(of, table, ctx, hops));
9422
+ if (held2 === null) {
9419
9423
  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 } });
9420
9424
  }
9421
- const field = findField(table, of.field_key);
9422
- const options = field?.type === "select" ? field.options : field?.type === "formula" ? field.formula.options : void 0;
9425
+ const field = findField(held2, of.field_key);
9426
+ if (field?.type === "select") return field.options;
9427
+ if (field?.type === "formula") return field.formula.options;
9428
+ if (field?.type !== "lookup" || field.lookup_field_type !== "select" || hops >= RESULT_HOPS) return void 0;
9429
+ const through = findField(held2, field.source_field_key);
9430
+ if (through?.type !== "select_record_link") return void 0;
9431
+ const next = { table_id: through.table_id, field_key: field.lookup_field_key };
9432
+ return optionsBehind(next, heldTable(next.table_id, ctx), ctx, hops + 1);
9433
+ }
9434
+ function aliasesOf(value, of, options, ctx) {
9423
9435
  if (options === void 0) {
9424
9436
  throw new WorkflowEvalError(`Reading "${of.field_key}" of table ${of.table_id} as its alias reads a field that holds no options.`, { kind: "no_options", extra: { table_id: of.table_id, field_key: of.field_key } });
9425
9437
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lotics/app-sdk",
3
- "version": "0.128.0",
3
+ "version": "0.128.1",
4
4
  "description": "The SDK a Lotics custom-code app reads and writes through — typed hooks over the host bridge, cell readers, mount() and AppRouter",
5
5
  "type": "module",
6
6
  "exports": {