@elementumai/edk 0.8.2-alpha.6 → 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 +49 -37
- package/dist-sdk/elementum-entity-client/clients/agents/models/agent-tool.d.ts +3 -3
- package/dist-sdk/elementum-entity-client/clients/aspects/models/index.d.ts +1 -1
- package/dist-sdk/elementum-entity-client/clients/aspects/models/picklist-config.d.ts +3 -11
- package/dist-sdk/elementum-entity-client/clients/automation/models/automation.d.ts +3 -11
- package/dist-sdk/elementum-entity-client/clients/skills/models/skill-tool.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/fs/entity.d.ts +2 -2
- package/dist-sdk/fs/entity.js +1 -1
- package/dist-sdk/pull/missing-report.d.ts +81 -0
- package/dist-sdk/pull/missing-report.js +52 -0
- 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 +96 -23
- package/dist-sdk/src/catalog/factories.js +141 -21
- package/dist-sdk/src/catalog/from-authoring.d.ts +5 -5
- package/dist-sdk/src/catalog/from-authoring.js +20 -10
- 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 +63 -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 +8 -2
- package/dist-sdk/src/catalog/token.js +18 -4
- package/dist-sdk/src/catalog/types.d.ts +64 -24
- package/dist-sdk/src/catalog/types.js +12 -4
- package/dist-sdk/src/core/app-to-ui.d.ts +6 -6
- package/dist-sdk/src/core/app-to-ui.js +7 -9
- package/dist-sdk/src/core/index.d.ts +11 -10
- package/dist-sdk/src/core/index.js +10 -9
- package/dist-sdk/src/core/platform-id.d.ts +11 -0
- package/dist-sdk/src/core/platform-id.js +8 -0
- package/dist-sdk/src/{entities/flow/activities/render-catalog.d.ts → core/render-tree.d.ts} +3 -3
- package/dist-sdk/src/{entities/flow/activities/render-catalog.js → core/render-tree.js} +7 -10
- 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 +78 -52
- package/dist-sdk/src/core/types/app.js +2 -3
- 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 +23 -16
- package/dist-sdk/src/engine/entity.d.ts +1 -1
- package/dist-sdk/src/engine/pull/attrs.d.ts +4 -0
- package/dist-sdk/src/engine/pull/attrs.js +17 -0
- package/dist-sdk/src/engine/pull/context.d.ts +73 -0
- package/dist-sdk/src/engine/pull/context.js +14 -0
- package/dist-sdk/src/engine/pull/org.d.ts +10 -0
- package/dist-sdk/src/engine/pull/org.js +35 -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 +7 -3
- package/dist-sdk/src/engine/tf/expr.js +27 -15
- 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/engine/workspace/authoring-layout.js +4 -2
- package/dist-sdk/src/entities/access-policy/build.d.ts +6 -16
- package/dist-sdk/src/entities/access-policy/build.js +2 -2
- package/dist-sdk/src/entities/access-policy/from-tf.d.ts +14 -40
- package/dist-sdk/src/entities/access-policy/from-tf.js +26 -85
- package/dist-sdk/src/entities/access-policy/principal.d.ts +39 -0
- package/dist-sdk/src/entities/access-policy/principal.js +13 -0
- package/dist-sdk/src/entities/access-policy/to-tf.d.ts +33 -6
- package/dist-sdk/src/entities/access-policy/to-tf.js +62 -60
- package/dist-sdk/src/entities/agent/build.d.ts +42 -11
- package/dist-sdk/src/entities/agent/build.js +40 -19
- package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.d.ts +11 -1
- package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +180 -45
- package/dist-sdk/src/entities/agent/from-tf.d.ts +3 -1
- package/dist-sdk/src/entities/agent/from-tf.js +17 -12
- package/dist-sdk/src/entities/agent/index.d.ts +5 -2
- package/dist-sdk/src/entities/agent/index.js +4 -2
- package/dist-sdk/src/entities/agent/module.js +7 -2
- package/dist-sdk/src/entities/agent/run-as.d.ts +16 -0
- package/dist-sdk/src/entities/agent/run-as.js +1 -0
- package/dist-sdk/src/entities/agent/to-tf.d.ts +6 -2
- package/dist-sdk/src/entities/agent/to-tf.js +58 -9
- package/dist-sdk/src/entities/agent/tools.d.ts +97 -70
- package/dist-sdk/src/entities/agent/tools.js +63 -43
- package/dist-sdk/src/entities/agent-a2a-skill/from-tf.js +1 -1
- package/dist-sdk/src/entities/agent-a2a-skill/to-tf.js +4 -4
- 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 +25 -15
- package/dist-sdk/src/entities/agent-tool/from-tf.js +175 -43
- package/dist-sdk/src/entities/agent-tool/module.js +6 -0
- package/dist-sdk/src/entities/agent-tool/to-tf.d.ts +15 -7
- package/dist-sdk/src/entities/agent-tool/to-tf.js +169 -48
- package/dist-sdk/src/entities/agent-tool/types.d.ts +4 -6
- package/dist-sdk/src/entities/agent-tool/types.js +30 -29
- package/dist-sdk/src/entities/app/build.d.ts +214 -47
- package/dist-sdk/src/entities/app/build.js +128 -66
- package/dist-sdk/src/entities/app/deserializer/normalize.d.ts +188 -8
- package/dist-sdk/src/entities/app/deserializer/pulled-expression.d.ts +59 -0
- package/dist-sdk/src/entities/app/deserializer/pulled-expression.js +70 -0
- package/dist-sdk/src/entities/app/display-blocks.d.ts +2 -1
- package/dist-sdk/src/entities/app/display-blocks.js +1 -1
- package/dist-sdk/src/entities/app/from-tf.d.ts +11 -1
- package/dist-sdk/src/entities/app/from-tf.js +30 -2
- package/dist-sdk/src/entities/app/index.d.ts +20 -8
- package/dist-sdk/src/entities/app/index.js +16 -6
- package/dist-sdk/src/entities/app/module.js +29 -4
- package/dist-sdk/src/entities/app/to-tf.d.ts +1 -1
- package/dist-sdk/src/entities/app/to-tf.js +97 -7
- package/dist-sdk/src/entities/approval-chain/build.d.ts +31 -16
- package/dist-sdk/src/entities/approval-chain/build.js +49 -49
- package/dist-sdk/src/entities/approval-chain/from-tf.d.ts +17 -0
- package/dist-sdk/src/entities/approval-chain/from-tf.js +57 -0
- package/dist-sdk/src/entities/approval-chain/index.d.ts +2 -3
- package/dist-sdk/src/entities/approval-chain/index.js +2 -3
- package/dist-sdk/src/entities/approval-chain/module.d.ts +3 -0
- package/dist-sdk/src/entities/approval-chain/module.js +51 -0
- package/dist-sdk/src/entities/approval-chain/printer.d.ts +2 -0
- package/dist-sdk/src/entities/approval-chain/printer.js +21 -0
- package/dist-sdk/src/entities/approval-chain/to-tf.d.ts +9 -0
- package/dist-sdk/src/entities/approval-chain/to-tf.js +43 -0
- package/dist-sdk/src/entities/automation/build.d.ts +177 -95
- package/dist-sdk/src/entities/automation/build.js +164 -72
- 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 +18 -9
- package/dist-sdk/src/entities/automation/deserializer/print-automation.d.ts +18 -14
- package/dist-sdk/src/entities/automation/deserializer/print-automation.js +214 -311
- package/dist-sdk/src/entities/automation/filter.d.ts +1 -115
- package/dist-sdk/src/entities/automation/filter.js +1 -197
- package/dist-sdk/src/entities/automation/from-tf.d.ts +28 -0
- package/dist-sdk/src/entities/automation/from-tf.js +695 -182
- package/dist-sdk/src/entities/automation/index.d.ts +9 -10
- package/dist-sdk/src/entities/automation/index.js +11 -11
- package/dist-sdk/src/entities/automation/module.js +82 -8
- 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 +107 -28
- package/dist-sdk/src/entities/automation/serialize.js +1 -1
- package/dist-sdk/src/entities/automation/tasks.d.ts +167 -102
- package/dist-sdk/src/entities/automation/tasks.js +66 -13
- package/dist-sdk/src/entities/automation/to-tf.d.ts +44 -3
- package/dist-sdk/src/entities/automation/to-tf.js +607 -161
- package/dist-sdk/src/entities/automation/triggers.d.ts +33 -25
- package/dist-sdk/src/entities/automation/triggers.js +8 -2
- 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 +44 -0
- package/dist-sdk/src/entities/dashboard/build.js +16 -0
- package/dist-sdk/src/entities/dashboard/from-tf.d.ts +12 -0
- package/dist-sdk/src/entities/dashboard/from-tf.js +113 -0
- package/dist-sdk/src/entities/dashboard/module.d.ts +3 -0
- package/dist-sdk/src/entities/dashboard/module.js +16 -0
- package/dist-sdk/src/entities/dashboard/to-tf.d.ts +43 -0
- package/dist-sdk/src/entities/dashboard/to-tf.js +121 -0
- package/dist-sdk/src/entities/dashboard-widget/module.d.ts +3 -0
- package/dist-sdk/src/entities/dashboard-widget/module.js +10 -0
- package/dist-sdk/src/entities/data-lookup/module.d.ts +3 -0
- package/dist-sdk/src/entities/data-lookup/module.js +22 -0
- package/dist-sdk/src/entities/datamine/build.d.ts +22 -0
- package/dist-sdk/src/entities/datamine/from-tf.d.ts +17 -0
- package/dist-sdk/src/entities/datamine/from-tf.js +98 -0
- package/dist-sdk/src/entities/datamine/module.d.ts +3 -0
- package/dist-sdk/src/entities/datamine/module.js +23 -0
- package/dist-sdk/src/entities/datamine/to-tf.d.ts +11 -0
- package/dist-sdk/src/entities/datamine/to-tf.js +53 -0
- package/dist-sdk/src/entities/dynamic-layout/build.d.ts +304 -0
- package/dist-sdk/src/entities/dynamic-layout/build.js +4 -0
- package/dist-sdk/src/entities/dynamic-layout/dialect.d.ts +4 -0
- package/dist-sdk/src/entities/dynamic-layout/dialect.js +47 -0
- package/dist-sdk/src/entities/dynamic-layout/from-tf.d.ts +10 -0
- package/dist-sdk/src/entities/dynamic-layout/from-tf.js +239 -0
- package/dist-sdk/src/entities/dynamic-layout/module.d.ts +3 -0
- package/dist-sdk/src/entities/dynamic-layout/module.js +13 -0
- package/dist-sdk/src/entities/dynamic-layout/to-tf.d.ts +26 -0
- package/dist-sdk/src/entities/dynamic-layout/to-tf.js +267 -0
- package/dist-sdk/src/entities/element/build.d.ts +48 -38
- package/dist-sdk/src/entities/element/build.js +24 -33
- package/dist-sdk/src/entities/element/from-tf.d.ts +9 -1
- package/dist-sdk/src/entities/element/from-tf.js +31 -2
- package/dist-sdk/src/entities/element/index.d.ts +14 -7
- package/dist-sdk/src/entities/element/index.js +11 -5
- package/dist-sdk/src/entities/element/module.js +26 -5
- package/dist-sdk/src/entities/element/to-tf.d.ts +2 -1
- package/dist-sdk/src/entities/element/to-tf.js +64 -4
- package/dist-sdk/src/entities/field/build.d.ts +55 -27
- 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.d.ts +6 -0
- package/dist-sdk/src/entities/field/calculation-types.js +49 -0
- package/dist-sdk/src/entities/field/from-tf.js +238 -13
- 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.d.ts +1 -0
- package/dist-sdk/src/entities/field/module.js +27 -7
- package/dist-sdk/src/entities/field/record-shape.d.ts +25 -11
- package/dist-sdk/src/entities/field/to-tf.d.ts +41 -2
- package/dist-sdk/src/entities/field/to-tf.js +314 -40
- package/dist-sdk/src/entities/field/types.d.ts +1 -1
- package/dist-sdk/src/entities/field/types.js +10 -1
- package/dist-sdk/src/entities/file-reader/build.d.ts +71 -19
- package/dist-sdk/src/entities/file-reader/build.js +49 -4
- package/dist-sdk/src/entities/file-reader/deserializer/print-file-reader.d.ts +1 -0
- package/dist-sdk/src/entities/file-reader/deserializer/print-file-reader.js +12 -10
- package/dist-sdk/src/entities/file-reader/from-tf.d.ts +1 -1
- package/dist-sdk/src/entities/file-reader/from-tf.js +31 -2
- package/dist-sdk/src/entities/file-reader/index.d.ts +3 -3
- package/dist-sdk/src/entities/file-reader/index.js +3 -3
- package/dist-sdk/src/entities/file-reader/module.js +6 -5
- package/dist-sdk/src/entities/file-reader/to-tf.d.ts +1 -1
- package/dist-sdk/src/entities/file-reader/to-tf.js +5 -2
- package/dist-sdk/src/entities/file-reader/types.d.ts +3 -4
- package/dist-sdk/src/entities/file-reader/types.js +4 -5
- package/dist-sdk/src/entities/org/category.js +4 -5
- 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/group.js +4 -5
- package/dist-sdk/src/entities/org/index.d.ts +2 -0
- package/dist-sdk/src/entities/org/index.js +2 -0
- package/dist-sdk/src/entities/org/phone-provider.d.ts +4 -0
- package/dist-sdk/src/entities/org/phone-provider.js +30 -0
- package/dist-sdk/src/entities/org/role.d.ts +3 -3
- package/dist-sdk/src/entities/org/role.js +9 -6
- package/dist-sdk/src/entities/organization/build.d.ts +241 -0
- package/dist-sdk/src/entities/organization/build.js +165 -0
- package/dist-sdk/src/entities/organization/index.d.ts +2 -0
- package/dist-sdk/src/entities/organization/index.js +2 -0
- package/dist-sdk/src/entities/organization/module.d.ts +2 -0
- package/dist-sdk/src/entities/organization/module.js +21 -0
- package/dist-sdk/src/entities/organization/to-tf.d.ts +7 -0
- package/dist-sdk/src/entities/organization/to-tf.js +154 -0
- package/dist-sdk/src/entities/phone-service/build.d.ts +17 -0
- package/dist-sdk/src/entities/phone-service/build.js +31 -0
- package/dist-sdk/src/entities/phone-service/deserializer/print-phone-service.d.ts +4 -0
- package/dist-sdk/src/entities/phone-service/deserializer/print-phone-service.js +56 -0
- package/dist-sdk/src/entities/phone-service/from-tf.d.ts +25 -0
- package/dist-sdk/src/entities/phone-service/from-tf.js +75 -0
- package/dist-sdk/src/entities/phone-service/index.d.ts +2 -0
- package/dist-sdk/src/entities/phone-service/index.js +2 -0
- package/dist-sdk/src/entities/phone-service/module.d.ts +3 -0
- package/dist-sdk/src/entities/phone-service/module.js +55 -0
- package/dist-sdk/src/entities/phone-service/to-tf.d.ts +12 -0
- package/dist-sdk/src/entities/phone-service/to-tf.js +54 -0
- package/dist-sdk/src/entities/phone-service/types.d.ts +35 -0
- package/dist-sdk/src/entities/phone-service/types.js +22 -0
- package/dist-sdk/src/entities/record-create-form/from-tf.d.ts +11 -0
- package/dist-sdk/src/entities/record-create-form/from-tf.js +74 -0
- package/dist-sdk/src/entities/record-create-form/module.d.ts +11 -0
- package/dist-sdk/src/entities/record-create-form/module.js +24 -0
- package/dist-sdk/src/entities/record-create-form/to-tf.d.ts +33 -0
- package/dist-sdk/src/entities/record-create-form/to-tf.js +88 -0
- package/dist-sdk/src/entities/relationship/build.d.ts +16 -0
- package/dist-sdk/src/entities/relationship/build.js +1 -0
- package/dist-sdk/src/entities/relationship/from-tf.d.ts +12 -0
- package/dist-sdk/src/entities/relationship/from-tf.js +109 -0
- package/dist-sdk/src/entities/relationship/module.d.ts +3 -0
- package/dist-sdk/src/entities/relationship/module.js +16 -0
- package/dist-sdk/src/entities/relationship/to-tf.d.ts +32 -0
- package/dist-sdk/src/entities/relationship/to-tf.js +145 -0
- package/dist-sdk/src/entities/role/build.d.ts +65 -0
- package/dist-sdk/src/entities/role/build.js +33 -0
- package/dist-sdk/src/entities/role/from-tf.d.ts +13 -0
- package/dist-sdk/src/entities/role/from-tf.js +138 -0
- package/dist-sdk/src/entities/role/to-tf.d.ts +13 -0
- package/dist-sdk/src/entities/role/to-tf.js +69 -0
- package/dist-sdk/src/entities/search-table/build.d.ts +67 -28
- package/dist-sdk/src/entities/search-table/build.js +110 -56
- package/dist-sdk/src/entities/search-table/from-tf.d.ts +37 -0
- package/dist-sdk/src/entities/search-table/from-tf.js +113 -0
- 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/module.js +88 -10
- package/dist-sdk/src/entities/search-table/printer.d.ts +2 -0
- package/dist-sdk/src/entities/search-table/printer.js +52 -0
- package/dist-sdk/src/entities/search-table/to-tf.d.ts +14 -0
- package/dist-sdk/src/entities/search-table/to-tf.js +104 -0
- package/dist-sdk/src/entities/search-table/types.d.ts +8 -0
- package/dist-sdk/src/entities/search-table/types.js +21 -0
- package/dist-sdk/src/entities/service-account/build.d.ts +32 -0
- package/dist-sdk/src/entities/service-account/build.js +9 -0
- package/dist-sdk/src/entities/service-account/from-tf.d.ts +10 -0
- package/dist-sdk/src/entities/service-account/from-tf.js +109 -0
- package/dist-sdk/src/entities/service-account/module.d.ts +4 -0
- package/dist-sdk/src/entities/service-account/module.js +21 -0
- package/dist-sdk/src/entities/service-account/ref.d.ts +11 -0
- package/dist-sdk/src/entities/service-account/ref.js +5 -0
- package/dist-sdk/src/entities/service-account/to-tf.d.ts +32 -0
- package/dist-sdk/src/entities/service-account/to-tf.js +103 -0
- package/dist-sdk/src/entities/shared/connector-from-tf.d.ts +14 -0
- package/dist-sdk/src/entities/shared/connector-from-tf.js +14 -0
- 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 +30 -81
- package/dist-sdk/src/entities/shared/filters/ast.js +6 -2
- package/dist-sdk/src/entities/shared/filters/index.d.ts +95 -206
- package/dist-sdk/src/entities/shared/filters/index.js +196 -341
- package/dist-sdk/src/entities/shared/filters/print.d.ts +11 -0
- package/dist-sdk/src/entities/shared/filters/print.js +122 -0
- package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +170 -0
- package/dist-sdk/src/entities/shared/filters/tf-codec.js +527 -0
- package/dist-sdk/src/entities/shared/filters/types.d.ts +66 -69
- package/dist-sdk/src/entities/shared/filters/types.js +2 -3
- 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 +4 -4
- package/dist-sdk/src/entities/skill/build.js +6 -5
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.d.ts +11 -1
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +100 -39
- package/dist-sdk/src/entities/skill/index.d.ts +3 -2
- package/dist-sdk/src/entities/skill/index.js +3 -2
- package/dist-sdk/src/entities/skill/module.js +8 -2
- package/dist-sdk/src/entities/skill/to-tf.d.ts +6 -2
- package/dist-sdk/src/entities/skill/to-tf.js +20 -2
- package/dist-sdk/src/entities/skill/tools.d.ts +47 -31
- package/dist-sdk/src/entities/skill/tools.js +37 -23
- package/dist-sdk/src/entities/skill-tool/from-tf.d.ts +17 -1
- package/dist-sdk/src/entities/skill-tool/from-tf.js +118 -8
- package/dist-sdk/src/entities/skill-tool/module.js +9 -0
- package/dist-sdk/src/entities/skill-tool/to-tf.d.ts +6 -1
- package/dist-sdk/src/entities/skill-tool/to-tf.js +100 -48
- package/dist-sdk/src/entities/skill-tool/types.js +18 -1
- package/dist-sdk/src/entities/table/build.d.ts +64 -23
- package/dist-sdk/src/entities/table/build.js +41 -26
- package/dist-sdk/src/entities/table/catalog-render.js +15 -1
- package/dist-sdk/src/entities/table/deserializer/normalize.d.ts +99 -0
- package/dist-sdk/src/entities/table/deserializer/normalize.js +192 -0
- package/dist-sdk/src/entities/table/fields/types.d.ts +86 -0
- package/dist-sdk/src/entities/table/fields/types.js +12 -0
- package/dist-sdk/src/entities/table/fields.d.ts +107 -47
- package/dist-sdk/src/entities/table/fields.js +76 -55
- package/dist-sdk/src/entities/table/from-tf.d.ts +4 -0
- package/dist-sdk/src/entities/table/from-tf.js +261 -0
- package/dist-sdk/src/entities/table/index.d.ts +7 -5
- package/dist-sdk/src/entities/table/index.js +7 -7
- package/dist-sdk/src/entities/table/joins.d.ts +22 -9
- package/dist-sdk/src/entities/table/joins.js +8 -16
- package/dist-sdk/src/entities/table/module.d.ts +2 -1
- package/dist-sdk/src/entities/table/module.js +13 -6
- package/dist-sdk/src/entities/table/to-tf.d.ts +10 -0
- package/dist-sdk/src/entities/table/to-tf.js +222 -0
- package/dist-sdk/src/entities/task/build.d.ts +43 -0
- package/dist-sdk/src/entities/task/build.js +17 -0
- package/dist-sdk/src/entities/task/from-tf.d.ts +28 -0
- package/dist-sdk/src/entities/task/from-tf.js +38 -0
- package/dist-sdk/src/entities/task/index.d.ts +1 -0
- package/dist-sdk/src/entities/task/index.js +1 -0
- package/dist-sdk/src/entities/task/module.d.ts +3 -0
- package/dist-sdk/src/entities/task/module.js +12 -0
- package/dist-sdk/src/entities/task/to-tf.d.ts +9 -0
- package/dist-sdk/src/entities/task/to-tf.js +49 -0
- 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.d.ts +7 -2
- package/dist-sdk/src/entities/view/from-tf.js +264 -30
- package/dist-sdk/src/entities/view/module.d.ts +6 -13
- package/dist-sdk/src/entities/view/module.js +12 -15
- 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 +56 -12
- package/dist-sdk/src/entities/view/to-tf.js +192 -20
- package/dist-sdk/src/entities/view/types.d.ts +8 -0
- package/dist-sdk/src/entities/view/types.js +46 -0
- package/dist-sdk/src/entities/visual-flow/build.d.ts +87 -0
- package/dist-sdk/src/entities/visual-flow/build.js +72 -0
- package/dist-sdk/src/entities/visual-flow/from-tf.d.ts +49 -0
- package/dist-sdk/src/entities/visual-flow/from-tf.js +124 -0
- package/dist-sdk/src/entities/visual-flow/index.d.ts +1 -0
- package/dist-sdk/src/entities/visual-flow/index.js +1 -0
- package/dist-sdk/src/entities/visual-flow/module.d.ts +3 -0
- package/dist-sdk/src/entities/visual-flow/module.js +41 -0
- package/dist-sdk/src/entities/visual-flow/printer.d.ts +8 -0
- package/dist-sdk/src/entities/visual-flow/printer.js +92 -0
- package/dist-sdk/src/entities/visual-flow/to-tf.d.ts +15 -0
- package/dist-sdk/src/entities/visual-flow/to-tf.js +97 -0
- package/dist-sdk/src/entities/widget/build.d.ts +55 -0
- package/dist-sdk/src/entities/widget/build.js +1 -0
- package/dist-sdk/src/entities/widget/from-tf.d.ts +11 -0
- package/dist-sdk/src/entities/widget/from-tf.js +209 -0
- package/dist-sdk/src/entities/widget/module.d.ts +3 -0
- package/dist-sdk/src/entities/widget/module.js +16 -0
- package/dist-sdk/src/entities/widget/to-tf.d.ts +45 -0
- package/dist-sdk/src/entities/widget/to-tf.js +206 -0
- package/dist-sdk/src/graph/deferred-catalog-render.d.ts +1 -1
- package/dist-sdk/src/graph/deferred-catalog-render.js +1 -1
- package/dist-sdk/src/graph/index.d.ts +12 -1
- package/dist-sdk/src/graph/index.js +8 -19
- package/dist-sdk/src/graph/modules.js +35 -1
- package/dist-sdk/src/graph/types.d.ts +106 -7
- 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 +5 -2
- package/package.json +39 -15
- package/dist-sdk/src/entities/access-policy/filter.d.ts +0 -61
- package/dist-sdk/src/entities/access-policy/filter.js +0 -83
- package/dist-sdk/src/entities/approval-chain/steps.d.ts +0 -24
- package/dist-sdk/src/entities/approval-chain/steps.js +0 -20
- package/dist-sdk/src/entities/flow/activities/agent.d.ts +0 -15
- package/dist-sdk/src/entities/flow/activities/agent.js +0 -29
- package/dist-sdk/src/entities/flow/activities/approval.d.ts +0 -9
- package/dist-sdk/src/entities/flow/activities/approval.js +0 -18
- package/dist-sdk/src/entities/flow/activities/automation.d.ts +0 -12
- package/dist-sdk/src/entities/flow/activities/automation.js +0 -22
- package/dist-sdk/src/entities/flow/activities/ctx.d.ts +0 -34
- package/dist-sdk/src/entities/flow/activities/ctx.js +0 -38
- package/dist-sdk/src/entities/flow/activities/form.d.ts +0 -22
- package/dist-sdk/src/entities/flow/activities/form.js +0 -36
- package/dist-sdk/src/entities/flow/activities/index.d.ts +0 -14
- package/dist-sdk/src/entities/flow/activities/index.js +0 -13
- package/dist-sdk/src/entities/flow/activities/input-refs.d.ts +0 -39
- package/dist-sdk/src/entities/flow/activities/input-refs.js +0 -19
- package/dist-sdk/src/entities/flow/activities/prompt-template.d.ts +0 -13
- package/dist-sdk/src/entities/flow/activities/prompt-template.js +0 -34
- package/dist-sdk/src/entities/flow/activities/types.d.ts +0 -33
- package/dist-sdk/src/entities/flow/build.d.ts +0 -38
- package/dist-sdk/src/entities/flow/build.js +0 -115
- package/dist-sdk/src/entities/flow/index.d.ts +0 -8
- package/dist-sdk/src/entities/flow/index.js +0 -7
- package/dist-sdk/src/entities/flow/serialize.d.ts +0 -51
- package/dist-sdk/src/entities/flow/serialize.js +0 -94
- package/dist-sdk/src/entities/flow/util.d.ts +0 -27
- package/dist-sdk/src/entities/flow/util.js +0 -38
- package/dist-sdk/src/entities/table/filter.d.ts +0 -41
- package/dist-sdk/src/entities/table/filter.js +0 -89
- /package/dist-sdk/src/entities/{flow/activities/types.js → datamine/build.js} +0 -0
|
@@ -1,12 +1,29 @@
|
|
|
1
|
-
import { EntityTfError } from "../../engine/entity.js";
|
|
1
|
+
import { EntityTfError, recordFieldContextOf } from "../../engine/entity.js";
|
|
2
2
|
import { DEPLOY_DEFAULT_SYSTEM_FIELD_NAMES, SYSTEM_FIELD_KEY_SET } from "../../core/system-fields.js";
|
|
3
|
-
import { appResourceLabelPrefix, appScopedResourceLabel, expr, isTfExpr, isUuid, sanitizeName, snakeSlug, tsLabelToTfLabel, } from "../../engine/tf/index.js";
|
|
3
|
+
import { appResourceLabelPrefix, appScopedResourceLabel, expr, isTfExpr, isUuid, sanitizeName, scopedResourceLabel, snakeSlug, tsLabelToTfLabel, } from "../../engine/tf/index.js";
|
|
4
|
+
import { workspaceAspectKey } from "../../engine/build/context.js";
|
|
5
|
+
import { SEARCH_TABLE_RESOURCE_TYPES } from "../search-table/types.js";
|
|
6
|
+
import { fieldRefToTfValue } from "../field/to-tf.js";
|
|
7
|
+
import { SERVICE_ACCOUNT_RESOURCE_TYPE } from "../service-account/module.js";
|
|
8
|
+
import { resolveForeignRef } from "../shared/foreign-ref.js";
|
|
9
|
+
import { filterToTf as serializeFilterToTf } from "../shared/filters/tf-codec.js";
|
|
4
10
|
import { CONNECTOR_ORG_BAG } from "../org/connector.js";
|
|
5
11
|
import { FILE_READER_SUB_TYPE_BY_RESOURCE, FILE_READER_SUB_TYPE_BY_TYPE_KEY } from "../file-reader/types.js";
|
|
12
|
+
import { UNRESOLVED_FIELD_MARKER } from "../shared/ref.js";
|
|
13
|
+
import { TABLE_RESOURCE_TYPE } from "../table/module.js";
|
|
6
14
|
import { AUTOMATION_RESOURCE_TYPE, WORKFLOW_PUBLISH_RESOURCE_TYPE } from "./types.js";
|
|
7
15
|
function scopedLabel(appTfLabel, label) {
|
|
8
16
|
return appScopedResourceLabel(appTfLabel, label);
|
|
9
17
|
}
|
|
18
|
+
/** Stable, non-cryptographic suffix for collision-resistant Terraform labels. */
|
|
19
|
+
function labelHash(value) {
|
|
20
|
+
let hash = 0x811c9dc5;
|
|
21
|
+
for (let i = 0; i < value.length; i += 1) {
|
|
22
|
+
hash ^= value.charCodeAt(i);
|
|
23
|
+
hash = Math.imul(hash, 0x01000193);
|
|
24
|
+
}
|
|
25
|
+
return (hash >>> 0).toString(36);
|
|
26
|
+
}
|
|
10
27
|
function scopedOptionLocalName(localName, owner) {
|
|
11
28
|
for (const suffix of ["_options_by_label", "_option_ids_by_label"]) {
|
|
12
29
|
if (!localName.endsWith(suffix))
|
|
@@ -123,6 +140,8 @@ const CONFIG_ATTRS = {
|
|
|
123
140
|
responseType: "response_type",
|
|
124
141
|
continueOnError: "continue_on_error",
|
|
125
142
|
searchTableId: "search_table_id",
|
|
143
|
+
phoneService: "phone_service_id",
|
|
144
|
+
query: "query",
|
|
126
145
|
textToSummarize: "text_to_summarize",
|
|
127
146
|
textToClassify: "text_to_classify",
|
|
128
147
|
fieldType: "field_type",
|
|
@@ -163,7 +182,12 @@ function onlyEntry(value, subject) {
|
|
|
163
182
|
return entries[0];
|
|
164
183
|
}
|
|
165
184
|
function token(value) {
|
|
166
|
-
if (!isObject(value) || typeof value.__kind !== "string"
|
|
185
|
+
if (!isObject(value) || typeof value.__kind !== "string")
|
|
186
|
+
return undefined;
|
|
187
|
+
// User refs are keyed by email and intentionally have no catalog refName.
|
|
188
|
+
if (value.__kind === "user" && typeof value.email === "string")
|
|
189
|
+
return value;
|
|
190
|
+
if (typeof value.refName !== "string")
|
|
167
191
|
return undefined;
|
|
168
192
|
return value;
|
|
169
193
|
}
|
|
@@ -178,7 +202,7 @@ function addressExpr(address, path = ["id"]) {
|
|
|
178
202
|
* this automation belongs to (e.g. a `recordSearch` task's filter against
|
|
179
203
|
* another app's field) — resolved via a `data.elementum_field` lookup keyed
|
|
180
204
|
* by the owner's id + the field's display name, mirroring
|
|
181
|
-
* `field/to-tf.ts`'s `
|
|
205
|
+
* `field/to-tf.ts`'s `resolveFieldOnObject` for a relation field's
|
|
182
206
|
* `relatedLabelField`. Self-contained: `parentKind`/`parentName` (stamped by
|
|
183
207
|
* `appCatalog`/`elementCatalog` — see `FieldRef`) carry everything needed to
|
|
184
208
|
* register the owner's own `data.elementum_app`/`data.elementum_element`
|
|
@@ -188,7 +212,33 @@ function addressExpr(address, path = ["id"]) {
|
|
|
188
212
|
* its own foreign-field label: an app and an element can share a refName,
|
|
189
213
|
* and `elementum_field` is one shared data-source type for both.
|
|
190
214
|
*/
|
|
191
|
-
|
|
215
|
+
/** App/element root lookup attrs when orgRefs is unavailable (mirrors graph rootNamespace strategy). */
|
|
216
|
+
function foreignRootLookup(kind, identity) {
|
|
217
|
+
const resourceType = kind === "element" ? "elementum_element" : "elementum_app";
|
|
218
|
+
if (identity.namespace !== undefined && identity.namespace !== "") {
|
|
219
|
+
return {
|
|
220
|
+
resourceType,
|
|
221
|
+
tfLabel: sanitizeName(identity.namespace),
|
|
222
|
+
lookupAttr: "namespace",
|
|
223
|
+
lookupValue: identity.namespace,
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
return {
|
|
227
|
+
resourceType,
|
|
228
|
+
tfLabel: sanitizeName(identity.name),
|
|
229
|
+
lookupAttr: "name",
|
|
230
|
+
lookupValue: identity.name,
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Validates and derives the shared naming for a cross-app/element field
|
|
235
|
+
* token — the `data.elementum_field` label {@link crossAppFieldToTf} emits,
|
|
236
|
+
* and the matching `<fieldLabel>_options_by_label` local a foreign PICKLIST
|
|
237
|
+
* field's option-label lookup (in {@link picklistFilterValueToTf}) resolves
|
|
238
|
+
* against. Kept as one function so the two call sites can never drift apart
|
|
239
|
+
* on how the label is built.
|
|
240
|
+
*/
|
|
241
|
+
function foreignFieldNaming(value) {
|
|
192
242
|
const parent = value.parent;
|
|
193
243
|
if (parent === undefined)
|
|
194
244
|
throw new EntityTfError(`field ref "${value.refName}" has no parent`);
|
|
@@ -206,33 +256,72 @@ function crossAppFieldToTf(value, ctx, dataBlocks) {
|
|
|
206
256
|
throw new EntityTfError(`field ref "${value.refName}" has a parent ("${parent}") but no parentName — incomplete foreign-field provenance; the owner lookup would key on the refName instead of its real display name and silently miss at apply`);
|
|
207
257
|
}
|
|
208
258
|
const fieldName = value.name ?? value.refName;
|
|
209
|
-
const
|
|
210
|
-
const
|
|
211
|
-
|
|
259
|
+
const ownerKind = value.parentKind === "element" ? "element" : "app";
|
|
260
|
+
const resolved = foreignRootLookup(ownerKind, {
|
|
261
|
+
name: value.parentName,
|
|
262
|
+
namespace: value.parentNamespace,
|
|
263
|
+
});
|
|
264
|
+
const ownerType = resolved.resourceType;
|
|
265
|
+
const ownerLabel = resolved.tfLabel;
|
|
212
266
|
const fieldLabel = `${value.parentKind}_${ownerLabel}_${tsLabelToTfLabel(value.refName)}`;
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
267
|
+
return { fieldName, ownerType, ownerLabel, ownerParentName: value.parentName, fieldLabel };
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Registers the `<fieldLabel>_options_by_label` local — a for-expression
|
|
271
|
+
* over the `data.elementum_field` block's `options` — into the shared
|
|
272
|
+
* `locals.tf` attrs, when the build wired one up ({@link
|
|
273
|
+
* AutomationToTfContext.localsAttrs}). Cross-app counterpart to
|
|
274
|
+
* `field/locals.ts`'s same-app `appendFieldLocals`; unconditional per field
|
|
275
|
+
* (options empty for non-picklist/calculated fields), matching that
|
|
276
|
+
* same-app precedent of always emitting the local whether or not any
|
|
277
|
+
* automation ends up looking a label up through it.
|
|
278
|
+
*/
|
|
279
|
+
function registerForeignOptionsByLabelLocal(fieldLabel, ctx) {
|
|
280
|
+
if (ctx.localsAttrs === undefined)
|
|
281
|
+
return;
|
|
282
|
+
const localName = `${fieldLabel}_options_by_label`;
|
|
283
|
+
if (localName in ctx.localsAttrs)
|
|
284
|
+
return;
|
|
285
|
+
ctx.localsAttrs[localName] = expr.forObject("opt", expr.dataAttr("elementum_field", fieldLabel, ["options"]), expr.scopedAttr("opt", ["label"]), expr.scopedAttr("opt", ["id"]));
|
|
286
|
+
}
|
|
287
|
+
function crossAppFieldToTf(value, ctx, dataBlocks) {
|
|
288
|
+
// A field owned by a SIBLING app/element built in this same workspace
|
|
289
|
+
// resolves to a direct resource address, same as the `case "app"/"element"`
|
|
290
|
+
// branch in `tokenToTf` — never a `data.elementum_field` lookup, which can
|
|
291
|
+
// only find something already live on the platform (see
|
|
292
|
+
// `ToTfContext.workspaceAspects`'s doc comment).
|
|
293
|
+
if (value.parent !== undefined && value.parentKind !== undefined) {
|
|
294
|
+
const sibling = ctx.workspaceAspects?.get(workspaceAspectKey(value.parentKind, value.parent));
|
|
295
|
+
// A table sibling cannot own a FIELD ref (tables expose columns, not
|
|
296
|
+
// fields, and `parentKind` is only ever app/element here), so it is
|
|
297
|
+
// filtered out rather than cast away — the map holds tables too, because a
|
|
298
|
+
// table-owned search table has to be distinguishable from an element-owned
|
|
299
|
+
// one.
|
|
300
|
+
if (sibling !== undefined && sibling.kind !== "table") {
|
|
301
|
+
const fieldValue = fieldRefToTfValue(value.fieldType ?? "", value.refName, sibling.tfLabel, sibling.kind);
|
|
302
|
+
if (fieldValue === undefined) {
|
|
303
|
+
throw new EntityTfError(`field ref "${value.refName}" on sibling ${sibling.kind} "${value.parent}" has no terraform field resource mapping (fieldType ${JSON.stringify(value.fieldType ?? "")})`);
|
|
304
|
+
}
|
|
305
|
+
return fieldValue;
|
|
227
306
|
}
|
|
228
|
-
|
|
307
|
+
}
|
|
308
|
+
const { fieldName, fieldLabel } = foreignFieldNaming(value);
|
|
309
|
+
const ownerKind = value.parentKind === "element" ? "element" : "app";
|
|
310
|
+
if (ctx.orgRefs !== undefined) {
|
|
311
|
+
const owner = resolveForeignRef(ownerKind, { name: value.parentName, namespace: value.parentNamespace }, ctx.orgRefs, ctx.diagnostics, `automation field "${value.refName}" owner`);
|
|
312
|
+
ctx.orgRefs.foreignField("elementum_field", fieldLabel, owner.value, fieldName);
|
|
229
313
|
}
|
|
230
314
|
else {
|
|
231
|
-
|
|
315
|
+
const resolved = foreignRootLookup(ownerKind, {
|
|
316
|
+
name: value.parentName,
|
|
317
|
+
namespace: value.parentNamespace,
|
|
318
|
+
});
|
|
319
|
+
const objectId = expr.dataAttr(resolved.resourceType, resolved.tfLabel, ["id"]);
|
|
320
|
+
dataBlocks.set(`${resolved.resourceType}.${resolved.tfLabel}`, {
|
|
232
321
|
kind: "data",
|
|
233
|
-
type:
|
|
234
|
-
label:
|
|
235
|
-
attrs: {
|
|
322
|
+
type: resolved.resourceType,
|
|
323
|
+
label: resolved.tfLabel,
|
|
324
|
+
attrs: { [resolved.lookupAttr]: resolved.lookupValue },
|
|
236
325
|
});
|
|
237
326
|
dataBlocks.set(`elementum_field.${fieldLabel}`, {
|
|
238
327
|
kind: "data",
|
|
@@ -241,40 +330,54 @@ function crossAppFieldToTf(value, ctx, dataBlocks) {
|
|
|
241
330
|
attrs: { object_id: objectId, name: fieldName },
|
|
242
331
|
});
|
|
243
332
|
}
|
|
333
|
+
registerForeignOptionsByLabelLocal(fieldLabel, ctx);
|
|
244
334
|
return expr.dataAttr("elementum_field", fieldLabel, ["id"]);
|
|
245
335
|
}
|
|
246
336
|
function tokenToTf(value, ctx, dataBlocks) {
|
|
247
337
|
switch (value.__kind) {
|
|
338
|
+
case "user": {
|
|
339
|
+
if (typeof value.email !== "string" || value.email === "") {
|
|
340
|
+
throw new EntityTfError("userRef requires an email lookup");
|
|
341
|
+
}
|
|
342
|
+
const normalizedEmail = value.email.toLowerCase();
|
|
343
|
+
const label = `${sanitizeName(value.email.split("@")[0] ?? value.email).slice(0, 50)}_${labelHash(normalizedEmail)}`;
|
|
344
|
+
if (ctx.orgRefs !== undefined) {
|
|
345
|
+
ctx.orgRefs.rawLookup("elementum_user", label, value.email);
|
|
346
|
+
}
|
|
347
|
+
else {
|
|
348
|
+
dataBlocks.set(`elementum_user.${label}`, {
|
|
349
|
+
kind: "data",
|
|
350
|
+
type: "elementum_user",
|
|
351
|
+
label,
|
|
352
|
+
attrs: { email: value.email },
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
return expr.dataAttr("elementum_user", label, ["id"]);
|
|
356
|
+
}
|
|
248
357
|
case "userField":
|
|
249
358
|
return value.refName;
|
|
250
359
|
case "app":
|
|
251
360
|
case "element":
|
|
252
361
|
if (value.refName !== ctx.appRefName) {
|
|
362
|
+
const sibling = ctx.workspaceAspects?.get(workspaceAspectKey(value.__kind, value.refName));
|
|
363
|
+
if (sibling !== undefined) {
|
|
364
|
+
const siblingType = sibling.kind === "element" ? "elementum_element" : "elementum_app";
|
|
365
|
+
return expr.resourceAttr(siblingType, sibling.tfLabel, ["id"]);
|
|
366
|
+
}
|
|
253
367
|
if (!value.name)
|
|
254
368
|
throw new EntityTfError(`cross-aspect ref "${value.refName}" has no lookup name`);
|
|
255
|
-
const
|
|
256
|
-
const label = tsLabelToTfLabel(value.refName);
|
|
257
|
-
// See `crossAppFieldToTf`'s comment: route through the build-wide
|
|
258
|
-
// `orgRefs` registry so multiple automations referencing the same
|
|
259
|
-
// foreign app/element collapse to one `data.tf` entry instead of
|
|
260
|
-
// each stamping a duplicate `data` block into its own file.
|
|
369
|
+
const kind = value.__kind === "element" ? "element" : "app";
|
|
261
370
|
if (ctx.orgRefs !== undefined) {
|
|
262
|
-
|
|
263
|
-
ctx.orgRefs.foreignElement(label, value.name);
|
|
264
|
-
}
|
|
265
|
-
else {
|
|
266
|
-
ctx.orgRefs.foreignApp(label, value.name);
|
|
267
|
-
}
|
|
371
|
+
return resolveForeignRef(kind, { name: value.name, namespace: value.namespace }, ctx.orgRefs, ctx.diagnostics, `automation ${value.refName}`).value;
|
|
268
372
|
}
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
return expr.dataAttr(type, label, ["id"]);
|
|
373
|
+
const resolved = foreignRootLookup(kind, { name: value.name, namespace: value.namespace });
|
|
374
|
+
dataBlocks.set(`${resolved.resourceType}.${resolved.tfLabel}`, {
|
|
375
|
+
kind: "data",
|
|
376
|
+
type: resolved.resourceType,
|
|
377
|
+
label: resolved.tfLabel,
|
|
378
|
+
attrs: { [resolved.lookupAttr]: resolved.lookupValue },
|
|
379
|
+
});
|
|
380
|
+
return expr.dataAttr(resolved.resourceType, resolved.tfLabel, ["id"]);
|
|
278
381
|
}
|
|
279
382
|
return expr.resourceAttr("elementum_app", ctx.appTfLabel, ["id"]);
|
|
280
383
|
case "field": {
|
|
@@ -318,8 +421,93 @@ function tokenToTf(value, ctx, dataBlocks) {
|
|
|
318
421
|
return expr.resourceAttr(AUTOMATION_RESOURCE_TYPE, scopedLabel(ctx.appTfLabel, tsLabelToTfLabel(value.refName)), ["id"]);
|
|
319
422
|
case "agent":
|
|
320
423
|
return expr.resourceAttr("elementum_agent", scopedLabel(ctx.appTfLabel, tsLabelToTfLabel(value.refName)), ["id"]);
|
|
321
|
-
case "
|
|
322
|
-
|
|
424
|
+
case "phone-service":
|
|
425
|
+
if (value.parent !== undefined && value.parent !== ctx.appRefName) {
|
|
426
|
+
throw new EntityTfError(`cross-app phone service ref "${value.parent}.${value.refName}" is not supported`);
|
|
427
|
+
}
|
|
428
|
+
return expr.resourceAttr("elementum_phone_service", scopedLabel(ctx.appTfLabel, tsLabelToTfLabel(value.refName)), ["id"]);
|
|
429
|
+
case "datamine":
|
|
430
|
+
if (value.parent === undefined || value.parent === "") {
|
|
431
|
+
throw new EntityTfError(`datamine ref "${value.refName}" is missing its owning table`);
|
|
432
|
+
}
|
|
433
|
+
return expr.resourceAttr("elementum_datamine", `${tsLabelToTfLabel(value.parent)}_${tsLabelToTfLabel(value.refName)}`, ["id"]);
|
|
434
|
+
case "table": {
|
|
435
|
+
const sibling = ctx.workspaceAspects?.get(workspaceAspectKey("table", value.refName));
|
|
436
|
+
if (sibling !== undefined) {
|
|
437
|
+
return expr.resourceAttr(TABLE_RESOURCE_TYPE, sibling.tfLabel, ["id"]);
|
|
438
|
+
}
|
|
439
|
+
const name = value.name ?? value.refName;
|
|
440
|
+
if (name === "")
|
|
441
|
+
throw new EntityTfError(`table ref "${value.refName}" has no lookup name`);
|
|
442
|
+
const label = tsLabelToTfLabel(value.refName);
|
|
443
|
+
if (ctx.orgRefs !== undefined) {
|
|
444
|
+
ctx.orgRefs.rawLookup(TABLE_RESOURCE_TYPE, label, name);
|
|
445
|
+
}
|
|
446
|
+
else {
|
|
447
|
+
dataBlocks.set(`${TABLE_RESOURCE_TYPE}.${label}`, {
|
|
448
|
+
kind: "data",
|
|
449
|
+
type: TABLE_RESOURCE_TYPE,
|
|
450
|
+
label,
|
|
451
|
+
attrs: { name },
|
|
452
|
+
});
|
|
453
|
+
}
|
|
454
|
+
return expr.dataAttr(TABLE_RESOURCE_TYPE, label, ["id"]);
|
|
455
|
+
}
|
|
456
|
+
case "searchTable": {
|
|
457
|
+
// Ownership + variant contract:
|
|
458
|
+
// snowflake / linked -> owned by an ELEMENT
|
|
459
|
+
// table -> owned by a TABLE
|
|
460
|
+
// never app-owned -> an app's backing Snowflake table is hybrid, and
|
|
461
|
+
// Cortex cannot index one ("AI Search Tables
|
|
462
|
+
// cannot be created on hybrid tables (target
|
|
463
|
+
// object has storageType HYBRID)").
|
|
464
|
+
//
|
|
465
|
+
// This previously scoped every search table to `ctx.appTfLabel`, which is
|
|
466
|
+
// therefore never a valid target. With an element owner it emitted a
|
|
467
|
+
// reference to a resource that is never written — with ZERO diagnostics —
|
|
468
|
+
// and failed only at `tofu plan` ("Reference to undeclared resource"),
|
|
469
|
+
// saying nothing about ownership. The sibling cases in this switch
|
|
470
|
+
// (automation / phone-service / datamine) all throw; this was silent.
|
|
471
|
+
//
|
|
472
|
+
// The VARIANT picks the resource type and the owner kind only has to
|
|
473
|
+
// agree with it. Deriving the type from the owner instead emits
|
|
474
|
+
// `elementum_ai_search_table` for a LINKED table — whose resource is
|
|
475
|
+
// `elementum_linked_ai_search_table` — recreating the very dangling
|
|
476
|
+
// reference this case exists to prevent, and lets an element win over a
|
|
477
|
+
// table when the two share a refName.
|
|
478
|
+
const owner = value.parent;
|
|
479
|
+
if (owner === undefined) {
|
|
480
|
+
throw new EntityTfError(`search table "${value.refName}" carries no owning aspect — a search table is owned by an element or a table`);
|
|
481
|
+
}
|
|
482
|
+
const aspects = ctx.workspaceAspects;
|
|
483
|
+
if (aspects === undefined) {
|
|
484
|
+
throw new EntityTfError(`search table "${owner}.${value.refName}" cannot be resolved without workspace ownership context`);
|
|
485
|
+
}
|
|
486
|
+
const variant = value.__variant ?? "snowflake";
|
|
487
|
+
const element = aspects.get(workspaceAspectKey("element", owner));
|
|
488
|
+
const table = aspects.get(workspaceAspectKey("table", owner));
|
|
489
|
+
if (variant === "table") {
|
|
490
|
+
if (table === undefined) {
|
|
491
|
+
throw new EntityTfError(`search table "${owner}.${value.refName}" is table-owned, but "${owner}" is not a table in this build` +
|
|
492
|
+
`${element !== undefined ? ` (it is an element — use searchTable, not tableSearchTable)` : ""}`);
|
|
493
|
+
}
|
|
494
|
+
// Label shape mirrors search-table/to-tf.ts's own table branch.
|
|
495
|
+
return expr.resourceAttr(SEARCH_TABLE_RESOURCE_TYPES.table, `tables_${table.tfLabel}_${tsLabelToTfLabel(value.refName)}`, ["id"]);
|
|
496
|
+
}
|
|
497
|
+
if (element !== undefined) {
|
|
498
|
+
return expr.resourceAttr(SEARCH_TABLE_RESOURCE_TYPES[variant], scopedResourceLabel(element.tfLabel, tsLabelToTfLabel(value.refName), "element"), ["id"]);
|
|
499
|
+
}
|
|
500
|
+
if (table !== undefined) {
|
|
501
|
+
throw new EntityTfError(`search table "${owner}.${value.refName}" is a ${variant} search table owned by table "${owner}" — ` +
|
|
502
|
+
`a table's search table is created with tableSearchTable`);
|
|
503
|
+
}
|
|
504
|
+
if (aspects.get(workspaceAspectKey("app", owner)) !== undefined) {
|
|
505
|
+
throw new EntityTfError(`search table "${owner}.${value.refName}" is owned by app "${owner}" — a search table is owned by an ` +
|
|
506
|
+
`element or a table, never an app`);
|
|
507
|
+
}
|
|
508
|
+
throw new EntityTfError(`search table "${owner}.${value.refName}" is owned by an aspect that is not part of this build — ` +
|
|
509
|
+
`a foreign search-table reference has no data-source lookup yet`);
|
|
510
|
+
}
|
|
323
511
|
case "approvalChain":
|
|
324
512
|
return value.unresolvedId !== undefined
|
|
325
513
|
? value.unresolvedId
|
|
@@ -332,7 +520,7 @@ function tokenToTf(value, ctx, dataBlocks) {
|
|
|
332
520
|
// reference to a resource block that's never written, failing only at
|
|
333
521
|
// `tofu plan`/`apply` instead of at build.
|
|
334
522
|
if (subType === undefined || subType.implemented !== true) {
|
|
335
|
-
throw new EntityTfError(`file reader token "${value.refName}" has no recognized readerType ("${value.readerType}") — was it built with
|
|
523
|
+
throw new EntityTfError(`file reader token "${value.refName}" has no recognized readerType ("${value.readerType}") — was it built with a file-reader factory?`);
|
|
336
524
|
}
|
|
337
525
|
return expr.resourceAttr(subType.resourceType, scopedLabel(ctx.appTfLabel, tsLabelToTfLabel(value.refName)), ["id"]);
|
|
338
526
|
}
|
|
@@ -370,6 +558,145 @@ function templateToTf(value, refs) {
|
|
|
370
558
|
parts.push(template.slice(cursor));
|
|
371
559
|
return expr.template(parts);
|
|
372
560
|
}
|
|
561
|
+
/**
|
|
562
|
+
* Calculation `formula` is the calc-engine language, not a task-input
|
|
563
|
+
* ValueReference. A bare `trigger.refs["Field"]` interpolates to a JSON
|
|
564
|
+
* envelope; the API rejects that with `Unable to validate` (edk#107, live
|
|
565
|
+
* apply 2026-08-21 on portertest). ei export and the accepted write shape
|
|
566
|
+
* are both `{{trigger name="record.<field-id>"}}`.
|
|
567
|
+
*/
|
|
568
|
+
function calculationFormulaToTf(template, refs) {
|
|
569
|
+
const parts = flattenAdjacentFormulaParts(calculationTemplateToParts(template, refs));
|
|
570
|
+
if (parts.length === 0)
|
|
571
|
+
return "";
|
|
572
|
+
if (parts.length === 1 && typeof parts[0] === "string")
|
|
573
|
+
return parts[0];
|
|
574
|
+
return expr.template(parts);
|
|
575
|
+
}
|
|
576
|
+
function calculationTemplateToParts(value, refs) {
|
|
577
|
+
const template = value.template;
|
|
578
|
+
const parameters = value.parameters;
|
|
579
|
+
if (typeof template !== "string" || !Array.isArray(parameters)) {
|
|
580
|
+
throw new EntityTfError("invalid calculation templateReference");
|
|
581
|
+
}
|
|
582
|
+
const byName = new Map();
|
|
583
|
+
for (const parameter of parameters) {
|
|
584
|
+
if (!isObject(parameter) || !isObject(parameter.value) || typeof parameter.value.name !== "string") {
|
|
585
|
+
throw new EntityTfError("nested/list calculation template parameters are not supported by the Terraform contract");
|
|
586
|
+
}
|
|
587
|
+
byName.set(parameter.value.name, calculationFormulaRefToParts(parameter.value.value, refs));
|
|
588
|
+
}
|
|
589
|
+
const parts = [];
|
|
590
|
+
let cursor = 0;
|
|
591
|
+
const pattern = /\{\{\{([^}]+)\}\}\}/g;
|
|
592
|
+
for (let match = pattern.exec(template); match !== null; match = pattern.exec(template)) {
|
|
593
|
+
if (match.index > cursor)
|
|
594
|
+
parts.push(template.slice(cursor, match.index));
|
|
595
|
+
const paramParts = byName.get(match[1]);
|
|
596
|
+
if (paramParts === undefined) {
|
|
597
|
+
throw new EntityTfError(`calculation template parameter "${match[1]}" is missing`);
|
|
598
|
+
}
|
|
599
|
+
parts.push(...paramParts);
|
|
600
|
+
cursor = match.index + match[0].length;
|
|
601
|
+
}
|
|
602
|
+
if (cursor < template.length)
|
|
603
|
+
parts.push(template.slice(cursor));
|
|
604
|
+
return parts;
|
|
605
|
+
}
|
|
606
|
+
function calculationFormulaRefToParts(value, refs) {
|
|
607
|
+
if (value === null || typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
|
608
|
+
return [String(value)];
|
|
609
|
+
}
|
|
610
|
+
if (!isObject(value))
|
|
611
|
+
throw new EntityTfError(`unsupported calculation formula value ${String(value)}`);
|
|
612
|
+
if ("value" in value &&
|
|
613
|
+
!("triggerReference" in value) &&
|
|
614
|
+
!("taskReference" in value) &&
|
|
615
|
+
!("variableReference" in value) &&
|
|
616
|
+
!("templateReference" in value) &&
|
|
617
|
+
Object.keys(value).length === 1) {
|
|
618
|
+
return calculationFormulaRefToParts(value.value, refs);
|
|
619
|
+
}
|
|
620
|
+
if (isObject(value.triggerReference) && typeof value.triggerReference.name === "string") {
|
|
621
|
+
return calculationTriggerMustache(value.triggerReference.name, refs);
|
|
622
|
+
}
|
|
623
|
+
if (isObject(value.taskReference) &&
|
|
624
|
+
typeof value.taskReference.taskRefKey === "string" &&
|
|
625
|
+
typeof value.taskReference.name === "string") {
|
|
626
|
+
return calculationTaskMustache(value.taskReference.taskRefKey, value.taskReference.name, refs);
|
|
627
|
+
}
|
|
628
|
+
if (isObject(value.variableReference) && typeof value.variableReference.id === "string") {
|
|
629
|
+
return [`variable.${value.variableReference.id}`];
|
|
630
|
+
}
|
|
631
|
+
if (isObject(value.templateReference))
|
|
632
|
+
return calculationTemplateToParts(value.templateReference, refs);
|
|
633
|
+
if (typeof value.kind === "string") {
|
|
634
|
+
if (value.kind === "unresolved" && typeof value.uuid === "string") {
|
|
635
|
+
return [`{{trigger name="${value.uuid}"}}`];
|
|
636
|
+
}
|
|
637
|
+
if (value.kind === "literal" && "value" in value)
|
|
638
|
+
return calculationFormulaRefToParts(value.value, refs);
|
|
639
|
+
}
|
|
640
|
+
throw new EntityTfError("calculation formula is not a trigger/task/variable ref, literal, or template");
|
|
641
|
+
}
|
|
642
|
+
/**
|
|
643
|
+
* Calc-engine mustache for a prior task output. Matches the live dialect
|
|
644
|
+
* `{{task name="<wire output>" id="<task-id>"}}` (name is the refs-map key,
|
|
645
|
+
* not the task display name). Task id interpolates from the task resource.
|
|
646
|
+
*/
|
|
647
|
+
function calculationTaskMustache(taskRefKey, wireName, refs) {
|
|
648
|
+
const target = refs.tasks.get(taskRefKey);
|
|
649
|
+
if (target === undefined)
|
|
650
|
+
throw new EntityTfError(`unresolved task ref "${taskRefKey}" in calculation formula`);
|
|
651
|
+
if (wireName.includes('"')) {
|
|
652
|
+
throw new EntityTfError(`calculation task output name "${wireName}" contains a double quote`);
|
|
653
|
+
}
|
|
654
|
+
return [
|
|
655
|
+
`{{task name="${wireName}" id="`,
|
|
656
|
+
expr.resourceAttr(target.type, target.label, ["id"]),
|
|
657
|
+
`"}}`,
|
|
658
|
+
];
|
|
659
|
+
}
|
|
660
|
+
function calculationTriggerMustache(name, refs) {
|
|
661
|
+
const parts = name.split(".");
|
|
662
|
+
if (parts[0] !== "record" || parts.length < 2) {
|
|
663
|
+
return [`{{trigger name="${name}"}}`];
|
|
664
|
+
}
|
|
665
|
+
const fieldKey = parts[1];
|
|
666
|
+
const suffix = parts.slice(2).join(".");
|
|
667
|
+
const suffixPart = suffix.length > 0 ? `.${suffix}` : "";
|
|
668
|
+
return [
|
|
669
|
+
'{{trigger name="record.',
|
|
670
|
+
calculationRecordFieldId(fieldKey, refs),
|
|
671
|
+
`${suffixPart}"}}`,
|
|
672
|
+
];
|
|
673
|
+
}
|
|
674
|
+
function calculationRecordFieldId(fieldKey, refs) {
|
|
675
|
+
if (fieldKey.startsWith(UNRESOLVED_FIELD_MARKER))
|
|
676
|
+
return fieldKey.slice(UNRESOLVED_FIELD_MARKER.length);
|
|
677
|
+
if (isUuid(fieldKey))
|
|
678
|
+
return fieldKey;
|
|
679
|
+
const address = refs.owner.fieldAddresses.get(fieldKey);
|
|
680
|
+
if (address !== undefined)
|
|
681
|
+
return addressExpr(address, ["id"]);
|
|
682
|
+
if (SYSTEM_FIELD_KEY_SET.has(fieldKey)) {
|
|
683
|
+
return expr.local(`${refs.owner.appTfLabel}_${tsLabelToTfLabel(fieldKey)}_field_id`);
|
|
684
|
+
}
|
|
685
|
+
throw new EntityTfError(`automation calculation targets field "${fieldKey}" which does not exist in app "${refs.owner.appRefName}"`);
|
|
686
|
+
}
|
|
687
|
+
function flattenAdjacentFormulaParts(parts) {
|
|
688
|
+
const out = [];
|
|
689
|
+
for (const part of parts) {
|
|
690
|
+
const last = out[out.length - 1];
|
|
691
|
+
if (typeof part === "string" && typeof last === "string") {
|
|
692
|
+
out[out.length - 1] = last + part;
|
|
693
|
+
}
|
|
694
|
+
else {
|
|
695
|
+
out.push(part);
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
return out;
|
|
699
|
+
}
|
|
373
700
|
const TS_REF_SEGMENT_TO_WIRE = {
|
|
374
701
|
record: "Record",
|
|
375
702
|
changedFieldIds: "Changed Fields",
|
|
@@ -379,6 +706,15 @@ const TS_REF_SEGMENT_TO_WIRE = {
|
|
|
379
706
|
title: "Title",
|
|
380
707
|
};
|
|
381
708
|
const TS_TRIGGER_REF_TO_WIRE = {
|
|
709
|
+
attachment: "Attachment",
|
|
710
|
+
// Full-name entry required: the live attachment-trigger ATTACHMENT_ID key is
|
|
711
|
+
// "Attachment Id" (triggerReference.name = "attachment.id"). Do NOT fold this
|
|
712
|
+
// onto FIELD_REF_SUFFIX_TO_WIRE — that table's `id` suffix is " ID", which
|
|
713
|
+
// would emit the wrong wire key "Attachment ID" and fail live validation.
|
|
714
|
+
"attachment.id": "Attachment Id",
|
|
715
|
+
"triggeredBy.id": "Triggered By's Id",
|
|
716
|
+
"triggeredBy.name": "Triggered By's Name",
|
|
717
|
+
"triggeredBy.email": "Triggered By's Email",
|
|
382
718
|
createdByEmail: "Created by Email",
|
|
383
719
|
updatedByManagerEmail: "Updated by Manager Email",
|
|
384
720
|
slackThreadId: "Slack Thread ID",
|
|
@@ -457,6 +793,51 @@ function wireRefName(name, ctx) {
|
|
|
457
793
|
parts[0] = TS_REF_SEGMENT_TO_WIRE[parts[0]] ?? parts[0];
|
|
458
794
|
return parts.join(".");
|
|
459
795
|
}
|
|
796
|
+
function forEachWireRefName(name, ctx) {
|
|
797
|
+
// A recordSearch collection's whole item and branded record identity both
|
|
798
|
+
// point at the loop's ASPECT_RECORD_ID reference. Live provider state
|
|
799
|
+
// exposes that reference under "Record"; "ID" is a distinct TEXT handle.
|
|
800
|
+
if (name === "item" || name === "recordId")
|
|
801
|
+
return "Record";
|
|
802
|
+
// Record fields are keyed by their platform display names, not their typed
|
|
803
|
+
// catalog handles. Reuse the same field/suffix mapping as trigger record
|
|
804
|
+
// paths, while preserving the generic forEach keys used by non-record
|
|
805
|
+
// collections (File, Iteration, etc.).
|
|
806
|
+
const fieldKey = name.split(".")[0];
|
|
807
|
+
if (fieldKey !== undefined &&
|
|
808
|
+
(ctx.fieldNames.has(fieldKey) || SYSTEM_FIELD_KEY_SET.has(fieldKey))) {
|
|
809
|
+
return wireRefName(`record.${name}`, ctx);
|
|
810
|
+
}
|
|
811
|
+
return wireRefName(name, ctx);
|
|
812
|
+
}
|
|
813
|
+
/**
|
|
814
|
+
* Authoring `records[N].<field>` accumulates as `records.N.<field>`. The
|
|
815
|
+
* platform's search-task refs map is flat display-name keys (same as
|
|
816
|
+
* `.record.<field>`), not dotted paths under "All found records" (#490).
|
|
817
|
+
* Collapse the indexed form onto the record-field path before wire lookup.
|
|
818
|
+
*/
|
|
819
|
+
function normalizeIndexedRecordsFieldPath(name) {
|
|
820
|
+
const match = /^records\.\d+\.(.+)$/.exec(name);
|
|
821
|
+
return match !== null ? `record.${match[1]}` : name;
|
|
822
|
+
}
|
|
823
|
+
/**
|
|
824
|
+
* Resolve a task output ref name against the task's record-bearing target
|
|
825
|
+
* app/element when known (cross-app recordSearch / createRecord / …), falling
|
|
826
|
+
* back to the automation owner for non-record tasks and same-app searches.
|
|
827
|
+
*/
|
|
828
|
+
function taskWireRefName(name, taskRefKey, refs) {
|
|
829
|
+
const normalized = normalizeIndexedRecordsFieldPath(name);
|
|
830
|
+
const taskApp = refs.recordFieldContext?.taskAppRefNameByRefKey?.[taskRefKey];
|
|
831
|
+
if (taskApp === undefined || taskApp === refs.owner.appRefName) {
|
|
832
|
+
return wireRefName(normalized, refs.owner);
|
|
833
|
+
}
|
|
834
|
+
const foreignNames = refs.fieldNamesByAppRefName?.get(taskApp);
|
|
835
|
+
return wireRefName(normalized, {
|
|
836
|
+
...refs.owner,
|
|
837
|
+
appRefName: taskApp,
|
|
838
|
+
fieldNames: foreignNames ?? new Map(),
|
|
839
|
+
});
|
|
840
|
+
}
|
|
460
841
|
function valueToTf(value, refs) {
|
|
461
842
|
const catalog = token(value);
|
|
462
843
|
if (catalog !== undefined)
|
|
@@ -467,6 +848,10 @@ function valueToTf(value, refs) {
|
|
|
467
848
|
return value.map((item) => valueToTf(item, refs));
|
|
468
849
|
if (!isObject(value))
|
|
469
850
|
throw new EntityTfError(`unsupported automation value ${String(value)}`);
|
|
851
|
+
if (value.__unsafe === "platformId" && typeof value.value === "string") {
|
|
852
|
+
refs.owner.diagnostics.push(`automation raw UUID fallback ${JSON.stringify(value.value)} is source-org-only and non-portable`);
|
|
853
|
+
return value.value;
|
|
854
|
+
}
|
|
470
855
|
if ("value" in value && Object.keys(value).length === 1)
|
|
471
856
|
return valueToTf(value.value, refs);
|
|
472
857
|
if (isObject(value.variableReference) && typeof value.variableReference.id === "string") {
|
|
@@ -492,14 +877,24 @@ function valueToTf(value, refs) {
|
|
|
492
877
|
// resources' actual refs map - confirmed live via a real apply's
|
|
493
878
|
// "Invalid index" error. Their field names pass through verbatim.
|
|
494
879
|
const isFileReaderTask = target.type === "elementum_ai_file_read_task" || target.type === "elementum_file_reader_task";
|
|
495
|
-
|
|
880
|
+
// aiSearchTable's collection is `refs["All Records"]`, not recordSearch's
|
|
881
|
+
// globally-mapped `refs["All found records"]` (TS_REF_SEGMENT_TO_WIRE).
|
|
882
|
+
// Accept both the authoring segment and the already-rewritten wire name
|
|
883
|
+
// from rewriteForwardTaskRefName so either path emits the same key.
|
|
884
|
+
const isAiSearchTableRecords = target.type === "elementum_ai_search_table_task" &&
|
|
885
|
+
(value.taskReference.name === "records" || value.taskReference.name === "All Records");
|
|
886
|
+
const refKey = isFileReaderTask
|
|
887
|
+
? value.taskReference.name
|
|
888
|
+
: isAiSearchTableRecords
|
|
889
|
+
? "All Records"
|
|
890
|
+
: taskWireRefName(value.taskReference.name, value.taskReference.taskRefKey, refs);
|
|
496
891
|
return expr.resourceAttr(target.type, target.label, ["refs", { index: refKey }]);
|
|
497
892
|
}
|
|
498
893
|
if (isObject(value.forEachReference) && typeof value.forEachReference.forEachTaskRefKey === "string" && typeof value.forEachReference.name === "string") {
|
|
499
894
|
const target = refs.tasks.get(value.forEachReference.forEachTaskRefKey);
|
|
500
895
|
if (target === undefined)
|
|
501
896
|
throw new EntityTfError(`unresolved forEach ref "${value.forEachReference.forEachTaskRefKey}"`);
|
|
502
|
-
return expr.resourceAttr(target.type, target.label, ["refs", { index:
|
|
897
|
+
return expr.resourceAttr(target.type, target.label, ["inner", "refs", { index: forEachWireRefName(value.forEachReference.name, refs.owner) }]);
|
|
503
898
|
}
|
|
504
899
|
if (isObject(value.templateReference))
|
|
505
900
|
return templateToTf(value.templateReference, refs);
|
|
@@ -552,6 +947,22 @@ function filterReferenceToTf(value, refs) {
|
|
|
552
947
|
const fieldKey = parts[1];
|
|
553
948
|
const address = refs.owner.fieldAddresses.get(fieldKey);
|
|
554
949
|
const suffix = parts.slice(2).join(".");
|
|
950
|
+
// A bare reference to a PICKLIST field (STATUS/STAGE included —
|
|
951
|
+
// `serializeSystemFields` wire-wraps both as a picklist too) has no
|
|
952
|
+
// valid suffix-less wire form — confirmed live via the platform's
|
|
953
|
+
// own switch-case editor, which always sends an explicit `.id`
|
|
954
|
+
// (compare by the chosen option's real id) or `.label` (compare by
|
|
955
|
+
// display text, unvalidated) and never a bare `record.<fieldId>`.
|
|
956
|
+
// Force the author to say which one they mean rather than guessing:
|
|
957
|
+
// a silent default reads as correct right up until the platform
|
|
958
|
+
// evaluates the two conventions differently, and there is no
|
|
959
|
+
// apply-time signal to catch that (the wire string is opaque to
|
|
960
|
+
// the provider).
|
|
961
|
+
if (suffix.length === 0 && refs.owner.fieldMetadata.get(fieldKey)?.fieldType === "PICKLIST") {
|
|
962
|
+
throw new EntityTfError(`filter reference to picklist field "${fieldKey}" is ambiguous — write ".id" ` +
|
|
963
|
+
`(ctx.trigger.record.${fieldKey}.id, compare by the option's id) or ".label" ` +
|
|
964
|
+
`(ctx.trigger.record.${fieldKey}.label, compare by display text) explicitly.`);
|
|
965
|
+
}
|
|
555
966
|
if (address !== undefined) {
|
|
556
967
|
return expr.template([
|
|
557
968
|
"trigger.record.",
|
|
@@ -594,7 +1005,7 @@ function filterReferenceToTf(value, refs) {
|
|
|
594
1005
|
const task = refs.tasks.get(value.taskRefKey);
|
|
595
1006
|
if (task === undefined)
|
|
596
1007
|
throw new EntityTfError(`unresolved task filter ref "${value.taskRefKey}"`);
|
|
597
|
-
return expr.resourceAttr(task.type, task.label, ["refs", { index: value.name }]);
|
|
1008
|
+
return expr.resourceAttr(task.type, task.label, ["refs", { index: taskWireRefName(value.name, value.taskRefKey, refs) }]);
|
|
598
1009
|
}
|
|
599
1010
|
case "FOR_EACH": {
|
|
600
1011
|
if (typeof value.forEachTaskRefKey !== "string" || typeof value.name !== "string")
|
|
@@ -602,7 +1013,7 @@ function filterReferenceToTf(value, refs) {
|
|
|
602
1013
|
const task = refs.tasks.get(value.forEachTaskRefKey);
|
|
603
1014
|
if (task === undefined)
|
|
604
1015
|
throw new EntityTfError(`unresolved forEach filter ref "${value.forEachTaskRefKey}"`);
|
|
605
|
-
return expr.resourceAttr(task.type, task.label, ["refs", { index: value.name }]);
|
|
1016
|
+
return expr.resourceAttr(task.type, task.label, ["inner", "refs", { index: forEachWireRefName(value.name, refs.owner) }]);
|
|
606
1017
|
}
|
|
607
1018
|
case "VALUE":
|
|
608
1019
|
return valueToTf(value.value, refs);
|
|
@@ -616,6 +1027,11 @@ function picklistFilterValueToTf(value, field, refs) {
|
|
|
616
1027
|
field.fieldType !== "PICKLIST" ||
|
|
617
1028
|
field.options === undefined)
|
|
618
1029
|
return undefined;
|
|
1030
|
+
// An empty value is the platform's explicit "clear this field" payload,
|
|
1031
|
+
// not a picklist option label. Preserve it verbatim instead of trying to
|
|
1032
|
+
// resolve it through the option-id lookup.
|
|
1033
|
+
if (value === "")
|
|
1034
|
+
return undefined;
|
|
619
1035
|
if (!field.options.includes(value)) {
|
|
620
1036
|
// Status/dropdown options can be deleted and recreated (new ids)
|
|
621
1037
|
// without the platform updating automations that already filtered on
|
|
@@ -629,16 +1045,39 @@ function picklistFilterValueToTf(value, field, refs) {
|
|
|
629
1045
|
return undefined;
|
|
630
1046
|
throw new EntityTfError(`automation filter for picklist field "${field.name ?? field.refName}" uses unknown option ${JSON.stringify(value)}; expected one of: ${field.options.map((option) => JSON.stringify(option)).join(", ")}`);
|
|
631
1047
|
}
|
|
1048
|
+
if (field.parent !== undefined && field.parentKind !== undefined) {
|
|
1049
|
+
// A field owned by a SIBLING app/element built in this same workspace
|
|
1050
|
+
// has its options-by-label local sourced from ITS OWN resource's
|
|
1051
|
+
// `options` attribute (the sibling's own `appendFieldLocals`/
|
|
1052
|
+
// `app/locals.ts` contribution) — the same naming a same-app field
|
|
1053
|
+
// gets below, just scoped to the sibling's tfLabel instead of the
|
|
1054
|
+
// automation's own app. Never the foreign `data.elementum_field`-backed
|
|
1055
|
+
// local: that local is only ever registered for a genuinely foreign
|
|
1056
|
+
// field (see `crossAppFieldToTf`'s sibling short-circuit).
|
|
1057
|
+
const sibling = refs.owner.workspaceAspects?.get(workspaceAspectKey(field.parentKind, field.parent));
|
|
1058
|
+
// Table siblings excluded for the same reason as in `crossAppFieldToTf`: a
|
|
1059
|
+
// picklist field's owner is an app or an element, never a table.
|
|
1060
|
+
if (sibling !== undefined && sibling.kind !== "table") {
|
|
1061
|
+
const localName = field.tags?.includes("STATUS")
|
|
1062
|
+
? `${sibling.tfLabel}_status_options_by_label`
|
|
1063
|
+
: field.tags?.includes("STAGE")
|
|
1064
|
+
? `${sibling.tfLabel}_stage_options_by_label`
|
|
1065
|
+
: `${scopedResourceLabel(sibling.tfLabel, tsLabelToTfLabel(field.refName), sibling.kind)}_options_by_label`;
|
|
1066
|
+
return expr.local(localName, [{ index: value }]);
|
|
1067
|
+
}
|
|
1068
|
+
}
|
|
632
1069
|
if (field.parent !== undefined && (field.parent !== refs.owner.appRefName || field.parentKind === "element")) {
|
|
633
|
-
//
|
|
634
|
-
//
|
|
635
|
-
//
|
|
636
|
-
//
|
|
637
|
-
//
|
|
638
|
-
//
|
|
639
|
-
//
|
|
640
|
-
//
|
|
641
|
-
|
|
1070
|
+
// A foreign field's options-by-label local is sourced from
|
|
1071
|
+
// `data.elementum_field.<label>.options` (issue #353) rather than an
|
|
1072
|
+
// owned resource's `options` attribute — `crossAppFieldToTf` registers
|
|
1073
|
+
// both the data block and the matching local; reuse the SAME naming
|
|
1074
|
+
// (`foreignFieldNaming`) so this reference always lines up with
|
|
1075
|
+
// whatever label that registration used, then make sure the data block
|
|
1076
|
+
// (and local) actually gets registered even when nothing else in this
|
|
1077
|
+
// payload resolves the field's id.
|
|
1078
|
+
const naming = foreignFieldNaming(field);
|
|
1079
|
+
crossAppFieldToTf(field, refs.owner, refs.dataBlocks);
|
|
1080
|
+
return expr.local(naming.fieldLabel + "_options_by_label", [{ index: value }]);
|
|
642
1081
|
}
|
|
643
1082
|
const localName = field.tags?.includes("STATUS")
|
|
644
1083
|
? `${refs.owner.appTfLabel}_status_options_by_label`
|
|
@@ -647,31 +1086,6 @@ function picklistFilterValueToTf(value, field, refs) {
|
|
|
647
1086
|
: `${scopedLabel(refs.owner.appTfLabel, tsLabelToTfLabel(field.refName))}_options_by_label`;
|
|
648
1087
|
return expr.local(localName, [{ index: value }]);
|
|
649
1088
|
}
|
|
650
|
-
function filterValueToTf(value, refs, field) {
|
|
651
|
-
if (!isObject(value) || typeof value.type !== "string")
|
|
652
|
-
return valueToTf(value, refs);
|
|
653
|
-
const type = value.type.toLowerCase();
|
|
654
|
-
const result = { type };
|
|
655
|
-
if (value.realType !== undefined)
|
|
656
|
-
result.real_type = String(value.realType).toLowerCase();
|
|
657
|
-
if (type === "current_user" && typeof value.currentUserType === "string") {
|
|
658
|
-
result.current_user_type = value.currentUserType;
|
|
659
|
-
}
|
|
660
|
-
if (value.value !== undefined) {
|
|
661
|
-
// The provider's `filter.value` schema splits "static" from "dynamic"
|
|
662
|
-
// across two distinct attributes — `value` vs `value_reference` — same
|
|
663
|
-
// split `left_value` already respects just above. A reference-typed
|
|
664
|
-
// value belongs under `value_reference`; the provider rejects it under
|
|
665
|
-
// `value` ("value_reference is required for reference type").
|
|
666
|
-
if (type === "reference") {
|
|
667
|
-
result.value_reference = filterReferenceToTf(value.value, refs);
|
|
668
|
-
}
|
|
669
|
-
else {
|
|
670
|
-
result.value = picklistFilterValueToTf(value.value, field, refs) ?? valueToTf(value.value, refs);
|
|
671
|
-
}
|
|
672
|
-
}
|
|
673
|
-
return result;
|
|
674
|
-
}
|
|
675
1089
|
function fieldFromFilterLeftValue(value, refs) {
|
|
676
1090
|
if (!isObject(value) || !isObject(value.value) || value.value.type?.toString().toUpperCase() !== "TRIGGER") {
|
|
677
1091
|
return undefined;
|
|
@@ -683,62 +1097,27 @@ function fieldFromFilterLeftValue(value, refs) {
|
|
|
683
1097
|
if (path[0] !== "record" || path.length < 2)
|
|
684
1098
|
return undefined;
|
|
685
1099
|
const refName = path[1];
|
|
1100
|
+
// Option-id resolution (picklistFilterValueToTf) only applies to the
|
|
1101
|
+
// ".id" convention `filterReferenceToTf` now requires for a picklist
|
|
1102
|
+
// field — an explicit ".label" (or any other drill-down suffix, e.g. a
|
|
1103
|
+
// USER field's ".email") compares raw text/whatever that sub-property
|
|
1104
|
+
// actually is, and must NOT have its value silently rewritten through
|
|
1105
|
+
// the options-by-label local.
|
|
1106
|
+
const suffix = path.slice(2).join(".");
|
|
1107
|
+
if (suffix !== "" && suffix !== "id")
|
|
1108
|
+
return undefined;
|
|
686
1109
|
const metadata = refs.owner.fieldMetadata.get(refName);
|
|
687
1110
|
if (metadata === undefined)
|
|
688
1111
|
return undefined;
|
|
689
1112
|
return { __kind: "field", refName, ...metadata };
|
|
690
1113
|
}
|
|
691
1114
|
function filterToTf(value, refs) {
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
continue;
|
|
699
|
-
if (key === "field") {
|
|
700
|
-
result.field_id = valueToTf(child, refs);
|
|
701
|
-
continue;
|
|
702
|
-
}
|
|
703
|
-
if (key === "leftValue") {
|
|
704
|
-
if (!isObject(child))
|
|
705
|
-
throw new EntityTfError("invalid filter leftValue");
|
|
706
|
-
result.left_value = {
|
|
707
|
-
value_reference: filterReferenceToTf(child.value, refs),
|
|
708
|
-
...(child.realType !== undefined ? { real_type: String(child.realType).toLowerCase() } : {}),
|
|
709
|
-
};
|
|
710
|
-
continue;
|
|
711
|
-
}
|
|
712
|
-
if (key === "children") {
|
|
713
|
-
if (!Array.isArray(child))
|
|
714
|
-
throw new EntityTfError("filter children must be an array");
|
|
715
|
-
result.children = child.map((item) => filterToTf(item, refs));
|
|
716
|
-
continue;
|
|
717
|
-
}
|
|
718
|
-
if (key === "value") {
|
|
719
|
-
result.value = filterValueToTf(child, refs, field);
|
|
720
|
-
continue;
|
|
721
|
-
}
|
|
722
|
-
if (key === "values") {
|
|
723
|
-
if (!Array.isArray(child))
|
|
724
|
-
throw new EntityTfError("filter values must be an array");
|
|
725
|
-
result.values = child.map((item) => filterValueToTf(item, refs, field));
|
|
726
|
-
continue;
|
|
727
|
-
}
|
|
728
|
-
if (key === "mode") {
|
|
729
|
-
if (typeof child !== "string")
|
|
730
|
-
throw new EntityTfError("filter mode must be a string");
|
|
731
|
-
result.mode = child.toLowerCase();
|
|
732
|
-
continue;
|
|
733
|
-
}
|
|
734
|
-
result[snake(key)] = valueToTf(child, refs);
|
|
735
|
-
}
|
|
736
|
-
// The platform silently defaults an unset LIKE mode to "legacy" and always
|
|
737
|
-
// echoes it back on export — emit it explicitly so build and export stay
|
|
738
|
-
// byte-fidelity equal instead of one omitting an attribute the other sets.
|
|
739
|
-
if (result.type === "like" && result.mode === undefined)
|
|
740
|
-
result.mode = "legacy";
|
|
741
|
-
return result;
|
|
1115
|
+
return serializeFilterToTf(value, {
|
|
1116
|
+
field: (field) => valueToTf(field, refs),
|
|
1117
|
+
fieldFromLeftValue: (left) => fieldFromFilterLeftValue(left, refs),
|
|
1118
|
+
reference: (reference) => filterReferenceToTf(reference, refs),
|
|
1119
|
+
literal: (literal, field) => picklistFilterValueToTf(literal, token(field), refs) ?? valueToTf(literal, refs),
|
|
1120
|
+
});
|
|
742
1121
|
}
|
|
743
1122
|
function configAttrs(kind, config, refs) {
|
|
744
1123
|
const attrs = {};
|
|
@@ -840,20 +1219,39 @@ function configAttrs(kind, config, refs) {
|
|
|
840
1219
|
const reference = item.calculationReference;
|
|
841
1220
|
if (!isObject(reference.templateReference))
|
|
842
1221
|
throw new EntityTfError("calculation expression is not a template reference");
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
1222
|
+
let includeType = "AUTO";
|
|
1223
|
+
let picklistFieldId;
|
|
1224
|
+
if (Array.isArray(item.includeTypes)) {
|
|
1225
|
+
let hasAuto = false;
|
|
1226
|
+
let hasManual = false;
|
|
1227
|
+
for (const include of item.includeTypes) {
|
|
1228
|
+
if (!isObject(include))
|
|
1229
|
+
continue;
|
|
1230
|
+
if (isObject(include.auto))
|
|
1231
|
+
hasAuto = true;
|
|
1232
|
+
if (isObject(include.manual))
|
|
1233
|
+
hasManual = true;
|
|
1234
|
+
if (isObject(include.picklist)) {
|
|
1235
|
+
includeType = "PICKLIST";
|
|
1236
|
+
if (include.picklist.picklistFieldId !== undefined) {
|
|
1237
|
+
picklistFieldId = valueToTf(include.picklist.picklistFieldId, refs);
|
|
1238
|
+
}
|
|
1239
|
+
}
|
|
1240
|
+
}
|
|
1241
|
+
if (includeType !== "PICKLIST") {
|
|
1242
|
+
includeType = hasAuto && hasManual ? "BOTH" : hasManual ? "MANUAL" : "AUTO";
|
|
850
1243
|
}
|
|
851
|
-
formula = valueToTf(parameter.value.value, refs);
|
|
852
|
-
}
|
|
853
|
-
else {
|
|
854
|
-
formula = templateToTf(template, refs);
|
|
855
1244
|
}
|
|
856
|
-
return {
|
|
1245
|
+
return {
|
|
1246
|
+
...(typeof item.id === "string" ? { id: item.id } : {}),
|
|
1247
|
+
variable_name: item.name,
|
|
1248
|
+
formula: calculationFormulaToTf(reference.templateReference, refs),
|
|
1249
|
+
...(includeType !== "AUTO" ? { include_type: includeType } : {}),
|
|
1250
|
+
...(picklistFieldId !== undefined ? { picklist_field_id: picklistFieldId } : {}),
|
|
1251
|
+
...(item.recordId !== null && item.recordId !== undefined
|
|
1252
|
+
? { record_id: valueToTf(item.recordId, refs) }
|
|
1253
|
+
: {}),
|
|
1254
|
+
};
|
|
857
1255
|
});
|
|
858
1256
|
continue;
|
|
859
1257
|
}
|
|
@@ -888,9 +1286,18 @@ function configAttrs(kind, config, refs) {
|
|
|
888
1286
|
attrs.fields = raw.map((field) => {
|
|
889
1287
|
if (!isObject(field))
|
|
890
1288
|
throw new EntityTfError("workflow field must be an object");
|
|
1289
|
+
const fieldToken = isObject(field.aspectFieldId) && typeof field.aspectFieldId.__kind === "string"
|
|
1290
|
+
? field.aspectFieldId
|
|
1291
|
+
: undefined;
|
|
1292
|
+
const staticValue = isObject(field.valueReference) && "value" in field.valueReference
|
|
1293
|
+
? field.valueReference.value
|
|
1294
|
+
: undefined;
|
|
1295
|
+
const optionValue = staticValue !== undefined
|
|
1296
|
+
? picklistFilterValueToTf(staticValue, fieldToken, refs)
|
|
1297
|
+
: undefined;
|
|
891
1298
|
return {
|
|
892
1299
|
field_id: valueToTf(field.aspectFieldId, refs),
|
|
893
|
-
value: valueToTf(field.valueReference, refs),
|
|
1300
|
+
value: optionValue ?? valueToTf(field.valueReference, refs),
|
|
894
1301
|
};
|
|
895
1302
|
});
|
|
896
1303
|
continue;
|
|
@@ -1063,7 +1470,7 @@ function taskLabel(automationLabel, refKey) {
|
|
|
1063
1470
|
const normalized = sanitizeName(refKey);
|
|
1064
1471
|
return normalized.startsWith(`${automationLabel}_`) ? normalized : `${automationLabel}_${normalized}`;
|
|
1065
1472
|
}
|
|
1066
|
-
/** App-owned `
|
|
1473
|
+
/** App- or element-owned `automation` entity → provider HCL blocks. */
|
|
1067
1474
|
export function automationToTf(entity, ctx) {
|
|
1068
1475
|
const owner = {
|
|
1069
1476
|
appRefName: ctx.appRefName ?? entity.parent,
|
|
@@ -1072,6 +1479,9 @@ export function automationToTf(entity, ctx) {
|
|
|
1072
1479
|
fieldNames: ctx.fieldNames ?? new Map(),
|
|
1073
1480
|
fieldMetadata: ctx.fieldMetadata ?? new Map(),
|
|
1074
1481
|
orgRefs: ctx.orgRefs,
|
|
1482
|
+
localsAttrs: ctx.localsAttrs,
|
|
1483
|
+
workspaceAspects: ctx.workspaceAspects,
|
|
1484
|
+
diagnostics: ctx.diagnostics ?? [],
|
|
1075
1485
|
};
|
|
1076
1486
|
if (entity.kind !== "automation")
|
|
1077
1487
|
throw new EntityTfError(`automationToTf expects kind "automation"; got "${entity.kind}"`);
|
|
@@ -1089,12 +1499,32 @@ export function automationToTf(entity, ctx) {
|
|
|
1089
1499
|
type: AUTOMATION_RESOURCE_TYPE,
|
|
1090
1500
|
label,
|
|
1091
1501
|
attrs: {
|
|
1092
|
-
app_id: expr.resourceAttr("elementum_app", ctx.appTfLabel, ["id"]),
|
|
1502
|
+
app_id: expr.resourceAttr(ctx.parentScope === "element" ? "elementum_element" : "elementum_app", ctx.appTfLabel, ["id"]),
|
|
1093
1503
|
name: payload.name ?? "",
|
|
1094
1504
|
...(payload.description !== undefined ? { description: payload.description } : {}),
|
|
1095
1505
|
...(payload.triggersOtherAutomations !== undefined ? { triggers_other_automations: payload.triggersOtherAutomations } : {}),
|
|
1506
|
+
...(payload.status === "INACTIVE" ? { status: "INACTIVE" } : {}),
|
|
1096
1507
|
},
|
|
1097
1508
|
};
|
|
1509
|
+
if (payload.serviceAccount !== undefined) {
|
|
1510
|
+
if (payload.serviceAccount.appRefName !== owner.appRefName) {
|
|
1511
|
+
throw new EntityTfError(`automation "${entity.refName}" service account belongs to app "${payload.serviceAccount.appRefName}", not "${owner.appRefName}"`);
|
|
1512
|
+
}
|
|
1513
|
+
const local = Object.entries(ctx.serviceAccounts ?? {}).find(([, account]) => `${account.firstName} ${account.lastName}` === payload.serviceAccount.name);
|
|
1514
|
+
if (local !== undefined) {
|
|
1515
|
+
automation.attrs.service_account_id = expr.resourceAttr(SERVICE_ACCOUNT_RESOURCE_TYPE, appScopedResourceLabel(owner.appTfLabel, tsLabelToTfLabel(local[0])), ["id"]);
|
|
1516
|
+
}
|
|
1517
|
+
else if (owner.orgRefs !== undefined) {
|
|
1518
|
+
const lookupLabel = sanitizeName(payload.serviceAccount.name);
|
|
1519
|
+
owner.orgRefs.rawLookup(SERVICE_ACCOUNT_RESOURCE_TYPE, lookupLabel, payload.serviceAccount.name, {
|
|
1520
|
+
app_id: expr.resourceAttr("elementum_app", owner.appTfLabel, ["id"]),
|
|
1521
|
+
});
|
|
1522
|
+
automation.attrs.service_account_id = expr.dataAttr(SERVICE_ACCOUNT_RESOURCE_TYPE, lookupLabel, ["id"]);
|
|
1523
|
+
}
|
|
1524
|
+
else {
|
|
1525
|
+
throw new EntityTfError(`automation "${entity.refName}" cannot resolve service account "${payload.serviceAccount.name}"`);
|
|
1526
|
+
}
|
|
1527
|
+
}
|
|
1098
1528
|
const [triggerKey, triggerConfig] = onlyEntry(payload.trigger, `automation "${entity.refName}" trigger`);
|
|
1099
1529
|
const triggerType = TRIGGER_RESOURCES[triggerKey];
|
|
1100
1530
|
if (triggerType === undefined)
|
|
@@ -1133,7 +1563,16 @@ export function automationToTf(entity, ctx) {
|
|
|
1133
1563
|
};
|
|
1134
1564
|
preRegister(payload.tasks ?? []);
|
|
1135
1565
|
const dataBlocks = new Map();
|
|
1136
|
-
const
|
|
1566
|
+
const recordFieldContext = recordFieldContextOf(entity);
|
|
1567
|
+
const refs = {
|
|
1568
|
+
trigger: { type: triggerType, label },
|
|
1569
|
+
tasks: taskRefs,
|
|
1570
|
+
owner,
|
|
1571
|
+
dataBlocks,
|
|
1572
|
+
variableById,
|
|
1573
|
+
...(recordFieldContext !== undefined ? { recordFieldContext } : {}),
|
|
1574
|
+
...(ctx.fieldNamesByAppRefName !== undefined ? { fieldNamesByAppRefName: ctx.fieldNamesByAppRefName } : {}),
|
|
1575
|
+
};
|
|
1137
1576
|
let triggerAttrs;
|
|
1138
1577
|
try {
|
|
1139
1578
|
triggerAttrs = configAttrs(triggerType, triggerConfig, refs);
|
|
@@ -1216,8 +1655,12 @@ export function automationToTf(entity, ctx) {
|
|
|
1216
1655
|
if (target === undefined || target.__kind !== "automation")
|
|
1217
1656
|
throw new EntityTfError(`runAutomation task "${refKey}" has an unresolved target`);
|
|
1218
1657
|
const targetLabel = scopedLabel(owner.appTfLabel, tsLabelToTfLabel(target.refName));
|
|
1219
|
-
|
|
1220
|
-
|
|
1658
|
+
// A publish resource only exists for ACTIVE automations. Depending on
|
|
1659
|
+
// a draft/inactive target's publish address produces invalid HCL.
|
|
1660
|
+
if (ctx.activeAutomationRefNames?.has(target.refName) === true) {
|
|
1661
|
+
block.attrs.depends_on = [expr.resourceAttr(WORKFLOW_PUBLISH_RESOURCE_TYPE, targetLabel)];
|
|
1662
|
+
runAutomationPublishes.add(targetLabel);
|
|
1663
|
+
}
|
|
1221
1664
|
}
|
|
1222
1665
|
blocks.push(block);
|
|
1223
1666
|
const address = expr.resourceAttr(resourceType, tfLabel);
|
|
@@ -1230,9 +1673,12 @@ export function automationToTf(entity, ctx) {
|
|
|
1230
1673
|
const children = task.children ?? [];
|
|
1231
1674
|
if (children.length !== 1)
|
|
1232
1675
|
throw new EntityTfError(`forEach task "${refKey}" must have exactly one child body`);
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1676
|
+
emitTasks(children[0].tasks ?? [], expr.resourceAttr(resourceType, tfLabel, ["inner"]));
|
|
1677
|
+
// The loop body is a separate operator-owned chain. A fluent sibling
|
|
1678
|
+
// authored after `forEach` continues from the for_each task itself,
|
|
1679
|
+
// not from the body's terminal task; the latter silently moves that
|
|
1680
|
+
// sibling into the loop and produces an invalid workflow graph.
|
|
1681
|
+
parent = address;
|
|
1236
1682
|
}
|
|
1237
1683
|
else if (wireType === "switch" || wireType === "forkJoin") {
|
|
1238
1684
|
const children = task.children ?? [];
|
|
@@ -1297,7 +1743,7 @@ export function automationToTf(entity, ctx) {
|
|
|
1297
1743
|
if (fileReaderDeps.length > 0) {
|
|
1298
1744
|
automation.attrs.depends_on = fileReaderDeps;
|
|
1299
1745
|
}
|
|
1300
|
-
{
|
|
1746
|
+
if (payload.status === "ACTIVE") {
|
|
1301
1747
|
const outputValues = payload.outputProperties?.outputs ?? [];
|
|
1302
1748
|
const publish = {
|
|
1303
1749
|
kind: "resource",
|