@elementumai/edk 0.10.1 → 0.10.3
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 +7 -7
- package/dist-sdk/src/catalog/org.d.ts +7 -5
- package/dist-sdk/src/catalog/org.js +14 -9
- package/dist-sdk/src/catalog/token.js +4 -0
- package/dist-sdk/src/core/types/app.d.ts +22 -0
- package/dist-sdk/src/engine/build/context.d.ts +8 -0
- package/dist-sdk/src/engine/build/source-context.d.ts +3 -4
- package/dist-sdk/src/engine/coverage-gaps.d.ts +2 -0
- package/dist-sdk/src/engine/coverage-gaps.js +3 -0
- package/dist-sdk/src/engine/ei/state.d.ts +48 -0
- package/dist-sdk/src/engine/ei/state.js +91 -0
- package/dist-sdk/src/engine/pull/authored-address.d.ts +100 -0
- package/dist-sdk/src/engine/pull/authored-address.js +360 -0
- package/dist-sdk/src/engine/pull/context.d.ts +59 -0
- package/dist-sdk/src/engine/tf/expr.d.ts +7 -0
- package/dist-sdk/src/engine/tf/expr.js +62 -18
- 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 +10 -2
- package/dist-sdk/src/engine/tf/labels.js +15 -2
- package/dist-sdk/src/engine/tf/parse.js +19 -6
- package/dist-sdk/src/engine/workspace/backend.d.ts +34 -0
- package/dist-sdk/src/engine/workspace/backend.js +104 -0
- package/dist-sdk/src/engine/workspace/generated-file.d.ts +3 -0
- package/dist-sdk/src/engine/workspace/generated-file.js +6 -0
- package/dist-sdk/src/engine/workspace/loader.js +2 -2
- package/dist-sdk/src/entities/agent-tool/to-tf.js +1 -1
- package/dist-sdk/src/entities/app/build.d.ts +36 -4
- package/dist-sdk/src/entities/app/build.js +67 -4
- package/dist-sdk/src/entities/app/deserializer/normalize.d.ts +12 -0
- package/dist-sdk/src/entities/app/from-tf.js +13 -9
- package/dist-sdk/src/entities/app/module.js +3 -1
- package/dist-sdk/src/entities/app/stage-keys.d.ts +82 -0
- package/dist-sdk/src/entities/app/stage-keys.js +160 -0
- package/dist-sdk/src/entities/app/to-tf.js +21 -21
- package/dist-sdk/src/entities/approval-chain/from-tf.d.ts +9 -1
- package/dist-sdk/src/entities/approval-chain/from-tf.js +31 -3
- package/dist-sdk/src/entities/approval-chain/module.js +12 -4
- package/dist-sdk/src/entities/approval-chain/to-tf.d.ts +1 -0
- package/dist-sdk/src/entities/approval-chain/to-tf.js +6 -1
- package/dist-sdk/src/entities/automation/build.d.ts +2 -0
- package/dist-sdk/src/entities/automation/build.js +25 -17
- package/dist-sdk/src/entities/automation/deserializer/ast.d.ts +3 -0
- package/dist-sdk/src/entities/automation/deserializer/print-automation.d.ts +5 -3
- package/dist-sdk/src/entities/automation/deserializer/print-automation.js +127 -31
- package/dist-sdk/src/entities/automation/from-tf.d.ts +28 -6
- package/dist-sdk/src/entities/automation/from-tf.js +172 -27
- package/dist-sdk/src/entities/automation/module.js +123 -37
- package/dist-sdk/src/entities/automation/output-key-wire-name.d.ts +21 -0
- package/dist-sdk/src/entities/automation/output-key-wire-name.js +38 -0
- package/dist-sdk/src/entities/automation/to-tf.d.ts +3 -1
- package/dist-sdk/src/entities/automation/to-tf.js +191 -33
- package/dist-sdk/src/entities/automation/triggers.d.ts +2 -0
- package/dist-sdk/src/entities/automation/triggers.js +1 -0
- package/dist-sdk/src/entities/chart/from-tf.d.ts +6 -0
- package/dist-sdk/src/entities/chart/from-tf.js +9 -1
- package/dist-sdk/src/entities/dashboard/from-tf.js +51 -4
- package/dist-sdk/src/entities/dynamic-layout/from-tf.d.ts +3 -0
- package/dist-sdk/src/entities/dynamic-layout/from-tf.js +48 -4
- package/dist-sdk/src/entities/dynamic-layout/to-tf.d.ts +2 -0
- package/dist-sdk/src/entities/dynamic-layout/to-tf.js +7 -2
- package/dist-sdk/src/entities/element/build.js +1 -1
- package/dist-sdk/src/entities/element/from-tf.d.ts +12 -6
- package/dist-sdk/src/entities/element/from-tf.js +23 -7
- package/dist-sdk/src/entities/element/module.js +5 -3
- package/dist-sdk/src/entities/element/to-tf.d.ts +3 -2
- package/dist-sdk/src/entities/element/to-tf.js +36 -25
- package/dist-sdk/src/entities/field/allow-list.d.ts +18 -0
- package/dist-sdk/src/entities/field/allow-list.js +42 -0
- package/dist-sdk/src/entities/field/build.d.ts +38 -3
- package/dist-sdk/src/entities/field/build.js +7 -2
- package/dist-sdk/src/entities/field/from-tf.js +252 -76
- package/dist-sdk/src/entities/field/module.d.ts +6 -0
- package/dist-sdk/src/entities/field/module.js +24 -2
- package/dist-sdk/src/entities/field/options.d.ts +2 -0
- package/dist-sdk/src/entities/field/order.d.ts +25 -0
- package/dist-sdk/src/entities/field/order.js +74 -0
- package/dist-sdk/src/entities/field/to-tf.d.ts +6 -0
- package/dist-sdk/src/entities/field/to-tf.js +87 -0
- package/dist-sdk/src/entities/field/types.d.ts +5 -0
- package/dist-sdk/src/entities/field/types.js +8 -0
- package/dist-sdk/src/entities/relationship/build.d.ts +3 -3
- package/dist-sdk/src/entities/relationship/from-tf.js +4 -2
- package/dist-sdk/src/entities/relationship/to-tf.js +3 -1
- package/dist-sdk/src/entities/service-account/workspace-owner.d.ts +8 -3
- package/dist-sdk/src/entities/service-account/workspace-owner.js +12 -4
- package/dist-sdk/src/entities/shared/aspect-target-from-tf.d.ts +5 -0
- package/dist-sdk/src/entities/shared/aspect-target-from-tf.js +13 -0
- package/dist-sdk/src/entities/shared/filters/ast.d.ts +7 -0
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +1 -1
- package/dist-sdk/src/entities/skill/to-tf.js +19 -14
- package/dist-sdk/src/entities/skill-tool/from-tf.d.ts +2 -0
- package/dist-sdk/src/entities/skill-tool/from-tf.js +3 -0
- package/dist-sdk/src/entities/skill-tool/to-tf.d.ts +6 -1
- package/dist-sdk/src/entities/skill-tool/to-tf.js +6 -1
- package/dist-sdk/src/entities/task/build.js +1 -1
- package/dist-sdk/src/entities/task/module.js +2 -1
- package/dist-sdk/src/entities/task/to-tf.js +4 -0
- package/dist-sdk/src/entities/view/agent-view-layout-to-tf.d.ts +11 -0
- package/dist-sdk/src/entities/view/agent-view-layout-to-tf.js +13 -38
- package/dist-sdk/src/entities/view/custom-view-validate.d.ts +29 -0
- package/dist-sdk/src/entities/view/custom-view-validate.js +292 -0
- package/dist-sdk/src/entities/view/from-tf.d.ts +2 -0
- package/dist-sdk/src/entities/view/from-tf.js +40 -6
- package/dist-sdk/src/entities/view/module.js +4 -1
- package/dist-sdk/src/entities/view/to-tf.d.ts +6 -0
- package/dist-sdk/src/entities/view/to-tf.js +25 -9
- package/dist-sdk/src/entities/view/types.d.ts +6 -0
- package/dist-sdk/src/entities/view/types.js +6 -0
- package/dist-sdk/src/entities/visual-flow/from-tf.d.ts +2 -1
- package/dist-sdk/src/entities/visual-flow/from-tf.js +11 -2
- package/dist-sdk/src/entities/visual-flow/module.js +15 -5
- package/dist-sdk/src/entities/visual-flow/to-tf.d.ts +2 -0
- package/dist-sdk/src/entities/visual-flow/to-tf.js +1 -1
- package/dist-sdk/src/entities/widget/build.d.ts +8 -1
- package/dist-sdk/src/entities/widget/from-tf.js +12 -6
- package/dist-sdk/src/entities/widget/to-tf.d.ts +1 -0
- package/dist-sdk/src/entities/widget/to-tf.js +16 -0
- package/dist-sdk/src/generated/ragnarok/ragnarok-spec.d.ts +8 -2
- package/dist-sdk/src/generated/ragnarok/ragnarok-spec.js +2 -2
- package/dist-sdk/src/graph/index.d.ts +9 -2
- package/dist-sdk/src/graph/index.js +4 -0
- package/dist-sdk/src/graph/modules.js +2 -1
- package/dist-sdk/src/graph/types.d.ts +72 -3
- package/package.json +2 -17
|
@@ -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, isTfLabel, ownerFromScopedChildLabel, sanitizeName, scopedLabelToBagKey, tfLabelToTsLabel, tsLabelToTfLabel, } from "../../engine/tf/index.js";
|
|
7
|
+
import { appResourceLabelPrefix, childPartFromScopedLabel, elementResourceLabelPrefix, isTfExpr, isTfLabel, isUuid, 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";
|
|
@@ -14,7 +14,7 @@ import { filterFromTf as deserializeFilterFromTf } from "../shared/filters/tf-co
|
|
|
14
14
|
import { TABLE_RESOURCE_TYPE } from "../table/module.js";
|
|
15
15
|
import { SEARCH_TABLE_RESOURCE_TYPES } from "../search-table/types.js";
|
|
16
16
|
import { outputFieldTypesFromScriptSchema, repeatedScriptOutputNames, scriptOutputReferenceIsDeclared } from "./output-field-types.js";
|
|
17
|
-
import { apiTaskRefAuthoringPath, matchesOutputWireKey, OUTPUT_KEY_WIRE_NAME } from "./output-key-wire-name.js";
|
|
17
|
+
import { apiTaskRefAuthoringPath, executeScriptAuthoringPath, matchesOutputWireKey, OUTPUT_KEY_WIRE_NAME } from "./output-key-wire-name.js";
|
|
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";
|
|
@@ -597,7 +597,13 @@ const TASK_OUTPUT_LABEL_TO_TS = {
|
|
|
597
597
|
elementum_record_search_task: { "First found record": ["record"] },
|
|
598
598
|
elementum_create_record_task: { "Created record": ["record"] },
|
|
599
599
|
elementum_update_field_task: { "Updated record": ["record"] },
|
|
600
|
-
elementum_execute_script_task: {
|
|
600
|
+
elementum_execute_script_task: {
|
|
601
|
+
// Display keys. Canonical `result` / `stringArrayResult` are not refs keys;
|
|
602
|
+
// `Result` is the whole JSON envelope, not a property named Result (#1656).
|
|
603
|
+
Result: ["result"],
|
|
604
|
+
"Text Result": ["textResult"],
|
|
605
|
+
"Text List Result": ["stringArrayResult"],
|
|
606
|
+
},
|
|
601
607
|
elementum_user_search_task: {
|
|
602
608
|
"Users Size": ["count"],
|
|
603
609
|
"User's Id": ["user", "id"],
|
|
@@ -978,9 +984,11 @@ function decodeStringifiedValueReference(value, ctx, diagnostics, where) {
|
|
|
978
984
|
found = true;
|
|
979
985
|
if (start > cursor)
|
|
980
986
|
parts.push(value.slice(cursor, start));
|
|
981
|
-
const reference = decodeFilterReferenceEnvelope(parsed, ctx);
|
|
982
|
-
if (reference === undefined ||
|
|
987
|
+
const reference = decodeFilterReferenceEnvelope(parsed, ctx, undefined, "envelope");
|
|
988
|
+
if (reference === undefined || stringifiedEnvelopeCannotMatchRead(parsed, reference, ctx, where)) {
|
|
983
989
|
unresolved = true;
|
|
990
|
+
if (ctx.stringifiedValueReferences !== undefined)
|
|
991
|
+
ctx.stringifiedValueReferences.unresolved = true;
|
|
984
992
|
parts.push({ kind: "unresolved", uuid: value.slice(start, end), hint: "value-reference (edk#1646)" });
|
|
985
993
|
}
|
|
986
994
|
else {
|
|
@@ -1027,6 +1035,69 @@ function stringifiedReferenceResolves(envelope, reference, ctx) {
|
|
|
1027
1035
|
}
|
|
1028
1036
|
return true;
|
|
1029
1037
|
}
|
|
1038
|
+
/**
|
|
1039
|
+
* A stringified envelope is safe to adopt only when a rebuilt ctx ref matches
|
|
1040
|
+
* what provider Read stores. "The task exists" is not that test: an undeclared
|
|
1041
|
+
* script output rebuilds as TEXT, and an envelope whose fieldType or multiple
|
|
1042
|
+
* is not the type build infers would plan an update after Read (#1858).
|
|
1043
|
+
*/
|
|
1044
|
+
function stringifiedEnvelopeCannotMatchRead(envelope, reference, ctx, where) {
|
|
1045
|
+
if (!stringifiedReferenceResolves(envelope, reference, ctx))
|
|
1046
|
+
return true;
|
|
1047
|
+
if (reference.kind === "taskRef" && reference.undeclaredScriptOutput === true)
|
|
1048
|
+
return true;
|
|
1049
|
+
if (typeof envelope.fieldType !== "string")
|
|
1050
|
+
return false;
|
|
1051
|
+
// record_reference / record_id Read as ASPECT_RECORD_ID. An envelope that
|
|
1052
|
+
// still says TEXT (or anything else) rebuilds as the wrong type (#1858).
|
|
1053
|
+
if ((where.endsWith("record_reference") || where.endsWith("record_id")) &&
|
|
1054
|
+
envelope.fieldType !== "ASPECT_RECORD_ID")
|
|
1055
|
+
return true;
|
|
1056
|
+
const inferred = inferredPublishOutputType(envelope, ctx);
|
|
1057
|
+
const multiple = envelope.multiple === true;
|
|
1058
|
+
return inferred.fieldType !== envelope.fieldType || inferred.multiple !== multiple;
|
|
1059
|
+
}
|
|
1060
|
+
/**
|
|
1061
|
+
* An on-demand parameter exported as a trigger envelope because a record
|
|
1062
|
+
* field owns its display name. Both the quoted JSON string and the
|
|
1063
|
+
* jsonencode form decode to the declared parameter.
|
|
1064
|
+
*/
|
|
1065
|
+
function shadowedOnDemandParamFromEnvelope(value, ctx) {
|
|
1066
|
+
if (ctx.trigger.type !== "elementum_on_demand_trigger")
|
|
1067
|
+
return undefined;
|
|
1068
|
+
const raw = isTfExpr(value) && value.$expr === "jsonencode" ? value.value : value;
|
|
1069
|
+
let parsed = raw;
|
|
1070
|
+
if (typeof raw === "string") {
|
|
1071
|
+
if (!raw.startsWith("{"))
|
|
1072
|
+
return undefined;
|
|
1073
|
+
try {
|
|
1074
|
+
parsed = JSON.parse(raw);
|
|
1075
|
+
}
|
|
1076
|
+
catch {
|
|
1077
|
+
return undefined;
|
|
1078
|
+
}
|
|
1079
|
+
}
|
|
1080
|
+
if (!isObject(parsed) || !isObject(parsed.triggerReference) || typeof parsed.triggerReference.name !== "string") {
|
|
1081
|
+
return undefined;
|
|
1082
|
+
}
|
|
1083
|
+
if (isObject(parsed.taskReference) || isObject(parsed.variableReference) || isObject(parsed.forEachReference)) {
|
|
1084
|
+
return undefined;
|
|
1085
|
+
}
|
|
1086
|
+
const wireName = parsed.triggerReference.name;
|
|
1087
|
+
if (wireName.startsWith("record."))
|
|
1088
|
+
return undefined;
|
|
1089
|
+
const declared = isDeclaredOnDemandParameter(ctx.trigger, wireName)
|
|
1090
|
+
? wireName
|
|
1091
|
+
: declaredOnDemandInputForWireName(ctx.trigger, wireName);
|
|
1092
|
+
if (declared === undefined)
|
|
1093
|
+
return undefined;
|
|
1094
|
+
const parameter = Array.isArray(ctx.trigger.attrs.parameters)
|
|
1095
|
+
? ctx.trigger.attrs.parameters.find((candidate) => isObject(candidate) && candidate.name === declared)
|
|
1096
|
+
: undefined;
|
|
1097
|
+
if (!isObject(parameter) || parameter.type === "record" || parameter.type === "user")
|
|
1098
|
+
return undefined;
|
|
1099
|
+
return declared;
|
|
1100
|
+
}
|
|
1030
1101
|
/** decodeValue, upgrading a stringified ValueReference envelope (edk#1646). */
|
|
1031
1102
|
function decodeValueOrStringifiedRef(value, ctx, diagnostics, where) {
|
|
1032
1103
|
if (typeof value === "string") {
|
|
@@ -1036,6 +1107,17 @@ function decodeValueOrStringifiedRef(value, ctx, diagnostics, where) {
|
|
|
1036
1107
|
}
|
|
1037
1108
|
return decodeValue(value, ctx);
|
|
1038
1109
|
}
|
|
1110
|
+
function canonicalTriggerRecordIdSlot(value, ctx) {
|
|
1111
|
+
if ((ctx.trigger.type === "elementum_record_created_trigger" || ctx.trigger.type === "elementum_record_updated_trigger") &&
|
|
1112
|
+
isObject(value) &&
|
|
1113
|
+
value.kind === "triggerRef" &&
|
|
1114
|
+
Array.isArray(value.path) &&
|
|
1115
|
+
((value.path.length === 1 && value.path[0] === "recordId") ||
|
|
1116
|
+
(value.path.length === 2 && value.path[0] === "record" && value.path[1] === "10000001-2000-4000-a000-800000000000"))) {
|
|
1117
|
+
return { ...value, path: ["record"] };
|
|
1118
|
+
}
|
|
1119
|
+
return value;
|
|
1120
|
+
}
|
|
1039
1121
|
function triggerRefPath(path, ctx) {
|
|
1040
1122
|
const names = pathNames(path);
|
|
1041
1123
|
if (names.length !== 1)
|
|
@@ -1304,6 +1386,14 @@ function decodeTaskReferenceFromString(taskIdOrKey, pathSegments, ctx) {
|
|
|
1304
1386
|
return { kind: "taskRef", task: refKey, path: apiPath };
|
|
1305
1387
|
}
|
|
1306
1388
|
}
|
|
1389
|
+
// Exact contract names only. `result.passed` is two segments and stays a
|
|
1390
|
+
// property; `Result` is the whole JSON envelope (#1656).
|
|
1391
|
+
if (block?.type === "elementum_execute_script_task" && pathSegments.length === 1) {
|
|
1392
|
+
const scriptPath = executeScriptAuthoringPath(pathSegments[0]);
|
|
1393
|
+
if (scriptPath !== undefined) {
|
|
1394
|
+
return { kind: "taskRef", task: refKey, path: [...scriptPath] };
|
|
1395
|
+
}
|
|
1396
|
+
}
|
|
1307
1397
|
const keyPath = pathSegments.map((segment) => WIRE_REF_SEGMENT_TO_TS[segment] ?? segment);
|
|
1308
1398
|
const taskKind = block?.type !== undefined ? TASK_FACTORIES[block.type] : undefined;
|
|
1309
1399
|
const wireOutputKey = taskKind !== undefined ? OUTPUT_KEY_WIRE_NAME[taskKind] : undefined;
|
|
@@ -1708,6 +1798,9 @@ function decodeValue(value, ctx) {
|
|
|
1708
1798
|
if (payloadKey !== undefined)
|
|
1709
1799
|
return { kind: "triggerRef", path: ["attachment", payloadKey] };
|
|
1710
1800
|
}
|
|
1801
|
+
const shadowedParam = shadowedOnDemandParamFromEnvelope(value, ctx);
|
|
1802
|
+
if (shadowedParam !== undefined)
|
|
1803
|
+
return { kind: "triggerRef", path: [shadowedParam] };
|
|
1711
1804
|
if (isTfExpr(value)) {
|
|
1712
1805
|
if (value.$expr === "template") {
|
|
1713
1806
|
return { kind: "template", parts: value.parts.map((part) => typeof part === "string" ? part : decodeValue(part, ctx)) };
|
|
@@ -2223,6 +2316,7 @@ function fieldRef(value, ctx) {
|
|
|
2223
2316
|
? {
|
|
2224
2317
|
foreign: {
|
|
2225
2318
|
entityType: foreign.ownerKind ?? "app",
|
|
2319
|
+
...(foreign.ownerKind === undefined ? { ownerKindUnknown: true } : {}),
|
|
2226
2320
|
name: foreign.ownerName ?? foreign.ownerRefName,
|
|
2227
2321
|
...(foreign.ownerNamespace !== undefined ? { namespace: foreign.ownerNamespace } : {}),
|
|
2228
2322
|
...(foreign.fieldName !== undefined ? { fieldName: foreign.fieldName } : {}),
|
|
@@ -2247,6 +2341,7 @@ function fieldRef(value, ctx) {
|
|
|
2247
2341
|
? {
|
|
2248
2342
|
foreign: {
|
|
2249
2343
|
entityType: foreign.ownerKind ?? "app",
|
|
2344
|
+
...(foreign.ownerKind === undefined ? { ownerKindUnknown: true } : {}),
|
|
2250
2345
|
name: foreign.ownerName ?? foreign.ownerRefName,
|
|
2251
2346
|
...(foreign.ownerNamespace !== undefined ? { namespace: foreign.ownerNamespace } : {}),
|
|
2252
2347
|
...(foreign.fieldName !== undefined ? { fieldName: foreign.fieldName } : {}),
|
|
@@ -2503,6 +2598,11 @@ function decodeCalculationTaskMustache(taskId, wireName, ctx) {
|
|
|
2503
2598
|
return { kind: "taskRef", task: refKey, path: apiPath };
|
|
2504
2599
|
}
|
|
2505
2600
|
}
|
|
2601
|
+
if (taskBlock?.type === "elementum_execute_script_task") {
|
|
2602
|
+
const scriptPath = executeScriptAuthoringPath(wireName);
|
|
2603
|
+
if (scriptPath !== undefined)
|
|
2604
|
+
return { kind: "taskRef", task: refKey, path: [...scriptPath] };
|
|
2605
|
+
}
|
|
2506
2606
|
const keyPath = wireName.split(".");
|
|
2507
2607
|
const taskKind = taskBlock?.type !== undefined ? TASK_FACTORIES[taskBlock.type] : undefined;
|
|
2508
2608
|
const wireOutputKey = taskKind !== undefined ? OUTPUT_KEY_WIRE_NAME[taskKind] : undefined;
|
|
@@ -2616,12 +2716,14 @@ function decodeFilterReferenceEnvelope(value, ctx, outputName, role) {
|
|
|
2616
2716
|
: schemaValue;
|
|
2617
2717
|
const outputTypes = outputFieldTypesFromScriptSchema(schema);
|
|
2618
2718
|
const declared = scriptOutputReferenceIsDeclared(outputTypes, taskRef.name);
|
|
2619
|
-
if (
|
|
2620
|
-
if (raw.multiple === true || raw.fieldType === "DECIMAL") {
|
|
2719
|
+
if (!declared && taskRef.name.startsWith("result.")) {
|
|
2720
|
+
if (role === "left" && (raw.multiple === true || raw.fieldType === "DECIMAL")) {
|
|
2621
2721
|
throw new EntityTfError(`execute-script reference "${taskRef.name}" is absent from its output schema and its ` +
|
|
2622
2722
|
`${raw.multiple === true ? "multiple" : "DECIMAL"} envelope cannot round-trip losslessly`);
|
|
2623
2723
|
}
|
|
2624
|
-
|
|
2724
|
+
if (role === "left" || role === "envelope" || outputName !== undefined) {
|
|
2725
|
+
return { ...decoded, undeclaredScriptOutput: true };
|
|
2726
|
+
}
|
|
2625
2727
|
}
|
|
2626
2728
|
}
|
|
2627
2729
|
return decoded;
|
|
@@ -2868,7 +2970,7 @@ function triggerFromBlock(block, ctx) {
|
|
|
2868
2970
|
// approval_chain_template_id is genuinely omittable on the platform
|
|
2869
2971
|
// (edk#712) - a null/never-set template means "any", not "unresolved".
|
|
2870
2972
|
if (block.attrs.approval_chain_template_id === undefined) {
|
|
2871
|
-
return { kind, app, status: block.attrs.status };
|
|
2973
|
+
return { kind, app, status: block.attrs.status, ...(filter ? { filter } : {}) };
|
|
2872
2974
|
}
|
|
2873
2975
|
const approvalChain = typeof block.attrs.approval_chain_template_id === "string"
|
|
2874
2976
|
? block.attrs.approval_chain_template_id
|
|
@@ -2876,7 +2978,7 @@ function triggerFromBlock(block, ctx) {
|
|
|
2876
2978
|
if (typeof approvalChain !== "string" && (!isObject(approvalChain) || approvalChain.kind !== "approvalChain")) {
|
|
2877
2979
|
throw new EntityTfError("approval trigger has an unreconstructable approval chain");
|
|
2878
2980
|
}
|
|
2879
|
-
return { kind, app, approvalChain: approvalChain, status: block.attrs.status };
|
|
2981
|
+
return { kind, app, approvalChain: approvalChain, status: block.attrs.status, ...(filter ? { filter } : {}) };
|
|
2880
2982
|
}
|
|
2881
2983
|
case "dataMine":
|
|
2882
2984
|
{
|
|
@@ -2963,6 +3065,9 @@ function taskArgs(block, factory, ctx, taskDiagnostics) {
|
|
|
2963
3065
|
? field.fieldKey
|
|
2964
3066
|
: `${UNRESOLVED_FIELD_MARKER}${field.uuid}`;
|
|
2965
3067
|
const decodedValue = decodeFieldAssignmentValue(item.value, ctx, taskDiagnostics, `${block.type}.${block.label} field ${field.kind === "field" ? field.fieldKey : field.uuid}`);
|
|
3068
|
+
const canonicalValue = factory === "createRecord" || factory === "updateField"
|
|
3069
|
+
? canonicalTriggerRecordIdSlot(decodedValue, ctx)
|
|
3070
|
+
: decodedValue;
|
|
2966
3071
|
const foreignInfo = field.kind === "field" && field.foreign !== undefined
|
|
2967
3072
|
? {
|
|
2968
3073
|
foreignFieldName: field.foreign.fieldName,
|
|
@@ -2972,14 +3077,23 @@ function taskArgs(block, factory, ctx, taskDiagnostics) {
|
|
|
2972
3077
|
...(field.foreign.fieldType !== undefined ? { foreignFieldType: field.foreign.fieldType } : {}),
|
|
2973
3078
|
}
|
|
2974
3079
|
: undefined;
|
|
2975
|
-
|
|
3080
|
+
// State can rename a foreign system-field id (Title) to its key
|
|
3081
|
+
// without a field type. The target aspect may still be outside this
|
|
3082
|
+
// workspace, and a bare key then prints as null and the file will
|
|
3083
|
+
// not load. Keep the platform id so the printer can emit
|
|
3084
|
+
// unsafePlatformId, which is what an element-only pull already does.
|
|
3085
|
+
const platformFieldId = typeof item.field_id === "string" && isUuid(item.field_id) && field.kind === "field" && field.fieldKey !== item.field_id
|
|
3086
|
+
? item.field_id
|
|
3087
|
+
: undefined;
|
|
3088
|
+
values[fieldKey] = item.update_mode === "add" || foreignInfo !== undefined || platformFieldId !== undefined
|
|
2976
3089
|
? {
|
|
2977
3090
|
__fieldAssignment: true,
|
|
2978
|
-
value:
|
|
3091
|
+
value: canonicalValue,
|
|
2979
3092
|
...(item.update_mode === "add" ? { updateMode: "add" } : {}),
|
|
2980
3093
|
...(foreignInfo !== undefined ? foreignInfo : {}),
|
|
3094
|
+
...(platformFieldId !== undefined ? { platformFieldId } : {}),
|
|
2981
3095
|
}
|
|
2982
|
-
:
|
|
3096
|
+
: canonicalValue;
|
|
2983
3097
|
}
|
|
2984
3098
|
args.values = values;
|
|
2985
3099
|
continue;
|
|
@@ -3520,9 +3634,12 @@ function taskArgs(block, factory, ctx, taskDiagnostics) {
|
|
|
3520
3634
|
continue;
|
|
3521
3635
|
}
|
|
3522
3636
|
const arg = ATTR_TO_ARG[attr] ?? attr.replace(/_([a-z])/g, (_, char) => char.toUpperCase());
|
|
3523
|
-
|
|
3637
|
+
const decoded = (attr === "record_reference" || attr === "record_id") && (factory === "createRecord" || factory === "updateField")
|
|
3524
3638
|
? decodeValueOrStringifiedRef(value, ctx, taskDiagnostics, `${block.type}.${block.label} ${attr}`)
|
|
3525
3639
|
: decodeValue(value, ctx);
|
|
3640
|
+
args[arg] = attr === "record_reference" && factory === "updateField"
|
|
3641
|
+
? canonicalTriggerRecordIdSlot(decoded, ctx)
|
|
3642
|
+
: decoded;
|
|
3526
3643
|
}
|
|
3527
3644
|
if (["recordSearch", "createRecord", "updateField", "bulkUpdateFields"].includes(factory))
|
|
3528
3645
|
args.app ??= appRef(ctx.appRefName);
|
|
@@ -3672,8 +3789,8 @@ function taskRefKey(block, automationLabel, appTfLabel) {
|
|
|
3672
3789
|
* conditions that make real extraction fail (zero triggers, an
|
|
3673
3790
|
* unrecognized task kind) so it over-collects rather than under-collects.
|
|
3674
3791
|
* More than one trigger throws {@link UnsupportedMultiTriggerError}. The
|
|
3675
|
-
* stream extractor
|
|
3676
|
-
*
|
|
3792
|
+
* stream extractor soft-skips those automations (diagnostic + skipped +
|
|
3793
|
+
* releaseIfManaged), so the rest of the app can still adopt (#1785).
|
|
3677
3794
|
* A false positive
|
|
3678
3795
|
* here just leaves one more resource unmanaged; a false negative would
|
|
3679
3796
|
* silently destroy a live automation on apply.
|
|
@@ -3854,9 +3971,9 @@ function unresolvedAuthoringValues(doc) {
|
|
|
3854
3971
|
/**
|
|
3855
3972
|
* EDK does not author multi-trigger automations; apps should keep one
|
|
3856
3973
|
* trigger and call the shared logic with a run-automation action. Stream
|
|
3857
|
-
* extraction
|
|
3858
|
-
*
|
|
3859
|
-
*
|
|
3974
|
+
* extraction soft-skips every one of these (warn + skip + releaseIfManaged)
|
|
3975
|
+
* so the rest of the app can still adopt (#1785). Direct `automationFromTf`
|
|
3976
|
+
* still throws so callers that need a hard signal can catch it.
|
|
3860
3977
|
*/
|
|
3861
3978
|
export class UnsupportedMultiTriggerError extends EntityTfError {
|
|
3862
3979
|
automationName;
|
|
@@ -3869,6 +3986,18 @@ export class UnsupportedMultiTriggerError extends EntityTfError {
|
|
|
3869
3986
|
this.triggerCount = triggerCount;
|
|
3870
3987
|
}
|
|
3871
3988
|
}
|
|
3989
|
+
/**
|
|
3990
|
+
* A bare service_account_id belongs to an app this export does not contain.
|
|
3991
|
+
* Pull cannot print a serviceAccountRef until that app is in the workspace,
|
|
3992
|
+
* and printing nothing would clear the live account.
|
|
3993
|
+
*/
|
|
3994
|
+
export class UnresolvedForeignServiceAccountError extends EntityTfError {
|
|
3995
|
+
constructor(automationLabel) {
|
|
3996
|
+
super(`${AUTOMATION_RESOURCE_TYPE}.${automationLabel}: service_account_id names a service account outside this export ` +
|
|
3997
|
+
"that no pulled app in state owns; pull the app that owns it first");
|
|
3998
|
+
this.name = "UnresolvedForeignServiceAccountError";
|
|
3999
|
+
}
|
|
4000
|
+
}
|
|
3872
4001
|
/**
|
|
3873
4002
|
* #1320: a task reads the current item of a loop that doesn't enclose it.
|
|
3874
4003
|
* Pull skips the automation like any other exclusion, and additionally
|
|
@@ -3884,14 +4013,14 @@ export class ForEachItemOutsideLoopError extends EntityTfError {
|
|
|
3884
4013
|
}
|
|
3885
4014
|
}
|
|
3886
4015
|
/** 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) {
|
|
4016
|
+
function automationFromTfDocument(doc, automationLabel, appRefName, foreignFieldRefsById, foreignFieldRefsByDataAddress, foreignTableRefsById, picklistOptionLabelById, fieldNamesByOwnerRefName, foreignAppRefNames, foreignElementRefNames, procedureKeysByDiscriminator, foreignTaskRefNames, groupKeysByName, serviceAccountsById) {
|
|
3888
4017
|
const automation = doc.blocks.find((block) => block.kind === "resource" && block.type === AUTOMATION_RESOURCE_TYPE && block.label === automationLabel);
|
|
3889
4018
|
if (automation === undefined)
|
|
3890
4019
|
throw new EntityTfError(`automation resource "${automationLabel}" not found`);
|
|
3891
4020
|
const triggers = doc.blocks.filter((block) => block.kind === "resource" && AUTOMATION_TRIGGER_TYPE_SET.has(block.type ?? "") && references(block.attrs.automation, AUTOMATION_RESOURCE_TYPE, automationLabel));
|
|
3892
|
-
// N > 1 is a product non-support
|
|
3893
|
-
//
|
|
3894
|
-
//
|
|
4021
|
+
// N > 1 is a product non-support. Throw before later structural checks so
|
|
4022
|
+
// extractAutomations can soft-skip the whole graph (#1785) instead of
|
|
4023
|
+
// partially decoding a shape EDK cannot author.
|
|
3895
4024
|
if (triggers.length > 1) {
|
|
3896
4025
|
const name = typeof automation.attrs.name === "string" && automation.attrs.name !== "" ? automation.attrs.name : automationLabel;
|
|
3897
4026
|
throw new UnsupportedMultiTriggerError(name, triggers.length);
|
|
@@ -4068,6 +4197,7 @@ function automationFromTfDocument(doc, automationLabel, appRefName, foreignField
|
|
|
4068
4197
|
stagesByKey.set(item.key, item.name);
|
|
4069
4198
|
}
|
|
4070
4199
|
}
|
|
4200
|
+
const stringifiedValueReferences = { unresolved: false };
|
|
4071
4201
|
const ctx = {
|
|
4072
4202
|
appRefName,
|
|
4073
4203
|
appTfLabel: app.label,
|
|
@@ -4091,6 +4221,7 @@ function automationFromTfDocument(doc, automationLabel, appRefName, foreignField
|
|
|
4091
4221
|
...(foreignTaskRefNames !== undefined && { foreignTaskRefNames }),
|
|
4092
4222
|
...(procedureKeysByDiscriminator !== undefined && { procedureKeysByDiscriminator }),
|
|
4093
4223
|
...(groupKeysByName !== undefined && { groupKeysByName }),
|
|
4224
|
+
stringifiedValueReferences,
|
|
4094
4225
|
};
|
|
4095
4226
|
let serviceAccountName;
|
|
4096
4227
|
const serviceAccountValue = automation.attrs.service_account_id;
|
|
@@ -4111,6 +4242,18 @@ function automationFromTfDocument(doc, automationLabel, appRefName, foreignField
|
|
|
4111
4242
|
}
|
|
4112
4243
|
}
|
|
4113
4244
|
}
|
|
4245
|
+
let serviceAccountAppRefName;
|
|
4246
|
+
if (typeof serviceAccountValue === "string" && isUuid(serviceAccountValue) && serviceAccountsById !== undefined) {
|
|
4247
|
+
const owned = serviceAccountsById.get(serviceAccountValue);
|
|
4248
|
+
if (owned !== undefined) {
|
|
4249
|
+
serviceAccountName = owned.name;
|
|
4250
|
+
if (owned.appRefName !== appRefName)
|
|
4251
|
+
serviceAccountAppRefName = owned.appRefName;
|
|
4252
|
+
}
|
|
4253
|
+
else {
|
|
4254
|
+
throw new UnresolvedForeignServiceAccountError(automationLabel);
|
|
4255
|
+
}
|
|
4256
|
+
}
|
|
4114
4257
|
const dependencyOrder = new Map();
|
|
4115
4258
|
if (publish && Array.isArray(publish.attrs.depends_on))
|
|
4116
4259
|
publish.attrs.depends_on.forEach((dep, index) => { const ref = resourceRef(dep); if (ref)
|
|
@@ -4285,7 +4428,8 @@ function automationFromTfDocument(doc, automationLabel, appRefName, foreignField
|
|
|
4285
4428
|
...(typeof automation.attrs.description === "string" ? { description: automation.attrs.description } : {}),
|
|
4286
4429
|
...(typeof automation.attrs.triggers_other_automations === "boolean" ? { triggersOtherAutomations: automation.attrs.triggers_other_automations } : {}),
|
|
4287
4430
|
...(serviceAccountName !== undefined ? { serviceAccountName } : {}),
|
|
4288
|
-
|
|
4431
|
+
...(serviceAccountAppRefName !== undefined ? { serviceAccountAppRefName } : {}),
|
|
4432
|
+
status: automation.attrs.status === "INACTIVE" ? "INACTIVE" : publish ? "ACTIVE" : "DRAFT",
|
|
4289
4433
|
trigger: triggerFromBlock(trigger, ctx),
|
|
4290
4434
|
tasks: topTasks,
|
|
4291
4435
|
...(outputs && outputs.length > 0 ? { outputs } : {}),
|
|
@@ -4304,9 +4448,10 @@ function automationFromTfDocument(doc, automationLabel, appRefName, foreignField
|
|
|
4304
4448
|
...taskDiagnostics.map((message) => `automation "${automationLabel}": ${message}`),
|
|
4305
4449
|
],
|
|
4306
4450
|
}),
|
|
4451
|
+
...(stringifiedValueReferences.unresolved ? { stringifiedValueReferences: true } : {}),
|
|
4307
4452
|
};
|
|
4308
4453
|
}
|
|
4309
|
-
export function automationFromTf(first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth, eleventh, twelfth, thirteenth) {
|
|
4454
|
+
export function automationFromTf(first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth, eleventh, twelfth, thirteenth, fourteenth) {
|
|
4310
4455
|
if (Array.isArray(first)) {
|
|
4311
4456
|
const ctx = second;
|
|
4312
4457
|
const automationBlock = first.find((block) => block.kind === "resource" && block.type === AUTOMATION_RESOURCE_TYPE);
|
|
@@ -4315,7 +4460,7 @@ export function automationFromTf(first, second, third, fourth, fifth, sixth, sev
|
|
|
4315
4460
|
throw new EntityTfError(`automation graph has no ${AUTOMATION_RESOURCE_TYPE} resource, so its resources (${addresses.join(", ") || "none"}) cannot be pulled`);
|
|
4316
4461
|
}
|
|
4317
4462
|
try {
|
|
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);
|
|
4463
|
+
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, ctx.serviceAccountsById);
|
|
4319
4464
|
if (result.diagnostics)
|
|
4320
4465
|
ctx.diagnostics.push(...result.diagnostics);
|
|
4321
4466
|
return { automation: result.ast };
|
|
@@ -4328,5 +4473,5 @@ export function automationFromTf(first, second, third, fourth, fifth, sixth, sev
|
|
|
4328
4473
|
return { skippedReason: message };
|
|
4329
4474
|
}
|
|
4330
4475
|
}
|
|
4331
|
-
return automationFromTfDocument(first, second, third ?? "", fourth, fifth, sixth, seventh, eighth, ninth, tenth, eleventh, twelfth, thirteenth);
|
|
4476
|
+
return automationFromTfDocument(first, second, third ?? "", fourth, fifth, sixth, seventh, eighth, ninth, tenth, eleventh, twelfth, thirteenth, fourteenth);
|
|
4332
4477
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** The automation entity's registry entry (see src/graph/). */
|
|
2
|
-
import { appScopedResourceLabel, sanitizeName, tfLabelToTsLabel, isTfExpr } from "../../engine/tf/index.js";
|
|
2
|
+
import { appScopedResourceLabel, sanitizeName, scopedLabelToBagKey, tfLabelToTsLabel, isTfExpr } from "../../engine/tf/index.js";
|
|
3
3
|
function elementOwnerHandle(payload) {
|
|
4
4
|
if (payload === null || typeof payload !== "object" || !("handle" in payload))
|
|
5
5
|
return undefined;
|
|
@@ -8,13 +8,13 @@ function elementOwnerHandle(payload) {
|
|
|
8
8
|
}
|
|
9
9
|
import { renderAutomationCatalogEntry } from "./catalog-render.js";
|
|
10
10
|
import { hasUnresolvedForEachItem, preserveAuthoredAutomationPullMeta, printAutomationV2WithScriptFiles, SCRIPT_FILES_DIR } from "./deserializer/print-automation.js";
|
|
11
|
-
import {
|
|
12
|
-
import { recordValidations } from "../../engine/validation.js";
|
|
13
|
-
import { automationFromTf, automationOwnedAddresses, ForEachItemOutsideLoopError, UnsupportedMultiTriggerError } from "./from-tf.js";
|
|
11
|
+
import { automationFromTf, automationOwnedAddresses, ForEachItemOutsideLoopError, UnresolvedForeignServiceAccountError, UnsupportedMultiTriggerError } from "./from-tf.js";
|
|
14
12
|
import { scriptFileRefs } from "./script-code.js";
|
|
15
13
|
import { typedCoverageGap } from "../../engine/coverage-gaps.js";
|
|
16
14
|
import { TASK_OUTPUT_REFERENCE_NAMES } from "./task-output-labels.js";
|
|
17
15
|
import { automationToTf } from "./to-tf.js";
|
|
16
|
+
import { approvalChainLostStage } from "../approval-chain/from-tf.js";
|
|
17
|
+
import { stageHandleIndexFromTfStages } from "../app/stage-keys.js";
|
|
18
18
|
import { ALL_AUTOMATION_SUB_TYPES, AUTOMATION_RESOURCE_TYPE, WORKFLOW_PUBLISH_RESOURCE_TYPE, } from "./types.js";
|
|
19
19
|
const AUTOMATION_MEMBER_TYPES = new Set([
|
|
20
20
|
WORKFLOW_PUBLISH_RESOURCE_TYPE,
|
|
@@ -131,13 +131,66 @@ export function droppedAutomationGap(autoBlock, autoLabel, reason) {
|
|
|
131
131
|
consequence: "it is not written to source or adopted; it keeps running on the platform unmanaged",
|
|
132
132
|
});
|
|
133
133
|
}
|
|
134
|
+
/** Addresses of the stream's approval processes that pull leaves unmanaged because their stage lost its only handle (#1136). */
|
|
135
|
+
function lostStageApprovalChains(stream, ctx) {
|
|
136
|
+
const lost = new Set();
|
|
137
|
+
if (ctx.parentScope !== "app")
|
|
138
|
+
return lost;
|
|
139
|
+
const stageHandles = stageHandleIndexFromTfStages(ctx.resourceByAddress?.(`elementum_app.${ctx.appTfLabel}`)?.attrs["stages"]);
|
|
140
|
+
if (stageHandles === undefined)
|
|
141
|
+
return lost;
|
|
142
|
+
for (const block of stream.allBlocks) {
|
|
143
|
+
if (block.kind !== "resource" || block.type !== "elementum_approval_process" || block.label === undefined)
|
|
144
|
+
continue;
|
|
145
|
+
if (approvalChainLostStage(block, ctx.appTfLabel, stageHandles) !== undefined)
|
|
146
|
+
lost.add(`${block.type}.${block.label}`);
|
|
147
|
+
}
|
|
148
|
+
return lost;
|
|
149
|
+
}
|
|
150
|
+
/** The first of `chains` that any block at `owned` references, if any. */
|
|
151
|
+
function referencedLostChain(stream, owned, chains) {
|
|
152
|
+
const ownedSet = new Set(owned);
|
|
153
|
+
const visit = (value) => {
|
|
154
|
+
if (Array.isArray(value)) {
|
|
155
|
+
for (const item of value) {
|
|
156
|
+
const hit = visit(item);
|
|
157
|
+
if (hit !== undefined)
|
|
158
|
+
return hit;
|
|
159
|
+
}
|
|
160
|
+
return undefined;
|
|
161
|
+
}
|
|
162
|
+
if (value === null || typeof value !== "object")
|
|
163
|
+
return undefined;
|
|
164
|
+
const record = value;
|
|
165
|
+
if (record["$expr"] === "resource-attr" && typeof record["type"] === "string" && typeof record["label"] === "string") {
|
|
166
|
+
const address = `${record["type"]}.${record["label"]}`;
|
|
167
|
+
if (chains.has(address))
|
|
168
|
+
return address;
|
|
169
|
+
}
|
|
170
|
+
for (const item of Object.values(record)) {
|
|
171
|
+
const hit = visit(item);
|
|
172
|
+
if (hit !== undefined)
|
|
173
|
+
return hit;
|
|
174
|
+
}
|
|
175
|
+
return undefined;
|
|
176
|
+
};
|
|
177
|
+
for (const block of stream.allBlocks) {
|
|
178
|
+
if (block.type === undefined || block.label === undefined || !ownedSet.has(`${block.type}.${block.label}`))
|
|
179
|
+
continue;
|
|
180
|
+
const hit = visit(block.attrs);
|
|
181
|
+
if (hit !== undefined)
|
|
182
|
+
return hit;
|
|
183
|
+
}
|
|
184
|
+
return undefined;
|
|
185
|
+
}
|
|
134
186
|
function extractAutomations(ownBlocks, stream, ctx) {
|
|
135
187
|
const items = [];
|
|
136
188
|
const skipped = [];
|
|
137
189
|
const releaseIfManaged = [];
|
|
190
|
+
const quarantineOwnFiles = [];
|
|
138
191
|
const diagnostics = [];
|
|
139
|
-
const validations = [];
|
|
140
192
|
const adoptionAddressAliases = [];
|
|
193
|
+
const lostChains = lostStageApprovalChains(stream, ctx);
|
|
141
194
|
for (const autoBlock of ownBlocks) {
|
|
142
195
|
const autoLabel = autoBlock.label ?? "";
|
|
143
196
|
const doc = { blocks: [...stream.allBlocks] };
|
|
@@ -145,8 +198,33 @@ function extractAutomations(ownBlocks, stream, ctx) {
|
|
|
145
198
|
// somehow omits the app RefExpr still feeds --with-dependencies. Cheap
|
|
146
199
|
// (one owned-address walk) relative to from-tf.
|
|
147
200
|
registerForeignObjectIdDeps(doc, autoLabel, ctx);
|
|
201
|
+
// An approval chain on a stage with no handle of its own is left
|
|
202
|
+
// unmanaged (#1136), so a reference to it would dangle at build. Skip the
|
|
203
|
+
// automation with a warning and release an earlier adoption of it.
|
|
204
|
+
if (lostChains.size > 0) {
|
|
205
|
+
const owned = automationOwnedAddresses(doc, autoLabel);
|
|
206
|
+
const chain = referencedLostChain(stream, owned, lostChains);
|
|
207
|
+
if (chain !== undefined) {
|
|
208
|
+
skipped.push(...owned);
|
|
209
|
+
releaseIfManaged.push(...owned);
|
|
210
|
+
diagnostics.push(droppedAutomationGap(autoBlock, autoLabel, `it references ${chain}, which is left unmanaged because its stage has no handle of its own (#1136)`));
|
|
211
|
+
continue;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
148
214
|
try {
|
|
149
|
-
const extracted = automationFromTf(doc, autoLabel, ctx.appRefName, ctx.foreignFieldRefsById, ctx.foreignFieldRefsByDataAddress, ctx.foreignTableRefsById, ctx.picklistOptionLabelById, ctx.fieldNamesByOwnerRefName, ctx.foreignAppRefNames, ctx.foreignElementRefNames, ctx.procedureKeysByDiscriminator, ctx.foreignTaskRefNames, ctx.groupKeysByName);
|
|
215
|
+
const extracted = automationFromTf(doc, autoLabel, ctx.appRefName, ctx.foreignFieldRefsById, ctx.foreignFieldRefsByDataAddress, ctx.foreignTableRefsById, ctx.picklistOptionLabelById, ctx.fieldNamesByOwnerRefName, ctx.foreignAppRefNames, ctx.foreignElementRefNames, ctx.procedureKeysByDiscriminator, ctx.foreignTaskRefNames, ctx.groupKeysByName, ctx.serviceAccountsById);
|
|
216
|
+
// edk#1646 / #1858: adopt when a rebuilt ctx ref matches provider Read.
|
|
217
|
+
// Otherwise the automation stays platform-managed. Releasing its state
|
|
218
|
+
// also archives the authored file, so the next plan does not create a
|
|
219
|
+
// second copy of the live automation.
|
|
220
|
+
if (extracted.stringifiedValueReferences === true) {
|
|
221
|
+
const owned = automationOwnedAddresses(doc, autoLabel);
|
|
222
|
+
skipped.push(...owned);
|
|
223
|
+
releaseIfManaged.push(...owned);
|
|
224
|
+
quarantineOwnFiles.push({ kind: "automation", refName: extracted.refName });
|
|
225
|
+
diagnostics.push(droppedAutomationGap(autoBlock, autoLabel, "the export embeds a stringified ValueReference that source cannot rebuild to match provider Read (edk#1646). It stays platform-managed, and its authored file is archived so the next plan does not create a duplicate."));
|
|
226
|
+
continue;
|
|
227
|
+
}
|
|
150
228
|
// Keep automationFromTf's label-derived refName — agent/skill tools store
|
|
151
229
|
// the same scopedLabelToBagKey as automationKey. Pushing bare AST (name
|
|
152
230
|
// only) made missing-automation diagnostics false-positive on every real
|
|
@@ -156,23 +234,6 @@ function extractAutomations(ownBlocks, stream, ctx) {
|
|
|
156
234
|
diagnostics.push(...(extracted.diagnostics ?? []).map((diagnostic) => `${autoLabel}: ${diagnostic}`));
|
|
157
235
|
}
|
|
158
236
|
catch (err) {
|
|
159
|
-
// Multi-trigger is unsupported, not an extract gap. Collect every
|
|
160
|
-
// offender and keep going. The addresses still go through `skipped` so
|
|
161
|
-
// adoption will not import a graph that was not written, and the
|
|
162
|
-
// message stays out of `diagnostics` (those are warnings).
|
|
163
|
-
if (err instanceof UnsupportedMultiTriggerError) {
|
|
164
|
-
const failure = {
|
|
165
|
-
severity: "fatal",
|
|
166
|
-
address: `${AUTOMATION_RESOURCE_TYPE}.${autoLabel}`,
|
|
167
|
-
name: err.automationName,
|
|
168
|
-
ownerKind: "automation",
|
|
169
|
-
message: err.message,
|
|
170
|
-
};
|
|
171
|
-
validations.push(failure);
|
|
172
|
-
recordValidations([failure]);
|
|
173
|
-
skipped.push(...automationOwnedAddresses(doc, autoLabel));
|
|
174
|
-
continue;
|
|
175
|
-
}
|
|
176
237
|
// Report the automation's FULL graph (trigger/tasks/branches/publish),
|
|
177
238
|
// not just its root - otherwise those children's otherwise-adoptable
|
|
178
239
|
// resource TYPES get imported into state anyway, and build (which
|
|
@@ -180,13 +241,22 @@ function extractAutomations(ownBlocks, stream, ctx) {
|
|
|
180
241
|
// `plan` shows them as destroy-on-apply. See automationOwnedAddresses.
|
|
181
242
|
const owned = automationOwnedAddresses(doc, autoLabel);
|
|
182
243
|
skipped.push(...owned);
|
|
183
|
-
//
|
|
184
|
-
//
|
|
185
|
-
//
|
|
186
|
-
//
|
|
187
|
-
//
|
|
188
|
-
if (err instanceof ForEachItemOutsideLoopError
|
|
244
|
+
// No authored form can manage these, so release an earlier adoption
|
|
245
|
+
// rather than let the next apply destroy the live automation:
|
|
246
|
+
// sibling-loop item refs (#1320) and multi-trigger (#1785 / #39).
|
|
247
|
+
// Soft diagnostic, not a validation fatal — the rest of the app must
|
|
248
|
+
// still adopt and plan clean while these stay platform-managed only.
|
|
249
|
+
if (err instanceof ForEachItemOutsideLoopError ||
|
|
250
|
+
err instanceof UnsupportedMultiTriggerError ||
|
|
251
|
+
err instanceof UnresolvedForeignServiceAccountError) {
|
|
189
252
|
releaseIfManaged.push(...owned);
|
|
253
|
+
}
|
|
254
|
+
if (err instanceof UnresolvedForeignServiceAccountError) {
|
|
255
|
+
quarantineOwnFiles.push({
|
|
256
|
+
kind: "automation",
|
|
257
|
+
refName: scopedLabelToBagKey(ctx.appTfLabel, autoLabel),
|
|
258
|
+
});
|
|
259
|
+
}
|
|
190
260
|
// edk#1480: name the dropped automation and say what that means, as a
|
|
191
261
|
// typed gap so it counts (and fails --strict-coverage) by itself.
|
|
192
262
|
diagnostics.push(droppedAutomationGap(autoBlock, autoLabel, err instanceof Error ? err.message : String(err)));
|
|
@@ -194,7 +264,10 @@ function extractAutomations(ownBlocks, stream, ctx) {
|
|
|
194
264
|
}
|
|
195
265
|
// A trigger, task, or publish with no automation resource is not in any
|
|
196
266
|
// skeleton's graph. extractAutomations never sees it, and its resource type
|
|
197
|
-
// is still adoptable, so the next plan can destroy it (#1484).
|
|
267
|
+
// is still adoptable, so the next plan can destroy it (#1484). Soft-skip
|
|
268
|
+
// rather than authoring-block the whole app: Blueprint exports sometimes
|
|
269
|
+
// omit a trigger (or leave a task without parent), and hard-failing hid
|
|
270
|
+
// the rest of the app from adoption (rfxclarificationquestion Retire Q&A).
|
|
198
271
|
const doc = { blocks: [...stream.allBlocks] };
|
|
199
272
|
const owned = new Set();
|
|
200
273
|
for (const autoBlock of ownBlocks) {
|
|
@@ -210,14 +283,18 @@ function extractAutomations(ownBlocks, stream, ctx) {
|
|
|
210
283
|
if (owned.has(address))
|
|
211
284
|
continue;
|
|
212
285
|
skipped.push(address);
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
286
|
+
releaseIfManaged.push(address);
|
|
287
|
+
const display = typeof block.attrs["name"] === "string" && block.attrs["name"] !== ""
|
|
288
|
+
? block.attrs["name"]
|
|
289
|
+
: block.label;
|
|
290
|
+
diagnostics.push(typedCoverageGap({
|
|
291
|
+
kind: "skipped",
|
|
292
|
+
entity: `${block.type} ${JSON.stringify(display)} (${block.label})`,
|
|
293
|
+
detail: "not pulled, skipped: not owned by an elementum_automation resource (export is missing the owning automation or the task has no parent chain)",
|
|
294
|
+
consequence: "it is not written to source or adopted; it keeps running on the platform unmanaged",
|
|
295
|
+
}));
|
|
219
296
|
}
|
|
220
|
-
return { items, skipped, releaseIfManaged,
|
|
297
|
+
return { items, skipped, releaseIfManaged, quarantineOwnFiles, diagnostics, adoptionAddressAliases };
|
|
221
298
|
}
|
|
222
299
|
export const automationModule = {
|
|
223
300
|
kind: "automation",
|
|
@@ -311,6 +388,7 @@ export const automationModule = {
|
|
|
311
388
|
...(ctx.allowUnknownPicklistOptions === true ? { allowUnknownPicklistOptions: true } : {}),
|
|
312
389
|
orgRefs: ctx.orgRefs,
|
|
313
390
|
workspaceAspects: ctx.workspaceAspects,
|
|
391
|
+
...(ctx.outOfScopeApps !== undefined && { outOfScopeApps: ctx.outOfScopeApps }),
|
|
314
392
|
localsAttrs: ctx.localsAttrs,
|
|
315
393
|
serviceAccounts: ctx.streamRootEntity?.payload?.serviceAccounts,
|
|
316
394
|
activeAutomationRefNames: ctx.activeAutomationRefNames ?? new Set((ctx.siblingEntities ?? [])
|
|
@@ -352,6 +430,14 @@ export const automationModule = {
|
|
|
352
430
|
localPrefix: "edk_variable_ids_",
|
|
353
431
|
listField: "id",
|
|
354
432
|
}],
|
|
433
|
+
// The provider's create_record / update_field / bulk_update_fields
|
|
434
|
+
// ModifyPlan equates these (`picklistValuesEquivalent`, #633), so plan
|
|
435
|
+
// stays clean whichever one the platform stored (#1891).
|
|
436
|
+
picklistLabelAssignments: [
|
|
437
|
+
"elementum_create_record_task",
|
|
438
|
+
"elementum_update_field_task",
|
|
439
|
+
"elementum_bulk_update_fields_task",
|
|
440
|
+
].map((resourceType) => ({ resourceType, attribute: "fields", fieldAttribute: "field_id", valueAttribute: "value" })),
|
|
355
441
|
},
|
|
356
442
|
};
|
|
357
443
|
/** The provider's `normalizeOnDemandFilterRefName`, which computes `filter_refs` at plan time. */
|