@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
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { expr, isUuid } from "../../engine/tf/index.js";
|
|
2
|
+
import { isOnDemandRecordType } from "../shared/types/field-types.js";
|
|
3
|
+
import { AUTOMATION_RESOURCE_TYPE, WORKFLOW_PUBLISH_RESOURCE_TYPE, automationResourceLabel } from "./types.js";
|
|
4
|
+
/**
|
|
5
|
+
* The app or element that owns an automation token, and whether that is the
|
|
6
|
+
* building automation's own app or element. A token with no `parent` is the
|
|
7
|
+
* caller's own. A same-named automation in another app or element is a
|
|
8
|
+
* different automation (edk#2118).
|
|
9
|
+
*/
|
|
10
|
+
export function automationTargetOwner(value, ctx) {
|
|
11
|
+
const ownerKind = value.parentKind ?? ctx.parentScope;
|
|
12
|
+
const isOwn = value.parent === undefined ||
|
|
13
|
+
(value.parent === ctx.appRefName && ownerKind === ctx.parentScope);
|
|
14
|
+
return { ownerKind, isOwn };
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* A bare platform-id target whose every input names a raw parameter id is a
|
|
18
|
+
* static run: pull prints a static export with an undiscovered target
|
|
19
|
+
* (`target_automation_id` + `input_mappings[].parameter_id`) as
|
|
20
|
+
* `automation: "<uuid>"` + `inputs[].name: "<uuid>"`. Dynamic mappings name
|
|
21
|
+
* the target's inputs, never a parameter id.
|
|
22
|
+
*/
|
|
23
|
+
export function bareStaticRunTarget(config) {
|
|
24
|
+
return typeof config.targetAutomationId === "string" &&
|
|
25
|
+
Array.isArray(config.inputMappings) &&
|
|
26
|
+
config.inputMappings.length > 0 &&
|
|
27
|
+
config.inputMappings.every((mapping) => mapping !== null && typeof mapping === "object" && "name" in mapping && typeof mapping.name === "string" && isUuid(mapping.name));
|
|
28
|
+
}
|
|
29
|
+
/** The onDemand trigger's record parameters: they expose only a record ID. */
|
|
30
|
+
export function onDemandRecordParamNames(trigger) {
|
|
31
|
+
const inputs = trigger?.onDemand?.inputs;
|
|
32
|
+
if (!Array.isArray(inputs))
|
|
33
|
+
return new Set();
|
|
34
|
+
return new Set(inputs.flatMap((input) => {
|
|
35
|
+
const param = input;
|
|
36
|
+
return typeof param?.name === "string" && isOnDemandRecordType(typeof param.type === "string" ? param.type : undefined) ? [param.name] : [];
|
|
37
|
+
}));
|
|
38
|
+
}
|
|
39
|
+
/** An automation payload's on-demand record inputs, for a static runAutomation caller's check (edk#1868). */
|
|
40
|
+
export function automationOnDemandRecordInputs(payload) {
|
|
41
|
+
return onDemandRecordParamNames(payload?.trigger);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* edk#1868: a static runAutomation mapping into the target's on-demand record
|
|
45
|
+
* input reaches the target as no record, so every task reading it fails at
|
|
46
|
+
* run time. Returns the problem, naming the text-handle workaround, or
|
|
47
|
+
* undefined. `recordInputNames` is known only for a target this build owns.
|
|
48
|
+
*/
|
|
49
|
+
export function recordInputMappingProblem(target, mappings, recordInputNames) {
|
|
50
|
+
if (recordInputNames === undefined || recordInputNames.size === 0)
|
|
51
|
+
return undefined;
|
|
52
|
+
const mapped = [...new Set(mappings.flatMap((mapping) => {
|
|
53
|
+
const name = mapping?.name;
|
|
54
|
+
return typeof name === "string" && recordInputNames.has(name) ? [name] : [];
|
|
55
|
+
}))];
|
|
56
|
+
if (mapped.length === 0)
|
|
57
|
+
return undefined;
|
|
58
|
+
const label = `${target.name !== undefined && target.name !== "" ? `"${target.name}" ` : ""}(${target.parent !== undefined ? `${target.parent}.` : ""}${target.refName})`;
|
|
59
|
+
const plural = mapped.length > 1;
|
|
60
|
+
return `maps automation ${label}'s on-demand record input${plural ? "s" : ""} ${mapped.map((name) => `"${name}"`).join(", ")}, ` +
|
|
61
|
+
`but the platform passes no record through a runAutomation input: the called automation's tasks that read ${plural ? "them" : "it"} ` +
|
|
62
|
+
`fail at run time ("missing workflow input parameter"). Make ${plural ? "each" : "it"} a text input, pass the record's handle as text, ` +
|
|
63
|
+
"and look the record up with a recordSearch in the called automation.";
|
|
64
|
+
}
|
|
65
|
+
/** Run-automation targets reference publish for ACTIVE automations, automation for draft/inactive. */
|
|
66
|
+
export function automationRunTargetResourceAttr(appTfLabel, automationRefName, activeAutomationRefNames, scope = "app", handle) {
|
|
67
|
+
const label = automationResourceLabel(appTfLabel, automationRefName, scope, handle);
|
|
68
|
+
if (activeAutomationRefNames?.has(automationRefName) === true) {
|
|
69
|
+
return expr.resourceAttr(WORKFLOW_PUBLISH_RESOURCE_TYPE, label, ["id"]);
|
|
70
|
+
}
|
|
71
|
+
return expr.resourceAttr(AUTOMATION_RESOURCE_TYPE, label, ["id"]);
|
|
72
|
+
}
|
|
73
|
+
const PUBLISH_DECL = new RegExp(`^resource\\s+"${WORKFLOW_PUBLISH_RESOURCE_TYPE}"\\s+"([^"]+)"`, "gm");
|
|
74
|
+
const PUBLISH_REF = new RegExp(`(?<![\\w.])${WORKFLOW_PUBLISH_RESOURCE_TYPE}\\.([a-z0-9_]+)`, "g");
|
|
75
|
+
/** The publish resource addresses a compiled automation file declares (its own). */
|
|
76
|
+
export function automationPublishDeclarations(text) {
|
|
77
|
+
return [...text.matchAll(PUBLISH_DECL)].map((match) => `${WORKFLOW_PUBLISH_RESOURCE_TYPE}.${match[1]}`);
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* The publish addresses of a compiled automation file's static
|
|
81
|
+
* `runAutomation` targets. A static call to an ACTIVE target names the
|
|
82
|
+
* target's publish: the run task and the caller's publish `depends_on` it
|
|
83
|
+
* (own app or element, `automationToTf`), and the target lookup
|
|
84
|
+
* `data.<automation>.<target>_for_<caller>` `depends_on` it (another app or
|
|
85
|
+
* element in the workspace, `automationTargetToTf`). Nothing else in an
|
|
86
|
+
* automation file names another automation's publish. A target outside the
|
|
87
|
+
* workspace (a lookup by name) or one that is not ACTIVE names no publish and
|
|
88
|
+
* is not tracked.
|
|
89
|
+
*/
|
|
90
|
+
export function staticRunTargets(text) {
|
|
91
|
+
const own = new Set(automationPublishDeclarations(text));
|
|
92
|
+
const targets = new Set();
|
|
93
|
+
for (const match of text.matchAll(PUBLISH_REF)) {
|
|
94
|
+
const address = `${WORKFLOW_PUBLISH_RESOURCE_TYPE}.${match[1]}`;
|
|
95
|
+
if (!own.has(address))
|
|
96
|
+
targets.add(address);
|
|
97
|
+
}
|
|
98
|
+
return [...targets].sort();
|
|
99
|
+
}
|
|
@@ -114,5 +114,14 @@ export declare function freeIdentifiersLexer(body: string, params: ReadonlySet<s
|
|
|
114
114
|
* there's no tracked source (not running under `elementum build`, e.g. an
|
|
115
115
|
* automation constructed directly in a test) or the name/shape wasn't found
|
|
116
116
|
* by the scan (falls back to `extractScriptBody`).
|
|
117
|
+
*
|
|
118
|
+
* A body that is not plain JavaScript is also `undefined` (#1927). The
|
|
119
|
+
* verbatim text exists so a pulled body, which is always JavaScript,
|
|
120
|
+
* round-trips byte for byte. A body with type annotations was written by
|
|
121
|
+
* hand, and the runtime that loaded the file has already erased its types
|
|
122
|
+
* from the function itself, so `extractScriptBody` gives the same result in
|
|
123
|
+
* every workspace instead of depending on whether a usable TypeScript
|
|
124
|
+
* compiler happens to resolve. It also runs the closure check, which this
|
|
125
|
+
* path skips.
|
|
117
126
|
*/
|
|
118
127
|
export declare function tryExtractFromCurrentSource(name: string): string | undefined;
|
|
@@ -7,7 +7,8 @@ let packageTsModule;
|
|
|
7
7
|
function getTs() {
|
|
8
8
|
if (packageTsModule === undefined) {
|
|
9
9
|
try {
|
|
10
|
-
|
|
10
|
+
const loaded = createRequire(import.meta.url)("typescript");
|
|
11
|
+
packageTsModule = hasCompilerApi(loaded) ? loaded : null;
|
|
11
12
|
}
|
|
12
13
|
catch {
|
|
13
14
|
packageTsModule = null;
|
|
@@ -26,7 +27,9 @@ function getTs() {
|
|
|
26
27
|
];
|
|
27
28
|
for (const root of roots) {
|
|
28
29
|
try {
|
|
29
|
-
|
|
30
|
+
const loaded = createRequire(root)("typescript");
|
|
31
|
+
if (hasCompilerApi(loaded))
|
|
32
|
+
return loaded;
|
|
30
33
|
}
|
|
31
34
|
catch {
|
|
32
35
|
// Try the next legitimate module root.
|
|
@@ -34,6 +37,14 @@ function getTs() {
|
|
|
34
37
|
}
|
|
35
38
|
return undefined;
|
|
36
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* TypeScript 7's package entry exposes only its version, not the compiler
|
|
42
|
+
* API (#1927). Treat that package as no TypeScript rather than calling
|
|
43
|
+
* functions it does not have.
|
|
44
|
+
*/
|
|
45
|
+
function hasCompilerApi(ts) {
|
|
46
|
+
return typeof ts?.transpileModule === "function" && typeof ts.createSourceFile === "function";
|
|
47
|
+
}
|
|
37
48
|
/**
|
|
38
49
|
* Reference a plain-JavaScript script file for `executeScript`'s `code:`.
|
|
39
50
|
* The path is relative to the automation file that calls it.
|
|
@@ -1339,6 +1350,15 @@ const scanCache = new WeakMap();
|
|
|
1339
1350
|
* there's no tracked source (not running under `elementum build`, e.g. an
|
|
1340
1351
|
* automation constructed directly in a test) or the name/shape wasn't found
|
|
1341
1352
|
* by the scan (falls back to `extractScriptBody`).
|
|
1353
|
+
*
|
|
1354
|
+
* A body that is not plain JavaScript is also `undefined` (#1927). The
|
|
1355
|
+
* verbatim text exists so a pulled body, which is always JavaScript,
|
|
1356
|
+
* round-trips byte for byte. A body with type annotations was written by
|
|
1357
|
+
* hand, and the runtime that loaded the file has already erased its types
|
|
1358
|
+
* from the function itself, so `extractScriptBody` gives the same result in
|
|
1359
|
+
* every workspace instead of depending on whether a usable TypeScript
|
|
1360
|
+
* compiler happens to resolve. It also runs the closure check, which this
|
|
1361
|
+
* path skips.
|
|
1342
1362
|
*/
|
|
1343
1363
|
export function tryExtractFromCurrentSource(name) {
|
|
1344
1364
|
const ctx = currentSourceText();
|
|
@@ -1349,7 +1369,8 @@ export function tryExtractFromCurrentSource(name) {
|
|
|
1349
1369
|
bodies = scanExecuteScriptBodies(ctx.text);
|
|
1350
1370
|
scanCache.set(ctx, bodies);
|
|
1351
1371
|
}
|
|
1352
|
-
|
|
1372
|
+
const body = bodies.get(name);
|
|
1373
|
+
return body !== undefined && plainJavaScriptSyntaxError(body) === undefined ? body : undefined;
|
|
1353
1374
|
}
|
|
1354
1375
|
/**
|
|
1355
1376
|
* Scan raw (untranspiled) `.ts` source text for every fluent
|
|
@@ -1,5 +1,14 @@
|
|
|
1
|
+
import type { TaskOutputReference } from "../../graph/types.js";
|
|
1
2
|
/** userSearch authoring output → provider refs-map key (as exported from live user-search tasks). */
|
|
2
3
|
export declare const USER_SEARCH_REF_WIRE_NAMES: Readonly<Record<string, string>>;
|
|
4
|
+
/**
|
|
5
|
+
* A user search's refs-map key → the reference an exported value envelope
|
|
6
|
+
* carries: the name and the `fieldType`/`multiple` of the envelope that key
|
|
7
|
+
* holds, as the provider's refs map of a live user-search task lists them
|
|
8
|
+
* (ironman capture, #1701). The build-vs-export comparison reads all of it;
|
|
9
|
+
* the build names the referenceable ones (TASK_OUTPUT_REFERENCE_NAMES below).
|
|
10
|
+
*/
|
|
11
|
+
export declare const USER_SEARCH_OUTPUT_REFERENCES: Readonly<Record<string, TaskOutputReference>>;
|
|
3
12
|
/**
|
|
4
13
|
* Task-own outputs whose WorkflowTaskReference name (what an exported
|
|
5
14
|
* envelope and a calculation mustache carry) differs from the provider
|
|
@@ -7,6 +16,13 @@ export declare const USER_SEARCH_REF_WIRE_NAMES: Readonly<Record<string, string>
|
|
|
7
16
|
* and matching mobius' `shared.json` label tables.
|
|
8
17
|
*/
|
|
9
18
|
export declare const TASK_OUTPUT_REFERENCE_NAMES: Readonly<Record<string, Readonly<Record<string, string>>>>;
|
|
19
|
+
/**
|
|
20
|
+
* Each {@link TASK_OUTPUT_REFERENCE_NAMES} key with the type of the envelope
|
|
21
|
+
* it holds: the output's contract (`TASK_OUTPUT_CONTRACTS`). The
|
|
22
|
+
* build-vs-export comparison reads an exported envelope as that key only when
|
|
23
|
+
* the envelope is of this type.
|
|
24
|
+
*/
|
|
25
|
+
export declare function taskOutputReferences(): Readonly<Record<string, Readonly<Record<string, TaskOutputReference>>>>;
|
|
10
26
|
/**
|
|
11
27
|
* A record-bearing task's whole-record output (ASPECT_RECORD). The bare
|
|
12
28
|
* `.record` accessor otherwise builds the ASPECT_RECORD_ID `Record` key a
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { RESOURCE_TYPE_TO_EXECUTOR, TASK_OUTPUT_CONTRACTS } from "./generated/task-output-contracts.js";
|
|
1
2
|
/** userSearch authoring output → provider refs-map key (as exported from live user-search tasks). */
|
|
2
3
|
export const USER_SEARCH_REF_WIRE_NAMES = {
|
|
3
4
|
"user.id": "User's Id",
|
|
@@ -8,6 +9,24 @@ export const USER_SEARCH_REF_WIRE_NAMES = {
|
|
|
8
9
|
users: "All found users",
|
|
9
10
|
count: "Users Size",
|
|
10
11
|
};
|
|
12
|
+
/**
|
|
13
|
+
* A user search's refs-map key → the reference an exported value envelope
|
|
14
|
+
* carries: the name and the `fieldType`/`multiple` of the envelope that key
|
|
15
|
+
* holds, as the provider's refs map of a live user-search task lists them
|
|
16
|
+
* (ironman capture, #1701). The build-vs-export comparison reads all of it;
|
|
17
|
+
* the build names the referenceable ones (TASK_OUTPUT_REFERENCE_NAMES below).
|
|
18
|
+
*/
|
|
19
|
+
export const USER_SEARCH_OUTPUT_REFERENCES = {
|
|
20
|
+
"Users Size": { name: "count", fieldType: "NUMBER", multiple: false },
|
|
21
|
+
"First found user": { name: "user", fieldType: "USER", multiple: false },
|
|
22
|
+
"All found users": { name: "users", fieldType: "USER", multiple: true },
|
|
23
|
+
"User's Id": { name: "user.id", fieldType: "USER_ID", multiple: false },
|
|
24
|
+
"User's Name": { name: "user.name", fieldType: "TEXT", multiple: false },
|
|
25
|
+
"User's Email": { name: "user.email", fieldType: "TEXT", multiple: false },
|
|
26
|
+
Manager: { name: "user.employee.manager", fieldType: "EMPLOYEE", multiple: false },
|
|
27
|
+
"Manager Name": { name: "user.employee.manager.name", fieldType: "TEXT", multiple: false },
|
|
28
|
+
"Manager Email": { name: "user.employee.manager.email", fieldType: "TEXT", multiple: false },
|
|
29
|
+
};
|
|
11
30
|
/**
|
|
12
31
|
* Task-own outputs whose WorkflowTaskReference name (what an exported
|
|
13
32
|
* envelope and a calculation mustache carry) differs from the provider
|
|
@@ -19,6 +38,12 @@ export const TASK_OUTPUT_REFERENCE_NAMES = {
|
|
|
19
38
|
"Records Size": "count",
|
|
20
39
|
"First found record id": "recordId",
|
|
21
40
|
},
|
|
41
|
+
// The user-search outputs with a contract, so a calculation names `count`,
|
|
42
|
+
// `user.id`, … and not "Users Size" (#1738). The manager outputs have no
|
|
43
|
+
// contract (not referenceable at publish) and keep their refs key.
|
|
44
|
+
elementum_user_search_task: Object.fromEntries(Object.entries(USER_SEARCH_OUTPUT_REFERENCES)
|
|
45
|
+
.filter(([, ref]) => TASK_OUTPUT_CONTRACTS.user_search?.[ref.name] !== undefined)
|
|
46
|
+
.map(([key, ref]) => [key, ref.name])),
|
|
22
47
|
elementum_user_group_search_task: {
|
|
23
48
|
"Groups Size": "count",
|
|
24
49
|
"First found group": "group",
|
|
@@ -26,12 +51,36 @@ export const TASK_OUTPUT_REFERENCE_NAMES = {
|
|
|
26
51
|
Name: "group.name",
|
|
27
52
|
"All found groups": "groups",
|
|
28
53
|
},
|
|
54
|
+
// A JSON apiRequest's refs keys (edk#2058, `ei refs --from-remote`); the
|
|
55
|
+
// send_api_request contract names them response/textResponse/statusCode.
|
|
56
|
+
elementum_api_task: {
|
|
57
|
+
"API Response": "response",
|
|
58
|
+
"API Response (text)": "textResponse",
|
|
59
|
+
"API Response Status Code": "statusCode",
|
|
60
|
+
},
|
|
29
61
|
// Captured live from a deployed bulk_update_fields task's refs map.
|
|
30
62
|
elementum_bulk_update_fields_task: {
|
|
31
63
|
"Records Updated": "recordsUpdated",
|
|
32
64
|
"All Matching Records Updated": "allMatchingRecordsUpdated",
|
|
33
65
|
},
|
|
34
66
|
};
|
|
67
|
+
/**
|
|
68
|
+
* Each {@link TASK_OUTPUT_REFERENCE_NAMES} key with the type of the envelope
|
|
69
|
+
* it holds: the output's contract (`TASK_OUTPUT_CONTRACTS`). The
|
|
70
|
+
* build-vs-export comparison reads an exported envelope as that key only when
|
|
71
|
+
* the envelope is of this type.
|
|
72
|
+
*/
|
|
73
|
+
export function taskOutputReferences() {
|
|
74
|
+
return Object.fromEntries(Object.entries(TASK_OUTPUT_REFERENCE_NAMES).map(([taskType, names]) => {
|
|
75
|
+
const executor = RESOURCE_TYPE_TO_EXECUTOR[taskType];
|
|
76
|
+
return [taskType, Object.fromEntries(Object.entries(names).map(([key, name]) => {
|
|
77
|
+
const contract = executor === undefined ? undefined : TASK_OUTPUT_CONTRACTS[executor]?.[name];
|
|
78
|
+
if (contract === undefined)
|
|
79
|
+
throw new Error(`no output contract for ${taskType} output "${name}" (refs key "${key}")`);
|
|
80
|
+
return [key, { name, fieldType: contract.fieldType, multiple: contract.multiple }];
|
|
81
|
+
}))];
|
|
82
|
+
}));
|
|
83
|
+
}
|
|
35
84
|
/**
|
|
36
85
|
* A record-bearing task's whole-record output (ASPECT_RECORD). The bare
|
|
37
86
|
* `.record` accessor otherwise builds the ASPECT_RECORD_ID `Record` key a
|
|
@@ -495,7 +495,24 @@ export interface ApiRequestMultipartPart {
|
|
|
495
495
|
export interface ApiRequestMultipartBody {
|
|
496
496
|
readonly parts: readonly ApiRequestMultipartPart[];
|
|
497
497
|
}
|
|
498
|
-
|
|
498
|
+
/** elementum_api_task's `response_type` values; the provider default is JSON. */
|
|
499
|
+
export type ApiResponseType = "JSON" | "FILE" | "CUSTOM";
|
|
500
|
+
/**
|
|
501
|
+
* apiRequest outputs for a `responseType`. JSON (also when omitted) has no
|
|
502
|
+
* `.file`, since build rejects it (edk#2058); FILE, CUSTOM or a non-literal
|
|
503
|
+
* type keep every accessor.
|
|
504
|
+
*/
|
|
505
|
+
export type ApiRequestOutputs<R extends ApiResponseType = ApiResponseType> = [R] extends ["JSON"] ? {
|
|
506
|
+
response: unknown;
|
|
507
|
+
statusCode?: unknown;
|
|
508
|
+
textResponse?: unknown;
|
|
509
|
+
} : {
|
|
510
|
+
response: unknown;
|
|
511
|
+
file?: unknown;
|
|
512
|
+
statusCode?: unknown;
|
|
513
|
+
textResponse?: unknown;
|
|
514
|
+
};
|
|
515
|
+
export interface ApiRequestOptions<R extends ApiResponseType = ApiResponseType> {
|
|
499
516
|
readonly url: ValueOrRef<unknown>;
|
|
500
517
|
readonly method: string;
|
|
501
518
|
readonly headers?: readonly ApiRequestHeader[];
|
|
@@ -513,15 +530,10 @@ export interface ApiRequestOptions {
|
|
|
513
530
|
readonly customBody?: ApiRequestCustomBody;
|
|
514
531
|
/** elementum_api_task's `multipart_body` block (file uploads). Mutually exclusive with `jsonBody`/`formBody`/`customBody`. */
|
|
515
532
|
readonly multipartBody?: ApiRequestMultipartBody;
|
|
516
|
-
readonly responseType?:
|
|
533
|
+
readonly responseType?: R;
|
|
517
534
|
readonly continueOnError?: boolean;
|
|
518
535
|
}
|
|
519
|
-
export declare function apiRequest(opts: ApiRequestOptions): ActionDef<
|
|
520
|
-
response: unknown;
|
|
521
|
-
file?: unknown;
|
|
522
|
-
statusCode?: unknown;
|
|
523
|
-
textResponse?: unknown;
|
|
524
|
-
}>;
|
|
536
|
+
export declare function apiRequest<R extends ApiResponseType = "JSON">(opts: ApiRequestOptions<R>): ActionDef<ApiRequestOutputs<R>>;
|
|
525
537
|
export interface AiSearchTableOptions {
|
|
526
538
|
readonly table: SearchTableRef | UnsafePlatformId;
|
|
527
539
|
readonly query: ValueOrRef<unknown>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { DeployableEntity } from "../../engine/entity.js";
|
|
2
2
|
import { type ValidationFailure } from "../../engine/validation.js";
|
|
3
|
-
import { type
|
|
3
|
+
import { type TfBlock, type TfValue } from "../../engine/tf/index.js";
|
|
4
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";
|
|
@@ -88,8 +88,6 @@ export interface AutomationToTfResult {
|
|
|
88
88
|
readonly blocks: readonly TfBlock[];
|
|
89
89
|
readonly address: string;
|
|
90
90
|
}
|
|
91
|
-
/** Run-automation targets reference publish for ACTIVE automations, automation for draft/inactive. */
|
|
92
|
-
export declare function automationRunTargetResourceAttr(appTfLabel: string, automationRefName: string, activeAutomationRefNames: ReadonlySet<string> | undefined, scope?: ChildResourceScope, handle?: string): TfExpr;
|
|
93
91
|
/**
|
|
94
92
|
* edk#1499: script-input field mappings read fields off a whole record. A
|
|
95
93
|
* value that exposes only a record ID (an onDemand record parameter, or
|
|
@@ -18,7 +18,7 @@ import { outputFieldTypesFromScriptSchema, scriptOutputReferenceIsDeclared } fro
|
|
|
18
18
|
import { RESOURCE_TYPE_TO_EXECUTOR, TASK_OUTPUT_CONTRACTS } from "./generated/task-output-contracts.js";
|
|
19
19
|
import { CONNECTOR_ORG_BAG } from "../org/connector.js";
|
|
20
20
|
import { GROUP_ORG_BAG } from "../org/group.js";
|
|
21
|
-
import { FILE_READER_SUB_TYPE_BY_RESOURCE, FILE_READER_SUB_TYPE_BY_TYPE_KEY } from "../file-reader/types.js";
|
|
21
|
+
import { FILE_READER_SUB_TYPE_BY_RESOURCE, FILE_READER_SUB_TYPE_BY_TYPE_KEY, fileReaderResourceLabel } from "../file-reader/types.js";
|
|
22
22
|
import { UNRESOLVED_FIELD_MARKER } from "../shared/ref.js";
|
|
23
23
|
import { ELEMENT_SYSTEM_FIELD_KEYS } from "../element/system-fields.js";
|
|
24
24
|
import { TABLE_RESOURCE_TYPE } from "../table/module.js";
|
|
@@ -28,6 +28,7 @@ import { onDemandTriggerRefKey } from "./value-ref-tf.js";
|
|
|
28
28
|
import { normalizeOnDemandParamKey } from "../../../pull/util.js";
|
|
29
29
|
import { PROVIDER_FIXED_SYSTEM_FIELD_KEYS, recordFieldWireRefName } from "./system-ref-name.js";
|
|
30
30
|
import { taskTfLabel } from "./task-label.js";
|
|
31
|
+
import { automationRunTargetResourceAttr, automationTargetOwner, bareStaticRunTarget, onDemandRecordParamNames, recordInputMappingProblem } from "./run-target.js";
|
|
31
32
|
import { FIELD_TYPE_MAP, isOnDemandRecordType } from "../shared/types/field-types.js";
|
|
32
33
|
/** The context for reading records of `appRefName` (a `kind`), retargeted from the owner. */
|
|
33
34
|
/**
|
|
@@ -129,6 +130,7 @@ const TRIGGER_RESOURCES = {
|
|
|
129
130
|
datamine: "elementum_datamine_trigger",
|
|
130
131
|
survey: "elementum_survey_trigger",
|
|
131
132
|
schedule: "elementum_schedule_trigger",
|
|
133
|
+
temporal: "elementum_temporal_trigger",
|
|
132
134
|
};
|
|
133
135
|
/**
|
|
134
136
|
* The live platform id of a created variable: `variables[<index>].id` on its
|
|
@@ -503,19 +505,6 @@ function registerForeignFieldLookup(value, ctx, dataBlocks) {
|
|
|
503
505
|
registerForeignOptionsByLabelLocal(fieldLabel, ctx);
|
|
504
506
|
return fieldLabel;
|
|
505
507
|
}
|
|
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
|
-
}
|
|
519
508
|
/**
|
|
520
509
|
* Resolve an automation token as a managed definition (same stream root or a
|
|
521
510
|
* sibling root in this build) or as a ref-only `data.elementum_automation`
|
|
@@ -524,9 +513,7 @@ function bareStaticRunTarget(config) {
|
|
|
524
513
|
* degrade to `target_automation_ref` / `dynamic_input_mappings`.
|
|
525
514
|
*/
|
|
526
515
|
function automationTargetToTf(value, ctx, dataBlocks) {
|
|
527
|
-
const ownerKind = value
|
|
528
|
-
const isOwn = value.parent === undefined ||
|
|
529
|
-
(value.parent === ctx.appRefName && ownerKind === ctx.parentScope);
|
|
516
|
+
const { ownerKind, isOwn } = automationTargetOwner(value, ctx);
|
|
530
517
|
const sibling = !isOwn && value.parent !== undefined
|
|
531
518
|
? ctx.workspaceAspects?.get(workspaceAspectKey(ownerKind, value.parent))
|
|
532
519
|
: undefined;
|
|
@@ -542,6 +529,7 @@ function automationTargetToTf(value, ctx, dataBlocks) {
|
|
|
542
529
|
: undefined;
|
|
543
530
|
const managedLabel = automationResourceLabel(managedOwnerLabel, value.refName, ownerKind === "element" ? "element" : "app", managedHandle);
|
|
544
531
|
const targetActiveRefs = targetOwner?.activeAutomationRefNames;
|
|
532
|
+
const recordInputNames = targetOwner?.onDemandRecordInputsByAutomationRefName?.get(value.refName);
|
|
545
533
|
const isActive = targetActiveRefs !== undefined
|
|
546
534
|
? targetActiveRefs.has(value.refName)
|
|
547
535
|
: isOwn && ctx.activeAutomationRefNames?.has(value.refName) === true;
|
|
@@ -574,12 +562,14 @@ function automationTargetToTf(value, ctx, dataBlocks) {
|
|
|
574
562
|
id: expr.dataAttr(AUTOMATION_RESOURCE_TYPE, currentBindingLabel, ["id"]),
|
|
575
563
|
parameterId: (name) => expr.dataAttr(AUTOMATION_RESOURCE_TYPE, currentBindingLabel, ["parameter_ids", { index: name }]),
|
|
576
564
|
managedLabel,
|
|
565
|
+
recordInputNames,
|
|
577
566
|
};
|
|
578
567
|
}
|
|
579
568
|
return {
|
|
580
569
|
id: expr.resourceAttr(AUTOMATION_RESOURCE_TYPE, managedLabel, ["id"]),
|
|
581
570
|
parameterId: (name) => expr.resourceAttr("elementum_on_demand_trigger", managedLabel, ["parameter_ids", { index: name }]),
|
|
582
571
|
managedLabel,
|
|
572
|
+
recordInputNames,
|
|
583
573
|
};
|
|
584
574
|
}
|
|
585
575
|
if (value.parent === undefined || value.parent === "") {
|
|
@@ -955,7 +945,7 @@ function tokenToTf(value, ctx, dataBlocks) {
|
|
|
955
945
|
if (subType === undefined || subType.implemented !== true) {
|
|
956
946
|
throw new EntityTfError(`file reader token "${value.refName}" has no recognized readerType ("${value.readerType}") — was it built with a file-reader factory?`);
|
|
957
947
|
}
|
|
958
|
-
return expr.resourceAttr(subType.resourceType,
|
|
948
|
+
return expr.resourceAttr(subType.resourceType, fileReaderResourceLabel(fileReaderOwnerTfLabel(value, ctx), value.refName), ["id"]);
|
|
959
949
|
}
|
|
960
950
|
case "group": {
|
|
961
951
|
// Static notification/add-watcher recipients (edk#1389). An org.ts
|
|
@@ -988,6 +978,28 @@ function tokenToTf(value, ctx, dataBlocks) {
|
|
|
988
978
|
throw new EntityTfError(`catalog ref kind "${value.__kind}" has no automation HCL representation`);
|
|
989
979
|
}
|
|
990
980
|
}
|
|
981
|
+
/**
|
|
982
|
+
* The Terraform label of the app that owns a file-reader token. Another
|
|
983
|
+
* app's reader is scoped under that app, built here or authored but left out
|
|
984
|
+
* of this build. An element-owned reader is reachable only from its own
|
|
985
|
+
* element: the provider and export do not carry one across owners yet.
|
|
986
|
+
*/
|
|
987
|
+
function fileReaderOwnerTfLabel(value, ctx) {
|
|
988
|
+
const owner = value.parent;
|
|
989
|
+
if (owner === undefined || owner === ctx.appRefName)
|
|
990
|
+
return ctx.appTfLabel;
|
|
991
|
+
const app = ctx.workspaceAspects?.get(workspaceAspectKey("app", owner));
|
|
992
|
+
if (app !== undefined)
|
|
993
|
+
return app.tfLabel;
|
|
994
|
+
const outOfScope = ctx.outOfScopeApps?.get(owner)?.namespace;
|
|
995
|
+
if (outOfScope !== undefined)
|
|
996
|
+
return outOfScope;
|
|
997
|
+
if (ctx.workspaceAspects?.get(workspaceAspectKey("element", owner)) !== undefined) {
|
|
998
|
+
throw new EntityTfError(`automation ${ctx.automationTfLabel}: file reader "${owner}.${value.refName}" is owned by element "${owner}" — ` +
|
|
999
|
+
"a file reader is referenced across owners only from an app");
|
|
1000
|
+
}
|
|
1001
|
+
throw new EntityTfError(`automation ${ctx.automationTfLabel}: file reader "${owner}.${value.refName}" is owned by "${owner}", which is not an app in this workspace`);
|
|
1002
|
+
}
|
|
991
1003
|
function procedureToTf(value, ctx, dataBlocks) {
|
|
992
1004
|
if (value.__kind !== "procedure")
|
|
993
1005
|
throw new EntityTfError("procedure requires a procedure catalog reference");
|
|
@@ -1213,12 +1225,18 @@ function calculationTaskRefName(targetType, name, taskRefKey, refs) {
|
|
|
1213
1225
|
suffix.length > 0 ? `.${suffix}` : "",
|
|
1214
1226
|
];
|
|
1215
1227
|
}
|
|
1216
|
-
const refName =
|
|
1228
|
+
const refName = taskOutputReferenceName(targetType, name, refs.tasks.get(taskRefKey)) ?? name;
|
|
1217
1229
|
if (refName.includes('"')) {
|
|
1218
1230
|
throw new EntityTfError(`calculation task output name "${refName}" contains a double quote`);
|
|
1219
1231
|
}
|
|
1220
1232
|
return [refName];
|
|
1221
1233
|
}
|
|
1234
|
+
/** A refs key's WorkflowTaskReference name. An apiRequest maps only when it's JSON; FILE and CUSTOM are unconfirmed live (edk#2058). */
|
|
1235
|
+
function taskOutputReferenceName(type, wireName, task) {
|
|
1236
|
+
if (type === TASK_RESOURCES.api && task?.jsonApiResponse !== true)
|
|
1237
|
+
return undefined;
|
|
1238
|
+
return TASK_OUTPUT_REFERENCE_NAMES[type]?.[wireName];
|
|
1239
|
+
}
|
|
1222
1240
|
/**
|
|
1223
1241
|
* The calc-engine field id of a found record's field. A field of an aspect in
|
|
1224
1242
|
* this build is its resource id. A sibling the workspace authors but this
|
|
@@ -1792,14 +1810,6 @@ function recordParamFieldWireName(paramName, suffix, refs) {
|
|
|
1792
1810
|
: fieldNamesForAppRefName(refs.fieldNamesByAppRefName, targetRefName);
|
|
1793
1811
|
return wireRefName(`record.${suffix}`, recordOwnerContext(refs.owner, targetRefName, target.__kind === "element" || target.__kind === "app" ? target.__kind : undefined, targetFieldNames));
|
|
1794
1812
|
}
|
|
1795
|
-
/** Run-automation targets reference publish for ACTIVE automations, automation for draft/inactive. */
|
|
1796
|
-
export function automationRunTargetResourceAttr(appTfLabel, automationRefName, activeAutomationRefNames, scope = "app", handle) {
|
|
1797
|
-
const label = automationResourceLabel(appTfLabel, automationRefName, scope, handle);
|
|
1798
|
-
if (activeAutomationRefNames?.has(automationRefName) === true) {
|
|
1799
|
-
return expr.resourceAttr(WORKFLOW_PUBLISH_RESOURCE_TYPE, label, ["id"]);
|
|
1800
|
-
}
|
|
1801
|
-
return expr.resourceAttr(AUTOMATION_RESOURCE_TYPE, label, ["id"]);
|
|
1802
|
-
}
|
|
1803
1813
|
const UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
1804
1814
|
const ISO_DATE_PATTERN = /^\d{4}-\d{2}-\d{2}$/;
|
|
1805
1815
|
/** The provider's `ValidateFieldValue` datetime shape: seconds and a timezone are required. */
|
|
@@ -2098,6 +2108,21 @@ function aiAgentPlatformRefName(refsKey) {
|
|
|
2098
2108
|
}
|
|
2099
2109
|
return `ai_agent_task_structured_output.${refsKey.toLowerCase()}`;
|
|
2100
2110
|
}
|
|
2111
|
+
/**
|
|
2112
|
+
* Switch left-value name for one AI agent structured field, or undefined
|
|
2113
|
+
* when `wireName` is the whole text response (`refs["Action Response"]`).
|
|
2114
|
+
* Filter refs arrive already rewritten (`candidateCount`); a leftover
|
|
2115
|
+
* `result.<field>` is accepted too.
|
|
2116
|
+
*/
|
|
2117
|
+
function aiAgentStructuredLeftValueName(wireName) {
|
|
2118
|
+
if (wireName === "Action Response" || wireName === "result" || wireName === "ai_agent_task_response") {
|
|
2119
|
+
return undefined;
|
|
2120
|
+
}
|
|
2121
|
+
const field = wireName.startsWith("result.") ? wireName.slice("result.".length) : wireName;
|
|
2122
|
+
if (field === "" || field === "Action Response")
|
|
2123
|
+
return undefined;
|
|
2124
|
+
return aiAgentPlatformRefName(field);
|
|
2125
|
+
}
|
|
2101
2126
|
function publishOutputType(value, target, wireName) {
|
|
2102
2127
|
if (typeof value.fieldType === "string") {
|
|
2103
2128
|
return { fieldType: value.fieldType, multiple: value.multiple === true };
|
|
@@ -2148,16 +2173,6 @@ function collectUnresolvedForEachItems(value, found) {
|
|
|
2148
2173
|
for (const nested of Object.values(value))
|
|
2149
2174
|
collectUnresolvedForEachItems(nested, found);
|
|
2150
2175
|
}
|
|
2151
|
-
/** The onDemand trigger's record parameters: they expose only a record ID. */
|
|
2152
|
-
function onDemandRecordParamNames(trigger) {
|
|
2153
|
-
const inputs = trigger?.onDemand?.inputs;
|
|
2154
|
-
if (!Array.isArray(inputs))
|
|
2155
|
-
return new Set();
|
|
2156
|
-
return new Set(inputs.flatMap((input) => {
|
|
2157
|
-
const param = input;
|
|
2158
|
-
return typeof param?.name === "string" && isOnDemandRecordType(typeof param.type === "string" ? param.type : undefined) ? [param.name] : [];
|
|
2159
|
-
}));
|
|
2160
|
-
}
|
|
2161
2176
|
/** refKey → task kind (`findRelatedRecords`, …) for every task, nested ones included. */
|
|
2162
2177
|
function collectPayloadTaskKinds(value, kinds) {
|
|
2163
2178
|
if (Array.isArray(value)) {
|
|
@@ -2770,6 +2785,23 @@ function filterReferenceToTf(value, refs, role = "value", realType, operator) {
|
|
|
2770
2785
|
},
|
|
2771
2786
|
});
|
|
2772
2787
|
}
|
|
2788
|
+
// An AI agent's structured field is `refs["<field>"]` on a task input
|
|
2789
|
+
// (#759). A switch left-value is the other spelling: a NUMBER (or
|
|
2790
|
+
// other) envelope whose taskReference.name is
|
|
2791
|
+
// `ai_agent_task_structured_output.<field>` (#2096). Emitting the
|
|
2792
|
+
// refs index here plans that envelope away after every pull.
|
|
2793
|
+
const aiAgentStructuredName = isAiAgentTask ? aiAgentStructuredLeftValueName(wireName) : undefined;
|
|
2794
|
+
if (aiAgentStructuredName !== undefined) {
|
|
2795
|
+
const declared = task.outputFieldTypes?.get(wireName);
|
|
2796
|
+
return expr.jsonencode({
|
|
2797
|
+
fieldType: (realType ?? declared?.fieldType ?? "TEXT").toUpperCase(),
|
|
2798
|
+
multiple: declared?.multiple === true,
|
|
2799
|
+
taskReference: {
|
|
2800
|
+
name: aiAgentStructuredName,
|
|
2801
|
+
taskId: expr.resourceAttr(task.type, task.label, ["id"]),
|
|
2802
|
+
},
|
|
2803
|
+
});
|
|
2804
|
+
}
|
|
2773
2805
|
// An explicit filter.text() on a runAutomation output is a TEXT
|
|
2774
2806
|
// envelope. A missing realType stays on .refs; the provider's refs
|
|
2775
2807
|
// map is already TEXT for outputs ei stores that way.
|
|
@@ -2790,7 +2822,7 @@ function filterReferenceToTf(value, refs, role = "value", realType, operator) {
|
|
|
2790
2822
|
// `multiple` follows the declaration so an array output is not
|
|
2791
2823
|
// flattened. A NUMBER comparison of a DECIMAL script output is the
|
|
2792
2824
|
// next branch (#1618).
|
|
2793
|
-
const envelopeName =
|
|
2825
|
+
const envelopeName = taskOutputReferenceName(task.type, wireName, task) ?? wireName;
|
|
2794
2826
|
const executor = RESOURCE_TYPE_TO_EXECUTOR[task.type];
|
|
2795
2827
|
const declared = task.outputFieldTypes?.get(wireName) ??
|
|
2796
2828
|
(executor === undefined ? undefined : TASK_OUTPUT_CONTRACTS[executor]?.[envelopeName]);
|
|
@@ -2884,7 +2916,9 @@ function filterReferenceToTf(value, refs, role = "value", realType, operator) {
|
|
|
2884
2916
|
: task.type === TASK_RESOURCES.recordSearch &&
|
|
2885
2917
|
(wireName === "First found record id" || value.name === "record.recordId" || value.name === "recordId")
|
|
2886
2918
|
? "recordId"
|
|
2887
|
-
:
|
|
2919
|
+
: task.type === TASK_RESOURCES.api
|
|
2920
|
+
? taskOutputReferenceName(task.type, wireName, task) ?? wireName
|
|
2921
|
+
: canonicalSingleOutputName(task.type, wireName) ?? wireName;
|
|
2888
2922
|
return expr.template([
|
|
2889
2923
|
"task.",
|
|
2890
2924
|
expr.resourceAttr(task.type, task.label, ["id"]),
|
|
@@ -3127,6 +3161,10 @@ function configAttrs(kind, config, refs) {
|
|
|
3127
3161
|
// default so build matches export's omit-when-1 convention.
|
|
3128
3162
|
if (kind === "elementum_schedule_trigger" && key === "interval" && raw === 1)
|
|
3129
3163
|
continue;
|
|
3164
|
+
if (kind === "elementum_temporal_trigger" && key === "aspectFieldId") {
|
|
3165
|
+
attrs.aspect_field_id = valueToTf(raw, refs);
|
|
3166
|
+
continue;
|
|
3167
|
+
}
|
|
3130
3168
|
// A config value of exactly `undefined` almost always means the
|
|
3131
3169
|
// authoring builder was called with a required option omitted (e.g. a
|
|
3132
3170
|
// TS-only-enforced field that no runtime actually type-checks at
|
|
@@ -3212,6 +3250,20 @@ function configAttrs(kind, config, refs) {
|
|
|
3212
3250
|
continue;
|
|
3213
3251
|
}
|
|
3214
3252
|
const resolvedTarget = automationTargetToTf(target, refs.owner, refs.dataBlocks);
|
|
3253
|
+
const recordInputProblem = recordInputMappingProblem(target, raw, resolvedTarget.recordInputNames);
|
|
3254
|
+
if (recordInputProblem !== undefined) {
|
|
3255
|
+
// The recorded unit is the whole automation (#2250): a key in
|
|
3256
|
+
// applied-automation-revisions.json means the platform already runs
|
|
3257
|
+
// this file, so a later edit of the mapping is reported too. Pull
|
|
3258
|
+
// reports and keeps emitting, the same as a record-id field mapping
|
|
3259
|
+
// (#1499), so the first pull can write that key. Build, plan, and
|
|
3260
|
+
// apply still refuse an automation the record does not have. The
|
|
3261
|
+
// report is an advisory (coverage-gaps.ts): the mapping is emitted
|
|
3262
|
+
// as authored, and the failure is at workflow runtime.
|
|
3263
|
+
if (!refs.owner.pulledLive && currentValidationMode() !== "pull")
|
|
3264
|
+
throw new EntityTfError(recordInputProblem);
|
|
3265
|
+
refs.owner.diagnostics.push(`automation ${refs.owner.automationTfLabel}: ${recordInputProblem}`);
|
|
3266
|
+
}
|
|
3215
3267
|
attrs.input_mappings = raw.map((mapping) => {
|
|
3216
3268
|
if (!isObject(mapping) || typeof mapping.name !== "string" || mapping.value === undefined) {
|
|
3217
3269
|
throw new EntityTfError("runAutomation input mapping requires name and value");
|
|
@@ -3247,6 +3299,11 @@ function configAttrs(kind, config, refs) {
|
|
|
3247
3299
|
}
|
|
3248
3300
|
const target = token(raw.value);
|
|
3249
3301
|
if (target?.__kind === "automation") {
|
|
3302
|
+
// The label below is the caller's own; another owner would bind a same-named automation (edk#2118).
|
|
3303
|
+
if (!automationTargetOwner(target, refs.owner).isOwn) {
|
|
3304
|
+
throw new EntityTfError(`runAutomation STATIC targetAutomationRef "${target.parent ?? ""}.${target.refName}" is owned by another ` +
|
|
3305
|
+
"app or element; pass the automation as `automation` (targetAutomationId) so it resolves by its owner");
|
|
3306
|
+
}
|
|
3250
3307
|
attrs["target_automation_ref"] = automationRunTargetResourceAttr(refs.owner.appTfLabel, target.refName, refs.owner.activeAutomationRefNames, refs.owner.parentScope, refs.owner.ownerHandle);
|
|
3251
3308
|
continue;
|
|
3252
3309
|
}
|
|
@@ -3724,6 +3781,9 @@ export function automationToTf(entity, ctx) {
|
|
|
3724
3781
|
ownerHandle: ctx.ownerHandle,
|
|
3725
3782
|
appTfLabel: ctx.appTfLabel,
|
|
3726
3783
|
automationTfLabel,
|
|
3784
|
+
pulledLive: ctx.workspaceAspects
|
|
3785
|
+
?.get(workspaceAspectKey(ctx.parentScope ?? "app", ctx.appRefName ?? entity.parent))
|
|
3786
|
+
?.pulledAutomationRefNames?.has(entity.refName) === true,
|
|
3727
3787
|
fieldAddresses: ctx.fieldAddresses ?? new Map(),
|
|
3728
3788
|
fieldNames: ctx.fieldNames ?? new Map(),
|
|
3729
3789
|
fieldMetadata: ctx.fieldMetadata ?? new Map(),
|
|
@@ -3861,6 +3921,7 @@ export function automationToTf(entity, ctx) {
|
|
|
3861
3921
|
...(wireType === "unimplementedTask" ? { isData: true } : {}),
|
|
3862
3922
|
...(outputFieldTypes !== undefined && outputFieldTypes.size > 0 ? { outputFieldTypes } : {}),
|
|
3863
3923
|
...(recordTarget !== undefined ? { recordTarget } : {}),
|
|
3924
|
+
...(wireType === "api" && (taskBody.responseType ?? "JSON") === "JSON" ? { jsonApiResponse: true } : {}),
|
|
3864
3925
|
});
|
|
3865
3926
|
if (wireType === "variable" && Array.isArray(taskBody.create)) {
|
|
3866
3927
|
taskBody.create.forEach((candidate, index) => {
|
|
@@ -4101,7 +4162,8 @@ export function automationToTf(entity, ctx) {
|
|
|
4101
4162
|
const block = { kind: "resource", type: resourceType, label: tfLabel, attrs };
|
|
4102
4163
|
if (wireType === "runAutomation") {
|
|
4103
4164
|
const target = token(inner.targetAutomationId) ?? (isObject(inner.targetAutomationRef) ? token(inner.targetAutomationRef.value) : undefined);
|
|
4104
|
-
|
|
4165
|
+
// Own targets only: another owner's publish edge rides its `_for_<caller>` lookup (edk#2118).
|
|
4166
|
+
if (target?.__kind === "automation" && automationTargetOwner(target, owner).isOwn) {
|
|
4105
4167
|
const targetLabel = scopedLabel(owner.appTfLabel, tsLabelToTfLabel(target.refName));
|
|
4106
4168
|
// Only a running (ACTIVE) target is a run dependency. A paused
|
|
4107
4169
|
// target keeps its publish resource, but ei export does not wait
|