@quillsql/node 0.4.4 → 0.4.5
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/db/CachedConnection.d.ts +3 -3
- package/dist/db/DatabaseHelper.d.ts +10 -10
- package/dist/db/DatabaseHelper.js +8 -8
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/src/db/CachedConnection.ts +3 -3
- package/src/db/DatabaseHelper.ts +10 -10
- package/src/index.ts +3 -2
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Mapable, CacheCredentials } from "../models/Cache";
|
|
2
|
-
import { DatabaseConnection,
|
|
2
|
+
import { DatabaseConnection, QuillDatabaseType } from "./DatabaseHelper";
|
|
3
3
|
export declare class CachedConnection {
|
|
4
|
-
databaseType:
|
|
4
|
+
databaseType: QuillDatabaseType;
|
|
5
5
|
pool: DatabaseConnection;
|
|
6
6
|
orgId: any;
|
|
7
7
|
ttl: number;
|
|
8
8
|
cache: Mapable | null;
|
|
9
|
-
constructor(databaseType:
|
|
9
|
+
constructor(databaseType: QuillDatabaseType, 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,7 +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
|
|
9
|
+
export declare enum QuillDatabaseType {
|
|
10
10
|
postgresql = "postgresql",
|
|
11
11
|
snowflake = "snowflake",
|
|
12
12
|
bigquery = "bigquery",
|
|
@@ -22,18 +22,18 @@ export interface QuillQueryResults {
|
|
|
22
22
|
[fieldName: string]: any;
|
|
23
23
|
}[];
|
|
24
24
|
}
|
|
25
|
-
export declare function getDatabaseCredentials(databaseType:
|
|
26
|
-
export declare function connectToDatabase(databaseType:
|
|
27
|
-
export declare function runQueryByDatabase(databaseType:
|
|
28
|
-
export declare function disconnectFromDatabase(databaseType:
|
|
29
|
-
export declare function getSchemasByDatabase(databaseType:
|
|
30
|
-
export declare function getTablesBySchemaByDatabase(databaseType:
|
|
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[] | {
|
|
31
31
|
tableName: string;
|
|
32
32
|
schemaName: string;
|
|
33
33
|
}[] | undefined>;
|
|
34
|
-
export declare function getColumnsByTableByDatabase(databaseType:
|
|
35
|
-
export declare function getForiegnKeysByDatabase(databaseType:
|
|
36
|
-
export declare function getColumnInfoBySchemaByDatabase(databaseType:
|
|
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[] | {
|
|
37
37
|
tableName: string;
|
|
38
38
|
schemaName: string;
|
|
39
39
|
}[]): Promise<{
|
|
@@ -9,18 +9,18 @@ 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.
|
|
12
|
+
exports.getColumnInfoBySchemaByDatabase = exports.getForiegnKeysByDatabase = exports.getColumnsByTableByDatabase = exports.getTablesBySchemaByDatabase = exports.getSchemasByDatabase = exports.disconnectFromDatabase = exports.runQueryByDatabase = exports.connectToDatabase = exports.getDatabaseCredentials = exports.QuillDatabaseType = 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
|
|
18
|
-
(function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
})(
|
|
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
24
|
function getDatabaseCredentials(databaseType, connectionString) {
|
|
25
25
|
switch (databaseType.toLowerCase()) {
|
|
26
26
|
case "postgres":
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ 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 {
|
|
5
|
+
import { QuillDatabaseType } from "./db/DatabaseHelper";
|
|
6
6
|
/**
|
|
7
7
|
* Quill - Fullstack API Platform for Dashboards and Reporting.
|
|
8
8
|
*/
|
|
@@ -15,6 +15,7 @@ export interface QuillQueryResult {
|
|
|
15
15
|
fields: any[];
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
|
+
export type DatabaseType = QuillDatabaseType;
|
|
18
19
|
export default class QuillClass {
|
|
19
20
|
targetConnection: CachedConnection;
|
|
20
21
|
private baseUrl;
|
package/dist/index.js
CHANGED
|
@@ -188,4 +188,4 @@ module.exports.getColumnInfoBySchemaByDatabase =
|
|
|
188
188
|
DatabaseHelper_1.getColumnInfoBySchemaByDatabase;
|
|
189
189
|
module.exports.connectToDatabase = DatabaseHelper_1.connectToDatabase;
|
|
190
190
|
module.exports.runQueryByDatabase = DatabaseHelper_1.runQueryByDatabase;
|
|
191
|
-
module.exports.DatabaseType = DatabaseHelper_1.
|
|
191
|
+
module.exports.DatabaseType = DatabaseHelper_1.QuillDatabaseType;
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@ import { createClient } from "redis";
|
|
|
5
5
|
import { isSuperset } from "../utils/Error";
|
|
6
6
|
import {
|
|
7
7
|
DatabaseConnection,
|
|
8
|
-
|
|
8
|
+
QuillDatabaseType,
|
|
9
9
|
connectToDatabase,
|
|
10
10
|
disconnectFromDatabase,
|
|
11
11
|
runQueryByDatabase,
|
|
@@ -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:
|
|
32
|
+
public databaseType: QuillDatabaseType;
|
|
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:
|
|
39
|
+
databaseType: QuillDatabaseType,
|
|
40
40
|
config: any,
|
|
41
41
|
cacheConfig: Partial<CacheCredentials> = {}
|
|
42
42
|
) {
|
package/src/db/DatabaseHelper.ts
CHANGED
|
@@ -51,7 +51,7 @@ import {
|
|
|
51
51
|
getSchemasMysql,
|
|
52
52
|
} from "./Mysql";
|
|
53
53
|
|
|
54
|
-
export enum
|
|
54
|
+
export enum QuillDatabaseType {
|
|
55
55
|
postgresql = "postgresql",
|
|
56
56
|
snowflake = "snowflake",
|
|
57
57
|
bigquery = "bigquery",
|
|
@@ -71,7 +71,7 @@ export interface QuillQueryResults {
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
export function getDatabaseCredentials(
|
|
74
|
-
databaseType:
|
|
74
|
+
databaseType: QuillDatabaseType,
|
|
75
75
|
connectionString: string
|
|
76
76
|
):
|
|
77
77
|
| PostgresConnectionConfig
|
|
@@ -96,7 +96,7 @@ export function getDatabaseCredentials(
|
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
export function connectToDatabase(
|
|
99
|
-
databaseType:
|
|
99
|
+
databaseType: QuillDatabaseType,
|
|
100
100
|
config:
|
|
101
101
|
| PostgresConnectionConfig
|
|
102
102
|
| SnowflakeConnectionConfig
|
|
@@ -120,7 +120,7 @@ export function connectToDatabase(
|
|
|
120
120
|
}
|
|
121
121
|
|
|
122
122
|
export function runQueryByDatabase(
|
|
123
|
-
databaseType:
|
|
123
|
+
databaseType: QuillDatabaseType,
|
|
124
124
|
connection: DatabaseConnection,
|
|
125
125
|
sql: string
|
|
126
126
|
): Promise<QuillQueryResults> | undefined {
|
|
@@ -141,7 +141,7 @@ export function runQueryByDatabase(
|
|
|
141
141
|
}
|
|
142
142
|
|
|
143
143
|
export function disconnectFromDatabase(
|
|
144
|
-
databaseType:
|
|
144
|
+
databaseType: QuillDatabaseType,
|
|
145
145
|
database: DatabaseConnection
|
|
146
146
|
) {
|
|
147
147
|
switch (databaseType.toLowerCase()) {
|
|
@@ -161,7 +161,7 @@ export function disconnectFromDatabase(
|
|
|
161
161
|
}
|
|
162
162
|
|
|
163
163
|
export async function getSchemasByDatabase(
|
|
164
|
-
databaseType:
|
|
164
|
+
databaseType: QuillDatabaseType,
|
|
165
165
|
connection: DatabaseConnection
|
|
166
166
|
): Promise<string[] | undefined> {
|
|
167
167
|
switch (databaseType.toLowerCase()) {
|
|
@@ -182,7 +182,7 @@ export async function getSchemasByDatabase(
|
|
|
182
182
|
|
|
183
183
|
// INFORMATION SCHEMA SELECTS
|
|
184
184
|
export async function getTablesBySchemaByDatabase(
|
|
185
|
-
databaseType:
|
|
185
|
+
databaseType: QuillDatabaseType,
|
|
186
186
|
connection: DatabaseConnection,
|
|
187
187
|
schemaName: string | string[]
|
|
188
188
|
): Promise<string[] | { tableName: string; schemaName: string }[] | undefined> {
|
|
@@ -219,7 +219,7 @@ export async function getTablesBySchemaByDatabase(
|
|
|
219
219
|
|
|
220
220
|
// INFORMATION SCHEMA SELECTS
|
|
221
221
|
export async function getColumnsByTableByDatabase(
|
|
222
|
-
databaseType:
|
|
222
|
+
databaseType: QuillDatabaseType,
|
|
223
223
|
connection: DatabaseConnection,
|
|
224
224
|
schemaName: string,
|
|
225
225
|
tableName: string
|
|
@@ -261,7 +261,7 @@ export async function getColumnsByTableByDatabase(
|
|
|
261
261
|
}
|
|
262
262
|
|
|
263
263
|
export async function getForiegnKeysByDatabase(
|
|
264
|
-
databaseType:
|
|
264
|
+
databaseType: QuillDatabaseType,
|
|
265
265
|
connection: DatabaseConnection,
|
|
266
266
|
schemaName: string,
|
|
267
267
|
tableName: string,
|
|
@@ -309,7 +309,7 @@ export async function getForiegnKeysByDatabase(
|
|
|
309
309
|
}
|
|
310
310
|
|
|
311
311
|
export function getColumnInfoBySchemaByDatabase(
|
|
312
|
-
databaseType:
|
|
312
|
+
databaseType: QuillDatabaseType,
|
|
313
313
|
connection: DatabaseConnection,
|
|
314
314
|
schemaName: string,
|
|
315
315
|
tables: string[] | { tableName: string; schemaName: string }[]
|
package/src/index.ts
CHANGED
|
@@ -10,7 +10,7 @@ import axios from "axios";
|
|
|
10
10
|
import "dotenv/config";
|
|
11
11
|
import { mapQueries, removeFields } from "./utils/RunQueryProcesses";
|
|
12
12
|
import {
|
|
13
|
-
|
|
13
|
+
QuillDatabaseType,
|
|
14
14
|
connectToDatabase,
|
|
15
15
|
getColumnInfoBySchemaByDatabase,
|
|
16
16
|
getColumnsByTableByDatabase,
|
|
@@ -38,6 +38,7 @@ export interface QuillQueryResult {
|
|
|
38
38
|
queries?: { rows: any[]; fields: any[] };
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
export type DatabaseType = QuillDatabaseType;
|
|
41
42
|
export default class QuillClass {
|
|
42
43
|
// Configure cached connection pools with the given config.
|
|
43
44
|
public targetConnection;
|
|
@@ -296,4 +297,4 @@ module.exports.getColumnInfoBySchemaByDatabase =
|
|
|
296
297
|
getColumnInfoBySchemaByDatabase;
|
|
297
298
|
module.exports.connectToDatabase = connectToDatabase;
|
|
298
299
|
module.exports.runQueryByDatabase = runQueryByDatabase;
|
|
299
|
-
module.exports.DatabaseType =
|
|
300
|
+
module.exports.DatabaseType = QuillDatabaseType;
|