@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,9 +1,13 @@
|
|
|
1
|
-
import { EntityTfError } from "../../engine/entity.js";
|
|
2
|
-
import { OUTPUT_KEY_WIRE_NAME } from "./output-key-wire-name.js";
|
|
3
1
|
import { USER_FIELD_KEYS } from "../../catalog/types.js";
|
|
4
2
|
import { DEPLOY_DEFAULT_SYSTEM_FIELD_NAMES, SYSTEM_FIELD_KEYS } from "../../core/system-fields.js";
|
|
3
|
+
import { EntityTfError } from "../../engine/entity.js";
|
|
5
4
|
import { bareChildResourceLabel, childPartFromScopedLabel, isTfExpr, sanitizeName, scopedLabelToBagKey, tfLabelToTsLabel, } from "../../engine/tf/index.js";
|
|
6
5
|
import { IMPLEMENTED_FILE_READER_RESOURCE_TYPES } from "../file-reader/types.js";
|
|
6
|
+
import { connectorIdentityFromTf } from "../shared/connector-from-tf.js";
|
|
7
|
+
import { UNRESOLVED_FIELD_MARKER } from "../shared/ref.js";
|
|
8
|
+
import { filterFromTf as deserializeFilterFromTf } from "../shared/filters/tf-codec.js";
|
|
9
|
+
import { TABLE_RESOURCE_TYPE } from "../table/module.js";
|
|
10
|
+
import { OUTPUT_KEY_WIRE_NAME } from "./output-key-wire-name.js";
|
|
7
11
|
import { ALL_AUTOMATION_TASK_TYPE_SET, AUTOMATION_BRANCH_TYPE_SET, AUTOMATION_RESOURCE_TYPE, AUTOMATION_TRIGGER_TYPE_SET, WORKFLOW_PUBLISH_RESOURCE_TYPE, } from "./types.js";
|
|
8
12
|
const TRIGGER_KINDS = {
|
|
9
13
|
elementum_record_created_trigger: "recordCreate",
|
|
@@ -77,6 +81,7 @@ const ATTR_TO_ARG = {
|
|
|
77
81
|
response_type: "responseType",
|
|
78
82
|
continue_on_error: "continueOnError",
|
|
79
83
|
search_table_id: "table",
|
|
84
|
+
phone_service_id: "phoneService",
|
|
80
85
|
text_to_summarize: "text",
|
|
81
86
|
text_to_classify: "text",
|
|
82
87
|
field_type: "fieldType",
|
|
@@ -168,6 +173,7 @@ const TASK_ATTRIBUTES = new Set([
|
|
|
168
173
|
"synchronous", "cloudlink_id", "stored_function_id", "variable_reference",
|
|
169
174
|
"relate_to_record_reference", "method", "parameters", "headers",
|
|
170
175
|
"basic_auth", "bearer_auth", "oauth", "json_body", "form_body", "custom_body", "multipart_body",
|
|
176
|
+
"query",
|
|
171
177
|
]);
|
|
172
178
|
const BRANCH_ATTRIBUTES = new Set([
|
|
173
179
|
"switch_task", "fork_join_task", "label", "is_default", "filter",
|
|
@@ -225,6 +231,54 @@ function pathNames(path) {
|
|
|
225
231
|
return WIRE_REF_SEGMENT_TO_TS[name] ?? name;
|
|
226
232
|
});
|
|
227
233
|
}
|
|
234
|
+
/**
|
|
235
|
+
* Resolve one platform field ref name (for example `"Facility"` or
|
|
236
|
+
* `"Created By Email"`) to the typed record path exposed by the public
|
|
237
|
+
* automation context. Shared by record-bearing trigger refs and
|
|
238
|
+
* create-record task outputs; both use the same display-name + suffix wire
|
|
239
|
+
* convention.
|
|
240
|
+
*/
|
|
241
|
+
function recordFieldRefPath(wireName, ctx) {
|
|
242
|
+
// Case-insensitive: the platform re-cases "By" to "by" when building some
|
|
243
|
+
// compound ref phrases (e.g. field "Created By" -> ref key "Created by
|
|
244
|
+
// Email").
|
|
245
|
+
const wireNameLower = wireName.toLowerCase();
|
|
246
|
+
for (const field of ctx.fieldById.values()) {
|
|
247
|
+
for (const [suffix, suffixPath] of FIELD_REF_SUFFIX_FROM_WIRE) {
|
|
248
|
+
if (wireNameLower === `${field.name}${suffix}`.toLowerCase()) {
|
|
249
|
+
return ["record", field.key, ...suffixPath];
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
// System fields have no `*_field` resource block, so they never appear in
|
|
254
|
+
// fieldById. Match their provider-default display names explicitly.
|
|
255
|
+
for (const key of SYSTEM_FIELD_KEYS) {
|
|
256
|
+
const defaultName = DEPLOY_DEFAULT_SYSTEM_FIELD_NAMES[key];
|
|
257
|
+
for (const [suffix, suffixPath] of FIELD_REF_SUFFIX_FROM_WIRE) {
|
|
258
|
+
if (wireNameLower === `${defaultName}${suffix}`.toLowerCase()) {
|
|
259
|
+
return ["record", key, ...suffixPath];
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
return undefined;
|
|
264
|
+
}
|
|
265
|
+
const RECORD_BEARING_TRIGGER_TYPES = new Set([
|
|
266
|
+
"elementum_record_created_trigger",
|
|
267
|
+
"elementum_record_updated_trigger",
|
|
268
|
+
"elementum_attachment_added_trigger",
|
|
269
|
+
"elementum_comment_added_trigger",
|
|
270
|
+
"elementum_approval_chain_trigger",
|
|
271
|
+
// On-demand workflows can also be launched with record context. Declared
|
|
272
|
+
// parameters take precedence below so a parameter named like a field does
|
|
273
|
+
// not get misclassified as `ctx.trigger.record.<field>`.
|
|
274
|
+
"elementum_on_demand_trigger",
|
|
275
|
+
]);
|
|
276
|
+
function isDeclaredOnDemandParameter(trigger, wireName) {
|
|
277
|
+
if (trigger.type !== "elementum_on_demand_trigger")
|
|
278
|
+
return false;
|
|
279
|
+
const parameters = trigger.attrs.parameters;
|
|
280
|
+
return Array.isArray(parameters) && parameters.some((parameter) => isObject(parameter) && parameter.name === wireName);
|
|
281
|
+
}
|
|
228
282
|
// recordSearch's own output ref names ("Records Size" -> totalCount, "All
|
|
229
283
|
// found records" -> records) — deliberately NOT in WIRE_REF_SEGMENT_TO_TS,
|
|
230
284
|
// which triggerRefPath also consults: a record-created/updated trigger's ref
|
|
@@ -238,6 +292,13 @@ const RECORD_SEARCH_TASK_REF_SEGMENT_TO_TS = {
|
|
|
238
292
|
"Records Size": "totalCount",
|
|
239
293
|
"All found records": "records",
|
|
240
294
|
};
|
|
295
|
+
// aiSearchTable's own output ref name — same scoping reason as
|
|
296
|
+
// RECORD_SEARCH_TASK_REF_SEGMENT_TO_TS: "All Records" is a platform-fixed
|
|
297
|
+
// wire key on elementum_ai_search_table_task only. A trigger field could
|
|
298
|
+
// coincidentally share that display name and must not be rewritten here.
|
|
299
|
+
const AI_SEARCH_TABLE_TASK_REF_SEGMENT_TO_TS = {
|
|
300
|
+
"All Records": "records",
|
|
301
|
+
};
|
|
241
302
|
/**
|
|
242
303
|
* A webhook trigger's `body`/`headers` refs come back as "Body (Plain
|
|
243
304
|
* Text)"/"Headers (Content-Type)" - one wire segment naming both the
|
|
@@ -252,16 +313,98 @@ const RECORD_SEARCH_TASK_REF_SEGMENT_TO_TS = {
|
|
|
252
313
|
* convention.
|
|
253
314
|
*/
|
|
254
315
|
const WEBHOOK_REF_PATTERN = /^(Body|Headers) \((.+)\)$/;
|
|
316
|
+
function aspectOwnerRefNameFromObjectId(objectId, appRefName, appTfLabel) {
|
|
317
|
+
if (!isTfExpr(objectId))
|
|
318
|
+
return undefined;
|
|
319
|
+
if (objectId.$expr === "data-attr" && (objectId.type === "elementum_app" || objectId.type === "elementum_element") && objectId.path[0] === "id") {
|
|
320
|
+
return tfLabelToTsLabel(objectId.label);
|
|
321
|
+
}
|
|
322
|
+
if (objectId.$expr === "resource-attr" && objectId.type === "elementum_app" && objectId.label === appTfLabel && objectId.path[0] === "id") {
|
|
323
|
+
return appRefName;
|
|
324
|
+
}
|
|
325
|
+
if (objectId.$expr === "resource-attr" && objectId.type === "elementum_element" && objectId.path[0] === "id") {
|
|
326
|
+
return tfLabelToTsLabel(objectId.label);
|
|
327
|
+
}
|
|
328
|
+
return undefined;
|
|
329
|
+
}
|
|
330
|
+
function lookupFieldKeyByDisplayName(ownerRefName, displayName, ctx) {
|
|
331
|
+
const lower = displayName.toLowerCase();
|
|
332
|
+
const foreign = ctx.fieldNamesByOwnerRefName?.get(ownerRefName)?.get(lower);
|
|
333
|
+
if (foreign !== undefined)
|
|
334
|
+
return foreign;
|
|
335
|
+
if (ownerRefName === ctx.appRefName) {
|
|
336
|
+
for (const field of ctx.fieldById.values()) {
|
|
337
|
+
if (field.name.toLowerCase() === lower)
|
|
338
|
+
return field.key;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
for (const key of SYSTEM_FIELD_KEYS) {
|
|
342
|
+
if (DEPLOY_DEFAULT_SYSTEM_FIELD_NAMES[key].toLowerCase() === lower)
|
|
343
|
+
return key;
|
|
344
|
+
}
|
|
345
|
+
return undefined;
|
|
346
|
+
}
|
|
347
|
+
function taskRecordSearchFieldPath(taskAddress, wireName, ctx) {
|
|
348
|
+
if (ctx.taskTargetOwnerRefNameByAddress?.get(taskAddress) === undefined)
|
|
349
|
+
return undefined;
|
|
350
|
+
const ownerRefName = ctx.taskTargetOwnerRefNameByAddress.get(taskAddress);
|
|
351
|
+
const wireNameLower = wireName.toLowerCase();
|
|
352
|
+
for (const [suffix, suffixPath] of FIELD_REF_SUFFIX_FROM_WIRE) {
|
|
353
|
+
for (const base of suffix === "" ? [wireName] : wireName.endsWith(suffix) ? [wireName.slice(0, -suffix.length)] : []) {
|
|
354
|
+
const fieldKey = lookupFieldKeyByDisplayName(ownerRefName, base, ctx);
|
|
355
|
+
if (fieldKey !== undefined && (suffix === "" || wireNameLower === `${base}${suffix}`.toLowerCase())) {
|
|
356
|
+
return ["record", fieldKey, ...suffixPath];
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
return undefined;
|
|
361
|
+
}
|
|
362
|
+
function decodeFieldAssignmentValue(value, ctx) {
|
|
363
|
+
if (typeof value === "string" && /^[a-f0-9-]{36}$/i.test(value)) {
|
|
364
|
+
const label = ctx.picklistOptionLabelById?.get(value);
|
|
365
|
+
if (label !== undefined)
|
|
366
|
+
return { kind: "literal", value: label };
|
|
367
|
+
}
|
|
368
|
+
return decodeValue(value, ctx);
|
|
369
|
+
}
|
|
255
370
|
function triggerRefPath(path, ctx) {
|
|
256
371
|
const names = pathNames(path);
|
|
257
372
|
if (names.length !== 1)
|
|
258
373
|
return names;
|
|
259
374
|
const wireName = names[0];
|
|
375
|
+
// Attachment-trigger payload refs ("Attachment" / "Attachment Id") — gated
|
|
376
|
+
// on the trigger type and compared case-sensitively. Field matching below
|
|
377
|
+
// is case-insensitive and uses suffix " ID"; for a coincidental field named
|
|
378
|
+
// "Attachment", refs["Attachment ID"] is the field path
|
|
379
|
+
// (ctx.trigger.record.<key>.id) while refs["Attachment Id"] is the trigger
|
|
380
|
+
// ATTACHMENT_ID payload (ctx.trigger.attachment.id). Those strings collide
|
|
381
|
+
// under .toLowerCase(), so this match must stay exact and must NOT reuse
|
|
382
|
+
// FIELD_REF_SUFFIX_FROM_WIRE.
|
|
383
|
+
if (ctx.trigger.type === "elementum_attachment_added_trigger") {
|
|
384
|
+
if (wireName === "Attachment")
|
|
385
|
+
return ["attachment"];
|
|
386
|
+
if (wireName === "Attachment Id")
|
|
387
|
+
return ["attachment", "id"];
|
|
388
|
+
}
|
|
260
389
|
if (ctx.trigger.type === "elementum_webhook_trigger") {
|
|
261
390
|
const webhookMatch = WEBHOOK_REF_PATTERN.exec(wireName);
|
|
262
391
|
if (webhookMatch)
|
|
263
392
|
return [webhookMatch[1].toLowerCase(), webhookMatch[2]];
|
|
264
393
|
}
|
|
394
|
+
if (ctx.trigger.type === "elementum_on_demand_trigger") {
|
|
395
|
+
if (wireName === "Triggered By's Id")
|
|
396
|
+
return ["triggeredBy", "id"];
|
|
397
|
+
if (wireName === "Triggered By's Name")
|
|
398
|
+
return ["triggeredBy", "name"];
|
|
399
|
+
if (wireName === "Triggered By's Email")
|
|
400
|
+
return ["triggeredBy", "email"];
|
|
401
|
+
}
|
|
402
|
+
// An on-demand parameter is an explicitly declared top-level ctx.trigger
|
|
403
|
+
// property. Check this before record-field inference: a perfectly ordinary
|
|
404
|
+
// parameter such as `FACILITY` can collide case-insensitively with the app
|
|
405
|
+
// field display name "Facility".
|
|
406
|
+
if (isDeclaredOnDemandParameter(ctx.trigger, wireName))
|
|
407
|
+
return names;
|
|
265
408
|
// A trigger's own bare record reference (confirmed live via `ei refs`,
|
|
266
409
|
// see trigger-record-id.test.ts) — deliberately scoped to triggerRefPath,
|
|
267
410
|
// not the shared WIRE_REF_SEGMENT_TO_TS table: createRecord/
|
|
@@ -273,34 +416,89 @@ function triggerRefPath(path, ctx) {
|
|
|
273
416
|
// types).
|
|
274
417
|
if (wireName === "Record")
|
|
275
418
|
return ["record"];
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
419
|
+
if (!RECORD_BEARING_TRIGGER_TYPES.has(ctx.trigger.type ?? ""))
|
|
420
|
+
return names;
|
|
421
|
+
return recordFieldRefPath(wireName, ctx) ?? names;
|
|
422
|
+
}
|
|
423
|
+
/**
|
|
424
|
+
* Resolve a forEach `.inner.refs["<display name>"]` key to the public record
|
|
425
|
+
* bag key used by `ctx.item`. The provider exposes current-item fields by
|
|
426
|
+
* display name (including system fields such as `"ID"`), while the authored
|
|
427
|
+
* TypeScript surface uses stable keys (`id`, custom field bag keys, and typed
|
|
428
|
+
* suffixes such as `.label`).
|
|
429
|
+
*/
|
|
430
|
+
function forEachItemRefPath(path, ctx) {
|
|
431
|
+
const names = pathNames(path);
|
|
432
|
+
if (names.length !== 1)
|
|
433
|
+
return names.flatMap((segment) => segment.split("."));
|
|
434
|
+
const wireName = names[0];
|
|
435
|
+
if (wireName === "Record")
|
|
436
|
+
return ["recordId"];
|
|
280
437
|
const wireNameLower = wireName.toLowerCase();
|
|
281
438
|
for (const field of ctx.fieldById.values()) {
|
|
282
439
|
for (const [suffix, suffixPath] of FIELD_REF_SUFFIX_FROM_WIRE) {
|
|
283
440
|
if (wireNameLower === `${field.name}${suffix}`.toLowerCase()) {
|
|
284
|
-
return [
|
|
441
|
+
return [field.key, ...suffixPath];
|
|
285
442
|
}
|
|
286
443
|
}
|
|
287
444
|
}
|
|
288
|
-
// System fields (id/title/status/stage/createdBy/updatedBy/...) have no
|
|
289
|
-
// `*_field` resource block of their own - they're elementum_app computed
|
|
290
|
-
// attributes, so they never appear in ctx.fieldById. Try their canonical
|
|
291
|
-
// bag keys against the provider's default display name too (e.g.
|
|
292
|
-
// "Created By" + " Email"). A renamed system field's ref key won't match
|
|
293
|
-
// here and falls through to the raw-name fallback below - no worse than
|
|
294
|
-
// today, since system fields were never matched at all before this.
|
|
295
445
|
for (const key of SYSTEM_FIELD_KEYS) {
|
|
296
446
|
const defaultName = DEPLOY_DEFAULT_SYSTEM_FIELD_NAMES[key];
|
|
297
447
|
for (const [suffix, suffixPath] of FIELD_REF_SUFFIX_FROM_WIRE) {
|
|
298
448
|
if (wireNameLower === `${defaultName}${suffix}`.toLowerCase()) {
|
|
299
|
-
return [
|
|
449
|
+
return [key, ...suffixPath];
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
return names.flatMap((segment) => segment.split("."));
|
|
454
|
+
}
|
|
455
|
+
function resolveTaskRefKey(taskIdOrKey, ctx) {
|
|
456
|
+
if (/^[a-f0-9-]{36}$/.test(taskIdOrKey)) {
|
|
457
|
+
for (const [address, task] of ctx.taskByAddress) {
|
|
458
|
+
if (ctx.resourceImportIds.get(address) === taskIdOrKey) {
|
|
459
|
+
return { refKey: task.refKey, block: task.block };
|
|
300
460
|
}
|
|
301
461
|
}
|
|
302
462
|
}
|
|
303
|
-
|
|
463
|
+
for (const [, task] of ctx.taskByAddress) {
|
|
464
|
+
if (task.refKey === taskIdOrKey)
|
|
465
|
+
return { refKey: task.refKey, block: task.block };
|
|
466
|
+
}
|
|
467
|
+
return { refKey: taskIdOrKey };
|
|
468
|
+
}
|
|
469
|
+
function decodeTaskReferenceFromString(taskIdOrKey, pathSegments, ctx) {
|
|
470
|
+
const { refKey, block } = resolveTaskRefKey(taskIdOrKey, ctx);
|
|
471
|
+
if (block?.type === "elementum_record_search_task" && pathSegments.length >= 1) {
|
|
472
|
+
const [head, ...tail] = pathSegments;
|
|
473
|
+
if (head === "count") {
|
|
474
|
+
return { kind: "taskRef", task: refKey, path: ["totalCount", ...tail] };
|
|
475
|
+
}
|
|
476
|
+
const recordSearchName = RECORD_SEARCH_TASK_REF_SEGMENT_TO_TS[head];
|
|
477
|
+
if (recordSearchName !== undefined) {
|
|
478
|
+
return { kind: "taskRef", task: refKey, path: [recordSearchName, ...tail] };
|
|
479
|
+
}
|
|
480
|
+
const taskAddress = block.label !== undefined ? `${block.type}.${block.label}` : undefined;
|
|
481
|
+
if (taskAddress !== undefined) {
|
|
482
|
+
const recordFieldPath = taskRecordSearchFieldPath(taskAddress, head, ctx);
|
|
483
|
+
if (recordFieldPath !== undefined) {
|
|
484
|
+
return { kind: "taskRef", task: refKey, path: [...recordFieldPath, ...tail] };
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
if (block?.type === "elementum_ai_search_table_task" && pathSegments.length >= 1) {
|
|
489
|
+
const [head, ...tail] = pathSegments;
|
|
490
|
+
const aiSearchName = AI_SEARCH_TABLE_TASK_REF_SEGMENT_TO_TS[head];
|
|
491
|
+
if (aiSearchName !== undefined) {
|
|
492
|
+
return { kind: "taskRef", task: refKey, path: [aiSearchName, ...tail] };
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
const keyPath = pathSegments.map((segment) => WIRE_REF_SEGMENT_TO_TS[segment] ?? segment);
|
|
496
|
+
const taskKind = block?.type !== undefined ? TASK_FACTORIES[block.type] : undefined;
|
|
497
|
+
const wireOutputKey = taskKind !== undefined ? OUTPUT_KEY_WIRE_NAME[taskKind] : undefined;
|
|
498
|
+
const outputKeyPath = wireOutputKey !== undefined && keyPath[0] === wireOutputKey
|
|
499
|
+
? ["output", ...keyPath.slice(1)]
|
|
500
|
+
: keyPath;
|
|
501
|
+
return { kind: "taskRef", task: refKey, path: outputKeyPath };
|
|
304
502
|
}
|
|
305
503
|
function decodeReferenceString(value, ctx) {
|
|
306
504
|
const pieces = value.split(".");
|
|
@@ -309,6 +507,10 @@ function decodeReferenceString(value, ctx) {
|
|
|
309
507
|
if (path[0] === "record" && path.length >= 2 && /^[a-f0-9-]{36}$/.test(path[1])) {
|
|
310
508
|
const sourceFieldId = path[1];
|
|
311
509
|
const field = ctx.fieldById.get(sourceFieldId);
|
|
510
|
+
const stateField = ctx.foreignFieldRefsById?.get(sourceFieldId);
|
|
511
|
+
const stateFieldKey = stateField?.ownerRefName === ctx.appRefName
|
|
512
|
+
? stateField.fieldKey
|
|
513
|
+
: undefined;
|
|
312
514
|
// Orphaned: the field this filter's value_reference points at no
|
|
313
515
|
// longer exists in the app export at all (deleted/recreated field,
|
|
314
516
|
// same drift class as the orphaned picklist option ids and skill_ids
|
|
@@ -318,12 +520,16 @@ function decodeReferenceString(value, ctx) {
|
|
|
318
520
|
// unresolved-segment escape already degrades a non-identifier path
|
|
319
521
|
// segment like this one) rather than throwing and losing the whole
|
|
320
522
|
// automation.
|
|
321
|
-
return {
|
|
523
|
+
return {
|
|
524
|
+
kind: "triggerRef",
|
|
525
|
+
path: ["record", field?.key ?? stateFieldKey ?? sourceFieldId, ...path.slice(2)],
|
|
526
|
+
};
|
|
322
527
|
}
|
|
323
528
|
return { kind: "triggerRef", path };
|
|
324
529
|
}
|
|
325
|
-
if (pieces[0] === "task" && pieces.length > 2)
|
|
326
|
-
return
|
|
530
|
+
if (pieces[0] === "task" && pieces.length > 2) {
|
|
531
|
+
return decodeTaskReferenceFromString(pieces[1], pieces.slice(2), ctx);
|
|
532
|
+
}
|
|
327
533
|
// Any other/future value_reference shape - confirmed live: conciergeforfield's
|
|
328
534
|
// cff_find_nearby_accounts_if_user_is_impersonating_a_sales_rep switch_case
|
|
329
535
|
// references a workflow variable ("variable.<uuid>"); setVariable/variable_task
|
|
@@ -385,17 +591,21 @@ function fieldKeyFromTriggerFieldIdExpr(fieldPart, ctx) {
|
|
|
385
591
|
}
|
|
386
592
|
/** Same provider/model derivation as `agentFromTf` and `renderAiProvidersBag`, read off the stream's own data blocks. */
|
|
387
593
|
function resolveConnectorRef(connectorType, connectorLabel, ctx) {
|
|
388
|
-
const
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
594
|
+
const identity = connectorIdentityFromTf(connectorType, connectorLabel, {
|
|
595
|
+
dataName: (type, label) => {
|
|
596
|
+
const block = ctx.dataBlocks.get(`${type}.${label}`);
|
|
597
|
+
const key = type === "elementum_ai_provider_connector" ? "model_name" : "name";
|
|
598
|
+
const value = block?.attrs[key];
|
|
599
|
+
return typeof value === "string" ? value : undefined;
|
|
600
|
+
},
|
|
601
|
+
dataRef: (type, label) => {
|
|
602
|
+
const value = ctx.dataBlocks.get(`${type}.${label}`)?.attrs["provider_id"];
|
|
603
|
+
return value !== undefined && isTfExpr(value) && value.$expr === "data-attr"
|
|
604
|
+
? { resourceType: value.type, tfLabel: value.label }
|
|
605
|
+
: undefined;
|
|
606
|
+
},
|
|
607
|
+
});
|
|
608
|
+
return { handle: identity.handle, ...(identity.providerKey !== undefined && { providerKey: identity.providerKey }) };
|
|
399
609
|
}
|
|
400
610
|
function decodeValue(value, ctx) {
|
|
401
611
|
if (isTfExpr(value)) {
|
|
@@ -405,10 +615,20 @@ function decodeValue(value, ctx) {
|
|
|
405
615
|
if (value.$expr === "jsonencode")
|
|
406
616
|
return decodePlain(value.value, ctx);
|
|
407
617
|
if (value.$expr === "resource-attr") {
|
|
618
|
+
const optionLabel = picklistOptionLabel(value);
|
|
619
|
+
if (optionLabel !== undefined)
|
|
620
|
+
return { kind: "literal", value: optionLabel };
|
|
408
621
|
if (value.type === ctx.trigger.type && value.label === ctx.trigger.label && value.path[0] === "refs") {
|
|
409
622
|
return { kind: "triggerRef", path: triggerRefPath(value.path.slice(1), ctx) };
|
|
410
623
|
}
|
|
411
624
|
const task = ctx.taskByAddress.get(`${value.type}.${value.label}`);
|
|
625
|
+
if (task !== undefined && value.path[0] === "inner" && value.path[1] === "refs") {
|
|
626
|
+
return {
|
|
627
|
+
kind: "forEachItemRef",
|
|
628
|
+
forEachTask: task.refKey,
|
|
629
|
+
path: forEachItemRefPath(value.path.slice(2), ctx),
|
|
630
|
+
};
|
|
631
|
+
}
|
|
412
632
|
if (task !== undefined && value.path[0] === "refs") {
|
|
413
633
|
const rawSegments = pathNames(value.path.slice(1));
|
|
414
634
|
if (task.block.type === "elementum_record_search_task" && rawSegments.length === 1 && rawSegments[0] === "First found record id") {
|
|
@@ -420,18 +640,38 @@ function decodeValue(value, ctx) {
|
|
|
420
640
|
// provider's own schema docs (build.ts's rewriteForwardTaskRefName
|
|
421
641
|
// has the full citation). Previously unhandled here entirely — a
|
|
422
642
|
// pulled automation referencing this output round-tripped as a raw
|
|
423
|
-
// `ctx.
|
|
643
|
+
// `ctx.actions.<t>.Record` property access that doesn't exist on
|
|
424
644
|
// either task's typed output, failing tsc.
|
|
425
645
|
if ((task.block.type === "elementum_create_record_task" || task.block.type === "elementum_find_related_records_task") &&
|
|
426
646
|
rawSegments.length === 1 &&
|
|
427
|
-
rawSegments[0] === "Record") {
|
|
647
|
+
(rawSegments[0] === "Record" || rawSegments[0] === "Record ID")) {
|
|
428
648
|
return { kind: "taskRef", task: task.refKey, path: ["record", "recordId"] };
|
|
429
649
|
}
|
|
650
|
+
// A create-record task exposes each created record field by its
|
|
651
|
+
// display name (for example refs["Title"] or refs["Facility"]). Its
|
|
652
|
+
// public task output is the typed `.record` object, so restore that
|
|
653
|
+
// missing hop and canonical field key on pull.
|
|
654
|
+
if (task.block.type === "elementum_create_record_task" && rawSegments.length === 1) {
|
|
655
|
+
const recordPath = recordFieldRefPath(rawSegments[0], ctx);
|
|
656
|
+
if (recordPath !== undefined) {
|
|
657
|
+
return { kind: "taskRef", task: task.refKey, path: recordPath };
|
|
658
|
+
}
|
|
659
|
+
}
|
|
430
660
|
if (task.block.type === "elementum_record_search_task" && rawSegments.length === 1) {
|
|
431
661
|
const recordSearchName = RECORD_SEARCH_TASK_REF_SEGMENT_TO_TS[rawSegments[0]];
|
|
432
662
|
if (recordSearchName !== undefined) {
|
|
433
663
|
return { kind: "taskRef", task: task.refKey, path: [recordSearchName] };
|
|
434
664
|
}
|
|
665
|
+
const recordFieldPath = taskRecordSearchFieldPath(`${value.type}.${value.label}`, rawSegments[0], ctx);
|
|
666
|
+
if (recordFieldPath !== undefined) {
|
|
667
|
+
return { kind: "taskRef", task: task.refKey, path: recordFieldPath };
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
if (task.block.type === "elementum_ai_search_table_task" && rawSegments.length === 1) {
|
|
671
|
+
const aiSearchName = AI_SEARCH_TABLE_TASK_REF_SEGMENT_TO_TS[rawSegments[0]];
|
|
672
|
+
if (aiSearchName !== undefined) {
|
|
673
|
+
return { kind: "taskRef", task: task.refKey, path: [aiSearchName] };
|
|
674
|
+
}
|
|
435
675
|
}
|
|
436
676
|
const keyPath = rawSegments.flatMap((segment) => segment.split("."));
|
|
437
677
|
if (task.block.type === "elementum_variable_task") {
|
|
@@ -466,6 +706,31 @@ function decodeValue(value, ctx) {
|
|
|
466
706
|
if (value.type === "elementum_agent" && value.path[0] === "id") {
|
|
467
707
|
return { kind: "agent", appHandle: ctx.appRefName, agentKey: scopedLabelToBagKey(ctx.appTfLabel, value.label), name: value.label };
|
|
468
708
|
}
|
|
709
|
+
if (value.type === "elementum_phone_service" && value.path[0] === "id") {
|
|
710
|
+
return {
|
|
711
|
+
kind: "phoneService",
|
|
712
|
+
appHandle: ctx.appRefName,
|
|
713
|
+
phoneServiceKey: scopedLabelToBagKey(ctx.appTfLabel, value.label),
|
|
714
|
+
};
|
|
715
|
+
}
|
|
716
|
+
if (value.type === TABLE_RESOURCE_TYPE && value.path[0] === "id") {
|
|
717
|
+
return { kind: "table", tableHandle: tfLabelToTsLabel(value.label) };
|
|
718
|
+
}
|
|
719
|
+
if (value.type === "elementum_datamine" && value.path[0] === "id") {
|
|
720
|
+
const datamineBlock = ctx.resourceBlocks.get(`elementum_datamine.${value.label}`);
|
|
721
|
+
const tableId = datamineBlock?.attrs["table_id"];
|
|
722
|
+
const tableLabel = tableId !== undefined && isTfExpr(tableId) && tableId.$expr === "resource-attr" && tableId.type === "elementum_table" && tableId.path[0] === "id"
|
|
723
|
+
? tableId.label
|
|
724
|
+
: undefined;
|
|
725
|
+
if (tableLabel === undefined)
|
|
726
|
+
throw new EntityTfError(`elementum_datamine.${value.label}: table_id is not a managed table reference`);
|
|
727
|
+
const prefix = `${tableLabel}_`;
|
|
728
|
+
return {
|
|
729
|
+
kind: "datamine",
|
|
730
|
+
tableHandle: tfLabelToTsLabel(tableLabel),
|
|
731
|
+
datamineKey: tfLabelToTsLabel(value.label.startsWith(prefix) ? value.label.slice(prefix.length) : value.label),
|
|
732
|
+
};
|
|
733
|
+
}
|
|
469
734
|
// IMPLEMENTED only, not ALL: a readFile task can reference an
|
|
470
735
|
// unimplemented reader type (ai/xml) - fileReaderFromTf correctly
|
|
471
736
|
// excludes those from extraction (no catalog entry is ever printed for
|
|
@@ -495,12 +760,24 @@ function decodeValue(value, ctx) {
|
|
|
495
760
|
}
|
|
496
761
|
throw new EntityTfError(`unreconstructable resource reference ${value.type}.${value.label}`);
|
|
497
762
|
}
|
|
498
|
-
if (value.$expr === "data-attr" &&
|
|
763
|
+
if (value.$expr === "data-attr" && value.type === TABLE_RESOURCE_TYPE && value.path[0] === "id") {
|
|
499
764
|
const lookup = ctx.dataBlocks.get(`${value.type}.${value.label}`);
|
|
500
765
|
const name = lookup?.attrs.name;
|
|
766
|
+
return {
|
|
767
|
+
kind: "table",
|
|
768
|
+
tableHandle: tfLabelToTsLabel(value.label),
|
|
769
|
+
...(typeof name === "string" ? { name } : {}),
|
|
770
|
+
};
|
|
771
|
+
}
|
|
772
|
+
if (value.$expr === "data-attr" && (value.type === "elementum_app" || value.type === "elementum_element") && value.path[0] === "id") {
|
|
773
|
+
const lookup = ctx.dataBlocks.get(`${value.type}.${value.label}`);
|
|
774
|
+
const name = lookup?.attrs.name ?? lookup?.attrs.namespace;
|
|
775
|
+
const mappedHandle = typeof name === "string"
|
|
776
|
+
? (value.type === "elementum_element" ? ctx.foreignElementRefNames : ctx.foreignAppRefNames)?.get(name)
|
|
777
|
+
: undefined;
|
|
501
778
|
return {
|
|
502
779
|
kind: "app",
|
|
503
|
-
appHandle: tfLabelToTsLabel(value.label),
|
|
780
|
+
appHandle: mappedHandle ?? tfLabelToTsLabel(value.label),
|
|
504
781
|
entityType: value.type === "elementum_element" ? "element" : "app",
|
|
505
782
|
...(typeof name === "string" ? { name } : {}),
|
|
506
783
|
};
|
|
@@ -518,11 +795,14 @@ function decodeValue(value, ctx) {
|
|
|
518
795
|
const entityType = objectId.type === "elementum_element" ? "element" : "app";
|
|
519
796
|
const ownerLabel = objectId.label;
|
|
520
797
|
const kindPrefix = `${entityType}_${ownerLabel}_`;
|
|
521
|
-
const
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
798
|
+
const elementumKindPrefix = `elementum_${kindPrefix}`;
|
|
799
|
+
const bareLabel = value.label.startsWith(elementumKindPrefix)
|
|
800
|
+
? value.label.slice(elementumKindPrefix.length)
|
|
801
|
+
: value.label.startsWith(kindPrefix)
|
|
802
|
+
? value.label.slice(kindPrefix.length)
|
|
803
|
+
: value.label.startsWith(`${ownerLabel}_`)
|
|
804
|
+
? value.label.slice(ownerLabel.length + 1)
|
|
805
|
+
: value.label;
|
|
526
806
|
const ownerName = ctx.dataBlocks.get(`${objectId.type}.${objectId.label}`)?.attrs["name"];
|
|
527
807
|
const fieldName = fieldBlock?.attrs["name"];
|
|
528
808
|
return {
|
|
@@ -548,18 +828,29 @@ function decodeValue(value, ctx) {
|
|
|
548
828
|
...(typeof name === "string" ? { name } : {}),
|
|
549
829
|
};
|
|
550
830
|
}
|
|
831
|
+
if (value.$expr === "data-attr" && value.type === "elementum_user" && value.path[0] === "id") {
|
|
832
|
+
const lookup = ctx.dataBlocks.get(`${value.type}.${value.label}`);
|
|
833
|
+
const email = lookup?.attrs.email;
|
|
834
|
+
if (typeof email !== "string" || email === "") {
|
|
835
|
+
throw new EntityTfError(`data.elementum_user.${value.label}: email lookup is missing`);
|
|
836
|
+
}
|
|
837
|
+
return { kind: "user", email };
|
|
838
|
+
}
|
|
551
839
|
if (value.$expr === "local") {
|
|
840
|
+
const stageName = stageFilterName(value, ctx);
|
|
841
|
+
if (stageName !== undefined)
|
|
842
|
+
return { kind: "literal", value: stageName };
|
|
552
843
|
const prefix = `${ctx.appTfLabel}_`;
|
|
553
844
|
if (value.name.startsWith(prefix) && value.name.endsWith("_field_id")) {
|
|
554
845
|
return { kind: "field", appHandle: ctx.appRefName, fieldKey: tfLabelToTsLabel(value.name.slice(prefix.length, -9)) };
|
|
555
846
|
}
|
|
556
|
-
//
|
|
557
|
-
//
|
|
558
|
-
//
|
|
559
|
-
// the exact
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
847
|
+
// Task field assignments have their field token alongside the value.
|
|
848
|
+
// Preserve public authoring as the readable option label; automation
|
|
849
|
+
// build validates that label against field metadata and reconstructs
|
|
850
|
+
// the exact options-by-label local expression.
|
|
851
|
+
const optionLabel = picklistOptionLabel(value);
|
|
852
|
+
if (optionLabel !== undefined)
|
|
853
|
+
return { kind: "literal", value: optionLabel };
|
|
563
854
|
throw new EntityTfError(`unreconstructable local reference local.${value.name}`);
|
|
564
855
|
}
|
|
565
856
|
throw new EntityTfError(`unsupported expression kind "${value.$expr}" in automation`);
|
|
@@ -571,14 +862,18 @@ function decodeValue(value, ctx) {
|
|
|
571
862
|
return { kind: "literal", value };
|
|
572
863
|
}
|
|
573
864
|
function decodePlain(value, ctx) {
|
|
574
|
-
const
|
|
575
|
-
|
|
865
|
+
const unwrap = (decoded) => {
|
|
866
|
+
if (isObject(decoded) && decoded.kind === "literal")
|
|
867
|
+
return decoded.value;
|
|
868
|
+
if (isObject(decoded) && typeof decoded.kind === "string")
|
|
869
|
+
return decoded;
|
|
870
|
+
if (Array.isArray(decoded))
|
|
871
|
+
return decoded.map(unwrap);
|
|
872
|
+
if (isObject(decoded))
|
|
873
|
+
return Object.fromEntries(Object.entries(decoded).map(([key, child]) => [key, unwrap(child)]));
|
|
576
874
|
return decoded;
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
if (isObject(decoded))
|
|
580
|
-
return Object.fromEntries(Object.entries(decoded).map(([key, child]) => [key, decodePlain(child, ctx)]));
|
|
581
|
-
return decoded;
|
|
875
|
+
};
|
|
876
|
+
return unwrap(decodeValue(value, ctx));
|
|
582
877
|
}
|
|
583
878
|
function decodeCustomResponse(value, ctx) {
|
|
584
879
|
if (!isObject(value))
|
|
@@ -609,11 +904,21 @@ function decodeCustomResponse(value, ctx) {
|
|
|
609
904
|
return { ...(success !== undefined ? { success } : {}), ...(failure !== undefined ? { failure } : {}) };
|
|
610
905
|
}
|
|
611
906
|
function fieldRef(value, ctx) {
|
|
907
|
+
if (isTfExpr(value) && value.$expr === "data-attr" && value.path.join(".") === "id") {
|
|
908
|
+
const foreign = ctx.foreignFieldRefsByDataAddress?.get(`${value.type}.${value.label}`);
|
|
909
|
+
if (foreign !== undefined)
|
|
910
|
+
return { kind: "field", appHandle: foreign.ownerRefName, fieldKey: foreign.fieldKey };
|
|
911
|
+
}
|
|
612
912
|
const decoded = decodeValue(value, ctx);
|
|
613
913
|
if (isObject(decoded) && decoded.kind === "field")
|
|
614
914
|
return decoded;
|
|
615
|
-
if (typeof value === "string")
|
|
915
|
+
if (typeof value === "string") {
|
|
916
|
+
const foreign = ctx.foreignFieldRefsById?.get(value);
|
|
917
|
+
if (foreign !== undefined) {
|
|
918
|
+
return { kind: "field", appHandle: foreign.ownerRefName, fieldKey: foreign.fieldKey };
|
|
919
|
+
}
|
|
616
920
|
return { kind: "unresolved", uuid: value, hint: "field" };
|
|
921
|
+
}
|
|
617
922
|
throw new EntityTfError("field reference cannot be reconstructed");
|
|
618
923
|
}
|
|
619
924
|
const USER_FIELD_KEY_SET = new Set(USER_FIELD_KEYS);
|
|
@@ -624,10 +929,15 @@ function userFieldRef(value, ctx) {
|
|
|
624
929
|
return fieldRef(value, ctx);
|
|
625
930
|
}
|
|
626
931
|
function picklistOptionLabel(value) {
|
|
627
|
-
if (value === undefined || !isTfExpr(value)
|
|
932
|
+
if (value === undefined || !isTfExpr(value))
|
|
628
933
|
return undefined;
|
|
629
|
-
const
|
|
630
|
-
|
|
934
|
+
const lookup = value.$expr === "local"
|
|
935
|
+
? value.name
|
|
936
|
+
: value.$expr === "resource-attr" && value.path.length === 2 && typeof value.path[0] === "string"
|
|
937
|
+
? value.path[0]
|
|
938
|
+
: undefined;
|
|
939
|
+
const segment = value.$expr === "local" ? value.path[0] : value.$expr === "resource-attr" ? value.path[1] : undefined;
|
|
940
|
+
const isOptionsLookup = lookup?.endsWith("_options_by_label") === true || lookup?.endsWith("_option_ids_by_label") === true;
|
|
631
941
|
return isOptionsLookup &&
|
|
632
942
|
typeof segment === "object" &&
|
|
633
943
|
segment !== null &&
|
|
@@ -650,90 +960,154 @@ function stageFilterName(value, ctx) {
|
|
|
650
960
|
return undefined;
|
|
651
961
|
return ctx.stagesByKey.get(segment.index);
|
|
652
962
|
}
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
963
|
+
/**
|
|
964
|
+
* ei exports `elementum_calculation_task.calculations[].formula` as the calc
|
|
965
|
+
* engine's mustache / short-form string, not as an HCL `refs["…"]`
|
|
966
|
+
* expression. `decodeValue` would keep platform ids in authored source
|
|
967
|
+
* (#312). Rewrite each embedded ref through the same resolvers used for
|
|
968
|
+
* filters, using import-block ids already in this stream.
|
|
969
|
+
*
|
|
970
|
+
* Recognized shapes:
|
|
971
|
+
* - `{{trigger name="record.<field-uuid>"}}`
|
|
972
|
+
* - `{{task name="<wire output>" id="<task-uuid>"}}`
|
|
973
|
+
* - `variable.<variable-uuid>` (calc-engine short form)
|
|
974
|
+
*/
|
|
975
|
+
function decodeCalculationFormula(value, ctx) {
|
|
976
|
+
if (typeof value !== "string")
|
|
664
977
|
return decodeValue(value, ctx);
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
const
|
|
670
|
-
|
|
978
|
+
const parts = [];
|
|
979
|
+
let cursor = 0;
|
|
980
|
+
const pattern = /\{\{(trigger|task)\s+([^}]*)\}\}|variable\.([a-f0-9-]{36})/g;
|
|
981
|
+
for (const match of value.matchAll(pattern)) {
|
|
982
|
+
const index = match.index ?? 0;
|
|
983
|
+
if (index > cursor)
|
|
984
|
+
parts.push(value.slice(cursor, index));
|
|
985
|
+
if (match[3] !== undefined) {
|
|
986
|
+
parts.push({ kind: "unresolved", uuid: `variable.${match[3]}`, hint: "variable" });
|
|
987
|
+
cursor = index + match[0].length;
|
|
988
|
+
continue;
|
|
989
|
+
}
|
|
990
|
+
const kind = match[1];
|
|
991
|
+
const attrs = match[2];
|
|
992
|
+
if (kind === "trigger") {
|
|
993
|
+
const name = /name="([^"]*)"/.exec(attrs)?.[1];
|
|
994
|
+
const decoded = name !== undefined ? decodeReferenceString(`trigger.${name}`, ctx) : undefined;
|
|
995
|
+
parts.push(decoded ?? { kind: "unresolved", uuid: name ?? match[0], hint: "calculation-reference" });
|
|
996
|
+
}
|
|
997
|
+
else {
|
|
998
|
+
const name = /name="([^"]*)"/.exec(attrs)?.[1];
|
|
999
|
+
const id = /id="([^"]*)"/.exec(attrs)?.[1];
|
|
1000
|
+
parts.push(decodeCalculationTaskMustache(id, name, ctx));
|
|
1001
|
+
}
|
|
1002
|
+
cursor = index + match[0].length;
|
|
671
1003
|
}
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
1004
|
+
if (parts.length === 0)
|
|
1005
|
+
return { kind: "literal", value };
|
|
1006
|
+
if (cursor < value.length)
|
|
1007
|
+
parts.push(value.slice(cursor));
|
|
1008
|
+
if (parts.length === 1 && typeof parts[0] !== "string")
|
|
1009
|
+
return parts[0];
|
|
1010
|
+
return { kind: "template", parts };
|
|
1011
|
+
}
|
|
1012
|
+
function decodeCalculationTaskMustache(taskId, wireName, ctx) {
|
|
1013
|
+
if (taskId === undefined || wireName === undefined) {
|
|
1014
|
+
return { kind: "unresolved", uuid: `task:${taskId ?? "?"}:${wireName ?? "?"}`, hint: "calculation-reference" };
|
|
1015
|
+
}
|
|
1016
|
+
let refKey;
|
|
1017
|
+
let taskBlock;
|
|
1018
|
+
for (const [address, task] of ctx.taskByAddress) {
|
|
1019
|
+
if (ctx.resourceImportIds.get(address) === taskId) {
|
|
1020
|
+
refKey = task.refKey;
|
|
1021
|
+
taskBlock = task.block;
|
|
1022
|
+
break;
|
|
1023
|
+
}
|
|
688
1024
|
}
|
|
689
|
-
if (
|
|
690
|
-
return { kind: "
|
|
691
|
-
|
|
1025
|
+
if (refKey === undefined) {
|
|
1026
|
+
return { kind: "unresolved", uuid: `task.${taskId}.${wireName}`, hint: "calculation-reference" };
|
|
1027
|
+
}
|
|
1028
|
+
if (taskBlock?.type === "elementum_record_search_task") {
|
|
1029
|
+
const recordSearchName = RECORD_SEARCH_TASK_REF_SEGMENT_TO_TS[wireName];
|
|
1030
|
+
if (recordSearchName !== undefined) {
|
|
1031
|
+
return { kind: "taskRef", task: refKey, path: [recordSearchName] };
|
|
1032
|
+
}
|
|
1033
|
+
const taskAddress = taskBlock.label !== undefined ? `${taskBlock.type}.${taskBlock.label}` : undefined;
|
|
1034
|
+
if (taskAddress !== undefined) {
|
|
1035
|
+
const recordFieldPath = taskRecordSearchFieldPath(taskAddress, wireName, ctx);
|
|
1036
|
+
if (recordFieldPath !== undefined) {
|
|
1037
|
+
return { kind: "taskRef", task: refKey, path: recordFieldPath };
|
|
1038
|
+
}
|
|
1039
|
+
}
|
|
1040
|
+
}
|
|
1041
|
+
if (taskBlock?.type === "elementum_ai_search_table_task") {
|
|
1042
|
+
const aiSearchName = AI_SEARCH_TABLE_TASK_REF_SEGMENT_TO_TS[wireName];
|
|
1043
|
+
if (aiSearchName !== undefined) {
|
|
1044
|
+
return { kind: "taskRef", task: refKey, path: [aiSearchName] };
|
|
1045
|
+
}
|
|
1046
|
+
}
|
|
1047
|
+
const keyPath = wireName.split(".");
|
|
1048
|
+
const taskKind = taskBlock?.type !== undefined ? TASK_FACTORIES[taskBlock.type] : undefined;
|
|
1049
|
+
const wireOutputKey = taskKind !== undefined ? OUTPUT_KEY_WIRE_NAME[taskKind] : undefined;
|
|
1050
|
+
const outputKeyPath = wireOutputKey !== undefined && keyPath[0] === wireOutputKey
|
|
1051
|
+
? ["output", ...keyPath.slice(1)]
|
|
1052
|
+
: keyPath.map((segment) => WIRE_REF_SEGMENT_TO_TS[segment] ?? segment);
|
|
1053
|
+
return { kind: "taskRef", task: refKey, path: outputKeyPath };
|
|
692
1054
|
}
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
1055
|
+
const PULLED_CALCULATION_RESULT_TYPES = {
|
|
1056
|
+
ATTACHMENT_ID: "attachment",
|
|
1057
|
+
BOOLEAN: "bool",
|
|
1058
|
+
DATE: "date",
|
|
1059
|
+
DATETIME: "datetime",
|
|
1060
|
+
DECIMAL: "decimal",
|
|
1061
|
+
GROUP_ID: "group",
|
|
1062
|
+
HANDLE: "handle",
|
|
1063
|
+
HTML: "html",
|
|
1064
|
+
JSON: "json",
|
|
1065
|
+
MULTI_PICKLIST: "multiPicklist",
|
|
1066
|
+
NUMBER: "number",
|
|
1067
|
+
PICKLIST: "picklist",
|
|
1068
|
+
TEXT: "text",
|
|
1069
|
+
USER_ID: "user",
|
|
1070
|
+
};
|
|
1071
|
+
function pulledRawCalculation(formula, outputType, multiple) {
|
|
1072
|
+
if (typeof formula !== "string" || multiple === true || typeof outputType !== "string")
|
|
1073
|
+
return undefined;
|
|
1074
|
+
const resultType = PULLED_CALCULATION_RESULT_TYPES[outputType];
|
|
1075
|
+
return resultType === undefined ? undefined : { kind: "calculationRaw", text: formula, resultType };
|
|
1076
|
+
}
|
|
1077
|
+
function decodeFilterReferenceEnvelope(value, ctx) {
|
|
1078
|
+
const raw = isTfExpr(value) && value.$expr === "jsonencode" ? value.value : value;
|
|
1079
|
+
if (!isObject(raw))
|
|
1080
|
+
return undefined;
|
|
1081
|
+
const taskRef = raw.taskReference;
|
|
1082
|
+
if (isObject(taskRef) && typeof taskRef.taskId === "string" && typeof taskRef.name === "string") {
|
|
1083
|
+
return decodeTaskReferenceFromString(taskRef.taskId, taskRef.name.split("."), ctx);
|
|
703
1084
|
}
|
|
704
|
-
const
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
? typeof value.left_value.value_reference === "string"
|
|
708
|
-
? decodeReferenceString(value.left_value.value_reference, ctx)
|
|
709
|
-
: decodeTemplateTriggerRecordFieldRef(value.left_value.value_reference, ctx)
|
|
710
|
-
?? decodeValue(value.left_value.value_reference, ctx)
|
|
711
|
-
: value.left_value !== undefined ? decodeValue(value.left_value, ctx) : undefined;
|
|
712
|
-
if (left === undefined)
|
|
713
|
-
throw new EntityTfError(`${type} filter has no left side`);
|
|
714
|
-
const not = value.not === true ? { not: true } : {};
|
|
715
|
-
if (type === "is_null")
|
|
716
|
-
return { kind: "isNull", left, ...not };
|
|
717
|
-
if (type === "in") {
|
|
718
|
-
if (!Array.isArray(value.values))
|
|
719
|
-
throw new EntityTfError("in filter has no values");
|
|
720
|
-
return { kind: "in", left, values: value.values.map((item) => filterValue(item, ctx)), ...not };
|
|
1085
|
+
const triggerRef = raw.triggerReference;
|
|
1086
|
+
if (isObject(triggerRef) && typeof triggerRef.name === "string") {
|
|
1087
|
+
return decodeReferenceString(`trigger.${triggerRef.name}`, ctx);
|
|
721
1088
|
}
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
return { kind: "between", left, values: [filterValue(value.values[0], ctx), filterValue(value.values[1], ctx)], ...not };
|
|
1089
|
+
const variableRef = raw.variableReference;
|
|
1090
|
+
if (isObject(variableRef) && typeof variableRef.id === "string") {
|
|
1091
|
+
return { kind: "unresolved", uuid: `variable.${variableRef.id}`, hint: "variable" };
|
|
726
1092
|
}
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
1093
|
+
return undefined;
|
|
1094
|
+
}
|
|
1095
|
+
function filterReference(value, ctx) {
|
|
1096
|
+
return typeof value === "string"
|
|
1097
|
+
? decodeReferenceString(value, ctx) ?? { kind: "unresolved", uuid: value, hint: "filter-reference" }
|
|
1098
|
+
: decodeFilterReferenceEnvelope(value, ctx)
|
|
1099
|
+
?? decodeTemplateTriggerRecordFieldRef(value, ctx)
|
|
1100
|
+
?? decodeValue(value, ctx);
|
|
1101
|
+
}
|
|
1102
|
+
function decodeFilter(value, ctx, fieldScope = "app") {
|
|
1103
|
+
return deserializeFilterFromTf(value, {
|
|
1104
|
+
field: (fieldValue, scope) => {
|
|
1105
|
+
const field = scope === "user" ? userFieldRef(fieldValue, ctx) : fieldRef(fieldValue, ctx);
|
|
1106
|
+
return field ?? { kind: "unresolved", uuid: String(fieldValue), hint: "field" };
|
|
1107
|
+
},
|
|
1108
|
+
reference: (reference) => filterReference(reference, ctx),
|
|
1109
|
+
literal: (literal) => picklistOptionLabel(literal) ?? stageFilterName(literal, ctx) ?? literal,
|
|
1110
|
+
}, fieldScope);
|
|
737
1111
|
}
|
|
738
1112
|
function triggerFromBlock(block, ctx) {
|
|
739
1113
|
const kind = TRIGGER_KINDS[block.type];
|
|
@@ -746,7 +1120,8 @@ function triggerFromBlock(block, ctx) {
|
|
|
746
1120
|
const parameters = block.attrs.parameters ?? [];
|
|
747
1121
|
if (!Array.isArray(parameters))
|
|
748
1122
|
throw new EntityTfError("on-demand parameters must be an array");
|
|
749
|
-
return {
|
|
1123
|
+
return {
|
|
1124
|
+
kind, inputs: parameters.map((parameter) => {
|
|
750
1125
|
if (!isObject(parameter) || typeof parameter.name !== "string" || typeof parameter.type !== "string")
|
|
751
1126
|
throw new EntityTfError("invalid on-demand parameter");
|
|
752
1127
|
// Inverse of to-tf's "attachment" special case above — the wire has
|
|
@@ -756,7 +1131,8 @@ function triggerFromBlock(block, ctx) {
|
|
|
756
1131
|
// "attachment" that TriggerFieldTypeAlias doesn't accept.
|
|
757
1132
|
const type = parameter.type === "attachment" ? "attachmentId" : parameter.type;
|
|
758
1133
|
return { name: parameter.name, type, ...(parameter.required === true ? { required: true } : {}), ...(parameter.multiple === true ? { multiple: true } : {}), ...(parameter.default_value !== undefined ? { defaultValue: parameter.default_value } : {}), ...(typeof parameter.description === "string" ? { description: parameter.description } : {}) };
|
|
759
|
-
}), ...(block.attrs.show_triggered_by === true ? { showTriggeredBy: true } : {})
|
|
1134
|
+
}), ...(block.attrs.show_triggered_by === true ? { showTriggeredBy: true } : {})
|
|
1135
|
+
};
|
|
760
1136
|
}
|
|
761
1137
|
case "recordCreate":
|
|
762
1138
|
case "recordUpdate":
|
|
@@ -771,9 +1147,13 @@ function triggerFromBlock(block, ctx) {
|
|
|
771
1147
|
throw new EntityTfError("conversation trigger requires conversation_type");
|
|
772
1148
|
return { kind, app, conversationType: block.attrs.conversation_type };
|
|
773
1149
|
case "webhook":
|
|
1150
|
+
// ei's export only reliably emits `authenticated` when it can (see
|
|
1151
|
+
// cmd/elementum/export/hcl_trigger.go) - a real captured stream can
|
|
1152
|
+
// still omit the key, so default to false rather than requiring it
|
|
1153
|
+
// (edk#557, same asymmetry as approval-chain's approveButton, #325).
|
|
774
1154
|
return {
|
|
775
1155
|
kind,
|
|
776
|
-
|
|
1156
|
+
authenticated: typeof block.attrs.authenticated === "boolean" ? block.attrs.authenticated : false,
|
|
777
1157
|
...(block.attrs.custom_response !== undefined ? { customResponse: decodeCustomResponse(block.attrs.custom_response, ctx) } : {}),
|
|
778
1158
|
};
|
|
779
1159
|
case "approvalProcessStatusUpdated": {
|
|
@@ -788,9 +1168,14 @@ function triggerFromBlock(block, ctx) {
|
|
|
788
1168
|
return { kind, app, approvalChain: approvalChain, status: block.attrs.status };
|
|
789
1169
|
}
|
|
790
1170
|
case "dataMine":
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
1171
|
+
{
|
|
1172
|
+
const raw = block.attrs.datamine_id;
|
|
1173
|
+
const datamine = typeof raw === "string" ? raw : decodeValue(raw, ctx);
|
|
1174
|
+
if (typeof datamine !== "string" && (!isObject(datamine) || datamine.kind !== "datamine")) {
|
|
1175
|
+
throw new EntityTfError("datamine trigger requires a managed datamine reference or explicit platform id");
|
|
1176
|
+
}
|
|
1177
|
+
return { kind, datamine: datamine, ...(typeof block.attrs.fire_on_alert === "boolean" ? { fireOnAlert: block.attrs.fire_on_alert } : {}), ...(typeof block.attrs.fire_on_recovery === "boolean" ? { fireOnRecovery: block.attrs.fire_on_recovery } : {}) };
|
|
1178
|
+
}
|
|
794
1179
|
case "emailReceived":
|
|
795
1180
|
if (typeof block.attrs.email_alias_id !== "string")
|
|
796
1181
|
throw new EntityTfError("email trigger requires email_alias_id");
|
|
@@ -816,42 +1201,21 @@ function taskArgs(block, factory, ctx) {
|
|
|
816
1201
|
if (!Array.isArray(value))
|
|
817
1202
|
throw new EntityTfError(`${block.type}.${block.label}: fields must be an array`);
|
|
818
1203
|
const values = {};
|
|
819
|
-
const unresolvable = [];
|
|
820
1204
|
for (const item of value) {
|
|
821
1205
|
if (!isObject(item) || item.field_id === undefined)
|
|
822
1206
|
throw new EntityTfError(`${block.type}.${block.label}: invalid field assignment`);
|
|
823
1207
|
const field = fieldRef(item.field_id, ctx);
|
|
824
|
-
//
|
|
825
|
-
//
|
|
826
|
-
//
|
|
827
|
-
//
|
|
828
|
-
//
|
|
829
|
-
//
|
|
830
|
-
//
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
// demoapptwo's "Create record app external" automation, whose target
|
|
836
|
-
// field lives on a different app - throw (same as any other
|
|
837
|
-
// unreconstructable reference) so the automation's full graph is
|
|
838
|
-
// excluded from adoption via automationOwnedAddresses, rather than
|
|
839
|
-
// permanently failing the adoption gate for the whole app. A
|
|
840
|
-
// foreign-target task typically has EVERY field assignment
|
|
841
|
-
// unresolvable for the same reason (confirmed live:
|
|
842
|
-
// conciergeforfield's cff_analyze_agent_performance_v3 has 13) - collect
|
|
843
|
-
// them all before throwing instead of stopping at the first, so the
|
|
844
|
-
// message doesn't look like a single-field fluke (#285).
|
|
845
|
-
if (field.kind !== "field") {
|
|
846
|
-
unresolvable.push(field.kind === "unresolved" ? field.uuid : "unknown");
|
|
847
|
-
continue;
|
|
848
|
-
}
|
|
849
|
-
values[field.fieldKey] = decodeValue(item.value, ctx);
|
|
850
|
-
}
|
|
851
|
-
if (unresolvable.length > 0) {
|
|
852
|
-
throw new EntityTfError(`${block.type}.${block.label}: ${unresolvable.length} field assignment${unresolvable.length === 1 ? "" : "s"} ` +
|
|
853
|
-
`reference${unresolvable.length === 1 ? "s" : ""} an unresolvable field (${unresolvable.join(", ")}) — ` +
|
|
854
|
-
`likely a foreign object_id target the export didn't recursively discover (--recursive=false)`);
|
|
1208
|
+
// Non-recursive exports preserve a real foreign target as
|
|
1209
|
+
// data.elementum_app/element, but its field assignments are bare ids
|
|
1210
|
+
// because the target's fields were not exported. Keep the automation
|
|
1211
|
+
// extractable and mark only those field keys as unresolved. The
|
|
1212
|
+
// printer makes the non-portability explicit with unsafePlatformId;
|
|
1213
|
+
// `--with-dependencies` pulls the target and the second extraction
|
|
1214
|
+
// pass upgrades these ids through foreignFieldRefsById to typed refs.
|
|
1215
|
+
const fieldKey = field.kind === "field"
|
|
1216
|
+
? field.fieldKey
|
|
1217
|
+
: `${UNRESOLVED_FIELD_MARKER}${field.uuid}`;
|
|
1218
|
+
values[fieldKey] = decodeFieldAssignmentValue(item.value, ctx);
|
|
855
1219
|
}
|
|
856
1220
|
args.values = values;
|
|
857
1221
|
continue;
|
|
@@ -879,15 +1243,75 @@ function taskArgs(block, factory, ctx) {
|
|
|
879
1243
|
}));
|
|
880
1244
|
continue;
|
|
881
1245
|
}
|
|
1246
|
+
if (attr === "input_mappings" && factory === "runAutomation") {
|
|
1247
|
+
if (!Array.isArray(value))
|
|
1248
|
+
throw new EntityTfError(`${block.type}.${block.label}: input_mappings must be an array`);
|
|
1249
|
+
args.inputs = value.map((item) => {
|
|
1250
|
+
if (!isObject(item) || item.parameter_id === undefined || item.value === undefined) {
|
|
1251
|
+
throw new EntityTfError(`${block.type}.${block.label}: invalid input mapping`);
|
|
1252
|
+
}
|
|
1253
|
+
const parameter = item.parameter_id;
|
|
1254
|
+
if (!isTfExpr(parameter) ||
|
|
1255
|
+
parameter.$expr !== "resource-attr" ||
|
|
1256
|
+
parameter.type !== "elementum_on_demand_trigger" ||
|
|
1257
|
+
parameter.path[0] !== "parameter_ids" ||
|
|
1258
|
+
typeof parameter.path[1] !== "object" ||
|
|
1259
|
+
parameter.path[1] === null ||
|
|
1260
|
+
!("index" in parameter.path[1]) ||
|
|
1261
|
+
typeof parameter.path[1].index !== "string") {
|
|
1262
|
+
throw new EntityTfError(`${block.type}.${block.label}: input mapping parameter_id is not a named trigger parameter reference`);
|
|
1263
|
+
}
|
|
1264
|
+
return { name: parameter.path[1].index, value: decodeValue(item.value, ctx) };
|
|
1265
|
+
});
|
|
1266
|
+
continue;
|
|
1267
|
+
}
|
|
1268
|
+
// `file_reader_id` resolves to a real `documentModel` RefExpr only
|
|
1269
|
+
// through decodeValue's resource-attr branch (an implemented reader
|
|
1270
|
+
// type's own resource block in this export). When ei instead emits a
|
|
1271
|
+
// bare platform id — an unimplemented reader type (ai/xml, per
|
|
1272
|
+
// `IMPLEMENTED_FILE_READER_RESOURCE_TYPES`) or a dangling/foreign file
|
|
1273
|
+
// reader this export never discovered — decodeValue's generic fallback
|
|
1274
|
+
// would otherwise wrap it as a plain `{kind: "literal"}` string, which
|
|
1275
|
+
// the printer emits as a bare string literal where readFile's `fileReader`
|
|
1276
|
+
// option requires a `FileReaderCatalogRef` object, failing tsc on the
|
|
1277
|
+
// generated file (edk#483). Route it through the same `unresolved`
|
|
1278
|
+
// escape hatch already used for other unreconstructable references
|
|
1279
|
+
// (`"<uuid>" as any /* TODO: ... */`) instead.
|
|
1280
|
+
if (attr === "file_reader_id" && factory === "documentModel") {
|
|
1281
|
+
const decoded = decodeValue(value, ctx);
|
|
1282
|
+
args.documentModel =
|
|
1283
|
+
typeof decoded === "object" && decoded !== null && decoded.kind === "documentModel"
|
|
1284
|
+
? decoded
|
|
1285
|
+
: { kind: "unresolved", uuid: typeof value === "string" ? value : JSON.stringify(value), hint: "file reader" };
|
|
1286
|
+
continue;
|
|
1287
|
+
}
|
|
882
1288
|
if (attr === "calculations" && factory === "calculation") {
|
|
883
1289
|
if (!Array.isArray(value))
|
|
884
1290
|
throw new EntityTfError("calculations must be an array");
|
|
885
|
-
args.
|
|
1291
|
+
args.values = Object.fromEntries(value.map((item) => {
|
|
886
1292
|
if (!isObject(item) || typeof item.variable_name !== "string" || item.formula === undefined) {
|
|
887
1293
|
throw new EntityTfError(`${block.type}.${block.label}: invalid calculation entry`);
|
|
888
1294
|
}
|
|
889
|
-
|
|
890
|
-
|
|
1295
|
+
const decodedExpression = decodeCalculationFormula(item.formula, ctx);
|
|
1296
|
+
const expression = isObject(decodedExpression) && decodedExpression.kind === "literal"
|
|
1297
|
+
? pulledRawCalculation(item.formula, item.output_type, item.multiple) ?? decodedExpression
|
|
1298
|
+
: decodedExpression;
|
|
1299
|
+
const include = item.include_type === "MANUAL" ? "manual"
|
|
1300
|
+
: item.include_type === "BOTH" ? "both"
|
|
1301
|
+
: item.include_type === "PICKLIST" && item.picklist_field_id !== undefined
|
|
1302
|
+
? { picklist: fieldRef(item.picklist_field_id, ctx) ?? decodeValue(item.picklist_field_id, ctx) }
|
|
1303
|
+
: undefined;
|
|
1304
|
+
if (item.id !== undefined && typeof item.id !== "string") {
|
|
1305
|
+
throw new EntityTfError(`${block.type}.${block.label}: calculation entry id must be a string`);
|
|
1306
|
+
}
|
|
1307
|
+
const advanced = item.id !== undefined || item.record_id !== undefined || include !== undefined;
|
|
1308
|
+
return [item.variable_name, advanced ? {
|
|
1309
|
+
expression,
|
|
1310
|
+
...(typeof item.id === "string" ? { id: item.id } : {}),
|
|
1311
|
+
...(item.record_id !== undefined ? { record: decodeValue(item.record_id, ctx) } : {}),
|
|
1312
|
+
...(include !== undefined ? { include } : {}),
|
|
1313
|
+
} : expression];
|
|
1314
|
+
}));
|
|
891
1315
|
continue;
|
|
892
1316
|
}
|
|
893
1317
|
if (attr === "categories" && factory === "aiClassify") {
|
|
@@ -906,6 +1330,15 @@ function taskArgs(block, factory, ctx) {
|
|
|
906
1330
|
};
|
|
907
1331
|
continue;
|
|
908
1332
|
}
|
|
1333
|
+
if (attr === "table_id" && factory === "tableRecordsSearch") {
|
|
1334
|
+
const foreign = typeof value === "string" ? ctx.foreignTableRefsById?.get(value) : undefined;
|
|
1335
|
+
args.table = foreign !== undefined
|
|
1336
|
+
? { kind: "table", tableHandle: foreign.tableRefName, name: foreign.name }
|
|
1337
|
+
: typeof value === "string"
|
|
1338
|
+
? { kind: "unresolved", uuid: value, hint: "table" }
|
|
1339
|
+
: decodeValue(value, ctx);
|
|
1340
|
+
continue;
|
|
1341
|
+
}
|
|
909
1342
|
if (attr === "list" && factory === "forEach") {
|
|
910
1343
|
args.collection = decodeValue(value, ctx);
|
|
911
1344
|
continue;
|
|
@@ -1146,12 +1579,35 @@ export function automationOwnedAddresses(doc, automationLabel) {
|
|
|
1146
1579
|
}
|
|
1147
1580
|
return [...owned];
|
|
1148
1581
|
}
|
|
1582
|
+
/** Bridge metadata for required values that GraphQL could not reconstruct. */
|
|
1583
|
+
function unresolvedAuthoringValues(doc) {
|
|
1584
|
+
const values = [];
|
|
1585
|
+
for (const block of doc.blocks) {
|
|
1586
|
+
if (block.kind !== "locals")
|
|
1587
|
+
continue;
|
|
1588
|
+
for (const [key, payload] of Object.entries(block.attrs)) {
|
|
1589
|
+
if (!key.startsWith("edk_unresolved_authoring_") || typeof payload !== "string")
|
|
1590
|
+
continue;
|
|
1591
|
+
try {
|
|
1592
|
+
const parsed = JSON.parse(payload);
|
|
1593
|
+
if (typeof parsed.resource === "string" && typeof parsed.field === "string" && typeof parsed.reason === "string") {
|
|
1594
|
+
values.push({ resource: parsed.resource, field: parsed.field, reason: parsed.reason });
|
|
1595
|
+
}
|
|
1596
|
+
}
|
|
1597
|
+
catch {
|
|
1598
|
+
// Malformed bridge metadata is ignored here. The ordinary extractor
|
|
1599
|
+
// validation still handles the underlying resource shape.
|
|
1600
|
+
}
|
|
1601
|
+
}
|
|
1602
|
+
}
|
|
1603
|
+
return values;
|
|
1604
|
+
}
|
|
1149
1605
|
/** Extract one app-owned automation graph from an ei app export. */
|
|
1150
|
-
function automationFromTfDocument(doc, automationLabel, appRefName) {
|
|
1606
|
+
function automationFromTfDocument(doc, automationLabel, appRefName, foreignFieldRefsById, foreignFieldRefsByDataAddress, foreignTableRefsById, picklistOptionLabelById, fieldNamesByOwnerRefName, foreignAppRefNames, foreignElementRefNames) {
|
|
1151
1607
|
const automation = doc.blocks.find((block) => block.kind === "resource" && block.type === AUTOMATION_RESOURCE_TYPE && block.label === automationLabel);
|
|
1152
1608
|
if (automation === undefined)
|
|
1153
1609
|
throw new EntityTfError(`automation resource "${automationLabel}" not found`);
|
|
1154
|
-
assertAllowed(automation, new Set(["app_id", "name", "description", "triggers_other_automations", "depends_on"]));
|
|
1610
|
+
assertAllowed(automation, new Set(["app_id", "name", "description", "status", "triggers_other_automations", "service_account_id", "depends_on"]));
|
|
1155
1611
|
const app = resourceRef(automation.attrs.app_id);
|
|
1156
1612
|
if (app === undefined || app.type !== "elementum_app" || app.path[0] !== "id")
|
|
1157
1613
|
throw new EntityTfError(`${AUTOMATION_RESOURCE_TYPE}.${automationLabel}: app_id is not an app reference`);
|
|
@@ -1194,6 +1650,17 @@ function automationFromTfDocument(doc, automationLabel, appRefName) {
|
|
|
1194
1650
|
}
|
|
1195
1651
|
const tasks = taskCandidates.filter((block) => owned.has(`${block.type}.${block.label}`));
|
|
1196
1652
|
const ownedBranches = branches.filter((block) => owned.has(`${block.type}.${block.label}`));
|
|
1653
|
+
// A required value that the bridge could not reconstruct is not a literal
|
|
1654
|
+
// empty string. Exclude the whole automation graph from authoring/adoption,
|
|
1655
|
+
// just as we already do for an unresolvable field_id. Otherwise resolving
|
|
1656
|
+
// the foreign field through a direct catalog accidentally turns the bridge's
|
|
1657
|
+
// `value = ""` placeholder into managed configuration and adoption plans a
|
|
1658
|
+
// live null -> "" update.
|
|
1659
|
+
const unresolved = unresolvedAuthoringValues(doc).find(({ resource }) => owned.has(resource));
|
|
1660
|
+
if (unresolved !== undefined) {
|
|
1661
|
+
throw new EntityTfError(`${unresolved.resource}.${unresolved.field}: ${unresolved.reason}; ` +
|
|
1662
|
+
"the automation is excluded because no safe authored value or UUID fallback is available");
|
|
1663
|
+
}
|
|
1197
1664
|
tasks.forEach((block) => assertAllowed(block, TASK_ATTRIBUTES));
|
|
1198
1665
|
ownedBranches.forEach((block) => assertAllowed(block, BRANCH_ATTRIBUTES));
|
|
1199
1666
|
const publishDependencies = Array.isArray(publish?.attrs.depends_on)
|
|
@@ -1236,6 +1703,12 @@ function automationFromTfDocument(doc, automationLabel, appRefName) {
|
|
|
1236
1703
|
}
|
|
1237
1704
|
const appTfLabel = app.label;
|
|
1238
1705
|
const taskByAddress = new Map(tasks.map((block) => [`${block.type}.${block.label}`, { block, refKey: taskRefKey(block, automationLabel, appTfLabel) }]));
|
|
1706
|
+
const taskTargetOwnerRefNameByAddress = new Map();
|
|
1707
|
+
for (const [address, { block }] of taskByAddress) {
|
|
1708
|
+
const ownerRefName = aspectOwnerRefNameFromObjectId(block.attrs.object_id, appRefName, appTfLabel);
|
|
1709
|
+
if (ownerRefName !== undefined)
|
|
1710
|
+
taskTargetOwnerRefNameByAddress.set(address, ownerRefName);
|
|
1711
|
+
}
|
|
1239
1712
|
const resourceImportIds = new Map();
|
|
1240
1713
|
for (const block of doc.blocks) {
|
|
1241
1714
|
if (block.kind !== "import" || typeof block.attrs.id !== "string")
|
|
@@ -1266,7 +1739,44 @@ function automationFromTfDocument(doc, automationLabel, appRefName) {
|
|
|
1266
1739
|
stagesByKey.set(item.key, item.name);
|
|
1267
1740
|
}
|
|
1268
1741
|
}
|
|
1269
|
-
const ctx = {
|
|
1742
|
+
const ctx = {
|
|
1743
|
+
appRefName,
|
|
1744
|
+
appTfLabel: app.label,
|
|
1745
|
+
trigger,
|
|
1746
|
+
taskByAddress,
|
|
1747
|
+
resourceBlocks,
|
|
1748
|
+
dataBlocks,
|
|
1749
|
+
resourceImportIds,
|
|
1750
|
+
fieldById,
|
|
1751
|
+
stagesByKey,
|
|
1752
|
+
...(foreignFieldRefsById !== undefined && { foreignFieldRefsById }),
|
|
1753
|
+
...(foreignFieldRefsByDataAddress !== undefined && { foreignFieldRefsByDataAddress }),
|
|
1754
|
+
...(foreignTableRefsById !== undefined && { foreignTableRefsById }),
|
|
1755
|
+
...(picklistOptionLabelById !== undefined && { picklistOptionLabelById }),
|
|
1756
|
+
...(fieldNamesByOwnerRefName !== undefined && { fieldNamesByOwnerRefName }),
|
|
1757
|
+
...(taskTargetOwnerRefNameByAddress.size > 0 && { taskTargetOwnerRefNameByAddress }),
|
|
1758
|
+
...(foreignAppRefNames !== undefined && { foreignAppRefNames }),
|
|
1759
|
+
...(foreignElementRefNames !== undefined && { foreignElementRefNames }),
|
|
1760
|
+
};
|
|
1761
|
+
let serviceAccountName;
|
|
1762
|
+
const serviceAccountValue = automation.attrs.service_account_id;
|
|
1763
|
+
if (serviceAccountValue !== undefined &&
|
|
1764
|
+
isTfExpr(serviceAccountValue) &&
|
|
1765
|
+
"type" in serviceAccountValue &&
|
|
1766
|
+
serviceAccountValue.type === "elementum_service_account" &&
|
|
1767
|
+
(serviceAccountValue.$expr === "resource-attr" || serviceAccountValue.$expr === "data-attr")) {
|
|
1768
|
+
const reference = serviceAccountValue;
|
|
1769
|
+
const block = reference.$expr === "resource-attr"
|
|
1770
|
+
? resourceBlocks.get(`${reference.type}.${reference.label}`)
|
|
1771
|
+
: dataBlocks.get(`${reference.type}.${reference.label}`);
|
|
1772
|
+
if (block !== undefined) {
|
|
1773
|
+
if (typeof block.attrs.name === "string")
|
|
1774
|
+
serviceAccountName = block.attrs.name;
|
|
1775
|
+
else if (typeof block.attrs.first_name === "string" && typeof block.attrs.last_name === "string") {
|
|
1776
|
+
serviceAccountName = `${block.attrs.first_name} ${block.attrs.last_name}`;
|
|
1777
|
+
}
|
|
1778
|
+
}
|
|
1779
|
+
}
|
|
1270
1780
|
const dependencyOrder = new Map();
|
|
1271
1781
|
if (publish && Array.isArray(publish.attrs.depends_on))
|
|
1272
1782
|
publish.attrs.depends_on.forEach((dep, index) => { const ref = resourceRef(dep); if (ref)
|
|
@@ -1344,7 +1854,8 @@ function automationFromTfDocument(doc, automationLabel, appRefName) {
|
|
|
1344
1854
|
workflowRevision: exportedRevision ?? "1.0.0",
|
|
1345
1855
|
...(typeof automation.attrs.description === "string" ? { description: automation.attrs.description } : {}),
|
|
1346
1856
|
...(typeof automation.attrs.triggers_other_automations === "boolean" ? { triggersOtherAutomations: automation.attrs.triggers_other_automations } : {}),
|
|
1347
|
-
|
|
1857
|
+
...(serviceAccountName !== undefined ? { serviceAccountName } : {}),
|
|
1858
|
+
status: publish ? "ACTIVE" : automation.attrs.status === "INACTIVE" ? "INACTIVE" : "DRAFT",
|
|
1348
1859
|
trigger: triggerFromBlock(trigger, ctx),
|
|
1349
1860
|
tasks: topTasks,
|
|
1350
1861
|
...(outputs && outputs.length > 0 ? { outputs } : {}),
|
|
@@ -1354,7 +1865,7 @@ function automationFromTfDocument(doc, automationLabel, appRefName) {
|
|
|
1354
1865
|
tfLabel: automationLabel, ast, blocks: [automation, trigger, ...tasks, ...ownedBranches, ...(publish ? [publish] : [])]
|
|
1355
1866
|
};
|
|
1356
1867
|
}
|
|
1357
|
-
export function automationFromTf(first, second, third) {
|
|
1868
|
+
export function automationFromTf(first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth) {
|
|
1358
1869
|
if (Array.isArray(first)) {
|
|
1359
1870
|
const ctx = second;
|
|
1360
1871
|
const automationBlock = first.find((block) => block.kind === "resource" && block.type === AUTOMATION_RESOURCE_TYPE);
|
|
@@ -1362,7 +1873,9 @@ export function automationFromTf(first, second, third) {
|
|
|
1362
1873
|
return { skippedReason: "automation resource not found" };
|
|
1363
1874
|
}
|
|
1364
1875
|
try {
|
|
1365
|
-
return {
|
|
1876
|
+
return {
|
|
1877
|
+
automation: automationFromTfDocument({ blocks: [...first] }, automationBlock.label, ctx.ownerHandle, ctx.foreignFieldRefsById, ctx.foreignFieldRefsByDataAddress, ctx.foreignTableRefsById, ctx.picklistOptionLabelById, ctx.fieldNamesByOwnerRefName, ctx.foreignAppRefNames, ctx.foreignElementRefNames).ast,
|
|
1878
|
+
};
|
|
1366
1879
|
}
|
|
1367
1880
|
catch (err) {
|
|
1368
1881
|
const message = err instanceof Error ? err.message : String(err);
|
|
@@ -1370,5 +1883,5 @@ export function automationFromTf(first, second, third) {
|
|
|
1370
1883
|
return { skippedReason: message };
|
|
1371
1884
|
}
|
|
1372
1885
|
}
|
|
1373
|
-
return automationFromTfDocument(first, second, third ?? "");
|
|
1886
|
+
return automationFromTfDocument(first, second, third ?? "", fourth, fifth, sixth, seventh, eighth, ninth, tenth);
|
|
1374
1887
|
}
|