@elementumai/edk 0.13.3 → 0.13.4
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.
- package/dist-sdk/src/engine/coverage-gaps.d.ts +3 -0
- package/dist-sdk/src/engine/coverage-gaps.js +5 -0
- package/dist-sdk/src/engine/pull/context.d.ts +1 -1
- package/dist-sdk/src/engine/pull/context.js +1 -1
- package/dist-sdk/src/engine/pull/stream-root.d.ts +5 -1
- package/dist-sdk/src/engine/pull/stream-root.js +3 -0
- package/dist-sdk/src/engine/tf/index.d.ts +1 -0
- package/dist-sdk/src/engine/tf/index.js +1 -0
- package/dist-sdk/src/engine/tf/jsonencode.d.ts +19 -0
- package/dist-sdk/src/engine/tf/jsonencode.js +49 -0
- package/dist-sdk/src/entities/app/index.d.ts +1 -1
- package/dist-sdk/src/entities/automation/approval-trigger-refs.d.ts +20 -0
- package/dist-sdk/src/entities/automation/approval-trigger-refs.js +83 -0
- package/dist-sdk/src/entities/automation/build.js +1 -1
- package/dist-sdk/src/entities/automation/deserializer/print-automation.js +7 -0
- package/dist-sdk/src/entities/automation/from-tf.d.ts +2 -0
- package/dist-sdk/src/entities/automation/from-tf.js +104 -14
- package/dist-sdk/src/entities/automation/index.d.ts +1 -1
- package/dist-sdk/src/entities/automation/lookup-owner.d.ts +23 -0
- package/dist-sdk/src/entities/automation/lookup-owner.js +27 -0
- package/dist-sdk/src/entities/automation/module.js +182 -24
- package/dist-sdk/src/entities/automation/to-tf.js +163 -5
- package/dist-sdk/src/entities/automation/triggers.d.ts +47 -1
- package/dist-sdk/src/entities/automation/unsafe-script-output.d.ts +10 -5
- package/dist-sdk/src/entities/automation/unsafe-script-output.js +10 -5
- package/dist-sdk/src/entities/dynamic-layout/build.d.ts +31 -11
- package/dist-sdk/src/entities/dynamic-layout/to-tf.js +38 -2
- package/dist-sdk/src/entities/element/index.d.ts +1 -1
- package/dist-sdk/src/entities/shared/filters/ast.d.ts +6 -0
- package/dist-sdk/src/entities/shared/filters/index.d.ts +15 -3
- package/dist-sdk/src/entities/shared/filters/index.js +19 -1
- package/dist-sdk/src/entities/shared/filters/print.js +5 -0
- package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +13 -0
- package/dist-sdk/src/entities/shared/filters/tf-codec.js +74 -1
- package/dist-sdk/src/entities/shared/filters/types.d.ts +8 -1
- package/dist-sdk/src/entities/widget/to-tf.js +2 -1
- package/dist-sdk/src/generated/ragnarok/ragnarok-spec.d.ts +4 -2
- package/dist-sdk/src/generated/ragnarok/ragnarok-spec.js +2 -2
- package/dist-sdk/src/graph/index.d.ts +1 -1
- package/dist-sdk/src/graph/types.d.ts +23 -0
- package/package.json +1 -1
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { OrgRefLookup } from "../../engine/build/context.js";
|
|
2
|
+
import { type TfBlock, type TfValue } from "../../engine/tf/index.js";
|
|
3
|
+
/** The owner kinds an automation can belong to, and the data source each is looked up with. */
|
|
4
|
+
declare const OWNER_DATA_TYPE: {
|
|
5
|
+
readonly app: "elementum_app";
|
|
6
|
+
readonly element: "elementum_element";
|
|
7
|
+
};
|
|
8
|
+
export type AutomationOwnerScope = keyof typeof OWNER_DATA_TYPE;
|
|
9
|
+
/**
|
|
10
|
+
* The owner lookup a `data.elementum_automation` lookup by display name
|
|
11
|
+
* reads its `app_id` from, for an automation of this app or element that is
|
|
12
|
+
* not in source (a widget, a dynamic-layout button, a Run Automation call,
|
|
13
|
+
* and adoption's stand-in for a skipped automation, #3047). The owner is
|
|
14
|
+
* looked up by its namespace, which is its Terraform label, rather than read
|
|
15
|
+
* from the managed app or element resource: OpenTofu defers a data source
|
|
16
|
+
* whose dependency has planned changes, so a plan that changes the app record
|
|
17
|
+
* would otherwise make the automation's id and parameter ids unknown, and
|
|
18
|
+
* every run task and reader of its outputs with them (edk#1514).
|
|
19
|
+
*/
|
|
20
|
+
export declare function automationLookupOwnerBlock(scope: AutomationOwnerScope, ownerTfLabel: string): TfBlock;
|
|
21
|
+
/** `automationLookupOwnerBlock`'s id, registering the block with `orgRefs`, or in `dataBlocks` when a build has no org lookup. */
|
|
22
|
+
export declare function automationLookupOwnerId(scope: AutomationOwnerScope, ownerTfLabel: string, orgRefs: OrgRefLookup | undefined, dataBlocks?: Map<string, TfBlock>): TfValue;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { expr } from "../../engine/tf/index.js";
|
|
2
|
+
/** The owner kinds an automation can belong to, and the data source each is looked up with. */
|
|
3
|
+
const OWNER_DATA_TYPE = { app: "elementum_app", element: "elementum_element" };
|
|
4
|
+
/**
|
|
5
|
+
* The owner lookup a `data.elementum_automation` lookup by display name
|
|
6
|
+
* reads its `app_id` from, for an automation of this app or element that is
|
|
7
|
+
* not in source (a widget, a dynamic-layout button, a Run Automation call,
|
|
8
|
+
* and adoption's stand-in for a skipped automation, #3047). The owner is
|
|
9
|
+
* looked up by its namespace, which is its Terraform label, rather than read
|
|
10
|
+
* from the managed app or element resource: OpenTofu defers a data source
|
|
11
|
+
* whose dependency has planned changes, so a plan that changes the app record
|
|
12
|
+
* would otherwise make the automation's id and parameter ids unknown, and
|
|
13
|
+
* every run task and reader of its outputs with them (edk#1514).
|
|
14
|
+
*/
|
|
15
|
+
export function automationLookupOwnerBlock(scope, ownerTfLabel) {
|
|
16
|
+
return { kind: "data", type: OWNER_DATA_TYPE[scope], label: ownerTfLabel, attrs: { namespace: ownerTfLabel } };
|
|
17
|
+
}
|
|
18
|
+
/** `automationLookupOwnerBlock`'s id, registering the block with `orgRefs`, or in `dataBlocks` when a build has no org lookup. */
|
|
19
|
+
export function automationLookupOwnerId(scope, ownerTfLabel, orgRefs, dataBlocks) {
|
|
20
|
+
if (orgRefs !== undefined) {
|
|
21
|
+
const resolved = orgRefs.resolveForeignRoot(scope, { tfLabel: ownerTfLabel, name: ownerTfLabel, namespace: ownerTfLabel });
|
|
22
|
+
return expr.dataAttr(resolved.resourceType, resolved.tfLabel, ["id"]);
|
|
23
|
+
}
|
|
24
|
+
const block = automationLookupOwnerBlock(scope, ownerTfLabel);
|
|
25
|
+
dataBlocks?.set(`${block.type}.${block.label}`, block);
|
|
26
|
+
return expr.dataAttr(block.type, block.label, ["id"]);
|
|
27
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** The automation entity's registry entry (see src/graph/). */
|
|
2
2
|
import { canonicalAuditRefKey } from "./system-ref-name.js";
|
|
3
|
-
import { appScopedResourceLabel, sanitizeName, scopedLabelToBagKey, tfLabelToTsLabel, tsLabelToTfLabel, isTfExpr } from "../../engine/tf/index.js";
|
|
3
|
+
import { appScopedResourceLabel, expr, sanitizeName, scopedLabelToBagKey, tfLabelToTsLabel, tsLabelToTfLabel, isTfExpr } from "../../engine/tf/index.js";
|
|
4
4
|
function elementOwnerHandle(payload) {
|
|
5
5
|
if (payload === null || typeof payload !== "object" || !("handle" in payload))
|
|
6
6
|
return undefined;
|
|
@@ -8,6 +8,7 @@ function elementOwnerHandle(payload) {
|
|
|
8
8
|
return typeof handle === "string" && handle !== "" ? handle : undefined;
|
|
9
9
|
}
|
|
10
10
|
import { renderAutomationCatalogEntry } from "./catalog-render.js";
|
|
11
|
+
import { automationLookupOwnerBlock } from "./lookup-owner.js";
|
|
11
12
|
import { hasUnresolvedForEachItem, preserveAuthoredAutomationPullMeta, printAutomationV2WithScriptFiles, SCRIPT_FILES_DIR } from "./deserializer/print-automation.js";
|
|
12
13
|
import { automationFromTf, automationOwnedAddresses, ForEachItemOutsideLoopError, UnresolvedForeignServiceAccountError, UnresolvedTaskFilterRefError, UnsupportedMultiTriggerError } from "./from-tf.js";
|
|
13
14
|
import { scriptFileRefs } from "./script-code.js";
|
|
@@ -159,15 +160,30 @@ export function droppedAutomationGap(autoBlock, autoLabel, gap) {
|
|
|
159
160
|
* automation is not in source (edk#2693). A button input reads its on-demand
|
|
160
161
|
* trigger's `parameter_ids`, which the lookup carries too (#3023).
|
|
161
162
|
*/
|
|
162
|
-
function unmanagedAutomationLookup(autoBlock, owned, label) {
|
|
163
|
+
function unmanagedAutomationLookup(autoBlock, owned, label, uniqueName) {
|
|
163
164
|
const name = autoBlock.attrs["name"];
|
|
164
165
|
const appId = autoBlock.attrs["app_id"];
|
|
165
166
|
const triggers = owned.filter((address) => address.startsWith("elementum_on_demand_trigger."));
|
|
166
|
-
|
|
167
|
+
// A Run Automation call reads the automation's id from the same lookup
|
|
168
|
+
// build emits for it (#3047), when the display name finds only this one.
|
|
169
|
+
const automation = uniqueName && autoBlock.label !== undefined ? [`${AUTOMATION_RESOURCE_TYPE}.${autoBlock.label}`] : [];
|
|
170
|
+
if (typeof name !== "string" || name === "" || appId === undefined || triggers.length + automation.length === 0)
|
|
167
171
|
return undefined;
|
|
172
|
+
// The owner by namespace, as build reads it (`automationLookupOwnerId`),
|
|
173
|
+
// so the lookups pair in the build-vs-export check (#3047).
|
|
174
|
+
const owner = isTfExpr(appId) && appId.$expr === "resource-attr" && (appId.type === "elementum_app" || appId.type === "elementum_element")
|
|
175
|
+
? automationLookupOwnerBlock(appId.type === "elementum_element" ? "element" : "app", appId.label)
|
|
176
|
+
: undefined;
|
|
168
177
|
return {
|
|
169
|
-
lookup: {
|
|
178
|
+
lookup: {
|
|
179
|
+
kind: "data",
|
|
180
|
+
type: AUTOMATION_RESOURCE_TYPE,
|
|
181
|
+
label,
|
|
182
|
+
attrs: { app_id: owner === undefined ? appId : expr.dataAttr(owner.type, owner.label, ["id"]), name },
|
|
183
|
+
},
|
|
170
184
|
addresses: triggers,
|
|
185
|
+
...(automation.length > 0 && { idAddresses: automation }),
|
|
186
|
+
...(owner !== undefined && { supporting: [owner] }),
|
|
171
187
|
};
|
|
172
188
|
}
|
|
173
189
|
const FIX_IN_PLATFORM = "To manage it with the EDK, change what the reason names in the platform, then pull again.";
|
|
@@ -179,7 +195,7 @@ const FIX_OR_REPORT = "If you can change what the reason names in the platform,
|
|
|
179
195
|
* display-name lookup (#1901), so archiving is safe. A dynamic-layout button
|
|
180
196
|
* does not count either (#2693). Any other reference from that layout still does.
|
|
181
197
|
*/
|
|
182
|
-
function externalReferrers(stream, owned, inSource) {
|
|
198
|
+
function externalReferrers(stream, owned, inSource, runnable = new Set()) {
|
|
183
199
|
const ownedSet = new Set(owned);
|
|
184
200
|
const referrers = [];
|
|
185
201
|
for (const block of stream.allBlocks) {
|
|
@@ -188,7 +204,9 @@ function externalReferrers(stream, owned, inSource) {
|
|
|
188
204
|
const address = `${block.type}.${block.label}`;
|
|
189
205
|
if (ownedSet.has(address) || block.type === "elementum_widget" || !inSource(address))
|
|
190
206
|
continue;
|
|
191
|
-
|
|
207
|
+
// A Run Automation call looks an automation that is not in source up by
|
|
208
|
+
// display name (#3047), so it does not keep the file either.
|
|
209
|
+
const attrs = block.type === "elementum_dynamic_layout" ? withoutAutomationButtons(block.attrs) : withoutRunTargetSites(block, runnable);
|
|
192
210
|
if (referenceIn(attrs, ownedSet) !== undefined)
|
|
193
211
|
referrers.push(address);
|
|
194
212
|
}
|
|
@@ -249,18 +267,119 @@ function referenceIn(value, targets) {
|
|
|
249
267
|
}
|
|
250
268
|
return undefined;
|
|
251
269
|
}
|
|
270
|
+
/**
|
|
271
|
+
* How many automations carry each display name: the stream's, plus every one
|
|
272
|
+
* the export left out (omitted-automations.json). The provider's name lookup
|
|
273
|
+
* sees those too and prefers an ACTIVE match, so a namesake it left out could
|
|
274
|
+
* take the lookup; counting them all is the conservative side (#3047).
|
|
275
|
+
*/
|
|
276
|
+
function automationDisplayNameCounts(stream, ctx) {
|
|
277
|
+
const counts = new Map();
|
|
278
|
+
const count = (name) => {
|
|
279
|
+
if (typeof name === "string")
|
|
280
|
+
counts.set(name, (counts.get(name) ?? 0) + 1);
|
|
281
|
+
};
|
|
282
|
+
for (const block of stream.allBlocks) {
|
|
283
|
+
if (block.kind === "resource" && block.type === AUTOMATION_RESOURCE_TYPE)
|
|
284
|
+
count(block.attrs["name"]);
|
|
285
|
+
}
|
|
286
|
+
for (const omitted of ctx.omittedAutomationsById?.values() ?? [])
|
|
287
|
+
count(omitted.name);
|
|
288
|
+
return counts;
|
|
289
|
+
}
|
|
252
290
|
/** The first of `targets` that any block at `owned` references, if any. */
|
|
253
|
-
function referencedAddress(stream, owned, targets) {
|
|
291
|
+
function referencedAddress(stream, owned, targets, runnable = new Set()) {
|
|
254
292
|
const ownedSet = new Set(owned);
|
|
255
293
|
for (const block of stream.allBlocks) {
|
|
256
294
|
if (block.type === undefined || block.label === undefined || !ownedSet.has(`${block.type}.${block.label}`))
|
|
257
295
|
continue;
|
|
258
|
-
const hit = referenceIn(block
|
|
296
|
+
const hit = referenceIn(withoutRunTargetSites(block, runnable), targets);
|
|
259
297
|
if (hit !== undefined)
|
|
260
298
|
return hit;
|
|
261
299
|
}
|
|
262
300
|
return undefined;
|
|
263
301
|
}
|
|
302
|
+
const RUN_AUTOMATION_TASK_TYPE = "elementum_run_automation_task";
|
|
303
|
+
/** The address a bare or attribute reference names, if it is a resource reference. */
|
|
304
|
+
function referencedResource(value) {
|
|
305
|
+
if (value === null || typeof value !== "object")
|
|
306
|
+
return undefined;
|
|
307
|
+
const record = value;
|
|
308
|
+
return record["$expr"] === "resource-attr" && typeof record["type"] === "string" && typeof record["label"] === "string"
|
|
309
|
+
? `${record["type"]}.${record["label"]}`
|
|
310
|
+
: undefined;
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* A block's attrs without the places a static Run Automation call names the
|
|
314
|
+
* automation it runs, when that automation is one of `runnable`: the run
|
|
315
|
+
* task's target, its inputs' trigger `parameter_ids` and `depends_on`, and the
|
|
316
|
+
* caller's publish `depends_on`. Pulled source names such a target with
|
|
317
|
+
* `automationRef({ refName, name, parent })`, and build looks the live
|
|
318
|
+
* automation up by that display name when it is not in source (#3047), as it
|
|
319
|
+
* does for a dynamic-layout button (#2693). Every other reference stays.
|
|
320
|
+
*/
|
|
321
|
+
function withoutRunTargetSites(block, runnable) {
|
|
322
|
+
if (runnable.size === 0 || (block.type !== RUN_AUTOMATION_TASK_TYPE && block.type !== WORKFLOW_PUBLISH_RESOURCE_TYPE))
|
|
323
|
+
return block.attrs;
|
|
324
|
+
const named = (value) => {
|
|
325
|
+
const address = referencedResource(value);
|
|
326
|
+
return address !== undefined && runnable.has(address);
|
|
327
|
+
};
|
|
328
|
+
const out = { ...block.attrs };
|
|
329
|
+
if (Array.isArray(out["depends_on"]))
|
|
330
|
+
out["depends_on"] = out["depends_on"].filter((entry) => !named(entry));
|
|
331
|
+
if (block.type !== RUN_AUTOMATION_TASK_TYPE)
|
|
332
|
+
return out;
|
|
333
|
+
for (const key of ["target_automation_id", "target_automation_ref"]) {
|
|
334
|
+
if (named(out[key]))
|
|
335
|
+
delete out[key];
|
|
336
|
+
}
|
|
337
|
+
if (Array.isArray(out["input_mappings"])) {
|
|
338
|
+
out["input_mappings"] = out["input_mappings"].map((mapping) => {
|
|
339
|
+
if (mapping === null || typeof mapping !== "object" || !named(mapping["parameter_id"]))
|
|
340
|
+
return mapping;
|
|
341
|
+
const { parameter_id: _parameterId, ...rest } = mapping;
|
|
342
|
+
return rest;
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
return out;
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* `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.
|
|
351
|
+
*/
|
|
352
|
+
function withUnmanagedRunTargets(value, names, ownerHandle) {
|
|
353
|
+
if (names.size === 0)
|
|
354
|
+
return value;
|
|
355
|
+
// Copy on write, through plain arrays and objects only: every other value
|
|
356
|
+
// (and any subtree with no such ref) keeps its identity and prototype.
|
|
357
|
+
const walk = (node) => {
|
|
358
|
+
if (Array.isArray(node)) {
|
|
359
|
+
const mapped = node.map(walk);
|
|
360
|
+
return mapped.some((child, index) => child !== node[index]) ? mapped : node;
|
|
361
|
+
}
|
|
362
|
+
if (node === null || typeof node !== "object")
|
|
363
|
+
return node;
|
|
364
|
+
const prototype = Object.getPrototypeOf(node);
|
|
365
|
+
if (prototype !== Object.prototype && prototype !== null)
|
|
366
|
+
return node;
|
|
367
|
+
const record = node;
|
|
368
|
+
if (record["kind"] === "automation" && typeof record["automationKey"] === "string") {
|
|
369
|
+
const name = record["appHandle"] === ownerHandle ? names.get(record["automationKey"]) : undefined;
|
|
370
|
+
return name === undefined ? record : { ...record, unmanagedName: name };
|
|
371
|
+
}
|
|
372
|
+
let changed = false;
|
|
373
|
+
const entries = Object.entries(record).map(([key, child]) => {
|
|
374
|
+
const next = walk(child);
|
|
375
|
+
if (next !== child)
|
|
376
|
+
changed = true;
|
|
377
|
+
return [key, next];
|
|
378
|
+
});
|
|
379
|
+
return changed ? Object.fromEntries(entries) : record;
|
|
380
|
+
};
|
|
381
|
+
return walk(value);
|
|
382
|
+
}
|
|
264
383
|
function extractAutomations(ownBlocks, stream, ctx) {
|
|
265
384
|
const items = [];
|
|
266
385
|
const skipped = [];
|
|
@@ -273,12 +392,45 @@ function extractAutomations(ownBlocks, stream, ctx) {
|
|
|
273
392
|
// Which file each skipped automation's resources come from (#1877).
|
|
274
393
|
const skippedOwnFiles = [];
|
|
275
394
|
const unmanagedLookups = [];
|
|
276
|
-
|
|
395
|
+
// What the pull summary lists for each skipped automation (#3053): a
|
|
396
|
+
// caller skipped only because of another skipped automation names that
|
|
397
|
+
// one's root cause, so the summary can group them.
|
|
398
|
+
const skippedReports = [];
|
|
399
|
+
const skippedOwner = new Map();
|
|
400
|
+
const rootCause = new Map();
|
|
401
|
+
// Skipped automations a Run Automation call can still name by display
|
|
402
|
+
// name (#3047): each one's addresses, and its key -> display name.
|
|
403
|
+
const runnable = new Set();
|
|
404
|
+
const runnableNames = new Map();
|
|
405
|
+
const displayNameCounts = automationDisplayNameCounts(stream, ctx);
|
|
406
|
+
const skip = (autoBlock, owned, refName, why, causedBy) => {
|
|
277
407
|
skipped.push(...owned);
|
|
278
408
|
skippedOwnFiles.push({ refName, addresses: owned });
|
|
279
|
-
const
|
|
409
|
+
const address = `${AUTOMATION_RESOURCE_TYPE}.${autoBlock.label ?? ""}`;
|
|
410
|
+
for (const member of owned)
|
|
411
|
+
skippedOwner.set(member, address);
|
|
412
|
+
const owner = causedBy === undefined ? undefined : skippedOwner.get(causedBy);
|
|
413
|
+
const root = owner === undefined ? undefined : rootCause.get(owner) ?? owner;
|
|
414
|
+
if (root !== undefined)
|
|
415
|
+
rootCause.set(address, root);
|
|
416
|
+
const name = autoBlock.attrs["name"];
|
|
417
|
+
skippedReports.push({
|
|
418
|
+
address,
|
|
419
|
+
name: typeof name === "string" && name !== "" ? name : autoBlock.label ?? "",
|
|
420
|
+
reason: why,
|
|
421
|
+
...(root !== undefined && { causedBy: root }),
|
|
422
|
+
});
|
|
423
|
+
// A name lookup fails when two automations in the app share the name.
|
|
424
|
+
const uniqueName = typeof name === "string" && name !== "" && displayNameCounts.get(name) === 1 && autoBlock.attrs["app_id"] !== undefined;
|
|
425
|
+
const lookup = unmanagedAutomationLookup(autoBlock, owned, `${ctx.appTfLabel}_${tsLabelToTfLabel(refName)}`, uniqueName);
|
|
280
426
|
if (lookup !== undefined)
|
|
281
427
|
unmanagedLookups.push(lookup);
|
|
428
|
+
if (uniqueName) {
|
|
429
|
+
for (const member of owned)
|
|
430
|
+
runnable.add(member);
|
|
431
|
+
// Keyed as the caller's decoded target ref is (from-tf `decodeValue`).
|
|
432
|
+
runnableNames.set(scopedLabelToBagKey(ctx.appTfLabel, autoBlock.label ?? ""), name);
|
|
433
|
+
}
|
|
282
434
|
};
|
|
283
435
|
const settledByState = new Set();
|
|
284
436
|
const release = (entry) => {
|
|
@@ -303,10 +455,11 @@ function extractAutomations(ownBlocks, stream, ctx) {
|
|
|
303
455
|
const owned = automationOwnedAddresses(doc, autoLabel);
|
|
304
456
|
const chain = referencedAddress(stream, owned, lostChains);
|
|
305
457
|
if (chain !== undefined) {
|
|
306
|
-
|
|
458
|
+
const why = `it uses ${chain}, which pull leaves unmanaged because its stage has no handle of its own (#1136)`;
|
|
459
|
+
skip(autoBlock, owned, scopedLabelToBagKey(ctx.appTfLabel, autoLabel), why);
|
|
307
460
|
release({
|
|
308
461
|
autoBlock, autoLabel, owned, refName: scopedLabelToBagKey(ctx.appTfLabel, autoLabel),
|
|
309
|
-
why
|
|
462
|
+
why,
|
|
310
463
|
nextStep: "To manage it with the EDK, give that stage its own handle in the platform, then pull again.",
|
|
311
464
|
});
|
|
312
465
|
continue;
|
|
@@ -320,10 +473,11 @@ function extractAutomations(ownBlocks, stream, ctx) {
|
|
|
320
473
|
// second copy of the live automation.
|
|
321
474
|
if (extracted.stringifiedValueReferences === true) {
|
|
322
475
|
const owned = automationOwnedAddresses(doc, autoLabel);
|
|
323
|
-
|
|
476
|
+
const why = "its export embeds a value reference as text that source cannot rebuild exactly (edk#1646)";
|
|
477
|
+
skip(autoBlock, owned, extracted.refName, why);
|
|
324
478
|
release({
|
|
325
479
|
autoBlock, autoLabel, owned, refName: extracted.refName,
|
|
326
|
-
why
|
|
480
|
+
why,
|
|
327
481
|
nextStep: "Keep editing it in the platform.",
|
|
328
482
|
});
|
|
329
483
|
continue;
|
|
@@ -354,7 +508,7 @@ function extractAutomations(ownBlocks, stream, ctx) {
|
|
|
354
508
|
message: err.message,
|
|
355
509
|
code: "unresolved-task-filter-ref",
|
|
356
510
|
});
|
|
357
|
-
skip(autoBlock, owned, scopedLabelToBagKey(ctx.appTfLabel, autoLabel));
|
|
511
|
+
skip(autoBlock, owned, scopedLabelToBagKey(ctx.appTfLabel, autoLabel), `pull could not turn its export into source: ${err.message}`);
|
|
358
512
|
release({
|
|
359
513
|
autoBlock, autoLabel, owned, refName: scopedLabelToBagKey(ctx.appTfLabel, autoLabel),
|
|
360
514
|
why: `pull could not turn its export into source: ${err.message}`,
|
|
@@ -364,7 +518,10 @@ function extractAutomations(ownBlocks, stream, ctx) {
|
|
|
364
518
|
});
|
|
365
519
|
continue;
|
|
366
520
|
}
|
|
367
|
-
|
|
521
|
+
// edk#1480: name the dropped automation and say what that means, as a
|
|
522
|
+
// typed gap so it counts (and fails --strict-coverage) by itself.
|
|
523
|
+
const why = `pull could not turn its export into source: ${err instanceof Error ? err.message : String(err)}`;
|
|
524
|
+
skip(autoBlock, owned, scopedLabelToBagKey(ctx.appTfLabel, autoLabel), why);
|
|
368
525
|
// No authored form can manage these, so release an earlier adoption
|
|
369
526
|
// rather than let the next apply destroy the live automation:
|
|
370
527
|
// sibling-loop item refs (#1320) and multi-trigger (#1785 / #39).
|
|
@@ -373,9 +530,6 @@ function extractAutomations(ownBlocks, stream, ctx) {
|
|
|
373
530
|
const released = err instanceof ForEachItemOutsideLoopError ||
|
|
374
531
|
err instanceof UnsupportedMultiTriggerError ||
|
|
375
532
|
err instanceof UnresolvedForeignServiceAccountError;
|
|
376
|
-
// edk#1480: name the dropped automation and say what that means, as a
|
|
377
|
-
// typed gap so it counts (and fails --strict-coverage) by itself.
|
|
378
|
-
const why = `pull could not turn its export into source: ${err instanceof Error ? err.message : String(err)}`;
|
|
379
533
|
if (released) {
|
|
380
534
|
release({
|
|
381
535
|
autoBlock, autoLabel, owned, refName: scopedLabelToBagKey(ctx.appTfLabel, autoLabel), why,
|
|
@@ -399,16 +553,19 @@ function extractAutomations(ownBlocks, stream, ctx) {
|
|
|
399
553
|
const skippedAddresses = new Set(skipped);
|
|
400
554
|
const releasedAddresses = new Set(releaseIfManaged);
|
|
401
555
|
for (const entry of kept) {
|
|
402
|
-
|
|
556
|
+
// A Run Automation call to a skipped automation keeps the caller: its
|
|
557
|
+
// source names the target by display name (#3047). Any other reference
|
|
558
|
+
// to a skipped resource still skips it.
|
|
559
|
+
const target = referencedAddress(stream, entry.owned, skippedAddresses, runnable);
|
|
403
560
|
if (target === undefined)
|
|
404
561
|
continue;
|
|
405
562
|
kept.delete(entry);
|
|
406
563
|
cascaded = true;
|
|
407
|
-
skip(entry.autoBlock, entry.owned, entry.extracted.refName);
|
|
408
564
|
const gap = {
|
|
409
565
|
why: `it uses ${target}, which pull skipped, so its reference would point at nothing`,
|
|
410
566
|
nextStep: `Fix ${target} first (see its own warning), then pull again.`,
|
|
411
567
|
};
|
|
568
|
+
skip(entry.autoBlock, entry.owned, entry.extracted.refName, gap.why, target);
|
|
412
569
|
if (releasedAddresses.has(target)) {
|
|
413
570
|
release({
|
|
414
571
|
autoBlock: entry.autoBlock, autoLabel: entry.autoLabel, owned: entry.owned, refName: entry.extracted.refName, ...gap,
|
|
@@ -442,7 +599,7 @@ function extractAutomations(ownBlocks, stream, ctx) {
|
|
|
442
599
|
changed = false;
|
|
443
600
|
const isSource = sourceGiven(archivedOwned());
|
|
444
601
|
for (const entry of [...archived]) {
|
|
445
|
-
if (externalReferrers(stream, entry.owned, isSource).length === 0)
|
|
602
|
+
if (externalReferrers(stream, entry.owned, isSource, runnable).length === 0)
|
|
446
603
|
continue;
|
|
447
604
|
archived.delete(entry);
|
|
448
605
|
changed = true;
|
|
@@ -452,7 +609,7 @@ function extractAutomations(ownBlocks, stream, ctx) {
|
|
|
452
609
|
const quarantineOwnFiles = [];
|
|
453
610
|
const settled = [];
|
|
454
611
|
for (const entry of released) {
|
|
455
|
-
const keptFor = archived.has(entry) ? [] : externalReferrers(stream, entry.owned, isSource);
|
|
612
|
+
const keptFor = archived.has(entry) ? [] : externalReferrers(stream, entry.owned, isSource, runnable);
|
|
456
613
|
if (keptFor.length === 0) {
|
|
457
614
|
quarantineOwnFiles.push({
|
|
458
615
|
kind: "automation",
|
|
@@ -480,7 +637,7 @@ function extractAutomations(ownBlocks, stream, ctx) {
|
|
|
480
637
|
// the same scopedLabelToBagKey as automationKey. Pushing bare AST (name
|
|
481
638
|
// only) made missing-automation diagnostics false-positive on every real
|
|
482
639
|
// extract (issue #395 / PR #417 review).
|
|
483
|
-
items.push({ ...extracted.ast, refName: extracted.refName });
|
|
640
|
+
items.push({ ...withUnmanagedRunTargets(extracted.ast, runnableNames, ctx.appRefName), refName: extracted.refName });
|
|
484
641
|
adoptionAddressAliases.push(...extracted.adoptionAddressAliases);
|
|
485
642
|
diagnostics.push(...(extracted.diagnostics ?? []).map((diagnostic) => `${autoLabel}: ${diagnostic}`));
|
|
486
643
|
}
|
|
@@ -521,6 +678,7 @@ function extractAutomations(ownBlocks, stream, ctx) {
|
|
|
521
678
|
...(validations.length > 0 && { validations }),
|
|
522
679
|
...(skippedOwnFiles.length > 0 && { skippedOwnFiles }),
|
|
523
680
|
...(unmanagedLookups.length > 0 && { unmanagedLookups }),
|
|
681
|
+
...(skippedReports.length > 0 && { skippedReports }),
|
|
524
682
|
...(settleAfterExtract !== undefined && { settleAfterExtract }),
|
|
525
683
|
};
|
|
526
684
|
}
|
|
@@ -33,7 +33,9 @@ import { normalizeOnDemandParamKey } from "../../../pull/util.js";
|
|
|
33
33
|
import { PROVIDER_FIXED_SYSTEM_FIELD_KEYS, recordFieldWireRefName } from "./system-ref-name.js";
|
|
34
34
|
import { taskTfLabel } from "./task-label.js";
|
|
35
35
|
import { slackMessageTriggerReferenceName, slackMessageTriggerRefName } from "./slack-message-refs.js";
|
|
36
|
+
import { approvalTriggerReferenceName, approvalTriggerRefsKey } from "./approval-trigger-refs.js";
|
|
36
37
|
import { automationRunTargetResourceAttr, automationTargetOwner, bareStaticRunTarget, onDemandRecordParamNames, recordInputMappingProblem } from "./run-target.js";
|
|
38
|
+
import { automationLookupOwnerId } from "./lookup-owner.js";
|
|
37
39
|
import { FIELD_TYPE_MAP, isOnDemandRecordType } from "../shared/types/field-types.js";
|
|
38
40
|
/** The context for reading records of `appRefName` (a `kind`), retargeted from the owner. */
|
|
39
41
|
/**
|
|
@@ -841,6 +843,32 @@ function automationTargetToTf(value, ctx, dataBlocks) {
|
|
|
841
843
|
: sibling !== undefined && sibling.kind !== "table"
|
|
842
844
|
? sibling.tfLabel
|
|
843
845
|
: undefined;
|
|
846
|
+
const ownAutomations = isOwn ? ctx.workspaceAspects?.get(workspaceAspectKey(ownerKind, ctx.appRefName))?.automationRefNames : undefined;
|
|
847
|
+
if (ownAutomations !== undefined && !ownAutomations.has(value.refName) && typeof value.name === "string" && value.name !== "") {
|
|
848
|
+
// An automation of this owner that is not in source (pull leaves it
|
|
849
|
+
// platform-managed, #3047): a reference to its resources would be
|
|
850
|
+
// undeclared, so read its id and published parameter ids through a
|
|
851
|
+
// lookup by display name, the lookup a widget or dynamic-layout button
|
|
852
|
+
// uses (#1901, #2693). It names no publish, so nothing waits on one, and
|
|
853
|
+
// it reads the owner by namespace, so an app change doesn't defer it.
|
|
854
|
+
const label = `${ctx.appTfLabel}_${tsLabelToTfLabel(value.refName)}`;
|
|
855
|
+
const ownerId = automationLookupOwnerId(ctx.parentScope, ctx.appTfLabel, ctx.orgRefs, dataBlocks);
|
|
856
|
+
if (ctx.orgRefs !== undefined) {
|
|
857
|
+
ctx.orgRefs.rawLookup(AUTOMATION_RESOURCE_TYPE, label, value.name, { app_id: ownerId });
|
|
858
|
+
}
|
|
859
|
+
else {
|
|
860
|
+
dataBlocks.set(`${AUTOMATION_RESOURCE_TYPE}.${label}`, {
|
|
861
|
+
kind: "data",
|
|
862
|
+
type: AUTOMATION_RESOURCE_TYPE,
|
|
863
|
+
label,
|
|
864
|
+
attrs: { app_id: ownerId, name: value.name },
|
|
865
|
+
});
|
|
866
|
+
}
|
|
867
|
+
return {
|
|
868
|
+
id: expr.dataAttr(AUTOMATION_RESOURCE_TYPE, label, ["id"]),
|
|
869
|
+
parameterId: (name) => expr.dataAttr(AUTOMATION_RESOURCE_TYPE, label, ["parameter_ids", { index: name }]),
|
|
870
|
+
};
|
|
871
|
+
}
|
|
844
872
|
if (managedOwnerLabel !== undefined) {
|
|
845
873
|
const targetOwner = ctx.workspaceAspects?.get(workspaceAspectKey(ownerKind, isOwn ? ctx.appRefName : value.parent ?? ""));
|
|
846
874
|
const managedHandle = ownerKind === "element"
|
|
@@ -1706,7 +1734,9 @@ function foreignFoundRecordFieldId(fieldKey, taskRefKey, refs) {
|
|
|
1706
1734
|
return expr.dataAttr("elementum_field", registerForeignFieldLookup(fieldToken, refs.owner, refs.dataBlocks), ["id"]);
|
|
1707
1735
|
}
|
|
1708
1736
|
function calculationTriggerMustache(name, refs) {
|
|
1709
|
-
const triggerName = onDemandTriggerRefName(name, refs) ??
|
|
1737
|
+
const triggerName = onDemandTriggerRefName(name, refs) ??
|
|
1738
|
+
slackTriggerReferenceName(name, refs) ??
|
|
1739
|
+
approvalTriggerReferenceNameOn(name, refs);
|
|
1710
1740
|
if (triggerName !== undefined)
|
|
1711
1741
|
return [`{{trigger name="${triggerName}"}}`];
|
|
1712
1742
|
const parts = name.split(".");
|
|
@@ -2148,6 +2178,20 @@ function slackTriggerRefName(name, refs) {
|
|
|
2148
2178
|
function slackTriggerReferenceName(name, refs) {
|
|
2149
2179
|
return refs.trigger.type === TRIGGER_RESOURCES.slackMessage ? slackMessageTriggerReferenceName(name) : undefined;
|
|
2150
2180
|
}
|
|
2181
|
+
/**
|
|
2182
|
+
* An approval process status trigger's refs-map key (#2990); undefined on any
|
|
2183
|
+
* other trigger or for a record reference. A field of the app that shares the
|
|
2184
|
+
* key's display name moves the output to its group-qualified key.
|
|
2185
|
+
*/
|
|
2186
|
+
function approvalTriggerRefName(name, refs) {
|
|
2187
|
+
return refs.trigger.type === TRIGGER_RESOURCES.approvalChain
|
|
2188
|
+
? approvalTriggerRefsKey(name, refs.owner.fieldNames.values())
|
|
2189
|
+
: undefined;
|
|
2190
|
+
}
|
|
2191
|
+
/** An approval process status trigger's `triggerReference.name`; undefined on any other trigger. */
|
|
2192
|
+
function approvalTriggerReferenceNameOn(name, refs) {
|
|
2193
|
+
return refs.trigger.type === TRIGGER_RESOURCES.approvalChain ? approvalTriggerReferenceName(name) : undefined;
|
|
2194
|
+
}
|
|
2151
2195
|
function triggerWireRefName(name, refs) {
|
|
2152
2196
|
const onDemandName = onDemandTriggerRefName(name, refs);
|
|
2153
2197
|
if (onDemandName !== undefined)
|
|
@@ -2155,6 +2199,9 @@ function triggerWireRefName(name, refs) {
|
|
|
2155
2199
|
const slackName = slackTriggerRefName(name, refs);
|
|
2156
2200
|
if (slackName !== undefined)
|
|
2157
2201
|
return slackName;
|
|
2202
|
+
const approvalName = approvalTriggerRefName(name, refs);
|
|
2203
|
+
if (approvalName !== undefined)
|
|
2204
|
+
return approvalName;
|
|
2158
2205
|
const scalarParams = refs.triggerParamNames.filter((param) => !refs.recordParamNames.includes(param));
|
|
2159
2206
|
const declared = onDemandTriggerRefKey(name, scalarParams);
|
|
2160
2207
|
if (declared !== name || scalarParams.includes(name))
|
|
@@ -2465,6 +2512,7 @@ function workflowPublishOutputEnvelope(value, refs) {
|
|
|
2465
2512
|
triggerReference: {
|
|
2466
2513
|
name: onDemandTriggerRefName(value.triggerReference.name, refs) ??
|
|
2467
2514
|
slackTriggerReferenceName(value.triggerReference.name, refs) ??
|
|
2515
|
+
approvalTriggerReferenceNameOn(value.triggerReference.name, refs) ??
|
|
2468
2516
|
wireRefName(value.triggerReference.name, refs.owner),
|
|
2469
2517
|
},
|
|
2470
2518
|
variableReference: null,
|
|
@@ -3145,6 +3193,20 @@ function filterReferenceToTf(value, refs, role = "value", realType, operator) {
|
|
|
3145
3193
|
(value.name === "recordId" || value.name === "record")) {
|
|
3146
3194
|
return "trigger.recordId";
|
|
3147
3195
|
}
|
|
3196
|
+
// An approval process status trigger's own outputs (#2990): a filter
|
|
3197
|
+
// reads them by the platform's short form, `trigger.approver.id`, as
|
|
3198
|
+
// the editor saves and export prints it (edk#1569). The bare approver
|
|
3199
|
+
// would walk to the whole user, so a filter names the field it compares.
|
|
3200
|
+
if (refs.trigger.type === TRIGGER_RESOURCES.approvalChain) {
|
|
3201
|
+
const referenceName = approvalTriggerReferenceName(value.name);
|
|
3202
|
+
if (referenceName !== undefined) {
|
|
3203
|
+
if (value.name === "approver") {
|
|
3204
|
+
throw new EntityTfError("filter on ctx.trigger.approver: compare a field of the approver, " +
|
|
3205
|
+
"ctx.trigger.approver.id, .email or .name");
|
|
3206
|
+
}
|
|
3207
|
+
return `trigger.${referenceName}`;
|
|
3208
|
+
}
|
|
3209
|
+
}
|
|
3148
3210
|
const triggerRefKey = triggerWireRefName(value.name, refs);
|
|
3149
3211
|
if (refs.trigger.type === TRIGGER_RESOURCES.onDemand) {
|
|
3150
3212
|
// filter_refs holds only declared inputs, so the user who ran the
|
|
@@ -3159,7 +3221,7 @@ function filterReferenceToTf(value, refs, role = "value", realType, operator) {
|
|
|
3159
3221
|
// object, so a filter must name the field it compares.
|
|
3160
3222
|
if (value.name === "triggeredBy") {
|
|
3161
3223
|
throw new EntityTfError("filter on ctx.trigger.triggeredBy: compare a field of the user who ran the automation, " +
|
|
3162
|
-
"ctx.trigger.triggeredBy.id, .email or .name");
|
|
3224
|
+
"ctx.trigger.triggeredBy.id, .email or .name (filter.groupsOf takes ctx.trigger.triggeredBy.id)");
|
|
3163
3225
|
}
|
|
3164
3226
|
return `trigger.${value.name}`;
|
|
3165
3227
|
}
|
|
@@ -3747,9 +3809,101 @@ function booleanTaskOutputRealType(reference, refs, authored) {
|
|
|
3747
3809
|
const declared = declaredTaskOutputType(task, wireName, envelopeName);
|
|
3748
3810
|
return declared?.fieldType === "BOOLEAN" && declared.multiple !== true ? "BOOLEAN" : undefined;
|
|
3749
3811
|
}
|
|
3750
|
-
|
|
3812
|
+
/**
|
|
3813
|
+
* What a record field holds when a filter reference reads it, for any record
|
|
3814
|
+
* `recordFieldSource` can place: the trigger record, an on-demand record
|
|
3815
|
+
* input, a found record or a record loop item, of this app or another
|
|
3816
|
+
* (edk#3039). A user field is the whole user unless the path ends in `.id`
|
|
3817
|
+
* (mobius normalizeUsers); every other known field is not a user's id.
|
|
3818
|
+
*/
|
|
3819
|
+
function recordFieldDeclaredType(reference, refs) {
|
|
3820
|
+
const kind = reference.type?.toString().toUpperCase();
|
|
3821
|
+
const valueReference = kind === "TASK" ? { taskReference: { taskRefKey: reference.taskRefKey, name: reference.name } }
|
|
3822
|
+
: kind === "TRIGGER" ? { triggerReference: { name: reference.name } }
|
|
3823
|
+
: kind === "FOR_EACH" ? { forEachReference: { forEachTaskRefKey: reference.forEachTaskRefKey, name: reference.name } }
|
|
3824
|
+
: undefined;
|
|
3825
|
+
const source = valueReference === undefined ? undefined : recordFieldSource(valueReference, refs);
|
|
3826
|
+
if (source === undefined)
|
|
3827
|
+
return undefined;
|
|
3828
|
+
const address = source.addresses?.get(source.fieldKey);
|
|
3829
|
+
const resourceType = address === undefined ? undefined : address.slice(0, address.indexOf("."));
|
|
3830
|
+
const catalogTypes = source.addresses === undefined && source.ownerRefName !== undefined
|
|
3831
|
+
? fieldNamesForAppRefName(refs.owner.catalogFieldTypesByAppRefName, source.ownerRefName)
|
|
3832
|
+
: undefined;
|
|
3833
|
+
const catalogType = catalogTypes?.get(source.fieldKey);
|
|
3834
|
+
const ownerKnown = source.addresses !== undefined || catalogTypes !== undefined;
|
|
3835
|
+
// Only a key the owner has is classified. Any other key (pull keeps a deleted
|
|
3836
|
+
// field's raw id, edk#3039 round 6) stays unchecked, as filter.uuid does.
|
|
3837
|
+
const systemField = ownerKnown && SYSTEM_FIELD_KEY_SET.has(source.fieldKey);
|
|
3838
|
+
const isUser = resourceType !== undefined ? resourceType === "elementum_user_field"
|
|
3839
|
+
: catalogType !== undefined ? catalogType === "USER" || catalogType === "USER_ID"
|
|
3840
|
+
: systemField ? OBJECT_VALUED_SYSTEM_FIELD_KINDS[source.fieldKey] === "user"
|
|
3841
|
+
: undefined;
|
|
3842
|
+
if (isUser === undefined)
|
|
3843
|
+
return undefined;
|
|
3844
|
+
const rest = source.rest.join(".");
|
|
3845
|
+
if (isUser)
|
|
3846
|
+
return { type: rest === "id" ? "USER_ID" : rest === "" ? "USER" : "TEXT" };
|
|
3847
|
+
// A deeper path through another field (a dynamic Dropdown's linked record,
|
|
3848
|
+
// `hallPassReason.createdBy.id`) reads that record, which isn't typed here.
|
|
3849
|
+
if (source.rest.length > 1)
|
|
3850
|
+
return undefined;
|
|
3851
|
+
const fieldType = resourceType?.replace(/^elementum_/, "").replace(/_field$/, "").toUpperCase()
|
|
3852
|
+
?? catalogType
|
|
3853
|
+
?? (source.fieldKey === "id" ? "RECORD_HANDLE" : "SYSTEM_FIELD");
|
|
3854
|
+
return { type: rest === "" ? fieldType : `${fieldType}_PART` };
|
|
3855
|
+
}
|
|
3856
|
+
/**
|
|
3857
|
+
* The declared type of what a filter reference holds, for `filter.groupsOf`'s
|
|
3858
|
+
* one-user-id check (edk#3039): the user who ran an on-demand automation, a
|
|
3859
|
+
* record field of any app (trigger record, on-demand record input, found
|
|
3860
|
+
* record or record loop item), a record loop's own item, a whole plain-list
|
|
3861
|
+
* loop item, a task output with a declared type, or a variable with a
|
|
3862
|
+
* declared type. Undefined when the type isn't known here.
|
|
3863
|
+
*/
|
|
3864
|
+
function filterReferenceDeclaredType(reference, refs) {
|
|
3865
|
+
if (!isObject(reference) || typeof reference.name !== "string")
|
|
3866
|
+
return undefined;
|
|
3867
|
+
const kind = reference.type?.toString().toUpperCase();
|
|
3868
|
+
if (kind === "TRIGGER") {
|
|
3869
|
+
if (refs.trigger?.type === TRIGGER_RESOURCES.onDemand && ON_DEMAND_TRIGGERED_BY_REFS[reference.name] !== undefined) {
|
|
3870
|
+
return { type: reference.name === "triggeredBy" || reference.name === "triggeredBy.id" ? "USER_ID" : "TEXT" };
|
|
3871
|
+
}
|
|
3872
|
+
return recordFieldDeclaredType(reference, refs);
|
|
3873
|
+
}
|
|
3874
|
+
if (kind === "TASK" && typeof reference.taskRefKey === "string") {
|
|
3875
|
+
const task = refs.tasks.get(reference.taskRefKey);
|
|
3876
|
+
if (task === undefined)
|
|
3877
|
+
return undefined;
|
|
3878
|
+
if (/^records?\./.test(reference.name))
|
|
3879
|
+
return recordFieldDeclaredType(reference, refs);
|
|
3880
|
+
const wireName = taskWireRefName(reference.name, reference.taskRefKey, refs);
|
|
3881
|
+
const envelopeName = taskOutputReferenceName(task.type, wireName, task) ?? wireName;
|
|
3882
|
+
const declared = declaredTaskOutputType(task, wireName, envelopeName);
|
|
3883
|
+
return declared === undefined ? undefined : { type: declared.fieldType, multiple: declared.multiple };
|
|
3884
|
+
}
|
|
3885
|
+
if (kind === "FOR_EACH" && typeof reference.forEachTaskRefKey === "string") {
|
|
3886
|
+
if (!refs.recordItemForEachRefKeys.has(reference.forEachTaskRefKey)) {
|
|
3887
|
+
// A plain-list loop's whole item (a user, say) is an object, not an id.
|
|
3888
|
+
return reference.name === "" || reference.name === "item" ? { type: "OBJECT" } : undefined;
|
|
3889
|
+
}
|
|
3890
|
+
// The loop item itself is the record, of any app: its id, never a user's.
|
|
3891
|
+
const [fieldKey] = reference.name.split(".");
|
|
3892
|
+
if (fieldKey === undefined || fieldKey === "" || fieldKey === "item" || fieldKey === "recordId")
|
|
3893
|
+
return { type: "ASPECT_RECORD_ID" };
|
|
3894
|
+
return recordFieldDeclaredType(reference, refs);
|
|
3895
|
+
}
|
|
3896
|
+
if (kind === "VARIABLE" && typeof reference.variableId === "string") {
|
|
3897
|
+
const valueType = refs.variableById.get(reference.variableId)?.valueType;
|
|
3898
|
+
return valueType === undefined ? undefined : { type: valueType };
|
|
3899
|
+
}
|
|
3900
|
+
return undefined;
|
|
3901
|
+
}
|
|
3902
|
+
function filterToTf(value, refs, options = {}) {
|
|
3751
3903
|
return serializeFilterToTf(value, {
|
|
3752
3904
|
...(refs.allowUnknownPicklistOptions === true && { keepUnresolvedOptions: true }),
|
|
3905
|
+
...(options.allowGroupsOf === true && { allowGroupsOf: true }),
|
|
3906
|
+
referenceDeclaredType: (reference) => filterReferenceDeclaredType(reference, refs),
|
|
3753
3907
|
field: (field) => valueToTf(field, refs),
|
|
3754
3908
|
// `userRef(email)` compares as the user's id, through the same user lookup a task value uses (#2891).
|
|
3755
3909
|
user: (email) => valueToTf({ __kind: "user", email }, refs),
|
|
@@ -4049,7 +4203,8 @@ function configAttrs(kind, config, refs) {
|
|
|
4049
4203
|
throw new EntityTfError("runAutomation targetAutomationId has an unresolved automation");
|
|
4050
4204
|
}
|
|
4051
4205
|
if (key === "filter") {
|
|
4052
|
-
|
|
4206
|
+
// Only a record search expands filter.groupsOf (ultron), edk#3039.
|
|
4207
|
+
attrs.filter = filterToTf(raw, refs, { allowGroupsOf: kind === TASK_RESOURCES.recordSearch });
|
|
4053
4208
|
continue;
|
|
4054
4209
|
}
|
|
4055
4210
|
if (key === "categorySource" && kind === "elementum_ai_classify_task") {
|
|
@@ -4650,7 +4805,10 @@ export function automationToTf(entity, ctx) {
|
|
|
4650
4805
|
if (wireType === "variable" && Array.isArray(taskBody.create)) {
|
|
4651
4806
|
taskBody.create.forEach((candidate, index) => {
|
|
4652
4807
|
if (isObject(candidate) && typeof candidate.id === "string" && typeof candidate.name === "string") {
|
|
4653
|
-
variableById.set(candidate.id, {
|
|
4808
|
+
variableById.set(candidate.id, {
|
|
4809
|
+
type: "elementum_variable_task", label: registeredLabel, name: candidate.name, index,
|
|
4810
|
+
...(typeof candidate.type === "string" ? { valueType: candidate.type } : {}),
|
|
4811
|
+
});
|
|
4654
4812
|
}
|
|
4655
4813
|
});
|
|
4656
4814
|
}
|