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