@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,24 +1,22 @@
1
1
  <script lang="ts">
2
2
  import {setContext, untrack, type Snippet} from 'svelte'
3
3
  import {writable} from 'svelte/store'
4
- import {propKey, strictBuild} from '../component-utilities/chartContext.js'
5
- import getColumnSummary from '../component-utilities/getColumnSummary.js'
6
- import {convertColumnToDate} from '../component-utilities/dateParsing.js'
7
- import checkInputs from '../component-utilities/checkInputs.js'
8
- import ErrorChart from './ErrorChart.svelte'
4
+ import {formatTitle} from '../component-utilities/format.ts'
5
+ import {summarizeColumn} from '../component-utilities/dataSummary.ts'
6
+ import ErrorDisplay from '../internal/ErrorDisplay.svelte'
9
7
  import TableHeader from './TableHeader.svelte'
10
8
  import TableRow from './TableRow.svelte'
11
9
  import TableGroupRow from './TableGroupRow.svelte'
12
10
  import TableSubtotalRow from './TableSubtotalRow.svelte'
13
11
  import TableTotalRow from './TableTotalRow.svelte'
14
12
  import Column from './Column.svelte'
15
- import {getFinalColumnOrder} from '../component-utilities/tableUtils'
16
13
  import {getThemeStores} from '../component-utilities/themeStores'
17
- import {toBoolean} from '../component-utilities/convert'
18
- import {logError} from '../internal/telemetry.js'
14
+ import {toBoolean} from '../component-utilities/inputUtils'
15
+ import {componentLogger} from '../internal/telemetry.js'
16
+ import type {QueryResult} from '../component-utilities/types.ts'
19
17
 
20
18
  interface Props {
21
- data?: any[], rows?: number | string, title?: string, subtitle?: string, rowNumbers?: boolean | string
19
+ data?: QueryResult, rows?: number | string, title?: string, rowNumbers?: boolean | string
22
20
  sort?: string, sortable?: boolean | string, groupBy?: string, groupsOpen?: boolean | string
23
21
  groupType?: 'accordion' | 'section', accordionRowColor?: string, groupNamePosition?: 'top' | 'middle' | 'bottom'
24
22
  subtotals?: boolean | string, subtotalRowColor?: string, subtotalFontColor?: string
@@ -32,7 +30,7 @@
32
30
  const {resolveColor} = getThemeStores()
33
31
 
34
32
  let {
35
- data = [], rows = 10, title = undefined, subtitle = undefined, rowNumbers = false, sort = undefined,
33
+ data = {rows: [], fields: []}, rows = 10, title = undefined, rowNumbers = false, sort = undefined,
36
34
  sortable = true, groupBy = undefined, groupsOpen = true, groupType = 'accordion',
37
35
  accordionRowColor = undefined, groupNamePosition = 'middle', subtotals = false,
38
36
  subtotalRowColor = undefined, subtotalFontColor = undefined, rowShading = false, rowLines = true,
@@ -64,15 +62,14 @@
64
62
 
65
63
  // Initialize store without data - it will be populated by the effect below
66
64
  const tablePropsStore = writable<{data: any[]; columns: any[]; priorityColumns:(string | undefined)[]}>({data: [], columns: [], priorityColumns: []})
67
- setContext(propKey, tablePropsStore)
65
+ setContext('tableProps', tablePropsStore)
68
66
 
69
67
  // Update store when data or groupBy changes
70
68
  $effect(() => {
71
- // Track data and groupBy
72
- let currentData = data
69
+ let currentRows = data?.rows ?? []
73
70
  let currentGroupBy = groupBy
74
71
  untrack(() => {
75
- tablePropsStore.update((state) => ({...state, data: currentData, priorityColumns: [currentGroupBy]}))
72
+ tablePropsStore.update((state) => ({...state, data: currentRows, priorityColumns: [currentGroupBy]}))
76
73
  })
77
74
  })
78
75
 
@@ -85,6 +82,7 @@
85
82
  let headerFontColorStore = $derived(resolveColor(headerFontColor))
86
83
  let backgroundColorStore = $derived(resolveColor(backgroundColor))
87
84
 
85
+ let logger = untrack(() => componentLogger('DataTable'))
88
86
  let priorityColumns = $derived<(string | undefined)[]>([groupBy])
89
87
 
90
88
  $effect(() => {
@@ -97,11 +95,6 @@
97
95
  // Use $derived to reactively read from the store
98
96
  let tablePropsColumns = $derived($tablePropsStore.columns ?? [])
99
97
 
100
- let finalColumnOrder = $derived(getFinalColumnOrder(tablePropsColumns.map((column: any) => column.id), priorityColumns))
101
- let orderedColumns = $derived([...tablePropsColumns].sort(
102
- (a, b) => finalColumnOrder.indexOf(a.id) - finalColumnOrder.indexOf(b.id),
103
- ))
104
-
105
98
  let sortObj: {col: string | null; ascending: boolean | null} = $state({col: null, ascending: null})
106
99
 
107
100
  // Parse initial sort on mount
@@ -129,69 +122,83 @@
129
122
  // Process data - combine all data processing into one $derived.by block to avoid loops
130
123
  let processedState = $derived.by(() => {
131
124
  let resultError: string | undefined = undefined
132
- let resultColumnSummary: any[] = []
125
+ let resultColumns: any[] = []
133
126
  let resultProcessedData: any[] = []
134
127
  let resultDataTestId: string | undefined = undefined
135
128
  let resultNormalizedData: any[] = []
136
129
 
137
130
  try {
138
- // First normalize data - extract rows array from object if needed
139
- let inputData: any[]
140
- if (!Array.isArray(data)) {
141
- let raw = data as any
142
- resultDataTestId = coerceId(raw?.id)
143
- let candidate = raw?.rows
144
- inputData = Array.isArray(candidate) ? candidate : []
145
- } else {
146
- resultDataTestId = coerceId((data as any)?.id)
147
- inputData = data
131
+ let inputRows = Array.isArray(data?.rows) ? data.rows : []
132
+ let inputFields = Array.isArray(data?.fields) ? data.fields : []
133
+ resultDataTestId = coerceId((data as any)?.id)
134
+
135
+ if (!Array.isArray(inputFields) || inputFields.length === 0) throw new Error('Table data is missing field metadata.')
136
+ if (Array.isArray(inputRows) && inputRows.length > 0) {
137
+ for (let colName of Object.keys(inputRows[0])) {
138
+ let field = inputFields.find(item => item?.name?.toLowerCase() === colName?.toLowerCase())
139
+ let type = String(field?.type || '').toLowerCase()
140
+ let resolvedField = field ?? {name: colName, type}
141
+ let stats = type === 'number' ? summarizeColumn(inputRows, resolvedField, ['min', 'max']) : {}
142
+
143
+ resultColumns.push({
144
+ id: colName,
145
+ defaultTitle: formatTitle(colName),
146
+ type,
147
+ field: resolvedField,
148
+ stats,
149
+ })
150
+ }
148
151
  }
149
152
 
150
- checkInputs(inputData)
151
- resultColumnSummary = getColumnSummary(inputData, 'array')
153
+ if (link && !showLinkColBool) resultColumns = resultColumns.filter((column) => column.id !== link)
152
154
 
153
155
  if (initialSort.sortBy) {
154
- let columnNames = resultColumnSummary.map((col) => col.id)
156
+ let columnNames = resultColumns.map((col) => col.id)
155
157
  if (!columnNames.includes(initialSort.sortBy)) {
156
158
  throw new Error(`${initialSort.sortBy} is not a column in the dataset. sort should contain one column name and optionally a direction (asc or desc).`)
157
159
  }
158
160
  }
159
161
 
160
- let dateCols = resultColumnSummary
161
- .filter((col) => col.type === 'date' && !(inputData?.[0]?.[col.id] instanceof Date))
162
- .map((col) => col.id)
163
-
164
- let tempData = inputData
165
- for (let columnId of dateCols) {
166
- tempData = convertColumnToDate(tempData, columnId)
167
- }
168
- resultProcessedData = tempData
169
- resultNormalizedData = tempData
170
-
171
- if (link && !showLinkColBool) {
172
- let linkIndex = resultColumnSummary.findIndex((col) => col.id === link)
173
- if (linkIndex !== -1) {
174
- resultColumnSummary = [...resultColumnSummary.slice(0, linkIndex), ...resultColumnSummary.slice(linkIndex + 1)]
175
- }
176
- }
177
- } catch (thrown) {
162
+ resultProcessedData = inputRows
163
+ resultNormalizedData = inputRows
164
+ } catch(thrown) {
178
165
  let message = thrown instanceof Error ? thrown.message : 'Unable to prepare dataset'
179
- logError(thrown, {id: 'DataTable'})
180
166
  resultError = message
181
- if (strictBuild) throw thrown
182
167
  }
168
+ logger.error(resultError)
183
169
 
184
170
  return {
185
171
  error: resultError,
186
- columnSummary: resultColumnSummary,
172
+ columns: resultColumns,
187
173
  processedData: resultProcessedData,
188
174
  dataTestId: resultDataTestId,
189
175
  normalizedData: resultNormalizedData,
190
176
  }
191
177
  })
192
178
 
179
+ let columnLookup = $derived.by(() => {
180
+ let lookup: Record<string, any> = {}
181
+ for (let column of processedState.columns) lookup[column.id] = column
182
+ return lookup
183
+ })
184
+
185
+ let resolvedColumns = $derived(tablePropsColumns.map((column: any) => {
186
+ let meta = columnLookup[column.id] || {}
187
+ return {
188
+ ...column,
189
+ defaultTitle: meta.defaultTitle ?? formatTitle(column.id),
190
+ type: meta.type,
191
+ field: meta.field,
192
+ stats: meta.stats,
193
+ }
194
+ }))
195
+
196
+ let finalColumnOrder = $derived(getFinalColumnOrder(resolvedColumns.map((column: any) => column.id), priorityColumns))
197
+ let orderedColumns = $derived([...resolvedColumns].sort(
198
+ (a, b) => finalColumnOrder.indexOf(a.id) - finalColumnOrder.indexOf(b.id),
199
+ ))
200
+
193
201
  // Extract processed state
194
- let columnSummary = $derived(processedState.columnSummary)
195
202
  let normalizedData = $derived(processedState.normalizedData)
196
203
  let dataTestId = $derived(processedState.dataTestId)
197
204
 
@@ -213,6 +220,12 @@
213
220
  return String(value).toLowerCase()
214
221
  }
215
222
 
223
+ const getFinalColumnOrder = (columns: string[], priorityColumns: Array<string | undefined>): string[] => {
224
+ let priorities = priorityColumns.filter(Boolean) as string[]
225
+ let restColumns = columns.filter(key => !priorities.includes(key))
226
+ return [...priorities, ...restColumns]
227
+ }
228
+
216
229
  const compareValues = (a: unknown, b: unknown, ascending: boolean) => {
217
230
  let modifier = ascending ? 1 : -1
218
231
  if (a === b) return 0
@@ -290,8 +303,7 @@
290
303
  }
291
304
  })
292
305
 
293
- const handleToggle = (event: CustomEvent<{groupName: string}>) => {
294
- let {groupName} = event.detail
306
+ const handleToggle = ({groupName}: {groupName: string}) => {
295
307
  groupToggleStates = {...groupToggleStates, [groupName]: !groupToggleStates[groupName]}
296
308
  }
297
309
 
@@ -353,7 +365,7 @@
353
365
  {#if children}
354
366
  {@render children()}
355
367
  {:else}
356
- {#each columnSummary as column (column.id)}
368
+ {#each processedState.columns as column (column.id)}
357
369
  <Column id={column.id} />
358
370
  {/each}
359
371
  {/if}
@@ -362,10 +374,9 @@
362
374
  class={`table-container ${paginated ? 'table-container--has-pagination' : ''}`}
363
375
  data-testid={isFullPageBool ? undefined : `DataTable-${dataTestId ?? 'no-id'}`}
364
376
  >
365
- {#if title || subtitle}
377
+ {#if title}
366
378
  <div class="table-title">
367
- {#if title}<div class="table-title__headline">{title}</div>{/if}
368
- {#if subtitle}<div class="table-title__subhead">{subtitle}</div>{/if}
379
+ <div class="table-title__headline">{title}</div>
369
380
  </div>
370
381
  {/if}
371
382
 
@@ -376,7 +387,6 @@
376
387
  headerColor={$headerColorStore}
377
388
  headerFontColor={$headerFontColorStore}
378
389
  {orderedColumns}
379
- {columnSummary}
380
390
  sortable={sortableBool}
381
391
  {sortClick}
382
392
  formatColumnTitles={formatColumnTitlesBool}
@@ -393,11 +403,10 @@
393
403
  {groupName}
394
404
  currentGroupData={sortedGroupedData[groupName]}
395
405
  toggled={groupToggleStates[groupName]}
396
- {columnSummary}
397
406
  rowNumbers={effectiveRowNumbers}
398
407
  rowColor={$accordionRowColorStore}
399
408
  subtotals={subtotalsBool}
400
- ontoggle={handleToggle}
409
+ onToggle={handleToggle}
401
410
  {orderedColumns}
402
411
  compact={compactBool}
403
412
  />
@@ -410,12 +419,12 @@
410
419
  rowNumbers={effectiveRowNumbers}
411
420
  rowLines={rowLinesBool}
412
421
  compact={compactBool}
413
- {columnSummary}
414
422
  grouped={true}
415
423
  {groupType}
416
424
  groupColumn={groupBy}
417
425
  groupNamePosition={groupNamePosition}
418
426
  orderedColumns={orderedColumns}
427
+ columnLookup={columnLookup}
419
428
  index={groupOffsets[groupName] ?? 0}
420
429
  rowSpan={sortedGroupedData[groupName].length}
421
430
  />
@@ -423,11 +432,11 @@
423
432
  <TableSubtotalRow
424
433
  {groupName}
425
434
  currentGroupData={sortedGroupedData[groupName]}
426
- {columnSummary}
427
435
  rowColor={$subtotalRowColorStore}
428
436
  fontColor={$subtotalFontColorStore}
429
437
  groupBy={groupBy}
430
438
  groupType={groupType}
439
+ rowNumbers={effectiveRowNumbers}
431
440
  {orderedColumns}
432
441
  compact={compactBool}
433
442
  />
@@ -442,12 +451,12 @@
442
451
  rowNumbers={effectiveRowNumbers}
443
452
  rowLines={rowLinesBool}
444
453
  compact={compactBool}
445
- {columnSummary}
446
454
  grouped={false}
447
455
  {groupType}
448
456
  groupColumn={groupBy}
449
457
  groupNamePosition={groupNamePosition}
450
458
  orderedColumns={orderedColumns}
459
+ columnLookup={columnLookup}
451
460
  index={rowsNum * (currentPage - 1)}
452
461
  />
453
462
  {/if}
@@ -456,7 +465,6 @@
456
465
  <TableTotalRow
457
466
  data={tableData}
458
467
  rowNumbers={effectiveRowNumbers}
459
- {columnSummary}
460
468
  rowColor={$totalRowColorStore}
461
469
  fontColor={$totalFontColorStore}
462
470
  groupType={groupType}
@@ -481,7 +489,9 @@
481
489
  {/if}
482
490
  </div>
483
491
  {:else}
484
- <ErrorChart title="Data Table" error={error ?? emptyMessage ?? 'Unable to render table'} />
492
+ <div style="min-height:200px;width:100%;display:grid;align-content:center;padding:8px;box-sizing:border-box">
493
+ <ErrorDisplay error={error ?? emptyMessage ?? 'Unable to render table'} />
494
+ </div>
485
495
  {/if}
486
496
 
487
497
  <style>
@@ -490,7 +500,7 @@
490
500
  margin: 8px 0;
491
501
  position: relative;
492
502
  color: var(--color-base-content, #1f2937);
493
- font-family: var(--ui-font-family, system-ui);
503
+ font-family: var(--font-ui, system-ui);
494
504
  line-height: 1.45;
495
505
  }
496
506
 
@@ -508,12 +518,6 @@
508
518
  line-height: 1.3;
509
519
  }
510
520
 
511
- .table-title__subhead {
512
- color: var(--color-base-content-muted, #6b7280);
513
- font-size: 13px;
514
- margin-top: 2px;
515
- }
516
-
517
521
  .scrollbox {
518
522
  width: 100%;
519
523
  overflow-x: auto;