@elementumai/edk 0.9.20 → 0.10.1
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 +19 -7
- package/dist-sdk/src/catalog/factories.d.ts +10 -2
- package/dist-sdk/src/catalog/factories.js +10 -1
- package/dist-sdk/src/catalog/index.d.ts +2 -2
- package/dist-sdk/src/catalog/index.js +1 -1
- package/dist-sdk/src/catalog/token.js +4 -0
- package/dist-sdk/src/catalog/types.d.ts +7 -1
- package/dist-sdk/src/catalog/types.js +1 -0
- package/dist-sdk/src/core/triggers/on-demand.d.ts +2 -2
- package/dist-sdk/src/core/triggers/on-demand.js +7 -0
- package/dist-sdk/src/core/types/app.d.ts +2 -2
- package/dist-sdk/src/engine/coverage-gaps.d.ts +86 -0
- package/dist-sdk/src/engine/coverage-gaps.js +156 -0
- package/dist-sdk/src/engine/ei/run.d.ts +21 -1
- package/dist-sdk/src/engine/ei/run.js +89 -2
- package/dist-sdk/src/engine/pull/catalog-ref.d.ts +16 -0
- package/dist-sdk/src/engine/pull/catalog-ref.js +24 -0
- package/dist-sdk/src/engine/pull/context.d.ts +68 -6
- package/dist-sdk/src/engine/pull/context.js +40 -1
- package/dist-sdk/src/engine/pull/procedure-refs.d.ts +8 -0
- package/dist-sdk/src/engine/pull/procedure-refs.js +28 -0
- package/dist-sdk/src/engine/pull/result-output.js +27 -1
- package/dist-sdk/src/engine/tf/index.d.ts +1 -1
- package/dist-sdk/src/engine/tf/index.js +1 -1
- package/dist-sdk/src/engine/tf/labels.d.ts +22 -5
- package/dist-sdk/src/engine/tf/labels.js +45 -3
- package/dist-sdk/src/engine/tf/parse.js +3 -2
- package/dist-sdk/src/engine/validation.d.ts +5 -0
- package/dist-sdk/src/engine/validation.js +12 -2
- package/dist-sdk/src/entities/access-policy/from-tf.js +38 -1
- package/dist-sdk/src/entities/access-policy/principal.d.ts +2 -0
- package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.d.ts +3 -0
- package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +42 -19
- package/dist-sdk/src/entities/agent/from-tf.js +11 -3
- package/dist-sdk/src/entities/agent/module.js +2 -0
- package/dist-sdk/src/entities/agent/to-tf.js +14 -3
- package/dist-sdk/src/entities/agent-tool/from-tf.d.ts +8 -1
- package/dist-sdk/src/entities/agent-tool/from-tf.js +11 -5
- package/dist-sdk/src/entities/agent-tool/module.js +3 -0
- package/dist-sdk/src/entities/app/auto-share.d.ts +38 -0
- package/dist-sdk/src/entities/app/auto-share.js +49 -0
- package/dist-sdk/src/entities/app/build.d.ts +17 -3
- package/dist-sdk/src/entities/app/build.js +56 -4
- package/dist-sdk/src/entities/app/deserializer/normalize.d.ts +6 -1
- package/dist-sdk/src/entities/app/from-tf.js +4 -0
- package/dist-sdk/src/entities/app/index.d.ts +2 -1
- package/dist-sdk/src/entities/app/index.js +1 -8
- package/dist-sdk/src/entities/app/to-tf.d.ts +6 -0
- package/dist-sdk/src/entities/app/to-tf.js +21 -2
- package/dist-sdk/src/entities/automation/build.d.ts +10 -2
- package/dist-sdk/src/entities/automation/build.js +104 -17
- package/dist-sdk/src/entities/automation/calculation-expression.d.ts +7 -7
- package/dist-sdk/src/entities/automation/deserializer/print-automation.d.ts +17 -4
- package/dist-sdk/src/entities/automation/deserializer/print-automation.js +156 -19
- package/dist-sdk/src/entities/automation/from-tf.d.ts +9 -2
- package/dist-sdk/src/entities/automation/from-tf.js +366 -86
- package/dist-sdk/src/entities/automation/index.d.ts +1 -1
- package/dist-sdk/src/entities/automation/index.js +1 -1
- package/dist-sdk/src/entities/automation/module.d.ts +3 -0
- package/dist-sdk/src/entities/automation/module.js +70 -7
- package/dist-sdk/src/entities/automation/script-code.d.ts +5 -2
- package/dist-sdk/src/entities/automation/script-code.js +23 -5
- package/dist-sdk/src/entities/automation/task-output-labels.d.ts +37 -0
- package/dist-sdk/src/entities/automation/task-output-labels.js +76 -0
- package/dist-sdk/src/entities/automation/tasks.d.ts +92 -20
- package/dist-sdk/src/entities/automation/tasks.js +48 -15
- package/dist-sdk/src/entities/automation/to-tf.d.ts +20 -3
- package/dist-sdk/src/entities/automation/to-tf.js +606 -62
- package/dist-sdk/src/entities/automation/triggers.d.ts +8 -4
- package/dist-sdk/src/entities/automation/types.d.ts +9 -0
- package/dist-sdk/src/entities/automation/types.js +19 -0
- package/dist-sdk/src/entities/automation/value-ref-tf.d.ts +1 -1
- package/dist-sdk/src/entities/automation/value-ref-tf.js +1 -1
- package/dist-sdk/src/entities/chart/from-tf.js +9 -1
- package/dist-sdk/src/entities/data-lookup/module.js +2 -0
- package/dist-sdk/src/entities/dynamic-layout/to-tf.d.ts +1 -0
- package/dist-sdk/src/entities/dynamic-layout/to-tf.js +7 -5
- package/dist-sdk/src/entities/element/build.d.ts +3 -0
- package/dist-sdk/src/entities/element/build.js +1 -0
- package/dist-sdk/src/entities/element/from-tf.js +4 -0
- package/dist-sdk/src/entities/element/to-tf.d.ts +1 -1
- package/dist-sdk/src/entities/element/to-tf.js +8 -14
- package/dist-sdk/src/entities/field/build.d.ts +3 -2
- package/dist-sdk/src/entities/field/calc.d.ts +7 -7
- package/dist-sdk/src/entities/field/from-tf.d.ts +4 -4
- package/dist-sdk/src/entities/field/from-tf.js +205 -48
- package/dist-sdk/src/entities/field/module.js +1 -0
- package/dist-sdk/src/entities/field/options.js +6 -1
- package/dist-sdk/src/entities/field/to-tf.d.ts +4 -4
- package/dist-sdk/src/entities/field/to-tf.js +7 -1
- package/dist-sdk/src/entities/field/types.d.ts +2 -0
- package/dist-sdk/src/entities/field/types.js +27 -0
- package/dist-sdk/src/entities/role/from-tf.js +3 -3
- package/dist-sdk/src/entities/role/to-tf.d.ts +2 -0
- package/dist-sdk/src/entities/role/to-tf.js +12 -4
- package/dist-sdk/src/entities/service-account/from-tf.js +3 -3
- package/dist-sdk/src/entities/service-account/workspace-owner.d.ts +16 -0
- package/dist-sdk/src/entities/service-account/workspace-owner.js +22 -0
- package/dist-sdk/src/entities/shared/filters/ast.d.ts +15 -1
- package/dist-sdk/src/entities/shared/filters/ast.js +2 -0
- package/dist-sdk/src/entities/shared/filters/index.d.ts +5 -0
- package/dist-sdk/src/entities/shared/filters/index.js +5 -0
- package/dist-sdk/src/entities/shared/filters/print.js +7 -2
- package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +5 -0
- package/dist-sdk/src/entities/shared/filters/tf-codec.js +42 -7
- package/dist-sdk/src/entities/shared/filters/types.d.ts +8 -3
- package/dist-sdk/src/entities/shared/ref.d.ts +5 -7
- package/dist-sdk/src/entities/shared/ref.js +5 -7
- package/dist-sdk/src/entities/shared/tool-field-ref.d.ts +9 -0
- package/dist-sdk/src/entities/shared/tool-field-ref.js +35 -2
- package/dist-sdk/src/entities/shared/types/field-types.d.ts +10 -0
- package/dist-sdk/src/entities/shared/types/field-types.js +4 -0
- package/dist-sdk/src/entities/skill/access-policy.js +3 -3
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.d.ts +3 -0
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +12 -5
- package/dist-sdk/src/entities/skill/from-tf.js +4 -2
- package/dist-sdk/src/entities/skill/module.js +2 -0
- package/dist-sdk/src/entities/skill-tool/from-tf.js +41 -8
- package/dist-sdk/src/entities/skill-tool/module.js +3 -0
- package/dist-sdk/src/entities/skill-tool/to-tf.d.ts +0 -6
- package/dist-sdk/src/entities/skill-tool/to-tf.js +22 -9
- package/dist-sdk/src/entities/task/build.d.ts +8 -0
- package/dist-sdk/src/entities/task/build.js +10 -1
- package/dist-sdk/src/entities/task/from-tf.d.ts +4 -2
- package/dist-sdk/src/entities/task/from-tf.js +7 -2
- package/dist-sdk/src/entities/task/module.js +2 -2
- package/dist-sdk/src/entities/task/to-tf.d.ts +8 -4
- package/dist-sdk/src/entities/task/to-tf.js +28 -1
- package/dist-sdk/src/entities/view/from-tf.js +9 -1
- package/dist-sdk/src/entities/view/to-tf.d.ts +6 -7
- package/dist-sdk/src/entities/view/to-tf.js +19 -8
- package/dist-sdk/src/entities/visual-flow/build.d.ts +16 -1
- package/dist-sdk/src/entities/visual-flow/build.js +9 -0
- package/dist-sdk/src/entities/visual-flow/from-tf.d.ts +14 -0
- package/dist-sdk/src/entities/visual-flow/from-tf.js +51 -3
- package/dist-sdk/src/entities/visual-flow/index.d.ts +1 -1
- package/dist-sdk/src/entities/visual-flow/index.js +1 -1
- package/dist-sdk/src/entities/visual-flow/printer.js +19 -0
- package/dist-sdk/src/entities/visual-flow/to-tf.js +87 -3
- package/dist-sdk/src/entities/widget/from-tf.js +3 -3
- package/dist-sdk/src/entities/widget/to-tf.d.ts +2 -0
- package/dist-sdk/src/entities/widget/to-tf.js +7 -6
- package/dist-sdk/src/generated/ragnarok/ragnarok-spec.d.ts +133 -9
- package/dist-sdk/src/generated/ragnarok/ragnarok-spec.js +2 -2
- package/dist-sdk/src/graph/index.d.ts +1 -0
- package/dist-sdk/src/graph/types.d.ts +29 -3
- package/package.json +7 -3
|
@@ -4,7 +4,7 @@ import { normalizeOnDemandParamKey } from "../../../pull/util.js";
|
|
|
4
4
|
import { EntityTfError } from "../../engine/entity.js";
|
|
5
5
|
import { dataRefLabel } from "../../engine/pull/context.js";
|
|
6
6
|
import { procedureDiscriminator } from "../../engine/pull/procedure-refs.js";
|
|
7
|
-
import { appResourceLabelPrefix, childPartFromScopedLabel, elementResourceLabelPrefix, isTfExpr, sanitizeName, scopedLabelToBagKey, tfLabelToTsLabel, tsLabelToTfLabel, } from "../../engine/tf/index.js";
|
|
7
|
+
import { appResourceLabelPrefix, childPartFromScopedLabel, elementResourceLabelPrefix, isTfExpr, isTfLabel, ownerFromScopedChildLabel, sanitizeName, scopedLabelToBagKey, tfLabelToTsLabel, tsLabelToTfLabel, } from "../../engine/tf/index.js";
|
|
8
8
|
import { SUB_TYPE_BY_RESOURCE } from "../field/types.js";
|
|
9
9
|
import { IMPLEMENTED_FILE_READER_RESOURCE_TYPES } from "../file-reader/types.js";
|
|
10
10
|
import { connectorIdentityFromTf } from "../shared/connector-from-tf.js";
|
|
@@ -18,6 +18,7 @@ import { apiTaskRefAuthoringPath, matchesOutputWireKey, OUTPUT_KEY_WIRE_NAME } f
|
|
|
18
18
|
import { RESOURCE_TYPE_TO_EXECUTOR, TASK_OUTPUT_CONTRACTS } from "./generated/task-output-contracts.js";
|
|
19
19
|
import { systemRefNameRoundTrips } from "./system-ref-name.js";
|
|
20
20
|
import { taskTfLabel } from "./task-label.js";
|
|
21
|
+
import { parseTriggerAttachmentPayloadRefJson, parseTriggerWholeRecordRefJson, TRIGGER_WHOLE_RECORD_REF_NAME } from "./task-output-labels.js";
|
|
21
22
|
import { workflowOutputTypeFromFieldType } from "./workflow-output.js";
|
|
22
23
|
import { ALL_AUTOMATION_TASK_TYPE_SET, AUTOMATION_BRANCH_TYPE_SET, AUTOMATION_RESOURCE_TYPE, AUTOMATION_TRIGGER_TYPE_SET, WORKFLOW_PUBLISH_RESOURCE_TYPE, } from "./types.js";
|
|
23
24
|
const TRIGGER_KINDS = {
|
|
@@ -38,6 +39,7 @@ const TRIGGER_KINDS = {
|
|
|
38
39
|
const TASK_FACTORIES = {
|
|
39
40
|
elementum_message_task: "postComment",
|
|
40
41
|
elementum_update_field_task: "updateField",
|
|
42
|
+
elementum_bulk_update_fields_task: "bulkUpdateFields",
|
|
41
43
|
elementum_variable_task: "setVariable",
|
|
42
44
|
elementum_update_variable_task: "setVariable",
|
|
43
45
|
elementum_create_record_task: "createRecord",
|
|
@@ -61,6 +63,7 @@ const TASK_FACTORIES = {
|
|
|
61
63
|
elementum_ai_search_table_task: "aiSearchTable",
|
|
62
64
|
elementum_ai_transform_task: "aiTransform",
|
|
63
65
|
elementum_save_attachment_task: "saveAttachment",
|
|
66
|
+
elementum_unzip_file_task: "unzip",
|
|
64
67
|
elementum_user_search_task: "userSearch",
|
|
65
68
|
elementum_user_group_search_task: "userGroupSearch",
|
|
66
69
|
elementum_calculation_task: "calculation",
|
|
@@ -327,7 +330,7 @@ const TRIGGER_ATTRIBUTES = new Set([
|
|
|
327
330
|
]);
|
|
328
331
|
const TASK_ATTRIBUTES = new Set([
|
|
329
332
|
"parent", "name", "depends_on", "filter", "fields", "inputs", "output_schema",
|
|
330
|
-
"list", "code", "
|
|
333
|
+
"list", "code", "variables", "updates", "variable", "value",
|
|
331
334
|
"object_id", "table_id", "record_reference", "record_id", "source_record_ids",
|
|
332
335
|
"approval_process_id", "requester_reference", "approver_references", "reason", "summary",
|
|
333
336
|
"approval_reference", "status",
|
|
@@ -342,7 +345,7 @@ const TASK_ATTRIBUTES = new Set([
|
|
|
342
345
|
"output_mappings", "file_reader_id", "raw_text", "procedure_id",
|
|
343
346
|
"calculations", "categories", "limit", "sort", "tag", "tags", "context", "length",
|
|
344
347
|
"subject", "phone_service_id", "phone_number", "default_language", "first_message",
|
|
345
|
-
"synchronous", "cloudlink_id", "stored_function_id",
|
|
348
|
+
"synchronous", "cloudlink_id", "stored_function_id",
|
|
346
349
|
"relate_to_record_reference", "method", "parameters", "headers",
|
|
347
350
|
"basic_auth", "bearer_auth", "oauth", "json_body", "form_body", "custom_body", "multipart_body",
|
|
348
351
|
"query",
|
|
@@ -705,11 +708,13 @@ function aspectRefFromObjectId(objectId, ctx) {
|
|
|
705
708
|
}
|
|
706
709
|
if (typeof identity !== "string" || identity === "")
|
|
707
710
|
return undefined;
|
|
711
|
+
const namespace = lookup?.attrs.namespace;
|
|
708
712
|
return {
|
|
709
713
|
kind: "app",
|
|
710
714
|
appHandle: tfLabelToTsLabel(objectId.label),
|
|
711
715
|
entityType: objectId.type === "elementum_task" ? "task" : objectId.type === "elementum_element" ? "element" : "app",
|
|
712
716
|
name: identity,
|
|
717
|
+
...(typeof namespace === "string" && namespace !== "" ? { namespace } : {}),
|
|
713
718
|
};
|
|
714
719
|
}
|
|
715
720
|
function aspectKindFromObjectId(objectId) {
|
|
@@ -891,22 +896,144 @@ function approverReferenceFieldAuthoringType(value, ctx) {
|
|
|
891
896
|
}
|
|
892
897
|
return undefined;
|
|
893
898
|
}
|
|
894
|
-
function decodeFieldAssignmentValue(value, ctx) {
|
|
899
|
+
function decodeFieldAssignmentValue(value, ctx, diagnostics, where = "field assignment") {
|
|
895
900
|
// Multi-Select assignments are exported as jsonencode([<option UUID>, ...])
|
|
896
901
|
// rather than the options-by-label locals used for a scalar Dropdown. Walk
|
|
897
902
|
// that payload with the state-derived option registry so pulled source stays
|
|
898
903
|
// portable across organizations and fresh creates.
|
|
899
904
|
if (isTfExpr(value) && value.$expr === "jsonencode") {
|
|
900
|
-
return decodeFieldAssignmentValue(value.value, ctx);
|
|
905
|
+
return decodeFieldAssignmentValue(value.value, ctx, diagnostics, where);
|
|
901
906
|
}
|
|
902
907
|
if (Array.isArray(value)) {
|
|
903
|
-
return value.map((item) => decodeFieldAssignmentValue(item, ctx));
|
|
908
|
+
return value.map((item) => decodeFieldAssignmentValue(item, ctx, diagnostics, where));
|
|
904
909
|
}
|
|
905
910
|
if (typeof value === "string" && /^[a-f0-9-]{36}$/i.test(value)) {
|
|
906
911
|
const label = ctx.picklistOptionLabelById?.get(value);
|
|
907
912
|
if (label !== undefined)
|
|
908
913
|
return { kind: "literal", value: label };
|
|
909
914
|
}
|
|
915
|
+
return decodeValueOrStringifiedRef(value, ctx, diagnostics, where);
|
|
916
|
+
}
|
|
917
|
+
const VALUE_REFERENCE_KEYS = ["taskReference", "triggerReference", "variableReference"];
|
|
918
|
+
/**
|
|
919
|
+
* edk#1646: ei's exporter falls back to a stringified wire ValueReference
|
|
920
|
+
* envelope (`"{\"fieldType\":…,\"taskReference\":{…}}"`) when it cannot emit a
|
|
921
|
+
* `refs["…"]` expression. Left as a literal, build ships the JSON text into
|
|
922
|
+
* the field (or fails a typed field). Decode the envelope - whole-string or
|
|
923
|
+
* embedded in surrounding text - through the same path calculation formulas
|
|
924
|
+
* use. An envelope whose task / trigger / variable does not resolve in this
|
|
925
|
+
* automation stays visible as an `unresolved` value-reference with a pull
|
|
926
|
+
* diagnostic instead of a silent literal. Returns undefined for any string
|
|
927
|
+
* that carries no envelope.
|
|
928
|
+
*/
|
|
929
|
+
function decodeStringifiedValueReference(value, ctx, diagnostics, where) {
|
|
930
|
+
if (!value.includes("{") || !VALUE_REFERENCE_KEYS.some((key) => value.includes(`"${key}"`)))
|
|
931
|
+
return undefined;
|
|
932
|
+
const parts = [];
|
|
933
|
+
let cursor = 0;
|
|
934
|
+
let unresolved = false;
|
|
935
|
+
let found = false;
|
|
936
|
+
for (let start = value.indexOf("{", cursor); start >= 0; start = value.indexOf("{", cursor)) {
|
|
937
|
+
let depth = 0;
|
|
938
|
+
let inString = false;
|
|
939
|
+
let escaped = false;
|
|
940
|
+
let end = start;
|
|
941
|
+
for (; end < value.length; end += 1) {
|
|
942
|
+
const char = value[end];
|
|
943
|
+
if (inString) {
|
|
944
|
+
if (escaped)
|
|
945
|
+
escaped = false;
|
|
946
|
+
else if (char === "\\")
|
|
947
|
+
escaped = true;
|
|
948
|
+
else if (char === '"')
|
|
949
|
+
inString = false;
|
|
950
|
+
continue;
|
|
951
|
+
}
|
|
952
|
+
if (char === '"')
|
|
953
|
+
inString = true;
|
|
954
|
+
else if (char === "{")
|
|
955
|
+
depth += 1;
|
|
956
|
+
else if (char === "}") {
|
|
957
|
+
depth -= 1;
|
|
958
|
+
if (depth === 0) {
|
|
959
|
+
end += 1;
|
|
960
|
+
break;
|
|
961
|
+
}
|
|
962
|
+
}
|
|
963
|
+
}
|
|
964
|
+
if (depth !== 0)
|
|
965
|
+
break;
|
|
966
|
+
let parsed;
|
|
967
|
+
try {
|
|
968
|
+
parsed = JSON.parse(value.slice(start, end));
|
|
969
|
+
}
|
|
970
|
+
catch {
|
|
971
|
+
cursor = start + 1;
|
|
972
|
+
continue;
|
|
973
|
+
}
|
|
974
|
+
if (!isObject(parsed) || !VALUE_REFERENCE_KEYS.some((key) => isObject(parsed[key]))) {
|
|
975
|
+
cursor = start + 1;
|
|
976
|
+
continue;
|
|
977
|
+
}
|
|
978
|
+
found = true;
|
|
979
|
+
if (start > cursor)
|
|
980
|
+
parts.push(value.slice(cursor, start));
|
|
981
|
+
const reference = decodeFilterReferenceEnvelope(parsed, ctx);
|
|
982
|
+
if (reference === undefined || !stringifiedReferenceResolves(parsed, reference, ctx)) {
|
|
983
|
+
unresolved = true;
|
|
984
|
+
parts.push({ kind: "unresolved", uuid: value.slice(start, end), hint: "value-reference (edk#1646)" });
|
|
985
|
+
}
|
|
986
|
+
else {
|
|
987
|
+
parts.push(reference);
|
|
988
|
+
}
|
|
989
|
+
cursor = end;
|
|
990
|
+
}
|
|
991
|
+
if (!found)
|
|
992
|
+
return undefined;
|
|
993
|
+
if (unresolved) {
|
|
994
|
+
diagnostics?.push(`${where}: value is a stringified platform ValueReference whose task/trigger/variable is not in this automation; ` +
|
|
995
|
+
"kept as an unresolved value-reference - rewrite it as a ctx reference before building (edk#1646)");
|
|
996
|
+
}
|
|
997
|
+
if (cursor < value.length)
|
|
998
|
+
parts.push(value.slice(cursor));
|
|
999
|
+
const merged = [];
|
|
1000
|
+
for (const part of parts) {
|
|
1001
|
+
const last = merged[merged.length - 1];
|
|
1002
|
+
if (typeof part === "string" && typeof last === "string")
|
|
1003
|
+
merged[merged.length - 1] = last + part;
|
|
1004
|
+
else
|
|
1005
|
+
merged.push(part);
|
|
1006
|
+
}
|
|
1007
|
+
// A sole unresolved envelope (or one that failed to resolve) becomes a
|
|
1008
|
+
// single unresolved value so the printer surfaces the TODO instead of a
|
|
1009
|
+
// template that still embeds the JSON text.
|
|
1010
|
+
if (unresolved && merged.length === 1 && typeof merged[0] !== "string") {
|
|
1011
|
+
return merged[0];
|
|
1012
|
+
}
|
|
1013
|
+
if (unresolved) {
|
|
1014
|
+
return { kind: "unresolved", uuid: value, hint: "value-reference (edk#1646)" };
|
|
1015
|
+
}
|
|
1016
|
+
if (merged.length === 1 && typeof merged[0] !== "string")
|
|
1017
|
+
return merged[0];
|
|
1018
|
+
return { kind: "template", parts: merged };
|
|
1019
|
+
}
|
|
1020
|
+
function stringifiedReferenceResolves(envelope, reference, ctx) {
|
|
1021
|
+
if (reference.kind === "unresolved")
|
|
1022
|
+
return false;
|
|
1023
|
+
const taskRef = envelope.taskReference;
|
|
1024
|
+
if (isObject(taskRef)) {
|
|
1025
|
+
const taskIdOrKey = workflowOutputTaskIdOrKey(taskRef.taskId, ctx);
|
|
1026
|
+
return taskIdOrKey !== undefined && resolveTaskRefKey(taskIdOrKey, ctx).block !== undefined;
|
|
1027
|
+
}
|
|
1028
|
+
return true;
|
|
1029
|
+
}
|
|
1030
|
+
/** decodeValue, upgrading a stringified ValueReference envelope (edk#1646). */
|
|
1031
|
+
function decodeValueOrStringifiedRef(value, ctx, diagnostics, where) {
|
|
1032
|
+
if (typeof value === "string") {
|
|
1033
|
+
const decoded = decodeStringifiedValueReference(value, ctx, diagnostics, where);
|
|
1034
|
+
if (decoded !== undefined)
|
|
1035
|
+
return decoded;
|
|
1036
|
+
}
|
|
910
1037
|
return decodeValue(value, ctx);
|
|
911
1038
|
}
|
|
912
1039
|
function triggerRefPath(path, ctx) {
|
|
@@ -966,15 +1093,16 @@ function triggerRefPath(path, ctx) {
|
|
|
966
1093
|
// field display name "Facility".
|
|
967
1094
|
if (isDeclaredOnDemandParameter(ctx.trigger, wireName))
|
|
968
1095
|
return names;
|
|
969
|
-
// A trigger's own bare record reference
|
|
970
|
-
//
|
|
971
|
-
//
|
|
972
|
-
//
|
|
973
|
-
//
|
|
974
|
-
//
|
|
975
|
-
//
|
|
976
|
-
//
|
|
977
|
-
//
|
|
1096
|
+
// A trigger's own bare record reference. refs["Record"] is the record ID
|
|
1097
|
+
// (ASPECT_RECORD_ID, confirmed live via `ei refs`, see
|
|
1098
|
+
// trigger-record-id.test.ts); the whole record shares that display name and
|
|
1099
|
+
// has no refs key, so it exports as its reference JSON instead (edk#1284).
|
|
1100
|
+
// Deliberately scoped to triggerRefPath, not the shared
|
|
1101
|
+
// WIRE_REF_SEGMENT_TO_TS table: createRecord/findRelatedRecords TASKS also
|
|
1102
|
+
// expose a wire key literally named "Record" (their record-ID output), and
|
|
1103
|
+
// translating it globally intercepted that task-level case before it could
|
|
1104
|
+
// ever be checked (decodeValue's own dedicated "Record" handling for those
|
|
1105
|
+
// task types).
|
|
978
1106
|
if (wireName === "Record") {
|
|
979
1107
|
const recordParams = onDemandRecordParameters(ctx.trigger);
|
|
980
1108
|
return recordParams.length === 1
|
|
@@ -993,7 +1121,11 @@ function triggerRefPath(path, ctx) {
|
|
|
993
1121
|
return names;
|
|
994
1122
|
return recordFieldRefPath(wireName, ctx) ?? names;
|
|
995
1123
|
}
|
|
996
|
-
function
|
|
1124
|
+
function forEachItemOwnerRefName(loop, ctx) {
|
|
1125
|
+
const collection = loop === undefined ? undefined : resourceRef(loop.attrs.list);
|
|
1126
|
+
return collection === undefined ? undefined : ctx.taskTargetOwnerRefNameByAddress?.get(`${collection.type}.${collection.label}`);
|
|
1127
|
+
}
|
|
1128
|
+
function forEachItemRefPath(path, ctx, loop) {
|
|
997
1129
|
const names = pathNames(path);
|
|
998
1130
|
if (names.length !== 1)
|
|
999
1131
|
return names.flatMap((segment) => segment.split("."));
|
|
@@ -1004,7 +1136,9 @@ function forEachItemRefPath(path, ctx) {
|
|
|
1004
1136
|
if (wireName === "Record")
|
|
1005
1137
|
return ["recordId"];
|
|
1006
1138
|
const wireNameLower = wireName.toLowerCase();
|
|
1007
|
-
|
|
1139
|
+
const itemOwner = forEachItemOwnerRefName(loop, ctx);
|
|
1140
|
+
const ownFields = itemOwner === undefined || itemOwner === ctx.appRefName ? ctx.fieldById.values() : [];
|
|
1141
|
+
for (const field of ownFields) {
|
|
1008
1142
|
// Some provider paths already contain the stable EDK field key (for
|
|
1009
1143
|
// example `for_each.<task-id>.productId`), while inner.refs uses the
|
|
1010
1144
|
// display name in other workflow shapes. Accept both forms.
|
|
@@ -1212,11 +1346,11 @@ function decodeReferenceString(value, ctx) {
|
|
|
1212
1346
|
return decodeTaskReferenceFromString(pieces[1], pieces.slice(2), ctx);
|
|
1213
1347
|
}
|
|
1214
1348
|
if (pieces[0] === "for_each" && pieces.length > 2) {
|
|
1215
|
-
const { refKey } = resolveTaskRefKey(pieces[1], ctx);
|
|
1349
|
+
const { refKey, block } = resolveTaskRefKey(pieces[1], ctx);
|
|
1216
1350
|
return {
|
|
1217
1351
|
kind: "forEachItemRef",
|
|
1218
1352
|
forEachTask: refKey,
|
|
1219
|
-
path: forEachItemRefPath(pieces.slice(2), ctx),
|
|
1353
|
+
path: forEachItemRefPath(pieces.slice(2), ctx, block),
|
|
1220
1354
|
};
|
|
1221
1355
|
}
|
|
1222
1356
|
if (pieces[0] === "variable" && pieces.length > 1) {
|
|
@@ -1356,7 +1490,7 @@ function decodeTemplateForEachRef(value, ctx) {
|
|
|
1356
1490
|
return {
|
|
1357
1491
|
kind: "forEachItemRef",
|
|
1358
1492
|
forEachTask: task.refKey,
|
|
1359
|
-
path: forEachItemRefPath(nameParts, ctx),
|
|
1493
|
+
path: forEachItemRefPath(nameParts, ctx, task.block),
|
|
1360
1494
|
};
|
|
1361
1495
|
}
|
|
1362
1496
|
/**
|
|
@@ -1368,6 +1502,12 @@ function decodeTemplateForEachRef(value, ctx) {
|
|
|
1368
1502
|
* decodeValue's generic local handling, but resolves to a triggerRef bag key
|
|
1369
1503
|
* instead of a "field" RefExpr so it stays a valid filter LHS.
|
|
1370
1504
|
*/
|
|
1505
|
+
function fieldBagKey(label, ctx) {
|
|
1506
|
+
const owned = ownerFromScopedChildLabel(label);
|
|
1507
|
+
if (owned !== undefined)
|
|
1508
|
+
return scopedLabelToBagKey(owned.ownerTfLabel, label, owned.scope);
|
|
1509
|
+
return scopedLabelToBagKey(ctx.appTfLabel, label, ctx.ownerScope);
|
|
1510
|
+
}
|
|
1371
1511
|
/**
|
|
1372
1512
|
* A field id under an on-demand record input belongs to that input's target
|
|
1373
1513
|
* (its `default_value`). Another app's or element's field decodes only when its
|
|
@@ -1399,7 +1539,7 @@ function fieldKeyOnRecordParameterTarget(fieldPart, target, ctx) {
|
|
|
1399
1539
|
}
|
|
1400
1540
|
function fieldKeyFromTriggerFieldIdExpr(fieldPart, ctx) {
|
|
1401
1541
|
if (fieldPart.$expr === "resource-attr" && fieldPart.type.endsWith("_field") && fieldPart.path[0] === "id") {
|
|
1402
|
-
return
|
|
1542
|
+
return fieldBagKey(fieldPart.label, ctx);
|
|
1403
1543
|
}
|
|
1404
1544
|
if (fieldPart.$expr === "local") {
|
|
1405
1545
|
const prefix = `${ctx.appTfLabel}_`;
|
|
@@ -1563,6 +1703,11 @@ function userIdDefault(value, ctx) {
|
|
|
1563
1703
|
return decoded?.kind === "user" ? decoded : value;
|
|
1564
1704
|
}
|
|
1565
1705
|
function decodeValue(value, ctx) {
|
|
1706
|
+
if (ctx.trigger.type === "elementum_attachment_added_trigger") {
|
|
1707
|
+
const payloadKey = parseTriggerAttachmentPayloadRefJson(isTfExpr(value) && value.$expr === "jsonencode" ? JSON.stringify(value.value) : value);
|
|
1708
|
+
if (payloadKey !== undefined)
|
|
1709
|
+
return { kind: "triggerRef", path: ["attachment", payloadKey] };
|
|
1710
|
+
}
|
|
1566
1711
|
if (isTfExpr(value)) {
|
|
1567
1712
|
if (value.$expr === "template") {
|
|
1568
1713
|
return { kind: "template", parts: value.parts.map((part) => typeof part === "string" ? part : decodeValue(part, ctx)) };
|
|
@@ -1581,7 +1726,7 @@ function decodeValue(value, ctx) {
|
|
|
1581
1726
|
return {
|
|
1582
1727
|
kind: "forEachItemRef",
|
|
1583
1728
|
forEachTask: task.refKey,
|
|
1584
|
-
path: forEachItemRefPath(value.path.slice(2), ctx),
|
|
1729
|
+
path: forEachItemRefPath(value.path.slice(2), ctx, task.block),
|
|
1585
1730
|
};
|
|
1586
1731
|
}
|
|
1587
1732
|
if (task !== undefined && value.path[0] === "refs") {
|
|
@@ -1691,7 +1836,7 @@ function decodeValue(value, ctx) {
|
|
|
1691
1836
|
return {
|
|
1692
1837
|
kind: "field",
|
|
1693
1838
|
appHandle: ctx.appRefName,
|
|
1694
|
-
fieldKey:
|
|
1839
|
+
fieldKey: fieldBagKey(value.label, ctx),
|
|
1695
1840
|
};
|
|
1696
1841
|
}
|
|
1697
1842
|
if (value.type === AUTOMATION_RESOURCE_TYPE && value.path[0] === "id") {
|
|
@@ -1702,13 +1847,13 @@ function decodeValue(value, ctx) {
|
|
|
1702
1847
|
};
|
|
1703
1848
|
}
|
|
1704
1849
|
if (value.type === "elementum_agent" && value.path[0] === "id") {
|
|
1705
|
-
return { kind: "agent", appHandle: ctx.appRefName, agentKey: scopedLabelToBagKey(ctx.appTfLabel, value.label), name: value.label };
|
|
1850
|
+
return { kind: "agent", appHandle: ctx.appRefName, agentKey: scopedLabelToBagKey(ctx.appTfLabel, value.label, ctx.ownerScope), name: value.label };
|
|
1706
1851
|
}
|
|
1707
1852
|
if (value.type === "elementum_phone_service" && value.path[0] === "id") {
|
|
1708
1853
|
return {
|
|
1709
1854
|
kind: "phoneService",
|
|
1710
1855
|
appHandle: ctx.appRefName,
|
|
1711
|
-
phoneServiceKey: scopedLabelToBagKey(ctx.appTfLabel, value.label),
|
|
1856
|
+
phoneServiceKey: scopedLabelToBagKey(ctx.appTfLabel, value.label, ctx.ownerScope),
|
|
1712
1857
|
};
|
|
1713
1858
|
}
|
|
1714
1859
|
if (value.type === TABLE_RESOURCE_TYPE && value.path[0] === "id") {
|
|
@@ -1746,7 +1891,7 @@ function decodeValue(value, ctx) {
|
|
|
1746
1891
|
return {
|
|
1747
1892
|
kind: "documentModel",
|
|
1748
1893
|
appHandle: ctx.appRefName,
|
|
1749
|
-
documentModelKey: scopedLabelToBagKey(ctx.appTfLabel, value.label),
|
|
1894
|
+
documentModelKey: scopedLabelToBagKey(ctx.appTfLabel, value.label, ctx.ownerScope),
|
|
1750
1895
|
};
|
|
1751
1896
|
}
|
|
1752
1897
|
if (value.type === "elementum_approval_process" && value.path[0] === "id") {
|
|
@@ -1757,7 +1902,7 @@ function decodeValue(value, ctx) {
|
|
|
1757
1902
|
return {
|
|
1758
1903
|
kind: "approvalChain",
|
|
1759
1904
|
appHandle: ctx.appRefName,
|
|
1760
|
-
approvalChainKey: scopedLabelToBagKey(ctx.appTfLabel, value.label),
|
|
1905
|
+
approvalChainKey: scopedLabelToBagKey(ctx.appTfLabel, value.label, ctx.ownerScope),
|
|
1761
1906
|
};
|
|
1762
1907
|
}
|
|
1763
1908
|
if ((value.type === SEARCH_TABLE_RESOURCE_TYPES.snowflake ||
|
|
@@ -1808,11 +1953,13 @@ function decodeValue(value, ctx) {
|
|
|
1808
1953
|
const mappedHandle = typeof name === "string"
|
|
1809
1954
|
? (value.type === "elementum_task" ? ctx.foreignTaskRefNames : value.type === "elementum_element" ? ctx.foreignElementRefNames : ctx.foreignAppRefNames)?.get(name)
|
|
1810
1955
|
: undefined;
|
|
1956
|
+
const namespace = lookup?.attrs.namespace;
|
|
1811
1957
|
return {
|
|
1812
1958
|
kind: "app",
|
|
1813
1959
|
appHandle: mappedHandle ?? tfLabelToTsLabel(value.label),
|
|
1814
1960
|
entityType: value.type === "elementum_task" ? "task" : value.type === "elementum_element" ? "element" : "app",
|
|
1815
1961
|
...(typeof name === "string" ? { name } : {}),
|
|
1962
|
+
...(typeof namespace === "string" && namespace !== "" ? { namespace } : {}),
|
|
1816
1963
|
};
|
|
1817
1964
|
}
|
|
1818
1965
|
if (value.$expr === "data-attr" && value.type === AUTOMATION_RESOURCE_TYPE && value.path[0] === "id") {
|
|
@@ -1951,6 +2098,25 @@ function decodeValue(value, ctx) {
|
|
|
1951
2098
|
}
|
|
1952
2099
|
return { kind: "user", email };
|
|
1953
2100
|
}
|
|
2101
|
+
if (value.$expr === "data-attr" && value.type === "elementum_vault_entry" && value.path[0] === "value_reference") {
|
|
2102
|
+
const key = ctx.dataBlocks.get(`${value.type}.${value.label}`)?.attrs.key;
|
|
2103
|
+
if (typeof key !== "string" || key === "") {
|
|
2104
|
+
throw new EntityTfError(`data.elementum_vault_entry.${value.label}: key lookup is missing`);
|
|
2105
|
+
}
|
|
2106
|
+
return { kind: "secret", key };
|
|
2107
|
+
}
|
|
2108
|
+
if (value.$expr === "data-attr" && value.type === "elementum_group" && value.path[0] === "id") {
|
|
2109
|
+
// Static notification/add-watcher recipients (edk#1389). The export
|
|
2110
|
+
// labels recipient lookups by id, so the org.groups key is the one
|
|
2111
|
+
// org.ts assigned this name (edk#1412), else the name's sanitized key,
|
|
2112
|
+
// the way `pull org` derives it.
|
|
2113
|
+
const name = ctx.dataBlocks.get(`${value.type}.${value.label}`)?.attrs.name;
|
|
2114
|
+
if (typeof name !== "string" || name === "") {
|
|
2115
|
+
throw new EntityTfError(`data.elementum_group.${value.label}: name lookup is missing`);
|
|
2116
|
+
}
|
|
2117
|
+
const groupKey = ctx.groupKeysByName?.get(name) ?? tfLabelToTsLabel(sanitizeName(name));
|
|
2118
|
+
return { kind: "orgGroup", groupKey, name };
|
|
2119
|
+
}
|
|
1954
2120
|
if (value.$expr === "variable") {
|
|
1955
2121
|
if (value.path.length !== 0) {
|
|
1956
2122
|
throw new EntityTfError(`unsupported variable reference var.${value.name}`);
|
|
@@ -2024,14 +2190,35 @@ function decodeCustomResponse(value, ctx) {
|
|
|
2024
2190
|
return undefined;
|
|
2025
2191
|
return { ...(success !== undefined ? { success } : {}), ...(failure !== undefined ? { failure } : {}) };
|
|
2026
2192
|
}
|
|
2193
|
+
/**
|
|
2194
|
+
* The managed bag key for a ref-only field lookup, matched on display name
|
|
2195
|
+
* and owner. Managed entries name the owner by its catalog ref or, when
|
|
2196
|
+
* bootstrapped from state, by the camelCase of its tf label (#1431).
|
|
2197
|
+
*/
|
|
2198
|
+
function managedFieldKeyForDisplayName(foreign, ctx) {
|
|
2199
|
+
if (foreign.fieldName === undefined)
|
|
2200
|
+
return undefined;
|
|
2201
|
+
const lower = foreign.fieldName.toLowerCase();
|
|
2202
|
+
const owners = new Set([foreign.ownerRefName]);
|
|
2203
|
+
if (foreign.ownerNamespace !== undefined && isTfLabel(foreign.ownerNamespace))
|
|
2204
|
+
owners.add(tfLabelToTsLabel(foreign.ownerNamespace));
|
|
2205
|
+
const keys = new Set();
|
|
2206
|
+
for (const [id, identity] of ctx.foreignFieldRefsById ?? []) {
|
|
2207
|
+
if (id.startsWith("refOnly:") || !owners.has(identity.ownerRefName) || identity.fieldName?.toLowerCase() !== lower)
|
|
2208
|
+
continue;
|
|
2209
|
+
keys.add(identity.fieldKey);
|
|
2210
|
+
}
|
|
2211
|
+
return keys.size === 1 ? keys.values().next().value : undefined;
|
|
2212
|
+
}
|
|
2027
2213
|
function fieldRef(value, ctx) {
|
|
2028
2214
|
if (isTfExpr(value) && value.$expr === "data-attr" && value.path.join(".") === "id") {
|
|
2029
2215
|
const foreign = ctx.foreignFieldRefsByDataAddress?.get(`${value.type}.${value.label}`);
|
|
2030
2216
|
if (foreign !== undefined) {
|
|
2217
|
+
const fieldKey = managedFieldKeyForDisplayName(foreign, ctx) ?? foreign.fieldKey;
|
|
2031
2218
|
return {
|
|
2032
2219
|
kind: "field",
|
|
2033
2220
|
appHandle: foreign.ownerRefName,
|
|
2034
|
-
fieldKey
|
|
2221
|
+
fieldKey,
|
|
2035
2222
|
...(foreign.ownerKind !== undefined || foreign.fieldName !== undefined || foreign.fieldType !== undefined
|
|
2036
2223
|
? {
|
|
2037
2224
|
foreign: {
|
|
@@ -2056,11 +2243,12 @@ function fieldRef(value, ctx) {
|
|
|
2056
2243
|
kind: "field",
|
|
2057
2244
|
appHandle: foreign.ownerRefName,
|
|
2058
2245
|
fieldKey: foreign.fieldKey,
|
|
2059
|
-
...(foreign.fieldName !== undefined || foreign.fieldType !== undefined
|
|
2246
|
+
...(foreign.ownerKind !== undefined || foreign.fieldName !== undefined || foreign.fieldType !== undefined
|
|
2060
2247
|
? {
|
|
2061
2248
|
foreign: {
|
|
2062
|
-
entityType: "app",
|
|
2063
|
-
name: foreign.ownerRefName,
|
|
2249
|
+
entityType: foreign.ownerKind ?? "app",
|
|
2250
|
+
name: foreign.ownerName ?? foreign.ownerRefName,
|
|
2251
|
+
...(foreign.ownerNamespace !== undefined ? { namespace: foreign.ownerNamespace } : {}),
|
|
2064
2252
|
...(foreign.fieldName !== undefined ? { fieldName: foreign.fieldName } : {}),
|
|
2065
2253
|
...(foreign.fieldType !== undefined ? { fieldType: foreign.fieldType } : {}),
|
|
2066
2254
|
},
|
|
@@ -2355,16 +2543,13 @@ function pulledRawCalculation(formula, outputType, multiple) {
|
|
|
2355
2543
|
return resultType === undefined ? undefined : { kind: "calculationRaw", text: formula, resultType };
|
|
2356
2544
|
}
|
|
2357
2545
|
function resolveVariableReference(rawId, rawName, outputName, ctx) {
|
|
2546
|
+
// One candidate per created variable (edk#1456: a task can create several).
|
|
2358
2547
|
const variableTasks = [];
|
|
2359
2548
|
for (const [, task] of ctx.taskByAddress) {
|
|
2360
2549
|
if (task.block.type === "elementum_variable_task") {
|
|
2361
|
-
const
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
const varId = typeof task.block.attrs.variable_id === "string"
|
|
2365
|
-
? task.block.attrs.variable_id
|
|
2366
|
-
: undefined;
|
|
2367
|
-
variableTasks.push({ refKey: task.refKey, varName, varId });
|
|
2550
|
+
for (const entry of variableTaskEntries(task.block)) {
|
|
2551
|
+
variableTasks.push({ refKey: task.refKey, varName: entry.name, ...(entry.id !== undefined ? { varId: entry.id } : {}) });
|
|
2552
|
+
}
|
|
2368
2553
|
}
|
|
2369
2554
|
}
|
|
2370
2555
|
if (variableTasks.length === 0)
|
|
@@ -2391,8 +2576,8 @@ function resolveVariableReference(rawId, rawName, outputName, ctx) {
|
|
|
2391
2576
|
}
|
|
2392
2577
|
}
|
|
2393
2578
|
// 4. The variable's real platform id is Computed on the provider, so the
|
|
2394
|
-
// static `variable_task` block does not carry `
|
|
2395
|
-
// in an EDK-only `
|
|
2579
|
+
// static `variable_task` block does not carry `variables[*].id`. Export puts them
|
|
2580
|
+
// in an EDK-only `edk_variable_ids_<label>` local (hydrated onto the block
|
|
2396
2581
|
// before this resolver runs). Without that, a workflow OUTPUT's
|
|
2397
2582
|
// `variableReference.name` is the synthetic "variable|<uuid>" placeholder,
|
|
2398
2583
|
// and #2/#3's name-based matches routinely
|
|
@@ -2404,6 +2589,7 @@ function resolveVariableReference(rawId, rawName, outputName, ctx) {
|
|
|
2404
2589
|
// "variable.<uuid>" is a DIFFERENT wire dialect with no such guarantee
|
|
2405
2590
|
// (board issue #171 contract: a filter referencing variable.<uuid> must
|
|
2406
2591
|
// NOT bind to a same-automation variable task).
|
|
2592
|
+
// One candidate means one variable in the whole automation.
|
|
2407
2593
|
if (rawId !== undefined && outputName !== undefined && variableTasks.length === 1) {
|
|
2408
2594
|
const only = variableTasks[0];
|
|
2409
2595
|
return { kind: "variableParamRef", varTask: only.refKey, name: only.varName };
|
|
@@ -2758,7 +2944,7 @@ function taskArgs(block, factory, ctx, taskDiagnostics) {
|
|
|
2758
2944
|
args.filter = decodeFilter(value, ctx, FILTER_FIELD_SCOPE_BY_FACTORY[factory] ?? "app");
|
|
2759
2945
|
continue;
|
|
2760
2946
|
}
|
|
2761
|
-
if (attr === "fields" && (factory === "createRecord" || factory === "updateField")) {
|
|
2947
|
+
if (attr === "fields" && (factory === "createRecord" || factory === "updateField" || factory === "bulkUpdateFields")) {
|
|
2762
2948
|
if (!Array.isArray(value))
|
|
2763
2949
|
throw new EntityTfError(`${block.type}.${block.label}: fields must be an array`);
|
|
2764
2950
|
const values = {};
|
|
@@ -2776,12 +2962,13 @@ function taskArgs(block, factory, ctx, taskDiagnostics) {
|
|
|
2776
2962
|
const fieldKey = field.kind === "field"
|
|
2777
2963
|
? field.fieldKey
|
|
2778
2964
|
: `${UNRESOLVED_FIELD_MARKER}${field.uuid}`;
|
|
2779
|
-
const decodedValue = decodeFieldAssignmentValue(item.value, ctx);
|
|
2965
|
+
const decodedValue = decodeFieldAssignmentValue(item.value, ctx, taskDiagnostics, `${block.type}.${block.label} field ${field.kind === "field" ? field.fieldKey : field.uuid}`);
|
|
2780
2966
|
const foreignInfo = field.kind === "field" && field.foreign !== undefined
|
|
2781
2967
|
? {
|
|
2782
2968
|
foreignFieldName: field.foreign.fieldName,
|
|
2783
2969
|
foreignEntityType: field.foreign.entityType,
|
|
2784
2970
|
foreignOwnerName: field.foreign.name,
|
|
2971
|
+
...(field.foreign.namespace !== undefined ? { foreignOwnerNamespace: field.foreign.namespace } : {}),
|
|
2785
2972
|
...(field.foreign.fieldType !== undefined ? { foreignFieldType: field.foreign.fieldType } : {}),
|
|
2786
2973
|
}
|
|
2787
2974
|
: undefined;
|
|
@@ -2833,7 +3020,15 @@ function taskArgs(block, factory, ctx, taskDiagnostics) {
|
|
|
2833
3020
|
fields.push({ alias: mapping.alias, field: fieldRef(mapping.field_id, ctx) });
|
|
2834
3021
|
}
|
|
2835
3022
|
if (fields.length > 0) {
|
|
2836
|
-
|
|
3023
|
+
// A record trigger's whole record exports as its reference JSON,
|
|
3024
|
+
// because refs["Record"] is the record ID (edk#1284). Field
|
|
3025
|
+
// mappings make it `ctx.trigger.record` again; build restores
|
|
3026
|
+
// the JSON (TRIGGER_WHOLE_RECORD_MARKER).
|
|
3027
|
+
const wholeRecord = parseTriggerWholeRecordRefJson(item.value);
|
|
3028
|
+
const value = wholeRecord === TRIGGER_WHOLE_RECORD_REF_NAME && ctx.trigger.type !== "elementum_on_demand_trigger"
|
|
3029
|
+
? { kind: "triggerRef", path: [TRIGGER_WHOLE_RECORD_REF_NAME] }
|
|
3030
|
+
: decodedValue;
|
|
3031
|
+
return [item.name, { __edkExecuteScriptListInput: true, value, fields }];
|
|
2837
3032
|
}
|
|
2838
3033
|
}
|
|
2839
3034
|
return [item.name, decodedValue];
|
|
@@ -2844,8 +3039,8 @@ function taskArgs(block, factory, ctx, taskDiagnostics) {
|
|
|
2844
3039
|
const raw = isTfExpr(value) && value.$expr === "jsonencode" ? value.value : value;
|
|
2845
3040
|
const root = isObject(raw) && isObject(raw.object) ? raw.object : undefined;
|
|
2846
3041
|
const props = Array.isArray(root?.properties) ? root.properties : [];
|
|
2847
|
-
//
|
|
2848
|
-
//
|
|
3042
|
+
// Export and import collapse an identical repeat of a property, but keep
|
|
3043
|
+
// a name listed twice with different shapes. The public `outputs`
|
|
2849
3044
|
// option is keyed by name and cannot carry the repeat, so keep the
|
|
2850
3045
|
// FIRST occurrence (position and type) and report the collapse: the
|
|
2851
3046
|
// rebuilt schema no longer matches live. The provider refreshes
|
|
@@ -2967,6 +3162,17 @@ function taskArgs(block, factory, ctx, taskDiagnostics) {
|
|
|
2967
3162
|
});
|
|
2968
3163
|
continue;
|
|
2969
3164
|
}
|
|
3165
|
+
if (attr === "output_mappings" && factory === "runAutomation") {
|
|
3166
|
+
if (!Array.isArray(value))
|
|
3167
|
+
throw new EntityTfError(`${block.type}.${block.label}: output_mappings must be an array`);
|
|
3168
|
+
args.outputs = value.map((item) => {
|
|
3169
|
+
if (!isObject(item) || typeof item.name !== "string") {
|
|
3170
|
+
throw new EntityTfError(`${block.type}.${block.label}: invalid output mapping`);
|
|
3171
|
+
}
|
|
3172
|
+
return item.name;
|
|
3173
|
+
});
|
|
3174
|
+
continue;
|
|
3175
|
+
}
|
|
2970
3176
|
// `file_reader_id` resolves to a real `documentModel` RefExpr only
|
|
2971
3177
|
// through decodeValue's resource-attr branch (an implemented reader
|
|
2972
3178
|
// type's own resource block in this export). When ei instead emits a
|
|
@@ -3100,7 +3306,7 @@ function taskArgs(block, factory, ctx, taskDiagnostics) {
|
|
|
3100
3306
|
continue;
|
|
3101
3307
|
}
|
|
3102
3308
|
if (attr === "list" && factory === "forEach") {
|
|
3103
|
-
args.collection =
|
|
3309
|
+
args.collection = decodeValueOrStringifiedRef(value, ctx, taskDiagnostics, `${block.type}.${block.label} list`);
|
|
3104
3310
|
continue;
|
|
3105
3311
|
}
|
|
3106
3312
|
if (attr === "code" && factory === "executeScript") {
|
|
@@ -3181,7 +3387,7 @@ function taskArgs(block, factory, ctx, taskDiagnostics) {
|
|
|
3181
3387
|
// the wire (relate_to_record_reference) - its presence alone implies
|
|
3182
3388
|
// relateToRecord: true (the provider has no separate boolean attribute).
|
|
3183
3389
|
if (attr === "relate_to_record_reference" && factory === "createRecord") {
|
|
3184
|
-
args.record =
|
|
3390
|
+
args.record = decodeValueOrStringifiedRef(value, ctx, taskDiagnostics, `${block.type}.${block.label} relate_to_record_reference`);
|
|
3185
3391
|
args.relateToRecord = true;
|
|
3186
3392
|
continue;
|
|
3187
3393
|
}
|
|
@@ -3207,11 +3413,25 @@ function taskArgs(block, factory, ctx, taskDiagnostics) {
|
|
|
3207
3413
|
if (!isObject(value))
|
|
3208
3414
|
throw new EntityTfError(`${block.type}.${block.label}: basic_auth must be an object`);
|
|
3209
3415
|
args.basicAuth = {
|
|
3210
|
-
|
|
3416
|
+
// reference_username is a vault-bound username; it authors back as
|
|
3417
|
+
// username: secret("KEY") (edk#1283).
|
|
3418
|
+
username: decodeValue((value.reference_username ?? value.username_wo ?? value.username), ctx),
|
|
3211
3419
|
...(value.reference_password !== undefined ? { referencePassword: decodeValue(value.reference_password, ctx) } : {}),
|
|
3212
3420
|
};
|
|
3213
3421
|
continue;
|
|
3214
3422
|
}
|
|
3423
|
+
if (attr === "headers" && factory === "apiRequest" && Array.isArray(value)) {
|
|
3424
|
+
// value_wo (write-only, edk#1400) authors back as the header's value.
|
|
3425
|
+
args.headers = value.map((h) => {
|
|
3426
|
+
if (!isObject(h))
|
|
3427
|
+
throw new EntityTfError(`${block.type}.${block.label}: invalid header`);
|
|
3428
|
+
return {
|
|
3429
|
+
name: decodeValue(h.name, ctx),
|
|
3430
|
+
value: decodeValue((h.value_wo ?? h.value), ctx),
|
|
3431
|
+
};
|
|
3432
|
+
});
|
|
3433
|
+
continue;
|
|
3434
|
+
}
|
|
3215
3435
|
if (attr === "bearer_auth" && factory === "apiRequest") {
|
|
3216
3436
|
if (!isObject(value))
|
|
3217
3437
|
throw new EntityTfError(`${block.type}.${block.label}: bearer_auth must be an object`);
|
|
@@ -3234,8 +3454,14 @@ function taskArgs(block, factory, ctx, taskDiagnostics) {
|
|
|
3234
3454
|
args.oauth = {
|
|
3235
3455
|
requestType: value.request_type,
|
|
3236
3456
|
...(value.url !== undefined ? { url: decodeValue(value.url, ctx) } : {}),
|
|
3237
|
-
|
|
3238
|
-
|
|
3457
|
+
// reference_client_id/reference_client_secret are vault-bound and
|
|
3458
|
+
// author back as secret("KEY") (edk#1283).
|
|
3459
|
+
...(value.reference_client_id !== undefined
|
|
3460
|
+
? { clientId: decodeValue(value.reference_client_id, ctx) }
|
|
3461
|
+
: value.client_id !== undefined ? { clientId: value.client_id } : {}),
|
|
3462
|
+
...(value.reference_client_secret !== undefined
|
|
3463
|
+
? { clientSecret: decodeValue(value.reference_client_secret, ctx) }
|
|
3464
|
+
: value.client_secret !== undefined ? { clientSecret: value.client_secret } : {}),
|
|
3239
3465
|
...(headers !== undefined ? { headers } : {}),
|
|
3240
3466
|
};
|
|
3241
3467
|
continue;
|
|
@@ -3294,9 +3520,11 @@ function taskArgs(block, factory, ctx, taskDiagnostics) {
|
|
|
3294
3520
|
continue;
|
|
3295
3521
|
}
|
|
3296
3522
|
const arg = ATTR_TO_ARG[attr] ?? attr.replace(/_([a-z])/g, (_, char) => char.toUpperCase());
|
|
3297
|
-
args[arg] =
|
|
3523
|
+
args[arg] = (attr === "record_reference" || attr === "record_id") && (factory === "createRecord" || factory === "updateField")
|
|
3524
|
+
? decodeValueOrStringifiedRef(value, ctx, taskDiagnostics, `${block.type}.${block.label} ${attr}`)
|
|
3525
|
+
: decodeValue(value, ctx);
|
|
3298
3526
|
}
|
|
3299
|
-
if (["recordSearch", "createRecord", "updateField"].includes(factory))
|
|
3527
|
+
if (["recordSearch", "createRecord", "updateField", "bulkUpdateFields"].includes(factory))
|
|
3300
3528
|
args.app ??= appRef(ctx.appRefName);
|
|
3301
3529
|
if (factory === "findRelatedRecords") {
|
|
3302
3530
|
args.relatedApp = args.app ?? appRef(ctx.appRefName);
|
|
@@ -3315,15 +3543,28 @@ function taskArgs(block, factory, ctx, taskDiagnostics) {
|
|
|
3315
3543
|
}
|
|
3316
3544
|
}
|
|
3317
3545
|
if (factory === "setVariable") {
|
|
3318
|
-
|
|
3319
|
-
|
|
3320
|
-
|
|
3321
|
-
|
|
3322
|
-
|
|
3323
|
-
|
|
3324
|
-
|
|
3325
|
-
|
|
3326
|
-
|
|
3546
|
+
// edk#1456: elementum_variable_task carries `variables` (creates) and
|
|
3547
|
+
// optionally `updates`; elementum_update_variable_task carries `updates`.
|
|
3548
|
+
// The provider's update attribute is variable_reference; the AST/authoring
|
|
3549
|
+
// key stays "variable" (SetVariableOptions.update[].variable).
|
|
3550
|
+
const create = block.type === "elementum_variable_task"
|
|
3551
|
+
? variableTaskEntries(block).map((entry) => ({
|
|
3552
|
+
name: entry.name,
|
|
3553
|
+
type: entry.type,
|
|
3554
|
+
...(entry.value !== undefined ? { value: decodeValue(entry.value, ctx) } : {}),
|
|
3555
|
+
}))
|
|
3556
|
+
: [];
|
|
3557
|
+
if (block.type === "elementum_variable_task" && create.length === 0)
|
|
3558
|
+
throw new EntityTfError("variable task is incomplete");
|
|
3559
|
+
const rawUpdates = Array.isArray(block.attrs.updates) ? block.attrs.updates : [];
|
|
3560
|
+
const update = rawUpdates.map((item) => {
|
|
3561
|
+
if (!isObject(item))
|
|
3562
|
+
throw new EntityTfError("variable task update is incomplete");
|
|
3563
|
+
return { variable: decodeValue(item.variable_reference, ctx), value: decodeValue(item.value, ctx) };
|
|
3564
|
+
});
|
|
3565
|
+
if (create.length === 0 && update.length === 0)
|
|
3566
|
+
throw new EntityTfError("update variable task is incomplete");
|
|
3567
|
+
return { ...(create.length > 0 ? { create } : {}), ...(update.length > 0 ? { update } : {}) };
|
|
3327
3568
|
}
|
|
3328
3569
|
return args;
|
|
3329
3570
|
}
|
|
@@ -3398,12 +3639,11 @@ function taskRefKey(block, automationLabel, appTfLabel) {
|
|
|
3398
3639
|
// keys them by the variable they create. Restrict this reconciliation to
|
|
3399
3640
|
// that positional export shape: named tasks such as "set_variable_task"
|
|
3400
3641
|
// remain valid action identities used by workflow outputs.
|
|
3401
|
-
|
|
3402
|
-
|
|
3403
|
-
block.attrs.variable_name !== "" &&
|
|
3642
|
+
const soleVariable = soleVariableName(block);
|
|
3643
|
+
if (soleVariable !== undefined &&
|
|
3404
3644
|
/(?:\s|-)\d+$/.test(taskName.trim()) &&
|
|
3405
3645
|
(sanitized === tail || sanitized === `_${tail}`)) {
|
|
3406
|
-
return
|
|
3646
|
+
return soleVariable;
|
|
3407
3647
|
}
|
|
3408
3648
|
// ei sanitizes `<automation>_<task>` as ONE combined string
|
|
3409
3649
|
// (imports.go), so the digit-leading guard only ever sees the
|
|
@@ -3442,7 +3682,8 @@ export function automationOwnedAddresses(doc, automationLabel) {
|
|
|
3442
3682
|
const owned = new Set([`${AUTOMATION_RESOURCE_TYPE}.${automationLabel}`]);
|
|
3443
3683
|
for (const block of doc.blocks) {
|
|
3444
3684
|
if (block.kind === "resource" && block.type !== undefined && block.label !== undefined &&
|
|
3445
|
-
references(block.attrs.automation, AUTOMATION_RESOURCE_TYPE, automationLabel)
|
|
3685
|
+
(references(block.attrs.automation, AUTOMATION_RESOURCE_TYPE, automationLabel) ||
|
|
3686
|
+
references(block.attrs.automation_id, AUTOMATION_RESOURCE_TYPE, automationLabel))) {
|
|
3446
3687
|
owned.add(`${block.type}.${block.label}`);
|
|
3447
3688
|
}
|
|
3448
3689
|
}
|
|
@@ -3464,30 +3705,61 @@ export function automationOwnedAddresses(doc, automationLabel) {
|
|
|
3464
3705
|
}
|
|
3465
3706
|
return [...owned];
|
|
3466
3707
|
}
|
|
3467
|
-
const
|
|
3468
|
-
/** Pull-only: computed
|
|
3708
|
+
const EDK_VARIABLE_IDS_LOCAL_PREFIX = "edk_variable_ids_";
|
|
3709
|
+
/** Pull-only: the computed variables[*].id cannot live on the resource config. */
|
|
3469
3710
|
function exportedVariableIdsByTaskLabel(doc) {
|
|
3470
3711
|
const ids = new Map();
|
|
3471
3712
|
for (const block of doc.blocks) {
|
|
3472
3713
|
if (block.kind !== "locals")
|
|
3473
3714
|
continue;
|
|
3474
3715
|
for (const [key, value] of Object.entries(block.attrs)) {
|
|
3475
|
-
if (key.startsWith(
|
|
3476
|
-
ids.set(key.slice(
|
|
3716
|
+
if (key.startsWith(EDK_VARIABLE_IDS_LOCAL_PREFIX) && Array.isArray(value)) {
|
|
3717
|
+
ids.set(key.slice(EDK_VARIABLE_IDS_LOCAL_PREFIX.length), value.map((id) => (typeof id === "string" ? id : "")));
|
|
3477
3718
|
}
|
|
3478
3719
|
}
|
|
3479
3720
|
}
|
|
3480
3721
|
return ids;
|
|
3481
3722
|
}
|
|
3723
|
+
/** Hydrates each exported variable id onto its `variables` entry, by position. */
|
|
3482
3724
|
function withExportedVariableId(block, ids) {
|
|
3483
|
-
if (block.type !== "elementum_variable_task" || block.label === undefined)
|
|
3484
|
-
return block;
|
|
3485
|
-
if (typeof block.attrs.variable_id === "string" && block.attrs.variable_id !== "")
|
|
3725
|
+
if (block.type !== "elementum_variable_task" || block.label === undefined || !Array.isArray(block.attrs.variables))
|
|
3486
3726
|
return block;
|
|
3487
3727
|
const exported = ids.get(block.label);
|
|
3488
3728
|
if (exported === undefined)
|
|
3489
3729
|
return block;
|
|
3490
|
-
|
|
3730
|
+
const variables = block.attrs.variables.map((entry, index) => {
|
|
3731
|
+
const id = exported[index];
|
|
3732
|
+
if (!isObject(entry))
|
|
3733
|
+
return entry;
|
|
3734
|
+
const object = entry;
|
|
3735
|
+
if (id === undefined || id === "" || (typeof object.id === "string" && object.id !== ""))
|
|
3736
|
+
return entry;
|
|
3737
|
+
return { ...object, id };
|
|
3738
|
+
});
|
|
3739
|
+
return { ...block, attrs: { ...block.attrs, variables } };
|
|
3740
|
+
}
|
|
3741
|
+
/** The created variables of an elementum_variable_task block, in order (edk#1456). */
|
|
3742
|
+
function variableTaskEntries(block) {
|
|
3743
|
+
if (block.type !== "elementum_variable_task" || !Array.isArray(block.attrs.variables))
|
|
3744
|
+
return [];
|
|
3745
|
+
return block.attrs.variables.flatMap((entry) => {
|
|
3746
|
+
if (!isObject(entry) || typeof entry.name !== "string" || typeof entry.type !== "string") {
|
|
3747
|
+
throw new EntityTfError(`${block.type}.${block.label}: variable entry is incomplete`);
|
|
3748
|
+
}
|
|
3749
|
+
return [{
|
|
3750
|
+
name: entry.name,
|
|
3751
|
+
type: entry.type,
|
|
3752
|
+
...(entry.value !== undefined && entry.value !== null ? { value: entry.value } : {}),
|
|
3753
|
+
...(typeof entry.id === "string" && entry.id !== "" ? { id: entry.id } : {}),
|
|
3754
|
+
}];
|
|
3755
|
+
});
|
|
3756
|
+
}
|
|
3757
|
+
/** The variable name of a variable task that creates exactly one variable. */
|
|
3758
|
+
function soleVariableName(block) {
|
|
3759
|
+
if (block.type !== "elementum_variable_task" || !Array.isArray(block.attrs.variables) || block.attrs.variables.length !== 1)
|
|
3760
|
+
return undefined;
|
|
3761
|
+
const entry = block.attrs.variables[0];
|
|
3762
|
+
return isObject(entry) && typeof entry.name === "string" && entry.name !== "" ? entry.name : undefined;
|
|
3491
3763
|
}
|
|
3492
3764
|
/**
|
|
3493
3765
|
* #1320: a task may read the current item of a loop that ENCLOSES it - the
|
|
@@ -3611,8 +3883,8 @@ export class ForEachItemOutsideLoopError extends EntityTfError {
|
|
|
3611
3883
|
this.name = "ForEachItemOutsideLoopError";
|
|
3612
3884
|
}
|
|
3613
3885
|
}
|
|
3614
|
-
/** Extract one app-owned automation graph from an ei
|
|
3615
|
-
function automationFromTfDocument(doc, automationLabel, appRefName, foreignFieldRefsById, foreignFieldRefsByDataAddress, foreignTableRefsById, picklistOptionLabelById, fieldNamesByOwnerRefName, foreignAppRefNames, foreignElementRefNames, procedureKeysByDiscriminator, foreignTaskRefNames) {
|
|
3886
|
+
/** Extract one app- or element-owned automation graph from an ei export. */
|
|
3887
|
+
function automationFromTfDocument(doc, automationLabel, appRefName, foreignFieldRefsById, foreignFieldRefsByDataAddress, foreignTableRefsById, picklistOptionLabelById, fieldNamesByOwnerRefName, foreignAppRefNames, foreignElementRefNames, procedureKeysByDiscriminator, foreignTaskRefNames, groupKeysByName) {
|
|
3616
3888
|
const automation = doc.blocks.find((block) => block.kind === "resource" && block.type === AUTOMATION_RESOURCE_TYPE && block.label === automationLabel);
|
|
3617
3889
|
if (automation === undefined)
|
|
3618
3890
|
throw new EntityTfError(`automation resource "${automationLabel}" not found`);
|
|
@@ -3626,8 +3898,12 @@ function automationFromTfDocument(doc, automationLabel, appRefName, foreignField
|
|
|
3626
3898
|
}
|
|
3627
3899
|
assertAllowed(automation, new Set(["app_id", "name", "description", "status", "triggers_other_automations", "service_account_id", "depends_on"]));
|
|
3628
3900
|
const app = resourceRef(automation.attrs.app_id);
|
|
3629
|
-
if (app === undefined ||
|
|
3630
|
-
|
|
3901
|
+
if (app === undefined ||
|
|
3902
|
+
app.path[0] !== "id" ||
|
|
3903
|
+
(app.type !== "elementum_app" && app.type !== "elementum_element")) {
|
|
3904
|
+
throw new EntityTfError(`${AUTOMATION_RESOURCE_TYPE}.${automationLabel}: app_id is not an app or element reference`);
|
|
3905
|
+
}
|
|
3906
|
+
const ownerScope = app.type === "elementum_element" ? "element" : "app";
|
|
3631
3907
|
const publish = doc.blocks.find((block) => block.kind === "resource" && block.type === WORKFLOW_PUBLISH_RESOURCE_TYPE && references(block.attrs.automation, AUTOMATION_RESOURCE_TYPE, automationLabel));
|
|
3632
3908
|
const unknownDirectChild = doc.blocks.find((block) => block.kind === "resource" &&
|
|
3633
3909
|
references(block.attrs.automation, AUTOMATION_RESOURCE_TYPE, automationLabel) &&
|
|
@@ -3744,9 +4020,7 @@ function automationFromTfDocument(doc, automationLabel, appRefName, foreignField
|
|
|
3744
4020
|
const dataBlocks = new Map(doc.blocks.filter((block) => block.kind === "data" && block.type && block.label).map((block) => [`${block.type}.${block.label}`, block]));
|
|
3745
4021
|
const taskByAddress = new Map(tasks.map((block) => [`${block.type}.${block.label}`, { block, refKey: taskRefKey(block, automationLabel, appTfLabel) }]));
|
|
3746
4022
|
const adoptionAddressAliases = [...taskByAddress.entries()].flatMap(([from, { block, refKey }]) => {
|
|
3747
|
-
if (block
|
|
3748
|
-
typeof block.attrs.variable_name !== "string" ||
|
|
3749
|
-
block.attrs.variable_name === "")
|
|
4023
|
+
if (soleVariableName(block) === undefined)
|
|
3750
4024
|
return [];
|
|
3751
4025
|
const to = `${block.type}.${taskTfLabel(automationLabel, refKey)}`;
|
|
3752
4026
|
return to === from ? [] : [{ from, to }];
|
|
@@ -3777,8 +4051,11 @@ function automationFromTfDocument(doc, automationLabel, appRefName, foreignField
|
|
|
3777
4051
|
const block = resourceBlocks.get(address);
|
|
3778
4052
|
if (block?.type?.endsWith("_field") !== true || block.label === undefined)
|
|
3779
4053
|
continue;
|
|
4054
|
+
const ownedField = ownerFromScopedChildLabel(block.label);
|
|
3780
4055
|
fieldById.set(id, {
|
|
3781
|
-
key:
|
|
4056
|
+
key: ownedField !== undefined
|
|
4057
|
+
? scopedLabelToBagKey(ownedField.ownerTfLabel, block.label, ownedField.scope)
|
|
4058
|
+
: scopedLabelToBagKey(appTfLabel, block.label, ownerScope),
|
|
3782
4059
|
name: typeof block.attrs.name === "string" ? block.attrs.name : block.label,
|
|
3783
4060
|
resourceType: block.type,
|
|
3784
4061
|
});
|
|
@@ -3794,6 +4071,7 @@ function automationFromTfDocument(doc, automationLabel, appRefName, foreignField
|
|
|
3794
4071
|
const ctx = {
|
|
3795
4072
|
appRefName,
|
|
3796
4073
|
appTfLabel: app.label,
|
|
4074
|
+
ownerScope,
|
|
3797
4075
|
trigger,
|
|
3798
4076
|
taskByAddress,
|
|
3799
4077
|
resourceBlocks,
|
|
@@ -3812,6 +4090,7 @@ function automationFromTfDocument(doc, automationLabel, appRefName, foreignField
|
|
|
3812
4090
|
...(foreignElementRefNames !== undefined && { foreignElementRefNames }),
|
|
3813
4091
|
...(foreignTaskRefNames !== undefined && { foreignTaskRefNames }),
|
|
3814
4092
|
...(procedureKeysByDiscriminator !== undefined && { procedureKeysByDiscriminator }),
|
|
4093
|
+
...(groupKeysByName !== undefined && { groupKeysByName }),
|
|
3815
4094
|
};
|
|
3816
4095
|
let serviceAccountName;
|
|
3817
4096
|
const serviceAccountValue = automation.attrs.service_account_id;
|
|
@@ -4027,15 +4306,16 @@ function automationFromTfDocument(doc, automationLabel, appRefName, foreignField
|
|
|
4027
4306
|
}),
|
|
4028
4307
|
};
|
|
4029
4308
|
}
|
|
4030
|
-
export function automationFromTf(first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth, eleventh, twelfth) {
|
|
4309
|
+
export function automationFromTf(first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth, eleventh, twelfth, thirteenth) {
|
|
4031
4310
|
if (Array.isArray(first)) {
|
|
4032
4311
|
const ctx = second;
|
|
4033
4312
|
const automationBlock = first.find((block) => block.kind === "resource" && block.type === AUTOMATION_RESOURCE_TYPE);
|
|
4034
4313
|
if (automationBlock?.label === undefined) {
|
|
4035
|
-
|
|
4314
|
+
const addresses = first.filter((block) => block.kind === "resource").map((block) => `${block.type}.${block.label}`);
|
|
4315
|
+
throw new EntityTfError(`automation graph has no ${AUTOMATION_RESOURCE_TYPE} resource, so its resources (${addresses.join(", ") || "none"}) cannot be pulled`);
|
|
4036
4316
|
}
|
|
4037
4317
|
try {
|
|
4038
|
-
const result = automationFromTfDocument({ blocks: [...first] }, automationBlock.label, ctx.ownerHandle, ctx.foreignFieldRefsById, ctx.foreignFieldRefsByDataAddress, ctx.foreignTableRefsById, ctx.picklistOptionLabelById, ctx.fieldNamesByOwnerRefName, ctx.foreignAppRefNames, ctx.foreignElementRefNames, ctx.procedureKeysByDiscriminator, ctx.foreignTaskRefNames);
|
|
4318
|
+
const result = automationFromTfDocument({ blocks: [...first] }, automationBlock.label, ctx.ownerHandle, ctx.foreignFieldRefsById, ctx.foreignFieldRefsByDataAddress, ctx.foreignTableRefsById, ctx.picklistOptionLabelById, ctx.fieldNamesByOwnerRefName, ctx.foreignAppRefNames, ctx.foreignElementRefNames, ctx.procedureKeysByDiscriminator, ctx.foreignTaskRefNames, ctx.groupKeysByName);
|
|
4039
4319
|
if (result.diagnostics)
|
|
4040
4320
|
ctx.diagnostics.push(...result.diagnostics);
|
|
4041
4321
|
return { automation: result.ast };
|
|
@@ -4048,5 +4328,5 @@ export function automationFromTf(first, second, third, fourth, fifth, sixth, sev
|
|
|
4048
4328
|
return { skippedReason: message };
|
|
4049
4329
|
}
|
|
4050
4330
|
}
|
|
4051
|
-
return automationFromTfDocument(first, second, third ?? "", fourth, fifth, sixth, seventh, eighth, ninth, tenth, eleventh, twelfth);
|
|
4331
|
+
return automationFromTfDocument(first, second, third ?? "", fourth, fifth, sixth, seventh, eighth, ninth, tenth, eleventh, twelfth, thirteenth);
|
|
4052
4332
|
}
|