@elementumai/edk 0.10.4 → 0.11.0
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 +11 -7
- package/dist-sdk/src/catalog/token.js +2 -1
- package/dist-sdk/src/core/wire/ref-serializer.js +26 -1
- package/dist-sdk/src/engine/build/context.d.ts +4 -0
- 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/json-stream-reader.d.ts +43 -0
- package/dist-sdk/src/engine/ei/json-stream-reader.js +234 -0
- package/dist-sdk/src/engine/ei/run.d.ts +22 -0
- package/dist-sdk/src/engine/ei/run.js +99 -18
- package/dist-sdk/src/engine/ei/saved-plan.d.ts +16 -0
- package/dist-sdk/src/engine/ei/saved-plan.js +19 -0
- package/dist-sdk/src/engine/ei/state.d.ts +1 -1
- package/dist-sdk/src/engine/ei/state.js +17 -4
- package/dist-sdk/src/engine/progress.d.ts +3 -1
- package/dist-sdk/src/engine/progress.js +7 -3
- package/dist-sdk/src/engine/pull/authored-address.d.ts +15 -1
- package/dist-sdk/src/engine/pull/authored-address.js +180 -29
- package/dist-sdk/src/engine/pull/context.d.ts +37 -2
- package/dist-sdk/src/engine/pull/context.js +7 -4
- package/dist-sdk/src/engine/tf/index.d.ts +2 -2
- package/dist-sdk/src/engine/tf/index.js +2 -2
- package/dist-sdk/src/engine/tf/labels.d.ts +22 -0
- package/dist-sdk/src/engine/tf/labels.js +50 -0
- package/dist-sdk/src/engine/tf/model.d.ts +2 -0
- package/dist-sdk/src/engine/tf/model.js +26 -0
- package/dist-sdk/src/engine/validation.d.ts +2 -0
- package/dist-sdk/src/entities/access-policy/from-tf.d.ts +17 -0
- package/dist-sdk/src/entities/access-policy/from-tf.js +52 -24
- package/dist-sdk/src/entities/access-policy/member-list.d.ts +32 -0
- package/dist-sdk/src/entities/access-policy/member-list.js +57 -0
- package/dist-sdk/src/entities/access-policy/module.js +5 -0
- package/dist-sdk/src/entities/access-policy/to-tf.d.ts +4 -3
- package/dist-sdk/src/entities/access-policy/to-tf.js +21 -12
- package/dist-sdk/src/entities/agent/build.js +7 -5
- package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +2 -0
- package/dist-sdk/src/entities/agent/from-tf.js +13 -3
- package/dist-sdk/src/entities/agent/to-tf.js +11 -5
- package/dist-sdk/src/entities/agent/tools.d.ts +8 -0
- package/dist-sdk/src/entities/agent/tools.js +6 -2
- package/dist-sdk/src/entities/agent-tool/from-tf.d.ts +2 -0
- package/dist-sdk/src/entities/agent-tool/to-tf.d.ts +29 -0
- package/dist-sdk/src/entities/agent-tool/to-tf.js +56 -3
- package/dist-sdk/src/entities/agent-tool/types.d.ts +12 -8
- package/dist-sdk/src/entities/agent-tool/types.js +13 -9
- package/dist-sdk/src/entities/app/build.d.ts +11 -0
- package/dist-sdk/src/entities/app/build.js +1 -0
- package/dist-sdk/src/entities/app/deserializer/normalize.d.ts +5 -7
- package/dist-sdk/src/entities/app/from-tf.js +16 -10
- package/dist-sdk/src/entities/app/to-tf.js +6 -4
- package/dist-sdk/src/entities/automation/build.d.ts +2 -7
- package/dist-sdk/src/entities/automation/build.js +43 -14
- package/dist-sdk/src/entities/automation/deserializer/ast.d.ts +7 -4
- package/dist-sdk/src/entities/automation/deserializer/print-automation.js +7 -11
- package/dist-sdk/src/entities/automation/from-tf.d.ts +23 -1
- package/dist-sdk/src/entities/automation/from-tf.js +456 -34
- package/dist-sdk/src/entities/automation/index.d.ts +1 -1
- package/dist-sdk/src/entities/automation/module.d.ts +22 -2
- package/dist-sdk/src/entities/automation/module.js +244 -57
- package/dist-sdk/src/entities/automation/output-key-wire-name.d.ts +22 -2
- package/dist-sdk/src/entities/automation/output-key-wire-name.js +54 -3
- package/dist-sdk/src/entities/automation/run-target.d.ts +59 -0
- package/dist-sdk/src/entities/automation/run-target.js +99 -0
- package/dist-sdk/src/entities/automation/script-code.d.ts +9 -0
- package/dist-sdk/src/entities/automation/script-code.js +24 -3
- package/dist-sdk/src/entities/automation/task-output-labels.d.ts +16 -0
- package/dist-sdk/src/entities/automation/task-output-labels.js +49 -0
- package/dist-sdk/src/entities/automation/tasks.d.ts +20 -8
- package/dist-sdk/src/entities/automation/to-tf.d.ts +1 -3
- package/dist-sdk/src/entities/automation/to-tf.js +102 -40
- package/dist-sdk/src/entities/automation/triggers.d.ts +22 -3
- package/dist-sdk/src/entities/automation/triggers.js +40 -0
- package/dist-sdk/src/entities/automation/types.d.ts +21 -0
- package/dist-sdk/src/entities/automation/types.js +26 -0
- package/dist-sdk/src/entities/dashboard/from-tf.d.ts +11 -1
- package/dist-sdk/src/entities/dashboard/from-tf.js +57 -7
- package/dist-sdk/src/entities/dashboard/to-tf.js +13 -0
- package/dist-sdk/src/entities/dynamic-layout/build.d.ts +7 -2
- package/dist-sdk/src/entities/dynamic-layout/from-tf.d.ts +3 -0
- package/dist-sdk/src/entities/dynamic-layout/from-tf.js +65 -19
- package/dist-sdk/src/entities/dynamic-layout/to-tf.d.ts +4 -2
- package/dist-sdk/src/entities/dynamic-layout/to-tf.js +341 -32
- package/dist-sdk/src/entities/element/build.d.ts +10 -0
- package/dist-sdk/src/entities/element/build.js +1 -0
- package/dist-sdk/src/entities/element/from-tf.js +14 -9
- package/dist-sdk/src/entities/element/to-tf.js +6 -4
- package/dist-sdk/src/entities/field/from-tf.d.ts +24 -0
- package/dist-sdk/src/entities/field/from-tf.js +79 -1
- package/dist-sdk/src/entities/field/module.js +7 -0
- package/dist-sdk/src/entities/field/to-tf.d.ts +30 -1
- package/dist-sdk/src/entities/field/to-tf.js +51 -0
- package/dist-sdk/src/entities/file-reader/module.js +3 -3
- package/dist-sdk/src/entities/file-reader/to-tf.js +3 -3
- package/dist-sdk/src/entities/file-reader/types.d.ts +4 -16
- package/dist-sdk/src/entities/file-reader/types.js +7 -0
- package/dist-sdk/src/entities/org/group.d.ts +1 -0
- package/dist-sdk/src/entities/org/group.js +2 -1
- package/dist-sdk/src/entities/record-create-form/from-tf.d.ts +8 -0
- package/dist-sdk/src/entities/record-create-form/from-tf.js +10 -2
- package/dist-sdk/src/entities/record-create-form/to-tf.d.ts +2 -1
- package/dist-sdk/src/entities/record-create-form/to-tf.js +14 -2
- package/dist-sdk/src/entities/relationship/from-tf.d.ts +8 -0
- package/dist-sdk/src/entities/relationship/from-tf.js +88 -10
- package/dist-sdk/src/entities/relationship/to-tf.d.ts +3 -2
- package/dist-sdk/src/entities/relationship/to-tf.js +79 -8
- package/dist-sdk/src/entities/role/from-tf.js +24 -7
- package/dist-sdk/src/entities/role/to-tf.js +25 -7
- package/dist-sdk/src/entities/service-account/from-tf.js +2 -1
- package/dist-sdk/src/entities/service-account/module.js +15 -0
- package/dist-sdk/src/entities/service-account/to-tf.js +12 -4
- package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +1 -1
- package/dist-sdk/src/entities/shared/filters/tf-codec.js +12 -7
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.d.ts +5 -2
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +8 -1
- package/dist-sdk/src/entities/skill/from-tf.js +10 -3
- package/dist-sdk/src/entities/skill/module.js +16 -0
- package/dist-sdk/src/entities/skill/to-tf.d.ts +8 -1
- package/dist-sdk/src/entities/skill/to-tf.js +23 -14
- package/dist-sdk/src/entities/skill/tools.d.ts +8 -0
- package/dist-sdk/src/entities/skill/tools.js +6 -2
- package/dist-sdk/src/entities/skill-tool/from-tf.d.ts +2 -0
- package/dist-sdk/src/entities/skill-tool/to-tf.d.ts +8 -0
- package/dist-sdk/src/entities/skill-tool/to-tf.js +6 -2
- package/dist-sdk/src/entities/view/agent-view-layout-from-tf.d.ts +8 -2
- package/dist-sdk/src/entities/view/agent-view-layout-from-tf.js +20 -10
- package/dist-sdk/src/entities/view/from-tf.d.ts +60 -0
- package/dist-sdk/src/entities/view/from-tf.js +391 -17
- package/dist-sdk/src/entities/view/module.js +15 -0
- package/dist-sdk/src/entities/view/portable.d.ts +11 -0
- package/dist-sdk/src/entities/view/portable.js +47 -0
- package/dist-sdk/src/entities/view/to-tf.d.ts +4 -1
- package/dist-sdk/src/entities/view/to-tf.js +25 -7
- package/dist-sdk/src/entities/view/types.js +1 -1
- package/dist-sdk/src/entities/widget/build.d.ts +4 -3
- package/dist-sdk/src/entities/widget/from-tf.d.ts +3 -0
- package/dist-sdk/src/entities/widget/from-tf.js +100 -3
- package/dist-sdk/src/entities/widget/to-tf.d.ts +16 -1
- package/dist-sdk/src/entities/widget/to-tf.js +77 -14
- package/dist-sdk/src/generated/ragnarok/ragnarok-spec.d.ts +27 -8
- package/dist-sdk/src/generated/ragnarok/ragnarok-spec.js +2 -2
- package/dist-sdk/src/graph/field-resource-types.d.ts +2 -0
- package/dist-sdk/src/graph/field-resource-types.js +11 -0
- package/dist-sdk/src/graph/index.d.ts +28 -3
- package/dist-sdk/src/graph/index.js +12 -2
- package/dist-sdk/src/graph/types.d.ts +157 -5
- package/package.json +1 -1
|
@@ -13,8 +13,9 @@
|
|
|
13
13
|
* `data.elementum_field` lookup when the typed target is foreign.
|
|
14
14
|
*/
|
|
15
15
|
import { workspaceAspectKey } from "../../engine/build/context.js";
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
16
|
+
import { EntityTfError } from "../../engine/entity.js";
|
|
17
|
+
import { automationRunTargetResourceAttr } from "../automation/run-target.js";
|
|
18
|
+
import { appScopedResourceLabel, collisionLabelSuffixes, expr, sanitizeName, scopedResourceLabel, stableIdSuffix, tsLabelToTfLabel } from "../../engine/tf/index.js";
|
|
18
19
|
import { authoredFieldKeysFromPayload, fieldRefToTfValue, } from "../field/to-tf.js";
|
|
19
20
|
import { foreignFieldDataLabel } from "../shared/foreign-ref.js";
|
|
20
21
|
import { encodeOptionalHandleDescription } from "../shared/handle-description.js";
|
|
@@ -164,6 +165,58 @@ function fieldRefValue(token, where, ctx, target) {
|
|
|
164
165
|
}
|
|
165
166
|
return value;
|
|
166
167
|
}
|
|
168
|
+
/** An agent tool's bare label: `sanitizeName(<agent>_<tool name>)` plus its collision suffix. */
|
|
169
|
+
export function agentToolBareLabel(agentBareTfLabel, toolName, labelSuffix) {
|
|
170
|
+
return `${sanitizeName(`${agentBareTfLabel}_${toolName}`)}${labelSuffix}`;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* `_N` suffixes, by tool index, for one agent's tools whose labels collide
|
|
174
|
+
* (`a-b` and `a_b` both sanitize to `a_b`), with one counter across tool
|
|
175
|
+
* kinds as in ei's export (`GenerateImportBlocks`, `toolNames` in
|
|
176
|
+
* imports.go). A tool with `labelSuffix` keeps that `_N`; the others take the
|
|
177
|
+
* lowest free count in tool order (`collisionLabelSuffixes`), so an unpinned
|
|
178
|
+
* tool's order is part of its address. Pull pins every tool ei suffixed
|
|
179
|
+
* (agentFromTf), so a pulled agent rebuilds its exported labels even when ei
|
|
180
|
+
* counted a tool pull doesn't print. Every known tool kind counts, implemented
|
|
181
|
+
* or not, as in ei. Parity holds within one agent only: ei's counter spans
|
|
182
|
+
* the whole app and is keyed on the agent's display name (edk#2000).
|
|
183
|
+
*/
|
|
184
|
+
export function agentToolLabelSuffixes(agentBareTfLabel, tools) {
|
|
185
|
+
return collisionLabelSuffixes(tools.map((entry) => {
|
|
186
|
+
const typeKey = Object.keys(entry)[0];
|
|
187
|
+
if (typeKey === undefined || !TOOL_SUB_TYPE_BY_TYPE_KEY.has(typeKey))
|
|
188
|
+
return undefined;
|
|
189
|
+
const inner = entry[typeKey];
|
|
190
|
+
return {
|
|
191
|
+
base: sanitizeName(`${agentBareTfLabel}_${inner?.name ?? ""}`),
|
|
192
|
+
...(inner?.labelSuffix !== undefined && { pinned: inner.labelSuffix }),
|
|
193
|
+
};
|
|
194
|
+
}));
|
|
195
|
+
}
|
|
196
|
+
/** A tool entry's (`{ createRecord: { name, ... } }`) platform name, or "". */
|
|
197
|
+
export function toolName(entry) {
|
|
198
|
+
const typeKey = Object.keys(entry)[0];
|
|
199
|
+
const inner = typeKey === undefined ? undefined : entry[typeKey];
|
|
200
|
+
return typeof inner?.name === "string" ? inner.name : "";
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Fail the build when two of one owner's tools land on one resource address
|
|
204
|
+
* (`a-b`, `a_b` and `a_b_1` of one kind: the second gets `_1`, the third is
|
|
205
|
+
* `a_b_1` already). OpenTofu would reject the duplicate only at plan, so name
|
|
206
|
+
* both tools here instead (edk#1987).
|
|
207
|
+
*/
|
|
208
|
+
export function assertUniqueToolAddresses(owner, tools) {
|
|
209
|
+
const seen = new Map();
|
|
210
|
+
for (const tool of tools) {
|
|
211
|
+
const other = seen.get(tool.address);
|
|
212
|
+
if (other !== undefined) {
|
|
213
|
+
throw new EntityTfError(`${owner}: tools ${JSON.stringify(other)} and ${JSON.stringify(tool.name)} both get the address ${tool.address} ` +
|
|
214
|
+
`(names that differ only in hyphens, underscores or case share a label; a colliding tool's _N comes from its labelSuffix or, without one, its tool order). ` +
|
|
215
|
+
`Rename one of them.`);
|
|
216
|
+
}
|
|
217
|
+
seen.set(tool.address, tool.name);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
167
220
|
/**
|
|
168
221
|
* One authored tool entry (`{ createRecord: {...} }`) → its resource block;
|
|
169
222
|
* undefined = degraded with a diagnostic (unimplemented sub-type, missing
|
|
@@ -191,7 +244,7 @@ export function toolToTf(entry, ctx) {
|
|
|
191
244
|
}
|
|
192
245
|
const where = `agent tool "${name}"`;
|
|
193
246
|
const agentTfLabel = appScopedResourceLabel(ctx.appTfLabel, ctx.agentBareTfLabel);
|
|
194
|
-
const tfLabel = appScopedResourceLabel(ctx.appTfLabel,
|
|
247
|
+
const tfLabel = appScopedResourceLabel(ctx.appTfLabel, agentToolBareLabel(ctx.agentBareTfLabel, name, ctx.labelSuffix ?? ""));
|
|
195
248
|
const attrs = {
|
|
196
249
|
agent_id: expr.resourceAttr("elementum_agent", agentTfLabel, ["id"]),
|
|
197
250
|
app_id: expr.resourceAttr("elementum_app", ctx.appTfLabel, ["id"]),
|
|
@@ -28,14 +28,18 @@ export declare const IMPLEMENTED_TOOL_RESOURCE_TYPES: readonly string[];
|
|
|
28
28
|
export declare const ALL_TOOL_RESOURCE_TYPES: readonly string[];
|
|
29
29
|
/**
|
|
30
30
|
* EDK's tool-name rule — enforced in the authoring builders (see
|
|
31
|
-
* `entities/agent/tools.ts`), never in the tf
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
* the
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
31
|
+
* `entities/agent/tools.ts` and `entities/skill/tools.ts`), never in the tf
|
|
32
|
+
* passes. It is the platform's own rule: 1–64 chars of letters, digits,
|
|
33
|
+
* underscores, and hyphens (`[A-Za-z0-9_-]`); no spaces; no consecutive
|
|
34
|
+
* underscores (the platform rejects those, opaquely). Hyphens are allowed
|
|
35
|
+
* because the platform mints them itself — its skill generator names a lookup
|
|
36
|
+
* tool `resolve_<label>` cut to 55 chars plus `-<8 hex>` — and pull prints the
|
|
37
|
+
* live name verbatim, so a stricter rule makes a pulled file fail to load
|
|
38
|
+
* (edk#1987). The name is sent to the platform verbatim; the terraform label is
|
|
39
|
+
* `sanitizeName(name)` (hyphens become underscores, the same as ei's export
|
|
40
|
+
* `SanitizeName`), and names that sanitize to one label get `_N` suffixes from
|
|
41
|
+
* a pinned `labelSuffix` or tool order (`computeToolLabelSuffixes`,
|
|
42
|
+
* `agentToolLabelSuffixes`).
|
|
39
43
|
*/
|
|
40
44
|
export declare function isValidToolName(name: string): boolean;
|
|
41
45
|
export declare const KNOWN_TOOL_ATTRS: Readonly<Record<string, ReadonlySet<string>>>;
|
|
@@ -29,17 +29,21 @@ export const IMPLEMENTED_TOOL_RESOURCE_TYPES = AGENT_TOOL_SUB_TYPES.filter((t) =
|
|
|
29
29
|
export const ALL_TOOL_RESOURCE_TYPES = AGENT_TOOL_SUB_TYPES.map((t) => t.resourceType);
|
|
30
30
|
/**
|
|
31
31
|
* EDK's tool-name rule — enforced in the authoring builders (see
|
|
32
|
-
* `entities/agent/tools.ts`), never in the tf
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
* the
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
32
|
+
* `entities/agent/tools.ts` and `entities/skill/tools.ts`), never in the tf
|
|
33
|
+
* passes. It is the platform's own rule: 1–64 chars of letters, digits,
|
|
34
|
+
* underscores, and hyphens (`[A-Za-z0-9_-]`); no spaces; no consecutive
|
|
35
|
+
* underscores (the platform rejects those, opaquely). Hyphens are allowed
|
|
36
|
+
* because the platform mints them itself — its skill generator names a lookup
|
|
37
|
+
* tool `resolve_<label>` cut to 55 chars plus `-<8 hex>` — and pull prints the
|
|
38
|
+
* live name verbatim, so a stricter rule makes a pulled file fail to load
|
|
39
|
+
* (edk#1987). The name is sent to the platform verbatim; the terraform label is
|
|
40
|
+
* `sanitizeName(name)` (hyphens become underscores, the same as ei's export
|
|
41
|
+
* `SanitizeName`), and names that sanitize to one label get `_N` suffixes from
|
|
42
|
+
* a pinned `labelSuffix` or tool order (`computeToolLabelSuffixes`,
|
|
43
|
+
* `agentToolLabelSuffixes`).
|
|
40
44
|
*/
|
|
41
45
|
export function isValidToolName(name) {
|
|
42
|
-
return /^[A-Za-z0-9_]{1,64}$/.test(name) && !name.includes("__");
|
|
46
|
+
return /^[A-Za-z0-9_-]{1,64}$/.test(name) && !name.includes("__");
|
|
43
47
|
}
|
|
44
48
|
/** Attributes `toolFromTf` understands per implemented sub-type — growth is reported loudly. */
|
|
45
49
|
const COMMON_TOOL_ATTRS = ["agent_id", "app_id", "name", "description", "start_message", "run_as", "service_account_id"];
|
|
@@ -550,6 +550,17 @@ interface AppV2OptionsBase<F extends Record<string, AppField> = Record<string, A
|
|
|
550
550
|
readonly relationships?: Readonly<Record<string, AppRelationship>>;
|
|
551
551
|
/** Display order of all authored views (by key). Defaults to declaration order by view bag. */
|
|
552
552
|
readonly viewOrder?: readonly string[];
|
|
553
|
+
/**
|
|
554
|
+
* Delete the platform's default "List" view (the LIST-type view named
|
|
555
|
+
* "List" the platform creates on every app and element), so the first entry
|
|
556
|
+
* of `viewOrder` is the main surface. The delete runs once: when the view
|
|
557
|
+
* order is created with it set, or when it changes from unset/`false` to
|
|
558
|
+
* `true`; later applies, including reorders, never delete a view. The plan
|
|
559
|
+
* warns with the view's id and name, and fails if several views qualify.
|
|
560
|
+
* Omitting it means `false` (nothing is deleted). `elementum new app` sets
|
|
561
|
+
* it. No declared view may be named "List".
|
|
562
|
+
*/
|
|
563
|
+
readonly deleteDefaultListView?: boolean;
|
|
553
564
|
/**
|
|
554
565
|
* App-level sharing & row-level-security policies (`elementum_access_policy`), in declaration order.
|
|
555
566
|
* Creating the app also has the platform mint a separate creator policy
|
|
@@ -588,6 +588,7 @@ export function app(opts) {
|
|
|
588
588
|
...(opts.dynamicLayouts !== undefined ? { dynamicLayouts: opts.dynamicLayouts } : {}),
|
|
589
589
|
...(opts.relationships !== undefined ? { relationships: opts.relationships } : {}),
|
|
590
590
|
...(opts.viewOrder !== undefined ? { viewOrder: opts.viewOrder } : {}),
|
|
591
|
+
...(opts.deleteDefaultListView !== undefined ? { deleteDefaultListView: opts.deleteDefaultListView } : {}),
|
|
591
592
|
...(opts.accessPolicies !== undefined ? { accessPolicies: opts.accessPolicies } : {}),
|
|
592
593
|
...(opts.roles !== undefined ? { roles: opts.roles } : {}),
|
|
593
594
|
...(opts.serviceAccounts !== undefined ? { serviceAccounts: opts.serviceAccounts } : {}),
|
|
@@ -220,13 +220,8 @@ export type NormalizedDashboardWidget = {
|
|
|
220
220
|
export interface NormalizedWidgetRef {
|
|
221
221
|
readonly kind: "app" | "element" | "task" | "automation" | "field" | "recordIdentity";
|
|
222
222
|
readonly key: string;
|
|
223
|
+
/** The display name; build looks an automation that is not in source up by it (#1900). */
|
|
223
224
|
readonly name: string;
|
|
224
|
-
/**
|
|
225
|
-
* Export display name, present only when pull read one. Build uses it to
|
|
226
|
-
* look up an automation that is not in source. Absent means `name` is not
|
|
227
|
-
* a display name.
|
|
228
|
-
*/
|
|
229
|
-
readonly displayName?: string;
|
|
230
225
|
readonly parent?: string;
|
|
231
226
|
readonly fieldType?: string;
|
|
232
227
|
readonly target?: NormalizedWidgetRef;
|
|
@@ -331,9 +326,10 @@ export interface PulledRelationshipRef {
|
|
|
331
326
|
export interface NormalizedRelationship {
|
|
332
327
|
readonly key: string;
|
|
333
328
|
readonly target: PulledRelationshipRef;
|
|
329
|
+
/** `relatedField` is a platform id when ei couldn't name another owner's field (#1991). */
|
|
334
330
|
readonly columns: readonly {
|
|
335
331
|
readonly field: string;
|
|
336
|
-
readonly relatedField: PulledRelationshipRef;
|
|
332
|
+
readonly relatedField: PulledRelationshipRef | string;
|
|
337
333
|
}[];
|
|
338
334
|
readonly filter?: NormalizedAccessPolicy["filter"];
|
|
339
335
|
}
|
|
@@ -409,6 +405,8 @@ export interface NormalizedApp {
|
|
|
409
405
|
readonly relationships?: readonly NormalizedRelationship[];
|
|
410
406
|
/** Display order of `listViews`, by key (`elementum_managed_view_order`). */
|
|
411
407
|
readonly viewOrder?: readonly string[];
|
|
408
|
+
/** `elementum_managed_view_order.delete_platform_default_list_view` (#1773). */
|
|
409
|
+
readonly deleteDefaultListView?: boolean;
|
|
412
410
|
/** App/element-level sharing & row-level-security policies (`elementum_access_policy`), in export order. */
|
|
413
411
|
readonly accessPolicies?: readonly NormalizedAccessPolicy[];
|
|
414
412
|
/** Custom roles only; managed roles are represented by data lookups. */
|
|
@@ -12,7 +12,7 @@ import { DEPLOY_DEFAULT_SYSTEM_FIELD_NAMES, SYSTEM_FIELD_KEYS, SYSTEM_FIELD_KEY_
|
|
|
12
12
|
import { EntityTfError } from "../../engine/entity.js";
|
|
13
13
|
import { dataRefLabel, optionalString, plainObject } from "../../engine/pull/context.js";
|
|
14
14
|
import { tfLabelToTsLabel } from "../../engine/tf/index.js";
|
|
15
|
-
import { accessPolicyFromTf } from "../access-policy/from-tf.js";
|
|
15
|
+
import { accessPolicyBlocksInLabelOrder, accessPolicyFromTf } from "../access-policy/from-tf.js";
|
|
16
16
|
import { dynamicLayoutCompanionWidgetLabels, dynamicLayoutsFromTf, } from "../dynamic-layout/from-tf.js";
|
|
17
17
|
import { dashboardsFromTf } from "../dashboard/from-tf.js";
|
|
18
18
|
import { fieldFromTf } from "../field/from-tf.js";
|
|
@@ -21,7 +21,7 @@ import { recordCreateFormFromTf } from "../record-create-form/from-tf.js";
|
|
|
21
21
|
import { relationshipsFromTf } from "../relationship/from-tf.js";
|
|
22
22
|
import { rolesFromTf } from "../role/from-tf.js";
|
|
23
23
|
import { serviceAccountsFromTf } from "../service-account/from-tf.js";
|
|
24
|
-
import { viewsFromTf } from "../view/from-tf.js";
|
|
24
|
+
import { fieldKeysByDisplayName, viewsFromTf } from "../view/from-tf.js";
|
|
25
25
|
import { widgetsFromTf } from "../widget/from-tf.js";
|
|
26
26
|
import { APP_RESOURCE_TYPE } from "./module.js";
|
|
27
27
|
import { stageHandleIndex } from "./stage-keys.js";
|
|
@@ -215,23 +215,28 @@ export function appFromTf(appBlock, fieldBlocks, ctx, viewBlocks = { layoutBlock
|
|
|
215
215
|
// One stage-handle map for every stage reference this app pulls (#1136).
|
|
216
216
|
const stageHandles = stageHandleIndex(stages.map((stage) => ({ key: stage.key, name: stage.stage.name })), ctx.diagnostics);
|
|
217
217
|
// --- View pass: layouts / list views / view order (entities/view), owner passed in.
|
|
218
|
-
const dashboards = dashboardsFromTf(viewBlocks.dashboardBlocks, viewBlocks.dashboardWidgetBlocks, { type: APP_RESOURCE_TYPE, label, ownerTfLabel: refName, ownerRefName: refName, scope: "app", ownerType: "APP_ASPECT" }, ctx);
|
|
219
218
|
const unextractedFieldIds = new Set();
|
|
220
|
-
const
|
|
219
|
+
const fieldKeys = new Set(fields.map((field) => field.key));
|
|
220
|
+
// Every field reference pull writes keeps an unextracted field as its platform id (#1736, #1966).
|
|
221
|
+
const fieldKeysByName = fieldKeysByDisplayName(fields);
|
|
222
|
+
const dashboards = dashboardsFromTf(viewBlocks.dashboardBlocks, viewBlocks.dashboardWidgetBlocks, { type: APP_RESOURCE_TYPE, label, ownerTfLabel: label, ownerRefName: refName, scope: "app", ownerType: "APP_ASPECT", fieldKeys, fieldKeysByName, unextractedFieldIds }, ctx);
|
|
223
|
+
const unextracted = { type: APP_RESOURCE_TYPE, label, ownerTfLabel: label, scope: "app", fieldKeys, fieldKeysByName, unextractedFieldIds };
|
|
224
|
+
const { layouts, listViews, calendarViews, kanbanViews, dashboardViews, agentViews, customViews, viewOrder, deleteDefaultListView } = viewsFromTf(viewBlocks.layoutBlocks, viewBlocks.listViewBlocks, viewBlocks.calendarViewBlocks, viewBlocks.kanbanViewBlocks, viewBlocks.dashboardViewBlocks, viewBlocks.agentViewBlocks, viewBlocks.managedViewOrderBlocks, {
|
|
221
225
|
type: APP_RESOURCE_TYPE, label, ownerTfLabel: label, scope: "app",
|
|
222
226
|
stageKeys: stageHandles.keys,
|
|
223
227
|
stageKeyByHandle: stageHandles.byHandle,
|
|
224
|
-
fieldKeys
|
|
228
|
+
fieldKeys,
|
|
229
|
+
fieldKeysByName,
|
|
225
230
|
unextractedFieldIds,
|
|
226
231
|
}, ctx, viewBlocks.customViewBlocks);
|
|
227
232
|
if (viewBlocks.recordCreateFormBlocks.length > 1) {
|
|
228
233
|
ctx.diagnostics.push(`app "${label}": found ${viewBlocks.recordCreateFormBlocks.length} record create forms; only the first is used`);
|
|
229
234
|
}
|
|
230
|
-
const recordCreateForm = recordCreateFormFromTf(viewBlocks.recordCreateFormBlocks[0], { type: APP_RESOURCE_TYPE, label, ownerTfLabel:
|
|
231
|
-
const dynamicLayoutOwner = { type: APP_RESOURCE_TYPE, label, ownerRefName: refName, ownerTfLabel: label, stageHandles };
|
|
235
|
+
const recordCreateForm = recordCreateFormFromTf(viewBlocks.recordCreateFormBlocks[0], { type: APP_RESOURCE_TYPE, label, ownerTfLabel: label, scope: "app", unextracted }, ctx);
|
|
236
|
+
const dynamicLayoutOwner = { type: APP_RESOURCE_TYPE, label, ownerRefName: refName, ownerTfLabel: label, stageHandles, unextracted };
|
|
232
237
|
const dynamicLayouts = dynamicLayoutsFromTf(viewBlocks.dynamicLayoutBlocks, dynamicLayoutOwner, ctx);
|
|
233
|
-
const relationships = relationshipsFromTf(viewBlocks.relationshipBlocks, { kind: "app", label, ownerRefName: refName, ownerTfLabel:
|
|
234
|
-
const widgets = widgetsFromTf(viewBlocks.widgetBlocks, { type: APP_RESOURCE_TYPE, label, ownerRefName: refName, ownerTfLabel: label, scope: "app" }, ctx, dynamicLayoutCompanionWidgetLabels(viewBlocks.dynamicLayoutBlocks, dynamicLayoutOwner));
|
|
238
|
+
const relationships = relationshipsFromTf(viewBlocks.relationshipBlocks, { kind: "app", label, ownerRefName: refName, ownerTfLabel: label, scope: "app", unextracted }, ctx);
|
|
239
|
+
const widgets = widgetsFromTf(viewBlocks.widgetBlocks, { type: APP_RESOURCE_TYPE, label, ownerRefName: refName, ownerTfLabel: label, scope: "app", unextracted }, ctx, dynamicLayoutCompanionWidgetLabels(viewBlocks.dynamicLayoutBlocks, dynamicLayoutOwner));
|
|
235
240
|
// --- Access policies (entities/access-policy), owner passed in.
|
|
236
241
|
const accessPolicyOwner = {
|
|
237
242
|
type: APP_RESOURCE_TYPE,
|
|
@@ -241,7 +246,7 @@ export function appFromTf(appBlock, fieldBlocks, ctx, viewBlocks = { layoutBlock
|
|
|
241
246
|
scope: "app",
|
|
242
247
|
};
|
|
243
248
|
const accessPolicies = [];
|
|
244
|
-
for (const block of accessPolicyBlocks) {
|
|
249
|
+
for (const block of accessPolicyBlocksInLabelOrder(accessPolicyBlocks)) {
|
|
245
250
|
const entry = accessPolicyFromTf(block, accessPolicyOwner, ctx);
|
|
246
251
|
if (entry !== undefined)
|
|
247
252
|
accessPolicies.push(entry);
|
|
@@ -283,6 +288,7 @@ export function appFromTf(appBlock, fieldBlocks, ctx, viewBlocks = { layoutBlock
|
|
|
283
288
|
...(dynamicLayouts.length > 0 && { dynamicLayouts }),
|
|
284
289
|
...(relationships.length > 0 && { relationships }),
|
|
285
290
|
...(viewOrder !== undefined && { viewOrder }),
|
|
291
|
+
...(deleteDefaultListView !== undefined && { deleteDefaultListView }),
|
|
286
292
|
...(accessPolicies.length > 0 && { accessPolicies }),
|
|
287
293
|
...(roles.length > 0 && { roles }),
|
|
288
294
|
...(serviceAccounts.length > 0 && { serviceAccounts }),
|
|
@@ -270,7 +270,7 @@ export function appToTf(entity, ctx) {
|
|
|
270
270
|
availableChartRefNames: ctx.workspaceAspects?.get(workspaceAspectKey("app", ctx.appRefName))?.managedChildRefNames?.get("chart"),
|
|
271
271
|
diagnostics: ctx.diagnostics,
|
|
272
272
|
}));
|
|
273
|
-
|
|
273
|
+
const widgets = widgetsToTf(payload.widgets, {
|
|
274
274
|
ownerRefName: ctx.appRefName,
|
|
275
275
|
ownerTfLabel: ctx.appTfLabel,
|
|
276
276
|
ownerType: APP_RESOURCE_TYPE,
|
|
@@ -281,7 +281,8 @@ export function appToTf(entity, ctx) {
|
|
|
281
281
|
diagnostics: ctx.diagnostics,
|
|
282
282
|
fieldAddresses,
|
|
283
283
|
relationshipTargets: relationshipTargetsFromBag(payload.relationships),
|
|
284
|
-
})
|
|
284
|
+
});
|
|
285
|
+
blocks.push(...widgets.blocks);
|
|
285
286
|
const { blocks: viewBlocks } = viewToTf(payload.layouts, payload.listViews, payload.calendarViews, payload.kanbanViews, payload.dashboardViews, payload.agentViews, payload.viewOrder, {
|
|
286
287
|
ownerRefName: ctx.appRefName,
|
|
287
288
|
ownerTfLabel: ctx.appTfLabel,
|
|
@@ -295,7 +296,8 @@ export function appToTf(entity, ctx) {
|
|
|
295
296
|
fieldAddresses,
|
|
296
297
|
fieldNames,
|
|
297
298
|
fieldMetadata,
|
|
298
|
-
|
|
299
|
+
widgets: widgets.widgets,
|
|
300
|
+
...(payload.deleteDefaultListView !== undefined ? { deleteDefaultListView: payload.deleteDefaultListView } : {}),
|
|
299
301
|
}, payload.customViews);
|
|
300
302
|
blocks.push(...viewBlocks);
|
|
301
303
|
const recordCreateForm = recordCreateFormToTf(payload.recordCreateForm, {
|
|
@@ -316,7 +318,7 @@ export function appToTf(entity, ctx) {
|
|
|
316
318
|
orgRefs: ctx.orgRefs,
|
|
317
319
|
workspaceAspects: ctx.workspaceAspects,
|
|
318
320
|
fieldAddresses,
|
|
319
|
-
|
|
321
|
+
widgets: widgets.widgets,
|
|
320
322
|
stageKeyByTfLabel,
|
|
321
323
|
}));
|
|
322
324
|
blocks.push(...relationshipsToTf(payload.relationships, {
|
|
@@ -97,7 +97,7 @@ export declare const FOR_EACH_PLACEHOLDER = "__forEach__";
|
|
|
97
97
|
* accessor → canonical; identity for most kinds. Validated against
|
|
98
98
|
* TASK_OUTPUT_CONTRACTS by canonical-reference-model.test.ts.
|
|
99
99
|
*/
|
|
100
|
-
export declare function rewriteCanonicalOutputRefName(taskKey: string | undefined, name: string, taskRefKey?: string, schema?: unknown): string;
|
|
100
|
+
export declare function rewriteCanonicalOutputRefName(taskKey: string | undefined, name: string, taskRefKey?: string, schema?: unknown, apiResponseType?: string): string;
|
|
101
101
|
/** One finalized automation-level output property (already serialized to wire). */
|
|
102
102
|
export interface OutputEntry {
|
|
103
103
|
readonly name: string;
|
|
@@ -278,12 +278,7 @@ interface ActionMethods<TTrigger, TActions extends Record<string, unknown>, TVar
|
|
|
278
278
|
aiFileAnalysis<TName extends string>(name: TName, opts: BuilderActionOptions<TTrigger, TActions, TVars, TItem, import("./tasks.js").AiFileAnalysisOptions>, displayName?: string, hclParent?: "trigger" | string): WithAction<TMode, TItem, TTrigger, TActions, TVars, TName, {
|
|
279
279
|
output: unknown;
|
|
280
280
|
}>;
|
|
281
|
-
apiRequest<TName extends string>(name: TName, opts: BuilderActionOptions<TTrigger, TActions, TVars, TItem, import("./tasks.js").ApiRequestOptions
|
|
282
|
-
response: unknown;
|
|
283
|
-
file?: unknown;
|
|
284
|
-
statusCode?: unknown;
|
|
285
|
-
textResponse?: unknown;
|
|
286
|
-
}>;
|
|
281
|
+
apiRequest<TName extends string, R extends import("./tasks.js").ApiResponseType = "JSON">(name: TName, opts: BuilderActionOptions<TTrigger, TActions, TVars, TItem, import("./tasks.js").ApiRequestOptions<R>>, displayName?: string, hclParent?: "trigger" | string): WithAction<TMode, TItem, TTrigger, TActions, TVars, TName, import("./tasks.js").ApiRequestOutputs<R>>;
|
|
287
282
|
calculation<TName extends string, const Values extends import("./tasks.js").CalculationValues>(name: TName, opts: BuilderActionOptions<TTrigger, TActions, TVars, TItem, import("./tasks.js").CalculationOptions<Values>>, displayName?: string, hclParent?: "trigger" | string): WithAction<TMode, TItem, TTrigger, TActions, TVars, TName, import("./tasks.js").CalculationValueOutputs<Values>>;
|
|
288
283
|
calculation<TName extends string, const Entries extends readonly import("./tasks.js").CalculationEntry[]>(name: TName, opts: BuilderActionOptions<TTrigger, TActions, TVars, TItem, import("./tasks.js").LegacyCalculationOptions<Entries>>, displayName?: string, hclParent?: "trigger" | string): WithAction<TMode, TItem, TTrigger, TActions, TVars, TName, import("./tasks.js").CalculationOutputs<Entries>>;
|
|
289
284
|
procedure<TName extends string, const Parameters extends readonly import("../../catalog/types.js").ProcedureParameterType[]>(name: TName, opts: BuilderActionOptions<TTrigger, TActions, TVars, TItem, import("./tasks.js").TypedProcedureOptions<Parameters>>, displayName?: string, hclParent?: "trigger" | string): WithAction<TMode, TItem, TTrigger, TActions, TVars, TName, Record<string, unknown>>;
|
|
@@ -31,7 +31,7 @@ import { isOnDemandRecordType } from "../shared/types/field-types.js";
|
|
|
31
31
|
import { buildContext, createForEachItemProxy } from "../shared/context.js";
|
|
32
32
|
import { outputFieldTypesFromScriptSchema, scriptSchemaIsSingleStringArray } from "./output-field-types.js";
|
|
33
33
|
import { isRef } from "../shared/ref.js";
|
|
34
|
-
import {
|
|
34
|
+
import { apiTaskCanonicalOutputName, apiTaskJsonRefsKeys, apiTaskRefsIndex, OUTPUT_KEY_CANONICAL, OUTPUT_KEY_WIRE_NAME } from "./output-key-wire-name.js";
|
|
35
35
|
import { extractScriptBody, inferOutputSchema, isScriptFile, readScriptFile, toPlatformScriptBody, tryExtractFromCurrentSource } from "./script-code.js";
|
|
36
36
|
import { serializeNode } from "./serialize.js";
|
|
37
37
|
// Runtime factory imports stay below the public action-native surface. Their
|
|
@@ -130,6 +130,30 @@ function collectExecuteScriptOutputSchemas(tasks) {
|
|
|
130
130
|
visit(tasks);
|
|
131
131
|
return out;
|
|
132
132
|
}
|
|
133
|
+
/** Build error for an output a JSON apiRequest doesn't have (edk#2058). */
|
|
134
|
+
function apiTaskMissingOutput(taskRefKey, name, apiResponseType) {
|
|
135
|
+
throw new EntityTfError(`apiRequest task "${taskRefKey ?? "?"}" has no "${name}" output: a ${apiResponseType ?? "JSON"} response ` +
|
|
136
|
+
`exposes only .response, .textResponse and .statusCode (refs ${apiTaskJsonRefsKeys().map((k) => `"${k}"`).join(", ")}). ` +
|
|
137
|
+
"Reference one of those, or set the task's responseType to the kind of response it returns.");
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Map every apiRequest task's refKey to its `responseType`, descending into
|
|
141
|
+
* operator children — mirrors `collectTaskKinds`. Its refs-map keys depend on
|
|
142
|
+
* it (edk#2058).
|
|
143
|
+
*/
|
|
144
|
+
function collectApiResponseTypes(tasks) {
|
|
145
|
+
const out = new Map();
|
|
146
|
+
const visit = (entries) => {
|
|
147
|
+
for (const { name, def } of entries) {
|
|
148
|
+
if (def.key === "api" && typeof def.config.responseType === "string")
|
|
149
|
+
out.set(name, def.config.responseType);
|
|
150
|
+
for (const child of def.operatorChildren ?? [])
|
|
151
|
+
visit(child.tasks);
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
visit(tasks);
|
|
155
|
+
return out;
|
|
156
|
+
}
|
|
133
157
|
/**
|
|
134
158
|
* Resolve an automation-level output's `valueType` from its (already
|
|
135
159
|
* serialized) value. Explicit workflowOutput metadata wins. Otherwise, infer
|
|
@@ -327,12 +351,12 @@ function assertKnownScriptOutput(name, taskRefKey, schema, checkDeclaredResult)
|
|
|
327
351
|
* - single-scalar-output tasks (see `OUTPUT_KEY_WIRE_NAME`): `output` →
|
|
328
352
|
* the platform's actual output name for that task kind.
|
|
329
353
|
*/
|
|
330
|
-
function rewriteForwardTaskRefName(taskKey, name, taskRefKey, schema, checkDeclaredScriptResult = true) {
|
|
354
|
+
function rewriteForwardTaskRefName(taskKey, name, taskRefKey, schema, checkDeclaredScriptResult = true, apiResponseType) {
|
|
331
355
|
if (taskKey === "findRelatedRecords" && FIND_RELATED_RECORDS_COUNT_REF_NAMES.has(name.split(".")[0])) {
|
|
332
356
|
throw findRelatedRecordsTotalCountError(taskRefKey);
|
|
333
357
|
}
|
|
334
358
|
if (taskKey === "api") {
|
|
335
|
-
return
|
|
359
|
+
return apiTaskRefsIndex(apiResponseType, name) ?? apiTaskMissingOutput(taskRefKey, name, apiResponseType);
|
|
336
360
|
}
|
|
337
361
|
if (taskKey === "recordSearch" && name === "totalCount") {
|
|
338
362
|
return "Records Size";
|
|
@@ -386,7 +410,7 @@ function rewriteForwardTaskRefName(taskKey, name, taskRefKey, schema, checkDecla
|
|
|
386
410
|
* accessor → canonical; identity for most kinds. Validated against
|
|
387
411
|
* TASK_OUTPUT_CONTRACTS by canonical-reference-model.test.ts.
|
|
388
412
|
*/
|
|
389
|
-
export function rewriteCanonicalOutputRefName(taskKey, name, taskRefKey, schema) {
|
|
413
|
+
export function rewriteCanonicalOutputRefName(taskKey, name, taskRefKey, schema, apiResponseType) {
|
|
390
414
|
if (taskKey === "findRelatedRecords" && FIND_RELATED_RECORDS_COUNT_REF_NAMES.has(name.split(".")[0])) {
|
|
391
415
|
throw findRelatedRecordsTotalCountError(taskRefKey);
|
|
392
416
|
}
|
|
@@ -399,8 +423,10 @@ export function rewriteCanonicalOutputRefName(taskKey, name, taskRefKey, schema)
|
|
|
399
423
|
// provider's refs-map DISPLAY label ("Content" / "Content Type" / "Name", via
|
|
400
424
|
// API_TASK_REF_WIRE_NAMES). Keep the base display rewrite. Top-level api
|
|
401
425
|
// outputs ARE contract names and ride the envelope as identity.
|
|
402
|
-
return rewriteForwardTaskRefName(taskKey, name, taskRefKey, schema);
|
|
426
|
+
return rewriteForwardTaskRefName(taskKey, name, taskRefKey, schema, true, apiResponseType);
|
|
403
427
|
}
|
|
428
|
+
if (taskKey === "api")
|
|
429
|
+
return apiTaskCanonicalOutputName(apiResponseType, name) ?? apiTaskMissingOutput(taskRefKey, name, apiResponseType);
|
|
404
430
|
if ((taskKey === "recordSearch" || taskKey === "tableRecordsSearch") && name === "totalCount") {
|
|
405
431
|
// Both expose a `totalCount` accessor, but the executors' canonical count
|
|
406
432
|
// output is `count` (aspect_records_search.count / table_records_search.count).
|
|
@@ -477,10 +503,10 @@ function rewriteTaskOutputRefs(node, taskKindByRefKey, scriptSchemas,
|
|
|
477
503
|
// those positions.
|
|
478
504
|
canonical = false,
|
|
479
505
|
// Field assignments rebuild an undeclared result.* as the value envelope.
|
|
480
|
-
checkDeclaredScriptResult = true) {
|
|
506
|
+
checkDeclaredScriptResult = true, apiResponseTypes = new Map()) {
|
|
481
507
|
if (Array.isArray(node)) {
|
|
482
508
|
for (const item of node)
|
|
483
|
-
rewriteTaskOutputRefs(item, taskKindByRefKey, scriptSchemas, canonical, checkDeclaredScriptResult);
|
|
509
|
+
rewriteTaskOutputRefs(item, taskKindByRefKey, scriptSchemas, canonical, checkDeclaredScriptResult, apiResponseTypes);
|
|
484
510
|
return;
|
|
485
511
|
}
|
|
486
512
|
if (node === null || typeof node !== "object")
|
|
@@ -504,14 +530,15 @@ checkDeclaredScriptResult = true) {
|
|
|
504
530
|
if (ref && typeof ref.taskRefKey === "string" && typeof ref.name === "string") {
|
|
505
531
|
const kind = taskKindByRefKey.get(ref.taskRefKey);
|
|
506
532
|
const schema = scriptSchemas.get(ref.taskRefKey);
|
|
533
|
+
const apiResponseType = apiResponseTypes.get(ref.taskRefKey);
|
|
507
534
|
ref.name = canonical
|
|
508
|
-
? rewriteCanonicalOutputRefName(kind, ref.name, ref.taskRefKey, schema)
|
|
509
|
-
: rewriteForwardTaskRefName(kind, ref.name, ref.taskRefKey, schema, checkDeclaredScriptResult);
|
|
535
|
+
? rewriteCanonicalOutputRefName(kind, ref.name, ref.taskRefKey, schema, apiResponseType)
|
|
536
|
+
: rewriteForwardTaskRefName(kind, ref.name, ref.taskRefKey, schema, checkDeclaredScriptResult, apiResponseType);
|
|
510
537
|
}
|
|
511
538
|
if (rec.type === "TASK" && typeof rec.taskRefKey === "string" && typeof rec.name === "string") {
|
|
512
539
|
// Filter `{type:"TASK"}` shapes never appear in a workflow OUTPUT subtree;
|
|
513
540
|
// keep the display rewrite (#1271's filter path) regardless of `canonical`.
|
|
514
|
-
rec.name = rewriteForwardTaskRefName(taskKindByRefKey.get(rec.taskRefKey), rec.name, rec.taskRefKey, scriptSchemas.get(rec.taskRefKey), false);
|
|
541
|
+
rec.name = rewriteForwardTaskRefName(taskKindByRefKey.get(rec.taskRefKey), rec.name, rec.taskRefKey, scriptSchemas.get(rec.taskRefKey), false, apiResponseTypes.get(rec.taskRefKey));
|
|
515
542
|
}
|
|
516
543
|
for (const [key, v] of Object.entries(rec)) {
|
|
517
544
|
// A calc-engine mustache subtree (`calculationReference` → templateReference)
|
|
@@ -519,7 +546,7 @@ checkDeclaredScriptResult = true) {
|
|
|
519
546
|
// (decodeCalculationTaskMustache) stays idempotent.
|
|
520
547
|
const childCanonical = key === "calculationReference" ? false : canonical;
|
|
521
548
|
const childCheck = key === "workflowFields" ? false : checkDeclaredScriptResult;
|
|
522
|
-
rewriteTaskOutputRefs(v, taskKindByRefKey, scriptSchemas, childCanonical, childCheck);
|
|
549
|
+
rewriteTaskOutputRefs(v, taskKindByRefKey, scriptSchemas, childCanonical, childCheck, apiResponseTypes);
|
|
523
550
|
}
|
|
524
551
|
}
|
|
525
552
|
/**
|
|
@@ -667,7 +694,8 @@ function makeActionBuilder(state, mode = "root", item, loops = {}) {
|
|
|
667
694
|
// untranspiled source when running under `elementum build`
|
|
668
695
|
// (tryExtractFromCurrentSource); fall back to the toString()-based
|
|
669
696
|
// extractScriptBody otherwise (e.g. an automation built directly in a
|
|
670
|
-
// test, with no tracked source file
|
|
697
|
+
// test, with no tracked source file, or a hand-typed body whose source
|
|
698
|
+
// is not plain JavaScript, #1927). Either way the body is computed
|
|
671
699
|
// exactly ONCE here and threaded straight into the ActionDef — no
|
|
672
700
|
// separate re-extraction downstream.
|
|
673
701
|
// Explicit `outputs` always wins; an explicit `null` means "no schema"
|
|
@@ -771,15 +799,16 @@ function makeActionBuilder(state, mode = "root", item, loops = {}) {
|
|
|
771
799
|
__finalize() {
|
|
772
800
|
const taskKindByRefKey = collectTaskKinds(state.tasks);
|
|
773
801
|
const scriptSchemas = collectExecuteScriptOutputSchemas(state.tasks);
|
|
802
|
+
const apiResponseTypes = collectApiResponseTypes(state.tasks);
|
|
774
803
|
const tasks = state.tasks.map((t) => serializeTaskEntry(t.name, t.def, t.displayName, t.hclParent));
|
|
775
804
|
// Deep copy: the rewrites below mutate in place, and `state.outputs` is
|
|
776
805
|
// shared by every build of this definition (#1536).
|
|
777
806
|
const outputs = state.outputs?.map((o) => structuredClone(o));
|
|
778
|
-
rewriteTaskOutputRefs(tasks, taskKindByRefKey, scriptSchemas);
|
|
807
|
+
rewriteTaskOutputRefs(tasks, taskKindByRefKey, scriptSchemas, false, true, apiResponseTypes);
|
|
779
808
|
// Workflow OUTPUTS emit the platform's CANONICAL output name (edk#835);
|
|
780
809
|
// task inputs/filters above stay on the display path (#1271 owns them).
|
|
781
810
|
if (outputs)
|
|
782
|
-
rewriteTaskOutputRefs(outputs, taskKindByRefKey, scriptSchemas, /* canonical */ true);
|
|
811
|
+
rewriteTaskOutputRefs(outputs, taskKindByRefKey, scriptSchemas, /* canonical */ true, true, apiResponseTypes);
|
|
783
812
|
// Trigger reference names are NOT canonicalized: the authored name is
|
|
784
813
|
// the name, everywhere in EDK. (Mobius canonicalizes reference names in
|
|
785
814
|
// ITS storage — `ValueReference.ofTriggerReference` — but on the tf
|
|
@@ -97,13 +97,13 @@ export type TriggerAst = {
|
|
|
97
97
|
customResponse?: {
|
|
98
98
|
success?: {
|
|
99
99
|
enabled: boolean;
|
|
100
|
-
format: "JSON" | "XML" | "
|
|
100
|
+
format: "JSON" | "XML" | "TEXT";
|
|
101
101
|
statusCode?: number;
|
|
102
102
|
body: string;
|
|
103
103
|
};
|
|
104
104
|
failure?: {
|
|
105
105
|
enabled: boolean;
|
|
106
|
-
format: "JSON" | "XML" | "
|
|
106
|
+
format: "JSON" | "XML" | "TEXT";
|
|
107
107
|
statusCode?: number;
|
|
108
108
|
body: string;
|
|
109
109
|
};
|
|
@@ -111,14 +111,15 @@ export type TriggerAst = {
|
|
|
111
111
|
} | {
|
|
112
112
|
kind: "temporal";
|
|
113
113
|
app: AppRefAst | UnresolvedRefAst;
|
|
114
|
-
|
|
114
|
+
field: FieldRefAst | UnresolvedRefAst;
|
|
115
115
|
temporalUnit: "MINUTES" | "HOURS" | "DAYS";
|
|
116
116
|
value: number;
|
|
117
|
+
filter?: Filter<RefExpr, RefExpr>;
|
|
117
118
|
} | {
|
|
118
119
|
kind: "approvalProcessStatusUpdated";
|
|
119
120
|
app: AppRefAst | UnresolvedRefAst;
|
|
120
121
|
approvalChain?: string | ApprovalChainRefAst;
|
|
121
|
-
status: "ACTIVE" | "STEP_APPROVED" | "CANCELLED" | "DENIED" | "APPROVED";
|
|
122
|
+
status: "ACTIVE" | "STEP_APPROVED" | "CANCELLED" | "DENIED" | "APPROVED" | "EXCEPTION";
|
|
122
123
|
filter?: Filter<RefExpr, RefExpr>;
|
|
123
124
|
} | {
|
|
124
125
|
kind: "schedule";
|
|
@@ -133,6 +134,7 @@ export type TriggerAst = {
|
|
|
133
134
|
datamine: DatamineRefAst | string;
|
|
134
135
|
fireOnAlert?: boolean;
|
|
135
136
|
fireOnRecovery?: boolean;
|
|
137
|
+
filter?: Filter<RefExpr, RefExpr>;
|
|
136
138
|
} | {
|
|
137
139
|
kind: "emailReceived";
|
|
138
140
|
emailAliasId: string;
|
|
@@ -142,6 +144,7 @@ export type TriggerAst = {
|
|
|
142
144
|
kind: "surveyResponseCreate";
|
|
143
145
|
app: AppRefAst | UnresolvedRefAst;
|
|
144
146
|
survey: string;
|
|
147
|
+
filter?: Filter<RefExpr, RefExpr>;
|
|
145
148
|
};
|
|
146
149
|
export interface AutomationAst {
|
|
147
150
|
readonly ownerHandle: string;
|
|
@@ -869,15 +869,14 @@ function printTrigger(trigger, state) {
|
|
|
869
869
|
}
|
|
870
870
|
case "temporal": {
|
|
871
871
|
const temporal = trackFactory("temporal", state);
|
|
872
|
-
const fieldExpr = trigger.app.kind === "app"
|
|
873
|
-
? printFieldRef(trigger.app.appHandle, trigger.fieldKey, state)
|
|
874
|
-
: `${quote(trigger.fieldKey.replace(/^__unresolved_/, ""))} as any /* TODO: unresolved field */`;
|
|
875
872
|
const parts = [
|
|
876
873
|
`app: ${printRef(trigger.app, state, DEFAULT_CTX)}`,
|
|
877
|
-
`field: ${
|
|
874
|
+
`field: ${printRef(trigger.field, state, DEFAULT_CTX)}`,
|
|
878
875
|
`temporalUnit: ${quote(trigger.temporalUnit)}`,
|
|
879
876
|
`value: ${trigger.value}`,
|
|
880
877
|
];
|
|
878
|
+
if (trigger.filter)
|
|
879
|
+
parts.push(`filter: ${printFilter(trigger.filter, state)}`);
|
|
881
880
|
return `${temporal}({\n ${parts.join(",\n ")}\n })`;
|
|
882
881
|
}
|
|
883
882
|
case "approvalProcessStatusUpdated": {
|
|
@@ -939,6 +938,9 @@ function printTrigger(trigger, state) {
|
|
|
939
938
|
if (trigger.fireOnRecovery !== undefined) {
|
|
940
939
|
parts.push(`fireOnRecovery: ${trigger.fireOnRecovery}`);
|
|
941
940
|
}
|
|
941
|
+
if (trigger.filter) {
|
|
942
|
+
parts.push(`filter: ${printFilter(trigger.filter, state)}`);
|
|
943
|
+
}
|
|
942
944
|
return `${dataMine}({ ${parts.join(", ")} })`;
|
|
943
945
|
}
|
|
944
946
|
case "emailReceived": {
|
|
@@ -955,6 +957,7 @@ function printTrigger(trigger, state) {
|
|
|
955
957
|
const parts = [
|
|
956
958
|
`app: ${printRef(trigger.app, state, DEFAULT_CTX)}`,
|
|
957
959
|
`survey: unsafePlatformId(${quote(trigger.survey)})${unresolvedReferenceComment(trigger.survey, state.unresolvedReferences)}`,
|
|
960
|
+
...(trigger.filter ? [`filter: ${printFilter(trigger.filter, state)}`] : []),
|
|
958
961
|
];
|
|
959
962
|
return `${surveyResponseCreate}({\n ${parts.join(",\n ")}\n })`;
|
|
960
963
|
}
|
|
@@ -975,13 +978,6 @@ function recordTriggerBody(trigger, state) {
|
|
|
975
978
|
parts.push(`thinkUi: ${trigger.thinkUi}`);
|
|
976
979
|
return `{ ${parts.join(", ")} }`;
|
|
977
980
|
}
|
|
978
|
-
function printFieldRef(appHandle, fieldKey, state) {
|
|
979
|
-
if (!fieldKey.startsWith("__unresolved_")) {
|
|
980
|
-
return `catalog.${catalogOwnerHandle(state, appHandle)}.fields${safeMember(fieldKey)}`;
|
|
981
|
-
}
|
|
982
|
-
const uuid = fieldKey.replace(/^__unresolved_/, "");
|
|
983
|
-
return `${quote(uuid)} as any /* TODO: unresolved field */`;
|
|
984
|
-
}
|
|
985
981
|
// ---------------------------------------------------------------------------
|
|
986
982
|
// Tasks
|
|
987
983
|
// ---------------------------------------------------------------------------
|