@sqlrooms/mosaic 0.29.0-rc.1 → 0.29.0-rc.2

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 (202) hide show
  1. package/README.md +41 -2
  2. package/dist/MosaicChart.d.ts +20 -0
  3. package/dist/MosaicChart.d.ts.map +1 -0
  4. package/dist/MosaicChart.js +25 -0
  5. package/dist/MosaicChart.js.map +1 -0
  6. package/dist/MosaicChartBuilder.d.ts +32 -0
  7. package/dist/MosaicChartBuilder.d.ts.map +1 -0
  8. package/dist/MosaicChartBuilder.js +35 -0
  9. package/dist/MosaicChartBuilder.js.map +1 -0
  10. package/dist/MosaicColorLegend.d.ts +18 -0
  11. package/dist/MosaicColorLegend.d.ts.map +1 -0
  12. package/dist/MosaicColorLegend.js +117 -0
  13. package/dist/MosaicColorLegend.js.map +1 -0
  14. package/dist/MosaicSlice.d.ts +16 -13
  15. package/dist/MosaicSlice.d.ts.map +1 -1
  16. package/dist/MosaicSlice.js +67 -32
  17. package/dist/MosaicSlice.js.map +1 -1
  18. package/dist/VgPlotChart.d.ts +8 -0
  19. package/dist/VgPlotChart.d.ts.map +1 -1
  20. package/dist/VgPlotChart.js +26 -6
  21. package/dist/VgPlotChart.js.map +1 -1
  22. package/dist/chart-builders/ChartBuilderContent.d.ts +26 -0
  23. package/dist/chart-builders/ChartBuilderContent.d.ts.map +1 -0
  24. package/dist/chart-builders/ChartBuilderContent.js +59 -0
  25. package/dist/chart-builders/ChartBuilderContent.js.map +1 -0
  26. package/dist/chart-builders/ChartBuilderContext.d.ts +11 -0
  27. package/dist/chart-builders/ChartBuilderContext.d.ts.map +1 -0
  28. package/dist/chart-builders/ChartBuilderContext.js +10 -0
  29. package/dist/chart-builders/ChartBuilderContext.js.map +1 -0
  30. package/dist/chart-builders/ChartBuilderDialog.d.ts +23 -0
  31. package/dist/chart-builders/ChartBuilderDialog.d.ts.map +1 -0
  32. package/dist/chart-builders/ChartBuilderDialog.js +15 -0
  33. package/dist/chart-builders/ChartBuilderDialog.js.map +1 -0
  34. package/dist/chart-builders/FieldSelectorInput.d.ts +13 -0
  35. package/dist/chart-builders/FieldSelectorInput.d.ts.map +1 -0
  36. package/dist/chart-builders/FieldSelectorInput.js +19 -0
  37. package/dist/chart-builders/FieldSelectorInput.js.map +1 -0
  38. package/dist/chart-builders/builders.d.ts +7 -0
  39. package/dist/chart-builders/builders.d.ts.map +1 -0
  40. package/dist/chart-builders/builders.js +280 -0
  41. package/dist/chart-builders/builders.js.map +1 -0
  42. package/dist/chart-builders/chartSpecTitle.d.ts +7 -0
  43. package/dist/chart-builders/chartSpecTitle.d.ts.map +1 -0
  44. package/dist/chart-builders/chartSpecTitle.js +10 -0
  45. package/dist/chart-builders/chartSpecTitle.js.map +1 -0
  46. package/dist/chart-builders/createMosaicChartTool.d.ts +45 -0
  47. package/dist/chart-builders/createMosaicChartTool.d.ts.map +1 -0
  48. package/dist/chart-builders/createMosaicChartTool.js +109 -0
  49. package/dist/chart-builders/createMosaicChartTool.js.map +1 -0
  50. package/dist/chart-builders/describeChartSpecs.d.ts +7 -0
  51. package/dist/chart-builders/describeChartSpecs.d.ts.map +1 -0
  52. package/dist/chart-builders/describeChartSpecs.js +38 -0
  53. package/dist/chart-builders/describeChartSpecs.js.map +1 -0
  54. package/dist/chart-builders/types.d.ts +40 -0
  55. package/dist/chart-builders/types.d.ts.map +1 -0
  56. package/dist/chart-builders/types.js +2 -0
  57. package/dist/chart-builders/types.js.map +1 -0
  58. package/dist/dashboard/MosaicDashboard.d.ts +20 -0
  59. package/dist/dashboard/MosaicDashboard.d.ts.map +1 -0
  60. package/dist/dashboard/MosaicDashboard.js +68 -0
  61. package/dist/dashboard/MosaicDashboard.js.map +1 -0
  62. package/dist/dashboard/MosaicDashboardChartPanel.d.ts +3 -0
  63. package/dist/dashboard/MosaicDashboardChartPanel.d.ts.map +1 -0
  64. package/dist/dashboard/MosaicDashboardChartPanel.js +49 -0
  65. package/dist/dashboard/MosaicDashboardChartPanel.js.map +1 -0
  66. package/dist/dashboard/MosaicDashboardCharts.d.ts +3 -0
  67. package/dist/dashboard/MosaicDashboardCharts.d.ts.map +1 -0
  68. package/dist/dashboard/MosaicDashboardCharts.js +45 -0
  69. package/dist/dashboard/MosaicDashboardCharts.js.map +1 -0
  70. package/dist/dashboard/MosaicDashboardContext.d.ts +11 -0
  71. package/dist/dashboard/MosaicDashboardContext.d.ts.map +1 -0
  72. package/dist/dashboard/MosaicDashboardContext.js +10 -0
  73. package/dist/dashboard/MosaicDashboardContext.js.map +1 -0
  74. package/dist/dashboard/MosaicDashboardProfiler.d.ts +3 -0
  75. package/dist/dashboard/MosaicDashboardProfiler.d.ts.map +1 -0
  76. package/dist/dashboard/MosaicDashboardProfiler.js +21 -0
  77. package/dist/dashboard/MosaicDashboardProfiler.js.map +1 -0
  78. package/dist/dashboard/MosaicDashboardSlice.d.ts +68 -0
  79. package/dist/dashboard/MosaicDashboardSlice.d.ts.map +1 -0
  80. package/dist/dashboard/MosaicDashboardSlice.js +230 -0
  81. package/dist/dashboard/MosaicDashboardSlice.js.map +1 -0
  82. package/dist/dashboard/MosaicDashboardToolbar.d.ts +3 -0
  83. package/dist/dashboard/MosaicDashboardToolbar.d.ts.map +1 -0
  84. package/dist/dashboard/MosaicDashboardToolbar.js +19 -0
  85. package/dist/dashboard/MosaicDashboardToolbar.js.map +1 -0
  86. package/dist/dashboard/VgPlotSpecPopoverEditor.d.ts +8 -0
  87. package/dist/dashboard/VgPlotSpecPopoverEditor.d.ts.map +1 -0
  88. package/dist/dashboard/VgPlotSpecPopoverEditor.js +40 -0
  89. package/dist/dashboard/VgPlotSpecPopoverEditor.js.map +1 -0
  90. package/dist/editor/MosaicChartContainer.d.ts +51 -0
  91. package/dist/editor/MosaicChartContainer.d.ts.map +1 -0
  92. package/dist/editor/MosaicChartContainer.js +39 -0
  93. package/dist/editor/MosaicChartContainer.js.map +1 -0
  94. package/dist/editor/MosaicChartDisplay.d.ts +18 -0
  95. package/dist/editor/MosaicChartDisplay.d.ts.map +1 -0
  96. package/dist/editor/MosaicChartDisplay.js +21 -0
  97. package/dist/editor/MosaicChartDisplay.js.map +1 -0
  98. package/dist/editor/MosaicChartEditorActions.d.ts +20 -0
  99. package/dist/editor/MosaicChartEditorActions.d.ts.map +1 -0
  100. package/dist/editor/MosaicChartEditorActions.js +18 -0
  101. package/dist/editor/MosaicChartEditorActions.js.map +1 -0
  102. package/dist/editor/MosaicCodeMirrorEditor.d.ts +15 -0
  103. package/dist/editor/MosaicCodeMirrorEditor.d.ts.map +1 -0
  104. package/dist/editor/MosaicCodeMirrorEditor.js +26 -0
  105. package/dist/editor/MosaicCodeMirrorEditor.js.map +1 -0
  106. package/dist/editor/MosaicEditorContext.d.ts +8 -0
  107. package/dist/editor/MosaicEditorContext.d.ts.map +1 -0
  108. package/dist/editor/MosaicEditorContext.js +14 -0
  109. package/dist/editor/MosaicEditorContext.js.map +1 -0
  110. package/dist/editor/MosaicSpecEditorPanel.d.ts +20 -0
  111. package/dist/editor/MosaicSpecEditorPanel.d.ts.map +1 -0
  112. package/dist/editor/MosaicSpecEditorPanel.js +25 -0
  113. package/dist/editor/MosaicSpecEditorPanel.js.map +1 -0
  114. package/dist/editor/mosaicSchema.d.ts +20 -0
  115. package/dist/editor/mosaicSchema.d.ts.map +1 -0
  116. package/dist/editor/mosaicSchema.js +57 -0
  117. package/dist/editor/mosaicSchema.js.map +1 -0
  118. package/dist/editor/types.d.ts +72 -0
  119. package/dist/editor/types.d.ts.map +1 -0
  120. package/dist/editor/types.js +2 -0
  121. package/dist/editor/types.js.map +1 -0
  122. package/dist/editor/useMosaicChartEditor.d.ts +9 -0
  123. package/dist/editor/useMosaicChartEditor.d.ts.map +1 -0
  124. package/dist/editor/useMosaicChartEditor.js +199 -0
  125. package/dist/editor/useMosaicChartEditor.js.map +1 -0
  126. package/dist/index.d.ts +27 -2
  127. package/dist/index.d.ts.map +1 -1
  128. package/dist/index.js +18 -1
  129. package/dist/index.js.map +1 -1
  130. package/dist/profiler/MosaicProfiler.d.ts +32 -0
  131. package/dist/profiler/MosaicProfiler.d.ts.map +1 -0
  132. package/dist/profiler/MosaicProfiler.js +57 -0
  133. package/dist/profiler/MosaicProfiler.js.map +1 -0
  134. package/dist/profiler/MosaicProfilerHeader.d.ts +7 -0
  135. package/dist/profiler/MosaicProfilerHeader.d.ts.map +1 -0
  136. package/dist/profiler/MosaicProfilerHeader.js +196 -0
  137. package/dist/profiler/MosaicProfilerHeader.js.map +1 -0
  138. package/dist/profiler/MosaicProfilerRows.d.ts +9 -0
  139. package/dist/profiler/MosaicProfilerRows.d.ts.map +1 -0
  140. package/dist/profiler/MosaicProfilerRows.js +65 -0
  141. package/dist/profiler/MosaicProfilerRows.js.map +1 -0
  142. package/dist/profiler/MosaicProfilerStatusBar.d.ts +9 -0
  143. package/dist/profiler/MosaicProfilerStatusBar.d.ts.map +1 -0
  144. package/dist/profiler/MosaicProfilerStatusBar.js +28 -0
  145. package/dist/profiler/MosaicProfilerStatusBar.js.map +1 -0
  146. package/dist/profiler/ProfilerCategoryClient.d.ts +50 -0
  147. package/dist/profiler/ProfilerCategoryClient.d.ts.map +1 -0
  148. package/dist/profiler/ProfilerCategoryClient.js +121 -0
  149. package/dist/profiler/ProfilerCategoryClient.js.map +1 -0
  150. package/dist/profiler/ProfilerCountClient.d.ts +28 -0
  151. package/dist/profiler/ProfilerCountClient.d.ts.map +1 -0
  152. package/dist/profiler/ProfilerCountClient.js +51 -0
  153. package/dist/profiler/ProfilerCountClient.js.map +1 -0
  154. package/dist/profiler/ProfilerHistogramClient.d.ts +69 -0
  155. package/dist/profiler/ProfilerHistogramClient.d.ts.map +1 -0
  156. package/dist/profiler/ProfilerHistogramClient.js +179 -0
  157. package/dist/profiler/ProfilerHistogramClient.js.map +1 -0
  158. package/dist/profiler/ProfilerPageClient.d.ts +37 -0
  159. package/dist/profiler/ProfilerPageClient.d.ts.map +1 -0
  160. package/dist/profiler/ProfilerPageClient.js +65 -0
  161. package/dist/profiler/ProfilerPageClient.js.map +1 -0
  162. package/dist/profiler/ProfilerUnsupportedSummaryClient.d.ts +24 -0
  163. package/dist/profiler/ProfilerUnsupportedSummaryClient.d.ts.map +1 -0
  164. package/dist/profiler/ProfilerUnsupportedSummaryClient.js +51 -0
  165. package/dist/profiler/ProfilerUnsupportedSummaryClient.js.map +1 -0
  166. package/dist/profiler/createProfilerStore.d.ts +45 -0
  167. package/dist/profiler/createProfilerStore.d.ts.map +1 -0
  168. package/dist/profiler/createProfilerStore.js +120 -0
  169. package/dist/profiler/createProfilerStore.js.map +1 -0
  170. package/dist/profiler/layout.d.ts +7 -0
  171. package/dist/profiler/layout.d.ts.map +1 -0
  172. package/dist/profiler/layout.js +13 -0
  173. package/dist/profiler/layout.js.map +1 -0
  174. package/dist/profiler/profilerController.d.ts +64 -0
  175. package/dist/profiler/profilerController.d.ts.map +1 -0
  176. package/dist/profiler/profilerController.js +123 -0
  177. package/dist/profiler/profilerController.js.map +1 -0
  178. package/dist/profiler/types.d.ts +86 -0
  179. package/dist/profiler/types.d.ts.map +1 -0
  180. package/dist/profiler/types.js +2 -0
  181. package/dist/profiler/types.js.map +1 -0
  182. package/dist/profiler/useMosaicProfiler.d.ts +7 -0
  183. package/dist/profiler/useMosaicProfiler.d.ts.map +1 -0
  184. package/dist/profiler/useMosaicProfiler.js +339 -0
  185. package/dist/profiler/useMosaicProfiler.js.map +1 -0
  186. package/dist/profiler/utils.d.ts +61 -0
  187. package/dist/profiler/utils.d.ts.map +1 -0
  188. package/dist/profiler/utils.js +347 -0
  189. package/dist/profiler/utils.js.map +1 -0
  190. package/dist/tableInterop.d.ts +30 -0
  191. package/dist/tableInterop.d.ts.map +1 -0
  192. package/dist/tableInterop.js +85 -0
  193. package/dist/tableInterop.js.map +1 -0
  194. package/dist/use-mosaic.d.ts +11 -0
  195. package/dist/use-mosaic.d.ts.map +1 -0
  196. package/dist/use-mosaic.js +42 -0
  197. package/dist/use-mosaic.js.map +1 -0
  198. package/dist/useMosaicClient.d.ts +5 -4
  199. package/dist/useMosaicClient.d.ts.map +1 -1
  200. package/dist/useMosaicClient.js +13 -3
  201. package/dist/useMosaicClient.js.map +1 -1
  202. package/package.json +24 -6
@@ -0,0 +1,65 @@
1
+ import { MosaicClient } from '@uwdata/mosaic-core';
2
+ import { buildProfilerBaseQuery, buildProfilerPageQuery } from './utils';
3
+ export class ProfilerPageClient extends MosaicClient {
4
+ columns;
5
+ datasetId;
6
+ error;
7
+ filter;
8
+ onStateChange;
9
+ pagination;
10
+ pageTable;
11
+ sorting;
12
+ tableName;
13
+ constructor(options) {
14
+ super();
15
+ this.columns = options.columns;
16
+ this.datasetId = [options.tableName, ...options.columns].join('\u0001');
17
+ this.filter = options.filter ?? [];
18
+ this.onStateChange = options.onStateChange;
19
+ this.pagination = options.pagination;
20
+ this.sorting = options.sorting;
21
+ this.tableName = options.tableName;
22
+ }
23
+ get filterStable() {
24
+ return false;
25
+ }
26
+ queryPending() {
27
+ this.onStateChange({
28
+ datasetId: this.datasetId,
29
+ error: this.error,
30
+ isLoading: true,
31
+ pageTable: this.pageTable,
32
+ });
33
+ return this;
34
+ }
35
+ query(filter = []) {
36
+ const resolvedFilter = this.filter ?? filter;
37
+ return buildProfilerPageQuery(buildProfilerBaseQuery({
38
+ columns: this.columns,
39
+ filter: resolvedFilter,
40
+ sorting: this.sorting,
41
+ tableName: this.tableName,
42
+ }), this.pagination);
43
+ }
44
+ queryResult(data) {
45
+ this.error = undefined;
46
+ this.pageTable = data;
47
+ this.onStateChange({
48
+ datasetId: this.datasetId,
49
+ isLoading: false,
50
+ pageTable: this.pageTable,
51
+ });
52
+ return this;
53
+ }
54
+ queryError(error) {
55
+ this.error = error;
56
+ this.onStateChange({
57
+ datasetId: this.datasetId,
58
+ error,
59
+ isLoading: false,
60
+ pageTable: this.pageTable,
61
+ });
62
+ return this;
63
+ }
64
+ }
65
+ //# sourceMappingURL=ProfilerPageClient.js.map
@@ -0,0 +1 @@
1
+ {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SAA0B,EAAE;QACzC,MAAM,cAAc,GAAG,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC;QAC7C,OAAO,sBAAsB,CAC3B,sBAAsB,CAAC;YACrB,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,MAAM,EAAE,cAAc;YACtB,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,SAAS,EAAE,IAAI,CAAC,SAAS;SAC1B,CAAC,EACF,IAAI,CAAC,UAAU,CAChB,CAAC;IACJ,CAAC;IAEQ,WAAW,CAAC,IAAa;QAChC,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC;QACvB,IAAI,CAAC,SAAS,GAAG,IAAa,CAAC;QAC/B,IAAI,CAAC,aAAa,CAAC;YACjB,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,SAAS,EAAE,KAAK;YAChB,SAAS,EAAE,IAAI,CAAC,SAAS;SAC1B,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IACd,CAAC;IAEQ,UAAU,CAAC,KAAY;QAC9B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,aAAa,CAAC;YACjB,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,KAAK;YACL,SAAS,EAAE,KAAK;YAChB,SAAS,EAAE,IAAI,CAAC,SAAS;SAC1B,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IACd,CAAC;CACF","sourcesContent":["import {MosaicClient, type Selection} from '@uwdata/mosaic-core';\nimport {type ExprNode, type Query} from '@uwdata/mosaic-sql';\nimport type {Table} from 'apache-arrow';\nimport type {\n MosaicProfilerPaginationState,\n MosaicProfilerSorting,\n} from './types';\nimport {buildProfilerBaseQuery, buildProfilerPageQuery} from './utils';\n\nexport type ProfilerPageState = {\n datasetId?: string;\n error?: Error;\n isLoading: boolean;\n pageTable?: Table;\n};\n\ntype ProfilerPageClientOptions = {\n columns: string[];\n filter?: ReturnType<Selection['predicate']>;\n onStateChange: (state: ProfilerPageState) => void;\n pagination: MosaicProfilerPaginationState;\n sorting: MosaicProfilerSorting;\n tableName: string;\n};\n\nexport class ProfilerPageClient extends MosaicClient {\n private readonly columns: string[];\n private readonly datasetId: string;\n private error?: Error;\n private readonly filter?: ReturnType<Selection['predicate']>;\n private readonly onStateChange: (state: ProfilerPageState) => void;\n private readonly pagination: MosaicProfilerPaginationState;\n private pageTable?: Table;\n private readonly sorting: MosaicProfilerSorting;\n private readonly tableName: string;\n\n constructor(options: ProfilerPageClientOptions) {\n super();\n this.columns = options.columns;\n this.datasetId = [options.tableName, ...options.columns].join('\\u0001');\n this.filter = options.filter ?? [];\n this.onStateChange = options.onStateChange;\n this.pagination = options.pagination;\n this.sorting = options.sorting;\n this.tableName = options.tableName;\n }\n\n override get filterStable(): boolean {\n return false;\n }\n\n override queryPending(): this {\n this.onStateChange({\n datasetId: this.datasetId,\n error: this.error,\n isLoading: true,\n pageTable: this.pageTable,\n });\n return this;\n }\n\n override query(filter: Array<ExprNode> = []): Query {\n const resolvedFilter = this.filter ?? filter;\n return buildProfilerPageQuery(\n buildProfilerBaseQuery({\n columns: this.columns,\n filter: resolvedFilter,\n sorting: this.sorting,\n tableName: this.tableName,\n }),\n this.pagination,\n );\n }\n\n override queryResult(data: unknown): this {\n this.error = undefined;\n this.pageTable = data as Table;\n this.onStateChange({\n datasetId: this.datasetId,\n isLoading: false,\n pageTable: this.pageTable,\n });\n return this;\n }\n\n override queryError(error: Error): this {\n this.error = error;\n this.onStateChange({\n datasetId: this.datasetId,\n error,\n isLoading: false,\n pageTable: this.pageTable,\n });\n return this;\n }\n}\n"]}
@@ -0,0 +1,24 @@
1
+ import { MosaicClient, type Selection } from '@uwdata/mosaic-core';
2
+ import { type ExprNode, type Query } from '@uwdata/mosaic-sql';
3
+ import type * as arrow from 'apache-arrow';
4
+ import type { MosaicProfilerUnsupportedSummary } from './types';
5
+ type UnsupportedSummaryClientOptions = {
6
+ field: arrow.Field;
7
+ onStateChange: (summary: MosaicProfilerUnsupportedSummary) => void;
8
+ selection: Selection;
9
+ tableName: string;
10
+ };
11
+ export declare class ProfilerUnsupportedSummaryClient extends MosaicClient {
12
+ private count;
13
+ private readonly field;
14
+ private readonly onStateChange;
15
+ private readonly tableName;
16
+ constructor(options: UnsupportedSummaryClientOptions);
17
+ get filterStable(): boolean;
18
+ queryPending(): this;
19
+ query(filter?: Array<ExprNode>): Query;
20
+ queryResult(data: unknown): this;
21
+ queryError(error: Error): this;
22
+ }
23
+ export {};
24
+ //# sourceMappingURL=ProfilerUnsupportedSummaryClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProfilerUnsupportedSummaryClient.d.ts","sourceRoot":"","sources":["../../src/profiler/ProfilerUnsupportedSummaryClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAE,KAAK,SAAS,EAAC,MAAM,qBAAqB,CAAC;AACjE,OAAO,EAAC,KAAK,QAAQ,EAAE,KAAK,KAAK,EAAC,MAAM,oBAAoB,CAAC;AAC7D,OAAO,KAAK,KAAK,KAAK,MAAM,cAAc,CAAC;AAC3C,OAAO,KAAK,EAAC,gCAAgC,EAAC,MAAM,SAAS,CAAC;AAG9D,KAAK,+BAA+B,GAAG;IACrC,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC;IACnB,aAAa,EAAE,CAAC,OAAO,EAAE,gCAAgC,KAAK,IAAI,CAAC;IACnE,SAAS,EAAE,SAAS,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,qBAAa,gCAAiC,SAAQ,YAAY;IAChE,OAAO,CAAC,KAAK,CAAK;IAClB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAc;IACpC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAEpB;IACV,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;gBAEvB,OAAO,EAAE,+BAA+B;IAOpD,IAAa,YAAY,IAAI,OAAO,CAEnC;IAEQ,YAAY,IAAI,IAAI;IASpB,KAAK,CAAC,MAAM,GAAE,KAAK,CAAC,QAAQ,CAAM,GAAG,KAAK;IAQ1C,WAAW,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI;IAUhC,UAAU,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI;CASxC"}
@@ -0,0 +1,51 @@
1
+ import { MosaicClient } from '@uwdata/mosaic-core';
2
+ import { buildDistinctCountQuery, readCountData } from './utils';
3
+ export class ProfilerUnsupportedSummaryClient extends MosaicClient {
4
+ count = 0;
5
+ field;
6
+ onStateChange;
7
+ tableName;
8
+ constructor(options) {
9
+ super(options.selection);
10
+ this.field = options.field;
11
+ this.onStateChange = options.onStateChange;
12
+ this.tableName = options.tableName;
13
+ }
14
+ get filterStable() {
15
+ return false;
16
+ }
17
+ queryPending() {
18
+ this.onStateChange({
19
+ isLoading: true,
20
+ kind: 'unsupported',
21
+ label: `${this.count.toLocaleString()} distinct values`,
22
+ });
23
+ return this;
24
+ }
25
+ query(filter = []) {
26
+ return buildDistinctCountQuery({
27
+ fieldName: this.field.name,
28
+ filter,
29
+ tableName: this.tableName,
30
+ });
31
+ }
32
+ queryResult(data) {
33
+ this.count = readCountData(data) ?? 0;
34
+ this.onStateChange({
35
+ isLoading: false,
36
+ kind: 'unsupported',
37
+ label: `${this.count.toLocaleString()} distinct values`,
38
+ });
39
+ return this;
40
+ }
41
+ queryError(error) {
42
+ this.onStateChange({
43
+ error,
44
+ isLoading: false,
45
+ kind: 'unsupported',
46
+ label: `${this.count.toLocaleString()} distinct values`,
47
+ });
48
+ return this;
49
+ }
50
+ }
51
+ //# sourceMappingURL=ProfilerUnsupportedSummaryClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProfilerUnsupportedSummaryClient.js","sourceRoot":"","sources":["../../src/profiler/ProfilerUnsupportedSummaryClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAiB,MAAM,qBAAqB,CAAC;AAIjE,OAAO,EAAC,uBAAuB,EAAE,aAAa,EAAC,MAAM,SAAS,CAAC;AAS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KAAK,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,cAAc,EAAE,kBAAkB;SACxD,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IACd,CAAC;CACF","sourcesContent":["import {MosaicClient, type Selection} from '@uwdata/mosaic-core';\nimport {type ExprNode, type Query} from '@uwdata/mosaic-sql';\nimport type * as arrow from 'apache-arrow';\nimport type {MosaicProfilerUnsupportedSummary} from './types';\nimport {buildDistinctCountQuery, readCountData} from './utils';\n\ntype UnsupportedSummaryClientOptions = {\n field: arrow.Field;\n onStateChange: (summary: MosaicProfilerUnsupportedSummary) => void;\n selection: Selection;\n tableName: string;\n};\n\nexport class ProfilerUnsupportedSummaryClient extends MosaicClient {\n private count = 0;\n private readonly field: arrow.Field;\n private readonly onStateChange: (\n summary: MosaicProfilerUnsupportedSummary,\n ) => void;\n private readonly tableName: string;\n\n constructor(options: UnsupportedSummaryClientOptions) {\n super(options.selection);\n this.field = options.field;\n this.onStateChange = options.onStateChange;\n this.tableName = options.tableName;\n }\n\n override get filterStable(): boolean {\n return false;\n }\n\n override queryPending(): this {\n this.onStateChange({\n isLoading: true,\n kind: 'unsupported',\n label: `${this.count.toLocaleString()} distinct values`,\n });\n return this;\n }\n\n override query(filter: Array<ExprNode> = []): Query {\n return buildDistinctCountQuery({\n fieldName: this.field.name,\n filter,\n tableName: this.tableName,\n });\n }\n\n override queryResult(data: unknown): this {\n this.count = readCountData(data) ?? 0;\n this.onStateChange({\n isLoading: false,\n kind: 'unsupported',\n label: `${this.count.toLocaleString()} distinct values`,\n });\n return this;\n }\n\n override queryError(error: Error): this {\n this.onStateChange({\n error,\n isLoading: false,\n kind: 'unsupported',\n label: `${this.count.toLocaleString()} distinct values`,\n });\n return this;\n }\n}\n"]}
@@ -0,0 +1,45 @@
1
+ import type * as arrow from 'apache-arrow';
2
+ import type { Dispatch, SetStateAction } from 'react';
3
+ import type { ProfilerCountState } from './ProfilerCountClient';
4
+ import type { ProfilerPageState } from './ProfilerPageClient';
5
+ import type { MosaicProfilerPaginationState, MosaicProfilerSorting, MosaicProfilerSummaryState } from './types';
6
+ export type ProfilerStoreState = {
7
+ filteredCount: ProfilerCountState;
8
+ lastNonEmptyPageTable?: {
9
+ datasetId: string;
10
+ pageTable: arrow.Table;
11
+ };
12
+ page: ProfilerPageState;
13
+ pagination: MosaicProfilerPaginationState;
14
+ schema: {
15
+ error?: Error;
16
+ fields: arrow.Field[];
17
+ isLoading: boolean;
18
+ };
19
+ setFilteredCount: (state: ProfilerCountState) => void;
20
+ setPage: (state: ProfilerPageState) => void;
21
+ setPagination: Dispatch<SetStateAction<MosaicProfilerPaginationState>>;
22
+ setSchemaError: (error?: Error) => void;
23
+ setSchemaLoading: (isLoading: boolean) => void;
24
+ setSchemaSuccess: (fields: arrow.Field[]) => void;
25
+ setSorting: Dispatch<SetStateAction<MosaicProfilerSorting>>;
26
+ setSummary: (fieldName: string, summary: MosaicProfilerSummaryState) => void;
27
+ setTotalCount: (state: ProfilerCountState) => void;
28
+ sorting: MosaicProfilerSorting;
29
+ summaries: Record<string, MosaicProfilerSummaryState>;
30
+ syncPageSize: (pageSize: number) => void;
31
+ totalCount: ProfilerCountState;
32
+ clearSummaries: () => void;
33
+ initializeSummaries: (fields: arrow.Field[]) => void;
34
+ resetPageIndex: () => void;
35
+ };
36
+ export type ProfilerStore = ReturnType<typeof createProfilerStore>;
37
+ /**
38
+ * Creates a profiler-local vanilla Zustand store that aggregates schema, row,
39
+ * count, and summary state for a single `useMosaicProfiler()` instance.
40
+ */
41
+ export declare function createProfilerStore(options: {
42
+ initialSorting?: MosaicProfilerSorting;
43
+ pageSize: number;
44
+ }): import("zustand").StoreApi<ProfilerStoreState>;
45
+ //# sourceMappingURL=createProfilerStore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createProfilerStore.d.ts","sourceRoot":"","sources":["../../src/profiler/createProfilerStore.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,KAAK,MAAM,cAAc,CAAC;AAC3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Aa,EAAE,CAAC,KAAK,EAAE,kBAAkB,KAAK,IAAI,CAAC;IACnD,OAAO,EAAE,qBAAqB,CAAC;IAC/B,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,0BAA0B,CAAC,CAAC;IACtD,YAAY,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC,UAAU,EAAE,kBAAkB,CAAC;IAC/B,cAAc,EAAE,MAAM,IAAI,CAAC;IAC3B,mBAAmB,EAAE,CAAC,MAAM,EAAE,KAAK,CAAC,KAAK,EAAE,KAAK,IAAI,CAAC;IACrD,cAAc,EAAE,MAAM,IAAI,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,UAAU,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEnE;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE;IAC3C,cAAc,CAAC,EAAE,qBAAqB,CAAC;IACvC,QAAQ,EAAE,MAAM,CAAC;CAClB,kDAyIA"}
@@ -0,0 +1,120 @@
1
+ import { castDraft, produce } from 'immer';
2
+ import { createStore } from 'zustand/vanilla';
3
+ import { createEmptySummaryState, normalizeProfilerPagination } from './utils';
4
+ function resolveSetStateAction(next, previous) {
5
+ // Preserve React-style setter semantics so hook callers can pass either
6
+ // a concrete value or an updater function to the local profiler store.
7
+ return typeof next === 'function'
8
+ ? next(previous)
9
+ : next;
10
+ }
11
+ /**
12
+ * Creates a profiler-local vanilla Zustand store that aggregates schema, row,
13
+ * count, and summary state for a single `useMosaicProfiler()` instance.
14
+ */
15
+ export function createProfilerStore(options) {
16
+ const { initialSorting = [], pageSize } = options;
17
+ return createStore((set) => ({
18
+ filteredCount: { isLoading: false },
19
+ lastNonEmptyPageTable: undefined,
20
+ page: { isLoading: false },
21
+ pagination: normalizeProfilerPagination({ pageIndex: 0, pageSize }),
22
+ schema: {
23
+ fields: [],
24
+ isLoading: false,
25
+ },
26
+ setFilteredCount: (nextState) => {
27
+ set((state) => produce(state, (draft) => {
28
+ draft.filteredCount = nextState;
29
+ }));
30
+ },
31
+ setPage: (nextState) => {
32
+ set((state) => produce(state, (draft) => {
33
+ draft.page = castDraft(nextState);
34
+ if (nextState.datasetId &&
35
+ nextState.pageTable &&
36
+ nextState.pageTable.numRows > 0) {
37
+ draft.lastNonEmptyPageTable = {
38
+ datasetId: nextState.datasetId,
39
+ pageTable: castDraft(nextState.pageTable),
40
+ };
41
+ }
42
+ }));
43
+ },
44
+ setPagination: (next) => {
45
+ set((state) => produce(state, (draft) => {
46
+ draft.pagination = normalizeProfilerPagination(resolveSetStateAction(next, state.pagination));
47
+ }));
48
+ },
49
+ setSchemaError: (error) => {
50
+ set((state) => produce(state, (draft) => {
51
+ draft.schema.error = error;
52
+ draft.schema.isLoading = false;
53
+ }));
54
+ },
55
+ setSchemaLoading: (isLoading) => {
56
+ set((state) => produce(state, (draft) => {
57
+ draft.schema.isLoading = isLoading;
58
+ if (isLoading) {
59
+ draft.schema.error = undefined;
60
+ }
61
+ }));
62
+ },
63
+ setSchemaSuccess: (fields) => {
64
+ set((state) => produce(state, (draft) => {
65
+ draft.schema.error = undefined;
66
+ draft.schema.fields = fields;
67
+ draft.schema.isLoading = false;
68
+ }));
69
+ },
70
+ setSorting: (next) => {
71
+ set((state) => produce(state, (draft) => {
72
+ draft.sorting = resolveSetStateAction(next, state.sorting);
73
+ draft.pagination.pageIndex = 0;
74
+ }));
75
+ },
76
+ setSummary: (fieldName, summary) => {
77
+ set((state) => produce(state, (draft) => {
78
+ draft.summaries[fieldName] = summary;
79
+ }));
80
+ },
81
+ setTotalCount: (nextState) => {
82
+ set((state) => produce(state, (draft) => {
83
+ draft.totalCount = nextState;
84
+ }));
85
+ },
86
+ sorting: initialSorting,
87
+ summaries: {},
88
+ syncPageSize: (nextPageSize) => {
89
+ set((state) => produce(state, (draft) => {
90
+ if (draft.pagination.pageSize === nextPageSize) {
91
+ return;
92
+ }
93
+ draft.pagination = normalizeProfilerPagination({
94
+ pageIndex: 0,
95
+ pageSize: nextPageSize,
96
+ });
97
+ }));
98
+ },
99
+ totalCount: { isLoading: false },
100
+ clearSummaries: () => {
101
+ set((state) => produce(state, (draft) => {
102
+ draft.summaries = {};
103
+ }));
104
+ },
105
+ initializeSummaries: (fields) => {
106
+ set((state) => produce(state, (draft) => {
107
+ draft.summaries = Object.fromEntries(fields.map((field) => [field.name, createEmptySummaryState(field)]));
108
+ }));
109
+ },
110
+ resetPageIndex: () => {
111
+ set((state) => produce(state, (draft) => {
112
+ draft.pagination = normalizeProfilerPagination({
113
+ ...draft.pagination,
114
+ pageIndex: 0,
115
+ });
116
+ }));
117
+ },
118
+ }));
119
+ }
120
+ //# sourceMappingURL=createProfilerStore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createProfilerStore.js","sourceRoot":"","sources":["../../src/profiler/createProfilerStore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAE,OAAO,EAAC,MAAM,OAAO,CAAC;AAGzC,OAAO,EAAC,WAAW,EAAC,MAAM,iBAAiB,CAAC;AAQ5C,OAAO,EAAC,uBAAuB,EAAE,2BAA2B,EAAC,MAAM,SAAS,CAAC;AAE7E,SAAS,qBAAqB,CAAI,IAAuB,EAAE,QAAW;IACpE,wEAAwE;IACxE,uEAAuE;IACvE,OAAO,OAAO,IAAI,KAAK,UAAU;QAC/B,CAAC,CAAE,IAAwB,CAAC,QAAQ,CAAC;QACrC,CAAC,CAAC,IAAI,CAAC;AACX,CAAC;AAmCD;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,OAGnC;IACC,MAAM,EAAC,cAAc,GAAG,EAAE,EAAE,QAAQ,EAAC,GAAG,OAAO,CAAC;IAEhD,OAAO,WAAW,CAAqB,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;QAC/C,aAAa,EAAE,EAAC,SAAS,EAAE,KAAK,EAAC;QACjC,qBAAqB,EAAE,SAAS;QAChC,IAAI,EAAE,EAAC,SAAS,EAAE,KAAK,EAAC;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AAG,CAAC,CAAC,KAAK,EAAE,EAAE,CACZ,OAAO,CAAC,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE;gBACvB,KAAK,CAAC,SAAS,GAAG,MAAM,CAAC,WAAW,CAClC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,uBAAuB,CAAC,KAAK,CAAC,CAAC,CAAC,CACpE,CAAC;YACJ,CAAC,CAAC,CACH,CAAC;QACJ,CAAC;QACD,cAAc,EAAE,GAAG,EAAE;YACnB,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CACZ,OAAO,CAAC,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE;gBACvB,KAAK,CAAC,UAAU,GAAG,2BAA2B,CAAC;oBAC7C,GAAG,KAAK,CAAC,UAAU;oBACnB,SAAS,EAAE,CAAC;iBACb,CAAC,CAAC;YACL,CAAC,CAAC,CACH,CAAC;QACJ,CAAC;KACF,CAAC,CAAC,CAAC;AACN,CAAC","sourcesContent":["import {castDraft, produce} from 'immer';\nimport type * as arrow from 'apache-arrow';\nimport type {Dispatch, SetStateAction} from 'react';\nimport {createStore} from 'zustand/vanilla';\nimport type {ProfilerCountState} from './ProfilerCountClient';\nimport type {ProfilerPageState} from './ProfilerPageClient';\nimport type {\n MosaicProfilerPaginationState,\n MosaicProfilerSorting,\n MosaicProfilerSummaryState,\n} from './types';\nimport {createEmptySummaryState, normalizeProfilerPagination} from './utils';\n\nfunction resolveSetStateAction<T>(next: SetStateAction<T>, previous: T): T {\n // Preserve React-style setter semantics so hook callers can pass either\n // a concrete value or an updater function to the local profiler store.\n return typeof next === 'function'\n ? (next as (value: T) => T)(previous)\n : next;\n}\n\nexport type ProfilerStoreState = {\n filteredCount: ProfilerCountState;\n lastNonEmptyPageTable?: {\n datasetId: string;\n pageTable: arrow.Table;\n };\n page: ProfilerPageState;\n pagination: MosaicProfilerPaginationState;\n schema: {\n error?: Error;\n fields: arrow.Field[];\n isLoading: boolean;\n };\n setFilteredCount: (state: ProfilerCountState) => void;\n setPage: (state: ProfilerPageState) => void;\n setPagination: Dispatch<SetStateAction<MosaicProfilerPaginationState>>;\n setSchemaError: (error?: Error) => void;\n setSchemaLoading: (isLoading: boolean) => void;\n setSchemaSuccess: (fields: arrow.Field[]) => void;\n setSorting: Dispatch<SetStateAction<MosaicProfilerSorting>>;\n setSummary: (fieldName: string, summary: MosaicProfilerSummaryState) => void;\n setTotalCount: (state: ProfilerCountState) => void;\n sorting: MosaicProfilerSorting;\n summaries: Record<string, MosaicProfilerSummaryState>;\n syncPageSize: (pageSize: number) => void;\n totalCount: ProfilerCountState;\n clearSummaries: () => void;\n initializeSummaries: (fields: arrow.Field[]) => void;\n resetPageIndex: () => void;\n};\n\nexport type ProfilerStore = ReturnType<typeof createProfilerStore>;\n\n/**\n * Creates a profiler-local vanilla Zustand store that aggregates schema, row,\n * count, and summary state for a single `useMosaicProfiler()` instance.\n */\nexport function createProfilerStore(options: {\n initialSorting?: MosaicProfilerSorting;\n pageSize: number;\n}) {\n const {initialSorting = [], pageSize} = options;\n\n return createStore<ProfilerStoreState>((set) => ({\n filteredCount: {isLoading: false},\n lastNonEmptyPageTable: undefined,\n page: {isLoading: false},\n pagination: normalizeProfilerPagination({pageIndex: 0, pageSize}),\n schema: {\n fields: [],\n isLoading: false,\n },\n setFilteredCount: (nextState) => {\n set((state) =>\n produce(state, (draft) => {\n draft.filteredCount = nextState;\n }),\n );\n },\n setPage: (nextState) => {\n set((state) =>\n produce(state, (draft) => {\n draft.page = castDraft(nextState);\n if (\n nextState.datasetId &&\n nextState.pageTable &&\n nextState.pageTable.numRows > 0\n ) {\n draft.lastNonEmptyPageTable = {\n datasetId: nextState.datasetId,\n pageTable: castDraft(nextState.pageTable),\n };\n }\n }),\n );\n },\n setPagination: (next) => {\n set((state) =>\n produce(state, (draft) => {\n draft.pagination = normalizeProfilerPagination(\n resolveSetStateAction(next, state.pagination),\n );\n }),\n );\n },\n setSchemaError: (error) => {\n set((state) =>\n produce(state, (draft) => {\n draft.schema.error = error;\n draft.schema.isLoading = false;\n }),\n );\n },\n setSchemaLoading: (isLoading) => {\n set((state) =>\n produce(state, (draft) => {\n draft.schema.isLoading = isLoading;\n if (isLoading) {\n draft.schema.error = undefined;\n }\n }),\n );\n },\n setSchemaSuccess: (fields) => {\n set((state) =>\n produce(state, (draft) => {\n draft.schema.error = undefined;\n draft.schema.fields = fields;\n draft.schema.isLoading = false;\n }),\n );\n },\n setSorting: (next) => {\n set((state) =>\n produce(state, (draft) => {\n draft.sorting = resolveSetStateAction(next, state.sorting);\n draft.pagination.pageIndex = 0;\n }),\n );\n },\n setSummary: (fieldName, summary) => {\n set((state) =>\n produce(state, (draft) => {\n draft.summaries[fieldName] = summary;\n }),\n );\n },\n setTotalCount: (nextState) => {\n set((state) =>\n produce(state, (draft) => {\n draft.totalCount = nextState;\n }),\n );\n },\n sorting: initialSorting,\n summaries: {},\n syncPageSize: (nextPageSize) => {\n set((state) =>\n produce(state, (draft) => {\n if (draft.pagination.pageSize === nextPageSize) {\n return;\n }\n draft.pagination = normalizeProfilerPagination({\n pageIndex: 0,\n pageSize: nextPageSize,\n });\n }),\n );\n },\n totalCount: {isLoading: false},\n clearSummaries: () => {\n set((state) =>\n produce(state, (draft) => {\n draft.summaries = {};\n }),\n );\n },\n initializeSummaries: (fields) => {\n set((state) =>\n produce(state, (draft) => {\n draft.summaries = Object.fromEntries(\n fields.map((field) => [field.name, createEmptySummaryState(field)]),\n );\n }),\n );\n },\n resetPageIndex: () => {\n set((state) =>\n produce(state, (draft) => {\n draft.pagination = normalizeProfilerPagination({\n ...draft.pagination,\n pageIndex: 0,\n });\n }),\n );\n },\n }));\n}\n"]}
@@ -0,0 +1,7 @@
1
+ import type { MosaicProfilerColumnState } from './types';
2
+ export declare const PROFILER_ROW_NUMBER_COLUMN_WIDTH_PX = 40;
3
+ export declare const PROFILER_DEFAULT_COLUMN_WIDTH_PX = 140;
4
+ export declare const PROFILER_UNSUPPORTED_COLUMN_WIDTH_PX = 104;
5
+ export declare function getProfilerColumnWidthPx(column: MosaicProfilerColumnState): 140 | 104;
6
+ export declare function getProfilerTableWidth(columns: MosaicProfilerColumnState[]): number;
7
+ //# sourceMappingURL=layout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../../src/profiler/layout.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,yBAAyB,EAAC,MAAM,SAAS,CAAC;AAEvD,eAAO,MAAM,mCAAmC,KAAK,CAAC;AACtD,eAAO,MAAM,gCAAgC,MAAM,CAAC;AACpD,eAAO,MAAM,oCAAoC,MAAM,CAAC;AAExD,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,yBAAyB,aAIzE;AAED,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,yBAAyB,EAAE,UAQzE"}
@@ -0,0 +1,13 @@
1
+ export const PROFILER_ROW_NUMBER_COLUMN_WIDTH_PX = 40;
2
+ export const PROFILER_DEFAULT_COLUMN_WIDTH_PX = 140;
3
+ export const PROFILER_UNSUPPORTED_COLUMN_WIDTH_PX = 104;
4
+ export function getProfilerColumnWidthPx(column) {
5
+ return column.kind === 'unsupported'
6
+ ? PROFILER_UNSUPPORTED_COLUMN_WIDTH_PX
7
+ : PROFILER_DEFAULT_COLUMN_WIDTH_PX;
8
+ }
9
+ export function getProfilerTableWidth(columns) {
10
+ return (PROFILER_ROW_NUMBER_COLUMN_WIDTH_PX +
11
+ columns.reduce((total, column) => total + getProfilerColumnWidthPx(column), 0));
12
+ }
13
+ //# sourceMappingURL=layout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layout.js","sourceRoot":"","sources":["../../src/profiler/layout.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,mCAAmC,GAAG,EAAE,CAAC;AACtD,MAAM,CAAC,MAAM,gCAAgC,GAAG,GAAG,CAAC;AACpD,MAAM,CAAC,MAAM,oCAAoC,GAAG,GAAG,CAAC;AAExD,MAAM,UAAU,wBAAwB,CAAC,MAAiC;IACxE,OAAO,MAAM,CAAC,IAAI,KAAK,aAAa;QAClC,CAAC,CAAC,oCAAoC;QACtC,CAAC,CAAC,gCAAgC,CAAC;AACvC,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,OAAoC;IACxE,OAAO,CACL,mCAAmC;QACnC,OAAO,CAAC,MAAM,CACZ,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,CAAC,KAAK,GAAG,wBAAwB,CAAC,MAAM,CAAC,EAC3D,CAAC,CACF,CACF,CAAC;AACJ,CAAC","sourcesContent":["import type {MosaicProfilerColumnState} from './types';\n\nexport const PROFILER_ROW_NUMBER_COLUMN_WIDTH_PX = 40;\nexport const PROFILER_DEFAULT_COLUMN_WIDTH_PX = 140;\nexport const PROFILER_UNSUPPORTED_COLUMN_WIDTH_PX = 104;\n\nexport function getProfilerColumnWidthPx(column: MosaicProfilerColumnState) {\n return column.kind === 'unsupported'\n ? PROFILER_UNSUPPORTED_COLUMN_WIDTH_PX\n : PROFILER_DEFAULT_COLUMN_WIDTH_PX;\n}\n\nexport function getProfilerTableWidth(columns: MosaicProfilerColumnState[]) {\n return (\n PROFILER_ROW_NUMBER_COLUMN_WIDTH_PX +\n columns.reduce(\n (total, column) => total + getProfilerColumnWidthPx(column),\n 0,\n )\n );\n}\n"]}
@@ -0,0 +1,64 @@
1
+ import type { MosaicClient, Selection } from '@uwdata/mosaic-core';
2
+ import { queryFieldInfo } from '@uwdata/mosaic-core';
3
+ import type * as arrow from 'apache-arrow';
4
+ import type { MosaicProfilerSorting } from './types';
5
+ import type { ProfilerStore } from './createProfilerStore';
6
+ /**
7
+ * Loads field metadata for the profiler table and writes the normalized field
8
+ * definitions into the profiler store.
9
+ */
10
+ export declare function loadProfilerSchema(options: {
11
+ columns?: string[];
12
+ coordinator: Parameters<typeof queryFieldInfo>[0];
13
+ store: ProfilerStore;
14
+ tableName: string;
15
+ }): Promise<void>;
16
+ type ReadyConnection = {
17
+ coordinator: {
18
+ connect: (client: MosaicClient) => void;
19
+ disconnect: (client: MosaicClient) => void;
20
+ };
21
+ };
22
+ /**
23
+ * Connects the paged row client for the current profiler page and disconnects
24
+ * it when the caller tears down the lifecycle.
25
+ */
26
+ export declare function connectProfilerPageClient(options: {
27
+ connection: ReadyConnection;
28
+ fieldNames: string[];
29
+ filter?: ReturnType<Selection['predicate']>;
30
+ pagination: {
31
+ pageIndex: number;
32
+ pageSize: number;
33
+ };
34
+ sorting: MosaicProfilerSorting;
35
+ store: ProfilerStore;
36
+ tableName: string;
37
+ }): () => void;
38
+ /**
39
+ * Connects either the filtered or total count client and routes updates into
40
+ * the corresponding store slice.
41
+ */
42
+ export declare function connectProfilerCountClient(options: {
43
+ connection: ReadyConnection;
44
+ filterStable?: boolean;
45
+ selection?: Selection;
46
+ store: ProfilerStore;
47
+ tableName: string;
48
+ target: 'filtered' | 'total';
49
+ }): () => void;
50
+ /**
51
+ * Connects all per-column summary clients for the active schema and initializes
52
+ * matching empty summary state in the profiler store.
53
+ */
54
+ export declare function connectProfilerSummaryClients(options: {
55
+ categoryLimit: number;
56
+ connection: ReadyConnection;
57
+ fields: arrow.Field[];
58
+ selection: Selection;
59
+ store: ProfilerStore;
60
+ summaryBins: number;
61
+ tableName: string;
62
+ }): () => void;
63
+ export {};
64
+ //# sourceMappingURL=profilerController.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"profilerController.d.ts","sourceRoot":"","sources":["../../src/profiler/profilerController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,YAAY,EAAE,SAAS,EAAC,MAAM,qBAAqB,CAAC;AACjE,OAAO,EAAC,cAAc,EAAC,MAAM,qBAAqB,CAAC;AACnD,OAAO,KAAK,KAAK,KAAK,MAAM,cAAc,CAAC;AAY3C,OAAO,KAAK,EAA6B,qBAAqB,EAAC,MAAM,SAAS,CAAC;AAC/E,OAAO,KAAK,EAAC,aAAa,EAAC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5B,MAAM,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC;IACtB,SAAS,EAAE,SAAS,CAAC;IACrB,KAAK,EAAE,aAAa,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;CACnB,cAsEA"}
@@ -0,0 +1,123 @@
1
+ import { queryFieldInfo } from '@uwdata/mosaic-core';
2
+ import { ProfilerCategoryClient, ProfilerCategoryTotalClient, } from './ProfilerCategoryClient';
3
+ import { ProfilerCountClient } from './ProfilerCountClient';
4
+ import { ProfilerHistogramClient, ProfilerHistogramTotalClient, } from './ProfilerHistogramClient';
5
+ import { ProfilerPageClient } from './ProfilerPageClient';
6
+ import { ProfilerUnsupportedSummaryClient } from './ProfilerUnsupportedSummaryClient';
7
+ import { fieldInfoToProfilerField, getProfilerValueType, isProfilerHistogramType, isProfilerUnsupportedSummaryType, } from './utils';
8
+ function toError(error) {
9
+ return error instanceof Error ? error : new Error(String(error));
10
+ }
11
+ /**
12
+ * Loads field metadata for the profiler table and writes the normalized field
13
+ * definitions into the profiler store.
14
+ */
15
+ export async function loadProfilerSchema(options) {
16
+ const { columns, coordinator, store, tableName } = options;
17
+ store.getState().setSchemaLoading(true);
18
+ try {
19
+ const fieldInfo = await queryFieldInfo(coordinator, columns?.length
20
+ ? columns.map((column) => ({ column, table: tableName }))
21
+ : [{ column: '*', table: tableName }]);
22
+ store.getState().setSchemaSuccess(fieldInfo.map(fieldInfoToProfilerField));
23
+ }
24
+ catch (error) {
25
+ store.getState().setSchemaSuccess([]);
26
+ store.getState().setSchemaError(toError(error));
27
+ }
28
+ }
29
+ /**
30
+ * Connects the paged row client for the current profiler page and disconnects
31
+ * it when the caller tears down the lifecycle.
32
+ */
33
+ export function connectProfilerPageClient(options) {
34
+ const client = new ProfilerPageClient({
35
+ columns: options.fieldNames,
36
+ filter: options.filter,
37
+ onStateChange: (state) => options.store.getState().setPage(state),
38
+ pagination: options.pagination,
39
+ sorting: options.sorting,
40
+ tableName: options.tableName,
41
+ });
42
+ options.connection.coordinator.connect(client);
43
+ return () => {
44
+ options.connection.coordinator.disconnect(client);
45
+ };
46
+ }
47
+ /**
48
+ * Connects either the filtered or total count client and routes updates into
49
+ * the corresponding store slice.
50
+ */
51
+ export function connectProfilerCountClient(options) {
52
+ const setCountState = options.target === 'filtered'
53
+ ? options.store.getState().setFilteredCount
54
+ : options.store.getState().setTotalCount;
55
+ const client = new ProfilerCountClient({
56
+ filterStable: options.filterStable,
57
+ onStateChange: setCountState,
58
+ selection: options.selection,
59
+ tableName: options.tableName,
60
+ });
61
+ options.connection.coordinator.connect(client);
62
+ return () => {
63
+ options.connection.coordinator.disconnect(client);
64
+ };
65
+ }
66
+ /**
67
+ * Connects all per-column summary clients for the active schema and initializes
68
+ * matching empty summary state in the profiler store.
69
+ */
70
+ export function connectProfilerSummaryClients(options) {
71
+ const { categoryLimit, connection, fields, selection, store, summaryBins, tableName, } = options;
72
+ store.getState().initializeSummaries(fields);
73
+ const clients = fields.flatMap((field) => {
74
+ const update = (summary) => {
75
+ store.getState().setSummary(field.name, summary);
76
+ };
77
+ if (isProfilerUnsupportedSummaryType(field.type)) {
78
+ return [
79
+ new ProfilerUnsupportedSummaryClient({
80
+ field,
81
+ onStateChange: update,
82
+ selection,
83
+ tableName,
84
+ }),
85
+ ];
86
+ }
87
+ if (isProfilerHistogramType(field.type)) {
88
+ const summaryClient = new ProfilerHistogramClient({
89
+ field,
90
+ onStateChange: update,
91
+ selection,
92
+ steps: summaryBins,
93
+ tableName,
94
+ valueType: getProfilerValueType(field.type) === 'date' ? 'date' : 'number',
95
+ });
96
+ return [
97
+ summaryClient,
98
+ new ProfilerHistogramTotalClient({
99
+ summaryClient,
100
+ }),
101
+ ];
102
+ }
103
+ const summaryClient = new ProfilerCategoryClient({
104
+ categoryLimit,
105
+ field,
106
+ onStateChange: update,
107
+ selection,
108
+ tableName,
109
+ });
110
+ return [
111
+ summaryClient,
112
+ new ProfilerCategoryTotalClient({
113
+ summaryClient,
114
+ }),
115
+ ];
116
+ });
117
+ clients.forEach((client) => connection.coordinator.connect(client));
118
+ return () => {
119
+ clients.forEach((client) => connection.coordinator.disconnect(client));
120
+ store.getState().clearSummaries();
121
+ };
122
+ }
123
+ //# sourceMappingURL=profilerController.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"profilerController.js","sourceRoot":"","sources":["../../src/profiler/profilerController.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,cAAc,EAAC,MAAM,qBAAqB,CAAC;AAEnD,OAAO,EACL,sBAAsB,EACtB,2BAA2B,GAC5B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAC,mBAAmB,EAAC,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EACL,uBAAuB,EACvB,4BAA4B,GAC7B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAC,kBAAkB,EAAC,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAC,gCAAgC,EAAC,MAAM,oCAAoC,CAAC;AAGpF,OAAO,EACL,wBAAwB,EACxB,oBAAoB,EACpB,uBAAuB,EACvB,gCAAgC,GACjC,MAAM,SAAS,CAAC;AAEjB,SAAS,OAAO,CAAC,KAAc;IAC7B,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;AACnE,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,OAKxC;IACC,MAAM,EAAC,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,SAAS,EAAC,GAAG,OAAO,CAAC;IACzD,KAAK,CAAC,QAAQ,EAAE,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;IAExC,IAAI,CAAC;QACH,MAAM,SAAS,GAAG,MAAM,cAAc,CACpC,WAAW,EACX,OAAO,EAAE,MAAM;YACb,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM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AAI,CAAC,EAAE,CAAC;YACxC,MAAM,aAAa,GAAG,IAAI,uBAAuB,CAAC;gBAChD,KAAK;gBACL,aAAa,EAAE,MAAM;gBACrB,SAAS;gBACT,KAAK,EAAE,WAAW;gBAClB,SAAS;gBACT,SAAS,EACP,oBAAoB,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ;aAClE,CAAC,CAAC;YAEH,OAAO;gBACL,aAAa;gBACb,IAAI,4BAA4B,CAAC;oBAC/B,aAAa;iBACd,CAAC;aACH,CAAC;QACJ,CAAC;QAED,MAAM,aAAa,GAAG,IAAI,sBAAsB,CAAC;YAC/C,aAAa;YACb,KAAK;YACL,aAAa,EAAE,MAAM;YACrB,SAAS;YACT,SAAS;SACV,CAAC,CAAC;QAEH,OAAO;YACL,aAAa;YACb,IAAI,2BAA2B,CAAC;gBAC9B,aAAa;aACd,CAAC;SACH,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,UAAU,CAAC,WAAW,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;IAEpE,OAAO,GAAG,EAAE;QACV,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,UAAU,CAAC,WAAW,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;QACvE,KAAK,CAAC,QAAQ,EAAE,CAAC,cAAc,EAAE,CAAC;IACpC,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import type {MosaicClient, Selection} from '@uwdata/mosaic-core';\nimport {queryFieldInfo} from '@uwdata/mosaic-core';\nimport type * as arrow from 'apache-arrow';\nimport {\n ProfilerCategoryClient,\n ProfilerCategoryTotalClient,\n} from './ProfilerCategoryClient';\nimport {ProfilerCountClient} from './ProfilerCountClient';\nimport {\n ProfilerHistogramClient,\n ProfilerHistogramTotalClient,\n} from './ProfilerHistogramClient';\nimport {ProfilerPageClient} from './ProfilerPageClient';\nimport {ProfilerUnsupportedSummaryClient} from './ProfilerUnsupportedSummaryClient';\nimport type {MosaicProfilerSummaryState, MosaicProfilerSorting} from './types';\nimport type {ProfilerStore} from './createProfilerStore';\nimport {\n fieldInfoToProfilerField,\n getProfilerValueType,\n isProfilerHistogramType,\n isProfilerUnsupportedSummaryType,\n} from './utils';\n\nfunction toError(error: unknown): Error {\n return error instanceof Error ? error : new Error(String(error));\n}\n\n/**\n * Loads field metadata for the profiler table and writes the normalized field\n * definitions into the profiler store.\n */\nexport async function loadProfilerSchema(options: {\n columns?: string[];\n coordinator: Parameters<typeof queryFieldInfo>[0];\n store: ProfilerStore;\n tableName: string;\n}) {\n const {columns, coordinator, store, tableName} = options;\n store.getState().setSchemaLoading(true);\n\n try {\n const fieldInfo = await queryFieldInfo(\n coordinator,\n columns?.length\n ? columns.map((column) => ({column, table: tableName}))\n : [{column: '*', table: tableName}],\n );\n store.getState().setSchemaSuccess(fieldInfo.map(fieldInfoToProfilerField));\n } catch (error: unknown) {\n store.getState().setSchemaSuccess([]);\n store.getState().setSchemaError(toError(error));\n }\n}\n\ntype ReadyConnection = {\n coordinator: {\n connect: (client: MosaicClient) => void;\n disconnect: (client: MosaicClient) => void;\n };\n};\n\n/**\n * Connects the paged row client for the current profiler page and disconnects\n * it when the caller tears down the lifecycle.\n */\nexport function connectProfilerPageClient(options: {\n connection: ReadyConnection;\n fieldNames: string[];\n filter?: ReturnType<Selection['predicate']>;\n pagination: {pageIndex: number; pageSize: number};\n sorting: MosaicProfilerSorting;\n store: ProfilerStore;\n tableName: string;\n}) {\n const client = new ProfilerPageClient({\n columns: options.fieldNames,\n filter: options.filter,\n onStateChange: (state) => options.store.getState().setPage(state),\n pagination: options.pagination,\n sorting: options.sorting,\n tableName: options.tableName,\n });\n\n options.connection.coordinator.connect(client);\n\n return () => {\n options.connection.coordinator.disconnect(client);\n };\n}\n\n/**\n * Connects either the filtered or total count client and routes updates into\n * the corresponding store slice.\n */\nexport function connectProfilerCountClient(options: {\n connection: ReadyConnection;\n filterStable?: boolean;\n selection?: Selection;\n store: ProfilerStore;\n tableName: string;\n target: 'filtered' | 'total';\n}) {\n const setCountState =\n options.target === 'filtered'\n ? options.store.getState().setFilteredCount\n : options.store.getState().setTotalCount;\n\n const client = new ProfilerCountClient({\n filterStable: options.filterStable,\n onStateChange: setCountState,\n selection: options.selection,\n tableName: options.tableName,\n });\n\n options.connection.coordinator.connect(client);\n\n return () => {\n options.connection.coordinator.disconnect(client);\n };\n}\n\n/**\n * Connects all per-column summary clients for the active schema and initializes\n * matching empty summary state in the profiler store.\n */\nexport function connectProfilerSummaryClients(options: {\n categoryLimit: number;\n connection: ReadyConnection;\n fields: arrow.Field[];\n selection: Selection;\n store: ProfilerStore;\n summaryBins: number;\n tableName: string;\n}) {\n const {\n categoryLimit,\n connection,\n fields,\n selection,\n store,\n summaryBins,\n tableName,\n } = options;\n\n store.getState().initializeSummaries(fields);\n\n const clients: MosaicClient[] = fields.flatMap((field): MosaicClient[] => {\n const update = (summary: MosaicProfilerSummaryState) => {\n store.getState().setSummary(field.name, summary);\n };\n\n if (isProfilerUnsupportedSummaryType(field.type)) {\n return [\n new ProfilerUnsupportedSummaryClient({\n field,\n onStateChange: update,\n selection,\n tableName,\n }),\n ];\n }\n\n if (isProfilerHistogramType(field.type)) {\n const summaryClient = new ProfilerHistogramClient({\n field,\n onStateChange: update,\n selection,\n steps: summaryBins,\n tableName,\n valueType:\n getProfilerValueType(field.type) === 'date' ? 'date' : 'number',\n });\n\n return [\n summaryClient,\n new ProfilerHistogramTotalClient({\n summaryClient,\n }),\n ];\n }\n\n const summaryClient = new ProfilerCategoryClient({\n categoryLimit,\n field,\n onStateChange: update,\n selection,\n tableName,\n });\n\n return [\n summaryClient,\n new ProfilerCategoryTotalClient({\n summaryClient,\n }),\n ];\n });\n\n clients.forEach((client) => connection.coordinator.connect(client));\n\n return () => {\n clients.forEach((client) => connection.coordinator.disconnect(client));\n store.getState().clearSummaries();\n };\n}\n"]}