@graphenedata/cli 0.0.3 → 0.0.4
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 +34 -38
- package/package.json +1 -1
package/dist/cli/cli.js
CHANGED
|
@@ -555,9 +555,9 @@ function analyzeQuery(queryNode) {
|
|
|
555
555
|
isAgg ||= !!isSelectDistinct;
|
|
556
556
|
selects.forEach((s) => {
|
|
557
557
|
if (s.getChild("Wildcard")) {
|
|
558
|
-
let
|
|
559
|
-
let pathStrings =
|
|
560
|
-
let target = followJoins(
|
|
558
|
+
let path8 = s.getChild("Wildcard").getChildren("Identifier");
|
|
559
|
+
let pathStrings = path8.map((p) => txt(p));
|
|
560
|
+
let target = followJoins(path8, scope.table);
|
|
561
561
|
if (!target) return;
|
|
562
562
|
target.fields.forEach((f) => {
|
|
563
563
|
if (isJoin(f) || f.isAgg) return;
|
|
@@ -655,8 +655,8 @@ function analyzeExpression(expr, scope) {
|
|
|
655
655
|
if (scope.outputFields.includes(field) && field.isAgg) {
|
|
656
656
|
return { node: "outputField", name: field.name, ...typeInfo, isAgg: field.isAgg };
|
|
657
657
|
}
|
|
658
|
-
let
|
|
659
|
-
return { node: "field", path:
|
|
658
|
+
let path8 = expr.getChildren("Identifier").map((i) => txt(i));
|
|
659
|
+
return { node: "field", path: path8, ...typeInfo, isAgg: field.isAgg };
|
|
660
660
|
}
|
|
661
661
|
case "ExtractExpression": {
|
|
662
662
|
let e = analyzeExpression(expr.getChild("Expression"), scope);
|
|
@@ -1215,11 +1215,11 @@ async function loadWorkspace(dir, includeMd) {
|
|
|
1215
1215
|
updateFile(contents, file);
|
|
1216
1216
|
}
|
|
1217
1217
|
}
|
|
1218
|
-
function updateFile(contents,
|
|
1219
|
-
FILE_MAP[
|
|
1220
|
-
FILE_MAP[
|
|
1221
|
-
FILE_MAP[
|
|
1222
|
-
return FILE_MAP[
|
|
1218
|
+
function updateFile(contents, path8) {
|
|
1219
|
+
FILE_MAP[path8] ||= { path: path8, contents, tree: null, tables: [], queries: [] };
|
|
1220
|
+
FILE_MAP[path8].contents = contents;
|
|
1221
|
+
FILE_MAP[path8].tree = null;
|
|
1222
|
+
return FILE_MAP[path8];
|
|
1223
1223
|
}
|
|
1224
1224
|
function analyze(contents, type) {
|
|
1225
1225
|
clearDiagnostics();
|
|
@@ -1286,8 +1286,6 @@ var bigQuery_exports = {};
|
|
|
1286
1286
|
__export(bigQuery_exports, {
|
|
1287
1287
|
BigQueryConnection: () => BigQueryConnection
|
|
1288
1288
|
});
|
|
1289
|
-
import fs3 from "fs";
|
|
1290
|
-
import path4 from "path";
|
|
1291
1289
|
import { BigQuery, BigQueryDate, BigQueryTimestamp } from "@google-cloud/bigquery";
|
|
1292
1290
|
var BigQueryConnection;
|
|
1293
1291
|
var init_bigQuery = __esm({
|
|
@@ -1298,10 +1296,8 @@ var init_bigQuery = __esm({
|
|
|
1298
1296
|
constructor(options = {}) {
|
|
1299
1297
|
if (process.env.GOOGLE_CREDENTIALS_CONTENT) {
|
|
1300
1298
|
let parsed = JSON.parse(process.env.GOOGLE_CREDENTIALS_CONTENT);
|
|
1301
|
-
let credPath = path4.resolve("./bq.json");
|
|
1302
|
-
fs3.writeFileSync("./bq.json", process.env.GOOGLE_CREDENTIALS_CONTENT.replace(" ", "\n "));
|
|
1303
|
-
process.env.GOOGLE_APPLICATION_CREDENTIALS = credPath;
|
|
1304
1299
|
options.projectId = parsed.project_id;
|
|
1300
|
+
options.credentials = parsed;
|
|
1305
1301
|
}
|
|
1306
1302
|
options.projectId ||= config.googleProjectId;
|
|
1307
1303
|
options.maxRetries ||= 3;
|
|
@@ -1331,8 +1327,8 @@ var duckdb_exports = {};
|
|
|
1331
1327
|
__export(duckdb_exports, {
|
|
1332
1328
|
DuckDBConnection: () => DuckDBConnection
|
|
1333
1329
|
});
|
|
1334
|
-
import { promises as
|
|
1335
|
-
import
|
|
1330
|
+
import { promises as fs3 } from "fs";
|
|
1331
|
+
import path4 from "path";
|
|
1336
1332
|
import { DuckDBTimestampValue, DuckDBInstance, DuckDBDateValue } from "@duckdb/node-api";
|
|
1337
1333
|
var DuckDBConnection;
|
|
1338
1334
|
var init_duckdb = __esm({
|
|
@@ -1345,10 +1341,10 @@ var init_duckdb = __esm({
|
|
|
1345
1341
|
this.ready = this.initialize();
|
|
1346
1342
|
}
|
|
1347
1343
|
async initialize() {
|
|
1348
|
-
let files = await
|
|
1344
|
+
let files = await fs3.readdir(config.root);
|
|
1349
1345
|
let databasePath = files.find((f) => f.endsWith(".duckdb"));
|
|
1350
1346
|
if (!databasePath) throw new Error("No .duckdb file found in current directory");
|
|
1351
|
-
databasePath =
|
|
1347
|
+
databasePath = path4.resolve(config.root, databasePath);
|
|
1352
1348
|
let db = await DuckDBInstance.create(":memory:");
|
|
1353
1349
|
this.connection = await db.connect();
|
|
1354
1350
|
let escapedPath = databasePath.replace(/'/g, "''");
|
|
@@ -1395,8 +1391,8 @@ var init_connections = __esm({
|
|
|
1395
1391
|
});
|
|
1396
1392
|
|
|
1397
1393
|
// mdCompile.ts
|
|
1398
|
-
import
|
|
1399
|
-
import
|
|
1394
|
+
import fs4 from "fs";
|
|
1395
|
+
import path5 from "path";
|
|
1400
1396
|
import { visit } from "unist-util-visit";
|
|
1401
1397
|
import sanitizeHtml from "sanitize-html";
|
|
1402
1398
|
function extractQueries() {
|
|
@@ -1473,8 +1469,8 @@ ${content}`;
|
|
|
1473
1469
|
}
|
|
1474
1470
|
function componentNames() {
|
|
1475
1471
|
if (cachedComponentNames) return cachedComponentNames;
|
|
1476
|
-
let files =
|
|
1477
|
-
cachedComponentNames = files.map((f) =>
|
|
1472
|
+
let files = fs4.readdirSync(path5.join(import.meta.dirname, "../ui/components"));
|
|
1473
|
+
cachedComponentNames = files.map((f) => path5.basename(f, ".svelte")).filter((f) => !f.startsWith("_"));
|
|
1478
1474
|
return cachedComponentNames || [];
|
|
1479
1475
|
}
|
|
1480
1476
|
var cachedComponentNames;
|
|
@@ -1492,18 +1488,18 @@ __export(serve2_exports, {
|
|
|
1492
1488
|
});
|
|
1493
1489
|
import { createServer, optimizeDeps } from "vite";
|
|
1494
1490
|
import { svelte, vitePreprocess } from "@sveltejs/vite-plugin-svelte";
|
|
1495
|
-
import
|
|
1491
|
+
import fs5 from "fs-extra";
|
|
1496
1492
|
import crypto from "crypto";
|
|
1497
1493
|
import { mdsvex } from "mdsvex";
|
|
1498
|
-
import
|
|
1494
|
+
import path6 from "path";
|
|
1499
1495
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
1500
1496
|
import { WebSocketServer } from "ws";
|
|
1501
1497
|
import { spawn as spawn2 } from "child_process";
|
|
1502
1498
|
async function serve2() {
|
|
1503
1499
|
grapheneRoot = config.root;
|
|
1504
|
-
uiRoot =
|
|
1505
|
-
await
|
|
1506
|
-
await
|
|
1500
|
+
uiRoot = path6.join(fileURLToPath2(import.meta.url), "../../ui");
|
|
1501
|
+
await fs5.ensureDir(path6.resolve(grapheneRoot, "node_modules/.graphene"));
|
|
1502
|
+
await fs5.writeFile(path6.resolve(grapheneRoot, `node_modules/.graphene/${process.env.NODE_ENV == "test" ? "test" : "serve"}.pid`), String(process.pid));
|
|
1507
1503
|
let server = await createServer({
|
|
1508
1504
|
root: config.root,
|
|
1509
1505
|
plugins: [
|
|
@@ -1530,7 +1526,7 @@ async function serve2() {
|
|
|
1530
1526
|
},
|
|
1531
1527
|
resolve: {
|
|
1532
1528
|
alias: {
|
|
1533
|
-
graphene:
|
|
1529
|
+
graphene: path6.resolve(uiRoot, "web.js")
|
|
1534
1530
|
}
|
|
1535
1531
|
}
|
|
1536
1532
|
});
|
|
@@ -1684,8 +1680,8 @@ var init_serve2 = __esm({
|
|
|
1684
1680
|
if (pathName == "/graphene/view") return await handleView(req, res);
|
|
1685
1681
|
if (pathName == "/__ct") return await handlePage(s, res, "__ct", false);
|
|
1686
1682
|
if (!pathName || pathName == "/") pathName = "index";
|
|
1687
|
-
let mdPath =
|
|
1688
|
-
if (await
|
|
1683
|
+
let mdPath = path6.join(grapheneRoot, pathName + ".md");
|
|
1684
|
+
if (await fs5.exists(mdPath)) {
|
|
1689
1685
|
await handlePage(s, res, mdPath, true);
|
|
1690
1686
|
} else {
|
|
1691
1687
|
next();
|
|
@@ -1767,8 +1763,8 @@ function printTable(rows) {
|
|
|
1767
1763
|
// cli.ts
|
|
1768
1764
|
init_core();
|
|
1769
1765
|
init_config();
|
|
1770
|
-
import
|
|
1771
|
-
import
|
|
1766
|
+
import fs6 from "fs-extra";
|
|
1767
|
+
import path7 from "path";
|
|
1772
1768
|
import os from "os";
|
|
1773
1769
|
|
|
1774
1770
|
// background.ts
|
|
@@ -1921,9 +1917,9 @@ program.command("view").description("Capture a screenshot of a rendered markdown
|
|
|
1921
1917
|
}
|
|
1922
1918
|
if (result.screenshot) {
|
|
1923
1919
|
let filename = `graphene-screenshot-${(/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-")}.png`;
|
|
1924
|
-
let screenshotPath =
|
|
1920
|
+
let screenshotPath = path7.join(os.tmpdir(), filename);
|
|
1925
1921
|
let base64Data = result.screenshot.replace(/^data:image\/png;base64,/, "");
|
|
1926
|
-
await
|
|
1922
|
+
await fs6.writeFile(screenshotPath, base64Data, "base64");
|
|
1927
1923
|
console.log("Screenshot saved to", screenshotPath);
|
|
1928
1924
|
}
|
|
1929
1925
|
});
|
|
@@ -1938,9 +1934,9 @@ async function readInput(arg) {
|
|
|
1938
1934
|
process.stdin.resume();
|
|
1939
1935
|
});
|
|
1940
1936
|
}
|
|
1941
|
-
let absolutePath =
|
|
1942
|
-
if (
|
|
1943
|
-
return await
|
|
1937
|
+
let absolutePath = path7.resolve(arg);
|
|
1938
|
+
if (fs6.existsSync(absolutePath)) {
|
|
1939
|
+
return await fs6.promises.readFile(absolutePath, "utf-8");
|
|
1944
1940
|
}
|
|
1945
1941
|
return arg;
|
|
1946
1942
|
}
|