@elementumai/edk 0.9.2 → 0.9.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +34 -26
- package/dist-sdk/elementum-entity-client/clients/automation/models/automation.d.ts +1 -1
- package/dist-sdk/elementum-entity-client/clients/skills/models/skill.d.ts +1 -1
- package/dist-sdk/elementum-entity-client/clients/skills/models/skill.js +1 -1
- package/dist-sdk/pull/util.d.ts +1 -1
- package/dist-sdk/pull/util.js +3 -3
- package/dist-sdk/src/catalog/factories.d.ts +49 -10
- package/dist-sdk/src/catalog/factories.js +94 -13
- package/dist-sdk/src/catalog/from-authoring.d.ts +5 -5
- package/dist-sdk/src/catalog/from-authoring.js +7 -7
- package/dist-sdk/src/catalog/index.d.ts +2 -2
- package/dist-sdk/src/catalog/index.js +1 -1
- package/dist-sdk/src/catalog/org.js +62 -4
- package/dist-sdk/src/catalog/render-helpers.d.ts +1 -1
- package/dist-sdk/src/catalog/render-helpers.js +1 -1
- package/dist-sdk/src/catalog/render.d.ts +1 -0
- package/dist-sdk/src/catalog/render.js +2 -2
- package/dist-sdk/src/catalog/token.js +11 -4
- package/dist-sdk/src/catalog/types.d.ts +33 -4
- package/dist-sdk/src/catalog/types.js +5 -0
- package/dist-sdk/src/core/index.d.ts +10 -10
- package/dist-sdk/src/core/index.js +9 -9
- package/dist-sdk/src/core/render-tree.d.ts +1 -1
- package/dist-sdk/src/core/render-tree.js +1 -2
- package/dist-sdk/src/core/types/ai-provider.d.ts +1 -1
- package/dist-sdk/src/core/types/ai-provider.js +1 -1
- package/dist-sdk/src/core/types/app.d.ts +66 -30
- package/dist-sdk/src/core/types/app.js +2 -2
- package/dist-sdk/src/core/types/aspect-category.d.ts +4 -4
- package/dist-sdk/src/core/types/aspect-category.js +4 -4
- package/dist-sdk/src/core/types/cloud-link.d.ts +3 -3
- package/dist-sdk/src/core/types/cloud-link.js +3 -3
- package/dist-sdk/src/core/types/display-block.d.ts +2 -2
- package/dist-sdk/src/core/types/display-block.js +2 -2
- package/dist-sdk/src/core/types/group.d.ts +1 -1
- package/dist-sdk/src/core/types/group.js +1 -1
- package/dist-sdk/src/core/types/user.d.ts +1 -1
- package/dist-sdk/src/core/types/user.js +1 -1
- package/dist-sdk/src/core/wire/ref-serializer.js +3 -3
- package/dist-sdk/src/engine/build/context.d.ts +20 -13
- package/dist-sdk/src/engine/entity.d.ts +1 -1
- package/dist-sdk/src/engine/pull/context.d.ts +34 -0
- package/dist-sdk/src/engine/pull/context.js +14 -0
- package/dist-sdk/src/engine/pull/org.d.ts +9 -0
- package/dist-sdk/src/engine/pull/org.js +33 -0
- package/dist-sdk/src/engine/pull/ref-only.d.ts +37 -0
- package/dist-sdk/src/engine/pull/ref-only.js +204 -0
- package/dist-sdk/src/engine/tf/expr.d.ts +6 -2
- package/dist-sdk/src/engine/tf/expr.js +18 -13
- package/dist-sdk/src/engine/tf/index.d.ts +1 -1
- package/dist-sdk/src/engine/tf/index.js +1 -1
- package/dist-sdk/src/engine/tf/model.d.ts +8 -1
- package/dist-sdk/src/engine/tf/model.js +4 -0
- package/dist-sdk/src/engine/tf/parse.js +13 -2
- package/dist-sdk/src/engine/tf/render.js +4 -0
- package/dist-sdk/src/entities/access-policy/build.d.ts +4 -5
- package/dist-sdk/src/entities/access-policy/build.js +1 -1
- package/dist-sdk/src/entities/access-policy/from-tf.d.ts +4 -4
- package/dist-sdk/src/entities/access-policy/from-tf.js +12 -13
- package/dist-sdk/src/entities/access-policy/principal.d.ts +14 -4
- package/dist-sdk/src/entities/access-policy/to-tf.d.ts +14 -2
- package/dist-sdk/src/entities/access-policy/to-tf.js +36 -6
- package/dist-sdk/src/entities/agent/build.d.ts +3 -3
- package/dist-sdk/src/entities/agent/build.js +5 -5
- package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.d.ts +6 -1
- package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +68 -18
- package/dist-sdk/src/entities/agent/from-tf.d.ts +3 -1
- package/dist-sdk/src/entities/agent/from-tf.js +12 -4
- package/dist-sdk/src/entities/agent/index.d.ts +2 -2
- package/dist-sdk/src/entities/agent/index.js +1 -1
- package/dist-sdk/src/entities/agent/module.js +2 -0
- package/dist-sdk/src/entities/agent/to-tf.d.ts +5 -2
- package/dist-sdk/src/entities/agent/to-tf.js +56 -8
- package/dist-sdk/src/entities/agent/tools.d.ts +38 -23
- package/dist-sdk/src/entities/agent/tools.js +21 -7
- package/dist-sdk/src/entities/agent-evaluation/build.d.ts +19 -0
- package/dist-sdk/src/entities/agent-evaluation/build.js +41 -0
- package/dist-sdk/src/entities/agent-evaluation/deserializer/print-agent-evaluation.d.ts +4 -0
- package/dist-sdk/src/entities/agent-evaluation/deserializer/print-agent-evaluation.js +30 -0
- package/dist-sdk/src/entities/agent-evaluation/from-tf.d.ts +12 -0
- package/dist-sdk/src/entities/agent-evaluation/from-tf.js +46 -0
- package/dist-sdk/src/entities/agent-evaluation/index.d.ts +1 -0
- package/dist-sdk/src/entities/agent-evaluation/index.js +1 -0
- package/dist-sdk/src/entities/agent-evaluation/module.d.ts +3 -0
- package/dist-sdk/src/entities/agent-evaluation/module.js +58 -0
- package/dist-sdk/src/entities/agent-evaluation/to-tf.d.ts +12 -0
- package/dist-sdk/src/entities/agent-evaluation/to-tf.js +35 -0
- package/dist-sdk/src/entities/agent-tool/from-tf.d.ts +8 -7
- package/dist-sdk/src/entities/agent-tool/from-tf.js +48 -6
- package/dist-sdk/src/entities/agent-tool/to-tf.d.ts +10 -2
- package/dist-sdk/src/entities/agent-tool/to-tf.js +76 -28
- package/dist-sdk/src/entities/agent-tool/types.d.ts +0 -1
- package/dist-sdk/src/entities/agent-tool/types.js +10 -37
- package/dist-sdk/src/entities/app/build.d.ts +97 -42
- package/dist-sdk/src/entities/app/build.js +25 -14
- package/dist-sdk/src/entities/app/deserializer/normalize.d.ts +32 -24
- package/dist-sdk/src/entities/app/deserializer/pulled-expression.d.ts +1 -1
- package/dist-sdk/src/entities/app/deserializer/pulled-expression.js +2 -0
- package/dist-sdk/src/entities/app/index.d.ts +11 -8
- package/dist-sdk/src/entities/app/index.js +10 -7
- package/dist-sdk/src/entities/app/module.js +2 -2
- package/dist-sdk/src/entities/app/to-tf.d.ts +1 -1
- package/dist-sdk/src/entities/app/to-tf.js +22 -6
- package/dist-sdk/src/entities/approval-chain/build.d.ts +1 -1
- package/dist-sdk/src/entities/approval-chain/build.js +5 -5
- package/dist-sdk/src/entities/approval-chain/index.d.ts +1 -1
- package/dist-sdk/src/entities/approval-chain/index.js +1 -1
- package/dist-sdk/src/entities/approval-chain/printer.js +2 -2
- package/dist-sdk/src/entities/automation/build.d.ts +172 -94
- package/dist-sdk/src/entities/automation/build.js +159 -68
- package/dist-sdk/src/entities/automation/calculation-expression.d.ts +191 -0
- package/dist-sdk/src/entities/automation/calculation-expression.js +57 -0
- package/dist-sdk/src/entities/automation/deserializer/ast.d.ts +11 -4
- package/dist-sdk/src/entities/automation/deserializer/print-automation.d.ts +18 -14
- package/dist-sdk/src/entities/automation/deserializer/print-automation.js +164 -198
- package/dist-sdk/src/entities/automation/from-tf.d.ts +26 -2
- package/dist-sdk/src/entities/automation/from-tf.js +510 -80
- package/dist-sdk/src/entities/automation/index.d.ts +9 -12
- package/dist-sdk/src/entities/automation/index.js +11 -13
- package/dist-sdk/src/entities/automation/module.js +74 -6
- package/dist-sdk/src/entities/automation/operators.d.ts +32 -48
- package/dist-sdk/src/entities/automation/operators.js +10 -37
- package/dist-sdk/src/entities/automation/output-key-wire-name.d.ts +1 -1
- package/dist-sdk/src/entities/automation/output-key-wire-name.js +1 -1
- package/dist-sdk/src/entities/automation/script-code.js +13 -22
- package/dist-sdk/src/entities/automation/serialize.js +1 -1
- package/dist-sdk/src/entities/automation/tasks.d.ts +153 -89
- package/dist-sdk/src/entities/automation/tasks.js +64 -11
- package/dist-sdk/src/entities/automation/to-tf.d.ts +10 -1
- package/dist-sdk/src/entities/automation/to-tf.js +342 -71
- package/dist-sdk/src/entities/automation/triggers.d.ts +17 -10
- package/dist-sdk/src/entities/automation/triggers.js +7 -1
- package/dist-sdk/src/entities/automation/types.d.ts +3 -2
- package/dist-sdk/src/entities/automation/types.js +3 -2
- package/dist-sdk/src/entities/chart/build.d.ts +95 -0
- package/dist-sdk/src/entities/chart/build.js +42 -0
- package/dist-sdk/src/entities/chart/from-tf.d.ts +55 -0
- package/dist-sdk/src/entities/chart/from-tf.js +269 -0
- package/dist-sdk/src/entities/chart/index.d.ts +4 -0
- package/dist-sdk/src/entities/chart/index.js +3 -0
- package/dist-sdk/src/entities/chart/module.d.ts +3 -0
- package/dist-sdk/src/entities/chart/module.js +61 -0
- package/dist-sdk/src/entities/chart/printer.d.ts +5 -0
- package/dist-sdk/src/entities/chart/printer.js +104 -0
- package/dist-sdk/src/entities/chart/to-tf.d.ts +15 -0
- package/dist-sdk/src/entities/chart/to-tf.js +150 -0
- package/dist-sdk/src/entities/chart/types.d.ts +53 -0
- package/dist-sdk/src/entities/chart/types.js +22 -0
- package/dist-sdk/src/entities/dashboard/build.d.ts +34 -7
- package/dist-sdk/src/entities/dashboard/build.js +16 -1
- package/dist-sdk/src/entities/dashboard/from-tf.js +22 -4
- package/dist-sdk/src/entities/dashboard/to-tf.d.ts +16 -3
- package/dist-sdk/src/entities/dashboard/to-tf.js +37 -10
- package/dist-sdk/src/entities/datamine/module.js +1 -1
- package/dist-sdk/src/entities/dynamic-layout/build.d.ts +4 -3
- package/dist-sdk/src/entities/dynamic-layout/build.js +1 -1
- package/dist-sdk/src/entities/dynamic-layout/dialect.d.ts +2 -0
- package/dist-sdk/src/entities/dynamic-layout/dialect.js +43 -5
- package/dist-sdk/src/entities/dynamic-layout/from-tf.js +12 -6
- package/dist-sdk/src/entities/dynamic-layout/to-tf.js +10 -10
- package/dist-sdk/src/entities/element/build.d.ts +25 -32
- package/dist-sdk/src/entities/element/build.js +15 -32
- package/dist-sdk/src/entities/element/index.d.ts +7 -5
- package/dist-sdk/src/entities/element/index.js +7 -4
- package/dist-sdk/src/entities/element/module.js +7 -3
- package/dist-sdk/src/entities/element/to-tf.d.ts +2 -1
- package/dist-sdk/src/entities/element/to-tf.js +7 -3
- package/dist-sdk/src/entities/field/build.d.ts +51 -24
- package/dist-sdk/src/entities/field/build.js +31 -6
- package/dist-sdk/src/entities/field/calc/aggregate.d.ts +52 -21
- package/dist-sdk/src/entities/field/calc/aggregate.js +59 -29
- package/dist-sdk/src/entities/field/calc/date.d.ts +78 -29
- package/dist-sdk/src/entities/field/calc/date.js +120 -29
- package/dist-sdk/src/entities/field/calc/index.d.ts +80 -85
- package/dist-sdk/src/entities/field/calc/index.js +82 -139
- package/dist-sdk/src/entities/field/calc/numeric.d.ts +8 -12
- package/dist-sdk/src/entities/field/calc/numeric.js +10 -27
- package/dist-sdk/src/entities/field/calc/runtime.d.ts +19 -2
- package/dist-sdk/src/entities/field/calc/runtime.js +79 -8
- package/dist-sdk/src/entities/field/calc/text.d.ts +32 -23
- package/dist-sdk/src/entities/field/calc/text.js +43 -31
- package/dist-sdk/src/entities/field/calc/types.d.ts +36 -81
- package/dist-sdk/src/entities/field/calc/types.js +1 -22
- package/dist-sdk/src/entities/field/calc.d.ts +71 -48
- package/dist-sdk/src/entities/field/calc.js +5 -15
- package/dist-sdk/src/entities/field/calculation-types.js +10 -3
- package/dist-sdk/src/entities/field/from-tf.js +156 -10
- package/dist-sdk/src/entities/field/locals.d.ts +11 -3
- package/dist-sdk/src/entities/field/locals.js +15 -2
- package/dist-sdk/src/entities/field/module.js +23 -6
- package/dist-sdk/src/entities/field/record-shape.d.ts +24 -10
- package/dist-sdk/src/entities/field/to-tf.d.ts +40 -1
- package/dist-sdk/src/entities/field/to-tf.js +293 -35
- package/dist-sdk/src/entities/field/types.d.ts +1 -1
- package/dist-sdk/src/entities/field/types.js +7 -1
- package/dist-sdk/src/entities/file-reader/build.d.ts +5 -0
- package/dist-sdk/src/entities/file-reader/deserializer/print-file-reader.js +1 -1
- package/dist-sdk/src/entities/org/cloud-link.js +4 -5
- package/dist-sdk/src/entities/org/email-alias.d.ts +2 -0
- package/dist-sdk/src/entities/org/email-alias.js +12 -0
- package/dist-sdk/src/entities/org/index.d.ts +1 -0
- package/dist-sdk/src/entities/org/index.js +1 -0
- package/dist-sdk/src/entities/org/phone-provider.js +4 -7
- package/dist-sdk/src/entities/organization/build.d.ts +214 -2
- package/dist-sdk/src/entities/organization/build.js +145 -4
- package/dist-sdk/src/entities/organization/index.d.ts +1 -1
- package/dist-sdk/src/entities/organization/index.js +1 -1
- package/dist-sdk/src/entities/organization/module.js +4 -1
- package/dist-sdk/src/entities/organization/to-tf.d.ts +1 -0
- package/dist-sdk/src/entities/organization/to-tf.js +118 -1
- package/dist-sdk/src/entities/phone-service/build.d.ts +1 -1
- package/dist-sdk/src/entities/phone-service/build.js +2 -2
- package/dist-sdk/src/entities/phone-service/deserializer/print-phone-service.js +5 -3
- package/dist-sdk/src/entities/phone-service/index.d.ts +1 -1
- package/dist-sdk/src/entities/phone-service/index.js +1 -1
- package/dist-sdk/src/entities/phone-service/types.js +1 -1
- package/dist-sdk/src/entities/record-create-form/to-tf.js +9 -1
- package/dist-sdk/src/entities/relationship/to-tf.d.ts +1 -0
- package/dist-sdk/src/entities/relationship/to-tf.js +5 -13
- package/dist-sdk/src/entities/search-table/build.d.ts +4 -4
- package/dist-sdk/src/entities/search-table/build.js +13 -13
- package/dist-sdk/src/entities/search-table/index.d.ts +2 -2
- package/dist-sdk/src/entities/search-table/index.js +2 -2
- package/dist-sdk/src/entities/search-table/printer.js +5 -5
- package/dist-sdk/src/entities/service-account/to-tf.d.ts +21 -0
- package/dist-sdk/src/entities/service-account/to-tf.js +32 -1
- package/dist-sdk/src/entities/shared/context.d.ts +25 -24
- package/dist-sdk/src/entities/shared/context.js +36 -35
- package/dist-sdk/src/entities/shared/filters/ast.d.ts +10 -3
- package/dist-sdk/src/entities/shared/filters/ast.js +1 -0
- package/dist-sdk/src/entities/shared/filters/index.d.ts +2 -1
- package/dist-sdk/src/entities/shared/filters/index.js +11 -4
- package/dist-sdk/src/entities/shared/foreign-ref.d.ts +14 -0
- package/dist-sdk/src/entities/shared/foreign-ref.js +12 -0
- package/dist-sdk/src/entities/shared/ref.d.ts +26 -11
- package/dist-sdk/src/entities/shared/ref.js +8 -3
- package/dist-sdk/src/entities/shared/types/common.d.ts +2 -2
- package/dist-sdk/src/entities/shared/types/field-types.d.ts +1 -1
- package/dist-sdk/src/entities/shared/types/field-types.js +1 -1
- package/dist-sdk/src/entities/skill/build.d.ts +2 -2
- package/dist-sdk/src/entities/skill/build.js +3 -3
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.d.ts +1 -1
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +26 -7
- package/dist-sdk/src/entities/skill/index.d.ts +1 -1
- package/dist-sdk/src/entities/skill/index.js +1 -1
- package/dist-sdk/src/entities/skill/module.js +2 -2
- package/dist-sdk/src/entities/skill/to-tf.d.ts +1 -1
- package/dist-sdk/src/entities/skill/to-tf.js +2 -2
- package/dist-sdk/src/entities/skill/tools.d.ts +4 -3
- package/dist-sdk/src/entities/skill/tools.js +4 -3
- package/dist-sdk/src/entities/skill-tool/from-tf.d.ts +13 -0
- package/dist-sdk/src/entities/skill-tool/from-tf.js +42 -0
- package/dist-sdk/src/entities/skill-tool/to-tf.js +6 -6
- package/dist-sdk/src/entities/table/build.d.ts +1 -1
- package/dist-sdk/src/entities/table/build.js +9 -9
- package/dist-sdk/src/entities/table/catalog-render.js +9 -1
- package/dist-sdk/src/entities/table/deserializer/normalize.js +4 -4
- package/dist-sdk/src/entities/table/fields/types.d.ts +1 -1
- package/dist-sdk/src/entities/table/fields/types.js +1 -1
- package/dist-sdk/src/entities/table/index.d.ts +2 -2
- package/dist-sdk/src/entities/table/index.js +3 -3
- package/dist-sdk/src/entities/table/module.js +1 -1
- package/dist-sdk/src/entities/table/to-tf.js +22 -30
- package/dist-sdk/src/entities/task/build.d.ts +1 -1
- package/dist-sdk/src/entities/task/build.js +5 -5
- package/dist-sdk/src/entities/task/index.d.ts +1 -1
- package/dist-sdk/src/entities/task/index.js +1 -1
- package/dist-sdk/src/entities/view/build.d.ts +46 -0
- package/dist-sdk/src/entities/view/build.js +19 -0
- package/dist-sdk/src/entities/view/from-tf.js +68 -18
- package/dist-sdk/src/entities/view/module.d.ts +6 -13
- package/dist-sdk/src/entities/view/module.js +7 -14
- package/dist-sdk/src/entities/view/sharing.d.ts +10 -0
- package/dist-sdk/src/entities/view/sharing.js +6 -0
- package/dist-sdk/src/entities/view/to-tf.d.ts +21 -19
- package/dist-sdk/src/entities/view/to-tf.js +61 -26
- package/dist-sdk/src/entities/view/types.js +3 -0
- package/dist-sdk/src/entities/visual-flow/build.d.ts +1 -1
- package/dist-sdk/src/entities/visual-flow/build.js +8 -8
- package/dist-sdk/src/entities/visual-flow/index.d.ts +1 -1
- package/dist-sdk/src/entities/visual-flow/index.js +1 -1
- package/dist-sdk/src/entities/visual-flow/module.js +1 -1
- package/dist-sdk/src/entities/visual-flow/printer.js +3 -3
- package/dist-sdk/src/entities/visual-flow/to-tf.d.ts +1 -0
- package/dist-sdk/src/entities/visual-flow/to-tf.js +3 -7
- package/dist-sdk/src/entities/widget/to-tf.d.ts +1 -0
- package/dist-sdk/src/entities/widget/to-tf.js +9 -7
- package/dist-sdk/src/graph/index.d.ts +5 -1
- package/dist-sdk/src/graph/index.js +4 -1
- package/dist-sdk/src/graph/modules.js +6 -1
- package/dist-sdk/src/graph/types.d.ts +52 -1
- package/dist-sdk/src/internal/safe-identifier.d.ts +4 -0
- package/dist-sdk/src/internal/safe-identifier.js +13 -0
- package/dist-sdk/src/internal/sdk-package.d.ts +1 -1
- package/dist-sdk/src/internal/sdk-package.js +1 -0
- package/package.json +12 -3
|
@@ -76,7 +76,13 @@ export function webHook(opts = {}) {
|
|
|
76
76
|
return chainableTrigger({
|
|
77
77
|
wire: {
|
|
78
78
|
webhook: {
|
|
79
|
-
|
|
79
|
+
// authenticated is schema-Optional but NOT Computed
|
|
80
|
+
// (webhook_trigger_resource.go) - omitting it from generated
|
|
81
|
+
// config when false reads to OpenTofu as "unset this" rather than
|
|
82
|
+
// "leave at the live false", diffing forever (edk#557, same defect
|
|
83
|
+
// class as the approval-chain approveButton fix, edk#325). Always
|
|
84
|
+
// emit it, defaulting to the platform's real false.
|
|
85
|
+
authenticated: opts.authenticated ?? false,
|
|
80
86
|
...(opts.customResponse !== undefined ? { customResponse: opts.customResponse } : {}),
|
|
81
87
|
},
|
|
82
88
|
},
|
|
@@ -12,13 +12,13 @@
|
|
|
12
12
|
* kind the printer can't reconstruct would plan as a destroy on rebuild.
|
|
13
13
|
*
|
|
14
14
|
* `typeKey` is the wire discriminant the authoring builders emit
|
|
15
|
-
* (`triggers.ts` trigger `wire` keys, `tasks.ts` `
|
|
15
|
+
* (`triggers.ts` trigger `wire` keys, `tasks.ts` `ActionDef.key`); `resourceType`
|
|
16
16
|
* is the terraform type ei's export uses. Only the implemented rows' `typeKey`
|
|
17
17
|
* is load-bearing (to-tf maps authored → resource by it); the declared rows
|
|
18
18
|
* need only an accurate `resourceType` for from-tf recognition.
|
|
19
19
|
*/
|
|
20
20
|
export interface AutomationSubType {
|
|
21
|
-
/** Wire discriminant: a trigger `wire` key or a `
|
|
21
|
+
/** Wire discriminant: a trigger `wire` key or a `ActionDef.key`. */
|
|
22
22
|
readonly typeKey: string;
|
|
23
23
|
/** Terraform resource type, e.g. "elementum_on_demand_trigger". */
|
|
24
24
|
readonly resourceType: string;
|
|
@@ -28,6 +28,7 @@ export interface AutomationSubType {
|
|
|
28
28
|
/** The automation's own resource + its versioning/publish resource. */
|
|
29
29
|
export declare const AUTOMATION_RESOURCE_TYPE = "elementum_automation";
|
|
30
30
|
export declare const WORKFLOW_PUBLISH_RESOURCE_TYPE = "elementum_workflow_publish";
|
|
31
|
+
export declare const TABLE_RECORDS_SEARCH_TASK_RESOURCE_TYPE = "elementum_table_records_search_task";
|
|
31
32
|
/** Trigger kinds. One trigger per automation. Phase 1: onDemand only. */
|
|
32
33
|
export declare const TRIGGER_SUB_TYPES: readonly AutomationSubType[];
|
|
33
34
|
/**
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* kind the printer can't reconstruct would plan as a destroy on rebuild.
|
|
13
13
|
*
|
|
14
14
|
* `typeKey` is the wire discriminant the authoring builders emit
|
|
15
|
-
* (`triggers.ts` trigger `wire` keys, `tasks.ts` `
|
|
15
|
+
* (`triggers.ts` trigger `wire` keys, `tasks.ts` `ActionDef.key`); `resourceType`
|
|
16
16
|
* is the terraform type ei's export uses. Only the implemented rows' `typeKey`
|
|
17
17
|
* is load-bearing (to-tf maps authored → resource by it); the declared rows
|
|
18
18
|
* need only an accurate `resourceType` for from-tf recognition.
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
/** The automation's own resource + its versioning/publish resource. */
|
|
21
21
|
export const AUTOMATION_RESOURCE_TYPE = "elementum_automation";
|
|
22
22
|
export const WORKFLOW_PUBLISH_RESOURCE_TYPE = "elementum_workflow_publish";
|
|
23
|
+
export const TABLE_RECORDS_SEARCH_TASK_RESOURCE_TYPE = "elementum_table_records_search_task";
|
|
23
24
|
/** Trigger kinds. One trigger per automation. Phase 1: onDemand only. */
|
|
24
25
|
export const TRIGGER_SUB_TYPES = [
|
|
25
26
|
{ typeKey: "onDemand", resourceType: "elementum_on_demand_trigger", implemented: true },
|
|
@@ -51,7 +52,7 @@ export const TASK_SUB_TYPES = [
|
|
|
51
52
|
{ typeKey: "updateVariable", resourceType: "elementum_update_variable_task", implemented: true },
|
|
52
53
|
{ typeKey: "updateField", resourceType: "elementum_update_field_task", implemented: true },
|
|
53
54
|
{ typeKey: "recordSearch", resourceType: "elementum_record_search_task", implemented: true },
|
|
54
|
-
{ typeKey: "tableRecordsSearch", resourceType:
|
|
55
|
+
{ typeKey: "tableRecordsSearch", resourceType: TABLE_RECORDS_SEARCH_TASK_RESOURCE_TYPE, implemented: true },
|
|
55
56
|
{ typeKey: "createRecord", resourceType: "elementum_create_record_task", implemented: true },
|
|
56
57
|
{ typeKey: "findRelatedRecords", resourceType: "elementum_find_related_records_task", implemented: true },
|
|
57
58
|
{ typeKey: "relateRecords", resourceType: "elementum_relate_records_task", implemented: true },
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { type AppCatalogRef, type AppOrElementRef, type ChartRef, type FieldRef, type TableColumnRef, type TableRef } from "../../catalog/index.js";
|
|
2
|
+
import type { DeployableEntity, EntityDeployOptions } from "../../engine/entity.js";
|
|
3
|
+
import type { Filter } from "../shared/filters/types.js";
|
|
4
|
+
import type { ChartAggregation, ChartColumnValueType, ChartJoinType, ChartType } from "./types.js";
|
|
5
|
+
export { chartAggregation, chartColumnValueType, chartJoinType, chartType, type ChartAggregation, type ChartColumnValueType, type ChartJoinType, type ChartType, } from "./types.js";
|
|
6
|
+
export type ChartDatasourceRef = AppOrElementRef | TableRef;
|
|
7
|
+
type RefBagValue<T> = T extends Readonly<Record<string, infer Value>> ? Value : never;
|
|
8
|
+
export type ChartFieldFor<Datasource> = Datasource extends {
|
|
9
|
+
readonly __kind: "table";
|
|
10
|
+
readonly columns?: infer Columns;
|
|
11
|
+
} ? Extract<RefBagValue<NonNullable<Columns>>, TableColumnRef> : Datasource extends {
|
|
12
|
+
readonly fields: infer Fields;
|
|
13
|
+
} ? Extract<RefBagValue<Fields>, FieldRef> : Datasource extends AppOrElementRef<infer Parent> ? FieldRef<Parent> : Datasource extends TableRef<infer Parent> ? TableColumnRef<Parent> : never;
|
|
14
|
+
interface ChartColumnBase {
|
|
15
|
+
readonly name?: string;
|
|
16
|
+
}
|
|
17
|
+
export type ChartColumn<Datasource extends ChartDatasourceRef = ChartDatasourceRef> = (ChartColumnBase & {
|
|
18
|
+
readonly field?: ChartFieldFor<Datasource>;
|
|
19
|
+
readonly aggregation: ChartAggregation;
|
|
20
|
+
readonly value?: never;
|
|
21
|
+
readonly valueType?: never;
|
|
22
|
+
readonly expression?: never;
|
|
23
|
+
}) | (ChartColumnBase & {
|
|
24
|
+
readonly value: string;
|
|
25
|
+
readonly valueType: ChartColumnValueType;
|
|
26
|
+
readonly field?: never;
|
|
27
|
+
readonly aggregation?: never;
|
|
28
|
+
readonly expression?: never;
|
|
29
|
+
});
|
|
30
|
+
export interface ChartGroupBy<Datasource extends ChartDatasourceRef = ChartDatasourceRef> {
|
|
31
|
+
readonly field: ChartFieldFor<Datasource>;
|
|
32
|
+
}
|
|
33
|
+
declare const chartJoinBrand: unique symbol;
|
|
34
|
+
export interface ChartJoin<From extends ChartDatasourceRef = ChartDatasourceRef, To extends ChartDatasourceRef = ChartDatasourceRef> {
|
|
35
|
+
readonly [chartJoinBrand]: {
|
|
36
|
+
readonly from: From;
|
|
37
|
+
readonly to: To;
|
|
38
|
+
};
|
|
39
|
+
readonly datasource: To;
|
|
40
|
+
readonly leftField?: ChartFieldFor<From>;
|
|
41
|
+
readonly rightField?: ChartFieldFor<To>;
|
|
42
|
+
readonly type?: ChartJoinType;
|
|
43
|
+
}
|
|
44
|
+
type ChartJoinSides<From extends ChartDatasourceRef, To extends ChartDatasourceRef> = {
|
|
45
|
+
readonly leftField: ChartFieldFor<From>;
|
|
46
|
+
readonly rightField: ChartFieldFor<To>;
|
|
47
|
+
readonly leftExpression?: never;
|
|
48
|
+
readonly rightExpression?: never;
|
|
49
|
+
};
|
|
50
|
+
/** Define an ownership-checked join used by a chart subscription. */
|
|
51
|
+
export declare function chartJoin<const From extends ChartDatasourceRef, const To extends ChartDatasourceRef>(opts: {
|
|
52
|
+
readonly from: From;
|
|
53
|
+
readonly datasource: To;
|
|
54
|
+
readonly type?: ChartJoinType;
|
|
55
|
+
} & ChartJoinSides<NoInfer<From>, NoInfer<To>>): ChartJoin<From, To>;
|
|
56
|
+
declare const chartSubscriptionBrand: unique symbol;
|
|
57
|
+
export interface ChartSubscription<Datasource extends ChartDatasourceRef = ChartDatasourceRef> {
|
|
58
|
+
readonly [chartSubscriptionBrand]: Datasource;
|
|
59
|
+
readonly datasource: Datasource;
|
|
60
|
+
readonly columns: readonly ChartColumn<Datasource>[];
|
|
61
|
+
readonly groupBy?: readonly ChartGroupBy<Datasource>[];
|
|
62
|
+
readonly joins?: readonly ChartJoin<Datasource, ChartDatasourceRef>[];
|
|
63
|
+
readonly filter?: Filter<ChartFieldFor<Datasource>, never>;
|
|
64
|
+
readonly limit?: string;
|
|
65
|
+
readonly tags?: readonly string[];
|
|
66
|
+
}
|
|
67
|
+
/** Build a chart subscription while preserving datasource/field ownership. */
|
|
68
|
+
export declare function chartSubscription<const Datasource extends ChartDatasourceRef>(opts: Omit<ChartSubscription<Datasource>, typeof chartSubscriptionBrand | "columns" | "groupBy" | "joins"> & {
|
|
69
|
+
readonly columns: readonly ChartColumn<NoInfer<Datasource>>[];
|
|
70
|
+
readonly groupBy?: readonly ChartGroupBy<NoInfer<Datasource>>[];
|
|
71
|
+
readonly joins?: readonly ChartJoin<NoInfer<Datasource>, ChartDatasourceRef>[];
|
|
72
|
+
}): ChartSubscription<Datasource>;
|
|
73
|
+
export interface ChartProperties {
|
|
74
|
+
readonly beginAtZero?: boolean;
|
|
75
|
+
readonly fill?: boolean;
|
|
76
|
+
readonly horizontal?: boolean;
|
|
77
|
+
readonly legend?: boolean;
|
|
78
|
+
readonly stacked?: boolean;
|
|
79
|
+
readonly target?: number;
|
|
80
|
+
}
|
|
81
|
+
export interface DefineChartOptions<AppRefName extends string = string> extends EntityDeployOptions {
|
|
82
|
+
/** Logical owner used for catalog placement and dashboard ownership checks. */
|
|
83
|
+
readonly app: AppCatalogRef<AppRefName>;
|
|
84
|
+
readonly name: string;
|
|
85
|
+
readonly type: ChartType;
|
|
86
|
+
readonly target?: number;
|
|
87
|
+
readonly properties?: ChartProperties;
|
|
88
|
+
readonly subscriptions: readonly ChartSubscription[];
|
|
89
|
+
}
|
|
90
|
+
export interface ChartConfigured<AppRefName extends string = string> {
|
|
91
|
+
ref<const RefName extends string>(refName: RefName): ChartRef<AppRefName, RefName>;
|
|
92
|
+
def(refName: string): DeployableEntity;
|
|
93
|
+
}
|
|
94
|
+
/** Define an app-owned chart resource for use by dashboard chart widgets. */
|
|
95
|
+
export declare function defineChart<const AppRefName extends string>(opts: DefineChartOptions<AppRefName>): ChartConfigured<AppRefName>;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { slimTokens, } from "../../catalog/index.js";
|
|
2
|
+
export { chartAggregation, chartColumnValueType, chartJoinType, chartType, } from "./types.js";
|
|
3
|
+
/** Define an ownership-checked join used by a chart subscription. */
|
|
4
|
+
export function chartJoin(opts) {
|
|
5
|
+
const { from: _from, ...wire } = opts;
|
|
6
|
+
return wire;
|
|
7
|
+
}
|
|
8
|
+
/** Build a chart subscription while preserving datasource/field ownership. */
|
|
9
|
+
export function chartSubscription(opts) {
|
|
10
|
+
return opts;
|
|
11
|
+
}
|
|
12
|
+
function validateChart(refName, opts) {
|
|
13
|
+
const fail = (message) => { throw new Error(`defineChart "${refName}": ${message}`); };
|
|
14
|
+
if (opts.app.__kind !== "app")
|
|
15
|
+
fail("app must be an app catalog ref");
|
|
16
|
+
if (opts.name.trim() === "")
|
|
17
|
+
fail("name must not be empty");
|
|
18
|
+
if (opts.subscriptions.length === 0)
|
|
19
|
+
fail("at least one subscription is required");
|
|
20
|
+
for (const [index, subscription] of opts.subscriptions.entries()) {
|
|
21
|
+
if (subscription.columns.length === 0)
|
|
22
|
+
fail(`subscriptions[${index}] must include at least one column`);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/** Define an app-owned chart resource for use by dashboard chart widgets. */
|
|
26
|
+
export function defineChart(opts) {
|
|
27
|
+
return {
|
|
28
|
+
ref(refName) {
|
|
29
|
+
return { __kind: "chart", refName, name: opts.name, parent: opts.app.refName };
|
|
30
|
+
},
|
|
31
|
+
def(refName) {
|
|
32
|
+
validateChart(refName, opts);
|
|
33
|
+
return {
|
|
34
|
+
kind: "chart",
|
|
35
|
+
parent: opts.app.refName,
|
|
36
|
+
refName,
|
|
37
|
+
payload: slimTokens(opts),
|
|
38
|
+
...(opts.enabled !== undefined ? { enabled: opts.enabled } : {}),
|
|
39
|
+
};
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
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 { ChartProperties } from "./build.js";
|
|
5
|
+
export interface NormalizedChartDatasource {
|
|
6
|
+
readonly kind: "app" | "element" | "table";
|
|
7
|
+
readonly refName: string;
|
|
8
|
+
readonly name?: string;
|
|
9
|
+
readonly local: boolean;
|
|
10
|
+
readonly tfLabel: string;
|
|
11
|
+
}
|
|
12
|
+
export interface NormalizedChartField {
|
|
13
|
+
readonly kind: "field" | "tableColumn";
|
|
14
|
+
readonly parentKind: "app" | "element" | "table";
|
|
15
|
+
readonly parentRefName: string;
|
|
16
|
+
readonly refName: string;
|
|
17
|
+
readonly name?: string;
|
|
18
|
+
}
|
|
19
|
+
export interface NormalizedChartColumn {
|
|
20
|
+
readonly field?: NormalizedChartField;
|
|
21
|
+
readonly aggregation?: string;
|
|
22
|
+
readonly name?: string;
|
|
23
|
+
readonly value?: string;
|
|
24
|
+
readonly valueType?: string;
|
|
25
|
+
}
|
|
26
|
+
export interface NormalizedChartGroupBy {
|
|
27
|
+
readonly field: NormalizedChartField;
|
|
28
|
+
}
|
|
29
|
+
export interface NormalizedChartJoin {
|
|
30
|
+
readonly datasource: NormalizedChartDatasource;
|
|
31
|
+
readonly leftField: NormalizedChartField;
|
|
32
|
+
readonly rightField: NormalizedChartField;
|
|
33
|
+
readonly type?: string;
|
|
34
|
+
}
|
|
35
|
+
export interface NormalizedChartSubscription {
|
|
36
|
+
readonly datasource: NormalizedChartDatasource;
|
|
37
|
+
readonly columns: readonly NormalizedChartColumn[];
|
|
38
|
+
readonly groupBy?: readonly NormalizedChartGroupBy[];
|
|
39
|
+
readonly joins?: readonly NormalizedChartJoin[];
|
|
40
|
+
readonly filter?: Filter<NormalizedChartField, never>;
|
|
41
|
+
readonly limit?: string;
|
|
42
|
+
readonly tags?: readonly string[];
|
|
43
|
+
}
|
|
44
|
+
export interface NormalizedChart {
|
|
45
|
+
readonly refName: string;
|
|
46
|
+
readonly name: string;
|
|
47
|
+
readonly type: string;
|
|
48
|
+
readonly target?: number;
|
|
49
|
+
readonly properties?: ChartProperties;
|
|
50
|
+
readonly subscriptions: readonly NormalizedChartSubscription[];
|
|
51
|
+
}
|
|
52
|
+
export declare function chartFromTf(block: TfBlock, opts: {
|
|
53
|
+
readonly appLabel: string;
|
|
54
|
+
readonly appRefName: string;
|
|
55
|
+
}, ctx: FromTfContext): NormalizedChart | undefined;
|
|
@@ -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
|
+
};
|