@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.
Files changed (752) hide show
  1. package/dist/cjs/.tsbuildinfo +1 -0
  2. package/dist/cjs/authorization/index.d.ts +1 -4
  3. package/dist/cjs/authorization/index.d.ts.map +1 -1
  4. package/dist/cjs/authorization/index.js +0 -4
  5. package/dist/cjs/authorization/index.js.map +1 -1
  6. package/dist/cjs/ee/AiAgent/chartConfig/web/getWebAiChartConfig.d.ts +8 -8
  7. package/dist/cjs/ee/AiAgent/index.d.ts +2 -2
  8. package/dist/cjs/ee/AiAgent/schemas/parser.d.ts +24 -24
  9. package/dist/cjs/ee/AiAgent/schemas/tools/toolDashboardV2Args.d.ts +96 -96
  10. package/dist/cjs/ee/AiAgent/schemas/tools/toolRunQueryArgs.d.ts +48 -48
  11. package/dist/cjs/ee/AiAgent/utils.d.ts +8 -8
  12. package/dist/cjs/index.d.ts +23 -449
  13. package/dist/cjs/index.d.ts.map +1 -1
  14. package/dist/cjs/index.js +21 -55
  15. package/dist/cjs/index.js.map +1 -1
  16. package/dist/cjs/pivot/index.d.ts +1 -0
  17. package/dist/cjs/pivot/index.d.ts.map +1 -1
  18. package/dist/cjs/pivot/index.js +1 -0
  19. package/dist/cjs/pivot/index.js.map +1 -1
  20. package/dist/cjs/pivot/pivotConfig.d.ts +7 -0
  21. package/dist/cjs/pivot/pivotConfig.d.ts.map +1 -0
  22. package/dist/cjs/pivot/pivotConfig.js +32 -0
  23. package/dist/cjs/pivot/pivotConfig.js.map +1 -0
  24. package/dist/cjs/types/api.d.ts +447 -0
  25. package/dist/cjs/types/api.d.ts.map +1 -1
  26. package/dist/cjs/types/api.js +50 -1
  27. package/dist/cjs/types/api.js.map +1 -1
  28. package/dist/cjs/types/auth.d.ts +2 -1
  29. package/dist/cjs/types/auth.d.ts.map +1 -1
  30. package/dist/cjs/types/auth.js +4 -4
  31. package/dist/cjs/types/auth.js.map +1 -1
  32. package/dist/cjs/types/changeset.d.ts +10 -10
  33. package/dist/cjs/types/pivot.d.ts +0 -2
  34. package/dist/cjs/types/pivot.d.ts.map +1 -1
  35. package/dist/cjs/types/pivot.js +0 -29
  36. package/dist/cjs/types/pivot.js.map +1 -1
  37. package/dist/cjs/types/resourceViewItem.d.ts +1 -1
  38. package/dist/esm/.tsbuildinfo +1 -0
  39. package/dist/esm/authorization/index.d.ts +1 -4
  40. package/dist/esm/authorization/index.d.ts.map +1 -1
  41. package/dist/esm/authorization/index.js +0 -4
  42. package/dist/esm/authorization/index.js.map +1 -1
  43. package/dist/esm/ee/AiAgent/chartConfig/web/getWebAiChartConfig.d.ts +8 -8
  44. package/dist/esm/ee/AiAgent/index.d.ts +2 -2
  45. package/dist/esm/ee/AiAgent/schemas/parser.d.ts +24 -24
  46. package/dist/esm/ee/AiAgent/schemas/tools/toolDashboardV2Args.d.ts +96 -96
  47. package/dist/esm/ee/AiAgent/schemas/tools/toolRunQueryArgs.d.ts +48 -48
  48. package/dist/esm/ee/AiAgent/utils.d.ts +8 -8
  49. package/dist/esm/index.d.ts +23 -449
  50. package/dist/esm/index.d.ts.map +1 -1
  51. package/dist/esm/index.js +16 -50
  52. package/dist/esm/index.js.map +1 -1
  53. package/dist/esm/pivot/index.d.ts +1 -0
  54. package/dist/esm/pivot/index.d.ts.map +1 -1
  55. package/dist/esm/pivot/index.js +1 -0
  56. package/dist/esm/pivot/index.js.map +1 -1
  57. package/dist/esm/pivot/pivotConfig.d.ts +7 -0
  58. package/dist/esm/pivot/pivotConfig.d.ts.map +1 -0
  59. package/dist/esm/pivot/pivotConfig.js +28 -0
  60. package/dist/esm/pivot/pivotConfig.js.map +1 -0
  61. package/dist/esm/types/api.d.ts +447 -0
  62. package/dist/esm/types/api.d.ts.map +1 -1
  63. package/dist/esm/types/api.js +46 -0
  64. package/dist/esm/types/api.js.map +1 -1
  65. package/dist/esm/types/auth.d.ts +2 -1
  66. package/dist/esm/types/auth.d.ts.map +1 -1
  67. package/dist/esm/types/auth.js +2 -2
  68. package/dist/esm/types/auth.js.map +1 -1
  69. package/dist/esm/types/changeset.d.ts +10 -10
  70. package/dist/esm/types/pivot.d.ts +0 -2
  71. package/dist/esm/types/pivot.d.ts.map +1 -1
  72. package/dist/esm/types/pivot.js +1 -27
  73. package/dist/esm/types/pivot.js.map +1 -1
  74. package/dist/esm/types/resourceViewItem.d.ts +1 -1
  75. package/dist/types/.tsbuildinfo +1 -0
  76. package/dist/types/authorization/buildAccountHelpers.js +11 -0
  77. package/dist/types/authorization/buildAccountHelpers.js.map +1 -0
  78. package/dist/types/authorization/index.d.ts +1 -4
  79. package/dist/types/authorization/index.d.ts.map +1 -1
  80. package/dist/types/authorization/index.js +62 -0
  81. package/dist/types/authorization/index.js.map +1 -0
  82. package/dist/types/authorization/index.mock.js +42 -0
  83. package/dist/types/authorization/index.mock.js.map +1 -0
  84. package/dist/types/authorization/index.test.js +220 -0
  85. package/dist/types/authorization/index.test.js.map +1 -0
  86. package/dist/types/authorization/jwtAbility.js +77 -0
  87. package/dist/types/authorization/jwtAbility.js.map +1 -0
  88. package/dist/types/authorization/jwtAbility.test.js +416 -0
  89. package/dist/types/authorization/jwtAbility.test.js.map +1 -0
  90. package/dist/types/authorization/organizationMemberAbility.js +318 -0
  91. package/dist/types/authorization/organizationMemberAbility.js.map +1 -0
  92. package/dist/types/authorization/organizationMemberAbility.mock.js +34 -0
  93. package/dist/types/authorization/organizationMemberAbility.mock.js.map +1 -0
  94. package/dist/types/authorization/organizationMemberAbility.test.js +1265 -0
  95. package/dist/types/authorization/organizationMemberAbility.test.js.map +1 -0
  96. package/dist/types/authorization/parseAccount.js +28 -0
  97. package/dist/types/authorization/parseAccount.js.map +1 -0
  98. package/dist/types/authorization/parseScopes.js +31 -0
  99. package/dist/types/authorization/parseScopes.js.map +1 -0
  100. package/dist/types/authorization/parseScopes.test.js +102 -0
  101. package/dist/types/authorization/parseScopes.test.js.map +1 -0
  102. package/dist/types/authorization/projectMemberAbility.js +239 -0
  103. package/dist/types/authorization/projectMemberAbility.js.map +1 -0
  104. package/dist/types/authorization/projectMemberAbility.mock.js +27 -0
  105. package/dist/types/authorization/projectMemberAbility.mock.js.map +1 -0
  106. package/dist/types/authorization/projectMemberAbility.test.js +1031 -0
  107. package/dist/types/authorization/projectMemberAbility.test.js.map +1 -0
  108. package/dist/types/authorization/roleToScopeMapping.js +150 -0
  109. package/dist/types/authorization/roleToScopeMapping.js.map +1 -0
  110. package/dist/types/authorization/roleToScopeMapping.test.js +561 -0
  111. package/dist/types/authorization/roleToScopeMapping.test.js.map +1 -0
  112. package/dist/types/authorization/roleToScopeMapping.testUtils.js +319 -0
  113. package/dist/types/authorization/roleToScopeMapping.testUtils.js.map +1 -0
  114. package/dist/types/authorization/roleToScopeParity.test.js +194 -0
  115. package/dist/types/authorization/roleToScopeParity.test.js.map +1 -0
  116. package/dist/types/authorization/scopeAbilityBuilder.js +57 -0
  117. package/dist/types/authorization/scopeAbilityBuilder.js.map +1 -0
  118. package/dist/types/authorization/scopeAbilityBuilder.test.js +1348 -0
  119. package/dist/types/authorization/scopeAbilityBuilder.test.js.map +1 -0
  120. package/dist/types/authorization/scopes.js +613 -0
  121. package/dist/types/authorization/scopes.js.map +1 -0
  122. package/dist/types/authorization/serviceAccountAbility.js +303 -0
  123. package/dist/types/authorization/serviceAccountAbility.js.map +1 -0
  124. package/dist/types/authorization/types.js +2 -0
  125. package/dist/types/authorization/types.js.map +1 -0
  126. package/dist/types/compiler/exploreCompiler.js +462 -0
  127. package/dist/types/compiler/exploreCompiler.js.map +1 -0
  128. package/dist/types/compiler/exploreCompiler.mock.js +2016 -0
  129. package/dist/types/compiler/exploreCompiler.mock.js.map +1 -0
  130. package/dist/types/compiler/exploreCompiler.test.js +679 -0
  131. package/dist/types/compiler/exploreCompiler.test.js.map +1 -0
  132. package/dist/types/compiler/fieldSetExpander.js +119 -0
  133. package/dist/types/compiler/fieldSetExpander.js.map +1 -0
  134. package/dist/types/compiler/fieldSetExpander.test.js +184 -0
  135. package/dist/types/compiler/fieldSetExpander.test.js.map +1 -0
  136. package/dist/types/compiler/filtersCompiler.js +337 -0
  137. package/dist/types/compiler/filtersCompiler.js.map +1 -0
  138. package/dist/types/compiler/filtersCompiler.mock.js +496 -0
  139. package/dist/types/compiler/filtersCompiler.mock.js.map +1 -0
  140. package/dist/types/compiler/filtersCompiler.test.js +570 -0
  141. package/dist/types/compiler/filtersCompiler.test.js.map +1 -0
  142. package/dist/types/compiler/lightdashProjectConfig.js +37 -0
  143. package/dist/types/compiler/lightdashProjectConfig.js.map +1 -0
  144. package/dist/types/compiler/parameters.js +75 -0
  145. package/dist/types/compiler/parameters.js.map +1 -0
  146. package/dist/types/compiler/parameters.test.js +216 -0
  147. package/dist/types/compiler/parameters.test.js.map +1 -0
  148. package/dist/types/compiler/translator.js +707 -0
  149. package/dist/types/compiler/translator.js.map +1 -0
  150. package/dist/types/compiler/translator.mock.js +1901 -0
  151. package/dist/types/compiler/translator.mock.js.map +1 -0
  152. package/dist/types/compiler/translator.test.js +323 -0
  153. package/dist/types/compiler/translator.test.js.map +1 -0
  154. package/dist/types/constants/pivot.js +7 -0
  155. package/dist/types/constants/pivot.js.map +1 -0
  156. package/dist/types/constants/sessionStorageKeys.js +6 -0
  157. package/dist/types/constants/sessionStorageKeys.js.map +1 -0
  158. package/dist/types/constants/sqlRunner.js +3 -0
  159. package/dist/types/constants/sqlRunner.js.map +1 -0
  160. package/dist/types/dbt/DbtSchemaEditor/DbtSchemaEditor.js +285 -0
  161. package/dist/types/dbt/DbtSchemaEditor/DbtSchemaEditor.js.map +1 -0
  162. package/dist/types/dbt/DbtSchemaEditor/DbtSchemaEditor.mock.js +224 -0
  163. package/dist/types/dbt/DbtSchemaEditor/DbtSchemaEditor.mock.js.map +1 -0
  164. package/dist/types/dbt/DbtSchemaEditor/DbtSchemaEditor.test.js +129 -0
  165. package/dist/types/dbt/DbtSchemaEditor/DbtSchemaEditor.test.js.map +1 -0
  166. package/dist/types/dbt/schemas/lightdashMetadata.json +385 -0
  167. package/dist/types/dbt/schemas/lightdashV10.json +72 -0
  168. package/dist/types/dbt/schemas/lightdashV11.json +72 -0
  169. package/dist/types/dbt/schemas/lightdashV12.json +63 -0
  170. package/dist/types/dbt/schemas/lightdashV7.json +72 -0
  171. package/dist/types/dbt/schemas/lightdashV8.json +76 -0
  172. package/dist/types/dbt/schemas/lightdashV9.json +72 -0
  173. package/dist/types/dbt/schemas/manifestV10.json +5545 -0
  174. package/dist/types/dbt/schemas/manifestV11.json +6041 -0
  175. package/dist/types/dbt/schemas/manifestV12.json +22567 -0
  176. package/dist/types/dbt/schemas/manifestV7.json +6481 -0
  177. package/dist/types/dbt/schemas/manifestV8.json +4358 -0
  178. package/dist/types/dbt/schemas/manifestV9.json +4879 -0
  179. package/dist/types/dbt/validation.js +67 -0
  180. package/dist/types/dbt/validation.js.map +1 -0
  181. package/dist/types/ee/AiAgent/adminTypes.js +2 -0
  182. package/dist/types/ee/AiAgent/adminTypes.js.map +1 -0
  183. package/dist/types/ee/AiAgent/chartConfig/shared/formatFieldLabel.js +10 -0
  184. package/dist/types/ee/AiAgent/chartConfig/shared/formatFieldLabel.js.map +1 -0
  185. package/dist/types/ee/AiAgent/chartConfig/slack/generateBarVizConfigTool/getVerticalBarChartEchartsConfig.js +60 -0
  186. package/dist/types/ee/AiAgent/chartConfig/slack/generateBarVizConfigTool/getVerticalBarChartEchartsConfig.js.map +1 -0
  187. package/dist/types/ee/AiAgent/chartConfig/slack/generateTimeSeriesVizConfigTool/getTimeSeriesChartEchartsConfig.js +60 -0
  188. package/dist/types/ee/AiAgent/chartConfig/slack/generateTimeSeriesVizConfigTool/getTimeSeriesChartEchartsConfig.js.map +1 -0
  189. package/dist/types/ee/AiAgent/chartConfig/slack/getSlackAiEchartsConfig.js +33 -0
  190. package/dist/types/ee/AiAgent/chartConfig/slack/getSlackAiEchartsConfig.js.map +1 -0
  191. package/dist/types/ee/AiAgent/chartConfig/slack/index.js +2 -0
  192. package/dist/types/ee/AiAgent/chartConfig/slack/index.js.map +1 -0
  193. package/dist/types/ee/AiAgent/chartConfig/slack/runQueryTool/getRunQueryEchartsConfig.js +43 -0
  194. package/dist/types/ee/AiAgent/chartConfig/slack/runQueryTool/getRunQueryEchartsConfig.js.map +1 -0
  195. package/dist/types/ee/AiAgent/chartConfig/slack/runQueryTool/viz/bar.js +98 -0
  196. package/dist/types/ee/AiAgent/chartConfig/slack/runQueryTool/viz/bar.js.map +1 -0
  197. package/dist/types/ee/AiAgent/chartConfig/slack/runQueryTool/viz/funnel.js +38 -0
  198. package/dist/types/ee/AiAgent/chartConfig/slack/runQueryTool/viz/funnel.js.map +1 -0
  199. package/dist/types/ee/AiAgent/chartConfig/slack/runQueryTool/viz/horizontalBar.js +65 -0
  200. package/dist/types/ee/AiAgent/chartConfig/slack/runQueryTool/viz/horizontalBar.js.map +1 -0
  201. package/dist/types/ee/AiAgent/chartConfig/slack/runQueryTool/viz/line.js +105 -0
  202. package/dist/types/ee/AiAgent/chartConfig/slack/runQueryTool/viz/line.js.map +1 -0
  203. package/dist/types/ee/AiAgent/chartConfig/slack/runQueryTool/viz/pie.js +34 -0
  204. package/dist/types/ee/AiAgent/chartConfig/slack/runQueryTool/viz/pie.js.map +1 -0
  205. package/dist/types/ee/AiAgent/chartConfig/slack/runQueryTool/viz/scatter.js +66 -0
  206. package/dist/types/ee/AiAgent/chartConfig/slack/runQueryTool/viz/scatter.js.map +1 -0
  207. package/dist/types/ee/AiAgent/chartConfig/slack/shared/getCommonEChartsConfig.js +104 -0
  208. package/dist/types/ee/AiAgent/chartConfig/slack/shared/getCommonEChartsConfig.js.map +1 -0
  209. package/dist/types/ee/AiAgent/chartConfig/slack/types.js +2 -0
  210. package/dist/types/ee/AiAgent/chartConfig/slack/types.js.map +1 -0
  211. package/dist/types/ee/AiAgent/chartConfig/web/generateBarVizConfigTool/getVerticalBarChartConfig.js +65 -0
  212. package/dist/types/ee/AiAgent/chartConfig/web/generateBarVizConfigTool/getVerticalBarChartConfig.js.map +1 -0
  213. package/dist/types/ee/AiAgent/chartConfig/web/generateTableVizConfigTool/getTableChartConfig.js +5 -0
  214. package/dist/types/ee/AiAgent/chartConfig/web/generateTableVizConfigTool/getTableChartConfig.js.map +1 -0
  215. package/dist/types/ee/AiAgent/chartConfig/web/generateTimeSeriesVizConfigTool/getTimeSeriesChartConfig.js +63 -0
  216. package/dist/types/ee/AiAgent/chartConfig/web/generateTimeSeriesVizConfigTool/getTimeSeriesChartConfig.js.map +1 -0
  217. package/dist/types/ee/AiAgent/chartConfig/web/getWebAiChartConfig.d.ts +8 -8
  218. package/dist/types/ee/AiAgent/chartConfig/web/getWebAiChartConfig.js +51 -0
  219. package/dist/types/ee/AiAgent/chartConfig/web/getWebAiChartConfig.js.map +1 -0
  220. package/dist/types/ee/AiAgent/chartConfig/web/index.js +6 -0
  221. package/dist/types/ee/AiAgent/chartConfig/web/index.js.map +1 -0
  222. package/dist/types/ee/AiAgent/chartConfig/web/runQueryTool/getRunQueryChartConfig.js +73 -0
  223. package/dist/types/ee/AiAgent/chartConfig/web/runQueryTool/getRunQueryChartConfig.js.map +1 -0
  224. package/dist/types/ee/AiAgent/chartConfig/web/runQueryTool/viz/bar.js +91 -0
  225. package/dist/types/ee/AiAgent/chartConfig/web/runQueryTool/viz/bar.js.map +1 -0
  226. package/dist/types/ee/AiAgent/chartConfig/web/runQueryTool/viz/funnel.js +17 -0
  227. package/dist/types/ee/AiAgent/chartConfig/web/runQueryTool/viz/funnel.js.map +1 -0
  228. package/dist/types/ee/AiAgent/chartConfig/web/runQueryTool/viz/horizontalBar.js +52 -0
  229. package/dist/types/ee/AiAgent/chartConfig/web/runQueryTool/viz/horizontalBar.js.map +1 -0
  230. package/dist/types/ee/AiAgent/chartConfig/web/runQueryTool/viz/line.js +96 -0
  231. package/dist/types/ee/AiAgent/chartConfig/web/runQueryTool/viz/line.js.map +1 -0
  232. package/dist/types/ee/AiAgent/chartConfig/web/runQueryTool/viz/pie.js +15 -0
  233. package/dist/types/ee/AiAgent/chartConfig/web/runQueryTool/viz/pie.js.map +1 -0
  234. package/dist/types/ee/AiAgent/chartConfig/web/runQueryTool/viz/scatter.js +66 -0
  235. package/dist/types/ee/AiAgent/chartConfig/web/runQueryTool/viz/scatter.js.map +1 -0
  236. package/dist/types/ee/AiAgent/chartConfig/web/shared/canRenderAsChart.js +24 -0
  237. package/dist/types/ee/AiAgent/chartConfig/web/shared/canRenderAsChart.js.map +1 -0
  238. package/dist/types/ee/AiAgent/chartConfig/web/shared/formatPivotValueLabel.js +15 -0
  239. package/dist/types/ee/AiAgent/chartConfig/web/shared/formatPivotValueLabel.js.map +1 -0
  240. package/dist/types/ee/AiAgent/chartConfig/web/shared/getAvailableChartTypes.js +11 -0
  241. package/dist/types/ee/AiAgent/chartConfig/web/shared/getAvailableChartTypes.js.map +1 -0
  242. package/dist/types/ee/AiAgent/chartConfig/web/shared/getGroupByDimensions.js +15 -0
  243. package/dist/types/ee/AiAgent/chartConfig/web/shared/getGroupByDimensions.js.map +1 -0
  244. package/dist/types/ee/AiAgent/chartConfig/web/types.js +2 -0
  245. package/dist/types/ee/AiAgent/chartConfig/web/types.js.map +1 -0
  246. package/dist/types/ee/AiAgent/constants.js +2 -0
  247. package/dist/types/ee/AiAgent/constants.js.map +1 -0
  248. package/dist/types/ee/AiAgent/filterExploreByTags.js +94 -0
  249. package/dist/types/ee/AiAgent/filterExploreByTags.js.map +1 -0
  250. package/dist/types/ee/AiAgent/filterExploreByTags.test.js +634 -0
  251. package/dist/types/ee/AiAgent/filterExploreByTags.test.js.map +1 -0
  252. package/dist/types/ee/AiAgent/followUpTools.js +33 -0
  253. package/dist/types/ee/AiAgent/followUpTools.js.map +1 -0
  254. package/dist/types/ee/AiAgent/index.d.ts +2 -2
  255. package/dist/types/ee/AiAgent/index.js +43 -0
  256. package/dist/types/ee/AiAgent/index.js.map +1 -0
  257. package/dist/types/ee/AiAgent/requestTypes.js +2 -0
  258. package/dist/types/ee/AiAgent/requestTypes.js.map +1 -0
  259. package/dist/types/ee/AiAgent/schemas/customMetrics.js +50 -0
  260. package/dist/types/ee/AiAgent/schemas/customMetrics.js.map +1 -0
  261. package/dist/types/ee/AiAgent/schemas/fieldId.js +11 -0
  262. package/dist/types/ee/AiAgent/schemas/fieldId.js.map +1 -0
  263. package/dist/types/ee/AiAgent/schemas/filters/booleanFilters.js +29 -0
  264. package/dist/types/ee/AiAgent/schemas/filters/booleanFilters.js.map +1 -0
  265. package/dist/types/ee/AiAgent/schemas/filters/dateFilters.js +84 -0
  266. package/dist/types/ee/AiAgent/schemas/filters/dateFilters.js.map +1 -0
  267. package/dist/types/ee/AiAgent/schemas/filters/index.js +98 -0
  268. package/dist/types/ee/AiAgent/schemas/filters/index.js.map +1 -0
  269. package/dist/types/ee/AiAgent/schemas/filters/numberFilters.js +53 -0
  270. package/dist/types/ee/AiAgent/schemas/filters/numberFilters.js.map +1 -0
  271. package/dist/types/ee/AiAgent/schemas/filters/stringFilters.js +33 -0
  272. package/dist/types/ee/AiAgent/schemas/filters/stringFilters.js.map +1 -0
  273. package/dist/types/ee/AiAgent/schemas/index.js +9 -0
  274. package/dist/types/ee/AiAgent/schemas/index.js.map +1 -0
  275. package/dist/types/ee/AiAgent/schemas/outputMetadata.js +5 -0
  276. package/dist/types/ee/AiAgent/schemas/outputMetadata.js.map +1 -0
  277. package/dist/types/ee/AiAgent/schemas/parser.d.ts +24 -24
  278. package/dist/types/ee/AiAgent/schemas/parser.js +43 -0
  279. package/dist/types/ee/AiAgent/schemas/parser.js.map +1 -0
  280. package/dist/types/ee/AiAgent/schemas/sortField.js +14 -0
  281. package/dist/types/ee/AiAgent/schemas/sortField.js.map +1 -0
  282. package/dist/types/ee/AiAgent/schemas/tableCalcs/tableCalcBaseSchemas.js +28 -0
  283. package/dist/types/ee/AiAgent/schemas/tableCalcs/tableCalcBaseSchemas.js.map +1 -0
  284. package/dist/types/ee/AiAgent/schemas/tableCalcs/tableCalcPercentChangeFromPrevious.js +14 -0
  285. package/dist/types/ee/AiAgent/schemas/tableCalcs/tableCalcPercentChangeFromPrevious.js.map +1 -0
  286. package/dist/types/ee/AiAgent/schemas/tableCalcs/tableCalcPercentOfColumnTotal.js +14 -0
  287. package/dist/types/ee/AiAgent/schemas/tableCalcs/tableCalcPercentOfColumnTotal.js.map +1 -0
  288. package/dist/types/ee/AiAgent/schemas/tableCalcs/tableCalcPercentOfPreviousValue.js +14 -0
  289. package/dist/types/ee/AiAgent/schemas/tableCalcs/tableCalcPercentOfPreviousValue.js.map +1 -0
  290. package/dist/types/ee/AiAgent/schemas/tableCalcs/tableCalcRankInColumn.js +10 -0
  291. package/dist/types/ee/AiAgent/schemas/tableCalcs/tableCalcRankInColumn.js.map +1 -0
  292. package/dist/types/ee/AiAgent/schemas/tableCalcs/tableCalcRunningTotal.js +10 -0
  293. package/dist/types/ee/AiAgent/schemas/tableCalcs/tableCalcRunningTotal.js.map +1 -0
  294. package/dist/types/ee/AiAgent/schemas/tableCalcs/tableCalcWindowFunction.js +105 -0
  295. package/dist/types/ee/AiAgent/schemas/tableCalcs/tableCalcWindowFunction.js.map +1 -0
  296. package/dist/types/ee/AiAgent/schemas/tableCalcs/tableCalcs.js +168 -0
  297. package/dist/types/ee/AiAgent/schemas/tableCalcs/tableCalcs.js.map +1 -0
  298. package/dist/types/ee/AiAgent/schemas/toolSchemaBuilder.js +37 -0
  299. package/dist/types/ee/AiAgent/schemas/toolSchemaBuilder.js.map +1 -0
  300. package/dist/types/ee/AiAgent/schemas/tools/index.js +16 -0
  301. package/dist/types/ee/AiAgent/schemas/tools/index.js.map +1 -0
  302. package/dist/types/ee/AiAgent/schemas/tools/toolDashboardArgs.js +103 -0
  303. package/dist/types/ee/AiAgent/schemas/tools/toolDashboardArgs.js.map +1 -0
  304. package/dist/types/ee/AiAgent/schemas/tools/toolDashboardV2Args.d.ts +96 -96
  305. package/dist/types/ee/AiAgent/schemas/tools/toolDashboardV2Args.js +50 -0
  306. package/dist/types/ee/AiAgent/schemas/tools/toolDashboardV2Args.js.map +1 -0
  307. package/dist/types/ee/AiAgent/schemas/tools/toolFindChartsArgs.js +34 -0
  308. package/dist/types/ee/AiAgent/schemas/tools/toolFindChartsArgs.js.map +1 -0
  309. package/dist/types/ee/AiAgent/schemas/tools/toolFindContentArgs.js +33 -0
  310. package/dist/types/ee/AiAgent/schemas/tools/toolFindContentArgs.js.map +1 -0
  311. package/dist/types/ee/AiAgent/schemas/tools/toolFindDashboardsArgs.js +36 -0
  312. package/dist/types/ee/AiAgent/schemas/tools/toolFindDashboardsArgs.js.map +1 -0
  313. package/dist/types/ee/AiAgent/schemas/tools/toolFindExploresArgs.js +45 -0
  314. package/dist/types/ee/AiAgent/schemas/tools/toolFindExploresArgs.js.map +1 -0
  315. package/dist/types/ee/AiAgent/schemas/tools/toolFindFieldsArgs.js +34 -0
  316. package/dist/types/ee/AiAgent/schemas/tools/toolFindFieldsArgs.js.map +1 -0
  317. package/dist/types/ee/AiAgent/schemas/tools/toolImproveContextArgs.js +60 -0
  318. package/dist/types/ee/AiAgent/schemas/tools/toolImproveContextArgs.js.map +1 -0
  319. package/dist/types/ee/AiAgent/schemas/tools/toolProposeChangeArgs.js +157 -0
  320. package/dist/types/ee/AiAgent/schemas/tools/toolProposeChangeArgs.js.map +1 -0
  321. package/dist/types/ee/AiAgent/schemas/tools/toolRunMetricQueryArgs.js +41 -0
  322. package/dist/types/ee/AiAgent/schemas/tools/toolRunMetricQueryArgs.js.map +1 -0
  323. package/dist/types/ee/AiAgent/schemas/tools/toolRunQueryArgs.d.ts +48 -48
  324. package/dist/types/ee/AiAgent/schemas/tools/toolRunQueryArgs.js +151 -0
  325. package/dist/types/ee/AiAgent/schemas/tools/toolRunQueryArgs.js.map +1 -0
  326. package/dist/types/ee/AiAgent/schemas/tools/toolSearchFieldValuesArgs.js +46 -0
  327. package/dist/types/ee/AiAgent/schemas/tools/toolSearchFieldValuesArgs.js.map +1 -0
  328. package/dist/types/ee/AiAgent/schemas/tools/toolTableVizArgs.js +53 -0
  329. package/dist/types/ee/AiAgent/schemas/tools/toolTableVizArgs.js.map +1 -0
  330. package/dist/types/ee/AiAgent/schemas/tools/toolTimeSeriesArgs.js +58 -0
  331. package/dist/types/ee/AiAgent/schemas/tools/toolTimeSeriesArgs.js.map +1 -0
  332. package/dist/types/ee/AiAgent/schemas/tools/toolVerticalBarArgs.js +53 -0
  333. package/dist/types/ee/AiAgent/schemas/tools/toolVerticalBarArgs.js.map +1 -0
  334. package/dist/types/ee/AiAgent/schemas/visualizationMetadata.js +9 -0
  335. package/dist/types/ee/AiAgent/schemas/visualizationMetadata.js.map +1 -0
  336. package/dist/types/ee/AiAgent/schemas/visualizations/index.js +58 -0
  337. package/dist/types/ee/AiAgent/schemas/visualizations/index.js.map +1 -0
  338. package/dist/types/ee/AiAgent/schemas/visualizations/tableViz.js +38 -0
  339. package/dist/types/ee/AiAgent/schemas/visualizations/tableViz.js.map +1 -0
  340. package/dist/types/ee/AiAgent/schemas/visualizations/timeSeriesViz.js +63 -0
  341. package/dist/types/ee/AiAgent/schemas/visualizations/timeSeriesViz.js.map +1 -0
  342. package/dist/types/ee/AiAgent/schemas/visualizations/verticalBarViz.js +68 -0
  343. package/dist/types/ee/AiAgent/schemas/visualizations/verticalBarViz.js.map +1 -0
  344. package/dist/types/ee/AiAgent/types.js +12 -0
  345. package/dist/types/ee/AiAgent/types.js.map +1 -0
  346. package/dist/types/ee/AiAgent/utils.d.ts +8 -8
  347. package/dist/types/ee/AiAgent/utils.js +82 -0
  348. package/dist/types/ee/AiAgent/utils.js.map +1 -0
  349. package/dist/types/ee/AiAgent/validators.js +10 -0
  350. package/dist/types/ee/AiAgent/validators.js.map +1 -0
  351. package/dist/types/ee/commercialFeatureFlags.js +10 -0
  352. package/dist/types/ee/commercialFeatureFlags.js.map +1 -0
  353. package/dist/types/ee/embed/index.js +90 -0
  354. package/dist/types/ee/embed/index.js.map +1 -0
  355. package/dist/types/ee/index.js +19 -0
  356. package/dist/types/ee/index.js.map +1 -0
  357. package/dist/types/ee/scim/errors.js +22 -0
  358. package/dist/types/ee/scim/errors.js.map +1 -0
  359. package/dist/types/ee/scim/types.js +2 -0
  360. package/dist/types/ee/scim/types.js.map +1 -0
  361. package/dist/types/ee/serviceAccounts/types.js +8 -0
  362. package/dist/types/ee/serviceAccounts/types.js.map +1 -0
  363. package/dist/types/index.d.ts +23 -449
  364. package/dist/types/index.d.ts.map +1 -1
  365. package/dist/types/index.js +652 -0
  366. package/dist/types/index.js.map +1 -0
  367. package/dist/types/index.mock.js +44 -0
  368. package/dist/types/index.mock.js.map +1 -0
  369. package/dist/types/index.test.js +123 -0
  370. package/dist/types/index.test.js.map +1 -0
  371. package/dist/types/pivot/derivePivotConfigFromChart.js +206 -0
  372. package/dist/types/pivot/derivePivotConfigFromChart.js.map +1 -0
  373. package/dist/types/pivot/derivePivotConfigFromChart.mock.js +112 -0
  374. package/dist/types/pivot/derivePivotConfigFromChart.mock.js.map +1 -0
  375. package/dist/types/pivot/derivePivotConfigFromChart.test.js +418 -0
  376. package/dist/types/pivot/derivePivotConfigFromChart.test.js.map +1 -0
  377. package/dist/types/pivot/index.d.ts +1 -0
  378. package/dist/types/pivot/index.d.ts.map +1 -1
  379. package/dist/types/pivot/index.js +5 -0
  380. package/dist/types/pivot/index.js.map +1 -0
  381. package/dist/types/pivot/pivotConfig.d.ts +7 -0
  382. package/dist/types/pivot/pivotConfig.d.ts.map +1 -0
  383. package/dist/types/pivot/pivotConfig.js +28 -0
  384. package/dist/types/pivot/pivotConfig.js.map +1 -0
  385. package/dist/types/pivot/pivotQueryResults.js +1034 -0
  386. package/dist/types/pivot/pivotQueryResults.js.map +1 -0
  387. package/dist/types/pivot/pivotQueryResults.mock.js +2412 -0
  388. package/dist/types/pivot/pivotQueryResults.mock.js.map +1 -0
  389. package/dist/types/pivot/pivotQueryResults.test.js +1222 -0
  390. package/dist/types/pivot/pivotQueryResults.test.js.map +1 -0
  391. package/dist/types/pivot/utils.js +14 -0
  392. package/dist/types/pivot/utils.js.map +1 -0
  393. package/dist/types/schemas/json/chart-as-code-1.0.json +436 -0
  394. package/dist/types/schemas/json/dashboard-as-code-1.0.json +349 -0
  395. package/dist/types/schemas/json/lightdash-dbt-2.0.json +1417 -0
  396. package/dist/types/schemas/json/lightdash-project-config-1.0.json +138 -0
  397. package/dist/types/templating/template.js +30 -0
  398. package/dist/types/templating/template.js.map +1 -0
  399. package/dist/types/templating/template.mock.js +45 -0
  400. package/dist/types/templating/template.mock.js.map +1 -0
  401. package/dist/types/templating/template.test.js +21 -0
  402. package/dist/types/templating/template.test.js.map +1 -0
  403. package/dist/types/types/SshKeyPair.js +2 -0
  404. package/dist/types/types/SshKeyPair.js.map +1 -0
  405. package/dist/types/types/account.js +2 -0
  406. package/dist/types/types/account.js.map +1 -0
  407. package/dist/types/types/analytics.js +29 -0
  408. package/dist/types/types/analytics.js.map +1 -0
  409. package/dist/types/types/any.js +2 -0
  410. package/dist/types/types/any.js.map +1 -0
  411. package/dist/types/types/api/comments.js +2 -0
  412. package/dist/types/types/api/comments.js.map +1 -0
  413. package/dist/types/types/api/email.js +2 -0
  414. package/dist/types/types/api/email.js.map +1 -0
  415. package/dist/types/types/api/errors.js +2 -0
  416. package/dist/types/types/api/errors.js.map +1 -0
  417. package/dist/types/types/api/notifications.js +5 -0
  418. package/dist/types/types/api/notifications.js.map +1 -0
  419. package/dist/types/types/api/paginatedQuery.js +3 -0
  420. package/dist/types/types/api/paginatedQuery.js.map +1 -0
  421. package/dist/types/types/api/parameters.js +2 -0
  422. package/dist/types/types/api/parameters.js.map +1 -0
  423. package/dist/types/types/api/share.js +2 -0
  424. package/dist/types/types/api/share.js.map +1 -0
  425. package/dist/types/types/api/sort.js +2 -0
  426. package/dist/types/types/api/sort.js.map +1 -0
  427. package/dist/types/types/api/spotlight.js +2 -0
  428. package/dist/types/types/api/spotlight.js.map +1 -0
  429. package/dist/types/types/api/success.js +2 -0
  430. package/dist/types/types/api/success.js.map +1 -0
  431. package/dist/types/types/api/uuid.js +2 -0
  432. package/dist/types/types/api/uuid.js.map +1 -0
  433. package/dist/types/types/api.d.ts +447 -0
  434. package/dist/types/types/api.d.ts.map +1 -1
  435. package/dist/types/types/api.js +57 -0
  436. package/dist/types/types/api.js.map +1 -0
  437. package/dist/types/types/applyDimensionOverrides.test.js +338 -0
  438. package/dist/types/types/applyDimensionOverrides.test.js.map +1 -0
  439. package/dist/types/types/auth.d.ts +2 -1
  440. package/dist/types/types/auth.d.ts.map +1 -1
  441. package/dist/types/types/auth.js +42 -0
  442. package/dist/types/types/auth.js.map +1 -0
  443. package/dist/types/types/bigQuerySSO.js +2 -0
  444. package/dist/types/types/bigQuerySSO.js.map +1 -0
  445. package/dist/types/types/catalog.js +50 -0
  446. package/dist/types/types/catalog.js.map +1 -0
  447. package/dist/types/types/changeset.d.ts +10 -10
  448. package/dist/types/types/changeset.js +72 -0
  449. package/dist/types/types/changeset.js.map +1 -0
  450. package/dist/types/types/coder.js +2 -0
  451. package/dist/types/types/coder.js.map +1 -0
  452. package/dist/types/types/comments.js +2 -0
  453. package/dist/types/types/comments.js.map +1 -0
  454. package/dist/types/types/conditionalFormatting.js +25 -0
  455. package/dist/types/types/conditionalFormatting.js.map +1 -0
  456. package/dist/types/types/content.js +19 -0
  457. package/dist/types/types/content.js.map +1 -0
  458. package/dist/types/types/csv.js +2 -0
  459. package/dist/types/types/csv.js.map +1 -0
  460. package/dist/types/types/dashboard.js +46 -0
  461. package/dist/types/types/dashboard.js.map +1 -0
  462. package/dist/types/types/dbt.js +262 -0
  463. package/dist/types/types/dbt.js.map +1 -0
  464. package/dist/types/types/dbtFromSchema.js +2 -0
  465. package/dist/types/types/dbtFromSchema.js.map +1 -0
  466. package/dist/types/types/deepPartial.js +7 -0
  467. package/dist/types/types/deepPartial.js.map +1 -0
  468. package/dist/types/types/downloadFile.js +9 -0
  469. package/dist/types/types/downloadFile.js.map +1 -0
  470. package/dist/types/types/email.js +2 -0
  471. package/dist/types/types/email.js.map +1 -0
  472. package/dist/types/types/errors.js +496 -0
  473. package/dist/types/types/errors.js.map +1 -0
  474. package/dist/types/types/explore.js +24 -0
  475. package/dist/types/types/explore.js.map +1 -0
  476. package/dist/types/types/featureFlags.js +62 -0
  477. package/dist/types/types/featureFlags.js.map +1 -0
  478. package/dist/types/types/field.js +473 -0
  479. package/dist/types/types/field.js.map +1 -0
  480. package/dist/types/types/field.test.js +90 -0
  481. package/dist/types/types/field.test.js.map +1 -0
  482. package/dist/types/types/fieldMatch.js +2 -0
  483. package/dist/types/types/fieldMatch.js.map +1 -0
  484. package/dist/types/types/filter.js +287 -0
  485. package/dist/types/types/filter.js.map +1 -0
  486. package/dist/types/types/filter.test.js +372 -0
  487. package/dist/types/types/filter.test.js.map +1 -0
  488. package/dist/types/types/filterGrammar.js +358 -0
  489. package/dist/types/types/filterGrammar.js.map +1 -0
  490. package/dist/types/types/filterGrammar.test.js +549 -0
  491. package/dist/types/types/filterGrammar.test.js.map +1 -0
  492. package/dist/types/types/filterGrammarConversion.js +94 -0
  493. package/dist/types/types/filterGrammarConversion.js.map +1 -0
  494. package/dist/types/types/filterGrammarConversion.test.js +260 -0
  495. package/dist/types/types/filterGrammarConversion.test.js.map +1 -0
  496. package/dist/types/types/gdrive.js +2 -0
  497. package/dist/types/types/gdrive.js.map +1 -0
  498. package/dist/types/types/gitIntegration.js +2 -0
  499. package/dist/types/types/gitIntegration.js.map +1 -0
  500. package/dist/types/types/groups.js +4 -0
  501. package/dist/types/types/groups.js.map +1 -0
  502. package/dist/types/types/job.js +67 -0
  503. package/dist/types/types/job.js.map +1 -0
  504. package/dist/types/types/knex-paginate.js +2 -0
  505. package/dist/types/types/knex-paginate.js.map +1 -0
  506. package/dist/types/types/lightdashProjectConfig.js +4 -0
  507. package/dist/types/types/lightdashProjectConfig.js.map +1 -0
  508. package/dist/types/types/metricQuery.js +20 -0
  509. package/dist/types/types/metricQuery.js.map +1 -0
  510. package/dist/types/types/metricsExplorer.js +12 -0
  511. package/dist/types/types/metricsExplorer.js.map +1 -0
  512. package/dist/types/types/notifications.js +2 -0
  513. package/dist/types/types/notifications.js.map +1 -0
  514. package/dist/types/types/oauth.js +2 -0
  515. package/dist/types/types/oauth.js.map +1 -0
  516. package/dist/types/types/openIdIdentity.js +12 -0
  517. package/dist/types/types/openIdIdentity.js.map +1 -0
  518. package/dist/types/types/organization.js +20 -0
  519. package/dist/types/types/organization.js.map +1 -0
  520. package/dist/types/types/organizationMemberProfile.js +30 -0
  521. package/dist/types/types/organizationMemberProfile.js.map +1 -0
  522. package/dist/types/types/organizationWarehouseCredentials.js +2 -0
  523. package/dist/types/types/organizationWarehouseCredentials.js.map +1 -0
  524. package/dist/types/types/paginateResults.js +2 -0
  525. package/dist/types/types/paginateResults.js.map +1 -0
  526. package/dist/types/types/parameters.js +2 -0
  527. package/dist/types/types/parameters.js.map +1 -0
  528. package/dist/types/types/personalAccessToken.js +2 -0
  529. package/dist/types/types/personalAccessToken.js.map +1 -0
  530. package/dist/types/types/pinning.js +5 -0
  531. package/dist/types/types/pinning.js.map +1 -0
  532. package/dist/types/types/pivot.d.ts +0 -2
  533. package/dist/types/types/pivot.d.ts.map +1 -1
  534. package/dist/types/types/pivot.js +2 -0
  535. package/dist/types/types/pivot.js.map +1 -0
  536. package/dist/types/types/projectGroupAccess.js +2 -0
  537. package/dist/types/types/projectGroupAccess.js.map +1 -0
  538. package/dist/types/types/projectMemberProfile.js +2 -0
  539. package/dist/types/types/projectMemberProfile.js.map +1 -0
  540. package/dist/types/types/projectMemberRole.js +30 -0
  541. package/dist/types/types/projectMemberRole.js.map +1 -0
  542. package/dist/types/types/projects.js +149 -0
  543. package/dist/types/types/projects.js.map +1 -0
  544. package/dist/types/types/promotion.js +8 -0
  545. package/dist/types/types/promotion.js.map +1 -0
  546. package/dist/types/types/queryHistory.js +8 -0
  547. package/dist/types/types/queryHistory.js.map +1 -0
  548. package/dist/types/types/rename.js +6 -0
  549. package/dist/types/types/rename.js.map +1 -0
  550. package/dist/types/types/resourceViewItem.d.ts +1 -1
  551. package/dist/types/types/resourceViewItem.js +103 -0
  552. package/dist/types/types/resourceViewItem.js.map +1 -0
  553. package/dist/types/types/results.js +51 -0
  554. package/dist/types/types/results.js.map +1 -0
  555. package/dist/types/types/roles.js +2 -0
  556. package/dist/types/types/roles.js.map +1 -0
  557. package/dist/types/types/savedCharts.js +225 -0
  558. package/dist/types/types/savedCharts.js.map +1 -0
  559. package/dist/types/types/scheduler.js +87 -0
  560. package/dist/types/types/scheduler.js.map +1 -0
  561. package/dist/types/types/schedulerLog.js +2 -0
  562. package/dist/types/types/schedulerLog.js.map +1 -0
  563. package/dist/types/types/schedulerTaskList.js +31 -0
  564. package/dist/types/types/schedulerTaskList.js.map +1 -0
  565. package/dist/types/types/scopes.js +14 -0
  566. package/dist/types/types/scopes.js.map +1 -0
  567. package/dist/types/types/search.js +53 -0
  568. package/dist/types/types/search.js.map +1 -0
  569. package/dist/types/types/share.js +2 -0
  570. package/dist/types/types/share.js.map +1 -0
  571. package/dist/types/types/slack.js +2 -0
  572. package/dist/types/types/slack.js.map +1 -0
  573. package/dist/types/types/slackSettings.js +2 -0
  574. package/dist/types/types/slackSettings.js.map +1 -0
  575. package/dist/types/types/space.js +7 -0
  576. package/dist/types/types/space.js.map +1 -0
  577. package/dist/types/types/spotlightTableConfig.js +17 -0
  578. package/dist/types/types/spotlightTableConfig.js.map +1 -0
  579. package/dist/types/types/sqlRunner.js +41 -0
  580. package/dist/types/types/sqlRunner.js.map +1 -0
  581. package/dist/types/types/table.js +6 -0
  582. package/dist/types/types/table.js.map +1 -0
  583. package/dist/types/types/tags.js +2 -0
  584. package/dist/types/types/tags.js.map +1 -0
  585. package/dist/types/types/timeFrames.js +42 -0
  586. package/dist/types/types/timeFrames.js.map +1 -0
  587. package/dist/types/types/timezone.js +33 -0
  588. package/dist/types/types/timezone.js.map +1 -0
  589. package/dist/types/types/user.js +23 -0
  590. package/dist/types/types/user.js.map +1 -0
  591. package/dist/types/types/userAttributes.js +2 -0
  592. package/dist/types/types/userAttributes.js.map +1 -0
  593. package/dist/types/types/userWarehouseCredentials.js +2 -0
  594. package/dist/types/types/userWarehouseCredentials.js.map +1 -0
  595. package/dist/types/types/validation.js +29 -0
  596. package/dist/types/types/validation.js.map +1 -0
  597. package/dist/types/types/warehouse.js +6 -0
  598. package/dist/types/types/warehouse.js.map +1 -0
  599. package/dist/types/types/yamlSchema.js +2 -0
  600. package/dist/types/types/yamlSchema.js.map +1 -0
  601. package/dist/types/utils/accessors.js +27 -0
  602. package/dist/types/utils/accessors.js.map +1 -0
  603. package/dist/types/utils/accessors.test.js +45 -0
  604. package/dist/types/utils/accessors.test.js.map +1 -0
  605. package/dist/types/utils/additionalMetrics.js +54 -0
  606. package/dist/types/utils/additionalMetrics.js.map +1 -0
  607. package/dist/types/utils/api.js +5 -0
  608. package/dist/types/utils/api.js.map +1 -0
  609. package/dist/types/utils/assertUnreachable.js +10 -0
  610. package/dist/types/utils/assertUnreachable.js.map +1 -0
  611. package/dist/types/utils/booleanConverter.js +27 -0
  612. package/dist/types/utils/booleanConverter.js.map +1 -0
  613. package/dist/types/utils/booleanConverter.test.js +59 -0
  614. package/dist/types/utils/booleanConverter.test.js.map +1 -0
  615. package/dist/types/utils/catalogMetricsTree.js +2 -0
  616. package/dist/types/utils/catalogMetricsTree.js.map +1 -0
  617. package/dist/types/utils/changeset.js +132 -0
  618. package/dist/types/utils/changeset.js.map +1 -0
  619. package/dist/types/utils/changeset.mock.js +146 -0
  620. package/dist/types/utils/changeset.mock.js.map +1 -0
  621. package/dist/types/utils/changeset.test.js +248 -0
  622. package/dist/types/utils/changeset.test.js.map +1 -0
  623. package/dist/types/utils/charts.js +74 -0
  624. package/dist/types/utils/charts.js.map +1 -0
  625. package/dist/types/utils/colors.js +15 -0
  626. package/dist/types/utils/colors.js.map +1 -0
  627. package/dist/types/utils/colors.test.js +85 -0
  628. package/dist/types/utils/colors.test.js.map +1 -0
  629. package/dist/types/utils/conditionalFormatting.js +436 -0
  630. package/dist/types/utils/conditionalFormatting.js.map +1 -0
  631. package/dist/types/utils/conditionalFormatting.test.js +105 -0
  632. package/dist/types/utils/conditionalFormatting.test.js.map +1 -0
  633. package/dist/types/utils/convertCustomDimensionsToYaml.js +115 -0
  634. package/dist/types/utils/convertCustomDimensionsToYaml.js.map +1 -0
  635. package/dist/types/utils/convertCustomMetricsToYaml.js +15 -0
  636. package/dist/types/utils/convertCustomMetricsToYaml.js.map +1 -0
  637. package/dist/types/utils/customDimensions.js +27 -0
  638. package/dist/types/utils/customDimensions.js.map +1 -0
  639. package/dist/types/utils/dashboard.js +35 -0
  640. package/dist/types/utils/dashboard.js.map +1 -0
  641. package/dist/types/utils/dashboard.test.js +36 -0
  642. package/dist/types/utils/dashboard.test.js.map +1 -0
  643. package/dist/types/utils/dbt.js +4 -0
  644. package/dist/types/utils/dbt.js.map +1 -0
  645. package/dist/types/utils/dbt.test.js +39 -0
  646. package/dist/types/utils/dbt.test.js.map +1 -0
  647. package/dist/types/utils/dependencyGraph.js +51 -0
  648. package/dist/types/utils/dependencyGraph.js.map +1 -0
  649. package/dist/types/utils/dependencyGraph.test.js +113 -0
  650. package/dist/types/utils/dependencyGraph.test.js.map +1 -0
  651. package/dist/types/utils/email.js +76 -0
  652. package/dist/types/utils/email.js.map +1 -0
  653. package/dist/types/utils/email.test.js +49 -0
  654. package/dist/types/utils/email.test.js.map +1 -0
  655. package/dist/types/utils/fields.js +183 -0
  656. package/dist/types/utils/fields.js.map +1 -0
  657. package/dist/types/utils/fields.mock.js +150 -0
  658. package/dist/types/utils/fields.mock.js.map +1 -0
  659. package/dist/types/utils/fields.test.js +259 -0
  660. package/dist/types/utils/fields.test.js.map +1 -0
  661. package/dist/types/utils/filters.js +763 -0
  662. package/dist/types/utils/filters.js.map +1 -0
  663. package/dist/types/utils/filters.mock.js +450 -0
  664. package/dist/types/utils/filters.mock.js.map +1 -0
  665. package/dist/types/utils/filters.test.js +360 -0
  666. package/dist/types/utils/filters.test.js.map +1 -0
  667. package/dist/types/utils/formatting.js +552 -0
  668. package/dist/types/utils/formatting.js.map +1 -0
  669. package/dist/types/utils/formatting.mock.js +28 -0
  670. package/dist/types/utils/formatting.mock.js.map +1 -0
  671. package/dist/types/utils/formatting.test.js +1047 -0
  672. package/dist/types/utils/formatting.test.js.map +1 -0
  673. package/dist/types/utils/github.js +11 -0
  674. package/dist/types/utils/github.js.map +1 -0
  675. package/dist/types/utils/i18n/abstract.js +3 -0
  676. package/dist/types/utils/i18n/abstract.js.map +1 -0
  677. package/dist/types/utils/i18n/chartAsCode.js +132 -0
  678. package/dist/types/utils/i18n/chartAsCode.js.map +1 -0
  679. package/dist/types/utils/i18n/chartAsCode.test.js +350 -0
  680. package/dist/types/utils/i18n/chartAsCode.test.js.map +1 -0
  681. package/dist/types/utils/i18n/dashboardAsCode.js +58 -0
  682. package/dist/types/utils/i18n/dashboardAsCode.js.map +1 -0
  683. package/dist/types/utils/i18n/index.js +5 -0
  684. package/dist/types/utils/i18n/index.js.map +1 -0
  685. package/dist/types/utils/i18n/merge.js +20 -0
  686. package/dist/types/utils/i18n/merge.js.map +1 -0
  687. package/dist/types/utils/i18n/types.js +2 -0
  688. package/dist/types/utils/i18n/types.js.map +1 -0
  689. package/dist/types/utils/item.js +154 -0
  690. package/dist/types/utils/item.js.map +1 -0
  691. package/dist/types/utils/loadLightdashProjectConfig.js +49 -0
  692. package/dist/types/utils/loadLightdashProjectConfig.js.map +1 -0
  693. package/dist/types/utils/loadLightdashProjectConfig.mock.js +127 -0
  694. package/dist/types/utils/loadLightdashProjectConfig.mock.js.map +1 -0
  695. package/dist/types/utils/loadLightdashProjectConfig.test.js +137 -0
  696. package/dist/types/utils/loadLightdashProjectConfig.test.js.map +1 -0
  697. package/dist/types/utils/metricsExplorer.js +365 -0
  698. package/dist/types/utils/metricsExplorer.js.map +1 -0
  699. package/dist/types/utils/oauth.js +242 -0
  700. package/dist/types/utils/oauth.js.map +1 -0
  701. package/dist/types/utils/organization.js +23 -0
  702. package/dist/types/utils/organization.js.map +1 -0
  703. package/dist/types/utils/projectMemberRole.js +85 -0
  704. package/dist/types/utils/projectMemberRole.js.map +1 -0
  705. package/dist/types/utils/projectMemberRole.test.js +36 -0
  706. package/dist/types/utils/projectMemberRole.test.js.map +1 -0
  707. package/dist/types/utils/promises.js +5 -0
  708. package/dist/types/utils/promises.js.map +1 -0
  709. package/dist/types/utils/sanitizeHtml.js +111 -0
  710. package/dist/types/utils/sanitizeHtml.js.map +1 -0
  711. package/dist/types/utils/sanitizeHtml.test.js +101 -0
  712. package/dist/types/utils/sanitizeHtml.test.js.map +1 -0
  713. package/dist/types/utils/scheduler.js +85 -0
  714. package/dist/types/utils/scheduler.js.map +1 -0
  715. package/dist/types/utils/scheduler.test.js +41 -0
  716. package/dist/types/utils/scheduler.test.js.map +1 -0
  717. package/dist/types/utils/searchParams.js +8 -0
  718. package/dist/types/utils/searchParams.js.map +1 -0
  719. package/dist/types/utils/sleep.js +6 -0
  720. package/dist/types/utils/sleep.js.map +1 -0
  721. package/dist/types/utils/slug.test.js +129 -0
  722. package/dist/types/utils/slug.test.js.map +1 -0
  723. package/dist/types/utils/slugs.js +55 -0
  724. package/dist/types/utils/slugs.js.map +1 -0
  725. package/dist/types/utils/subtotals.js +4 -0
  726. package/dist/types/utils/subtotals.js.map +1 -0
  727. package/dist/types/utils/time.js +25 -0
  728. package/dist/types/utils/time.js.map +1 -0
  729. package/dist/types/utils/timeFrames.js +529 -0
  730. package/dist/types/utils/timeFrames.js.map +1 -0
  731. package/dist/types/utils/timeFrames.test.js +50 -0
  732. package/dist/types/utils/timeFrames.test.js.map +1 -0
  733. package/dist/types/utils/virtualView.js +98 -0
  734. package/dist/types/utils/virtualView.js.map +1 -0
  735. package/dist/types/utils/warehouse.js +57 -0
  736. package/dist/types/utils/warehouse.js.map +1 -0
  737. package/dist/types/visualizations/CartesianChartDataModel.js +515 -0
  738. package/dist/types/visualizations/CartesianChartDataModel.js.map +1 -0
  739. package/dist/types/visualizations/PieChartDataModel.js +258 -0
  740. package/dist/types/visualizations/PieChartDataModel.js.map +1 -0
  741. package/dist/types/visualizations/TableDataModel.js +96 -0
  742. package/dist/types/visualizations/TableDataModel.js.map +1 -0
  743. package/dist/types/visualizations/chartTransformations.js +107 -0
  744. package/dist/types/visualizations/chartTransformations.js.map +1 -0
  745. package/dist/types/visualizations/helpers/getCartesianAxisFormatterConfig.js +142 -0
  746. package/dist/types/visualizations/helpers/getCartesianAxisFormatterConfig.js.map +1 -0
  747. package/dist/types/visualizations/types/IResultsRunner.js +2 -0
  748. package/dist/types/visualizations/types/IResultsRunner.js.map +1 -0
  749. package/dist/types/visualizations/types/index.js +78 -0
  750. package/dist/types/visualizations/types/index.js.map +1 -0
  751. package/package.json +1 -1
  752. package/dist/tsconfig.types.tsbuildinfo +0 -1
@@ -0,0 +1,1047 @@
1
+ import dayjs from 'dayjs';
2
+ import moment from 'moment';
3
+ import { Compact, CustomFormatType, DimensionType, FieldType, Format, MetricType, NumberSeparator, } from '../types/field';
4
+ import { TimeFrames } from '../types/timeFrames';
5
+ import { applyCustomFormat, applyDefaultFormat, convertCustomFormatToFormatExpression, currencies, formatItemValue, formatNumberValue, formatValueWithExpression, getCustomFormatFromLegacy, isMomentInput, } from './formatting';
6
+ import { additionalMetric, dimension, metric, tableCalculation, } from './formatting.mock';
7
+ describe('Formatting', () => {
8
+ describe('convert legacy Format type', () => {
9
+ [Format.KM, Format.MI].forEach((format) => {
10
+ test(`when it is ${format.toUpperCase()} getCustomFormatFromLegacy should return the correct CustomFormat options`, () => {
11
+ expect(getCustomFormatFromLegacy({ format })).toEqual({
12
+ type: CustomFormatType.NUMBER,
13
+ suffix: ` ${format}`,
14
+ compact: undefined,
15
+ round: undefined,
16
+ });
17
+ });
18
+ });
19
+ [Format.EUR, Format.GBP, Format.USD].forEach((format) => {
20
+ test(`when it is ${format.toUpperCase()} getCustomFormatFromLegacy should return the correct CustomFormat options`, () => {
21
+ expect(getCustomFormatFromLegacy({ format })).toEqual({
22
+ type: CustomFormatType.CURRENCY,
23
+ currency: format.toUpperCase(),
24
+ compact: undefined,
25
+ round: undefined,
26
+ });
27
+ });
28
+ });
29
+ test(`when it is ${Format.PERCENT.toUpperCase()} getCustomFormatFromLegacy should return the correct CustomFormat options`, () => {
30
+ expect(getCustomFormatFromLegacy({ format: Format.PERCENT })).toEqual({
31
+ type: CustomFormatType.PERCENT,
32
+ compact: undefined,
33
+ round: undefined,
34
+ });
35
+ });
36
+ test(`when it is ${Format.ID.toUpperCase()} getCustomFormatFromLegacy should return the correct CustomFormat options`, () => {
37
+ expect(getCustomFormatFromLegacy({ format: Format.ID })).toEqual({
38
+ type: CustomFormatType.ID,
39
+ });
40
+ });
41
+ });
42
+ describe('applying CustomFormat to value', () => {
43
+ describe('when using legacy format', () => {
44
+ test('if Format is legacy distance unit it should return the right format', () => {
45
+ expect(applyCustomFormat(5, getCustomFormatFromLegacy({ format: Format.KM }))).toEqual('5 km');
46
+ expect(applyCustomFormat(5, getCustomFormatFromLegacy({
47
+ format: Format.MI,
48
+ }))).toEqual('5 mi');
49
+ });
50
+ test('if Format is currency unit it should return the right format', () => {
51
+ expect(applyCustomFormat(5, {
52
+ type: CustomFormatType.CURRENCY,
53
+ currency: Format.USD,
54
+ })).toEqual('$5.00');
55
+ expect(applyCustomFormat(5, {
56
+ type: CustomFormatType.CURRENCY,
57
+ currency: Format.GBP,
58
+ })).toEqual('£5.00');
59
+ expect(applyCustomFormat(5, {
60
+ type: CustomFormatType.CURRENCY,
61
+ currency: Format.EUR,
62
+ })).toEqual('€5.00');
63
+ expect(applyCustomFormat(5, {
64
+ type: CustomFormatType.CURRENCY,
65
+ currency: Format.JPY,
66
+ })).toEqual('¥5');
67
+ expect(applyCustomFormat(5, {
68
+ type: CustomFormatType.CURRENCY,
69
+ currency: Format.DKK,
70
+ })).toEqual('DKK 5.00');
71
+ });
72
+ test('if Format is percent it should return the right format', () => {
73
+ const percentFormat = {
74
+ type: CustomFormatType.PERCENT,
75
+ };
76
+ expect(applyCustomFormat(5, percentFormat)).toEqual('500%');
77
+ expect(applyCustomFormat(0.05, percentFormat)).toEqual('5%');
78
+ expect(applyCustomFormat('5', percentFormat)).toEqual('500%');
79
+ expect(applyCustomFormat('foo', percentFormat)).toEqual('foo');
80
+ expect(applyCustomFormat(false, percentFormat)).toEqual('false');
81
+ });
82
+ test('if Format is undefined it should return the right format', () => {
83
+ expect(applyCustomFormat(1103)).toEqual('1,103');
84
+ expect(applyCustomFormat(5)).toEqual('5');
85
+ });
86
+ test('if Format is id it should return the right format', () => {
87
+ // ids are not comma separated
88
+ expect(applyCustomFormat(1019, { type: CustomFormatType.ID })).toEqual('1019');
89
+ });
90
+ });
91
+ describe('when applying round', () => {
92
+ test('if round is undefined it should keep up to 3 decimal places', () => {
93
+ expect(applyCustomFormat(5.9)).toEqual('5.9');
94
+ expect(applyCustomFormat(5.99)).toEqual('5.99');
95
+ expect(applyCustomFormat(5.999)).toEqual('5.999');
96
+ expect(applyCustomFormat(5.9999)).toEqual('6');
97
+ expect(applyCustomFormat(5.99999)).toEqual('6');
98
+ });
99
+ test('when round zero it should return the right round', () => {
100
+ const roundZeroFormat = {
101
+ type: CustomFormatType.NUMBER,
102
+ round: 0,
103
+ };
104
+ expect(applyCustomFormat(1, roundZeroFormat)).toEqual('1');
105
+ expect(applyCustomFormat(10, roundZeroFormat)).toEqual('10');
106
+ expect(applyCustomFormat(100, roundZeroFormat)).toEqual('100');
107
+ expect(applyCustomFormat(5, roundZeroFormat)).toEqual('5');
108
+ expect(applyCustomFormat(5.001, roundZeroFormat)).toEqual('5');
109
+ expect(applyCustomFormat(0.001, roundZeroFormat)).toEqual('0');
110
+ expect(applyCustomFormat(1000, roundZeroFormat)).toEqual('1,000');
111
+ expect(applyCustomFormat(10000, roundZeroFormat)).toEqual('10,000');
112
+ expect(applyCustomFormat(100000, roundZeroFormat)).toEqual('100,000');
113
+ expect(applyCustomFormat(1000000, roundZeroFormat)).toEqual('1,000,000');
114
+ expect(applyCustomFormat(5.9999999, roundZeroFormat)).toEqual('6');
115
+ });
116
+ test('when round is positive number it should return the right round', () => {
117
+ const roundTwoFormat = {
118
+ type: CustomFormatType.NUMBER,
119
+ round: 2,
120
+ };
121
+ expect(applyCustomFormat(5, roundTwoFormat)).toEqual('5.00');
122
+ expect(applyCustomFormat('foo', roundTwoFormat)).toEqual('foo');
123
+ expect(applyCustomFormat(5.001, roundTwoFormat)).toEqual('5.00');
124
+ expect(applyCustomFormat(5.555, roundTwoFormat)).toEqual('5.56');
125
+ expect(applyCustomFormat(5.5555, roundTwoFormat)).toEqual('5.56');
126
+ expect(applyCustomFormat(5.9999999, roundTwoFormat)).toEqual('6.00');
127
+ expect(applyCustomFormat(false, roundTwoFormat)).toEqual('false');
128
+ const roundTenFormat = {
129
+ type: CustomFormatType.NUMBER,
130
+ round: 10,
131
+ };
132
+ expect(applyCustomFormat(5, roundTenFormat)).toEqual('5.0000000000');
133
+ expect(applyCustomFormat(5.001, roundTenFormat)).toEqual('5.0010000000');
134
+ expect(applyCustomFormat(5.9999999, roundTenFormat)).toEqual('5.9999999000');
135
+ });
136
+ test('when round is negative number it should return the right round', () => {
137
+ const number = 123456789.12345;
138
+ expect(formatNumberValue(number, {
139
+ type: CustomFormatType.DEFAULT,
140
+ round: -1,
141
+ })).toEqual('123,456,790');
142
+ expect(formatNumberValue(number, {
143
+ type: CustomFormatType.DEFAULT,
144
+ round: -2,
145
+ })).toEqual('123,456,800');
146
+ expect(formatNumberValue(number, {
147
+ type: CustomFormatType.DEFAULT,
148
+ round: -3,
149
+ })).toEqual('123,457,000');
150
+ expect(formatNumberValue(number, {
151
+ type: CustomFormatType.DEFAULT,
152
+ round: -99,
153
+ })).toEqual('100,000,000');
154
+ });
155
+ });
156
+ test('applyCustomFormat should return the right format and round', () => {
157
+ expect(applyCustomFormat(5, {
158
+ type: CustomFormatType.NUMBER,
159
+ suffix: ` ${Format.KM}`,
160
+ round: 2,
161
+ })).toEqual('5.00 km');
162
+ expect(applyCustomFormat(5, {
163
+ type: CustomFormatType.NUMBER,
164
+ suffix: ` ${Format.KM}`,
165
+ round: -2,
166
+ })).toEqual('5 km');
167
+ expect(applyCustomFormat(5, {
168
+ type: CustomFormatType.NUMBER,
169
+ suffix: ` ${Format.MI}`,
170
+ round: 4,
171
+ })).toEqual('5.0000 mi');
172
+ expect(applyCustomFormat(5, {
173
+ type: CustomFormatType.NUMBER,
174
+ suffix: ` ${Format.MI}`,
175
+ round: -4,
176
+ })).toEqual('5 mi');
177
+ expect(applyCustomFormat(5, {
178
+ type: CustomFormatType.CURRENCY,
179
+ currency: Format.USD,
180
+ round: 2,
181
+ })).toEqual('$5.00');
182
+ expect(applyCustomFormat(5.0, {
183
+ type: CustomFormatType.CURRENCY,
184
+ currency: Format.USD,
185
+ round: 0,
186
+ })).toEqual('$5');
187
+ expect(applyCustomFormat(5, {
188
+ type: CustomFormatType.CURRENCY,
189
+ currency: Format.USD,
190
+ round: -2,
191
+ })).toEqual('$5');
192
+ expect(applyCustomFormat(5.25, {
193
+ type: CustomFormatType.CURRENCY,
194
+ currency: Format.USD,
195
+ round: -1,
196
+ })).toEqual('$5');
197
+ expect(applyCustomFormat('5.0000', {
198
+ type: CustomFormatType.CURRENCY,
199
+ currency: Format.USD,
200
+ round: 2,
201
+ })).toEqual('$5.00');
202
+ expect(applyCustomFormat(5, {
203
+ type: CustomFormatType.CURRENCY,
204
+ currency: Format.GBP,
205
+ round: 2,
206
+ })).toEqual('£5.00');
207
+ expect(applyCustomFormat(5, {
208
+ type: CustomFormatType.CURRENCY,
209
+ currency: Format.GBP,
210
+ round: -2,
211
+ })).toEqual('£5');
212
+ expect(applyCustomFormat(5.25, {
213
+ type: CustomFormatType.CURRENCY,
214
+ currency: Format.GBP,
215
+ round: -2,
216
+ })).toEqual('£5');
217
+ expect(applyCustomFormat(5, {
218
+ type: CustomFormatType.CURRENCY,
219
+ currency: Format.EUR,
220
+ round: 2,
221
+ })).toEqual('€5.00');
222
+ expect(applyCustomFormat(5, {
223
+ type: CustomFormatType.CURRENCY,
224
+ currency: Format.EUR,
225
+ round: -2,
226
+ })).toEqual('€5');
227
+ expect(applyCustomFormat(5.25, {
228
+ type: CustomFormatType.CURRENCY,
229
+ currency: Format.EUR,
230
+ round: -1,
231
+ })).toEqual('€5');
232
+ expect(applyCustomFormat(5, {
233
+ type: CustomFormatType.PERCENT,
234
+ round: 2,
235
+ })).toEqual('500.00%');
236
+ expect(applyCustomFormat(0.05, {
237
+ type: CustomFormatType.PERCENT,
238
+ round: 2,
239
+ })).toEqual('5.00%');
240
+ expect(applyCustomFormat('5', {
241
+ type: CustomFormatType.PERCENT,
242
+ round: 2,
243
+ })).toEqual('500.00%');
244
+ expect(applyCustomFormat(0.0511, {
245
+ type: CustomFormatType.PERCENT,
246
+ round: 2,
247
+ })).toEqual('5.11%');
248
+ expect(applyCustomFormat(0.0511, {
249
+ type: CustomFormatType.PERCENT,
250
+ round: 4,
251
+ })).toEqual('5.1100%');
252
+ expect(applyCustomFormat('foo', {
253
+ type: CustomFormatType.PERCENT,
254
+ round: 2,
255
+ })).toEqual('foo');
256
+ expect(applyCustomFormat(false, {
257
+ type: CustomFormatType.PERCENT,
258
+ round: 2,
259
+ })).toEqual('false');
260
+ expect(applyCustomFormat(0.05, {
261
+ type: CustomFormatType.PERCENT,
262
+ round: -2,
263
+ })).toEqual('5%');
264
+ expect(applyCustomFormat('5', {
265
+ type: CustomFormatType.PERCENT,
266
+ round: -2,
267
+ })).toEqual('500%');
268
+ });
269
+ describe('when applying compact', () => {
270
+ const K = Compact.THOUSANDS;
271
+ const M = Compact.MILLIONS;
272
+ const B = Compact.BILLIONS;
273
+ const T = Compact.TRILLIONS;
274
+ const thousandsConfig = {
275
+ type: CustomFormatType.NUMBER,
276
+ compact: K,
277
+ };
278
+ const millionsConfig = {
279
+ type: CustomFormatType.NUMBER,
280
+ compact: M,
281
+ };
282
+ const billionsConfig = {
283
+ type: CustomFormatType.NUMBER,
284
+ compact: B,
285
+ };
286
+ const trillionsConfig = {
287
+ type: CustomFormatType.NUMBER,
288
+ compact: T,
289
+ };
290
+ test('it should return the right style', () => {
291
+ expect(applyCustomFormat(5, thousandsConfig)).toEqual('0.005K');
292
+ expect(applyCustomFormat(5, millionsConfig)).toEqual('0M');
293
+ expect(applyCustomFormat(500000, billionsConfig)).toEqual('0.001B');
294
+ expect(applyCustomFormat(5, billionsConfig)).toEqual('0B');
295
+ expect(applyCustomFormat(5000000000, trillionsConfig)).toEqual('0.005T');
296
+ });
297
+ test('when applying round it should return the right style', () => {
298
+ expect(applyCustomFormat(5, { ...millionsConfig, round: 2 })).toEqual('0.00M');
299
+ expect(applyCustomFormat(5400000, { ...millionsConfig, round: 0 })).toEqual('5M');
300
+ expect(applyCustomFormat(4956789123, {
301
+ ...trillionsConfig,
302
+ round: -1,
303
+ })).toEqual('0.005T');
304
+ });
305
+ test('with legacy distance format it should return the right format', () => {
306
+ expect(applyCustomFormat(5000, getCustomFormatFromLegacy({
307
+ compact: K,
308
+ round: 2,
309
+ format: Format.KM,
310
+ }))).toEqual('5.00K km');
311
+ expect(applyCustomFormat(50000, getCustomFormatFromLegacy({
312
+ compact: K,
313
+ round: 4,
314
+ format: Format.MI,
315
+ }))).toEqual('50.0000K mi');
316
+ });
317
+ test('with legacy currency format it should return the right format', () => {
318
+ expect(applyCustomFormat(5000, getCustomFormatFromLegacy({
319
+ compact: K,
320
+ round: 2,
321
+ format: Format.USD,
322
+ }))).toEqual('$5.00K');
323
+ expect(applyCustomFormat(5000000, getCustomFormatFromLegacy({
324
+ compact: K,
325
+ round: 2,
326
+ format: Format.USD,
327
+ }))).toEqual('$5,000.00K');
328
+ expect(applyCustomFormat(5000000, getCustomFormatFromLegacy({
329
+ compact: M,
330
+ round: 2,
331
+ format: Format.USD,
332
+ }))).toEqual('$5.00M');
333
+ expect(applyCustomFormat(4, getCustomFormatFromLegacy({
334
+ compact: K,
335
+ round: 2,
336
+ format: Format.USD,
337
+ }))).toEqual('$0.00K');
338
+ expect(applyCustomFormat(4, getCustomFormatFromLegacy({
339
+ compact: K,
340
+ round: 3,
341
+ format: Format.USD,
342
+ }))).toEqual('$0.004K');
343
+ expect(applyCustomFormat(4000, getCustomFormatFromLegacy({
344
+ compact: K,
345
+ format: Format.USD,
346
+ }))).toEqual('$4.00K');
347
+ expect(applyCustomFormat(5000000, getCustomFormatFromLegacy({
348
+ compact: M,
349
+ round: 2,
350
+ format: Format.USD,
351
+ }))).toEqual('$5.00M');
352
+ expect(applyCustomFormat(5000000000, getCustomFormatFromLegacy({
353
+ compact: M,
354
+ round: 2,
355
+ format: Format.USD,
356
+ }))).toEqual('$5,000.00M');
357
+ expect(applyCustomFormat(5000000000, getCustomFormatFromLegacy({
358
+ compact: B,
359
+ round: 2,
360
+ format: Format.USD,
361
+ }))).toEqual('$5.00B');
362
+ expect(applyCustomFormat(5000.0, getCustomFormatFromLegacy({
363
+ compact: K,
364
+ round: 0,
365
+ format: Format.USD,
366
+ }))).toEqual('$5K');
367
+ expect(applyCustomFormat('5000', getCustomFormatFromLegacy({
368
+ compact: K,
369
+ round: 2,
370
+ format: Format.USD,
371
+ }))).toEqual('$5.00K');
372
+ expect(applyCustomFormat(5000, getCustomFormatFromLegacy({
373
+ compact: K,
374
+ round: 2,
375
+ format: Format.GBP,
376
+ }))).toEqual('£5.00K');
377
+ expect(applyCustomFormat(5000, getCustomFormatFromLegacy({
378
+ compact: K,
379
+ round: 2,
380
+ format: Format.EUR,
381
+ }))).toEqual('€5.00K');
382
+ });
383
+ test('with legacy percent format it should return the right format', () => {
384
+ expect(applyCustomFormat(0.05, getCustomFormatFromLegacy({
385
+ compact: K,
386
+ round: 2,
387
+ format: Format.PERCENT,
388
+ }))).toEqual('5.00%');
389
+ });
390
+ test('suports compact alias', () => {
391
+ expect(applyCustomFormat(1000, {
392
+ type: CustomFormatType.NUMBER,
393
+ compact: 'K',
394
+ })).toEqual('1K');
395
+ expect(applyCustomFormat(1000, {
396
+ type: CustomFormatType.NUMBER,
397
+ compact: 'thousand',
398
+ })).toEqual('1K');
399
+ expect(applyCustomFormat(1000000, {
400
+ type: CustomFormatType.NUMBER,
401
+ compact: 'M',
402
+ })).toEqual('1M');
403
+ expect(applyCustomFormat(1000000, {
404
+ type: CustomFormatType.NUMBER,
405
+ compact: 'million',
406
+ })).toEqual('1M');
407
+ expect(applyCustomFormat(1000000000, {
408
+ type: CustomFormatType.NUMBER,
409
+ compact: 'B',
410
+ })).toEqual('1B');
411
+ expect(applyCustomFormat(1000000000, {
412
+ type: CustomFormatType.NUMBER,
413
+ compact: 'billion',
414
+ })).toEqual('1B');
415
+ expect(applyCustomFormat(1000000000000, {
416
+ type: CustomFormatType.NUMBER,
417
+ compact: 'T',
418
+ })).toEqual('1T');
419
+ expect(applyCustomFormat(1000000000000, {
420
+ type: CustomFormatType.NUMBER,
421
+ compact: 'trillion',
422
+ })).toEqual('1T');
423
+ });
424
+ });
425
+ });
426
+ describe('formatItemValue', () => {
427
+ test('formatItemValue should return the right format when field is undefined', () => {
428
+ expect(formatItemValue(undefined, undefined)).toEqual('-');
429
+ expect(formatItemValue(undefined, null)).toEqual('∅');
430
+ expect(formatItemValue(undefined, '5')).toEqual('5');
431
+ expect(formatItemValue(undefined, 5)).toEqual('5');
432
+ });
433
+ test('formatItemValue should return the right format when field is Dimension', () => {
434
+ expect(formatItemValue(dimension, undefined)).toEqual('-');
435
+ expect(formatItemValue(dimension, null)).toEqual('∅');
436
+ expect(formatItemValue({ ...dimension, type: DimensionType.STRING }, '5')).toEqual('5');
437
+ expect(formatItemValue({ ...dimension, type: DimensionType.NUMBER }, 5)).toEqual('5');
438
+ expect(formatItemValue({ ...dimension, type: DimensionType.STRING }, 132323123)).toEqual('132323123');
439
+ expect(formatItemValue({ ...dimension, type: DimensionType.BOOLEAN }, true)).toEqual('True');
440
+ expect(formatItemValue({
441
+ ...dimension,
442
+ type: DimensionType.DATE,
443
+ }, new Date('2021-03-10T00:00:00.000Z'))).toEqual('2021-03-10');
444
+ expect(formatItemValue({
445
+ ...dimension,
446
+ type: DimensionType.TIMESTAMP,
447
+ }, new Date('2021-03-10T00:00:00.000Z'))).toEqual('2021-03-10, 00:00:00:000 (+00:00)');
448
+ expect(formatItemValue({
449
+ ...dimension,
450
+ timeInterval: TimeFrames.YEAR_NUM,
451
+ type: DimensionType.NUMBER,
452
+ }, 2021)).toEqual('2021');
453
+ });
454
+ test('formatItemValue should return the right format when field is Metric', () => {
455
+ expect(formatItemValue(metric, undefined)).toEqual('-');
456
+ expect(formatItemValue(metric, null)).toEqual('∅');
457
+ expect(formatItemValue({ ...metric, type: MetricType.AVERAGE }, 5)).toEqual('5');
458
+ expect(formatItemValue({ ...metric, type: MetricType.COUNT }, 5)).toEqual('5');
459
+ expect(formatItemValue({ ...metric, type: MetricType.COUNT_DISTINCT }, 5)).toEqual('5');
460
+ expect(formatItemValue({ ...metric, type: MetricType.SUM }, 5)).toEqual('5');
461
+ expect(formatItemValue({ ...metric, type: MetricType.MIN }, 5000)).toEqual('5,000');
462
+ expect(formatItemValue({ ...metric, type: MetricType.MAX }, 5000)).toEqual('5,000');
463
+ expect(formatItemValue({ ...metric, type: MetricType.MIN }, new Date('2021-03-10T00:00:00.000Z'))).toEqual('2021-03-10, 00:00:00:000 (+00:00)');
464
+ expect(formatItemValue({ ...metric, type: MetricType.MAX }, new Date('2021-03-10T00:00:00.000Z'))).toEqual('2021-03-10, 00:00:00:000 (+00:00)');
465
+ expect(formatItemValue({
466
+ ...metric,
467
+ type: MetricType.NUMBER,
468
+ round: 2,
469
+ }, '1.123456123123')).toEqual('1.12');
470
+ expect(formatItemValue({
471
+ ...metric,
472
+ type: MetricType.NUMBER,
473
+ compact: Compact.THOUSANDS,
474
+ }, 1000)).toEqual('1K');
475
+ });
476
+ describe('formatItemValue timestamp handling', () => {
477
+ const mockTimestampField = {
478
+ type: DimensionType.TIMESTAMP,
479
+ name: 'test_timestamp',
480
+ table: 'test',
481
+ fieldType: FieldType.DIMENSION,
482
+ label: 'Test Timestamp',
483
+ sql: 'test.timestamp',
484
+ tableLabel: 'Test',
485
+ hidden: false,
486
+ };
487
+ test('should handle valid timestamp formats', () => {
488
+ const validTimestamps = [
489
+ '2020-08-11T16:44:00Z',
490
+ '2020-08-11 16:44:00',
491
+ '2020-08-11T16:44:00.123Z',
492
+ new Date('2020-08-11T16:44:00Z'),
493
+ moment('2020-08-11T16:44:00Z'),
494
+ ];
495
+ validTimestamps.forEach((timestamp) => {
496
+ const result = formatItemValue(mockTimestampField, timestamp);
497
+ expect(result).not.toBe('NaT');
498
+ expect(result).not.toContain('Invalid');
499
+ });
500
+ });
501
+ test('should return NaT for invalid formats', () => {
502
+ const invalidTimestamps = [
503
+ 'invalid-date-string',
504
+ '2020-13-45',
505
+ '2020-08-11T25:00:00',
506
+ '',
507
+ 'not-a-date',
508
+ '2025-07-08 23:59:58.656000 Asia/Bangkok',
509
+ ];
510
+ invalidTimestamps.forEach((timestamp) => {
511
+ const result = formatItemValue(mockTimestampField, timestamp);
512
+ expect(result).toBe('NaT');
513
+ });
514
+ });
515
+ });
516
+ });
517
+ describe('additional metric formatting', () => {
518
+ test('format additional metric with custom format DATE', () => {
519
+ expect(formatItemValue({
520
+ ...additionalMetric,
521
+ type: MetricType.MIN,
522
+ formatOptions: { type: CustomFormatType.DATE },
523
+ }, new Date('2021-03-10T00:00:00.000Z'))).toEqual('2021-03-10');
524
+ expect(formatItemValue({
525
+ ...additionalMetric,
526
+ type: MetricType.MAX,
527
+ formatOptions: {
528
+ type: CustomFormatType.DATE,
529
+ timeInterval: TimeFrames.DAY,
530
+ },
531
+ }, new Date('2021-03-10T00:00:00.000Z'))).toEqual('2021-03-10');
532
+ expect(formatItemValue({
533
+ ...additionalMetric,
534
+ type: MetricType.MIN,
535
+ formatOptions: {
536
+ type: CustomFormatType.DATE,
537
+ timeInterval: TimeFrames.YEAR,
538
+ },
539
+ }, new Date('2021-03-10T00:00:00.000Z'))).toEqual('2021');
540
+ expect(formatItemValue({
541
+ ...additionalMetric,
542
+ type: MetricType.MAX,
543
+ formatOptions: {
544
+ type: CustomFormatType.DATE,
545
+ timeInterval: TimeFrames.MONTH,
546
+ },
547
+ }, new Date('2021-03-10T00:00:00.000Z'))).toEqual('2021-03');
548
+ });
549
+ test('format additional metric with custom format TIMESTAMP', () => {
550
+ expect(formatItemValue({
551
+ ...additionalMetric,
552
+ type: MetricType.MIN,
553
+ formatOptions: { type: CustomFormatType.TIMESTAMP },
554
+ }, new Date('2021-03-10T00:00:00.000Z'))).toEqual('2021-03-10, 00:00:00:000 (+00:00)');
555
+ expect(formatItemValue({
556
+ ...additionalMetric,
557
+ type: MetricType.MAX,
558
+ formatOptions: {
559
+ type: CustomFormatType.TIMESTAMP,
560
+ timeInterval: TimeFrames.HOUR,
561
+ },
562
+ }, new Date('2021-03-10T00:00:00.000Z'))).toEqual('2021-03-10, 00 (+00:00)');
563
+ expect(formatItemValue({
564
+ ...additionalMetric,
565
+ type: MetricType.MIN,
566
+ formatOptions: {
567
+ type: CustomFormatType.TIMESTAMP,
568
+ timeInterval: TimeFrames.MINUTE,
569
+ },
570
+ }, new Date('2021-03-10T00:00:00.000Z'))).toEqual('2021-03-10, 00:00 (+00:00)');
571
+ expect(formatItemValue({
572
+ ...additionalMetric,
573
+ type: MetricType.MAX,
574
+ formatOptions: {
575
+ type: CustomFormatType.TIMESTAMP,
576
+ timeInterval: TimeFrames.SECOND,
577
+ },
578
+ }, new Date('2021-03-10T00:00:00.000Z'))).toEqual('2021-03-10, 00:00:00 (+00:00)');
579
+ });
580
+ });
581
+ describe('format item value', () => {
582
+ test('formatItemValue should return the right format when field is undefined', () => {
583
+ expect(formatItemValue(undefined, undefined)).toEqual('-');
584
+ expect(formatItemValue(undefined, null)).toEqual('∅');
585
+ expect(formatItemValue(undefined, '5')).toEqual('5');
586
+ expect(formatItemValue(undefined, 5)).toEqual('5');
587
+ });
588
+ test('formatItemValue should return the right format when field is table calculation', () => {
589
+ expect(formatItemValue(tableCalculation, undefined)).toEqual('-');
590
+ expect(formatItemValue(tableCalculation, null)).toEqual('∅');
591
+ expect(formatItemValue(tableCalculation, '5')).toEqual('5');
592
+ expect(formatItemValue(tableCalculation, 5)).toEqual('5');
593
+ });
594
+ });
595
+ describe('format table calculation', () => {
596
+ test('table calculation with default format', () => {
597
+ const defaultFormat = {
598
+ ...tableCalculation,
599
+ format: { type: CustomFormatType.DEFAULT },
600
+ };
601
+ expect(formatItemValue(defaultFormat, undefined)).toEqual('-');
602
+ expect(formatItemValue(defaultFormat, null)).toEqual('∅');
603
+ expect(formatItemValue(defaultFormat, '5')).toEqual('5');
604
+ expect(formatItemValue(defaultFormat, 5)).toEqual('5');
605
+ });
606
+ test('table calculation with default format and extra arguments', () => {
607
+ // This round or separator should not affect default format
608
+ const withExtraFormat = {
609
+ ...tableCalculation,
610
+ format: {
611
+ type: CustomFormatType.DEFAULT,
612
+ round: 2,
613
+ separator: NumberSeparator.COMMA_PERIOD,
614
+ },
615
+ };
616
+ expect(formatItemValue(withExtraFormat, undefined)).toEqual('-');
617
+ expect(formatItemValue(withExtraFormat, null)).toEqual('∅');
618
+ expect(formatItemValue(withExtraFormat, '5')).toEqual('5');
619
+ expect(formatItemValue(withExtraFormat, 5)).toEqual('5');
620
+ });
621
+ test('table calculation with percent format', () => {
622
+ const percentFormat = {
623
+ ...tableCalculation,
624
+ format: { type: CustomFormatType.PERCENT },
625
+ };
626
+ expect(formatItemValue(percentFormat, undefined)).toEqual('-');
627
+ expect(formatItemValue(percentFormat, null)).toEqual('∅');
628
+ expect(formatItemValue(percentFormat, '0.05')).toEqual('5%');
629
+ expect(formatItemValue(percentFormat, 0.05)).toEqual('5%');
630
+ expect(formatItemValue(percentFormat, 1)).toEqual('100%');
631
+ expect(formatItemValue(percentFormat, 5)).toEqual('500%');
632
+ expect(formatItemValue(percentFormat, '0.05123')).toEqual('5.123%');
633
+ });
634
+ test('table calculation with percent format and round', () => {
635
+ const percentFormat = {
636
+ ...tableCalculation,
637
+ format: { type: CustomFormatType.PERCENT, round: 1 },
638
+ };
639
+ expect(formatItemValue(percentFormat, undefined)).toEqual('-');
640
+ expect(formatItemValue(percentFormat, null)).toEqual('∅');
641
+ expect(formatItemValue(percentFormat, '0.05')).toEqual('5.0%');
642
+ expect(formatItemValue(percentFormat, 0.05)).toEqual('5.0%');
643
+ expect(formatItemValue(percentFormat, 1)).toEqual('100.0%');
644
+ expect(formatItemValue(percentFormat, 5)).toEqual('500.0%');
645
+ expect(formatItemValue(percentFormat, '0.05123')).toEqual('5.1%');
646
+ });
647
+ test('table calculation with percent format and number separator', () => {
648
+ const percentFormat = {
649
+ ...tableCalculation,
650
+ format: {
651
+ type: CustomFormatType.PERCENT,
652
+ round: 2,
653
+ separator: NumberSeparator.PERIOD_COMMA,
654
+ },
655
+ };
656
+ expect(formatItemValue(percentFormat, undefined)).toEqual('-');
657
+ expect(formatItemValue(percentFormat, null)).toEqual('∅');
658
+ expect(formatItemValue(percentFormat, '0.05')).toEqual('5,00%');
659
+ expect(formatItemValue(percentFormat, '0.05123')).toEqual('5,12%');
660
+ });
661
+ test('format number separator', () => {
662
+ const number = 123456789.12345;
663
+ expect(formatNumberValue(number, {
664
+ type: CustomFormatType.DEFAULT,
665
+ round: 0,
666
+ separator: NumberSeparator.COMMA_PERIOD,
667
+ })).toEqual('123,456,789');
668
+ expect(formatNumberValue(number, {
669
+ type: CustomFormatType.DEFAULT,
670
+ round: 0,
671
+ separator: NumberSeparator.PERIOD_COMMA,
672
+ })).toEqual('123.456.789');
673
+ expect(formatNumberValue(number, {
674
+ type: CustomFormatType.DEFAULT,
675
+ round: 2,
676
+ separator: NumberSeparator.SPACE_PERIOD,
677
+ })).toEqual('123 456 789.12');
678
+ expect(formatNumberValue(number, {
679
+ type: CustomFormatType.DEFAULT,
680
+ round: 2,
681
+ separator: NumberSeparator.NO_SEPARATOR_PERIOD,
682
+ })).toEqual('123456789.12');
683
+ });
684
+ test('available currencies', () => {
685
+ const symbols = currencies.map((currency) => {
686
+ const format = Intl.NumberFormat(undefined, {
687
+ style: 'currency',
688
+ currency,
689
+ });
690
+ return format.format(1).replace(' ', ' ');
691
+ });
692
+ expect(symbols).toEqual([
693
+ '$1.00',
694
+ '€1.00',
695
+ '£1.00',
696
+ '¥1',
697
+ 'DKK 1.00',
698
+ 'CHF 1.00',
699
+ 'CA$1.00',
700
+ 'A$1.00',
701
+ 'CN¥1.00',
702
+ 'ARS 1.00',
703
+ 'R$1.00',
704
+ 'CLP 1',
705
+ 'COP 1.00',
706
+ 'CZK 1.00',
707
+ 'HK$1.00',
708
+ 'HUF 1.00',
709
+ '₹1.00',
710
+ '₪1.00',
711
+ '₩1',
712
+ 'MYR 1.00',
713
+ 'MX$1.00',
714
+ 'MAD 1.00',
715
+ 'NZ$1.00',
716
+ 'NOK 1.00',
717
+ '₱1.00',
718
+ 'PLN 1.00',
719
+ 'RUB 1.00',
720
+ 'SAR 1.00',
721
+ 'SGD 1.00',
722
+ 'ZAR 1.00',
723
+ 'SEK 1.00',
724
+ 'NT$1.00',
725
+ 'THB 1.00',
726
+ 'TRY 1.00',
727
+ '₫1',
728
+ ]);
729
+ });
730
+ test('convert currencies with default settings', () => {
731
+ expect(currencies.slice(0, 4).map((currency) => applyCustomFormat(12345.1235, {
732
+ type: CustomFormatType.CURRENCY,
733
+ currency,
734
+ }))).toEqual(['$12,345.12', '€12,345.12', '£12,345.12', '¥12,345']);
735
+ // Number as string
736
+ expect(currencies.slice(0, 4).map((currency) => applyCustomFormat('12345.1235', {
737
+ type: CustomFormatType.CURRENCY,
738
+ currency,
739
+ }))).toEqual(['$12,345.12', '€12,345.12', '£12,345.12', '¥12,345']);
740
+ });
741
+ test('convert currencies with round', () => {
742
+ expect(currencies.slice(0, 4).map((currency) => applyCustomFormat(12345.1235, {
743
+ type: CustomFormatType.CURRENCY,
744
+ currency,
745
+ round: 3,
746
+ }))).toEqual([
747
+ '$12,345.124',
748
+ '€12,345.124',
749
+ '£12,345.124',
750
+ '¥12,345.124',
751
+ ]);
752
+ });
753
+ test('convert currencies with separator ', () => {
754
+ // Using PERIOD_COMMA changes the position of the currency symbol
755
+ expect(currencies.slice(0, 4).map((currency) => applyCustomFormat(12345.1235, {
756
+ type: CustomFormatType.CURRENCY,
757
+ currency,
758
+ separator: NumberSeparator.PERIOD_COMMA,
759
+ }))).toEqual([
760
+ '12.345,12 $',
761
+ '12.345,12 €',
762
+ '12.345,12 £',
763
+ '12.345 ¥',
764
+ ]);
765
+ });
766
+ test('convert currencies with compact ', () => {
767
+ expect(currencies.slice(0, 4).map((currency) => applyCustomFormat(12345.1235, {
768
+ type: CustomFormatType.CURRENCY,
769
+ currency,
770
+ compact: Compact.THOUSANDS,
771
+ }))).toEqual(['$12.35K', '€12.35K', '£12.35K', '¥12K']);
772
+ expect(currencies.slice(0, 4).map((currency) => applyCustomFormat(123456789.1235, {
773
+ type: CustomFormatType.CURRENCY,
774
+ currency,
775
+ compact: Compact.MILLIONS,
776
+ round: 0,
777
+ }))).toEqual(['$123M', '€123M', '£123M', '¥123M']);
778
+ });
779
+ test('convert numbers ', () => {
780
+ expect(applyCustomFormat(12345.56789, {
781
+ type: CustomFormatType.NUMBER,
782
+ })).toEqual('12,345.568');
783
+ expect(applyCustomFormat(12345.1235, {
784
+ type: CustomFormatType.NUMBER,
785
+ round: 2,
786
+ prefix: 'foo ',
787
+ suffix: ' bar',
788
+ compact: Compact.THOUSANDS,
789
+ })).toEqual('foo 12.35K bar');
790
+ // Number as string
791
+ expect(applyCustomFormat('12345.1235', {
792
+ type: CustomFormatType.NUMBER,
793
+ prefix: 'foo ',
794
+ suffix: ' bar',
795
+ })).toEqual('foo 12,345.124 bar');
796
+ });
797
+ test('convert table calculation formats with invalid numbers', () => {
798
+ // This method should return the original value if the value is not a number
799
+ const values = [
800
+ 'this is a string',
801
+ '',
802
+ undefined,
803
+ null,
804
+ true,
805
+ false,
806
+ ];
807
+ const expectedValue = [
808
+ 'this is a string',
809
+ '',
810
+ '-',
811
+ '∅',
812
+ 'true',
813
+ 'false',
814
+ ];
815
+ values.map((value, i) => expect(applyCustomFormat(value, {
816
+ type: CustomFormatType.DEFAULT,
817
+ })).toEqual(expectedValue[i]));
818
+ values.map((value, i) => expect(applyCustomFormat(value, {
819
+ type: CustomFormatType.CURRENCY,
820
+ currency: Format.USD,
821
+ })).toEqual(expectedValue[i]));
822
+ values.map((value, i) => expect(applyCustomFormat(value, {
823
+ type: CustomFormatType.CURRENCY,
824
+ currency: Format.USD,
825
+ round: 2,
826
+ compact: Compact.THOUSANDS,
827
+ separator: NumberSeparator.PERIOD_COMMA,
828
+ })).toEqual(expectedValue[i]));
829
+ values.map((value, i) => expect(applyCustomFormat(value, {
830
+ type: CustomFormatType.NUMBER,
831
+ })).toEqual(expectedValue[i]));
832
+ values.map((value, i) => expect(applyCustomFormat(value, {
833
+ type: CustomFormatType.NUMBER,
834
+ prefix: 'foo',
835
+ suffix: 'bar',
836
+ round: 2,
837
+ compact: Compact.THOUSANDS,
838
+ separator: NumberSeparator.PERIOD_COMMA,
839
+ })).toEqual(expectedValue[i]));
840
+ values.map((value, i) => expect(applyCustomFormat(value, {
841
+ type: CustomFormatType.PERCENT,
842
+ })).toEqual(expectedValue[i]));
843
+ values.map((value, i) => expect(applyCustomFormat(value, {
844
+ type: CustomFormatType.PERCENT,
845
+ round: 2,
846
+ separator: NumberSeparator.PERIOD_COMMA,
847
+ })).toEqual(expectedValue[i]));
848
+ });
849
+ test('formatValueWithExpression handles binary byte units correctly', () => {
850
+ // Test KIBIBYTES (should divide by 1024)
851
+ const kibibyteExpression = convertCustomFormatToFormatExpression({
852
+ type: CustomFormatType.BYTES_IEC,
853
+ compact: Compact.KIBIBYTES,
854
+ });
855
+ expect(kibibyteExpression).toEqual('#,##0.00"KiB"');
856
+ expect(formatValueWithExpression(kibibyteExpression, 2048)).toEqual('2.00KiB');
857
+ // Test MEBIBYTES (should divide by 1048576)
858
+ const mebibyteExpression = convertCustomFormatToFormatExpression({
859
+ type: CustomFormatType.BYTES_IEC,
860
+ compact: Compact.MEBIBYTES,
861
+ });
862
+ expect(mebibyteExpression).toEqual('#,##0.00"MiB"');
863
+ expect(formatValueWithExpression(mebibyteExpression, 2097152)).toEqual('2.00MiB');
864
+ // Test with rounding
865
+ const roundedExpression = convertCustomFormatToFormatExpression({
866
+ type: CustomFormatType.BYTES_IEC,
867
+ compact: Compact.KIBIBYTES,
868
+ round: 1,
869
+ });
870
+ expect(roundedExpression).toEqual('#,##0.0"KiB"');
871
+ expect(formatValueWithExpression(roundedExpression, 1536)).toEqual('1.5KiB');
872
+ });
873
+ test('backend scenario: formatOptions converted to format expression', () => {
874
+ // This simulates the exact scenario from the backend PR
875
+ // where formatOptions are converted to format expressions
876
+ const formatOptions = {
877
+ type: CustomFormatType.BYTES_IEC,
878
+ compact: Compact.KIBIBYTES,
879
+ };
880
+ // Backend calls convertCustomFormatToFormatExpression
881
+ const formatExpression = convertCustomFormatToFormatExpression(formatOptions);
882
+ expect(formatExpression).toEqual('#,##0.00"KiB"');
883
+ // Mock metric with format expression set by backend
884
+ const mockMetric = {
885
+ fieldType: FieldType.METRIC,
886
+ type: MetricType.NUMBER,
887
+ name: 'test_metric',
888
+ label: 'Test Metric',
889
+ table: 'test_table',
890
+ tableLabel: 'Test Table',
891
+ sql: 'test_sql',
892
+ hidden: false,
893
+ // Backend sets format expression instead of formatOptions
894
+ format: formatExpression || undefined,
895
+ };
896
+ // Frontend uses formatItemValue which should call formatValueWithExpression
897
+ const result = formatItemValue(mockMetric, 2048);
898
+ expect(result).toEqual('2.00KiB'); // Should be correctly divided by 1024
899
+ // Test larger values
900
+ expect(formatItemValue(mockMetric, 1024)).toEqual('1.00KiB');
901
+ expect(formatItemValue(mockMetric, 3072)).toEqual('3.00KiB');
902
+ });
903
+ });
904
+ describe('isMomentInput', () => {
905
+ test('should return true for moment object', () => {
906
+ expect(isMomentInput(moment())).toBe(true);
907
+ });
908
+ test('should return true for dayjs object', () => {
909
+ expect(isMomentInput(dayjs())).toBe(true);
910
+ });
911
+ test('should return true for dates', () => {
912
+ expect(isMomentInput(new Date())).toBe(true);
913
+ });
914
+ test('should return true for strings', () => {
915
+ expect(isMomentInput('2021-03-10')).toBe(true);
916
+ });
917
+ test('should return false for non-dates-strings-moment-dayjs types', () => {
918
+ expect(isMomentInput(undefined)).toBe(false);
919
+ expect(isMomentInput(null)).toBe(false);
920
+ });
921
+ });
922
+ describe('convertCustomFormatToFormatExpression', () => {
923
+ test('should convert format object to expression', () => {
924
+ const customFormats = [
925
+ {
926
+ type: CustomFormatType.CURRENCY,
927
+ currency: Format.USD,
928
+ },
929
+ {
930
+ type: CustomFormatType.CURRENCY,
931
+ currency: Format.JPY, // test JPY because it has no decimal
932
+ },
933
+ {
934
+ type: CustomFormatType.CURRENCY,
935
+ currency: Format.DKK, // test DKK because it has prefix instead of symbol
936
+ },
937
+ {
938
+ type: CustomFormatType.CURRENCY,
939
+ currency: Format.USD,
940
+ round: 0, // test with no round
941
+ },
942
+ {
943
+ type: CustomFormatType.CURRENCY,
944
+ currency: Format.USD,
945
+ round: 4, // test with extra round
946
+ },
947
+ {
948
+ type: CustomFormatType.CURRENCY,
949
+ currency: Format.USD,
950
+ compact: Compact.THOUSANDS, // test with compact
951
+ },
952
+ {
953
+ type: CustomFormatType.CURRENCY,
954
+ currency: Format.USD,
955
+ separator: NumberSeparator.COMMA_PERIOD, // test with separator
956
+ },
957
+ {
958
+ type: CustomFormatType.CURRENCY,
959
+ currency: Format.USD,
960
+ separator: NumberSeparator.NO_SEPARATOR_PERIOD, // test with no separator
961
+ },
962
+ {
963
+ type: CustomFormatType.CURRENCY,
964
+ currency: Format.USD,
965
+ // test with multiple options
966
+ compact: Compact.THOUSANDS,
967
+ round: 3,
968
+ separator: NumberSeparator.NO_SEPARATOR_PERIOD,
969
+ },
970
+ {
971
+ type: CustomFormatType.PERCENT,
972
+ },
973
+ {
974
+ type: CustomFormatType.PERCENT,
975
+ round: 0, // test with no round
976
+ },
977
+ {
978
+ type: CustomFormatType.PERCENT,
979
+ round: 3, // test with round
980
+ },
981
+ {
982
+ type: CustomFormatType.PERCENT,
983
+ separator: NumberSeparator.COMMA_PERIOD, // test with separator
984
+ },
985
+ {
986
+ type: CustomFormatType.NUMBER,
987
+ },
988
+ {
989
+ type: CustomFormatType.NUMBER,
990
+ round: 0, // test with no round
991
+ },
992
+ {
993
+ type: CustomFormatType.NUMBER,
994
+ round: 3, // test with round
995
+ },
996
+ {
997
+ type: CustomFormatType.NUMBER,
998
+ prefix: 'prefix', // test with prefix
999
+ },
1000
+ {
1001
+ type: CustomFormatType.NUMBER,
1002
+ suffix: 'suffix', // test with suffix
1003
+ },
1004
+ {
1005
+ type: CustomFormatType.NUMBER,
1006
+ // test with multiple options
1007
+ prefix: 'prefix',
1008
+ compact: Compact.THOUSANDS,
1009
+ round: 3,
1010
+ separator: NumberSeparator.NO_SEPARATOR_PERIOD,
1011
+ suffix: 'suffix',
1012
+ },
1013
+ ];
1014
+ customFormats.forEach((format) => {
1015
+ const value = 12345.1235;
1016
+ const formatExpression = convertCustomFormatToFormatExpression(format);
1017
+ // Check if the format expression was generated
1018
+ expect(formatExpression).not.toBe(null);
1019
+ const formattedValueWithCustomFormat = applyCustomFormat(value, format);
1020
+ const formattedValueWithFormatExpression = formatValueWithExpression(formatExpression, value);
1021
+ // Check if the formatted value is the same
1022
+ expect(formattedValueWithFormatExpression).toEqual(formattedValueWithCustomFormat);
1023
+ });
1024
+ });
1025
+ });
1026
+ describe('applyDefaultFormatting', () => {
1027
+ it('should handle boolean values', () => {
1028
+ expect(applyDefaultFormat(true)).toBe('true');
1029
+ expect(applyDefaultFormat(false)).toBe('false');
1030
+ });
1031
+ it('should handle falsey values', () => {
1032
+ expect(applyDefaultFormat(undefined)).toBe('-');
1033
+ expect(applyDefaultFormat(null)).toBe('∅');
1034
+ expect(applyDefaultFormat(0)).toBe('0');
1035
+ expect(applyDefaultFormat('')).toBe('');
1036
+ });
1037
+ it('should handle strings', () => {
1038
+ expect(applyDefaultFormat('foo')).toBe('foo');
1039
+ });
1040
+ it('should handle numbers', () => {
1041
+ expect(applyDefaultFormat(1234567)).toBe('1,234,567');
1042
+ expect(applyDefaultFormat(1234)).toBe('1,234');
1043
+ expect(applyDefaultFormat(-1234)).toBe('-1,234');
1044
+ });
1045
+ });
1046
+ });
1047
+ //# sourceMappingURL=formatting.test.js.map