@graphenedata/cli 0.0.15 → 0.0.16

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 (117) hide show
  1. package/README.md +138 -0
  2. package/dist/cli/bigQuery-I3F46SC6.js +75 -0
  3. package/dist/cli/bigQuery-I3F46SC6.js.map +7 -0
  4. package/dist/cli/chunk-OVWODUTJ.js +12849 -0
  5. package/dist/cli/chunk-OVWODUTJ.js.map +7 -0
  6. package/dist/cli/chunk-QAXEOZ43.js +53 -0
  7. package/dist/cli/chunk-QAXEOZ43.js.map +7 -0
  8. package/dist/cli/cli.js +234 -11197
  9. package/dist/cli/clickhouse-ZN5AN2UL.js +64 -0
  10. package/dist/cli/clickhouse-ZN5AN2UL.js.map +7 -0
  11. package/dist/cli/duckdb-IYBIO5KJ.js +87 -0
  12. package/dist/cli/duckdb-IYBIO5KJ.js.map +7 -0
  13. package/dist/cli/serve2-TNN5EROW.js +447 -0
  14. package/dist/cli/serve2-TNN5EROW.js.map +7 -0
  15. package/dist/cli/snowflake-MOQB5GA4.js +128 -0
  16. package/dist/cli/snowflake-MOQB5GA4.js.map +7 -0
  17. package/dist/index.d.ts +63 -0
  18. package/dist/lang/index.d.ts +63 -0
  19. package/dist/skills/graphene/SKILL.md +150 -96
  20. package/dist/skills/graphene/references/big-value.md +6 -41
  21. package/dist/skills/graphene/references/date-range.md +64 -0
  22. package/dist/skills/graphene/references/dropdown.md +3 -4
  23. package/dist/skills/graphene/references/echarts.md +162 -0
  24. package/dist/skills/graphene/references/gsql.md +55 -25
  25. package/dist/skills/graphene/references/model-gsql.md +72 -0
  26. package/dist/skills/graphene/references/table.md +13 -14
  27. package/dist/skills/graphene/references/text-input.md +2 -1
  28. package/dist/ui/app.css +239 -340
  29. package/dist/ui/component-utilities/dataShaping.ts +484 -0
  30. package/dist/ui/component-utilities/dataSummary.ts +57 -0
  31. package/dist/ui/component-utilities/enrich.ts +763 -0
  32. package/dist/ui/component-utilities/format.ts +177 -0
  33. package/dist/ui/component-utilities/inputUtils.ts +44 -8
  34. package/dist/ui/component-utilities/theme.ts +200 -0
  35. package/dist/ui/component-utilities/themeStores.ts +21 -8
  36. package/dist/ui/component-utilities/types.ts +70 -0
  37. package/dist/ui/components/AreaChart.svelte +57 -105
  38. package/dist/ui/components/BarChart.svelte +71 -129
  39. package/dist/ui/components/BigValue.svelte +24 -40
  40. package/dist/ui/components/Column.svelte +10 -18
  41. package/dist/ui/components/DateRange.svelte +54 -21
  42. package/dist/ui/components/Dropdown.svelte +47 -26
  43. package/dist/ui/components/DropdownOption.svelte +1 -2
  44. package/dist/ui/components/ECharts.svelte +181 -67
  45. package/dist/ui/components/InlineDelta.svelte +50 -31
  46. package/dist/ui/components/LineChart.svelte +54 -125
  47. package/dist/ui/components/PieChart.svelte +27 -37
  48. package/dist/ui/components/QueryLoad.svelte +77 -45
  49. package/dist/ui/components/Row.svelte +2 -1
  50. package/dist/ui/components/ScatterPlot.svelte +52 -0
  51. package/dist/ui/components/Skeleton.svelte +32 -0
  52. package/dist/ui/components/Table.svelte +3 -2
  53. package/dist/ui/components/TableGroupRow.svelte +28 -36
  54. package/dist/ui/components/TableHarness.svelte +32 -0
  55. package/dist/ui/components/TableHeader.svelte +34 -59
  56. package/dist/ui/components/TableRow.svelte +14 -38
  57. package/dist/ui/components/TableSubtotalRow.svelte +18 -21
  58. package/dist/ui/components/TableTotalRow.svelte +27 -37
  59. package/dist/ui/components/TextInput.svelte +13 -12
  60. package/dist/ui/components/Value.svelte +25 -0
  61. package/dist/ui/components/_Table.svelte +72 -70
  62. package/dist/ui/internal/ChartGallery.svelte +527 -0
  63. package/dist/ui/internal/ErrorDisplay.svelte +22 -97
  64. package/dist/ui/internal/LocalApp.svelte +80 -17
  65. package/dist/ui/internal/PageNavGroup.svelte +269 -0
  66. package/dist/ui/internal/Sidebar.svelte +178 -0
  67. package/dist/ui/internal/SidebarToggle.svelte +47 -0
  68. package/dist/ui/internal/StyleGallery.svelte +244 -0
  69. package/dist/ui/internal/clientCache.ts +2 -2
  70. package/dist/ui/internal/pageInputs.svelte.js +292 -0
  71. package/dist/ui/internal/queryEngine.ts +102 -117
  72. package/dist/ui/internal/runSocket.ts +32 -12
  73. package/dist/ui/internal/sidebar.svelte.js +18 -0
  74. package/dist/ui/internal/telemetry.ts +51 -16
  75. package/dist/ui/internal/types.d.ts +7 -0
  76. package/dist/ui/web.js +28 -11
  77. package/package.json +36 -38
  78. package/dist/skills/graphene/references/area-chart.md +0 -95
  79. package/dist/skills/graphene/references/bar-chart.md +0 -112
  80. package/dist/skills/graphene/references/line-chart.md +0 -108
  81. package/dist/skills/graphene/references/pie-chart.md +0 -29
  82. package/dist/skills/graphene/references/value-formats.md +0 -104
  83. package/dist/ui/component-utilities/autoFormatting.js +0 -280
  84. package/dist/ui/component-utilities/builtInFormats.js +0 -481
  85. package/dist/ui/component-utilities/chartContext.js +0 -12
  86. package/dist/ui/component-utilities/chartWindowDebug.js +0 -21
  87. package/dist/ui/component-utilities/checkInputs.js +0 -84
  88. package/dist/ui/component-utilities/convert.js +0 -15
  89. package/dist/ui/component-utilities/dateParsing.js +0 -56
  90. package/dist/ui/component-utilities/dropdownContext.ts +0 -1
  91. package/dist/ui/component-utilities/echarts.js +0 -252
  92. package/dist/ui/component-utilities/echartsThemes.js +0 -443
  93. package/dist/ui/component-utilities/formatTitle.js +0 -24
  94. package/dist/ui/component-utilities/formatting.js +0 -241
  95. package/dist/ui/component-utilities/getColumnExtents.js +0 -79
  96. package/dist/ui/component-utilities/getColumnSummary.js +0 -62
  97. package/dist/ui/component-utilities/getCompletedData.js +0 -122
  98. package/dist/ui/component-utilities/getDistinctCount.js +0 -7
  99. package/dist/ui/component-utilities/getDistinctValues.js +0 -15
  100. package/dist/ui/component-utilities/getSeriesConfig.js +0 -231
  101. package/dist/ui/component-utilities/getSortedData.js +0 -9
  102. package/dist/ui/component-utilities/getStackPercentages.js +0 -45
  103. package/dist/ui/component-utilities/getStackedData.js +0 -19
  104. package/dist/ui/component-utilities/getYAxisIndex.js +0 -15
  105. package/dist/ui/component-utilities/globalContexts.js +0 -1
  106. package/dist/ui/component-utilities/helpers/getCompletedData.helpers.js +0 -119
  107. package/dist/ui/component-utilities/replaceNulls.js +0 -16
  108. package/dist/ui/component-utilities/tableUtils.ts +0 -107
  109. package/dist/ui/component-utilities/tidyWithTypes.js +0 -9
  110. package/dist/ui/components/Area.svelte +0 -214
  111. package/dist/ui/components/Bar.svelte +0 -347
  112. package/dist/ui/components/Chart.svelte +0 -995
  113. package/dist/ui/components/Line.svelte +0 -227
  114. package/dist/ui/internal/NavSidebar.svelte +0 -396
  115. package/dist/ui/internal/theme.ts +0 -60
  116. package/dist/ui/public/inter-latin-ext.woff2 +0 -0
  117. package/dist/ui/public/inter-latin.woff2 +0 -0
@@ -1,280 +0,0 @@
1
- import ssf from 'ssf'
2
-
3
- export const AUTO_FORMAT_CODE = 'auto'
4
-
5
- /**
6
- * The number of units to display the median value in the series
7
- */
8
- const AUTO_FORMAT_MEDIAN_PRECISION = 3
9
- /**
10
- * Describes implicit formats for columns having a certain name pattern and an evidence type (matched via matchingFunction).
11
- * This will only be applied to columns that cannot be matched to existing custom or built-in formats.
12
- * These won't be shown in the settings panel.
13
- * The ORDER in the array will take precedence as a columnName/evidenceType can be matched to multiple formats
14
- */
15
- const IMPLICIT_COLUMN_AUTO_FORMATS = [
16
- {
17
- name: 'year',
18
- description: 'When lowerCase(columnName)="year" with the column having numeric values will result in no formatting',
19
- matchingFunction: (columnName, evidenceTypeDescriptor, columnUnitSummary) => {
20
- if (columnName && evidenceTypeDescriptor) {
21
- return 'year' === columnName.toLowerCase() && (evidenceTypeDescriptor?.evidenceType === 'number' || columnUnitSummary?.unitType === 'number') //TODO use evidence type constant
22
- }
23
- return false
24
- },
25
- format: {
26
- formatCode: AUTO_FORMAT_CODE,
27
- valueType: 'number',
28
- exampleInput: 2013,
29
- _autoFormat: {
30
- autoFormatCode: '@',
31
- truncateUnits: false,
32
- },
33
- },
34
- },
35
- {
36
- name: 'id',
37
- description: 'When lowerCase(columnName)="id" with the column having numeric values, then values will have no formatting',
38
- matchingFunction: (columnName, evidenceTypeDescriptor, columnUnitSummary) => {
39
- if (columnName && evidenceTypeDescriptor) {
40
- return 'id' === columnName.toLowerCase() && (evidenceTypeDescriptor?.evidenceType === 'number' || columnUnitSummary?.unitType === 'number')
41
- }
42
- return false
43
- },
44
- format: {
45
- formatCode: AUTO_FORMAT_CODE,
46
- valueType: 'number',
47
- exampleInput: 93120121,
48
- _autoFormat: {
49
- autoFormatFunction: typedValue => {
50
- if (typedValue !== null && typedValue !== undefined && !isNaN(typedValue)) {
51
- return typedValue.toLocaleString('fullwide', {
52
- useGrouping: false,
53
- })
54
- } else {
55
- return typedValue
56
- }
57
- },
58
- },
59
- },
60
- },
61
- {
62
- name: 'defaultDate',
63
- description: 'Formatting for Default Date',
64
- matchingFunction: (columnName, evidenceTypeDescriptor, columnUnitSummary) => {
65
- if (evidenceTypeDescriptor) {
66
- return evidenceTypeDescriptor?.evidenceType === 'date' || columnUnitSummary?.unitType === 'date'
67
- }
68
- return false
69
- },
70
- format: {
71
- formatCode: AUTO_FORMAT_CODE,
72
- valueType: 'date',
73
- exampleInput: 'Sat Jan 01 2022 03:15:00 GMT-0500',
74
- _autoFormat: {
75
- autoFormatCode: 'YYYY-MM-DD',
76
- truncateUnits: false,
77
- },
78
- },
79
- },
80
- ]
81
-
82
- /**
83
- *
84
- * @param {number | undefined} value
85
- * @param {string} unit
86
- * @returns {number | undefined} the value in the given unit
87
- */
88
- export const applyColumnUnits = (value, unit) => {
89
- switch (unit) {
90
- case 'T':
91
- return value / 1000000000000
92
- case 'B':
93
- return value / 1000000000
94
- case 'M':
95
- return value / 1000000
96
- case 'k':
97
- return value / 1000
98
- default:
99
- return value
100
- }
101
- }
102
-
103
- /**
104
- *
105
- * @param {*} format the format to update with auto formatting
106
- * @param {*} formatCode the code to use
107
- * @param {*} truncateNumbers should k, M, B column units be applied?
108
- * @returns the format
109
- */
110
- export const configureAutoFormatting = (format, formatCode = '@', truncateUnits = false) => {
111
- format._autoFormat = {
112
- autoFormatCode: formatCode,
113
- truncateUnits: truncateUnits,
114
- }
115
- return format
116
- }
117
-
118
- export const isAutoFormat = (format, effectiveCode) => {
119
- let matchesCode = (effectiveCode || format.formatCode)?.toLowerCase() === AUTO_FORMAT_CODE
120
- let autoFormatCode = format._autoFormat?.autoFormatFunction || format._autoFormat?.autoFormatCode
121
- if (matchesCode && autoFormatCode !== undefined) {
122
- return true
123
- } else {
124
- return false
125
- }
126
- }
127
-
128
- export const generateImplicitNumberFormat = (columnUnitSummary, maxDisplayDecimals = 7) => {
129
- let effectiveFormatCode
130
- let columnUnits = ''
131
-
132
- let median = columnUnitSummary?.median
133
- let truncateUnits
134
-
135
- if (median !== undefined) {
136
- let medianInUnitTerms
137
- columnUnits = getAutoColumnUnit(median)
138
- if (columnUnits) {
139
- medianInUnitTerms = applyColumnUnits(median, columnUnits)
140
- truncateUnits = true
141
- } else {
142
- medianInUnitTerms = median
143
- truncateUnits = false
144
- }
145
-
146
- if (columnUnitSummary.maxDecimals === 0 && !truncateUnits) {
147
- effectiveFormatCode = '#,##0'
148
- } else {
149
- effectiveFormatCode = computeNumberAutoFormatCode(medianInUnitTerms, maxDisplayDecimals)
150
- }
151
- } else {
152
- effectiveFormatCode = '#,##0'
153
- truncateUnits = false
154
- }
155
-
156
- return {
157
- formatCode: AUTO_FORMAT_CODE,
158
- valueType: 'number',
159
- _autoFormat: {
160
- autoFormatCode: effectiveFormatCode,
161
- truncateUnits: truncateUnits,
162
- columnUnits: columnUnits,
163
- },
164
- }
165
- }
166
-
167
- export const findImplicitAutoFormat = (columnName, evidenceTypeDescriptor, columnUnitSummary) => {
168
- let matched = IMPLICIT_COLUMN_AUTO_FORMATS.find(implicitFormat => implicitFormat.matchingFunction(columnName, evidenceTypeDescriptor, columnUnitSummary))
169
- if (matched) {
170
- return matched.format
171
- } else {
172
- if (columnUnitSummary?.unitType === 'number') {
173
- return generateImplicitNumberFormat(columnUnitSummary)
174
- }
175
- }
176
- return undefined
177
- }
178
-
179
- /**
180
- * Formatting logic for formats with formatCode=AUTO_FORMAT_CODE
181
- * @param {*} typedValue the value to be formatted
182
- * @param {*} columnFormat the auto formatting description with _autoFormat settings
183
- * @param {*} columnUnitSummary the summary of units in the column (only applicable to numbered columns)
184
- * @returns formattedv value
185
- */
186
- export const autoFormat = (typedValue, columnFormat, columnUnitSummary = undefined) => {
187
- if (columnFormat._autoFormat?.autoFormatFunction) {
188
- return columnFormat._autoFormat.autoFormatFunction(typedValue, columnFormat, columnUnitSummary)
189
- } else if (columnFormat._autoFormat.autoFormatCode) {
190
- let autoFormatCode = columnFormat?._autoFormat?.autoFormatCode
191
- let valueType = columnFormat.valueType
192
- if ('number' === valueType) {
193
- let truncateUnits = columnFormat?._autoFormat?.truncateUnits
194
-
195
- let unitValue = typedValue
196
- let unit = ''
197
-
198
- if (truncateUnits && columnUnitSummary?.median !== undefined) {
199
- //use of median is a bit detached here. Perhaps _autoFormat.truncateUnits could instead be _autoFormat.columnUnits=k|M|B (already done for default currency)
200
- //this will affect the auto currency formatting since they simply rely on the median. Perhaps they should be functions instead.
201
- unit = getAutoColumnUnit(columnUnitSummary.median)
202
- unitValue = applyColumnUnits(typedValue, unit)
203
- }
204
- return ssf.format(autoFormatCode, unitValue) + unit
205
- } else {
206
- return ssf.format(autoFormatCode, typedValue)
207
- }
208
- } else {
209
- console.warn('autoFormat called without a formatCode or function')
210
- }
211
- return typedValue
212
- }
213
-
214
- /**
215
- * Formatting for any column without formatting settings
216
- * @param {*} typedValue a value of type number|date|string
217
- * @returns the formatted value
218
- */
219
- export const fallbackFormat = typedValue => {
220
- if (typeof typedValue === 'number') {
221
- return typedValue.toLocaleString(undefined, {
222
- minimumFractionDigits: 0,
223
- maximumFractionDigits: 2,
224
- })
225
- } else if (typedValue !== undefined && typedValue !== null) {
226
- return typedValue?.toString()
227
- } else {
228
- return '-'
229
- }
230
- }
231
-
232
- //TODO: use rewire.js to enable testing without exporting.
233
- /**
234
- * @param {number} referenceValue
235
- * @returns {string} the number format code for the given reference value
236
- */
237
- export function computeNumberAutoFormatCode(referenceValue, maxDisplayDecimals = 7, significantDigits = AUTO_FORMAT_MEDIAN_PRECISION) {
238
- let formatCodeBuilder = '#,##0'
239
-
240
- let referenceValueLeadingDigitExponent = base10Exponent(referenceValue)
241
- let displayDecimals = 0
242
-
243
- if (referenceValueLeadingDigitExponent - significantDigits < 0) {
244
- displayDecimals = Math.min(Math.max(Math.abs(referenceValueLeadingDigitExponent - significantDigits + 1), 0), maxDisplayDecimals)
245
- }
246
-
247
- if (displayDecimals > 0) {
248
- formatCodeBuilder += '.'
249
- formatCodeBuilder += '0'.repeat(displayDecimals)
250
- }
251
-
252
- return formatCodeBuilder
253
- }
254
-
255
- /**
256
- * @param {number | undefined} value
257
- * @returns {string} the appropriate unit (B, M, k or '') for the given value
258
- */
259
- function getAutoColumnUnit(value) {
260
- let absoluteValue = Math.abs(value)
261
- if (absoluteValue >= 5000000000000) {
262
- return 'T'
263
- } else if (absoluteValue >= 5000000000) {
264
- return 'B'
265
- } else if (absoluteValue >= 5000000) {
266
- return 'M'
267
- } else if (absoluteValue >= 5000) {
268
- return 'k'
269
- } else {
270
- return ''
271
- }
272
- }
273
-
274
- function base10Exponent(value) {
275
- if (value === 0) {
276
- return 0
277
- } else {
278
- return Math.floor(Math.log10(value))
279
- }
280
- }