@elementumai/edk 0.9.17 → 0.9.19

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 (130) hide show
  1. package/README.md +8 -3
  2. package/dist-sdk/src/catalog/factories.d.ts +11 -0
  3. package/dist-sdk/src/catalog/factories.js +6 -0
  4. package/dist-sdk/src/catalog/index.d.ts +2 -2
  5. package/dist-sdk/src/catalog/index.js +2 -2
  6. package/dist-sdk/src/catalog/org.d.ts +39 -1
  7. package/dist-sdk/src/catalog/org.js +460 -50
  8. package/dist-sdk/src/catalog/types.d.ts +12 -2
  9. package/dist-sdk/src/catalog/types.js +2 -0
  10. package/dist-sdk/src/engine/pull/ref-only.js +54 -20
  11. package/dist-sdk/src/engine/pull/result-output.d.ts +2 -0
  12. package/dist-sdk/src/engine/pull/result-output.js +1 -1
  13. package/dist-sdk/src/engine/tf/expr.js +38 -13
  14. package/dist-sdk/src/engine/tf/index.d.ts +2 -2
  15. package/dist-sdk/src/engine/tf/index.js +2 -2
  16. package/dist-sdk/src/engine/tf/labels.d.ts +2 -0
  17. package/dist-sdk/src/engine/tf/labels.js +4 -0
  18. package/dist-sdk/src/engine/tf/parse.d.ts +19 -0
  19. package/dist-sdk/src/engine/tf/parse.js +105 -6
  20. package/dist-sdk/src/engine/workspace/loader.js +49 -12
  21. package/dist-sdk/src/entities/access-policy/from-tf.d.ts +11 -1
  22. package/dist-sdk/src/entities/access-policy/from-tf.js +6 -1
  23. package/dist-sdk/src/entities/access-policy/to-tf.d.ts +11 -0
  24. package/dist-sdk/src/entities/access-policy/to-tf.js +11 -4
  25. package/dist-sdk/src/entities/agent-tool/to-tf.js +2 -1
  26. package/dist-sdk/src/entities/app/build.d.ts +10 -0
  27. package/dist-sdk/src/entities/app/build.js +0 -13
  28. package/dist-sdk/src/entities/app/deserializer/normalize.d.ts +6 -1
  29. package/dist-sdk/src/entities/app/from-tf.js +4 -3
  30. package/dist-sdk/src/entities/app/index.d.ts +2 -0
  31. package/dist-sdk/src/entities/app/index.js +1 -0
  32. package/dist-sdk/src/entities/app/module.js +13 -0
  33. package/dist-sdk/src/entities/app/to-tf.js +2 -0
  34. package/dist-sdk/src/entities/automation/build.d.ts +2 -1
  35. package/dist-sdk/src/entities/automation/build.js +27 -0
  36. package/dist-sdk/src/entities/automation/deserializer/print-automation.js +6 -0
  37. package/dist-sdk/src/entities/automation/from-tf.js +156 -26
  38. package/dist-sdk/src/entities/automation/index.d.ts +1 -1
  39. package/dist-sdk/src/entities/automation/module.d.ts +2 -0
  40. package/dist-sdk/src/entities/automation/module.js +56 -0
  41. package/dist-sdk/src/entities/automation/output-field-types.d.ts +5 -4
  42. package/dist-sdk/src/entities/automation/output-field-types.js +23 -5
  43. package/dist-sdk/src/entities/automation/system-ref-name.d.ts +16 -0
  44. package/dist-sdk/src/entities/automation/system-ref-name.js +44 -0
  45. package/dist-sdk/src/entities/automation/task-output-labels.d.ts +15 -0
  46. package/dist-sdk/src/entities/automation/task-output-labels.js +38 -0
  47. package/dist-sdk/src/entities/automation/tasks.d.ts +37 -5
  48. package/dist-sdk/src/entities/automation/tasks.js +23 -1
  49. package/dist-sdk/src/entities/automation/to-tf.js +158 -84
  50. package/dist-sdk/src/entities/automation/types.js +1 -0
  51. package/dist-sdk/src/entities/chart/from-tf.js +33 -17
  52. package/dist-sdk/src/entities/chart/module.js +3 -1
  53. package/dist-sdk/src/entities/chart/printer.d.ts +1 -0
  54. package/dist-sdk/src/entities/chart/printer.js +26 -16
  55. package/dist-sdk/src/entities/chart/rebind-owner.d.ts +3 -0
  56. package/dist-sdk/src/entities/chart/rebind-owner.js +42 -0
  57. package/dist-sdk/src/entities/chart/to-tf.js +12 -10
  58. package/dist-sdk/src/entities/dashboard/build.d.ts +4 -0
  59. package/dist-sdk/src/entities/dashboard/from-tf.js +15 -4
  60. package/dist-sdk/src/entities/dashboard/to-tf.d.ts +2 -0
  61. package/dist-sdk/src/entities/dashboard/to-tf.js +13 -0
  62. package/dist-sdk/src/entities/dashboard-widget/module.js +4 -0
  63. package/dist-sdk/src/entities/dynamic-layout/build.d.ts +51 -2
  64. package/dist-sdk/src/entities/dynamic-layout/dialect.d.ts +3 -0
  65. package/dist-sdk/src/entities/dynamic-layout/dialect.js +5 -0
  66. package/dist-sdk/src/entities/dynamic-layout/from-tf.d.ts +9 -6
  67. package/dist-sdk/src/entities/dynamic-layout/from-tf.js +188 -26
  68. package/dist-sdk/src/entities/dynamic-layout/module.js +4 -1
  69. package/dist-sdk/src/entities/dynamic-layout/to-tf.d.ts +5 -1
  70. package/dist-sdk/src/entities/dynamic-layout/to-tf.js +254 -23
  71. package/dist-sdk/src/entities/element/build.d.ts +8 -0
  72. package/dist-sdk/src/entities/element/build.js +1 -0
  73. package/dist-sdk/src/entities/element/from-tf.d.ts +1 -0
  74. package/dist-sdk/src/entities/element/from-tf.js +6 -2
  75. package/dist-sdk/src/entities/element/index.d.ts +1 -0
  76. package/dist-sdk/src/entities/element/index.js +1 -0
  77. package/dist-sdk/src/entities/element/module.js +2 -0
  78. package/dist-sdk/src/entities/element/to-tf.js +12 -0
  79. package/dist-sdk/src/entities/field/from-tf.d.ts +2 -0
  80. package/dist-sdk/src/entities/field/from-tf.js +11 -0
  81. package/dist-sdk/src/entities/field/to-tf.js +13 -9
  82. package/dist-sdk/src/entities/relationship/from-tf.d.ts +8 -1
  83. package/dist-sdk/src/entities/relationship/from-tf.js +53 -10
  84. package/dist-sdk/src/entities/relationship/to-tf.d.ts +8 -0
  85. package/dist-sdk/src/entities/relationship/to-tf.js +19 -10
  86. package/dist-sdk/src/entities/shared/filters/ast.d.ts +7 -2
  87. package/dist-sdk/src/entities/shared/filters/index.d.ts +23 -2
  88. package/dist-sdk/src/entities/shared/filters/index.js +24 -1
  89. package/dist-sdk/src/entities/shared/filters/print.js +22 -4
  90. package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +23 -3
  91. package/dist-sdk/src/entities/shared/filters/tf-codec.js +60 -18
  92. package/dist-sdk/src/entities/shared/filters/types.d.ts +13 -4
  93. package/dist-sdk/src/entities/shared/foreign-ref.d.ts +16 -0
  94. package/dist-sdk/src/entities/shared/foreign-ref.js +17 -1
  95. package/dist-sdk/src/entities/shared/tool-field-ref.js +6 -9
  96. package/dist-sdk/src/entities/skill/access-policy.d.ts +17 -0
  97. package/dist-sdk/src/entities/skill/access-policy.js +101 -0
  98. package/dist-sdk/src/entities/skill/build.d.ts +3 -0
  99. package/dist-sdk/src/entities/skill/build.js +3 -0
  100. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.d.ts +4 -1
  101. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +21 -0
  102. package/dist-sdk/src/entities/skill/from-tf.d.ts +2 -0
  103. package/dist-sdk/src/entities/skill/from-tf.js +4 -9
  104. package/dist-sdk/src/entities/skill/index.d.ts +2 -0
  105. package/dist-sdk/src/entities/skill/index.js +1 -0
  106. package/dist-sdk/src/entities/skill/module.js +1 -0
  107. package/dist-sdk/src/entities/skill/to-tf.d.ts +2 -2
  108. package/dist-sdk/src/entities/skill/to-tf.js +5 -2
  109. package/dist-sdk/src/entities/skill-tool/to-tf.js +2 -1
  110. package/dist-sdk/src/entities/table/to-tf.js +3 -3
  111. package/dist-sdk/src/entities/view/agent-view-layout-from-tf.d.ts +49 -0
  112. package/dist-sdk/src/entities/view/agent-view-layout-from-tf.js +224 -0
  113. package/dist-sdk/src/entities/view/agent-view-layout-to-tf.d.ts +36 -0
  114. package/dist-sdk/src/entities/view/agent-view-layout-to-tf.js +288 -0
  115. package/dist-sdk/src/entities/view/agent-view-layout.d.ts +121 -0
  116. package/dist-sdk/src/entities/view/agent-view-layout.js +21 -0
  117. package/dist-sdk/src/entities/view/from-tf.d.ts +3 -1
  118. package/dist-sdk/src/entities/view/from-tf.js +42 -7
  119. package/dist-sdk/src/entities/view/ragnarok.d.ts +7 -0
  120. package/dist-sdk/src/entities/view/ragnarok.js +1 -0
  121. package/dist-sdk/src/entities/view/to-tf.d.ts +10 -1
  122. package/dist-sdk/src/entities/view/to-tf.js +30 -1
  123. package/dist-sdk/src/entities/view/types.js +2 -0
  124. package/dist-sdk/src/entities/widget/to-tf.js +2 -2
  125. package/dist-sdk/src/generated/ragnarok/ragnarok-spec.d.ts +815 -0
  126. package/dist-sdk/src/generated/ragnarok/ragnarok-spec.js +5 -0
  127. package/dist-sdk/src/graph/index.d.ts +43 -0
  128. package/dist-sdk/src/graph/index.js +9 -0
  129. package/dist-sdk/src/graph/types.d.ts +78 -0
  130. package/package.json +11 -1
@@ -6,7 +6,7 @@ import { workspaceAspectKey } from "../../engine/build/context.js";
6
6
  import { SEARCH_TABLE_RESOURCE_TYPES } from "../search-table/types.js";
7
7
  import { fieldRefToTfValue } from "../field/to-tf.js";
8
8
  import { SERVICE_ACCOUNT_RESOURCE_TYPE } from "../service-account/module.js";
9
- import { resolveForeignRef } from "../shared/foreign-ref.js";
9
+ import { foreignFieldDataLabel, resolveForeignRef } from "../shared/foreign-ref.js";
10
10
  import { filterToTf as serializeFilterToTf } from "../shared/filters/tf-codec.js";
11
11
  import { referenceValueTypeForField } from "../shared/filters/index.js";
12
12
  import { API_TASK_REF_AUTHORING_NAMES, API_TASK_REF_WIRE_NAMES } from "./output-key-wire-name.js";
@@ -16,7 +16,9 @@ import { FILE_READER_SUB_TYPE_BY_RESOURCE, FILE_READER_SUB_TYPE_BY_TYPE_KEY } fr
16
16
  import { UNRESOLVED_FIELD_MARKER } from "../shared/ref.js";
17
17
  import { TABLE_RESOURCE_TYPE } from "../table/module.js";
18
18
  import { AUTOMATION_RESOURCE_TYPE, WORKFLOW_PUBLISH_RESOURCE_TYPE } from "./types.js";
19
+ import { TASK_OUTPUT_REFERENCE_NAMES, USER_SEARCH_REF_WIRE_NAMES } from "./task-output-labels.js";
19
20
  import { onDemandTriggerRefKey } from "./value-ref-tf.js";
21
+ import { PROVIDER_FIXED_SYSTEM_FIELD_KEYS, recordFieldWireRefName } from "./system-ref-name.js";
20
22
  import { taskTfLabel } from "./task-label.js";
21
23
  import { isOnDemandRecordType } from "../shared/types/field-types.js";
22
24
  function scopedLabel(appTfLabel, label) {
@@ -103,6 +105,7 @@ const TASK_RESOURCES = {
103
105
  aiTransform: "elementum_ai_transform_task",
104
106
  saveAttachment: "elementum_save_attachment_task",
105
107
  userSearch: "elementum_user_search_task",
108
+ userGroupSearch: "elementum_user_group_search_task",
106
109
  calculation: "elementum_calculation_task",
107
110
  executeScript: "elementum_execute_script_task",
108
111
  documentModel: "elementum_file_reader_task",
@@ -115,6 +118,7 @@ const TASK_RESOURCES = {
115
118
  // on `taskRefs` entries and the dedicated emission branch in `emitTasks`.
116
119
  unimplementedTask: "elementum_unmanaged_task_reference",
117
120
  };
121
+ const USER_SEARCH_PATH_BY_WIRE_NAME = new Map(Object.entries(USER_SEARCH_REF_WIRE_NAMES).map(([path, wire]) => [wire, path]));
118
122
  const CONFIG_ATTRS = {
119
123
  aspectId: "object_id",
120
124
  relatedAspectId: "object_id",
@@ -317,15 +321,8 @@ function foreignRootLookup(kind, identity) {
317
321
  lookupValue: identity.name,
318
322
  };
319
323
  }
320
- /**
321
- * Validates and derives the shared naming for a cross-app/element/task field
322
- * token — the `data.elementum_field` label {@link crossAppFieldToTf} emits,
323
- * and the matching `<fieldLabel>_options_by_label` local a foreign PICKLIST
324
- * field's option-label lookup (in {@link picklistFilterValueToTf}) resolves
325
- * against. Kept as one function so the two call sites can never drift apart
326
- * on how the label is built.
327
- */
328
- function foreignFieldNaming(value) {
324
+ /** Validates a cross-app/element/task field token's owner provenance. */
325
+ function foreignFieldProvenance(value) {
329
326
  const parent = value.parent;
330
327
  if (parent === undefined)
331
328
  throw new EntityTfError(`field ref "${value.refName}" has no parent`);
@@ -344,14 +341,7 @@ function foreignFieldNaming(value) {
344
341
  }
345
342
  const fieldName = value.name ?? value.refName;
346
343
  const ownerKind = value.parentKind === "task" ? "task" : value.parentKind === "element" ? "element" : "app";
347
- const resolved = foreignRootLookup(ownerKind, {
348
- name: value.parentName,
349
- namespace: value.parentNamespace,
350
- });
351
- const ownerType = resolved.resourceType;
352
- const ownerLabel = resolved.tfLabel;
353
- const fieldLabel = `${value.parentKind}_${ownerLabel}_${tsLabelToTfLabel(value.refName)}`;
354
- return { fieldName, ownerType, ownerLabel, ownerParentName: value.parentName, fieldLabel };
344
+ return { fieldName, ownerKind, ownerParentName: value.parentName };
355
345
  }
356
346
  /**
357
347
  * Registers the `<fieldLabel>_options_by_label` local — a for-expression
@@ -393,17 +383,29 @@ function crossAppFieldToTf(value, ctx, dataBlocks) {
393
383
  return fieldValue;
394
384
  }
395
385
  }
396
- const { fieldName, fieldLabel } = foreignFieldNaming(value);
397
- const ownerKind = value.parentKind === "task" ? "task" : value.parentKind === "element" ? "element" : "app";
386
+ return expr.dataAttr("elementum_field", registerForeignFieldLookup(value, ctx, dataBlocks), ["id"]);
387
+ }
388
+ /**
389
+ * Registers the `data.elementum_field` lookup (and its owner root lookup) for
390
+ * a genuinely foreign field, plus the matching `<label>_options_by_label`
391
+ * local, and returns the lookup label. The one place both a foreign field's
392
+ * id ({@link crossAppFieldToTf}) and its option-label local
393
+ * ({@link picklistFilterValueToTf}) get their label, so the two never drift.
394
+ */
395
+ function registerForeignFieldLookup(value, ctx, dataBlocks) {
396
+ const { fieldName, ownerKind, ownerParentName } = foreignFieldProvenance(value);
397
+ let fieldLabel;
398
398
  if (ctx.orgRefs !== undefined) {
399
- const owner = resolveForeignRef(ownerKind, { name: value.parentName, namespace: value.parentNamespace }, ctx.orgRefs, ctx.diagnostics, `automation field "${value.refName}" owner`);
399
+ const owner = resolveForeignRef(ownerKind, { name: ownerParentName, namespace: value.parentNamespace }, ctx.orgRefs, ctx.diagnostics, `automation field "${value.refName}" owner`);
400
+ fieldLabel = foreignFieldDataLabel(ownerKind, owner.tfLabel, fieldName);
400
401
  ctx.orgRefs.foreignField("elementum_field", fieldLabel, owner.value, fieldName);
401
402
  }
402
403
  else {
403
404
  const resolved = foreignRootLookup(ownerKind, {
404
- name: value.parentName,
405
+ name: ownerParentName,
405
406
  namespace: value.parentNamespace,
406
407
  });
408
+ fieldLabel = foreignFieldDataLabel(ownerKind, resolved.tfLabel, fieldName);
407
409
  const objectId = expr.dataAttr(resolved.resourceType, resolved.tfLabel, ["id"]);
408
410
  dataBlocks.set(`${resolved.resourceType}.${resolved.tfLabel}`, {
409
411
  kind: "data",
@@ -419,7 +421,7 @@ function crossAppFieldToTf(value, ctx, dataBlocks) {
419
421
  });
420
422
  }
421
423
  registerForeignOptionsByLabelLocal(fieldLabel, ctx);
422
- return expr.dataAttr("elementum_field", fieldLabel, ["id"]);
424
+ return fieldLabel;
423
425
  }
424
426
  /**
425
427
  * Resolve an automation token as a managed definition (same stream root or a
@@ -549,6 +551,7 @@ function tokenToTf(value, ctx, dataBlocks) {
549
551
  return expr.dataAttr("elementum_user", label, ["id"]);
550
552
  }
551
553
  case "userField":
554
+ case "userGroupField":
552
555
  return value.refName;
553
556
  case "task": {
554
557
  const sibling = ctx.workspaceAspects?.get(workspaceAspectKey("task", value.refName));
@@ -1020,31 +1023,18 @@ function calculationTaskMustache(taskRefKey, name, refs) {
1020
1023
  `"}}`,
1021
1024
  ];
1022
1025
  }
1023
- /**
1024
- * Task-own outputs whose calc-engine reference name differs from the
1025
- * refs-map key. Keys are the display labels the refs map uses (and that
1026
- * `build.ts`'s `rewriteForwardTaskRefName` already rewrote authoring names
1027
- * into); values are the underlying reference names — captured live with
1028
- * `ei refs --from-remote` against a real record-search task, and matching
1029
- * mobius' `shared.json` `aspect_records_search` label table.
1030
- */
1031
- const CALCULATION_TASK_OUTPUT_REF_NAME = {
1032
- elementum_record_search_task: {
1033
- "Records Size": "count",
1034
- "First found record id": "recordId",
1035
- },
1036
- };
1037
1026
  function calculationTaskRefName(targetType, name, taskRefKey, refs) {
1038
1027
  const segments = name.split(".");
1039
1028
  if (segments[0] === "record" && segments.length >= 2) {
1040
1029
  const suffix = segments.slice(2).join(".");
1030
+ const fieldKey = segments[1];
1041
1031
  return [
1042
1032
  "record.",
1043
- calculationRecordFieldId(segments[1], calculationFieldScope(taskRefKey, refs)),
1033
+ calculationRawFieldId(fieldKey) ?? calculationRecordFieldId(fieldKey, calculationFieldScope(taskRefKey, refs)),
1044
1034
  suffix.length > 0 ? `.${suffix}` : "",
1045
1035
  ];
1046
1036
  }
1047
- const refName = CALCULATION_TASK_OUTPUT_REF_NAME[targetType]?.[name] ?? name;
1037
+ const refName = TASK_OUTPUT_REFERENCE_NAMES[targetType]?.[name] ?? name;
1048
1038
  if (refName.includes('"')) {
1049
1039
  throw new EntityTfError(`calculation task output name "${refName}" contains a double quote`);
1050
1040
  }
@@ -1070,6 +1060,33 @@ function calculationFieldScope(taskRefKey, refs) {
1070
1060
  ?? refs.owner.workspaceAspects?.get(workspaceAspectKey("element", taskApp));
1071
1061
  return { appRefName: taskApp, appTfLabel: aspect?.tfLabel ?? refs.owner.appTfLabel, fieldAddresses };
1072
1062
  }
1063
+ const FOUND_RECORD_TASK_TYPES = new Set([
1064
+ "elementum_record_search_task",
1065
+ "elementum_create_record_task",
1066
+ "elementum_find_related_records_task",
1067
+ ]);
1068
+ /**
1069
+ * A short-form `task.<id>.<name>` value reference addresses a found record's
1070
+ * field by its platform reference name `record.<fieldId>` (as ei exports it),
1071
+ * not by the refs-map display label. Undefined when the field's id cannot be
1072
+ * resolved in this build, which keeps the display-label form.
1073
+ */
1074
+ function foundRecordFieldReferenceName(targetType, name, taskRefKey, refs) {
1075
+ const segments = name.split(".");
1076
+ const addressesRecordFields = FOUND_RECORD_TASK_TYPES.has(targetType) || targetType === TASK_RESOURCES.updateField;
1077
+ if (!addressesRecordFields || segments[0] !== "record" || segments.length < 2)
1078
+ return undefined;
1079
+ if (segments[1] === "recordId")
1080
+ return undefined;
1081
+ try {
1082
+ return calculationTaskRefName(targetType, name, taskRefKey, refs).filter((part) => part !== "");
1083
+ }
1084
+ catch (error) {
1085
+ if (error instanceof EntityTfError)
1086
+ return undefined;
1087
+ throw error;
1088
+ }
1089
+ }
1073
1090
  function calculationTriggerMustache(name, refs) {
1074
1091
  const parts = name.split(".");
1075
1092
  if (parts[0] !== "record" || parts.length < 2) {
@@ -1084,11 +1101,16 @@ function calculationTriggerMustache(name, refs) {
1084
1101
  `${suffixPart}"}}`,
1085
1102
  ];
1086
1103
  }
1087
- function calculationRecordFieldId(fieldKey, scope) {
1104
+ /** A field id that is already on the wire (pulled raw UUID / unresolved marker) needs no aspect to resolve. */
1105
+ function calculationRawFieldId(fieldKey) {
1088
1106
  if (fieldKey.startsWith(UNRESOLVED_FIELD_MARKER))
1089
1107
  return fieldKey.slice(UNRESOLVED_FIELD_MARKER.length);
1090
- if (isUuid(fieldKey))
1091
- return fieldKey;
1108
+ return isUuid(fieldKey) ? fieldKey : undefined;
1109
+ }
1110
+ function calculationRecordFieldId(fieldKey, scope) {
1111
+ const raw = calculationRawFieldId(fieldKey);
1112
+ if (raw !== undefined)
1113
+ return raw;
1092
1114
  const address = scope.fieldAddresses.get(fieldKey);
1093
1115
  if (address !== undefined)
1094
1116
  return addressExpr(address, ["id"]);
@@ -1167,15 +1189,6 @@ const FIELD_REF_SUFFIX_TO_WIRE = {
1167
1189
  "employee.manager.email": " Manager Email",
1168
1190
  "employee.manager.name": " Manager Name",
1169
1191
  };
1170
- const PROVIDER_FIXED_SYSTEM_FIELD_KEYS = new Set([
1171
- "stage",
1172
- "createdAt",
1173
- "createdBy",
1174
- "updatedAt",
1175
- "updatedBy",
1176
- "closedAt",
1177
- "closedBy",
1178
- ]);
1179
1192
  function wireRefName(name, ctx) {
1180
1193
  const known = TS_TRIGGER_REF_TO_WIRE[name];
1181
1194
  if (known !== undefined)
@@ -1222,13 +1235,7 @@ function wireRefName(name, ctx) {
1222
1235
  if (wireSuffix === undefined) {
1223
1236
  throw new EntityTfError(`automation reference "${name}" has unsupported record-field path "${suffix}"`);
1224
1237
  }
1225
- // Email audit refs have historically varied in the capitalization of
1226
- // "by" between organizations. The provider exposes both spellings as
1227
- // aliases, so author the established lowercase wire name consistently.
1228
- const refName = `${fieldName}${wireSuffix}`;
1229
- return /^(Created|Updated) By (?:Manager )?Email$/.test(refName)
1230
- ? refName.replace(/ By(?= (?:Manager )?Email$)/, " by")
1231
- : refName;
1238
+ return recordFieldWireRefName(fieldName, wireSuffix);
1232
1239
  }
1233
1240
  // A webhook trigger's body/headers refs (ctx.trigger.body["X"]) can only
1234
1241
  // type-check against DeepRefs<WebhookTriggerOutput>, so parts[0] being
@@ -1269,8 +1276,14 @@ const RECORD_COLLECTION_TASK_WIRE_TYPES = new Set([
1269
1276
  const TS_FOR_EACH_GENERIC_SEGMENT_TO_WIRE = {
1270
1277
  iteration: "Iteration",
1271
1278
  };
1272
- function forEachCompactFilterName(name) {
1273
- return name === "recordId" ? "item" : name;
1279
+ function forEachCompactFilterName(name, isRecordCollection) {
1280
+ if (name === "recordId")
1281
+ return "item";
1282
+ // A plain-list loop's whole item is ForEachReference name "" on the
1283
+ // platform; provider Read renders it as `for_each.<id>.`.
1284
+ if (name === "item" && !isRecordCollection)
1285
+ return "";
1286
+ return name;
1274
1287
  }
1275
1288
  function forEachWireRefName(name, ctx, isRecordCollection) {
1276
1289
  // A recordSearch collection's whole item and branded record identity both
@@ -1756,6 +1769,10 @@ function unwrapDefault(value) {
1756
1769
  const values = Object.values(value);
1757
1770
  return values.length === 1 ? values[0] : value;
1758
1771
  }
1772
+ /** `options` is filled only from picklistValues, so a related-record dropdown is a PICKLIST with none. */
1773
+ function isOptionBearingPicklist(metadata) {
1774
+ return metadata?.fieldType === "PICKLIST" && (metadata.options?.length ?? 0) > 0;
1775
+ }
1759
1776
  function filterReferenceToTf(value, refs, role = "value", realType, operator) {
1760
1777
  // Raw pass-through for a filter left side the pull-time deserializer
1761
1778
  // couldn't decode to a typed ref (filter.ts's leftDescriptor, matching the
@@ -1781,17 +1798,9 @@ function filterReferenceToTf(value, refs, role = "value", realType, operator) {
1781
1798
  const address = refs.owner.fieldAddresses.get(fieldKey);
1782
1799
  const suffix = parts.slice(2).join(".");
1783
1800
  let wireSuffix = suffix === "recordId" ? "10000001-2000-4000-a000-800000000000" : suffix;
1784
- // A bare reference to a PICKLIST field (STATUS/STAGE included —
1785
- // `serializeSystemFields` wire-wraps both as a picklist too) has no
1786
- // valid suffix-less wire form — confirmed live via the platform's
1787
- // own switch-case editor, which always sends an explicit `.id`
1788
- // (compare by the chosen option's real id) or `.label` (compare by
1789
- // display text, unvalidated) and never a bare `record.<fieldId>`.
1790
- // Comparisons stay ambiguous (eq/in/…). Null-checks are equivalent
1791
- // for `.id` and `.label` when no option is selected, so
1792
- // `isNull`/`isNotNull` on a bare Dropdown emit the platform editor's
1793
- // `.id` + uuid shape — the Accept `isNotNull(record.dropdown)` form.
1794
- if (suffix.length === 0 && refs.owner.fieldMetadata.get(fieldKey)?.fieldType === "PICKLIST") {
1801
+ // An option-bearing picklist has no bare wire form. The platform editor
1802
+ // sends `.id` or `.label`, and a null-check emits `.id`.
1803
+ if (suffix.length === 0 && isOptionBearingPicklist(refs.owner.fieldMetadata.get(fieldKey))) {
1795
1804
  if (operator === "is_null") {
1796
1805
  wireSuffix = "id";
1797
1806
  }
@@ -1919,12 +1928,45 @@ function filterReferenceToTf(value, refs, role = "value", realType, operator) {
1919
1928
  },
1920
1929
  });
1921
1930
  }
1931
+ const ambiguousRecordField = recordRefKeyIsAmbiguous(value.name, wireName, value.taskRefKey, refs)
1932
+ ? foundRecordFieldReferenceName(task.type, value.name, value.taskRefKey, refs)
1933
+ : undefined;
1934
+ if (ambiguousRecordField !== undefined) {
1935
+ return expr.jsonencode({
1936
+ fieldType: (realType ?? "TEXT").toUpperCase(),
1937
+ multiple: false,
1938
+ taskReference: {
1939
+ name: expr.template(ambiguousRecordField),
1940
+ taskId: expr.resourceAttr(task.type, task.label, ["id"]),
1941
+ },
1942
+ });
1943
+ }
1944
+ // A field id the workspace cannot resolve (a foreign element's field)
1945
+ // has no display label to key `refs` by; only the envelope names it.
1946
+ const unresolvedFieldId = wireName.split(".")[1];
1947
+ if (wireName.startsWith("record.") && unresolvedFieldId !== undefined && isUuid(unresolvedFieldId)) {
1948
+ return expr.jsonencode({
1949
+ fieldType: (realType ?? "TEXT").toUpperCase(),
1950
+ multiple: false,
1951
+ taskReference: {
1952
+ name: wireName,
1953
+ taskId: expr.resourceAttr(task.type, task.label, ["id"]),
1954
+ },
1955
+ });
1956
+ }
1922
1957
  return expr.resourceAttr(task.type, task.label, ["refs", { index: wireName }]);
1923
1958
  }
1959
+ const recordFieldName = foundRecordFieldReferenceName(task.type, value.name, value.taskRefKey, refs);
1960
+ // The short form addresses user-search outputs by path; only `.refs`
1961
+ // is keyed by their display labels.
1962
+ const shortName = task.type === TASK_RESOURCES.userSearch
1963
+ ? USER_SEARCH_PATH_BY_WIRE_NAME.get(wireName) ?? wireName
1964
+ : wireName;
1924
1965
  return expr.template([
1925
1966
  "task.",
1926
1967
  expr.resourceAttr(task.type, task.label, ["id"]),
1927
- `.${wireName}`,
1968
+ ".",
1969
+ ...(recordFieldName ?? [shortName]),
1928
1970
  ]);
1929
1971
  }
1930
1972
  case "FOR_EACH": {
@@ -1936,7 +1978,7 @@ function filterReferenceToTf(value, refs, role = "value", realType, operator) {
1936
1978
  return expr.template([
1937
1979
  "for_each.",
1938
1980
  expr.resourceAttr(task.type, task.label, ["id"]),
1939
- `.${forEachCompactFilterName(value.name)}`,
1981
+ `.${forEachCompactFilterName(value.name, refs.recordItemForEachRefKeys.has(value.forEachTaskRefKey))}`,
1940
1982
  ]);
1941
1983
  }
1942
1984
  case "VALUE":
@@ -2019,15 +2061,10 @@ function picklistFilterValueToTf(value, field, refs) {
2019
2061
  if (field.parent !== undefined && (field.parent !== refs.owner.appRefName || field.parentKind === "element")) {
2020
2062
  // A foreign field's options-by-label local is sourced from
2021
2063
  // `data.elementum_field.<label>.options` (issue #353) rather than an
2022
- // owned resource's `options` attribute — `crossAppFieldToTf` registers
2023
- // both the data block and the matching local; reuse the SAME naming
2024
- // (`foreignFieldNaming`) so this reference always lines up with
2025
- // whatever label that registration used, then make sure the data block
2026
- // (and local) actually gets registered even when nothing else in this
2027
- // payload resolves the field's id.
2028
- const naming = foreignFieldNaming(field);
2029
- crossAppFieldToTf(field, refs.owner, refs.dataBlocks);
2030
- return expr.local(naming.fieldLabel + "_options_by_label", [{ index: value }]);
2064
+ // owned resource's `options` attribute. Registering here also covers a
2065
+ // payload where nothing else resolves the field's id.
2066
+ const fieldLabel = registerForeignFieldLookup(field, refs.owner, refs.dataBlocks);
2067
+ return expr.local(fieldLabel + "_options_by_label", [{ index: value }]);
2031
2068
  }
2032
2069
  const localName = field.tags?.includes("STATUS")
2033
2070
  ? `${refs.owner.appTfLabel}_status_options_by_label`
@@ -2047,9 +2084,14 @@ function triggerRecordFieldPath(reference) {
2047
2084
  function fieldFromFilterLeftValue(value, refs) {
2048
2085
  if (isObject(value) && value.type === "FIELD")
2049
2086
  return token(value.value ?? value.field);
2050
- if (!isObject(value) || !isObject(value.value) || value.value.type?.toString().toUpperCase() !== "TRIGGER") {
2087
+ if (!isObject(value) || !isObject(value.value))
2088
+ return undefined;
2089
+ const referenceType = value.value.type?.toString().toUpperCase();
2090
+ const ownAppTask = referenceType === "TASK" &&
2091
+ typeof value.value.taskRefKey === "string" &&
2092
+ taskSearchesOwnerApp(value.value.taskRefKey, refs);
2093
+ if (referenceType !== "TRIGGER" && !ownAppTask)
2051
2094
  return undefined;
2052
- }
2053
2095
  const parsed = triggerRecordFieldPath(value.value);
2054
2096
  if (parsed === undefined)
2055
2097
  return undefined;
@@ -2067,16 +2109,48 @@ function fieldFromFilterLeftValue(value, refs) {
2067
2109
  return undefined;
2068
2110
  return { __kind: "field", refName, ...metadata };
2069
2111
  }
2112
+ function taskSearchesOwnerApp(taskRefKey, refs) {
2113
+ const task = refs.tasks.get(taskRefKey);
2114
+ if (task === undefined || !FOUND_RECORD_TASK_TYPES.has(task.type))
2115
+ return false;
2116
+ const taskApp = refs.recordFieldContext?.taskAppRefNameByRefKey?.[taskRefKey];
2117
+ return taskApp === undefined || taskApp === refs.owner.appRefName;
2118
+ }
2119
+ /**
2120
+ * `refs` is keyed by display label, so a drilled-down record field (the
2121
+ * Stage field's `.id` is "Stage ID") can share its key with another field's
2122
+ * own label (a custom "Stage ID" text field) on the same app.
2123
+ */
2124
+ function recordRefKeyIsAmbiguous(name, wireName, taskRefKey, refs) {
2125
+ const segments = name.split(".");
2126
+ if (segments[0] !== "record" || segments.length < 3)
2127
+ return false;
2128
+ const taskApp = refs.recordFieldContext?.taskAppRefNameByRefKey?.[taskRefKey];
2129
+ const fieldNames = taskApp === undefined || taskApp === refs.owner.appRefName
2130
+ ? refs.owner.fieldNames
2131
+ : fieldNamesForAppRefName(refs.fieldNamesByAppRefName, taskApp);
2132
+ for (const [fieldKey, fieldName] of fieldNames ?? []) {
2133
+ if (fieldKey !== segments[1] && fieldName === wireName)
2134
+ return true;
2135
+ }
2136
+ return false;
2137
+ }
2070
2138
  function filterToTf(value, refs) {
2071
2139
  return serializeFilterToTf(value, {
2072
2140
  field: (field) => valueToTf(field, refs),
2073
2141
  fieldFromLeftValue: (left) => fieldFromFilterLeftValue(left, refs),
2074
2142
  reference: (reference, role, realType, operator) => filterReferenceToTf(reference, refs, role ?? "value", realType, operator),
2075
2143
  referenceRealType: (reference, _role, authored) => {
2144
+ if (!isObject(reference) || reference.type?.toString().toUpperCase() !== "TRIGGER")
2145
+ return authored;
2076
2146
  const parsed = triggerRecordFieldPath(reference);
2077
2147
  if (parsed === undefined)
2078
2148
  return authored;
2079
2149
  const metadata = refs.owner.fieldMetadata.get(parsed.fieldKey);
2150
+ // A suffix-less option picklist is a UUID. A bare dynamic dropdown is stored as text.
2151
+ if (parsed.suffix === "" && metadata?.fieldType === "PICKLIST" && !isOptionBearingPicklist(metadata)) {
2152
+ return authored;
2153
+ }
2080
2154
  const inferred = referenceValueTypeForField(metadata?.fieldType, parsed.suffix);
2081
2155
  if (inferred === undefined)
2082
2156
  return authored;
@@ -76,6 +76,7 @@ export const TASK_SUB_TYPES = [
76
76
  { typeKey: "addWatcher", resourceType: "elementum_add_watcher_task", implemented: true },
77
77
  { typeKey: "saveAttachment", resourceType: "elementum_save_attachment_task", implemented: true },
78
78
  { typeKey: "userSearch", resourceType: "elementum_user_search_task", implemented: true },
79
+ { typeKey: "userGroupSearch", resourceType: "elementum_user_group_search_task", implemented: true },
79
80
  { typeKey: "aspectRecordFieldLocking", resourceType: "elementum_aspect_record_field_locking_task", implemented: true },
80
81
  { typeKey: "initiateCall", resourceType: "elementum_initiate_call_task", implemented: true },
81
82
  // Operators (branching) — later phases:
@@ -4,6 +4,7 @@ import { FIELD_RESOURCE_TYPES } from "../field/types.js";
4
4
  import { fieldKeyFromTfValue } from "../field/from-tf.js";
5
5
  import { filterFromTf } from "../shared/filters/tf-codec.js";
6
6
  import { CHART_RESOURCE_TYPE } from "./types.js";
7
+ import { dataAspectDisplayName } from "../shared/aspect-target-from-tf.js";
7
8
  const APP_RESOURCE_TYPE = "elementum_app";
8
9
  const TABLE_RESOURCE_TYPE = "elementum_table";
9
10
  function decodeJson(value) {
@@ -34,22 +35,35 @@ function datasourceFromTf(value, appLabel, appRefName, ctx, where) {
34
35
  }
35
36
  const dataLabel = dataRefLabel(value, type);
36
37
  if (dataLabel !== undefined) {
38
+ if (kind === "app" || kind === "element") {
39
+ const attrs = ctx.dataAttrs?.(type, dataLabel);
40
+ const namespace = typeof attrs?.["namespace"] === "string" && attrs["namespace"] !== "" ? attrs["namespace"] : undefined;
41
+ const name = dataAspectDisplayName(ctx, kind, dataLabel);
42
+ // The printer emits catalog members. Bind their actual keys, and never
43
+ // substitute a same-name target when the stable namespace is unknown.
44
+ const refName = namespace !== undefined
45
+ ? (kind === "app" ? ctx.foreignAppRefNamespaces : ctx.foreignElementRefNamespaces)?.get(namespace)
46
+ : name !== undefined
47
+ ? (kind === "app" ? ctx.foreignAppRefNames : ctx.foreignElementRefNames)?.get(name)
48
+ : undefined;
49
+ if (refName === undefined) {
50
+ ctx.diagnostics.push(`${where}: ${kind} datasource ${namespace ?? name ?? dataLabel} cannot be resolved to the pulled catalog; skipped`);
51
+ return undefined;
52
+ }
53
+ return { kind, refName, ...(name !== undefined ? { name } : {}), local: false, tfLabel: dataLabel };
54
+ }
37
55
  const name = ctx.dataName(type, dataLabel) ?? tfLabelToTsLabel(dataLabel);
38
- const refName = kind === "app"
39
- ? ctx.foreignAppRefNames?.get(name) ?? tfLabelToTsLabel(dataLabel)
40
- : kind === "element"
41
- ? ctx.foreignElementRefNames?.get(name) ?? tfLabelToTsLabel(dataLabel)
42
- : kind === "task"
43
- ? tfLabelToTsLabel(dataLabel)
44
- : (() => {
45
- const attrs = ctx.dataAttrs?.(type, dataLabel);
46
- const id = typeof attrs?.["id"] === "string" ? attrs["id"] : ctx.importId(`data.${type}.${dataLabel}`);
47
- const byId = id === undefined ? undefined : ctx.foreignTableRefsById?.get(id);
48
- if (byId !== undefined)
49
- return byId.tableRefName;
50
- const matches = [...(ctx.foreignTableRefsById?.values() ?? [])].filter((candidate) => candidate.name === name);
51
- return matches.length === 1 ? matches[0].tableRefName : undefined;
52
- })();
56
+ const refName = kind === "task"
57
+ ? tfLabelToTsLabel(dataLabel)
58
+ : (() => {
59
+ const attrs = ctx.dataAttrs?.(type, dataLabel);
60
+ const id = typeof attrs?.["id"] === "string" ? attrs["id"] : ctx.importId(`data.${type}.${dataLabel}`);
61
+ const byId = id === undefined ? undefined : ctx.foreignTableRefsById?.get(id);
62
+ if (byId !== undefined)
63
+ return byId.tableRefName;
64
+ const matches = [...(ctx.foreignTableRefsById?.values() ?? [])].filter((candidate) => candidate.name === name);
65
+ return matches.length === 1 ? matches[0].tableRefName : undefined;
66
+ })();
53
67
  if (refName === undefined) {
54
68
  ctx.diagnostics.push(`${where}: table datasource ${name} cannot be resolved to the org catalog; skipped`);
55
69
  return undefined;
@@ -216,8 +230,10 @@ function parseSubscription(value, appLabel, appRefName, ctx, where) {
216
230
  return undefined;
217
231
  }
218
232
  const field = column["column_id"] !== undefined ? fieldFromTf(column["column_id"], datasource, ctx, `${where}.columns[${index}].column_id`) : undefined;
219
- if (column["column_id"] !== undefined && field === undefined)
220
- continue;
233
+ if (column["column_id"] !== undefined && field === undefined) {
234
+ ctx.diagnostics.push(`${where}.columns[${index}]: unresolved field; subscription skipped to preserve all chart series`);
235
+ return undefined;
236
+ }
221
237
  if (column["expression"] !== undefined) {
222
238
  ctx.diagnostics.push(`${where}.columns[${index}].expression: unsupported chart expression; subscription skipped`);
223
239
  return undefined;
@@ -1,6 +1,7 @@
1
1
  import { bareFactoryEntry } from "../../catalog/render-helpers.js";
2
2
  import { NO_CANVAS } from "../../graph/types.js";
3
3
  import { chartFromTf } from "./from-tf.js";
4
+ import { rebindChartOwner } from "./rebind-owner.js";
4
5
  import { printChart } from "./printer.js";
5
6
  import { chartToTf } from "./to-tf.js";
6
7
  import { CHART_RESOURCE_TYPE } from "./types.js";
@@ -33,9 +34,10 @@ export const chartModule = {
33
34
  }
34
35
  return { items, skipped, diagnostics: [] };
35
36
  },
37
+ rebindOwnFileOwner: (item, from, to) => rebindChartOwner(item, from, to),
36
38
  printOwnFile: (item, opts) => ({
37
39
  refName: item.refName,
38
- source: printChart(item, { appRefName: opts.appRefName, orgImportPath: opts.orgImportPath }),
40
+ source: printChart(item, { appRefName: opts.appRefName, orgImportPath: opts.orgImportPath, elementCatalogKeys: opts.elementCatalogKeys }),
39
41
  }),
40
42
  toTf: (entity, ctx) => chartToTf(entity, {
41
43
  appRefName: ctx.appRefName,
@@ -2,4 +2,5 @@ import type { NormalizedChart } from "./from-tf.js";
2
2
  export declare function printChart(chart: NormalizedChart, opts: {
3
3
  readonly appRefName: string;
4
4
  readonly orgImportPath: string;
5
+ readonly elementCatalogKeys?: ReadonlyMap<string, string>;
5
6
  }): string;
@@ -9,13 +9,23 @@ function constantKey(values, value, domain) {
9
9
  throw new Error(`chart pull: unsupported ${domain} ${JSON.stringify(value)}`);
10
10
  return entry[0];
11
11
  }
12
- function dataExpr(value) {
13
- return value.kind === "table" ? `catalog.tables${member(value.refName)}` : `catalog${member(value.refName)}`;
12
+ function elementKey(refName, keys) {
13
+ if (keys === undefined)
14
+ return refName;
15
+ const key = keys.get(refName);
16
+ if (key === undefined)
17
+ throw new Error(`chart pull: element ${JSON.stringify(refName)} has no catalog key`);
18
+ return key;
14
19
  }
15
- function fieldExpr(value) {
20
+ function dataExpr(value, keys) {
21
+ const key = value.kind === "element" ? elementKey(value.refName, keys) : value.refName;
22
+ return value.kind === "table" ? `catalog.tables${member(key)}` : `catalog${member(key)}`;
23
+ }
24
+ function fieldExpr(value, keys) {
25
+ const key = value.parentKind === "element" ? elementKey(value.parentRefName, keys) : value.parentRefName;
16
26
  return value.kind === "tableColumn"
17
- ? `catalog.tables${member(value.parentRefName)}.columns${member(value.refName)}`
18
- : `catalog${member(value.parentRefName)}.fields${member(value.refName)}`;
27
+ ? `catalog.tables${member(key)}.columns${member(value.refName)}`
28
+ : `catalog${member(key)}.fields${member(value.refName)}`;
19
29
  }
20
30
  function printOpaqueSubscription(subscription) {
21
31
  const attrs = Object.entries(subscription.attributes)
@@ -28,10 +38,10 @@ function printOpaqueSubscription(subscription) {
28
38
  " }),",
29
39
  ];
30
40
  }
31
- function printColumn(column) {
41
+ function printColumn(column, keys) {
32
42
  const parts = [];
33
43
  if (column.field !== undefined)
34
- parts.push(`field: ${fieldExpr(column.field)}`);
44
+ parts.push(`field: ${fieldExpr(column.field, keys)}`);
35
45
  if (column.aggregation !== undefined)
36
46
  parts.push(`aggregation: chartAggregation.${constantKey(chartAggregation, column.aggregation, "aggregation")}`);
37
47
  if (column.name !== undefined)
@@ -42,18 +52,18 @@ function printColumn(column) {
42
52
  parts.push(`valueType: chartColumnValueType.${constantKey(chartColumnValueType, column.valueType, "column value type")}`);
43
53
  return `{ ${parts.join(", ")} }`;
44
54
  }
45
- function printSubscription(subscription) {
46
- const lines = [" chartSubscription({", ` datasource: ${dataExpr(subscription.datasource)},`];
47
- lines.push(` columns: [${subscription.columns.map(printColumn).join(", ")}],`);
55
+ function printSubscription(subscription, keys) {
56
+ const lines = [" chartSubscription({", ` datasource: ${dataExpr(subscription.datasource, keys)},`];
57
+ lines.push(` columns: [${subscription.columns.map((column) => printColumn(column, keys)).join(", ")}],`);
48
58
  if (subscription.groupBy !== undefined) {
49
- lines.push(` groupBy: [${subscription.groupBy.map((group) => `{ field: ${fieldExpr(group.field)} }`).join(", ")}],`);
59
+ lines.push(` groupBy: [${subscription.groupBy.map((group) => `{ field: ${fieldExpr(group.field, keys)} }`).join(", ")}],`);
50
60
  }
51
61
  if (subscription.joins !== undefined) {
52
62
  lines.push(" joins: [");
53
63
  for (const join of subscription.joins) {
54
- const parts = [`from: ${dataExpr(subscription.datasource)}`, `datasource: ${dataExpr(join.datasource)}`];
55
- parts.push(`leftField: ${fieldExpr(join.leftField)}`);
56
- parts.push(`rightField: ${fieldExpr(join.rightField)}`);
64
+ const parts = [`from: ${dataExpr(subscription.datasource, keys)}`, `datasource: ${dataExpr(join.datasource, keys)}`];
65
+ parts.push(`leftField: ${fieldExpr(join.leftField, keys)}`);
66
+ parts.push(`rightField: ${fieldExpr(join.rightField, keys)}`);
57
67
  if (join.type !== undefined)
58
68
  parts.push(`type: chartJoinType.${constantKey(chartJoinType, join.type, "join type")}`);
59
69
  lines.push(` chartJoin({ ${parts.join(", ")} }),`);
@@ -62,7 +72,7 @@ function printSubscription(subscription) {
62
72
  }
63
73
  if (subscription.filter !== undefined) {
64
74
  lines.push(` filter: ${printFilter(subscription.filter, {
65
- field: fieldExpr,
75
+ field: (field) => fieldExpr(field, keys),
66
76
  aspect: () => { throw new Error("chart pull: filter aspect overrides are unsupported"); },
67
77
  reference: () => { throw new Error("chart pull: filter references are unsupported"); },
68
78
  })},`);
@@ -117,7 +127,7 @@ export function printChart(chart, opts) {
117
127
  if (subscription.kind === "opaque")
118
128
  lines.push(...printOpaqueSubscription(subscription));
119
129
  else
120
- lines.push(...printSubscription(subscription));
130
+ lines.push(...printSubscription(subscription, opts.elementCatalogKeys));
121
131
  }
122
132
  lines.push(" ],", "});", "", "export default chart;", "");
123
133
  return lines.join("\n");
@@ -0,0 +1,3 @@
1
+ import type { NormalizedChart } from "./from-tf.js";
2
+ /** Rebind self references only; foreign roots can share the export owner's key. */
3
+ export declare function rebindChartOwner(chart: NormalizedChart, from: string, to: string): NormalizedChart;