@squadbase/vite-server 0.0.1-build-8 → 0.0.1-build-10
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/index.js +12 -15
- package/dist/index.d.ts +1 -1
- package/dist/index.js +9 -12
- package/dist/main.js +9 -12
- package/dist/vite-plugin.d.ts +0 -1
- package/dist/vite-plugin.js +19 -14
- package/package.json +3 -3
package/dist/cli/index.js
CHANGED
|
@@ -82,10 +82,11 @@ var init_interactive = __esm({
|
|
|
82
82
|
// src/cli/index.ts
|
|
83
83
|
import { parseArgs } from "util";
|
|
84
84
|
import path4 from "path";
|
|
85
|
-
import { readFile as
|
|
85
|
+
import { readFile as readFile4 } from "fs/promises";
|
|
86
86
|
|
|
87
87
|
// src/connector-client/registry.ts
|
|
88
88
|
import { readFileSync, watch as fsWatch } from "fs";
|
|
89
|
+
import { readFile } from "fs/promises";
|
|
89
90
|
import path from "path";
|
|
90
91
|
|
|
91
92
|
// src/connector-client/postgresql.ts
|
|
@@ -358,24 +359,21 @@ function createDatabricksClient(entry, connectionId) {
|
|
|
358
359
|
|
|
359
360
|
// src/connector-client/registry.ts
|
|
360
361
|
function createConnectorRegistry() {
|
|
361
|
-
let connectionsCache = null;
|
|
362
362
|
const clientCache = /* @__PURE__ */ new Map();
|
|
363
363
|
function getConnectionsFilePath() {
|
|
364
364
|
return process.env.CONNECTIONS_PATH ?? path.join(process.cwd(), ".squadbase/connections.json");
|
|
365
365
|
}
|
|
366
|
-
function loadConnections2() {
|
|
367
|
-
if (connectionsCache !== null) return connectionsCache;
|
|
366
|
+
async function loadConnections2() {
|
|
368
367
|
const filePath = getConnectionsFilePath();
|
|
369
368
|
try {
|
|
370
|
-
const raw =
|
|
371
|
-
|
|
369
|
+
const raw = await readFile(filePath, "utf-8");
|
|
370
|
+
return JSON.parse(raw);
|
|
372
371
|
} catch {
|
|
373
|
-
|
|
372
|
+
return {};
|
|
374
373
|
}
|
|
375
|
-
return connectionsCache;
|
|
376
374
|
}
|
|
377
375
|
async function getClient2(connectionId) {
|
|
378
|
-
const connections = loadConnections2();
|
|
376
|
+
const connections = await loadConnections2();
|
|
379
377
|
const entry = connections[connectionId];
|
|
380
378
|
if (!entry) {
|
|
381
379
|
throw new Error(`connection '${connectionId}' not found in .squadbase/connections.json`);
|
|
@@ -443,8 +441,7 @@ function createConnectorRegistry() {
|
|
|
443
441
|
const envPath = path.join(process.cwd(), ".env");
|
|
444
442
|
try {
|
|
445
443
|
fsWatch(filePath, { persistent: false }, () => {
|
|
446
|
-
console.log("[connector-client] connections.json changed, clearing cache");
|
|
447
|
-
connectionsCache = null;
|
|
444
|
+
console.log("[connector-client] connections.json changed, clearing client cache");
|
|
448
445
|
clientCache.clear();
|
|
449
446
|
setImmediate(() => reloadEnvFile2(envPath));
|
|
450
447
|
});
|
|
@@ -465,11 +462,11 @@ function loadEnvFile(envPath) {
|
|
|
465
462
|
|
|
466
463
|
// src/cli/runner.ts
|
|
467
464
|
import { pathToFileURL } from "url";
|
|
468
|
-
import { readFile as
|
|
465
|
+
import { readFile as readFile3, readdir as readdir2 } from "fs/promises";
|
|
469
466
|
import path3 from "path";
|
|
470
467
|
|
|
471
468
|
// src/registry.ts
|
|
472
|
-
import { readdir, readFile, mkdir } from "fs/promises";
|
|
469
|
+
import { readdir, readFile as readFile2, mkdir } from "fs/promises";
|
|
473
470
|
import { watch as fsWatch2 } from "fs";
|
|
474
471
|
import path2 from "path";
|
|
475
472
|
function buildQuery(queryTemplate, parameterMeta, runtimeParams) {
|
|
@@ -607,7 +604,7 @@ async function runDataSource(slug, dirPath, params, limit) {
|
|
|
607
604
|
const jsonPath = path3.join(dirPath, `${slug}.json`);
|
|
608
605
|
let def;
|
|
609
606
|
try {
|
|
610
|
-
const raw = await
|
|
607
|
+
const raw = await readFile3(jsonPath, "utf-8");
|
|
611
608
|
def = JSON.parse(raw);
|
|
612
609
|
} catch {
|
|
613
610
|
return {
|
|
@@ -813,7 +810,7 @@ Total: ${results.length}, Failed: ${failed}`);
|
|
|
813
810
|
const jsonPath = path4.join(dirPath, `${slug}.json`);
|
|
814
811
|
let paramMeta = [];
|
|
815
812
|
try {
|
|
816
|
-
const raw = await
|
|
813
|
+
const raw = await readFile4(jsonPath, "utf-8");
|
|
817
814
|
const def = JSON.parse(raw);
|
|
818
815
|
paramMeta = def.parameters ?? [];
|
|
819
816
|
} catch {
|
package/dist/index.d.ts
CHANGED
|
@@ -124,7 +124,7 @@ declare const getClient: (connectionId: string) => Promise<{
|
|
|
124
124
|
client: DatabaseClient;
|
|
125
125
|
connectorSlug: string;
|
|
126
126
|
}>;
|
|
127
|
-
declare const loadConnections: () => ConnectionsMap
|
|
127
|
+
declare const loadConnections: () => Promise<ConnectionsMap>;
|
|
128
128
|
|
|
129
129
|
declare const app: Hono<hono_types.BlankEnv, hono_types.BlankSchema, "/">;
|
|
130
130
|
|
package/dist/index.js
CHANGED
|
@@ -4,12 +4,13 @@ import { cors } from "hono/cors";
|
|
|
4
4
|
import path4 from "path";
|
|
5
5
|
|
|
6
6
|
// src/registry.ts
|
|
7
|
-
import { readdir, readFile, mkdir } from "fs/promises";
|
|
7
|
+
import { readdir, readFile as readFile2, mkdir } from "fs/promises";
|
|
8
8
|
import { watch as fsWatch2 } from "fs";
|
|
9
9
|
import path2 from "path";
|
|
10
10
|
|
|
11
11
|
// src/connector-client/registry.ts
|
|
12
12
|
import { readFileSync, watch as fsWatch } from "fs";
|
|
13
|
+
import { readFile } from "fs/promises";
|
|
13
14
|
import path from "path";
|
|
14
15
|
|
|
15
16
|
// src/connector-client/postgresql.ts
|
|
@@ -282,24 +283,21 @@ function createDatabricksClient(entry, connectionId) {
|
|
|
282
283
|
|
|
283
284
|
// src/connector-client/registry.ts
|
|
284
285
|
function createConnectorRegistry() {
|
|
285
|
-
let connectionsCache = null;
|
|
286
286
|
const clientCache = /* @__PURE__ */ new Map();
|
|
287
287
|
function getConnectionsFilePath() {
|
|
288
288
|
return process.env.CONNECTIONS_PATH ?? path.join(process.cwd(), ".squadbase/connections.json");
|
|
289
289
|
}
|
|
290
|
-
function loadConnections2() {
|
|
291
|
-
if (connectionsCache !== null) return connectionsCache;
|
|
290
|
+
async function loadConnections2() {
|
|
292
291
|
const filePath = getConnectionsFilePath();
|
|
293
292
|
try {
|
|
294
|
-
const raw =
|
|
295
|
-
|
|
293
|
+
const raw = await readFile(filePath, "utf-8");
|
|
294
|
+
return JSON.parse(raw);
|
|
296
295
|
} catch {
|
|
297
|
-
|
|
296
|
+
return {};
|
|
298
297
|
}
|
|
299
|
-
return connectionsCache;
|
|
300
298
|
}
|
|
301
299
|
async function getClient2(connectionId) {
|
|
302
|
-
const connections = loadConnections2();
|
|
300
|
+
const connections = await loadConnections2();
|
|
303
301
|
const entry = connections[connectionId];
|
|
304
302
|
if (!entry) {
|
|
305
303
|
throw new Error(`connection '${connectionId}' not found in .squadbase/connections.json`);
|
|
@@ -367,8 +365,7 @@ function createConnectorRegistry() {
|
|
|
367
365
|
const envPath = path.join(process.cwd(), ".env");
|
|
368
366
|
try {
|
|
369
367
|
fsWatch(filePath, { persistent: false }, () => {
|
|
370
|
-
console.log("[connector-client] connections.json changed, clearing cache");
|
|
371
|
-
connectionsCache = null;
|
|
368
|
+
console.log("[connector-client] connections.json changed, clearing client cache");
|
|
372
369
|
clientCache.clear();
|
|
373
370
|
setImmediate(() => reloadEnvFile2(envPath));
|
|
374
371
|
});
|
|
@@ -707,7 +704,7 @@ async function initialize() {
|
|
|
707
704
|
const results = await Promise.allSettled(
|
|
708
705
|
jsonFiles.map(async (file) => {
|
|
709
706
|
const slug = file.replace(/\.json$/, "");
|
|
710
|
-
const raw = await
|
|
707
|
+
const raw = await readFile2(`${dirPath}/${file}`, "utf-8");
|
|
711
708
|
const def = JSON.parse(raw);
|
|
712
709
|
if (!def.description) {
|
|
713
710
|
console.warn(`[registry] Skipping ${file}: missing description`);
|
package/dist/main.js
CHANGED
|
@@ -4,12 +4,13 @@ import { cors } from "hono/cors";
|
|
|
4
4
|
import path4 from "path";
|
|
5
5
|
|
|
6
6
|
// src/registry.ts
|
|
7
|
-
import { readdir, readFile, mkdir } from "fs/promises";
|
|
7
|
+
import { readdir, readFile as readFile2, mkdir } from "fs/promises";
|
|
8
8
|
import { watch as fsWatch2 } from "fs";
|
|
9
9
|
import path2 from "path";
|
|
10
10
|
|
|
11
11
|
// src/connector-client/registry.ts
|
|
12
12
|
import { readFileSync, watch as fsWatch } from "fs";
|
|
13
|
+
import { readFile } from "fs/promises";
|
|
13
14
|
import path from "path";
|
|
14
15
|
|
|
15
16
|
// src/connector-client/postgresql.ts
|
|
@@ -282,24 +283,21 @@ function createDatabricksClient(entry, connectionId) {
|
|
|
282
283
|
|
|
283
284
|
// src/connector-client/registry.ts
|
|
284
285
|
function createConnectorRegistry() {
|
|
285
|
-
let connectionsCache = null;
|
|
286
286
|
const clientCache = /* @__PURE__ */ new Map();
|
|
287
287
|
function getConnectionsFilePath() {
|
|
288
288
|
return process.env.CONNECTIONS_PATH ?? path.join(process.cwd(), ".squadbase/connections.json");
|
|
289
289
|
}
|
|
290
|
-
function loadConnections2() {
|
|
291
|
-
if (connectionsCache !== null) return connectionsCache;
|
|
290
|
+
async function loadConnections2() {
|
|
292
291
|
const filePath = getConnectionsFilePath();
|
|
293
292
|
try {
|
|
294
|
-
const raw =
|
|
295
|
-
|
|
293
|
+
const raw = await readFile(filePath, "utf-8");
|
|
294
|
+
return JSON.parse(raw);
|
|
296
295
|
} catch {
|
|
297
|
-
|
|
296
|
+
return {};
|
|
298
297
|
}
|
|
299
|
-
return connectionsCache;
|
|
300
298
|
}
|
|
301
299
|
async function getClient2(connectionId) {
|
|
302
|
-
const connections = loadConnections2();
|
|
300
|
+
const connections = await loadConnections2();
|
|
303
301
|
const entry = connections[connectionId];
|
|
304
302
|
if (!entry) {
|
|
305
303
|
throw new Error(`connection '${connectionId}' not found in .squadbase/connections.json`);
|
|
@@ -367,8 +365,7 @@ function createConnectorRegistry() {
|
|
|
367
365
|
const envPath = path.join(process.cwd(), ".env");
|
|
368
366
|
try {
|
|
369
367
|
fsWatch(filePath, { persistent: false }, () => {
|
|
370
|
-
console.log("[connector-client] connections.json changed, clearing cache");
|
|
371
|
-
connectionsCache = null;
|
|
368
|
+
console.log("[connector-client] connections.json changed, clearing client cache");
|
|
372
369
|
clientCache.clear();
|
|
373
370
|
setImmediate(() => reloadEnvFile2(envPath));
|
|
374
371
|
});
|
|
@@ -445,7 +442,7 @@ async function initialize() {
|
|
|
445
442
|
const results = await Promise.allSettled(
|
|
446
443
|
jsonFiles.map(async (file) => {
|
|
447
444
|
const slug = file.replace(/\.json$/, "");
|
|
448
|
-
const raw = await
|
|
445
|
+
const raw = await readFile2(`${dirPath}/${file}`, "utf-8");
|
|
449
446
|
const def = JSON.parse(raw);
|
|
450
447
|
if (!def.description) {
|
|
451
448
|
console.warn(`[registry] Skipping ${file}: missing description`);
|
package/dist/vite-plugin.d.ts
CHANGED
package/dist/vite-plugin.js
CHANGED
|
@@ -6,12 +6,13 @@ import { fileURLToPath } from "url";
|
|
|
6
6
|
import path3 from "path";
|
|
7
7
|
|
|
8
8
|
// src/registry.ts
|
|
9
|
-
import { readdir, readFile, mkdir } from "fs/promises";
|
|
9
|
+
import { readdir, readFile as readFile2, mkdir } from "fs/promises";
|
|
10
10
|
import { watch as fsWatch2 } from "fs";
|
|
11
11
|
import path2 from "path";
|
|
12
12
|
|
|
13
13
|
// src/connector-client/registry.ts
|
|
14
14
|
import { readFileSync, watch as fsWatch } from "fs";
|
|
15
|
+
import { readFile } from "fs/promises";
|
|
15
16
|
import path from "path";
|
|
16
17
|
|
|
17
18
|
// src/connector-client/postgresql.ts
|
|
@@ -284,24 +285,21 @@ function createDatabricksClient(entry, connectionId) {
|
|
|
284
285
|
|
|
285
286
|
// src/connector-client/registry.ts
|
|
286
287
|
function createConnectorRegistry() {
|
|
287
|
-
let connectionsCache = null;
|
|
288
288
|
const clientCache = /* @__PURE__ */ new Map();
|
|
289
289
|
function getConnectionsFilePath() {
|
|
290
290
|
return process.env.CONNECTIONS_PATH ?? path.join(process.cwd(), ".squadbase/connections.json");
|
|
291
291
|
}
|
|
292
|
-
function loadConnections2() {
|
|
293
|
-
if (connectionsCache !== null) return connectionsCache;
|
|
292
|
+
async function loadConnections2() {
|
|
294
293
|
const filePath = getConnectionsFilePath();
|
|
295
294
|
try {
|
|
296
|
-
const raw =
|
|
297
|
-
|
|
295
|
+
const raw = await readFile(filePath, "utf-8");
|
|
296
|
+
return JSON.parse(raw);
|
|
298
297
|
} catch {
|
|
299
|
-
|
|
298
|
+
return {};
|
|
300
299
|
}
|
|
301
|
-
return connectionsCache;
|
|
302
300
|
}
|
|
303
301
|
async function getClient2(connectionId) {
|
|
304
|
-
const connections = loadConnections2();
|
|
302
|
+
const connections = await loadConnections2();
|
|
305
303
|
const entry = connections[connectionId];
|
|
306
304
|
if (!entry) {
|
|
307
305
|
throw new Error(`connection '${connectionId}' not found in .squadbase/connections.json`);
|
|
@@ -369,8 +367,7 @@ function createConnectorRegistry() {
|
|
|
369
367
|
const envPath = path.join(process.cwd(), ".env");
|
|
370
368
|
try {
|
|
371
369
|
fsWatch(filePath, { persistent: false }, () => {
|
|
372
|
-
console.log("[connector-client] connections.json changed, clearing cache");
|
|
373
|
-
connectionsCache = null;
|
|
370
|
+
console.log("[connector-client] connections.json changed, clearing client cache");
|
|
374
371
|
clientCache.clear();
|
|
375
372
|
setImmediate(() => reloadEnvFile2(envPath));
|
|
376
373
|
});
|
|
@@ -417,8 +414,17 @@ function squadbasePlugin(options = {}) {
|
|
|
417
414
|
const {
|
|
418
415
|
buildEntry = "@squadbase/vite-server/main",
|
|
419
416
|
devEntry = "@squadbase/vite-server",
|
|
420
|
-
|
|
421
|
-
|
|
417
|
+
external = [
|
|
418
|
+
"pg",
|
|
419
|
+
"@google-cloud/bigquery",
|
|
420
|
+
"snowflake-sdk",
|
|
421
|
+
"mysql2",
|
|
422
|
+
"@databricks/sql",
|
|
423
|
+
"@aws-sdk/client-athena",
|
|
424
|
+
"@aws-sdk/client-redshift-data",
|
|
425
|
+
"@google-analytics/data",
|
|
426
|
+
"@kintone/rest-api-client"
|
|
427
|
+
],
|
|
422
428
|
exclude = DEFAULT_EXCLUDE
|
|
423
429
|
} = options;
|
|
424
430
|
const isServerBuild = (_, { command, mode }) => command === "build" && mode !== "client";
|
|
@@ -426,7 +432,6 @@ function squadbasePlugin(options = {}) {
|
|
|
426
432
|
entry: resolveEntry(buildEntry),
|
|
427
433
|
outputDir: "./dist/server",
|
|
428
434
|
output: "index.js",
|
|
429
|
-
port,
|
|
430
435
|
external
|
|
431
436
|
});
|
|
432
437
|
const rawDevServerPlugin = devServer({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@squadbase/vite-server",
|
|
3
|
-
"version": "0.0.1-build-
|
|
3
|
+
"version": "0.0.1-build-10",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"@google-cloud/bigquery": "^7.9.4",
|
|
43
43
|
"@hono/node-server": "^1.19.9",
|
|
44
44
|
"@hono/vite-build": "^1.10.0",
|
|
45
|
-
"@hono/vite-dev-server": "^0.
|
|
45
|
+
"@hono/vite-dev-server": "^0.25.0",
|
|
46
46
|
"@kintone/rest-api-client": "^5.5.0",
|
|
47
47
|
"hono": "^4.11.9",
|
|
48
48
|
"mysql2": "^3.11.0",
|
|
@@ -57,6 +57,6 @@
|
|
|
57
57
|
"tsup": "^8.4.0",
|
|
58
58
|
"tsx": "^4.19.3",
|
|
59
59
|
"typescript": "~5.7.0",
|
|
60
|
-
"vite": "^
|
|
60
|
+
"vite": "^7.0.0"
|
|
61
61
|
}
|
|
62
62
|
}
|