@elementumai/edk 0.9.6 → 0.9.7
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/README.md +31 -1
- package/dist-sdk/src/catalog/factories.d.ts +12 -3
- package/dist-sdk/src/catalog/factories.js +9 -6
- package/dist-sdk/src/catalog/org.js +26 -13
- package/dist-sdk/src/catalog/types.d.ts +22 -1
- package/dist-sdk/src/core/index.d.ts +1 -1
- package/dist-sdk/src/core/system-fields.d.ts +4 -0
- package/dist-sdk/src/core/system-fields.js +15 -0
- package/dist-sdk/src/core/types/app.d.ts +14 -9
- package/dist-sdk/src/core/types/platform.d.ts +1 -1
- package/dist-sdk/src/engine/build/context.d.ts +4 -0
- package/dist-sdk/src/engine/pull/context.d.ts +9 -0
- package/dist-sdk/src/engine/pull/ref-only.d.ts +14 -0
- package/dist-sdk/src/engine/pull/ref-only.js +35 -2
- package/dist-sdk/src/entities/access-policy/from-tf.js +14 -2
- package/dist-sdk/src/entities/access-policy/to-tf.d.ts +6 -0
- package/dist-sdk/src/entities/access-policy/to-tf.js +4 -1
- package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +18 -1
- package/dist-sdk/src/entities/agent/module.js +1 -0
- package/dist-sdk/src/entities/agent/to-tf.d.ts +1 -0
- package/dist-sdk/src/entities/agent/to-tf.js +1 -0
- package/dist-sdk/src/entities/agent-tool/from-tf.d.ts +9 -0
- package/dist-sdk/src/entities/agent-tool/from-tf.js +10 -2
- package/dist-sdk/src/entities/agent-tool/to-tf.d.ts +2 -0
- package/dist-sdk/src/entities/agent-tool/to-tf.js +2 -3
- package/dist-sdk/src/entities/app/build.d.ts +42 -22
- package/dist-sdk/src/entities/app/build.js +12 -5
- package/dist-sdk/src/entities/app/deserializer/normalize.d.ts +10 -0
- package/dist-sdk/src/entities/app/from-tf.js +71 -8
- package/dist-sdk/src/entities/app/index.d.ts +3 -2
- package/dist-sdk/src/entities/app/index.js +2 -1
- package/dist-sdk/src/entities/app/to-tf.js +16 -0
- package/dist-sdk/src/entities/automation/build.d.ts +31 -19
- package/dist-sdk/src/entities/automation/build.js +85 -7
- package/dist-sdk/src/entities/automation/catalog-render.js +5 -2
- package/dist-sdk/src/entities/automation/deserializer/ast.d.ts +5 -3
- package/dist-sdk/src/entities/automation/deserializer/print-automation.js +26 -12
- package/dist-sdk/src/entities/automation/from-tf.js +364 -31
- package/dist-sdk/src/entities/automation/index.d.ts +1 -1
- package/dist-sdk/src/entities/automation/module.js +2 -2
- package/dist-sdk/src/entities/automation/operators.d.ts +2 -2
- package/dist-sdk/src/entities/automation/operators.js +1 -0
- package/dist-sdk/src/entities/automation/output-field-types.d.ts +17 -0
- package/dist-sdk/src/entities/automation/output-field-types.js +45 -0
- package/dist-sdk/src/entities/automation/output-key-wire-name.d.ts +8 -0
- package/dist-sdk/src/entities/automation/output-key-wire-name.js +16 -0
- package/dist-sdk/src/entities/automation/script-code.js +153 -25
- package/dist-sdk/src/entities/automation/tasks.d.ts +100 -37
- package/dist-sdk/src/entities/automation/tasks.js +44 -43
- package/dist-sdk/src/entities/automation/to-tf.d.ts +3 -1
- package/dist-sdk/src/entities/automation/to-tf.js +454 -58
- package/dist-sdk/src/entities/automation/value-ref-tf.d.ts +78 -0
- package/dist-sdk/src/entities/automation/value-ref-tf.js +193 -0
- package/dist-sdk/src/entities/element/build.js +1 -0
- package/dist-sdk/src/entities/element/index.d.ts +2 -1
- package/dist-sdk/src/entities/element/index.js +2 -1
- package/dist-sdk/src/entities/field/build.d.ts +94 -3
- package/dist-sdk/src/entities/field/build.js +82 -3
- package/dist-sdk/src/entities/field/from-tf.js +92 -1
- package/dist-sdk/src/entities/field/locals.js +6 -7
- package/dist-sdk/src/entities/field/options.d.ts +2 -0
- package/dist-sdk/src/entities/field/options.js +12 -2
- package/dist-sdk/src/entities/field/record-shape.d.ts +12 -15
- package/dist-sdk/src/entities/field/to-tf.d.ts +12 -2
- package/dist-sdk/src/entities/field/to-tf.js +172 -51
- package/dist-sdk/src/entities/field/types.js +2 -0
- package/dist-sdk/src/entities/record-create-form/to-tf.js +5 -8
- package/dist-sdk/src/entities/relationship/from-tf.js +91 -9
- package/dist-sdk/src/entities/shared/aspect-target-from-tf.d.ts +9 -0
- package/dist-sdk/src/entities/shared/aspect-target-from-tf.js +39 -0
- package/dist-sdk/src/entities/shared/filters/ast.d.ts +18 -1
- package/dist-sdk/src/entities/shared/filters/ast.js +1 -0
- package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +6 -1
- package/dist-sdk/src/entities/shared/filters/tf-codec.js +6 -4
- package/dist-sdk/src/entities/shared/tool-field-ref.d.ts +5 -3
- package/dist-sdk/src/entities/shared/tool-field-ref.js +11 -16
- package/dist-sdk/src/entities/shared/types/common.d.ts +7 -5
- package/dist-sdk/src/entities/shared/types/platform.d.ts +15 -2
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.d.ts +1 -1
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +44 -15
- package/dist-sdk/src/entities/skill/from-tf.js +11 -1
- package/dist-sdk/src/entities/skill/input-coverage.d.ts +68 -0
- package/dist-sdk/src/entities/skill/input-coverage.js +184 -0
- package/dist-sdk/src/entities/skill/module.js +2 -0
- package/dist-sdk/src/entities/skill/to-tf.d.ts +3 -0
- package/dist-sdk/src/entities/skill/to-tf.js +7 -2
- package/dist-sdk/src/entities/skill/tools.d.ts +10 -1
- package/dist-sdk/src/entities/skill/tools.js +0 -5
- package/dist-sdk/src/entities/skill-tool/from-tf.d.ts +19 -0
- package/dist-sdk/src/entities/skill-tool/from-tf.js +40 -11
- package/dist-sdk/src/entities/skill-tool/to-tf.d.ts +4 -2
- package/dist-sdk/src/entities/skill-tool/to-tf.js +24 -16
- package/dist-sdk/src/entities/table/to-tf.js +18 -1
- package/dist-sdk/src/entities/view/to-tf.js +8 -3
- package/dist-sdk/src/entities/visual-flow/from-tf.js +6 -2
- package/dist-sdk/src/graph/types.d.ts +3 -0
- package/package.json +2 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { USER_FIELD_KEYS } from "../../catalog/types.js";
|
|
2
2
|
import { DEPLOY_DEFAULT_SYSTEM_FIELD_NAMES, SYSTEM_FIELD_KEYS } from "../../core/system-fields.js";
|
|
3
3
|
import { EntityTfError } from "../../engine/entity.js";
|
|
4
|
-
import {
|
|
4
|
+
import { childPartFromScopedLabel, isTfExpr, sanitizeName, scopedLabelToBagKey, tfLabelToTsLabel, } from "../../engine/tf/index.js";
|
|
5
5
|
import { IMPLEMENTED_FILE_READER_RESOURCE_TYPES } from "../file-reader/types.js";
|
|
6
6
|
import { connectorIdentityFromTf } from "../shared/connector-from-tf.js";
|
|
7
7
|
import { UNRESOLVED_FIELD_MARKER } from "../shared/ref.js";
|
|
@@ -88,8 +88,6 @@ const ATTR_TO_ARG = {
|
|
|
88
88
|
category_source: "categorySource",
|
|
89
89
|
user_ids: "userIds",
|
|
90
90
|
group_ids: "groupIds",
|
|
91
|
-
user_value_references: "userRefs",
|
|
92
|
-
group_value_references: "groupRefs",
|
|
93
91
|
notify_watchers: "notifyWatchers",
|
|
94
92
|
fields_to_lock: "fieldsToLock",
|
|
95
93
|
fields_to_unlock: "fieldsToUnlock",
|
|
@@ -142,6 +140,62 @@ function references(value, type, label) {
|
|
|
142
140
|
const ref = resourceRef(value);
|
|
143
141
|
return ref?.type === type && ref.label === label;
|
|
144
142
|
}
|
|
143
|
+
/**
|
|
144
|
+
* Order switch_case / fork_join_branch blocks by their previous_*_id chain.
|
|
145
|
+
* Falls back to depends_on index / label only when the chain is incomplete.
|
|
146
|
+
* Alphabetical label order inverts real evaluation order whenever a later
|
|
147
|
+
* case's display name sorts before the first (Sanofi: "…Invalid" before
|
|
148
|
+
* "…Valid"), which rebuilds previous_case_id edges backwards and plans
|
|
149
|
+
* in-place updates on every case.
|
|
150
|
+
*/
|
|
151
|
+
function orderBranchesByPreviousLink(matching, previousAttr, dependencyOrder) {
|
|
152
|
+
if (matching.length <= 1)
|
|
153
|
+
return matching;
|
|
154
|
+
const byAddress = new Map(matching.map((branch) => [`${branch.type}.${branch.label}`, branch]));
|
|
155
|
+
const successor = new Map();
|
|
156
|
+
const roots = [];
|
|
157
|
+
for (const branch of matching) {
|
|
158
|
+
const prev = resourceRef(branch.attrs[previousAttr]);
|
|
159
|
+
if (prev === undefined) {
|
|
160
|
+
roots.push(branch);
|
|
161
|
+
continue;
|
|
162
|
+
}
|
|
163
|
+
const prevAddress = `${prev.type}.${prev.label}`;
|
|
164
|
+
if (!byAddress.has(prevAddress)) {
|
|
165
|
+
roots.push(branch);
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
if (successor.has(prevAddress)) {
|
|
169
|
+
// Ambiguous chain — fall back to legacy sort for the whole set.
|
|
170
|
+
return [...matching].sort((a, b) => (dependencyOrder.get(`${a.type}.${a.label}`) ?? Number.MAX_SAFE_INTEGER)
|
|
171
|
+
- (dependencyOrder.get(`${b.type}.${b.label}`) ?? Number.MAX_SAFE_INTEGER)
|
|
172
|
+
|| a.label.localeCompare(b.label));
|
|
173
|
+
}
|
|
174
|
+
successor.set(prevAddress, branch);
|
|
175
|
+
}
|
|
176
|
+
if (roots.length !== 1) {
|
|
177
|
+
return [...matching].sort((a, b) => (dependencyOrder.get(`${a.type}.${a.label}`) ?? Number.MAX_SAFE_INTEGER)
|
|
178
|
+
- (dependencyOrder.get(`${b.type}.${b.label}`) ?? Number.MAX_SAFE_INTEGER)
|
|
179
|
+
|| a.label.localeCompare(b.label));
|
|
180
|
+
}
|
|
181
|
+
const ordered = [];
|
|
182
|
+
let cursor = roots[0];
|
|
183
|
+
const seen = new Set();
|
|
184
|
+
while (cursor !== undefined) {
|
|
185
|
+
const address = `${cursor.type}.${cursor.label}`;
|
|
186
|
+
if (seen.has(address))
|
|
187
|
+
break;
|
|
188
|
+
seen.add(address);
|
|
189
|
+
ordered.push(cursor);
|
|
190
|
+
cursor = successor.get(address);
|
|
191
|
+
}
|
|
192
|
+
if (ordered.length !== matching.length) {
|
|
193
|
+
return [...matching].sort((a, b) => (dependencyOrder.get(`${a.type}.${a.label}`) ?? Number.MAX_SAFE_INTEGER)
|
|
194
|
+
- (dependencyOrder.get(`${b.type}.${b.label}`) ?? Number.MAX_SAFE_INTEGER)
|
|
195
|
+
|| a.label.localeCompare(b.label));
|
|
196
|
+
}
|
|
197
|
+
return ordered;
|
|
198
|
+
}
|
|
145
199
|
function assertAllowed(block, allowed) {
|
|
146
200
|
for (const key of Object.keys(block.attrs)) {
|
|
147
201
|
if (!allowed.has(key))
|
|
@@ -158,13 +212,13 @@ const TASK_ATTRIBUTES = new Set([
|
|
|
158
212
|
"parent", "name", "depends_on", "filter", "fields", "inputs", "output_schema",
|
|
159
213
|
"list", "code", "variable_name", "variable_type", "variable", "value",
|
|
160
214
|
"object_id", "table_id", "record_reference", "record_id", "source_record_ids",
|
|
215
|
+
"approval_process_id", "requester_reference", "approver_references", "reason", "summary",
|
|
161
216
|
"target_record_id", "message", "message_body", "body", "from_username",
|
|
162
217
|
"from_personal", "external_emails", "users", "groups", "attachments", "contents",
|
|
163
218
|
"agent_id", "prompt", "output_type", "json_fields", "ai_provider_connector_id",
|
|
164
219
|
"url", "response_type", "continue_on_error", "search_table_id",
|
|
165
220
|
"text_to_summarize", "text_to_classify", "field_type", "category_source",
|
|
166
|
-
"title", "user_ids", "group_ids", "
|
|
167
|
-
"group_value_references", "notify_watchers", "field_id", "user_id", "group_id",
|
|
221
|
+
"title", "user_ids", "group_ids", "notify_watchers", "field_id", "user_id", "group_id",
|
|
168
222
|
"fields_to_lock", "fields_to_unlock", "file", "file_id", "attachment", "attachment_id", "view_state", "target_automation_id",
|
|
169
223
|
"target_automation_ref", "input_mappings", "dynamic_input_mappings",
|
|
170
224
|
"output_mappings", "file_reader_id", "raw_text", "procedure_id",
|
|
@@ -190,7 +244,7 @@ function appRef(appRefName) {
|
|
|
190
244
|
// be added here. A hardcoded flat entry here short-circuits triggerRefPath's
|
|
191
245
|
// field-name+suffix matching below (pathNames runs first), producing an
|
|
192
246
|
// invalid, un-typed property name instead of the real ["record", field.key,
|
|
193
|
-
// "email"] path - confirmed live: "Created
|
|
247
|
+
// "email"] path - confirmed live: "Created By Email"/"Updated By Manager
|
|
194
248
|
// Email" were hardcoded this way and printed as ctx.trigger.createdByEmail /
|
|
195
249
|
// ctx.trigger.updatedByManagerEmail, neither of which exists on the typed
|
|
196
250
|
// ctx, so every pulled automation using them failed `tsc --noEmit`.
|
|
@@ -211,6 +265,9 @@ const FIELD_REF_SUFFIX_FROM_WIRE = [
|
|
|
211
265
|
[" Manager Name", ["employee", "manager", "name"]],
|
|
212
266
|
[" Manager", ["employee", "manager"]],
|
|
213
267
|
[" Field ID", ["fieldId"]],
|
|
268
|
+
// Dynamically sourced Dropdown selected source record. Confirmed
|
|
269
|
+
// live as "<Field> - Record" with type ASPECT_RECORD_ID.
|
|
270
|
+
[" - Record", ["recordId"]],
|
|
214
271
|
// Deliberately the literal suffix text, not a camelCase "asText" segment:
|
|
215
272
|
// Ref<T> has no ".asText" projection anywhere in the type system (checked
|
|
216
273
|
// shared/ref.ts - it's a sealed brand, nothing else), so claiming one as a
|
|
@@ -239,9 +296,8 @@ function pathNames(path) {
|
|
|
239
296
|
* convention.
|
|
240
297
|
*/
|
|
241
298
|
function recordFieldRefPath(wireName, ctx) {
|
|
242
|
-
// Case-insensitive
|
|
243
|
-
//
|
|
244
|
-
// Email").
|
|
299
|
+
// Case-insensitive so exports remain readable across historical platform
|
|
300
|
+
// casing while authored HCL targets the current exact live ref keys.
|
|
245
301
|
const wireNameLower = wireName.toLowerCase();
|
|
246
302
|
for (const field of ctx.fieldById.values()) {
|
|
247
303
|
for (const [suffix, suffixPath] of FIELD_REF_SUFFIX_FROM_WIRE) {
|
|
@@ -299,6 +355,14 @@ const RECORD_SEARCH_TASK_REF_SEGMENT_TO_TS = {
|
|
|
299
355
|
const AI_SEARCH_TABLE_TASK_REF_SEGMENT_TO_TS = {
|
|
300
356
|
"All Records": "records",
|
|
301
357
|
};
|
|
358
|
+
// tableRecordsSearch collection output — platform wire key
|
|
359
|
+
// "All matching table rows" (not recordSearch's "All found records" or
|
|
360
|
+
// aiSearchTable's "All Records"). Leaving it unmapped prints
|
|
361
|
+
// `(ctx.actions.x as any)["All matching table rows"]`, which drops the Ref
|
|
362
|
+
// proxy at build time and omits the script/filter input entirely.
|
|
363
|
+
const TABLE_RECORDS_SEARCH_TASK_REF_SEGMENT_TO_TS = {
|
|
364
|
+
"All matching table rows": "records",
|
|
365
|
+
};
|
|
302
366
|
/**
|
|
303
367
|
* A webhook trigger's `body`/`headers` refs come back as "Body (Plain
|
|
304
368
|
* Text)"/"Headers (Content-Type)" - one wire segment naming both the
|
|
@@ -360,6 +424,16 @@ function taskRecordSearchFieldPath(taskAddress, wireName, ctx) {
|
|
|
360
424
|
return undefined;
|
|
361
425
|
}
|
|
362
426
|
function decodeFieldAssignmentValue(value, ctx) {
|
|
427
|
+
// Multi-Select assignments are exported as jsonencode([<option UUID>, ...])
|
|
428
|
+
// rather than the options-by-label locals used for a scalar Dropdown. Walk
|
|
429
|
+
// that payload with the state-derived option registry so pulled source stays
|
|
430
|
+
// portable across organizations and fresh creates.
|
|
431
|
+
if (isTfExpr(value) && value.$expr === "jsonencode") {
|
|
432
|
+
return decodeFieldAssignmentValue(value.value, ctx);
|
|
433
|
+
}
|
|
434
|
+
if (Array.isArray(value)) {
|
|
435
|
+
return value.map((item) => decodeFieldAssignmentValue(item, ctx));
|
|
436
|
+
}
|
|
363
437
|
if (typeof value === "string" && /^[a-f0-9-]{36}$/i.test(value)) {
|
|
364
438
|
const label = ctx.picklistOptionLabelById?.get(value);
|
|
365
439
|
if (label !== undefined)
|
|
@@ -436,6 +510,11 @@ function forEachItemRefPath(path, ctx) {
|
|
|
436
510
|
return ["recordId"];
|
|
437
511
|
const wireNameLower = wireName.toLowerCase();
|
|
438
512
|
for (const field of ctx.fieldById.values()) {
|
|
513
|
+
// Some provider paths already contain the stable EDK field key (for
|
|
514
|
+
// example `for_each.<task-id>.productId`), while inner.refs uses the
|
|
515
|
+
// display name in other workflow shapes. Accept both forms.
|
|
516
|
+
if (wireName === field.key)
|
|
517
|
+
return [field.key];
|
|
439
518
|
for (const [suffix, suffixPath] of FIELD_REF_SUFFIX_FROM_WIRE) {
|
|
440
519
|
if (wireNameLower === `${field.name}${suffix}`.toLowerCase()) {
|
|
441
520
|
return [field.key, ...suffixPath];
|
|
@@ -466,6 +545,18 @@ function resolveTaskRefKey(taskIdOrKey, ctx) {
|
|
|
466
545
|
}
|
|
467
546
|
return { refKey: taskIdOrKey };
|
|
468
547
|
}
|
|
548
|
+
function resolveFieldKeyFromId(fieldId, ownerRefName, ctx) {
|
|
549
|
+
const local = ctx.fieldById.get(fieldId);
|
|
550
|
+
if (local !== undefined) {
|
|
551
|
+
if (ownerRefName === undefined || ownerRefName === ctx.appRefName)
|
|
552
|
+
return local.key;
|
|
553
|
+
}
|
|
554
|
+
const state = ctx.foreignFieldRefsById?.get(fieldId);
|
|
555
|
+
if (state === undefined)
|
|
556
|
+
return undefined;
|
|
557
|
+
const expectedOwner = ownerRefName ?? ctx.appRefName;
|
|
558
|
+
return state.ownerRefName === expectedOwner ? state.fieldKey : undefined;
|
|
559
|
+
}
|
|
469
560
|
function decodeTaskReferenceFromString(taskIdOrKey, pathSegments, ctx) {
|
|
470
561
|
const { refKey, block } = resolveTaskRefKey(taskIdOrKey, ctx);
|
|
471
562
|
if (block?.type === "elementum_record_search_task" && pathSegments.length >= 1) {
|
|
@@ -478,6 +569,22 @@ function decodeTaskReferenceFromString(taskIdOrKey, pathSegments, ctx) {
|
|
|
478
569
|
return { kind: "taskRef", task: refKey, path: [recordSearchName, ...tail] };
|
|
479
570
|
}
|
|
480
571
|
const taskAddress = block.label !== undefined ? `${block.type}.${block.label}` : undefined;
|
|
572
|
+
// Live filters often address a found-record field as
|
|
573
|
+
// `record.<field-uuid>[.suffix]` (Sanofi: Status Label → record.<status-id>.label).
|
|
574
|
+
// System fields have no `*_field` import; resolve the UUID through state the
|
|
575
|
+
// same way trigger `record.<uuid>` already does (#432).
|
|
576
|
+
if (taskAddress !== undefined &&
|
|
577
|
+
head === "record" &&
|
|
578
|
+
tail.length >= 1 &&
|
|
579
|
+
/^[a-f0-9-]{36}$/i.test(tail[0])) {
|
|
580
|
+
const ownerRefName = ctx.taskTargetOwnerRefNameByAddress?.get(taskAddress) ?? ctx.appRefName;
|
|
581
|
+
const fieldKey = resolveFieldKeyFromId(tail[0], ownerRefName, ctx);
|
|
582
|
+
return {
|
|
583
|
+
kind: "taskRef",
|
|
584
|
+
task: refKey,
|
|
585
|
+
path: ["record", fieldKey ?? tail[0], ...tail.slice(1)],
|
|
586
|
+
};
|
|
587
|
+
}
|
|
481
588
|
if (taskAddress !== undefined) {
|
|
482
589
|
const recordFieldPath = taskRecordSearchFieldPath(taskAddress, head, ctx);
|
|
483
590
|
if (recordFieldPath !== undefined) {
|
|
@@ -492,6 +599,43 @@ function decodeTaskReferenceFromString(taskIdOrKey, pathSegments, ctx) {
|
|
|
492
599
|
return { kind: "taskRef", task: refKey, path: [aiSearchName, ...tail] };
|
|
493
600
|
}
|
|
494
601
|
}
|
|
602
|
+
if (block?.type === "elementum_table_records_search_task" && pathSegments.length >= 1) {
|
|
603
|
+
const [head, ...tail] = pathSegments;
|
|
604
|
+
const tableSearchName = TABLE_RECORDS_SEARCH_TASK_REF_SEGMENT_TO_TS[head];
|
|
605
|
+
if (tableSearchName !== undefined) {
|
|
606
|
+
return { kind: "taskRef", task: refKey, path: [tableSearchName, ...tail] };
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
// createRecord/findRelatedRecords record-id + field outputs (same as the
|
|
610
|
+
// refs["Title"] / refs["Record"] resource-attr path in decodeValue).
|
|
611
|
+
if ((block?.type === "elementum_create_record_task" || block?.type === "elementum_find_related_records_task") &&
|
|
612
|
+
pathSegments.length >= 1) {
|
|
613
|
+
const [head, ...tail] = pathSegments;
|
|
614
|
+
if (pathSegments.length === 1 && (head === "Record" || head === "Record ID")) {
|
|
615
|
+
return { kind: "taskRef", task: refKey, path: ["record", "recordId"] };
|
|
616
|
+
}
|
|
617
|
+
if (block.type === "elementum_create_record_task" &&
|
|
618
|
+
head === "record" &&
|
|
619
|
+
tail.length >= 1 &&
|
|
620
|
+
/^[a-f0-9-]{36}$/i.test(tail[0])) {
|
|
621
|
+
const taskAddress = block.label !== undefined ? `${block.type}.${block.label}` : undefined;
|
|
622
|
+
const ownerRefName = taskAddress !== undefined
|
|
623
|
+
? ctx.taskTargetOwnerRefNameByAddress?.get(taskAddress) ?? ctx.appRefName
|
|
624
|
+
: ctx.appRefName;
|
|
625
|
+
const fieldKey = resolveFieldKeyFromId(tail[0], ownerRefName, ctx);
|
|
626
|
+
return {
|
|
627
|
+
kind: "taskRef",
|
|
628
|
+
task: refKey,
|
|
629
|
+
path: ["record", fieldKey ?? tail[0], ...tail.slice(1)],
|
|
630
|
+
};
|
|
631
|
+
}
|
|
632
|
+
if (block.type === "elementum_create_record_task" && pathSegments.length === 1) {
|
|
633
|
+
const recordPath = recordFieldRefPath(head, ctx);
|
|
634
|
+
if (recordPath !== undefined) {
|
|
635
|
+
return { kind: "taskRef", task: refKey, path: recordPath };
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
}
|
|
495
639
|
const keyPath = pathSegments.map((segment) => WIRE_REF_SEGMENT_TO_TS[segment] ?? segment);
|
|
496
640
|
const taskKind = block?.type !== undefined ? TASK_FACTORIES[block.type] : undefined;
|
|
497
641
|
const wireOutputKey = taskKind !== undefined ? OUTPUT_KEY_WIRE_NAME[taskKind] : undefined;
|
|
@@ -530,6 +674,14 @@ function decodeReferenceString(value, ctx) {
|
|
|
530
674
|
if (pieces[0] === "task" && pieces.length > 2) {
|
|
531
675
|
return decodeTaskReferenceFromString(pieces[1], pieces.slice(2), ctx);
|
|
532
676
|
}
|
|
677
|
+
if (pieces[0] === "for_each" && pieces.length > 2) {
|
|
678
|
+
const { refKey } = resolveTaskRefKey(pieces[1], ctx);
|
|
679
|
+
return {
|
|
680
|
+
kind: "forEachItemRef",
|
|
681
|
+
forEachTask: refKey,
|
|
682
|
+
path: forEachItemRefPath(pieces.slice(2), ctx),
|
|
683
|
+
};
|
|
684
|
+
}
|
|
533
685
|
// Any other/future value_reference shape - confirmed live: conciergeforfield's
|
|
534
686
|
// cff_find_nearby_accounts_if_user_is_impersonating_a_sales_rep switch_case
|
|
535
687
|
// references a workflow variable ("variable.<uuid>"); setVariable/variable_task
|
|
@@ -566,8 +718,34 @@ function decodeTemplateTriggerRecordFieldRef(value, ctx) {
|
|
|
566
718
|
if (fieldKey === undefined)
|
|
567
719
|
return undefined;
|
|
568
720
|
const suffix = suffixPart === undefined ? [] : suffixPart.replace(/^\./, "").split(".").filter((s) => s.length > 0);
|
|
721
|
+
if (suffix.length === 1 && suffix[0] === "10000001-2000-4000-a000-800000000000") {
|
|
722
|
+
return { kind: "triggerRef", path: ["record", fieldKey, "recordId"] };
|
|
723
|
+
}
|
|
569
724
|
return { kind: "triggerRef", path: ["record", fieldKey, ...suffix] };
|
|
570
725
|
}
|
|
726
|
+
/**
|
|
727
|
+
* Inverse of filterReferenceToTf's TASK case: filters render
|
|
728
|
+
* `"task." + <task.id> + ".<wireName>"` templates so provider Read's plain
|
|
729
|
+
* `task.<uuid>.<wireName>` strings round-trip without perpetual plan drift.
|
|
730
|
+
*/
|
|
731
|
+
function decodeTemplateTaskRef(value, ctx) {
|
|
732
|
+
if (!isTfExpr(value) || value.$expr !== "template")
|
|
733
|
+
return undefined;
|
|
734
|
+
const [prefix, idPart, suffixPart] = value.parts;
|
|
735
|
+
if (prefix !== "task." || idPart === undefined || typeof idPart === "string")
|
|
736
|
+
return undefined;
|
|
737
|
+
if (typeof suffixPart !== "string" || !suffixPart.startsWith("."))
|
|
738
|
+
return undefined;
|
|
739
|
+
if (!isTfExpr(idPart) || idPart.$expr !== "resource-attr" || idPart.path[0] !== "id")
|
|
740
|
+
return undefined;
|
|
741
|
+
const task = ctx.taskByAddress.get(`${idPart.type}.${idPart.label}`);
|
|
742
|
+
if (task === undefined)
|
|
743
|
+
return undefined;
|
|
744
|
+
const nameParts = suffixPart.slice(1).split(".").filter((segment) => segment.length > 0);
|
|
745
|
+
if (nameParts.length === 0)
|
|
746
|
+
return undefined;
|
|
747
|
+
return decodeTaskReferenceFromString(task.refKey, nameParts, ctx);
|
|
748
|
+
}
|
|
571
749
|
/**
|
|
572
750
|
* Resolve the field-id expression at the middle of a `trigger.record.<id>[.suffix]`
|
|
573
751
|
* template. A custom field's id is a `resource-attr` (`elementum_x_field.<label>.id`);
|
|
@@ -607,6 +785,29 @@ function resolveConnectorRef(connectorType, connectorLabel, ctx) {
|
|
|
607
785
|
});
|
|
608
786
|
return { handle: identity.handle, ...(identity.providerKey !== undefined && { providerKey: identity.providerKey }) };
|
|
609
787
|
}
|
|
788
|
+
/**
|
|
789
|
+
* `field_ids["Display Name"]` on either the managed table resource or its
|
|
790
|
+
* `data` lookup. The bag key is derived the same way `table/from-tf.ts` derives
|
|
791
|
+
* it for an out-of-stream table, so the printed token lines up with the key the
|
|
792
|
+
* table's own catalog publishes.
|
|
793
|
+
*/
|
|
794
|
+
function tableColumnRefFromPath(label, path, tableName) {
|
|
795
|
+
const index = path[1];
|
|
796
|
+
const name = typeof index === "string"
|
|
797
|
+
? index
|
|
798
|
+
: typeof index === "object" && index !== null && "index" in index && typeof index.index === "string"
|
|
799
|
+
? index.index
|
|
800
|
+
: undefined;
|
|
801
|
+
if (name === undefined)
|
|
802
|
+
throw new EntityTfError(`${TABLE_RESOURCE_TYPE}.${label}: field_ids reference has no column name`);
|
|
803
|
+
return {
|
|
804
|
+
kind: "tableColumn",
|
|
805
|
+
tableHandle: tfLabelToTsLabel(label),
|
|
806
|
+
columnKey: tfLabelToTsLabel(sanitizeName(name)),
|
|
807
|
+
name,
|
|
808
|
+
...(tableName !== undefined ? { tableName } : {}),
|
|
809
|
+
};
|
|
810
|
+
}
|
|
610
811
|
function decodeValue(value, ctx) {
|
|
611
812
|
if (isTfExpr(value)) {
|
|
612
813
|
if (value.$expr === "template") {
|
|
@@ -673,6 +874,12 @@ function decodeValue(value, ctx) {
|
|
|
673
874
|
return { kind: "taskRef", task: task.refKey, path: [aiSearchName] };
|
|
674
875
|
}
|
|
675
876
|
}
|
|
877
|
+
if (task.block.type === "elementum_table_records_search_task" && rawSegments.length === 1) {
|
|
878
|
+
const tableSearchName = TABLE_RECORDS_SEARCH_TASK_REF_SEGMENT_TO_TS[rawSegments[0]];
|
|
879
|
+
if (tableSearchName !== undefined) {
|
|
880
|
+
return { kind: "taskRef", task: task.refKey, path: [tableSearchName] };
|
|
881
|
+
}
|
|
882
|
+
}
|
|
676
883
|
const keyPath = rawSegments.flatMap((segment) => segment.split("."));
|
|
677
884
|
if (task.block.type === "elementum_variable_task") {
|
|
678
885
|
return { kind: "variableParamRef", varTask: task.refKey, name: keyPath.join(".") };
|
|
@@ -716,6 +923,9 @@ function decodeValue(value, ctx) {
|
|
|
716
923
|
if (value.type === TABLE_RESOURCE_TYPE && value.path[0] === "id") {
|
|
717
924
|
return { kind: "table", tableHandle: tfLabelToTsLabel(value.label) };
|
|
718
925
|
}
|
|
926
|
+
if (value.type === TABLE_RESOURCE_TYPE && value.path[0] === "field_ids") {
|
|
927
|
+
return tableColumnRefFromPath(value.label, value.path, undefined);
|
|
928
|
+
}
|
|
719
929
|
if (value.type === "elementum_datamine" && value.path[0] === "id") {
|
|
720
930
|
const datamineBlock = ctx.resourceBlocks.get(`elementum_datamine.${value.label}`);
|
|
721
931
|
const tableId = datamineBlock?.attrs["table_id"];
|
|
@@ -749,12 +959,11 @@ function decodeValue(value, ctx) {
|
|
|
749
959
|
};
|
|
750
960
|
}
|
|
751
961
|
if (value.type === "elementum_approval_process" && value.path[0] === "id") {
|
|
752
|
-
const bare = bareChildResourceLabel(ctx.appTfLabel, value.label);
|
|
753
962
|
const unresolvedId = ctx.resourceImportIds.get(`${value.type}.${value.label}`);
|
|
754
963
|
return {
|
|
755
964
|
kind: "approvalChain",
|
|
756
965
|
appHandle: ctx.appRefName,
|
|
757
|
-
approvalChainKey:
|
|
966
|
+
approvalChainKey: scopedLabelToBagKey(ctx.appTfLabel, value.label),
|
|
758
967
|
...(unresolvedId !== undefined ? { unresolvedId } : {}),
|
|
759
968
|
};
|
|
760
969
|
}
|
|
@@ -769,6 +978,11 @@ function decodeValue(value, ctx) {
|
|
|
769
978
|
...(typeof name === "string" ? { name } : {}),
|
|
770
979
|
};
|
|
771
980
|
}
|
|
981
|
+
if (value.$expr === "data-attr" && value.type === TABLE_RESOURCE_TYPE && value.path[0] === "field_ids") {
|
|
982
|
+
const lookup = ctx.dataBlocks.get(`${value.type}.${value.label}`);
|
|
983
|
+
const tableName = lookup?.attrs.name;
|
|
984
|
+
return tableColumnRefFromPath(value.label, value.path, typeof tableName === "string" ? tableName : undefined);
|
|
985
|
+
}
|
|
772
986
|
if (value.$expr === "data-attr" && (value.type === "elementum_app" || value.type === "elementum_element") && value.path[0] === "id") {
|
|
773
987
|
const lookup = ctx.dataBlocks.get(`${value.type}.${value.label}`);
|
|
774
988
|
const name = lookup?.attrs.name ?? lookup?.attrs.namespace;
|
|
@@ -782,6 +996,28 @@ function decodeValue(value, ctx) {
|
|
|
782
996
|
...(typeof name === "string" ? { name } : {}),
|
|
783
997
|
};
|
|
784
998
|
}
|
|
999
|
+
if (value.$expr === "data-attr" && value.type === AUTOMATION_RESOURCE_TYPE && value.path[0] === "id") {
|
|
1000
|
+
const lookup = ctx.dataBlocks.get(`${value.type}.${value.label}`);
|
|
1001
|
+
const ownerId = lookup?.attrs["app_id"];
|
|
1002
|
+
if (ownerId === undefined ||
|
|
1003
|
+
!isTfExpr(ownerId) ||
|
|
1004
|
+
ownerId.$expr !== "data-attr" ||
|
|
1005
|
+
(ownerId.type !== "elementum_app" && ownerId.type !== "elementum_element") ||
|
|
1006
|
+
ownerId.path[0] !== "id") {
|
|
1007
|
+
throw new EntityTfError(`data.${AUTOMATION_RESOURCE_TYPE}.${value.label}: app_id is not a resolvable app/element data reference`);
|
|
1008
|
+
}
|
|
1009
|
+
const ownerLookup = ctx.dataBlocks.get(`${ownerId.type}.${ownerId.label}`);
|
|
1010
|
+
const ownerIdentity = ownerLookup?.attrs.namespace ?? ownerLookup?.attrs.name;
|
|
1011
|
+
const mappedHandle = typeof ownerIdentity === "string"
|
|
1012
|
+
? (ownerId.type === "elementum_element" ? ctx.foreignElementRefNames : ctx.foreignAppRefNames)?.get(ownerIdentity)
|
|
1013
|
+
: undefined;
|
|
1014
|
+
const prefix = `${ownerId.label}_`;
|
|
1015
|
+
return {
|
|
1016
|
+
kind: "automation",
|
|
1017
|
+
appHandle: mappedHandle ?? tfLabelToTsLabel(ownerId.label),
|
|
1018
|
+
automationKey: tfLabelToTsLabel(value.label.startsWith(prefix) ? value.label.slice(prefix.length) : value.label),
|
|
1019
|
+
};
|
|
1020
|
+
}
|
|
785
1021
|
if (value.$expr === "data-attr" && value.type === "elementum_field" && value.path[0] === "id") {
|
|
786
1022
|
// The reverse of to-tf.ts's `crossAppFieldToTf`: a field belonging to a
|
|
787
1023
|
// DIFFERENT app/element than this automation's own — resolved via the
|
|
@@ -921,6 +1157,24 @@ function fieldRef(value, ctx) {
|
|
|
921
1157
|
}
|
|
922
1158
|
throw new EntityTfError("field reference cannot be reconstructed");
|
|
923
1159
|
}
|
|
1160
|
+
/**
|
|
1161
|
+
* A TABLE search's filter addresses table COLUMNS, not app fields. The bridge
|
|
1162
|
+
* now hydrates the searched table, so the left side arrives as
|
|
1163
|
+
* `field_ids["Column"]` where it used to be the raw column UUID that
|
|
1164
|
+
* `fieldRef` degraded to an `unresolved` field.
|
|
1165
|
+
*/
|
|
1166
|
+
function filterFieldRef(value, ctx) {
|
|
1167
|
+
if (isTfExpr(value) &&
|
|
1168
|
+
(value.$expr === "resource-attr" || value.$expr === "data-attr") &&
|
|
1169
|
+
value.type === TABLE_RESOURCE_TYPE &&
|
|
1170
|
+
value.path[0] === "field_ids") {
|
|
1171
|
+
const tableName = value.$expr === "data-attr"
|
|
1172
|
+
? ctx.dataBlocks.get(`${value.type}.${value.label}`)?.attrs.name
|
|
1173
|
+
: undefined;
|
|
1174
|
+
return tableColumnRefFromPath(value.label, value.path, typeof tableName === "string" ? tableName : undefined);
|
|
1175
|
+
}
|
|
1176
|
+
return fieldRef(value, ctx);
|
|
1177
|
+
}
|
|
924
1178
|
const USER_FIELD_KEY_SET = new Set(USER_FIELD_KEYS);
|
|
925
1179
|
function userFieldRef(value, ctx) {
|
|
926
1180
|
if (typeof value === "string" && USER_FIELD_KEY_SET.has(value)) {
|
|
@@ -1044,6 +1298,12 @@ function decodeCalculationTaskMustache(taskId, wireName, ctx) {
|
|
|
1044
1298
|
return { kind: "taskRef", task: refKey, path: [aiSearchName] };
|
|
1045
1299
|
}
|
|
1046
1300
|
}
|
|
1301
|
+
if (taskBlock?.type === "elementum_table_records_search_task") {
|
|
1302
|
+
const tableSearchName = TABLE_RECORDS_SEARCH_TASK_REF_SEGMENT_TO_TS[wireName];
|
|
1303
|
+
if (tableSearchName !== undefined) {
|
|
1304
|
+
return { kind: "taskRef", task: refKey, path: [tableSearchName] };
|
|
1305
|
+
}
|
|
1306
|
+
}
|
|
1047
1307
|
const keyPath = wireName.split(".");
|
|
1048
1308
|
const taskKind = taskBlock?.type !== undefined ? TASK_FACTORIES[taskBlock.type] : undefined;
|
|
1049
1309
|
const wireOutputKey = taskKind !== undefined ? OUTPUT_KEY_WIRE_NAME[taskKind] : undefined;
|
|
@@ -1079,8 +1339,11 @@ function decodeFilterReferenceEnvelope(value, ctx) {
|
|
|
1079
1339
|
if (!isObject(raw))
|
|
1080
1340
|
return undefined;
|
|
1081
1341
|
const taskRef = raw.taskReference;
|
|
1082
|
-
if (isObject(taskRef) && typeof taskRef.
|
|
1083
|
-
|
|
1342
|
+
if (isObject(taskRef) && typeof taskRef.name === "string") {
|
|
1343
|
+
const taskIdOrKey = workflowOutputTaskIdOrKey(taskRef.taskId, ctx);
|
|
1344
|
+
if (taskIdOrKey !== undefined) {
|
|
1345
|
+
return decodeTaskReferenceFromString(taskIdOrKey, taskRef.name.split("."), ctx);
|
|
1346
|
+
}
|
|
1084
1347
|
}
|
|
1085
1348
|
const triggerRef = raw.triggerReference;
|
|
1086
1349
|
if (isObject(triggerRef) && typeof triggerRef.name === "string") {
|
|
@@ -1092,17 +1355,33 @@ function decodeFilterReferenceEnvelope(value, ctx) {
|
|
|
1092
1355
|
}
|
|
1093
1356
|
return undefined;
|
|
1094
1357
|
}
|
|
1358
|
+
/** Resolve export UUID or build-time `task.id` resource attr to a task id/refKey. */
|
|
1359
|
+
function workflowOutputTaskIdOrKey(taskId, ctx) {
|
|
1360
|
+
if (typeof taskId === "string" && taskId !== "")
|
|
1361
|
+
return taskId;
|
|
1362
|
+
if (typeof taskId === "object" && taskId !== null && isTfExpr(taskId)) {
|
|
1363
|
+
const exprValue = taskId;
|
|
1364
|
+
if (exprValue.$expr === "resource-attr" && "path" in exprValue && Array.isArray(exprValue.path) && exprValue.path[0] === "id"
|
|
1365
|
+
&& "type" in exprValue && "label" in exprValue
|
|
1366
|
+
&& typeof exprValue.type === "string" && typeof exprValue.label === "string") {
|
|
1367
|
+
const task = ctx.taskByAddress.get(`${exprValue.type}.${exprValue.label}`);
|
|
1368
|
+
return task?.refKey;
|
|
1369
|
+
}
|
|
1370
|
+
}
|
|
1371
|
+
return undefined;
|
|
1372
|
+
}
|
|
1095
1373
|
function filterReference(value, ctx) {
|
|
1096
1374
|
return typeof value === "string"
|
|
1097
1375
|
? decodeReferenceString(value, ctx) ?? { kind: "unresolved", uuid: value, hint: "filter-reference" }
|
|
1098
1376
|
: decodeFilterReferenceEnvelope(value, ctx)
|
|
1099
1377
|
?? decodeTemplateTriggerRecordFieldRef(value, ctx)
|
|
1378
|
+
?? decodeTemplateTaskRef(value, ctx)
|
|
1100
1379
|
?? decodeValue(value, ctx);
|
|
1101
1380
|
}
|
|
1102
1381
|
function decodeFilter(value, ctx, fieldScope = "app") {
|
|
1103
1382
|
return deserializeFilterFromTf(value, {
|
|
1104
1383
|
field: (fieldValue, scope) => {
|
|
1105
|
-
const field = scope === "user" ? userFieldRef(fieldValue, ctx) :
|
|
1384
|
+
const field = scope === "user" ? userFieldRef(fieldValue, ctx) : filterFieldRef(fieldValue, ctx);
|
|
1106
1385
|
return field ?? { kind: "unresolved", uuid: String(fieldValue), hint: "field" };
|
|
1107
1386
|
},
|
|
1108
1387
|
reference: (reference) => filterReference(reference, ctx),
|
|
@@ -1215,7 +1494,10 @@ function taskArgs(block, factory, ctx) {
|
|
|
1215
1494
|
const fieldKey = field.kind === "field"
|
|
1216
1495
|
? field.fieldKey
|
|
1217
1496
|
: `${UNRESOLVED_FIELD_MARKER}${field.uuid}`;
|
|
1218
|
-
|
|
1497
|
+
const decodedValue = decodeFieldAssignmentValue(item.value, ctx);
|
|
1498
|
+
values[fieldKey] = item.update_mode === "add"
|
|
1499
|
+
? { __fieldAssignment: true, value: decodedValue, updateMode: "add" }
|
|
1500
|
+
: decodedValue;
|
|
1219
1501
|
}
|
|
1220
1502
|
args.values = values;
|
|
1221
1503
|
continue;
|
|
@@ -1232,8 +1514,9 @@ function taskArgs(block, factory, ctx) {
|
|
|
1232
1514
|
}
|
|
1233
1515
|
if (attr === "output_schema" && factory === "executeScript") {
|
|
1234
1516
|
const raw = isTfExpr(value) && value.$expr === "jsonencode" ? value.value : value;
|
|
1235
|
-
const
|
|
1236
|
-
|
|
1517
|
+
const root = isObject(raw) && isObject(raw.object) ? raw.object : undefined;
|
|
1518
|
+
const props = Array.isArray(root?.properties) ? root.properties : [];
|
|
1519
|
+
const properties = Object.fromEntries(props.map((property) => {
|
|
1237
1520
|
if (!isObject(property))
|
|
1238
1521
|
throw new EntityTfError("invalid script output schema");
|
|
1239
1522
|
const [type, definition] = Object.entries(property)[0] ?? [];
|
|
@@ -1241,6 +1524,12 @@ function taskArgs(block, factory, ctx) {
|
|
|
1241
1524
|
throw new EntityTfError("invalid script output property");
|
|
1242
1525
|
return [definition.name, type === "bool" ? "boolean" : type];
|
|
1243
1526
|
}));
|
|
1527
|
+
// The root object's own name is inert to the platform but real stored
|
|
1528
|
+
// data, so carry it through rather than rebuilding a schema that
|
|
1529
|
+
// differs from the one just read.
|
|
1530
|
+
args.outputs = typeof root?.name === "string" && root.name !== ""
|
|
1531
|
+
? { name: root.name, properties }
|
|
1532
|
+
: properties;
|
|
1244
1533
|
continue;
|
|
1245
1534
|
}
|
|
1246
1535
|
if (attr === "input_mappings" && factory === "runAutomation") {
|
|
@@ -1251,17 +1540,31 @@ function taskArgs(block, factory, ctx) {
|
|
|
1251
1540
|
throw new EntityTfError(`${block.type}.${block.label}: invalid input mapping`);
|
|
1252
1541
|
}
|
|
1253
1542
|
const parameter = item.parameter_id;
|
|
1254
|
-
if (
|
|
1255
|
-
parameter.$expr
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
parameter.path[
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1543
|
+
if (isTfExpr(parameter) &&
|
|
1544
|
+
(parameter.$expr === "resource-attr" &&
|
|
1545
|
+
parameter.type === "elementum_on_demand_trigger" ||
|
|
1546
|
+
parameter.$expr === "data-attr" &&
|
|
1547
|
+
parameter.type === AUTOMATION_RESOURCE_TYPE) &&
|
|
1548
|
+
parameter.path[0] === "parameter_ids" &&
|
|
1549
|
+
typeof parameter.path[1] === "object" &&
|
|
1550
|
+
parameter.path[1] !== null &&
|
|
1551
|
+
"index" in parameter.path[1] &&
|
|
1552
|
+
typeof parameter.path[1].index === "string") {
|
|
1553
|
+
return { name: parameter.path[1].index, value: decodeValue(item.value, ctx) };
|
|
1263
1554
|
}
|
|
1264
|
-
|
|
1555
|
+
// ei emits bare platform parameter UUIDs when the target automation's
|
|
1556
|
+
// onDemand trigger is not in this export (foreign / undiscovered).
|
|
1557
|
+
// Throwing here used to abort the WHOLE parent automation extract, so
|
|
1558
|
+
// skill tools that only needed the automation catalog key (e.g.
|
|
1559
|
+
// ridesTriggerRides) were dropped on build. Keep extract alive with an
|
|
1560
|
+
// unresolved placeholder — printer emits a TODO, build stays honest.
|
|
1561
|
+
if (typeof parameter === "string" && parameter !== "") {
|
|
1562
|
+
return {
|
|
1563
|
+
name: parameter,
|
|
1564
|
+
value: decodeValue(item.value, ctx),
|
|
1565
|
+
};
|
|
1566
|
+
}
|
|
1567
|
+
throw new EntityTfError(`${block.type}.${block.label}: input mapping parameter_id is not a named trigger parameter reference`);
|
|
1265
1568
|
});
|
|
1266
1569
|
continue;
|
|
1267
1570
|
}
|
|
@@ -1339,6 +1642,24 @@ function taskArgs(block, factory, ctx) {
|
|
|
1339
1642
|
: decodeValue(value, ctx);
|
|
1340
1643
|
continue;
|
|
1341
1644
|
}
|
|
1645
|
+
if (factory === "approvalChain" && attr === "approval_process_id") {
|
|
1646
|
+
args.approvalProcess = decodeValue(value, ctx);
|
|
1647
|
+
continue;
|
|
1648
|
+
}
|
|
1649
|
+
if (factory === "approvalChain" && attr === "record_reference") {
|
|
1650
|
+
args.record = decodeValue(value, ctx);
|
|
1651
|
+
continue;
|
|
1652
|
+
}
|
|
1653
|
+
if (factory === "approvalChain" && attr === "requester_reference") {
|
|
1654
|
+
args.requester = decodeValue(value, ctx);
|
|
1655
|
+
continue;
|
|
1656
|
+
}
|
|
1657
|
+
if (factory === "approvalChain" && attr === "approver_references") {
|
|
1658
|
+
if (!Array.isArray(value))
|
|
1659
|
+
throw new EntityTfError(`${block.type}.${block.label}: approver_references must be an array`);
|
|
1660
|
+
args.approvers = value.map((item) => decodeValue(item, ctx));
|
|
1661
|
+
continue;
|
|
1662
|
+
}
|
|
1342
1663
|
if (attr === "list" && factory === "forEach") {
|
|
1343
1664
|
args.collection = decodeValue(value, ctx);
|
|
1344
1665
|
continue;
|
|
@@ -1488,6 +1809,13 @@ function taskArgs(block, factory, ctx) {
|
|
|
1488
1809
|
args.message = decodeValue(value, ctx);
|
|
1489
1810
|
continue;
|
|
1490
1811
|
}
|
|
1812
|
+
// Notification's dynamic-recipient HCL attributes share the names
|
|
1813
|
+
// `users`/`groups` with sendEmail, but their public options are
|
|
1814
|
+
// userRefs/groupRefs (not sendEmail's toUsers/toGroups).
|
|
1815
|
+
if (factory === "notification" && (attr === "users" || attr === "groups")) {
|
|
1816
|
+
args[attr === "users" ? "userRefs" : "groupRefs"] = decodeValue(value, ctx);
|
|
1817
|
+
continue;
|
|
1818
|
+
}
|
|
1491
1819
|
const arg = ATTR_TO_ARG[attr] ?? attr.replace(/_([a-z])/g, (_, char) => char.toUpperCase());
|
|
1492
1820
|
args[arg] = decodeValue(value, ctx);
|
|
1493
1821
|
}
|
|
@@ -1805,14 +2133,15 @@ function automationFromTfDocument(doc, automationLabel, appRefName, foreignField
|
|
|
1805
2133
|
children = [{ label: null, tasks: buildTasks(`${address}.inner`) }];
|
|
1806
2134
|
if (factory === "switchTask" || factory === "forkJoin") {
|
|
1807
2135
|
const branchAttr = factory === "switchTask" ? "switch_task" : "fork_join_task";
|
|
2136
|
+
const previousAttr = factory === "switchTask" ? "previous_case_id" : "previous_branch_id";
|
|
1808
2137
|
const matching = ownedBranches.filter((branch) => references(branch.attrs[branchAttr], block.type, block.label));
|
|
1809
|
-
|
|
1810
|
-
children =
|
|
2138
|
+
const ordered = orderBranchesByPreviousLink(matching, previousAttr, dependencyOrder);
|
|
2139
|
+
children = ordered.map((branch) => {
|
|
1811
2140
|
const shape = factory === "switchTask" ? defaultSwitchShape(branch) : undefined;
|
|
1812
2141
|
const isDefault = shape !== undefined;
|
|
1813
2142
|
const rawLabel = typeof branch.attrs.label === "string" ? branch.attrs.label : undefined;
|
|
1814
2143
|
return {
|
|
1815
|
-
label: isDefault ?
|
|
2144
|
+
...(isDefault ? { label: null, isDefault: true } : rawLabel !== undefined ? { label: rawLabel } : {}),
|
|
1816
2145
|
// ei always writes SOME display label on the default case, but it's
|
|
1817
2146
|
// not always the literal string "Default" (e.g. a manual rename to
|
|
1818
2147
|
// "Default Path") - carry the real text so the printer/build round
|
|
@@ -1842,7 +2171,11 @@ function automationFromTfDocument(doc, automationLabel, appRefName, foreignField
|
|
|
1842
2171
|
const outputs = Array.isArray(outputBlocks) ? outputBlocks.map((output) => {
|
|
1843
2172
|
if (!isObject(output) || typeof output.name !== "string" || output.value === undefined)
|
|
1844
2173
|
throw new EntityTfError("invalid workflow output");
|
|
1845
|
-
|
|
2174
|
+
// Export/provider Read emit jsonencode({fieldType, taskReference, ...});
|
|
2175
|
+
// collapse that envelope to a RefExpr the same way filter references do.
|
|
2176
|
+
const value = decodeFilterReferenceEnvelope(output.value, ctx)
|
|
2177
|
+
?? decodeValue(output.value, ctx);
|
|
2178
|
+
return { name: output.name, value };
|
|
1846
2179
|
}) : undefined;
|
|
1847
2180
|
const exportedRevision = publish?.attrs.workflow_revision;
|
|
1848
2181
|
if (exportedRevision !== undefined && typeof exportedRevision !== "string") {
|