@graphenedata/cli 0.0.15 → 0.0.17

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 +174 -0
  2. package/dist/cli/bigQuery-OQUNH3VT.js +75 -0
  3. package/dist/cli/bigQuery-OQUNH3VT.js.map +7 -0
  4. package/dist/cli/chunk-56K2FF57.js +53 -0
  5. package/dist/cli/chunk-56K2FF57.js.map +7 -0
  6. package/dist/cli/chunk-TZTTALAV.js +12868 -0
  7. package/dist/cli/chunk-TZTTALAV.js.map +7 -0
  8. package/dist/cli/cli.js +260 -11196
  9. package/dist/cli/clickhouse-S3BJSKND.js +65 -0
  10. package/dist/cli/clickhouse-S3BJSKND.js.map +7 -0
  11. package/dist/cli/duckdb-TKVMONRK.js +87 -0
  12. package/dist/cli/duckdb-TKVMONRK.js.map +7 -0
  13. package/dist/cli/serve2-S2LL4D4D.js +448 -0
  14. package/dist/cli/serve2-S2LL4D4D.js.map +7 -0
  15. package/dist/cli/snowflake-3VPDEYYP.js +128 -0
  16. package/dist/cli/snowflake-3VPDEYYP.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 +156 -95
  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 +70 -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 +793 -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 +84 -19
  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 +112 -129
  72. package/dist/ui/internal/runSocket.ts +31 -14
  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 +30 -11
  77. package/package.json +40 -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,481 +0,0 @@
1
- import ssf from 'ssf'
2
-
3
- import {AUTO_FORMAT_CODE, applyColumnUnits, generateImplicitNumberFormat} from './autoFormatting'
4
-
5
- export const SUPPORTED_CURRENCIES = [
6
- {
7
- primaryCode: 'usd',
8
- currencySymbol: '$',
9
- displayName: 'USD - United States Dollar',
10
- },
11
- {
12
- primaryCode: 'aud',
13
- currencySymbol: 'A$',
14
- displayName: 'AUD - Australian Dollar',
15
- escapeCurrencySymbol: true,
16
- },
17
- {
18
- primaryCode: 'brl',
19
- currencySymbol: 'R$',
20
- displayName: 'BRL - Brazilian Real',
21
- escapeCurrencySymbol: true,
22
- },
23
- {
24
- primaryCode: 'cad',
25
- currencySymbol: 'C$',
26
- displayName: 'CAD - Canadian Dollar',
27
- escapeCurrencySymbol: true,
28
- },
29
- {
30
- primaryCode: 'cny',
31
- currencySymbol: '¥',
32
- displayName: 'CNY - Renminbi',
33
- escapeCurrencySymbol: true,
34
- },
35
- {primaryCode: 'eur', currencySymbol: '€', displayName: 'EUR - Euro'},
36
- {
37
- primaryCode: 'gbp',
38
- currencySymbol: '£',
39
- displayName: 'GBP - Pound Sterling',
40
- escapeCurrencySymbol: true,
41
- },
42
- {
43
- primaryCode: 'jpy',
44
- currencySymbol: '¥',
45
- displayName: 'JPY - Japanese Yen',
46
- escapeCurrencySymbol: true,
47
- },
48
- {
49
- primaryCode: 'inr',
50
- currencySymbol: '₹',
51
- displayName: 'INR - Indian Rupee',
52
- escapeCurrencySymbol: true,
53
- },
54
- {
55
- primaryCode: 'krw',
56
- currencySymbol: '₩',
57
- displayName: 'KRW - South Korean won',
58
- escapeCurrencySymbol: true,
59
- },
60
- {
61
- primaryCode: 'ngn',
62
- currencySymbol: '₦',
63
- displayName: 'NGN - Nigerian Naira',
64
- escapeCurrencySymbol: true,
65
- },
66
- {
67
- primaryCode: 'rub',
68
- currencySymbol: 'rub',
69
- displayName: 'RUB - Russian Ruble',
70
- escapeCurrencySymbol: true,
71
- },
72
- {
73
- primaryCode: 'sek',
74
- currencySymbol: 'kr',
75
- displayName: 'SEK - Swedish Krona',
76
- escapeCurrencySymbol: true,
77
- },
78
- ]
79
-
80
- const DERIVED_CURRENCY_FORMATS = [
81
- {
82
- derivedSuffix: '',
83
- valueFormatCode: '#,##0',
84
- exampleInput: 412.17,
85
- auto: true,
86
- },
87
- {
88
- derivedSuffix: '0',
89
- valueFormatCode: '#,##0',
90
- exampleInput: 7043.123,
91
- },
92
- {
93
- derivedSuffix: '1',
94
- valueFormatCode: '#,##0.0',
95
- exampleInput: 7043.123,
96
- },
97
- {
98
- derivedSuffix: '2',
99
- valueFormatCode: '#,##0.00',
100
- exampleInput: 7043.123,
101
- },
102
- {
103
- derivedSuffix: '0k',
104
- valueFormatCode: '#,##0,"k"',
105
- exampleInput: 64301.12,
106
- },
107
- {
108
- derivedSuffix: '1k',
109
- valueFormatCode: '#,##0.0,"k"',
110
- exampleInput: 64301.12,
111
- },
112
- {
113
- derivedSuffix: '2k',
114
- valueFormatCode: '#,##0.00,"k"',
115
- exampleInput: 64301.12,
116
- },
117
- {
118
- derivedSuffix: '0m',
119
- valueFormatCode: '#,##0,,"M"',
120
- exampleInput: 4564301.12,
121
- },
122
- {
123
- derivedSuffix: '1m',
124
- valueFormatCode: '#,##0.0,,"M"',
125
- exampleInput: 4564301.12,
126
- },
127
- {
128
- derivedSuffix: '2m',
129
- valueFormatCode: '#,##0.00,,"M"',
130
- exampleInput: 4564301.12,
131
- },
132
- {
133
- derivedSuffix: '0b',
134
- valueFormatCode: '#,##0,,,"B"',
135
- exampleInput: 9784564301.12,
136
- },
137
- {
138
- derivedSuffix: '1b',
139
- valueFormatCode: '#,##0.0,,,"B"',
140
- exampleInput: 9784564301.12,
141
- },
142
- {
143
- derivedSuffix: '2b',
144
- valueFormatCode: '#,##0.00,,,"B"',
145
- exampleInput: 9784564301.12,
146
- },
147
- ]
148
-
149
- const CURRENCY_FORMATS = SUPPORTED_CURRENCIES.map(currency => {
150
- let derivedFormats = []
151
- DERIVED_CURRENCY_FORMATS.forEach(derivedFormat => {
152
- let next = {
153
- formatTag: currency.primaryCode + derivedFormat.derivedSuffix,
154
- parentFormat: currency.primaryCode,
155
- formatCategory: 'currency',
156
- valueType: 'number',
157
- exampleInput: derivedFormat.exampleInput,
158
- titleTagReplacement: ` (${currency.currencySymbol})`,
159
- }
160
- let symbolInFormatCode = currency.escapeCurrencySymbol ? `"${currency.currencySymbol}"` : currency.currencySymbol
161
- if (derivedFormat.auto || AUTO_FORMAT_CODE === derivedFormat.formatCode) {
162
- next.formatCode = AUTO_FORMAT_CODE
163
- //TODO This should be fixed so that 1)the format is NOT recomputed for each value, 2)remove some of magic is done to make it look good.
164
- next._autoFormat = {
165
- autoFormatFunction: (typedValue, columnFormat, columnUnitSummary) => {
166
- let format = generateImplicitNumberFormat(columnUnitSummary, 2)
167
- let effectiveCode = `${symbolInFormatCode}${format._autoFormat.autoFormatCode}`
168
- let suffix = ''
169
- let displayValue = typedValue
170
- if (format._autoFormat.truncateUnits && format._autoFormat.columnUnits) {
171
- suffix = format._autoFormat.columnUnits
172
- displayValue = applyColumnUnits(typedValue, format._autoFormat.columnUnits)
173
- } else {
174
- if (effectiveCode.endsWith('.0')) {
175
- effectiveCode = effectiveCode + '0'
176
- }
177
- }
178
- return ssf.format(effectiveCode, displayValue) + suffix
179
- },
180
- }
181
- } else {
182
- next.formatCode = `${symbolInFormatCode}${derivedFormat.valueFormatCode}`
183
- }
184
- if (derivedFormat.axisValueFormatCode) {
185
- next.axisFormatCode = derivedFormat.axisValueFormatCode
186
- }
187
- derivedFormats.push(next)
188
- })
189
- return derivedFormats
190
- }).flat()
191
-
192
- export const BUILT_IN_FORMATS = [
193
- ...CURRENCY_FORMATS,
194
- //auto formats
195
- // Date/Time:
196
- {
197
- formatTag: 'ddd',
198
- formatCode: 'ddd',
199
- formatCategory: 'date',
200
- valueType: 'date',
201
- exampleInput: '2022-01-09 12:45',
202
- },
203
- {
204
- formatTag: 'dddd',
205
- formatCode: 'dddd',
206
- formatCategory: 'date',
207
- valueType: 'date',
208
- exampleInput: '2022-01-09 12:45',
209
- },
210
- {
211
- formatTag: 'mmm',
212
- formatCode: 'mmm',
213
- formatCategory: 'date',
214
- valueType: 'date',
215
- exampleInput: '2022-01-09 12:45',
216
- },
217
- {
218
- formatTag: 'mmmm',
219
- formatCode: 'mmmm',
220
- formatCategory: 'date',
221
- valueType: 'date',
222
- exampleInput: '2022-01-09 12:45',
223
- },
224
- {
225
- formatTag: 'yyyy',
226
- formatCode: 'yyyy',
227
- formatCategory: 'date',
228
- valueType: 'date',
229
- exampleInput: '2022-01-09 12:45',
230
- },
231
- {
232
- formatTag: 'shortdate',
233
- formatCode: 'mmm d/yy',
234
- formatCategory: 'date',
235
- valueType: 'date',
236
- exampleInput: '2022-01-09 12:45',
237
- },
238
- {
239
- formatTag: 'longdate',
240
- formatCode: 'mmmm d, yyyy',
241
- formatCategory: 'date',
242
- valueType: 'date',
243
- exampleInput: '2022-01-09 12:45',
244
- },
245
- {
246
- formatTag: 'fulldate',
247
- formatCode: 'dddd mmmm d, yyyy',
248
- formatCategory: 'date',
249
- valueType: 'date',
250
- exampleInput: '2022-01-09 12:45',
251
- },
252
- {
253
- formatTag: 'mdy',
254
- formatCode: 'm/d/y',
255
- formatCategory: 'date',
256
- valueType: 'date',
257
- exampleInput: '2022-01-09 12:45',
258
- },
259
- {
260
- formatTag: 'dmy',
261
- formatCode: 'd/m/y',
262
- formatCategory: 'date',
263
- valueType: 'date',
264
- exampleInput: '2022-01-09 12:45',
265
- },
266
- {
267
- formatTag: 'hms',
268
- formatCode: 'H:MM:SS AM/PM',
269
- formatCategory: 'date',
270
- valueType: 'date',
271
- exampleInput: '2022-01-09T11:45:03',
272
- },
273
- // Numbers:
274
- {
275
- formatTag: 'num0',
276
- formatCode: '#,##0',
277
- formatCategory: 'number',
278
- valueType: 'number',
279
- exampleInput: 11.23168,
280
- },
281
- {
282
- formatTag: 'num1',
283
- formatCode: '#,##0.0',
284
- formatCategory: 'number',
285
- valueType: 'number',
286
- exampleInput: 11.23168,
287
- },
288
- {
289
- formatTag: 'num2',
290
- formatCode: '#,##0.00',
291
- formatCategory: 'number',
292
- valueType: 'number',
293
- exampleInput: 11.23168,
294
- },
295
- {
296
- formatTag: 'num3',
297
- formatCode: '#,##0.000',
298
- formatCategory: 'number',
299
- valueType: 'number',
300
- exampleInput: 11.23168,
301
- },
302
- {
303
- formatTag: 'num4',
304
- formatCode: '#,##0.0000',
305
- formatCategory: 'number',
306
- valueType: 'number',
307
- exampleInput: 11.23168,
308
- },
309
- {
310
- formatTag: 'num0k',
311
- formatCode: '#,##0,"k"',
312
- formatCategory: 'number',
313
- valueType: 'number',
314
- exampleInput: 64201,
315
- },
316
- {
317
- formatTag: 'num1k',
318
- formatCode: '#,##0.0,"k"',
319
- formatCategory: 'number',
320
- valueType: 'number',
321
- exampleInput: 64201,
322
- },
323
- {
324
- formatTag: 'num2k',
325
- formatCode: '#,##0.00,"k"',
326
- formatCategory: 'number',
327
- valueType: 'number',
328
- exampleInput: 64201,
329
- },
330
- {
331
- formatTag: 'num0m',
332
- formatCode: '#,##0,,"M"',
333
- formatCategory: 'number',
334
- valueType: 'number',
335
- exampleInput: 42539483,
336
- },
337
- {
338
- formatTag: 'num1m',
339
- formatCode: '#,##0.0,,"M"',
340
- formatCategory: 'number',
341
- valueType: 'number',
342
- exampleInput: 42539483,
343
- },
344
- {
345
- formatTag: 'num2m',
346
- formatCode: '#,##0.00,,"M"',
347
- formatCategory: 'number',
348
- valueType: 'number',
349
- exampleInput: 42539483,
350
- },
351
- {
352
- formatTag: 'num0b',
353
- formatCode: '#,##0,,,"B"',
354
- formatCategory: 'number',
355
- valueType: 'number',
356
- exampleInput: 1384937584,
357
- },
358
- {
359
- formatTag: 'num1b',
360
- formatCode: '#,##0.0,,,"B"',
361
- formatCategory: 'number',
362
- valueType: 'number',
363
- exampleInput: 1384937584,
364
- },
365
- {
366
- formatTag: 'num2b',
367
- formatCode: '#,##0.00,,,"B"',
368
- formatCategory: 'number',
369
- valueType: 'number',
370
- exampleInput: 1384937584,
371
- },
372
- {
373
- formatTag: 'id',
374
- formatCode: '0',
375
- formatCategory: 'number',
376
- valueType: 'number',
377
- exampleInput: '921594675',
378
- titleTagReplacement: ' id',
379
- },
380
- {
381
- formatTag: 'fract',
382
- formatCode: '# ?/?',
383
- formatCategory: 'number',
384
- valueType: 'number',
385
- exampleInput: '0.25',
386
- },
387
- {
388
- formatTag: 'mult',
389
- formatCode: '#,##0.0"x"',
390
- formatCategory: 'number',
391
- valueType: 'number',
392
- exampleInput: '5.32',
393
- },
394
- {
395
- formatTag: 'mult0',
396
- formatCode: '#,##0"x"',
397
- formatCategory: 'number',
398
- valueType: 'number',
399
- exampleInput: '5.32',
400
- },
401
- {
402
- formatTag: 'mult1',
403
- formatCode: '#,##0.0"x"',
404
- formatCategory: 'number',
405
- valueType: 'number',
406
- exampleInput: '5.32',
407
- },
408
- {
409
- formatTag: 'mult2',
410
- formatCode: '#,##0.00"x"',
411
- formatCategory: 'number',
412
- valueType: 'number',
413
- exampleInput: '5.32',
414
- },
415
- {
416
- formatTag: 'sci',
417
- formatCode: '0.00E+0',
418
- formatCategory: 'number',
419
- valueType: 'number',
420
- exampleInput: '16546.1561',
421
- },
422
-
423
- // Percent:
424
- {
425
- formatTag: 'pct',
426
- formatCode: AUTO_FORMAT_CODE,
427
- formatCategory: 'percent',
428
- valueType: 'number',
429
- exampleInput: 0.731,
430
- titleTagReplacement: '',
431
- _autoFormat: {
432
- autoFormatFunction: (typedValue, columnFormat, columnUnitSummary) => {
433
- if ('number' === columnUnitSummary?.unitType) {
434
- let adjustedColumnUnitSummary = {
435
- min: columnUnitSummary.min * 100,
436
- max: columnUnitSummary.max * 100,
437
- median: columnUnitSummary.median * 100,
438
- maxDecimals: Math.max(columnUnitSummary.maxDecimals - 2, 0),
439
- unitType: columnUnitSummary.unitType,
440
- }
441
- let format = generateImplicitNumberFormat(adjustedColumnUnitSummary)
442
- return ssf.format(format._autoFormat.autoFormatCode, typedValue * 100) + '%'
443
- } else {
444
- return ssf.format('#,##0%', typedValue)
445
- }
446
- },
447
- },
448
- },
449
- {
450
- formatTag: 'pct0',
451
- formatCode: '#,##0%',
452
- formatCategory: 'percent',
453
- valueType: 'number',
454
- exampleInput: 0.731,
455
- titleTagReplacement: '',
456
- },
457
- {
458
- formatTag: 'pct1',
459
- formatCode: '#,##0.0%',
460
- formatCategory: 'percent',
461
- valueType: 'number',
462
- exampleInput: 0.731,
463
- titleTagReplacement: '',
464
- },
465
- {
466
- formatTag: 'pct2',
467
- formatCode: '#,##0.00%',
468
- formatCategory: 'percent',
469
- valueType: 'number',
470
- exampleInput: 0.731,
471
- titleTagReplacement: '',
472
- },
473
- {
474
- formatTag: 'pct3',
475
- formatCode: '#,##0.000%',
476
- formatCategory: 'percent',
477
- valueType: 'number',
478
- exampleInput: 0.731,
479
- titleTagReplacement: '',
480
- },
481
- ]
@@ -1,12 +0,0 @@
1
- import {getContext, setContext} from 'svelte'
2
- const configKey = Symbol()
3
- const propKey = Symbol()
4
-
5
- export const strictBuild = false
6
- export {configKey, propKey}
7
-
8
- export const getConfigContext = () => getContext(configKey)
9
- export const setConfigContext = v => setContext(configKey, v)
10
-
11
- export const getPropContext = () => getContext(propKey)
12
- export const setPropContext = v => setContext(propKey, v)
@@ -1,21 +0,0 @@
1
- const s = Symbol.for('__evidence-chart-window-debug__')
2
- const isBrowser = typeof window !== 'undefined'
3
-
4
- /**
5
- * @param {string} key
6
- * @param {unknown} value
7
- */
8
- export const set = (key, value) => {
9
- if (!isBrowser) return
10
- if (!window[s]) window[s] = {}
11
- window[s][key] = value
12
- }
13
-
14
- /**
15
- * @param {string} key
16
- */
17
- export const unset = key => {
18
- if (!isBrowser) return
19
- if (!window[s]) window[s] = {}
20
- delete window[s][key]
21
- }
@@ -1,84 +0,0 @@
1
- export default function checkInputs(data, reqCols, optCols) {
2
- // reqCols is an array of columns to check in the dataset
3
- let columns = []
4
-
5
- // Check if dataset was provided
6
- if (data === undefined) {
7
- throw Error('No data provided')
8
- } else if (typeof data !== 'object') {
9
- throw Error("'" + data + "'" + ' is not a recognized query result. Data should be provided in the format: data = {' + data.replace('data.', '') + '}')
10
- } else if (data[0] === undefined || data.length === 0) {
11
- throw Error('Dataset is empty: query ran successfully, but no data was returned from the database')
12
- }
13
-
14
- // Check if data warehouse returned an error
15
- if (data[0]?.error_object?.error != null) {
16
- throw Error('SQL Error: ' + data[0]?.error_object?.error?.message)
17
- }
18
-
19
- if (reqCols != undefined) {
20
- if (!(reqCols instanceof Array)) {
21
- throw Error('reqCols must be passed in as an array')
22
- }
23
-
24
- // Check if columns were provided
25
- for (let i = 0; i < reqCols.length; i++) {
26
- if (reqCols[i] == null) {
27
- throw Error(`Missing required column(s): ${reqCols[i]} not found in data set.`)
28
- } else if (reqCols[i] == '') {
29
- throw Error('Missing required column(s): A Empty string was provided for one of your props.')
30
- }
31
- }
32
-
33
- // let errorString;
34
- // if(missingCols.length > 0){
35
- // errorString = missingCols[0]
36
- // for(i = 1; i < missingCols.length; i++){
37
- // errorString = errorString + ", " + missingCols[i];
38
- // }
39
- // errorString = errorString + " not provided";
40
- // throw Error(errorString);
41
- // }
42
-
43
- // const dataIsQueryStore = data instanceof QueryStore;
44
-
45
- // Get list of all columns in dataset
46
- // we want to handle cases where the columns have not yet been fetched, but the data is avialable
47
- // this is most likely to happen during pre-rendering, because column metadata is not yet included
48
- // in the prerendering process
49
- if (!data.columnsLoaded && data.dataLoaded) {
50
- let cols = Object.keys(data[0])
51
- for (let col of cols) {
52
- columns.push(col)
53
- }
54
- } else {
55
- for (let col of data.columns) {
56
- columns.push(col.column_name)
57
- }
58
- }
59
-
60
- // Check if provided columns are in the dataset
61
- let currentCol
62
- for (let i = 0; i < reqCols.length; i++) {
63
- currentCol = reqCols[i]
64
- if (!columns.includes(currentCol)) {
65
- throw Error("'" + currentCol + "' is not a column in the dataset")
66
- }
67
- }
68
-
69
- if (optCols != undefined && optCols.some(col => col != null)) {
70
- for (let i = 0; i < optCols.length; i++) {
71
- currentCol = optCols[i]
72
- if (currentCol == null) continue
73
- if (!columns.includes(currentCol)) {
74
- throw Error("'" + currentCol + "' is not a column in the dataset")
75
- }
76
- }
77
- }
78
- }
79
- // IDEAS:
80
- // Trigger a function call when error is caught - that function somehow sends us to the Error chart component
81
- // rather than letting the rest of the current component file continue running?
82
- // Almost 2 layers of error: (1) up front check errors and (2) actual execution of the chart errors
83
- // (1) is handled here, (2) may need a wrapper around the main part of the component code
84
- }
@@ -1,15 +0,0 @@
1
- export const toBoolean = value => {
2
- if (typeof value === 'undefined' || value === null) return undefined
3
- if (typeof value === 'string') {
4
- let normalized = value.trim().toLowerCase()
5
- if (normalized === 'true') return true
6
- if (normalized === 'false') return false
7
- }
8
- return Boolean(value)
9
- }
10
-
11
- export const toNumber = value => {
12
- if (typeof value === 'undefined' || value === null) return undefined
13
- let num = Number(value)
14
- return Number.isNaN(num) ? undefined : num
15
- }
@@ -1,56 +0,0 @@
1
- import {mutate} from '@tidyjs/tidy'
2
-
3
- import {tidyWithTypes} from './tidyWithTypes.js'
4
-
5
- export function standardizeDateString(date) {
6
- if (date && typeof date === 'string') {
7
- // Parses an individual string into a JS date object
8
-
9
- let dateSplit = date.split(' ')
10
-
11
- // If date doesn't contain timestamp, add one at midnight (avoids timezone interpretation issue)
12
- if (!date.includes(':')) {
13
- date = date + 'T00:00:00'
14
- }
15
-
16
- // Remove any character groups beyond 2 (date and time):
17
- if (dateSplit.length > 2) {
18
- date = dateSplit[0] + ' ' + dateSplit[1]
19
- }
20
-
21
- // Replace microseconds if needed:
22
- let re = /\.([^\s]+)/
23
- date = date.replace(re, '')
24
-
25
- // Remove "Z" to avoid timezone interpretation issue:
26
- date = date.replace('Z', '')
27
-
28
- // Replace spaces with "T" to conform to ECMA standard:
29
- date = date.replace(' ', 'T')
30
- }
31
-
32
- return date
33
- }
34
-
35
- export function convertColumnToDate(data, column) {
36
- // Replaces a date column's string values with JS date objects, using the standardizeDateString function
37
-
38
- let converted = tidyWithTypes(data, mutate({[column]: d => (d[column] ? new Date(standardizeDateString(d[column])) : null)}))
39
-
40
- if (data && typeof data === 'object') {
41
- for (let key of Object.keys(data)) {
42
- if (!/^\d+$/.test(key)) converted[key] = data[key]
43
- }
44
- }
45
-
46
- return converted
47
- }
48
-
49
- export function standardizeDateColumn(data, column) {
50
- // Replaces a date column's string values with standardized date strings, using the standardizeDateString function
51
- // Used in Chart.svelte, where using Date objects leads to errors
52
-
53
- data = tidyWithTypes(data, mutate({[column]: d => standardizeDateString(d[column])}))
54
-
55
- return data
56
- }
@@ -1 +0,0 @@
1
- export const DROPDOWN_CONTEXT = Symbol('DropdownContext')