@elementumai/edk 0.10.2 → 0.10.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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 +69 -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 +2 -1
- package/dist-sdk/src/engine/tf/index.js +2 -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/tf/scan.d.ts +22 -0
- package/dist-sdk/src/engine/tf/scan.js +123 -0
- 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.d.ts +8 -0
- package/dist-sdk/src/engine/workspace/loader.js +22 -2
- package/dist-sdk/src/entities/agent/to-tf.d.ts +13 -11
- package/dist-sdk/src/entities/agent/to-tf.js +17 -12
- package/dist-sdk/src/entities/agent-tool/from-tf.js +2 -2
- package/dist-sdk/src/entities/agent-tool/to-tf.js +10 -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 +18 -0
- package/dist-sdk/src/entities/app/from-tf.js +17 -9
- package/dist-sdk/src/entities/app/module.js +1 -0
- 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 +17 -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.js +25 -8
- 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 +90 -17
- package/dist-sdk/src/entities/automation/from-tf.d.ts +28 -6
- package/dist-sdk/src/entities/automation/from-tf.js +140 -23
- package/dist-sdk/src/entities/automation/module.js +158 -44
- package/dist-sdk/src/entities/automation/output-field-types.d.ts +8 -0
- package/dist-sdk/src/entities/automation/output-field-types.js +20 -0
- package/dist-sdk/src/entities/automation/output-key-wire-name.d.ts +2 -0
- package/dist-sdk/src/entities/automation/output-key-wire-name.js +18 -0
- package/dist-sdk/src/entities/automation/to-tf.d.ts +10 -1
- package/dist-sdk/src/entities/automation/to-tf.js +200 -38
- 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 +26 -8
- package/dist-sdk/src/entities/element/module.js +3 -2
- package/dist-sdk/src/entities/element/to-tf.d.ts +3 -2
- package/dist-sdk/src/entities/element/to-tf.js +32 -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 +178 -20
- package/dist-sdk/src/entities/field/module.js +2 -0
- package/dist-sdk/src/entities/field/options.d.ts +2 -0
- package/dist-sdk/src/entities/field/order.d.ts +9 -0
- package/dist-sdk/src/entities/field/order.js +33 -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.js +3 -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/module.js +28 -2
- 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/view/agent-view-layout-from-tf.d.ts +2 -0
- package/dist-sdk/src/entities/view/agent-view-layout-from-tf.js +6 -2
- 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 +293 -0
- package/dist-sdk/src/entities/view/from-tf.d.ts +10 -0
- package/dist-sdk/src/entities/view/from-tf.js +164 -26
- package/dist-sdk/src/entities/view/to-tf.d.ts +6 -0
- package/dist-sdk/src/entities/view/to-tf.js +14 -6
- 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 +6 -0
- package/dist-sdk/src/graph/index.js +1 -0
- package/dist-sdk/src/graph/types.d.ts +66 -2
- package/package.json +2 -17
|
@@ -984,9 +984,11 @@ function decodeStringifiedValueReference(value, ctx, diagnostics, where) {
|
|
|
984
984
|
found = true;
|
|
985
985
|
if (start > cursor)
|
|
986
986
|
parts.push(value.slice(cursor, start));
|
|
987
|
-
const reference = decodeFilterReferenceEnvelope(parsed, ctx);
|
|
988
|
-
if (reference === undefined ||
|
|
987
|
+
const reference = decodeFilterReferenceEnvelope(parsed, ctx, undefined, "envelope");
|
|
988
|
+
if (reference === undefined || stringifiedEnvelopeCannotMatchRead(parsed, reference, ctx, where)) {
|
|
989
989
|
unresolved = true;
|
|
990
|
+
if (ctx.stringifiedValueReferences !== undefined)
|
|
991
|
+
ctx.stringifiedValueReferences.unresolved = true;
|
|
990
992
|
parts.push({ kind: "unresolved", uuid: value.slice(start, end), hint: "value-reference (edk#1646)" });
|
|
991
993
|
}
|
|
992
994
|
else {
|
|
@@ -1033,6 +1035,69 @@ function stringifiedReferenceResolves(envelope, reference, ctx) {
|
|
|
1033
1035
|
}
|
|
1034
1036
|
return true;
|
|
1035
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
|
+
}
|
|
1036
1101
|
/** decodeValue, upgrading a stringified ValueReference envelope (edk#1646). */
|
|
1037
1102
|
function decodeValueOrStringifiedRef(value, ctx, diagnostics, where) {
|
|
1038
1103
|
if (typeof value === "string") {
|
|
@@ -1042,6 +1107,17 @@ function decodeValueOrStringifiedRef(value, ctx, diagnostics, where) {
|
|
|
1042
1107
|
}
|
|
1043
1108
|
return decodeValue(value, ctx);
|
|
1044
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
|
+
}
|
|
1045
1121
|
function triggerRefPath(path, ctx) {
|
|
1046
1122
|
const names = pathNames(path);
|
|
1047
1123
|
if (names.length !== 1)
|
|
@@ -1722,6 +1798,9 @@ function decodeValue(value, ctx) {
|
|
|
1722
1798
|
if (payloadKey !== undefined)
|
|
1723
1799
|
return { kind: "triggerRef", path: ["attachment", payloadKey] };
|
|
1724
1800
|
}
|
|
1801
|
+
const shadowedParam = shadowedOnDemandParamFromEnvelope(value, ctx);
|
|
1802
|
+
if (shadowedParam !== undefined)
|
|
1803
|
+
return { kind: "triggerRef", path: [shadowedParam] };
|
|
1725
1804
|
if (isTfExpr(value)) {
|
|
1726
1805
|
if (value.$expr === "template") {
|
|
1727
1806
|
return { kind: "template", parts: value.parts.map((part) => typeof part === "string" ? part : decodeValue(part, ctx)) };
|
|
@@ -2237,6 +2316,7 @@ function fieldRef(value, ctx) {
|
|
|
2237
2316
|
? {
|
|
2238
2317
|
foreign: {
|
|
2239
2318
|
entityType: foreign.ownerKind ?? "app",
|
|
2319
|
+
...(foreign.ownerKind === undefined ? { ownerKindUnknown: true } : {}),
|
|
2240
2320
|
name: foreign.ownerName ?? foreign.ownerRefName,
|
|
2241
2321
|
...(foreign.ownerNamespace !== undefined ? { namespace: foreign.ownerNamespace } : {}),
|
|
2242
2322
|
...(foreign.fieldName !== undefined ? { fieldName: foreign.fieldName } : {}),
|
|
@@ -2261,6 +2341,7 @@ function fieldRef(value, ctx) {
|
|
|
2261
2341
|
? {
|
|
2262
2342
|
foreign: {
|
|
2263
2343
|
entityType: foreign.ownerKind ?? "app",
|
|
2344
|
+
...(foreign.ownerKind === undefined ? { ownerKindUnknown: true } : {}),
|
|
2264
2345
|
name: foreign.ownerName ?? foreign.ownerRefName,
|
|
2265
2346
|
...(foreign.ownerNamespace !== undefined ? { namespace: foreign.ownerNamespace } : {}),
|
|
2266
2347
|
...(foreign.fieldName !== undefined ? { fieldName: foreign.fieldName } : {}),
|
|
@@ -2635,12 +2716,14 @@ function decodeFilterReferenceEnvelope(value, ctx, outputName, role) {
|
|
|
2635
2716
|
: schemaValue;
|
|
2636
2717
|
const outputTypes = outputFieldTypesFromScriptSchema(schema);
|
|
2637
2718
|
const declared = scriptOutputReferenceIsDeclared(outputTypes, taskRef.name);
|
|
2638
|
-
if (
|
|
2639
|
-
if (raw.multiple === true || raw.fieldType === "DECIMAL") {
|
|
2719
|
+
if (!declared && taskRef.name.startsWith("result.")) {
|
|
2720
|
+
if (role === "left" && (raw.multiple === true || raw.fieldType === "DECIMAL")) {
|
|
2640
2721
|
throw new EntityTfError(`execute-script reference "${taskRef.name}" is absent from its output schema and its ` +
|
|
2641
2722
|
`${raw.multiple === true ? "multiple" : "DECIMAL"} envelope cannot round-trip losslessly`);
|
|
2642
2723
|
}
|
|
2643
|
-
|
|
2724
|
+
if (role === "left" || role === "envelope" || outputName !== undefined) {
|
|
2725
|
+
return { ...decoded, undeclaredScriptOutput: true };
|
|
2726
|
+
}
|
|
2644
2727
|
}
|
|
2645
2728
|
}
|
|
2646
2729
|
return decoded;
|
|
@@ -2887,7 +2970,7 @@ function triggerFromBlock(block, ctx) {
|
|
|
2887
2970
|
// approval_chain_template_id is genuinely omittable on the platform
|
|
2888
2971
|
// (edk#712) - a null/never-set template means "any", not "unresolved".
|
|
2889
2972
|
if (block.attrs.approval_chain_template_id === undefined) {
|
|
2890
|
-
return { kind, app, status: block.attrs.status };
|
|
2973
|
+
return { kind, app, status: block.attrs.status, ...(filter ? { filter } : {}) };
|
|
2891
2974
|
}
|
|
2892
2975
|
const approvalChain = typeof block.attrs.approval_chain_template_id === "string"
|
|
2893
2976
|
? block.attrs.approval_chain_template_id
|
|
@@ -2895,7 +2978,7 @@ function triggerFromBlock(block, ctx) {
|
|
|
2895
2978
|
if (typeof approvalChain !== "string" && (!isObject(approvalChain) || approvalChain.kind !== "approvalChain")) {
|
|
2896
2979
|
throw new EntityTfError("approval trigger has an unreconstructable approval chain");
|
|
2897
2980
|
}
|
|
2898
|
-
return { kind, app, approvalChain: approvalChain, status: block.attrs.status };
|
|
2981
|
+
return { kind, app, approvalChain: approvalChain, status: block.attrs.status, ...(filter ? { filter } : {}) };
|
|
2899
2982
|
}
|
|
2900
2983
|
case "dataMine":
|
|
2901
2984
|
{
|
|
@@ -2982,6 +3065,9 @@ function taskArgs(block, factory, ctx, taskDiagnostics) {
|
|
|
2982
3065
|
? field.fieldKey
|
|
2983
3066
|
: `${UNRESOLVED_FIELD_MARKER}${field.uuid}`;
|
|
2984
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;
|
|
2985
3071
|
const foreignInfo = field.kind === "field" && field.foreign !== undefined
|
|
2986
3072
|
? {
|
|
2987
3073
|
foreignFieldName: field.foreign.fieldName,
|
|
@@ -3002,12 +3088,12 @@ function taskArgs(block, factory, ctx, taskDiagnostics) {
|
|
|
3002
3088
|
values[fieldKey] = item.update_mode === "add" || foreignInfo !== undefined || platformFieldId !== undefined
|
|
3003
3089
|
? {
|
|
3004
3090
|
__fieldAssignment: true,
|
|
3005
|
-
value:
|
|
3091
|
+
value: canonicalValue,
|
|
3006
3092
|
...(item.update_mode === "add" ? { updateMode: "add" } : {}),
|
|
3007
3093
|
...(foreignInfo !== undefined ? foreignInfo : {}),
|
|
3008
3094
|
...(platformFieldId !== undefined ? { platformFieldId } : {}),
|
|
3009
3095
|
}
|
|
3010
|
-
:
|
|
3096
|
+
: canonicalValue;
|
|
3011
3097
|
}
|
|
3012
3098
|
args.values = values;
|
|
3013
3099
|
continue;
|
|
@@ -3548,9 +3634,12 @@ function taskArgs(block, factory, ctx, taskDiagnostics) {
|
|
|
3548
3634
|
continue;
|
|
3549
3635
|
}
|
|
3550
3636
|
const arg = ATTR_TO_ARG[attr] ?? attr.replace(/_([a-z])/g, (_, char) => char.toUpperCase());
|
|
3551
|
-
|
|
3637
|
+
const decoded = (attr === "record_reference" || attr === "record_id") && (factory === "createRecord" || factory === "updateField")
|
|
3552
3638
|
? decodeValueOrStringifiedRef(value, ctx, taskDiagnostics, `${block.type}.${block.label} ${attr}`)
|
|
3553
3639
|
: decodeValue(value, ctx);
|
|
3640
|
+
args[arg] = attr === "record_reference" && factory === "updateField"
|
|
3641
|
+
? canonicalTriggerRecordIdSlot(decoded, ctx)
|
|
3642
|
+
: decoded;
|
|
3554
3643
|
}
|
|
3555
3644
|
if (["recordSearch", "createRecord", "updateField", "bulkUpdateFields"].includes(factory))
|
|
3556
3645
|
args.app ??= appRef(ctx.appRefName);
|
|
@@ -3700,8 +3789,8 @@ function taskRefKey(block, automationLabel, appTfLabel) {
|
|
|
3700
3789
|
* conditions that make real extraction fail (zero triggers, an
|
|
3701
3790
|
* unrecognized task kind) so it over-collects rather than under-collects.
|
|
3702
3791
|
* More than one trigger throws {@link UnsupportedMultiTriggerError}. The
|
|
3703
|
-
* stream extractor
|
|
3704
|
-
*
|
|
3792
|
+
* stream extractor soft-skips those automations (diagnostic + skipped +
|
|
3793
|
+
* releaseIfManaged), so the rest of the app can still adopt (#1785).
|
|
3705
3794
|
* A false positive
|
|
3706
3795
|
* here just leaves one more resource unmanaged; a false negative would
|
|
3707
3796
|
* silently destroy a live automation on apply.
|
|
@@ -3882,9 +3971,9 @@ function unresolvedAuthoringValues(doc) {
|
|
|
3882
3971
|
/**
|
|
3883
3972
|
* EDK does not author multi-trigger automations; apps should keep one
|
|
3884
3973
|
* trigger and call the shared logic with a run-automation action. Stream
|
|
3885
|
-
* extraction
|
|
3886
|
-
*
|
|
3887
|
-
*
|
|
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.
|
|
3888
3977
|
*/
|
|
3889
3978
|
export class UnsupportedMultiTriggerError extends EntityTfError {
|
|
3890
3979
|
automationName;
|
|
@@ -3897,6 +3986,18 @@ export class UnsupportedMultiTriggerError extends EntityTfError {
|
|
|
3897
3986
|
this.triggerCount = triggerCount;
|
|
3898
3987
|
}
|
|
3899
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
|
+
}
|
|
3900
4001
|
/**
|
|
3901
4002
|
* #1320: a task reads the current item of a loop that doesn't enclose it.
|
|
3902
4003
|
* Pull skips the automation like any other exclusion, and additionally
|
|
@@ -3912,14 +4013,14 @@ export class ForEachItemOutsideLoopError extends EntityTfError {
|
|
|
3912
4013
|
}
|
|
3913
4014
|
}
|
|
3914
4015
|
/** Extract one app- or element-owned automation graph from an ei export. */
|
|
3915
|
-
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) {
|
|
3916
4017
|
const automation = doc.blocks.find((block) => block.kind === "resource" && block.type === AUTOMATION_RESOURCE_TYPE && block.label === automationLabel);
|
|
3917
4018
|
if (automation === undefined)
|
|
3918
4019
|
throw new EntityTfError(`automation resource "${automationLabel}" not found`);
|
|
3919
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));
|
|
3920
|
-
// N > 1 is a product non-support
|
|
3921
|
-
//
|
|
3922
|
-
//
|
|
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.
|
|
3923
4024
|
if (triggers.length > 1) {
|
|
3924
4025
|
const name = typeof automation.attrs.name === "string" && automation.attrs.name !== "" ? automation.attrs.name : automationLabel;
|
|
3925
4026
|
throw new UnsupportedMultiTriggerError(name, triggers.length);
|
|
@@ -4096,6 +4197,7 @@ function automationFromTfDocument(doc, automationLabel, appRefName, foreignField
|
|
|
4096
4197
|
stagesByKey.set(item.key, item.name);
|
|
4097
4198
|
}
|
|
4098
4199
|
}
|
|
4200
|
+
const stringifiedValueReferences = { unresolved: false };
|
|
4099
4201
|
const ctx = {
|
|
4100
4202
|
appRefName,
|
|
4101
4203
|
appTfLabel: app.label,
|
|
@@ -4119,6 +4221,7 @@ function automationFromTfDocument(doc, automationLabel, appRefName, foreignField
|
|
|
4119
4221
|
...(foreignTaskRefNames !== undefined && { foreignTaskRefNames }),
|
|
4120
4222
|
...(procedureKeysByDiscriminator !== undefined && { procedureKeysByDiscriminator }),
|
|
4121
4223
|
...(groupKeysByName !== undefined && { groupKeysByName }),
|
|
4224
|
+
stringifiedValueReferences,
|
|
4122
4225
|
};
|
|
4123
4226
|
let serviceAccountName;
|
|
4124
4227
|
const serviceAccountValue = automation.attrs.service_account_id;
|
|
@@ -4139,6 +4242,18 @@ function automationFromTfDocument(doc, automationLabel, appRefName, foreignField
|
|
|
4139
4242
|
}
|
|
4140
4243
|
}
|
|
4141
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
|
+
}
|
|
4142
4257
|
const dependencyOrder = new Map();
|
|
4143
4258
|
if (publish && Array.isArray(publish.attrs.depends_on))
|
|
4144
4259
|
publish.attrs.depends_on.forEach((dep, index) => { const ref = resourceRef(dep); if (ref)
|
|
@@ -4313,7 +4428,8 @@ function automationFromTfDocument(doc, automationLabel, appRefName, foreignField
|
|
|
4313
4428
|
...(typeof automation.attrs.description === "string" ? { description: automation.attrs.description } : {}),
|
|
4314
4429
|
...(typeof automation.attrs.triggers_other_automations === "boolean" ? { triggersOtherAutomations: automation.attrs.triggers_other_automations } : {}),
|
|
4315
4430
|
...(serviceAccountName !== undefined ? { serviceAccountName } : {}),
|
|
4316
|
-
|
|
4431
|
+
...(serviceAccountAppRefName !== undefined ? { serviceAccountAppRefName } : {}),
|
|
4432
|
+
status: automation.attrs.status === "INACTIVE" ? "INACTIVE" : publish ? "ACTIVE" : "DRAFT",
|
|
4317
4433
|
trigger: triggerFromBlock(trigger, ctx),
|
|
4318
4434
|
tasks: topTasks,
|
|
4319
4435
|
...(outputs && outputs.length > 0 ? { outputs } : {}),
|
|
@@ -4332,9 +4448,10 @@ function automationFromTfDocument(doc, automationLabel, appRefName, foreignField
|
|
|
4332
4448
|
...taskDiagnostics.map((message) => `automation "${automationLabel}": ${message}`),
|
|
4333
4449
|
],
|
|
4334
4450
|
}),
|
|
4451
|
+
...(stringifiedValueReferences.unresolved ? { stringifiedValueReferences: true } : {}),
|
|
4335
4452
|
};
|
|
4336
4453
|
}
|
|
4337
|
-
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) {
|
|
4338
4455
|
if (Array.isArray(first)) {
|
|
4339
4456
|
const ctx = second;
|
|
4340
4457
|
const automationBlock = first.find((block) => block.kind === "resource" && block.type === AUTOMATION_RESOURCE_TYPE);
|
|
@@ -4343,7 +4460,7 @@ export function automationFromTf(first, second, third, fourth, fifth, sixth, sev
|
|
|
4343
4460
|
throw new EntityTfError(`automation graph has no ${AUTOMATION_RESOURCE_TYPE} resource, so its resources (${addresses.join(", ") || "none"}) cannot be pulled`);
|
|
4344
4461
|
}
|
|
4345
4462
|
try {
|
|
4346
|
-
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);
|
|
4347
4464
|
if (result.diagnostics)
|
|
4348
4465
|
ctx.diagnostics.push(...result.diagnostics);
|
|
4349
4466
|
return { automation: result.ast };
|
|
@@ -4356,5 +4473,5 @@ export function automationFromTf(first, second, third, fourth, fifth, sixth, sev
|
|
|
4356
4473
|
return { skippedReason: message };
|
|
4357
4474
|
}
|
|
4358
4475
|
}
|
|
4359
|
-
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);
|
|
4360
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,67 @@ 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 `targets` that any block at `owned` references, if any. */
|
|
151
|
+
function referencedAddress(stream, owned, targets) {
|
|
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 (targets.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 extractedAutomations = [];
|
|
194
|
+
const lostChains = lostStageApprovalChains(stream, ctx);
|
|
141
195
|
for (const autoBlock of ownBlocks) {
|
|
142
196
|
const autoLabel = autoBlock.label ?? "";
|
|
143
197
|
const doc = { blocks: [...stream.allBlocks] };
|
|
@@ -145,34 +199,36 @@ function extractAutomations(ownBlocks, stream, ctx) {
|
|
|
145
199
|
// somehow omits the app RefExpr still feeds --with-dependencies. Cheap
|
|
146
200
|
// (one owned-address walk) relative to from-tf.
|
|
147
201
|
registerForeignObjectIdDeps(doc, autoLabel, ctx);
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
202
|
+
// An approval chain on a stage with no handle of its own is left
|
|
203
|
+
// unmanaged (#1136), so a reference to it would dangle at build. Skip the
|
|
204
|
+
// automation with a warning and release an earlier adoption of it.
|
|
205
|
+
if (lostChains.size > 0) {
|
|
206
|
+
const owned = automationOwnedAddresses(doc, autoLabel);
|
|
207
|
+
const chain = referencedAddress(stream, owned, lostChains);
|
|
208
|
+
if (chain !== undefined) {
|
|
209
|
+
skipped.push(...owned);
|
|
210
|
+
releaseIfManaged.push(...owned);
|
|
211
|
+
diagnostics.push(droppedAutomationGap(autoBlock, autoLabel, `it references ${chain}, which is left unmanaged because its stage has no handle of its own (#1136)`));
|
|
212
|
+
continue;
|
|
213
|
+
}
|
|
157
214
|
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
//
|
|
161
|
-
//
|
|
162
|
-
//
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
};
|
|
171
|
-
validations.push(failure);
|
|
172
|
-
recordValidations([failure]);
|
|
173
|
-
skipped.push(...automationOwnedAddresses(doc, autoLabel));
|
|
215
|
+
try {
|
|
216
|
+
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);
|
|
217
|
+
// edk#1646 / #1858: adopt when a rebuilt ctx ref matches provider Read.
|
|
218
|
+
// Otherwise the automation stays platform-managed. Releasing its state
|
|
219
|
+
// also archives the authored file, so the next plan does not create a
|
|
220
|
+
// second copy of the live automation.
|
|
221
|
+
if (extracted.stringifiedValueReferences === true) {
|
|
222
|
+
const owned = automationOwnedAddresses(doc, autoLabel);
|
|
223
|
+
skipped.push(...owned);
|
|
224
|
+
releaseIfManaged.push(...owned);
|
|
225
|
+
quarantineOwnFiles.push({ kind: "automation", refName: extracted.refName });
|
|
226
|
+
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."));
|
|
174
227
|
continue;
|
|
175
228
|
}
|
|
229
|
+
extractedAutomations.push({ autoBlock, autoLabel, owned: automationOwnedAddresses(doc, autoLabel), extracted });
|
|
230
|
+
}
|
|
231
|
+
catch (err) {
|
|
176
232
|
// Report the automation's FULL graph (trigger/tasks/branches/publish),
|
|
177
233
|
// not just its root - otherwise those children's otherwise-adoptable
|
|
178
234
|
// resource TYPES get imported into state anyway, and build (which
|
|
@@ -180,21 +236,65 @@ function extractAutomations(ownBlocks, stream, ctx) {
|
|
|
180
236
|
// `plan` shows them as destroy-on-apply. See automationOwnedAddresses.
|
|
181
237
|
const owned = automationOwnedAddresses(doc, autoLabel);
|
|
182
238
|
skipped.push(...owned);
|
|
183
|
-
//
|
|
184
|
-
//
|
|
185
|
-
//
|
|
186
|
-
//
|
|
187
|
-
//
|
|
188
|
-
if (err instanceof ForEachItemOutsideLoopError
|
|
239
|
+
// No authored form can manage these, so release an earlier adoption
|
|
240
|
+
// rather than let the next apply destroy the live automation:
|
|
241
|
+
// sibling-loop item refs (#1320) and multi-trigger (#1785 / #39).
|
|
242
|
+
// Soft diagnostic, not a validation fatal — the rest of the app must
|
|
243
|
+
// still adopt and plan clean while these stay platform-managed only.
|
|
244
|
+
if (err instanceof ForEachItemOutsideLoopError ||
|
|
245
|
+
err instanceof UnsupportedMultiTriggerError ||
|
|
246
|
+
err instanceof UnresolvedForeignServiceAccountError) {
|
|
189
247
|
releaseIfManaged.push(...owned);
|
|
248
|
+
}
|
|
249
|
+
if (err instanceof UnresolvedForeignServiceAccountError) {
|
|
250
|
+
quarantineOwnFiles.push({
|
|
251
|
+
kind: "automation",
|
|
252
|
+
refName: scopedLabelToBagKey(ctx.appTfLabel, autoLabel),
|
|
253
|
+
});
|
|
254
|
+
}
|
|
190
255
|
// edk#1480: name the dropped automation and say what that means, as a
|
|
191
256
|
// typed gap so it counts (and fails --strict-coverage) by itself.
|
|
192
257
|
diagnostics.push(droppedAutomationGap(autoBlock, autoLabel, err instanceof Error ? err.message : String(err)));
|
|
193
258
|
}
|
|
194
259
|
}
|
|
260
|
+
// An automation that runs a skipped automation (or reads its trigger's
|
|
261
|
+
// parameter ids) would print a ref to an automation source never gets, and
|
|
262
|
+
// its export would keep a reference to a resource adoption strips. Skip it
|
|
263
|
+
// too, transitively, and release it only when its target was released.
|
|
264
|
+
const kept = new Set(extractedAutomations);
|
|
265
|
+
for (let cascaded = true; cascaded;) {
|
|
266
|
+
cascaded = false;
|
|
267
|
+
const skippedAddresses = new Set(skipped);
|
|
268
|
+
const releasedAddresses = new Set(releaseIfManaged);
|
|
269
|
+
for (const entry of kept) {
|
|
270
|
+
const target = referencedAddress(stream, entry.owned, skippedAddresses);
|
|
271
|
+
if (target === undefined)
|
|
272
|
+
continue;
|
|
273
|
+
kept.delete(entry);
|
|
274
|
+
cascaded = true;
|
|
275
|
+
skipped.push(...entry.owned);
|
|
276
|
+
if (releasedAddresses.has(target)) {
|
|
277
|
+
releaseIfManaged.push(...entry.owned);
|
|
278
|
+
quarantineOwnFiles.push({ kind: "automation", refName: entry.extracted.refName });
|
|
279
|
+
}
|
|
280
|
+
diagnostics.push(droppedAutomationGap(entry.autoBlock, entry.autoLabel, `it references ${target}, which is skipped, so the reference would dangle`));
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
for (const { autoLabel, extracted } of kept) {
|
|
284
|
+
// Keep automationFromTf's label-derived refName — agent/skill tools store
|
|
285
|
+
// the same scopedLabelToBagKey as automationKey. Pushing bare AST (name
|
|
286
|
+
// only) made missing-automation diagnostics false-positive on every real
|
|
287
|
+
// extract (issue #395 / PR #417 review).
|
|
288
|
+
items.push({ ...extracted.ast, refName: extracted.refName });
|
|
289
|
+
adoptionAddressAliases.push(...extracted.adoptionAddressAliases);
|
|
290
|
+
diagnostics.push(...(extracted.diagnostics ?? []).map((diagnostic) => `${autoLabel}: ${diagnostic}`));
|
|
291
|
+
}
|
|
195
292
|
// A trigger, task, or publish with no automation resource is not in any
|
|
196
293
|
// skeleton's graph. extractAutomations never sees it, and its resource type
|
|
197
|
-
// is still adoptable, so the next plan can destroy it (#1484).
|
|
294
|
+
// is still adoptable, so the next plan can destroy it (#1484). Soft-skip
|
|
295
|
+
// rather than authoring-block the whole app: Blueprint exports sometimes
|
|
296
|
+
// omit a trigger (or leave a task without parent), and hard-failing hid
|
|
297
|
+
// the rest of the app from adoption (rfxclarificationquestion Retire Q&A).
|
|
198
298
|
const doc = { blocks: [...stream.allBlocks] };
|
|
199
299
|
const owned = new Set();
|
|
200
300
|
for (const autoBlock of ownBlocks) {
|
|
@@ -210,14 +310,18 @@ function extractAutomations(ownBlocks, stream, ctx) {
|
|
|
210
310
|
if (owned.has(address))
|
|
211
311
|
continue;
|
|
212
312
|
skipped.push(address);
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
313
|
+
releaseIfManaged.push(address);
|
|
314
|
+
const display = typeof block.attrs["name"] === "string" && block.attrs["name"] !== ""
|
|
315
|
+
? block.attrs["name"]
|
|
316
|
+
: block.label;
|
|
317
|
+
diagnostics.push(typedCoverageGap({
|
|
318
|
+
kind: "skipped",
|
|
319
|
+
entity: `${block.type} ${JSON.stringify(display)} (${block.label})`,
|
|
320
|
+
detail: "not pulled, skipped: not owned by an elementum_automation resource (export is missing the owning automation or the task has no parent chain)",
|
|
321
|
+
consequence: "it is not written to source or adopted; it keeps running on the platform unmanaged",
|
|
322
|
+
}));
|
|
219
323
|
}
|
|
220
|
-
return { items, skipped, releaseIfManaged,
|
|
324
|
+
return { items, skipped, releaseIfManaged, quarantineOwnFiles, diagnostics, adoptionAddressAliases };
|
|
221
325
|
}
|
|
222
326
|
export const automationModule = {
|
|
223
327
|
kind: "automation",
|
|
@@ -308,9 +412,11 @@ export const automationModule = {
|
|
|
308
412
|
fieldMetadata: ctx.fieldMetadata ?? new Map(),
|
|
309
413
|
...(ctx.fieldNamesByAppRefName !== undefined ? { fieldNamesByAppRefName: ctx.fieldNamesByAppRefName } : {}),
|
|
310
414
|
...(ctx.fieldAddressesByAppRefName !== undefined ? { fieldAddressesByAppRefName: ctx.fieldAddressesByAppRefName } : {}),
|
|
415
|
+
...(ctx.authoredAspectKeys !== undefined ? { authoredAspectKeys: ctx.authoredAspectKeys } : {}),
|
|
311
416
|
...(ctx.allowUnknownPicklistOptions === true ? { allowUnknownPicklistOptions: true } : {}),
|
|
312
417
|
orgRefs: ctx.orgRefs,
|
|
313
418
|
workspaceAspects: ctx.workspaceAspects,
|
|
419
|
+
...(ctx.outOfScopeApps !== undefined && { outOfScopeApps: ctx.outOfScopeApps }),
|
|
314
420
|
localsAttrs: ctx.localsAttrs,
|
|
315
421
|
serviceAccounts: ctx.streamRootEntity?.payload?.serviceAccounts,
|
|
316
422
|
activeAutomationRefNames: ctx.activeAutomationRefNames ?? new Set((ctx.siblingEntities ?? [])
|
|
@@ -352,6 +458,14 @@ export const automationModule = {
|
|
|
352
458
|
localPrefix: "edk_variable_ids_",
|
|
353
459
|
listField: "id",
|
|
354
460
|
}],
|
|
461
|
+
// The provider's create_record / update_field / bulk_update_fields
|
|
462
|
+
// ModifyPlan equates these (`picklistValuesEquivalent`, #633), so plan
|
|
463
|
+
// stays clean whichever one the platform stored (#1891).
|
|
464
|
+
picklistLabelAssignments: [
|
|
465
|
+
"elementum_create_record_task",
|
|
466
|
+
"elementum_update_field_task",
|
|
467
|
+
"elementum_bulk_update_fields_task",
|
|
468
|
+
].map((resourceType) => ({ resourceType, attribute: "fields", fieldAttribute: "field_id", valueAttribute: "value" })),
|
|
355
469
|
},
|
|
356
470
|
};
|
|
357
471
|
/** The provider's `normalizeOnDemandFilterRefName`, which computes `filter_refs` at plan time. */
|
|
@@ -10,6 +10,14 @@
|
|
|
10
10
|
* dependency-free like `output-key-wire-name.ts` so importing it from
|
|
11
11
|
* either side can never introduce a cycle.
|
|
12
12
|
*/
|
|
13
|
+
/**
|
|
14
|
+
* True when the schema's only top-level property is a TEXT list (a format-less
|
|
15
|
+
* or EMAIL/UUID4 string array). The runtime then also fills
|
|
16
|
+
* `stringArrayResult` with it (#1725 live repro). DATE/DATETIME and object
|
|
17
|
+
* arrays don't count, and an unwrapped `{ properties }` root is no schema, as
|
|
18
|
+
* in build's `declaredScriptResultProperties`.
|
|
19
|
+
*/
|
|
20
|
+
export declare function scriptSchemaIsSingleStringArray(schema: unknown): boolean;
|
|
13
21
|
/** Map executeScript output_schema properties to refs keys (`result.<name>`). */
|
|
14
22
|
export declare function outputFieldTypesFromScriptSchema(schema: unknown): Map<string, {
|
|
15
23
|
fieldType: string;
|