@elementumai/edk 0.13.1 → 0.13.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/dist-sdk/src/engine/coverage-gaps.d.ts +10 -0
  2. package/dist-sdk/src/engine/coverage-gaps.js +19 -0
  3. package/dist-sdk/src/engine/progress.d.ts +1 -0
  4. package/dist-sdk/src/engine/progress.js +6 -0
  5. package/dist-sdk/src/engine/pull/context.d.ts +10 -4
  6. package/dist-sdk/src/engine/pull/context.js +2 -0
  7. package/dist-sdk/src/engine/pull/result-output.d.ts +2 -0
  8. package/dist-sdk/src/engine/pull/result-output.js +1 -1
  9. package/dist-sdk/src/engine/pull/stream-root.d.ts +3 -1
  10. package/dist-sdk/src/engine/pull/stream-root.js +3 -0
  11. package/dist-sdk/src/engine/tf/escape.d.ts +8 -3
  12. package/dist-sdk/src/engine/tf/escape.js +17 -4
  13. package/dist-sdk/src/entities/app/index.d.ts +1 -1
  14. package/dist-sdk/src/entities/automation/deserializer/print-automation.js +8 -0
  15. package/dist-sdk/src/entities/automation/module.js +29 -7
  16. package/dist-sdk/src/entities/automation/omitted-ref.d.ts +12 -0
  17. package/dist-sdk/src/entities/automation/omitted-ref.js +21 -0
  18. package/dist-sdk/src/entities/automation/to-tf.d.ts +1 -1
  19. package/dist-sdk/src/entities/automation/to-tf.js +101 -33
  20. package/dist-sdk/src/entities/automation/triggers.d.ts +5 -1
  21. package/dist-sdk/src/entities/automation/workflow-output.d.ts +7 -0
  22. package/dist-sdk/src/entities/automation/workflow-output.js +8 -0
  23. package/dist-sdk/src/entities/dynamic-layout/build.d.ts +12 -7
  24. package/dist-sdk/src/entities/dynamic-layout/from-tf.js +37 -21
  25. package/dist-sdk/src/entities/dynamic-layout/lint.d.ts +7 -0
  26. package/dist-sdk/src/entities/dynamic-layout/lint.js +48 -0
  27. package/dist-sdk/src/entities/dynamic-layout/to-tf.js +11 -3
  28. package/dist-sdk/src/entities/element/index.d.ts +1 -1
  29. package/dist-sdk/src/entities/element/to-tf.js +1 -0
  30. package/dist-sdk/src/entities/view/agent-view-layout-from-tf.d.ts +3 -3
  31. package/dist-sdk/src/entities/view/agent-view-layout-from-tf.js +6 -4
  32. package/dist-sdk/src/entities/view/agent-view-layout-to-tf.d.ts +4 -2
  33. package/dist-sdk/src/entities/view/agent-view-layout-to-tf.js +6 -1
  34. package/dist-sdk/src/entities/view/agent-view-layout.d.ts +14 -2
  35. package/dist-sdk/src/entities/view/custom-view-references.d.ts +33 -0
  36. package/dist-sdk/src/entities/view/custom-view-references.js +140 -0
  37. package/dist-sdk/src/entities/view/custom-view-validate.d.ts +10 -5
  38. package/dist-sdk/src/entities/view/custom-view-validate.js +2 -0
  39. package/dist-sdk/src/entities/view/layout-lint.d.ts +26 -0
  40. package/dist-sdk/src/entities/view/layout-lint.js +50 -0
  41. package/dist-sdk/src/entities/view/to-tf.d.ts +2 -0
  42. package/dist-sdk/src/entities/view/to-tf.js +3 -0
  43. package/dist-sdk/src/entities/visual-flow/build.d.ts +8 -1
  44. package/dist-sdk/src/entities/visual-flow/from-tf.js +16 -0
  45. package/dist-sdk/src/entities/visual-flow/initiate.d.ts +12 -0
  46. package/dist-sdk/src/entities/visual-flow/initiate.js +12 -0
  47. package/dist-sdk/src/entities/visual-flow/to-tf.js +16 -2
  48. package/dist-sdk/src/entities/widget/from-tf.js +8 -4
  49. package/dist-sdk/src/graph/index.d.ts +1 -1
  50. package/dist-sdk/src/graph/types.d.ts +13 -0
  51. package/package.json +1 -1
@@ -15,6 +15,11 @@
15
15
  * (edk#2250; the mapping is emitted, and the called workflow fails at run time)
16
16
  * - a synchronous Dynamic Reference runAutomation inside a forEach (edk#1870;
17
17
  * the task is emitted, and the caller never resumes at run time)
18
+ * - a live automation output that reads a task inside a switch case, for-each
19
+ * loop or fork/join branch (edk#2988; the output is emitted, and a republish
20
+ * fails the platform's publish check)
21
+ * - a record trigger's changedFields listing a platform-managed system field
22
+ * (edk#2989; the field is kept, and the platform never fires on its change)
18
23
  * - the custom-view non-PanesBlock root hint (check.mjs `warn`; the layout is
19
24
  * emitted exactly as authored, edk#1771)
20
25
  * - a custom-view binding to a path missing from spec.state (the page reads it
@@ -22,6 +27,11 @@
22
27
  * - the executeScript lint for an undeclared input, an output no return sets
23
28
  * (edk#2286), or a script with no top-level return (edk#2364); the script is
24
29
  * emitted as authored
30
+ * - the record details layout checks (edk#1774): an empty classic group, a
31
+ * group of more than 12 fields or of more than 8 at maxColumns 1, a
32
+ * right-panel section sharing a displayOrder with a main-area one, and in
33
+ * dynamic layouts an empty container or more than 8 stacked fields; the
34
+ * layout is emitted as authored
25
35
  *
26
36
  * The ~600 emit sites push free-form `"<where>: <what>; dropped"` strings.
27
37
  * Rather than rewrite every site, they are classified here, where they leave
@@ -15,6 +15,11 @@
15
15
  * (edk#2250; the mapping is emitted, and the called workflow fails at run time)
16
16
  * - a synchronous Dynamic Reference runAutomation inside a forEach (edk#1870;
17
17
  * the task is emitted, and the caller never resumes at run time)
18
+ * - a live automation output that reads a task inside a switch case, for-each
19
+ * loop or fork/join branch (edk#2988; the output is emitted, and a republish
20
+ * fails the platform's publish check)
21
+ * - a record trigger's changedFields listing a platform-managed system field
22
+ * (edk#2989; the field is kept, and the platform never fires on its change)
18
23
  * - the custom-view non-PanesBlock root hint (check.mjs `warn`; the layout is
19
24
  * emitted exactly as authored, edk#1771)
20
25
  * - a custom-view binding to a path missing from spec.state (the page reads it
@@ -22,6 +27,11 @@
22
27
  * - the executeScript lint for an undeclared input, an output no return sets
23
28
  * (edk#2286), or a script with no top-level return (edk#2364); the script is
24
29
  * emitted as authored
30
+ * - the record details layout checks (edk#1774): an empty classic group, a
31
+ * group of more than 12 fields or of more than 8 at maxColumns 1, a
32
+ * right-panel section sharing a displayOrder with a main-area one, and in
33
+ * dynamic layouts an empty container or more than 8 stacked fields; the
34
+ * layout is emitted as authored
25
35
  *
26
36
  * The ~600 emit sites push free-form `"<where>: <what>; dropped"` strings.
27
37
  * Rather than rewrite every site, they are classified here, where they leave
@@ -37,10 +47,19 @@ const ADVISORY_DIAGNOSTICS = [
37
47
  // [\s\S]* and anchor on the fixed rest of the message, end included (the label is a sanitized TF label).
38
48
  /^automation \S+: task "[\s\S]*" is a synchronous Dynamic Reference runAutomation inside forEach "[\s\S]*"; the platform never resumes the caller after the called automation finishes, so the steps after it never run and the run stays parked\. Move the call out of the forEach, or call a known automation by its catalog ref \(Select Automation\)$/,
39
49
  /^automation \S+: field ".*" is set from .+, a (?:whole|Multi-Select)/,
50
+ // edk#2988. Output and task names are quoted as authored, so match them with [\s\S]*.
51
+ /^automation \S+: automation output "[\s\S]*" references task "[\s\S]*" inside a switch case, for-each loop or fork\/join branch; the platform's publish check accepts outputs only from top-level tasks/,
52
+ // edk#2989. Field names are quoted as authored; anchor on the fixed rest of the message.
53
+ /^automation \S+: changedFields lists system fields? [\s\S]*; the platform never fires a record trigger on a system field's change, so (?:this trigger never fires|only the other listed fields fire it)\. Kept as listed: removing a field would change what the trigger watches \(with none left, it fires on every change\)$/,
40
54
  /^automation \S+: executeScript ".*" (?:reads input|declares output|has no top-level return) /,
41
55
  /^applied-automation-revisions\.json .*; until then no automation is checked for an edit without a revision bump$/,
42
56
  /\.root: "[^"]*" is (?:untyped|a [A-Za-z0-9_]+); the root is usually a PanesBlock \(needed for record lists to open the details pane\)$/,
43
57
  /: binds to "[^"]*", which is not in spec\.state, so it starts undefined\. Add an initial value there to set its default\.$/,
58
+ // edk#1774 record details layout checks (src/entities/view/layout-lint.ts, src/entities/dynamic-layout/lint.ts).
59
+ // Section names are quoted as authored, so match them with [\s\S]* and anchor on the fixed rest of the message.
60
+ /\.sections\[\d+\](?: \("[\s\S]*"\))?: group section (?:has no fields, widgets or agent, so the record page shows an empty section; add fields or remove it|holds \d+ fields; split them into labeled groups \(key fields first\) so the record page doesn't read as one long list|stacks \d+ fields in one column \(maxColumns: 1\); use maxColumns: 2 or split it into labeled groups)$/,
61
+ /\.sections\[\d+\](?: \("[\s\S]*"\))?: right-panel section shares displayOrder -?\d+ with main-area [\s\S]+; the platform reads sections back by displayOrder, so plan replaces this layout on every run\. Give each section its own displayOrder, counted across both panels$/,
62
+ /dynamicLayouts\.[\s\S]+\.components\.[\s\S]+: (?:(?:container|section|row|column|grid|card) has no children, so it renders empty; add components or remove it|(?:container|section|column|card) stacks \d+ fields in one column; put them in a grid \(columns: 2\) or split them into titled sections)$/,
44
63
  ];
45
64
  export function isAdvisoryDiagnostic(message) {
46
65
  return ADVISORY_DIAGNOSTICS.some((pattern) => pattern.test(message));
@@ -138,5 +138,6 @@ export declare function liveProgressActive(): boolean;
138
138
  export declare function applyProgressEvent(event: ProgressEvent): void;
139
139
  export declare function renderTextEffects(text: string, effects: readonly TextEffect[] | undefined): string;
140
140
  export declare function green(text: string): PullResultSegment;
141
+ export declare function yellow(text: string): PullResultSegment;
141
142
  export declare function red(text: string): PullResultSegment;
142
143
  export declare function bold(text: string): PullResultSegment;
@@ -702,6 +702,12 @@ export function green(text) {
702
702
  };
703
703
  }
704
704
  ;
705
+ export function yellow(text) {
706
+ return {
707
+ text,
708
+ textEffects: [{ start: 0, end: text.length, color: "yellow" }],
709
+ };
710
+ }
705
711
  export function red(text) {
706
712
  return {
707
713
  text,
@@ -15,10 +15,14 @@ export interface ImportedResourceRef {
15
15
  readonly label: string;
16
16
  readonly attrs: Readonly<Record<string, TfValue>>;
17
17
  }
18
+ /** Why the bridge left an automation out; a bridge from before #1764 writes no kind. */
19
+ export declare const OMITTED_AUTOMATION_KINDS: readonly ["unrepresentable", "disabled", "no-draft", "unadoptable"];
20
+ export type OmittedAutomationKind = (typeof OMITTED_AUTOMATION_KINDS)[number];
18
21
  /** Extraction context: stream lookups + the diagnostics sink. */
19
22
  /** An automation the export left out, as omitted-automations.json names it. */
20
23
  export interface OmittedAutomationIdentity {
21
24
  readonly name: string;
25
+ readonly kind?: OmittedAutomationKind;
22
26
  readonly reason: string;
23
27
  }
24
28
  export interface FromTfContext {
@@ -158,10 +162,12 @@ export interface FromTfContext {
158
162
  readonly serviceAccountsById?: ReadonlyMap<string, ServiceAccountIdentity>;
159
163
  /**
160
164
  * The automations the export left out (omitted-automations.json), by
161
- * platform id (#1877). A run-automation widget whose raw automation id is
162
- * listed here warns, naming the automation and the export's reason; any
163
- * other raw id (such as another app's automation) is a valid reference and
164
- * stays silent. Undefined: no listed id, so only an empty id warns.
165
+ * platform id (#1877). A widget or layout button whose raw automation id is
166
+ * listed here and not DISABLED pulls as a reference by display name, which
167
+ * build looks up; a DISABLED one warns, naming the automation and the
168
+ * export's reason. Any other raw id (such as another app's automation) is a
169
+ * valid reference and stays silent. Undefined: no listed id, so only an
170
+ * empty id warns.
165
171
  */
166
172
  readonly omittedAutomationsById?: ReadonlyMap<string, OmittedAutomationIdentity>;
167
173
  /**
@@ -6,6 +6,8 @@
6
6
  */
7
7
  import { EntityTfError } from "../entity.js";
8
8
  import { isTfExpr, tfLabelToTsLabel } from "../tf/index.js";
9
+ /** Why the bridge left an automation out; a bridge from before #1764 writes no kind. */
10
+ export const OMITTED_AUTOMATION_KINDS = ["unrepresentable", "disabled", "no-draft", "unadoptable"];
9
11
  /** The pull-abort (or, for `clone app`, clone-abort) message for one or more authoring blockers. */
10
12
  export function authoringBlockedMessage(blockers, command = "pull") {
11
13
  const remedies = [...new Set(blockers.map((blocker) => blocker.remedy))];
@@ -15,6 +15,8 @@ export interface ManagedResultVerdict {
15
15
  readonly gaps?: number;
16
16
  /** Live configuration left out of source on request (e.g. `--skip-unsupported-layouts`). */
17
17
  readonly omitted?: number;
18
+ /** Other problems the command reported without failing (e.g. a data-only org pull's failed workspace build). */
19
+ readonly warnings?: number;
18
20
  }
19
21
  export declare function managedResultStatus(operation: string, verdict: ManagedResultVerdict): ManagedResultStatus;
20
22
  /**
@@ -4,7 +4,7 @@ import { flushRepeatedTechnicalLogs, machineReadableLogsEnabled, renderTextEffec
4
4
  export function managedResultStatus(operation, verdict) {
5
5
  const outcome = verdict.failed === true
6
6
  ? "failure"
7
- : (verdict.skipped ?? 0) > 0 || (verdict.gaps ?? 0) > 0 || (verdict.omitted ?? 0) > 0
7
+ : (verdict.skipped ?? 0) > 0 || (verdict.gaps ?? 0) > 0 || (verdict.omitted ?? 0) > 0 || (verdict.warnings ?? 0) > 0
8
8
  ? "warning"
9
9
  : "success";
10
10
  return { operation, outcome };
@@ -12,7 +12,7 @@
12
12
  * Kind switches live in the entity graph — this file walks TYPE_TO_KIND /
13
13
  * lifecycle hooks and must not import entity modules (value or type).
14
14
  */
15
- import { type EntityKindId, type AdoptionAddressAlias } from "../../graph/index.js";
15
+ import { type EntityKindId, type AdoptionAddressAlias, type UnmanagedLookup } from "../../graph/index.js";
16
16
  import type { QuarantinedOwnFile } from "../../graph/types.js";
17
17
  import { type TfDocument } from "../tf/index.js";
18
18
  import type { ValidationFailure } from "../validation.js";
@@ -55,6 +55,8 @@ export interface StreamRootExtract {
55
55
  readonly importIds: ReadonlyMap<string, string>;
56
56
  /** Export addresses whose printed current-API source rebuilds at a canonical alias. */
57
57
  readonly adoptionAddressAliases: readonly AdoptionAddressAlias[];
58
+ /** Lookups adoption declares for references to skipped resources (see {@link UnmanagedLookup}). */
59
+ readonly unmanagedLookups?: readonly UnmanagedLookup[];
58
60
  /**
59
61
  * Resource address → the addresses it `depends_on` (e.g. a workflow_publish
60
62
  * depending on its automation's tasks). `tofu plan -target=X` implicitly
@@ -446,6 +446,7 @@ export function extractStreamRoot(doc, kindId, opts = {}) {
446
446
  };
447
447
  const ownFileByKind = new Map();
448
448
  const adoptionAddressAliases = [];
449
+ const unmanagedLookups = [];
449
450
  const quarantineOwnFiles = [];
450
451
  const validationFailures = [];
451
452
  const settles = [];
@@ -462,6 +463,7 @@ export function extractStreamRoot(doc, kindId, opts = {}) {
462
463
  diagnostics.push(...result.diagnostics);
463
464
  validationFailures.push(...(result.validations ?? []));
464
465
  adoptionAddressAliases.push(...(result.adoptionAddressAliases ?? []));
466
+ unmanagedLookups.push(...(result.unmanagedLookups ?? []));
465
467
  quarantineOwnFiles.push(...(result.quarantineOwnFiles ?? []));
466
468
  if (result.settleAfterExtract !== undefined)
467
469
  settles.push(result.settleAfterExtract);
@@ -497,6 +499,7 @@ export function extractStreamRoot(doc, kindId, opts = {}) {
497
499
  reports,
498
500
  importIds,
499
501
  adoptionAddressAliases,
502
+ ...(unmanagedLookups.length > 0 && { unmanagedLookups }),
500
503
  dependsOn,
501
504
  unresolvedForeignRefs: { apps: [...unresolvedForeignApps], elements: [...unresolvedForeignElements] },
502
505
  authoringBlockers: [
@@ -15,8 +15,13 @@ export declare function decodeTemplateEscapes(s: string): string;
15
15
  export declare function encodeTemplateEscapes(s: string): string;
16
16
  /**
17
17
  * Render a logical string as an HCL2 quoted string literal.
18
- * JSON string escaping is a subset of HCL2's quoted-string escapes
19
- * (\n, \t, \", \\, \uXXXX are all valid HCL); template introducers are
20
- * additionally doubled so they stay literal.
18
+ * JSON string escaping is almost a subset of HCL2's quoted-string escapes
19
+ * (\n, \r, \t, \", \\, \uXXXX are all valid HCL), but JSON also writes
20
+ * U+0008 as `\b` and U+000C as `\f`, which HCL2 rejects ("Invalid escape
21
+ * sequence"). Those two are rewritten as `\u0008` / `\u000c` (#3003): a live
22
+ * script can hold a real backspace where its author meant a regex `\b`.
23
+ * Template introducers are additionally doubled so they stay literal. A lone
24
+ * UTF-16 surrogate (JSON `\ud800`) has no UTF-8 form, so HCL still rejects it;
25
+ * plan fails loudly on that rather than writing something different.
21
26
  */
22
27
  export declare function quoteHclString(logical: string): string;
@@ -19,10 +19,23 @@ export function encodeTemplateEscapes(s) {
19
19
  }
20
20
  /**
21
21
  * Render a logical string as an HCL2 quoted string literal.
22
- * JSON string escaping is a subset of HCL2's quoted-string escapes
23
- * (\n, \t, \", \\, \uXXXX are all valid HCL); template introducers are
24
- * additionally doubled so they stay literal.
22
+ * JSON string escaping is almost a subset of HCL2's quoted-string escapes
23
+ * (\n, \r, \t, \", \\, \uXXXX are all valid HCL), but JSON also writes
24
+ * U+0008 as `\b` and U+000C as `\f`, which HCL2 rejects ("Invalid escape
25
+ * sequence"). Those two are rewritten as `\u0008` / `\u000c` (#3003): a live
26
+ * script can hold a real backspace where its author meant a regex `\b`.
27
+ * Template introducers are additionally doubled so they stay literal. A lone
28
+ * UTF-16 surrogate (JSON `\ud800`) has no UTF-8 form, so HCL still rejects it;
29
+ * plan fails loudly on that rather than writing something different.
25
30
  */
26
31
  export function quoteHclString(logical) {
27
- return JSON.stringify(encodeTemplateEscapes(logical));
32
+ // Walk JSON's escape pairs, so an escaped backslash followed by "b" (`\\b`)
33
+ // is never mistaken for a `\b` escape.
34
+ return JSON.stringify(encodeTemplateEscapes(logical)).replace(/\\(u[0-9a-fA-F]{4}|.)/g, (pair, escape) => {
35
+ if (escape === "b")
36
+ return "\\u0008";
37
+ if (escape === "f")
38
+ return "\\u000c";
39
+ return pair;
40
+ });
28
41
  }
@@ -23,7 +23,7 @@ export { preservePulledCalculation } from "./deserializer/pulled-expression.js";
23
23
  export { groupId, userId, type AccessPolicyGroupRef, type AccessPolicyOptions, type AccessPolicyPrincipalRef, type AccessPolicyUserRef, type GroupId, type UserId } from "../access-policy/build.js";
24
24
  export { type ManagedViewSharing } from "../view/sharing.js";
25
25
  export { type ElementumBlocksElement, type ElementumBlocksSpec } from "../view/ragnarok.js";
26
- export { agentViewFontFamily, type AgentViewBlock, type AgentViewBranding, type AgentViewCustomView, type AgentViewFontFamily, type AgentViewHexColor, type AgentViewImage, type AgentViewSpecApp, type AgentViewSpecField, type AgentViewSpecFilterRef, type AppAgentViewLayout, type ViewBlock, type ViewBlocksField, type ViewBlocksFilterRef, type ViewBlocksLayout, type ViewBlocksSource, } from "../view/agent-view-layout.js";
26
+ export { agentViewFontFamily, type AgentViewBlock, type AgentViewBranding, type AgentViewCustomView, type AgentViewFontFamily, type AgentViewHexColor, type AgentViewImage, type AgentViewSpecApp, type AgentViewSpecField, type AgentViewSpecFilterRef, type AppAgentViewLayout, type ViewBlock, type ViewBlocksField, type ViewBlocksFilterRef, type ViewBlocksLayout, type ViewBlocksSource, type ViewBlocksStateValue, } from "../view/agent-view-layout.js";
27
27
  export { roleAutoShare, rolePermissionGroup, rolePermissionLevel, userRef, type AppRole, type RoleAutoShare, type RoleGroupRef, type RolePermission, type RolePermissionGroup, type RolePermissionLevel, type RoleUserRef } from "../role/build.js";
28
28
  export { serviceAccountRoleRef, serviceAccountStatus, type AppServiceAccount, type ServiceAccountAccessPolicy, type ServiceAccountRole, type ServiceAccountRoleRef, type ServiceAccountStatus } from "../service-account/build.js";
29
29
  export { serviceAccountRef, type ServiceAccountRef } from "../service-account/ref.js";
@@ -1699,6 +1699,14 @@ function printRef(ref, state, refCtx) {
1699
1699
  }
1700
1700
  return `${ctxName}.actions${safeMember(ref.task)}` + ref.path.map(safeMember).join("");
1701
1701
  }
1702
+ // A Run Automation task's outputs are the called automation's declared
1703
+ // output names (typed from its catalog ref or `outputs:` list), not
1704
+ // record fields: a name that isn't a valid identifier ("My Output",
1705
+ // punctuation, a reserved word) is still a real key, so print it as
1706
+ // bracket access instead of the unresolved-field escape (#3026).
1707
+ if (state.taskFactoriesByRefKey.get(ref.task) === "runAutomation") {
1708
+ return `${ctxName}.actions${safeMember(ref.task)}` + ref.path.map(safeMember).join("");
1709
+ }
1702
1710
  return printPathAccess(`${ctxName}.actions${safeMember(ref.task)}`, ref.path);
1703
1711
  }
1704
1712
  case "triggerRef": {
@@ -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, isTfExpr } from "../../engine/tf/index.js";
3
+ import { appScopedResourceLabel, 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;
@@ -153,6 +153,23 @@ export function droppedAutomationGap(autoBlock, autoLabel, gap) {
153
153
  : `it is not adopted. If this workspace already manages it, its state and its existing source file are kept as they were, so the next plan compares that older source with the live automation: it can undo edits made in the platform, or delete the automation if its source file is gone. Review the plan before applying. ${gap.nextStep}`,
154
154
  });
155
155
  }
156
+ /**
157
+ * The `data.elementum_automation` lookup by display name that stands in for a
158
+ * skipped automation, the shape build emits for a dynamic-layout button whose
159
+ * automation is not in source (edk#2693). A button input reads its on-demand
160
+ * trigger's `parameter_ids`, which the lookup carries too (#3023).
161
+ */
162
+ function unmanagedAutomationLookup(autoBlock, owned, label) {
163
+ const name = autoBlock.attrs["name"];
164
+ const appId = autoBlock.attrs["app_id"];
165
+ const triggers = owned.filter((address) => address.startsWith("elementum_on_demand_trigger."));
166
+ if (typeof name !== "string" || name === "" || appId === undefined || triggers.length === 0)
167
+ return undefined;
168
+ return {
169
+ lookup: { kind: "data", type: AUTOMATION_RESOURCE_TYPE, label, attrs: { app_id: appId, name } },
170
+ addresses: triggers,
171
+ };
172
+ }
156
173
  const FIX_IN_PLATFORM = "To manage it with the EDK, change what the reason names in the platform, then pull again.";
157
174
  const FIX_OR_REPORT = "If you can change what the reason names in the platform, do so and pull again; otherwise report it as an EDK bug.";
158
175
  /**
@@ -255,9 +272,13 @@ function extractAutomations(ownBlocks, stream, ctx) {
255
272
  const released = [];
256
273
  // Which file each skipped automation's resources come from (#1877).
257
274
  const skippedOwnFiles = [];
258
- const skip = (owned, refName) => {
275
+ const unmanagedLookups = [];
276
+ const skip = (autoBlock, owned, refName) => {
259
277
  skipped.push(...owned);
260
278
  skippedOwnFiles.push({ refName, addresses: owned });
279
+ const lookup = unmanagedAutomationLookup(autoBlock, owned, `${ctx.appTfLabel}_${tsLabelToTfLabel(refName)}`);
280
+ if (lookup !== undefined)
281
+ unmanagedLookups.push(lookup);
261
282
  };
262
283
  const settledByState = new Set();
263
284
  const release = (entry) => {
@@ -282,7 +303,7 @@ function extractAutomations(ownBlocks, stream, ctx) {
282
303
  const owned = automationOwnedAddresses(doc, autoLabel);
283
304
  const chain = referencedAddress(stream, owned, lostChains);
284
305
  if (chain !== undefined) {
285
- skip(owned, scopedLabelToBagKey(ctx.appTfLabel, autoLabel));
306
+ skip(autoBlock, owned, scopedLabelToBagKey(ctx.appTfLabel, autoLabel));
286
307
  release({
287
308
  autoBlock, autoLabel, owned, refName: scopedLabelToBagKey(ctx.appTfLabel, autoLabel),
288
309
  why: `it uses ${chain}, which pull leaves unmanaged because its stage has no handle of its own (#1136)`,
@@ -299,7 +320,7 @@ function extractAutomations(ownBlocks, stream, ctx) {
299
320
  // second copy of the live automation.
300
321
  if (extracted.stringifiedValueReferences === true) {
301
322
  const owned = automationOwnedAddresses(doc, autoLabel);
302
- skip(owned, extracted.refName);
323
+ skip(autoBlock, owned, extracted.refName);
303
324
  release({
304
325
  autoBlock, autoLabel, owned, refName: extracted.refName,
305
326
  why: "its export embeds a value reference as text that source cannot rebuild exactly (edk#1646)",
@@ -333,7 +354,7 @@ function extractAutomations(ownBlocks, stream, ctx) {
333
354
  message: err.message,
334
355
  code: "unresolved-task-filter-ref",
335
356
  });
336
- skip(owned, scopedLabelToBagKey(ctx.appTfLabel, autoLabel));
357
+ skip(autoBlock, owned, scopedLabelToBagKey(ctx.appTfLabel, autoLabel));
337
358
  release({
338
359
  autoBlock, autoLabel, owned, refName: scopedLabelToBagKey(ctx.appTfLabel, autoLabel),
339
360
  why: `pull could not turn its export into source: ${err.message}`,
@@ -343,7 +364,7 @@ function extractAutomations(ownBlocks, stream, ctx) {
343
364
  });
344
365
  continue;
345
366
  }
346
- skip(owned, scopedLabelToBagKey(ctx.appTfLabel, autoLabel));
367
+ skip(autoBlock, owned, scopedLabelToBagKey(ctx.appTfLabel, autoLabel));
347
368
  // No authored form can manage these, so release an earlier adoption
348
369
  // rather than let the next apply destroy the live automation:
349
370
  // sibling-loop item refs (#1320) and multi-trigger (#1785 / #39).
@@ -383,7 +404,7 @@ function extractAutomations(ownBlocks, stream, ctx) {
383
404
  continue;
384
405
  kept.delete(entry);
385
406
  cascaded = true;
386
- skip(entry.owned, entry.extracted.refName);
407
+ skip(entry.autoBlock, entry.owned, entry.extracted.refName);
387
408
  const gap = {
388
409
  why: `it uses ${target}, which pull skipped, so its reference would point at nothing`,
389
410
  nextStep: `Fix ${target} first (see its own warning), then pull again.`,
@@ -499,6 +520,7 @@ function extractAutomations(ownBlocks, stream, ctx) {
499
520
  items, skipped, releaseIfManaged, diagnostics, adoptionAddressAliases,
500
521
  ...(validations.length > 0 && { validations }),
501
522
  ...(skippedOwnFiles.length > 0 && { skippedOwnFiles }),
523
+ ...(unmanagedLookups.length > 0 && { unmanagedLookups }),
502
524
  ...(settleAfterExtract !== undefined && { settleAfterExtract }),
503
525
  };
504
526
  }
@@ -0,0 +1,12 @@
1
+ import type { FromTfContext } from "../../engine/pull/context.js";
2
+ /**
3
+ * The export writes a live automation it left out (no draft, for example) as
4
+ * its platform id. Its display name from omitted-automations.json lets build
5
+ * look it up by name (edk#2693), so the reference keeps its automation with
6
+ * no id in source. A DISABLED automation is deleted, and a key that names an
7
+ * exported automation would build that one instead, so neither gets a key.
8
+ */
9
+ export declare function omittedAutomationKey(id: string, ownerTfLabel: string, ctx: FromTfContext): {
10
+ readonly key: string;
11
+ readonly name: string;
12
+ } | undefined;
@@ -0,0 +1,21 @@
1
+ import { isTfLabel, sanitizeName, tfLabelToTsLabel } from "../../engine/tf/index.js";
2
+ import { AUTOMATION_RESOURCE_TYPE, automationResourceLabel } from "./types.js";
3
+ /**
4
+ * The export writes a live automation it left out (no draft, for example) as
5
+ * its platform id. Its display name from omitted-automations.json lets build
6
+ * look it up by name (edk#2693), so the reference keeps its automation with
7
+ * no id in source. A DISABLED automation is deleted, and a key that names an
8
+ * exported automation would build that one instead, so neither gets a key.
9
+ */
10
+ export function omittedAutomationKey(id, ownerTfLabel, ctx) {
11
+ const omitted = ctx.omittedAutomationsById?.get(id);
12
+ if (omitted === undefined || omitted.kind === "disabled")
13
+ return undefined;
14
+ const label = sanitizeName(omitted.name);
15
+ if (!isTfLabel(label))
16
+ return undefined;
17
+ const key = tfLabelToTsLabel(label);
18
+ if (ctx.resourceByAddress?.(`${AUTOMATION_RESOURCE_TYPE}.${automationResourceLabel(ownerTfLabel, key)}`) !== undefined)
19
+ return undefined;
20
+ return { key, name: omitted.name };
21
+ }
@@ -36,7 +36,7 @@ export interface AutomationToTfContext {
36
36
  readonly fieldAddressesByAppRefName?: ReadonlyMap<string, ReadonlyMap<string, string>>;
37
37
  /** Org catalog field types for every app/element it lists, keyed by refName and then field key. */
38
38
  readonly catalogFieldTypesByAppRefName?: ReadonlyMap<string, ReadonlyMap<string, string>>;
39
- /** Whole-object findings, advisories only while the revision record lists them (#2283). */
39
+ /** Whole-object (#2283) and nested-task output (#2988) findings, advisories only while the revision record lists them. */
40
40
  readonly advisoriesWhileRecorded?: AdvisoryWhileRecorded[];
41
41
  /**
42
42
  * Every app/element authored in the workspace, keyed by