@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
|
@@ -62,3 +62,24 @@ export declare const API_TASK_REF_AUTHORING_NAMES: Readonly<Record<string, strin
|
|
|
62
62
|
* callers can fall back to the generic segment mapping.
|
|
63
63
|
*/
|
|
64
64
|
export declare function apiTaskRefAuthoringPath(wireSegment: string): string[] | undefined;
|
|
65
|
+
/**
|
|
66
|
+
* executeScript contract outputs whose authoring name is not the refs-map key.
|
|
67
|
+
*
|
|
68
|
+
* Live provider state (UA Activity) keys the whole JSON result as `Result`
|
|
69
|
+
* and the text-list contract output as `Text List Result`. The canonical
|
|
70
|
+
* taskReference names — and the accessors EDK authors — stay `result` and
|
|
71
|
+
* `stringArrayResult`. Property refs stay `result.<prop>` on both sides, so
|
|
72
|
+
* this table is exact keys only: `result.passed` must not become `Result.passed`.
|
|
73
|
+
* `numberArrayResult` is already the refs key. A variable named `Result` is a
|
|
74
|
+
* different resource and must not use this table.
|
|
75
|
+
*/
|
|
76
|
+
export declare const EXECUTE_SCRIPT_REFS_INDEX: Readonly<Record<string, string>>;
|
|
77
|
+
/** Inverse of {@link EXECUTE_SCRIPT_REFS_INDEX}, plus the canonical names themselves. */
|
|
78
|
+
export declare const EXECUTE_SCRIPT_REF_AUTHORING_PATH: Readonly<Record<string, readonly string[]>>;
|
|
79
|
+
/** refs-map key for one executeScript contract output, or undefined when `name` is not one. */
|
|
80
|
+
export declare function executeScriptRefsIndex(name: string): string | undefined;
|
|
81
|
+
/**
|
|
82
|
+
* Authoring path for an executeScript refs key or canonical output name.
|
|
83
|
+
* Undefined for `result.<prop>` and for any other task's output.
|
|
84
|
+
*/
|
|
85
|
+
export declare function executeScriptAuthoringPath(name: string): readonly string[] | undefined;
|
|
@@ -84,3 +84,41 @@ export function apiTaskRefAuthoringPath(wireSegment) {
|
|
|
84
84
|
const authoring = API_TASK_REF_AUTHORING_NAMES[wireSegment];
|
|
85
85
|
return authoring !== undefined ? authoring.split(".") : undefined;
|
|
86
86
|
}
|
|
87
|
+
/**
|
|
88
|
+
* executeScript contract outputs whose authoring name is not the refs-map key.
|
|
89
|
+
*
|
|
90
|
+
* Live provider state (UA Activity) keys the whole JSON result as `Result`
|
|
91
|
+
* and the text-list contract output as `Text List Result`. The canonical
|
|
92
|
+
* taskReference names — and the accessors EDK authors — stay `result` and
|
|
93
|
+
* `stringArrayResult`. Property refs stay `result.<prop>` on both sides, so
|
|
94
|
+
* this table is exact keys only: `result.passed` must not become `Result.passed`.
|
|
95
|
+
* `numberArrayResult` is already the refs key. A variable named `Result` is a
|
|
96
|
+
* different resource and must not use this table.
|
|
97
|
+
*/
|
|
98
|
+
export const EXECUTE_SCRIPT_REFS_INDEX = {
|
|
99
|
+
result: "Result",
|
|
100
|
+
textResult: "Text Result",
|
|
101
|
+
stringArrayResult: "Text List Result",
|
|
102
|
+
numberArrayResult: "numberArrayResult",
|
|
103
|
+
};
|
|
104
|
+
/** Inverse of {@link EXECUTE_SCRIPT_REFS_INDEX}, plus the canonical names themselves. */
|
|
105
|
+
export const EXECUTE_SCRIPT_REF_AUTHORING_PATH = {
|
|
106
|
+
Result: ["result"],
|
|
107
|
+
result: ["result"],
|
|
108
|
+
"Text Result": ["textResult"],
|
|
109
|
+
textResult: ["textResult"],
|
|
110
|
+
"Text List Result": ["stringArrayResult"],
|
|
111
|
+
stringArrayResult: ["stringArrayResult"],
|
|
112
|
+
numberArrayResult: ["numberArrayResult"],
|
|
113
|
+
};
|
|
114
|
+
/** refs-map key for one executeScript contract output, or undefined when `name` is not one. */
|
|
115
|
+
export function executeScriptRefsIndex(name) {
|
|
116
|
+
return EXECUTE_SCRIPT_REFS_INDEX[name];
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Authoring path for an executeScript refs key or canonical output name.
|
|
120
|
+
* Undefined for `result.<prop>` and for any other task's output.
|
|
121
|
+
*/
|
|
122
|
+
export function executeScriptAuthoringPath(name) {
|
|
123
|
+
return EXECUTE_SCRIPT_REF_AUTHORING_PATH[name];
|
|
124
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { DeployableEntity } from "../../engine/entity.js";
|
|
2
2
|
import { type ValidationFailure } from "../../engine/validation.js";
|
|
3
3
|
import { type ChildResourceScope, type TfBlock, type TfExpr, type TfValue } from "../../engine/tf/index.js";
|
|
4
|
-
import { type OrgRefLookup, type WorkspaceAspect } from "../../engine/build/context.js";
|
|
4
|
+
import { type ForeignRootIdentity, type OrgRefLookup, type WorkspaceAspect } from "../../engine/build/context.js";
|
|
5
5
|
import type { BuildFieldMetadata } from "../../graph/types.js";
|
|
6
6
|
import type { AppServiceAccount } from "../service-account/build.js";
|
|
7
7
|
export interface AutomationToTfContext {
|
|
@@ -59,6 +59,8 @@ export interface AutomationToTfContext {
|
|
|
59
59
|
* label shape from an element-owned one.
|
|
60
60
|
*/
|
|
61
61
|
readonly workspaceAspects?: ReadonlyMap<string, WorkspaceAspect>;
|
|
62
|
+
/** See `ToTfContext.outOfScopeApps`. */
|
|
63
|
+
readonly outOfScopeApps?: ReadonlyMap<string, ForeignRootIdentity>;
|
|
62
64
|
/**
|
|
63
65
|
* The build's shared `locals.tf` attrs map — mutated in place so a foreign
|
|
64
66
|
* field crossing through {@link crossAppFieldToTf} can contribute its own
|
|
@@ -8,10 +8,12 @@ import { workspaceAspectKey } from "../../engine/build/context.js";
|
|
|
8
8
|
import { SEARCH_TABLE_RESOURCE_TYPES } from "../search-table/types.js";
|
|
9
9
|
import { fieldRefToTfValue } from "../field/to-tf.js";
|
|
10
10
|
import { SERVICE_ACCOUNT_RESOURCE_TYPE } from "../service-account/module.js";
|
|
11
|
+
import { serviceAccountRefToTf } from "../service-account/to-tf.js";
|
|
12
|
+
import { workspaceServiceAccountAppResolver } from "../service-account/workspace-owner.js";
|
|
11
13
|
import { foreignFieldDataLabel, resolveForeignRef } from "../shared/foreign-ref.js";
|
|
12
14
|
import { filterToTf as serializeFilterToTf } from "../shared/filters/tf-codec.js";
|
|
13
15
|
import { referenceValueTypeForField } from "../shared/filters/index.js";
|
|
14
|
-
import { API_TASK_REF_AUTHORING_NAMES, API_TASK_REF_WIRE_NAMES, OUTPUT_KEY_CANONICAL, OUTPUT_KEY_WIRE_NAME } from "./output-key-wire-name.js";
|
|
16
|
+
import { API_TASK_REF_AUTHORING_NAMES, API_TASK_REF_WIRE_NAMES, executeScriptRefsIndex, OUTPUT_KEY_CANONICAL, OUTPUT_KEY_WIRE_NAME } from "./output-key-wire-name.js";
|
|
15
17
|
import { outputFieldTypesFromScriptSchema, scriptOutputReferenceIsDeclared } from "./output-field-types.js";
|
|
16
18
|
import { RESOURCE_TYPE_TO_EXECUTOR, TASK_OUTPUT_CONTRACTS } from "./generated/task-output-contracts.js";
|
|
17
19
|
import { CONNECTOR_ORG_BAG } from "../org/connector.js";
|
|
@@ -26,7 +28,7 @@ import { onDemandTriggerRefKey } from "./value-ref-tf.js";
|
|
|
26
28
|
import { normalizeOnDemandParamKey } from "../../../pull/util.js";
|
|
27
29
|
import { PROVIDER_FIXED_SYSTEM_FIELD_KEYS, recordFieldWireRefName } from "./system-ref-name.js";
|
|
28
30
|
import { taskTfLabel } from "./task-label.js";
|
|
29
|
-
import { isOnDemandRecordType } from "../shared/types/field-types.js";
|
|
31
|
+
import { FIELD_TYPE_MAP, isOnDemandRecordType } from "../shared/types/field-types.js";
|
|
30
32
|
/** The context for reading records of `appRefName` (a `kind`), retargeted from the owner. */
|
|
31
33
|
/**
|
|
32
34
|
* Wire WorkflowFieldType -> elementum_on_demand_trigger `parameters[].type`.
|
|
@@ -501,6 +503,19 @@ function registerForeignFieldLookup(value, ctx, dataBlocks) {
|
|
|
501
503
|
registerForeignOptionsByLabelLocal(fieldLabel, ctx);
|
|
502
504
|
return fieldLabel;
|
|
503
505
|
}
|
|
506
|
+
/**
|
|
507
|
+
* A bare platform-id target whose every input names a raw parameter id is a
|
|
508
|
+
* static run: pull prints a static export with an undiscovered target
|
|
509
|
+
* (`target_automation_id` + `input_mappings[].parameter_id`) as
|
|
510
|
+
* `automation: "<uuid>"` + `inputs[].name: "<uuid>"`. Dynamic mappings name
|
|
511
|
+
* the target's inputs, never a parameter id.
|
|
512
|
+
*/
|
|
513
|
+
function bareStaticRunTarget(config) {
|
|
514
|
+
return typeof config.targetAutomationId === "string" &&
|
|
515
|
+
Array.isArray(config.inputMappings) &&
|
|
516
|
+
config.inputMappings.length > 0 &&
|
|
517
|
+
config.inputMappings.every((mapping) => isObject(mapping) && typeof mapping.name === "string" && isUuid(mapping.name));
|
|
518
|
+
}
|
|
504
519
|
/**
|
|
505
520
|
* Resolve an automation token as a managed definition (same stream root or a
|
|
506
521
|
* sibling root in this build) or as a ref-only `data.elementum_automation`
|
|
@@ -1663,6 +1678,13 @@ function taskOutputWireRefKey(targetType, name, taskRefKey, refs) {
|
|
|
1663
1678
|
(name === "records" || name === "All matching table rows")) {
|
|
1664
1679
|
return "All matching table rows";
|
|
1665
1680
|
}
|
|
1681
|
+
// refs index only. Envelopes and calc mustaches keep the canonical name
|
|
1682
|
+
// (`result`, `stringArrayResult`); the provider refs map does not (#1656).
|
|
1683
|
+
if (targetType === "elementum_execute_script_task") {
|
|
1684
|
+
const scriptIndex = executeScriptRefsIndex(name);
|
|
1685
|
+
if (scriptIndex !== undefined)
|
|
1686
|
+
return scriptIndex;
|
|
1687
|
+
}
|
|
1666
1688
|
return taskWireRefName(name, taskRefKey, refs);
|
|
1667
1689
|
}
|
|
1668
1690
|
/** The platform's own on-demand "Triggered By" refs (live refs-map keys). */
|
|
@@ -2172,6 +2194,53 @@ function unresolvedForEachFailures(entity, payload, address) {
|
|
|
2172
2194
|
"(e.g. restructure the loops, or pass the value through a variable) before this automation can build",
|
|
2173
2195
|
}));
|
|
2174
2196
|
}
|
|
2197
|
+
/**
|
|
2198
|
+
* An on-demand scalar whose refs key is also a record field's display name.
|
|
2199
|
+
* The field owns that key, so the parameter is written as the same envelope
|
|
2200
|
+
* export uses (`buildTriggerRefJSONFull`: fieldType, multiple, and the
|
|
2201
|
+
* normalized trigger name) instead of `refs["<display name>"]`.
|
|
2202
|
+
*/
|
|
2203
|
+
function shadowedOnDemandParamRef(value, refs) {
|
|
2204
|
+
if (refs.trigger.type !== TRIGGER_RESOURCES.onDemand)
|
|
2205
|
+
return undefined;
|
|
2206
|
+
if (!isObject(value.triggerReference) || typeof value.triggerReference.name !== "string")
|
|
2207
|
+
return undefined;
|
|
2208
|
+
const inputName = onDemandTriggerRefKey(value.triggerReference.name, [...refs.triggerParamFieldTypes.keys()]);
|
|
2209
|
+
const input = refs.triggerParamFieldTypes.get(inputName);
|
|
2210
|
+
if (input === undefined ||
|
|
2211
|
+
refs.recordParamNames.includes(inputName) ||
|
|
2212
|
+
refs.userParamNames.includes(inputName))
|
|
2213
|
+
return undefined;
|
|
2214
|
+
const refsKey = triggerWireRefName(value.triggerReference.name, refs);
|
|
2215
|
+
let ownedByField = false;
|
|
2216
|
+
for (const displayName of refs.owner.fieldNames.values()) {
|
|
2217
|
+
if (displayName === refsKey) {
|
|
2218
|
+
ownedByField = true;
|
|
2219
|
+
break;
|
|
2220
|
+
}
|
|
2221
|
+
}
|
|
2222
|
+
if (!ownedByField)
|
|
2223
|
+
return undefined;
|
|
2224
|
+
const typed = typeof value.fieldType === "string"
|
|
2225
|
+
? { fieldType: value.fieldType, multiple: value.multiple === true }
|
|
2226
|
+
: { fieldType: onDemandEnvelopeFieldType(input.fieldType), multiple: input.multiple };
|
|
2227
|
+
return {
|
|
2228
|
+
fieldType: typed.fieldType,
|
|
2229
|
+
multiple: typed.multiple,
|
|
2230
|
+
triggerReference: { name: normalizeOnDemandParamKey(inputName) },
|
|
2231
|
+
};
|
|
2232
|
+
}
|
|
2233
|
+
/** Authoring / HCL parameter type → the WorkflowFieldType export writes into the envelope. */
|
|
2234
|
+
function onDemandEnvelopeFieldType(type) {
|
|
2235
|
+
if (type === "attachment")
|
|
2236
|
+
return "ATTACHMENT_ID";
|
|
2237
|
+
if (type === "group")
|
|
2238
|
+
return "GROUP_ID";
|
|
2239
|
+
const mapped = FIELD_TYPE_MAP[type];
|
|
2240
|
+
if (mapped !== undefined)
|
|
2241
|
+
return mapped;
|
|
2242
|
+
return type;
|
|
2243
|
+
}
|
|
2175
2244
|
/**
|
|
2176
2245
|
* execute_script `inputs[].value` only. Provider Read stores the
|
|
2177
2246
|
* Mobius-normalized short name (`reasonForClosingEarly`) for on-demand
|
|
@@ -2239,6 +2308,35 @@ function normalizeTriggerRecordIdEnvelopeString(raw, refs) {
|
|
|
2239
2308
|
envelope.multiple = false;
|
|
2240
2309
|
return JSON.stringify(envelope);
|
|
2241
2310
|
}
|
|
2311
|
+
function undeclaredExecuteScriptFieldEnvelope(reference, refs, fieldType = "TEXT") {
|
|
2312
|
+
let value = reference;
|
|
2313
|
+
while (isObject(value) && "value" in value && Object.keys(value).length === 1) {
|
|
2314
|
+
value = value.value;
|
|
2315
|
+
}
|
|
2316
|
+
if (!isObject(value) || !isObject(value.taskReference))
|
|
2317
|
+
return undefined;
|
|
2318
|
+
const taskRef = value.taskReference;
|
|
2319
|
+
const taskRefKey = taskRef.taskRefKey;
|
|
2320
|
+
const name = taskRef.name;
|
|
2321
|
+
if (typeof taskRefKey !== "string" || typeof name !== "string" || !name.startsWith("result."))
|
|
2322
|
+
return undefined;
|
|
2323
|
+
const task = refs.tasks.get(taskRefKey);
|
|
2324
|
+
if (task?.type !== TASK_RESOURCES.executeScript)
|
|
2325
|
+
return undefined;
|
|
2326
|
+
// A declared output is a real refs["result.<key>"] entry. An undeclared one
|
|
2327
|
+
// (outputs omitted, or a key the schema does not list) is not in that map —
|
|
2328
|
+
// indexing it fails the plan. Provider Read stores the JSON envelope instead.
|
|
2329
|
+
if (task.outputFieldTypes !== undefined && scriptOutputReferenceIsDeclared(task.outputFieldTypes, name))
|
|
2330
|
+
return undefined;
|
|
2331
|
+
return expr.jsonencode({
|
|
2332
|
+
fieldType,
|
|
2333
|
+
multiple: false,
|
|
2334
|
+
taskReference: {
|
|
2335
|
+
name,
|
|
2336
|
+
taskId: expr.resourceAttr(task.type, task.label, ["id"]),
|
|
2337
|
+
},
|
|
2338
|
+
});
|
|
2339
|
+
}
|
|
2242
2340
|
function valueToTf(value, refs) {
|
|
2243
2341
|
const catalog = token(value);
|
|
2244
2342
|
if (catalog !== undefined)
|
|
@@ -2291,6 +2389,9 @@ function valueToTf(value, refs) {
|
|
|
2291
2389
|
if (payloadRef !== undefined)
|
|
2292
2390
|
return expr.jsonencode(payloadRef);
|
|
2293
2391
|
}
|
|
2392
|
+
const shadowedParam = shadowedOnDemandParamRef(value, refs);
|
|
2393
|
+
if (shadowedParam !== undefined)
|
|
2394
|
+
return expr.jsonencode(shadowedParam);
|
|
2294
2395
|
return expr.resourceAttr(refs.trigger.type, refs.trigger.label, ["refs", { index: triggerWireRefName(value.triggerReference.name, refs) }]);
|
|
2295
2396
|
}
|
|
2296
2397
|
if (isObject(value.taskReference) && typeof value.taskReference.taskRefKey === "string" && typeof value.taskReference.name === "string") {
|
|
@@ -2315,7 +2416,7 @@ function valueToTf(value, refs) {
|
|
|
2315
2416
|
? refs.owner
|
|
2316
2417
|
: recordOwnerContext(refs.owner, sourceApp, taskTargetKind(source, refs), sourceApp === refs.owner.appRefName
|
|
2317
2418
|
? refs.owner.fieldNames
|
|
2318
|
-
: fieldNamesForAppRefName(refs.fieldNamesByAppRefName, sourceApp)
|
|
2419
|
+
: fieldNamesForAppRefName(refs.fieldNamesByAppRefName, sourceApp)), refs.recordItemForEachRefKeys.has(value.forEachReference.forEachTaskRefKey));
|
|
2319
2420
|
return expr.resourceAttr(target.type, target.label, ["inner", "refs", { index }]);
|
|
2320
2421
|
}
|
|
2321
2422
|
if (isObject(value.templateReference))
|
|
@@ -2422,6 +2523,7 @@ function canonicalSingleOutputName(resourceType, wireName) {
|
|
|
2422
2523
|
return undefined;
|
|
2423
2524
|
return OUTPUT_KEY_CANONICAL[taskKey];
|
|
2424
2525
|
}
|
|
2526
|
+
const TRIGGER_REFERENCE_NAME_PATTERN = /^[a-z][A-Za-z0-9]*(?:\.[a-z][A-Za-z0-9]*)*$/;
|
|
2425
2527
|
function filterReferenceToTf(value, refs, role = "value", realType, operator) {
|
|
2426
2528
|
// Raw pass-through for a filter left side the pull-time deserializer
|
|
2427
2529
|
// couldn't decode to a typed ref (filter.ts's leftDescriptor, matching the
|
|
@@ -2546,6 +2648,13 @@ function filterReferenceToTf(value, refs, role = "value", realType, operator) {
|
|
|
2546
2648
|
}
|
|
2547
2649
|
return expr.resourceAttr(refs.trigger.type, refs.trigger.label, ["filter_refs", { index: triggerRefKey }]);
|
|
2548
2650
|
}
|
|
2651
|
+
// `refs` is keyed by display label. A camelCase path with no display
|
|
2652
|
+
// mapping is the platform's own reference name (`approver.id`, which
|
|
2653
|
+
// `refs` labels "Final Approval By's id"); the short form is how
|
|
2654
|
+
// export and provider Read spell it.
|
|
2655
|
+
if (triggerRefKey === value.name && TRIGGER_REFERENCE_NAME_PATTERN.test(value.name)) {
|
|
2656
|
+
return `trigger.${value.name}`;
|
|
2657
|
+
}
|
|
2549
2658
|
return expr.resourceAttr(refs.trigger.type, refs.trigger.label, ["refs", { index: triggerRefKey }]);
|
|
2550
2659
|
}
|
|
2551
2660
|
case "TASK": {
|
|
@@ -2625,17 +2734,24 @@ function filterReferenceToTf(value, refs, role = "value", realType, operator) {
|
|
|
2625
2734
|
},
|
|
2626
2735
|
});
|
|
2627
2736
|
}
|
|
2628
|
-
//
|
|
2629
|
-
//
|
|
2630
|
-
//
|
|
2631
|
-
//
|
|
2737
|
+
// Provider Read types a left-value envelope by the comparison's
|
|
2738
|
+
// `real_type` when that differs from the output's declared type: a
|
|
2739
|
+
// text check of a BOOLEAN, NUMBER, or DECIMAL output (#1442), and a
|
|
2740
|
+
// text or uuid check of an ASPECT_RECORD_ID record id (#1569).
|
|
2741
|
+
// `multiple` follows the declaration so an array output is not
|
|
2742
|
+
// flattened. A NUMBER comparison of a DECIMAL script output is the
|
|
2743
|
+
// next branch (#1618).
|
|
2632
2744
|
const envelopeName = TASK_OUTPUT_REFERENCE_NAMES[task.type]?.[wireName] ?? wireName;
|
|
2633
2745
|
const executor = RESOURCE_TYPE_TO_EXECUTOR[task.type];
|
|
2634
2746
|
const declared = task.outputFieldTypes?.get(wireName) ??
|
|
2635
2747
|
(executor === undefined ? undefined : TASK_OUTPUT_CONTRACTS[executor]?.[envelopeName]);
|
|
2636
|
-
|
|
2748
|
+
const compared = realType?.toUpperCase();
|
|
2749
|
+
if (compared !== undefined &&
|
|
2750
|
+
declared !== undefined &&
|
|
2751
|
+
declared.fieldType !== compared &&
|
|
2752
|
+
!(compared === "NUMBER" && declared.fieldType === "DECIMAL")) {
|
|
2637
2753
|
return expr.jsonencode({
|
|
2638
|
-
fieldType:
|
|
2754
|
+
fieldType: compared,
|
|
2639
2755
|
multiple: declared.multiple,
|
|
2640
2756
|
taskReference: {
|
|
2641
2757
|
name: envelopeName,
|
|
@@ -2702,7 +2818,10 @@ function filterReferenceToTf(value, refs, role = "value", realType, operator) {
|
|
|
2702
2818
|
},
|
|
2703
2819
|
});
|
|
2704
2820
|
}
|
|
2705
|
-
|
|
2821
|
+
const refsIndex = task.type === TASK_RESOURCES.executeScript
|
|
2822
|
+
? executeScriptRefsIndex(wireName) ?? wireName
|
|
2823
|
+
: wireName;
|
|
2824
|
+
return expr.resourceAttr(task.type, task.label, ["refs", { index: refsIndex }]);
|
|
2706
2825
|
}
|
|
2707
2826
|
const recordFieldName = foundRecordFieldReferenceName(task.type, value.name, value.taskRefKey, refs);
|
|
2708
2827
|
// The short form addresses user-search outputs by path, and an AI task's
|
|
@@ -2931,10 +3050,10 @@ function filterToTf(value, refs) {
|
|
|
2931
3050
|
}
|
|
2932
3051
|
/**
|
|
2933
3052
|
* System fields a record-updated trigger cannot meaningfully watch: these never
|
|
2934
|
-
* change after create, or change on every update.
|
|
2935
|
-
*
|
|
3053
|
+
* change after create, or change on every update. The platform stores ID,
|
|
3054
|
+
* Closed At and Closed By in changed_fields, so they round-trip.
|
|
2936
3055
|
*/
|
|
2937
|
-
const UNWATCHABLE_SYSTEM_FIELD_KEYS = new Set(["
|
|
3056
|
+
const UNWATCHABLE_SYSTEM_FIELD_KEYS = new Set(["createdAt", "createdBy", "updatedAt", "updatedBy"]);
|
|
2938
3057
|
function isRunAutomationValueReference(raw) {
|
|
2939
3058
|
if (!isObject(raw))
|
|
2940
3059
|
return false;
|
|
@@ -2988,6 +3107,12 @@ function configAttrs(kind, config, refs) {
|
|
|
2988
3107
|
attrs.relate_to_record_reference = valueToTf(raw, refs);
|
|
2989
3108
|
continue;
|
|
2990
3109
|
}
|
|
3110
|
+
if (key === "recordReference" && kind === "elementum_update_field_task") {
|
|
3111
|
+
attrs.record_reference =
|
|
3112
|
+
undeclaredExecuteScriptFieldEnvelope(raw, refs, "ASPECT_RECORD_ID") ??
|
|
3113
|
+
valueToTf(raw, refs);
|
|
3114
|
+
continue;
|
|
3115
|
+
}
|
|
2991
3116
|
if (key === "code" && kind === "elementum_execute_script_task") {
|
|
2992
3117
|
if (typeof raw !== "string")
|
|
2993
3118
|
throw new EntityTfError("executeScript code must be a string");
|
|
@@ -3019,6 +3144,15 @@ function configAttrs(kind, config, refs) {
|
|
|
3019
3144
|
if (!Array.isArray(raw))
|
|
3020
3145
|
throw new EntityTfError("runAutomation inputMappings must be an array");
|
|
3021
3146
|
const target = token(config.targetAutomationId);
|
|
3147
|
+
if (bareStaticRunTarget(config)) {
|
|
3148
|
+
attrs.input_mappings = raw.map((mapping) => {
|
|
3149
|
+
if (!isObject(mapping) || typeof mapping.name !== "string" || mapping.value === undefined) {
|
|
3150
|
+
throw new EntityTfError("runAutomation input mapping requires name and value");
|
|
3151
|
+
}
|
|
3152
|
+
return { parameter_id: mapping.name, value: valueToTf(mapping.value, refs) };
|
|
3153
|
+
});
|
|
3154
|
+
continue;
|
|
3155
|
+
}
|
|
3022
3156
|
if (target?.__kind !== "automation") {
|
|
3023
3157
|
attrs.dynamic_input_mappings = raw.map((mapping) => {
|
|
3024
3158
|
if (!isObject(mapping) || typeof mapping.name !== "string" || mapping.value === undefined) {
|
|
@@ -3085,7 +3219,7 @@ function configAttrs(kind, config, refs) {
|
|
|
3085
3219
|
continue;
|
|
3086
3220
|
}
|
|
3087
3221
|
if (typeof raw === "string" && raw !== "") {
|
|
3088
|
-
attrs[Array.isArray(config.inputMappings) && config.inputMappings.length > 0
|
|
3222
|
+
attrs[Array.isArray(config.inputMappings) && config.inputMappings.length > 0 && !bareStaticRunTarget(config)
|
|
3089
3223
|
? "target_automation_ref"
|
|
3090
3224
|
: "target_automation_id"] = raw;
|
|
3091
3225
|
refs.owner.diagnostics?.push(`runAutomation: target automation ${JSON.stringify(raw)} is unresolved; emitted as bare id`);
|
|
@@ -3300,7 +3434,11 @@ function configAttrs(kind, config, refs) {
|
|
|
3300
3434
|
};
|
|
3301
3435
|
}
|
|
3302
3436
|
if (Array.isArray(staticValue)) {
|
|
3303
|
-
|
|
3437
|
+
// An empty list on a raw platform-id field is the Multi-Select clear
|
|
3438
|
+
// export prints when the field's owner is outside the workspace; a
|
|
3439
|
+
// non-empty list still needs a typed Multi-Select field (#1707).
|
|
3440
|
+
const rawIdClear = fieldToken === undefined && staticValue.length === 0;
|
|
3441
|
+
if (fieldToken?.fieldType !== "MULTI_PICKLIST" && !rawIdClear) {
|
|
3304
3442
|
throw new EntityTfError(`automation field "${fieldToken?.name ?? fieldToken?.refName ?? "unknown"}" uses an array value but is not a Multi-Select field`);
|
|
3305
3443
|
}
|
|
3306
3444
|
const values = staticValue.map((value) => picklistFilterValueToTf(value, fieldToken, refs) ?? valueToTf(value, refs));
|
|
@@ -3323,7 +3461,7 @@ function configAttrs(kind, config, refs) {
|
|
|
3323
3461
|
}
|
|
3324
3462
|
return {
|
|
3325
3463
|
field_id: valueToTf(field.aspectFieldId, refs),
|
|
3326
|
-
value: optionValue ?? valueToTf(reference, refs),
|
|
3464
|
+
value: optionValue ?? undeclaredExecuteScriptFieldEnvelope(reference, refs) ?? valueToTf(reference, refs),
|
|
3327
3465
|
...(field.operation === "ADD" ? { update_mode: "add" } : {}),
|
|
3328
3466
|
};
|
|
3329
3467
|
});
|
|
@@ -3517,6 +3655,9 @@ function fileReaderDependsOn(blocks) {
|
|
|
3517
3655
|
});
|
|
3518
3656
|
return deps;
|
|
3519
3657
|
}
|
|
3658
|
+
function automationStatusPublishes(status) {
|
|
3659
|
+
return status === "ACTIVE" || status === "INACTIVE";
|
|
3660
|
+
}
|
|
3520
3661
|
/** App- or element-owned `automation` entity → provider HCL blocks. */
|
|
3521
3662
|
function elementHandleOf(explicit, payload) {
|
|
3522
3663
|
if (explicit !== undefined && explicit !== "")
|
|
@@ -3540,6 +3681,7 @@ export function automationToTf(entity, ctx) {
|
|
|
3540
3681
|
orgRefs: ctx.orgRefs,
|
|
3541
3682
|
localsAttrs: ctx.localsAttrs,
|
|
3542
3683
|
workspaceAspects: ctx.workspaceAspects,
|
|
3684
|
+
...(ctx.outOfScopeApps !== undefined ? { outOfScopeApps: ctx.outOfScopeApps } : {}),
|
|
3543
3685
|
diagnostics: ctx.diagnostics ?? [],
|
|
3544
3686
|
activeAutomationRefNames: ctx.activeAutomationRefNames,
|
|
3545
3687
|
...(ctx.elementsWithoutAuditFields !== undefined ? { elementsWithoutAuditFields: ctx.elementsWithoutAuditFields } : {}),
|
|
@@ -3583,22 +3725,37 @@ export function automationToTf(entity, ctx) {
|
|
|
3583
3725
|
},
|
|
3584
3726
|
};
|
|
3585
3727
|
if (payload.serviceAccount !== undefined) {
|
|
3586
|
-
|
|
3587
|
-
|
|
3588
|
-
|
|
3589
|
-
|
|
3590
|
-
|
|
3591
|
-
|
|
3592
|
-
|
|
3593
|
-
|
|
3594
|
-
|
|
3595
|
-
|
|
3596
|
-
|
|
3597
|
-
|
|
3598
|
-
|
|
3728
|
+
const accountApp = payload.serviceAccount.appRefName;
|
|
3729
|
+
if (accountApp !== owner.appRefName) {
|
|
3730
|
+
// A sibling app's account uses the same resolver as roles (#1592):
|
|
3731
|
+
// bag key → resource ref, miss → data source. Do not guess the label
|
|
3732
|
+
// from the display name.
|
|
3733
|
+
const owning = workspaceServiceAccountAppResolver(owner.workspaceAspects, { apps: owner.outOfScopeApps, orgRefs: owner.orgRefs })(accountApp);
|
|
3734
|
+
if (owning === undefined || owner.orgRefs === undefined) {
|
|
3735
|
+
throw new EntityTfError(`automation "${entity.refName}" service account belongs to app "${accountApp}", which is not in this workspace`);
|
|
3736
|
+
}
|
|
3737
|
+
const diagnostics = [];
|
|
3738
|
+
const value = serviceAccountRefToTf(payload.serviceAccount, { appRefName: accountApp, ...owning, orgRefs: owner.orgRefs }, `automation "${entity.refName}" serviceAccount`, diagnostics);
|
|
3739
|
+
if (value === undefined) {
|
|
3740
|
+
throw new EntityTfError(diagnostics[0] ?? `automation "${entity.refName}" cannot resolve service account "${payload.serviceAccount.name}"`);
|
|
3741
|
+
}
|
|
3742
|
+
automation.attrs.service_account_id = value;
|
|
3599
3743
|
}
|
|
3600
3744
|
else {
|
|
3601
|
-
|
|
3745
|
+
const local = Object.entries(ctx.serviceAccounts ?? {}).find(([, account]) => `${account.firstName} ${account.lastName}` === payload.serviceAccount.name);
|
|
3746
|
+
if (local !== undefined) {
|
|
3747
|
+
automation.attrs.service_account_id = expr.resourceAttr(SERVICE_ACCOUNT_RESOURCE_TYPE, appScopedResourceLabel(owner.appTfLabel, tsLabelToTfLabel(local[0])), ["id"]);
|
|
3748
|
+
}
|
|
3749
|
+
else if (owner.orgRefs !== undefined) {
|
|
3750
|
+
const lookupLabel = sanitizeName(payload.serviceAccount.name);
|
|
3751
|
+
owner.orgRefs.rawLookup(SERVICE_ACCOUNT_RESOURCE_TYPE, lookupLabel, payload.serviceAccount.name, {
|
|
3752
|
+
app_id: expr.resourceAttr("elementum_app", owner.appTfLabel, ["id"]),
|
|
3753
|
+
});
|
|
3754
|
+
automation.attrs.service_account_id = expr.dataAttr(SERVICE_ACCOUNT_RESOURCE_TYPE, lookupLabel, ["id"]);
|
|
3755
|
+
}
|
|
3756
|
+
else {
|
|
3757
|
+
throw new EntityTfError(`automation "${entity.refName}" cannot resolve service account "${payload.serviceAccount.name}"`);
|
|
3758
|
+
}
|
|
3602
3759
|
}
|
|
3603
3760
|
}
|
|
3604
3761
|
const [triggerKey, triggerConfig] = onlyEntry(payload.trigger, `automation "${entity.refName}" trigger`);
|
|
@@ -3895,8 +4052,9 @@ export function automationToTf(entity, ctx) {
|
|
|
3895
4052
|
const target = token(inner.targetAutomationId) ?? (isObject(inner.targetAutomationRef) ? token(inner.targetAutomationRef.value) : undefined);
|
|
3896
4053
|
if (target?.__kind === "automation") {
|
|
3897
4054
|
const targetLabel = scopedLabel(owner.appTfLabel, tsLabelToTfLabel(target.refName));
|
|
3898
|
-
//
|
|
3899
|
-
//
|
|
4055
|
+
// Only a running (ACTIVE) target is a run dependency. A paused
|
|
4056
|
+
// target keeps its publish resource, but ei export does not wait
|
|
4057
|
+
// on it, and a draft target has none.
|
|
3900
4058
|
if (ctx.activeAutomationRefNames?.has(target.refName) === true) {
|
|
3901
4059
|
block.attrs.depends_on = [expr.resourceAttr(WORKFLOW_PUBLISH_RESOURCE_TYPE, targetLabel)];
|
|
3902
4060
|
runAutomationPublishes.add(targetLabel);
|
|
@@ -4036,7 +4194,7 @@ export function automationToTf(entity, ctx) {
|
|
|
4036
4194
|
if (fileReaderDeps.length > 0) {
|
|
4037
4195
|
automation.attrs.depends_on = fileReaderDeps;
|
|
4038
4196
|
}
|
|
4039
|
-
if (payload.status
|
|
4197
|
+
if (automationStatusPublishes(payload.status)) {
|
|
4040
4198
|
const outputValues = payload.outputProperties?.outputs ?? [];
|
|
4041
4199
|
const publish = {
|
|
4042
4200
|
kind: "resource",
|
|
@@ -123,6 +123,8 @@ export interface approvalProcessStatusUpdatedTriggerOptions<A extends AppOrEleme
|
|
|
123
123
|
*/
|
|
124
124
|
readonly approvalChain?: ApprovalChainRef | UnsafePlatformId;
|
|
125
125
|
readonly status: approvalProcessStatusUpdatedStatus;
|
|
126
|
+
/** Record filter the approval-chain trigger additionally requires. */
|
|
127
|
+
readonly filter?: Filter;
|
|
126
128
|
}
|
|
127
129
|
/** Fires when an approval chain on a record changes to the configured status. */
|
|
128
130
|
export declare function approvalProcessStatusUpdated<A extends AppOrElementRef>(opts: approvalProcessStatusUpdatedTriggerOptions<A>): TriggerChain<RecordTriggerOutput<A>>;
|
|
@@ -119,6 +119,7 @@ export function approvalProcessStatusUpdated(opts) {
|
|
|
119
119
|
aspectId: opts.app,
|
|
120
120
|
...(opts.approvalChain !== undefined ? { approvalChainTemplateId: opts.approvalChain } : {}),
|
|
121
121
|
status: opts.status,
|
|
122
|
+
...(opts.filter !== undefined ? { filter: opts.filter } : {}),
|
|
122
123
|
type: "APPROVAL_CHAIN_UPDATE",
|
|
123
124
|
},
|
|
124
125
|
},
|
|
@@ -55,6 +55,12 @@ export interface NormalizedChart {
|
|
|
55
55
|
readonly properties?: ChartProperties;
|
|
56
56
|
readonly subscriptions: readonly (NormalizedChartSubscription | NormalizedChartOpaqueSubscription)[];
|
|
57
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* The chart's refName, which is also its own-file name (`charts/<refName>.ts`)
|
|
60
|
+
* and the key a dashboard chart widget prints: the chart's TF label with the
|
|
61
|
+
* owning app's TF label (not its camelCase ref) stripped (#1731).
|
|
62
|
+
*/
|
|
63
|
+
export declare function chartRefNameFromTfLabel(appTfLabel: string, chartTfLabel: string): string;
|
|
58
64
|
export declare function chartFromTf(block: TfBlock, opts: {
|
|
59
65
|
readonly appLabel: string;
|
|
60
66
|
readonly appRefName: string;
|
|
@@ -329,6 +329,14 @@ function parseSubscription(value, appLabel, appRefName, ctx, where) {
|
|
|
329
329
|
...(stringList(rec["tags"]) !== undefined ? { tags: stringList(rec["tags"]) } : {}),
|
|
330
330
|
};
|
|
331
331
|
}
|
|
332
|
+
/**
|
|
333
|
+
* The chart's refName, which is also its own-file name (`charts/<refName>.ts`)
|
|
334
|
+
* and the key a dashboard chart widget prints: the chart's TF label with the
|
|
335
|
+
* owning app's TF label (not its camelCase ref) stripped (#1731).
|
|
336
|
+
*/
|
|
337
|
+
export function chartRefNameFromTfLabel(appTfLabel, chartTfLabel) {
|
|
338
|
+
return scopedLabelToBagKey(appTfLabel, chartTfLabel, "app");
|
|
339
|
+
}
|
|
332
340
|
export function chartFromTf(block, opts, ctx) {
|
|
333
341
|
if (block.type !== CHART_RESOURCE_TYPE || block.label === undefined)
|
|
334
342
|
return undefined;
|
|
@@ -356,7 +364,7 @@ export function chartFromTf(block, opts, ctx) {
|
|
|
356
364
|
...(typeof rawProperties["target"] === "number" ? { target: rawProperties["target"] } : {}),
|
|
357
365
|
};
|
|
358
366
|
return {
|
|
359
|
-
refName:
|
|
367
|
+
refName: chartRefNameFromTfLabel(opts.appLabel, block.label), name, type,
|
|
360
368
|
...(typeof block.attrs["target"] === "number" ? { target: block.attrs["target"] } : {}),
|
|
361
369
|
...(properties !== undefined ? { properties } : {}), subscriptions,
|
|
362
370
|
};
|
|
@@ -6,6 +6,7 @@ import { filterWireToTf } from "../shared/filters/tf-codec.js";
|
|
|
6
6
|
import { DASHBOARD_WIDGET_RESOURCE_TYPE } from "../dashboard-widget/module.js";
|
|
7
7
|
import { DASHBOARD_RESOURCE_TYPE } from "./module.js";
|
|
8
8
|
import { CHART_RESOURCE_TYPE } from "../chart/types.js";
|
|
9
|
+
import { chartRefNameFromTfLabel } from "../chart/from-tf.js";
|
|
9
10
|
import { dashboardWidgetSize } from "./build.js";
|
|
10
11
|
import { resolveDataAspectTarget } from "../shared/aspect-target-from-tf.js";
|
|
11
12
|
import { managedViewSortFromTf } from "../view/from-tf.js";
|
|
@@ -30,7 +31,7 @@ export function dashboardsFromTf(blocks, widgetBlocks, owner, ctx) {
|
|
|
30
31
|
}
|
|
31
32
|
const tags = stringList(block.attrs, "tags", where, ctx);
|
|
32
33
|
const key = scopedLabelToBagKey(owner.ownerTfLabel, label, owner.scope);
|
|
33
|
-
const widgets = dashboardWidgetsFromTf(widgetBlocks.filter((widget) => resourceRefLabel(widget.attrs["dashboard_id"], DASHBOARD_RESOURCE_TYPE) === label), label, owner, ctx);
|
|
34
|
+
const widgets = dashboardWidgetsFromTf(widgetBlocks.filter((widget) => resourceRefLabel(widget.attrs["dashboard_id"], DASHBOARD_RESOURCE_TYPE) === label), label, key, owner, ctx);
|
|
34
35
|
dashboards.push({
|
|
35
36
|
key,
|
|
36
37
|
name: optionalString(block.attrs, "name", where, ctx) ?? "",
|
|
@@ -41,7 +42,7 @@ export function dashboardsFromTf(blocks, widgetBlocks, owner, ctx) {
|
|
|
41
42
|
}
|
|
42
43
|
return dashboards;
|
|
43
44
|
}
|
|
44
|
-
function dashboardWidgetsFromTf(blocks, dashboardLabel, owner, ctx) {
|
|
45
|
+
function dashboardWidgetsFromTf(blocks, dashboardLabel, dashboardKey, owner, ctx) {
|
|
45
46
|
return blocks.flatMap((block) => {
|
|
46
47
|
const where = `${DASHBOARD_WIDGET_RESOURCE_TYPE}.${block.label ?? "?"}`;
|
|
47
48
|
const label = block.label ?? "";
|
|
@@ -58,12 +59,33 @@ function dashboardWidgetsFromTf(blocks, dashboardLabel, owner, ctx) {
|
|
|
58
59
|
const style = { key, name, size, ...(color !== undefined && { color }), ...(icon !== undefined && { icon }) };
|
|
59
60
|
const chart = plainObject(block.attrs["chart_widget"]);
|
|
60
61
|
if (chart !== undefined) {
|
|
62
|
+
const address = `${DASHBOARD_WIDGET_RESOURCE_TYPE}.${label}`;
|
|
61
63
|
const chartLabel = resourceRefLabel(chart["chart_id"], CHART_RESOURCE_TYPE);
|
|
62
64
|
if (chartLabel === undefined) {
|
|
63
|
-
|
|
65
|
+
// A raw chart id or a data.elementum_chart ref names no chart this
|
|
66
|
+
// pull writes, so the widget cannot be written either. Skip and
|
|
67
|
+
// release it, or adoption imports it and the next plan destroys it
|
|
68
|
+
// (#1731).
|
|
69
|
+
if (ctx.requiresExtracted === undefined)
|
|
70
|
+
ctx.diagnostics.push(`${where}.chart_widget.chart_id: expected a managed chart reference; skipped`);
|
|
71
|
+
ctx.requiresExtracted?.push({ address, requires: unresolvedChartRef(chart["chart_id"]), unresolved: true, prune: (root) => root });
|
|
64
72
|
return [];
|
|
65
73
|
}
|
|
66
|
-
|
|
74
|
+
// The chart's own file is named from the app's TF label, so derive the
|
|
75
|
+
// key the same way: owner.ownerTfLabel is the camelCase ref, which
|
|
76
|
+
// differs for a namespace with underscores (#1731).
|
|
77
|
+
const chartKey = chartRefNameFromTfLabel(owner.label, chartLabel);
|
|
78
|
+
// The chart extracts later, as an own-file child. If pull skips it and
|
|
79
|
+
// no authored file for it is kept, build cannot emit this widget, so
|
|
80
|
+
// stream-root drops and releases it rather than leave it adopted for
|
|
81
|
+
// the next plan to destroy (#1731).
|
|
82
|
+
ctx.requiresExtracted?.push({
|
|
83
|
+
address,
|
|
84
|
+
requires: `${CHART_RESOURCE_TYPE}.${chartLabel}`,
|
|
85
|
+
requiresOwnFile: { kind: "chart", refName: chartKey },
|
|
86
|
+
prune: (root) => withoutDashboardWidget(root, dashboardKey, key),
|
|
87
|
+
});
|
|
88
|
+
return [{ ...style, type: "chart", chartKey }];
|
|
67
89
|
}
|
|
68
90
|
if (aspect === undefined) {
|
|
69
91
|
ctx.diagnostics.push(`${where}: expected an aspect_widget or chart_widget; skipped`);
|
|
@@ -95,6 +117,31 @@ function dashboardWidgetsFromTf(blocks, dashboardLabel, owner, ctx) {
|
|
|
95
117
|
}];
|
|
96
118
|
});
|
|
97
119
|
}
|
|
120
|
+
/** How an unresolved `chart_id` was exported, for the skipped gap. */
|
|
121
|
+
function unresolvedChartRef(value) {
|
|
122
|
+
const dataLabel = dataRefLabel(value, CHART_RESOURCE_TYPE);
|
|
123
|
+
if (dataLabel !== undefined)
|
|
124
|
+
return `data.${CHART_RESOURCE_TYPE}.${dataLabel}`;
|
|
125
|
+
if (typeof value === "string")
|
|
126
|
+
return `chart id ${JSON.stringify(value)}`;
|
|
127
|
+
return "an unresolved chart_id";
|
|
128
|
+
}
|
|
129
|
+
/** `root` without widget `widgetKey` of dashboard `dashboardKey`; unchanged when it has no such widget. */
|
|
130
|
+
function withoutDashboardWidget(root, dashboardKey, widgetKey) {
|
|
131
|
+
const dashboards = root.dashboards;
|
|
132
|
+
if (dashboards === undefined)
|
|
133
|
+
return root;
|
|
134
|
+
return {
|
|
135
|
+
...root,
|
|
136
|
+
dashboards: dashboards.map((dashboard) => {
|
|
137
|
+
if (dashboard.key !== dashboardKey || dashboard.widgets === undefined)
|
|
138
|
+
return dashboard;
|
|
139
|
+
const { widgets, ...rest } = dashboard;
|
|
140
|
+
const kept = widgets.filter((widget) => widget.key !== widgetKey);
|
|
141
|
+
return kept.length > 0 ? { ...rest, widgets: kept } : rest;
|
|
142
|
+
}),
|
|
143
|
+
};
|
|
144
|
+
}
|
|
98
145
|
function aspectRef(value, owner, ctx) {
|
|
99
146
|
if (typeof value === "string")
|
|
100
147
|
return undefined;
|