@quillsql/node 0.4.5 → 0.4.6

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,13 @@
1
1
  import { Mapable, CacheCredentials } from "../models/Cache";
2
- import { DatabaseConnection, QuillDatabaseType } from "./DatabaseHelper";
2
+ import { DatabaseConnection } from "./DatabaseHelper";
3
+ import { DatabaseType } from "..";
3
4
  export declare class CachedConnection {
4
- databaseType: QuillDatabaseType;
5
+ databaseType: DatabaseType;
5
6
  pool: DatabaseConnection;
6
7
  orgId: any;
7
8
  ttl: number;
8
9
  cache: Mapable | null;
9
- constructor(databaseType: QuillDatabaseType, config: any, cacheConfig?: Partial<CacheCredentials>);
10
+ constructor(databaseType: DatabaseType, config: any, cacheConfig?: Partial<CacheCredentials>);
10
11
  query(text: string, values?: any[]): Promise<any>;
11
12
  /**
12
13
  * Configures and returns a cache instance or null if none could be created.
@@ -6,12 +6,7 @@ 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
- }
9
+ import { DatabaseType } from "..";
15
10
  export type DatabaseConnection = Pool | snowflake.Connection | BigQuery | MysqlPool;
16
11
  export interface QuillQueryResults {
17
12
  fields: {
@@ -22,18 +17,18 @@ export interface QuillQueryResults {
22
17
  [fieldName: string]: any;
23
18
  }[];
24
19
  }
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[] | {
20
+ export declare function getDatabaseCredentials(databaseType: DatabaseType, connectionString: string): PostgresConnectionConfig | SnowflakeConnectionConfig | BigQueryConfig | MysqlConnectionConfig | undefined;
21
+ export declare function connectToDatabase(databaseType: DatabaseType, config: PostgresConnectionConfig | SnowflakeConnectionConfig | BigQueryConfig | MysqlConnectionConfig): DatabaseConnection;
22
+ export declare function runQueryByDatabase(databaseType: DatabaseType, connection: DatabaseConnection, sql: string): Promise<QuillQueryResults> | undefined;
23
+ export declare function disconnectFromDatabase(databaseType: DatabaseType, database: DatabaseConnection): void | Promise<void>;
24
+ export declare function getSchemasByDatabase(databaseType: DatabaseType, connection: DatabaseConnection): Promise<string[] | undefined>;
25
+ export declare function getTablesBySchemaByDatabase(databaseType: DatabaseType, connection: DatabaseConnection, schemaName: string | string[]): Promise<string[] | {
31
26
  tableName: string;
32
27
  schemaName: string;
33
28
  }[] | 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[] | {
29
+ export declare function getColumnsByTableByDatabase(databaseType: DatabaseType, connection: DatabaseConnection, schemaName: string, tableName: string): Promise<string[] | undefined>;
30
+ export declare function getForiegnKeysByDatabase(databaseType: DatabaseType, connection: DatabaseConnection, schemaName: string, tableName: string, primaryKey: string): Promise<string[] | undefined>;
31
+ export declare function getColumnInfoBySchemaByDatabase(databaseType: DatabaseType, connection: DatabaseConnection, schemaName: string, tables: string[] | {
37
32
  tableName: string;
38
33
  schemaName: string;
39
34
  }[]): 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,7 +14,12 @@ 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;
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,6 +1,6 @@
1
1
  {
2
2
  "name": "@quillsql/node",
3
- "version": "0.4.5",
3
+ "version": "0.4.6",
4
4
  "description": "Quill's client SDK for node backends.",
5
5
  "main": "dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -5,11 +5,11 @@ 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,
12
11
  } from "./DatabaseHelper";
12
+ import { DatabaseType } from "..";
13
13
 
14
14
  class PgError extends Error {
15
15
  code?: string;
@@ -29,14 +29,14 @@ class PgError extends Error {
29
29
  const DEFAULT_CACHE_TTL = 24 * 60 * 60;
30
30
 
31
31
  export class CachedConnection {
32
- public databaseType: QuillDatabaseType;
32
+ public databaseType: DatabaseType;
33
33
  public pool: DatabaseConnection;
34
34
  public orgId: any;
35
35
  public ttl: number;
36
36
  public cache: Mapable | null;
37
37
 
38
38
  constructor(
39
- databaseType: QuillDatabaseType,
39
+ databaseType: DatabaseType,
40
40
  config: any,
41
41
  cacheConfig: Partial<CacheCredentials> = {}
42
42
  ) {
@@ -50,13 +50,7 @@ import {
50
50
  getSchemaColumnInfoMysql,
51
51
  getSchemasMysql,
52
52
  } from "./Mysql";
53
-
54
- export enum QuillDatabaseType {
55
- postgresql = "postgresql",
56
- snowflake = "snowflake",
57
- bigquery = "bigquery",
58
- mysql = "mysql",
59
- }
53
+ import { DatabaseType } from "..";
60
54
 
61
55
  // export all database connections types
62
56
  export type DatabaseConnection =
@@ -71,7 +65,7 @@ export interface QuillQueryResults {
71
65
  }
72
66
 
73
67
  export function getDatabaseCredentials(
74
- databaseType: QuillDatabaseType,
68
+ databaseType: DatabaseType,
75
69
  connectionString: string
76
70
  ):
77
71
  | PostgresConnectionConfig
@@ -96,7 +90,7 @@ export function getDatabaseCredentials(
96
90
  }
97
91
 
98
92
  export function connectToDatabase(
99
- databaseType: QuillDatabaseType,
93
+ databaseType: DatabaseType,
100
94
  config:
101
95
  | PostgresConnectionConfig
102
96
  | SnowflakeConnectionConfig
@@ -120,7 +114,7 @@ export function connectToDatabase(
120
114
  }
121
115
 
122
116
  export function runQueryByDatabase(
123
- databaseType: QuillDatabaseType,
117
+ databaseType: DatabaseType,
124
118
  connection: DatabaseConnection,
125
119
  sql: string
126
120
  ): Promise<QuillQueryResults> | undefined {
@@ -141,7 +135,7 @@ export function runQueryByDatabase(
141
135
  }
142
136
 
143
137
  export function disconnectFromDatabase(
144
- databaseType: QuillDatabaseType,
138
+ databaseType: DatabaseType,
145
139
  database: DatabaseConnection
146
140
  ) {
147
141
  switch (databaseType.toLowerCase()) {
@@ -161,7 +155,7 @@ export function disconnectFromDatabase(
161
155
  }
162
156
 
163
157
  export async function getSchemasByDatabase(
164
- databaseType: QuillDatabaseType,
158
+ databaseType: DatabaseType,
165
159
  connection: DatabaseConnection
166
160
  ): Promise<string[] | undefined> {
167
161
  switch (databaseType.toLowerCase()) {
@@ -182,7 +176,7 @@ export async function getSchemasByDatabase(
182
176
 
183
177
  // INFORMATION SCHEMA SELECTS
184
178
  export async function getTablesBySchemaByDatabase(
185
- databaseType: QuillDatabaseType,
179
+ databaseType: DatabaseType,
186
180
  connection: DatabaseConnection,
187
181
  schemaName: string | string[]
188
182
  ): Promise<string[] | { tableName: string; schemaName: string }[] | undefined> {
@@ -219,7 +213,7 @@ export async function getTablesBySchemaByDatabase(
219
213
 
220
214
  // INFORMATION SCHEMA SELECTS
221
215
  export async function getColumnsByTableByDatabase(
222
- databaseType: QuillDatabaseType,
216
+ databaseType: DatabaseType,
223
217
  connection: DatabaseConnection,
224
218
  schemaName: string,
225
219
  tableName: string
@@ -261,7 +255,7 @@ export async function getColumnsByTableByDatabase(
261
255
  }
262
256
 
263
257
  export async function getForiegnKeysByDatabase(
264
- databaseType: QuillDatabaseType,
258
+ databaseType: DatabaseType,
265
259
  connection: DatabaseConnection,
266
260
  schemaName: string,
267
261
  tableName: string,
@@ -309,7 +303,7 @@ export async function getForiegnKeysByDatabase(
309
303
  }
310
304
 
311
305
  export function getColumnInfoBySchemaByDatabase(
312
- databaseType: QuillDatabaseType,
306
+ databaseType: DatabaseType,
313
307
  connection: DatabaseConnection,
314
308
  schemaName: string,
315
309
  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;
@@ -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;