@elementumai/edk 0.9.12 → 0.9.14
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/progress.d.ts +3 -0
- package/dist-sdk/src/engine/progress.js +43 -5
- package/dist-sdk/src/engine/pull/result-output.js +13 -2
- package/dist-sdk/src/entities/automation/build.js +22 -8
- package/dist-sdk/src/entities/automation/deserializer/print-automation.js +8 -1
- package/dist-sdk/src/entities/automation/from-tf.js +13 -1
- package/dist-sdk/src/entities/automation/task-label.js +25 -2
- package/dist-sdk/src/entities/automation/to-tf.js +81 -6
- package/dist-sdk/src/entities/shared/filters/index.js +8 -1
- package/dist-sdk/src/entities/shared/filters/types.d.ts +1 -0
- package/package.json +1 -1
|
@@ -23,6 +23,9 @@ export declare function machineReadableLogsEnabled(): boolean;
|
|
|
23
23
|
export declare function writeProgress(line: string, textEffects?: readonly TextEffect[]): void;
|
|
24
24
|
/** Render one EDK-owned technical log through the same live-output arbiter. */
|
|
25
25
|
export declare function writeTechnicalLog(level: LogLevel, source: string, message: string, timestamp?: string, messageEffects?: readonly TextEffect[]): void;
|
|
26
|
+
/** Emit suppressed WARN/ERROR summaries at the end of a command. */
|
|
27
|
+
export declare function flushRepeatedTechnicalLogs(): void;
|
|
28
|
+
export declare function resetTechnicalLogDeduplication(): void;
|
|
26
29
|
/** Write user-owned output without allowing it to collide with the live row. */
|
|
27
30
|
export declare function writeUserOutput(text: string, destination?: NodeJS.WritableStream): void;
|
|
28
31
|
/** Write a final user-facing operation status without contaminating pipes. */
|
|
@@ -17,6 +17,8 @@ export function progressStream() {
|
|
|
17
17
|
return process.stderr;
|
|
18
18
|
}
|
|
19
19
|
let machineReadableLogs = false;
|
|
20
|
+
const LOG_LEVEL_PRIORITY = { DEBUG: 10, INFO: 20, WARN: 30, ERROR: 40 };
|
|
21
|
+
const repeatedTechnicalLogs = new Map();
|
|
20
22
|
/** Configure the global machine-readable diagnostic mode. */
|
|
21
23
|
export function configureMachineReadableLogs(enabled) {
|
|
22
24
|
machineReadableLogs = enabled;
|
|
@@ -38,8 +40,37 @@ export function writeProgress(line, textEffects) {
|
|
|
38
40
|
}
|
|
39
41
|
/** Render one EDK-owned technical log through the same live-output arbiter. */
|
|
40
42
|
export function writeTechnicalLog(level, source, message, timestamp = new Date().toISOString(), messageEffects) {
|
|
41
|
-
if (level
|
|
43
|
+
if (LOG_LEVEL_PRIORITY[level] < LOG_LEVEL_PRIORITY[configuredLogLevel()])
|
|
42
44
|
return;
|
|
45
|
+
if (level === "WARN" || level === "ERROR") {
|
|
46
|
+
const key = `${level}\0${source}\0${message}`;
|
|
47
|
+
const previous = repeatedTechnicalLogs.get(key);
|
|
48
|
+
if (previous !== undefined) {
|
|
49
|
+
previous.count += 1;
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
emitTechnicalLog(level, source, message, timestamp, messageEffects);
|
|
53
|
+
// The first occurrence is emitted immediately; only later occurrences are
|
|
54
|
+
// retained so they can be summarized without losing the original context.
|
|
55
|
+
repeatedTechnicalLogs.set(key, { level, source, message, count: 0 });
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
emitTechnicalLog(level, source, message, timestamp, messageEffects);
|
|
59
|
+
}
|
|
60
|
+
/** Emit suppressed WARN/ERROR summaries at the end of a command. */
|
|
61
|
+
export function flushRepeatedTechnicalLogs() {
|
|
62
|
+
for (const repeated of repeatedTechnicalLogs.values()) {
|
|
63
|
+
if (repeated.count === 0)
|
|
64
|
+
continue;
|
|
65
|
+
emitTechnicalLog(repeated.level, repeated.source, `Repeated entries: ${repeated.message} (repeated ${repeated.count} additional time${repeated.count === 1 ? "" : "s"})`);
|
|
66
|
+
repeated.count = 0;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
export function resetTechnicalLogDeduplication() {
|
|
70
|
+
flushRepeatedTechnicalLogs();
|
|
71
|
+
repeatedTechnicalLogs.clear();
|
|
72
|
+
}
|
|
73
|
+
function emitTechnicalLog(level, source, message, timestamp = new Date().toISOString(), messageEffects) {
|
|
43
74
|
if (machineReadableLogs) {
|
|
44
75
|
const event = {
|
|
45
76
|
timestamp,
|
|
@@ -69,13 +100,20 @@ export function writeTechnicalLog(level, source, message, timestamp = new Date()
|
|
|
69
100
|
});
|
|
70
101
|
writeProgress(prefix + message, effects.sort((a, b) => a.start - b.start));
|
|
71
102
|
}
|
|
72
|
-
function
|
|
73
|
-
const configured = process.env["ELEMENTUM_LOG_LEVEL"]?.
|
|
74
|
-
|
|
75
|
-
|
|
103
|
+
function configuredLogLevel() {
|
|
104
|
+
const configured = process.env["ELEMENTUM_LOG_LEVEL"]?.toUpperCase();
|
|
105
|
+
if (configured === "DEBUG" || configured === "TRACE")
|
|
106
|
+
return "DEBUG";
|
|
107
|
+
if (configured === "WARN" || configured === "ERROR" || configured === "INFO")
|
|
108
|
+
return configured;
|
|
109
|
+
if (process.env["EDK_DEBUG"] === "1" || process.argv.some((arg) => arg === "--debug" || arg === "--log-level=debug" || arg === "--log-level=trace"))
|
|
110
|
+
return "DEBUG";
|
|
111
|
+
return "INFO";
|
|
76
112
|
}
|
|
77
113
|
/** Write user-owned output without allowing it to collide with the live row. */
|
|
78
114
|
export function writeUserOutput(text, destination = process.stdout) {
|
|
115
|
+
if (machineReadableLogs)
|
|
116
|
+
return;
|
|
79
117
|
const live = activeProgress;
|
|
80
118
|
if (live !== undefined) {
|
|
81
119
|
live.writeUserOutput(text, destination);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { renderTextEffects, writeUserOutput } from "../progress.js";
|
|
1
|
+
import { flushRepeatedTechnicalLogs, machineReadableLogsEnabled, renderTextEffects, writeUserOutput } from "../progress.js";
|
|
2
2
|
export function managedResultStatus(operation, verdict) {
|
|
3
3
|
const outcome = verdict.failed === true
|
|
4
4
|
? "failure"
|
|
@@ -13,10 +13,13 @@ export function managedResultStatus(operation, verdict) {
|
|
|
13
13
|
* redirect gets the complete machine-readable result object.
|
|
14
14
|
*/
|
|
15
15
|
export function writePullResult(result, humanLines, status) {
|
|
16
|
+
// Put duplicate-warning summaries before the final success/warning/failure
|
|
17
|
+
// marker, so the marker remains the last diagnostic signal of the command.
|
|
18
|
+
flushRepeatedTechnicalLogs();
|
|
16
19
|
const resultWithStatus = status !== undefined && result !== null && typeof result === "object"
|
|
17
20
|
? { ...result, status: status.outcome }
|
|
18
21
|
: result;
|
|
19
|
-
if (process.stdout.isTTY === true) {
|
|
22
|
+
if (process.stdout.isTTY === true && !machineReadableLogsEnabled()) {
|
|
20
23
|
const renderedLines = humanLines.flatMap((line) => Array.isArray(line) && line.length === 0 ? [] : [renderPullResultLine(line)]);
|
|
21
24
|
if (status !== undefined) {
|
|
22
25
|
const message = status.outcome === "success"
|
|
@@ -34,6 +37,14 @@ export function writePullResult(result, humanLines, status) {
|
|
|
34
37
|
writeUserOutput(`${renderedLines.join("\n")}\n`);
|
|
35
38
|
return;
|
|
36
39
|
}
|
|
40
|
+
if (status !== undefined && !machineReadableLogsEnabled()) {
|
|
41
|
+
const message = status.outcome === "success"
|
|
42
|
+
? `${status.operation} completed successfully`
|
|
43
|
+
: status.outcome === "warning"
|
|
44
|
+
? `${status.operation} completed with warnings`
|
|
45
|
+
: `${status.operation} failed`;
|
|
46
|
+
process.stderr.write(`[edk] ${message}\n`);
|
|
47
|
+
}
|
|
37
48
|
process.stdout.write(`${JSON.stringify(resultWithStatus, null, 2)}\n`);
|
|
38
49
|
}
|
|
39
50
|
function renderPullResultLine(line) {
|
|
@@ -327,9 +327,23 @@ function stampAndCollectVariableIds(tasks) {
|
|
|
327
327
|
visit(tasks);
|
|
328
328
|
return map;
|
|
329
329
|
}
|
|
330
|
+
/** Resolve a `setVariable` action's variable to its minted id, or throw. */
|
|
331
|
+
function resolveVariableId(idMap, variableTaskRefKey, name) {
|
|
332
|
+
const id = idMap.get(`${variableTaskRefKey}::${name}`);
|
|
333
|
+
if (!id) {
|
|
334
|
+
throw new Error(`Variable "${name}" not found on action "${variableTaskRefKey}". ` +
|
|
335
|
+
`Check that a setVariable action with that refKey creates a variable with that name.`);
|
|
336
|
+
}
|
|
337
|
+
return id;
|
|
338
|
+
}
|
|
330
339
|
/**
|
|
331
|
-
* Replace
|
|
332
|
-
*
|
|
340
|
+
* Replace, in the serialized tree, every marker that names a workflow variable
|
|
341
|
+
* by its authoring-time `setVariable` refKey with the variable's minted id:
|
|
342
|
+
* - ordinary value positions: `{ __variableParamRef: { variableTaskRefKey, name } }`
|
|
343
|
+
* → `{ variableReference: { id, name: "variable|<id>" } }`.
|
|
344
|
+
* - filter value positions (recordSearch/switch/…): the `{ type: "VARIABLE",
|
|
345
|
+
* variableTaskRefKey, name }` reference emitted by `refDataToFilterReference`
|
|
346
|
+
* → `{ type: "VARIABLE", variableId: id }`, which to-tf emits as `variable.<uuid>` (#1045).
|
|
333
347
|
* Throws when a referenced variable isn't in `idMap` — the variable must be
|
|
334
348
|
* created by a `setVariable` action in the same automation.
|
|
335
349
|
*/
|
|
@@ -344,16 +358,16 @@ function resolveVariableParamMarkers(node, idMap) {
|
|
|
344
358
|
const o = node;
|
|
345
359
|
const marker = o.__variableParamRef;
|
|
346
360
|
if (marker) {
|
|
347
|
-
const
|
|
348
|
-
const id = idMap.get(key);
|
|
349
|
-
if (!id) {
|
|
350
|
-
throw new Error(`Variable "${marker.name}" not found on action "${marker.variableTaskRefKey}". ` +
|
|
351
|
-
`Check that a setVariable action with that refKey creates a variable with that name.`);
|
|
352
|
-
}
|
|
361
|
+
const id = resolveVariableId(idMap, marker.variableTaskRefKey, marker.name);
|
|
353
362
|
delete o.__variableParamRef;
|
|
354
363
|
o.variableReference = { id, name: `variable|${id}` };
|
|
355
364
|
return;
|
|
356
365
|
}
|
|
366
|
+
if (o.type === "VARIABLE" && typeof o.variableTaskRefKey === "string") {
|
|
367
|
+
o.variableId = resolveVariableId(idMap, o.variableTaskRefKey, String(o.name));
|
|
368
|
+
delete o.variableTaskRefKey;
|
|
369
|
+
return;
|
|
370
|
+
}
|
|
357
371
|
for (const v of Object.values(o))
|
|
358
372
|
resolveVariableParamMarkers(v, idMap);
|
|
359
373
|
}
|
|
@@ -1158,8 +1158,15 @@ function printRef(ref, state, refCtx) {
|
|
|
1158
1158
|
: state.foreignAppRefNames?.get(ref.foreign.name);
|
|
1159
1159
|
if (foreignRefName !== undefined)
|
|
1160
1160
|
return `catalog.${foreignRefName}.fields${safeMember(ref.fieldKey)}`;
|
|
1161
|
+
// `parentNamespace` (when the owner's own data block only carried a
|
|
1162
|
+
// namespace, no display name) lets build key its owner lookup on the
|
|
1163
|
+
// real namespace instead of the `parentName` guess — see from-tf.ts's
|
|
1164
|
+
// matching comment.
|
|
1165
|
+
const parentNamespace = ref.foreign.namespace !== undefined
|
|
1166
|
+
? `, parentNamespace: ${quote(ref.foreign.namespace)}`
|
|
1167
|
+
: "";
|
|
1161
1168
|
return (`{ __kind: "field", refName: ${quote(ref.fieldKey)}, name: ${quote(ref.foreign.fieldName ?? ref.fieldKey)}, fieldType: "TEXT", ` +
|
|
1162
|
-
`parent: ${quote(ref.appHandle)}, parentKind: ${quote(ref.foreign.entityType)}, parentName: ${quote(ref.foreign.name)} } ` +
|
|
1169
|
+
`parent: ${quote(ref.appHandle)}, parentKind: ${quote(ref.foreign.entityType)}, parentName: ${quote(ref.foreign.name)}${parentNamespace} } ` +
|
|
1163
1170
|
`/* TODO: foreign field — type unconfirmed (ei's elementum_field data source doesn't expose it) and refName is a best-effort guess; verify against "${ref.foreign.name}" */`);
|
|
1164
1171
|
}
|
|
1165
1172
|
case "userField":
|
|
@@ -1522,7 +1522,9 @@ function decodeValue(value, ctx) {
|
|
|
1522
1522
|
: value.label.startsWith(`${ownerLabel}_`)
|
|
1523
1523
|
? value.label.slice(ownerLabel.length + 1)
|
|
1524
1524
|
: value.label;
|
|
1525
|
-
const
|
|
1525
|
+
const ownerBlock = ctx.dataBlocks.get(`${objectId.type}.${objectId.label}`);
|
|
1526
|
+
const ownerName = ownerBlock?.attrs["name"];
|
|
1527
|
+
const ownerNamespace = ownerBlock?.attrs["namespace"];
|
|
1526
1528
|
const fieldName = fieldBlock?.attrs["name"];
|
|
1527
1529
|
return {
|
|
1528
1530
|
kind: "field",
|
|
@@ -1530,7 +1532,17 @@ function decodeValue(value, ctx) {
|
|
|
1530
1532
|
fieldKey: tfLabelToTsLabel(bareLabel),
|
|
1531
1533
|
foreign: {
|
|
1532
1534
|
entityType,
|
|
1535
|
+
// ei's owner data block can carry ONLY `namespace` (no `name`) —
|
|
1536
|
+
// confirmed live: `data.elementum_element.x { namespace = "..." }`
|
|
1537
|
+
// with no name attr at all. A tfLabel->tsLabel guess is a real
|
|
1538
|
+
// platform NAME only by luck; printing it as one, and then having
|
|
1539
|
+
// build key a `data.elementum_element` lookup on `name`, produces
|
|
1540
|
+
// a request the platform can never satisfy ("Element Not Found").
|
|
1541
|
+
// Carry the real namespace through instead, when that's all ei
|
|
1542
|
+
// gave us — `foreignRootLookup`/`resolveForeignRef` already prefer
|
|
1543
|
+
// `namespace` over `name` for exactly this reason.
|
|
1533
1544
|
name: typeof ownerName === "string" ? ownerName : tfLabelToTsLabel(ownerLabel),
|
|
1545
|
+
...(typeof ownerName !== "string" && typeof ownerNamespace === "string" ? { namespace: ownerNamespace } : {}),
|
|
1534
1546
|
...(typeof fieldName === "string" ? { fieldName } : {}),
|
|
1535
1547
|
},
|
|
1536
1548
|
};
|
|
@@ -10,8 +10,31 @@ export function taskTfLabel(automationLabel, refKey) {
|
|
|
10
10
|
//
|
|
11
11
|
// ALLCAPS / SCREAMING_SNAKE refKeys (`GREETING`) also round-trip the
|
|
12
12
|
// bijection (via ugly `_g_r_e_e_t_i_n_g`), but ei's SanitizeName yields
|
|
13
|
-
// `greeting
|
|
14
|
-
|
|
13
|
+
// `greeting`.
|
|
14
|
+
//
|
|
15
|
+
// A raw platform display-name stem printed verbatim as the refKey
|
|
16
|
+
// (`Add_Watcher`, `Some_Calculation` — confirmed live on demoapptwo) can
|
|
17
|
+
// ALSO round-trip the bijection by coincidence (it has both cases and no
|
|
18
|
+
// characters outside the tf-label alphabet), producing `add__watcher`
|
|
19
|
+
// (double underscore) against ei's own `add_watcher` — a permanent
|
|
20
|
+
// destroy+create. A "require a lowercase FIRST character" guard is NOT
|
|
21
|
+
// enough: `add_Watcher`/`some_Calculation` (lowercase-leading, but still
|
|
22
|
+
// an underscore-joined raw stem) pass that check too and still round-trip
|
|
23
|
+
// the bijection to the same wrong `add__watcher` shape (review catch on
|
|
24
|
+
// #1060 — `taskTfLabel("auto", "add_Watcher")` still produced
|
|
25
|
+
// `auto_add__watcher`).
|
|
26
|
+
//
|
|
27
|
+
// The real distinguishing shape: EDK's own generated camelCase refKeys
|
|
28
|
+
// (`commodityBHit`, optionally with a trailing `_<digits>` disambiguator
|
|
29
|
+
// like `commodityBHit_1`) NEVER contain a literal `_` immediately
|
|
30
|
+
// followed by a letter — every word boundary is a bare capital, and the
|
|
31
|
+
// only underscore EDK ever inserts is that numeric suffix. A raw
|
|
32
|
+
// display-name stem that uses `_` as its OWN word separator always has
|
|
33
|
+
// `_` followed by a letter (the next word's first character). Match that
|
|
34
|
+
// shape directly instead of trying to carve exceptions out of a looser
|
|
35
|
+
// check.
|
|
36
|
+
const GENERATED_CAMEL_CASE_RE = /^[a-z][A-Za-z0-9]*(_\d+)?$/;
|
|
37
|
+
const normalized = GENERATED_CAMEL_CASE_RE.test(refKey) && isCanonicalTsLabel(refKey)
|
|
15
38
|
? tsLabelToTfLabel(refKey)
|
|
16
39
|
: sanitizeName(refKey);
|
|
17
40
|
return normalized.startsWith(`${automationLabel}_`) ? normalized : `${automationLabel}_${normalized}`;
|
|
@@ -1098,8 +1098,12 @@ const TS_TRIGGER_REF_TO_WIRE = {
|
|
|
1098
1098
|
// onto FIELD_REF_SUFFIX_TO_WIRE — that table's `id` suffix is " ID", which
|
|
1099
1099
|
// would emit the wrong wire key "Attachment ID" and fail live validation.
|
|
1100
1100
|
"attachment.id": "Attachment Id",
|
|
1101
|
-
createdByEmail:
|
|
1102
|
-
|
|
1101
|
+
// NOT createdByEmail/updatedByManagerEmail: the real record-field path
|
|
1102
|
+
// ("record.createdBy.email") never reaches this flat lookup table (see
|
|
1103
|
+
// from-tf.ts's matching comment) — this table is for genuine trigger-level
|
|
1104
|
+
// pseudo-fields only, keyed by the DIRECT ts accessor name, not a dotted
|
|
1105
|
+
// record path. The audit-email casing exception lives in
|
|
1106
|
+
// AUDIT_FIELD_EMAIL_WIRE_NAME, next to the code that actually builds it.
|
|
1103
1107
|
slackThreadId: "Slack Thread ID",
|
|
1104
1108
|
slackChannelId: "Slack Channel ID",
|
|
1105
1109
|
messageAuthorEmail: "Message Author Email",
|
|
@@ -1136,6 +1140,13 @@ const FIELD_REF_SUFFIX_TO_WIRE = {
|
|
|
1136
1140
|
"employee.manager.email": " Manager Email",
|
|
1137
1141
|
"employee.manager.name": " Manager Name",
|
|
1138
1142
|
};
|
|
1143
|
+
// Confirmed live on demoapptwo: the "...Email"/"...Manager Email" audit refs
|
|
1144
|
+
// lowercase "by", unlike every other audit-field ref suffix. Only these two
|
|
1145
|
+
// keys/suffixes are overridden; closedBy is not confirmed and is left alone.
|
|
1146
|
+
const AUDIT_FIELD_EMAIL_WIRE_NAME = {
|
|
1147
|
+
createdBy: "Created by",
|
|
1148
|
+
updatedBy: "Updated by",
|
|
1149
|
+
};
|
|
1139
1150
|
const PROVIDER_FIXED_SYSTEM_FIELD_KEYS = new Set([
|
|
1140
1151
|
"stage",
|
|
1141
1152
|
"createdAt",
|
|
@@ -1194,8 +1205,15 @@ function wireRefName(name, ctx) {
|
|
|
1194
1205
|
// Build must reproduce the live refs[] key's exact casing because the
|
|
1195
1206
|
// Terraform map lookup is case-sensitive. The current provider emits
|
|
1196
1207
|
// compound audit refs with the system field's display casing intact
|
|
1197
|
-
// (for example "Created By ID")
|
|
1198
|
-
|
|
1208
|
+
// (for example "Created By ID") — EXCEPT the "...Email"/"...Manager
|
|
1209
|
+
// Email" audit refs, which lowercase "by" (confirmed live on
|
|
1210
|
+
// demoapptwo: "Created by Email", "Updated by Manager Email"). Only
|
|
1211
|
+
// override those two confirmed suffixes; every other suffix (and every
|
|
1212
|
+
// other system field) keeps the field's own display casing.
|
|
1213
|
+
const auditEmailName = systemFieldKey !== undefined && (wireSuffix === " Email" || wireSuffix === " Manager Email")
|
|
1214
|
+
? AUDIT_FIELD_EMAIL_WIRE_NAME[systemFieldKey]
|
|
1215
|
+
: undefined;
|
|
1216
|
+
return `${auditEmailName ?? fieldName}${wireSuffix}`;
|
|
1199
1217
|
}
|
|
1200
1218
|
// A webhook trigger's body/headers refs (ctx.trigger.body["X"]) can only
|
|
1201
1219
|
// type-check against DeepRefs<WebhookTriggerOutput>, so parts[0] being
|
|
@@ -1467,6 +1485,44 @@ function workflowPublishOutputValueToTf(value, refs) {
|
|
|
1467
1485
|
}
|
|
1468
1486
|
return valueToTf(value, refs);
|
|
1469
1487
|
}
|
|
1488
|
+
/**
|
|
1489
|
+
* A `createRecord` task's own output record's field, embedded as a LIVE
|
|
1490
|
+
* field resource `.id` reference instead of a resolved display name.
|
|
1491
|
+
* Confirmed live (demoapptwo, #1066): the platform stores this specific
|
|
1492
|
+
* reference shape as `"record.<field-platform-id>.<suffix>"` — the SAME raw
|
|
1493
|
+
* form the unresolved-field escape hatch above already reproduces for a
|
|
1494
|
+
* field EDK can't resolve AT ALL — even though this field genuinely
|
|
1495
|
+
* resolves. Unlike a TRIGGER's record (`wireRefName`, fixed for the
|
|
1496
|
+
* audit-email casing in #1062), the platform never re-derives a
|
|
1497
|
+
* display-name form for a task's own JUST-CREATED record; a fresh `ei`
|
|
1498
|
+
* export of this exact automation still has the raw id form, so building
|
|
1499
|
+
* the resolved-name string here is not one-time drift, it is simply wrong.
|
|
1500
|
+
*
|
|
1501
|
+
* `expr.template` gives the field's CURRENT id at plan/apply time (same
|
|
1502
|
+
* pattern as `taskId`/`variableReference.name` just below), so this stays
|
|
1503
|
+
* correct even across a field id change, unlike a literal string would.
|
|
1504
|
+
*
|
|
1505
|
+
* Scoped to createRecord and to the SAME app as the automation owner — the
|
|
1506
|
+
* only case confirmed live. A cross-app createRecord output, or a
|
|
1507
|
+
* recordSearch/findRelatedRecords field access on an EXISTING (not
|
|
1508
|
+
* just-created) record, is left on the existing display-name path until
|
|
1509
|
+
* confirmed either way; returning `undefined` here falls through to it.
|
|
1510
|
+
*/
|
|
1511
|
+
function createRecordOwnFieldRefTfValue(target, name, refs) {
|
|
1512
|
+
if (target?.type !== "elementum_create_record_task")
|
|
1513
|
+
return undefined;
|
|
1514
|
+
const match = /^record\.([^.]+)\.(.+)$/.exec(name);
|
|
1515
|
+
if (match === null)
|
|
1516
|
+
return undefined;
|
|
1517
|
+
const [, fieldKey, suffix] = match;
|
|
1518
|
+
const fieldType = refs.owner.fieldMetadata.get(fieldKey)?.fieldType;
|
|
1519
|
+
if (fieldType === undefined)
|
|
1520
|
+
return undefined;
|
|
1521
|
+
const fieldId = fieldRefToTfValue(fieldType, fieldKey, refs.owner.appTfLabel, refs.owner.parentScope, refs.owner.fieldAddresses);
|
|
1522
|
+
if (fieldId === undefined)
|
|
1523
|
+
return undefined;
|
|
1524
|
+
return expr.template(["record.", fieldId, `.${suffix}`]);
|
|
1525
|
+
}
|
|
1470
1526
|
function workflowPublishOutputEnvelope(value, refs) {
|
|
1471
1527
|
if (!isObject(value))
|
|
1472
1528
|
return undefined;
|
|
@@ -1492,9 +1548,10 @@ function workflowPublishOutputEnvelope(value, refs) {
|
|
|
1492
1548
|
? "All matching table rows"
|
|
1493
1549
|
: "records"
|
|
1494
1550
|
: taskWireRefName(value.taskReference.name, value.taskReference.taskRefKey, refs);
|
|
1495
|
-
const
|
|
1551
|
+
const ownRecordFieldRef = createRecordOwnFieldRefTfValue(target, value.taskReference.name, refs);
|
|
1552
|
+
const platformRefName = ownRecordFieldRef ?? (isAiAgentTask
|
|
1496
1553
|
? aiAgentPlatformRefName(refsKey)
|
|
1497
|
-
: refsKey;
|
|
1554
|
+
: refsKey);
|
|
1498
1555
|
const typed = publishOutputType(value, target, refsKey);
|
|
1499
1556
|
return {
|
|
1500
1557
|
fieldType: typed.fieldType,
|
|
@@ -1833,6 +1890,24 @@ function filterReferenceToTf(value, refs, role = "value", realType, operator) {
|
|
|
1833
1890
|
}
|
|
1834
1891
|
case "VALUE":
|
|
1835
1892
|
return valueToTf(value.value, refs);
|
|
1893
|
+
case "VARIABLE": {
|
|
1894
|
+
// Build finalize (resolveVariableParamMarkers) resolves the authored
|
|
1895
|
+
// variableTaskRefKey to this build's minted `variable.create` id, which
|
|
1896
|
+
// keys `variableById` → the owning `elementum_variable_task`. ei encodes a
|
|
1897
|
+
// variable filter value as `variable.<uuid>` (live-captured, #1045) in both
|
|
1898
|
+
// the value (recordSearch RHS) and left_value (switch) slots.
|
|
1899
|
+
//
|
|
1900
|
+
// INTERPOLATE the live `variable_id`, never bake in the minted id: the
|
|
1901
|
+
// client-minted uuid is never the variable's deploy-time platform id, so a
|
|
1902
|
+
// literal always mismatches live state on the very next plan (identical
|
|
1903
|
+
// reasoning to the ordinary variableReference path above). The template
|
|
1904
|
+
// resolves to `variable.<live variable_id>`, byte-identical to ei's export.
|
|
1905
|
+
const target = typeof value.variableId === "string" ? refs.variableById.get(value.variableId) : undefined;
|
|
1906
|
+
if (target === undefined) {
|
|
1907
|
+
throw new EntityTfError("variable filter reference could not be resolved to a variable task — the referenced workflow variable must be created by a setVariable task in the same automation");
|
|
1908
|
+
}
|
|
1909
|
+
return expr.template(["variable.", expr.resourceAttr(target.type, target.label, ["variable_id"])]);
|
|
1910
|
+
}
|
|
1836
1911
|
default:
|
|
1837
1912
|
throw new EntityTfError(`unsupported filter reference type "${value.type}"`);
|
|
1838
1913
|
}
|
|
@@ -94,7 +94,14 @@ export function refDataToFilterReference(data) {
|
|
|
94
94
|
case "forEach": return { type: "FOR_EACH", forEachTaskRefKey: data.forEachActionName, name: data.name };
|
|
95
95
|
case "static": return { type: "VALUE", value: data.value };
|
|
96
96
|
case "template": return { type: "VALUE", value: serializeRefData(data) };
|
|
97
|
-
|
|
97
|
+
// A workflow variable used as a filter value (recordSearch/switch/…). ei
|
|
98
|
+
// encodes this as `variable.<uuid>` (#1045). Carry the setVariable action's
|
|
99
|
+
// refKey as a marker; automation build finalize resolves it to the variable's
|
|
100
|
+
// minted id (`variableId`), which to-tf emits as `variable.<uuid>`.
|
|
101
|
+
case "variableParam": return { type: "VARIABLE", name: data.name, variableTaskRefKey: data.variableActionRefKey };
|
|
102
|
+
// A vault secret has no filter reference kind in the platform filter model
|
|
103
|
+
// (jarvis ReferenceType = VALUE/TASK/TRIGGER/FOR_EACH/VARIABLE), so it can
|
|
104
|
+
// never be a filter comparison value — reject it at authoring.
|
|
98
105
|
case "secret": throw new EdkValidationError("Secret refs cannot be used directly in filter values");
|
|
99
106
|
}
|
|
100
107
|
}
|
package/package.json
CHANGED