@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
@@ -19,5 +19,5 @@ export { automationStatus, chainableTrigger, actions, automation, type ActionBui
19
19
  export { ScriptCodeError, scriptFile, type ScriptCodeFn, type ScriptFile, type ScriptInput } from "./script-code.js";
20
20
  export { unsafeScriptOutput } from "./unsafe-script-output.js";
21
21
  export { workflowOutput, workflowOutputType, type WorkflowOutputDeclaration, type WorkflowOutputType, } from "./workflow-output.js";
22
- export { addWatcher, aiAgent, aiClassify, aiEmailAnalysis, aiFileAnalysis, aiSearchTable, aiSummarize, aiTransform, apiRequest, approvalChain, approvalChainTemplate, approvalStatusUpdate, requiredSecret, assignGroup, assignUser, assignmentEngine, bulkExcel, bulkUpdateFields, calculation, createRecord, executeScript, findRelatedRecords, generateReport, initiateCall, initiateEmailConversation, notification, postComment, postTeamsMessage, procedure, readFile, recordFieldLocking, recordSearch, relateRecords, runAutomation, saveAttachment, sendEmail, sendSurvey, setVariable, tableRecordsSearch, unzip, updateField, userGroupSearch, userSearch, withFieldMappings, type AddWatcherOptions, type AiAgentAttachment, type AiAgentOptions, type AiAgentOutput, type AiAgentOutputField, type AiAgentOutputFieldType, type AiClassifyCategorySource, type AiClassifyOptions, type AiClassifyStaticCategory, type AiEmailAnalysisOptions, type AiFileAnalysisOptions, type AiSearchTableOptions, type AiSearchTableOutput, type AiSummarizeOptions, type AiTransformOptions, type ApiRequestHeader, type ApiRequestOptions, type ApiRequestOutputs, type ApiResponseType, type ApprovalChainOptions, type RequiredSecret, type ApprovalChainTemplateOptions, type ApprovalStatusUpdateOptions, type ApprovalStatusUpdateStatus, type AssignGroupOptions, type AssignUserOptions, type AssignmentEngineOptions, type BulkExcelFieldMapping, type BulkExcelFieldSource, type BulkExcelOptions, type BulkUpdateFieldsOptions, type BulkUpdateFieldsOutput, type CalculationEntry, type CalculationExpression, type CalculationInclude, type CalculationOptions, type CalculationOutputs, type CalculationValueInput, type CalculationValueOptions, type CalculationValueOutputs, type CalculationValues, type CreateRecordOptions, type CreateRecordOutput, type EmailAttachment, type ExecuteScriptFieldMapping, type ExecuteScriptOptions, type ExecuteScriptOutput, type FieldAssignment, type FindRelatedRecordsOptions, type FindRelatedRecordsOutput, type GenerateReportOptions, type InitiateCallOptions, type InitiateEmailConversationOptions, type InitiateEmailFirstEmail, type LegacyCalculationOptions, type MultiSelectUpdateMode, type NotificationOptions, type StaticGroupRecipient, type StaticUserRecipient, type PostCommentOptions, type PostTeamsMessageOptions, type LegacyProcedureOptions, type ProcedureOptions, type TypedProcedureOptions, type ReadFileDataSource, type ReadFileOptions, type RecordFieldLockingOptions, type RecordId, type RecordReference, type RecordSearchOptions, type RecordSearchOutput, type RelateRecordsOptions, type RunAutomationInput, type RunAutomationDynamicReferenceOptions, type RunAutomationOptions, type RunAutomationStaticOptions, type SaveAttachmentOptions, type ScriptOutputProperties, type ScriptOutputScalarType, type ScriptOutputType, type ScriptOutputs, type SendEmailOptions, type SendSurveyOptions, type SetVariableOptions, type TableRecordsSearchOptions, type TableRecordsSearchOutput, type UnzipOptions, type UpdateFieldAssignment, type UpdateFieldOptions, type UserGroupSearchOptions, type UserGroupSearchOutput, type UserGroupShape, type UserSearchOptions, type VariableAssign, type VariableDecl } from "./tasks.js";
23
- export { approvalProcessStatusUpdated, attachment, commentAdded, conversationEnd, dataMine, emailReceived, onDemand, recordCreated, recordUpdated, schedule, slackMessage, surveyResponseCreate, temporal, webHook, webhook, type AttachmentTriggerOptions, type AttachmentTriggerOutput, type CommentAddedTriggerOptions, type CommentAddedTriggerOutput, type ConversationEndConversationType, type ConversationEndTriggerOptions, type ConversationEndTriggerOutput, type DataMineTriggerOptions, type DataMineTriggerOutput, type EmailReceivedTriggerOptions, type EmailReceivedTriggerOutput, type RecordTriggerOptions, type RecordTriggerOutput, type ScheduleFrequency, type ScheduleTriggerOptions, type ScheduleTriggerOutput, type SlackMessageTriggerOutput, type SurveyResponseCreateTriggerOptions, type SurveyResponseCreateTriggerOutput, type TemporalTriggerOptions, type TemporalUnit, type WebhookTriggerOptions, type WebhookTriggerOutput, type Weekday, type approvalProcessStatusUpdatedStatus, type approvalProcessStatusUpdatedTriggerOptions } from "./triggers.js";
22
+ export { addWatcher, aiAgent, aiClassify, aiEmailAnalysis, aiFileAnalysis, aiSearchTable, aiSummarize, aiTransform, apiRequest, approvalChain, approvalChainTemplate, approvalStatusUpdate, groupApprover, requiredSecret, assignGroup, assignUser, assignmentEngine, bulkExcel, bulkUpdateFields, calculation, createRecord, executeScript, findRelatedRecords, generateReport, initiateCall, initiateEmailConversation, notification, postComment, postTeamsMessage, procedure, readFile, recordFieldLocking, recordSearch, relateRecords, runAutomation, saveAttachment, sendEmail, sendSurvey, setVariable, tableRecordsSearch, unzip, updateField, userGroupSearch, userSearch, withFieldMappings, type AddWatcherOptions, type AiAgentAttachment, type AiAgentOptions, type AiAgentOutput, type AiAgentOutputField, type AiAgentOutputFieldType, type AiClassifyCategorySource, type AiClassifyOptions, type AiClassifyStaticCategory, type AiEmailAnalysisOptions, type AiFileAnalysisOptions, type AiSearchTableOptions, type AiSearchTableOutput, type AiSummarizeOptions, type AiTransformOptions, type ApiRequestHeader, type ApiRequestOptions, type ApiRequestOutputs, type ApiResponseType, type ApprovalChainOptions, type ApprovalGroupApprover, type GroupApproverArgumentError, type GroupApproverValue, type RequiredSecret, type ApprovalChainTemplateOptions, type ApprovalStatusUpdateOptions, type ApprovalStatusUpdateStatus, type AssignGroupOptions, type AssignUserOptions, type AssignmentEngineOptions, type BulkExcelFieldMapping, type BulkExcelFieldSource, type BulkExcelOptions, type BulkUpdateFieldsOptions, type BulkUpdateFieldsOutput, type CalculationEntry, type CalculationExpression, type CalculationInclude, type CalculationOptions, type CalculationOutputs, type CalculationValueInput, type CalculationValueOptions, type CalculationValueOutputs, type CalculationValues, type CreateRecordOptions, type CreateRecordOutput, type EmailAttachment, type ExecuteScriptFieldMapping, type ExecuteScriptOptions, type ExecuteScriptOutput, type FieldAssignment, type FindRelatedRecordsOptions, type FindRelatedRecordsOutput, type GenerateReportOptions, type InitiateCallOptions, type InitiateEmailConversationOptions, type InitiateEmailFirstEmail, type LegacyCalculationOptions, type MultiSelectUpdateMode, type NotificationOptions, type StaticGroupRecipient, type StaticUserRecipient, type PostCommentOptions, type PostTeamsMessageOptions, type LegacyProcedureOptions, type ProcedureOptions, type TypedProcedureOptions, type ReadFileDataSource, type ReadFileOptions, type RecordFieldLockingOptions, type RecordId, type RecordReference, type RecordSearchOptions, type RecordSearchOutput, type RelateRecordsOptions, type RunAutomationInput, type RunAutomationDynamicReferenceOptions, type RunAutomationOptions, type RunAutomationStaticOptions, type SaveAttachmentOptions, type ScriptOutputProperties, type ScriptOutputScalarType, type ScriptOutputType, type ScriptOutputs, type SendEmailOptions, type SendSurveyOptions, type SetVariableOptions, type TableRecordsSearchOptions, type TableRecordsSearchOutput, type UnzipOptions, type UpdateFieldAssignment, type UpdateFieldOptions, type UserGroupSearchOptions, type UserGroupSearchOutput, type UserGroupShape, type UserSearchOptions, type VariableAssign, type VariableDecl } from "./tasks.js";
23
+ export { approvalProcessStatusUpdated, attachment, commentAdded, conversationEnd, dataMine, emailReceived, onDemand, recordCreated, recordUpdated, schedule, slackMessage, surveyResponseCreate, temporal, webHook, webhook, type ApprovalProcessStatusUpdatedApprover, type ApprovalProcessStatusUpdatedTriggerOutput, type AttachmentTriggerOptions, type AttachmentTriggerOutput, type CommentAddedTriggerOptions, type CommentAddedTriggerOutput, type ConversationEndConversationType, type ConversationEndTriggerOptions, type ConversationEndTriggerOutput, type DataMineTriggerOptions, type DataMineTriggerOutput, type EmailReceivedTriggerOptions, type EmailReceivedTriggerOutput, type RecordTriggerOptions, type RecordTriggerOutput, type ScheduleFrequency, type ScheduleTriggerOptions, type ScheduleTriggerOutput, type SlackMessageTriggerOutput, type SurveyResponseCreateTriggerOptions, type SurveyResponseCreateTriggerOutput, type TemporalTriggerOptions, type TemporalUnit, type WebhookTriggerOptions, type WebhookTriggerOutput, type Weekday, type approvalProcessStatusUpdatedStatus, type approvalProcessStatusUpdatedTriggerOptions } from "./triggers.js";
@@ -19,7 +19,7 @@ export { automationStatus, chainableTrigger, actions, automation } from "./build
19
19
  export { ScriptCodeError, scriptFile } from "./script-code.js";
20
20
  export { unsafeScriptOutput } from "./unsafe-script-output.js";
21
21
  export { workflowOutput, workflowOutputType, } from "./workflow-output.js";
22
- export { addWatcher, aiAgent, aiClassify, aiEmailAnalysis, aiFileAnalysis, aiSearchTable, aiSummarize, aiTransform, apiRequest, approvalChain, approvalChainTemplate, approvalStatusUpdate, requiredSecret, assignGroup, assignUser, assignmentEngine, bulkExcel, bulkUpdateFields, calculation, createRecord, executeScript, findRelatedRecords, generateReport, initiateCall, initiateEmailConversation, notification, postComment, postTeamsMessage, procedure, readFile, recordFieldLocking, recordSearch, relateRecords, runAutomation, saveAttachment, sendEmail, sendSurvey, setVariable, tableRecordsSearch, unzip, updateField, userGroupSearch, userSearch, withFieldMappings } from "./tasks.js";
22
+ export { addWatcher, aiAgent, aiClassify, aiEmailAnalysis, aiFileAnalysis, aiSearchTable, aiSummarize, aiTransform, apiRequest, approvalChain, approvalChainTemplate, approvalStatusUpdate, groupApprover, requiredSecret, assignGroup, assignUser, assignmentEngine, bulkExcel, bulkUpdateFields, calculation, createRecord, executeScript, findRelatedRecords, generateReport, initiateCall, initiateEmailConversation, notification, postComment, postTeamsMessage, procedure, readFile, recordFieldLocking, recordSearch, relateRecords, runAutomation, saveAttachment, sendEmail, sendSurvey, setVariable, tableRecordsSearch, unzip, updateField, userGroupSearch, userSearch, withFieldMappings } from "./tasks.js";
23
23
  export { approvalProcessStatusUpdated, attachment, commentAdded, conversationEnd, dataMine, emailReceived, onDemand, recordCreated, recordUpdated, schedule, slackMessage, surveyResponseCreate, temporal, webHook, webhook } from "./triggers.js";
24
24
  // Pull a deployed automation back as editable v2 source. `automation`
25
25
  // is a plain factory returning a builder-chain object (not an Object.assign-able
@@ -0,0 +1,23 @@
1
+ import type { OrgRefLookup } from "../../engine/build/context.js";
2
+ import { type TfBlock, type TfValue } from "../../engine/tf/index.js";
3
+ /** The owner kinds an automation can belong to, and the data source each is looked up with. */
4
+ declare const OWNER_DATA_TYPE: {
5
+ readonly app: "elementum_app";
6
+ readonly element: "elementum_element";
7
+ };
8
+ export type AutomationOwnerScope = keyof typeof OWNER_DATA_TYPE;
9
+ /**
10
+ * The owner lookup a `data.elementum_automation` lookup by display name
11
+ * reads its `app_id` from, for an automation of this app or element that is
12
+ * not in source (a widget, a dynamic-layout button, a Run Automation call,
13
+ * and adoption's stand-in for a skipped automation, #3047). The owner is
14
+ * looked up by its namespace, which is its Terraform label, rather than read
15
+ * from the managed app or element resource: OpenTofu defers a data source
16
+ * whose dependency has planned changes, so a plan that changes the app record
17
+ * would otherwise make the automation's id and parameter ids unknown, and
18
+ * every run task and reader of its outputs with them (edk#1514).
19
+ */
20
+ export declare function automationLookupOwnerBlock(scope: AutomationOwnerScope, ownerTfLabel: string): TfBlock;
21
+ /** `automationLookupOwnerBlock`'s id, registering the block with `orgRefs`, or in `dataBlocks` when a build has no org lookup. */
22
+ export declare function automationLookupOwnerId(scope: AutomationOwnerScope, ownerTfLabel: string, orgRefs: OrgRefLookup | undefined, dataBlocks?: Map<string, TfBlock>): TfValue;
23
+ export {};
@@ -0,0 +1,27 @@
1
+ import { expr } from "../../engine/tf/index.js";
2
+ /** The owner kinds an automation can belong to, and the data source each is looked up with. */
3
+ const OWNER_DATA_TYPE = { app: "elementum_app", element: "elementum_element" };
4
+ /**
5
+ * The owner lookup a `data.elementum_automation` lookup by display name
6
+ * reads its `app_id` from, for an automation of this app or element that is
7
+ * not in source (a widget, a dynamic-layout button, a Run Automation call,
8
+ * and adoption's stand-in for a skipped automation, #3047). The owner is
9
+ * looked up by its namespace, which is its Terraform label, rather than read
10
+ * from the managed app or element resource: OpenTofu defers a data source
11
+ * whose dependency has planned changes, so a plan that changes the app record
12
+ * would otherwise make the automation's id and parameter ids unknown, and
13
+ * every run task and reader of its outputs with them (edk#1514).
14
+ */
15
+ export function automationLookupOwnerBlock(scope, ownerTfLabel) {
16
+ return { kind: "data", type: OWNER_DATA_TYPE[scope], label: ownerTfLabel, attrs: { namespace: ownerTfLabel } };
17
+ }
18
+ /** `automationLookupOwnerBlock`'s id, registering the block with `orgRefs`, or in `dataBlocks` when a build has no org lookup. */
19
+ export function automationLookupOwnerId(scope, ownerTfLabel, orgRefs, dataBlocks) {
20
+ if (orgRefs !== undefined) {
21
+ const resolved = orgRefs.resolveForeignRoot(scope, { tfLabel: ownerTfLabel, name: ownerTfLabel, namespace: ownerTfLabel });
22
+ return expr.dataAttr(resolved.resourceType, resolved.tfLabel, ["id"]);
23
+ }
24
+ const block = automationLookupOwnerBlock(scope, ownerTfLabel);
25
+ dataBlocks?.set(`${block.type}.${block.label}`, block);
26
+ return expr.dataAttr(block.type, block.label, ["id"]);
27
+ }
@@ -1,6 +1,6 @@
1
1
  /** The automation entity's registry entry (see src/graph/). */
2
2
  import { canonicalAuditRefKey } from "./system-ref-name.js";
3
- import { appScopedResourceLabel, sanitizeName, scopedLabelToBagKey, tfLabelToTsLabel, tsLabelToTfLabel, isTfExpr } from "../../engine/tf/index.js";
3
+ import { appScopedResourceLabel, expr, sanitizeName, scopedLabelToBagKey, tfLabelToTsLabel, tsLabelToTfLabel, isTfExpr } from "../../engine/tf/index.js";
4
4
  function elementOwnerHandle(payload) {
5
5
  if (payload === null || typeof payload !== "object" || !("handle" in payload))
6
6
  return undefined;
@@ -8,8 +8,9 @@ function elementOwnerHandle(payload) {
8
8
  return typeof handle === "string" && handle !== "" ? handle : undefined;
9
9
  }
10
10
  import { renderAutomationCatalogEntry } from "./catalog-render.js";
11
+ import { automationLookupOwnerBlock } from "./lookup-owner.js";
11
12
  import { hasUnresolvedForEachItem, preserveAuthoredAutomationPullMeta, printAutomationV2WithScriptFiles, SCRIPT_FILES_DIR } from "./deserializer/print-automation.js";
12
- import { automationFromTf, automationOwnedAddresses, ForEachItemOutsideLoopError, UnresolvedForeignServiceAccountError, UnresolvedTaskFilterRefError, UnsupportedMultiTriggerError } from "./from-tf.js";
13
+ import { automationFromTf, automationOwnedAddresses, foreignAutomationTarget, ForEachItemOutsideLoopError, UnresolvedCalculationOutputError, UnresolvedForeignServiceAccountError, UnresolvedTaskFilterRefError, UnsupportedMultiTriggerError } from "./from-tf.js";
13
14
  import { scriptFileRefs } from "./script-code.js";
14
15
  import { typedCoverageGap } from "../../engine/coverage-gaps.js";
15
16
  import { executeScriptOutputReferences, taskOutputReferences, USER_SEARCH_OUTPUT_REFERENCES } from "./task-output-labels.js";
@@ -159,15 +160,30 @@ export function droppedAutomationGap(autoBlock, autoLabel, gap) {
159
160
  * automation is not in source (edk#2693). A button input reads its on-demand
160
161
  * trigger's `parameter_ids`, which the lookup carries too (#3023).
161
162
  */
162
- function unmanagedAutomationLookup(autoBlock, owned, label) {
163
+ function unmanagedAutomationLookup(autoBlock, owned, label, uniqueName) {
163
164
  const name = autoBlock.attrs["name"];
164
165
  const appId = autoBlock.attrs["app_id"];
165
166
  const triggers = owned.filter((address) => address.startsWith("elementum_on_demand_trigger."));
166
- if (typeof name !== "string" || name === "" || appId === undefined || triggers.length === 0)
167
+ // A Run Automation call reads the automation's id from the same lookup
168
+ // build emits for it (#3047), when the display name finds only this one.
169
+ const automation = uniqueName && autoBlock.label !== undefined ? [`${AUTOMATION_RESOURCE_TYPE}.${autoBlock.label}`] : [];
170
+ if (typeof name !== "string" || name === "" || appId === undefined || triggers.length + automation.length === 0)
167
171
  return undefined;
172
+ // The owner by namespace, as build reads it (`automationLookupOwnerId`),
173
+ // so the lookups pair in the build-vs-export check (#3047).
174
+ const owner = isTfExpr(appId) && appId.$expr === "resource-attr" && (appId.type === "elementum_app" || appId.type === "elementum_element")
175
+ ? automationLookupOwnerBlock(appId.type === "elementum_element" ? "element" : "app", appId.label)
176
+ : undefined;
168
177
  return {
169
- lookup: { kind: "data", type: AUTOMATION_RESOURCE_TYPE, label, attrs: { app_id: appId, name } },
178
+ lookup: {
179
+ kind: "data",
180
+ type: AUTOMATION_RESOURCE_TYPE,
181
+ label,
182
+ attrs: { app_id: owner === undefined ? appId : expr.dataAttr(owner.type, owner.label, ["id"]), name },
183
+ },
170
184
  addresses: triggers,
185
+ ...(automation.length > 0 && { idAddresses: automation }),
186
+ ...(owner !== undefined && { supporting: [owner] }),
171
187
  };
172
188
  }
173
189
  const FIX_IN_PLATFORM = "To manage it with the EDK, change what the reason names in the platform, then pull again.";
@@ -179,7 +195,7 @@ const FIX_OR_REPORT = "If you can change what the reason names in the platform,
179
195
  * display-name lookup (#1901), so archiving is safe. A dynamic-layout button
180
196
  * does not count either (#2693). Any other reference from that layout still does.
181
197
  */
182
- function externalReferrers(stream, owned, inSource) {
198
+ function externalReferrers(stream, owned, inSource, runnable = new Set()) {
183
199
  const ownedSet = new Set(owned);
184
200
  const referrers = [];
185
201
  for (const block of stream.allBlocks) {
@@ -188,7 +204,9 @@ function externalReferrers(stream, owned, inSource) {
188
204
  const address = `${block.type}.${block.label}`;
189
205
  if (ownedSet.has(address) || block.type === "elementum_widget" || !inSource(address))
190
206
  continue;
191
- const attrs = block.type === "elementum_dynamic_layout" ? withoutAutomationButtons(block.attrs) : block.attrs;
207
+ // A Run Automation call looks an automation that is not in source up by
208
+ // display name (#3047), so it does not keep the file either.
209
+ const attrs = block.type === "elementum_dynamic_layout" ? withoutAutomationButtons(block.attrs) : withoutRunTargetSites(block, runnable);
192
210
  if (referenceIn(attrs, ownedSet) !== undefined)
193
211
  referrers.push(address);
194
212
  }
@@ -249,18 +267,164 @@ function referenceIn(value, targets) {
249
267
  }
250
268
  return undefined;
251
269
  }
270
+ /**
271
+ * How many automations carry each display name: the stream's, plus every one
272
+ * the export left out (omitted-automations.json). The provider's name lookup
273
+ * sees those too and prefers an ACTIVE match, so a namesake it left out could
274
+ * take the lookup; counting them all is the conservative side (#3047).
275
+ */
276
+ function automationDisplayNameCounts(stream, ctx) {
277
+ const counts = new Map();
278
+ const count = (name) => {
279
+ if (typeof name === "string")
280
+ counts.set(name, (counts.get(name) ?? 0) + 1);
281
+ };
282
+ for (const block of stream.allBlocks) {
283
+ if (block.kind === "resource" && block.type === AUTOMATION_RESOURCE_TYPE)
284
+ count(block.attrs["name"]);
285
+ }
286
+ for (const omitted of ctx.omittedAutomationsById?.values() ?? [])
287
+ count(omitted.name);
288
+ return counts;
289
+ }
252
290
  /** The first of `targets` that any block at `owned` references, if any. */
253
- function referencedAddress(stream, owned, targets) {
291
+ function referencedAddress(stream, owned, targets, runnable = new Set()) {
254
292
  const ownedSet = new Set(owned);
255
293
  for (const block of stream.allBlocks) {
256
294
  if (block.type === undefined || block.label === undefined || !ownedSet.has(`${block.type}.${block.label}`))
257
295
  continue;
258
- const hit = referenceIn(block.attrs, targets);
296
+ const hit = referenceIn(withoutRunTargetSites(block, runnable), targets);
259
297
  if (hit !== undefined)
260
298
  return hit;
261
299
  }
262
300
  return undefined;
263
301
  }
302
+ const RUN_AUTOMATION_TASK_TYPE = "elementum_run_automation_task";
303
+ /** The address a bare or attribute reference names, if it is a resource reference. */
304
+ function referencedResource(value) {
305
+ if (value === null || typeof value !== "object")
306
+ return undefined;
307
+ const record = value;
308
+ return record["$expr"] === "resource-attr" && typeof record["type"] === "string" && typeof record["label"] === "string"
309
+ ? `${record["type"]}.${record["label"]}`
310
+ : undefined;
311
+ }
312
+ /**
313
+ * A block's attrs without the places a static Run Automation call names the
314
+ * automation it runs, when that automation is one of `runnable`: the run
315
+ * task's target, its inputs' trigger `parameter_ids` and `depends_on`, and the
316
+ * caller's publish `depends_on`. Pulled source names such a target with
317
+ * `automationRef({ refName, name, parent })`, and build looks the live
318
+ * automation up by that display name when it is not in source (#3047), as it
319
+ * does for a dynamic-layout button (#2693). Every other reference stays.
320
+ */
321
+ function withoutRunTargetSites(block, runnable) {
322
+ if (runnable.size === 0 || (block.type !== RUN_AUTOMATION_TASK_TYPE && block.type !== WORKFLOW_PUBLISH_RESOURCE_TYPE))
323
+ return block.attrs;
324
+ const named = (value) => {
325
+ const address = referencedResource(value);
326
+ return address !== undefined && runnable.has(address);
327
+ };
328
+ const out = { ...block.attrs };
329
+ if (Array.isArray(out["depends_on"]))
330
+ out["depends_on"] = out["depends_on"].filter((entry) => !named(entry));
331
+ if (block.type !== RUN_AUTOMATION_TASK_TYPE)
332
+ return out;
333
+ for (const key of ["target_automation_id", "target_automation_ref"]) {
334
+ if (named(out[key]))
335
+ delete out[key];
336
+ }
337
+ if (Array.isArray(out["input_mappings"])) {
338
+ out["input_mappings"] = out["input_mappings"].map((mapping) => {
339
+ if (mapping === null || typeof mapping !== "object" || !named(mapping["parameter_id"]))
340
+ return mapping;
341
+ const { parameter_id: _parameterId, ...rest } = mapping;
342
+ return rest;
343
+ });
344
+ }
345
+ return out;
346
+ }
347
+ /**
348
+ * The display name of an automation ref's target when that target is not in
349
+ * its owner's source: one of this owner's (`ownerHandle`) whose key is in
350
+ * `names` (#3047), or another workspace app's or element's that the export
351
+ * looks up by display name while that owner's source has no automation with
352
+ * its key: the owner's pull skipped it (#3064). Another app's automation can
353
+ * have the same key, so the owner has to match too. A ref-only stub owner is
354
+ * not in `workspaceKeys`, and its catalog lists the automation, so its
355
+ * references stay catalog references.
356
+ */
357
+ function unmanagedRunTargetName(names, ownerHandle, stream, ctx) {
358
+ const foreign = new Map();
359
+ const workspaceKeys = ctx.workspaceAutomationKeys;
360
+ if (workspaceKeys !== undefined && workspaceKeys.size > 0) {
361
+ const dataBlocks = new Map(stream.allBlocks
362
+ .filter((block) => block.kind === "data" && block.type !== undefined && block.label !== undefined)
363
+ .map((block) => [`${block.type}.${block.label}`, block]));
364
+ for (const block of dataBlocks.values()) {
365
+ if (block.type !== AUTOMATION_RESOURCE_TYPE || block.label === undefined)
366
+ continue;
367
+ let target;
368
+ try {
369
+ target = foreignAutomationTarget(block.label, dataBlocks, ctx.foreignAppRefNames, ctx.foreignElementRefNames);
370
+ }
371
+ catch {
372
+ continue;
373
+ }
374
+ if (!target.mapped || target.name === undefined || target.appHandle === ownerHandle)
375
+ continue;
376
+ const keys = workspaceKeys.get(`${target.ownerKind}:${target.appHandle}`);
377
+ if (keys === undefined || keys.has(target.automationKey))
378
+ continue;
379
+ // `automationRef` names its owner by refName alone, so an app and an
380
+ // element that share it would leave build guessing the owner's kind.
381
+ if (workspaceKeys.has(`${target.ownerKind === "app" ? "element" : "app"}:${target.appHandle}`))
382
+ continue;
383
+ const byKey = foreign.get(target.appHandle) ?? new Map();
384
+ byKey.set(target.automationKey, target.name);
385
+ foreign.set(target.appHandle, byKey);
386
+ }
387
+ }
388
+ if (names.size === 0 && foreign.size === 0)
389
+ return undefined;
390
+ return (appHandle, key) => {
391
+ if (typeof appHandle !== "string")
392
+ return undefined;
393
+ return appHandle === ownerHandle ? names.get(key) : foreign.get(appHandle)?.get(key);
394
+ };
395
+ }
396
+ /** `value` with each automation ref whose target `nameOf` names given that display name (#3047, #3064). */
397
+ function withUnmanagedRunTargets(value, nameOf) {
398
+ if (nameOf === undefined)
399
+ return value;
400
+ // Copy on write, through plain arrays and objects only: every other value
401
+ // (and any subtree with no such ref) keeps its identity and prototype.
402
+ const walk = (node) => {
403
+ if (Array.isArray(node)) {
404
+ const mapped = node.map(walk);
405
+ return mapped.some((child, index) => child !== node[index]) ? mapped : node;
406
+ }
407
+ if (node === null || typeof node !== "object")
408
+ return node;
409
+ const prototype = Object.getPrototypeOf(node);
410
+ if (prototype !== Object.prototype && prototype !== null)
411
+ return node;
412
+ const record = node;
413
+ if (record["kind"] === "automation" && typeof record["automationKey"] === "string") {
414
+ const name = nameOf(record["appHandle"], record["automationKey"]);
415
+ return name === undefined ? record : { ...record, unmanagedName: name };
416
+ }
417
+ let changed = false;
418
+ const entries = Object.entries(record).map(([key, child]) => {
419
+ const next = walk(child);
420
+ if (next !== child)
421
+ changed = true;
422
+ return [key, next];
423
+ });
424
+ return changed ? Object.fromEntries(entries) : record;
425
+ };
426
+ return walk(value);
427
+ }
264
428
  function extractAutomations(ownBlocks, stream, ctx) {
265
429
  const items = [];
266
430
  const skipped = [];
@@ -273,12 +437,47 @@ function extractAutomations(ownBlocks, stream, ctx) {
273
437
  // Which file each skipped automation's resources come from (#1877).
274
438
  const skippedOwnFiles = [];
275
439
  const unmanagedLookups = [];
276
- const skip = (autoBlock, owned, refName) => {
440
+ // What the pull summary lists for each skipped automation (#3053): a
441
+ // caller skipped only because of another skipped automation names that
442
+ // one's root cause, so the summary can group them.
443
+ const skippedReports = [];
444
+ // References in the kept automations that the first plan rewrites (#3109).
445
+ const triggerReferenceRepairs = [];
446
+ const skippedOwner = new Map();
447
+ const rootCause = new Map();
448
+ // Skipped automations a Run Automation call can still name by display
449
+ // name (#3047): each one's addresses, and its key -> display name.
450
+ const runnable = new Set();
451
+ const runnableNames = new Map();
452
+ const displayNameCounts = automationDisplayNameCounts(stream, ctx);
453
+ const skip = (autoBlock, owned, refName, why, causedBy) => {
277
454
  skipped.push(...owned);
278
455
  skippedOwnFiles.push({ refName, addresses: owned });
279
- const lookup = unmanagedAutomationLookup(autoBlock, owned, `${ctx.appTfLabel}_${tsLabelToTfLabel(refName)}`);
456
+ const address = `${AUTOMATION_RESOURCE_TYPE}.${autoBlock.label ?? ""}`;
457
+ for (const member of owned)
458
+ skippedOwner.set(member, address);
459
+ const owner = causedBy === undefined ? undefined : skippedOwner.get(causedBy);
460
+ const root = owner === undefined ? undefined : rootCause.get(owner) ?? owner;
461
+ if (root !== undefined)
462
+ rootCause.set(address, root);
463
+ const name = autoBlock.attrs["name"];
464
+ skippedReports.push({
465
+ address,
466
+ name: typeof name === "string" && name !== "" ? name : autoBlock.label ?? "",
467
+ reason: why,
468
+ ...(root !== undefined && { causedBy: root }),
469
+ });
470
+ // A name lookup fails when two automations in the app share the name.
471
+ const uniqueName = typeof name === "string" && name !== "" && displayNameCounts.get(name) === 1 && autoBlock.attrs["app_id"] !== undefined;
472
+ const lookup = unmanagedAutomationLookup(autoBlock, owned, `${ctx.appTfLabel}_${tsLabelToTfLabel(refName)}`, uniqueName);
280
473
  if (lookup !== undefined)
281
474
  unmanagedLookups.push(lookup);
475
+ if (uniqueName) {
476
+ for (const member of owned)
477
+ runnable.add(member);
478
+ // Keyed as the caller's decoded target ref is (from-tf `decodeValue`).
479
+ runnableNames.set(scopedLabelToBagKey(ctx.appTfLabel, autoBlock.label ?? ""), name);
480
+ }
282
481
  };
283
482
  const settledByState = new Set();
284
483
  const release = (entry) => {
@@ -303,10 +502,11 @@ function extractAutomations(ownBlocks, stream, ctx) {
303
502
  const owned = automationOwnedAddresses(doc, autoLabel);
304
503
  const chain = referencedAddress(stream, owned, lostChains);
305
504
  if (chain !== undefined) {
306
- skip(autoBlock, owned, scopedLabelToBagKey(ctx.appTfLabel, autoLabel));
505
+ const why = `it uses ${chain}, which pull leaves unmanaged because its stage has no handle of its own (#1136)`;
506
+ skip(autoBlock, owned, scopedLabelToBagKey(ctx.appTfLabel, autoLabel), why);
307
507
  release({
308
508
  autoBlock, autoLabel, owned, refName: scopedLabelToBagKey(ctx.appTfLabel, autoLabel),
309
- why: `it uses ${chain}, which pull leaves unmanaged because its stage has no handle of its own (#1136)`,
509
+ why,
310
510
  nextStep: "To manage it with the EDK, give that stage its own handle in the platform, then pull again.",
311
511
  });
312
512
  continue;
@@ -320,14 +520,33 @@ function extractAutomations(ownBlocks, stream, ctx) {
320
520
  // second copy of the live automation.
321
521
  if (extracted.stringifiedValueReferences === true) {
322
522
  const owned = automationOwnedAddresses(doc, autoLabel);
323
- skip(autoBlock, owned, extracted.refName);
523
+ const why = "its export embeds a value reference as text that source cannot rebuild exactly (edk#1646)";
524
+ skip(autoBlock, owned, extracted.refName, why);
324
525
  release({
325
526
  autoBlock, autoLabel, owned, refName: extracted.refName,
326
- why: "its export embeds a value reference as text that source cannot rebuild exactly (edk#1646)",
527
+ why,
327
528
  nextStep: "Keep editing it in the platform.",
328
529
  });
329
530
  continue;
330
531
  }
532
+ // #3112: the source pull printed for it does not load. Writing it would
533
+ // leave a workspace no plan loads, with adoption's imports already in
534
+ // state. Leave it out and release it, like a shape source can't
535
+ // represent. Its file is settled by state: a pull that does not release
536
+ // it (under --no-adopt) keeps the earlier file and the binding to it.
537
+ const loadError = ctx.unloadableOwnFiles?.get("automation")?.get(extracted.refName);
538
+ if (loadError !== undefined) {
539
+ const owned = automationOwnedAddresses(doc, autoLabel);
540
+ const why = `the source pull printed for it does not load: ${loadError}`;
541
+ skip(autoBlock, owned, extracted.refName, why);
542
+ release({
543
+ autoBlock, autoLabel, owned, refName: extracted.refName,
544
+ why,
545
+ nextStep: "This is an EDK bug; report it with this warning. Until an EDK release fixes it, keep editing the automation in the platform.",
546
+ settleByState: true,
547
+ });
548
+ continue;
549
+ }
331
550
  extractedAutomations.push({ autoBlock, autoLabel, owned: automationOwnedAddresses(doc, autoLabel), extracted });
332
551
  }
333
552
  catch (err) {
@@ -354,7 +573,7 @@ function extractAutomations(ownBlocks, stream, ctx) {
354
573
  message: err.message,
355
574
  code: "unresolved-task-filter-ref",
356
575
  });
357
- skip(autoBlock, owned, scopedLabelToBagKey(ctx.appTfLabel, autoLabel));
576
+ skip(autoBlock, owned, scopedLabelToBagKey(ctx.appTfLabel, autoLabel), `pull could not turn its export into source: ${err.message}`);
358
577
  release({
359
578
  autoBlock, autoLabel, owned, refName: scopedLabelToBagKey(ctx.appTfLabel, autoLabel),
360
579
  why: `pull could not turn its export into source: ${err.message}`,
@@ -364,18 +583,20 @@ function extractAutomations(ownBlocks, stream, ctx) {
364
583
  });
365
584
  continue;
366
585
  }
367
- skip(autoBlock, owned, scopedLabelToBagKey(ctx.appTfLabel, autoLabel));
586
+ // edk#1480: name the dropped automation and say what that means, as a
587
+ // typed gap so it counts (and fails --strict-coverage) by itself.
588
+ const why = `pull could not turn its export into source: ${err instanceof Error ? err.message : String(err)}`;
589
+ skip(autoBlock, owned, scopedLabelToBagKey(ctx.appTfLabel, autoLabel), why);
368
590
  // No authored form can manage these, so release an earlier adoption
369
591
  // rather than let the next apply destroy the live automation:
370
- // sibling-loop item refs (#1320) and multi-trigger (#1785 / #39).
592
+ // sibling-loop item refs (#1320), multi-trigger (#1785 / #39), and a
593
+ // reference to a deleted calculation's result (#3085).
371
594
  // Soft diagnostic, not a validation fatal — the rest of the app must
372
595
  // still adopt and plan clean while these stay platform-managed only.
373
596
  const released = err instanceof ForEachItemOutsideLoopError ||
597
+ err instanceof UnresolvedCalculationOutputError ||
374
598
  err instanceof UnsupportedMultiTriggerError ||
375
599
  err instanceof UnresolvedForeignServiceAccountError;
376
- // edk#1480: name the dropped automation and say what that means, as a
377
- // typed gap so it counts (and fails --strict-coverage) by itself.
378
- const why = `pull could not turn its export into source: ${err instanceof Error ? err.message : String(err)}`;
379
600
  if (released) {
380
601
  release({
381
602
  autoBlock, autoLabel, owned, refName: scopedLabelToBagKey(ctx.appTfLabel, autoLabel), why,
@@ -399,16 +620,19 @@ function extractAutomations(ownBlocks, stream, ctx) {
399
620
  const skippedAddresses = new Set(skipped);
400
621
  const releasedAddresses = new Set(releaseIfManaged);
401
622
  for (const entry of kept) {
402
- const target = referencedAddress(stream, entry.owned, skippedAddresses);
623
+ // A Run Automation call to a skipped automation keeps the caller: its
624
+ // source names the target by display name (#3047). Any other reference
625
+ // to a skipped resource still skips it.
626
+ const target = referencedAddress(stream, entry.owned, skippedAddresses, runnable);
403
627
  if (target === undefined)
404
628
  continue;
405
629
  kept.delete(entry);
406
630
  cascaded = true;
407
- skip(entry.autoBlock, entry.owned, entry.extracted.refName);
408
631
  const gap = {
409
632
  why: `it uses ${target}, which pull skipped, so its reference would point at nothing`,
410
633
  nextStep: `Fix ${target} first (see its own warning), then pull again.`,
411
634
  };
635
+ skip(entry.autoBlock, entry.owned, entry.extracted.refName, gap.why, target);
412
636
  if (releasedAddresses.has(target)) {
413
637
  release({
414
638
  autoBlock: entry.autoBlock, autoLabel: entry.autoLabel, owned: entry.owned, refName: entry.extracted.refName, ...gap,
@@ -442,7 +666,7 @@ function extractAutomations(ownBlocks, stream, ctx) {
442
666
  changed = false;
443
667
  const isSource = sourceGiven(archivedOwned());
444
668
  for (const entry of [...archived]) {
445
- if (externalReferrers(stream, entry.owned, isSource).length === 0)
669
+ if (externalReferrers(stream, entry.owned, isSource, runnable).length === 0)
446
670
  continue;
447
671
  archived.delete(entry);
448
672
  changed = true;
@@ -452,7 +676,7 @@ function extractAutomations(ownBlocks, stream, ctx) {
452
676
  const quarantineOwnFiles = [];
453
677
  const settled = [];
454
678
  for (const entry of released) {
455
- const keptFor = archived.has(entry) ? [] : externalReferrers(stream, entry.owned, isSource);
679
+ const keptFor = archived.has(entry) ? [] : externalReferrers(stream, entry.owned, isSource, runnable);
456
680
  if (keptFor.length === 0) {
457
681
  quarantineOwnFiles.push({
458
682
  kind: "automation",
@@ -475,14 +699,16 @@ function extractAutomations(ownBlocks, stream, ctx) {
475
699
  }
476
700
  return { quarantineOwnFiles, diagnostics: settled };
477
701
  };
702
+ const unmanagedTargetName = unmanagedRunTargetName(runnableNames, ctx.appRefName, stream, ctx);
478
703
  for (const { autoLabel, extracted } of kept) {
479
704
  // Keep automationFromTf's label-derived refName — agent/skill tools store
480
705
  // the same scopedLabelToBagKey as automationKey. Pushing bare AST (name
481
706
  // only) made missing-automation diagnostics false-positive on every real
482
707
  // extract (issue #395 / PR #417 review).
483
- items.push({ ...extracted.ast, refName: extracted.refName });
708
+ items.push({ ...withUnmanagedRunTargets(extracted.ast, unmanagedTargetName), refName: extracted.refName });
484
709
  adoptionAddressAliases.push(...extracted.adoptionAddressAliases);
485
710
  diagnostics.push(...(extracted.diagnostics ?? []).map((diagnostic) => `${autoLabel}: ${diagnostic}`));
711
+ triggerReferenceRepairs.push(...(extracted.triggerReferenceRepairs ?? []));
486
712
  }
487
713
  // A trigger, task, or publish with no automation resource is not in any
488
714
  // skeleton's graph. extractAutomations never sees it, and its resource type
@@ -521,6 +747,8 @@ function extractAutomations(ownBlocks, stream, ctx) {
521
747
  ...(validations.length > 0 && { validations }),
522
748
  ...(skippedOwnFiles.length > 0 && { skippedOwnFiles }),
523
749
  ...(unmanagedLookups.length > 0 && { unmanagedLookups }),
750
+ ...(skippedReports.length > 0 && { skippedReports }),
751
+ ...(triggerReferenceRepairs.length > 0 && { triggerReferenceRepairs }),
524
752
  ...(settleAfterExtract !== undefined && { settleAfterExtract }),
525
753
  };
526
754
  }
@@ -588,6 +816,7 @@ export const automationModule = {
588
816
  ...(opts.foreignAppRefNamespaces !== undefined && { foreignAppRefNamespaces: opts.foreignAppRefNamespaces }),
589
817
  ...(opts.foreignElementRefNamespaces !== undefined && { foreignElementRefNamespaces: opts.foreignElementRefNamespaces }),
590
818
  ...(opts.foreignTaskRefNames !== undefined && { foreignTaskRefNames: opts.foreignTaskRefNames }),
819
+ ...(opts.foreignSearchTableRefsByName !== undefined && { foreignSearchTableRefsByName: opts.foreignSearchTableRefsByName }),
591
820
  ...(opts.unresolvedReferences !== undefined && { unresolvedReferences: opts.unresolvedReferences }),
592
821
  });
593
822
  return {
@@ -621,6 +850,8 @@ export const automationModule = {
621
850
  orgRefs: ctx.orgRefs,
622
851
  workspaceAspects: ctx.workspaceAspects,
623
852
  ...(ctx.outOfScopeApps !== undefined && { outOfScopeApps: ctx.outOfScopeApps }),
853
+ ...(ctx.outOfScopeElements !== undefined && { outOfScopeElements: ctx.outOfScopeElements }),
854
+ ...(ctx.catalogElementIdentities !== undefined && { catalogElementIdentities: ctx.catalogElementIdentities }),
624
855
  localsAttrs: ctx.localsAttrs,
625
856
  serviceAccounts: ctx.streamRootEntity?.payload?.serviceAccounts,
626
857
  activeAutomationRefNames: ctx.activeAutomationRefNames ?? new Set((ctx.siblingEntities ?? [])
@@ -672,6 +903,14 @@ export const automationModule = {
672
903
  { resourceType: "elementum_create_record_task", attribute: "fields" },
673
904
  ],
674
905
  recordFieldOutputKeys: [{ nameAttribute: "name", ownerAttribute: "object_id" }],
906
+ listEntryOutputKeys: [{
907
+ resourceType: "elementum_calculation_task",
908
+ prefix: "calculationOutputMap.",
909
+ listAttribute: "calculations",
910
+ idAttribute: "id",
911
+ keyAttribute: "variable_name",
912
+ types: { localPrefix: "edk_calculation_outputs_", typeAttribute: "output_type", multipleAttribute: "multiple" },
913
+ }],
675
914
  // A platform-named audit ref ("Created on", or "<input> - Created on")
676
915
  // and the provider's alias of it ("Created At"), which a build reads
677
916
  // (#2936). The provider skips the alias when the owner has its own
@@ -42,7 +42,11 @@ export interface SwitchCase<TTrigger, TActions extends Record<string, unknown>,
42
42
  readonly actions: (innerCtx: Context<TTrigger, TActions, TVars>) => readonly NestedActionEntry[];
43
43
  }
44
44
  export interface SwitchConfig<TTrigger, TActions extends Record<string, unknown>, TVars extends Record<string, unknown> = NoVariables> {
45
- /** Ordered cases — first match wins. */
45
+ /**
46
+ * Ordered cases — first match wins. May be empty: the platform keeps an If
47
+ * task whose cases were all removed, and pull prints it as `cases: []`, an
48
+ * empty step (#3105). The platform can refuse to publish it.
49
+ */
46
50
  readonly cases: readonly SwitchCase<TTrigger, TActions, TVars>[];
47
51
  /**
48
52
  * Actions when no case matches (the default/else branch). Plain function form
@@ -70,7 +74,7 @@ export interface ForkJoinBranch<TTrigger, TActions extends Record<string, unknow
70
74
  readonly actions: (innerCtx: Context<TTrigger, TActions, TVars>) => readonly NestedActionEntry[];
71
75
  }
72
76
  export interface ForkJoinConfig<TTrigger, TActions extends Record<string, unknown>, TVars extends Record<string, unknown> = NoVariables> {
73
- /** Parallel branches, each executed concurrently. */
77
+ /** Parallel branches, each executed concurrently. May be empty, as pulled (#3105). */
74
78
  readonly branches: readonly ForkJoinBranch<TTrigger, TActions, TVars>[];
75
79
  }
76
80
  export declare function forkJoin<TTrigger, TActions extends Record<string, unknown>, TVars extends Record<string, unknown> = NoVariables>(_ctx: Context<TTrigger, TActions, TVars>, config: ForkJoinConfig<TTrigger, TActions, TVars>): ActionDef<Empty>;
@@ -10,8 +10,6 @@ export function forEach(_ctx, config) {
10
10
  };
11
11
  }
12
12
  export function switchAction(_ctx, config) {
13
- if (config.cases.length === 0)
14
- throw new Error("switch requires at least one case");
15
13
  const innerCtx = buildContext([]);
16
14
  const operatorChildren = config.cases.map((c) => ({
17
15
  label: c.label,
@@ -40,6 +40,14 @@ export declare function executeScriptOutputReferences(): Readonly<Record<string,
40
40
  * `record_reference` needs; a script input needs the record itself.
41
41
  */
42
42
  export declare const WHOLE_RECORD_REF_WIRE_NAMES: Readonly<Record<string, string>>;
43
+ /**
44
+ * The whole-record output a record attachment (`aiAgent` / `sendEmail`
45
+ * `{ record }`) reads. Find Related Records has one too (ultron
46
+ * FindRelatedRecordsExecutor `record`, ASPECT_RECORD; its refs map lists
47
+ * `First found record`, checked live for #3069), so it is mapped here even
48
+ * though script inputs still read its `.record` as the ID (#1499).
49
+ */
50
+ export declare const ATTACHMENT_WHOLE_RECORD_REF_WIRE_NAMES: Readonly<Record<string, string>>;
43
51
  /**
44
52
  * Marks a trigger reference that a field-mapped script input reads as the
45
53
  * whole record (edk#1284). Record triggers expose the whole record
@@ -122,6 +122,17 @@ export const WHOLE_RECORD_REF_WIRE_NAMES = {
122
122
  createRecord: "Created record",
123
123
  updateField: "Updated record",
124
124
  };
125
+ /**
126
+ * The whole-record output a record attachment (`aiAgent` / `sendEmail`
127
+ * `{ record }`) reads. Find Related Records has one too (ultron
128
+ * FindRelatedRecordsExecutor `record`, ASPECT_RECORD; its refs map lists
129
+ * `First found record`, checked live for #3069), so it is mapped here even
130
+ * though script inputs still read its `.record` as the ID (#1499).
131
+ */
132
+ export const ATTACHMENT_WHOLE_RECORD_REF_WIRE_NAMES = {
133
+ ...WHOLE_RECORD_REF_WIRE_NAMES,
134
+ findRelatedRecords: "First found record",
135
+ };
125
136
  /**
126
137
  * Marks a trigger reference that a field-mapped script input reads as the
127
138
  * whole record (edk#1284). Record triggers expose the whole record