@elementumai/edk 0.11.0 → 0.13.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 +40 -6
- package/dist-sdk/src/catalog/factories.d.ts +7 -1
- package/dist-sdk/src/catalog/factories.js +2 -0
- package/dist-sdk/src/catalog/index.d.ts +2 -2
- package/dist-sdk/src/catalog/index.js +1 -1
- package/dist-sdk/src/catalog/org.js +79 -34
- package/dist-sdk/src/catalog/token.js +5 -0
- package/dist-sdk/src/catalog/types.d.ts +7 -1
- package/dist-sdk/src/catalog/types.js +3 -0
- package/dist-sdk/src/core/system-fields.d.ts +1 -1
- package/dist-sdk/src/core/system-fields.js +1 -1
- package/dist-sdk/src/core/triggers/on-demand.d.ts +2 -0
- package/dist-sdk/src/core/triggers/on-demand.js +3 -0
- package/dist-sdk/src/core/types/app.d.ts +6 -0
- package/dist-sdk/src/engine/build/context.d.ts +3 -0
- package/dist-sdk/src/engine/coverage-gaps.d.ts +5 -0
- package/dist-sdk/src/engine/coverage-gaps.js +9 -0
- package/dist-sdk/src/engine/ei/run.d.ts +20 -1
- package/dist-sdk/src/engine/ei/run.js +102 -14
- package/dist-sdk/src/engine/pull/authored-address.js +42 -6
- package/dist-sdk/src/engine/pull/authored-root.d.ts +88 -0
- package/dist-sdk/src/engine/pull/authored-root.js +306 -0
- package/dist-sdk/src/engine/pull/context.d.ts +10 -0
- package/dist-sdk/src/engine/pull/field-refs-registry.d.ts +114 -0
- package/dist-sdk/src/engine/pull/field-refs-registry.js +501 -0
- package/dist-sdk/src/engine/pull/org.d.ts +1 -0
- package/dist-sdk/src/engine/pull/org.js +2 -0
- package/dist-sdk/src/engine/pull/partition.d.ts +8 -0
- package/dist-sdk/src/engine/pull/partition.js +43 -0
- package/dist-sdk/src/engine/pull/pulled-roots.d.ts +89 -0
- package/dist-sdk/src/engine/pull/pulled-roots.js +203 -0
- package/dist-sdk/src/engine/pull/ref-only.d.ts +22 -0
- package/dist-sdk/src/engine/pull/ref-only.js +59 -1
- package/dist-sdk/src/engine/pull/source-resources.d.ts +39 -0
- package/dist-sdk/src/engine/pull/source-resources.js +110 -0
- package/dist-sdk/src/engine/pull/stream-root.d.ts +148 -0
- package/dist-sdk/src/engine/pull/stream-root.js +563 -0
- package/dist-sdk/src/engine/workspace/reserved-catalog-keys.d.ts +47 -0
- package/dist-sdk/src/engine/workspace/reserved-catalog-keys.js +115 -0
- package/dist-sdk/src/entities/access-policy/build.d.ts +2 -1
- package/dist-sdk/src/entities/access-policy/from-tf.d.ts +9 -1
- package/dist-sdk/src/entities/access-policy/from-tf.js +25 -4
- package/dist-sdk/src/entities/access-policy/module.js +5 -0
- package/dist-sdk/src/entities/access-policy/to-tf.d.ts +19 -0
- package/dist-sdk/src/entities/access-policy/to-tf.js +65 -8
- package/dist-sdk/src/entities/agent/build.d.ts +52 -1
- package/dist-sdk/src/entities/agent/build.js +34 -0
- package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +68 -0
- package/dist-sdk/src/entities/agent/from-tf.d.ts +34 -1
- package/dist-sdk/src/entities/agent/from-tf.js +262 -2
- package/dist-sdk/src/entities/agent/index.d.ts +1 -1
- package/dist-sdk/src/entities/agent/to-tf.d.ts +8 -10
- package/dist-sdk/src/entities/agent/to-tf.js +158 -14
- package/dist-sdk/src/entities/agent-tool/from-tf.js +6 -0
- package/dist-sdk/src/entities/agent-tool/to-tf.d.ts +2 -2
- package/dist-sdk/src/entities/agent-tool/to-tf.js +2 -2
- package/dist-sdk/src/entities/app/build.d.ts +34 -14
- package/dist-sdk/src/entities/app/build.js +93 -16
- package/dist-sdk/src/entities/app/from-tf.js +25 -11
- package/dist-sdk/src/entities/app/index.d.ts +1 -0
- package/dist-sdk/src/entities/app/index.js +1 -0
- package/dist-sdk/src/entities/app/module.js +1 -0
- package/dist-sdk/src/entities/app/stage-keys.d.ts +20 -5
- package/dist-sdk/src/entities/app/stage-keys.js +43 -9
- package/dist-sdk/src/entities/app/to-tf.js +2 -0
- package/dist-sdk/src/entities/approval-chain/build.d.ts +46 -11
- package/dist-sdk/src/entities/approval-chain/build.js +120 -8
- package/dist-sdk/src/entities/approval-chain/from-tf.d.ts +24 -2
- package/dist-sdk/src/entities/approval-chain/from-tf.js +148 -6
- package/dist-sdk/src/entities/approval-chain/index.d.ts +4 -1
- package/dist-sdk/src/entities/approval-chain/index.js +4 -1
- package/dist-sdk/src/entities/approval-chain/module.js +23 -5
- package/dist-sdk/src/entities/approval-chain/printer.d.ts +1 -1
- package/dist-sdk/src/entities/approval-chain/printer.js +91 -5
- package/dist-sdk/src/entities/approval-chain/steps-tf.d.ts +77 -0
- package/dist-sdk/src/entities/approval-chain/steps-tf.js +255 -0
- package/dist-sdk/src/entities/approval-chain/steps.d.ts +71 -0
- package/dist-sdk/src/entities/approval-chain/steps.js +83 -0
- package/dist-sdk/src/entities/approval-chain/to-tf.d.ts +16 -6
- package/dist-sdk/src/entities/approval-chain/to-tf.js +37 -4
- package/dist-sdk/src/entities/automation/build.d.ts +50 -24
- package/dist-sdk/src/entities/automation/build.js +86 -33
- package/dist-sdk/src/entities/automation/deserializer/print-automation.js +52 -8
- package/dist-sdk/src/entities/automation/from-tf.d.ts +38 -6
- package/dist-sdk/src/entities/automation/from-tf.js +855 -157
- package/dist-sdk/src/entities/automation/index.d.ts +2 -1
- package/dist-sdk/src/entities/automation/index.js +1 -0
- package/dist-sdk/src/entities/automation/module.d.ts +4 -3
- package/dist-sdk/src/entities/automation/module.js +33 -12
- package/dist-sdk/src/entities/automation/refs-read.d.ts +19 -0
- package/dist-sdk/src/entities/automation/refs-read.js +48 -0
- package/dist-sdk/src/entities/automation/run-target.d.ts +2 -0
- package/dist-sdk/src/entities/automation/run-target.js +5 -0
- package/dist-sdk/src/entities/automation/script-code.d.ts +2 -1
- package/dist-sdk/src/entities/automation/script-code.js +82 -1
- package/dist-sdk/src/entities/automation/script-lint.d.ts +13 -0
- package/dist-sdk/src/entities/automation/script-lint.js +418 -0
- package/dist-sdk/src/entities/automation/slack-message-refs.d.ts +9 -0
- package/dist-sdk/src/entities/automation/slack-message-refs.js +75 -0
- package/dist-sdk/src/entities/automation/task-output-labels.d.ts +12 -1
- package/dist-sdk/src/entities/automation/task-output-labels.js +32 -1
- package/dist-sdk/src/entities/automation/tasks.d.ts +76 -18
- package/dist-sdk/src/entities/automation/tasks.js +52 -15
- package/dist-sdk/src/entities/automation/to-tf.d.ts +3 -0
- package/dist-sdk/src/entities/automation/to-tf.js +585 -97
- package/dist-sdk/src/entities/automation/triggers.d.ts +48 -23
- package/dist-sdk/src/entities/automation/triggers.js +27 -12
- package/dist-sdk/src/entities/automation/unsafe-script-output.d.ts +50 -0
- package/dist-sdk/src/entities/automation/unsafe-script-output.js +92 -0
- package/dist-sdk/src/entities/chart/build.d.ts +18 -2
- package/dist-sdk/src/entities/chart/from-tf.d.ts +2 -2
- package/dist-sdk/src/entities/chart/from-tf.js +28 -1
- package/dist-sdk/src/entities/chart/index.d.ts +1 -1
- package/dist-sdk/src/entities/chart/printer.js +5 -2
- package/dist-sdk/src/entities/chart/to-tf.js +38 -3
- package/dist-sdk/src/entities/dynamic-layout/build.d.ts +3 -0
- package/dist-sdk/src/entities/dynamic-layout/condition-keys.d.ts +48 -0
- package/dist-sdk/src/entities/dynamic-layout/condition-keys.js +261 -0
- package/dist-sdk/src/entities/dynamic-layout/from-tf.js +45 -6
- package/dist-sdk/src/entities/dynamic-layout/module.js +2 -1
- package/dist-sdk/src/entities/dynamic-layout/to-tf.js +46 -12
- package/dist-sdk/src/entities/element/audit-field-guard.d.ts +9 -0
- package/dist-sdk/src/entities/element/audit-field-guard.js +88 -0
- package/dist-sdk/src/entities/element/build.js +2 -1
- package/dist-sdk/src/entities/element/from-tf.js +15 -2
- package/dist-sdk/src/entities/element/module.js +3 -0
- package/dist-sdk/src/entities/element/system-fields.d.ts +13 -0
- package/dist-sdk/src/entities/element/system-fields.js +23 -0
- package/dist-sdk/src/entities/element/to-tf.js +2 -0
- package/dist-sdk/src/entities/field/build.d.ts +9 -0
- package/dist-sdk/src/entities/field/from-tf.d.ts +29 -1
- package/dist-sdk/src/entities/field/from-tf.js +99 -6
- package/dist-sdk/src/entities/field/module.js +12 -2
- package/dist-sdk/src/entities/field/to-tf.d.ts +13 -3
- package/dist-sdk/src/entities/field/to-tf.js +90 -46
- package/dist-sdk/src/entities/org/category.js +1 -0
- package/dist-sdk/src/entities/org/index.d.ts +1 -0
- package/dist-sdk/src/entities/org/index.js +1 -0
- package/dist-sdk/src/entities/org/role.js +5 -0
- package/dist-sdk/src/entities/org/voice-auth.d.ts +5 -0
- package/dist-sdk/src/entities/org/voice-auth.js +33 -0
- package/dist-sdk/src/entities/organization/build.d.ts +3 -0
- package/dist-sdk/src/entities/organization/build.js +2 -0
- package/dist-sdk/src/entities/organization/index.d.ts +1 -0
- package/dist-sdk/src/entities/organization/index.js +1 -0
- package/dist-sdk/src/entities/organization/to-tf.d.ts +2 -0
- package/dist-sdk/src/entities/organization/to-tf.js +59 -1
- package/dist-sdk/src/entities/organization/voice-auth.d.ts +60 -0
- package/dist-sdk/src/entities/organization/voice-auth.js +60 -0
- package/dist-sdk/src/entities/phone-service/build.d.ts +9 -1
- package/dist-sdk/src/entities/phone-service/build.js +1 -0
- package/dist-sdk/src/entities/phone-service/deserializer/print-phone-service.js +3 -0
- package/dist-sdk/src/entities/phone-service/from-tf.d.ts +1 -0
- package/dist-sdk/src/entities/phone-service/from-tf.js +8 -1
- package/dist-sdk/src/entities/phone-service/to-tf.js +16 -0
- package/dist-sdk/src/entities/record-create-form/from-tf.js +2 -2
- package/dist-sdk/src/entities/relationship/from-tf.js +7 -2
- package/dist-sdk/src/entities/relationship/module.js +2 -2
- package/dist-sdk/src/entities/relationship/pair-check.d.ts +6 -2
- package/dist-sdk/src/entities/relationship/pair-check.js +105 -18
- package/dist-sdk/src/entities/relationship/to-tf.js +5 -2
- package/dist-sdk/src/entities/role/permission-levels.d.ts +7 -0
- package/dist-sdk/src/entities/role/permission-levels.js +78 -0
- package/dist-sdk/src/entities/role/to-tf.js +32 -2
- package/dist-sdk/src/entities/service-account/module.d.ts +2 -1
- package/dist-sdk/src/entities/service-account/module.js +9 -1
- package/dist-sdk/src/entities/service-account/resource-type.d.ts +2 -0
- package/dist-sdk/src/entities/service-account/resource-type.js +2 -0
- package/dist-sdk/src/entities/service-account/role-fidelity.d.ts +5 -5
- package/dist-sdk/src/entities/service-account/role-fidelity.js +21 -13
- package/dist-sdk/src/entities/service-account/role-membership-check.d.ts +20 -0
- package/dist-sdk/src/entities/service-account/role-membership-check.js +80 -0
- package/dist-sdk/src/entities/shared/aspect-target-from-tf.d.ts +15 -0
- package/dist-sdk/src/entities/shared/aspect-target-from-tf.js +36 -0
- package/dist-sdk/src/entities/shared/filters/ast.d.ts +4 -0
- package/dist-sdk/src/entities/shared/filters/index.d.ts +85 -14
- package/dist-sdk/src/entities/shared/filters/index.js +18 -6
- package/dist-sdk/src/entities/shared/filters/option-lookups.d.ts +57 -0
- package/dist-sdk/src/entities/shared/filters/option-lookups.js +108 -0
- package/dist-sdk/src/entities/shared/filters/print.js +9 -5
- package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +12 -7
- package/dist-sdk/src/entities/shared/filters/tf-codec.js +9 -5
- package/dist-sdk/src/entities/shared/raw-option-id.d.ts +30 -0
- package/dist-sdk/src/entities/shared/raw-option-id.js +41 -0
- package/dist-sdk/src/entities/shared/tool-field-ref.js +6 -2
- package/dist-sdk/src/entities/shared/types/field-types.d.ts +6 -3
- package/dist-sdk/src/entities/shared/types/field-types.js +3 -1
- package/dist-sdk/src/entities/skill/input-coverage.js +5 -2
- package/dist-sdk/src/entities/skill/module.js +2 -0
- package/dist-sdk/src/entities/sla/build.d.ts +96 -0
- package/dist-sdk/src/entities/sla/build.js +124 -0
- package/dist-sdk/src/entities/sla/from-tf.d.ts +40 -0
- package/dist-sdk/src/entities/sla/from-tf.js +164 -0
- package/dist-sdk/src/entities/sla/index.d.ts +1 -0
- package/dist-sdk/src/entities/sla/index.js +1 -0
- package/dist-sdk/src/entities/sla/module.d.ts +4 -0
- package/dist-sdk/src/entities/sla/module.js +73 -0
- package/dist-sdk/src/entities/sla/printer.d.ts +2 -0
- package/dist-sdk/src/entities/sla/printer.js +84 -0
- package/dist-sdk/src/entities/sla/to-tf.d.ts +12 -0
- package/dist-sdk/src/entities/sla/to-tf.js +81 -0
- package/dist-sdk/src/entities/table/build.d.ts +7 -2
- package/dist-sdk/src/entities/table/build.js +22 -1
- package/dist-sdk/src/entities/table/deserializer/normalize.d.ts +4 -1
- package/dist-sdk/src/entities/table/from-tf.js +89 -14
- package/dist-sdk/src/entities/table/index.d.ts +1 -1
- package/dist-sdk/src/entities/table/to-tf.js +41 -2
- package/dist-sdk/src/entities/task/from-tf.js +2 -1
- package/dist-sdk/src/entities/task/to-tf.js +1 -0
- package/dist-sdk/src/entities/view/from-tf.d.ts +8 -4
- package/dist-sdk/src/entities/view/from-tf.js +10 -9
- package/dist-sdk/src/entities/view/module.js +5 -0
- package/dist-sdk/src/entities/widget/from-tf.js +15 -4
- package/dist-sdk/src/generated/ragnarok/ragnarok-spec.d.ts +51 -4
- package/dist-sdk/src/generated/ragnarok/ragnarok-spec.js +2 -2
- package/dist-sdk/src/graph/index.d.ts +20 -2
- package/dist-sdk/src/graph/index.js +19 -0
- package/dist-sdk/src/graph/modules.js +11 -1
- package/dist-sdk/src/graph/resource-types.d.ts +47 -0
- package/dist-sdk/src/graph/resource-types.js +62 -0
- package/dist-sdk/src/graph/types.d.ts +116 -6
- package/package.json +6 -3
|
@@ -0,0 +1,418 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Advisory checks of an executeScript body against its declared inputs and
|
|
3
|
+
* outputs (edk#2286). A read of an undeclared input is always undefined, and a
|
|
4
|
+
* declared output no return sets is always empty. A script with no top-level
|
|
5
|
+
* return fails every run (edk#2364). Build, plan and apply can't catch these, so
|
|
6
|
+
* build reports them as advisories.
|
|
7
|
+
*/
|
|
8
|
+
import { parse } from "acorn";
|
|
9
|
+
import { toPlatformScriptBody } from "./script-code.js";
|
|
10
|
+
const FUNCTION_TYPES = new Set(["FunctionDeclaration", "FunctionExpression", "ArrowFunctionExpression"]);
|
|
11
|
+
function parseScript(code) {
|
|
12
|
+
const options = { ecmaVersion: "latest", sourceType: "script", allowReturnOutsideFunction: true };
|
|
13
|
+
try {
|
|
14
|
+
return parse(code, options);
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
try {
|
|
18
|
+
return parse(toPlatformScriptBody(code, "script lint"), options);
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function isNode(value) {
|
|
26
|
+
return typeof value === "object" && value !== null && typeof value.type === "string";
|
|
27
|
+
}
|
|
28
|
+
function children(node) {
|
|
29
|
+
return Object.entries(node).filter(([key]) => key !== "type" && key !== "start" && key !== "end").map(([, value]) => value);
|
|
30
|
+
}
|
|
31
|
+
function propertyName(key, computed) {
|
|
32
|
+
if (!isNode(key))
|
|
33
|
+
return undefined;
|
|
34
|
+
if (computed !== true && key.type === "Identifier")
|
|
35
|
+
return key["name"];
|
|
36
|
+
if (key.type === "Literal" && typeof key["value"] === "string")
|
|
37
|
+
return key["value"];
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
function newScope(parent, isFunction) {
|
|
41
|
+
return { parent, isFunction, bindings: new Map() };
|
|
42
|
+
}
|
|
43
|
+
function bind(scope, name) {
|
|
44
|
+
let binding = scope.bindings.get(name);
|
|
45
|
+
if (binding === undefined) {
|
|
46
|
+
binding = { alias: false, assigned: false, inits: [] };
|
|
47
|
+
scope.bindings.set(name, binding);
|
|
48
|
+
}
|
|
49
|
+
return binding;
|
|
50
|
+
}
|
|
51
|
+
function functionScope(scope) {
|
|
52
|
+
let current = scope;
|
|
53
|
+
while (!current.isFunction && current.parent !== undefined)
|
|
54
|
+
current = current.parent;
|
|
55
|
+
return current;
|
|
56
|
+
}
|
|
57
|
+
function resolve(scope, name) {
|
|
58
|
+
for (let current = scope; current !== undefined; current = current.parent) {
|
|
59
|
+
const binding = current.bindings.get(name);
|
|
60
|
+
if (binding !== undefined)
|
|
61
|
+
return binding;
|
|
62
|
+
}
|
|
63
|
+
return undefined;
|
|
64
|
+
}
|
|
65
|
+
function patternNames(pattern) {
|
|
66
|
+
const names = [];
|
|
67
|
+
const collect = (node) => {
|
|
68
|
+
if (!isNode(node))
|
|
69
|
+
return;
|
|
70
|
+
switch (node.type) {
|
|
71
|
+
case "Identifier":
|
|
72
|
+
names.push(node["name"]);
|
|
73
|
+
return;
|
|
74
|
+
case "ObjectPattern":
|
|
75
|
+
for (const property of node["properties"])
|
|
76
|
+
collect(property.type === "RestElement" ? property["argument"] : property["value"]);
|
|
77
|
+
return;
|
|
78
|
+
case "ArrayPattern":
|
|
79
|
+
for (const element of node["elements"])
|
|
80
|
+
collect(element);
|
|
81
|
+
return;
|
|
82
|
+
case "RestElement":
|
|
83
|
+
collect(node["argument"]);
|
|
84
|
+
return;
|
|
85
|
+
case "AssignmentPattern":
|
|
86
|
+
collect(node["left"]);
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
collect(pattern);
|
|
91
|
+
return names;
|
|
92
|
+
}
|
|
93
|
+
/** Whether `name` is bound by `{ parameters: name }` (or `{ parameters }`) in an object pattern. */
|
|
94
|
+
function parametersPropertyValue(pattern, name) {
|
|
95
|
+
if (!isNode(pattern) || pattern.type !== "ObjectPattern")
|
|
96
|
+
return false;
|
|
97
|
+
return pattern["properties"].some((property) => property.type === "Property" && propertyName(property["key"], property["computed"]) === "parameters" &&
|
|
98
|
+
isNode(property["value"]) && property["value"].type === "Identifier" && property["value"]["name"] === name);
|
|
99
|
+
}
|
|
100
|
+
/** The `<object>.parameters` member expression, for a binding destructured out of `<object>`. */
|
|
101
|
+
function parametersOf(object) {
|
|
102
|
+
return { type: "MemberExpression", computed: false, object, property: { type: "Identifier", name: "parameters" } };
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Builds the scopes of a script. The platform runs the body in a function
|
|
106
|
+
* nested in one that declares `const input`, so an undeclared `input` is the
|
|
107
|
+
* script's input. Each
|
|
108
|
+
* function, block, loop, catch clause and switch gets its own scope, and `var`
|
|
109
|
+
* belongs to the nearest function.
|
|
110
|
+
*/
|
|
111
|
+
function buildScopes(program) {
|
|
112
|
+
const scopes = new Map();
|
|
113
|
+
const declareFunction = (node, scope) => {
|
|
114
|
+
const inner = newScope(scope, true);
|
|
115
|
+
scopes.set(node, inner);
|
|
116
|
+
if (node.type === "FunctionExpression" && isNode(node["id"]))
|
|
117
|
+
bind(inner, node["id"]["name"]);
|
|
118
|
+
for (const param of node["params"])
|
|
119
|
+
for (const name of patternNames(param))
|
|
120
|
+
bind(inner, name);
|
|
121
|
+
declare(node["params"], inner);
|
|
122
|
+
const body = node["body"];
|
|
123
|
+
if (isNode(body) && body.type === "BlockStatement") {
|
|
124
|
+
scopes.set(body, inner);
|
|
125
|
+
declare(body["body"], inner);
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
declare(body, inner);
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
const declare = (node, scope) => {
|
|
132
|
+
if (Array.isArray(node)) {
|
|
133
|
+
for (const item of node)
|
|
134
|
+
declare(item, scope);
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
if (!isNode(node))
|
|
138
|
+
return;
|
|
139
|
+
switch (node.type) {
|
|
140
|
+
case "FunctionDeclaration":
|
|
141
|
+
if (isNode(node["id"]))
|
|
142
|
+
bind(scope, node["id"]["name"]);
|
|
143
|
+
declareFunction(node, scope);
|
|
144
|
+
return;
|
|
145
|
+
case "FunctionExpression":
|
|
146
|
+
case "ArrowFunctionExpression":
|
|
147
|
+
declareFunction(node, scope);
|
|
148
|
+
return;
|
|
149
|
+
case "ClassDeclaration":
|
|
150
|
+
if (isNode(node["id"]))
|
|
151
|
+
bind(scope, node["id"]["name"]);
|
|
152
|
+
break;
|
|
153
|
+
case "BlockStatement":
|
|
154
|
+
case "ForStatement":
|
|
155
|
+
case "ForInStatement":
|
|
156
|
+
case "ForOfStatement": {
|
|
157
|
+
const inner = newScope(scope, false);
|
|
158
|
+
scopes.set(node, inner);
|
|
159
|
+
for (const child of children(node))
|
|
160
|
+
declare(child, inner);
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
case "SwitchStatement": {
|
|
164
|
+
// The discriminant is outside the cases' block.
|
|
165
|
+
declare(node["discriminant"], scope);
|
|
166
|
+
const inner = newScope(scope, false);
|
|
167
|
+
for (const switchCase of node["cases"]) {
|
|
168
|
+
scopes.set(switchCase, inner);
|
|
169
|
+
declare(switchCase, inner);
|
|
170
|
+
}
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
case "StaticBlock": {
|
|
174
|
+
const inner = newScope(scope, true);
|
|
175
|
+
scopes.set(node, inner);
|
|
176
|
+
declare(node["body"], inner);
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
case "ClassExpression": {
|
|
180
|
+
if (!isNode(node["id"]))
|
|
181
|
+
break;
|
|
182
|
+
const inner = newScope(scope, false);
|
|
183
|
+
scopes.set(node, inner);
|
|
184
|
+
bind(inner, node["id"]["name"]);
|
|
185
|
+
for (const child of children(node))
|
|
186
|
+
declare(child, inner);
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
case "CatchClause": {
|
|
190
|
+
const inner = newScope(scope, false);
|
|
191
|
+
scopes.set(node, inner);
|
|
192
|
+
for (const name of patternNames(node["param"]))
|
|
193
|
+
bind(inner, name);
|
|
194
|
+
declare(node["body"], inner);
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
case "VariableDeclaration": {
|
|
198
|
+
const target = node["kind"] === "var" ? functionScope(scope) : scope;
|
|
199
|
+
for (const declarator of node["declarations"]) {
|
|
200
|
+
for (const name of patternNames(declarator["id"])) {
|
|
201
|
+
const binding = bind(target, name);
|
|
202
|
+
if (isNode(declarator["id"]) && declarator["id"].type === "Identifier") {
|
|
203
|
+
if (declarator["init"] !== null && declarator["init"] !== undefined) {
|
|
204
|
+
binding.inits.push({ init: declarator["init"], scope });
|
|
205
|
+
}
|
|
206
|
+
else if (node["kind"] !== "var") {
|
|
207
|
+
binding.inits.push({ init: undefined, scope });
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
else if (parametersPropertyValue(declarator["id"], name)) {
|
|
211
|
+
binding.inits.push({ init: parametersOf(declarator["init"]), scope });
|
|
212
|
+
}
|
|
213
|
+
else {
|
|
214
|
+
binding.assigned = true;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
declare(declarator["id"], scope);
|
|
218
|
+
declare(declarator["init"], scope);
|
|
219
|
+
}
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
for (const child of children(node))
|
|
224
|
+
declare(child, scope);
|
|
225
|
+
};
|
|
226
|
+
const root = newScope(undefined, true);
|
|
227
|
+
scopes.set(program, root);
|
|
228
|
+
declare(program["body"], root);
|
|
229
|
+
return scopes;
|
|
230
|
+
}
|
|
231
|
+
/** Walks a node with the scope that holds each node, and whether it is inside a function. */
|
|
232
|
+
function walkScoped(node, scope, inFunction, scopes, visit) {
|
|
233
|
+
if (Array.isArray(node)) {
|
|
234
|
+
for (const item of node)
|
|
235
|
+
walkScoped(item, scope, inFunction, scopes, visit);
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
if (!isNode(node))
|
|
239
|
+
return;
|
|
240
|
+
const own = scopes.get(node) ?? scope;
|
|
241
|
+
visit(node, own, inFunction);
|
|
242
|
+
const childInFunction = inFunction || FUNCTION_TYPES.has(node.type);
|
|
243
|
+
for (const child of children(node))
|
|
244
|
+
walkScoped(child, own, childInFunction, scopes, visit);
|
|
245
|
+
}
|
|
246
|
+
export function scriptParameterUse(code) {
|
|
247
|
+
const program = parseScript(code);
|
|
248
|
+
if (program === undefined)
|
|
249
|
+
return undefined;
|
|
250
|
+
const scopes = buildScopes(program);
|
|
251
|
+
const root = scopes.get(program);
|
|
252
|
+
walkScoped(program, root, false, scopes, (node, scope) => {
|
|
253
|
+
if (node.type === "AssignmentExpression" && isNode(node["left"]) && node["left"].type === "Identifier") {
|
|
254
|
+
const binding = resolve(scope, node["left"]["name"]);
|
|
255
|
+
if (binding !== undefined)
|
|
256
|
+
binding.assigned = true;
|
|
257
|
+
}
|
|
258
|
+
if (node.type === "UpdateExpression" && isNode(node["argument"]) && node["argument"].type === "Identifier") {
|
|
259
|
+
const binding = resolve(scope, node["argument"]["name"]);
|
|
260
|
+
if (binding !== undefined)
|
|
261
|
+
binding.assigned = true;
|
|
262
|
+
}
|
|
263
|
+
if ((node.type === "ForInStatement" || node.type === "ForOfStatement") && isNode(node["left"])) {
|
|
264
|
+
const targets = node["left"].type === "VariableDeclaration"
|
|
265
|
+
? node["left"]["declarations"].flatMap((declarator) => patternNames(declarator["id"]))
|
|
266
|
+
: patternNames(node["left"]);
|
|
267
|
+
for (const name of targets) {
|
|
268
|
+
const binding = resolve(scope, name);
|
|
269
|
+
if (binding !== undefined)
|
|
270
|
+
binding.assigned = true;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
});
|
|
274
|
+
// `input.parameters`, read through the script's own `input`, or an alias of it.
|
|
275
|
+
const isParametersOf = (node, scope) => {
|
|
276
|
+
if (!isNode(node))
|
|
277
|
+
return false;
|
|
278
|
+
switch (node.type) {
|
|
279
|
+
case "Identifier":
|
|
280
|
+
return resolve(scope, node["name"])?.alias === true;
|
|
281
|
+
case "MemberExpression":
|
|
282
|
+
return node["computed"] !== true && isNode(node["object"]) && node["object"].type === "Identifier" &&
|
|
283
|
+
node["object"]["name"] === "input" && resolve(scope, "input") === undefined &&
|
|
284
|
+
isNode(node["property"]) && node["property"]["name"] === "parameters";
|
|
285
|
+
case "LogicalExpression":
|
|
286
|
+
return node["operator"] === "&&" ? isParametersOf(node["right"], scope) : isParametersOf(node["left"], scope);
|
|
287
|
+
case "ChainExpression":
|
|
288
|
+
return isParametersOf(node["expression"], scope);
|
|
289
|
+
case "ConditionalExpression":
|
|
290
|
+
return (isParametersOf(node["consequent"], scope) && isEmptyObjectOrParameters(node["alternate"], scope)) ||
|
|
291
|
+
(isParametersOf(node["alternate"], scope) && isEmptyObjectOrParameters(node["consequent"], scope));
|
|
292
|
+
}
|
|
293
|
+
return false;
|
|
294
|
+
};
|
|
295
|
+
const isEmptyObjectOrParameters = (node, scope) => (isNode(node) && node.type === "ObjectExpression" && node["properties"].length === 0) || isParametersOf(node, scope);
|
|
296
|
+
const bindings = [...new Set([...scopes.values()])].flatMap((scope) => [...scope.bindings.values()]);
|
|
297
|
+
for (let changed = true; changed;) {
|
|
298
|
+
changed = false;
|
|
299
|
+
for (const binding of bindings) {
|
|
300
|
+
if (binding.alias || binding.assigned || binding.inits.length === 0)
|
|
301
|
+
continue;
|
|
302
|
+
if (binding.inits.every(({ init, scope }) => isParametersOf(init, scope))) {
|
|
303
|
+
binding.alias = true;
|
|
304
|
+
changed = true;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
const reads = new Set();
|
|
309
|
+
const returnedKeys = new Set();
|
|
310
|
+
let returnsKnown = true;
|
|
311
|
+
let returnsValue = false;
|
|
312
|
+
const collectReturn = (argument, scope) => {
|
|
313
|
+
if (!returnsUndefined(argument, scope))
|
|
314
|
+
returnsValue = true;
|
|
315
|
+
if (!isNode(argument) || argument.type !== "ObjectExpression") {
|
|
316
|
+
returnsKnown = false;
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
for (const property of argument["properties"]) {
|
|
320
|
+
const name = property.type === "Property" ? propertyName(property["key"], property["computed"]) : undefined;
|
|
321
|
+
if (name === undefined)
|
|
322
|
+
returnsKnown = false;
|
|
323
|
+
else
|
|
324
|
+
returnedKeys.add(name);
|
|
325
|
+
}
|
|
326
|
+
};
|
|
327
|
+
// A called member such as `input.parameters.hasOwnProperty(...)` is a method, and a written one is
|
|
328
|
+
// set by the script. Neither is an input.
|
|
329
|
+
const notReads = new Set();
|
|
330
|
+
const written = new Set();
|
|
331
|
+
walkScoped(program, root, false, scopes, (node, scope, inFunction) => {
|
|
332
|
+
if (node.type === "CallExpression" && isNode(node["callee"]))
|
|
333
|
+
notReads.add(node["callee"]);
|
|
334
|
+
if (node.type === "AssignmentExpression" && isNode(node["left"]))
|
|
335
|
+
notReads.add(node["left"]);
|
|
336
|
+
if (node.type === "UpdateExpression" && isNode(node["argument"]))
|
|
337
|
+
notReads.add(node["argument"]);
|
|
338
|
+
if (node.type === "VariableDeclarator" && isNode(node["id"]) && node["id"].type === "ObjectPattern" &&
|
|
339
|
+
isParametersOf(node["init"], scope)) {
|
|
340
|
+
for (const property of node["id"]["properties"]) {
|
|
341
|
+
const name = property.type === "Property" ? propertyName(property["key"], property["computed"]) : undefined;
|
|
342
|
+
if (name !== undefined)
|
|
343
|
+
reads.add(name);
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
if (node.type === "MemberExpression" && isParametersOf(node["object"], scope)) {
|
|
347
|
+
const name = propertyName(node["property"], node["computed"]);
|
|
348
|
+
if (name !== undefined)
|
|
349
|
+
(notReads.has(node) ? written : reads).add(name);
|
|
350
|
+
}
|
|
351
|
+
if (node.type === "ReturnStatement" && !inFunction)
|
|
352
|
+
collectReturn(node["argument"], scope);
|
|
353
|
+
});
|
|
354
|
+
for (const name of written)
|
|
355
|
+
reads.delete(name);
|
|
356
|
+
return { reads, returnedKeys: returnsKnown ? returnedKeys : undefined, returnsValue };
|
|
357
|
+
}
|
|
358
|
+
/** Whether a return argument is plainly undefined: none, `undefined` (not shadowed), or `void <expr>`. */
|
|
359
|
+
function returnsUndefined(argument, scope) {
|
|
360
|
+
if (!isNode(argument))
|
|
361
|
+
return true;
|
|
362
|
+
if (argument.type === "Identifier" && argument["name"] === "undefined")
|
|
363
|
+
return resolve(scope, "undefined") === undefined;
|
|
364
|
+
return argument.type === "UnaryExpression" && argument["operator"] === "void";
|
|
365
|
+
}
|
|
366
|
+
/** The top-level output names an `outputs` schema declares, or undefined when its shape isn't a plain object. */
|
|
367
|
+
export function declaredScriptOutputs(outputSchema) {
|
|
368
|
+
if (typeof outputSchema !== "object" || outputSchema === null)
|
|
369
|
+
return undefined;
|
|
370
|
+
const root = outputSchema.object;
|
|
371
|
+
if (root === undefined || !Array.isArray(root.properties))
|
|
372
|
+
return undefined;
|
|
373
|
+
const names = [];
|
|
374
|
+
for (const property of root.properties) {
|
|
375
|
+
if (typeof property !== "object" || property === null)
|
|
376
|
+
return undefined;
|
|
377
|
+
const inner = Object.values(property)[0];
|
|
378
|
+
const name = typeof inner === "object" && inner !== null ? inner.name : undefined;
|
|
379
|
+
if (typeof name !== "string")
|
|
380
|
+
return undefined;
|
|
381
|
+
names.push(name);
|
|
382
|
+
}
|
|
383
|
+
return names;
|
|
384
|
+
}
|
|
385
|
+
/** Advisory messages for one executeScript task. */
|
|
386
|
+
export function scriptLintFindings(taskName, code, inputs, outputSchema) {
|
|
387
|
+
if (typeof code !== "string")
|
|
388
|
+
return [];
|
|
389
|
+
const use = scriptParameterUse(code);
|
|
390
|
+
if (use === undefined)
|
|
391
|
+
return [];
|
|
392
|
+
const declaredInputs = Array.isArray(inputs)
|
|
393
|
+
? inputs.flatMap((input) => typeof input === "object" && input !== null && typeof input.name === "string" ? [input.name] : [])
|
|
394
|
+
: [];
|
|
395
|
+
const findings = [];
|
|
396
|
+
const declared = declaredInputs.length > 0 ? declaredInputs.join(", ") : "none";
|
|
397
|
+
for (const name of use.reads) {
|
|
398
|
+
if (!declaredInputs.includes(name)) {
|
|
399
|
+
findings.push(`executeScript "${taskName}" reads input "${name}", which its inputs don't declare, so it is always undefined. Declared inputs: ${declared}.`);
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
if (!use.returnsValue) {
|
|
403
|
+
// The platform's executor throws "The function MUST return a valid JavaScript object" when the
|
|
404
|
+
// script's result is undefined, so each declared output being empty is the lesser problem.
|
|
405
|
+
findings.push(`executeScript "${taskName}" has no top-level return that returns a value, so every run fails ("The function MUST return a valid JavaScript object"). A return inside a callback or nested function does not count. End the script with return { ... }.`);
|
|
406
|
+
return findings;
|
|
407
|
+
}
|
|
408
|
+
const outputs = declaredScriptOutputs(outputSchema);
|
|
409
|
+
if (outputs !== undefined && use.returnedKeys !== undefined) {
|
|
410
|
+
const returned = use.returnedKeys.size > 0 ? [...use.returnedKeys].join(", ") : "none";
|
|
411
|
+
for (const name of outputs) {
|
|
412
|
+
if (!use.returnedKeys.has(name)) {
|
|
413
|
+
findings.push(`executeScript "${taskName}" declares output "${name}", which no return of its script sets, so it is always empty. Returned keys: ${returned}.`);
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
return findings;
|
|
418
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The accessor path for a stored Slack message trigger reference, or
|
|
3
|
+
* undefined when its first segment names no Slack output (pull keeps it).
|
|
4
|
+
*/
|
|
5
|
+
export declare function slackMessageTriggerPathFromWire(path: readonly string[]): string[] | undefined;
|
|
6
|
+
/** The `refs` map key for `ctx.trigger.<name>` on a Slack message trigger. */
|
|
7
|
+
export declare function slackMessageTriggerRefName(name: string): string;
|
|
8
|
+
/** The `triggerReference.name` (calculation formula, ValueReference) for `ctx.trigger.<name>`. */
|
|
9
|
+
export declare function slackMessageTriggerReferenceName(name: string): string;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { EntityTfError } from "../../engine/entity.js";
|
|
2
|
+
/**
|
|
3
|
+
* Every `ctx.trigger.<accessor>` on a Slack message trigger (#2581), keyed by
|
|
4
|
+
* `keyof SlackMessageTriggerOutput` so an output added to the type without an
|
|
5
|
+
* entry here fails `tsc`. Live-confirmed (`ei refs --from-remote`, edk#2581):
|
|
6
|
+
* - `refsKey` is the trigger's `refs` map key, read by task inputs and filters;
|
|
7
|
+
* - `referenceName` is its `triggerReference.name`, the name a calculation
|
|
8
|
+
* formula (`{{trigger name="content"}}`) and a ValueReference envelope use.
|
|
9
|
+
* The platform rejects the refs key there with `Unable to validate`.
|
|
10
|
+
*/
|
|
11
|
+
const SLACK_MESSAGE_TRIGGER_REFS = {
|
|
12
|
+
threadId: { refsKey: "Slack Thread ID", referenceName: "threadId" },
|
|
13
|
+
channelId: { refsKey: "Slack Channel ID", referenceName: "channelId" },
|
|
14
|
+
authorEmail: { refsKey: "Message Author Email", referenceName: "authorEmail" },
|
|
15
|
+
authorId: { refsKey: "Message Author ID", referenceName: "authorId" },
|
|
16
|
+
authorName: { refsKey: "Message Author Name", referenceName: "authorName" },
|
|
17
|
+
content: { refsKey: "Message Content", referenceName: "content" },
|
|
18
|
+
messageId: { refsKey: "Message ID", referenceName: "messageId" },
|
|
19
|
+
meta: { refsKey: "Message Metadata", referenceName: "metadata" },
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Names pull may find stored on a Slack message trigger reference → accessor:
|
|
23
|
+
* the refs keys, the reference names, and the accessor names removed in
|
|
24
|
+
* #2581. Pull-only, so a re-pull writes the one accessor spelling.
|
|
25
|
+
*/
|
|
26
|
+
const SLACK_MESSAGE_TRIGGER_REF_FROM_WIRE = new Map([
|
|
27
|
+
...Object.entries(SLACK_MESSAGE_TRIGGER_REFS).flatMap(([accessor, { refsKey, referenceName }]) => [
|
|
28
|
+
[refsKey, accessor],
|
|
29
|
+
[referenceName, accessor],
|
|
30
|
+
[accessor, accessor],
|
|
31
|
+
]),
|
|
32
|
+
["slackThreadId", "threadId"],
|
|
33
|
+
["slackChannelId", "channelId"],
|
|
34
|
+
["messageAuthorEmail", "authorEmail"],
|
|
35
|
+
["messageAuthorId", "authorId"],
|
|
36
|
+
["messageAuthorName", "authorName"],
|
|
37
|
+
["messageContent", "content"],
|
|
38
|
+
["messageMetadata", "meta"],
|
|
39
|
+
]);
|
|
40
|
+
/**
|
|
41
|
+
* The accessor path for a stored Slack message trigger reference, or
|
|
42
|
+
* undefined when its first segment names no Slack output (pull keeps it).
|
|
43
|
+
*/
|
|
44
|
+
export function slackMessageTriggerPathFromWire(path) {
|
|
45
|
+
const accessor = path[0] !== undefined ? SLACK_MESSAGE_TRIGGER_REF_FROM_WIRE.get(path[0]) : undefined;
|
|
46
|
+
return accessor !== undefined ? [accessor, ...path.slice(1)] : undefined;
|
|
47
|
+
}
|
|
48
|
+
const ACCESSOR_BY_REFS_KEY_LOWER = new Map(Object.entries(SLACK_MESSAGE_TRIGGER_REFS).map(([accessor, { refsKey }]) => [refsKey.toLowerCase(), accessor]));
|
|
49
|
+
/**
|
|
50
|
+
* Resolve `ctx.trigger.<name>` on a Slack message trigger. Fails closed: an
|
|
51
|
+
* accessor the trigger does not publish is a build error, not a name that
|
|
52
|
+
* only fails at apply (`Invalid index`, `Unable to validate`).
|
|
53
|
+
*/
|
|
54
|
+
function resolveSlackAccessor(name, column) {
|
|
55
|
+
const byRefsKey = ACCESSOR_BY_REFS_KEY_LOWER.get(name.toLowerCase());
|
|
56
|
+
if (byRefsKey !== undefined)
|
|
57
|
+
return SLACK_MESSAGE_TRIGGER_REFS[byRefsKey][column];
|
|
58
|
+
const [head, ...rest] = name.split(".");
|
|
59
|
+
const entry = Object.hasOwn(SLACK_MESSAGE_TRIGGER_REFS, head)
|
|
60
|
+
? SLACK_MESSAGE_TRIGGER_REFS[head]
|
|
61
|
+
: undefined;
|
|
62
|
+
if (entry === undefined) {
|
|
63
|
+
throw new EntityTfError(`ctx.trigger.${name}: a Slack message trigger publishes no such reference. ` +
|
|
64
|
+
`Use one of ${Object.keys(SLACK_MESSAGE_TRIGGER_REFS).join(", ")}.`);
|
|
65
|
+
}
|
|
66
|
+
return [entry[column], ...rest].join(".");
|
|
67
|
+
}
|
|
68
|
+
/** The `refs` map key for `ctx.trigger.<name>` on a Slack message trigger. */
|
|
69
|
+
export function slackMessageTriggerRefName(name) {
|
|
70
|
+
return resolveSlackAccessor(name, "refsKey");
|
|
71
|
+
}
|
|
72
|
+
/** The `triggerReference.name` (calculation formula, ValueReference) for `ctx.trigger.<name>`. */
|
|
73
|
+
export function slackMessageTriggerReferenceName(name) {
|
|
74
|
+
return resolveSlackAccessor(name, "referenceName");
|
|
75
|
+
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { TaskOutputReference } from "../../graph/types.js";
|
|
2
|
+
/** Platform reference name for a whole record's identity, distinct from its TEXT handle. */
|
|
3
|
+
export declare const RECORD_ID_REFERENCE_FIELD = "10000001-2000-4000-a000-800000000000";
|
|
2
4
|
/** userSearch authoring output → provider refs-map key (as exported from live user-search tasks). */
|
|
3
5
|
export declare const USER_SEARCH_REF_WIRE_NAMES: Readonly<Record<string, string>>;
|
|
4
6
|
/**
|
|
@@ -23,10 +25,19 @@ export declare const TASK_OUTPUT_REFERENCE_NAMES: Readonly<Record<string, Readon
|
|
|
23
25
|
* the envelope is of this type.
|
|
24
26
|
*/
|
|
25
27
|
export declare function taskOutputReferences(): Readonly<Record<string, Readonly<Record<string, TaskOutputReference>>>>;
|
|
28
|
+
/**
|
|
29
|
+
* executeScript contract outputs keyed by refs-map key ("Text Result" →
|
|
30
|
+
* `textResult`), for the build-vs-export comparison only. Build reads a
|
|
31
|
+
* script output as `refs["Text Result"]` (EXECUTE_SCRIPT_REFS_INDEX); the
|
|
32
|
+
* export spells the same read as the `textResult` envelope, so without this
|
|
33
|
+
* the comparison reported every such filter as a difference (edk#2791). Kept
|
|
34
|
+
* out of TASK_OUTPUT_REFERENCE_NAMES, which build also reads.
|
|
35
|
+
*/
|
|
36
|
+
export declare function executeScriptOutputReferences(): Readonly<Record<string, TaskOutputReference>>;
|
|
26
37
|
/**
|
|
27
38
|
* A record-bearing task's whole-record output (ASPECT_RECORD). The bare
|
|
28
39
|
* `.record` accessor otherwise builds the ASPECT_RECORD_ID `Record` key a
|
|
29
|
-
* `record_reference` needs; a
|
|
40
|
+
* `record_reference` needs; a script input needs the record itself.
|
|
30
41
|
*/
|
|
31
42
|
export declare const WHOLE_RECORD_REF_WIRE_NAMES: Readonly<Record<string, string>>;
|
|
32
43
|
/**
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { RESOURCE_TYPE_TO_EXECUTOR, TASK_OUTPUT_CONTRACTS } from "./generated/task-output-contracts.js";
|
|
2
|
+
import { EXECUTE_SCRIPT_REFS_INDEX } from "./output-key-wire-name.js";
|
|
3
|
+
/** Platform reference name for a whole record's identity, distinct from its TEXT handle. */
|
|
4
|
+
export const RECORD_ID_REFERENCE_FIELD = "10000001-2000-4000-a000-800000000000";
|
|
2
5
|
/** userSearch authoring output → provider refs-map key (as exported from live user-search tasks). */
|
|
3
6
|
export const USER_SEARCH_REF_WIRE_NAMES = {
|
|
4
7
|
"user.id": "User's Id",
|
|
@@ -58,6 +61,14 @@ export const TASK_OUTPUT_REFERENCE_NAMES = {
|
|
|
58
61
|
"API Response (text)": "textResponse",
|
|
59
62
|
"API Response Status Code": "statusCode",
|
|
60
63
|
},
|
|
64
|
+
// Captured live from a deployed table_records_search task's refs map (edk#2407).
|
|
65
|
+
elementum_table_records_search_task: {
|
|
66
|
+
"All matching table rows": "records",
|
|
67
|
+
"First matching table row": "record",
|
|
68
|
+
"Row count": "count",
|
|
69
|
+
"Column metadata for the result": "metaData",
|
|
70
|
+
"Source table id": "tableId",
|
|
71
|
+
},
|
|
61
72
|
// Captured live from a deployed bulk_update_fields task's refs map.
|
|
62
73
|
elementum_bulk_update_fields_task: {
|
|
63
74
|
"Records Updated": "recordsUpdated",
|
|
@@ -81,10 +92,30 @@ export function taskOutputReferences() {
|
|
|
81
92
|
}))];
|
|
82
93
|
}));
|
|
83
94
|
}
|
|
95
|
+
/**
|
|
96
|
+
* executeScript contract outputs keyed by refs-map key ("Text Result" →
|
|
97
|
+
* `textResult`), for the build-vs-export comparison only. Build reads a
|
|
98
|
+
* script output as `refs["Text Result"]` (EXECUTE_SCRIPT_REFS_INDEX); the
|
|
99
|
+
* export spells the same read as the `textResult` envelope, so without this
|
|
100
|
+
* the comparison reported every such filter as a difference (edk#2791). Kept
|
|
101
|
+
* out of TASK_OUTPUT_REFERENCE_NAMES, which build also reads.
|
|
102
|
+
*/
|
|
103
|
+
export function executeScriptOutputReferences() {
|
|
104
|
+
const taskType = "elementum_execute_script_task";
|
|
105
|
+
const executor = RESOURCE_TYPE_TO_EXECUTOR[taskType];
|
|
106
|
+
return Object.fromEntries(Object.entries(EXECUTE_SCRIPT_REFS_INDEX)
|
|
107
|
+
.filter(([name, key]) => name !== key)
|
|
108
|
+
.map(([name, key]) => {
|
|
109
|
+
const contract = executor === undefined ? undefined : TASK_OUTPUT_CONTRACTS[executor]?.[name];
|
|
110
|
+
if (contract === undefined)
|
|
111
|
+
throw new Error(`no output contract for ${taskType} output "${name}" (refs key "${key}")`);
|
|
112
|
+
return [key, { name, fieldType: contract.fieldType, multiple: contract.multiple }];
|
|
113
|
+
}));
|
|
114
|
+
}
|
|
84
115
|
/**
|
|
85
116
|
* A record-bearing task's whole-record output (ASPECT_RECORD). The bare
|
|
86
117
|
* `.record` accessor otherwise builds the ASPECT_RECORD_ID `Record` key a
|
|
87
|
-
* `record_reference` needs; a
|
|
118
|
+
* `record_reference` needs; a script input needs the record itself.
|
|
88
119
|
*/
|
|
89
120
|
export const WHOLE_RECORD_REF_WIRE_NAMES = {
|
|
90
121
|
recordSearch: "First found record",
|