@elementumai/edk 0.10.2 → 0.10.3

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 (114) hide show
  1. package/README.md +7 -7
  2. package/dist-sdk/src/catalog/org.d.ts +7 -5
  3. package/dist-sdk/src/catalog/org.js +14 -9
  4. package/dist-sdk/src/catalog/token.js +4 -0
  5. package/dist-sdk/src/core/types/app.d.ts +22 -0
  6. package/dist-sdk/src/engine/build/context.d.ts +8 -0
  7. package/dist-sdk/src/engine/build/source-context.d.ts +3 -4
  8. package/dist-sdk/src/engine/coverage-gaps.d.ts +2 -0
  9. package/dist-sdk/src/engine/coverage-gaps.js +3 -0
  10. package/dist-sdk/src/engine/ei/state.d.ts +48 -0
  11. package/dist-sdk/src/engine/ei/state.js +91 -0
  12. package/dist-sdk/src/engine/pull/authored-address.d.ts +100 -0
  13. package/dist-sdk/src/engine/pull/authored-address.js +360 -0
  14. package/dist-sdk/src/engine/pull/context.d.ts +59 -0
  15. package/dist-sdk/src/engine/tf/expr.d.ts +7 -0
  16. package/dist-sdk/src/engine/tf/expr.js +62 -18
  17. package/dist-sdk/src/engine/tf/index.d.ts +1 -1
  18. package/dist-sdk/src/engine/tf/index.js +1 -1
  19. package/dist-sdk/src/engine/tf/labels.d.ts +10 -2
  20. package/dist-sdk/src/engine/tf/labels.js +15 -2
  21. package/dist-sdk/src/engine/tf/parse.js +19 -6
  22. package/dist-sdk/src/engine/workspace/backend.d.ts +34 -0
  23. package/dist-sdk/src/engine/workspace/backend.js +104 -0
  24. package/dist-sdk/src/engine/workspace/generated-file.d.ts +3 -0
  25. package/dist-sdk/src/engine/workspace/generated-file.js +6 -0
  26. package/dist-sdk/src/engine/workspace/loader.js +2 -2
  27. package/dist-sdk/src/entities/agent-tool/to-tf.js +1 -1
  28. package/dist-sdk/src/entities/app/build.d.ts +36 -4
  29. package/dist-sdk/src/entities/app/build.js +67 -4
  30. package/dist-sdk/src/entities/app/deserializer/normalize.d.ts +12 -0
  31. package/dist-sdk/src/entities/app/from-tf.js +13 -9
  32. package/dist-sdk/src/entities/app/module.js +1 -0
  33. package/dist-sdk/src/entities/app/stage-keys.d.ts +82 -0
  34. package/dist-sdk/src/entities/app/stage-keys.js +160 -0
  35. package/dist-sdk/src/entities/app/to-tf.js +17 -21
  36. package/dist-sdk/src/entities/approval-chain/from-tf.d.ts +9 -1
  37. package/dist-sdk/src/entities/approval-chain/from-tf.js +31 -3
  38. package/dist-sdk/src/entities/approval-chain/module.js +12 -4
  39. package/dist-sdk/src/entities/approval-chain/to-tf.d.ts +1 -0
  40. package/dist-sdk/src/entities/approval-chain/to-tf.js +6 -1
  41. package/dist-sdk/src/entities/automation/build.js +13 -6
  42. package/dist-sdk/src/entities/automation/deserializer/ast.d.ts +3 -0
  43. package/dist-sdk/src/entities/automation/deserializer/print-automation.d.ts +5 -3
  44. package/dist-sdk/src/entities/automation/deserializer/print-automation.js +90 -17
  45. package/dist-sdk/src/entities/automation/from-tf.d.ts +28 -6
  46. package/dist-sdk/src/entities/automation/from-tf.js +140 -23
  47. package/dist-sdk/src/entities/automation/module.js +123 -37
  48. package/dist-sdk/src/entities/automation/to-tf.d.ts +3 -1
  49. package/dist-sdk/src/entities/automation/to-tf.js +131 -20
  50. package/dist-sdk/src/entities/automation/triggers.d.ts +2 -0
  51. package/dist-sdk/src/entities/automation/triggers.js +1 -0
  52. package/dist-sdk/src/entities/chart/from-tf.d.ts +6 -0
  53. package/dist-sdk/src/entities/chart/from-tf.js +9 -1
  54. package/dist-sdk/src/entities/dashboard/from-tf.js +51 -4
  55. package/dist-sdk/src/entities/dynamic-layout/from-tf.d.ts +3 -0
  56. package/dist-sdk/src/entities/dynamic-layout/from-tf.js +48 -4
  57. package/dist-sdk/src/entities/dynamic-layout/to-tf.d.ts +2 -0
  58. package/dist-sdk/src/entities/dynamic-layout/to-tf.js +7 -2
  59. package/dist-sdk/src/entities/element/build.js +1 -1
  60. package/dist-sdk/src/entities/element/from-tf.d.ts +12 -6
  61. package/dist-sdk/src/entities/element/from-tf.js +23 -7
  62. package/dist-sdk/src/entities/element/module.js +3 -2
  63. package/dist-sdk/src/entities/element/to-tf.d.ts +3 -2
  64. package/dist-sdk/src/entities/element/to-tf.js +32 -25
  65. package/dist-sdk/src/entities/field/allow-list.d.ts +18 -0
  66. package/dist-sdk/src/entities/field/allow-list.js +42 -0
  67. package/dist-sdk/src/entities/field/build.d.ts +38 -3
  68. package/dist-sdk/src/entities/field/build.js +7 -2
  69. package/dist-sdk/src/entities/field/from-tf.js +178 -20
  70. package/dist-sdk/src/entities/field/module.js +2 -0
  71. package/dist-sdk/src/entities/field/options.d.ts +2 -0
  72. package/dist-sdk/src/entities/field/order.d.ts +9 -0
  73. package/dist-sdk/src/entities/field/order.js +33 -0
  74. package/dist-sdk/src/entities/field/to-tf.d.ts +6 -0
  75. package/dist-sdk/src/entities/field/to-tf.js +87 -0
  76. package/dist-sdk/src/entities/field/types.js +3 -0
  77. package/dist-sdk/src/entities/relationship/build.d.ts +3 -3
  78. package/dist-sdk/src/entities/relationship/from-tf.js +4 -2
  79. package/dist-sdk/src/entities/relationship/to-tf.js +3 -1
  80. package/dist-sdk/src/entities/service-account/workspace-owner.d.ts +8 -3
  81. package/dist-sdk/src/entities/service-account/workspace-owner.js +12 -4
  82. package/dist-sdk/src/entities/shared/aspect-target-from-tf.d.ts +5 -0
  83. package/dist-sdk/src/entities/shared/aspect-target-from-tf.js +13 -0
  84. package/dist-sdk/src/entities/shared/filters/ast.d.ts +7 -0
  85. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +1 -1
  86. package/dist-sdk/src/entities/skill/to-tf.js +19 -14
  87. package/dist-sdk/src/entities/skill-tool/from-tf.d.ts +2 -0
  88. package/dist-sdk/src/entities/skill-tool/from-tf.js +3 -0
  89. package/dist-sdk/src/entities/skill-tool/to-tf.d.ts +6 -1
  90. package/dist-sdk/src/entities/skill-tool/to-tf.js +6 -1
  91. package/dist-sdk/src/entities/task/build.js +1 -1
  92. package/dist-sdk/src/entities/view/agent-view-layout-to-tf.d.ts +11 -0
  93. package/dist-sdk/src/entities/view/agent-view-layout-to-tf.js +13 -38
  94. package/dist-sdk/src/entities/view/custom-view-validate.d.ts +29 -0
  95. package/dist-sdk/src/entities/view/custom-view-validate.js +292 -0
  96. package/dist-sdk/src/entities/view/from-tf.d.ts +2 -0
  97. package/dist-sdk/src/entities/view/from-tf.js +40 -6
  98. package/dist-sdk/src/entities/view/to-tf.d.ts +6 -0
  99. package/dist-sdk/src/entities/view/to-tf.js +14 -6
  100. package/dist-sdk/src/entities/visual-flow/from-tf.d.ts +2 -1
  101. package/dist-sdk/src/entities/visual-flow/from-tf.js +11 -2
  102. package/dist-sdk/src/entities/visual-flow/module.js +15 -5
  103. package/dist-sdk/src/entities/visual-flow/to-tf.d.ts +2 -0
  104. package/dist-sdk/src/entities/visual-flow/to-tf.js +1 -1
  105. package/dist-sdk/src/entities/widget/build.d.ts +8 -1
  106. package/dist-sdk/src/entities/widget/from-tf.js +12 -6
  107. package/dist-sdk/src/entities/widget/to-tf.d.ts +1 -0
  108. package/dist-sdk/src/entities/widget/to-tf.js +16 -0
  109. package/dist-sdk/src/generated/ragnarok/ragnarok-spec.d.ts +8 -2
  110. package/dist-sdk/src/generated/ragnarok/ragnarok-spec.js +2 -2
  111. package/dist-sdk/src/graph/index.d.ts +6 -0
  112. package/dist-sdk/src/graph/index.js +1 -0
  113. package/dist-sdk/src/graph/types.d.ts +59 -2
  114. package/package.json +2 -17
@@ -6,8 +6,8 @@
6
6
  * import blocks and stay data-side.
7
7
  */
8
8
  import { EntityTfError } from "../../engine/entity.js";
9
- import { SYSTEM_FIELD_KEY_SET } from "../../core/system-fields.js";
10
- import { dataRefLabel, optionalString, reportAuthoringBlocker, resourceRefLabel } from "../../engine/pull/context.js";
9
+ import { DEPLOY_DEFAULT_SYSTEM_FIELD_NAMES, SYSTEM_FIELD_KEY_SET } from "../../core/system-fields.js";
10
+ import { dataRefLabel, groupCatalogKey, optionalString, reportAuthoringBlocker, resourceRefLabel } from "../../engine/pull/context.js";
11
11
  import { bareChildResourceLabel, isTfExpr, sanitizeName, scopedLabelToBagKey, tfLabelToTsLabel, tsLabelToTfLabel } from "../../engine/tf/index.js";
12
12
  import { filterFromTf as deserializeFilterFromTf } from "../shared/filters/tf-codec.js";
13
13
  import { __pulledExpression } from "../app/deserializer/pulled-expression.js";
@@ -15,9 +15,23 @@ import { isAttachmentMediaType } from "./media-types.js";
15
15
  import { optionsFromTf } from "./options.js";
16
16
  import { isCalculationResultType } from "./calculation-types.js";
17
17
  import { KNOWN_FIELD_ATTRS, SUB_TYPE_BY_RESOURCE } from "./types.js";
18
- import { ELEMENT_AUDIT_SYSTEM_FIELD_KEYS } from "../element/system-fields.js";
19
- import { resolveDataAspectTarget } from "../shared/aspect-target-from-tf.js";
18
+ import { ELEMENT_AUDIT_SYSTEM_FIELD_KEYS, ELEMENT_SYSTEM_FIELD_KEYS } from "../element/system-fields.js";
19
+ import { resolveDataAspectTarget, resolveDataTaskTarget } from "../shared/aspect-target-from-tf.js";
20
20
  const ELEMENT_AUDIT_SYSTEM_FIELD_KEY_SET = new Set(ELEMENT_AUDIT_SYSTEM_FIELD_KEYS);
21
+ const ELEMENT_SYSTEM_FIELD_KEY_SET = new Set(ELEMENT_SYSTEM_FIELD_KEYS);
22
+ /** A system field's authoring type, as the owner's own `fields.<key>` token carries it. */
23
+ const SYSTEM_FIELD_TYPE_BY_KEY = {
24
+ id: "HANDLE",
25
+ title: "TEXT",
26
+ status: "PICKLIST",
27
+ stage: "PICKLIST",
28
+ createdAt: "DATETIME",
29
+ createdBy: "USER",
30
+ updatedAt: "DATETIME",
31
+ updatedBy: "USER",
32
+ closedAt: "DATETIME",
33
+ closedBy: "USER",
34
+ };
21
35
  /**
22
36
  * A related_object_id/related_label_field_id value → its raw platform id, if
23
37
  * recoverable: a literal string as-is, or a `<type>.<label>.id` resource
@@ -63,12 +77,8 @@ function resolveRelatedObject(v, ctx, namespaceFallback = false) {
63
77
  return undefined;
64
78
  }
65
79
  if (v.type === "elementum_task") {
66
- const attrs = ctx.dataAttrs?.("elementum_task", v.label);
67
- const namespace = typeof attrs?.namespace === "string" ? attrs.namespace : undefined;
68
- const name = ctx.dataName("elementum_task", v.label) ?? (typeof attrs?.name === "string" ? attrs.name : undefined);
69
- const refName = namespace !== undefined ? ctx.foreignTaskRefNamespaces?.get(namespace) : name !== undefined ? ctx.foreignTaskRefNames?.get(name) : undefined;
70
- const finalRefName = refName ?? tfLabelToTsLabel(v.label);
71
- return { __kind: "task", refName: finalRefName, name: name ?? finalRefName, ...(namespace !== undefined ? { namespace } : {}) };
80
+ const task = resolveDataTaskTarget(ctx, v.label);
81
+ return { __kind: "task", refName: task.key, name: task.name, ...(task.namespace !== undefined ? { namespace: task.namespace } : {}) };
72
82
  }
73
83
  return undefined;
74
84
  }
@@ -158,15 +168,75 @@ function selfRelatedField(v, owner, ctx) {
158
168
  ...(fieldType !== undefined ? { fieldType } : {}),
159
169
  };
160
170
  }
171
+ /**
172
+ * One of the owner's own system fields (Title, ID, …), named by a
173
+ * self-sourced Dropdown's config (edk#1749). The export writes these as the
174
+ * owner's `local.<owner>_<key>_field_id`, or keeps the raw platform id, which
175
+ * pull resolves through the live system-field read (#1704). Either way the
176
+ * build writes the local back. Only for a Dropdown whose source is the owner:
177
+ * every field such a config names belongs to its source.
178
+ */
179
+ function selfSystemField(v, owner, ctx) {
180
+ const self = selfIdentity(owner, ctx);
181
+ if (self === undefined || v === undefined || owner.refName === undefined)
182
+ return undefined;
183
+ const scope = owner.scope ?? "app";
184
+ let fieldKey;
185
+ if (typeof v === "string") {
186
+ const stateRef = ctx.foreignFieldRefsById?.get(v);
187
+ if (stateRef?.ownerRefName === owner.refName)
188
+ fieldKey = stateRef.fieldKey;
189
+ }
190
+ else if (isTfExpr(v) && v.$expr === "local") {
191
+ fieldKey = fieldKeyFromTfRef(v, owner.label, scope);
192
+ }
193
+ if (fieldKey === undefined)
194
+ return undefined;
195
+ const systemKeys = scope === "element" ? ELEMENT_SYSTEM_FIELD_KEY_SET : SYSTEM_FIELD_KEY_SET;
196
+ if (!systemKeys.has(fieldKey))
197
+ return undefined;
198
+ // An element's custom field may own an audit key; build then resolves that
199
+ // key to the custom field, which would retarget this reference.
200
+ if (scope === "element" && ELEMENT_AUDIT_SYSTEM_FIELD_KEY_SET.has(fieldKey) && ownerMayHaveCustomField(owner, fieldKey, ctx))
201
+ return undefined;
202
+ // Title and ID carry their display names on the owner's own block; any
203
+ // other key (or an unrenamed one) prints the platform's deploy default.
204
+ const named = ctx.resourceByAddress?.(`${owner.type}.${owner.label}`)?.attrs?.[`${tsLabelToTfLabel(fieldKey)}_field_name`];
205
+ const fieldName = typeof named === "string" ? named : DEPLOY_DEFAULT_SYSTEM_FIELD_NAMES[fieldKey];
206
+ return {
207
+ fieldName,
208
+ ownerRefName: self.refName,
209
+ ownerKind: self.__kind,
210
+ ownerName: self.name,
211
+ ...(self.namespace !== undefined ? { ownerNamespace: self.namespace } : {}),
212
+ fieldKey,
213
+ fieldType: SYSTEM_FIELD_TYPE_BY_KEY[fieldKey],
214
+ };
215
+ }
216
+ /** Whether one of the owner's own field resources is keyed `fieldKey`; true when the stream can't be listed. */
217
+ function ownerMayHaveCustomField(owner, fieldKey, ctx) {
218
+ if (ctx.resourcesOfType === undefined)
219
+ return true;
220
+ const scope = owner.scope ?? "app";
221
+ for (const type of SUB_TYPE_BY_RESOURCE.keys()) {
222
+ for (const resource of ctx.resourcesOfType(type)) {
223
+ if (resourceRefLabel(resource.attrs["object_id"], owner.type) !== owner.label)
224
+ continue;
225
+ if (scopedLabelToBagKey(owner.label, resource.label, scope) === fieldKey)
226
+ return true;
227
+ }
228
+ }
229
+ return false;
230
+ }
161
231
  /**
162
232
  * `resolveRelatedField`, else the owner's own field as `ctx.selfAspectRef`'s
163
233
  * (clone of a self-sourced Dropdown, edk#1481). Used wherever a dynamic
164
234
  * config names a field of its source, which for a self-sourced Dropdown is
165
235
  * the owner: the label field, filter fields, sort orders and parent mappings.
166
236
  */
167
- function resolveRelatedOrSelfField(v, owner, ctx) {
237
+ function resolveRelatedOrSelfField(v, owner, ctx, selfSourced) {
168
238
  // Self first: in pull the owner's own fields also have import ids (edk#1493).
169
- return selfRelatedField(v, owner, ctx) ?? resolveRelatedField(v, ctx);
239
+ return selfRelatedField(v, owner, ctx) ?? (selfSourced ? selfSystemField(v, owner, ctx) : undefined) ?? resolveRelatedField(v, ctx);
170
240
  }
171
241
  function resolveRelatedField(v, ctx) {
172
242
  const raw = resolveRelatedId(v, ctx);
@@ -227,8 +297,8 @@ function resolveRelatedField(v, ctx) {
227
297
  * ref-only dependency data address resolves to its generated catalog member;
228
298
  * a preserved raw id remains an explicit unresolved/unsafe fallback.
229
299
  */
230
- function dynamicPicklistFilterFieldRef(value, owner, ctx) {
231
- const resolved = resolveRelatedOrSelfField(value, owner, ctx);
300
+ function dynamicPicklistFilterFieldRef(value, owner, ctx, selfSourced) {
301
+ const resolved = resolveRelatedOrSelfField(value, owner, ctx, selfSourced);
232
302
  if (typeof resolved === "string")
233
303
  return { kind: "unresolved", uuid: resolved, hint: "field" };
234
304
  if (resolved !== undefined) {
@@ -346,8 +416,10 @@ function dynamicConfigFromTf(value, owner, ctx, site) {
346
416
  return undefined;
347
417
  }
348
418
  const attrs = value;
349
- const relatedAspectId = selfRelatedObject(attrs["related_aspect_id"], owner, ctx) ?? resolveRelatedObject(attrs["related_aspect_id"], ctx, /* namespaceFallback (#1440) */ true);
350
- const relatedLabelFieldId = resolveRelatedOrSelfField(attrs["related_label_field_id"], owner, ctx);
419
+ const selfSource = selfRelatedObject(attrs["related_aspect_id"], owner, ctx);
420
+ const selfSourced = selfSource !== undefined;
421
+ const relatedAspectId = selfSource ?? resolveRelatedObject(attrs["related_aspect_id"], ctx, /* namespaceFallback (#1440) */ true);
422
+ const relatedLabelFieldId = resolveRelatedOrSelfField(attrs["related_label_field_id"], owner, ctx, selfSourced);
351
423
  if (relatedAspectId === undefined || relatedLabelFieldId === undefined) {
352
424
  const missing = [
353
425
  relatedAspectId === undefined && "related_aspect_id",
@@ -369,7 +441,7 @@ function dynamicConfigFromTf(value, owner, ctx, site) {
369
441
  if (attrs["filter"] !== undefined) {
370
442
  try {
371
443
  filter = deserializeFilterFromTf(attrs["filter"], {
372
- field: (v) => dynamicPicklistFilterFieldRef(v, owner, ctx),
444
+ field: (v) => dynamicPicklistFilterFieldRef(v, owner, ctx, selfSourced),
373
445
  recordField: (v) => dynamicPicklistRecordFieldRef(v, owner, ctx),
374
446
  recordFieldOwner: (v) => resourceRefLabel(v, owner.type) === owner.label,
375
447
  reference: () => {
@@ -406,7 +478,7 @@ function dynamicConfigFromTf(value, owner, ctx, site) {
406
478
  unresolvedField = true;
407
479
  return rawOrder;
408
480
  }
409
- const resolved = resolveRelatedOrSelfField(field, owner, ctx);
481
+ const resolved = resolveRelatedOrSelfField(field, owner, ctx, selfSourced);
410
482
  if (resolved === undefined)
411
483
  unresolvedField = true;
412
484
  return resolved === undefined ? rawOrder : { ...order, field: resolved };
@@ -439,8 +511,8 @@ function dynamicConfigFromTf(value, owner, ctx, site) {
439
511
  // Dropdown's sources), so resolve them like related_label_field_id:
440
512
  // raw/imported id, else the foreign data.elementum_field identity (#1404),
441
513
  // else (clone) the owner's own field (edk#1481).
442
- const parentAspectFieldId = resolveRelatedOrSelfField(mapping["parent_aspect_field_id"], owner, ctx);
443
- const relatedAspectFieldId = resolveRelatedOrSelfField(mapping["related_aspect_field_id"], owner, ctx);
514
+ const parentAspectFieldId = resolveRelatedOrSelfField(mapping["parent_aspect_field_id"], owner, ctx, selfSourced);
515
+ const relatedAspectFieldId = resolveRelatedOrSelfField(mapping["related_aspect_field_id"], owner, ctx, selfSourced);
444
516
  if (parentAspectFieldId === undefined || relatedAspectFieldId === undefined) {
445
517
  blockUnclearableParentMappings(ctx, site);
446
518
  parentMappings = undefined;
@@ -693,6 +765,7 @@ export function fieldFromTf(block, owner, ctx) {
693
765
  }
694
766
  }
695
767
  const scope = owner.scope ?? "app";
768
+ const allowList = allowListFromTf(subType.typeKey, attrs, owner, ctx, { address: `${block.type}.${fieldLabel}`, where });
696
769
  const calculation = subType.typeKey === "calculated" ? optionalString(attrs, "calculation", where, ctx) : undefined;
697
770
  if (subType.typeKey === "calculated" && calculation === undefined) {
698
771
  blockUnextractableField(ctx, { address: `${block.type}.${fieldLabel}`, where }, "calculation is missing", MALFORMED_FIELD_REMEDY);
@@ -753,8 +826,93 @@ export function fieldFromTf(block, owner, ctx) {
753
826
  ...(autoRelate !== undefined && { autoRelate }),
754
827
  ...(numericFormat !== undefined && { numericFormat }),
755
828
  ...(decimalPlaces !== undefined && { decimalPlaces }),
829
+ ...(allowList.allowedGroups !== undefined && { allowedGroups: allowList.allowedGroups }),
830
+ ...(allowList.allowedUsers !== undefined && { allowedUsers: allowList.allowedUsers }),
756
831
  },
832
+ ...(allowList.parentGroupFieldKey !== undefined && { parentGroupFieldKey: allowList.parentGroupFieldKey }),
833
+ };
834
+ }
835
+ /**
836
+ * Group/user field pick-list restrictions (edk#1776). Each principal must
837
+ * decode to a portable identity (a group name lookup, a user email lookup, a
838
+ * same-owner group field). One that does not is an authoring blocker, never
839
+ * dropped: printing the rest would let the next apply broaden who can be
840
+ * picked, or plan an error over the live restriction.
841
+ */
842
+ function compareText(a, b) {
843
+ return a < b ? -1 : a > b ? 1 : 0;
844
+ }
845
+ function allowListFromTf(typeKey, attrs, owner, ctx, site) {
846
+ if (typeKey !== "group" && typeKey !== "user")
847
+ return {};
848
+ const remedy = "Give each restricted group a unique name and make sure each restricted user has an email (or remove that entry from the field's " +
849
+ "restriction in the Elementum UI), then pull again.";
850
+ const block = (attr, reason) => {
851
+ reportAuthoringBlocker(ctx, {
852
+ address: site.address,
853
+ description: `${site.where}: ${attr} ${reason}; leaving it out would remove part of the live pick-list restriction.`,
854
+ remedy,
855
+ });
757
856
  };
857
+ const out = {};
858
+ const groups = attrs["allowed_group_ids"];
859
+ if (groups !== undefined) {
860
+ if (!Array.isArray(groups))
861
+ block("allowed_group_ids", "is not a list");
862
+ else {
863
+ const list = [];
864
+ for (const value of groups) {
865
+ const label = dataRefLabel(value, "elementum_group");
866
+ const name = label === undefined ? undefined : ctx.dataName("elementum_group", label);
867
+ if (label === undefined || name === undefined || name.trim() === "") {
868
+ block("allowed_group_ids", "has a group without a portable name lookup");
869
+ continue;
870
+ }
871
+ list.push({ __kind: "group", refName: groupCatalogKey(ctx, label, name), name });
872
+ }
873
+ // Print in a portable order (org.ts key, then name), never platform-id
874
+ // order: ids differ per org, so id order would reprint differently there.
875
+ out.allowedGroups = list.sort((a, b) => compareText(a.refName, b.refName) || compareText(a.name ?? "", b.name ?? ""));
876
+ }
877
+ }
878
+ const users = attrs["allowed_user_ids"];
879
+ if (users !== undefined) {
880
+ if (typeKey !== "user")
881
+ block("allowed_user_ids", "is set on a group field");
882
+ else if (!Array.isArray(users))
883
+ block("allowed_user_ids", "is not a list");
884
+ else {
885
+ const list = [];
886
+ for (const value of users) {
887
+ const label = dataRefLabel(value, "elementum_user");
888
+ const email = label === undefined ? undefined : ctx.dataName("elementum_user", label)?.trim();
889
+ if (email === undefined || !/^[^\s@]+@[^\s@]+$/.test(email)) {
890
+ block("allowed_user_ids", "has a user without a portable email lookup");
891
+ continue;
892
+ }
893
+ list.push({ __kind: "user", email });
894
+ }
895
+ out.allowedUsers = list.sort((a, b) => compareText(a.email, b.email));
896
+ }
897
+ }
898
+ const parent = attrs["parent_group_field_id"];
899
+ if (parent !== undefined) {
900
+ if (typeKey !== "user")
901
+ block("parent_group_field_id", "is set on a group field");
902
+ else if (parent === "")
903
+ out.parentGroupFieldKey = null;
904
+ else {
905
+ const isGroupFieldRef = isTfExpr(parent) && parent.$expr === "resource-attr" && parent.type === "elementum_group_field";
906
+ const key = typeof parent === "string" || isGroupFieldRef
907
+ ? fieldKeyFromTfValue(parent, owner.refName ?? "", owner.label, owner.scope ?? "app", ctx)
908
+ : undefined;
909
+ if (key === undefined)
910
+ block("parent_group_field_id", "does not resolve to a group field on the same app or element");
911
+ else
912
+ out.parentGroupFieldKey = key;
913
+ }
914
+ }
915
+ return out;
758
916
  }
759
917
  /**
760
918
  * `<resourceType>.<tfLabel>.id` → the field's bag key — shared by anything
@@ -1,6 +1,7 @@
1
1
  /** The field entity's registry entry (see src/graph/). */
2
2
  import { asNamedRef, namedFactoryEntry } from "../../catalog/render-helpers.js";
3
3
  import { NO_CANVAS, NO_CATALOG, NO_DATA, NO_LIFECYCLE } from "../../graph/types.js";
4
+ import { managedFieldOrderStateAdoption } from "./order.js";
4
5
  import { FIELD_SUB_TYPES, MANAGED_FIELD_ORDER_RESOURCE_TYPE } from "./types.js";
5
6
  export const FIELD_DATA_RESOURCE_TYPE = "elementum_field";
6
7
  export const fieldModule = {
@@ -90,4 +91,5 @@ export const managedFieldOrderModule = {
90
91
  lifecycle: NO_LIFECYCLE,
91
92
  canvas: NO_CANVAS,
92
93
  catalog: NO_CATALOG,
94
+ stateAdoption: managedFieldOrderStateAdoption,
93
95
  };
@@ -16,6 +16,8 @@ export interface PicklistValueWire {
16
16
  readonly icon?: string;
17
17
  readonly active?: boolean;
18
18
  readonly relatedParentValues?: unknown;
19
+ /** Stage options only: explicit Terraform stage alias (AppStageOption.key). */
20
+ readonly __stageKey?: string;
19
21
  }
20
22
  export declare function picklistLabel(pv: PicklistValueWire): string;
21
23
  export declare const KNOWN_OPTION_TAGS: ReadonlySet<PicklistOptionTag>;
@@ -6,6 +6,7 @@
6
6
  */
7
7
  import { type TfBlock, type TfExpr } from "../../engine/tf/index.js";
8
8
  import { type FieldOwnerScope } from "../../engine/tf/labels.js";
9
+ import type { StateAdoptionFacet } from "../../graph/types.js";
9
10
  /** The owner's field order block, or undefined when it has no field resource. `fieldAddresses` iterates in authored order. */
10
11
  export declare function managedFieldOrderToTf(ownerTfLabel: string, scope: FieldOwnerScope, objectId: TfExpr, fieldAddresses: ReadonlyMap<string, string>): TfBlock | undefined;
11
12
  /**
@@ -14,3 +15,11 @@ export declare function managedFieldOrderToTf(ownerTfLabel: string, scope: Field
14
15
  * Fields it doesn't list keep their relative order after the listed ones.
15
16
  */
16
17
  export declare function inManagedFieldOrder(fieldBlocks: readonly TfBlock[], orderBlocks: readonly TfBlock[]): readonly TfBlock[];
18
+ /**
19
+ * #1699: a workspace pulled before #1677 has no field order state, so the
20
+ * built order would plan a hidden create (a live reorder). When the owner is
21
+ * in state but its order isn't, import the live order (keyed by the owner's
22
+ * id, like the provider's ImportState); the plan then shows any reorder as a
23
+ * visible in-place `field_ids` update.
24
+ */
25
+ export declare const managedFieldOrderStateAdoption: StateAdoptionFacet;
@@ -39,3 +39,36 @@ export function inManagedFieldOrder(fieldBlocks, orderBlocks) {
39
39
  const at = (block) => position.get(`${block.type}.${block.label}`) ?? Number.MAX_SAFE_INTEGER;
40
40
  return [...fieldBlocks].sort((a, b) => at(a) - at(b));
41
41
  }
42
+ /**
43
+ * #1699: a workspace pulled before #1677 has no field order state, so the
44
+ * built order would plan a hidden create (a live reorder). When the owner is
45
+ * in state but its order isn't, import the live order (keyed by the owner's
46
+ * id, like the provider's ImportState); the plan then shows any reorder as a
47
+ * visible in-place `field_ids` update.
48
+ */
49
+ export const managedFieldOrderStateAdoption = {
50
+ importsFor(blocks, state) {
51
+ const out = [];
52
+ for (const block of blocks) {
53
+ if (block.kind !== "resource" || block.type !== MANAGED_FIELD_ORDER_RESOURCE_TYPE || block.label === undefined)
54
+ continue;
55
+ if (state.has(block.type, block.label))
56
+ continue;
57
+ const owner = block.attrs["object_id"];
58
+ if (!isTfExpr(owner) || owner.$expr !== "resource-attr")
59
+ continue;
60
+ const id = state.idOf(owner.type, owner.label);
61
+ if (id !== undefined)
62
+ out.push({ type: block.type, label: block.label, id });
63
+ }
64
+ return out;
65
+ },
66
+ warning(imports) {
67
+ const names = imports.slice(0, 5).map((i) => i.label).join(", ");
68
+ const more = imports.length > 5 ? `, … (+${imports.length - 5} more)` : "";
69
+ return [
70
+ `${imports.length} owner(s) have no ${MANAGED_FIELD_ORDER_RESOURCE_TYPE} state (workspace pulled before field order was managed): ${names}${more}.`,
71
+ "Importing their live field order; any field_ids change in the plan is a real reorder. Re-pull before applying to keep the live order.",
72
+ ].join("\n");
73
+ },
74
+ };
@@ -116,6 +116,12 @@ export interface FieldInnerWire {
116
116
  readonly decimalPlaces?: number;
117
117
  /** Attachment fields only — allowed MIME types. Omitted from HCL when unset or empty. */
118
118
  readonly mediaTypes?: readonly string[];
119
+ /** Group/user fields only (edk#1776) — slim `org.groups` tokens. `[]` is an explicit clear. */
120
+ readonly allowedGroups?: readonly unknown[];
121
+ /** User fields only — `userRef(email)` tokens. `[]` is an explicit clear. */
122
+ readonly allowedUsers?: readonly unknown[];
123
+ /** User fields only — a same-owner group field token; `null` is an explicit clear. */
124
+ readonly parentGroupField?: FieldTokenWire | null;
119
125
  }
120
126
  export interface FieldToTfOptions {
121
127
  /** The owning stream root's terraform label (namespace). */
@@ -611,6 +611,7 @@ export function fieldToTf(typeKey, inner, opts) {
611
611
  if (inner.tags !== undefined && inner.tags.length > 0) {
612
612
  attrs["field_role"] = [...inner.tags];
613
613
  }
614
+ allowListToTf(subType.typeKey, inner, opts, attrs, name);
614
615
  if (inner.mediaTypes !== undefined) {
615
616
  if (subType.typeKey !== "attachment") {
616
617
  diagnostics.push(`field "${name}": mediaTypes is only valid on attachment fields; dropped`);
@@ -714,6 +715,92 @@ export function fieldToTf(typeKey, inner, opts) {
714
715
  const block = { kind: "resource", type: subType.resourceType, label: tfLabel, attrs };
715
716
  return { block, bagKey, address: `${subType.resourceType}.${tfLabel}` };
716
717
  }
718
+ /**
719
+ * Group/user field pick-list restrictions (edk#1776) → `allowed_group_ids`,
720
+ * `allowed_user_ids`, `parent_group_field_id`. Fail closed: a principal that
721
+ * does not resolve throws instead of being dropped, since dropping one entry
722
+ * would broaden who can be picked. `[]` and a null parent are emitted as the
723
+ * provider's explicit clear values (`[]` / `""`); an unset option emits
724
+ * nothing, and the provider rejects that plan when the live field still has
725
+ * a restriction.
726
+ */
727
+ function allowListToTf(typeKey, inner, opts, attrs, name) {
728
+ const where = `field "${name}"`;
729
+ const groupOrUser = typeKey === "group" || typeKey === "user";
730
+ if (!groupOrUser) {
731
+ if (inner.allowedGroups !== undefined || inner.allowedUsers !== undefined || inner.parentGroupField !== undefined) {
732
+ throw new EntityTfError(`${where}: allowedGroups, allowedUsers and parentGroupField are only valid on group and user fields`);
733
+ }
734
+ return;
735
+ }
736
+ if (typeKey === "group" && (inner.allowedUsers !== undefined || inner.parentGroupField !== undefined)) {
737
+ throw new EntityTfError(`${where}: allowedUsers and parentGroupField are only valid on user fields`);
738
+ }
739
+ if (inner.allowedGroups !== undefined) {
740
+ if (!Array.isArray(inner.allowedGroups))
741
+ throw new EntityTfError(`${where}: allowedGroups must be a list of org.groups references`);
742
+ if (inner.allowedGroups.length > 0 && opts.orgRefs === undefined) {
743
+ throw new EntityTfError(`${where}: allowedGroups needs org context to resolve org.groups references`);
744
+ }
745
+ const seen = new Set();
746
+ attrs["allowed_group_ids"] = inner.allowedGroups.flatMap((entry) => {
747
+ const token = entry;
748
+ if (token === null || typeof token !== "object" || token.__kind !== "group" || typeof token.refName !== "string" || token.refName === "") {
749
+ throw new EntityTfError(`${where}: allowedGroups requires org.groups references; raw ids and other principals are unsupported`);
750
+ }
751
+ if (seen.has(token.refName))
752
+ return [];
753
+ seen.add(token.refName);
754
+ const resolved = opts.orgRefs.byTsLabel("groups", token.refName);
755
+ if (resolved === undefined)
756
+ throw new EntityTfError(`${where}: allowedGroups group ${JSON.stringify(token.refName)} is not in org.ts; run \`elementum pull org --data-only\``);
757
+ return [resolved.managed
758
+ ? expr.resourceAttr("elementum_group", resolved.tfLabel, ["id"])
759
+ : expr.dataAttr("elementum_group", resolved.tfLabel, ["id"])];
760
+ });
761
+ }
762
+ if (inner.allowedUsers !== undefined) {
763
+ if (!Array.isArray(inner.allowedUsers))
764
+ throw new EntityTfError(`${where}: allowedUsers must be a list of userRef(email) references`);
765
+ if (inner.allowedUsers.length > 0 && opts.orgRefs === undefined) {
766
+ throw new EntityTfError(`${where}: allowedUsers needs org context to write user lookups`);
767
+ }
768
+ const seen = new Set();
769
+ attrs["allowed_user_ids"] = inner.allowedUsers.flatMap((entry) => {
770
+ const user = entry;
771
+ if (user === null || typeof user !== "object" || user.__kind !== "user" || typeof user.email !== "string" || !/^[^\s@]+@[^\s@]+$/.test(user.email)) {
772
+ throw new EntityTfError(`${where}: allowedUsers requires userRef(email); raw ids and other principals are unsupported`);
773
+ }
774
+ if (seen.has(user.email))
775
+ return [];
776
+ seen.add(user.email);
777
+ // The whole email names the lookup, as ei's export does, so two users
778
+ // sharing a local part never share one data address.
779
+ const label = sanitizeName(user.email);
780
+ if (label === "")
781
+ throw new EntityTfError(`${where}: allowedUsers email ${JSON.stringify(user.email)} has no usable lookup label`);
782
+ opts.orgRefs.rawLookup("elementum_user", label, user.email);
783
+ return [expr.dataAttr("elementum_user", label, ["id"])];
784
+ });
785
+ }
786
+ if (inner.parentGroupField !== undefined) {
787
+ if (inner.parentGroupField === null) {
788
+ attrs["parent_group_field_id"] = "";
789
+ return;
790
+ }
791
+ const token = inner.parentGroupField;
792
+ if (typeof token !== "object" || token.__kind !== "field" || (token.fieldType !== "GROUP" && token.fieldType !== "GROUP_ID")) {
793
+ throw new EntityTfError(`${where}: parentGroupField must reference a group field on the same app or element`);
794
+ }
795
+ if (token.parent !== undefined && token.parent !== opts.appRefName) {
796
+ throw new EntityTfError(`${where}: parentGroupField must belong to the same app or element, not ${JSON.stringify(token.parent)}`);
797
+ }
798
+ const value = fieldRefToTfValue(token.fieldType, token.refName ?? "", opts.ownerTfLabel, opts.scope ?? "app", opts.fieldOwnership);
799
+ if (value === undefined)
800
+ throw new EntityTfError(`${where}: parentGroupField ${JSON.stringify(token.refName ?? "")} does not resolve to a group field resource`);
801
+ attrs["parent_group_field_id"] = value;
802
+ }
803
+ }
717
804
  /**
718
805
  * Attachment `media_types`. An unset or empty list stays omitted so a field
719
806
  * without a restriction keeps its previous HCL. A value that is not
@@ -76,6 +76,9 @@ export const KNOWN_FIELD_ATTRS = new Set([
76
76
  "include_type",
77
77
  "picklist_field_id",
78
78
  "media_types",
79
+ "allowed_group_ids",
80
+ "allowed_user_ids",
81
+ "parent_group_field_id",
79
82
  ]);
80
83
  /** Authoring constructor base name (`richText` for `richTextField`) → FIELD_SUB_TYPES typeKey. */
81
84
  const FIELD_CTOR_TYPE_KEYS = {
@@ -1,7 +1,7 @@
1
- import type { AppOrElementRef, FieldRef, RecordIdentityRef, TableColumnRef, TableRef } from "../../catalog/index.js";
1
+ import type { AppOrElementOrTaskRef, FieldRef, RecordIdentityRef, TableColumnRef, TableRef } from "../../catalog/index.js";
2
2
  import type { Filter } from "../shared/filters/types.js";
3
3
  import type { AppViewFieldRef } from "../app/build.js";
4
- export interface AppRelationshipColumn<Target extends AppOrElementRef | TableRef = AppOrElementRef | TableRef> {
4
+ export interface AppRelationshipColumn<Target extends AppOrElementOrTaskRef | TableRef = AppOrElementOrTaskRef | TableRef> {
5
5
  /**
6
6
  * Field on the owning app/element. System `"id"` is HANDLE (the record
7
7
  * handle), not the record UUID. AutoRelation create rejects HANDLE joined
@@ -26,7 +26,7 @@ export interface AppRelationshipColumn<Target extends AppOrElementRef | TableRef
26
26
  * A child `relationField` / `autoRelate` is an instance link, not a substitute
27
27
  * for a join owned here, and does not populate a parent `relatedRecords` widget.
28
28
  */
29
- export interface AppRelationship<Target extends AppOrElementRef | TableRef = AppOrElementRef | TableRef> {
29
+ export interface AppRelationship<Target extends AppOrElementOrTaskRef | TableRef = AppOrElementOrTaskRef | TableRef> {
30
30
  readonly target: Target;
31
31
  readonly columns: readonly AppRelationshipColumn<Target>[];
32
32
  /** Uses the same typed filter DSL as access policies. */
@@ -2,7 +2,7 @@ import { dataRefLabel, resourceRefLabel } from "../../engine/pull/context.js";
2
2
  import { isTfExpr, scopedLabelToBagKey, tfLabelToTsLabel, } from "../../engine/tf/index.js";
3
3
  import { filterFromTf } from "../access-policy/from-tf.js";
4
4
  import { decodeForeignDataField, fieldKeyFromTfRef, fieldKeyFromTfValue } from "../field/from-tf.js";
5
- import { resolveDataAspectTarget } from "../shared/aspect-target-from-tf.js";
5
+ import { resolveDataAspectTarget, resolveDataTaskTarget } from "../shared/aspect-target-from-tf.js";
6
6
  import { SUB_TYPE_BY_RESOURCE } from "../field/types.js";
7
7
  import { RELATIONSHIP_RESOURCE_TYPE } from "./module.js";
8
8
  const KNOWN_ATTRS = new Set(["object_id", "related_object_id", "columns", "filter"]);
@@ -145,7 +145,9 @@ function targetRef(value, owner, ctx) {
145
145
  return { kind, key: tfLabelToTsLabel(resourceLabel), name: tfLabelToTsLabel(resourceLabel), tfLabel: resourceLabel, managed: true };
146
146
  const dataLabel = dataRefLabel(value, type);
147
147
  if (dataLabel !== undefined) {
148
- if (kind === "app" || kind === "element" || kind === "task") {
148
+ if (kind === "task")
149
+ return { kind, tfLabel: dataLabel, managed: false, ...resolveDataTaskTarget(ctx, dataLabel) };
150
+ if (kind === "app" || kind === "element") {
149
151
  return { kind, tfLabel: dataLabel, managed: false, ...resolveDataAspectTarget(ctx, kind, dataLabel) };
150
152
  }
151
153
  const name = ctx.dataName(type, dataLabel) ?? tfLabelToTsLabel(dataLabel);
@@ -189,9 +189,11 @@ function resolveRelatedField(value, target, where, opts) {
189
189
  opts.diagnostics.push(`${where}: field "${refName}" does not belong to target "${target.refName}"; dropped`);
190
190
  return undefined;
191
191
  }
192
+ // A task has no system-field locals, so only its custom fields resolve to
193
+ // their resources; its Title/ID/Status stay a lookup on the task.
192
194
  if (target.managed &&
193
195
  target.kind !== "table" &&
194
- target.kind !== "task" &&
196
+ (target.kind !== "task" || target.fieldOwnership?.has(refName) === true) &&
195
197
  target.tfLabel !== undefined) {
196
198
  const direct = fieldRefToTfValue(value?.fieldType ?? "", refName, target.tfLabel, target.kind, target.fieldOwnership);
197
199
  if (direct !== undefined)
@@ -1,4 +1,4 @@
1
- import { type WorkspaceAspect } from "../../engine/build/context.js";
1
+ import { type ForeignRootIdentity, type OrgRefLookup, type WorkspaceAspect } from "../../engine/build/context.js";
2
2
  import { type TfValue } from "../../engine/tf/index.js";
3
3
  import type { AppServiceAccount } from "./build.js";
4
4
  /** The app that owns a service account, as a role or policy on another object resolves it. */
@@ -11,6 +11,11 @@ export interface ServiceAccountOwningApp {
11
11
  * Resolve the workspace app that owns a `serviceAccountRef` named from a
12
12
  * different object (another app or an element), so its lookup is scoped to the
13
13
  * OWNING app (#1592), not the object that grants it access. A managed account
14
- * becomes a direct resource ref, so same-apply creation is sequenced.
14
+ * becomes a direct resource ref, so same-apply creation is sequenced. An app
15
+ * left out of a scoped build resolves through its `data.elementum_app` lookup,
16
+ * so the account becomes a `data.elementum_service_account` lookup (#1912).
15
17
  */
16
- export declare function workspaceServiceAccountAppResolver(workspaceAspects: ReadonlyMap<string, WorkspaceAspect> | undefined): (appRefName: string) => ServiceAccountOwningApp | undefined;
18
+ export declare function workspaceServiceAccountAppResolver(workspaceAspects: ReadonlyMap<string, WorkspaceAspect> | undefined, outOfScope?: {
19
+ readonly apps?: ReadonlyMap<string, ForeignRootIdentity>;
20
+ readonly orgRefs?: OrgRefLookup;
21
+ }): (appRefName: string) => ServiceAccountOwningApp | undefined;
@@ -1,17 +1,25 @@
1
1
  import { workspaceAspectKey } from "../../engine/build/context.js";
2
2
  import { expr } from "../../engine/tf/index.js";
3
3
  import { APP_RESOURCE_TYPE } from "../app/module.js";
4
+ import { resolveForeignRef } from "../shared/foreign-ref.js";
4
5
  /**
5
6
  * Resolve the workspace app that owns a `serviceAccountRef` named from a
6
7
  * different object (another app or an element), so its lookup is scoped to the
7
8
  * OWNING app (#1592), not the object that grants it access. A managed account
8
- * becomes a direct resource ref, so same-apply creation is sequenced.
9
+ * becomes a direct resource ref, so same-apply creation is sequenced. An app
10
+ * left out of a scoped build resolves through its `data.elementum_app` lookup,
11
+ * so the account becomes a `data.elementum_service_account` lookup (#1912).
9
12
  */
10
- export function workspaceServiceAccountAppResolver(workspaceAspects) {
13
+ export function workspaceServiceAccountAppResolver(workspaceAspects, outOfScope) {
11
14
  return (appRefName) => {
12
15
  const app = workspaceAspects?.get(workspaceAspectKey("app", appRefName));
13
- if (app === undefined)
14
- return undefined;
16
+ if (app === undefined) {
17
+ const identity = outOfScope?.apps?.get(appRefName);
18
+ if (identity === undefined || outOfScope?.orgRefs === undefined)
19
+ return undefined;
20
+ const foreign = resolveForeignRef("app", identity, outOfScope.orgRefs);
21
+ return { appTfLabel: foreign.tfLabel, appId: foreign.value };
22
+ }
15
23
  const serviceAccounts = app.streamRootEntity?.payload?.serviceAccounts;
16
24
  return {
17
25
  appTfLabel: app.tfLabel,
@@ -7,6 +7,11 @@ import type { FromTfContext } from "../../engine/pull/context.js";
7
7
  export declare function dataAspectDisplayName(ctx: FromTfContext, kind: "app" | "element" | "task", label: string): string | undefined;
8
8
  /** Resolve the stable pulled catalog key for the same foreign lookup. */
9
9
  export declare function dataAspectRefName(ctx: FromTfContext, kind: "app" | "element" | "task", label: string, displayName?: string): string | undefined;
10
+ /**
11
+ * Resolve a foreign task data lookup to the task on disk. ei names a task by
12
+ * display name (or namespace) only, so its label is just the fallback key.
13
+ */
14
+ export declare function resolveDataTaskTarget(ctx: FromTfContext, dataLabel: string): ResolvedAspectTarget;
10
15
  export interface ResolvedAspectTarget {
11
16
  readonly key: string;
12
17
  readonly name: string;
@@ -45,6 +45,19 @@ export function dataAspectRefName(ctx, kind, label, displayName) {
45
45
  // ElementResourceName), so the namespace alone gives the real refName before the target is pulled.
46
46
  return pulled ?? (namespace === undefined ? undefined : tfLabelToTsLabel(sanitizeName(namespace)));
47
47
  }
48
+ /**
49
+ * Resolve a foreign task data lookup to the task on disk. ei names a task by
50
+ * display name (or namespace) only, so its label is just the fallback key.
51
+ */
52
+ export function resolveDataTaskTarget(ctx, dataLabel) {
53
+ const attrs = ctx.dataAttrs?.("elementum_task", dataLabel);
54
+ const namespace = typeof attrs?.namespace === "string" ? attrs.namespace : undefined;
55
+ const name = ctx.dataName("elementum_task", dataLabel) ?? (typeof attrs?.name === "string" ? attrs.name : undefined);
56
+ const refName = (namespace !== undefined ? ctx.foreignTaskRefNamespaces?.get(namespace) : undefined)
57
+ ?? (name !== undefined ? ctx.foreignTaskRefNames?.get(name) : undefined);
58
+ const key = refName ?? tfLabelToTsLabel(dataLabel);
59
+ return { key, name: name ?? key, ...(namespace !== undefined ? { namespace } : {}), catalogRef: true };
60
+ }
48
61
  /**
49
62
  * Resolve a foreign app/element data lookup to the full identity a caller
50
63
  * needs to build its own ref shape: the real display name/refName when the