@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.
- package/LICENSE.md +3 -3
- package/README.md +138 -0
- package/THIRD_PARTY_NOTICES.md +1 -0
- package/bin.js +2 -2
- package/dist/cli/bigQuery-I3F46SC6.js +75 -0
- package/dist/cli/bigQuery-I3F46SC6.js.map +7 -0
- package/dist/cli/chunk-OVWODUTJ.js +12849 -0
- package/dist/cli/chunk-OVWODUTJ.js.map +7 -0
- package/dist/cli/chunk-QAXEOZ43.js +53 -0
- package/dist/cli/chunk-QAXEOZ43.js.map +7 -0
- package/dist/cli/cli.js +245 -10290
- package/dist/cli/clickhouse-ZN5AN2UL.js +64 -0
- package/dist/cli/clickhouse-ZN5AN2UL.js.map +7 -0
- package/dist/cli/duckdb-IYBIO5KJ.js +87 -0
- package/dist/cli/duckdb-IYBIO5KJ.js.map +7 -0
- package/dist/cli/serve2-TNN5EROW.js +447 -0
- package/dist/cli/serve2-TNN5EROW.js.map +7 -0
- package/dist/cli/snowflake-MOQB5GA4.js +128 -0
- package/dist/cli/snowflake-MOQB5GA4.js.map +7 -0
- package/dist/index.d.ts +63 -0
- package/dist/lang/index.d.ts +63 -0
- package/dist/skills/graphene/SKILL.md +235 -0
- package/dist/skills/graphene/references/big-value.md +20 -0
- package/dist/skills/graphene/references/date-range.md +64 -0
- package/dist/skills/graphene/references/dropdown.md +62 -0
- package/dist/skills/graphene/references/echarts.md +162 -0
- package/dist/skills/graphene/references/gsql.md +393 -0
- package/dist/skills/graphene/references/model-gsql.md +72 -0
- package/dist/skills/graphene/references/table.md +143 -0
- package/dist/skills/graphene/references/text-input.md +29 -0
- package/dist/ui/app.css +263 -299
- package/dist/ui/component-utilities/dataShaping.ts +484 -0
- package/dist/ui/component-utilities/dataSummary.ts +57 -0
- package/dist/ui/component-utilities/enrich.ts +763 -0
- package/dist/ui/component-utilities/format.ts +177 -0
- package/dist/ui/component-utilities/inputUtils.ts +48 -9
- package/dist/ui/component-utilities/theme.ts +200 -0
- package/dist/ui/component-utilities/themeStores.ts +26 -21
- package/dist/ui/component-utilities/types.ts +70 -0
- package/dist/ui/components/AreaChart.svelte +57 -105
- package/dist/ui/components/BarChart.svelte +71 -129
- package/dist/ui/components/BigValue.svelte +24 -40
- package/dist/ui/components/Column.svelte +11 -19
- package/dist/ui/components/DateRange.svelte +71 -34
- package/dist/ui/components/Dropdown.svelte +82 -49
- package/dist/ui/components/DropdownOption.svelte +1 -2
- package/dist/ui/components/ECharts.svelte +179 -60
- package/dist/ui/components/InlineDelta.svelte +51 -32
- package/dist/ui/components/LineChart.svelte +54 -125
- package/dist/ui/components/PieChart.svelte +27 -37
- package/dist/ui/components/QueryLoad.svelte +78 -44
- package/dist/ui/components/Row.svelte +2 -1
- package/dist/ui/components/ScatterPlot.svelte +52 -0
- package/dist/ui/components/Skeleton.svelte +32 -0
- package/dist/ui/components/Table.svelte +3 -2
- package/dist/ui/components/TableGroupRow.svelte +28 -36
- package/dist/ui/components/TableHarness.svelte +32 -0
- package/dist/ui/components/TableHeader.svelte +34 -59
- package/dist/ui/components/TableRow.svelte +15 -39
- package/dist/ui/components/TableSubtotalRow.svelte +26 -21
- package/dist/ui/components/TableTotalRow.svelte +27 -37
- package/dist/ui/components/TextInput.svelte +17 -14
- package/dist/ui/components/Value.svelte +25 -0
- package/dist/ui/components/_Table.svelte +80 -76
- package/dist/ui/internal/ChartGallery.svelte +527 -0
- package/dist/ui/internal/ErrorDisplay.svelte +60 -0
- package/dist/ui/internal/LocalApp.svelte +87 -19
- package/dist/ui/internal/PageNavGroup.svelte +269 -0
- package/dist/ui/internal/Sidebar.svelte +178 -0
- package/dist/ui/internal/SidebarToggle.svelte +47 -0
- package/dist/ui/internal/StyleGallery.svelte +244 -0
- package/dist/ui/internal/clientCache.ts +15 -13
- package/dist/ui/internal/pageInputs.svelte.js +292 -0
- package/dist/ui/internal/queryEngine.ts +124 -132
- package/dist/ui/internal/runSocket.ts +59 -0
- package/dist/ui/internal/sidebar.svelte.js +18 -0
- package/dist/ui/internal/telemetry.ts +52 -17
- package/dist/ui/internal/types.d.ts +7 -0
- package/dist/ui/web.js +55 -13
- package/package.json +40 -41
- package/dist/docs/agent-instructions.md +0 -18
- package/dist/docs/base.md +0 -98
- package/dist/docs/cli.md +0 -22
- package/dist/docs/graphene.md +0 -1462
- package/dist/ui/component-utilities/autoFormatting.js +0 -301
- package/dist/ui/component-utilities/builtInFormats.js +0 -482
- package/dist/ui/component-utilities/chartContext.js +0 -12
- package/dist/ui/component-utilities/chartWindowDebug.js +0 -21
- package/dist/ui/component-utilities/checkInputs.js +0 -95
- package/dist/ui/component-utilities/convert.js +0 -15
- package/dist/ui/component-utilities/dateParsing.js +0 -57
- package/dist/ui/component-utilities/dropdownContext.ts +0 -1
- package/dist/ui/component-utilities/echarts.js +0 -272
- package/dist/ui/component-utilities/echartsThemes.js +0 -453
- package/dist/ui/component-utilities/formatTitle.js +0 -24
- package/dist/ui/component-utilities/formatting.js +0 -250
- package/dist/ui/component-utilities/getColumnExtents.js +0 -79
- package/dist/ui/component-utilities/getColumnSummary.js +0 -67
- package/dist/ui/component-utilities/getCompletedData.js +0 -114
- package/dist/ui/component-utilities/getDistinctCount.js +0 -7
- package/dist/ui/component-utilities/getDistinctValues.js +0 -15
- package/dist/ui/component-utilities/getSeriesConfig.js +0 -237
- package/dist/ui/component-utilities/getSortedData.js +0 -7
- package/dist/ui/component-utilities/getStackPercentages.js +0 -43
- package/dist/ui/component-utilities/getStackedData.js +0 -17
- package/dist/ui/component-utilities/getYAxisIndex.js +0 -15
- package/dist/ui/component-utilities/globalContexts.js +0 -1
- package/dist/ui/component-utilities/helpers/getCompletedData.helpers.js +0 -119
- package/dist/ui/component-utilities/replaceNulls.js +0 -14
- package/dist/ui/component-utilities/tableUtils.ts +0 -120
- package/dist/ui/components/Area.svelte +0 -214
- package/dist/ui/components/Bar.svelte +0 -350
- package/dist/ui/components/Chart.svelte +0 -989
- package/dist/ui/components/ErrorChart.svelte +0 -118
- package/dist/ui/components/Line.svelte +0 -227
- package/dist/ui/internal/NavSidebar.svelte +0 -396
- package/dist/ui/internal/PageError.svelte +0 -23
- package/dist/ui/internal/checkSocket.ts +0 -48
- package/dist/ui/internal/theme.ts +0 -88
- package/dist/ui/public/inter-latin-ext.woff2 +0 -0
- 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
|
-
}
|