@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,53 @@
|
|
|
1
|
+
/** Terraform resource type for chart resources. Kept dependency-free to avoid entity-module cycles. */
|
|
2
|
+
export declare const CHART_RESOURCE_TYPE = "elementum_chart";
|
|
3
|
+
declare const chartTypeBrand: unique symbol;
|
|
4
|
+
declare const chartAggregationBrand: unique symbol;
|
|
5
|
+
declare const chartColumnValueTypeBrand: unique symbol;
|
|
6
|
+
declare const chartJoinTypeBrand: unique symbol;
|
|
7
|
+
type Branded<Value extends string, Brand extends symbol> = Value & {
|
|
8
|
+
readonly [Key in Brand]: true;
|
|
9
|
+
};
|
|
10
|
+
type ChartTypeValue = "BAR" | "BUBBLE" | "DOUGHNUT" | "LINE" | "PIE" | "POLAR" | "RADAR" | "SCATTER" | "SINGLEBAR" | "SINGLELINE" | "SINGLEVALUE";
|
|
11
|
+
export type ChartType = Branded<ChartTypeValue, typeof chartTypeBrand>;
|
|
12
|
+
export declare const chartType: {
|
|
13
|
+
readonly bar: ChartType;
|
|
14
|
+
readonly bubble: ChartType;
|
|
15
|
+
readonly doughnut: ChartType;
|
|
16
|
+
readonly line: ChartType;
|
|
17
|
+
readonly pie: ChartType;
|
|
18
|
+
readonly polar: ChartType;
|
|
19
|
+
readonly radar: ChartType;
|
|
20
|
+
readonly scatter: ChartType;
|
|
21
|
+
readonly singleBar: ChartType;
|
|
22
|
+
readonly singleLine: ChartType;
|
|
23
|
+
readonly singleValue: ChartType;
|
|
24
|
+
};
|
|
25
|
+
type ChartAggregationValue = "AVERAGE" | "COUNT" | "MAX" | "MIN" | "SUM";
|
|
26
|
+
export type ChartAggregation = Branded<ChartAggregationValue, typeof chartAggregationBrand>;
|
|
27
|
+
export declare const chartAggregation: {
|
|
28
|
+
readonly average: ChartAggregation;
|
|
29
|
+
readonly count: ChartAggregation;
|
|
30
|
+
readonly max: ChartAggregation;
|
|
31
|
+
readonly min: ChartAggregation;
|
|
32
|
+
readonly sum: ChartAggregation;
|
|
33
|
+
};
|
|
34
|
+
type ChartColumnValueTypeValue = "BOOLEAN" | "DATE" | "DATETIME" | "DECIMAL" | "LONG" | "TEXT" | "UUID";
|
|
35
|
+
export type ChartColumnValueType = Branded<ChartColumnValueTypeValue, typeof chartColumnValueTypeBrand>;
|
|
36
|
+
export declare const chartColumnValueType: {
|
|
37
|
+
readonly boolean: ChartColumnValueType;
|
|
38
|
+
readonly date: ChartColumnValueType;
|
|
39
|
+
readonly dateTime: ChartColumnValueType;
|
|
40
|
+
readonly decimal: ChartColumnValueType;
|
|
41
|
+
readonly long: ChartColumnValueType;
|
|
42
|
+
readonly text: ChartColumnValueType;
|
|
43
|
+
readonly uuid: ChartColumnValueType;
|
|
44
|
+
};
|
|
45
|
+
type ChartJoinTypeValue = "FULL" | "INNER" | "LEFT" | "RIGHT";
|
|
46
|
+
export type ChartJoinType = Branded<ChartJoinTypeValue, typeof chartJoinTypeBrand>;
|
|
47
|
+
export declare const chartJoinType: {
|
|
48
|
+
readonly full: ChartJoinType;
|
|
49
|
+
readonly inner: ChartJoinType;
|
|
50
|
+
readonly left: ChartJoinType;
|
|
51
|
+
readonly right: ChartJoinType;
|
|
52
|
+
};
|
|
53
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** Terraform resource type for chart resources. Kept dependency-free to avoid entity-module cycles. */
|
|
2
|
+
export const CHART_RESOURCE_TYPE = "elementum_chart";
|
|
3
|
+
export const chartType = {
|
|
4
|
+
bar: "BAR", bubble: "BUBBLE", doughnut: "DOUGHNUT",
|
|
5
|
+
line: "LINE", pie: "PIE", polar: "POLAR",
|
|
6
|
+
radar: "RADAR", scatter: "SCATTER", singleBar: "SINGLEBAR",
|
|
7
|
+
singleLine: "SINGLELINE", singleValue: "SINGLEVALUE",
|
|
8
|
+
};
|
|
9
|
+
export const chartAggregation = {
|
|
10
|
+
average: "AVERAGE", count: "COUNT",
|
|
11
|
+
max: "MAX", min: "MIN", sum: "SUM",
|
|
12
|
+
};
|
|
13
|
+
export const chartColumnValueType = {
|
|
14
|
+
boolean: "BOOLEAN", date: "DATE",
|
|
15
|
+
dateTime: "DATETIME", decimal: "DECIMAL",
|
|
16
|
+
long: "LONG", text: "TEXT",
|
|
17
|
+
uuid: "UUID",
|
|
18
|
+
};
|
|
19
|
+
export const chartJoinType = {
|
|
20
|
+
full: "FULL", inner: "INNER",
|
|
21
|
+
left: "LEFT", right: "RIGHT",
|
|
22
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { AppCatalogRef, AppOrElementRef, ChartRef, FieldRef } from "../../catalog/index.js";
|
|
2
|
+
import type { Filter } from "../shared/filters/types.js";
|
|
3
|
+
declare const dashboardWidgetSizeBrand: unique symbol;
|
|
4
|
+
declare const dashboardWidgetBrand: unique symbol;
|
|
5
|
+
type DashboardWidgetSizeValue = "EXTRA_SMALL" | "SMALL" | "MEDIUM" | "LARGE" | "EXTRA_LARGE";
|
|
6
|
+
export type DashboardWidgetSize = DashboardWidgetSizeValue & {
|
|
7
|
+
readonly [dashboardWidgetSizeBrand]: true;
|
|
8
|
+
};
|
|
9
|
+
export declare const dashboardWidgetSize: {
|
|
10
|
+
readonly extraSmall: DashboardWidgetSize;
|
|
11
|
+
readonly small: DashboardWidgetSize;
|
|
12
|
+
readonly medium: DashboardWidgetSize;
|
|
13
|
+
readonly large: DashboardWidgetSize;
|
|
14
|
+
readonly extraLarge: DashboardWidgetSize;
|
|
15
|
+
};
|
|
16
|
+
interface DashboardWidgetBase {
|
|
17
|
+
readonly name: string;
|
|
18
|
+
readonly size?: DashboardWidgetSize;
|
|
19
|
+
readonly color?: string;
|
|
20
|
+
readonly icon?: string;
|
|
21
|
+
}
|
|
22
|
+
export interface DashboardRecordsWidget<Target extends AppOrElementRef = AppOrElementRef> extends DashboardWidgetBase {
|
|
23
|
+
readonly [dashboardWidgetBrand]: "records";
|
|
24
|
+
readonly type: "records";
|
|
25
|
+
readonly target: Target;
|
|
26
|
+
readonly filter?: Filter<FieldRef<Target["refName"]>, never>;
|
|
27
|
+
}
|
|
28
|
+
export interface DashboardChartWidget<Parent extends string = string> extends DashboardWidgetBase {
|
|
29
|
+
readonly [dashboardWidgetBrand]: "chart";
|
|
30
|
+
readonly type: "chart";
|
|
31
|
+
readonly chart: ChartRef<Parent>;
|
|
32
|
+
}
|
|
33
|
+
/** Build a record-list widget with a typed app/element target. */
|
|
34
|
+
export declare function dashboardRecordsWidget<const Target extends AppOrElementRef>(opts: DashboardWidgetBase & {
|
|
35
|
+
readonly target: Target;
|
|
36
|
+
readonly filter?: Filter<FieldRef<NoInfer<Target>["refName"]>, never>;
|
|
37
|
+
}): DashboardRecordsWidget<Target>;
|
|
38
|
+
/** Build a chart widget and enforce that chart and dashboard share an app owner. */
|
|
39
|
+
export declare function dashboardChartWidget<const Parent extends string>(opts: DashboardWidgetBase & {
|
|
40
|
+
readonly owner: AppCatalogRef<Parent>;
|
|
41
|
+
readonly chart: ChartRef<NoInfer<Parent>>;
|
|
42
|
+
}): DashboardChartWidget<Parent>;
|
|
43
|
+
export type DashboardWidget = DashboardRecordsWidget | DashboardChartWidget;
|
|
44
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export const dashboardWidgetSize = {
|
|
2
|
+
extraSmall: "EXTRA_SMALL",
|
|
3
|
+
small: "SMALL",
|
|
4
|
+
medium: "MEDIUM",
|
|
5
|
+
large: "LARGE",
|
|
6
|
+
extraLarge: "EXTRA_LARGE",
|
|
7
|
+
};
|
|
8
|
+
/** Build a record-list widget with a typed app/element target. */
|
|
9
|
+
export function dashboardRecordsWidget(opts) {
|
|
10
|
+
return { ...opts, type: "records" };
|
|
11
|
+
}
|
|
12
|
+
/** Build a chart widget and enforce that chart and dashboard share an app owner. */
|
|
13
|
+
export function dashboardChartWidget(opts) {
|
|
14
|
+
const { owner: _owner, ...widget } = opts;
|
|
15
|
+
return { ...widget, type: "chart" };
|
|
16
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type FromTfContext } from "../../engine/pull/context.js";
|
|
2
|
+
import { type ChildResourceScope, type TfBlock } from "../../engine/tf/index.js";
|
|
3
|
+
import type { NormalizedDashboard } from "../app/deserializer/normalize.js";
|
|
4
|
+
export interface DashboardOwner {
|
|
5
|
+
readonly type: "elementum_app" | "elementum_element";
|
|
6
|
+
readonly label: string;
|
|
7
|
+
readonly ownerTfLabel: string;
|
|
8
|
+
readonly ownerRefName?: string;
|
|
9
|
+
readonly scope: ChildResourceScope;
|
|
10
|
+
readonly ownerType: "APP_ASPECT" | "ELEMENT_ASPECT";
|
|
11
|
+
}
|
|
12
|
+
export declare function dashboardsFromTf(blocks: readonly TfBlock[], widgetBlocks: readonly TfBlock[], owner: DashboardOwner, ctx: FromTfContext): NormalizedDashboard[];
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { dataRefLabel, optionalString, plainObject, resourceRefLabel } from "../../engine/pull/context.js";
|
|
2
|
+
import { reportUnknownAttrs, stringList } from "../../engine/pull/attrs.js";
|
|
3
|
+
import { isTfExpr, scopedLabelToBagKey, tfLabelToTsLabel } from "../../engine/tf/index.js";
|
|
4
|
+
import { filterFromTf } from "../access-policy/from-tf.js";
|
|
5
|
+
import { filterWireToTf } from "../shared/filters/tf-codec.js";
|
|
6
|
+
import { DASHBOARD_WIDGET_RESOURCE_TYPE } from "../dashboard-widget/module.js";
|
|
7
|
+
import { DASHBOARD_RESOURCE_TYPE } from "./module.js";
|
|
8
|
+
import { CHART_RESOURCE_TYPE } from "../chart/types.js";
|
|
9
|
+
import { dashboardWidgetSize } from "./build.js";
|
|
10
|
+
const KNOWN_DASHBOARD_ATTRS = new Set(["name", "owner_id", "owner_type", "favorite", "tags"]);
|
|
11
|
+
export function dashboardsFromTf(blocks, widgetBlocks, owner, ctx) {
|
|
12
|
+
const dashboards = [];
|
|
13
|
+
for (const block of blocks) {
|
|
14
|
+
const label = block.label;
|
|
15
|
+
if (label === undefined || label === "") {
|
|
16
|
+
ctx.diagnostics.push(`${DASHBOARD_RESOURCE_TYPE} block is missing its label; skipped`);
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
const where = `dashboard "${label}"`;
|
|
20
|
+
reportUnknownAttrs(block.attrs, KNOWN_DASHBOARD_ATTRS, where, "dashboardsFromTf", ctx);
|
|
21
|
+
if (resourceRefLabel(block.attrs["owner_id"], owner.type) !== owner.label) {
|
|
22
|
+
ctx.diagnostics.push(`${where}: owner_id does not reference ${owner.type}.${owner.label}; skipped`);
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
if (block.attrs["owner_type"] !== owner.ownerType) {
|
|
26
|
+
ctx.diagnostics.push(`${where}: owner_type is not ${owner.ownerType}; skipped`);
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
const tags = stringList(block.attrs, "tags", where, ctx);
|
|
30
|
+
const key = scopedLabelToBagKey(owner.ownerTfLabel, label, owner.scope);
|
|
31
|
+
const widgets = dashboardWidgetsFromTf(widgetBlocks.filter((widget) => resourceRefLabel(widget.attrs["dashboard_id"], DASHBOARD_RESOURCE_TYPE) === label), label, owner, ctx);
|
|
32
|
+
dashboards.push({
|
|
33
|
+
key,
|
|
34
|
+
name: optionalString(block.attrs, "name", where, ctx) ?? "",
|
|
35
|
+
...(typeof block.attrs["favorite"] === "boolean" && { favorite: block.attrs["favorite"] }),
|
|
36
|
+
...(tags !== undefined && { tags }),
|
|
37
|
+
...(widgets.length > 0 && { widgets }),
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
return dashboards;
|
|
41
|
+
}
|
|
42
|
+
function dashboardWidgetsFromTf(blocks, dashboardLabel, owner, ctx) {
|
|
43
|
+
return blocks.flatMap((block) => {
|
|
44
|
+
const where = `${DASHBOARD_WIDGET_RESOURCE_TYPE}.${block.label ?? "?"}`;
|
|
45
|
+
const label = block.label ?? "";
|
|
46
|
+
const key = tfLabelToTsLabel(label.startsWith(`${dashboardLabel}_`) ? label.slice(dashboardLabel.length + 1) : label);
|
|
47
|
+
const name = optionalString(block.attrs, "name", where, ctx) ?? "";
|
|
48
|
+
const size = optionalString(block.attrs, "size", where, ctx) ?? "MEDIUM";
|
|
49
|
+
if (!Object.values(dashboardWidgetSize).includes(size)) {
|
|
50
|
+
ctx.diagnostics.push(`${where}.size: unsupported dashboard widget size ${JSON.stringify(size)}; skipped`);
|
|
51
|
+
return [];
|
|
52
|
+
}
|
|
53
|
+
const color = optionalString(block.attrs, "color", where, ctx);
|
|
54
|
+
const icon = optionalString(block.attrs, "icon", where, ctx);
|
|
55
|
+
const aspect = plainObject(block.attrs["aspect_widget"]);
|
|
56
|
+
const style = { key, name, size, ...(color !== undefined && { color }), ...(icon !== undefined && { icon }) };
|
|
57
|
+
const chart = plainObject(block.attrs["chart_widget"]);
|
|
58
|
+
if (chart !== undefined) {
|
|
59
|
+
const chartLabel = resourceRefLabel(chart["chart_id"], CHART_RESOURCE_TYPE);
|
|
60
|
+
if (chartLabel === undefined) {
|
|
61
|
+
ctx.diagnostics.push(`${where}.chart_widget.chart_id: expected a managed chart reference; skipped`);
|
|
62
|
+
return [];
|
|
63
|
+
}
|
|
64
|
+
return [{ ...style, type: "chart", chartKey: scopedLabelToBagKey(owner.ownerTfLabel, chartLabel, owner.scope) }];
|
|
65
|
+
}
|
|
66
|
+
if (aspect === undefined) {
|
|
67
|
+
ctx.diagnostics.push(`${where}: expected an aspect_widget or chart_widget; skipped`);
|
|
68
|
+
return [];
|
|
69
|
+
}
|
|
70
|
+
if (aspect["sort"] !== undefined) {
|
|
71
|
+
ctx.diagnostics.push(`${where}.aspect_widget.sort: dashboard record sort has no typed public contract; skipped`);
|
|
72
|
+
return [];
|
|
73
|
+
}
|
|
74
|
+
const target = aspectRef(aspect["aspect_id"], owner, ctx);
|
|
75
|
+
if (target === undefined) {
|
|
76
|
+
ctx.diagnostics.push(`${where}.aspect_widget.aspect_id: unresolved; skipped`);
|
|
77
|
+
return [];
|
|
78
|
+
}
|
|
79
|
+
return [{ ...style, type: "records", target,
|
|
80
|
+
...(aspect["filter"] !== undefined && {
|
|
81
|
+
filter: filterFromTf(filterWireToTf(decodeJson(aspect["filter"])), { ...owner, ownerRefName: owner.ownerRefName ?? owner.ownerTfLabel }, `${where}.aspect_widget.filter`),
|
|
82
|
+
}),
|
|
83
|
+
}];
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
function aspectRef(value, owner, ctx) {
|
|
87
|
+
if (typeof value === "string")
|
|
88
|
+
return undefined;
|
|
89
|
+
if (resourceRefLabel(value, owner.type) === owner.label)
|
|
90
|
+
return { kind: owner.scope, key: owner.ownerTfLabel, name: owner.ownerTfLabel };
|
|
91
|
+
for (const [type, kind] of [["elementum_app", "app"], ["elementum_element", "element"]]) {
|
|
92
|
+
const resourceLabel = resourceRefLabel(value, type);
|
|
93
|
+
if (resourceLabel !== undefined)
|
|
94
|
+
return { kind, key: tfLabelToTsLabel(resourceLabel), name: tfLabelToTsLabel(resourceLabel) };
|
|
95
|
+
const dataLabel = dataRefLabel(value, type);
|
|
96
|
+
if (dataLabel !== undefined)
|
|
97
|
+
return { kind, key: tfLabelToTsLabel(dataLabel), name: ctx.dataName(type, dataLabel) ?? tfLabelToTsLabel(dataLabel) };
|
|
98
|
+
}
|
|
99
|
+
return undefined;
|
|
100
|
+
}
|
|
101
|
+
function decodeJson(value) {
|
|
102
|
+
if (isTfExpr(value) && value.$expr === "jsonencode")
|
|
103
|
+
return value.value;
|
|
104
|
+
if (typeof value === "string") {
|
|
105
|
+
try {
|
|
106
|
+
return JSON.parse(value);
|
|
107
|
+
}
|
|
108
|
+
catch {
|
|
109
|
+
return value;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return value;
|
|
113
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { NO_CANVAS, NO_CATALOG, NO_LIFECYCLE } from "../../graph/types.js";
|
|
2
|
+
export const DASHBOARD_RESOURCE_TYPE = "elementum_dashboard";
|
|
3
|
+
export const dashboardModule = {
|
|
4
|
+
kind: "dashboard",
|
|
5
|
+
stream: { role: "streamMember" },
|
|
6
|
+
authoring: { unit: "inline", bag: "dashboards" },
|
|
7
|
+
parents: [
|
|
8
|
+
{ parent: "app", child: "dashboard" },
|
|
9
|
+
{ parent: "element", child: "dashboard" },
|
|
10
|
+
],
|
|
11
|
+
resource: { shape: "single", resourceType: DASHBOARD_RESOURCE_TYPE, adoptable: true },
|
|
12
|
+
data: { participates: true, resourceType: DASHBOARD_RESOURCE_TYPE, lookupAttr: "name", referencedByBuild: false },
|
|
13
|
+
lifecycle: NO_LIFECYCLE,
|
|
14
|
+
canvas: NO_CANVAS,
|
|
15
|
+
catalog: NO_CATALOG,
|
|
16
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { type ChildResourceScope, type TfBlock, type TfValue } from "../../engine/tf/index.js";
|
|
2
|
+
import { type OrgRefLookup, type WorkspaceAspect } from "../../engine/build/context.js";
|
|
3
|
+
import type { Filter } from "../shared/filters/types.js";
|
|
4
|
+
export interface AppDashboardWire {
|
|
5
|
+
readonly name?: string;
|
|
6
|
+
readonly favorite?: boolean;
|
|
7
|
+
readonly tags?: readonly string[];
|
|
8
|
+
readonly widgets?: Readonly<Record<string, DashboardWidgetWire>>;
|
|
9
|
+
}
|
|
10
|
+
interface RefWire {
|
|
11
|
+
readonly __kind?: string;
|
|
12
|
+
readonly refName?: string;
|
|
13
|
+
readonly name?: string;
|
|
14
|
+
readonly parent?: string;
|
|
15
|
+
readonly namespace?: string;
|
|
16
|
+
}
|
|
17
|
+
interface DashboardWidgetWireBase {
|
|
18
|
+
readonly name: string;
|
|
19
|
+
readonly size?: string;
|
|
20
|
+
readonly color?: string;
|
|
21
|
+
readonly icon?: string;
|
|
22
|
+
}
|
|
23
|
+
type DashboardWidgetWire = (DashboardWidgetWireBase & {
|
|
24
|
+
readonly type: "records";
|
|
25
|
+
readonly target?: RefWire | string;
|
|
26
|
+
readonly filter?: Filter;
|
|
27
|
+
}) | (DashboardWidgetWireBase & {
|
|
28
|
+
readonly type: "chart";
|
|
29
|
+
readonly chart?: RefWire | string;
|
|
30
|
+
});
|
|
31
|
+
export interface DashboardToTfOptions {
|
|
32
|
+
readonly ownerTfLabel: string;
|
|
33
|
+
readonly scope: ChildResourceScope;
|
|
34
|
+
readonly ownerType: "APP_ASPECT" | "ELEMENT_ASPECT";
|
|
35
|
+
readonly ownerId: TfValue;
|
|
36
|
+
readonly ownerRefName?: string;
|
|
37
|
+
readonly ownerResourceType?: "elementum_app" | "elementum_element";
|
|
38
|
+
readonly orgRefs?: OrgRefLookup;
|
|
39
|
+
readonly workspaceAspects?: ReadonlyMap<string, WorkspaceAspect>;
|
|
40
|
+
readonly diagnostics: string[];
|
|
41
|
+
}
|
|
42
|
+
export declare function dashboardsToTf(dashboards: Readonly<Record<string, AppDashboardWire>> | undefined, opts: DashboardToTfOptions): TfBlock[];
|
|
43
|
+
export {};
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { expr, isCanonicalTsLabel, scopedResourceLabel, tsLabelToTfLabel, } from "../../engine/tf/index.js";
|
|
2
|
+
import { workspaceAspectKey } from "../../engine/build/context.js";
|
|
3
|
+
import { filterToTf } from "../access-policy/to-tf.js";
|
|
4
|
+
import { filterTfToWire } from "../shared/filters/tf-codec.js";
|
|
5
|
+
import { DASHBOARD_WIDGET_RESOURCE_TYPE } from "../dashboard-widget/module.js";
|
|
6
|
+
import { resolveForeignRef } from "../shared/foreign-ref.js";
|
|
7
|
+
import { DASHBOARD_RESOURCE_TYPE } from "./module.js";
|
|
8
|
+
import { CHART_RESOURCE_TYPE } from "../chart/types.js";
|
|
9
|
+
export function dashboardsToTf(dashboards, opts) {
|
|
10
|
+
const blocks = [];
|
|
11
|
+
for (const [key, dashboard] of Object.entries(dashboards ?? {})) {
|
|
12
|
+
if (!isCanonicalTsLabel(key)) {
|
|
13
|
+
opts.diagnostics.push(`dashboards key "${key}" is not a canonical tsLabel (see src/engine/tf/labels.ts) — rename the key`);
|
|
14
|
+
continue;
|
|
15
|
+
}
|
|
16
|
+
const attrs = {
|
|
17
|
+
name: dashboard.name ?? "",
|
|
18
|
+
owner_id: opts.ownerId,
|
|
19
|
+
owner_type: opts.ownerType,
|
|
20
|
+
favorite: dashboard.favorite ?? false,
|
|
21
|
+
};
|
|
22
|
+
if (dashboard.tags !== undefined)
|
|
23
|
+
attrs["tags"] = [...dashboard.tags];
|
|
24
|
+
const dashboardLabel = scopedResourceLabel(opts.ownerTfLabel, tsLabelToTfLabel(key), opts.scope);
|
|
25
|
+
blocks.push({
|
|
26
|
+
kind: "resource",
|
|
27
|
+
type: DASHBOARD_RESOURCE_TYPE,
|
|
28
|
+
label: dashboardLabel,
|
|
29
|
+
attrs,
|
|
30
|
+
});
|
|
31
|
+
for (const [widgetKey, widget] of Object.entries(dashboard.widgets ?? {})) {
|
|
32
|
+
const where = `dashboards.${key}.widgets.${widgetKey}`;
|
|
33
|
+
if (!isCanonicalTsLabel(widgetKey)) {
|
|
34
|
+
opts.diagnostics.push(`${where}: key is not a canonical tsLabel; dropped`);
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
const widgetAttrs = {
|
|
38
|
+
owner_id: opts.ownerId,
|
|
39
|
+
dashboard_id: expr.resourceAttr(DASHBOARD_RESOURCE_TYPE, dashboardLabel, ["id"]),
|
|
40
|
+
name: widget.name,
|
|
41
|
+
size: widget.size ?? "MEDIUM",
|
|
42
|
+
};
|
|
43
|
+
if (widget.color !== undefined)
|
|
44
|
+
widgetAttrs["color"] = widget.color;
|
|
45
|
+
if (widget.icon !== undefined)
|
|
46
|
+
widgetAttrs["icon"] = widget.icon;
|
|
47
|
+
if (widget.type === "records") {
|
|
48
|
+
const aspectId = resolveAspect(widget.target, `${where}.target`, opts);
|
|
49
|
+
if (aspectId === undefined)
|
|
50
|
+
continue;
|
|
51
|
+
const body = { aspect_id: aspectId };
|
|
52
|
+
if (widget.filter !== undefined) {
|
|
53
|
+
const hclFilter = filterToTf(widget.filter, `${where}.filter`, {
|
|
54
|
+
ownerTfLabel: opts.ownerTfLabel,
|
|
55
|
+
scope: opts.scope,
|
|
56
|
+
objectId: opts.ownerId,
|
|
57
|
+
diagnostics: opts.diagnostics,
|
|
58
|
+
orgRefs: opts.orgRefs,
|
|
59
|
+
});
|
|
60
|
+
body["filter"] = expr.jsonencode(filterTfToWire(hclFilter));
|
|
61
|
+
}
|
|
62
|
+
widgetAttrs["aspect_widget"] = body;
|
|
63
|
+
}
|
|
64
|
+
else if (widget.type === "chart") {
|
|
65
|
+
const chart = resolveChart(widget.chart, `${where}.chart`, opts);
|
|
66
|
+
if (chart === undefined)
|
|
67
|
+
continue;
|
|
68
|
+
widgetAttrs["chart_widget"] = { chart_id: chart };
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
opts.diagnostics.push(`${where}: unsupported widget type; dropped`);
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
blocks.push({ kind: "resource", type: DASHBOARD_WIDGET_RESOURCE_TYPE, label: scopedResourceLabel(opts.ownerTfLabel, tsLabelToTfLabel(`${key}_${widgetKey}`), opts.scope), attrs: widgetAttrs });
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return blocks;
|
|
78
|
+
}
|
|
79
|
+
function resolveChart(value, where, opts) {
|
|
80
|
+
if (typeof value === "string") {
|
|
81
|
+
opts.diagnostics.push(`${where}: raw chart ids are not supported in public authoring; dropped`);
|
|
82
|
+
return undefined;
|
|
83
|
+
}
|
|
84
|
+
const refName = value?.refName ?? "";
|
|
85
|
+
if (refName === "") {
|
|
86
|
+
opts.diagnostics.push(`${where}: chart has no refName; dropped`);
|
|
87
|
+
return undefined;
|
|
88
|
+
}
|
|
89
|
+
if (value?.__kind !== "chart") {
|
|
90
|
+
opts.diagnostics.push(`${where}: expected a chart ref; dropped`);
|
|
91
|
+
return undefined;
|
|
92
|
+
}
|
|
93
|
+
if (value.parent === undefined || value.parent === "") {
|
|
94
|
+
opts.diagnostics.push(`${where}: chart ref has no app owner; dropped`);
|
|
95
|
+
return undefined;
|
|
96
|
+
}
|
|
97
|
+
if (value.parent !== opts.ownerRefName) {
|
|
98
|
+
opts.diagnostics.push(`${where}: chart belongs to ${JSON.stringify(value.parent)}, not dashboard owner ${JSON.stringify(opts.ownerRefName)}; dropped`);
|
|
99
|
+
return undefined;
|
|
100
|
+
}
|
|
101
|
+
return expr.resourceAttr(CHART_RESOURCE_TYPE, scopedResourceLabel(opts.ownerTfLabel, tsLabelToTfLabel(refName), opts.scope), ["id"]);
|
|
102
|
+
}
|
|
103
|
+
function resolveAspect(value, where, opts) {
|
|
104
|
+
if (typeof value === "string") {
|
|
105
|
+
opts.diagnostics.push(`${where}: raw aspect ids are not supported in public authoring; dropped`);
|
|
106
|
+
return undefined;
|
|
107
|
+
}
|
|
108
|
+
const kind = value?.__kind === "element" ? "element" : "app";
|
|
109
|
+
const refName = value?.refName ?? "";
|
|
110
|
+
if (kind === opts.scope && refName === (opts.ownerRefName ?? opts.ownerTfLabel))
|
|
111
|
+
return opts.ownerId;
|
|
112
|
+
const sibling = opts.workspaceAspects?.get(workspaceAspectKey(kind, refName));
|
|
113
|
+
if (sibling !== undefined)
|
|
114
|
+
return expr.resourceAttr(kind === "app" ? "elementum_app" : "elementum_element", sibling.tfLabel, ["id"]);
|
|
115
|
+
const name = value?.name ?? refName;
|
|
116
|
+
if (name === "" || opts.orgRefs === undefined) {
|
|
117
|
+
opts.diagnostics.push(`${where}: target has no resolvable name; dropped`);
|
|
118
|
+
return undefined;
|
|
119
|
+
}
|
|
120
|
+
return resolveForeignRef(kind, { name, namespace: value?.namespace }, opts.orgRefs, opts.diagnostics, where).value;
|
|
121
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { NO_CANVAS, NO_CATALOG, NO_DATA, NO_LIFECYCLE } from "../../graph/types.js";
|
|
2
|
+
export const DASHBOARD_WIDGET_RESOURCE_TYPE = "elementum_dashboard_widget";
|
|
3
|
+
export const dashboardWidgetModule = {
|
|
4
|
+
kind: "dashboard-widget",
|
|
5
|
+
stream: { role: "streamMember" },
|
|
6
|
+
authoring: { unit: "inline", bag: "widgets" },
|
|
7
|
+
parents: [{ parent: "dashboard", child: "dashboard-widget" }],
|
|
8
|
+
resource: { shape: "single", resourceType: DASHBOARD_WIDGET_RESOURCE_TYPE, adoptable: true },
|
|
9
|
+
data: NO_DATA, lifecycle: NO_LIFECYCLE, canvas: NO_CANVAS, catalog: NO_CATALOG,
|
|
10
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** Provider data sources that are reference surfaces rather than authored resources. */
|
|
2
|
+
import { NO_CANVAS, NO_CATALOG, NO_LIFECYCLE } from "../../graph/types.js";
|
|
3
|
+
function lookup(kind, resourceType, lookupAttr, referencedByBuild = false) {
|
|
4
|
+
return {
|
|
5
|
+
kind,
|
|
6
|
+
stream: { role: "streamReported" },
|
|
7
|
+
authoring: { unit: "none" },
|
|
8
|
+
parents: [],
|
|
9
|
+
resource: { shape: "none" },
|
|
10
|
+
data: { participates: true, resourceType, lookupAttr, referencedByBuild },
|
|
11
|
+
lifecycle: NO_LIFECYCLE,
|
|
12
|
+
canvas: NO_CANVAS,
|
|
13
|
+
catalog: NO_CATALOG,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export const dataLookupModules = [
|
|
17
|
+
lookup("automation-value-references", "elementum_automation_value_references", "automation_id"),
|
|
18
|
+
// Empty lookupAttr means the singleton has no selector; pull keys it by block label.
|
|
19
|
+
lookup("organization", "elementum_organization", ""),
|
|
20
|
+
lookup("permission-template", "elementum_permission_template", "template"),
|
|
21
|
+
lookup("stored-function", "elementum_stored_function", "name"),
|
|
22
|
+
];
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Filter } from "../shared/filters/types.js";
|
|
2
|
+
export type DatamineTimeUnit = "DAY" | "HOUR" | "MINUTE" | "MONTH" | "WEEK";
|
|
3
|
+
export type DatamineSchedule = {
|
|
4
|
+
readonly kind: "fixed";
|
|
5
|
+
readonly timeUnit: DatamineTimeUnit;
|
|
6
|
+
readonly value: number;
|
|
7
|
+
readonly description?: string;
|
|
8
|
+
} | {
|
|
9
|
+
readonly kind: "cron";
|
|
10
|
+
readonly cronExpression: string;
|
|
11
|
+
readonly description?: string;
|
|
12
|
+
};
|
|
13
|
+
/** A rule-based datamine owned by its containing table. Column keys are
|
|
14
|
+
* resolved to that table's field ids at build time. */
|
|
15
|
+
export interface TableDatamine<ColumnKey extends string = string> {
|
|
16
|
+
readonly name: string;
|
|
17
|
+
readonly primaryColumns: readonly [ColumnKey, ...ColumnKey[]];
|
|
18
|
+
readonly description?: string;
|
|
19
|
+
readonly filter?: Filter;
|
|
20
|
+
readonly schedule?: DatamineSchedule;
|
|
21
|
+
readonly limit?: number;
|
|
22
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type FromTfContext } from "../../engine/pull/context.js";
|
|
2
|
+
import { type TfBlock } from "../../engine/tf/index.js";
|
|
3
|
+
import type { Filter } from "../shared/filters/types.js";
|
|
4
|
+
import type { NormalizedTableFilterField } from "../table/deserializer/normalize.js";
|
|
5
|
+
import type { DatamineSchedule } from "./build.js";
|
|
6
|
+
export interface NormalizedTableDatamine {
|
|
7
|
+
readonly key: string;
|
|
8
|
+
readonly name: string;
|
|
9
|
+
readonly primaryColumns: readonly string[];
|
|
10
|
+
readonly description?: string;
|
|
11
|
+
readonly filter?: Filter<NormalizedTableFilterField, never>;
|
|
12
|
+
readonly schedule?: DatamineSchedule;
|
|
13
|
+
readonly limit?: number;
|
|
14
|
+
}
|
|
15
|
+
/** Decode datamines exported with a table stream. Primary ids must be
|
|
16
|
+
* resource references to that table's name-keyed `field_ids` map. */
|
|
17
|
+
export declare function tableDataminesFromTf(blocks: readonly TfBlock[], tableTfLabel: string, columnKeyByName: ReadonlyMap<string, string>, ctx: FromTfContext, columnKeyById?: ReadonlyMap<string, string>): NormalizedTableDatamine[];
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { optionalString, plainObject, resourceRefLabel } from "../../engine/pull/context.js";
|
|
2
|
+
import { reportUnknownAttrs } from "../../engine/pull/attrs.js";
|
|
3
|
+
import { EntityTfError } from "../../engine/entity.js";
|
|
4
|
+
import { isTfExpr, tfLabelToTsLabel } from "../../engine/tf/index.js";
|
|
5
|
+
import { filterFromTf } from "../shared/filters/tf-codec.js";
|
|
6
|
+
const KNOWN_DATAMINE_ATTRS = new Set([
|
|
7
|
+
"id",
|
|
8
|
+
"table_id",
|
|
9
|
+
"name",
|
|
10
|
+
"description",
|
|
11
|
+
"filter",
|
|
12
|
+
"primary_column_names",
|
|
13
|
+
"primary_column_ids",
|
|
14
|
+
"schedule_fixed",
|
|
15
|
+
"schedule_cron",
|
|
16
|
+
"limit",
|
|
17
|
+
"active",
|
|
18
|
+
]);
|
|
19
|
+
function isTimeUnit(value) {
|
|
20
|
+
return typeof value === "string" && ["DAY", "HOUR", "MINUTE", "MONTH", "WEEK"].includes(value);
|
|
21
|
+
}
|
|
22
|
+
/** Decode datamines exported with a table stream. Primary ids must be
|
|
23
|
+
* resource references to that table's name-keyed `field_ids` map. */
|
|
24
|
+
export function tableDataminesFromTf(blocks, tableTfLabel, columnKeyByName, ctx, columnKeyById = new Map()) {
|
|
25
|
+
return blocks.flatMap((block) => {
|
|
26
|
+
const label = block.label ?? "";
|
|
27
|
+
const where = `elementum_datamine.${label || "?"}`;
|
|
28
|
+
if (label === "") {
|
|
29
|
+
ctx.diagnostics.push(`${where}: missing label; skipped`);
|
|
30
|
+
return [];
|
|
31
|
+
}
|
|
32
|
+
reportUnknownAttrs(block.attrs, KNOWN_DATAMINE_ATTRS, where, "tableDataminesFromTf", ctx);
|
|
33
|
+
if (resourceRefLabel(block.attrs["table_id"], "elementum_table") !== tableTfLabel) {
|
|
34
|
+
ctx.diagnostics.push(`${where}.table_id does not reference elementum_table.${tableTfLabel}; skipped`);
|
|
35
|
+
return [];
|
|
36
|
+
}
|
|
37
|
+
const rawNames = block.attrs["primary_column_names"];
|
|
38
|
+
const rawIDs = block.attrs["primary_column_ids"];
|
|
39
|
+
if (!Array.isArray(rawNames) && !Array.isArray(rawIDs)) {
|
|
40
|
+
ctx.diagnostics.push(`${where}: expected primary_column_names or primary_column_ids; skipped`);
|
|
41
|
+
return [];
|
|
42
|
+
}
|
|
43
|
+
const rawColumns = Array.isArray(rawNames) ? rawNames : rawIDs;
|
|
44
|
+
const lookup = Array.isArray(rawNames) ? columnKeyByName : columnKeyById;
|
|
45
|
+
const primaryColumns = rawColumns.flatMap((value) => {
|
|
46
|
+
const key = typeof value === "string" ? lookup.get(value) : undefined;
|
|
47
|
+
return key === undefined ? [] : [key];
|
|
48
|
+
});
|
|
49
|
+
if (primaryColumns.length !== rawColumns.length) {
|
|
50
|
+
ctx.diagnostics.push(`${where}.${Array.isArray(rawNames) ? "primary_column_names" : "primary_column_ids"}: one or more columns could not be resolved to this table; skipped`);
|
|
51
|
+
return [];
|
|
52
|
+
}
|
|
53
|
+
const fixed = plainObject(block.attrs["schedule_fixed"]);
|
|
54
|
+
const cron = plainObject(block.attrs["schedule_cron"]);
|
|
55
|
+
let schedule;
|
|
56
|
+
if (fixed !== undefined && isTimeUnit(fixed["time_unit"]) && typeof fixed["value"] === "number") {
|
|
57
|
+
schedule = { kind: "fixed", timeUnit: fixed["time_unit"], value: fixed["value"], ...(typeof fixed["description"] === "string" && { description: fixed["description"] }) };
|
|
58
|
+
}
|
|
59
|
+
else if (cron !== undefined && typeof cron["cron_expression"] === "string") {
|
|
60
|
+
schedule = { kind: "cron", cronExpression: cron["cron_expression"], ...(typeof cron["description"] === "string" && { description: cron["description"] }) };
|
|
61
|
+
}
|
|
62
|
+
const prefix = `${tableTfLabel}_`;
|
|
63
|
+
const description = optionalString(block.attrs, "description", where, ctx);
|
|
64
|
+
return [{
|
|
65
|
+
key: tfLabelToTsLabel(label.startsWith(prefix) ? label.slice(prefix.length) : label),
|
|
66
|
+
name: optionalString(block.attrs, "name", where, ctx) ?? "",
|
|
67
|
+
primaryColumns,
|
|
68
|
+
...(description !== undefined && { description }),
|
|
69
|
+
...(block.attrs["filter"] !== undefined && {
|
|
70
|
+
filter: filterFromTf(block.attrs["filter"], {
|
|
71
|
+
field: (value) => ({
|
|
72
|
+
kind: "tableColumn",
|
|
73
|
+
tableRefName: tfLabelToTsLabel(tableTfLabel),
|
|
74
|
+
columnRefName: tableColumnKey(value, tableTfLabel, columnKeyByName, columnKeyById, where),
|
|
75
|
+
}),
|
|
76
|
+
reference: () => { throw new EntityTfError(`${where}.filter: datamine filters do not support reference values`); },
|
|
77
|
+
}),
|
|
78
|
+
}),
|
|
79
|
+
...(schedule !== undefined && { schedule }),
|
|
80
|
+
...(typeof block.attrs["limit"] === "number" && { limit: block.attrs["limit"] }),
|
|
81
|
+
}];
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
function tableColumnKey(value, tableTfLabel, columnKeyByName, columnKeyById, where) {
|
|
85
|
+
if (typeof value === "string") {
|
|
86
|
+
return columnKeyById.get(value) ?? columnKeyByName.get(value) ?? value;
|
|
87
|
+
}
|
|
88
|
+
if (isTfExpr(value) && value.$expr === "resource-attr" && value.type === "elementum_table" && value.label === tableTfLabel && value.path[0] === "field_ids") {
|
|
89
|
+
const index = value.path[1];
|
|
90
|
+
const name = typeof index === "object" && index !== null && "index" in index && typeof index.index === "string"
|
|
91
|
+
? index.index
|
|
92
|
+
: typeof index === "string" ? index : undefined;
|
|
93
|
+
const key = name === undefined ? undefined : columnKeyByName.get(name) ?? tfLabelToTsLabel(name);
|
|
94
|
+
if (key !== undefined)
|
|
95
|
+
return key;
|
|
96
|
+
}
|
|
97
|
+
throw new EntityTfError(`${where}.filter: field does not resolve to a column on this table`);
|
|
98
|
+
}
|