@lightdash/common 0.2104.6 → 0.2104.8
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/dist/cjs/.tsbuildinfo +1 -0
- package/dist/cjs/authorization/index.d.ts +1 -4
- package/dist/cjs/authorization/index.d.ts.map +1 -1
- package/dist/cjs/authorization/index.js +0 -4
- package/dist/cjs/authorization/index.js.map +1 -1
- package/dist/cjs/ee/AiAgent/chartConfig/web/getWebAiChartConfig.d.ts +8 -8
- package/dist/cjs/ee/AiAgent/index.d.ts +2 -2
- package/dist/cjs/ee/AiAgent/schemas/parser.d.ts +24 -24
- package/dist/cjs/ee/AiAgent/schemas/tools/toolDashboardV2Args.d.ts +96 -96
- package/dist/cjs/ee/AiAgent/schemas/tools/toolRunQueryArgs.d.ts +48 -48
- package/dist/cjs/ee/AiAgent/utils.d.ts +8 -8
- package/dist/cjs/index.d.ts +23 -449
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +21 -55
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/pivot/index.d.ts +1 -0
- package/dist/cjs/pivot/index.d.ts.map +1 -1
- package/dist/cjs/pivot/index.js +1 -0
- package/dist/cjs/pivot/index.js.map +1 -1
- package/dist/cjs/pivot/pivotConfig.d.ts +7 -0
- package/dist/cjs/pivot/pivotConfig.d.ts.map +1 -0
- package/dist/cjs/pivot/pivotConfig.js +32 -0
- package/dist/cjs/pivot/pivotConfig.js.map +1 -0
- package/dist/cjs/types/api.d.ts +447 -0
- package/dist/cjs/types/api.d.ts.map +1 -1
- package/dist/cjs/types/api.js +50 -1
- package/dist/cjs/types/api.js.map +1 -1
- package/dist/cjs/types/auth.d.ts +2 -1
- package/dist/cjs/types/auth.d.ts.map +1 -1
- package/dist/cjs/types/auth.js +4 -4
- package/dist/cjs/types/auth.js.map +1 -1
- package/dist/cjs/types/changeset.d.ts +10 -10
- package/dist/cjs/types/pivot.d.ts +0 -2
- package/dist/cjs/types/pivot.d.ts.map +1 -1
- package/dist/cjs/types/pivot.js +0 -29
- package/dist/cjs/types/pivot.js.map +1 -1
- package/dist/cjs/types/resourceViewItem.d.ts +1 -1
- package/dist/esm/.tsbuildinfo +1 -0
- package/dist/esm/authorization/index.d.ts +1 -4
- package/dist/esm/authorization/index.d.ts.map +1 -1
- package/dist/esm/authorization/index.js +0 -4
- package/dist/esm/authorization/index.js.map +1 -1
- package/dist/esm/ee/AiAgent/chartConfig/web/getWebAiChartConfig.d.ts +8 -8
- package/dist/esm/ee/AiAgent/index.d.ts +2 -2
- package/dist/esm/ee/AiAgent/schemas/parser.d.ts +24 -24
- package/dist/esm/ee/AiAgent/schemas/tools/toolDashboardV2Args.d.ts +96 -96
- package/dist/esm/ee/AiAgent/schemas/tools/toolRunQueryArgs.d.ts +48 -48
- package/dist/esm/ee/AiAgent/utils.d.ts +8 -8
- package/dist/esm/index.d.ts +23 -449
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +16 -50
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/pivot/index.d.ts +1 -0
- package/dist/esm/pivot/index.d.ts.map +1 -1
- package/dist/esm/pivot/index.js +1 -0
- package/dist/esm/pivot/index.js.map +1 -1
- package/dist/esm/pivot/pivotConfig.d.ts +7 -0
- package/dist/esm/pivot/pivotConfig.d.ts.map +1 -0
- package/dist/esm/pivot/pivotConfig.js +28 -0
- package/dist/esm/pivot/pivotConfig.js.map +1 -0
- package/dist/esm/types/api.d.ts +447 -0
- package/dist/esm/types/api.d.ts.map +1 -1
- package/dist/esm/types/api.js +46 -0
- package/dist/esm/types/api.js.map +1 -1
- package/dist/esm/types/auth.d.ts +2 -1
- package/dist/esm/types/auth.d.ts.map +1 -1
- package/dist/esm/types/auth.js +2 -2
- package/dist/esm/types/auth.js.map +1 -1
- package/dist/esm/types/changeset.d.ts +10 -10
- package/dist/esm/types/pivot.d.ts +0 -2
- package/dist/esm/types/pivot.d.ts.map +1 -1
- package/dist/esm/types/pivot.js +1 -27
- package/dist/esm/types/pivot.js.map +1 -1
- package/dist/esm/types/resourceViewItem.d.ts +1 -1
- package/dist/types/.tsbuildinfo +1 -0
- package/dist/types/authorization/buildAccountHelpers.js +11 -0
- package/dist/types/authorization/buildAccountHelpers.js.map +1 -0
- package/dist/types/authorization/index.d.ts +1 -4
- package/dist/types/authorization/index.d.ts.map +1 -1
- package/dist/types/authorization/index.js +62 -0
- package/dist/types/authorization/index.js.map +1 -0
- package/dist/types/authorization/index.mock.js +42 -0
- package/dist/types/authorization/index.mock.js.map +1 -0
- package/dist/types/authorization/index.test.js +220 -0
- package/dist/types/authorization/index.test.js.map +1 -0
- package/dist/types/authorization/jwtAbility.js +77 -0
- package/dist/types/authorization/jwtAbility.js.map +1 -0
- package/dist/types/authorization/jwtAbility.test.js +416 -0
- package/dist/types/authorization/jwtAbility.test.js.map +1 -0
- package/dist/types/authorization/organizationMemberAbility.js +318 -0
- package/dist/types/authorization/organizationMemberAbility.js.map +1 -0
- package/dist/types/authorization/organizationMemberAbility.mock.js +34 -0
- package/dist/types/authorization/organizationMemberAbility.mock.js.map +1 -0
- package/dist/types/authorization/organizationMemberAbility.test.js +1265 -0
- package/dist/types/authorization/organizationMemberAbility.test.js.map +1 -0
- package/dist/types/authorization/parseAccount.js +28 -0
- package/dist/types/authorization/parseAccount.js.map +1 -0
- package/dist/types/authorization/parseScopes.js +31 -0
- package/dist/types/authorization/parseScopes.js.map +1 -0
- package/dist/types/authorization/parseScopes.test.js +102 -0
- package/dist/types/authorization/parseScopes.test.js.map +1 -0
- package/dist/types/authorization/projectMemberAbility.js +239 -0
- package/dist/types/authorization/projectMemberAbility.js.map +1 -0
- package/dist/types/authorization/projectMemberAbility.mock.js +27 -0
- package/dist/types/authorization/projectMemberAbility.mock.js.map +1 -0
- package/dist/types/authorization/projectMemberAbility.test.js +1031 -0
- package/dist/types/authorization/projectMemberAbility.test.js.map +1 -0
- package/dist/types/authorization/roleToScopeMapping.js +150 -0
- package/dist/types/authorization/roleToScopeMapping.js.map +1 -0
- package/dist/types/authorization/roleToScopeMapping.test.js +561 -0
- package/dist/types/authorization/roleToScopeMapping.test.js.map +1 -0
- package/dist/types/authorization/roleToScopeMapping.testUtils.js +319 -0
- package/dist/types/authorization/roleToScopeMapping.testUtils.js.map +1 -0
- package/dist/types/authorization/roleToScopeParity.test.js +194 -0
- package/dist/types/authorization/roleToScopeParity.test.js.map +1 -0
- package/dist/types/authorization/scopeAbilityBuilder.js +57 -0
- package/dist/types/authorization/scopeAbilityBuilder.js.map +1 -0
- package/dist/types/authorization/scopeAbilityBuilder.test.js +1348 -0
- package/dist/types/authorization/scopeAbilityBuilder.test.js.map +1 -0
- package/dist/types/authorization/scopes.js +613 -0
- package/dist/types/authorization/scopes.js.map +1 -0
- package/dist/types/authorization/serviceAccountAbility.js +303 -0
- package/dist/types/authorization/serviceAccountAbility.js.map +1 -0
- package/dist/types/authorization/types.js +2 -0
- package/dist/types/authorization/types.js.map +1 -0
- package/dist/types/compiler/exploreCompiler.js +462 -0
- package/dist/types/compiler/exploreCompiler.js.map +1 -0
- package/dist/types/compiler/exploreCompiler.mock.js +2016 -0
- package/dist/types/compiler/exploreCompiler.mock.js.map +1 -0
- package/dist/types/compiler/exploreCompiler.test.js +679 -0
- package/dist/types/compiler/exploreCompiler.test.js.map +1 -0
- package/dist/types/compiler/fieldSetExpander.js +119 -0
- package/dist/types/compiler/fieldSetExpander.js.map +1 -0
- package/dist/types/compiler/fieldSetExpander.test.js +184 -0
- package/dist/types/compiler/fieldSetExpander.test.js.map +1 -0
- package/dist/types/compiler/filtersCompiler.js +337 -0
- package/dist/types/compiler/filtersCompiler.js.map +1 -0
- package/dist/types/compiler/filtersCompiler.mock.js +496 -0
- package/dist/types/compiler/filtersCompiler.mock.js.map +1 -0
- package/dist/types/compiler/filtersCompiler.test.js +570 -0
- package/dist/types/compiler/filtersCompiler.test.js.map +1 -0
- package/dist/types/compiler/lightdashProjectConfig.js +37 -0
- package/dist/types/compiler/lightdashProjectConfig.js.map +1 -0
- package/dist/types/compiler/parameters.js +75 -0
- package/dist/types/compiler/parameters.js.map +1 -0
- package/dist/types/compiler/parameters.test.js +216 -0
- package/dist/types/compiler/parameters.test.js.map +1 -0
- package/dist/types/compiler/translator.js +707 -0
- package/dist/types/compiler/translator.js.map +1 -0
- package/dist/types/compiler/translator.mock.js +1901 -0
- package/dist/types/compiler/translator.mock.js.map +1 -0
- package/dist/types/compiler/translator.test.js +323 -0
- package/dist/types/compiler/translator.test.js.map +1 -0
- package/dist/types/constants/pivot.js +7 -0
- package/dist/types/constants/pivot.js.map +1 -0
- package/dist/types/constants/sessionStorageKeys.js +6 -0
- package/dist/types/constants/sessionStorageKeys.js.map +1 -0
- package/dist/types/constants/sqlRunner.js +3 -0
- package/dist/types/constants/sqlRunner.js.map +1 -0
- package/dist/types/dbt/DbtSchemaEditor/DbtSchemaEditor.js +285 -0
- package/dist/types/dbt/DbtSchemaEditor/DbtSchemaEditor.js.map +1 -0
- package/dist/types/dbt/DbtSchemaEditor/DbtSchemaEditor.mock.js +224 -0
- package/dist/types/dbt/DbtSchemaEditor/DbtSchemaEditor.mock.js.map +1 -0
- package/dist/types/dbt/DbtSchemaEditor/DbtSchemaEditor.test.js +129 -0
- package/dist/types/dbt/DbtSchemaEditor/DbtSchemaEditor.test.js.map +1 -0
- package/dist/types/dbt/schemas/lightdashMetadata.json +385 -0
- package/dist/types/dbt/schemas/lightdashV10.json +72 -0
- package/dist/types/dbt/schemas/lightdashV11.json +72 -0
- package/dist/types/dbt/schemas/lightdashV12.json +63 -0
- package/dist/types/dbt/schemas/lightdashV7.json +72 -0
- package/dist/types/dbt/schemas/lightdashV8.json +76 -0
- package/dist/types/dbt/schemas/lightdashV9.json +72 -0
- package/dist/types/dbt/schemas/manifestV10.json +5545 -0
- package/dist/types/dbt/schemas/manifestV11.json +6041 -0
- package/dist/types/dbt/schemas/manifestV12.json +22567 -0
- package/dist/types/dbt/schemas/manifestV7.json +6481 -0
- package/dist/types/dbt/schemas/manifestV8.json +4358 -0
- package/dist/types/dbt/schemas/manifestV9.json +4879 -0
- package/dist/types/dbt/validation.js +67 -0
- package/dist/types/dbt/validation.js.map +1 -0
- package/dist/types/ee/AiAgent/adminTypes.js +2 -0
- package/dist/types/ee/AiAgent/adminTypes.js.map +1 -0
- package/dist/types/ee/AiAgent/chartConfig/shared/formatFieldLabel.js +10 -0
- package/dist/types/ee/AiAgent/chartConfig/shared/formatFieldLabel.js.map +1 -0
- package/dist/types/ee/AiAgent/chartConfig/slack/generateBarVizConfigTool/getVerticalBarChartEchartsConfig.js +60 -0
- package/dist/types/ee/AiAgent/chartConfig/slack/generateBarVizConfigTool/getVerticalBarChartEchartsConfig.js.map +1 -0
- package/dist/types/ee/AiAgent/chartConfig/slack/generateTimeSeriesVizConfigTool/getTimeSeriesChartEchartsConfig.js +60 -0
- package/dist/types/ee/AiAgent/chartConfig/slack/generateTimeSeriesVizConfigTool/getTimeSeriesChartEchartsConfig.js.map +1 -0
- package/dist/types/ee/AiAgent/chartConfig/slack/getSlackAiEchartsConfig.js +33 -0
- package/dist/types/ee/AiAgent/chartConfig/slack/getSlackAiEchartsConfig.js.map +1 -0
- package/dist/types/ee/AiAgent/chartConfig/slack/index.js +2 -0
- package/dist/types/ee/AiAgent/chartConfig/slack/index.js.map +1 -0
- package/dist/types/ee/AiAgent/chartConfig/slack/runQueryTool/getRunQueryEchartsConfig.js +43 -0
- package/dist/types/ee/AiAgent/chartConfig/slack/runQueryTool/getRunQueryEchartsConfig.js.map +1 -0
- package/dist/types/ee/AiAgent/chartConfig/slack/runQueryTool/viz/bar.js +98 -0
- package/dist/types/ee/AiAgent/chartConfig/slack/runQueryTool/viz/bar.js.map +1 -0
- package/dist/types/ee/AiAgent/chartConfig/slack/runQueryTool/viz/funnel.js +38 -0
- package/dist/types/ee/AiAgent/chartConfig/slack/runQueryTool/viz/funnel.js.map +1 -0
- package/dist/types/ee/AiAgent/chartConfig/slack/runQueryTool/viz/horizontalBar.js +65 -0
- package/dist/types/ee/AiAgent/chartConfig/slack/runQueryTool/viz/horizontalBar.js.map +1 -0
- package/dist/types/ee/AiAgent/chartConfig/slack/runQueryTool/viz/line.js +105 -0
- package/dist/types/ee/AiAgent/chartConfig/slack/runQueryTool/viz/line.js.map +1 -0
- package/dist/types/ee/AiAgent/chartConfig/slack/runQueryTool/viz/pie.js +34 -0
- package/dist/types/ee/AiAgent/chartConfig/slack/runQueryTool/viz/pie.js.map +1 -0
- package/dist/types/ee/AiAgent/chartConfig/slack/runQueryTool/viz/scatter.js +66 -0
- package/dist/types/ee/AiAgent/chartConfig/slack/runQueryTool/viz/scatter.js.map +1 -0
- package/dist/types/ee/AiAgent/chartConfig/slack/shared/getCommonEChartsConfig.js +104 -0
- package/dist/types/ee/AiAgent/chartConfig/slack/shared/getCommonEChartsConfig.js.map +1 -0
- package/dist/types/ee/AiAgent/chartConfig/slack/types.js +2 -0
- package/dist/types/ee/AiAgent/chartConfig/slack/types.js.map +1 -0
- package/dist/types/ee/AiAgent/chartConfig/web/generateBarVizConfigTool/getVerticalBarChartConfig.js +65 -0
- package/dist/types/ee/AiAgent/chartConfig/web/generateBarVizConfigTool/getVerticalBarChartConfig.js.map +1 -0
- package/dist/types/ee/AiAgent/chartConfig/web/generateTableVizConfigTool/getTableChartConfig.js +5 -0
- package/dist/types/ee/AiAgent/chartConfig/web/generateTableVizConfigTool/getTableChartConfig.js.map +1 -0
- package/dist/types/ee/AiAgent/chartConfig/web/generateTimeSeriesVizConfigTool/getTimeSeriesChartConfig.js +63 -0
- package/dist/types/ee/AiAgent/chartConfig/web/generateTimeSeriesVizConfigTool/getTimeSeriesChartConfig.js.map +1 -0
- package/dist/types/ee/AiAgent/chartConfig/web/getWebAiChartConfig.d.ts +8 -8
- package/dist/types/ee/AiAgent/chartConfig/web/getWebAiChartConfig.js +51 -0
- package/dist/types/ee/AiAgent/chartConfig/web/getWebAiChartConfig.js.map +1 -0
- package/dist/types/ee/AiAgent/chartConfig/web/index.js +6 -0
- package/dist/types/ee/AiAgent/chartConfig/web/index.js.map +1 -0
- package/dist/types/ee/AiAgent/chartConfig/web/runQueryTool/getRunQueryChartConfig.js +73 -0
- package/dist/types/ee/AiAgent/chartConfig/web/runQueryTool/getRunQueryChartConfig.js.map +1 -0
- package/dist/types/ee/AiAgent/chartConfig/web/runQueryTool/viz/bar.js +91 -0
- package/dist/types/ee/AiAgent/chartConfig/web/runQueryTool/viz/bar.js.map +1 -0
- package/dist/types/ee/AiAgent/chartConfig/web/runQueryTool/viz/funnel.js +17 -0
- package/dist/types/ee/AiAgent/chartConfig/web/runQueryTool/viz/funnel.js.map +1 -0
- package/dist/types/ee/AiAgent/chartConfig/web/runQueryTool/viz/horizontalBar.js +52 -0
- package/dist/types/ee/AiAgent/chartConfig/web/runQueryTool/viz/horizontalBar.js.map +1 -0
- package/dist/types/ee/AiAgent/chartConfig/web/runQueryTool/viz/line.js +96 -0
- package/dist/types/ee/AiAgent/chartConfig/web/runQueryTool/viz/line.js.map +1 -0
- package/dist/types/ee/AiAgent/chartConfig/web/runQueryTool/viz/pie.js +15 -0
- package/dist/types/ee/AiAgent/chartConfig/web/runQueryTool/viz/pie.js.map +1 -0
- package/dist/types/ee/AiAgent/chartConfig/web/runQueryTool/viz/scatter.js +66 -0
- package/dist/types/ee/AiAgent/chartConfig/web/runQueryTool/viz/scatter.js.map +1 -0
- package/dist/types/ee/AiAgent/chartConfig/web/shared/canRenderAsChart.js +24 -0
- package/dist/types/ee/AiAgent/chartConfig/web/shared/canRenderAsChart.js.map +1 -0
- package/dist/types/ee/AiAgent/chartConfig/web/shared/formatPivotValueLabel.js +15 -0
- package/dist/types/ee/AiAgent/chartConfig/web/shared/formatPivotValueLabel.js.map +1 -0
- package/dist/types/ee/AiAgent/chartConfig/web/shared/getAvailableChartTypes.js +11 -0
- package/dist/types/ee/AiAgent/chartConfig/web/shared/getAvailableChartTypes.js.map +1 -0
- package/dist/types/ee/AiAgent/chartConfig/web/shared/getGroupByDimensions.js +15 -0
- package/dist/types/ee/AiAgent/chartConfig/web/shared/getGroupByDimensions.js.map +1 -0
- package/dist/types/ee/AiAgent/chartConfig/web/types.js +2 -0
- package/dist/types/ee/AiAgent/chartConfig/web/types.js.map +1 -0
- package/dist/types/ee/AiAgent/constants.js +2 -0
- package/dist/types/ee/AiAgent/constants.js.map +1 -0
- package/dist/types/ee/AiAgent/filterExploreByTags.js +94 -0
- package/dist/types/ee/AiAgent/filterExploreByTags.js.map +1 -0
- package/dist/types/ee/AiAgent/filterExploreByTags.test.js +634 -0
- package/dist/types/ee/AiAgent/filterExploreByTags.test.js.map +1 -0
- package/dist/types/ee/AiAgent/followUpTools.js +33 -0
- package/dist/types/ee/AiAgent/followUpTools.js.map +1 -0
- package/dist/types/ee/AiAgent/index.d.ts +2 -2
- package/dist/types/ee/AiAgent/index.js +43 -0
- package/dist/types/ee/AiAgent/index.js.map +1 -0
- package/dist/types/ee/AiAgent/requestTypes.js +2 -0
- package/dist/types/ee/AiAgent/requestTypes.js.map +1 -0
- package/dist/types/ee/AiAgent/schemas/customMetrics.js +50 -0
- package/dist/types/ee/AiAgent/schemas/customMetrics.js.map +1 -0
- package/dist/types/ee/AiAgent/schemas/fieldId.js +11 -0
- package/dist/types/ee/AiAgent/schemas/fieldId.js.map +1 -0
- package/dist/types/ee/AiAgent/schemas/filters/booleanFilters.js +29 -0
- package/dist/types/ee/AiAgent/schemas/filters/booleanFilters.js.map +1 -0
- package/dist/types/ee/AiAgent/schemas/filters/dateFilters.js +84 -0
- package/dist/types/ee/AiAgent/schemas/filters/dateFilters.js.map +1 -0
- package/dist/types/ee/AiAgent/schemas/filters/index.js +98 -0
- package/dist/types/ee/AiAgent/schemas/filters/index.js.map +1 -0
- package/dist/types/ee/AiAgent/schemas/filters/numberFilters.js +53 -0
- package/dist/types/ee/AiAgent/schemas/filters/numberFilters.js.map +1 -0
- package/dist/types/ee/AiAgent/schemas/filters/stringFilters.js +33 -0
- package/dist/types/ee/AiAgent/schemas/filters/stringFilters.js.map +1 -0
- package/dist/types/ee/AiAgent/schemas/index.js +9 -0
- package/dist/types/ee/AiAgent/schemas/index.js.map +1 -0
- package/dist/types/ee/AiAgent/schemas/outputMetadata.js +5 -0
- package/dist/types/ee/AiAgent/schemas/outputMetadata.js.map +1 -0
- package/dist/types/ee/AiAgent/schemas/parser.d.ts +24 -24
- package/dist/types/ee/AiAgent/schemas/parser.js +43 -0
- package/dist/types/ee/AiAgent/schemas/parser.js.map +1 -0
- package/dist/types/ee/AiAgent/schemas/sortField.js +14 -0
- package/dist/types/ee/AiAgent/schemas/sortField.js.map +1 -0
- package/dist/types/ee/AiAgent/schemas/tableCalcs/tableCalcBaseSchemas.js +28 -0
- package/dist/types/ee/AiAgent/schemas/tableCalcs/tableCalcBaseSchemas.js.map +1 -0
- package/dist/types/ee/AiAgent/schemas/tableCalcs/tableCalcPercentChangeFromPrevious.js +14 -0
- package/dist/types/ee/AiAgent/schemas/tableCalcs/tableCalcPercentChangeFromPrevious.js.map +1 -0
- package/dist/types/ee/AiAgent/schemas/tableCalcs/tableCalcPercentOfColumnTotal.js +14 -0
- package/dist/types/ee/AiAgent/schemas/tableCalcs/tableCalcPercentOfColumnTotal.js.map +1 -0
- package/dist/types/ee/AiAgent/schemas/tableCalcs/tableCalcPercentOfPreviousValue.js +14 -0
- package/dist/types/ee/AiAgent/schemas/tableCalcs/tableCalcPercentOfPreviousValue.js.map +1 -0
- package/dist/types/ee/AiAgent/schemas/tableCalcs/tableCalcRankInColumn.js +10 -0
- package/dist/types/ee/AiAgent/schemas/tableCalcs/tableCalcRankInColumn.js.map +1 -0
- package/dist/types/ee/AiAgent/schemas/tableCalcs/tableCalcRunningTotal.js +10 -0
- package/dist/types/ee/AiAgent/schemas/tableCalcs/tableCalcRunningTotal.js.map +1 -0
- package/dist/types/ee/AiAgent/schemas/tableCalcs/tableCalcWindowFunction.js +105 -0
- package/dist/types/ee/AiAgent/schemas/tableCalcs/tableCalcWindowFunction.js.map +1 -0
- package/dist/types/ee/AiAgent/schemas/tableCalcs/tableCalcs.js +168 -0
- package/dist/types/ee/AiAgent/schemas/tableCalcs/tableCalcs.js.map +1 -0
- package/dist/types/ee/AiAgent/schemas/toolSchemaBuilder.js +37 -0
- package/dist/types/ee/AiAgent/schemas/toolSchemaBuilder.js.map +1 -0
- package/dist/types/ee/AiAgent/schemas/tools/index.js +16 -0
- package/dist/types/ee/AiAgent/schemas/tools/index.js.map +1 -0
- package/dist/types/ee/AiAgent/schemas/tools/toolDashboardArgs.js +103 -0
- package/dist/types/ee/AiAgent/schemas/tools/toolDashboardArgs.js.map +1 -0
- package/dist/types/ee/AiAgent/schemas/tools/toolDashboardV2Args.d.ts +96 -96
- package/dist/types/ee/AiAgent/schemas/tools/toolDashboardV2Args.js +50 -0
- package/dist/types/ee/AiAgent/schemas/tools/toolDashboardV2Args.js.map +1 -0
- package/dist/types/ee/AiAgent/schemas/tools/toolFindChartsArgs.js +34 -0
- package/dist/types/ee/AiAgent/schemas/tools/toolFindChartsArgs.js.map +1 -0
- package/dist/types/ee/AiAgent/schemas/tools/toolFindContentArgs.js +33 -0
- package/dist/types/ee/AiAgent/schemas/tools/toolFindContentArgs.js.map +1 -0
- package/dist/types/ee/AiAgent/schemas/tools/toolFindDashboardsArgs.js +36 -0
- package/dist/types/ee/AiAgent/schemas/tools/toolFindDashboardsArgs.js.map +1 -0
- package/dist/types/ee/AiAgent/schemas/tools/toolFindExploresArgs.js +45 -0
- package/dist/types/ee/AiAgent/schemas/tools/toolFindExploresArgs.js.map +1 -0
- package/dist/types/ee/AiAgent/schemas/tools/toolFindFieldsArgs.js +34 -0
- package/dist/types/ee/AiAgent/schemas/tools/toolFindFieldsArgs.js.map +1 -0
- package/dist/types/ee/AiAgent/schemas/tools/toolImproveContextArgs.js +60 -0
- package/dist/types/ee/AiAgent/schemas/tools/toolImproveContextArgs.js.map +1 -0
- package/dist/types/ee/AiAgent/schemas/tools/toolProposeChangeArgs.js +157 -0
- package/dist/types/ee/AiAgent/schemas/tools/toolProposeChangeArgs.js.map +1 -0
- package/dist/types/ee/AiAgent/schemas/tools/toolRunMetricQueryArgs.js +41 -0
- package/dist/types/ee/AiAgent/schemas/tools/toolRunMetricQueryArgs.js.map +1 -0
- package/dist/types/ee/AiAgent/schemas/tools/toolRunQueryArgs.d.ts +48 -48
- package/dist/types/ee/AiAgent/schemas/tools/toolRunQueryArgs.js +151 -0
- package/dist/types/ee/AiAgent/schemas/tools/toolRunQueryArgs.js.map +1 -0
- package/dist/types/ee/AiAgent/schemas/tools/toolSearchFieldValuesArgs.js +46 -0
- package/dist/types/ee/AiAgent/schemas/tools/toolSearchFieldValuesArgs.js.map +1 -0
- package/dist/types/ee/AiAgent/schemas/tools/toolTableVizArgs.js +53 -0
- package/dist/types/ee/AiAgent/schemas/tools/toolTableVizArgs.js.map +1 -0
- package/dist/types/ee/AiAgent/schemas/tools/toolTimeSeriesArgs.js +58 -0
- package/dist/types/ee/AiAgent/schemas/tools/toolTimeSeriesArgs.js.map +1 -0
- package/dist/types/ee/AiAgent/schemas/tools/toolVerticalBarArgs.js +53 -0
- package/dist/types/ee/AiAgent/schemas/tools/toolVerticalBarArgs.js.map +1 -0
- package/dist/types/ee/AiAgent/schemas/visualizationMetadata.js +9 -0
- package/dist/types/ee/AiAgent/schemas/visualizationMetadata.js.map +1 -0
- package/dist/types/ee/AiAgent/schemas/visualizations/index.js +58 -0
- package/dist/types/ee/AiAgent/schemas/visualizations/index.js.map +1 -0
- package/dist/types/ee/AiAgent/schemas/visualizations/tableViz.js +38 -0
- package/dist/types/ee/AiAgent/schemas/visualizations/tableViz.js.map +1 -0
- package/dist/types/ee/AiAgent/schemas/visualizations/timeSeriesViz.js +63 -0
- package/dist/types/ee/AiAgent/schemas/visualizations/timeSeriesViz.js.map +1 -0
- package/dist/types/ee/AiAgent/schemas/visualizations/verticalBarViz.js +68 -0
- package/dist/types/ee/AiAgent/schemas/visualizations/verticalBarViz.js.map +1 -0
- package/dist/types/ee/AiAgent/types.js +12 -0
- package/dist/types/ee/AiAgent/types.js.map +1 -0
- package/dist/types/ee/AiAgent/utils.d.ts +8 -8
- package/dist/types/ee/AiAgent/utils.js +82 -0
- package/dist/types/ee/AiAgent/utils.js.map +1 -0
- package/dist/types/ee/AiAgent/validators.js +10 -0
- package/dist/types/ee/AiAgent/validators.js.map +1 -0
- package/dist/types/ee/commercialFeatureFlags.js +10 -0
- package/dist/types/ee/commercialFeatureFlags.js.map +1 -0
- package/dist/types/ee/embed/index.js +90 -0
- package/dist/types/ee/embed/index.js.map +1 -0
- package/dist/types/ee/index.js +19 -0
- package/dist/types/ee/index.js.map +1 -0
- package/dist/types/ee/scim/errors.js +22 -0
- package/dist/types/ee/scim/errors.js.map +1 -0
- package/dist/types/ee/scim/types.js +2 -0
- package/dist/types/ee/scim/types.js.map +1 -0
- package/dist/types/ee/serviceAccounts/types.js +8 -0
- package/dist/types/ee/serviceAccounts/types.js.map +1 -0
- package/dist/types/index.d.ts +23 -449
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +652 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/index.mock.js +44 -0
- package/dist/types/index.mock.js.map +1 -0
- package/dist/types/index.test.js +123 -0
- package/dist/types/index.test.js.map +1 -0
- package/dist/types/pivot/derivePivotConfigFromChart.js +206 -0
- package/dist/types/pivot/derivePivotConfigFromChart.js.map +1 -0
- package/dist/types/pivot/derivePivotConfigFromChart.mock.js +112 -0
- package/dist/types/pivot/derivePivotConfigFromChart.mock.js.map +1 -0
- package/dist/types/pivot/derivePivotConfigFromChart.test.js +418 -0
- package/dist/types/pivot/derivePivotConfigFromChart.test.js.map +1 -0
- package/dist/types/pivot/index.d.ts +1 -0
- package/dist/types/pivot/index.d.ts.map +1 -1
- package/dist/types/pivot/index.js +5 -0
- package/dist/types/pivot/index.js.map +1 -0
- package/dist/types/pivot/pivotConfig.d.ts +7 -0
- package/dist/types/pivot/pivotConfig.d.ts.map +1 -0
- package/dist/types/pivot/pivotConfig.js +28 -0
- package/dist/types/pivot/pivotConfig.js.map +1 -0
- package/dist/types/pivot/pivotQueryResults.js +1034 -0
- package/dist/types/pivot/pivotQueryResults.js.map +1 -0
- package/dist/types/pivot/pivotQueryResults.mock.js +2412 -0
- package/dist/types/pivot/pivotQueryResults.mock.js.map +1 -0
- package/dist/types/pivot/pivotQueryResults.test.js +1222 -0
- package/dist/types/pivot/pivotQueryResults.test.js.map +1 -0
- package/dist/types/pivot/utils.js +14 -0
- package/dist/types/pivot/utils.js.map +1 -0
- package/dist/types/schemas/json/chart-as-code-1.0.json +436 -0
- package/dist/types/schemas/json/dashboard-as-code-1.0.json +349 -0
- package/dist/types/schemas/json/lightdash-dbt-2.0.json +1417 -0
- package/dist/types/schemas/json/lightdash-project-config-1.0.json +138 -0
- package/dist/types/templating/template.js +30 -0
- package/dist/types/templating/template.js.map +1 -0
- package/dist/types/templating/template.mock.js +45 -0
- package/dist/types/templating/template.mock.js.map +1 -0
- package/dist/types/templating/template.test.js +21 -0
- package/dist/types/templating/template.test.js.map +1 -0
- package/dist/types/types/SshKeyPair.js +2 -0
- package/dist/types/types/SshKeyPair.js.map +1 -0
- package/dist/types/types/account.js +2 -0
- package/dist/types/types/account.js.map +1 -0
- package/dist/types/types/analytics.js +29 -0
- package/dist/types/types/analytics.js.map +1 -0
- package/dist/types/types/any.js +2 -0
- package/dist/types/types/any.js.map +1 -0
- package/dist/types/types/api/comments.js +2 -0
- package/dist/types/types/api/comments.js.map +1 -0
- package/dist/types/types/api/email.js +2 -0
- package/dist/types/types/api/email.js.map +1 -0
- package/dist/types/types/api/errors.js +2 -0
- package/dist/types/types/api/errors.js.map +1 -0
- package/dist/types/types/api/notifications.js +5 -0
- package/dist/types/types/api/notifications.js.map +1 -0
- package/dist/types/types/api/paginatedQuery.js +3 -0
- package/dist/types/types/api/paginatedQuery.js.map +1 -0
- package/dist/types/types/api/parameters.js +2 -0
- package/dist/types/types/api/parameters.js.map +1 -0
- package/dist/types/types/api/share.js +2 -0
- package/dist/types/types/api/share.js.map +1 -0
- package/dist/types/types/api/sort.js +2 -0
- package/dist/types/types/api/sort.js.map +1 -0
- package/dist/types/types/api/spotlight.js +2 -0
- package/dist/types/types/api/spotlight.js.map +1 -0
- package/dist/types/types/api/success.js +2 -0
- package/dist/types/types/api/success.js.map +1 -0
- package/dist/types/types/api/uuid.js +2 -0
- package/dist/types/types/api/uuid.js.map +1 -0
- package/dist/types/types/api.d.ts +447 -0
- package/dist/types/types/api.d.ts.map +1 -1
- package/dist/types/types/api.js +57 -0
- package/dist/types/types/api.js.map +1 -0
- package/dist/types/types/applyDimensionOverrides.test.js +338 -0
- package/dist/types/types/applyDimensionOverrides.test.js.map +1 -0
- package/dist/types/types/auth.d.ts +2 -1
- package/dist/types/types/auth.d.ts.map +1 -1
- package/dist/types/types/auth.js +42 -0
- package/dist/types/types/auth.js.map +1 -0
- package/dist/types/types/bigQuerySSO.js +2 -0
- package/dist/types/types/bigQuerySSO.js.map +1 -0
- package/dist/types/types/catalog.js +50 -0
- package/dist/types/types/catalog.js.map +1 -0
- package/dist/types/types/changeset.d.ts +10 -10
- package/dist/types/types/changeset.js +72 -0
- package/dist/types/types/changeset.js.map +1 -0
- package/dist/types/types/coder.js +2 -0
- package/dist/types/types/coder.js.map +1 -0
- package/dist/types/types/comments.js +2 -0
- package/dist/types/types/comments.js.map +1 -0
- package/dist/types/types/conditionalFormatting.js +25 -0
- package/dist/types/types/conditionalFormatting.js.map +1 -0
- package/dist/types/types/content.js +19 -0
- package/dist/types/types/content.js.map +1 -0
- package/dist/types/types/csv.js +2 -0
- package/dist/types/types/csv.js.map +1 -0
- package/dist/types/types/dashboard.js +46 -0
- package/dist/types/types/dashboard.js.map +1 -0
- package/dist/types/types/dbt.js +262 -0
- package/dist/types/types/dbt.js.map +1 -0
- package/dist/types/types/dbtFromSchema.js +2 -0
- package/dist/types/types/dbtFromSchema.js.map +1 -0
- package/dist/types/types/deepPartial.js +7 -0
- package/dist/types/types/deepPartial.js.map +1 -0
- package/dist/types/types/downloadFile.js +9 -0
- package/dist/types/types/downloadFile.js.map +1 -0
- package/dist/types/types/email.js +2 -0
- package/dist/types/types/email.js.map +1 -0
- package/dist/types/types/errors.js +496 -0
- package/dist/types/types/errors.js.map +1 -0
- package/dist/types/types/explore.js +24 -0
- package/dist/types/types/explore.js.map +1 -0
- package/dist/types/types/featureFlags.js +62 -0
- package/dist/types/types/featureFlags.js.map +1 -0
- package/dist/types/types/field.js +473 -0
- package/dist/types/types/field.js.map +1 -0
- package/dist/types/types/field.test.js +90 -0
- package/dist/types/types/field.test.js.map +1 -0
- package/dist/types/types/fieldMatch.js +2 -0
- package/dist/types/types/fieldMatch.js.map +1 -0
- package/dist/types/types/filter.js +287 -0
- package/dist/types/types/filter.js.map +1 -0
- package/dist/types/types/filter.test.js +372 -0
- package/dist/types/types/filter.test.js.map +1 -0
- package/dist/types/types/filterGrammar.js +358 -0
- package/dist/types/types/filterGrammar.js.map +1 -0
- package/dist/types/types/filterGrammar.test.js +549 -0
- package/dist/types/types/filterGrammar.test.js.map +1 -0
- package/dist/types/types/filterGrammarConversion.js +94 -0
- package/dist/types/types/filterGrammarConversion.js.map +1 -0
- package/dist/types/types/filterGrammarConversion.test.js +260 -0
- package/dist/types/types/filterGrammarConversion.test.js.map +1 -0
- package/dist/types/types/gdrive.js +2 -0
- package/dist/types/types/gdrive.js.map +1 -0
- package/dist/types/types/gitIntegration.js +2 -0
- package/dist/types/types/gitIntegration.js.map +1 -0
- package/dist/types/types/groups.js +4 -0
- package/dist/types/types/groups.js.map +1 -0
- package/dist/types/types/job.js +67 -0
- package/dist/types/types/job.js.map +1 -0
- package/dist/types/types/knex-paginate.js +2 -0
- package/dist/types/types/knex-paginate.js.map +1 -0
- package/dist/types/types/lightdashProjectConfig.js +4 -0
- package/dist/types/types/lightdashProjectConfig.js.map +1 -0
- package/dist/types/types/metricQuery.js +20 -0
- package/dist/types/types/metricQuery.js.map +1 -0
- package/dist/types/types/metricsExplorer.js +12 -0
- package/dist/types/types/metricsExplorer.js.map +1 -0
- package/dist/types/types/notifications.js +2 -0
- package/dist/types/types/notifications.js.map +1 -0
- package/dist/types/types/oauth.js +2 -0
- package/dist/types/types/oauth.js.map +1 -0
- package/dist/types/types/openIdIdentity.js +12 -0
- package/dist/types/types/openIdIdentity.js.map +1 -0
- package/dist/types/types/organization.js +20 -0
- package/dist/types/types/organization.js.map +1 -0
- package/dist/types/types/organizationMemberProfile.js +30 -0
- package/dist/types/types/organizationMemberProfile.js.map +1 -0
- package/dist/types/types/organizationWarehouseCredentials.js +2 -0
- package/dist/types/types/organizationWarehouseCredentials.js.map +1 -0
- package/dist/types/types/paginateResults.js +2 -0
- package/dist/types/types/paginateResults.js.map +1 -0
- package/dist/types/types/parameters.js +2 -0
- package/dist/types/types/parameters.js.map +1 -0
- package/dist/types/types/personalAccessToken.js +2 -0
- package/dist/types/types/personalAccessToken.js.map +1 -0
- package/dist/types/types/pinning.js +5 -0
- package/dist/types/types/pinning.js.map +1 -0
- package/dist/types/types/pivot.d.ts +0 -2
- package/dist/types/types/pivot.d.ts.map +1 -1
- package/dist/types/types/pivot.js +2 -0
- package/dist/types/types/pivot.js.map +1 -0
- package/dist/types/types/projectGroupAccess.js +2 -0
- package/dist/types/types/projectGroupAccess.js.map +1 -0
- package/dist/types/types/projectMemberProfile.js +2 -0
- package/dist/types/types/projectMemberProfile.js.map +1 -0
- package/dist/types/types/projectMemberRole.js +30 -0
- package/dist/types/types/projectMemberRole.js.map +1 -0
- package/dist/types/types/projects.js +149 -0
- package/dist/types/types/projects.js.map +1 -0
- package/dist/types/types/promotion.js +8 -0
- package/dist/types/types/promotion.js.map +1 -0
- package/dist/types/types/queryHistory.js +8 -0
- package/dist/types/types/queryHistory.js.map +1 -0
- package/dist/types/types/rename.js +6 -0
- package/dist/types/types/rename.js.map +1 -0
- package/dist/types/types/resourceViewItem.d.ts +1 -1
- package/dist/types/types/resourceViewItem.js +103 -0
- package/dist/types/types/resourceViewItem.js.map +1 -0
- package/dist/types/types/results.js +51 -0
- package/dist/types/types/results.js.map +1 -0
- package/dist/types/types/roles.js +2 -0
- package/dist/types/types/roles.js.map +1 -0
- package/dist/types/types/savedCharts.js +225 -0
- package/dist/types/types/savedCharts.js.map +1 -0
- package/dist/types/types/scheduler.js +87 -0
- package/dist/types/types/scheduler.js.map +1 -0
- package/dist/types/types/schedulerLog.js +2 -0
- package/dist/types/types/schedulerLog.js.map +1 -0
- package/dist/types/types/schedulerTaskList.js +31 -0
- package/dist/types/types/schedulerTaskList.js.map +1 -0
- package/dist/types/types/scopes.js +14 -0
- package/dist/types/types/scopes.js.map +1 -0
- package/dist/types/types/search.js +53 -0
- package/dist/types/types/search.js.map +1 -0
- package/dist/types/types/share.js +2 -0
- package/dist/types/types/share.js.map +1 -0
- package/dist/types/types/slack.js +2 -0
- package/dist/types/types/slack.js.map +1 -0
- package/dist/types/types/slackSettings.js +2 -0
- package/dist/types/types/slackSettings.js.map +1 -0
- package/dist/types/types/space.js +7 -0
- package/dist/types/types/space.js.map +1 -0
- package/dist/types/types/spotlightTableConfig.js +17 -0
- package/dist/types/types/spotlightTableConfig.js.map +1 -0
- package/dist/types/types/sqlRunner.js +41 -0
- package/dist/types/types/sqlRunner.js.map +1 -0
- package/dist/types/types/table.js +6 -0
- package/dist/types/types/table.js.map +1 -0
- package/dist/types/types/tags.js +2 -0
- package/dist/types/types/tags.js.map +1 -0
- package/dist/types/types/timeFrames.js +42 -0
- package/dist/types/types/timeFrames.js.map +1 -0
- package/dist/types/types/timezone.js +33 -0
- package/dist/types/types/timezone.js.map +1 -0
- package/dist/types/types/user.js +23 -0
- package/dist/types/types/user.js.map +1 -0
- package/dist/types/types/userAttributes.js +2 -0
- package/dist/types/types/userAttributes.js.map +1 -0
- package/dist/types/types/userWarehouseCredentials.js +2 -0
- package/dist/types/types/userWarehouseCredentials.js.map +1 -0
- package/dist/types/types/validation.js +29 -0
- package/dist/types/types/validation.js.map +1 -0
- package/dist/types/types/warehouse.js +6 -0
- package/dist/types/types/warehouse.js.map +1 -0
- package/dist/types/types/yamlSchema.js +2 -0
- package/dist/types/types/yamlSchema.js.map +1 -0
- package/dist/types/utils/accessors.js +27 -0
- package/dist/types/utils/accessors.js.map +1 -0
- package/dist/types/utils/accessors.test.js +45 -0
- package/dist/types/utils/accessors.test.js.map +1 -0
- package/dist/types/utils/additionalMetrics.js +54 -0
- package/dist/types/utils/additionalMetrics.js.map +1 -0
- package/dist/types/utils/api.js +5 -0
- package/dist/types/utils/api.js.map +1 -0
- package/dist/types/utils/assertUnreachable.js +10 -0
- package/dist/types/utils/assertUnreachable.js.map +1 -0
- package/dist/types/utils/booleanConverter.js +27 -0
- package/dist/types/utils/booleanConverter.js.map +1 -0
- package/dist/types/utils/booleanConverter.test.js +59 -0
- package/dist/types/utils/booleanConverter.test.js.map +1 -0
- package/dist/types/utils/catalogMetricsTree.js +2 -0
- package/dist/types/utils/catalogMetricsTree.js.map +1 -0
- package/dist/types/utils/changeset.js +132 -0
- package/dist/types/utils/changeset.js.map +1 -0
- package/dist/types/utils/changeset.mock.js +146 -0
- package/dist/types/utils/changeset.mock.js.map +1 -0
- package/dist/types/utils/changeset.test.js +248 -0
- package/dist/types/utils/changeset.test.js.map +1 -0
- package/dist/types/utils/charts.js +74 -0
- package/dist/types/utils/charts.js.map +1 -0
- package/dist/types/utils/colors.js +15 -0
- package/dist/types/utils/colors.js.map +1 -0
- package/dist/types/utils/colors.test.js +85 -0
- package/dist/types/utils/colors.test.js.map +1 -0
- package/dist/types/utils/conditionalFormatting.js +436 -0
- package/dist/types/utils/conditionalFormatting.js.map +1 -0
- package/dist/types/utils/conditionalFormatting.test.js +105 -0
- package/dist/types/utils/conditionalFormatting.test.js.map +1 -0
- package/dist/types/utils/convertCustomDimensionsToYaml.js +115 -0
- package/dist/types/utils/convertCustomDimensionsToYaml.js.map +1 -0
- package/dist/types/utils/convertCustomMetricsToYaml.js +15 -0
- package/dist/types/utils/convertCustomMetricsToYaml.js.map +1 -0
- package/dist/types/utils/customDimensions.js +27 -0
- package/dist/types/utils/customDimensions.js.map +1 -0
- package/dist/types/utils/dashboard.js +35 -0
- package/dist/types/utils/dashboard.js.map +1 -0
- package/dist/types/utils/dashboard.test.js +36 -0
- package/dist/types/utils/dashboard.test.js.map +1 -0
- package/dist/types/utils/dbt.js +4 -0
- package/dist/types/utils/dbt.js.map +1 -0
- package/dist/types/utils/dbt.test.js +39 -0
- package/dist/types/utils/dbt.test.js.map +1 -0
- package/dist/types/utils/dependencyGraph.js +51 -0
- package/dist/types/utils/dependencyGraph.js.map +1 -0
- package/dist/types/utils/dependencyGraph.test.js +113 -0
- package/dist/types/utils/dependencyGraph.test.js.map +1 -0
- package/dist/types/utils/email.js +76 -0
- package/dist/types/utils/email.js.map +1 -0
- package/dist/types/utils/email.test.js +49 -0
- package/dist/types/utils/email.test.js.map +1 -0
- package/dist/types/utils/fields.js +183 -0
- package/dist/types/utils/fields.js.map +1 -0
- package/dist/types/utils/fields.mock.js +150 -0
- package/dist/types/utils/fields.mock.js.map +1 -0
- package/dist/types/utils/fields.test.js +259 -0
- package/dist/types/utils/fields.test.js.map +1 -0
- package/dist/types/utils/filters.js +763 -0
- package/dist/types/utils/filters.js.map +1 -0
- package/dist/types/utils/filters.mock.js +450 -0
- package/dist/types/utils/filters.mock.js.map +1 -0
- package/dist/types/utils/filters.test.js +360 -0
- package/dist/types/utils/filters.test.js.map +1 -0
- package/dist/types/utils/formatting.js +552 -0
- package/dist/types/utils/formatting.js.map +1 -0
- package/dist/types/utils/formatting.mock.js +28 -0
- package/dist/types/utils/formatting.mock.js.map +1 -0
- package/dist/types/utils/formatting.test.js +1047 -0
- package/dist/types/utils/formatting.test.js.map +1 -0
- package/dist/types/utils/github.js +11 -0
- package/dist/types/utils/github.js.map +1 -0
- package/dist/types/utils/i18n/abstract.js +3 -0
- package/dist/types/utils/i18n/abstract.js.map +1 -0
- package/dist/types/utils/i18n/chartAsCode.js +132 -0
- package/dist/types/utils/i18n/chartAsCode.js.map +1 -0
- package/dist/types/utils/i18n/chartAsCode.test.js +350 -0
- package/dist/types/utils/i18n/chartAsCode.test.js.map +1 -0
- package/dist/types/utils/i18n/dashboardAsCode.js +58 -0
- package/dist/types/utils/i18n/dashboardAsCode.js.map +1 -0
- package/dist/types/utils/i18n/index.js +5 -0
- package/dist/types/utils/i18n/index.js.map +1 -0
- package/dist/types/utils/i18n/merge.js +20 -0
- package/dist/types/utils/i18n/merge.js.map +1 -0
- package/dist/types/utils/i18n/types.js +2 -0
- package/dist/types/utils/i18n/types.js.map +1 -0
- package/dist/types/utils/item.js +154 -0
- package/dist/types/utils/item.js.map +1 -0
- package/dist/types/utils/loadLightdashProjectConfig.js +49 -0
- package/dist/types/utils/loadLightdashProjectConfig.js.map +1 -0
- package/dist/types/utils/loadLightdashProjectConfig.mock.js +127 -0
- package/dist/types/utils/loadLightdashProjectConfig.mock.js.map +1 -0
- package/dist/types/utils/loadLightdashProjectConfig.test.js +137 -0
- package/dist/types/utils/loadLightdashProjectConfig.test.js.map +1 -0
- package/dist/types/utils/metricsExplorer.js +365 -0
- package/dist/types/utils/metricsExplorer.js.map +1 -0
- package/dist/types/utils/oauth.js +242 -0
- package/dist/types/utils/oauth.js.map +1 -0
- package/dist/types/utils/organization.js +23 -0
- package/dist/types/utils/organization.js.map +1 -0
- package/dist/types/utils/projectMemberRole.js +85 -0
- package/dist/types/utils/projectMemberRole.js.map +1 -0
- package/dist/types/utils/projectMemberRole.test.js +36 -0
- package/dist/types/utils/projectMemberRole.test.js.map +1 -0
- package/dist/types/utils/promises.js +5 -0
- package/dist/types/utils/promises.js.map +1 -0
- package/dist/types/utils/sanitizeHtml.js +111 -0
- package/dist/types/utils/sanitizeHtml.js.map +1 -0
- package/dist/types/utils/sanitizeHtml.test.js +101 -0
- package/dist/types/utils/sanitizeHtml.test.js.map +1 -0
- package/dist/types/utils/scheduler.js +85 -0
- package/dist/types/utils/scheduler.js.map +1 -0
- package/dist/types/utils/scheduler.test.js +41 -0
- package/dist/types/utils/scheduler.test.js.map +1 -0
- package/dist/types/utils/searchParams.js +8 -0
- package/dist/types/utils/searchParams.js.map +1 -0
- package/dist/types/utils/sleep.js +6 -0
- package/dist/types/utils/sleep.js.map +1 -0
- package/dist/types/utils/slug.test.js +129 -0
- package/dist/types/utils/slug.test.js.map +1 -0
- package/dist/types/utils/slugs.js +55 -0
- package/dist/types/utils/slugs.js.map +1 -0
- package/dist/types/utils/subtotals.js +4 -0
- package/dist/types/utils/subtotals.js.map +1 -0
- package/dist/types/utils/time.js +25 -0
- package/dist/types/utils/time.js.map +1 -0
- package/dist/types/utils/timeFrames.js +529 -0
- package/dist/types/utils/timeFrames.js.map +1 -0
- package/dist/types/utils/timeFrames.test.js +50 -0
- package/dist/types/utils/timeFrames.test.js.map +1 -0
- package/dist/types/utils/virtualView.js +98 -0
- package/dist/types/utils/virtualView.js.map +1 -0
- package/dist/types/utils/warehouse.js +57 -0
- package/dist/types/utils/warehouse.js.map +1 -0
- package/dist/types/visualizations/CartesianChartDataModel.js +515 -0
- package/dist/types/visualizations/CartesianChartDataModel.js.map +1 -0
- package/dist/types/visualizations/PieChartDataModel.js +258 -0
- package/dist/types/visualizations/PieChartDataModel.js.map +1 -0
- package/dist/types/visualizations/TableDataModel.js +96 -0
- package/dist/types/visualizations/TableDataModel.js.map +1 -0
- package/dist/types/visualizations/chartTransformations.js +107 -0
- package/dist/types/visualizations/chartTransformations.js.map +1 -0
- package/dist/types/visualizations/helpers/getCartesianAxisFormatterConfig.js +142 -0
- package/dist/types/visualizations/helpers/getCartesianAxisFormatterConfig.js.map +1 -0
- package/dist/types/visualizations/types/IResultsRunner.js +2 -0
- package/dist/types/visualizations/types/IResultsRunner.js.map +1 -0
- package/dist/types/visualizations/types/index.js +78 -0
- package/dist/types/visualizations/types/index.js.map +1 -0
- package/package.json +1 -1
- package/dist/tsconfig.types.tsbuildinfo +0 -1
|
@@ -0,0 +1,1034 @@
|
|
|
1
|
+
import isNumber from 'lodash/isNumber';
|
|
2
|
+
import last from 'lodash/last';
|
|
3
|
+
import { UnexpectedIndexError, UnexpectedServerError } from '../types/errors';
|
|
4
|
+
import { FieldType, isDimension, isField, isSummable, } from '../types/field';
|
|
5
|
+
import { getArrayValue, getObjectValue } from '../utils/accessors';
|
|
6
|
+
import { formatItemValue } from '../utils/formatting';
|
|
7
|
+
const isRecursiveRecord = (value) => typeof value === 'object' && value !== null;
|
|
8
|
+
const create2DArray = (rows, columns, value = null) => Array.from({ length: rows }, () => Array.from({ length: columns }, () => value));
|
|
9
|
+
const parseNumericValue = (value) => {
|
|
10
|
+
if (value === null)
|
|
11
|
+
return 0;
|
|
12
|
+
const parsedVal = Number(value.raw);
|
|
13
|
+
return Number.isNaN(parsedVal) ? 0 : parsedVal;
|
|
14
|
+
};
|
|
15
|
+
const setIndexByKey = (obj, keys, value) => {
|
|
16
|
+
if (keys.length === 0) {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
const [key, ...rest] = keys;
|
|
20
|
+
if (key === undefined) {
|
|
21
|
+
throw new UnexpectedIndexError(`setIndexByKey: Cannot get key from keys ${keys.length}`);
|
|
22
|
+
}
|
|
23
|
+
if (rest.length === 0) {
|
|
24
|
+
if (obj[key] === undefined) {
|
|
25
|
+
// eslint-disable-next-line no-param-reassign
|
|
26
|
+
obj[key] = value;
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
if (obj[key] === undefined) {
|
|
32
|
+
// eslint-disable-next-line no-param-reassign
|
|
33
|
+
obj[key] = {};
|
|
34
|
+
}
|
|
35
|
+
const nextObject = obj[key];
|
|
36
|
+
if (!isRecursiveRecord(nextObject)) {
|
|
37
|
+
throw new Error('Cannot set key on non-object');
|
|
38
|
+
}
|
|
39
|
+
return setIndexByKey(nextObject, rest, value);
|
|
40
|
+
};
|
|
41
|
+
const getIndexByKey = (obj, keys) => {
|
|
42
|
+
if (keys.length === 0) {
|
|
43
|
+
throw new Error('Cannot get key from empty keys array');
|
|
44
|
+
}
|
|
45
|
+
const [key, ...rest] = keys;
|
|
46
|
+
if (key === undefined) {
|
|
47
|
+
throw new UnexpectedServerError(`getIndexByKey: Cannot get key from keys ${keys.length}`);
|
|
48
|
+
}
|
|
49
|
+
if (rest.length === 0) {
|
|
50
|
+
const value = obj[key];
|
|
51
|
+
if (typeof value !== 'number') {
|
|
52
|
+
throw new Error('Expected a number');
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
return value;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
const nextObj = obj[key];
|
|
60
|
+
if (isRecursiveRecord(nextObj)) {
|
|
61
|
+
return getIndexByKey(nextObj, rest);
|
|
62
|
+
}
|
|
63
|
+
throw new Error('Expected a RecursiveRecord object');
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
const getAllIndicesForFieldId = (obj, fieldId) => {
|
|
67
|
+
const entries = Object.entries(obj);
|
|
68
|
+
return entries.reduce((acc, [key, value]) => {
|
|
69
|
+
if (key === fieldId && isNumber(value)) {
|
|
70
|
+
return [...acc, value];
|
|
71
|
+
}
|
|
72
|
+
if (isRecursiveRecord(value)) {
|
|
73
|
+
return [...acc, ...getAllIndicesForFieldId(value, fieldId)];
|
|
74
|
+
}
|
|
75
|
+
return acc;
|
|
76
|
+
}, []);
|
|
77
|
+
};
|
|
78
|
+
const getAllIndices = (obj) => Object.values(obj).reduce((acc, value) => {
|
|
79
|
+
if (isNumber(value)) {
|
|
80
|
+
return [...acc, value];
|
|
81
|
+
}
|
|
82
|
+
return [...acc, ...getAllIndices(value)];
|
|
83
|
+
}, []);
|
|
84
|
+
const getAllIndicesByKey = (obj, keys) => {
|
|
85
|
+
const [key, ...rest] = keys;
|
|
86
|
+
if (key === undefined) {
|
|
87
|
+
throw new UnexpectedIndexError('Cannot set key on undefined');
|
|
88
|
+
}
|
|
89
|
+
if (rest.length === 0) {
|
|
90
|
+
const value = getObjectValue(obj, key);
|
|
91
|
+
if (isNumber(value)) {
|
|
92
|
+
return [value];
|
|
93
|
+
}
|
|
94
|
+
return getAllIndices(value);
|
|
95
|
+
}
|
|
96
|
+
const nextObj = obj[key];
|
|
97
|
+
if (isRecursiveRecord(nextObj)) {
|
|
98
|
+
return getAllIndicesByKey(nextObj, rest);
|
|
99
|
+
}
|
|
100
|
+
throw new Error('Expected a RecursiveRecord object');
|
|
101
|
+
};
|
|
102
|
+
const getColSpanByKey = (currentColumnPosition, obj, keys) => {
|
|
103
|
+
const allIndices = getAllIndicesByKey(obj, keys).sort((a, b) => a - b);
|
|
104
|
+
if (allIndices.length === 0) {
|
|
105
|
+
throw new Error('Cannot get span from empty indices array');
|
|
106
|
+
}
|
|
107
|
+
const currentColumnPositionIndex = allIndices.indexOf(currentColumnPosition);
|
|
108
|
+
const previousColumnPosition = allIndices[currentColumnPositionIndex - 1];
|
|
109
|
+
if (currentColumnPositionIndex < 0) {
|
|
110
|
+
throw new Error('Cannot get span for index that does not exist in indices array');
|
|
111
|
+
}
|
|
112
|
+
const isFirstColInSpan = !isNumber(previousColumnPosition) ||
|
|
113
|
+
previousColumnPosition !== currentColumnPosition - 1;
|
|
114
|
+
if (!isFirstColInSpan) {
|
|
115
|
+
return 0;
|
|
116
|
+
}
|
|
117
|
+
return allIndices
|
|
118
|
+
.slice(currentColumnPositionIndex)
|
|
119
|
+
.reduce((acc, curr, i) => {
|
|
120
|
+
if (curr === currentColumnPosition + i) {
|
|
121
|
+
return acc + 1;
|
|
122
|
+
}
|
|
123
|
+
return acc;
|
|
124
|
+
}, 0);
|
|
125
|
+
};
|
|
126
|
+
const combinedRetrofit = (data, getField, getFieldLabel) => {
|
|
127
|
+
const indexValues = data.indexValues.length ? data.indexValues : [[]];
|
|
128
|
+
const baseIdInfo = last(data.headerValues);
|
|
129
|
+
if (data.headerValues[0] === undefined) {
|
|
130
|
+
throw new UnexpectedIndexError('combinedRetrofit: Cannot get header values');
|
|
131
|
+
}
|
|
132
|
+
const uniqueIdsForDataValueColumns = Array(getArrayValue(data.headerValues, 0).length);
|
|
133
|
+
data.headerValues.forEach((headerRow) => {
|
|
134
|
+
headerRow.forEach((headerColValue, colIndex) => {
|
|
135
|
+
uniqueIdsForDataValueColumns[colIndex] = `${(uniqueIdsForDataValueColumns[colIndex] ?? '') +
|
|
136
|
+
headerColValue.fieldId}__`;
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
const getMetricAsRowTotalValueFromAxis = (total, rowIndex) => {
|
|
140
|
+
const value = last(data.indexValues[rowIndex]);
|
|
141
|
+
if (!value || !value.fieldId)
|
|
142
|
+
throw new Error('Invalid pivot data');
|
|
143
|
+
const item = getField(value.fieldId);
|
|
144
|
+
if (!isSummable(item)) {
|
|
145
|
+
return null;
|
|
146
|
+
}
|
|
147
|
+
const formattedValue = formatItemValue(item, total);
|
|
148
|
+
return {
|
|
149
|
+
raw: total,
|
|
150
|
+
formatted: formattedValue,
|
|
151
|
+
};
|
|
152
|
+
};
|
|
153
|
+
const getRowTotalValueFromAxis = (field, total) => {
|
|
154
|
+
if (!field || !field.fieldId)
|
|
155
|
+
throw new Error('Invalid pivot data');
|
|
156
|
+
const item = getField(field.fieldId);
|
|
157
|
+
const formattedValue = formatItemValue(item, total);
|
|
158
|
+
return {
|
|
159
|
+
raw: total,
|
|
160
|
+
formatted: formattedValue,
|
|
161
|
+
};
|
|
162
|
+
};
|
|
163
|
+
let pivotColumnInfo = [];
|
|
164
|
+
const allCombinedData = indexValues.map((row, rowIndex) => {
|
|
165
|
+
const newRow = row.map((cell, colIndex) => {
|
|
166
|
+
if (cell.type === 'label') {
|
|
167
|
+
const cellValue = getFieldLabel(cell.fieldId);
|
|
168
|
+
return {
|
|
169
|
+
...cell,
|
|
170
|
+
fieldId: `label-${colIndex}`,
|
|
171
|
+
value: {
|
|
172
|
+
raw: cellValue,
|
|
173
|
+
formatted: cellValue,
|
|
174
|
+
},
|
|
175
|
+
columnType: 'label',
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
return {
|
|
179
|
+
...cell,
|
|
180
|
+
columnType: 'indexValue',
|
|
181
|
+
};
|
|
182
|
+
});
|
|
183
|
+
const remappedDataValues = getArrayValue(data.dataValues, rowIndex).map((dataValue, colIndex) => {
|
|
184
|
+
const baseIdInfoForCol = baseIdInfo
|
|
185
|
+
? baseIdInfo[colIndex]
|
|
186
|
+
: undefined;
|
|
187
|
+
const baseId = baseIdInfoForCol?.fieldId;
|
|
188
|
+
const id = getArrayValue(uniqueIdsForDataValueColumns, colIndex) +
|
|
189
|
+
colIndex;
|
|
190
|
+
return {
|
|
191
|
+
baseId,
|
|
192
|
+
fieldId: id,
|
|
193
|
+
value: dataValue || {},
|
|
194
|
+
};
|
|
195
|
+
});
|
|
196
|
+
const remappedRowTotals = data.rowTotals?.[rowIndex]?.map((total, colIndex) => {
|
|
197
|
+
const baseId = `row-total-${colIndex}`;
|
|
198
|
+
const id = baseId;
|
|
199
|
+
const underlyingData = last(data.rowTotalFields)?.[colIndex];
|
|
200
|
+
const value = data.pivotConfig.metricsAsRows
|
|
201
|
+
? getMetricAsRowTotalValueFromAxis(total, rowIndex)
|
|
202
|
+
: getRowTotalValueFromAxis(underlyingData, total);
|
|
203
|
+
const underlyingId = data.pivotConfig.metricsAsRows
|
|
204
|
+
? undefined
|
|
205
|
+
: underlyingData?.fieldId;
|
|
206
|
+
return {
|
|
207
|
+
baseId,
|
|
208
|
+
fieldId: id,
|
|
209
|
+
underlyingId,
|
|
210
|
+
value,
|
|
211
|
+
columnType: 'rowTotal',
|
|
212
|
+
};
|
|
213
|
+
});
|
|
214
|
+
const entireRow = [
|
|
215
|
+
...newRow,
|
|
216
|
+
...remappedDataValues,
|
|
217
|
+
...(remappedRowTotals || []),
|
|
218
|
+
];
|
|
219
|
+
if (rowIndex === 0) {
|
|
220
|
+
pivotColumnInfo = entireRow.map((cell) => ({
|
|
221
|
+
fieldId: cell.fieldId,
|
|
222
|
+
baseId: 'baseId' in cell ? cell.baseId : undefined,
|
|
223
|
+
underlyingId: 'underlyingId' in cell ? cell.underlyingId : undefined,
|
|
224
|
+
columnType: 'columnType' in cell ? cell.columnType : undefined,
|
|
225
|
+
}));
|
|
226
|
+
}
|
|
227
|
+
const altRow = {};
|
|
228
|
+
entireRow.forEach((cell) => {
|
|
229
|
+
const val = cell.value;
|
|
230
|
+
if (val && 'formatted' in val && val.formatted !== undefined) {
|
|
231
|
+
altRow[cell.fieldId] = {
|
|
232
|
+
value: {
|
|
233
|
+
raw: val.raw,
|
|
234
|
+
formatted: val.formatted,
|
|
235
|
+
},
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
return altRow;
|
|
240
|
+
});
|
|
241
|
+
// eslint-disable-next-line no-param-reassign
|
|
242
|
+
data.retrofitData = { allCombinedData, pivotColumnInfo };
|
|
243
|
+
return data;
|
|
244
|
+
};
|
|
245
|
+
const getHeaderValueTypes = ({ metricsAsRows, pivotDimensionNames, }) => {
|
|
246
|
+
const headerDimensionValueTypes = pivotDimensionNames.map((fieldId) => ({
|
|
247
|
+
type: FieldType.DIMENSION,
|
|
248
|
+
fieldId,
|
|
249
|
+
}));
|
|
250
|
+
const headerMetricValueTypes = metricsAsRows
|
|
251
|
+
? []
|
|
252
|
+
: [{ type: FieldType.METRIC }];
|
|
253
|
+
return [...headerDimensionValueTypes, ...headerMetricValueTypes];
|
|
254
|
+
};
|
|
255
|
+
const getColumnTotals = ({ summableMetricFieldIds, rowIndices, totalColumns, dataColumns, dataValues, hasIndex, pivotConfig, indexValues, }) => {
|
|
256
|
+
let columnTotalFields;
|
|
257
|
+
let columnTotals;
|
|
258
|
+
const N_DATA_COLUMNS = dataColumns;
|
|
259
|
+
if (pivotConfig.columnTotals && hasIndex) {
|
|
260
|
+
if (pivotConfig.metricsAsRows) {
|
|
261
|
+
const N_TOTAL_ROWS = summableMetricFieldIds.length;
|
|
262
|
+
const N_TOTAL_COLS = totalColumns;
|
|
263
|
+
columnTotalFields = create2DArray(N_TOTAL_ROWS, N_TOTAL_COLS);
|
|
264
|
+
columnTotals = create2DArray(N_TOTAL_ROWS, N_DATA_COLUMNS);
|
|
265
|
+
summableMetricFieldIds.forEach((fieldId, metricIndex) => {
|
|
266
|
+
columnTotalFields[metricIndex][N_TOTAL_COLS - 1] = {
|
|
267
|
+
fieldId,
|
|
268
|
+
};
|
|
269
|
+
});
|
|
270
|
+
columnTotals = columnTotals.map((row, rowIndex) => row.map((_, totalColIndex) => {
|
|
271
|
+
const totalColFieldId = columnTotalFields[rowIndex][N_TOTAL_COLS - 1]?.fieldId;
|
|
272
|
+
const valueColIndices = totalColFieldId
|
|
273
|
+
? getAllIndicesForFieldId(rowIndices, totalColFieldId)
|
|
274
|
+
: [];
|
|
275
|
+
return dataValues
|
|
276
|
+
.filter((__, dataValueColIndex) => valueColIndices.includes(dataValueColIndex))
|
|
277
|
+
.reduce((acc, value) => acc + parseNumericValue(value[totalColIndex]), 0);
|
|
278
|
+
}));
|
|
279
|
+
}
|
|
280
|
+
else {
|
|
281
|
+
const N_TOTAL_COLS = indexValues[0].length;
|
|
282
|
+
const N_TOTAL_ROWS = 1;
|
|
283
|
+
columnTotalFields = create2DArray(N_TOTAL_ROWS, N_TOTAL_COLS);
|
|
284
|
+
columnTotals = create2DArray(N_TOTAL_ROWS, N_DATA_COLUMNS);
|
|
285
|
+
// set the last index cell as the "Total"
|
|
286
|
+
columnTotalFields[N_TOTAL_ROWS - 1][N_TOTAL_COLS - 1] = {
|
|
287
|
+
fieldId: undefined,
|
|
288
|
+
};
|
|
289
|
+
columnTotals = columnTotals.map((row, _totalRowIndex) => row.map((_col, colIndex) => dataValues
|
|
290
|
+
.map((dataRow) => dataRow[colIndex])
|
|
291
|
+
.reduce((acc, value) => acc + parseNumericValue(value), 0)));
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
return { columnTotalFields, columnTotals };
|
|
295
|
+
};
|
|
296
|
+
const getTitleFields = ({ hasHeader, hasIndex, headerValueTypes, indexValueTypes, }) => {
|
|
297
|
+
const titleFields = create2DArray(hasHeader ? headerValueTypes.length : 1, hasIndex ? indexValueTypes.length : 1);
|
|
298
|
+
headerValueTypes.forEach((headerValueType, headerIndex) => {
|
|
299
|
+
if (headerValueType.type === FieldType.DIMENSION) {
|
|
300
|
+
titleFields[headerIndex][hasIndex ? indexValueTypes.length - 1 : 0] = {
|
|
301
|
+
fieldId: headerValueType.fieldId,
|
|
302
|
+
direction: 'header',
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
});
|
|
306
|
+
indexValueTypes.forEach((indexValueType, indexIndex) => {
|
|
307
|
+
if (indexValueType.type === FieldType.DIMENSION) {
|
|
308
|
+
titleFields[hasHeader ? headerValueTypes.length - 1 : 0][indexIndex] = {
|
|
309
|
+
fieldId: indexValueType.fieldId,
|
|
310
|
+
direction: 'index',
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
});
|
|
314
|
+
return titleFields;
|
|
315
|
+
};
|
|
316
|
+
export const pivotQueryResults = ({ pivotConfig, metricQuery, rows, options, getField, getFieldLabel, groupedSubtotals, }) => {
|
|
317
|
+
if (rows.length === 0) {
|
|
318
|
+
throw new Error('Cannot pivot results with no rows');
|
|
319
|
+
}
|
|
320
|
+
const hiddenMetricFieldIds = pivotConfig.hiddenMetricFieldIds || [];
|
|
321
|
+
const summableMetricFieldIds = metricQuery.metrics.filter((metricId) => {
|
|
322
|
+
const field = getField(metricId);
|
|
323
|
+
// Skip if field is not found or is a dimension or is hidden
|
|
324
|
+
if (!field || isDimension(field))
|
|
325
|
+
return false;
|
|
326
|
+
if (hiddenMetricFieldIds.includes(metricId))
|
|
327
|
+
return false;
|
|
328
|
+
return isSummable(field);
|
|
329
|
+
});
|
|
330
|
+
const columnOrder = (pivotConfig.columnOrder || []).filter((id) => !hiddenMetricFieldIds.includes(id));
|
|
331
|
+
const dimensions = [...metricQuery.dimensions];
|
|
332
|
+
// Headers (column index)
|
|
333
|
+
const headerDimensions = pivotConfig.pivotDimensions.filter((pivotDimension) => dimensions.includes(pivotDimension));
|
|
334
|
+
const headerValueTypes = getHeaderValueTypes({
|
|
335
|
+
metricsAsRows: pivotConfig.metricsAsRows,
|
|
336
|
+
pivotDimensionNames: headerDimensions,
|
|
337
|
+
});
|
|
338
|
+
// Indices (row index)
|
|
339
|
+
const indexDimensions = dimensions
|
|
340
|
+
.filter((d) => !pivotConfig.pivotDimensions.includes(d))
|
|
341
|
+
.slice()
|
|
342
|
+
.sort((a, b) => columnOrder.indexOf(a) - columnOrder.indexOf(b));
|
|
343
|
+
const indexDimensionValueTypes = indexDimensions.map((d) => ({
|
|
344
|
+
type: FieldType.DIMENSION,
|
|
345
|
+
fieldId: d,
|
|
346
|
+
}));
|
|
347
|
+
const indexMetricValueTypes = pivotConfig.metricsAsRows ? [{ type: FieldType.METRIC }] : [];
|
|
348
|
+
const indexValueTypes = [
|
|
349
|
+
...indexDimensionValueTypes,
|
|
350
|
+
...indexMetricValueTypes,
|
|
351
|
+
];
|
|
352
|
+
// Metrics
|
|
353
|
+
const metrics = [
|
|
354
|
+
...metricQuery.metrics,
|
|
355
|
+
...metricQuery.tableCalculations.map((tc) => tc.name),
|
|
356
|
+
]
|
|
357
|
+
.filter((m) => !hiddenMetricFieldIds.includes(m))
|
|
358
|
+
.sort((a, b) => columnOrder.indexOf(a) - columnOrder.indexOf(b))
|
|
359
|
+
.map((id) => ({ fieldId: id }));
|
|
360
|
+
if (metrics.length === 0) {
|
|
361
|
+
throw new Error('Cannot pivot results with no metrics');
|
|
362
|
+
}
|
|
363
|
+
const N_ROWS = rows.length;
|
|
364
|
+
// For every row in the results, compute the index and header values to determine the shape of the result set
|
|
365
|
+
const indexValues = [];
|
|
366
|
+
const headerValuesT = [];
|
|
367
|
+
const rowIndices = {};
|
|
368
|
+
const columnIndices = {};
|
|
369
|
+
let rowCount = 0;
|
|
370
|
+
let columnCount = 0;
|
|
371
|
+
for (let nRow = 0; nRow < N_ROWS; nRow += 1) {
|
|
372
|
+
const row = rows[nRow];
|
|
373
|
+
for (let nMetric = 0; nMetric < metrics.length; nMetric += 1) {
|
|
374
|
+
const indexRowValues = indexDimensions
|
|
375
|
+
.map((fieldId) => ({
|
|
376
|
+
type: 'value',
|
|
377
|
+
fieldId,
|
|
378
|
+
value: getObjectValue(row, fieldId).value,
|
|
379
|
+
colSpan: 1,
|
|
380
|
+
}))
|
|
381
|
+
.concat(pivotConfig.metricsAsRows
|
|
382
|
+
? [
|
|
383
|
+
{
|
|
384
|
+
type: 'label',
|
|
385
|
+
fieldId: getArrayValue(metrics, nMetric)
|
|
386
|
+
.fieldId,
|
|
387
|
+
},
|
|
388
|
+
]
|
|
389
|
+
: []);
|
|
390
|
+
const headerRowValues = headerDimensions
|
|
391
|
+
.map((fieldId) => ({
|
|
392
|
+
type: 'value',
|
|
393
|
+
fieldId,
|
|
394
|
+
value: getObjectValue(row, fieldId).value,
|
|
395
|
+
colSpan: 1,
|
|
396
|
+
}))
|
|
397
|
+
.concat(pivotConfig.metricsAsRows
|
|
398
|
+
? []
|
|
399
|
+
: [
|
|
400
|
+
{
|
|
401
|
+
type: 'label',
|
|
402
|
+
fieldId: getArrayValue(metrics, nMetric)
|
|
403
|
+
.fieldId,
|
|
404
|
+
},
|
|
405
|
+
]);
|
|
406
|
+
// Write the index values
|
|
407
|
+
if (setIndexByKey(rowIndices, indexRowValues.map((l) => l.type === 'value' ? String(l.value?.raw) : l.fieldId), rowCount)) {
|
|
408
|
+
rowCount += 1;
|
|
409
|
+
indexValues.push(indexRowValues);
|
|
410
|
+
}
|
|
411
|
+
// Write the header values
|
|
412
|
+
if (setIndexByKey(columnIndices, headerRowValues.map((l) => l.type === 'value' ? String(l.value.raw) : l.fieldId), columnCount)) {
|
|
413
|
+
columnCount += 1;
|
|
414
|
+
if (columnCount > options.maxColumns) {
|
|
415
|
+
throw new Error(`Cannot pivot results with more than ${options.maxColumns} columns. Try adding a filter to limit your results.`);
|
|
416
|
+
}
|
|
417
|
+
headerValuesT.push(headerRowValues);
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
const headerValues = headerValuesT[0]?.map((_, colIndex) => headerValuesT.map((row, rowIndex) => {
|
|
422
|
+
const cell = getArrayValue(row, colIndex);
|
|
423
|
+
if (cell.type === 'label') {
|
|
424
|
+
return cell;
|
|
425
|
+
}
|
|
426
|
+
const keys = row
|
|
427
|
+
.slice(0, colIndex + 1)
|
|
428
|
+
.reduce((acc, l) => l.type === 'value'
|
|
429
|
+
? [...acc, String(l.value.raw)]
|
|
430
|
+
: acc, []);
|
|
431
|
+
const cellWithSpan = {
|
|
432
|
+
...cell,
|
|
433
|
+
colSpan: getColSpanByKey(rowIndex, columnIndices, keys),
|
|
434
|
+
};
|
|
435
|
+
return cellWithSpan;
|
|
436
|
+
})) ?? [];
|
|
437
|
+
const hasIndex = indexValueTypes.length > 0;
|
|
438
|
+
const hasHeader = headerValueTypes.length > 0;
|
|
439
|
+
// Compute the size of the data values
|
|
440
|
+
const N_DATA_ROWS = hasIndex ? rowCount : 1;
|
|
441
|
+
const N_DATA_COLUMNS = hasHeader ? columnCount : 1;
|
|
442
|
+
// Compute the data values
|
|
443
|
+
const dataValues = create2DArray(N_DATA_ROWS, N_DATA_COLUMNS);
|
|
444
|
+
if (N_DATA_ROWS === 0 || N_DATA_COLUMNS === 0) {
|
|
445
|
+
throw new Error('Cannot pivot results with no data');
|
|
446
|
+
}
|
|
447
|
+
// Compute pivoted data
|
|
448
|
+
for (let nRow = 0; nRow < N_ROWS; nRow += 1) {
|
|
449
|
+
const row = rows[nRow];
|
|
450
|
+
for (let nMetric = 0; nMetric < metrics.length; nMetric += 1) {
|
|
451
|
+
const metric = metrics[nMetric];
|
|
452
|
+
const { value } = row?.[metric.fieldId] ?? {};
|
|
453
|
+
const rowKeys = [
|
|
454
|
+
...indexDimensions.map((d) => row[d].value.raw),
|
|
455
|
+
...(pivotConfig.metricsAsRows ? [metric.fieldId] : []),
|
|
456
|
+
];
|
|
457
|
+
const columnKeys = [
|
|
458
|
+
...headerDimensions.map((d) => row[d].value.raw),
|
|
459
|
+
...(pivotConfig.metricsAsRows ? [] : [metric.fieldId]),
|
|
460
|
+
];
|
|
461
|
+
const rowKeysString = rowKeys.map(String);
|
|
462
|
+
const columnKeysString = columnKeys.map(String);
|
|
463
|
+
const rowIndex = hasIndex
|
|
464
|
+
? getIndexByKey(rowIndices, rowKeysString)
|
|
465
|
+
: 0;
|
|
466
|
+
const columnIndex = hasHeader
|
|
467
|
+
? getIndexByKey(columnIndices, columnKeysString)
|
|
468
|
+
: 0;
|
|
469
|
+
dataValues[rowIndex][columnIndex] = value;
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
// compute row totals
|
|
473
|
+
let rowTotalFields;
|
|
474
|
+
let rowTotals;
|
|
475
|
+
if (pivotConfig.rowTotals && hasHeader) {
|
|
476
|
+
if (pivotConfig.metricsAsRows) {
|
|
477
|
+
const N_TOTAL_COLS = 1;
|
|
478
|
+
const N_TOTAL_ROWS = headerValues.length;
|
|
479
|
+
rowTotalFields = create2DArray(N_TOTAL_ROWS, N_TOTAL_COLS);
|
|
480
|
+
rowTotals = create2DArray(N_DATA_ROWS, N_TOTAL_COLS);
|
|
481
|
+
// set the last header cell as the "Total"
|
|
482
|
+
rowTotalFields[N_TOTAL_ROWS - 1][N_TOTAL_COLS - 1] = {
|
|
483
|
+
fieldId: undefined,
|
|
484
|
+
};
|
|
485
|
+
rowTotals = rowTotals.map((row, rowIndex) => row.map(() => dataValues[rowIndex].reduce((acc, value) => acc + parseNumericValue(value), 0)));
|
|
486
|
+
}
|
|
487
|
+
else {
|
|
488
|
+
const N_TOTAL_COLS = summableMetricFieldIds.length;
|
|
489
|
+
const N_TOTAL_ROWS = headerValues.length;
|
|
490
|
+
rowTotalFields = create2DArray(N_TOTAL_ROWS, N_TOTAL_COLS);
|
|
491
|
+
rowTotals = create2DArray(N_DATA_ROWS, N_TOTAL_COLS);
|
|
492
|
+
summableMetricFieldIds.forEach((fieldId, metricIndex) => {
|
|
493
|
+
rowTotalFields[N_TOTAL_ROWS - 1][metricIndex] = {
|
|
494
|
+
fieldId,
|
|
495
|
+
};
|
|
496
|
+
});
|
|
497
|
+
rowTotals = rowTotals.map((row, rowIndex) => row.map((_, totalColIndex) => {
|
|
498
|
+
const totalColFieldId = rowTotalFields[N_TOTAL_ROWS - 1][totalColIndex]
|
|
499
|
+
?.fieldId;
|
|
500
|
+
const valueColIndices = totalColFieldId
|
|
501
|
+
? getAllIndicesForFieldId(columnIndices, totalColFieldId)
|
|
502
|
+
: [];
|
|
503
|
+
return dataValues[rowIndex]
|
|
504
|
+
.filter((__, dataValueColIndex) => valueColIndices.includes(dataValueColIndex))
|
|
505
|
+
.reduce((acc, value) => acc + parseNumericValue(value), 0);
|
|
506
|
+
}));
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
const { columnTotalFields, columnTotals } = getColumnTotals({
|
|
510
|
+
summableMetricFieldIds,
|
|
511
|
+
totalColumns: indexValueTypes.length,
|
|
512
|
+
dataColumns: N_DATA_COLUMNS,
|
|
513
|
+
dataValues,
|
|
514
|
+
rowIndices,
|
|
515
|
+
pivotConfig,
|
|
516
|
+
indexValues,
|
|
517
|
+
hasIndex,
|
|
518
|
+
});
|
|
519
|
+
const titleFields = getTitleFields({
|
|
520
|
+
hasIndex,
|
|
521
|
+
hasHeader,
|
|
522
|
+
headerValueTypes,
|
|
523
|
+
indexValueTypes,
|
|
524
|
+
});
|
|
525
|
+
const cellsCount = (indexValueTypes.length === 0 ? titleFields[0].length : 0) +
|
|
526
|
+
indexValueTypes.length +
|
|
527
|
+
dataValues[0].length +
|
|
528
|
+
(pivotConfig.rowTotals && rowTotals ? rowTotals[0].length : 0);
|
|
529
|
+
const rowsCount = dataValues.length || 0;
|
|
530
|
+
const pivotData = {
|
|
531
|
+
titleFields,
|
|
532
|
+
headerValueTypes,
|
|
533
|
+
headerValues,
|
|
534
|
+
indexValueTypes,
|
|
535
|
+
indexValues,
|
|
536
|
+
dataColumnCount: N_DATA_COLUMNS,
|
|
537
|
+
dataValues,
|
|
538
|
+
rowTotalFields,
|
|
539
|
+
columnTotalFields,
|
|
540
|
+
rowTotals,
|
|
541
|
+
columnTotals,
|
|
542
|
+
cellsCount,
|
|
543
|
+
rowsCount,
|
|
544
|
+
pivotConfig,
|
|
545
|
+
retrofitData: {
|
|
546
|
+
allCombinedData: [],
|
|
547
|
+
pivotColumnInfo: [],
|
|
548
|
+
},
|
|
549
|
+
groupedSubtotals,
|
|
550
|
+
};
|
|
551
|
+
return combinedRetrofit(pivotData, getField, getFieldLabel);
|
|
552
|
+
};
|
|
553
|
+
/**
|
|
554
|
+
* Converts SQL-pivoted results to PivotData format
|
|
555
|
+
* This handles results that are already pivoted at the SQL level (e.g., payments_total_revenue_any_bank_transfer)
|
|
556
|
+
* and transforms them into the same PivotData structure as pivotQueryResults
|
|
557
|
+
*/
|
|
558
|
+
export const convertSqlPivotedRowsToPivotData = ({ rows, pivotDetails, pivotConfig, getField, getFieldLabel, groupedSubtotals, }) => {
|
|
559
|
+
if (rows.length === 0) {
|
|
560
|
+
throw new Error('Cannot convert SQL pivoted results with no rows');
|
|
561
|
+
}
|
|
562
|
+
const hiddenMetricFieldIds = pivotConfig.hiddenMetricFieldIds || [];
|
|
563
|
+
const columnOrder = pivotConfig.columnOrder || [];
|
|
564
|
+
// Extract information from pivot details metadata
|
|
565
|
+
let indexColumns;
|
|
566
|
+
if (pivotDetails.indexColumn) {
|
|
567
|
+
if (Array.isArray(pivotDetails.indexColumn)) {
|
|
568
|
+
indexColumns = pivotDetails.indexColumn
|
|
569
|
+
.map((col) => col.reference)
|
|
570
|
+
.sort((a, b) => columnOrder.indexOf(a) - columnOrder.indexOf(b));
|
|
571
|
+
}
|
|
572
|
+
else {
|
|
573
|
+
indexColumns = [pivotDetails.indexColumn.reference];
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
else {
|
|
577
|
+
indexColumns = [];
|
|
578
|
+
}
|
|
579
|
+
const filteredValuesColumns = pivotDetails.valuesColumns.filter(({ referenceField }) => !hiddenMetricFieldIds.includes(referenceField));
|
|
580
|
+
// Get unique base metrics from valuesColumns
|
|
581
|
+
const baseMetricsArray = Array.from(new Set(filteredValuesColumns.map((col) => col.referenceField)));
|
|
582
|
+
const headerValueTypes = getHeaderValueTypes({
|
|
583
|
+
metricsAsRows: pivotConfig.metricsAsRows,
|
|
584
|
+
pivotDimensionNames: (pivotDetails.groupByColumns ?? []).map(({ reference }) => reference),
|
|
585
|
+
});
|
|
586
|
+
const indexValueTypes = pivotConfig.metricsAsRows
|
|
587
|
+
? [
|
|
588
|
+
...indexColumns.map((col) => ({
|
|
589
|
+
type: FieldType.DIMENSION,
|
|
590
|
+
fieldId: col,
|
|
591
|
+
})),
|
|
592
|
+
{ type: FieldType.METRIC },
|
|
593
|
+
]
|
|
594
|
+
: indexColumns.map((col) => ({
|
|
595
|
+
type: FieldType.DIMENSION,
|
|
596
|
+
fieldId: col,
|
|
597
|
+
}));
|
|
598
|
+
// Build header values (pivot dimension values)
|
|
599
|
+
const headerValues = [];
|
|
600
|
+
pivotDetails.groupByColumns?.forEach(({ reference }, index) => {
|
|
601
|
+
headerValues.push([]);
|
|
602
|
+
let columns = filteredValuesColumns;
|
|
603
|
+
if (pivotConfig.metricsAsRows) {
|
|
604
|
+
// For metrics as rows, we only need unique combinations of pivot values, excluding per metric duplicates
|
|
605
|
+
columns = Array.from(new Map(columns.map((col) => [
|
|
606
|
+
col.pivotValues
|
|
607
|
+
.map(({ referenceField, value }) => `${referenceField}:${value}`)
|
|
608
|
+
.join('|'),
|
|
609
|
+
col,
|
|
610
|
+
])).values());
|
|
611
|
+
}
|
|
612
|
+
columns.forEach(({ pivotValues, pivotColumnName }) => {
|
|
613
|
+
const pivotValue = pivotValues.find(({ referenceField }) => referenceField === reference);
|
|
614
|
+
if (pivotValue) {
|
|
615
|
+
const field = getField(pivotValue.referenceField);
|
|
616
|
+
const formattedValue = pivotValue.formatted ||
|
|
617
|
+
(field
|
|
618
|
+
? formatItemValue(field, pivotValue.value, true)
|
|
619
|
+
: String(pivotValue.value));
|
|
620
|
+
const allColumnsWithSamePivotValues = columns.filter((matchingColumn) => {
|
|
621
|
+
const referencesToMatch = (pivotDetails.groupByColumns || [])
|
|
622
|
+
.map((groupByColumn) => groupByColumn.reference)
|
|
623
|
+
.slice(0, index + 1);
|
|
624
|
+
// Match all pivot values
|
|
625
|
+
return referencesToMatch.every((referenceToMatch) => {
|
|
626
|
+
const pivotValueA = pivotValues.find(({ referenceField: referenceField3 }) => referenceField3 === referenceToMatch);
|
|
627
|
+
const pivotValueB = matchingColumn.pivotValues.find(({ referenceField: referenceField3 }) => referenceField3 === referenceToMatch);
|
|
628
|
+
return pivotValueA?.value === pivotValueB?.value;
|
|
629
|
+
});
|
|
630
|
+
});
|
|
631
|
+
const isFirstInGroup = allColumnsWithSamePivotValues[0].pivotColumnName ===
|
|
632
|
+
pivotColumnName;
|
|
633
|
+
headerValues[index].push({
|
|
634
|
+
type: 'value',
|
|
635
|
+
fieldId: reference,
|
|
636
|
+
value: {
|
|
637
|
+
raw: pivotValue.value,
|
|
638
|
+
formatted: formattedValue,
|
|
639
|
+
},
|
|
640
|
+
colSpan: isFirstInGroup
|
|
641
|
+
? allColumnsWithSamePivotValues.length
|
|
642
|
+
: 0,
|
|
643
|
+
});
|
|
644
|
+
}
|
|
645
|
+
});
|
|
646
|
+
});
|
|
647
|
+
// Add metric labels for columns if not metrics as rows
|
|
648
|
+
if (!pivotConfig.metricsAsRows && baseMetricsArray.length > 0) {
|
|
649
|
+
headerValues.push(filteredValuesColumns
|
|
650
|
+
.sort((a, b) => {
|
|
651
|
+
const columnIndexSort = Number(a.columnIndex) - Number(b.columnIndex);
|
|
652
|
+
const columnOrderSort = columnOrder.indexOf(a.referenceField) -
|
|
653
|
+
columnOrder.indexOf(b.referenceField);
|
|
654
|
+
return columnIndexSort || columnOrderSort;
|
|
655
|
+
})
|
|
656
|
+
.map(({ referenceField }) => ({
|
|
657
|
+
type: 'label',
|
|
658
|
+
fieldId: referenceField,
|
|
659
|
+
})));
|
|
660
|
+
}
|
|
661
|
+
const filteredHeaderValues = headerValues.filter((row) => row.length > 0);
|
|
662
|
+
// Build index values (row identifiers)
|
|
663
|
+
let indexValues;
|
|
664
|
+
if (pivotConfig.metricsAsRows) {
|
|
665
|
+
indexValues = rows.reduce((acc, row) => {
|
|
666
|
+
// multiply rows per metric
|
|
667
|
+
baseMetricsArray.forEach((metric) => {
|
|
668
|
+
acc.push([
|
|
669
|
+
...indexColumns.map((col) => ({
|
|
670
|
+
type: 'value',
|
|
671
|
+
fieldId: col,
|
|
672
|
+
value: row[col].value,
|
|
673
|
+
colSpan: 1,
|
|
674
|
+
})),
|
|
675
|
+
{
|
|
676
|
+
type: 'label',
|
|
677
|
+
fieldId: metric,
|
|
678
|
+
},
|
|
679
|
+
]);
|
|
680
|
+
});
|
|
681
|
+
return acc;
|
|
682
|
+
}, []);
|
|
683
|
+
}
|
|
684
|
+
else {
|
|
685
|
+
indexValues = rows.map((row) => indexColumns.map((col) => ({
|
|
686
|
+
type: 'value',
|
|
687
|
+
fieldId: col,
|
|
688
|
+
value: row[col].value,
|
|
689
|
+
colSpan: 1,
|
|
690
|
+
})));
|
|
691
|
+
}
|
|
692
|
+
// Build data values (the actual pivot data)
|
|
693
|
+
let dataValues;
|
|
694
|
+
const rowIndices = {};
|
|
695
|
+
let rowCount = 0;
|
|
696
|
+
// Get unique columns
|
|
697
|
+
const uniqueColumns = pivotConfig.metricsAsRows
|
|
698
|
+
? Array.from(new Map(filteredValuesColumns.map((col) => [
|
|
699
|
+
col.pivotValues
|
|
700
|
+
.map(({ referenceField, value }) => `${referenceField}:${value}`)
|
|
701
|
+
.join('|'),
|
|
702
|
+
col,
|
|
703
|
+
])).values())
|
|
704
|
+
: filteredValuesColumns;
|
|
705
|
+
if (pivotConfig.metricsAsRows) {
|
|
706
|
+
// multiply rows per metric
|
|
707
|
+
dataValues = rows.reduce((acc, row) => {
|
|
708
|
+
baseMetricsArray.forEach((metric) => {
|
|
709
|
+
const indexRowValues = [
|
|
710
|
+
...indexColumns.map((fieldId) => String(row[fieldId].value.raw)),
|
|
711
|
+
metric,
|
|
712
|
+
];
|
|
713
|
+
// Build row data for this metric using unique columns
|
|
714
|
+
// For each unique column combination, find the corresponding value for this metric
|
|
715
|
+
const rowData = uniqueColumns.map((uniqueCol) => {
|
|
716
|
+
// Find the actual column in sortedValuesColumns that matches this unique combination and metric
|
|
717
|
+
const matchingColumn = filteredValuesColumns.find((col) => col.referenceField === metric &&
|
|
718
|
+
col.pivotValues.every((pv) => uniqueCol.pivotValues.some((upv) => upv.referenceField ===
|
|
719
|
+
pv.referenceField &&
|
|
720
|
+
upv.value === pv.value)));
|
|
721
|
+
return matchingColumn && row[matchingColumn.pivotColumnName]
|
|
722
|
+
? row[matchingColumn.pivotColumnName].value
|
|
723
|
+
: null;
|
|
724
|
+
});
|
|
725
|
+
acc.push(rowData);
|
|
726
|
+
setIndexByKey(rowIndices, indexRowValues, rowCount);
|
|
727
|
+
rowCount += 1;
|
|
728
|
+
});
|
|
729
|
+
return acc;
|
|
730
|
+
}, []);
|
|
731
|
+
}
|
|
732
|
+
else {
|
|
733
|
+
dataValues = rows.map((row, rowIndex) => {
|
|
734
|
+
const indexRowValues = indexColumns.map((fieldId) => String(row[fieldId].value.raw));
|
|
735
|
+
setIndexByKey(rowIndices, indexRowValues, rowIndex);
|
|
736
|
+
return filteredValuesColumns.map((valueCol) => row[valueCol.pivotColumnName]
|
|
737
|
+
? row[valueCol.pivotColumnName].value
|
|
738
|
+
: null);
|
|
739
|
+
});
|
|
740
|
+
rowCount = rows.length;
|
|
741
|
+
}
|
|
742
|
+
const fullPivotConfig = {
|
|
743
|
+
pivotDimensions: pivotDetails.groupByColumns?.map((col) => col.reference) || [],
|
|
744
|
+
metricsAsRows: pivotConfig.metricsAsRows || false,
|
|
745
|
+
columnOrder: pivotConfig.columnOrder,
|
|
746
|
+
hiddenMetricFieldIds: pivotConfig.hiddenMetricFieldIds || [],
|
|
747
|
+
columnTotals: pivotConfig.columnTotals,
|
|
748
|
+
rowTotals: pivotConfig.rowTotals,
|
|
749
|
+
};
|
|
750
|
+
// Compute row totals if requested
|
|
751
|
+
let rowTotalFields;
|
|
752
|
+
let rowTotals;
|
|
753
|
+
const hasHeader = headerValueTypes.length > 0;
|
|
754
|
+
const hasIndex = indexValueTypes.length > 0;
|
|
755
|
+
const N_DATA_ROWS = hasIndex ? dataValues.length : 1;
|
|
756
|
+
const N_DATA_COLUMNS = hasHeader ? uniqueColumns.length : 1;
|
|
757
|
+
// Build column indices using unique columns
|
|
758
|
+
const columnIndices = uniqueColumns.reduce((acc, valuesColumn, index) => {
|
|
759
|
+
const pivotValues = (pivotDetails.groupByColumns || []).map((col) => valuesColumn.pivotValues.find(({ referenceField }) => referenceField === col.reference)?.value);
|
|
760
|
+
// Create nested structure based on pivotValues
|
|
761
|
+
let current = acc;
|
|
762
|
+
for (let i = 0; i < pivotValues.length; i += 1) {
|
|
763
|
+
const pivotValue = String(pivotValues[i]);
|
|
764
|
+
if (!Object.prototype.hasOwnProperty.call(current, pivotValue)) {
|
|
765
|
+
Object.defineProperty(current, pivotValue, {
|
|
766
|
+
value: {},
|
|
767
|
+
writable: true,
|
|
768
|
+
enumerable: true,
|
|
769
|
+
configurable: true,
|
|
770
|
+
});
|
|
771
|
+
}
|
|
772
|
+
current = current[pivotValue];
|
|
773
|
+
}
|
|
774
|
+
// For metricsAsRows, don't include metric in column key
|
|
775
|
+
if (!pivotConfig.metricsAsRows) {
|
|
776
|
+
Object.defineProperty(current, valuesColumn.referenceField, {
|
|
777
|
+
value: index,
|
|
778
|
+
writable: true,
|
|
779
|
+
enumerable: true,
|
|
780
|
+
configurable: true,
|
|
781
|
+
});
|
|
782
|
+
}
|
|
783
|
+
else {
|
|
784
|
+
// Use a generic key since metrics are in rows, not columns
|
|
785
|
+
Object.defineProperty(current, 'value', {
|
|
786
|
+
value: index,
|
|
787
|
+
writable: true,
|
|
788
|
+
enumerable: true,
|
|
789
|
+
configurable: true,
|
|
790
|
+
});
|
|
791
|
+
}
|
|
792
|
+
return acc;
|
|
793
|
+
}, {});
|
|
794
|
+
const summableMetricFieldIds = baseMetricsArray.filter((metricId) => {
|
|
795
|
+
const field = getField(metricId);
|
|
796
|
+
// Skip if field is not found or is a dimension or is hidden
|
|
797
|
+
if (!field || isDimension(field))
|
|
798
|
+
return false;
|
|
799
|
+
if (hiddenMetricFieldIds.includes(metricId))
|
|
800
|
+
return false;
|
|
801
|
+
return isSummable(field);
|
|
802
|
+
});
|
|
803
|
+
if (fullPivotConfig.rowTotals && hasHeader) {
|
|
804
|
+
if (fullPivotConfig.metricsAsRows) {
|
|
805
|
+
const N_TOTAL_COLS = 1;
|
|
806
|
+
const N_TOTAL_ROWS = headerValues.length;
|
|
807
|
+
rowTotalFields = create2DArray(N_TOTAL_ROWS, N_TOTAL_COLS);
|
|
808
|
+
rowTotals = create2DArray(N_DATA_ROWS, N_TOTAL_COLS);
|
|
809
|
+
// set the last header cell as the "Total"
|
|
810
|
+
rowTotalFields[N_TOTAL_ROWS - 1][N_TOTAL_COLS - 1] = {
|
|
811
|
+
fieldId: undefined,
|
|
812
|
+
};
|
|
813
|
+
rowTotals = rowTotals.map((row, rowIndex) => row.map(() => dataValues[rowIndex].reduce((acc, value) => acc + parseNumericValue(value), 0)));
|
|
814
|
+
}
|
|
815
|
+
else {
|
|
816
|
+
const N_TOTAL_COLS = summableMetricFieldIds.length;
|
|
817
|
+
const N_TOTAL_ROWS = headerValues.length;
|
|
818
|
+
rowTotalFields = create2DArray(N_TOTAL_ROWS, N_TOTAL_COLS);
|
|
819
|
+
rowTotals = create2DArray(rows.length, N_TOTAL_COLS);
|
|
820
|
+
// Set the last header cell as the "Total"
|
|
821
|
+
summableMetricFieldIds.forEach((fieldId, metricIndex) => {
|
|
822
|
+
rowTotalFields[N_TOTAL_ROWS - 1][metricIndex] = {
|
|
823
|
+
fieldId,
|
|
824
|
+
};
|
|
825
|
+
});
|
|
826
|
+
rowTotals = rowTotals.map((row, rowIndex) => row.map((_, totalColIndex) => {
|
|
827
|
+
const totalColFieldId = rowTotalFields[N_TOTAL_ROWS - 1][totalColIndex]
|
|
828
|
+
?.fieldId;
|
|
829
|
+
const valueColIndices = totalColFieldId
|
|
830
|
+
? getAllIndicesForFieldId(columnIndices, totalColFieldId)
|
|
831
|
+
: [];
|
|
832
|
+
return dataValues[rowIndex]
|
|
833
|
+
.filter((__, dataValueColIndex) => valueColIndices.includes(dataValueColIndex))
|
|
834
|
+
.reduce((acc, value) => acc + parseNumericValue(value), 0);
|
|
835
|
+
}));
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
const { columnTotalFields, columnTotals } = getColumnTotals({
|
|
839
|
+
summableMetricFieldIds,
|
|
840
|
+
totalColumns: indexValueTypes.length,
|
|
841
|
+
dataColumns: N_DATA_COLUMNS,
|
|
842
|
+
dataValues,
|
|
843
|
+
rowIndices,
|
|
844
|
+
pivotConfig,
|
|
845
|
+
indexValues,
|
|
846
|
+
hasIndex,
|
|
847
|
+
});
|
|
848
|
+
// Build retrofit data for backwards compatibility
|
|
849
|
+
const allCombinedData = rows
|
|
850
|
+
.map((row) => {
|
|
851
|
+
const combinedRow = {};
|
|
852
|
+
// Add index columns
|
|
853
|
+
indexColumns.forEach((col) => {
|
|
854
|
+
combinedRow[col] = row[col];
|
|
855
|
+
});
|
|
856
|
+
if (pivotConfig.metricsAsRows) {
|
|
857
|
+
// Add metric label with correct index (after all index columns)
|
|
858
|
+
const labelIndex = indexColumns.length;
|
|
859
|
+
const metricLabel = getFieldLabel(baseMetricsArray[0]) || baseMetricsArray[0];
|
|
860
|
+
combinedRow[`label-${labelIndex}`] = {
|
|
861
|
+
value: {
|
|
862
|
+
raw: metricLabel,
|
|
863
|
+
formatted: metricLabel,
|
|
864
|
+
},
|
|
865
|
+
};
|
|
866
|
+
}
|
|
867
|
+
// Add data columns with generated field IDs using metadata
|
|
868
|
+
filteredValuesColumns.forEach((valueCol, colIndex) => {
|
|
869
|
+
const pivotDimensions = (pivotDetails.groupByColumns || []).map((col) => col.reference);
|
|
870
|
+
const fieldId = pivotConfig.metricsAsRows
|
|
871
|
+
? `${pivotDimensions.join('__')}__${colIndex}`
|
|
872
|
+
: `${pivotDimensions.join('__')}__${valueCol.referenceField}__${colIndex}`;
|
|
873
|
+
if (row[valueCol.pivotColumnName]) {
|
|
874
|
+
combinedRow[fieldId] = row[valueCol.pivotColumnName];
|
|
875
|
+
}
|
|
876
|
+
});
|
|
877
|
+
return combinedRow;
|
|
878
|
+
})
|
|
879
|
+
.map((combinedRow, rowIndex) => {
|
|
880
|
+
// Add row totals if enabled
|
|
881
|
+
if (fullPivotConfig.rowTotals && rowTotals) {
|
|
882
|
+
const rowTotalValue = rowTotals[rowIndex]?.[0];
|
|
883
|
+
if (rowTotalValue !== undefined) {
|
|
884
|
+
const field = getField(baseMetricsArray[0]);
|
|
885
|
+
const formattedValue = field
|
|
886
|
+
? formatItemValue(field, rowTotalValue)
|
|
887
|
+
: String(rowTotalValue);
|
|
888
|
+
return {
|
|
889
|
+
...combinedRow,
|
|
890
|
+
'row-total-0': {
|
|
891
|
+
value: {
|
|
892
|
+
raw: rowTotalValue,
|
|
893
|
+
formatted: formattedValue,
|
|
894
|
+
},
|
|
895
|
+
},
|
|
896
|
+
};
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
return combinedRow;
|
|
900
|
+
});
|
|
901
|
+
const pivotColumnInfo = [
|
|
902
|
+
...indexColumns.map((col) => ({
|
|
903
|
+
fieldId: col,
|
|
904
|
+
baseId: undefined,
|
|
905
|
+
underlyingId: undefined,
|
|
906
|
+
columnType: 'indexValue',
|
|
907
|
+
})),
|
|
908
|
+
...(pivotConfig.metricsAsRows
|
|
909
|
+
? [
|
|
910
|
+
{
|
|
911
|
+
fieldId: `label-${indexColumns.length}`,
|
|
912
|
+
baseId: undefined,
|
|
913
|
+
underlyingId: undefined,
|
|
914
|
+
columnType: 'label',
|
|
915
|
+
},
|
|
916
|
+
]
|
|
917
|
+
: []),
|
|
918
|
+
...filteredValuesColumns.map((valueCol, colIndex) => {
|
|
919
|
+
const pivotDimensions = (pivotDetails.groupByColumns || []).map((col) => col.reference);
|
|
920
|
+
const fieldId = pivotConfig.metricsAsRows
|
|
921
|
+
? `${pivotDimensions.join('__')}__${colIndex}`
|
|
922
|
+
: `${pivotDimensions.join('__')}__${valueCol.referenceField}__${colIndex}`;
|
|
923
|
+
return {
|
|
924
|
+
fieldId,
|
|
925
|
+
baseId: pivotConfig.metricsAsRows
|
|
926
|
+
? pivotDimensions[0]
|
|
927
|
+
: valueCol.referenceField,
|
|
928
|
+
underlyingId: undefined,
|
|
929
|
+
columnType: undefined,
|
|
930
|
+
};
|
|
931
|
+
}),
|
|
932
|
+
...(fullPivotConfig.rowTotals
|
|
933
|
+
? [
|
|
934
|
+
{
|
|
935
|
+
fieldId: 'row-total-0',
|
|
936
|
+
baseId: 'row-total-0',
|
|
937
|
+
underlyingId: undefined,
|
|
938
|
+
columnType: 'rowTotal',
|
|
939
|
+
},
|
|
940
|
+
]
|
|
941
|
+
: []),
|
|
942
|
+
];
|
|
943
|
+
const titleFields = getTitleFields({
|
|
944
|
+
hasIndex,
|
|
945
|
+
hasHeader,
|
|
946
|
+
headerValueTypes,
|
|
947
|
+
indexValueTypes,
|
|
948
|
+
});
|
|
949
|
+
const pivotData = {
|
|
950
|
+
titleFields,
|
|
951
|
+
headerValueTypes,
|
|
952
|
+
headerValues: filteredHeaderValues,
|
|
953
|
+
indexValueTypes,
|
|
954
|
+
indexValues,
|
|
955
|
+
dataColumnCount: N_DATA_COLUMNS,
|
|
956
|
+
dataValues,
|
|
957
|
+
rowTotalFields,
|
|
958
|
+
columnTotalFields,
|
|
959
|
+
rowTotals,
|
|
960
|
+
columnTotals,
|
|
961
|
+
cellsCount: pivotConfig.metricsAsRows
|
|
962
|
+
? indexColumns.length +
|
|
963
|
+
1 + // label column
|
|
964
|
+
uniqueColumns.length +
|
|
965
|
+
(rowTotals ? rowTotals[0].length : 0)
|
|
966
|
+
: indexColumns.length +
|
|
967
|
+
uniqueColumns.length +
|
|
968
|
+
(rowTotals ? rowTotals[0].length : 0),
|
|
969
|
+
rowsCount: pivotConfig.metricsAsRows
|
|
970
|
+
? rows.length * baseMetricsArray.length
|
|
971
|
+
: rows.length,
|
|
972
|
+
pivotConfig: fullPivotConfig,
|
|
973
|
+
retrofitData: {
|
|
974
|
+
allCombinedData,
|
|
975
|
+
pivotColumnInfo,
|
|
976
|
+
},
|
|
977
|
+
groupedSubtotals,
|
|
978
|
+
};
|
|
979
|
+
return combinedRetrofit(pivotData, getField, getFieldLabel);
|
|
980
|
+
};
|
|
981
|
+
export const pivotResultsAsCsv = ({ pivotConfig, rows, itemMap, metricQuery, customLabels, onlyRaw, maxColumnLimit, undefinedCharacter = '', pivotDetails, }) => {
|
|
982
|
+
const getFieldLabel = (fieldId) => {
|
|
983
|
+
const customLabel = customLabels?.[fieldId];
|
|
984
|
+
if (customLabel !== undefined)
|
|
985
|
+
return customLabel;
|
|
986
|
+
const field = itemMap[fieldId];
|
|
987
|
+
return (field && isField(field) && field?.label) || fieldId;
|
|
988
|
+
};
|
|
989
|
+
const pivotedResults = pivotDetails
|
|
990
|
+
? convertSqlPivotedRowsToPivotData({
|
|
991
|
+
getField: (fieldId) => itemMap && itemMap[fieldId],
|
|
992
|
+
getFieldLabel,
|
|
993
|
+
rows,
|
|
994
|
+
pivotDetails,
|
|
995
|
+
pivotConfig,
|
|
996
|
+
groupedSubtotals: undefined, // TODO: is this something that we have?
|
|
997
|
+
})
|
|
998
|
+
: pivotQueryResults({
|
|
999
|
+
pivotConfig,
|
|
1000
|
+
metricQuery,
|
|
1001
|
+
rows,
|
|
1002
|
+
options: {
|
|
1003
|
+
maxColumns: maxColumnLimit,
|
|
1004
|
+
},
|
|
1005
|
+
getField: (fieldId) => itemMap && itemMap[fieldId], // itemsMap && itemsMap[fieldId],
|
|
1006
|
+
getFieldLabel,
|
|
1007
|
+
});
|
|
1008
|
+
const formatField = onlyRaw ? 'raw' : 'formatted';
|
|
1009
|
+
const headers = pivotedResults.headerValues.reduce((acc, row, i) => {
|
|
1010
|
+
const values = row.map((header) => 'value' in header
|
|
1011
|
+
? header.value[formatField]
|
|
1012
|
+
: getFieldLabel(header.fieldId));
|
|
1013
|
+
const fields = pivotedResults.titleFields[i];
|
|
1014
|
+
const fieldLabels = fields.map((field) => field ? getFieldLabel(field.fieldId) : undefinedCharacter);
|
|
1015
|
+
// Row totals
|
|
1016
|
+
const rowTotalLabels = pivotedResults.rowTotalFields?.[i]?.map((totalField) => totalField?.fieldId
|
|
1017
|
+
? `Total ${getFieldLabel(totalField.fieldId)}`
|
|
1018
|
+
: 'Total') || [];
|
|
1019
|
+
acc[i] = [...fieldLabels, ...values, ...rowTotalLabels];
|
|
1020
|
+
return acc;
|
|
1021
|
+
}, [[]]);
|
|
1022
|
+
const fieldIds = Object.values(pivotedResults.retrofitData.pivotColumnInfo).map((field) => field.fieldId);
|
|
1023
|
+
const hasIndex = pivotedResults.indexValues.length > 0;
|
|
1024
|
+
const pivotedRows = pivotedResults.retrofitData.allCombinedData.map((row) => {
|
|
1025
|
+
// Fields that return `null` don't appear in the pivot table
|
|
1026
|
+
// If there are no index fields, we need to add an empty string to the beginning of the row
|
|
1027
|
+
const noIndexPrefix = hasIndex ? [] : [''];
|
|
1028
|
+
const formattedRows = fieldIds.map((fieldId) => row[fieldId]?.value?.[formatField] ||
|
|
1029
|
+
undefinedCharacter);
|
|
1030
|
+
return [...noIndexPrefix, ...formattedRows];
|
|
1031
|
+
});
|
|
1032
|
+
return [...headers, ...pivotedRows];
|
|
1033
|
+
};
|
|
1034
|
+
//# sourceMappingURL=pivotQueryResults.js.map
|