@elementumai/edk 0.9.2 → 0.9.5
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 +34 -26
- package/dist-sdk/elementum-entity-client/clients/automation/models/automation.d.ts +1 -1
- package/dist-sdk/elementum-entity-client/clients/skills/models/skill.d.ts +1 -1
- package/dist-sdk/elementum-entity-client/clients/skills/models/skill.js +1 -1
- package/dist-sdk/pull/util.d.ts +1 -1
- package/dist-sdk/pull/util.js +3 -3
- package/dist-sdk/src/catalog/factories.d.ts +49 -10
- package/dist-sdk/src/catalog/factories.js +94 -13
- package/dist-sdk/src/catalog/from-authoring.d.ts +5 -5
- package/dist-sdk/src/catalog/from-authoring.js +7 -7
- 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 +62 -4
- package/dist-sdk/src/catalog/render-helpers.d.ts +1 -1
- package/dist-sdk/src/catalog/render-helpers.js +1 -1
- package/dist-sdk/src/catalog/render.d.ts +1 -0
- package/dist-sdk/src/catalog/render.js +2 -2
- package/dist-sdk/src/catalog/token.js +11 -4
- package/dist-sdk/src/catalog/types.d.ts +33 -4
- package/dist-sdk/src/catalog/types.js +5 -0
- package/dist-sdk/src/core/index.d.ts +10 -10
- package/dist-sdk/src/core/index.js +9 -9
- package/dist-sdk/src/core/render-tree.d.ts +1 -1
- package/dist-sdk/src/core/render-tree.js +1 -2
- package/dist-sdk/src/core/types/ai-provider.d.ts +1 -1
- package/dist-sdk/src/core/types/ai-provider.js +1 -1
- package/dist-sdk/src/core/types/app.d.ts +66 -30
- package/dist-sdk/src/core/types/app.js +2 -2
- package/dist-sdk/src/core/types/aspect-category.d.ts +4 -4
- package/dist-sdk/src/core/types/aspect-category.js +4 -4
- package/dist-sdk/src/core/types/cloud-link.d.ts +3 -3
- package/dist-sdk/src/core/types/cloud-link.js +3 -3
- package/dist-sdk/src/core/types/display-block.d.ts +2 -2
- package/dist-sdk/src/core/types/display-block.js +2 -2
- package/dist-sdk/src/core/types/group.d.ts +1 -1
- package/dist-sdk/src/core/types/group.js +1 -1
- package/dist-sdk/src/core/types/user.d.ts +1 -1
- package/dist-sdk/src/core/types/user.js +1 -1
- package/dist-sdk/src/core/wire/ref-serializer.js +3 -3
- package/dist-sdk/src/engine/build/context.d.ts +20 -13
- package/dist-sdk/src/engine/entity.d.ts +1 -1
- package/dist-sdk/src/engine/pull/context.d.ts +34 -0
- package/dist-sdk/src/engine/pull/context.js +14 -0
- package/dist-sdk/src/engine/pull/org.d.ts +9 -0
- package/dist-sdk/src/engine/pull/org.js +33 -0
- package/dist-sdk/src/engine/pull/ref-only.d.ts +37 -0
- package/dist-sdk/src/engine/pull/ref-only.js +204 -0
- package/dist-sdk/src/engine/tf/expr.d.ts +6 -2
- package/dist-sdk/src/engine/tf/expr.js +18 -13
- package/dist-sdk/src/engine/tf/index.d.ts +1 -1
- package/dist-sdk/src/engine/tf/index.js +1 -1
- package/dist-sdk/src/engine/tf/model.d.ts +8 -1
- package/dist-sdk/src/engine/tf/model.js +4 -0
- package/dist-sdk/src/engine/tf/parse.js +13 -2
- package/dist-sdk/src/engine/tf/render.js +4 -0
- package/dist-sdk/src/entities/access-policy/build.d.ts +4 -5
- package/dist-sdk/src/entities/access-policy/build.js +1 -1
- package/dist-sdk/src/entities/access-policy/from-tf.d.ts +4 -4
- package/dist-sdk/src/entities/access-policy/from-tf.js +12 -13
- package/dist-sdk/src/entities/access-policy/principal.d.ts +14 -4
- package/dist-sdk/src/entities/access-policy/to-tf.d.ts +14 -2
- package/dist-sdk/src/entities/access-policy/to-tf.js +36 -6
- package/dist-sdk/src/entities/agent/build.d.ts +3 -3
- package/dist-sdk/src/entities/agent/build.js +5 -5
- package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.d.ts +6 -1
- package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +68 -18
- package/dist-sdk/src/entities/agent/from-tf.d.ts +3 -1
- package/dist-sdk/src/entities/agent/from-tf.js +12 -4
- package/dist-sdk/src/entities/agent/index.d.ts +2 -2
- package/dist-sdk/src/entities/agent/index.js +1 -1
- package/dist-sdk/src/entities/agent/module.js +2 -0
- package/dist-sdk/src/entities/agent/to-tf.d.ts +5 -2
- package/dist-sdk/src/entities/agent/to-tf.js +56 -8
- package/dist-sdk/src/entities/agent/tools.d.ts +38 -23
- package/dist-sdk/src/entities/agent/tools.js +21 -7
- package/dist-sdk/src/entities/agent-evaluation/build.d.ts +19 -0
- package/dist-sdk/src/entities/agent-evaluation/build.js +41 -0
- package/dist-sdk/src/entities/agent-evaluation/deserializer/print-agent-evaluation.d.ts +4 -0
- package/dist-sdk/src/entities/agent-evaluation/deserializer/print-agent-evaluation.js +30 -0
- package/dist-sdk/src/entities/agent-evaluation/from-tf.d.ts +12 -0
- package/dist-sdk/src/entities/agent-evaluation/from-tf.js +46 -0
- package/dist-sdk/src/entities/agent-evaluation/index.d.ts +1 -0
- package/dist-sdk/src/entities/agent-evaluation/index.js +1 -0
- package/dist-sdk/src/entities/agent-evaluation/module.d.ts +3 -0
- package/dist-sdk/src/entities/agent-evaluation/module.js +58 -0
- package/dist-sdk/src/entities/agent-evaluation/to-tf.d.ts +12 -0
- package/dist-sdk/src/entities/agent-evaluation/to-tf.js +35 -0
- package/dist-sdk/src/entities/agent-tool/from-tf.d.ts +8 -7
- package/dist-sdk/src/entities/agent-tool/from-tf.js +48 -6
- package/dist-sdk/src/entities/agent-tool/to-tf.d.ts +10 -2
- package/dist-sdk/src/entities/agent-tool/to-tf.js +76 -28
- package/dist-sdk/src/entities/agent-tool/types.d.ts +0 -1
- package/dist-sdk/src/entities/agent-tool/types.js +10 -37
- package/dist-sdk/src/entities/app/build.d.ts +97 -42
- package/dist-sdk/src/entities/app/build.js +25 -14
- package/dist-sdk/src/entities/app/deserializer/normalize.d.ts +32 -24
- package/dist-sdk/src/entities/app/deserializer/pulled-expression.d.ts +1 -1
- package/dist-sdk/src/entities/app/deserializer/pulled-expression.js +2 -0
- package/dist-sdk/src/entities/app/index.d.ts +11 -8
- package/dist-sdk/src/entities/app/index.js +10 -7
- package/dist-sdk/src/entities/app/module.js +2 -2
- package/dist-sdk/src/entities/app/to-tf.d.ts +1 -1
- package/dist-sdk/src/entities/app/to-tf.js +22 -6
- package/dist-sdk/src/entities/approval-chain/build.d.ts +1 -1
- package/dist-sdk/src/entities/approval-chain/build.js +5 -5
- package/dist-sdk/src/entities/approval-chain/index.d.ts +1 -1
- package/dist-sdk/src/entities/approval-chain/index.js +1 -1
- package/dist-sdk/src/entities/approval-chain/printer.js +2 -2
- package/dist-sdk/src/entities/automation/build.d.ts +172 -94
- package/dist-sdk/src/entities/automation/build.js +159 -68
- package/dist-sdk/src/entities/automation/calculation-expression.d.ts +191 -0
- package/dist-sdk/src/entities/automation/calculation-expression.js +57 -0
- package/dist-sdk/src/entities/automation/deserializer/ast.d.ts +11 -4
- package/dist-sdk/src/entities/automation/deserializer/print-automation.d.ts +18 -14
- package/dist-sdk/src/entities/automation/deserializer/print-automation.js +164 -198
- package/dist-sdk/src/entities/automation/from-tf.d.ts +26 -2
- package/dist-sdk/src/entities/automation/from-tf.js +510 -80
- package/dist-sdk/src/entities/automation/index.d.ts +9 -12
- package/dist-sdk/src/entities/automation/index.js +11 -13
- package/dist-sdk/src/entities/automation/module.js +74 -6
- package/dist-sdk/src/entities/automation/operators.d.ts +32 -48
- package/dist-sdk/src/entities/automation/operators.js +10 -37
- package/dist-sdk/src/entities/automation/output-key-wire-name.d.ts +1 -1
- package/dist-sdk/src/entities/automation/output-key-wire-name.js +1 -1
- package/dist-sdk/src/entities/automation/script-code.js +13 -22
- package/dist-sdk/src/entities/automation/serialize.js +1 -1
- package/dist-sdk/src/entities/automation/tasks.d.ts +153 -89
- package/dist-sdk/src/entities/automation/tasks.js +64 -11
- package/dist-sdk/src/entities/automation/to-tf.d.ts +10 -1
- package/dist-sdk/src/entities/automation/to-tf.js +342 -71
- package/dist-sdk/src/entities/automation/triggers.d.ts +17 -10
- package/dist-sdk/src/entities/automation/triggers.js +7 -1
- package/dist-sdk/src/entities/automation/types.d.ts +3 -2
- package/dist-sdk/src/entities/automation/types.js +3 -2
- package/dist-sdk/src/entities/chart/build.d.ts +95 -0
- package/dist-sdk/src/entities/chart/build.js +42 -0
- package/dist-sdk/src/entities/chart/from-tf.d.ts +55 -0
- package/dist-sdk/src/entities/chart/from-tf.js +269 -0
- package/dist-sdk/src/entities/chart/index.d.ts +4 -0
- package/dist-sdk/src/entities/chart/index.js +3 -0
- package/dist-sdk/src/entities/chart/module.d.ts +3 -0
- package/dist-sdk/src/entities/chart/module.js +61 -0
- package/dist-sdk/src/entities/chart/printer.d.ts +5 -0
- package/dist-sdk/src/entities/chart/printer.js +104 -0
- package/dist-sdk/src/entities/chart/to-tf.d.ts +15 -0
- package/dist-sdk/src/entities/chart/to-tf.js +150 -0
- package/dist-sdk/src/entities/chart/types.d.ts +53 -0
- package/dist-sdk/src/entities/chart/types.js +22 -0
- package/dist-sdk/src/entities/dashboard/build.d.ts +34 -7
- package/dist-sdk/src/entities/dashboard/build.js +16 -1
- package/dist-sdk/src/entities/dashboard/from-tf.js +22 -4
- package/dist-sdk/src/entities/dashboard/to-tf.d.ts +16 -3
- package/dist-sdk/src/entities/dashboard/to-tf.js +37 -10
- package/dist-sdk/src/entities/datamine/module.js +1 -1
- package/dist-sdk/src/entities/dynamic-layout/build.d.ts +4 -3
- package/dist-sdk/src/entities/dynamic-layout/build.js +1 -1
- package/dist-sdk/src/entities/dynamic-layout/dialect.d.ts +2 -0
- package/dist-sdk/src/entities/dynamic-layout/dialect.js +43 -5
- package/dist-sdk/src/entities/dynamic-layout/from-tf.js +12 -6
- package/dist-sdk/src/entities/dynamic-layout/to-tf.js +10 -10
- package/dist-sdk/src/entities/element/build.d.ts +25 -32
- package/dist-sdk/src/entities/element/build.js +15 -32
- package/dist-sdk/src/entities/element/index.d.ts +7 -5
- package/dist-sdk/src/entities/element/index.js +7 -4
- package/dist-sdk/src/entities/element/module.js +7 -3
- package/dist-sdk/src/entities/element/to-tf.d.ts +2 -1
- package/dist-sdk/src/entities/element/to-tf.js +7 -3
- package/dist-sdk/src/entities/field/build.d.ts +51 -24
- package/dist-sdk/src/entities/field/build.js +31 -6
- package/dist-sdk/src/entities/field/calc/aggregate.d.ts +52 -21
- package/dist-sdk/src/entities/field/calc/aggregate.js +59 -29
- package/dist-sdk/src/entities/field/calc/date.d.ts +78 -29
- package/dist-sdk/src/entities/field/calc/date.js +120 -29
- package/dist-sdk/src/entities/field/calc/index.d.ts +80 -85
- package/dist-sdk/src/entities/field/calc/index.js +82 -139
- package/dist-sdk/src/entities/field/calc/numeric.d.ts +8 -12
- package/dist-sdk/src/entities/field/calc/numeric.js +10 -27
- package/dist-sdk/src/entities/field/calc/runtime.d.ts +19 -2
- package/dist-sdk/src/entities/field/calc/runtime.js +79 -8
- package/dist-sdk/src/entities/field/calc/text.d.ts +32 -23
- package/dist-sdk/src/entities/field/calc/text.js +43 -31
- package/dist-sdk/src/entities/field/calc/types.d.ts +36 -81
- package/dist-sdk/src/entities/field/calc/types.js +1 -22
- package/dist-sdk/src/entities/field/calc.d.ts +71 -48
- package/dist-sdk/src/entities/field/calc.js +5 -15
- package/dist-sdk/src/entities/field/calculation-types.js +10 -3
- package/dist-sdk/src/entities/field/from-tf.js +156 -10
- package/dist-sdk/src/entities/field/locals.d.ts +11 -3
- package/dist-sdk/src/entities/field/locals.js +15 -2
- package/dist-sdk/src/entities/field/module.js +23 -6
- package/dist-sdk/src/entities/field/record-shape.d.ts +24 -10
- package/dist-sdk/src/entities/field/to-tf.d.ts +40 -1
- package/dist-sdk/src/entities/field/to-tf.js +293 -35
- package/dist-sdk/src/entities/field/types.d.ts +1 -1
- package/dist-sdk/src/entities/field/types.js +7 -1
- package/dist-sdk/src/entities/file-reader/build.d.ts +5 -0
- package/dist-sdk/src/entities/file-reader/deserializer/print-file-reader.js +1 -1
- package/dist-sdk/src/entities/org/cloud-link.js +4 -5
- package/dist-sdk/src/entities/org/email-alias.d.ts +2 -0
- package/dist-sdk/src/entities/org/email-alias.js +12 -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/phone-provider.js +4 -7
- package/dist-sdk/src/entities/organization/build.d.ts +214 -2
- package/dist-sdk/src/entities/organization/build.js +145 -4
- package/dist-sdk/src/entities/organization/index.d.ts +1 -1
- package/dist-sdk/src/entities/organization/index.js +1 -1
- package/dist-sdk/src/entities/organization/module.js +4 -1
- package/dist-sdk/src/entities/organization/to-tf.d.ts +1 -0
- package/dist-sdk/src/entities/organization/to-tf.js +118 -1
- package/dist-sdk/src/entities/phone-service/build.d.ts +1 -1
- package/dist-sdk/src/entities/phone-service/build.js +2 -2
- package/dist-sdk/src/entities/phone-service/deserializer/print-phone-service.js +5 -3
- package/dist-sdk/src/entities/phone-service/index.d.ts +1 -1
- package/dist-sdk/src/entities/phone-service/index.js +1 -1
- package/dist-sdk/src/entities/phone-service/types.js +1 -1
- package/dist-sdk/src/entities/record-create-form/to-tf.js +9 -1
- package/dist-sdk/src/entities/relationship/to-tf.d.ts +1 -0
- package/dist-sdk/src/entities/relationship/to-tf.js +5 -13
- package/dist-sdk/src/entities/search-table/build.d.ts +4 -4
- package/dist-sdk/src/entities/search-table/build.js +13 -13
- package/dist-sdk/src/entities/search-table/index.d.ts +2 -2
- package/dist-sdk/src/entities/search-table/index.js +2 -2
- package/dist-sdk/src/entities/search-table/printer.js +5 -5
- package/dist-sdk/src/entities/service-account/to-tf.d.ts +21 -0
- package/dist-sdk/src/entities/service-account/to-tf.js +32 -1
- package/dist-sdk/src/entities/shared/context.d.ts +25 -24
- package/dist-sdk/src/entities/shared/context.js +36 -35
- package/dist-sdk/src/entities/shared/filters/ast.d.ts +10 -3
- package/dist-sdk/src/entities/shared/filters/ast.js +1 -0
- package/dist-sdk/src/entities/shared/filters/index.d.ts +2 -1
- package/dist-sdk/src/entities/shared/filters/index.js +11 -4
- package/dist-sdk/src/entities/shared/foreign-ref.d.ts +14 -0
- package/dist-sdk/src/entities/shared/foreign-ref.js +12 -0
- package/dist-sdk/src/entities/shared/ref.d.ts +26 -11
- package/dist-sdk/src/entities/shared/ref.js +8 -3
- package/dist-sdk/src/entities/shared/types/common.d.ts +2 -2
- package/dist-sdk/src/entities/shared/types/field-types.d.ts +1 -1
- package/dist-sdk/src/entities/shared/types/field-types.js +1 -1
- package/dist-sdk/src/entities/skill/build.d.ts +2 -2
- package/dist-sdk/src/entities/skill/build.js +3 -3
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.d.ts +1 -1
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +26 -7
- package/dist-sdk/src/entities/skill/index.d.ts +1 -1
- package/dist-sdk/src/entities/skill/index.js +1 -1
- package/dist-sdk/src/entities/skill/module.js +2 -2
- package/dist-sdk/src/entities/skill/to-tf.d.ts +1 -1
- package/dist-sdk/src/entities/skill/to-tf.js +2 -2
- package/dist-sdk/src/entities/skill/tools.d.ts +4 -3
- package/dist-sdk/src/entities/skill/tools.js +4 -3
- package/dist-sdk/src/entities/skill-tool/from-tf.d.ts +13 -0
- package/dist-sdk/src/entities/skill-tool/from-tf.js +42 -0
- package/dist-sdk/src/entities/skill-tool/to-tf.js +6 -6
- package/dist-sdk/src/entities/table/build.d.ts +1 -1
- package/dist-sdk/src/entities/table/build.js +9 -9
- package/dist-sdk/src/entities/table/catalog-render.js +9 -1
- package/dist-sdk/src/entities/table/deserializer/normalize.js +4 -4
- package/dist-sdk/src/entities/table/fields/types.d.ts +1 -1
- package/dist-sdk/src/entities/table/fields/types.js +1 -1
- package/dist-sdk/src/entities/table/index.d.ts +2 -2
- package/dist-sdk/src/entities/table/index.js +3 -3
- package/dist-sdk/src/entities/table/module.js +1 -1
- package/dist-sdk/src/entities/table/to-tf.js +22 -30
- package/dist-sdk/src/entities/task/build.d.ts +1 -1
- package/dist-sdk/src/entities/task/build.js +5 -5
- package/dist-sdk/src/entities/task/index.d.ts +1 -1
- package/dist-sdk/src/entities/task/index.js +1 -1
- package/dist-sdk/src/entities/view/build.d.ts +46 -0
- package/dist-sdk/src/entities/view/build.js +19 -0
- package/dist-sdk/src/entities/view/from-tf.js +68 -18
- package/dist-sdk/src/entities/view/module.d.ts +6 -13
- package/dist-sdk/src/entities/view/module.js +7 -14
- package/dist-sdk/src/entities/view/sharing.d.ts +10 -0
- package/dist-sdk/src/entities/view/sharing.js +6 -0
- package/dist-sdk/src/entities/view/to-tf.d.ts +21 -19
- package/dist-sdk/src/entities/view/to-tf.js +61 -26
- package/dist-sdk/src/entities/view/types.js +3 -0
- package/dist-sdk/src/entities/visual-flow/build.d.ts +1 -1
- package/dist-sdk/src/entities/visual-flow/build.js +8 -8
- package/dist-sdk/src/entities/visual-flow/index.d.ts +1 -1
- package/dist-sdk/src/entities/visual-flow/index.js +1 -1
- package/dist-sdk/src/entities/visual-flow/module.js +1 -1
- package/dist-sdk/src/entities/visual-flow/printer.js +3 -3
- package/dist-sdk/src/entities/visual-flow/to-tf.d.ts +1 -0
- package/dist-sdk/src/entities/visual-flow/to-tf.js +3 -7
- package/dist-sdk/src/entities/widget/to-tf.d.ts +1 -0
- package/dist-sdk/src/entities/widget/to-tf.js +9 -7
- package/dist-sdk/src/graph/index.d.ts +5 -1
- package/dist-sdk/src/graph/index.js +4 -1
- package/dist-sdk/src/graph/modules.js +6 -1
- package/dist-sdk/src/graph/types.d.ts +52 -1
- package/dist-sdk/src/internal/safe-identifier.d.ts +4 -0
- package/dist-sdk/src/internal/safe-identifier.js +13 -0
- package/dist-sdk/src/internal/sdk-package.d.ts +1 -1
- package/dist-sdk/src/internal/sdk-package.js +1 -0
- package/package.json +12 -3
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { serializeValueOrRef } from "../../core/wire/ref-serializer.js";
|
|
2
|
+
import { isExpr } from "../field/calc/runtime.js";
|
|
3
|
+
import { renderCalculationExpression, } from "./calculation-expression.js";
|
|
2
4
|
import { extractScriptBody } from "./script-code.js";
|
|
3
5
|
function workflowFields(fields) {
|
|
4
6
|
return fields.map((f) => {
|
|
@@ -191,15 +193,15 @@ function outputSchema(outputs) {
|
|
|
191
193
|
return { object: { properties } };
|
|
192
194
|
}
|
|
193
195
|
/**
|
|
194
|
-
* Build the executeScript `
|
|
196
|
+
* Build the executeScript `ActionDef` from an ALREADY-RESOLVED body string.
|
|
195
197
|
* Shared by the public `executeScript()` factory below (which resolves the
|
|
196
198
|
* body via `extractScriptBody`'s `toString()` path) and the fluent
|
|
197
|
-
* `
|
|
199
|
+
* `ActionBuilder.executeScript()` in `build.ts` (which resolves it via
|
|
198
200
|
* `tryExtractFromCurrentSource` first, for byte-exact pulled-source fidelity,
|
|
199
201
|
* falling back to `extractScriptBody` only when there's no tracked source) —
|
|
200
202
|
* so the body is computed exactly once, not re-derived by each layer.
|
|
201
203
|
*/
|
|
202
|
-
export function
|
|
204
|
+
export function executeScriptActionDefWithBody(body, opts) {
|
|
203
205
|
const inputs = Object.entries(opts.inputs ?? {}).map(([name, value]) => ({
|
|
204
206
|
name,
|
|
205
207
|
value: serializeValueOrRef(value),
|
|
@@ -214,7 +216,7 @@ export function executeScriptTaskDefWithBody(body, opts) {
|
|
|
214
216
|
};
|
|
215
217
|
}
|
|
216
218
|
export function executeScript(opts) {
|
|
217
|
-
return
|
|
219
|
+
return executeScriptActionDefWithBody(extractScriptBody(opts.code), opts);
|
|
218
220
|
}
|
|
219
221
|
function apiRequestHeaders(headers) {
|
|
220
222
|
return (headers ?? []).map((h) => ({ name: h.name, value: serializeValueOrRef(h.value) }));
|
|
@@ -406,7 +408,7 @@ export function notification(opts) {
|
|
|
406
408
|
},
|
|
407
409
|
};
|
|
408
410
|
}
|
|
409
|
-
export function
|
|
411
|
+
export function filterAction(opts) {
|
|
410
412
|
return { key: "filter", config: { filter: opts.condition } };
|
|
411
413
|
}
|
|
412
414
|
export function assignUser(opts) {
|
|
@@ -543,11 +545,44 @@ function calculationTemplateParameters(parameters) {
|
|
|
543
545
|
}
|
|
544
546
|
: p);
|
|
545
547
|
}
|
|
548
|
+
function calculationIncludeTypes(include) {
|
|
549
|
+
if (include === undefined || include === "auto")
|
|
550
|
+
return [];
|
|
551
|
+
if (include === "manual")
|
|
552
|
+
return [{ manual: { type: "MANUAL" } }];
|
|
553
|
+
if (include === "both")
|
|
554
|
+
return [{ auto: { type: "AUTO" } }, { manual: { type: "MANUAL" } }];
|
|
555
|
+
return [{ picklist: { type: "PICKLIST", picklistFieldId: include.picklist } }];
|
|
556
|
+
}
|
|
557
|
+
function normalizeCalculationOptions(opts) {
|
|
558
|
+
if ("values" in opts) {
|
|
559
|
+
return Object.entries(opts.values).map(([name, value]) => {
|
|
560
|
+
const advanced = typeof value === "object" && value !== null && "expression" in value;
|
|
561
|
+
return {
|
|
562
|
+
...(advanced && value.id !== undefined ? { id: value.id } : {}),
|
|
563
|
+
name,
|
|
564
|
+
expression: advanced ? value.expression : value,
|
|
565
|
+
...(advanced && value.record !== undefined
|
|
566
|
+
? { record: value.record }
|
|
567
|
+
: opts.record !== undefined ? { record: opts.record } : {}),
|
|
568
|
+
...(advanced && value.include !== undefined
|
|
569
|
+
? { include: value.include }
|
|
570
|
+
: opts.include !== undefined ? { include: opts.include } : {}),
|
|
571
|
+
};
|
|
572
|
+
});
|
|
573
|
+
}
|
|
574
|
+
return opts.calculations.map((entry) => ({
|
|
575
|
+
...entry,
|
|
576
|
+
...(entry.record === undefined && opts.record !== undefined ? { record: opts.record } : {}),
|
|
577
|
+
...(entry.include === undefined && opts.include !== undefined ? { include: opts.include } : {}),
|
|
578
|
+
}));
|
|
579
|
+
}
|
|
546
580
|
export function calculation(opts) {
|
|
547
|
-
|
|
548
|
-
|
|
581
|
+
const entries = normalizeCalculationOptions(opts);
|
|
582
|
+
if (entries.length === 0)
|
|
583
|
+
throw new Error("calculation requires at least one value.");
|
|
549
584
|
const names = new Set();
|
|
550
|
-
for (const c of
|
|
585
|
+
for (const c of entries) {
|
|
551
586
|
if (names.has(c.name))
|
|
552
587
|
throw new Error(`calculation entry names must be unique — duplicate "${c.name}".`);
|
|
553
588
|
names.add(c.name);
|
|
@@ -563,8 +598,26 @@ export function calculation(opts) {
|
|
|
563
598
|
// actually accepts. `id` is server-assigned and simply omitted from the
|
|
564
599
|
// entry when authoring new (mirrors {@link VariableDecl.id}).
|
|
565
600
|
const calculations = [];
|
|
566
|
-
for (const c of
|
|
567
|
-
const rawCalculationReference =
|
|
601
|
+
for (const c of entries) {
|
|
602
|
+
const rawCalculationReference = isExpr(c.expression)
|
|
603
|
+
? (() => {
|
|
604
|
+
const rendered = renderCalculationExpression(c.expression);
|
|
605
|
+
if (rendered.parameters.length === 0) {
|
|
606
|
+
return serializeValueOrRef(rendered.text);
|
|
607
|
+
}
|
|
608
|
+
return {
|
|
609
|
+
templateReference: {
|
|
610
|
+
template: rendered.text,
|
|
611
|
+
parameters: rendered.parameters.map((parameter) => ({
|
|
612
|
+
value: {
|
|
613
|
+
name: parameter.name,
|
|
614
|
+
value: serializeValueOrRef(parameter.value),
|
|
615
|
+
},
|
|
616
|
+
})),
|
|
617
|
+
},
|
|
618
|
+
};
|
|
619
|
+
})()
|
|
620
|
+
: serializeValueOrRef(c.expression);
|
|
568
621
|
// The calc engine always expects `calculationReference` to be a
|
|
569
622
|
// `templateReference`, even for one trivial reference — confirmed via a
|
|
570
623
|
// live GET dump and the CALCULATION test fixture, both of which show a
|
|
@@ -598,7 +651,7 @@ export function calculation(opts) {
|
|
|
598
651
|
name: c.name,
|
|
599
652
|
recordId: c.record !== undefined ? serializeValueOrRef(c.record) : null,
|
|
600
653
|
calculationReference: wireCalculationReference,
|
|
601
|
-
includeTypes:
|
|
654
|
+
includeTypes: calculationIncludeTypes(c.include),
|
|
602
655
|
});
|
|
603
656
|
}
|
|
604
657
|
return {
|
|
@@ -4,11 +4,20 @@ import { type OrgRefLookup, type WorkspaceAspect } from "../../engine/build/cont
|
|
|
4
4
|
import type { BuildFieldMetadata } from "../../graph/types.js";
|
|
5
5
|
import type { AppServiceAccount } from "../service-account/build.js";
|
|
6
6
|
export interface AutomationToTfContext {
|
|
7
|
+
/** The owning app or element's refName. */
|
|
7
8
|
readonly appRefName?: string;
|
|
9
|
+
/** The product owner kind; defaults to app for direct legacy callers. */
|
|
10
|
+
readonly parentScope?: "app" | "element";
|
|
8
11
|
readonly appTfLabel: string;
|
|
9
12
|
readonly fieldAddresses?: ReadonlyMap<string, string>;
|
|
10
13
|
readonly fieldNames?: ReadonlyMap<string, string>;
|
|
11
14
|
readonly fieldMetadata?: ReadonlyMap<string, BuildFieldMetadata>;
|
|
15
|
+
/**
|
|
16
|
+
* Field display-name maps for every app/element in this build, keyed by
|
|
17
|
+
* stream-root refName. Lets a task whose `.record`/`.records` output is
|
|
18
|
+
* typed against a DIFFERENT aspect resolve cross-app refs (#490).
|
|
19
|
+
*/
|
|
20
|
+
readonly fieldNamesByAppRefName?: ReadonlyMap<string, ReadonlyMap<string, string>>;
|
|
12
21
|
readonly orgRefs?: OrgRefLookup;
|
|
13
22
|
readonly diagnostics?: string[];
|
|
14
23
|
readonly serviceAccounts?: Readonly<Record<string, AppServiceAccount>>;
|
|
@@ -47,5 +56,5 @@ export interface AutomationToTfResult {
|
|
|
47
56
|
readonly blocks: readonly TfBlock[];
|
|
48
57
|
readonly address: string;
|
|
49
58
|
}
|
|
50
|
-
/** App-owned `
|
|
59
|
+
/** App- or element-owned `automation` entity → provider HCL blocks. */
|
|
51
60
|
export declare function automationToTf(entity: DeployableEntity, ctx: AutomationToTfContext): AutomationToTfResult;
|