@graphenedata/cli 0.0.12 → 0.0.14
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.
- package/dist/cli/cli.js +8591 -1214
- package/dist/docs/base.md +98 -0
- package/dist/docs/cli.md +22 -0
- package/dist/docs/graphene.md +10 -10
- package/dist/ui/component-utilities/echarts.js +2 -3
- package/dist/ui/component-utilities/formatting.js +3 -11
- package/dist/ui/component-utilities/getSeriesConfig.js +2 -1
- package/dist/ui/components/Area.svelte +188 -151
- package/dist/ui/components/AreaChart.svelte +43 -79
- package/dist/ui/components/Bar.svelte +273 -255
- package/dist/ui/components/BarChart.svelte +58 -112
- package/dist/ui/components/BigValue.svelte +13 -7
- package/dist/ui/components/Chart.svelte +280 -317
- package/dist/ui/components/Column.svelte +102 -113
- package/dist/ui/components/DateRange.svelte +37 -27
- package/dist/ui/components/Dropdown.svelte +77 -57
- package/dist/ui/components/DropdownOption.svelte +10 -7
- package/dist/ui/components/ECharts.svelte +23 -16
- package/dist/ui/components/ErrorChart.svelte +85 -21
- package/dist/ui/components/GrapheneQuery.svelte +7 -3
- package/dist/ui/components/InlineDelta.svelte +53 -34
- package/dist/ui/components/Line.svelte +192 -178
- package/dist/ui/components/LineChart.svelte +53 -96
- package/dist/ui/components/PieChart.svelte +26 -15
- package/dist/ui/components/QueryLoad.svelte +15 -10
- package/dist/ui/components/SortIcon.svelte +5 -1
- package/dist/ui/components/Table.svelte +15 -9
- package/dist/ui/components/TableCell.svelte +30 -17
- package/dist/ui/components/TableGroupRow.svelte +26 -19
- package/dist/ui/components/TableGroupToggle.svelte +9 -6
- package/dist/ui/components/TableHeader.svelte +37 -27
- package/dist/ui/components/TableRow.svelte +30 -20
- package/dist/ui/components/TableSubtotalRow.svelte +16 -9
- package/dist/ui/components/TableTotalRow.svelte +18 -11
- package/dist/ui/components/TextInput.svelte +23 -20
- package/dist/ui/components/_Table.svelte +303 -260
- package/dist/ui/internal/LocalApp.svelte +40 -0
- package/dist/ui/internal/NavSidebar.svelte +27 -30
- package/dist/ui/internal/PageError.svelte +23 -0
- package/dist/ui/internal/checkSocket.ts +48 -0
- package/dist/ui/internal/queryEngine.ts +9 -2
- package/dist/ui/internal/telemetry.ts +1 -0
- package/dist/ui/web.js +5 -55
- package/package.json +9 -10
- package/cli.ts +0 -156
- package/dist/ui/internal/NavSidebarHMR.svelte +0 -8
|
@@ -1,24 +1,31 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import echarts from '../component-utilities/echarts.js'
|
|
3
|
-
import {createEventDispatcher} from 'svelte'
|
|
4
3
|
import {getThemeStores} from '../component-utilities/themeStores'
|
|
5
4
|
|
|
5
|
+
interface Props {
|
|
6
|
+
config: any
|
|
7
|
+
height?: string | number
|
|
8
|
+
width?: string | number
|
|
9
|
+
data: any
|
|
10
|
+
queryID?: any
|
|
11
|
+
renderer?: 'canvas' | 'svg'
|
|
12
|
+
echartsOptions?: any
|
|
13
|
+
seriesOptions?: any
|
|
14
|
+
seriesColors?: any
|
|
15
|
+
connectGroup?: string
|
|
16
|
+
xAxisLabelOverflow?: 'truncate' | 'break'
|
|
17
|
+
chartTitle?: string
|
|
18
|
+
onclick?: (params: any) => void
|
|
19
|
+
}
|
|
20
|
+
|
|
6
21
|
const {activeAppearance} = getThemeStores()
|
|
7
22
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
export let renderer: 'canvas' | 'svg' | undefined = undefined
|
|
14
|
-
export let echartsOptions: any = undefined
|
|
15
|
-
export let seriesOptions: any = undefined
|
|
16
|
-
export let seriesColors: any = undefined
|
|
17
|
-
export let connectGroup: string | undefined = undefined
|
|
18
|
-
export let xAxisLabelOverflow: 'truncate' | 'break' | undefined = undefined
|
|
19
|
-
export let chartTitle: string | undefined = undefined
|
|
23
|
+
let {
|
|
24
|
+
config, height = '240px', width = '100%', data, queryID = undefined, renderer = undefined,
|
|
25
|
+
echartsOptions = undefined, seriesOptions = undefined, seriesColors = undefined,
|
|
26
|
+
connectGroup = undefined, xAxisLabelOverflow = undefined, chartTitle = undefined, onclick = undefined,
|
|
27
|
+
}: Props = $props()
|
|
20
28
|
|
|
21
|
-
const dispatch = createEventDispatcher()
|
|
22
29
|
const isBrowser = typeof window !== 'undefined'
|
|
23
30
|
|
|
24
31
|
const toDimension = (dimension: string | number | undefined, fallback: string) => {
|
|
@@ -42,14 +49,14 @@
|
|
|
42
49
|
data,
|
|
43
50
|
echartsOptions,
|
|
44
51
|
seriesOptions,
|
|
45
|
-
|
|
52
|
+
onclick,
|
|
46
53
|
renderer,
|
|
47
54
|
connectGroup,
|
|
48
55
|
xAxisLabelOverflow,
|
|
49
56
|
seriesColors,
|
|
50
57
|
theme: $activeAppearance,
|
|
51
58
|
}}
|
|
52
|
-
|
|
59
|
+
></div>
|
|
53
60
|
{/if}
|
|
54
61
|
</div>
|
|
55
62
|
|
|
@@ -1,24 +1,81 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
2
|
+
type GrapheneError = {
|
|
3
|
+
type?: string
|
|
4
|
+
id?: string
|
|
5
|
+
file?: string
|
|
6
|
+
message?: string
|
|
7
|
+
stack?: string
|
|
8
|
+
from?: {line?: number, col?: number, lineText?: string}
|
|
9
|
+
loc?: {line?: number, column?: number}
|
|
10
|
+
line?: number
|
|
11
|
+
column?: number
|
|
12
|
+
codeFrame?: string
|
|
13
|
+
frame?: string
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
interface Props {
|
|
17
|
+
error: unknown
|
|
18
|
+
title?: string
|
|
19
|
+
height?: number
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
let {error, title: _title, height = 200}: Props = $props()
|
|
23
|
+
|
|
24
|
+
function parseError (raw: unknown): GrapheneError {
|
|
25
|
+
if (raw instanceof Error) return {message: raw.message, stack: raw.stack}
|
|
26
|
+
if (typeof raw === 'string') return {message: raw}
|
|
27
|
+
if (raw && typeof raw === 'object') return raw as GrapheneError
|
|
28
|
+
return {message: String(raw)}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function lineDetails (e: GrapheneError) {
|
|
32
|
+
let line = e.from?.line ?? e.loc?.line ?? e.line
|
|
33
|
+
let column = e.from?.col ?? e.loc?.column ?? e.column
|
|
34
|
+
let lineText = e.from?.lineText
|
|
35
|
+
let pointer = Number.isFinite(column) ? `${' '.repeat(Math.max(0, (column || 1) - 1))}^` : ''
|
|
36
|
+
return {line, lineText, pointer}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function classifyError (e: GrapheneError) {
|
|
40
|
+
if (e.type === 'analysis' || e.from || e.loc || e.codeFrame || e.frame) return `GSQL error - ${e.message || 'Unknown query error'}`
|
|
41
|
+
if (e.type === 'database') return 'Database query failed'
|
|
42
|
+
if (e.type === 'server') return 'Server error while running query'
|
|
43
|
+
return 'Query failed'
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
let parsed = $derived.by(() => {
|
|
47
|
+
let e = parseError(error)
|
|
48
|
+
let heading = classifyError(e)
|
|
49
|
+
let message = e.message || 'An unknown error occurred'
|
|
50
|
+
let details: string[] = []
|
|
51
|
+
let line = lineDetails(e)
|
|
52
|
+
// Query errors can be analyzed from generated wrapper gsql (`table <name> as (...)`).
|
|
53
|
+
// When that happens, line numbers are often for synthetic sql and can be misleading,
|
|
54
|
+
// but the captured source line text and caret are still accurate and useful to users.
|
|
55
|
+
// So we show file + line only when the diagnostic has a reliable line.
|
|
56
|
+
let fileLine = e.file && e.file !== 'input' ? `${e.file}${line.line ? `:${line.line}` : ''}` : undefined
|
|
57
|
+
|
|
58
|
+
if (e.id) details.push(e.id)
|
|
59
|
+
if (fileLine) details.push(fileLine)
|
|
60
|
+
else if (line.line) details.push(`Line ${line.line}`)
|
|
61
|
+
if (line.lineText) details.push(line.lineText)
|
|
62
|
+
if (line.pointer) details.push(line.pointer)
|
|
63
|
+
if (e.codeFrame) details.push(e.codeFrame)
|
|
64
|
+
if (e.frame) details.push(e.frame)
|
|
65
|
+
|
|
66
|
+
if (heading.startsWith('GSQL error - ')) message = ''
|
|
67
|
+
return {heading, message, details}
|
|
68
|
+
})
|
|
17
69
|
</script>
|
|
18
70
|
|
|
19
71
|
<div class="error-chart" style={`min-height:${height}px`} role="alert">
|
|
20
|
-
<div class="error-
|
|
21
|
-
|
|
72
|
+
<div class="error-chart__heading">{parsed.heading}</div>
|
|
73
|
+
{#if parsed.message}
|
|
74
|
+
<div class="error-chart__message">{parsed.message}</div>
|
|
75
|
+
{/if}
|
|
76
|
+
{#if parsed.details.length}
|
|
77
|
+
<pre class="error-chart__details">{parsed.details.join('\n')}</pre>
|
|
78
|
+
{/if}
|
|
22
79
|
</div>
|
|
23
80
|
|
|
24
81
|
<style>
|
|
@@ -35,14 +92,21 @@
|
|
|
35
92
|
box-sizing: border-box;
|
|
36
93
|
}
|
|
37
94
|
|
|
38
|
-
.error-
|
|
39
|
-
font-weight:
|
|
40
|
-
|
|
41
|
-
|
|
95
|
+
.error-chart__heading {
|
|
96
|
+
font-weight: 700;
|
|
97
|
+
margin-bottom: 4px;
|
|
98
|
+
text-align: center;
|
|
42
99
|
}
|
|
43
100
|
|
|
44
101
|
.error-chart__message {
|
|
45
102
|
margin: 0;
|
|
103
|
+
text-align: center;
|
|
104
|
+
max-width: 72ch;
|
|
105
|
+
line-height: 1.4;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.error-chart__details {
|
|
109
|
+
margin: 10px 0 0;
|
|
46
110
|
font-family: 'SFMono-Regular', Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
|
|
47
111
|
font-size: 12px;
|
|
48
112
|
white-space: pre-wrap;
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
<script>
|
|
1
|
+
<script lang="ts">
|
|
2
2
|
import {onMount} from 'svelte'
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
interface Props {
|
|
5
|
+
name: string
|
|
6
|
+
code: string
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
let {name, code}: Props = $props()
|
|
6
10
|
|
|
7
11
|
onMount(() => {
|
|
8
12
|
if (typeof window !== 'undefined' && window.$GRAPHENE) {
|
|
@@ -3,35 +3,54 @@
|
|
|
3
3
|
import {getThemeStores} from '../component-utilities/themeStores'
|
|
4
4
|
import {toBoolean} from '../component-utilities/convert'
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
6
|
+
interface Props {
|
|
7
|
+
value?: number | string | null
|
|
8
|
+
fmt?: string
|
|
9
|
+
formatObject?: any
|
|
10
|
+
columnUnitSummary?: any
|
|
11
|
+
downIsGood?: boolean
|
|
12
|
+
showValue?: boolean
|
|
13
|
+
showSymbol?: boolean
|
|
14
|
+
symbolPosition?: 'left' | 'right'
|
|
15
|
+
neutralMin?: number
|
|
16
|
+
neutralMax?: number
|
|
17
|
+
chip?: boolean
|
|
18
|
+
align?: 'left' | 'right' | 'center' | string
|
|
19
|
+
text?: string
|
|
20
|
+
className?: string
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
let {
|
|
24
|
+
value = undefined,
|
|
25
|
+
fmt = undefined,
|
|
26
|
+
formatObject = undefined,
|
|
27
|
+
columnUnitSummary = undefined,
|
|
28
|
+
downIsGood: downIsGoodProp = false,
|
|
29
|
+
showValue: showValueProp = true,
|
|
30
|
+
showSymbol: showSymbolProp = true,
|
|
31
|
+
symbolPosition = 'right',
|
|
32
|
+
neutralMin = 0,
|
|
33
|
+
neutralMax = 0,
|
|
34
|
+
chip: chipProp = false,
|
|
35
|
+
align = 'right',
|
|
36
|
+
text = undefined,
|
|
37
|
+
className = undefined,
|
|
38
|
+
}: Props = $props()
|
|
39
|
+
|
|
40
|
+
let downIsGood = $derived(toBoolean(downIsGoodProp) ?? false)
|
|
41
|
+
let showValue = $derived(toBoolean(showValueProp) ?? true)
|
|
42
|
+
let showSymbol = $derived(toBoolean(showSymbolProp) ?? true)
|
|
43
|
+
let chip = $derived(toBoolean(chipProp) ?? false)
|
|
25
44
|
|
|
26
45
|
const {theme} = getThemeStores()
|
|
27
46
|
|
|
28
|
-
|
|
29
|
-
|
|
47
|
+
let numericValue = $derived(value === null || value === undefined ? null : Number(value))
|
|
48
|
+
let status = $derived((() => {
|
|
30
49
|
if (numericValue === null) return 'neutral'
|
|
31
50
|
if (numericValue > neutralMax) return 'positive'
|
|
32
51
|
if (numericValue < neutralMin) return 'negative'
|
|
33
52
|
return 'neutral'
|
|
34
|
-
})()
|
|
53
|
+
})())
|
|
35
54
|
|
|
36
55
|
const pickColor = (positive: string, negative: string, neutral: string) => {
|
|
37
56
|
if (status === 'positive') return positive
|
|
@@ -39,39 +58,39 @@
|
|
|
39
58
|
return neutral
|
|
40
59
|
}
|
|
41
60
|
|
|
42
|
-
|
|
61
|
+
let symbol = $derived((() => {
|
|
43
62
|
if (status === 'positive') return '▲'
|
|
44
63
|
if (status === 'negative') return '▼'
|
|
45
64
|
return '–'
|
|
46
|
-
})()
|
|
47
|
-
|
|
65
|
+
})())
|
|
66
|
+
let symbolColor = $derived(pickColor(
|
|
48
67
|
downIsGood ? $theme.colors.negative : $theme.colors.positive,
|
|
49
68
|
downIsGood ? $theme.colors.positive : $theme.colors.negative,
|
|
50
69
|
$theme.colors['base-content-muted'],
|
|
51
|
-
)
|
|
70
|
+
))
|
|
52
71
|
|
|
53
|
-
|
|
72
|
+
let textColor = $derived(pickColor(
|
|
54
73
|
downIsGood ? $theme.colors.negative : $theme.colors.positive,
|
|
55
74
|
downIsGood ? $theme.colors.positive : $theme.colors.negative,
|
|
56
75
|
$theme.colors['base-content-muted'],
|
|
57
|
-
)
|
|
76
|
+
))
|
|
58
77
|
|
|
59
|
-
|
|
78
|
+
let chipClass = $derived(pickColor('delta-chip--positive', 'delta-chip--negative', 'delta-chip--neutral'))
|
|
60
79
|
|
|
61
|
-
|
|
80
|
+
let resolvedFormat = $derived((() => {
|
|
62
81
|
if (formatObject) return formatObject
|
|
63
82
|
if (fmt) return getFormatObjectFromString(fmt, 'number')
|
|
64
83
|
return undefined
|
|
65
|
-
})()
|
|
84
|
+
})())
|
|
66
85
|
|
|
67
|
-
|
|
86
|
+
let deltaClass = $derived((() => {
|
|
68
87
|
let classes = ['delta']
|
|
69
88
|
if (chip) classes = [...classes, 'delta-chip', chipClass]
|
|
70
89
|
if (className) classes.push(className)
|
|
71
90
|
return classes.join(' ')
|
|
72
|
-
})()
|
|
91
|
+
})())
|
|
73
92
|
|
|
74
|
-
|
|
93
|
+
let resolvedAlign = $derived(align ?? 'right')
|
|
75
94
|
|
|
76
95
|
const renderValue = () => {
|
|
77
96
|
if (numericValue === null) return '–'
|