@quillsql/node 0.4.5 → 0.4.7

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.
@@ -1,12 +1,12 @@
1
1
  import { Mapable, CacheCredentials } from "../models/Cache";
2
- import { DatabaseConnection, QuillDatabaseType } from "./DatabaseHelper";
2
+ import { DatabaseConnection } from "./DatabaseHelper";
3
3
  export declare class CachedConnection {
4
- databaseType: QuillDatabaseType;
4
+ databaseType: "postgresql" | "snowflake" | "bigquery" | "mysql";
5
5
  pool: DatabaseConnection;
6
6
  orgId: any;
7
7
  ttl: number;
8
8
  cache: Mapable | null;
9
- constructor(databaseType: QuillDatabaseType, config: any, cacheConfig?: Partial<CacheCredentials>);
9
+ constructor(databaseType: "postgresql" | "snowflake" | "bigquery" | "mysql", config: any, cacheConfig?: Partial<CacheCredentials>);
10
10
  query(text: string, values?: any[]): Promise<any>;
11
11
  /**
12
12
  * Configures and returns a cache instance or null if none could be created.
@@ -6,12 +6,6 @@ import { PostgresConnectionConfig } from "./Postgres";
6
6
  import { SnowflakeConnectionConfig } from "./Snowflake";
7
7
  import { BigQueryConfig } from "./BigQuery";
8
8
  import { MysqlConnectionConfig } from "./Mysql";
9
- export declare enum QuillDatabaseType {
10
- postgresql = "postgresql",
11
- snowflake = "snowflake",
12
- bigquery = "bigquery",
13
- mysql = "mysql"
14
- }
15
9
  export type DatabaseConnection = Pool | snowflake.Connection | BigQuery | MysqlPool;
16
10
  export interface QuillQueryResults {
17
11
  fields: {
@@ -22,18 +16,18 @@ export interface QuillQueryResults {
22
16
  [fieldName: string]: any;
23
17
  }[];
24
18
  }
25
- export declare function getDatabaseCredentials(databaseType: QuillDatabaseType, connectionString: string): PostgresConnectionConfig | SnowflakeConnectionConfig | BigQueryConfig | MysqlConnectionConfig | undefined;
26
- export declare function connectToDatabase(databaseType: QuillDatabaseType, config: PostgresConnectionConfig | SnowflakeConnectionConfig | BigQueryConfig | MysqlConnectionConfig): DatabaseConnection;
27
- export declare function runQueryByDatabase(databaseType: QuillDatabaseType, connection: DatabaseConnection, sql: string): Promise<QuillQueryResults> | undefined;
28
- export declare function disconnectFromDatabase(databaseType: QuillDatabaseType, database: DatabaseConnection): void | Promise<void>;
29
- export declare function getSchemasByDatabase(databaseType: QuillDatabaseType, connection: DatabaseConnection): Promise<string[] | undefined>;
30
- export declare function getTablesBySchemaByDatabase(databaseType: QuillDatabaseType, connection: DatabaseConnection, schemaName: string | string[]): Promise<string[] | {
19
+ export declare function getDatabaseCredentials(databaseType: "postgresql" | "snowflake" | "bigquery" | "mysql", connectionString: string): PostgresConnectionConfig | SnowflakeConnectionConfig | BigQueryConfig | MysqlConnectionConfig | undefined;
20
+ export declare function connectToDatabase(databaseType: "postgresql" | "snowflake" | "bigquery" | "mysql", config: PostgresConnectionConfig | SnowflakeConnectionConfig | BigQueryConfig | MysqlConnectionConfig): DatabaseConnection;
21
+ export declare function runQueryByDatabase(databaseType: "postgresql" | "snowflake" | "bigquery" | "mysql", connection: DatabaseConnection, sql: string): Promise<QuillQueryResults> | undefined;
22
+ export declare function disconnectFromDatabase(databaseType: "postgresql" | "snowflake" | "bigquery" | "mysql", database: DatabaseConnection): void | Promise<void>;
23
+ export declare function getSchemasByDatabase(databaseType: "postgresql" | "snowflake" | "bigquery" | "mysql", connection: DatabaseConnection): Promise<string[] | undefined>;
24
+ export declare function getTablesBySchemaByDatabase(databaseType: "postgresql" | "snowflake" | "bigquery" | "mysql", connection: DatabaseConnection, schemaName: string | string[]): Promise<string[] | {
31
25
  tableName: string;
32
26
  schemaName: string;
33
27
  }[] | undefined>;
34
- export declare function getColumnsByTableByDatabase(databaseType: QuillDatabaseType, connection: DatabaseConnection, schemaName: string, tableName: string): Promise<string[] | undefined>;
35
- export declare function getForiegnKeysByDatabase(databaseType: QuillDatabaseType, connection: DatabaseConnection, schemaName: string, tableName: string, primaryKey: string): Promise<string[] | undefined>;
36
- export declare function getColumnInfoBySchemaByDatabase(databaseType: QuillDatabaseType, connection: DatabaseConnection, schemaName: string, tables: string[] | {
28
+ export declare function getColumnsByTableByDatabase(databaseType: "postgresql" | "snowflake" | "bigquery" | "mysql", connection: DatabaseConnection, schemaName: string, tableName: string): Promise<string[] | undefined>;
29
+ export declare function getForiegnKeysByDatabase(databaseType: "postgresql" | "snowflake" | "bigquery" | "mysql", connection: DatabaseConnection, schemaName: string, tableName: string, primaryKey: string): Promise<string[] | undefined>;
30
+ export declare function getColumnInfoBySchemaByDatabase(databaseType: "postgresql" | "snowflake" | "bigquery" | "mysql", connection: DatabaseConnection, schemaName: string, tables: string[] | {
37
31
  tableName: string;
38
32
  schemaName: string;
39
33
  }[]): Promise<{
@@ -9,18 +9,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.getColumnInfoBySchemaByDatabase = exports.getForiegnKeysByDatabase = exports.getColumnsByTableByDatabase = exports.getTablesBySchemaByDatabase = exports.getSchemasByDatabase = exports.disconnectFromDatabase = exports.runQueryByDatabase = exports.connectToDatabase = exports.getDatabaseCredentials = exports.QuillDatabaseType = void 0;
12
+ exports.getColumnInfoBySchemaByDatabase = exports.getForiegnKeysByDatabase = exports.getColumnsByTableByDatabase = exports.getTablesBySchemaByDatabase = exports.getSchemasByDatabase = exports.disconnectFromDatabase = exports.runQueryByDatabase = exports.connectToDatabase = exports.getDatabaseCredentials = void 0;
13
13
  const Postgres_1 = require("./Postgres");
14
14
  const Snowflake_1 = require("./Snowflake");
15
15
  const BigQuery_1 = require("./BigQuery");
16
16
  const Mysql_1 = require("./Mysql");
17
- var QuillDatabaseType;
18
- (function (QuillDatabaseType) {
19
- QuillDatabaseType["postgresql"] = "postgresql";
20
- QuillDatabaseType["snowflake"] = "snowflake";
21
- QuillDatabaseType["bigquery"] = "bigquery";
22
- QuillDatabaseType["mysql"] = "mysql";
23
- })(QuillDatabaseType || (exports.QuillDatabaseType = QuillDatabaseType = {}));
24
17
  function getDatabaseCredentials(databaseType, connectionString) {
25
18
  switch (databaseType.toLowerCase()) {
26
19
  case "postgres":
package/dist/index.d.ts CHANGED
@@ -2,7 +2,6 @@ import { CacheCredentials } from "./models/Cache";
2
2
  import { QuillQueryParams } from "./models/Quill";
3
3
  import { CachedConnection } from "./db/CachedConnection";
4
4
  import "dotenv/config";
5
- import { QuillDatabaseType } from "./db/DatabaseHelper";
6
5
  /**
7
6
  * Quill - Fullstack API Platform for Dashboards and Reporting.
8
7
  */
@@ -15,14 +14,19 @@ export interface QuillQueryResult {
15
14
  fields: any[];
16
15
  };
17
16
  }
18
- export type DatabaseType = QuillDatabaseType;
17
+ export declare enum DatabaseType {
18
+ postgresql = "postgresql",
19
+ snowflake = "snowflake",
20
+ bigquery = "bigquery",
21
+ mysql = "mysql"
22
+ }
19
23
  export default class QuillClass {
20
24
  targetConnection: CachedConnection;
21
25
  private baseUrl;
22
26
  private config;
23
27
  constructor(data: {
24
28
  privateKey: string;
25
- databaseType: DatabaseType;
29
+ databaseType: "postgresql" | "snowflake" | "bigquery" | "mysql";
26
30
  databaseConnectionString?: string;
27
31
  databaseConfig?: any;
28
32
  cache?: Partial<CacheCredentials>;
package/dist/index.js CHANGED
@@ -12,6 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.DatabaseType = void 0;
15
16
  const CachedConnection_1 = require("./db/CachedConnection");
16
17
  const axios_1 = __importDefault(require("axios"));
17
18
  require("dotenv/config");
@@ -21,6 +22,13 @@ const schemaConversion_1 = require("./utils/schemaConversion");
21
22
  const HOST = process.env.ENV === "development"
22
23
  ? "http://localhost:8080"
23
24
  : "https://quill-344421.uc.r.appspot.com";
25
+ var DatabaseType;
26
+ (function (DatabaseType) {
27
+ DatabaseType["postgresql"] = "postgresql";
28
+ DatabaseType["snowflake"] = "snowflake";
29
+ DatabaseType["bigquery"] = "bigquery";
30
+ DatabaseType["mysql"] = "mysql";
31
+ })(DatabaseType || (exports.DatabaseType = DatabaseType = {}));
24
32
  class QuillClass {
25
33
  constructor(data) {
26
34
  const { privateKey, databaseType, databaseConnectionString, databaseConfig, cache, metadataServerURL, } = data;
@@ -188,4 +196,4 @@ module.exports.getColumnInfoBySchemaByDatabase =
188
196
  DatabaseHelper_1.getColumnInfoBySchemaByDatabase;
189
197
  module.exports.connectToDatabase = DatabaseHelper_1.connectToDatabase;
190
198
  module.exports.runQueryByDatabase = DatabaseHelper_1.runQueryByDatabase;
191
- module.exports.DatabaseType = DatabaseHelper_1.QuillDatabaseType;
199
+ module.exports.DatabaseType = DatabaseType;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@quillsql/node",
3
- "version": "0.4.5",
4
- "description": "Quill's client SDK for node backends.",
3
+ "version": "0.4.7",
4
+ "description": "Quill Server SDK for Node.js",
5
5
  "main": "dist/index.js",
6
6
  "module": "./dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -5,7 +5,6 @@ import { createClient } from "redis";
5
5
  import { isSuperset } from "../utils/Error";
6
6
  import {
7
7
  DatabaseConnection,
8
- QuillDatabaseType,
9
8
  connectToDatabase,
10
9
  disconnectFromDatabase,
11
10
  runQueryByDatabase,
@@ -29,14 +28,14 @@ class PgError extends Error {
29
28
  const DEFAULT_CACHE_TTL = 24 * 60 * 60;
30
29
 
31
30
  export class CachedConnection {
32
- public databaseType: QuillDatabaseType;
31
+ public databaseType: "postgresql" | "snowflake" | "bigquery" | "mysql";
33
32
  public pool: DatabaseConnection;
34
33
  public orgId: any;
35
34
  public ttl: number;
36
35
  public cache: Mapable | null;
37
36
 
38
37
  constructor(
39
- databaseType: QuillDatabaseType,
38
+ databaseType: "postgresql" | "snowflake" | "bigquery" | "mysql",
40
39
  config: any,
41
40
  cacheConfig: Partial<CacheCredentials> = {}
42
41
  ) {
@@ -51,13 +51,6 @@ import {
51
51
  getSchemasMysql,
52
52
  } from "./Mysql";
53
53
 
54
- export enum QuillDatabaseType {
55
- postgresql = "postgresql",
56
- snowflake = "snowflake",
57
- bigquery = "bigquery",
58
- mysql = "mysql",
59
- }
60
-
61
54
  // export all database connections types
62
55
  export type DatabaseConnection =
63
56
  | Pool
@@ -71,7 +64,7 @@ export interface QuillQueryResults {
71
64
  }
72
65
 
73
66
  export function getDatabaseCredentials(
74
- databaseType: QuillDatabaseType,
67
+ databaseType: "postgresql" | "snowflake" | "bigquery" | "mysql",
75
68
  connectionString: string
76
69
  ):
77
70
  | PostgresConnectionConfig
@@ -96,7 +89,7 @@ export function getDatabaseCredentials(
96
89
  }
97
90
 
98
91
  export function connectToDatabase(
99
- databaseType: QuillDatabaseType,
92
+ databaseType: "postgresql" | "snowflake" | "bigquery" | "mysql",
100
93
  config:
101
94
  | PostgresConnectionConfig
102
95
  | SnowflakeConnectionConfig
@@ -120,7 +113,7 @@ export function connectToDatabase(
120
113
  }
121
114
 
122
115
  export function runQueryByDatabase(
123
- databaseType: QuillDatabaseType,
116
+ databaseType: "postgresql" | "snowflake" | "bigquery" | "mysql",
124
117
  connection: DatabaseConnection,
125
118
  sql: string
126
119
  ): Promise<QuillQueryResults> | undefined {
@@ -141,7 +134,7 @@ export function runQueryByDatabase(
141
134
  }
142
135
 
143
136
  export function disconnectFromDatabase(
144
- databaseType: QuillDatabaseType,
137
+ databaseType: "postgresql" | "snowflake" | "bigquery" | "mysql",
145
138
  database: DatabaseConnection
146
139
  ) {
147
140
  switch (databaseType.toLowerCase()) {
@@ -161,7 +154,7 @@ export function disconnectFromDatabase(
161
154
  }
162
155
 
163
156
  export async function getSchemasByDatabase(
164
- databaseType: QuillDatabaseType,
157
+ databaseType: "postgresql" | "snowflake" | "bigquery" | "mysql",
165
158
  connection: DatabaseConnection
166
159
  ): Promise<string[] | undefined> {
167
160
  switch (databaseType.toLowerCase()) {
@@ -182,7 +175,7 @@ export async function getSchemasByDatabase(
182
175
 
183
176
  // INFORMATION SCHEMA SELECTS
184
177
  export async function getTablesBySchemaByDatabase(
185
- databaseType: QuillDatabaseType,
178
+ databaseType: "postgresql" | "snowflake" | "bigquery" | "mysql",
186
179
  connection: DatabaseConnection,
187
180
  schemaName: string | string[]
188
181
  ): Promise<string[] | { tableName: string; schemaName: string }[] | undefined> {
@@ -219,7 +212,7 @@ export async function getTablesBySchemaByDatabase(
219
212
 
220
213
  // INFORMATION SCHEMA SELECTS
221
214
  export async function getColumnsByTableByDatabase(
222
- databaseType: QuillDatabaseType,
215
+ databaseType: "postgresql" | "snowflake" | "bigquery" | "mysql",
223
216
  connection: DatabaseConnection,
224
217
  schemaName: string,
225
218
  tableName: string
@@ -261,7 +254,7 @@ export async function getColumnsByTableByDatabase(
261
254
  }
262
255
 
263
256
  export async function getForiegnKeysByDatabase(
264
- databaseType: QuillDatabaseType,
257
+ databaseType: "postgresql" | "snowflake" | "bigquery" | "mysql",
265
258
  connection: DatabaseConnection,
266
259
  schemaName: string,
267
260
  tableName: string,
@@ -309,7 +302,7 @@ export async function getForiegnKeysByDatabase(
309
302
  }
310
303
 
311
304
  export function getColumnInfoBySchemaByDatabase(
312
- databaseType: QuillDatabaseType,
305
+ databaseType: "postgresql" | "snowflake" | "bigquery" | "mysql",
313
306
  connection: DatabaseConnection,
314
307
  schemaName: string,
315
308
  tables: string[] | { tableName: string; schemaName: string }[]
package/src/index.ts CHANGED
@@ -10,7 +10,6 @@ import axios from "axios";
10
10
  import "dotenv/config";
11
11
  import { mapQueries, removeFields } from "./utils/RunQueryProcesses";
12
12
  import {
13
- QuillDatabaseType,
14
13
  connectToDatabase,
15
14
  getColumnInfoBySchemaByDatabase,
16
15
  getColumnsByTableByDatabase,
@@ -38,7 +37,13 @@ export interface QuillQueryResult {
38
37
  queries?: { rows: any[]; fields: any[] };
39
38
  }
40
39
 
41
- export type DatabaseType = QuillDatabaseType;
40
+ export enum DatabaseType {
41
+ postgresql = "postgresql",
42
+ snowflake = "snowflake",
43
+ bigquery = "bigquery",
44
+ mysql = "mysql",
45
+ }
46
+
42
47
  export default class QuillClass {
43
48
  // Configure cached connection pools with the given config.
44
49
  public targetConnection;
@@ -51,7 +56,7 @@ export default class QuillClass {
51
56
 
52
57
  constructor(data: {
53
58
  privateKey: string;
54
- databaseType: DatabaseType;
59
+ databaseType: "postgresql" | "snowflake" | "bigquery" | "mysql";
55
60
  databaseConnectionString?: string;
56
61
  databaseConfig?: any;
57
62
  cache?: Partial<CacheCredentials>;
@@ -154,7 +159,7 @@ export default class QuillClass {
154
159
 
155
160
  private async runQueries(
156
161
  queries: string[] | undefined,
157
- pkDatabaseType: DatabaseType,
162
+ pkDatabaseType: "postgresql" | "snowflake" | "bigquery" | "mysql",
158
163
  databaseType?: string,
159
164
  runQueryConfig?: AdditionalProcessing
160
165
  ) {
@@ -271,7 +276,7 @@ const Quill = ({
271
276
  privateKey: string;
272
277
  databaseConnectionString: string;
273
278
  cache?: Partial<CacheCredentials>;
274
- databaseType: DatabaseType;
279
+ databaseType: "postgresql" | "snowflake" | "bigquery" | "mysql";
275
280
  databaseConfig: any;
276
281
  metadataServerURL?: string;
277
282
  }) => {
@@ -297,4 +302,4 @@ module.exports.getColumnInfoBySchemaByDatabase =
297
302
  getColumnInfoBySchemaByDatabase;
298
303
  module.exports.connectToDatabase = connectToDatabase;
299
304
  module.exports.runQueryByDatabase = runQueryByDatabase;
300
- module.exports.DatabaseType = QuillDatabaseType;
305
+ module.exports.DatabaseType = DatabaseType;