@elementumai/edk 0.13.3 → 0.14.0

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 (140) hide show
  1. package/dist-sdk/src/catalog/factories.d.ts +4 -2
  2. package/dist-sdk/src/catalog/factories.js +3 -1
  3. package/dist-sdk/src/catalog/from-authoring.d.ts +8 -3
  4. package/dist-sdk/src/catalog/from-authoring.js +21 -8
  5. package/dist-sdk/src/engine/build/context.d.ts +17 -0
  6. package/dist-sdk/src/engine/coverage-gaps.d.ts +13 -0
  7. package/dist-sdk/src/engine/coverage-gaps.js +21 -0
  8. package/dist-sdk/src/engine/pull/context.d.ts +57 -1
  9. package/dist-sdk/src/engine/pull/context.js +9 -1
  10. package/dist-sdk/src/engine/pull/pulled-roots.d.ts +14 -1
  11. package/dist-sdk/src/engine/pull/pulled-roots.js +23 -3
  12. package/dist-sdk/src/engine/pull/ref-only.d.ts +6 -1
  13. package/dist-sdk/src/engine/pull/ref-only.js +4 -1
  14. package/dist-sdk/src/engine/pull/stream-root.d.ts +17 -1
  15. package/dist-sdk/src/engine/pull/stream-root.js +57 -4
  16. package/dist-sdk/src/engine/tf/index.d.ts +1 -0
  17. package/dist-sdk/src/engine/tf/index.js +1 -0
  18. package/dist-sdk/src/engine/tf/jsonencode.d.ts +19 -0
  19. package/dist-sdk/src/engine/tf/jsonencode.js +49 -0
  20. package/dist-sdk/src/engine/validation.d.ts +36 -1
  21. package/dist-sdk/src/engine/validation.js +56 -2
  22. package/dist-sdk/src/engine/workspace/loader.d.ts +6 -0
  23. package/dist-sdk/src/engine/workspace/loader.js +87 -2
  24. package/dist-sdk/src/entities/access-policy/from-tf.d.ts +7 -0
  25. package/dist-sdk/src/entities/access-policy/from-tf.js +58 -17
  26. package/dist-sdk/src/entities/access-policy/to-tf.d.ts +3 -1
  27. package/dist-sdk/src/entities/access-policy/to-tf.js +1 -1
  28. package/dist-sdk/src/entities/agent/build.d.ts +15 -0
  29. package/dist-sdk/src/entities/agent/build.js +139 -16
  30. package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.d.ts +3 -3
  31. package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +39 -25
  32. package/dist-sdk/src/entities/agent/module.js +95 -3
  33. package/dist-sdk/src/entities/agent/to-tf.js +6 -4
  34. package/dist-sdk/src/entities/agent-evaluation/from-tf.d.ts +7 -0
  35. package/dist-sdk/src/entities/agent-evaluation/from-tf.js +14 -5
  36. package/dist-sdk/src/entities/agent-evaluation/module.js +4 -2
  37. package/dist-sdk/src/entities/agent-tool/from-tf.d.ts +11 -2
  38. package/dist-sdk/src/entities/agent-tool/from-tf.js +38 -40
  39. package/dist-sdk/src/entities/agent-tool/to-tf.js +12 -5
  40. package/dist-sdk/src/entities/app/build.d.ts +1 -1
  41. package/dist-sdk/src/entities/app/index.d.ts +1 -1
  42. package/dist-sdk/src/entities/automation/approval-trigger-refs.d.ts +20 -0
  43. package/dist-sdk/src/entities/automation/approval-trigger-refs.js +83 -0
  44. package/dist-sdk/src/entities/automation/build.d.ts +75 -42
  45. package/dist-sdk/src/entities/automation/build.js +18 -8
  46. package/dist-sdk/src/entities/automation/deserializer/ast.d.ts +14 -2
  47. package/dist-sdk/src/entities/automation/deserializer/print-automation.d.ts +9 -0
  48. package/dist-sdk/src/entities/automation/deserializer/print-automation.js +64 -12
  49. package/dist-sdk/src/entities/automation/from-tf.d.ts +53 -0
  50. package/dist-sdk/src/entities/automation/from-tf.js +579 -106
  51. package/dist-sdk/src/entities/automation/index.d.ts +2 -2
  52. package/dist-sdk/src/entities/automation/index.js +1 -1
  53. package/dist-sdk/src/entities/automation/lookup-owner.d.ts +23 -0
  54. package/dist-sdk/src/entities/automation/lookup-owner.js +27 -0
  55. package/dist-sdk/src/entities/automation/module.js +265 -26
  56. package/dist-sdk/src/entities/automation/operators.d.ts +6 -2
  57. package/dist-sdk/src/entities/automation/operators.js +0 -2
  58. package/dist-sdk/src/entities/automation/task-output-labels.d.ts +8 -0
  59. package/dist-sdk/src/entities/automation/task-output-labels.js +11 -0
  60. package/dist-sdk/src/entities/automation/tasks.d.ts +37 -2
  61. package/dist-sdk/src/entities/automation/tasks.js +38 -1
  62. package/dist-sdk/src/entities/automation/to-tf.d.ts +8 -0
  63. package/dist-sdk/src/entities/automation/to-tf.js +576 -52
  64. package/dist-sdk/src/entities/automation/triggers.d.ts +47 -1
  65. package/dist-sdk/src/entities/automation/unsafe-script-output.d.ts +10 -5
  66. package/dist-sdk/src/entities/automation/unsafe-script-output.js +10 -5
  67. package/dist-sdk/src/entities/chart/to-tf.js +18 -5
  68. package/dist-sdk/src/entities/dashboard/from-tf.js +45 -11
  69. package/dist-sdk/src/entities/dashboard-widget-order/order.d.ts +5 -3
  70. package/dist-sdk/src/entities/dashboard-widget-order/order.js +6 -4
  71. package/dist-sdk/src/entities/datamine/from-tf.js +10 -3
  72. package/dist-sdk/src/entities/dynamic-layout/build.d.ts +38 -11
  73. package/dist-sdk/src/entities/dynamic-layout/from-tf.js +35 -7
  74. package/dist-sdk/src/entities/dynamic-layout/to-tf.js +101 -9
  75. package/dist-sdk/src/entities/element/build.d.ts +4 -1
  76. package/dist-sdk/src/entities/element/build.js +3 -4
  77. package/dist-sdk/src/entities/element/index.d.ts +1 -1
  78. package/dist-sdk/src/entities/field/from-tf.js +8 -1
  79. package/dist-sdk/src/entities/field/to-tf.d.ts +29 -2
  80. package/dist-sdk/src/entities/field/to-tf.js +106 -7
  81. package/dist-sdk/src/entities/phone-service/from-tf.d.ts +7 -0
  82. package/dist-sdk/src/entities/phone-service/from-tf.js +15 -7
  83. package/dist-sdk/src/entities/phone-service/module.js +4 -2
  84. package/dist-sdk/src/entities/portal/to-tf.d.ts +1 -1
  85. package/dist-sdk/src/entities/portal/to-tf.js +61 -2
  86. package/dist-sdk/src/entities/record-create-form/from-tf.js +3 -1
  87. package/dist-sdk/src/entities/relationship/from-tf.js +34 -4
  88. package/dist-sdk/src/entities/relationship/to-tf.js +24 -6
  89. package/dist-sdk/src/entities/role/from-tf.js +3 -1
  90. package/dist-sdk/src/entities/search-table/from-tf.d.ts +3 -1
  91. package/dist-sdk/src/entities/search-table/from-tf.js +6 -3
  92. package/dist-sdk/src/entities/search-table/module.js +18 -2
  93. package/dist-sdk/src/entities/search-table/to-tf.js +10 -16
  94. package/dist-sdk/src/entities/shared/aspect-target-from-tf.js +6 -1
  95. package/dist-sdk/src/entities/shared/filters/ast.d.ts +6 -0
  96. package/dist-sdk/src/entities/shared/filters/index.d.ts +21 -4
  97. package/dist-sdk/src/entities/shared/filters/index.js +27 -3
  98. package/dist-sdk/src/entities/shared/filters/print.js +23 -7
  99. package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +24 -0
  100. package/dist-sdk/src/entities/shared/filters/tf-codec.js +98 -3
  101. package/dist-sdk/src/entities/shared/filters/types.d.ts +8 -1
  102. package/dist-sdk/src/entities/shared/run-automation-requirement.d.ts +15 -0
  103. package/dist-sdk/src/entities/shared/run-automation-requirement.js +28 -0
  104. package/dist-sdk/src/entities/shared/search-table-address.d.ts +17 -0
  105. package/dist-sdk/src/entities/shared/search-table-address.js +24 -0
  106. package/dist-sdk/src/entities/shared/skip-release.d.ts +49 -0
  107. package/dist-sdk/src/entities/shared/skip-release.js +74 -0
  108. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.d.ts +3 -3
  109. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +11 -5
  110. package/dist-sdk/src/entities/skill/module.js +3 -25
  111. package/dist-sdk/src/entities/skill-tool/from-tf.d.ts +4 -2
  112. package/dist-sdk/src/entities/skill-tool/from-tf.js +28 -27
  113. package/dist-sdk/src/entities/skill-tool/to-tf.js +12 -5
  114. package/dist-sdk/src/entities/skill-tool/types.d.ts +1 -0
  115. package/dist-sdk/src/entities/skill-tool/types.js +2 -1
  116. package/dist-sdk/src/entities/table/catalog.d.ts +16 -0
  117. package/dist-sdk/src/entities/table/catalog.js +44 -2
  118. package/dist-sdk/src/entities/table/from-tf.js +30 -4
  119. package/dist-sdk/src/entities/table/keys.d.ts +27 -0
  120. package/dist-sdk/src/entities/table/keys.js +46 -0
  121. package/dist-sdk/src/entities/table/to-tf.js +2 -2
  122. package/dist-sdk/src/entities/view/agent-view-layout-from-tf.d.ts +12 -1
  123. package/dist-sdk/src/entities/view/agent-view-layout-from-tf.js +9 -4
  124. package/dist-sdk/src/entities/view/agent-view-layout-to-tf.js +215 -10
  125. package/dist-sdk/src/entities/view/agent-view-layout.d.ts +10 -4
  126. package/dist-sdk/src/entities/view/custom-view-runtime-rules.d.ts +43 -0
  127. package/dist-sdk/src/entities/view/custom-view-runtime-rules.js +285 -0
  128. package/dist-sdk/src/entities/view/custom-view-validate.d.ts +3 -1
  129. package/dist-sdk/src/entities/view/custom-view-validate.js +24 -5
  130. package/dist-sdk/src/entities/view/from-tf.js +14 -1
  131. package/dist-sdk/src/entities/widget/from-tf.js +14 -7
  132. package/dist-sdk/src/entities/widget/to-tf.js +9 -6
  133. package/dist-sdk/src/generated/ragnarok/ragnarok-spec.d.ts +4 -2
  134. package/dist-sdk/src/generated/ragnarok/ragnarok-spec.js +2 -2
  135. package/dist-sdk/src/graph/index.d.ts +14 -1
  136. package/dist-sdk/src/graph/index.js +2 -0
  137. package/dist-sdk/src/graph/resource-types.d.ts +2 -0
  138. package/dist-sdk/src/graph/resource-types.js +3 -0
  139. package/dist-sdk/src/graph/types.d.ts +105 -0
  140. package/package.json +1 -1
@@ -22,12 +22,14 @@ export const agentEvaluationModule = {
22
22
  participates: true,
23
23
  extractOwnFile: (ownBlocks, _stream, ctx) => {
24
24
  const items = [];
25
+ const quarantineOwnFiles = [];
25
26
  for (const block of ownBlocks) {
26
- const evaluation = agentEvaluationFromTf(block, { appLabel: ctx.appTfLabel }, ctx);
27
+ const evaluation = agentEvaluationFromTf(block, { appLabel: ctx.appTfLabel, quarantineOwnFiles }, ctx);
27
28
  if (evaluation !== undefined)
28
29
  items.push(evaluation);
29
30
  }
30
- return { items, skipped: [], diagnostics: [] };
31
+ // A skipped one is in ctx.skipped and ctx.releaseIfManaged (skipOwnFileAndRelease).
32
+ return { items, skipped: [], diagnostics: [], ...(quarantineOwnFiles.length > 0 && { quarantineOwnFiles }) };
31
33
  },
32
34
  printOwnFile: (item, opts) => {
33
35
  const evaluation = item;
@@ -117,6 +117,13 @@ export interface NormalizedAgentTool {
117
117
  readonly handleDescription?: string;
118
118
  /** executeWorkflow: the target automation's bag key (bijective image of its tf label). */
119
119
  readonly automationKey?: string;
120
+ /**
121
+ * executeWorkflow: how the live tool is out of step with its automation in
122
+ * the export (a required parameter it doesn't map, an output the
123
+ * automation doesn't declare; edk#3230, #3231). The printer widens the
124
+ * automation ref for such a tool so the pulled file typechecks.
125
+ */
126
+ readonly staleMappings?: readonly string[];
120
127
  readonly inputs?: readonly NormalizedExecuteWorkflowInput[];
121
128
  readonly outputs?: readonly NormalizedExecuteWorkflowOutput[];
122
129
  /** Search-table bag key when the table is a pulled resource. */
@@ -156,7 +163,9 @@ export interface ToolOwner {
156
163
  readonly agentLabel: string;
157
164
  }
158
165
  /**
159
- * One tool block → its normalized shape; undefined = skipped with a
160
- * diagnostic (unimplemented sub-type, wrong owner, unresolvable target).
166
+ * One tool block → its normalized shape; undefined = skipped (unimplemented
167
+ * sub-type, wrong owner, unresolvable target). A tool written to no source
168
+ * is also left out of adoption, or released if state has it, so the next
169
+ * plan doesn't destroy it (edk#3172); skipAndRelease does both.
161
170
  */
162
171
  export declare function toolFromTf(block: TfBlock, owner: ToolOwner, ctx: FromTfContext): NormalizedAgentTool | undefined;
@@ -7,6 +7,7 @@
7
7
  import { EntityTfError } from "../../engine/entity.js";
8
8
  import { dataRefLabel, optionalString, resourceRefLabel } from "../../engine/pull/context.js";
9
9
  import { isTfExpr, sanitizeName, scopedLabelToBagKey, scopedResourceLabel, tfLabelToTsLabel, tsLabelToTfLabel } from "../../engine/tf/index.js";
10
+ import { skipAndRelease, unresolvedReferenceName } from "../shared/skip-release.js";
10
11
  import { droppedToolFieldDiagnostic, resolveToolFieldKey } from "../shared/tool-field-ref.js";
11
12
  import { dataAspectDisplayName } from "../shared/aspect-target-from-tf.js";
12
13
  import { KNOWN_TOOL_ATTRS, TOOL_SUB_TYPE_BY_RESOURCE } from "./types.js";
@@ -50,13 +51,16 @@ function runAsFromTf(attrs, owner, where, ctx) {
50
51
  return undefined;
51
52
  }
52
53
  /**
53
- * One tool block → its normalized shape; undefined = skipped with a
54
- * diagnostic (unimplemented sub-type, wrong owner, unresolvable target).
54
+ * One tool block → its normalized shape; undefined = skipped (unimplemented
55
+ * sub-type, wrong owner, unresolvable target). A tool written to no source
56
+ * is also left out of adoption, or released if state has it, so the next
57
+ * plan doesn't destroy it (edk#3172); skipAndRelease does both.
55
58
  */
56
59
  export function toolFromTf(block, owner, ctx) {
57
60
  const subType = TOOL_SUB_TYPE_BY_RESOURCE.get(block.type ?? "");
58
61
  if (subType === undefined) {
59
- ctx.diagnostics.push(`resource "${block.type}" is not a known agent tool resource; skipped`);
62
+ const fallback = `resource "${block.type}" is not a known agent tool resource; skipped`;
63
+ skipAndRelease(ctx, `${block.type}.${block.label ?? ""}`, { problem: "its resource type is not an agent tool pull knows" }, fallback);
60
64
  return undefined;
61
65
  }
62
66
  const label = block.label;
@@ -66,11 +70,19 @@ export function toolFromTf(block, owner, ctx) {
66
70
  const attrs = block.attrs;
67
71
  const name = optionalString(attrs, "name", `tool "${label}"`, ctx) ?? "";
68
72
  const where = `agent tool "${name}" (${block.type}.${label})`;
69
- if (subType.implemented !== true) {
70
- ctx.diagnostics.push(subType.typeKey === "selectBotRoute"
71
- ? `${where}: select-bot-route is a platform-internal Nexus routing tool and is not part of the public EDK; skipped`
72
- : `${where}: tool kind is not supported on the terraform path yet; skipped`);
73
+ const address = `${block.type}.${label}`;
74
+ const skipReference = (attribute, value, fallback) => {
75
+ skipAndRelease(ctx, address, { reference: unresolvedReferenceName(value, attribute) }, fallback);
76
+ return undefined;
77
+ };
78
+ const skipProblem = (problem, fallback) => {
79
+ skipAndRelease(ctx, address, { problem }, fallback);
73
80
  return undefined;
81
+ };
82
+ if (subType.implemented !== true) {
83
+ return subType.typeKey === "selectBotRoute"
84
+ ? skipProblem("select-bot-route is a platform-internal Nexus routing tool and is not part of the public EDK", `${where}: select-bot-route is a platform-internal Nexus routing tool and is not part of the public EDK; skipped`)
85
+ : skipProblem("its tool kind is not supported yet", `${where}: tool kind is not supported on the terraform path yet; skipped`);
74
86
  }
75
87
  const known = KNOWN_TOOL_ATTRS[subType.typeKey];
76
88
  for (const key of Object.keys(attrs)) {
@@ -83,7 +95,7 @@ export function toolFromTf(block, owner, ctx) {
83
95
  return undefined;
84
96
  }
85
97
  if (subType.typeKey === "executeWorkflow") {
86
- return executeWorkflowFromTf(block, name, where, owner, ctx);
98
+ return executeWorkflowFromTf(block, name, where, owner, ctx, skipReference);
87
99
  }
88
100
  const startMessage = optionalString(attrs, "start_message", where, ctx);
89
101
  const runAs = runAsFromTf(attrs, owner, where, ctx);
@@ -96,13 +108,11 @@ export function toolFromTf(block, owner, ctx) {
96
108
  if (subType.typeKey === "runAgent") {
97
109
  const targetLabel = resourceRefLabel(attrs["target_agent_id"], "elementum_agent");
98
110
  if (targetLabel === undefined) {
99
- ctx.diagnostics.push(`${where}: target_agent_id is not an elementum_agent resource reference; skipped`);
100
- return undefined;
111
+ return skipReference("target_agent_id", attrs["target_agent_id"], `${where}: target_agent_id is not an elementum_agent resource reference; skipped`);
101
112
  }
102
113
  const targetAgentKey = scopedLabelToBagKey(owner.ownerTfLabel, targetLabel);
103
114
  if (scopedResourceLabel(owner.ownerTfLabel, tsLabelToTfLabel(targetAgentKey), "app") !== targetLabel) {
104
- ctx.diagnostics.push(`${where}: cross-app run-agent targets are not supported; skipped`);
105
- return undefined;
115
+ return skipProblem(`its target agent elementum_agent.${targetLabel} is in another app, which a run-agent tool can't target`, `${where}: cross-app run-agent targets are not supported; skipped`);
106
116
  }
107
117
  return {
108
118
  typeKey: "runAgent",
@@ -115,8 +125,7 @@ export function toolFromTf(block, owner, ctx) {
115
125
  const serverUrl = optionalString(attrs, "server_url", where, ctx);
116
126
  const mcpToolName = optionalString(attrs, "mcp_tool_name", where, ctx);
117
127
  if (serverUrl === undefined || serverUrl === "" || mcpToolName === undefined || mcpToolName === "") {
118
- ctx.diagnostics.push(`${where}: server_url or mcp_tool_name is missing; skipped`);
119
- return undefined;
128
+ return skipProblem("the export gives it no server_url or mcp_tool_name", `${where}: server_url or mcp_tool_name is missing; skipped`);
120
129
  }
121
130
  const headers = [];
122
131
  const rawHeaders = attrs["headers"];
@@ -155,12 +164,11 @@ export function toolFromTf(block, owner, ctx) {
155
164
  let fieldScope = "app";
156
165
  if (targetAttr === undefined) {
157
166
  if (subType.typeKey !== "searchTable") {
158
- ctx.diagnostics.push(`${where}: target_id is missing; skipped`);
159
- return undefined;
167
+ return skipProblem("the export gives it no target_id", `${where}: target_id is missing; skipped`);
160
168
  }
161
169
  }
162
170
  else {
163
- const resolved = aspectTargetFromTf(targetAttr, "target_id", owner, ctx, where);
171
+ const resolved = aspectTargetFromTf(targetAttr, "target_id", owner, ctx, where, skipReference);
164
172
  if (resolved === undefined)
165
173
  return undefined;
166
174
  target = resolved.target;
@@ -333,8 +341,7 @@ export function toolFromTf(block, owner, ctx) {
333
341
  }
334
342
  }
335
343
  if (searchTableName === undefined) {
336
- ctx.diagnostics.push(`${where}: search_table_id references data.${value.type}.${value.label} without a matching name lookup; skipped`);
337
- return undefined;
344
+ return skipReference("search_table_id", value, `${where}: search_table_id references data.${value.type}.${value.label} without a matching name lookup; skipped`);
338
345
  }
339
346
  }
340
347
  else if (typeof value === "string" && value !== "") {
@@ -352,14 +359,13 @@ export function toolFromTf(block, owner, ctx) {
352
359
  searchTableRawId = value;
353
360
  }
354
361
  else {
355
- ctx.diagnostics.push(`${where}: search_table_id is not a supported search-table reference; skipped`);
356
- return undefined;
362
+ return skipReference("search_table_id", value, `${where}: search_table_id is not a supported search-table reference; skipped`);
357
363
  }
358
364
  }
359
365
  let relatedTarget;
360
366
  if (subType.typeKey === "relateRecord") {
361
367
  const relatedAttr = attrs["related_target_id"];
362
- const resolved = aspectTargetFromTf(relatedAttr, "related_target_id", owner, ctx, where);
368
+ const resolved = aspectTargetFromTf(relatedAttr, "related_target_id", owner, ctx, where, skipReference);
363
369
  if (resolved === undefined)
364
370
  return undefined;
365
371
  relatedTarget = resolved.target;
@@ -393,11 +399,9 @@ export function toolFromTf(block, owner, ctx) {
393
399
  ...(searchTableRawId !== undefined && { searchTableRawId }),
394
400
  };
395
401
  }
396
- function aspectTargetFromTf(value, attrName, owner, ctx, where) {
397
- if (value === undefined) {
398
- ctx.diagnostics.push(`${where}: ${attrName} is missing; skipped`);
399
- return undefined;
400
- }
402
+ function aspectTargetFromTf(value, attrName, owner, ctx, where, skip) {
403
+ if (value === undefined)
404
+ return skip(attrName, value, `${where}: ${attrName} is missing; skipped`);
401
405
  if (owner.appLabel !== undefined && resourceRefLabel(value, owner.appType) === owner.appLabel) {
402
406
  return { target: { kind: "self" }, fieldScopeLabel: owner.ownerTfLabel, fieldScope: "app" };
403
407
  }
@@ -410,8 +414,7 @@ function aspectTargetFromTf(value, attrName, owner, ctx, where) {
410
414
  continue;
411
415
  const name = dataAspectDisplayName(ctx, scope, value.label);
412
416
  if (name === undefined) {
413
- ctx.diagnostics.push(`${where}: ${attrName} references data.${type}.${value.label} but the stream has no such data block; skipped`);
414
- return undefined;
417
+ return skip(attrName, value, `${where}: ${attrName} references data.${type}.${value.label} but the stream has no such data block; skipped`);
415
418
  }
416
419
  return { target: { kind, name }, fieldScopeLabel: value.label, fieldScope: scope };
417
420
  }
@@ -422,8 +425,7 @@ function aspectTargetFromTf(value, attrName, owner, ctx, where) {
422
425
  ctx.diagnostics.push(`${where}: ${attrName} could not be resolved to a portable reference ("${value}"); kept as unresolved`);
423
426
  return { target: { kind: "unresolved", uuid: value }, fieldScopeLabel: owner.ownerTfLabel, fieldScope: "app" };
424
427
  }
425
- ctx.diagnostics.push(`${where}: ${attrName} has an unrecognized shape (${JSON.stringify(value)}); skipped`);
426
- return undefined;
428
+ return skip(attrName, value, `${where}: ${attrName} has an unrecognized shape (${JSON.stringify(value)}); skipped`);
427
429
  }
428
430
  /**
429
431
  * Run-automation (executeWorkflow) tool extraction. `automation_id` may
@@ -431,7 +433,7 @@ function aspectTargetFromTf(value, attrName, owner, ctx, where) {
431
433
  * generated after the automation's, and both carry the same platform id) or
432
434
  * the automation resource itself; both labels are the automation's.
433
435
  */
434
- function executeWorkflowFromTf(block, name, where, owner, ctx) {
436
+ function executeWorkflowFromTf(block, name, where, owner, ctx, skip) {
435
437
  const attrs = block.attrs;
436
438
  const autoRef = attrs["automation_id"];
437
439
  const autoLabel = isTfExpr(autoRef) &&
@@ -440,14 +442,10 @@ function executeWorkflowFromTf(block, name, where, owner, ctx) {
440
442
  ? autoRef.label
441
443
  : undefined;
442
444
  if (autoLabel === undefined) {
443
- ctx.diagnostics.push(`${where}: automation_id is not an automation/workflow_publish resource reference (${JSON.stringify(autoRef)}); skipped`);
444
- if (typeof autoRef === "string" && block.type !== undefined && block.label !== undefined) {
445
- // A raw id: the export left the automation out, so no source can manage
446
- // the tool. Release an earlier adoption rather than destroy it (#2525).
447
- ctx.skipped.push(`${block.type}.${block.label}`);
448
- ctx.releaseIfManaged?.push(`${block.type}.${block.label}`);
449
- }
450
- return undefined;
445
+ // A raw id (the export left the automation out, #2525) or another app's
446
+ // automation (data.elementum_automation): no source can manage the tool,
447
+ // so it is left out of adoption, or released, rather than destroyed.
448
+ return skip("automation_id", autoRef, `${where}: automation_id is not an automation/workflow_publish resource reference (${JSON.stringify(autoRef)}); skipped`);
451
449
  }
452
450
  const inputs = [];
453
451
  for (const item of Array.isArray(attrs["inputs"]) ? attrs["inputs"] : []) {
@@ -15,9 +15,10 @@
15
15
  import { workspaceAspectKey } from "../../engine/build/context.js";
16
16
  import { EntityTfError } from "../../engine/entity.js";
17
17
  import { automationRunTargetResourceAttr } from "../automation/run-target.js";
18
- import { appScopedResourceLabel, collisionLabelSuffixes, expr, sanitizeName, scopedResourceLabel, stableIdSuffix, tsLabelToTfLabel } from "../../engine/tf/index.js";
19
- import { authoredFieldKeysFromPayload, fieldRefToTfValue, } from "../field/to-tf.js";
18
+ import { appScopedResourceLabel, collisionLabelSuffixes, expr, sanitizeName, stableIdSuffix, tsLabelToTfLabel } from "../../engine/tf/index.js";
19
+ import { fieldRefToTfValue, siblingFieldOwnership, } from "../field/to-tf.js";
20
20
  import { foreignFieldDataLabel } from "../shared/foreign-ref.js";
21
+ import { localSearchTableLabel } from "../shared/search-table-address.js";
21
22
  import { encodeOptionalHandleDescription } from "../shared/handle-description.js";
22
23
  import { TOOL_SUB_TYPE_BY_TYPE_KEY } from "./types.js";
23
24
  function serviceAccountIdValue(token, where, ctx) {
@@ -70,7 +71,9 @@ function resolveTarget(token, ctx) {
70
71
  refName,
71
72
  kind,
72
73
  localTfLabel: sibling.tfLabel,
73
- fieldOwnership: authoredFieldKeysFromPayload(sibling.streamRootEntity?.payload),
74
+ // Each field resolves to the address the sibling's own build gives it,
75
+ // whatever type the reference carries (#3088).
76
+ fieldOwnership: siblingFieldOwnership(sibling.streamRootEntity?.payload, sibling.tfLabel, kind),
74
77
  };
75
78
  }
76
79
  // ei derives foreign-app/foreign-element data labels from the display NAME.
@@ -159,7 +162,7 @@ function fieldRefValue(token, where, ctx, target) {
159
162
  // vs. real field resource, by authoring type) rather than reimplementing
160
163
  // it here — see fieldRefToTfValue's doc comment for the system-field
161
164
  // ordering rationale.
162
- const value = fieldRefToTfValue(token.fieldType ?? "", refName, target?.localTfLabel ?? ctx.appTfLabel, target?.kind === "element" ? "element" : "app", target?.fieldOwnership);
165
+ const value = fieldRefToTfValue(token.fieldType ?? "", refName, target?.localTfLabel ?? ctx.appTfLabel, target?.kind === "element" ? "element" : "app", target?.fieldOwnership, undefined, token.name);
163
166
  if (value === undefined) {
164
167
  ctx.diagnostics.push(`${where}: field token "${refName}" has no terraform field resource mapping (fieldType ${JSON.stringify(token.fieldType ?? "")}); dropped`);
165
168
  }
@@ -497,7 +500,11 @@ export function toolToTf(entry, ctx) {
497
500
  : table.__variant === "table"
498
501
  ? "elementum_table_search_table"
499
502
  : "elementum_ai_search_table";
500
- attrs["search_table_id"] = expr.resourceAttr(resourceType, scopedResourceLabel(target.localTfLabel, tsLabelToTfLabel(table.refName), target.kind === "element" ? "element" : "app"), ["id"]);
503
+ attrs["search_table_id"] = expr.resourceAttr(resourceType, localSearchTableLabel(where, { refName: table.refName ?? "", ...(table.name !== undefined && { name: table.name }) }, {
504
+ refName: target.refName,
505
+ tfLabel: target.localTfLabel,
506
+ scope: target.kind === "element" ? "element" : "app",
507
+ }), ["id"]);
501
508
  }
502
509
  else {
503
510
  const lookupLabel = sanitizeName(`${target.foreignTfLabel}_${table.name ?? table.refName}`);
@@ -516,7 +516,7 @@ interface AppV2OptionsBase<F extends Record<string, AppField> = Record<string, A
516
516
  readonly lockStages?: boolean;
517
517
  /** Automatic record sharing toggles. Omit to leave the platform setting untouched. */
518
518
  readonly autoShare?: AutoShareOptions;
519
- /** Fields keyed by ref name. At least one required by the compose API. */
519
+ /** Fields keyed by ref name. `app()` needs at least one entry here or a `systemFields` override. */
520
520
  readonly fields: F;
521
521
  /**
522
522
  * Overrides for the platform's auto-provisioned system fields (ID, Title,
@@ -12,7 +12,7 @@ export { runAutomationParameterValue, type AppWidget, type CreateRecordWidget, t
12
12
  export { type DisplayBlock } from "./display-blocks.js";
13
13
  export { type AppRelationship, type AppRelationshipColumn } from "../relationship/build.js";
14
14
  export { dashboardChartWidget, dashboardRecordsWidget, dashboardWidgetSize, type DashboardChartWidget, type DashboardRecordsWidget, type DashboardWidget, type DashboardWidgetSize, } from "../dashboard/build.js";
15
- export { type AppDynamicLayout, type DynamicLayoutBlockCommon, type DynamicLayoutComponent, type DynamicLayoutCondition, type DynamicLayoutCssLength, type DynamicLayoutDependency, type DynamicLayoutFieldComponent, type DynamicLayoutFieldValidation, type DynamicLayoutSaveGroup, type DynamicLayoutStyle, type DynamicLayoutTypedValue, type DynamicLayoutValidationRule, dynamicLayout, } from "../dynamic-layout/build.js";
15
+ export { type AppDynamicLayout, type DynamicLayoutBlockCommon, type DynamicLayoutComponent, type DynamicLayoutCondition, type DynamicLayoutCssLength, type DynamicLayoutDependency, type DynamicLayoutFieldComponent, type DynamicLayoutFieldValidation, type DynamicLayoutSaveGroup, type DynamicLayoutStyle, type DynamicLayoutTypedValue, type DynamicLayoutCurrentUserValue, type DynamicLayoutCurrentUserGroupsValue, type DynamicLayoutEqualityComparison, type DynamicLayoutMembershipComparison, type DynamicLayoutValidationRule, dynamicLayout, } from "../dynamic-layout/build.js";
16
16
  export { attachmentField, booleanField, calculatedField, dateField, dateTimeField, decimalField, dropdownDisplay, dropdownField, dropdownOption, dropdownValue, groupField, jsonField, multiSelectField, numberField, relationField, richTextField, textField, userField, type AttachmentFieldOptions, type BaseFieldOptions, type CalculatedFieldOptions, type InferredCalculatedField, type DropdownConfig, type DropdownDisplay, type DropdownFieldOptions, type DropdownOption, type DropdownParentValueRef, type DynamicDropdownConfig, type DynamicDropdownParent, type DynamicDropdownParentMapping, type MultiSelectFieldOptions, type NumericFieldOptions, type NumericFieldFormat, type PicklistFieldOptions, type RelationFieldOptions, type TextFieldOptions, type QrFieldFormat, } from "../field/build.js";
17
17
  export { asc, desc, sortBy, type SortDirection, type SortOrder } from "../shared/types/common.js";
18
18
  export { calc, dateDifUnit, dateTimeTruncPrecision, field, orderByDirection, predicateOp, weekdayMode, type ConcatExprType, type DateDifUnit, type DateTimeTruncPrecision, type Expr, type ExprType, type FieldRefExprType, type OrderByDirection, type Predicate, type PredicateOp, type StringAggOptions, type StringAggOrderBy, type WeekdayMode, } from "../field/calc.js";
@@ -0,0 +1,20 @@
1
+ /**
2
+ * The `refs` map key for `ctx.trigger.<name>` on an approval process status
3
+ * trigger, or undefined when the name is not an approval output.
4
+ * `fieldNames` are the display names of the trigger app's fields.
5
+ */
6
+ export declare function approvalTriggerRefsKey(name: string, fieldNames: Iterable<string>): string | undefined;
7
+ /** The `triggerReference.name` for `ctx.trigger.<name>`, or undefined when it is not an approval output. */
8
+ export declare function approvalTriggerReferenceName(name: string): string | undefined;
9
+ /**
10
+ * The accessor path for an approval process status trigger's `refs` key, or
11
+ * undefined when the key is not an approval output. A plain key that a field
12
+ * of the trigger's app owns (`fieldOwnsKey`) is that field, not the output.
13
+ */
14
+ export declare function approvalTriggerPathFromRefsKey(key: string, fieldOwnsKey: (key: string) => boolean): string[] | undefined;
15
+ /**
16
+ * The top-level `ctx.trigger.<name>` heads an approval process status trigger
17
+ * declares (`record` plus every approval output), derived from the table
18
+ * above so pull's undeclared-head check can't drift from it.
19
+ */
20
+ export declare const APPROVAL_TRIGGER_OUTPUT_HEADS: ReadonlySet<string>;
@@ -0,0 +1,83 @@
1
+ import { EntityTfError } from "../../engine/entity.js";
2
+ const APPROVAL_TRIGGER_REFS = {
3
+ approver: { refsKey: "Final Approval By's id", referenceName: "approver.id" },
4
+ "approver.id": { refsKey: "Final Approval By's id", referenceName: "approver.id" },
5
+ "approver.email": { refsKey: "Final Approval By's Email", referenceName: "approver.email" },
6
+ "approver.name": { refsKey: "Final Approval By's Name", referenceName: "approver.name" },
7
+ approvalUpdatedAt: { refsKey: "Final Approval At", referenceName: "approvalUpdatedAt" },
8
+ status: { refsKey: "Approval Status", referenceName: "status" },
9
+ reason: { refsKey: "Approval Reason", referenceName: "reason" },
10
+ };
11
+ /**
12
+ * When a field of the trigger's app has the same display name as one of these
13
+ * keys, the field keeps the plain key and the trigger output is published as
14
+ * "<group> - <key>" (the provider's `refkeys.Qualified`; live: an app with an
15
+ * "Approval Status" text field gets refs["Approval Chain Trigger - Approval
16
+ * Status"] for the trigger's status).
17
+ */
18
+ const APPROVAL_TRIGGER_REF_GROUP = "Approval Chain Trigger";
19
+ const QUALIFIED_PREFIX = `${APPROVAL_TRIGGER_REF_GROUP} - `;
20
+ function isApprovalAccessor(name) {
21
+ return Object.hasOwn(APPROVAL_TRIGGER_REFS, name);
22
+ }
23
+ /**
24
+ * The accessor entry for `ctx.trigger.<name>`, or undefined when the name is
25
+ * not one of the approval outputs (the record and its fields). Fails closed on
26
+ * an approver property the platform does not publish.
27
+ */
28
+ function approvalEntry(name) {
29
+ if (isApprovalAccessor(name))
30
+ return APPROVAL_TRIGGER_REFS[name];
31
+ if (name.startsWith("approver.")) {
32
+ throw new EntityTfError(`ctx.trigger.${name}: an approval process status trigger publishes only the approver's id, email and name. ` +
33
+ "Use ctx.trigger.approver.id, ctx.trigger.approver.email or ctx.trigger.approver.name.");
34
+ }
35
+ return undefined;
36
+ }
37
+ /**
38
+ * The `refs` map key for `ctx.trigger.<name>` on an approval process status
39
+ * trigger, or undefined when the name is not an approval output.
40
+ * `fieldNames` are the display names of the trigger app's fields.
41
+ */
42
+ export function approvalTriggerRefsKey(name, fieldNames) {
43
+ const entry = approvalEntry(name);
44
+ if (entry === undefined)
45
+ return undefined;
46
+ for (const fieldName of fieldNames) {
47
+ if (fieldName === entry.refsKey)
48
+ return `${QUALIFIED_PREFIX}${entry.refsKey}`;
49
+ }
50
+ return entry.refsKey;
51
+ }
52
+ /** The `triggerReference.name` for `ctx.trigger.<name>`, or undefined when it is not an approval output. */
53
+ export function approvalTriggerReferenceName(name) {
54
+ return approvalEntry(name)?.referenceName;
55
+ }
56
+ /** Plain refs key → accessor path. The bare `approver` shares the id's key, so pull prints `.id`. */
57
+ const PATH_BY_REFS_KEY = new Map(Object.entries(APPROVAL_TRIGGER_REFS)
58
+ .filter(([accessor]) => accessor !== "approver")
59
+ .map(([accessor, { refsKey }]) => [refsKey, accessor.split(".")]));
60
+ /**
61
+ * The accessor path for an approval process status trigger's `refs` key, or
62
+ * undefined when the key is not an approval output. A plain key that a field
63
+ * of the trigger's app owns (`fieldOwnsKey`) is that field, not the output.
64
+ */
65
+ export function approvalTriggerPathFromRefsKey(key, fieldOwnsKey) {
66
+ if (key.startsWith(QUALIFIED_PREFIX)) {
67
+ const path = PATH_BY_REFS_KEY.get(key.slice(QUALIFIED_PREFIX.length));
68
+ return path === undefined ? undefined : [...path];
69
+ }
70
+ const path = PATH_BY_REFS_KEY.get(key);
71
+ if (path === undefined || fieldOwnsKey(key))
72
+ return undefined;
73
+ return [...path];
74
+ }
75
+ /**
76
+ * The top-level `ctx.trigger.<name>` heads an approval process status trigger
77
+ * declares (`record` plus every approval output), derived from the table
78
+ * above so pull's undeclared-head check can't drift from it.
79
+ */
80
+ export const APPROVAL_TRIGGER_OUTPUT_HEADS = new Set([
81
+ "record",
82
+ ...Object.keys(APPROVAL_TRIGGER_REFS).map((accessor) => accessor.split(".")[0]),
83
+ ]);