@elementumai/edk 0.13.4 → 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 (123) 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 +10 -0
  7. package/dist-sdk/src/engine/coverage-gaps.js +16 -0
  8. package/dist-sdk/src/engine/pull/context.d.ts +56 -0
  9. package/dist-sdk/src/engine/pull/context.js +8 -0
  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 +13 -1
  15. package/dist-sdk/src/engine/pull/stream-root.js +54 -4
  16. package/dist-sdk/src/engine/validation.d.ts +36 -1
  17. package/dist-sdk/src/engine/validation.js +56 -2
  18. package/dist-sdk/src/engine/workspace/loader.d.ts +6 -0
  19. package/dist-sdk/src/engine/workspace/loader.js +87 -2
  20. package/dist-sdk/src/entities/access-policy/from-tf.d.ts +7 -0
  21. package/dist-sdk/src/entities/access-policy/from-tf.js +58 -17
  22. package/dist-sdk/src/entities/access-policy/to-tf.d.ts +3 -1
  23. package/dist-sdk/src/entities/access-policy/to-tf.js +1 -1
  24. package/dist-sdk/src/entities/agent/build.d.ts +15 -0
  25. package/dist-sdk/src/entities/agent/build.js +139 -16
  26. package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.d.ts +3 -3
  27. package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +39 -25
  28. package/dist-sdk/src/entities/agent/module.js +95 -3
  29. package/dist-sdk/src/entities/agent/to-tf.js +6 -4
  30. package/dist-sdk/src/entities/agent-evaluation/from-tf.d.ts +7 -0
  31. package/dist-sdk/src/entities/agent-evaluation/from-tf.js +14 -5
  32. package/dist-sdk/src/entities/agent-evaluation/module.js +4 -2
  33. package/dist-sdk/src/entities/agent-tool/from-tf.d.ts +11 -2
  34. package/dist-sdk/src/entities/agent-tool/from-tf.js +38 -40
  35. package/dist-sdk/src/entities/agent-tool/to-tf.js +12 -5
  36. package/dist-sdk/src/entities/app/build.d.ts +1 -1
  37. package/dist-sdk/src/entities/automation/build.d.ts +75 -42
  38. package/dist-sdk/src/entities/automation/build.js +17 -7
  39. package/dist-sdk/src/entities/automation/deserializer/ast.d.ts +14 -2
  40. package/dist-sdk/src/entities/automation/deserializer/print-automation.d.ts +9 -0
  41. package/dist-sdk/src/entities/automation/deserializer/print-automation.js +57 -12
  42. package/dist-sdk/src/entities/automation/from-tf.d.ts +51 -0
  43. package/dist-sdk/src/entities/automation/from-tf.js +476 -93
  44. package/dist-sdk/src/entities/automation/index.d.ts +1 -1
  45. package/dist-sdk/src/entities/automation/index.js +1 -1
  46. package/dist-sdk/src/entities/automation/module.js +90 -9
  47. package/dist-sdk/src/entities/automation/operators.d.ts +6 -2
  48. package/dist-sdk/src/entities/automation/operators.js +0 -2
  49. package/dist-sdk/src/entities/automation/task-output-labels.d.ts +8 -0
  50. package/dist-sdk/src/entities/automation/task-output-labels.js +11 -0
  51. package/dist-sdk/src/entities/automation/tasks.d.ts +37 -2
  52. package/dist-sdk/src/entities/automation/tasks.js +38 -1
  53. package/dist-sdk/src/entities/automation/to-tf.d.ts +8 -0
  54. package/dist-sdk/src/entities/automation/to-tf.js +413 -47
  55. package/dist-sdk/src/entities/chart/to-tf.js +18 -5
  56. package/dist-sdk/src/entities/dashboard/from-tf.js +45 -11
  57. package/dist-sdk/src/entities/dashboard-widget-order/order.d.ts +5 -3
  58. package/dist-sdk/src/entities/dashboard-widget-order/order.js +6 -4
  59. package/dist-sdk/src/entities/datamine/from-tf.js +10 -3
  60. package/dist-sdk/src/entities/dynamic-layout/build.d.ts +9 -2
  61. package/dist-sdk/src/entities/dynamic-layout/from-tf.js +35 -7
  62. package/dist-sdk/src/entities/dynamic-layout/to-tf.js +63 -7
  63. package/dist-sdk/src/entities/element/build.d.ts +4 -1
  64. package/dist-sdk/src/entities/element/build.js +3 -4
  65. package/dist-sdk/src/entities/field/from-tf.js +8 -1
  66. package/dist-sdk/src/entities/field/to-tf.d.ts +29 -2
  67. package/dist-sdk/src/entities/field/to-tf.js +106 -7
  68. package/dist-sdk/src/entities/phone-service/from-tf.d.ts +7 -0
  69. package/dist-sdk/src/entities/phone-service/from-tf.js +15 -7
  70. package/dist-sdk/src/entities/phone-service/module.js +4 -2
  71. package/dist-sdk/src/entities/portal/to-tf.d.ts +1 -1
  72. package/dist-sdk/src/entities/portal/to-tf.js +61 -2
  73. package/dist-sdk/src/entities/record-create-form/from-tf.js +3 -1
  74. package/dist-sdk/src/entities/relationship/from-tf.js +34 -4
  75. package/dist-sdk/src/entities/relationship/to-tf.js +24 -6
  76. package/dist-sdk/src/entities/role/from-tf.js +3 -1
  77. package/dist-sdk/src/entities/search-table/from-tf.d.ts +3 -1
  78. package/dist-sdk/src/entities/search-table/from-tf.js +6 -3
  79. package/dist-sdk/src/entities/search-table/module.js +18 -2
  80. package/dist-sdk/src/entities/search-table/to-tf.js +10 -16
  81. package/dist-sdk/src/entities/shared/aspect-target-from-tf.js +6 -1
  82. package/dist-sdk/src/entities/shared/filters/index.d.ts +6 -1
  83. package/dist-sdk/src/entities/shared/filters/index.js +8 -2
  84. package/dist-sdk/src/entities/shared/filters/print.js +18 -7
  85. package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +11 -0
  86. package/dist-sdk/src/entities/shared/filters/tf-codec.js +24 -2
  87. package/dist-sdk/src/entities/shared/run-automation-requirement.d.ts +15 -0
  88. package/dist-sdk/src/entities/shared/run-automation-requirement.js +28 -0
  89. package/dist-sdk/src/entities/shared/search-table-address.d.ts +17 -0
  90. package/dist-sdk/src/entities/shared/search-table-address.js +24 -0
  91. package/dist-sdk/src/entities/shared/skip-release.d.ts +49 -0
  92. package/dist-sdk/src/entities/shared/skip-release.js +74 -0
  93. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.d.ts +3 -3
  94. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +11 -5
  95. package/dist-sdk/src/entities/skill/module.js +3 -25
  96. package/dist-sdk/src/entities/skill-tool/from-tf.d.ts +4 -2
  97. package/dist-sdk/src/entities/skill-tool/from-tf.js +28 -27
  98. package/dist-sdk/src/entities/skill-tool/to-tf.js +12 -5
  99. package/dist-sdk/src/entities/skill-tool/types.d.ts +1 -0
  100. package/dist-sdk/src/entities/skill-tool/types.js +2 -1
  101. package/dist-sdk/src/entities/table/catalog.d.ts +16 -0
  102. package/dist-sdk/src/entities/table/catalog.js +44 -2
  103. package/dist-sdk/src/entities/table/from-tf.js +30 -4
  104. package/dist-sdk/src/entities/table/keys.d.ts +27 -0
  105. package/dist-sdk/src/entities/table/keys.js +46 -0
  106. package/dist-sdk/src/entities/table/to-tf.js +2 -2
  107. package/dist-sdk/src/entities/view/agent-view-layout-from-tf.d.ts +12 -1
  108. package/dist-sdk/src/entities/view/agent-view-layout-from-tf.js +9 -4
  109. package/dist-sdk/src/entities/view/agent-view-layout-to-tf.js +215 -10
  110. package/dist-sdk/src/entities/view/agent-view-layout.d.ts +10 -4
  111. package/dist-sdk/src/entities/view/custom-view-runtime-rules.d.ts +43 -0
  112. package/dist-sdk/src/entities/view/custom-view-runtime-rules.js +285 -0
  113. package/dist-sdk/src/entities/view/custom-view-validate.d.ts +3 -1
  114. package/dist-sdk/src/entities/view/custom-view-validate.js +24 -5
  115. package/dist-sdk/src/entities/view/from-tf.js +14 -1
  116. package/dist-sdk/src/entities/widget/from-tf.js +14 -7
  117. package/dist-sdk/src/entities/widget/to-tf.js +7 -5
  118. package/dist-sdk/src/graph/index.d.ts +14 -1
  119. package/dist-sdk/src/graph/index.js +2 -0
  120. package/dist-sdk/src/graph/resource-types.d.ts +2 -0
  121. package/dist-sdk/src/graph/resource-types.js +3 -0
  122. package/dist-sdk/src/graph/types.d.ts +82 -0
  123. 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";
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
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
@@ -10,7 +10,7 @@ function elementOwnerHandle(payload) {
10
10
  import { renderAutomationCatalogEntry } from "./catalog-render.js";
11
11
  import { automationLookupOwnerBlock } from "./lookup-owner.js";
12
12
  import { hasUnresolvedForEachItem, preserveAuthoredAutomationPullMeta, printAutomationV2WithScriptFiles, SCRIPT_FILES_DIR } from "./deserializer/print-automation.js";
13
- 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";
14
14
  import { scriptFileRefs } from "./script-code.js";
15
15
  import { typedCoverageGap } from "../../engine/coverage-gaps.js";
16
16
  import { executeScriptOutputReferences, taskOutputReferences, USER_SEARCH_OUTPUT_REFERENCES } from "./task-output-labels.js";
@@ -345,12 +345,57 @@ function withoutRunTargetSites(block, runnable) {
345
345
  return out;
346
346
  }
347
347
  /**
348
- * `value` with each automation ref of this owner (`ownerHandle`) whose key is
349
- * in `names` given that display name (#3047). Another app's automation can
350
- * have the same key, so the owner has to match too.
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.
351
356
  */
352
- function withUnmanagedRunTargets(value, names, ownerHandle) {
353
- if (names.size === 0)
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)
354
399
  return value;
355
400
  // Copy on write, through plain arrays and objects only: every other value
356
401
  // (and any subtree with no such ref) keeps its identity and prototype.
@@ -366,7 +411,7 @@ function withUnmanagedRunTargets(value, names, ownerHandle) {
366
411
  return node;
367
412
  const record = node;
368
413
  if (record["kind"] === "automation" && typeof record["automationKey"] === "string") {
369
- const name = record["appHandle"] === ownerHandle ? names.get(record["automationKey"]) : undefined;
414
+ const name = nameOf(record["appHandle"], record["automationKey"]);
370
415
  return name === undefined ? record : { ...record, unmanagedName: name };
371
416
  }
372
417
  let changed = false;
@@ -396,6 +441,8 @@ function extractAutomations(ownBlocks, stream, ctx) {
396
441
  // caller skipped only because of another skipped automation names that
397
442
  // one's root cause, so the summary can group them.
398
443
  const skippedReports = [];
444
+ // References in the kept automations that the first plan rewrites (#3109).
445
+ const triggerReferenceRepairs = [];
399
446
  const skippedOwner = new Map();
400
447
  const rootCause = new Map();
401
448
  // Skipped automations a Run Automation call can still name by display
@@ -482,6 +529,24 @@ function extractAutomations(ownBlocks, stream, ctx) {
482
529
  });
483
530
  continue;
484
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
+ }
485
550
  extractedAutomations.push({ autoBlock, autoLabel, owned: automationOwnedAddresses(doc, autoLabel), extracted });
486
551
  }
487
552
  catch (err) {
@@ -524,10 +589,12 @@ function extractAutomations(ownBlocks, stream, ctx) {
524
589
  skip(autoBlock, owned, scopedLabelToBagKey(ctx.appTfLabel, autoLabel), why);
525
590
  // No authored form can manage these, so release an earlier adoption
526
591
  // rather than let the next apply destroy the live automation:
527
- // 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).
528
594
  // Soft diagnostic, not a validation fatal — the rest of the app must
529
595
  // still adopt and plan clean while these stay platform-managed only.
530
596
  const released = err instanceof ForEachItemOutsideLoopError ||
597
+ err instanceof UnresolvedCalculationOutputError ||
531
598
  err instanceof UnsupportedMultiTriggerError ||
532
599
  err instanceof UnresolvedForeignServiceAccountError;
533
600
  if (released) {
@@ -632,14 +699,16 @@ function extractAutomations(ownBlocks, stream, ctx) {
632
699
  }
633
700
  return { quarantineOwnFiles, diagnostics: settled };
634
701
  };
702
+ const unmanagedTargetName = unmanagedRunTargetName(runnableNames, ctx.appRefName, stream, ctx);
635
703
  for (const { autoLabel, extracted } of kept) {
636
704
  // Keep automationFromTf's label-derived refName — agent/skill tools store
637
705
  // the same scopedLabelToBagKey as automationKey. Pushing bare AST (name
638
706
  // only) made missing-automation diagnostics false-positive on every real
639
707
  // extract (issue #395 / PR #417 review).
640
- items.push({ ...withUnmanagedRunTargets(extracted.ast, runnableNames, ctx.appRefName), refName: extracted.refName });
708
+ items.push({ ...withUnmanagedRunTargets(extracted.ast, unmanagedTargetName), refName: extracted.refName });
641
709
  adoptionAddressAliases.push(...extracted.adoptionAddressAliases);
642
710
  diagnostics.push(...(extracted.diagnostics ?? []).map((diagnostic) => `${autoLabel}: ${diagnostic}`));
711
+ triggerReferenceRepairs.push(...(extracted.triggerReferenceRepairs ?? []));
643
712
  }
644
713
  // A trigger, task, or publish with no automation resource is not in any
645
714
  // skeleton's graph. extractAutomations never sees it, and its resource type
@@ -679,6 +748,7 @@ function extractAutomations(ownBlocks, stream, ctx) {
679
748
  ...(skippedOwnFiles.length > 0 && { skippedOwnFiles }),
680
749
  ...(unmanagedLookups.length > 0 && { unmanagedLookups }),
681
750
  ...(skippedReports.length > 0 && { skippedReports }),
751
+ ...(triggerReferenceRepairs.length > 0 && { triggerReferenceRepairs }),
682
752
  ...(settleAfterExtract !== undefined && { settleAfterExtract }),
683
753
  };
684
754
  }
@@ -746,6 +816,7 @@ export const automationModule = {
746
816
  ...(opts.foreignAppRefNamespaces !== undefined && { foreignAppRefNamespaces: opts.foreignAppRefNamespaces }),
747
817
  ...(opts.foreignElementRefNamespaces !== undefined && { foreignElementRefNamespaces: opts.foreignElementRefNamespaces }),
748
818
  ...(opts.foreignTaskRefNames !== undefined && { foreignTaskRefNames: opts.foreignTaskRefNames }),
819
+ ...(opts.foreignSearchTableRefsByName !== undefined && { foreignSearchTableRefsByName: opts.foreignSearchTableRefsByName }),
749
820
  ...(opts.unresolvedReferences !== undefined && { unresolvedReferences: opts.unresolvedReferences }),
750
821
  });
751
822
  return {
@@ -779,6 +850,8 @@ export const automationModule = {
779
850
  orgRefs: ctx.orgRefs,
780
851
  workspaceAspects: ctx.workspaceAspects,
781
852
  ...(ctx.outOfScopeApps !== undefined && { outOfScopeApps: ctx.outOfScopeApps }),
853
+ ...(ctx.outOfScopeElements !== undefined && { outOfScopeElements: ctx.outOfScopeElements }),
854
+ ...(ctx.catalogElementIdentities !== undefined && { catalogElementIdentities: ctx.catalogElementIdentities }),
782
855
  localsAttrs: ctx.localsAttrs,
783
856
  serviceAccounts: ctx.streamRootEntity?.payload?.serviceAccounts,
784
857
  activeAutomationRefNames: ctx.activeAutomationRefNames ?? new Set((ctx.siblingEntities ?? [])
@@ -830,6 +903,14 @@ export const automationModule = {
830
903
  { resourceType: "elementum_create_record_task", attribute: "fields" },
831
904
  ],
832
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
+ }],
833
914
  // A platform-named audit ref ("Created on", or "<input> - Created on")
834
915
  // and the provider's alias of it ("Created At"), which a build reads
835
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
@@ -1044,8 +1044,12 @@ export interface ApprovalChainOptions {
1044
1044
  readonly record: RecordReference;
1045
1045
  /** User requesting the approval. Use a USER_ID value reference. */
1046
1046
  readonly requester: ValueOrRef<unknown>;
1047
- /** Optional dynamic approvers. Each entry must resolve to a USER_ID. */
1048
- readonly approvers?: readonly ValueOrRef<unknown>[];
1047
+ /**
1048
+ * Optional dynamic approvers, one per dynamic approver slot of the process,
1049
+ * in order. A plain entry is a user: a USER_ID value reference (or a
1050
+ * variable holding a user id). Wrap a group in `groupApprover(...)`.
1051
+ */
1052
+ readonly approvers?: readonly (ValueOrRef<unknown> | ApprovalGroupApprover)[];
1049
1053
  readonly reason?: ValueOrRef<unknown>;
1050
1054
  readonly summary?: ValueOrRef<unknown>;
1051
1055
  /**
@@ -1056,6 +1060,37 @@ export interface ApprovalChainOptions {
1056
1060
  */
1057
1061
  readonly tag?: ValueOrRef<unknown>;
1058
1062
  }
1063
+ /**
1064
+ * A group in a dynamic approver slot of `approvalChain`, with how many of its
1065
+ * members must approve or deny. Build it with `groupApprover(...)`.
1066
+ */
1067
+ export interface ApprovalGroupApprover {
1068
+ readonly kind: "groupApprover";
1069
+ /** The group: a GROUP_ID value reference (a group field's `.id`), a variable holding a group id, or an `org.groups` token. */
1070
+ readonly group: ValueOrRef<string> | GroupRef | Ref<unknown, string>;
1071
+ readonly approvalsRequired: number;
1072
+ readonly denialsRequired: number;
1073
+ }
1074
+ /**
1075
+ * What `groupApprover` accepts as its group: an `org.groups` token, a group
1076
+ * id, a reference whose value is a string (a group field's `.id`), or a
1077
+ * variable (its reference is untyped). A reference to anything else, such as
1078
+ * the group field itself (`record.team` instead of `record.team.id`), is a
1079
+ * type error.
1080
+ */
1081
+ export type GroupApproverValue<G> = G extends GroupRef ? G : G extends string ? G : G extends Ref<infer T, string> ? (unknown extends T ? G : [T] extends [string] ? G : GroupApproverArgumentError) : GroupApproverArgumentError;
1082
+ /** The type a wrong `groupApprover` argument is checked against, so the compiler error says what to pass. */
1083
+ export interface GroupApproverArgumentError {
1084
+ readonly "groupApprover takes a group: an org.groups token, a Group field's .id (record.<field>.id, not record.<field>), a group id string, or a variable": never;
1085
+ }
1086
+ /**
1087
+ * A group approves in an `approvalChain` dynamic approver slot:
1088
+ * `groupApprover(ctx.item.approvalGroup.id, { approvalsRequired: 1, denialsRequired: 1 })`.
1089
+ */
1090
+ export declare function groupApprover<G>(group: G & GroupApproverValue<G>, options: {
1091
+ readonly approvalsRequired: number;
1092
+ readonly denialsRequired: number;
1093
+ }): ApprovalGroupApprover;
1059
1094
  export declare function approvalChain(opts: ApprovalChainOptions): ActionDef<Empty>;
1060
1095
  export type ApprovalChainTemplateOptions = ApprovalChainOptions;
1061
1096
  export declare function approvalChainTemplate(opts: ApprovalChainTemplateOptions): ActionDef<Empty>;
@@ -927,6 +927,43 @@ export function bulkExcel(opts) {
927
927
  },
928
928
  };
929
929
  }
930
+ /**
931
+ * A group approves in an `approvalChain` dynamic approver slot:
932
+ * `groupApprover(ctx.item.approvalGroup.id, { approvalsRequired: 1, denialsRequired: 1 })`.
933
+ */
934
+ export function groupApprover(group, options) {
935
+ if (group === undefined || group === null)
936
+ throw new Error("groupApprover requires a group.");
937
+ for (const [name, value] of [["approvalsRequired", options.approvalsRequired], ["denialsRequired", options.denialsRequired]]) {
938
+ if (!Number.isInteger(value) || value < 0) {
939
+ throw new Error(`groupApprover: ${name} must be an integer >= 0 (got ${String(value)}).`);
940
+ }
941
+ }
942
+ return {
943
+ kind: "groupApprover",
944
+ group: group,
945
+ approvalsRequired: options.approvalsRequired,
946
+ denialsRequired: options.denialsRequired,
947
+ };
948
+ }
949
+ function isGroupApprover(value) {
950
+ return !isRef(value) && typeof value === "object" && value !== null && value.kind === "groupApprover";
951
+ }
952
+ /**
953
+ * The approvers config: `approverReferences` while every slot is a user (the
954
+ * HCL `approver_references`), otherwise `approvers`, one `{ user }` or
955
+ * `{ group, approvalsRequired, denialsRequired }` per slot, the only form that
956
+ * keeps a group (edk#3163). Export makes the same choice.
957
+ */
958
+ function approversConfig(approvers) {
959
+ if (!approvers.some(isGroupApprover))
960
+ return { approverReferences: approvers.map((a) => serializeValueOrRef(a)) };
961
+ return {
962
+ approvers: approvers.map((a) => isGroupApprover(a)
963
+ ? { group: serializeValueOrRef(a.group), approvalsRequired: a.approvalsRequired, denialsRequired: a.denialsRequired }
964
+ : { user: serializeValueOrRef(a) }),
965
+ };
966
+ }
930
967
  export function approvalChain(opts) {
931
968
  return {
932
969
  key: "approvalChain",
@@ -934,7 +971,7 @@ export function approvalChain(opts) {
934
971
  approvalProcessId: opts.approvalProcess,
935
972
  recordReference: serializeValueOrRef(opts.record),
936
973
  requesterReference: serializeValueOrRef(opts.requester),
937
- ...(opts.approvers !== undefined ? { approverReferences: opts.approvers.map((a) => serializeValueOrRef(a)) } : {}),
974
+ ...(opts.approvers !== undefined ? approversConfig(opts.approvers) : {}),
938
975
  ...(opts.reason !== undefined ? { reason: serializeValueOrRef(opts.reason) } : {}),
939
976
  ...(opts.summary !== undefined ? { summary: serializeValueOrRef(opts.summary) } : {}),
940
977
  ...(opts.tag !== undefined ? { tags: serializeValueOrRef(opts.tag) } : {}),
@@ -75,6 +75,10 @@ export interface AutomationToTfContext {
75
75
  readonly workspaceAspects?: ReadonlyMap<string, WorkspaceAspect>;
76
76
  /** See `ToTfContext.outOfScopeApps`. */
77
77
  readonly outOfScopeApps?: ReadonlyMap<string, ForeignRootIdentity>;
78
+ /** See `ToTfContext.outOfScopeElements`. */
79
+ readonly outOfScopeElements?: ReadonlyMap<string, ForeignRootIdentity>;
80
+ /** See `ToTfContext.catalogElementIdentities`. */
81
+ readonly catalogElementIdentities?: ReadonlyMap<string, ForeignRootIdentity>;
78
82
  /**
79
83
  * The build's shared `locals.tf` attrs map — mutated in place so a foreign
80
84
  * field crossing through {@link crossAppFieldToTf} can contribute its own
@@ -102,6 +106,10 @@ export interface AutomationToTfResult {
102
106
  * plus field mappings, and the script receives `{}` at runtime. Record
103
107
  * triggers' `ctx.trigger.record` and the `.record` of recordSearch,
104
108
  * createRecord and updateField carry the whole record (#1284, #1489).
109
+ * AI agent and email record attachments read the record's files from the
110
+ * whole record too: an on-demand record parameter or an explicit record ID
111
+ * fails there (#3069). A task's `.record`, Find Related Records' included,
112
+ * builds the whole record in an attachment.
105
113
  */
106
114
  export declare function recordIdFieldMappingFailures(entity: DeployableEntity, payload: object, address: string): ValidationFailure[];
107
115
  export declare function automationToTf(entity: DeployableEntity, ctx: AutomationToTfContext): AutomationToTfResult;