@elementumai/edk 0.11.0 → 0.12.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 (72) hide show
  1. package/README.md +38 -6
  2. package/dist-sdk/src/core/triggers/on-demand.d.ts +2 -0
  3. package/dist-sdk/src/core/triggers/on-demand.js +3 -0
  4. package/dist-sdk/src/engine/coverage-gaps.d.ts +5 -0
  5. package/dist-sdk/src/engine/coverage-gaps.js +9 -0
  6. package/dist-sdk/src/engine/ei/run.d.ts +20 -1
  7. package/dist-sdk/src/engine/ei/run.js +102 -14
  8. package/dist-sdk/src/engine/pull/ref-only.d.ts +18 -0
  9. package/dist-sdk/src/engine/pull/ref-only.js +52 -0
  10. package/dist-sdk/src/entities/access-policy/from-tf.d.ts +2 -1
  11. package/dist-sdk/src/entities/access-policy/from-tf.js +7 -1
  12. package/dist-sdk/src/entities/access-policy/module.js +5 -0
  13. package/dist-sdk/src/entities/app/build.d.ts +1 -1
  14. package/dist-sdk/src/entities/app/build.js +79 -4
  15. package/dist-sdk/src/entities/app/from-tf.js +1 -2
  16. package/dist-sdk/src/entities/app/stage-keys.d.ts +18 -3
  17. package/dist-sdk/src/entities/app/stage-keys.js +40 -6
  18. package/dist-sdk/src/entities/app/to-tf.js +1 -0
  19. package/dist-sdk/src/entities/automation/build.d.ts +50 -24
  20. package/dist-sdk/src/entities/automation/build.js +16 -6
  21. package/dist-sdk/src/entities/automation/deserializer/print-automation.js +32 -3
  22. package/dist-sdk/src/entities/automation/from-tf.d.ts +13 -2
  23. package/dist-sdk/src/entities/automation/from-tf.js +269 -63
  24. package/dist-sdk/src/entities/automation/index.d.ts +1 -1
  25. package/dist-sdk/src/entities/automation/module.js +1 -1
  26. package/dist-sdk/src/entities/automation/run-target.d.ts +2 -0
  27. package/dist-sdk/src/entities/automation/run-target.js +5 -0
  28. package/dist-sdk/src/entities/automation/script-code.d.ts +2 -1
  29. package/dist-sdk/src/entities/automation/script-code.js +82 -1
  30. package/dist-sdk/src/entities/automation/script-lint.d.ts +13 -0
  31. package/dist-sdk/src/entities/automation/script-lint.js +418 -0
  32. package/dist-sdk/src/entities/automation/task-output-labels.d.ts +1 -1
  33. package/dist-sdk/src/entities/automation/task-output-labels.js +9 -1
  34. package/dist-sdk/src/entities/automation/tasks.d.ts +47 -14
  35. package/dist-sdk/src/entities/automation/tasks.js +18 -4
  36. package/dist-sdk/src/entities/automation/to-tf.js +256 -28
  37. package/dist-sdk/src/entities/automation/triggers.d.ts +48 -15
  38. package/dist-sdk/src/entities/automation/triggers.js +9 -9
  39. package/dist-sdk/src/entities/chart/build.d.ts +9 -1
  40. package/dist-sdk/src/entities/chart/from-tf.d.ts +2 -2
  41. package/dist-sdk/src/entities/chart/from-tf.js +25 -1
  42. package/dist-sdk/src/entities/chart/index.d.ts +1 -1
  43. package/dist-sdk/src/entities/chart/printer.js +5 -2
  44. package/dist-sdk/src/entities/chart/to-tf.js +19 -1
  45. package/dist-sdk/src/entities/dynamic-layout/build.d.ts +1 -0
  46. package/dist-sdk/src/entities/dynamic-layout/condition-keys.d.ts +48 -0
  47. package/dist-sdk/src/entities/dynamic-layout/condition-keys.js +261 -0
  48. package/dist-sdk/src/entities/dynamic-layout/from-tf.js +1 -1
  49. package/dist-sdk/src/entities/dynamic-layout/module.js +2 -1
  50. package/dist-sdk/src/entities/element/to-tf.js +1 -0
  51. package/dist-sdk/src/entities/field/module.js +8 -2
  52. package/dist-sdk/src/entities/field/to-tf.d.ts +8 -2
  53. package/dist-sdk/src/entities/field/to-tf.js +57 -34
  54. package/dist-sdk/src/entities/org/role.js +5 -0
  55. package/dist-sdk/src/entities/service-account/module.js +5 -0
  56. package/dist-sdk/src/entities/service-account/role-fidelity.d.ts +5 -5
  57. package/dist-sdk/src/entities/service-account/role-fidelity.js +21 -13
  58. package/dist-sdk/src/entities/shared/filters/ast.d.ts +2 -0
  59. package/dist-sdk/src/entities/shared/types/field-types.d.ts +6 -3
  60. package/dist-sdk/src/entities/shared/types/field-types.js +3 -1
  61. package/dist-sdk/src/entities/skill/module.js +2 -0
  62. package/dist-sdk/src/entities/task/to-tf.js +1 -0
  63. package/dist-sdk/src/entities/view/from-tf.d.ts +8 -4
  64. package/dist-sdk/src/entities/view/from-tf.js +3 -5
  65. package/dist-sdk/src/entities/view/module.js +5 -0
  66. package/dist-sdk/src/entities/widget/from-tf.js +2 -2
  67. package/dist-sdk/src/generated/ragnarok/ragnarok-spec.d.ts +5 -3
  68. package/dist-sdk/src/generated/ragnarok/ragnarok-spec.js +2 -2
  69. package/dist-sdk/src/graph/index.d.ts +15 -2
  70. package/dist-sdk/src/graph/index.js +12 -0
  71. package/dist-sdk/src/graph/types.d.ts +38 -0
  72. package/package.json +1 -1
@@ -28,14 +28,25 @@ export declare function stageKeyFromPicklistValue(pv: PicklistValueWire): AppSta
28
28
  * derive the same handle, the first keeps it and a diagnostic says so,
29
29
  * instead of silently rebinding. A stage left with no handle that maps to
30
30
  * its own key (a punctuation key whose only handle is another stage's key,
31
- * e.g. `pre-approval` next to `pre_approval`) is diagnosed too. Pull never
32
- * writes another stage's handle for it: see {@link pulledStageHandle}.
31
+ * e.g. `pre-approval` next to `pre_approval`) is diagnosed too. So is a
32
+ * stage whose only handle is the `SanitizeName` fallback and another stage
33
+ * already holds it: two stages whose names have no usable characters
34
+ * (`"!!!"` and `"日本"`) both fall back to `resource`, and the second has no
35
+ * handle at all (#1767). Pull never writes another stage's handle for it:
36
+ * see {@link pulledStageHandle}.
33
37
  */
34
38
  export declare function stageKeyByHandle(stages: readonly AppStageKey[], diagnostics?: string[]): Map<string, string>;
39
+ /** A stage left with no handle because its only fallback handle belongs to another stage (#1767). */
40
+ export interface FallbackLostStage {
41
+ readonly handle: string;
42
+ readonly owner: string;
43
+ }
35
44
  /** An app's stage handles plus its real stage keys, for pull-side resolution (#1136). */
36
45
  export interface StageHandleIndex {
37
46
  readonly byHandle: ReadonlyMap<string, string>;
38
47
  readonly keys: ReadonlySet<string>;
48
+ /** Stages whose only (fallback) handle another stage holds, by real key (#1767). */
49
+ readonly fallbackLost?: ReadonlyMap<string, FallbackLostStage>;
39
50
  }
40
51
  /** {@link stageKeyByHandle} plus the real key set. */
41
52
  export declare function stageHandleIndex(stages: readonly AppStageKey[], diagnostics?: string[]): StageHandleIndex;
@@ -50,6 +61,7 @@ export type PulledStageHandle = {
50
61
  readonly kind: "lost";
51
62
  readonly handle: string;
52
63
  readonly owner: string;
64
+ readonly fallback?: true;
53
65
  } | {
54
66
  readonly kind: "none";
55
67
  };
@@ -60,7 +72,9 @@ export type PulledStageHandle = {
60
72
  * slug is another stage's own key, e.g. `pre-approval` next to
61
73
  * `pre_approval`), returns `lost`: writing that handle would bind the
62
74
  * reference to the other stage on build, so the caller leaves the
63
- * reference out with a diagnostic instead. Without an index (or for an
75
+ * reference out with a diagnostic instead. The same holds for a stage whose
76
+ * only handle is the shared `SanitizeName` fallback another stage holds
77
+ * (#1767). Without an index (or for an
64
78
  * index that is not one of the app's stages) this is `stageHandleTfLabel`.
65
79
  */
66
80
  export declare function pulledStageHandle(index: string, stages: StageHandleIndex | undefined): PulledStageHandle;
@@ -77,6 +91,7 @@ export declare class LostStageHandleError extends EntityTfError {
77
91
  export declare function lostStageMessage(where: string, index: string, lost: {
78
92
  readonly handle: string;
79
93
  readonly owner: string;
94
+ readonly fallback?: true;
80
95
  }, outcome: string): string;
81
96
  /** The owning app's stage handles (see {@link stageKeyByHandle}) from its built payload, for child entities. */
82
97
  export declare function appStageKeyByHandle(payload: unknown): Map<string, string> | undefined;
@@ -30,10 +30,17 @@ export function stageKeyFromPicklistValue(pv) {
30
30
  * derive the same handle, the first keeps it and a diagnostic says so,
31
31
  * instead of silently rebinding. A stage left with no handle that maps to
32
32
  * its own key (a punctuation key whose only handle is another stage's key,
33
- * e.g. `pre-approval` next to `pre_approval`) is diagnosed too. Pull never
34
- * writes another stage's handle for it: see {@link pulledStageHandle}.
33
+ * e.g. `pre-approval` next to `pre_approval`) is diagnosed too. So is a
34
+ * stage whose only handle is the `SanitizeName` fallback and another stage
35
+ * already holds it: two stages whose names have no usable characters
36
+ * (`"!!!"` and `"日本"`) both fall back to `resource`, and the second has no
37
+ * handle at all (#1767). Pull never writes another stage's handle for it:
38
+ * see {@link pulledStageHandle}.
35
39
  */
36
40
  export function stageKeyByHandle(stages, diagnostics) {
41
+ return stageHandleBindings(stages, diagnostics).byHandle;
42
+ }
43
+ function stageHandleBindings(stages, diagnostics) {
37
44
  const byHandle = new Map();
38
45
  for (const stage of stages) {
39
46
  if (isTfLabel(stage.key) && !byHandle.has(stage.key))
@@ -78,17 +85,34 @@ export function stageKeyByHandle(stages, diagnostics) {
78
85
  byHandle.set(exportHandle, stage.key);
79
86
  }
80
87
  const bound = new Set(byHandle.values());
88
+ const fallbackLost = new Map();
89
+ for (const stage of stages) {
90
+ if (bound.has(stage.key) || reported.has(stage.key) || lostTo.has(stage.key) || fallbackLost.has(stage.key))
91
+ continue;
92
+ const exportHandle = sanitizeName(stage.name);
93
+ const owner = byHandle.get(exportHandle);
94
+ if (owner === undefined || owner === stage.key)
95
+ continue;
96
+ fallbackLost.set(stage.key, { handle: exportHandle, owner });
97
+ // An empty slug ("!!!", "日本") has no handle characters at all; a
98
+ // non-empty one ("1st!!!") has them, but only as the same fallback.
99
+ const why = snakeSlug(stage.name) === ""
100
+ ? `its name ${JSON.stringify(stage.name)} has no characters a handle can use, so its only handle is the fallback handle "${exportHandle}"`
101
+ : `its only handle is the fallback handle "${exportHandle}" that its name ${JSON.stringify(stage.name)} produces`;
102
+ diagnostics?.push(`systemFields.stage: stage "${stage.key}" has no handle of its own: ${why}, and stage "${owner}" already holds that handle. Source cannot reference "${stage.key}", so pull leaves its layouts, dynamic layouts, approval chains and flows unmanaged (each one warned) instead of binding them to "${owner}". Rename one of the stages so their names produce different handles (#1767).`);
103
+ }
81
104
  for (const stage of stages) {
82
105
  const lost = lostTo.get(stage.key);
83
106
  if (bound.has(stage.key) || reported.has(stage.key) || lost === undefined)
84
107
  continue;
85
108
  diagnostics?.push(`systemFields.stage: stage "${stage.key}" has no handle of its own: its handle "${lost.handle}" is stage "${lost.owner}"'s key. Source cannot reference "${stage.key}", so pull leaves its layouts, dynamic layouts, approval chains and flows unmanaged (each one warned) instead of binding them to "${lost.owner}". Rename one of the stages so each has its own handle.`);
86
109
  }
87
- return byHandle;
110
+ return { byHandle, fallbackLost };
88
111
  }
89
112
  /** {@link stageKeyByHandle} plus the real key set. */
90
113
  export function stageHandleIndex(stages, diagnostics) {
91
- return { byHandle: stageKeyByHandle(stages, diagnostics), keys: new Set(stages.map((stage) => stage.key)) };
114
+ const { byHandle, fallbackLost } = stageHandleBindings(stages, diagnostics);
115
+ return { byHandle, keys: new Set(stages.map((stage) => stage.key)), ...(fallbackLost.size > 0 ? { fallbackLost } : {}) };
92
116
  }
93
117
  /** The stage handles of an `elementum_app` block's `stages` attribute, or undefined when it has none. */
94
118
  export function stageHandleIndexFromTfStages(value) {
@@ -111,7 +135,9 @@ export function stageHandleIndexFromTfStages(value) {
111
135
  * slug is another stage's own key, e.g. `pre-approval` next to
112
136
  * `pre_approval`), returns `lost`: writing that handle would bind the
113
137
  * reference to the other stage on build, so the caller leaves the
114
- * reference out with a diagnostic instead. Without an index (or for an
138
+ * reference out with a diagnostic instead. The same holds for a stage whose
139
+ * only handle is the shared `SanitizeName` fallback another stage holds
140
+ * (#1767). Without an index (or for an
115
141
  * index that is not one of the app's stages) this is `stageHandleTfLabel`.
116
142
  */
117
143
  export function pulledStageHandle(index, stages) {
@@ -123,6 +149,9 @@ export function pulledStageHandle(index, stages) {
123
149
  for (const [handle, key] of stages.byHandle)
124
150
  if (key === index && isTfLabel(handle))
125
151
  return { kind: "handle", handle };
152
+ const fallbackLost = stages.fallbackLost?.get(index);
153
+ if (fallbackLost !== undefined)
154
+ return { kind: "lost", handle: fallbackLost.handle, owner: fallbackLost.owner, fallback: true };
126
155
  if (preferred === undefined)
127
156
  return { kind: "none" };
128
157
  const owner = stages.byHandle.get(preferred);
@@ -142,7 +171,12 @@ export class LostStageHandleError extends EntityTfError {
142
171
  }
143
172
  /** The per-reference warning for a `lost` {@link pulledStageHandle}. */
144
173
  export function lostStageMessage(where, index, lost, outcome) {
145
- return `${where}: stage "${index}" has no handle of its own (its handle "${lost.handle}" is stage "${lost.owner}"'s key); ${outcome} instead of binding it to "${lost.owner}" (#1136)`;
174
+ // A fallback loss (#1767): the handle is the SanitizeName fallback the other
175
+ // stage holds, not that stage's key, so the #1136 sentence would be false.
176
+ const why = lost.fallback === true
177
+ ? `its only handle is the fallback handle "${lost.handle}", which stage "${lost.owner}" already holds`
178
+ : `its handle "${lost.handle}" is stage "${lost.owner}"'s key`;
179
+ return `${where}: stage "${index}" has no handle of its own (${why}); ${outcome} instead of binding it to "${lost.owner}" (${lost.fallback === true ? "#1767" : "#1136"})`;
146
180
  }
147
181
  /** The owning app's stage handles (see {@link stageKeyByHandle}) from its built payload, for child entities. */
148
182
  export function appStageKeyByHandle(payload) {
@@ -227,6 +227,7 @@ export function appToTf(entity, ctx) {
227
227
  const field = fieldToTf(typeKey, inner, {
228
228
  ownerTfLabel: ctx.appTfLabel,
229
229
  appRefName: ctx.appRefName,
230
+ ...(payload.name !== undefined && { ownerName: payload.name }),
230
231
  objectId,
231
232
  diagnostics: ctx.diagnostics,
232
233
  orgRefs: ctx.orgRefs,
@@ -7,7 +7,7 @@ import { type Ref, type Simplify, type ValueOrRef } from "../shared/ref.js";
7
7
  import type { Filter } from "./filter.js";
8
8
  import { type ScriptFile, type ScriptInput } from "./script-code.js";
9
9
  import * as actionFactories from "./tasks.js";
10
- import type { ScriptOutputs } from "./tasks.js";
10
+ import type { ExecuteScriptOutput, ScriptOutputs } from "./tasks.js";
11
11
  import { type WorkflowOutputDeclaration } from "./workflow-output.js";
12
12
  /** Structural empty object — neutral element for the accumulated action map. */
13
13
  type EmptyObject = {
@@ -198,37 +198,63 @@ type WithAction<TMode extends BuilderMode, TItem, TTrigger, TActions extends Rec
198
198
  */
199
199
  interface ActionMethods<TTrigger, TActions extends Record<string, unknown>, TVars extends Record<string, unknown> = EmptyObject, TMode extends BuilderMode = "root", TItem = never> {
200
200
  /**
201
- * `inputs` is a ctx-lambda mapping input names to
202
- * refs/values; `code` is ALWAYS a FUNCTION — the TS contract is the
203
- * authoring surface (typed `input.parameters` from `inputs`; the return
204
- * type flows to `ctx.actions.<name>.result.*` downstream; no raw-string
205
- * alternative — #125). Under `elementum build`, the body ships byte-exact
206
- * from the automation file's own untranspiled source (see
207
- * `tryExtractFromCurrentSource` in `script-code.ts`) rather than from the
208
- * transpiled function's `toString()`, which would otherwise reformat a
209
- * pulled script's exact text on every rebuild. Outside `elementum build`
210
- * (e.g. constructing an automation directly in a test), the body falls
211
- * back to `extractScriptBody`'s `toString()` extraction.
201
+ * `inputs` is a ctx-lambda mapping input names to refs/values. `code` is
202
+ * either an inline function (#125) or a `scriptFile(...)` reference to a
203
+ * plain `.js` body. Under `elementum build`, an inline body's text ships
204
+ * byte-exact from the automation file (see `tryExtractFromCurrentSource`);
205
+ * outside build it falls back to `extractScriptBody`'s `toString()`. A
206
+ * `scriptFile` body is the file's text, never type-stripped.
212
207
  *
213
- * The output schema is INFERRED from the code's `return {...}` literals —
214
- * property names statically, property types from literal values (default
215
- * text). Pass `outputs` only to override: a non-text property whose value
216
- * isn't a literal, or a return the scan can't enumerate. Pass `outputs:
217
- * null` (rather than omitting it) to explicitly suppress inference — the
218
- * printer does this for pulled actions whose platform resource genuinely
219
- * carries no `output_schema`, so a rebuild doesn't invent one and drift
220
- * from state.
208
+ * Downstream `ctx.actions.<name>.result.*` typing:
209
+ * - inline function: from the function's return type;
210
+ * - `scriptFile` with a declared `outputs`: from that schema (#2125);
211
+ * - `scriptFile` with `outputs` omitted or `null`: `Record<string, unknown>`.
212
+ *
213
+ * For an inline function the output schema is also INFERRED from
214
+ * `return {...}` literals (property names statically; types from literals,
215
+ * default text). Pass `outputs` to override a non-text property or a return
216
+ * the scan can't enumerate. Pass `outputs: null` to suppress inference —
217
+ * the printer does this for pulled actions with no platform
218
+ * `output_schema`, so a rebuild doesn't invent one and drift from state.
219
+ * For `scriptFile`, inference from the file is not available at the type
220
+ * level: declare `outputs` when downstream steps need typed results.
221
+ */
222
+ executeScript<TName extends string, I extends Record<string, ValueOrRef<unknown> | actionFactories.ExecuteScriptListInputToken>, const O extends ScriptOutputs>(name: TName, opts: {
223
+ readonly inputs?: (ctx: NestedActionContext<TTrigger, TActions, TVars, TItem>) => I;
224
+ readonly code: ScriptFile;
225
+ readonly outputs: O;
226
+ }, displayName?: string, hclParent?: "trigger" | string): WithAction<TMode, TItem, TTrigger, TActions, TVars, TName, {
227
+ result: ExecuteScriptOutput<O>["result"];
228
+ textResult: string;
229
+ stringArrayResult: readonly string[];
230
+ numberArrayResult: readonly number[];
231
+ }>;
232
+ /**
233
+ * `scriptFile` with `outputs` omitted, `null`, or typed `ScriptOutputs | null`
234
+ * (or wider): untyped result, as before #2125. A plain non-null
235
+ * `ScriptOutputs` variable still takes the overload above, so each result
236
+ * key is a union of every output value type rather than `unknown`.
221
237
  */
238
+ executeScript<TName extends string, I extends Record<string, ValueOrRef<unknown> | actionFactories.ExecuteScriptListInputToken>>(name: TName, opts: {
239
+ readonly inputs?: (ctx: NestedActionContext<TTrigger, TActions, TVars, TItem>) => I;
240
+ readonly code: ScriptFile;
241
+ readonly outputs?: ScriptOutputs | null;
242
+ }, displayName?: string, hclParent?: "trigger" | string): WithAction<TMode, TItem, TTrigger, TActions, TVars, TName, {
243
+ result: Record<string, unknown>;
244
+ textResult: string;
245
+ stringArrayResult: readonly string[];
246
+ numberArrayResult: readonly number[];
247
+ }>;
248
+ /** Inline function: result keys follow the function's return type. */
222
249
  executeScript<TName extends string, I extends Record<string, ValueOrRef<unknown> | actionFactories.ExecuteScriptListInputToken>, R extends Record<string, unknown> = Record<string, unknown>>(name: TName, opts: {
223
250
  readonly inputs?: (ctx: NestedActionContext<TTrigger, TActions, TVars, TItem>) => I;
224
- readonly code: ((input: ScriptInput<ResolvedRefs<NoInfer<I>>>) => R) | ScriptFile;
251
+ readonly code: (input: ScriptInput<ResolvedRefs<NoInfer<I>>>) => R;
225
252
  /**
226
253
  * Override the inferred output schema: property name → scalar type or a
227
254
  * recursive `{ type: "array", items }` / `{ type: "object", properties }`
228
255
  * descriptor; the object form may also carry `name` for the root.
229
- * `null`
230
- * explicitly means "no schema" and suppresses inference; omitting the
231
- * option infers from the code body.
256
+ * `null` explicitly means "no schema" and suppresses inference; omitting
257
+ * the option infers from the code body.
232
258
  */
233
259
  readonly outputs?: ScriptOutputs | null;
234
260
  }, displayName?: string, hclParent?: "trigger" | string): WithAction<TMode, TItem, TTrigger, TActions, TVars, TName, {
@@ -486,6 +486,15 @@ export function rewriteCanonicalOutputRefName(taskKey, name, taskRefKey, schema,
486
486
  }
487
487
  return name;
488
488
  }
489
+ /** Rename a task's `.record` reference to its whole-record output, in place. */
490
+ function useWholeTaskRecord(value, taskKindByRefKey) {
491
+ const mapped = value?.taskReference;
492
+ if (typeof mapped?.taskRefKey !== "string" || mapped.name !== "record")
493
+ return;
494
+ const wholeRecord = WHOLE_RECORD_REF_WIRE_NAMES[taskKindByRefKey.get(mapped.taskRefKey) ?? ""];
495
+ if (wholeRecord !== undefined)
496
+ mapped.name = wholeRecord;
497
+ }
489
498
  /**
490
499
  * Walk a serialized wire node and rewrite, in place, the `name` of every task
491
500
  * output reference whose target task needs an output-name rewrite. Two wire
@@ -512,13 +521,14 @@ checkDeclaredScriptResult = true, apiResponseTypes = new Map()) {
512
521
  if (node === null || typeof node !== "object")
513
522
  return;
514
523
  const rec = node;
524
+ // A script input reads a task's `.record` as the whole record, mapped or not.
525
+ const scriptInputs = rec.executeScript?.inputs;
526
+ if (Array.isArray(scriptInputs)) {
527
+ for (const input of scriptInputs)
528
+ useWholeTaskRecord(input?.value, taskKindByRefKey);
529
+ }
515
530
  if (Array.isArray(rec.field_mappings)) {
516
- const mapped = rec.value?.taskReference;
517
- const wholeRecord = typeof mapped?.taskRefKey === "string" && mapped.name === "record"
518
- ? WHOLE_RECORD_REF_WIRE_NAMES[taskKindByRefKey.get(mapped.taskRefKey) ?? ""]
519
- : undefined;
520
- if (wholeRecord !== undefined)
521
- mapped.name = wholeRecord;
531
+ useWholeTaskRecord(rec.value, taskKindByRefKey);
522
532
  // Field mappings read a trigger's whole record too, which shares its
523
533
  // display name with the record ID (edk#1284); see TRIGGER_WHOLE_RECORD_MARKER.
524
534
  const value = rec.value;
@@ -534,6 +534,7 @@ function emptyImports() {
534
534
  usesScriptInput: false,
535
535
  usesRefType: false,
536
536
  usesTableSearchTableRef: false,
537
+ usesGroupRef: false,
537
538
  };
538
539
  }
539
540
  /** Folder (inside the automations folder) that holds printed script files. */
@@ -776,8 +777,12 @@ function renderHeader(ast, imports, _opts) {
776
777
  return alias ? `${name} as ${alias}` : name;
777
778
  });
778
779
  lines.push(`import { ${sortedSpecifiers.join(", ")} } from "${sdkPackageSpecifier("automations")}";`);
779
- if (imports.usesTableSearchTableRef) {
780
- lines.push(`import { tableSearchTableRef } from "${sdkPackageSpecifier("catalog")}";`);
780
+ const catalogNamed = [
781
+ ...(imports.usesGroupRef ? ["groupRef"] : []),
782
+ ...(imports.usesTableSearchTableRef ? ["tableSearchTableRef"] : []),
783
+ ];
784
+ if (catalogNamed.length > 0) {
785
+ lines.push(`import { ${catalogNamed.join(", ")} } from "${sdkPackageSpecifier("catalog")}";`);
781
786
  }
782
787
  if (imports.usesSecret || imports.usesTemplate || imports.usesUnresolvedField || imports.usesUnsafePlatformId || imports.usesRefType) {
783
788
  const coreNamed = [];
@@ -1058,7 +1063,7 @@ function formatExecuteScript(task, state, indent, refCtx = DEFAULT_CTX) {
1058
1063
  }
1059
1064
  }
1060
1065
  if (task.args.outputs !== undefined && task.args.outputs !== null && typeof task.args.outputs === "object") {
1061
- lines.push(`${configPad}outputs: ${printObjectLiteral(task.args.outputs, state, indent + 1, DEFAULT_CTX)},`);
1066
+ lines.push(`${configPad}outputs: ${printOutputSchemaLiteral(task.args.outputs, indent + 1)},`);
1062
1067
  }
1063
1068
  else {
1064
1069
  // No `output_schema` on the platform resource — print an explicit `null`
@@ -1858,6 +1863,10 @@ function printRef(ref, state, refCtx) {
1858
1863
  state.imports.usesSecret = true;
1859
1864
  return `secret(${quote(ref.key)})`;
1860
1865
  case "orgGroup":
1866
+ if (ref.inOrgCatalog === false) {
1867
+ state.imports.usesGroupRef = true;
1868
+ return `groupRef({ name: ${quote(ref.name)} })`;
1869
+ }
1861
1870
  state.imports.usesOrg = true;
1862
1871
  return `org.groups${safeMember(ref.groupKey)}`;
1863
1872
  case "documentModel":
@@ -2004,6 +2013,26 @@ function printObjectLiteral(obj, state, indent, refCtx) {
2004
2013
  });
2005
2014
  return `{\n${lines.join("\n")}\n${" ".repeat(indent - 1)}}`;
2006
2015
  }
2016
+ /**
2017
+ * An output schema is plain data: a property named `code` or `script` is an
2018
+ * output's type, not a script body, so none of printArgValue's detection applies.
2019
+ */
2020
+ function printOutputSchemaLiteral(value, indent) {
2021
+ const pad = " ".repeat(indent);
2022
+ const closePad = " ".repeat(indent - 1);
2023
+ if (Array.isArray(value)) {
2024
+ if (value.length === 0)
2025
+ return "[]";
2026
+ return `[\n${value.map((item) => `${pad}${printOutputSchemaLiteral(item, indent + 1)},`).join("\n")}\n${closePad}]`;
2027
+ }
2028
+ if (value && typeof value === "object") {
2029
+ const entries = Object.entries(value);
2030
+ if (entries.length === 0)
2031
+ return "{}";
2032
+ return `{\n${entries.map(([k, v]) => `${pad}${safeKey(k)}: ${printOutputSchemaLiteral(v, indent + 1)},`).join("\n")}\n${closePad}}`;
2033
+ }
2034
+ return literalJson(value);
2035
+ }
2007
2036
  function printArrayLiteral(arr, state, indent, refCtx) {
2008
2037
  if (arr.length === 0)
2009
2038
  return "[]";
@@ -82,6 +82,8 @@ interface DecodeContext {
82
82
  readonly stringifiedValueReferences?: {
83
83
  unresolved: boolean;
84
84
  };
85
+ /** Names of static group recipients org.ts doesn't carry yet (edk#2241), for one pull diagnostic each. */
86
+ readonly groupsMissingFromOrg?: Set<string>;
85
87
  /** Says what a task id that matches none of this automation's tasks points to (#2054). */
86
88
  readonly describeUnresolvedTask?: (taskId: string) => string;
87
89
  /** This automation's platform id, from its import block. */
@@ -156,7 +158,15 @@ export declare class UnresolvedTaskFilterRefError extends EntityTfError {
156
158
  * and printing nothing would clear the live account.
157
159
  */
158
160
  export declare class UnresolvedForeignServiceAccountError extends EntityTfError {
159
- constructor(automationLabel: string);
161
+ constructor(automationLabel: string, message?: string);
162
+ }
163
+ /**
164
+ * The service account is another app's, looked up through that app
165
+ * (`data.elementum_app.<label>`), and no app in the workspace declares it.
166
+ * Pull names the app so the next step can say which one to pull.
167
+ */
168
+ export declare class UnresolvedServiceAccountOwnerAppError extends UnresolvedForeignServiceAccountError {
169
+ constructor(automationLabel: string, serviceAccountName: string | undefined, missingApp: string);
160
170
  }
161
171
  /**
162
172
  * #1320: a task reads the current item of a loop that doesn't enclose it.
@@ -198,6 +208,7 @@ export interface AutomationFromTfContext {
198
208
  readonly groupKeysByName?: ReadonlyMap<string, string>;
199
209
  readonly serviceAccountsById?: FromTfContext["serviceAccountsById"];
200
210
  readonly foreignFileReaderRefsById?: FromTfContext["foreignFileReaderRefsById"];
211
+ readonly foreignAppRefNamespaces?: ReadonlyMap<string, string>;
201
212
  }
202
213
  export interface AutomationGraphFromTfResult {
203
214
  readonly automation?: AutomationAst;
@@ -221,5 +232,5 @@ export declare function automationFromTf(doc: TfDocument, automationLabel: strin
221
232
  }>, foreignTableRefsById?: ReadonlyMap<string, {
222
233
  readonly tableRefName: string;
223
234
  readonly name: string;
224
- }>, picklistOptionLabelById?: ReadonlyMap<string, string>, fieldNamesByOwnerRefName?: ReadonlyMap<string, ReadonlyMap<string, string>>, foreignAppRefNames?: ReadonlyMap<string, string>, foreignElementRefNames?: ReadonlyMap<string, string>, procedureKeysByDiscriminator?: ReadonlyMap<string, string>, foreignTaskRefNames?: ReadonlyMap<string, string>, groupKeysByName?: ReadonlyMap<string, string>, serviceAccountsById?: FromTfContext["serviceAccountsById"], foreignFileReaderRefsById?: FromTfContext["foreignFileReaderRefsById"]): AutomationFromTfResult;
235
+ }>, picklistOptionLabelById?: ReadonlyMap<string, string>, fieldNamesByOwnerRefName?: ReadonlyMap<string, ReadonlyMap<string, string>>, foreignAppRefNames?: ReadonlyMap<string, string>, foreignElementRefNames?: ReadonlyMap<string, string>, procedureKeysByDiscriminator?: ReadonlyMap<string, string>, foreignTaskRefNames?: ReadonlyMap<string, string>, groupKeysByName?: ReadonlyMap<string, string>, serviceAccountsById?: FromTfContext["serviceAccountsById"], foreignFileReaderRefsById?: FromTfContext["foreignFileReaderRefsById"], foreignAppRefNamespaces?: ReadonlyMap<string, string>): AutomationFromTfResult;
225
236
  export {};