@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
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
import { dataRefLabel, plainObject, resourceRefLabel } from "../../engine/pull/context.js";
|
|
2
|
+
import { isTfExpr, scopedLabelToBagKey, tfLabelToTsLabel } from "../../engine/tf/index.js";
|
|
3
|
+
import { FIELD_RESOURCE_TYPES } from "../field/types.js";
|
|
4
|
+
import { fieldKeyFromTfRef } from "../field/from-tf.js";
|
|
5
|
+
import { filterFromTf } from "../shared/filters/tf-codec.js";
|
|
6
|
+
import { CHART_RESOURCE_TYPE } from "./types.js";
|
|
7
|
+
const APP_RESOURCE_TYPE = "elementum_app";
|
|
8
|
+
const TABLE_RESOURCE_TYPE = "elementum_table";
|
|
9
|
+
function decodeJson(value) {
|
|
10
|
+
if (value === undefined)
|
|
11
|
+
return undefined;
|
|
12
|
+
if (isTfExpr(value) && value.$expr === "jsonencode")
|
|
13
|
+
return value.value;
|
|
14
|
+
if (typeof value === "string") {
|
|
15
|
+
try {
|
|
16
|
+
return JSON.parse(value);
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
return value;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return value;
|
|
23
|
+
}
|
|
24
|
+
function datasourceFromTf(value, appLabel, appRefName, ctx, where) {
|
|
25
|
+
for (const [type, kind] of [[APP_RESOURCE_TYPE, "app"], ["elementum_element", "element"], [TABLE_RESOURCE_TYPE, "table"]]) {
|
|
26
|
+
const resourceLabel = resourceRefLabel(value, type);
|
|
27
|
+
if (resourceLabel !== undefined) {
|
|
28
|
+
return {
|
|
29
|
+
kind,
|
|
30
|
+
refName: kind === "app" && resourceLabel === appLabel ? appRefName : tfLabelToTsLabel(resourceLabel),
|
|
31
|
+
local: true,
|
|
32
|
+
tfLabel: resourceLabel,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
const dataLabel = dataRefLabel(value, type);
|
|
36
|
+
if (dataLabel !== undefined) {
|
|
37
|
+
const name = ctx.dataName(type, dataLabel) ?? tfLabelToTsLabel(dataLabel);
|
|
38
|
+
const refName = kind === "app"
|
|
39
|
+
? ctx.foreignAppRefNames?.get(name) ?? tfLabelToTsLabel(dataLabel)
|
|
40
|
+
: kind === "element"
|
|
41
|
+
? ctx.foreignElementRefNames?.get(name) ?? tfLabelToTsLabel(dataLabel)
|
|
42
|
+
: (() => {
|
|
43
|
+
const attrs = ctx.dataAttrs?.(type, dataLabel);
|
|
44
|
+
const id = typeof attrs?.["id"] === "string" ? attrs["id"] : ctx.importId(`data.${type}.${dataLabel}`);
|
|
45
|
+
const byId = id === undefined ? undefined : ctx.foreignTableRefsById?.get(id);
|
|
46
|
+
if (byId !== undefined)
|
|
47
|
+
return byId.tableRefName;
|
|
48
|
+
const matches = [...(ctx.foreignTableRefsById?.values() ?? [])].filter((candidate) => candidate.name === name);
|
|
49
|
+
return matches.length === 1 ? matches[0].tableRefName : undefined;
|
|
50
|
+
})();
|
|
51
|
+
if (refName === undefined) {
|
|
52
|
+
ctx.diagnostics.push(`${where}: table datasource ${name} cannot be resolved to the org catalog; skipped`);
|
|
53
|
+
return undefined;
|
|
54
|
+
}
|
|
55
|
+
return { kind, refName, name, local: false, tfLabel: dataLabel };
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (typeof value === "string") {
|
|
59
|
+
const table = ctx.foreignTableRefsById?.get(value);
|
|
60
|
+
if (table !== undefined)
|
|
61
|
+
return { kind: "table", refName: table.tableRefName, name: table.name, local: false, tfLabel: table.tableRefName };
|
|
62
|
+
}
|
|
63
|
+
ctx.diagnostics.push(`${where}: datasource_id is not a typed app, element, or table reference; skipped`);
|
|
64
|
+
return undefined;
|
|
65
|
+
}
|
|
66
|
+
function indexedField(value) {
|
|
67
|
+
if (value === undefined || !isTfExpr(value) || (value.$expr !== "resource-attr" && value.$expr !== "data-attr") || value.type !== TABLE_RESOURCE_TYPE)
|
|
68
|
+
return undefined;
|
|
69
|
+
const index = value.path[1];
|
|
70
|
+
if (value.path[0] !== "field_ids" || typeof index !== "object" || index === null || typeof index.index !== "string")
|
|
71
|
+
return undefined;
|
|
72
|
+
return { label: value.label, name: index.index, data: value.$expr === "data-attr" };
|
|
73
|
+
}
|
|
74
|
+
function fieldFromTf(value, datasource, ctx, where) {
|
|
75
|
+
if (value !== undefined && (datasource.kind === "app" || datasource.kind === "element")) {
|
|
76
|
+
const refName = fieldKeyFromTfRef(value, datasource.tfLabel, datasource.kind);
|
|
77
|
+
if (refName !== undefined)
|
|
78
|
+
return { kind: "field", parentKind: datasource.kind, parentRefName: datasource.refName, refName };
|
|
79
|
+
}
|
|
80
|
+
if (typeof value === "string" && datasource.kind === "table") {
|
|
81
|
+
const table = [...(ctx.foreignTableRefsById?.values() ?? [])].find((candidate) => candidate.tableRefName === datasource.refName);
|
|
82
|
+
const refName = table?.columnRefNamesById?.get(value);
|
|
83
|
+
if (refName !== undefined)
|
|
84
|
+
return { kind: "tableColumn", parentKind: "table", parentRefName: datasource.refName, refName };
|
|
85
|
+
}
|
|
86
|
+
const tableField = indexedField(value);
|
|
87
|
+
if (tableField !== undefined) {
|
|
88
|
+
const table = [...(ctx.foreignTableRefsById?.values() ?? [])].find((candidate) => candidate.tableRefName === datasource.refName);
|
|
89
|
+
const refName = table?.columnRefNamesByName?.get(tableField.name);
|
|
90
|
+
if (refName === undefined) {
|
|
91
|
+
ctx.diagnostics.push(`${where}: table column ${tableField.name} is not present in the pulled table catalog; dropped`);
|
|
92
|
+
return undefined;
|
|
93
|
+
}
|
|
94
|
+
return { kind: "tableColumn", parentKind: "table", parentRefName: datasource.refName, refName, name: tableField.name };
|
|
95
|
+
}
|
|
96
|
+
if (value !== undefined && isTfExpr(value) && value.$expr === "resource-attr" && FIELD_RESOURCE_TYPES.includes(value.type)) {
|
|
97
|
+
return {
|
|
98
|
+
kind: "field",
|
|
99
|
+
parentKind: datasource.kind === "element" ? "element" : "app",
|
|
100
|
+
parentRefName: datasource.refName,
|
|
101
|
+
refName: scopedLabelToBagKey(datasource.tfLabel, value.label, datasource.kind === "element" ? "element" : "app"),
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
const dataLabel = dataRefLabel(value, "elementum_field");
|
|
105
|
+
if (dataLabel !== undefined) {
|
|
106
|
+
const attrs = ctx.dataAttrs?.("elementum_field", dataLabel);
|
|
107
|
+
const name = typeof attrs?.["name"] === "string" ? attrs["name"] : ctx.dataName("elementum_field", dataLabel);
|
|
108
|
+
const id = typeof attrs?.["id"] === "string"
|
|
109
|
+
? attrs["id"]
|
|
110
|
+
: ctx.importId(`data.elementum_field.${dataLabel}`);
|
|
111
|
+
let resolved = id === undefined ? undefined : ctx.foreignFieldRefsById?.get(id);
|
|
112
|
+
if (resolved === undefined && name !== undefined) {
|
|
113
|
+
const matches = [...(ctx.foreignFieldRefsById?.values() ?? [])].filter((candidate) => candidate.ownerRefName === datasource.refName && candidate.fieldName === name);
|
|
114
|
+
if (matches.length === 1)
|
|
115
|
+
resolved = matches[0];
|
|
116
|
+
}
|
|
117
|
+
if (resolved === undefined || resolved.ownerRefName !== datasource.refName) {
|
|
118
|
+
ctx.diagnostics.push(`${where}: foreign field ${name ?? dataLabel} cannot be resolved to a typed catalog key; dropped`);
|
|
119
|
+
return undefined;
|
|
120
|
+
}
|
|
121
|
+
return {
|
|
122
|
+
kind: datasource.kind === "table" ? "tableColumn" : "field",
|
|
123
|
+
parentKind: datasource.kind,
|
|
124
|
+
parentRefName: datasource.refName,
|
|
125
|
+
refName: resolved.fieldKey,
|
|
126
|
+
...(name !== undefined ? { name } : {}),
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
ctx.diagnostics.push(`${where}: column reference is not resolvable against datasource ${datasource.refName}; dropped`);
|
|
130
|
+
return undefined;
|
|
131
|
+
}
|
|
132
|
+
function stringList(value) {
|
|
133
|
+
return Array.isArray(value) && value.every((item) => typeof item === "string") ? value : undefined;
|
|
134
|
+
}
|
|
135
|
+
function parseSubscription(value, appLabel, appRefName, ctx, where) {
|
|
136
|
+
const rec = plainObject(value);
|
|
137
|
+
if (rec === undefined) {
|
|
138
|
+
ctx.diagnostics.push(`${where}: subscription is not an object; skipped`);
|
|
139
|
+
return undefined;
|
|
140
|
+
}
|
|
141
|
+
const datasource = datasourceFromTf(rec["datasource_id"], appLabel, appRefName, ctx, `${where}.datasource_id`);
|
|
142
|
+
if (datasource === undefined)
|
|
143
|
+
return undefined;
|
|
144
|
+
const columnsRaw = rec["columns"];
|
|
145
|
+
if (!Array.isArray(columnsRaw)) {
|
|
146
|
+
ctx.diagnostics.push(`${where}: columns is not a list; skipped`);
|
|
147
|
+
return undefined;
|
|
148
|
+
}
|
|
149
|
+
const columns = [];
|
|
150
|
+
for (const [index, value] of columnsRaw.entries()) {
|
|
151
|
+
const column = plainObject(value);
|
|
152
|
+
if (column === undefined) {
|
|
153
|
+
ctx.diagnostics.push(`${where}.columns[${index}]: not an object; subscription skipped`);
|
|
154
|
+
return undefined;
|
|
155
|
+
}
|
|
156
|
+
if (column["expression"] !== undefined) {
|
|
157
|
+
ctx.diagnostics.push(`${where}.columns[${index}]: expression columns are not authorable; subscription skipped`);
|
|
158
|
+
return undefined;
|
|
159
|
+
}
|
|
160
|
+
const field = column["column_id"] !== undefined ? fieldFromTf(column["column_id"], datasource, ctx, `${where}.columns[${index}].column_id`) : undefined;
|
|
161
|
+
if (column["column_id"] !== undefined && field === undefined)
|
|
162
|
+
return undefined;
|
|
163
|
+
columns.push({
|
|
164
|
+
...(field !== undefined ? { field } : {}),
|
|
165
|
+
...(typeof column["aggregation"] === "string" ? { aggregation: column["aggregation"] } : {}),
|
|
166
|
+
...(typeof column["name"] === "string" ? { name: column["name"] } : {}),
|
|
167
|
+
...(typeof column["value"] === "string" ? { value: column["value"] } : {}),
|
|
168
|
+
...(typeof column["value_type"] === "string" ? { valueType: column["value_type"] } : {}),
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
const rawGroupBys = rec["group_bys"];
|
|
172
|
+
const groupBy = Array.isArray(rawGroupBys) ? [] : undefined;
|
|
173
|
+
if (groupBy !== undefined && Array.isArray(rawGroupBys))
|
|
174
|
+
for (const [index, value] of rawGroupBys.entries()) {
|
|
175
|
+
const group = plainObject(value);
|
|
176
|
+
if (group === undefined || group["expression"] !== undefined || group["column_id"] === undefined) {
|
|
177
|
+
ctx.diagnostics.push(`${where}.group_bys[${index}]: only typed field groupings are authorable; subscription skipped`);
|
|
178
|
+
return undefined;
|
|
179
|
+
}
|
|
180
|
+
const field = fieldFromTf(group["column_id"], datasource, ctx, `${where}.group_bys[${index}].column_id`);
|
|
181
|
+
if (field === undefined)
|
|
182
|
+
return undefined;
|
|
183
|
+
groupBy.push({ field });
|
|
184
|
+
}
|
|
185
|
+
const rawJoins = rec["joins"];
|
|
186
|
+
const joins = Array.isArray(rawJoins) ? [] : undefined;
|
|
187
|
+
if (joins !== undefined && Array.isArray(rawJoins))
|
|
188
|
+
for (const [index, value] of rawJoins.entries()) {
|
|
189
|
+
const join = plainObject(value);
|
|
190
|
+
if (join === undefined || join["left_expression"] !== undefined || join["right_expression"] !== undefined) {
|
|
191
|
+
ctx.diagnostics.push(`${where}.joins[${index}]: only typed field joins are authorable; subscription skipped`);
|
|
192
|
+
return undefined;
|
|
193
|
+
}
|
|
194
|
+
const joined = datasourceFromTf(join["datasource_id"], appLabel, appRefName, ctx, `${where}.joins[${index}].datasource_id`);
|
|
195
|
+
if (joined === undefined || join["left_column_id"] === undefined || join["right_column_id"] === undefined)
|
|
196
|
+
return undefined;
|
|
197
|
+
const leftField = fieldFromTf(join["left_column_id"], datasource, ctx, `${where}.joins[${index}].left_column_id`);
|
|
198
|
+
const rightField = fieldFromTf(join["right_column_id"], joined, ctx, `${where}.joins[${index}].right_column_id`);
|
|
199
|
+
if (leftField === undefined || rightField === undefined)
|
|
200
|
+
return undefined;
|
|
201
|
+
joins.push({ datasource: joined, leftField, rightField, ...(typeof join["type"] === "string" ? { type: join["type"] } : {}) });
|
|
202
|
+
}
|
|
203
|
+
if (rec["sort"] !== undefined || rec["with"] !== undefined) {
|
|
204
|
+
ctx.diagnostics.push(`${where}: sort/with JSON is not an authorable typed chart contract; subscription skipped`);
|
|
205
|
+
return undefined;
|
|
206
|
+
}
|
|
207
|
+
let filter;
|
|
208
|
+
if (rec["filter"] !== undefined) {
|
|
209
|
+
try {
|
|
210
|
+
const decoded = decodeJson(rec["filter"]);
|
|
211
|
+
if (decoded === undefined)
|
|
212
|
+
throw new Error("empty filter");
|
|
213
|
+
filter = filterFromTf(decoded, {
|
|
214
|
+
field: (field) => {
|
|
215
|
+
const resolved = fieldFromTf(field, datasource, ctx, `${where}.filter.field`);
|
|
216
|
+
if (resolved === undefined)
|
|
217
|
+
throw new Error("unresolved chart filter field");
|
|
218
|
+
return resolved;
|
|
219
|
+
},
|
|
220
|
+
aspect: () => { throw new Error("chart filter aspect overrides are unsupported"); },
|
|
221
|
+
reference: () => { throw new Error("chart filter references are unsupported"); },
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
catch (error) {
|
|
225
|
+
ctx.diagnostics.push(`${where}.filter: ${error instanceof Error ? error.message : String(error)}; subscription skipped`);
|
|
226
|
+
return undefined;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
return {
|
|
230
|
+
datasource, columns,
|
|
231
|
+
...(groupBy !== undefined ? { groupBy } : {}),
|
|
232
|
+
...(joins !== undefined ? { joins } : {}),
|
|
233
|
+
...(filter !== undefined ? { filter } : {}),
|
|
234
|
+
...(typeof rec["limit"] === "string" ? { limit: rec["limit"] } : {}),
|
|
235
|
+
...(stringList(rec["tags"]) !== undefined ? { tags: stringList(rec["tags"]) } : {}),
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
export function chartFromTf(block, opts, ctx) {
|
|
239
|
+
if (block.type !== CHART_RESOURCE_TYPE || block.label === undefined)
|
|
240
|
+
return undefined;
|
|
241
|
+
const where = `${CHART_RESOURCE_TYPE}.${block.label}`;
|
|
242
|
+
const name = block.attrs["name"];
|
|
243
|
+
const type = block.attrs["type"];
|
|
244
|
+
const rawSubscriptions = block.attrs["subscriptions"];
|
|
245
|
+
if (typeof name !== "string" || typeof type !== "string" || !Array.isArray(rawSubscriptions)) {
|
|
246
|
+
ctx.diagnostics.push(`${where}: name, type, and subscriptions are required; skipped`);
|
|
247
|
+
return undefined;
|
|
248
|
+
}
|
|
249
|
+
const subscriptions = rawSubscriptions.flatMap((value, index) => {
|
|
250
|
+
const parsed = parseSubscription(value, opts.appLabel, opts.appRefName, ctx, `${where}.subscriptions[${index}]`);
|
|
251
|
+
return parsed === undefined ? [] : [parsed];
|
|
252
|
+
});
|
|
253
|
+
if (subscriptions.length !== rawSubscriptions.length)
|
|
254
|
+
return undefined;
|
|
255
|
+
const rawProperties = plainObject(block.attrs["properties"]);
|
|
256
|
+
const properties = rawProperties === undefined ? undefined : {
|
|
257
|
+
...(typeof rawProperties["begin_at_zero"] === "boolean" ? { beginAtZero: rawProperties["begin_at_zero"] } : {}),
|
|
258
|
+
...(typeof rawProperties["fill"] === "boolean" ? { fill: rawProperties["fill"] } : {}),
|
|
259
|
+
...(typeof rawProperties["horizontal"] === "boolean" ? { horizontal: rawProperties["horizontal"] } : {}),
|
|
260
|
+
...(typeof rawProperties["legend"] === "boolean" ? { legend: rawProperties["legend"] } : {}),
|
|
261
|
+
...(typeof rawProperties["stacked"] === "boolean" ? { stacked: rawProperties["stacked"] } : {}),
|
|
262
|
+
...(typeof rawProperties["target"] === "number" ? { target: rawProperties["target"] } : {}),
|
|
263
|
+
};
|
|
264
|
+
return {
|
|
265
|
+
refName: scopedLabelToBagKey(opts.appLabel, block.label, "app"), name, type,
|
|
266
|
+
...(typeof block.attrs["target"] === "number" ? { target: block.attrs["target"] } : {}),
|
|
267
|
+
...(properties !== undefined ? { properties } : {}), subscriptions,
|
|
268
|
+
};
|
|
269
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { chartAggregation, chartColumnValueType, chartJoin, chartJoinType, chartSubscription, chartType, defineChart, type ChartAggregation, type ChartColumn, type ChartColumnValueType, type ChartConfigured, type ChartDatasourceRef, type ChartFieldFor, type ChartGroupBy, type ChartJoin, type ChartJoinType, type ChartProperties, type ChartSubscription, type ChartType, type DefineChartOptions, } from "./build.js";
|
|
2
|
+
export { dashboardChartWidget, dashboardRecordsWidget, dashboardWidgetSize, type DashboardChartWidget, type DashboardWidgetSize, } from "../dashboard/build.js";
|
|
3
|
+
export * as filter from "../shared/filters/index.js";
|
|
4
|
+
export { type Filter } from "../shared/filters/index.js";
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { chartAggregation, chartColumnValueType, chartJoin, chartJoinType, chartSubscription, chartType, defineChart, } from "./build.js";
|
|
2
|
+
export { dashboardChartWidget, dashboardRecordsWidget, dashboardWidgetSize, } from "../dashboard/build.js";
|
|
3
|
+
export * as filter from "../shared/filters/index.js";
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { bareFactoryEntry } from "../../catalog/render-helpers.js";
|
|
2
|
+
import { NO_CANVAS } from "../../graph/types.js";
|
|
3
|
+
import { chartFromTf } from "./from-tf.js";
|
|
4
|
+
import { printChart } from "./printer.js";
|
|
5
|
+
import { chartToTf } from "./to-tf.js";
|
|
6
|
+
import { CHART_RESOURCE_TYPE } from "./types.js";
|
|
7
|
+
export { CHART_RESOURCE_TYPE } from "./types.js";
|
|
8
|
+
function chartStubRef(refName, parent) {
|
|
9
|
+
return { __kind: "chart", refName, name: refName, parent };
|
|
10
|
+
}
|
|
11
|
+
function chartRefFromAuthoring(args) {
|
|
12
|
+
const configured = args.defaultExport;
|
|
13
|
+
return typeof configured?.ref === "function" ? configured.ref(args.refName) : undefined;
|
|
14
|
+
}
|
|
15
|
+
export const chartModule = {
|
|
16
|
+
kind: "chart",
|
|
17
|
+
stream: { role: "streamMember" },
|
|
18
|
+
authoring: { unit: "ownFile", bag: "charts" },
|
|
19
|
+
parents: [{ parent: "app", child: "chart" }],
|
|
20
|
+
resource: { shape: "single", resourceType: CHART_RESOURCE_TYPE, adoptable: true },
|
|
21
|
+
data: { participates: true, resourceType: CHART_RESOURCE_TYPE, lookupAttr: "id", referencedByBuild: false },
|
|
22
|
+
lifecycle: {
|
|
23
|
+
participates: true,
|
|
24
|
+
extractOwnFile: (ownBlocks, _stream, ctx) => {
|
|
25
|
+
const items = [];
|
|
26
|
+
const skipped = [];
|
|
27
|
+
for (const block of ownBlocks) {
|
|
28
|
+
const chart = chartFromTf(block, { appLabel: ctx.appTfLabel, appRefName: ctx.appRefName }, ctx);
|
|
29
|
+
if (chart !== undefined)
|
|
30
|
+
items.push(chart);
|
|
31
|
+
else if (block.label !== undefined)
|
|
32
|
+
skipped.push(`${CHART_RESOURCE_TYPE}.${block.label}`);
|
|
33
|
+
}
|
|
34
|
+
return { items, skipped, diagnostics: [] };
|
|
35
|
+
},
|
|
36
|
+
printOwnFile: (item, opts) => ({
|
|
37
|
+
refName: item.refName,
|
|
38
|
+
source: printChart(item, { appRefName: opts.appRefName, orgImportPath: opts.orgImportPath }),
|
|
39
|
+
}),
|
|
40
|
+
toTf: (entity, ctx) => chartToTf(entity, {
|
|
41
|
+
appRefName: ctx.appRefName,
|
|
42
|
+
appTfLabel: ctx.appTfLabel,
|
|
43
|
+
orgRefs: ctx.orgRefs,
|
|
44
|
+
workspaceAspects: ctx.workspaceAspects,
|
|
45
|
+
streamRootEntity: ctx.streamRootEntity,
|
|
46
|
+
diagnostics: ctx.diagnostics,
|
|
47
|
+
}),
|
|
48
|
+
},
|
|
49
|
+
canvas: NO_CANVAS,
|
|
50
|
+
catalog: {
|
|
51
|
+
participates: true,
|
|
52
|
+
refKind: "chart",
|
|
53
|
+
catalogBag: "charts",
|
|
54
|
+
renderOrder: 66,
|
|
55
|
+
catalogRoot: "app",
|
|
56
|
+
factoryName: "chartRef",
|
|
57
|
+
renderEntry: ({ keyName, baseIndent }) => bareFactoryEntry("chartRef", keyName, baseIndent),
|
|
58
|
+
stubRef: chartStubRef,
|
|
59
|
+
refFromAuthoring: chartRefFromAuthoring,
|
|
60
|
+
},
|
|
61
|
+
};
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { quote } from "../../../pull/util.js";
|
|
2
|
+
import { sdkPackageSpecifier } from "../../internal/sdk-package.js";
|
|
3
|
+
import { printFilter } from "../shared/filters/print.js";
|
|
4
|
+
import { chartAggregation, chartColumnValueType, chartJoinType, chartType, } from "./types.js";
|
|
5
|
+
function member(value) { return /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(value) ? `.${value}` : `[${quote(value)}]`; }
|
|
6
|
+
function constantKey(values, value, domain) {
|
|
7
|
+
const entry = Object.entries(values).find(([, candidate]) => candidate === value);
|
|
8
|
+
if (entry === undefined)
|
|
9
|
+
throw new Error(`chart pull: unsupported ${domain} ${JSON.stringify(value)}`);
|
|
10
|
+
return entry[0];
|
|
11
|
+
}
|
|
12
|
+
function dataExpr(value) {
|
|
13
|
+
return value.kind === "table" ? `catalog.tables${member(value.refName)}` : `catalog${member(value.refName)}`;
|
|
14
|
+
}
|
|
15
|
+
function fieldExpr(value) {
|
|
16
|
+
return value.kind === "tableColumn"
|
|
17
|
+
? `catalog.tables${member(value.parentRefName)}.columns${member(value.refName)}`
|
|
18
|
+
: `catalog${member(value.parentRefName)}.fields${member(value.refName)}`;
|
|
19
|
+
}
|
|
20
|
+
function printColumn(column) {
|
|
21
|
+
const parts = [];
|
|
22
|
+
if (column.field !== undefined)
|
|
23
|
+
parts.push(`field: ${fieldExpr(column.field)}`);
|
|
24
|
+
if (column.aggregation !== undefined)
|
|
25
|
+
parts.push(`aggregation: chartAggregation.${constantKey(chartAggregation, column.aggregation, "aggregation")}`);
|
|
26
|
+
if (column.name !== undefined)
|
|
27
|
+
parts.push(`name: ${quote(column.name)}`);
|
|
28
|
+
if (column.value !== undefined)
|
|
29
|
+
parts.push(`value: ${quote(column.value)}`);
|
|
30
|
+
if (column.valueType !== undefined)
|
|
31
|
+
parts.push(`valueType: chartColumnValueType.${constantKey(chartColumnValueType, column.valueType, "column value type")}`);
|
|
32
|
+
return `{ ${parts.join(", ")} }`;
|
|
33
|
+
}
|
|
34
|
+
function printSubscription(subscription) {
|
|
35
|
+
const lines = [" chartSubscription({", ` datasource: ${dataExpr(subscription.datasource)},`];
|
|
36
|
+
lines.push(` columns: [${subscription.columns.map(printColumn).join(", ")}],`);
|
|
37
|
+
if (subscription.groupBy !== undefined) {
|
|
38
|
+
lines.push(` groupBy: [${subscription.groupBy.map((group) => `{ field: ${fieldExpr(group.field)} }`).join(", ")}],`);
|
|
39
|
+
}
|
|
40
|
+
if (subscription.joins !== undefined) {
|
|
41
|
+
lines.push(" joins: [");
|
|
42
|
+
for (const join of subscription.joins) {
|
|
43
|
+
const parts = [`from: ${dataExpr(subscription.datasource)}`, `datasource: ${dataExpr(join.datasource)}`];
|
|
44
|
+
parts.push(`leftField: ${fieldExpr(join.leftField)}`);
|
|
45
|
+
parts.push(`rightField: ${fieldExpr(join.rightField)}`);
|
|
46
|
+
if (join.type !== undefined)
|
|
47
|
+
parts.push(`type: chartJoinType.${constantKey(chartJoinType, join.type, "join type")}`);
|
|
48
|
+
lines.push(` chartJoin({ ${parts.join(", ")} }),`);
|
|
49
|
+
}
|
|
50
|
+
lines.push(" ],");
|
|
51
|
+
}
|
|
52
|
+
if (subscription.filter !== undefined) {
|
|
53
|
+
lines.push(` filter: ${printFilter(subscription.filter, {
|
|
54
|
+
field: fieldExpr,
|
|
55
|
+
aspect: () => { throw new Error("chart pull: filter aspect overrides are unsupported"); },
|
|
56
|
+
reference: () => { throw new Error("chart pull: filter references are unsupported"); },
|
|
57
|
+
})},`);
|
|
58
|
+
}
|
|
59
|
+
if (subscription.limit !== undefined)
|
|
60
|
+
lines.push(` limit: ${quote(subscription.limit)},`);
|
|
61
|
+
if (subscription.tags !== undefined)
|
|
62
|
+
lines.push(` tags: ${JSON.stringify(subscription.tags)},`);
|
|
63
|
+
lines.push(" }),");
|
|
64
|
+
return lines;
|
|
65
|
+
}
|
|
66
|
+
export function printChart(chart, opts) {
|
|
67
|
+
const imports = ["chartSubscription", "chartType", "defineChart"];
|
|
68
|
+
if (chart.subscriptions.some((subscription) => subscription.columns.some((column) => column.aggregation !== undefined)))
|
|
69
|
+
imports.push("chartAggregation");
|
|
70
|
+
if (chart.subscriptions.some((subscription) => subscription.columns.some((column) => column.valueType !== undefined)))
|
|
71
|
+
imports.push("chartColumnValueType");
|
|
72
|
+
if (chart.subscriptions.some((subscription) => (subscription.joins?.length ?? 0) > 0))
|
|
73
|
+
imports.push("chartJoin");
|
|
74
|
+
if (chart.subscriptions.some((subscription) => subscription.joins?.some((join) => join.type !== undefined) === true))
|
|
75
|
+
imports.push("chartJoinType");
|
|
76
|
+
if (chart.subscriptions.some((subscription) => subscription.filter !== undefined))
|
|
77
|
+
imports.push("filter");
|
|
78
|
+
const lines = [
|
|
79
|
+
"/** Auto-generated by EDK pull. Hand-edit freely. */",
|
|
80
|
+
`import { ${imports.sort().join(", ")} } from ${quote(sdkPackageSpecifier("charts"))};`,
|
|
81
|
+
'import catalog from "@catalog";',
|
|
82
|
+
"",
|
|
83
|
+
"const chart = defineChart({",
|
|
84
|
+
` app: catalog${member(opts.appRefName)},`,
|
|
85
|
+
` name: ${quote(chart.name)},`,
|
|
86
|
+
` type: chartType.${constantKey(chartType, chart.type, "type")},`,
|
|
87
|
+
];
|
|
88
|
+
if (chart.target !== undefined)
|
|
89
|
+
lines.push(` target: ${chart.target},`);
|
|
90
|
+
if (chart.properties !== undefined) {
|
|
91
|
+
const parts = [];
|
|
92
|
+
for (const key of ["beginAtZero", "fill", "horizontal", "legend", "stacked", "target"]) {
|
|
93
|
+
const value = chart.properties[key];
|
|
94
|
+
if (value !== undefined)
|
|
95
|
+
parts.push(`${key}: ${String(value)}`);
|
|
96
|
+
}
|
|
97
|
+
lines.push(` properties: { ${parts.join(", ")} },`);
|
|
98
|
+
}
|
|
99
|
+
lines.push(" subscriptions: [");
|
|
100
|
+
for (const subscription of chart.subscriptions)
|
|
101
|
+
lines.push(...printSubscription(subscription));
|
|
102
|
+
lines.push(" ],", "});", "", "export default chart;", "");
|
|
103
|
+
return lines.join("\n");
|
|
104
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type OrgRefLookup, type WorkspaceAspect } from "../../engine/build/context.js";
|
|
2
|
+
import { type DeployableEntity } from "../../engine/entity.js";
|
|
3
|
+
import { type TfBlock } from "../../engine/tf/index.js";
|
|
4
|
+
export interface ChartToTfOptions {
|
|
5
|
+
readonly appRefName: string;
|
|
6
|
+
readonly appTfLabel: string;
|
|
7
|
+
readonly orgRefs: OrgRefLookup;
|
|
8
|
+
readonly workspaceAspects?: ReadonlyMap<string, WorkspaceAspect>;
|
|
9
|
+
readonly streamRootEntity?: DeployableEntity;
|
|
10
|
+
readonly diagnostics: string[];
|
|
11
|
+
}
|
|
12
|
+
export declare function chartToTf(entity: DeployableEntity, opts: ChartToTfOptions): {
|
|
13
|
+
readonly blocks: readonly TfBlock[];
|
|
14
|
+
readonly address: string;
|
|
15
|
+
};
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { workspaceAspectKey, } from "../../engine/build/context.js";
|
|
2
|
+
import { EntityTfError } from "../../engine/entity.js";
|
|
3
|
+
import { expr, sanitizeName, scopedResourceLabel, tsLabelToTfLabel, } from "../../engine/tf/index.js";
|
|
4
|
+
import { fieldRefToTfValue } from "../field/to-tf.js";
|
|
5
|
+
import { filterToTf as serializeFilterToTf } from "../shared/filters/tf-codec.js";
|
|
6
|
+
import { CHART_RESOURCE_TYPE } from "./types.js";
|
|
7
|
+
const APP_RESOURCE_TYPE = "elementum_app";
|
|
8
|
+
const TABLE_RESOURCE_TYPE = "elementum_table";
|
|
9
|
+
function datasourceId(ref, opts, where) {
|
|
10
|
+
if (ref?.refName === undefined || ref.refName === "" || ref.__kind === undefined) {
|
|
11
|
+
throw new EntityTfError(`${where}: datasource must be a typed app, element, or table ref`);
|
|
12
|
+
}
|
|
13
|
+
if (ref.__kind !== "app" && ref.__kind !== "element" && ref.__kind !== "table") {
|
|
14
|
+
throw new EntityTfError(`${where}: unsupported datasource kind ${JSON.stringify(ref.__kind)}`);
|
|
15
|
+
}
|
|
16
|
+
const local = opts.workspaceAspects?.get(workspaceAspectKey(ref.__kind, ref.refName));
|
|
17
|
+
if (local !== undefined) {
|
|
18
|
+
const type = ref.__kind === "app" ? APP_RESOURCE_TYPE : ref.__kind === "element" ? "elementum_element" : TABLE_RESOURCE_TYPE;
|
|
19
|
+
return { ref, id: expr.resourceAttr(type, local.tfLabel, ["id"]), tfLabel: local.tfLabel, local: true };
|
|
20
|
+
}
|
|
21
|
+
const name = ref.name ?? ref.refName;
|
|
22
|
+
const label = sanitizeName(name);
|
|
23
|
+
if (ref.__kind === "app")
|
|
24
|
+
opts.orgRefs.foreignApp(label, name);
|
|
25
|
+
else if (ref.__kind === "element")
|
|
26
|
+
opts.orgRefs.foreignElement(label, name);
|
|
27
|
+
else
|
|
28
|
+
opts.orgRefs.rawLookup(TABLE_RESOURCE_TYPE, label, name);
|
|
29
|
+
const type = ref.__kind === "app" ? APP_RESOURCE_TYPE : ref.__kind === "element" ? "elementum_element" : TABLE_RESOURCE_TYPE;
|
|
30
|
+
return { ref, id: expr.dataAttr(type, label, ["id"]), tfLabel: label, local: false };
|
|
31
|
+
}
|
|
32
|
+
function fieldId(ref, datasource, opts, where) {
|
|
33
|
+
if (ref?.refName === undefined || ref.refName === "")
|
|
34
|
+
throw new EntityTfError(`${where}: field ref is missing its key`);
|
|
35
|
+
if (ref.parent !== undefined && ref.parent !== datasource.ref.refName) {
|
|
36
|
+
throw new EntityTfError(`${where}: field belongs to ${JSON.stringify(ref.parent)}, not datasource ${JSON.stringify(datasource.ref.refName)}`);
|
|
37
|
+
}
|
|
38
|
+
if (ref.__kind === "tableColumn") {
|
|
39
|
+
const fieldName = ref.name ?? ref.refName;
|
|
40
|
+
return datasource.local
|
|
41
|
+
? expr.resourceAttr(TABLE_RESOURCE_TYPE, datasource.tfLabel, ["field_ids", { index: fieldName }])
|
|
42
|
+
: expr.dataAttr(TABLE_RESOURCE_TYPE, datasource.tfLabel, ["field_ids", { index: fieldName }]);
|
|
43
|
+
}
|
|
44
|
+
if (ref.__kind !== "field")
|
|
45
|
+
throw new EntityTfError(`${where}: expected a field or table-column ref`);
|
|
46
|
+
if (datasource.ref.__kind === "table")
|
|
47
|
+
throw new EntityTfError(`${where}: app/element fields cannot belong to a table datasource`);
|
|
48
|
+
if (datasource.local) {
|
|
49
|
+
const scope = datasource.ref.__kind === "element" ? "element" : "app";
|
|
50
|
+
const direct = fieldRefToTfValue(ref.fieldType ?? "", ref.refName, datasource.tfLabel, scope);
|
|
51
|
+
if (direct !== undefined)
|
|
52
|
+
return direct;
|
|
53
|
+
}
|
|
54
|
+
const label = sanitizeName(`${datasource.ref.__kind}_${datasource.ref.refName}_${ref.refName}`);
|
|
55
|
+
opts.orgRefs.foreignField("elementum_field", label, datasource.id, ref.name ?? ref.refName);
|
|
56
|
+
return expr.dataAttr("elementum_field", label, ["id"]);
|
|
57
|
+
}
|
|
58
|
+
function columnToTf(column, datasource, opts, where) {
|
|
59
|
+
const out = {};
|
|
60
|
+
if (column.field !== undefined)
|
|
61
|
+
out["column_id"] = fieldId(column.field, datasource, opts, `${where}.field`);
|
|
62
|
+
if (column.aggregation !== undefined)
|
|
63
|
+
out["aggregation"] = column.aggregation;
|
|
64
|
+
if (column.name !== undefined)
|
|
65
|
+
out["name"] = column.name;
|
|
66
|
+
if (column.value !== undefined)
|
|
67
|
+
out["value"] = column.value;
|
|
68
|
+
if (column.valueType !== undefined)
|
|
69
|
+
out["value_type"] = column.valueType;
|
|
70
|
+
return out;
|
|
71
|
+
}
|
|
72
|
+
function filterToTf(value, datasource, opts, where) {
|
|
73
|
+
return expr.jsonencode(serializeFilterToTf(value, {
|
|
74
|
+
field: (field) => fieldId(field, datasource, opts, `${where}.field`),
|
|
75
|
+
aspect: () => datasource.id,
|
|
76
|
+
reference: () => { throw new EntityTfError(`${where}: runtime reference values are not supported in chart filters`); },
|
|
77
|
+
}));
|
|
78
|
+
}
|
|
79
|
+
function subscriptionToTf(subscription, opts, where) {
|
|
80
|
+
const datasource = datasourceId(subscription.datasource, opts, `${where}.datasource`);
|
|
81
|
+
const out = {
|
|
82
|
+
datasource_id: datasource.id,
|
|
83
|
+
columns: (subscription.columns ?? []).map((column, index) => columnToTf(column, datasource, opts, `${where}.columns[${index}]`)),
|
|
84
|
+
};
|
|
85
|
+
if (subscription.groupBy !== undefined && subscription.groupBy.length > 0) {
|
|
86
|
+
out["group_bys"] = subscription.groupBy.map((group, index) => ({
|
|
87
|
+
column_id: fieldId(group.field, datasource, opts, `${where}.groupBy[${index}].field`),
|
|
88
|
+
}));
|
|
89
|
+
}
|
|
90
|
+
if (subscription.joins !== undefined && subscription.joins.length > 0) {
|
|
91
|
+
out["joins"] = subscription.joins.map((join, index) => {
|
|
92
|
+
const joined = datasourceId(join.datasource, opts, `${where}.joins[${index}].datasource`);
|
|
93
|
+
return {
|
|
94
|
+
datasource_id: joined.id,
|
|
95
|
+
left_column_id: fieldId(join.leftField, datasource, opts, `${where}.joins[${index}].leftField`),
|
|
96
|
+
right_column_id: fieldId(join.rightField, joined, opts, `${where}.joins[${index}].rightField`),
|
|
97
|
+
...(join.type !== undefined ? { type: join.type } : {}),
|
|
98
|
+
};
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
if (subscription.filter !== undefined)
|
|
102
|
+
out["filter"] = filterToTf(subscription.filter, datasource, opts, `${where}.filter`);
|
|
103
|
+
if (subscription.limit !== undefined)
|
|
104
|
+
out["limit"] = subscription.limit;
|
|
105
|
+
if (subscription.tags !== undefined && subscription.tags.length > 0)
|
|
106
|
+
out["tags"] = [...subscription.tags];
|
|
107
|
+
return out;
|
|
108
|
+
}
|
|
109
|
+
function hasSameAppChartWidget(entity, root) {
|
|
110
|
+
const payload = root.payload;
|
|
111
|
+
if (payload?.dashboards === undefined)
|
|
112
|
+
return false;
|
|
113
|
+
return Object.values(payload.dashboards).some((dashboard) => Object.values(dashboard.widgets ?? {}).some((widget) => {
|
|
114
|
+
if (typeof widget !== "object" || widget === null)
|
|
115
|
+
return false;
|
|
116
|
+
const candidate = widget;
|
|
117
|
+
return candidate.type === "chart" && candidate.chart?.refName === entity.refName && candidate.chart.parent === root.refName;
|
|
118
|
+
}));
|
|
119
|
+
}
|
|
120
|
+
export function chartToTf(entity, opts) {
|
|
121
|
+
if (entity.kind !== "chart")
|
|
122
|
+
throw new EntityTfError(`chartToTf expects kind "chart"; got ${JSON.stringify(entity.kind)}`);
|
|
123
|
+
const chart = entity.payload;
|
|
124
|
+
if (chart === null || chart.app?.refName !== opts.appRefName) {
|
|
125
|
+
throw new EntityTfError(`chart "${entity.refName}" does not reference owning app "${opts.appRefName}"`);
|
|
126
|
+
}
|
|
127
|
+
if (opts.streamRootEntity !== undefined && !hasSameAppChartWidget(entity, opts.streamRootEntity)) {
|
|
128
|
+
throw new EntityTfError(`chart "${entity.refName}" must be referenced by a same-app dashboard chart widget so pull can rediscover its owner`);
|
|
129
|
+
}
|
|
130
|
+
const label = scopedResourceLabel(opts.appTfLabel, tsLabelToTfLabel(entity.refName), "app");
|
|
131
|
+
const attrs = {
|
|
132
|
+
name: chart.name ?? "",
|
|
133
|
+
type: chart.type ?? "",
|
|
134
|
+
subscriptions: (chart.subscriptions ?? []).map((subscription, index) => subscriptionToTf(subscription, opts, `chart ${entity.refName}.subscriptions[${index}]`)),
|
|
135
|
+
};
|
|
136
|
+
if (chart.target !== undefined)
|
|
137
|
+
attrs["target"] = chart.target;
|
|
138
|
+
if (chart.properties !== undefined) {
|
|
139
|
+
attrs["properties"] = {
|
|
140
|
+
...(chart.properties.beginAtZero !== undefined ? { begin_at_zero: chart.properties.beginAtZero } : {}),
|
|
141
|
+
...(chart.properties.fill !== undefined ? { fill: chart.properties.fill } : {}),
|
|
142
|
+
...(chart.properties.horizontal !== undefined ? { horizontal: chart.properties.horizontal } : {}),
|
|
143
|
+
...(chart.properties.legend !== undefined ? { legend: chart.properties.legend } : {}),
|
|
144
|
+
...(chart.properties.stacked !== undefined ? { stacked: chart.properties.stacked } : {}),
|
|
145
|
+
...(chart.properties.target !== undefined ? { target: chart.properties.target } : {}),
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
const block = { kind: "resource", type: CHART_RESOURCE_TYPE, label, attrs };
|
|
149
|
+
return { blocks: [block], address: `${CHART_RESOURCE_TYPE}.${label}` };
|
|
150
|
+
}
|