@squadbase/vite-server 0.0.1-build-12 → 0.0.1-build-13

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 CHANGED
@@ -333,6 +333,47 @@ function createSnowflakeClient(entry, connectionId) {
333
333
  };
334
334
  }
335
335
 
336
+ // src/connector-client/snowflake-pat.ts
337
+ function createSnowflakePatClient(entry, connectionId) {
338
+ const accountIdentifier = resolveEnvVar(entry, "account", connectionId);
339
+ const user = resolveEnvVar(entry, "user", connectionId);
340
+ const role = resolveEnvVar(entry, "role", connectionId);
341
+ const warehouse = resolveEnvVar(entry, "warehouse", connectionId);
342
+ const password = resolveEnvVar(entry, "pat", connectionId);
343
+ return {
344
+ async query(sql) {
345
+ const snowflake = (await import("snowflake-sdk")).default;
346
+ snowflake.configure({ logLevel: "ERROR" });
347
+ const connection2 = snowflake.createConnection({
348
+ account: accountIdentifier,
349
+ username: user,
350
+ role,
351
+ warehouse,
352
+ password
353
+ });
354
+ await new Promise((resolve, reject) => {
355
+ connection2.connect((err) => {
356
+ if (err) reject(new Error(`Snowflake connect failed: ${err.message}`));
357
+ else resolve();
358
+ });
359
+ });
360
+ const rows = await new Promise((resolve, reject) => {
361
+ connection2.execute({
362
+ sqlText: sql,
363
+ complete: (err, _stmt, rows2) => {
364
+ if (err) reject(new Error(`Snowflake query failed: ${err.message}`));
365
+ else resolve(rows2 ?? []);
366
+ }
367
+ });
368
+ });
369
+ connection2.destroy((err) => {
370
+ if (err) console.warn(`[connector-client] Snowflake destroy error: ${err.message}`);
371
+ });
372
+ return { rows };
373
+ }
374
+ };
375
+ }
376
+
336
377
  // src/connector-client/mysql.ts
337
378
  function createMySQLClient(entry, connectionId) {
338
379
  const connectionUrl = resolveEnvVar(entry, "connection-url", connectionId);
@@ -528,6 +569,9 @@ function createConnectorRegistry() {
528
569
  const cached = clientCache.get(connectionId);
529
570
  if (cached) return { client: cached, connectorSlug };
530
571
  if (connectorSlug === "snowflake") {
572
+ if (entry.connector.authType === "pat") {
573
+ return { client: createSnowflakePatClient(entry, connectionId), connectorSlug };
574
+ }
531
575
  return { client: createSnowflakeClient(entry, connectionId), connectorSlug };
532
576
  }
533
577
  if (connectorSlug === "bigquery") {
package/dist/index.js CHANGED
@@ -258,6 +258,47 @@ function createSnowflakeClient(entry, connectionId) {
258
258
  };
259
259
  }
260
260
 
261
+ // src/connector-client/snowflake-pat.ts
262
+ function createSnowflakePatClient(entry, connectionId) {
263
+ const accountIdentifier = resolveEnvVar(entry, "account", connectionId);
264
+ const user = resolveEnvVar(entry, "user", connectionId);
265
+ const role = resolveEnvVar(entry, "role", connectionId);
266
+ const warehouse = resolveEnvVar(entry, "warehouse", connectionId);
267
+ const password = resolveEnvVar(entry, "pat", connectionId);
268
+ return {
269
+ async query(sql) {
270
+ const snowflake = (await import("snowflake-sdk")).default;
271
+ snowflake.configure({ logLevel: "ERROR" });
272
+ const connection2 = snowflake.createConnection({
273
+ account: accountIdentifier,
274
+ username: user,
275
+ role,
276
+ warehouse,
277
+ password
278
+ });
279
+ await new Promise((resolve, reject) => {
280
+ connection2.connect((err) => {
281
+ if (err) reject(new Error(`Snowflake connect failed: ${err.message}`));
282
+ else resolve();
283
+ });
284
+ });
285
+ const rows = await new Promise((resolve, reject) => {
286
+ connection2.execute({
287
+ sqlText: sql,
288
+ complete: (err, _stmt, rows2) => {
289
+ if (err) reject(new Error(`Snowflake query failed: ${err.message}`));
290
+ else resolve(rows2 ?? []);
291
+ }
292
+ });
293
+ });
294
+ connection2.destroy((err) => {
295
+ if (err) console.warn(`[connector-client] Snowflake destroy error: ${err.message}`);
296
+ });
297
+ return { rows };
298
+ }
299
+ };
300
+ }
301
+
261
302
  // src/connector-client/mysql.ts
262
303
  function createMySQLClient(entry, connectionId) {
263
304
  const connectionUrl = resolveEnvVar(entry, "connection-url", connectionId);
@@ -453,6 +494,9 @@ function createConnectorRegistry() {
453
494
  const cached = clientCache.get(connectionId);
454
495
  if (cached) return { client: cached, connectorSlug };
455
496
  if (connectorSlug === "snowflake") {
497
+ if (entry.connector.authType === "pat") {
498
+ return { client: createSnowflakePatClient(entry, connectionId), connectorSlug };
499
+ }
456
500
  return { client: createSnowflakeClient(entry, connectionId), connectorSlug };
457
501
  }
458
502
  if (connectorSlug === "bigquery") {
package/dist/main.js CHANGED
@@ -258,6 +258,47 @@ function createSnowflakeClient(entry, connectionId) {
258
258
  };
259
259
  }
260
260
 
261
+ // src/connector-client/snowflake-pat.ts
262
+ function createSnowflakePatClient(entry, connectionId) {
263
+ const accountIdentifier = resolveEnvVar(entry, "account", connectionId);
264
+ const user = resolveEnvVar(entry, "user", connectionId);
265
+ const role = resolveEnvVar(entry, "role", connectionId);
266
+ const warehouse = resolveEnvVar(entry, "warehouse", connectionId);
267
+ const password = resolveEnvVar(entry, "pat", connectionId);
268
+ return {
269
+ async query(sql) {
270
+ const snowflake = (await import("snowflake-sdk")).default;
271
+ snowflake.configure({ logLevel: "ERROR" });
272
+ const connection2 = snowflake.createConnection({
273
+ account: accountIdentifier,
274
+ username: user,
275
+ role,
276
+ warehouse,
277
+ password
278
+ });
279
+ await new Promise((resolve, reject) => {
280
+ connection2.connect((err) => {
281
+ if (err) reject(new Error(`Snowflake connect failed: ${err.message}`));
282
+ else resolve();
283
+ });
284
+ });
285
+ const rows = await new Promise((resolve, reject) => {
286
+ connection2.execute({
287
+ sqlText: sql,
288
+ complete: (err, _stmt, rows2) => {
289
+ if (err) reject(new Error(`Snowflake query failed: ${err.message}`));
290
+ else resolve(rows2 ?? []);
291
+ }
292
+ });
293
+ });
294
+ connection2.destroy((err) => {
295
+ if (err) console.warn(`[connector-client] Snowflake destroy error: ${err.message}`);
296
+ });
297
+ return { rows };
298
+ }
299
+ };
300
+ }
301
+
261
302
  // src/connector-client/mysql.ts
262
303
  function createMySQLClient(entry, connectionId) {
263
304
  const connectionUrl = resolveEnvVar(entry, "connection-url", connectionId);
@@ -453,6 +494,9 @@ function createConnectorRegistry() {
453
494
  const cached = clientCache.get(connectionId);
454
495
  if (cached) return { client: cached, connectorSlug };
455
496
  if (connectorSlug === "snowflake") {
497
+ if (entry.connector.authType === "pat") {
498
+ return { client: createSnowflakePatClient(entry, connectionId), connectorSlug };
499
+ }
456
500
  return { client: createSnowflakeClient(entry, connectionId), connectorSlug };
457
501
  }
458
502
  if (connectorSlug === "bigquery") {
@@ -259,6 +259,47 @@ function createSnowflakeClient(entry, connectionId) {
259
259
  };
260
260
  }
261
261
 
262
+ // src/connector-client/snowflake-pat.ts
263
+ function createSnowflakePatClient(entry, connectionId) {
264
+ const accountIdentifier = resolveEnvVar(entry, "account", connectionId);
265
+ const user = resolveEnvVar(entry, "user", connectionId);
266
+ const role = resolveEnvVar(entry, "role", connectionId);
267
+ const warehouse = resolveEnvVar(entry, "warehouse", connectionId);
268
+ const password = resolveEnvVar(entry, "pat", connectionId);
269
+ return {
270
+ async query(sql) {
271
+ const snowflake = (await import("snowflake-sdk")).default;
272
+ snowflake.configure({ logLevel: "ERROR" });
273
+ const connection2 = snowflake.createConnection({
274
+ account: accountIdentifier,
275
+ username: user,
276
+ role,
277
+ warehouse,
278
+ password
279
+ });
280
+ await new Promise((resolve, reject) => {
281
+ connection2.connect((err) => {
282
+ if (err) reject(new Error(`Snowflake connect failed: ${err.message}`));
283
+ else resolve();
284
+ });
285
+ });
286
+ const rows = await new Promise((resolve, reject) => {
287
+ connection2.execute({
288
+ sqlText: sql,
289
+ complete: (err, _stmt, rows2) => {
290
+ if (err) reject(new Error(`Snowflake query failed: ${err.message}`));
291
+ else resolve(rows2 ?? []);
292
+ }
293
+ });
294
+ });
295
+ connection2.destroy((err) => {
296
+ if (err) console.warn(`[connector-client] Snowflake destroy error: ${err.message}`);
297
+ });
298
+ return { rows };
299
+ }
300
+ };
301
+ }
302
+
262
303
  // src/connector-client/mysql.ts
263
304
  function createMySQLClient(entry, connectionId) {
264
305
  const connectionUrl = resolveEnvVar(entry, "connection-url", connectionId);
@@ -454,6 +495,9 @@ function createConnectorRegistry() {
454
495
  const cached = clientCache.get(connectionId);
455
496
  if (cached) return { client: cached, connectorSlug };
456
497
  if (connectorSlug === "snowflake") {
498
+ if (entry.connector.authType === "pat") {
499
+ return { client: createSnowflakePatClient(entry, connectionId), connectorSlug };
500
+ }
457
501
  return { client: createSnowflakeClient(entry, connectionId), connectorSlug };
458
502
  }
459
503
  if (connectorSlug === "bigquery") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@squadbase/vite-server",
3
- "version": "0.0.1-build-12",
3
+ "version": "0.0.1-build-13",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {