@graphenedata/cli 0.0.8 → 0.0.9
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/cli.ts +4 -8
- package/dist/cli/cli.js +13 -43
- package/dist/docs/graphene.md +8 -8
- package/package.json +1 -1
package/cli.ts
CHANGED
|
@@ -24,8 +24,7 @@ program.hook('preAction', async () => {
|
|
|
24
24
|
loadConfig(process.cwd())
|
|
25
25
|
})
|
|
26
26
|
|
|
27
|
-
program
|
|
28
|
-
.command('compile')
|
|
27
|
+
program.command('compile')
|
|
29
28
|
.description('Translate a query to SQL and print it')
|
|
30
29
|
.argument('[input]', 'Path to file, a raw string, or "-" for stdin')
|
|
31
30
|
.action(async (input: string | undefined) => {
|
|
@@ -36,8 +35,7 @@ program
|
|
|
36
35
|
console.log(toSql(queries[0]))
|
|
37
36
|
})
|
|
38
37
|
|
|
39
|
-
program
|
|
40
|
-
.command('run')
|
|
38
|
+
program.command('run')
|
|
41
39
|
.description('Run a query against your database')
|
|
42
40
|
.argument('[input]', 'Path to file, a raw string, or "-" for stdin')
|
|
43
41
|
.action(async (input: string | undefined) => {
|
|
@@ -84,8 +82,7 @@ program.command('schema')
|
|
|
84
82
|
console.log(')')
|
|
85
83
|
})
|
|
86
84
|
|
|
87
|
-
program
|
|
88
|
-
.command('serve')
|
|
85
|
+
program.command('serve')
|
|
89
86
|
.description('Run the local server')
|
|
90
87
|
.option('--bg', 'Run the server in the background')
|
|
91
88
|
.action(async (options: {bg?: boolean}) => {
|
|
@@ -103,8 +100,7 @@ program.command('stop')
|
|
|
103
100
|
.description('Stop the local server')
|
|
104
101
|
.action(async () => { await stopGrapheneIfRunning() })
|
|
105
102
|
|
|
106
|
-
program
|
|
107
|
-
.command('check')
|
|
103
|
+
program.command('check')
|
|
108
104
|
.description('Check the project for errors, optionally capturing a page screenshot')
|
|
109
105
|
.argument('[mdFile]', 'Markdown file to check (e.g., index.md)')
|
|
110
106
|
.option('-c, --chart <chartTitle>', 'Title of a specific chart to capture')
|
package/dist/cli/cli.js
CHANGED
|
@@ -1506,63 +1506,33 @@ var init_markdown = __esm({
|
|
|
1506
1506
|
});
|
|
1507
1507
|
|
|
1508
1508
|
// ../lang/snowflake.ts
|
|
1509
|
-
function uppercaseMalloyQuery(query) {
|
|
1510
|
-
query.baseTableName = uppercaseIdentifier(query.baseTableName);
|
|
1511
|
-
for (let stage of query.pipeline || []) {
|
|
1512
|
-
let fields = stage.queryFields || [];
|
|
1513
|
-
fields.forEach((field) => uppercaseColumnField(field));
|
|
1514
|
-
let filters = stage.filterList || [];
|
|
1515
|
-
filters.forEach((filter) => uppercaseExpression(filter?.e));
|
|
1516
|
-
}
|
|
1517
|
-
}
|
|
1518
1509
|
function uppercaseTable(table2) {
|
|
1519
1510
|
if (table2.upperCased) return;
|
|
1520
1511
|
table2.upperCased = true;
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
if (table2.tablePath) table2.tablePath = uppercaseQualified(table2.tablePath);
|
|
1525
|
-
table2.fields?.forEach((field) => uppercaseField(field));
|
|
1526
|
-
if (table2.query) uppercaseMalloyQuery(table2.query);
|
|
1512
|
+
if (table2.query) return;
|
|
1513
|
+
table2.tablePath = uppercaseIdentifier(table2.tablePath);
|
|
1514
|
+
table2.fields.forEach(uppercaseField);
|
|
1527
1515
|
}
|
|
1528
1516
|
function uppercaseField(field) {
|
|
1529
|
-
if (
|
|
1530
|
-
if (
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
if (field.structPath) field.structPath = field.structPath.map(uppercaseIdentifier);
|
|
1535
|
-
if (field.path) field.path = field.path.map(uppercaseIdentifier);
|
|
1536
|
-
if (field.onExpression) uppercaseExpression(field.onExpression);
|
|
1537
|
-
uppercaseTable(field);
|
|
1538
|
-
} else {
|
|
1539
|
-
uppercaseColumnField(field);
|
|
1540
|
-
}
|
|
1541
|
-
}
|
|
1542
|
-
function uppercaseColumnField(field) {
|
|
1543
|
-
if (!field) return;
|
|
1517
|
+
if (isJoinField(field)) return uppercaseTable(field);
|
|
1518
|
+
if (field.upperCased) return;
|
|
1519
|
+
field.upperCased = true;
|
|
1520
|
+
if (field.e) return uppercaseExpression(field.e);
|
|
1521
|
+
field.as = field.name;
|
|
1544
1522
|
field.name = uppercaseIdentifier(field.name);
|
|
1545
|
-
if (field.path) field.path = field.path.map(uppercaseIdentifier);
|
|
1546
|
-
if (field.structPath) field.structPath = field.structPath.map(uppercaseIdentifier);
|
|
1547
|
-
if (field.tableName) field.tableName = uppercaseQualified(field.tableName);
|
|
1548
|
-
if (field.tablePath) field.tablePath = uppercaseQualified(field.tablePath);
|
|
1549
|
-
if (field.e) uppercaseExpression(field.e);
|
|
1550
1523
|
}
|
|
1551
1524
|
function uppercaseExpression(expr) {
|
|
1552
1525
|
if (!expr) return;
|
|
1553
1526
|
walkExpression(expr, (node) => {
|
|
1554
|
-
if (
|
|
1555
|
-
|
|
1527
|
+
if (node.type == "field") {
|
|
1528
|
+
node.path = node.path.map(uppercaseIdentifier);
|
|
1529
|
+
}
|
|
1556
1530
|
});
|
|
1557
1531
|
}
|
|
1558
1532
|
function uppercaseIdentifier(value) {
|
|
1559
1533
|
if (!value) return value || "";
|
|
1560
1534
|
return value.toString().toUpperCase();
|
|
1561
1535
|
}
|
|
1562
|
-
function uppercaseQualified(value) {
|
|
1563
|
-
if (!value) return value;
|
|
1564
|
-
return value.split(".").map((part) => part.startsWith('"') && part.endsWith('"') ? part : uppercaseIdentifier(part)).join(".");
|
|
1565
|
-
}
|
|
1566
1536
|
function isJoinField(field) {
|
|
1567
1537
|
return !!field?.join;
|
|
1568
1538
|
}
|
|
@@ -1635,7 +1605,6 @@ function toSql(query, params = {}) {
|
|
|
1635
1605
|
}));
|
|
1636
1606
|
query = structuredClone(query);
|
|
1637
1607
|
fillInParams(query, params);
|
|
1638
|
-
if (config.dialect == "snowflake") uppercaseMalloyQuery(query);
|
|
1639
1608
|
let visited = /* @__PURE__ */ new Set();
|
|
1640
1609
|
function setStructRefs(obj) {
|
|
1641
1610
|
if (!obj || typeof obj !== "object" || visited.has(obj)) return;
|
|
@@ -2489,7 +2458,7 @@ var init_snowflake2 = __esm({
|
|
|
2489
2458
|
order by ordinal_position
|
|
2490
2459
|
`);
|
|
2491
2460
|
return res.rows.map((row) => {
|
|
2492
|
-
return { name: String(row["column_name"]), dataType: String(row["data_type"]) };
|
|
2461
|
+
return { name: String(row["column_name"]).toLowerCase(), dataType: String(row["data_type"]) };
|
|
2493
2462
|
});
|
|
2494
2463
|
}
|
|
2495
2464
|
};
|
|
@@ -2685,6 +2654,7 @@ async function createConfig() {
|
|
|
2685
2654
|
optimizeDeps: {
|
|
2686
2655
|
noDiscovery: process.env.NODE_ENV == "test",
|
|
2687
2656
|
// tests manually optimize before starting test workers
|
|
2657
|
+
exclude: ["virtual:nav"],
|
|
2688
2658
|
include: [
|
|
2689
2659
|
"@graphenedata/cli > svelte",
|
|
2690
2660
|
"@graphenedata/cli > ssf",
|
package/dist/docs/graphene.md
CHANGED
|
@@ -575,8 +575,8 @@ Here's an example:
|
|
|
575
575
|
|----------|-------------|----------|---------|---------|
|
|
576
576
|
| data | Query name, wrapped in curly braces | true | query name | - |
|
|
577
577
|
| x | Column or expression to use for the x-axis of the chart | false | column name, stored expression name, GSQL expression | First column |
|
|
578
|
-
| y | Column(s) or expression(s) to use for the y-axis of the chart. Each will create its own series. Consider a split axis with `y2` if there is a difference of scale or unit of measure between the series. | false | column name, stored expression name, GSQL expression, list of any combination of these | Any non-assigned numeric columns |
|
|
579
|
-
| y2 | Column(s) or expression(s) to include on a secondary y-axis. | false | column name, stored expression name, GSQL expression, list of any combination of these | - |
|
|
578
|
+
| y | Column(s) or expression(s) to use for the y-axis of the chart. Each will create its own series. Consider a split axis with `y2` if there is a difference of scale or unit of measure between the series. | false | column name, stored expression name, GSQL expression, list of any combination of these e.g. `"col1, my_expr"` | Any non-assigned numeric columns |
|
|
579
|
+
| y2 | Column(s) or expression(s) to include on a secondary y-axis. | false | column name, stored expression name, GSQL expression, list of any combination of these e.g. `"col1, my_expr"` | - |
|
|
580
580
|
| y2SeriesType | Chart type to apply to the series on the y2 axis | false | `bar`, `line`, `scatter` | `bar` |
|
|
581
581
|
| series | Column or expression to use to define the series (groups) in a multi-series chart. Use when values of a particular column dictate the multiple series to plot, eg. `country` would create a series for every distinct country in the column. | false | column name, stored expression name, GSQL expression | - |
|
|
582
582
|
| sort | Whether to apply default sort to your data. Default sort is x ascending for number and date x-axes, and y descending for category x-axes | false | `true`, `false` | `true` |
|
|
@@ -598,7 +598,7 @@ Here's an example:
|
|
|
598
598
|
| outlineWidth | Width of line surrounding each bar | number | `0` |
|
|
599
599
|
| outlineColor | Color to use for outline if outlineWidth > 0 | CSS name, hexademical, RGB, HSL | - |
|
|
600
600
|
| colorPalette | List of custom colors to use for the chart | list of color strings (CSS name, hexademical, RGB, HSL) e.g. `"#cf0d06, #eb5752, #e88a87"` | built-in color palette |
|
|
601
|
-
| seriesOrder | Apply a specific order to the series in a multi-series chart. | list of series names in the order they should be used in the chart `"Canada, US"` | default order implied by the data |
|
|
601
|
+
| seriesOrder | Apply a specific order to the series in a multi-series chart. | list of series names in the order they should be used in the chart e.g. `"Canada, US"` | default order implied by the data |
|
|
602
602
|
| leftPadding | Number representing the padding (whitespace) on the left side of the chart. Useful to avoid labels getting cut off | number | - |
|
|
603
603
|
| rightPadding | Number representing the padding (whitespace) on the left side of the chart. Useful to avoid labels getting cut off | number | - |
|
|
604
604
|
| xLabelWrap | Whether to wrap x-axis labels when there is not enough space. Default behaviour is to truncate the labels. | `true`, `false` | `false` |
|
|
@@ -723,8 +723,8 @@ Here's an example:
|
|
|
723
723
|
|------|-------------|----------|---------|---------|
|
|
724
724
|
| data | Query name, wrapped in curly braces | true | query name | - |
|
|
725
725
|
| x | Column or expression to use for the x-axis of the chart | true | column name, stored expression name, GSQL expression | - |
|
|
726
|
-
| y | Column(s) or expression(s) to use for the y-axis of the chart. Each will create its own series. Consider a split axis with `y2` if there is a difference of scale or unit of measure between the series. | true | column name, stored expression name, GSQL expression, list of any combination of these | - |
|
|
727
|
-
| y2 | Column(s) or expression(s) to include on a secondary y-axis. | false | column name, stored expression name, GSQL expression, list of any combination of these | - |
|
|
726
|
+
| y | Column(s) or expression(s) to use for the y-axis of the chart. Each will create its own series. Consider a split axis with `y2` if there is a difference of scale or unit of measure between the series. | true | column name, stored expression name, GSQL expression, list of any combination of these e.g. `"col1, my_expr"` | - |
|
|
727
|
+
| y2 | Column(s) or expression(s) to include on a secondary y-axis. | false | column name, stored expression name, GSQL expression, list of any combination of these e.g. `"col1, my_expr"` | - |
|
|
728
728
|
| y2SeriesType | Chart type to apply to the series on the y2 axis | false | `line`, `bar`, `scatter` | `line` |
|
|
729
729
|
| series | Column or expression to use to define the series (groups) in a multi-series chart. Use when values of a particular column dictate the multiple series to plot, eg. `country` would create a series for every distinct country in the column. | false | column name, stored expression name, GSQL expression | - |
|
|
730
730
|
| sort | Whether to apply default sort to your data. Default is x ascending for number and date x-axes, and y descending for category x-axes | false | `true`, `false` | `true` |
|
|
@@ -750,7 +750,7 @@ Here's an example:
|
|
|
750
750
|
| markerShape | Shape to use if markers=true | false | `circle`, `emptyCircle`, `rect`, `triangle`, `diamond` | `circle` |
|
|
751
751
|
| markerSize | Size of each shape (in pixels) | false | number | `8` |
|
|
752
752
|
| colorPalette | List of custom colors to use for the chart | false | list of color strings (CSS name, hexademical, RGB, HSL) e.g. `"#cf0d06, #eb5752, #e88a87"` | - |
|
|
753
|
-
| seriesOrder | Apply a specific order to the series in a multi-series chart. | false | list of series names in the order they should be used in the chart `"Canada, US"` | default order implied by the data |
|
|
753
|
+
| seriesOrder | Apply a specific order to the series in a multi-series chart. | false | list of series names in the order they should be used in the chart e.g. `"Canada, US"` | default order implied by the data |
|
|
754
754
|
| labels | Show value labels | false | `true`, `false` | `false` |
|
|
755
755
|
| labelSize | Font size of value labels | false | number | `11` |
|
|
756
756
|
| labelPosition | Where label will appear on your series | false | `above`, `middle`, `below` | `above` |
|
|
@@ -832,7 +832,7 @@ Here's an example:
|
|
|
832
832
|
|------|-------------|----------|---------|---------|
|
|
833
833
|
| data | Query name, wrapped in curly braces | true | query name | - |
|
|
834
834
|
| x | Column or expression to use for the x-axis of the chart | true | column name, stored expression name, GSQL expression | First column |
|
|
835
|
-
| y | Column(s) or expression(s) to use for the y-axis of the chart. Each will create its own series. Consider a split axis with `y2` if there is a difference of scale or unit of measure between the series. | true | column name, stored expression name, GSQL expression, list of any combination of these | Any non-assigned numeric columns |
|
|
835
|
+
| y | Column(s) or expression(s) to use for the y-axis of the chart. Each will create its own series. Consider a split axis with `y2` if there is a difference of scale or unit of measure between the series. | true | column name, stored expression name, GSQL expression, list of any combination of these e.g. `"col1, my_expr"` | Any non-assigned numeric columns |
|
|
836
836
|
| series | Column or expression to use to define the series (groups) in a multi-series chart. Use when values of a particular column dictate the multiple series to plot, eg. `country` would create a series for every distinct country in the column. | false | column name, stored expression name, GSQL expression | - |
|
|
837
837
|
| sort | Whether to apply default sort to your data. Default sort is x ascending for number and date x-axes, and y descending for category x-axes | false | `true`, `false` | `true` |
|
|
838
838
|
| type | Grouping method to use for multi-series charts | false | `stacked`, `stacked100` | `stacked` |
|
|
@@ -854,7 +854,7 @@ Here's an example:
|
|
|
854
854
|
| fillOpacity | % of the full color that should be rendered, with remainder being transparent | false | number (0 to 1) | `0.7` |
|
|
855
855
|
| line | Show line on top of the area | false | `true`, `false` | `true` |
|
|
856
856
|
| colorPalette | List of custom colors to use for the chart | false | list of color strings (CSS name, hexademical, RGB, HSL) e.g. `"#cf0d06, #eb5752, #e88a87"` | built-in color palette |
|
|
857
|
-
| seriesOrder | Apply a specific order to the series in a multi-series chart. | false | list of series names in the order they should be used in the chart `"Canada, US"` | default order implied by the data |
|
|
857
|
+
| seriesOrder | Apply a specific order to the series in a multi-series chart. | false | list of series names in the order they should be used in the chart e.g. `"Canada, US"` | default order implied by the data |
|
|
858
858
|
| leftPadding | Number representing the padding (whitespace) on the left side of the chart. Useful to avoid labels getting cut off | false | number | - |
|
|
859
859
|
| rightPadding | Number representing the padding (whitespace) on the left side of the chart. Useful to avoid labels getting cut off | false | number | - |
|
|
860
860
|
| xLabelWrap | Whether to wrap x-axis labels when there is not enough space. Default behaviour is to truncate the labels. | false | `true`, `false` | `false` |
|