@quillsql/node 0.4.6 → 0.4.8
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 +2 -3
- package/dist/db/DatabaseHelper.d.ts +9 -10
- package/dist/index.d.ts +2 -2
- package/dist/index.js +7 -7
- package/package.json +2 -2
- package/src/db/CachedConnection.ts +2 -3
- package/src/db/DatabaseHelper.ts +9 -10
- package/src/index.ts +8 -8
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { Mapable, CacheCredentials } from "../models/Cache";
|
|
2
2
|
import { DatabaseConnection } from "./DatabaseHelper";
|
|
3
|
-
import { DatabaseType } from "..";
|
|
4
3
|
export declare class CachedConnection {
|
|
5
|
-
databaseType:
|
|
4
|
+
databaseType: "postgresql" | "snowflake" | "bigquery" | "mysql";
|
|
6
5
|
pool: DatabaseConnection;
|
|
7
6
|
orgId: any;
|
|
8
7
|
ttl: number;
|
|
9
8
|
cache: Mapable | null;
|
|
10
|
-
constructor(databaseType:
|
|
9
|
+
constructor(databaseType: "postgresql" | "snowflake" | "bigquery" | "mysql", config: any, cacheConfig?: Partial<CacheCredentials>);
|
|
11
10
|
query(text: string, values?: any[]): Promise<any>;
|
|
12
11
|
/**
|
|
13
12
|
* Configures and returns a cache instance or null if none could be created.
|
|
@@ -6,7 +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
|
-
import { DatabaseType } from "..";
|
|
10
9
|
export type DatabaseConnection = Pool | snowflake.Connection | BigQuery | MysqlPool;
|
|
11
10
|
export interface QuillQueryResults {
|
|
12
11
|
fields: {
|
|
@@ -17,18 +16,18 @@ export interface QuillQueryResults {
|
|
|
17
16
|
[fieldName: string]: any;
|
|
18
17
|
}[];
|
|
19
18
|
}
|
|
20
|
-
export declare function getDatabaseCredentials(databaseType:
|
|
21
|
-
export declare function connectToDatabase(databaseType:
|
|
22
|
-
export declare function runQueryByDatabase(databaseType:
|
|
23
|
-
export declare function disconnectFromDatabase(databaseType:
|
|
24
|
-
export declare function getSchemasByDatabase(databaseType:
|
|
25
|
-
export declare function getTablesBySchemaByDatabase(databaseType:
|
|
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[] | {
|
|
26
25
|
tableName: string;
|
|
27
26
|
schemaName: string;
|
|
28
27
|
}[] | undefined>;
|
|
29
|
-
export declare function getColumnsByTableByDatabase(databaseType:
|
|
30
|
-
export declare function getForiegnKeysByDatabase(databaseType:
|
|
31
|
-
export declare function getColumnInfoBySchemaByDatabase(databaseType:
|
|
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[] | {
|
|
32
31
|
tableName: string;
|
|
33
32
|
schemaName: string;
|
|
34
33
|
}[]): Promise<{
|
package/dist/index.d.ts
CHANGED
|
@@ -20,13 +20,13 @@ export declare enum DatabaseType {
|
|
|
20
20
|
bigquery = "bigquery",
|
|
21
21
|
mysql = "mysql"
|
|
22
22
|
}
|
|
23
|
-
export
|
|
23
|
+
export declare class Quill {
|
|
24
24
|
targetConnection: CachedConnection;
|
|
25
25
|
private baseUrl;
|
|
26
26
|
private config;
|
|
27
27
|
constructor(data: {
|
|
28
28
|
privateKey: string;
|
|
29
|
-
databaseType:
|
|
29
|
+
databaseType: "postgresql" | "snowflake" | "bigquery" | "mysql";
|
|
30
30
|
databaseConnectionString?: string;
|
|
31
31
|
databaseConfig?: any;
|
|
32
32
|
cache?: Partial<CacheCredentials>;
|
package/dist/index.js
CHANGED
|
@@ -12,7 +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
|
+
exports.Quill = exports.DatabaseType = void 0;
|
|
16
16
|
const CachedConnection_1 = require("./db/CachedConnection");
|
|
17
17
|
const axios_1 = __importDefault(require("axios"));
|
|
18
18
|
require("dotenv/config");
|
|
@@ -29,7 +29,7 @@ var DatabaseType;
|
|
|
29
29
|
DatabaseType["bigquery"] = "bigquery";
|
|
30
30
|
DatabaseType["mysql"] = "mysql";
|
|
31
31
|
})(DatabaseType || (exports.DatabaseType = DatabaseType = {}));
|
|
32
|
-
class
|
|
32
|
+
class Quill {
|
|
33
33
|
constructor(data) {
|
|
34
34
|
const { privateKey, databaseType, databaseConnectionString, databaseConfig, cache, metadataServerURL, } = data;
|
|
35
35
|
this.baseUrl = metadataServerURL ? metadataServerURL : HOST;
|
|
@@ -173,9 +173,9 @@ class QuillClass {
|
|
|
173
173
|
});
|
|
174
174
|
}
|
|
175
175
|
}
|
|
176
|
-
exports.
|
|
177
|
-
const
|
|
178
|
-
return new
|
|
176
|
+
exports.Quill = Quill;
|
|
177
|
+
const requireQuill = ({ privateKey, databaseConnectionString, databaseConfig, cache, databaseType, metadataServerURL, }) => {
|
|
178
|
+
return new Quill({
|
|
179
179
|
privateKey,
|
|
180
180
|
databaseType,
|
|
181
181
|
databaseConnectionString,
|
|
@@ -184,9 +184,9 @@ const Quill = ({ privateKey, databaseConnectionString, databaseConfig, cache, da
|
|
|
184
184
|
metadataServerURL,
|
|
185
185
|
});
|
|
186
186
|
};
|
|
187
|
-
module.exports =
|
|
187
|
+
module.exports = requireQuill;
|
|
188
|
+
module.exports.default = requireQuill;
|
|
188
189
|
module.exports.Quill = Quill;
|
|
189
|
-
module.exports.default = Quill;
|
|
190
190
|
module.exports.getTablesBySchemaByDatabase = DatabaseHelper_1.getTablesBySchemaByDatabase;
|
|
191
191
|
module.exports.getDatabaseCredentials = DatabaseHelper_1.getDatabaseCredentials;
|
|
192
192
|
module.exports.getColumnsByTableByDatabase = DatabaseHelper_1.getColumnsByTableByDatabase;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quillsql/node",
|
|
3
|
-
"version": "0.4.
|
|
4
|
-
"description": "Quill
|
|
3
|
+
"version": "0.4.8",
|
|
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",
|
|
@@ -9,7 +9,6 @@ import {
|
|
|
9
9
|
disconnectFromDatabase,
|
|
10
10
|
runQueryByDatabase,
|
|
11
11
|
} from "./DatabaseHelper";
|
|
12
|
-
import { DatabaseType } from "..";
|
|
13
12
|
|
|
14
13
|
class PgError extends Error {
|
|
15
14
|
code?: string;
|
|
@@ -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:
|
|
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:
|
|
38
|
+
databaseType: "postgresql" | "snowflake" | "bigquery" | "mysql",
|
|
40
39
|
config: any,
|
|
41
40
|
cacheConfig: Partial<CacheCredentials> = {}
|
|
42
41
|
) {
|
package/src/db/DatabaseHelper.ts
CHANGED
|
@@ -50,7 +50,6 @@ import {
|
|
|
50
50
|
getSchemaColumnInfoMysql,
|
|
51
51
|
getSchemasMysql,
|
|
52
52
|
} from "./Mysql";
|
|
53
|
-
import { DatabaseType } from "..";
|
|
54
53
|
|
|
55
54
|
// export all database connections types
|
|
56
55
|
export type DatabaseConnection =
|
|
@@ -65,7 +64,7 @@ export interface QuillQueryResults {
|
|
|
65
64
|
}
|
|
66
65
|
|
|
67
66
|
export function getDatabaseCredentials(
|
|
68
|
-
databaseType:
|
|
67
|
+
databaseType: "postgresql" | "snowflake" | "bigquery" | "mysql",
|
|
69
68
|
connectionString: string
|
|
70
69
|
):
|
|
71
70
|
| PostgresConnectionConfig
|
|
@@ -90,7 +89,7 @@ export function getDatabaseCredentials(
|
|
|
90
89
|
}
|
|
91
90
|
|
|
92
91
|
export function connectToDatabase(
|
|
93
|
-
databaseType:
|
|
92
|
+
databaseType: "postgresql" | "snowflake" | "bigquery" | "mysql",
|
|
94
93
|
config:
|
|
95
94
|
| PostgresConnectionConfig
|
|
96
95
|
| SnowflakeConnectionConfig
|
|
@@ -114,7 +113,7 @@ export function connectToDatabase(
|
|
|
114
113
|
}
|
|
115
114
|
|
|
116
115
|
export function runQueryByDatabase(
|
|
117
|
-
databaseType:
|
|
116
|
+
databaseType: "postgresql" | "snowflake" | "bigquery" | "mysql",
|
|
118
117
|
connection: DatabaseConnection,
|
|
119
118
|
sql: string
|
|
120
119
|
): Promise<QuillQueryResults> | undefined {
|
|
@@ -135,7 +134,7 @@ export function runQueryByDatabase(
|
|
|
135
134
|
}
|
|
136
135
|
|
|
137
136
|
export function disconnectFromDatabase(
|
|
138
|
-
databaseType:
|
|
137
|
+
databaseType: "postgresql" | "snowflake" | "bigquery" | "mysql",
|
|
139
138
|
database: DatabaseConnection
|
|
140
139
|
) {
|
|
141
140
|
switch (databaseType.toLowerCase()) {
|
|
@@ -155,7 +154,7 @@ export function disconnectFromDatabase(
|
|
|
155
154
|
}
|
|
156
155
|
|
|
157
156
|
export async function getSchemasByDatabase(
|
|
158
|
-
databaseType:
|
|
157
|
+
databaseType: "postgresql" | "snowflake" | "bigquery" | "mysql",
|
|
159
158
|
connection: DatabaseConnection
|
|
160
159
|
): Promise<string[] | undefined> {
|
|
161
160
|
switch (databaseType.toLowerCase()) {
|
|
@@ -176,7 +175,7 @@ export async function getSchemasByDatabase(
|
|
|
176
175
|
|
|
177
176
|
// INFORMATION SCHEMA SELECTS
|
|
178
177
|
export async function getTablesBySchemaByDatabase(
|
|
179
|
-
databaseType:
|
|
178
|
+
databaseType: "postgresql" | "snowflake" | "bigquery" | "mysql",
|
|
180
179
|
connection: DatabaseConnection,
|
|
181
180
|
schemaName: string | string[]
|
|
182
181
|
): Promise<string[] | { tableName: string; schemaName: string }[] | undefined> {
|
|
@@ -213,7 +212,7 @@ export async function getTablesBySchemaByDatabase(
|
|
|
213
212
|
|
|
214
213
|
// INFORMATION SCHEMA SELECTS
|
|
215
214
|
export async function getColumnsByTableByDatabase(
|
|
216
|
-
databaseType:
|
|
215
|
+
databaseType: "postgresql" | "snowflake" | "bigquery" | "mysql",
|
|
217
216
|
connection: DatabaseConnection,
|
|
218
217
|
schemaName: string,
|
|
219
218
|
tableName: string
|
|
@@ -255,7 +254,7 @@ export async function getColumnsByTableByDatabase(
|
|
|
255
254
|
}
|
|
256
255
|
|
|
257
256
|
export async function getForiegnKeysByDatabase(
|
|
258
|
-
databaseType:
|
|
257
|
+
databaseType: "postgresql" | "snowflake" | "bigquery" | "mysql",
|
|
259
258
|
connection: DatabaseConnection,
|
|
260
259
|
schemaName: string,
|
|
261
260
|
tableName: string,
|
|
@@ -303,7 +302,7 @@ export async function getForiegnKeysByDatabase(
|
|
|
303
302
|
}
|
|
304
303
|
|
|
305
304
|
export function getColumnInfoBySchemaByDatabase(
|
|
306
|
-
databaseType:
|
|
305
|
+
databaseType: "postgresql" | "snowflake" | "bigquery" | "mysql",
|
|
307
306
|
connection: DatabaseConnection,
|
|
308
307
|
schemaName: string,
|
|
309
308
|
tables: string[] | { tableName: string; schemaName: string }[]
|
package/src/index.ts
CHANGED
|
@@ -44,7 +44,7 @@ export enum DatabaseType {
|
|
|
44
44
|
mysql = "mysql",
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
export
|
|
47
|
+
export class Quill {
|
|
48
48
|
// Configure cached connection pools with the given config.
|
|
49
49
|
public targetConnection;
|
|
50
50
|
private baseUrl: string;
|
|
@@ -56,7 +56,7 @@ export default class QuillClass {
|
|
|
56
56
|
|
|
57
57
|
constructor(data: {
|
|
58
58
|
privateKey: string;
|
|
59
|
-
databaseType:
|
|
59
|
+
databaseType: "postgresql" | "snowflake" | "bigquery" | "mysql";
|
|
60
60
|
databaseConnectionString?: string;
|
|
61
61
|
databaseConfig?: any;
|
|
62
62
|
cache?: Partial<CacheCredentials>;
|
|
@@ -159,7 +159,7 @@ export default class QuillClass {
|
|
|
159
159
|
|
|
160
160
|
private async runQueries(
|
|
161
161
|
queries: string[] | undefined,
|
|
162
|
-
pkDatabaseType:
|
|
162
|
+
pkDatabaseType: "postgresql" | "snowflake" | "bigquery" | "mysql",
|
|
163
163
|
databaseType?: string,
|
|
164
164
|
runQueryConfig?: AdditionalProcessing
|
|
165
165
|
) {
|
|
@@ -265,7 +265,7 @@ export default class QuillClass {
|
|
|
265
265
|
}
|
|
266
266
|
}
|
|
267
267
|
|
|
268
|
-
const
|
|
268
|
+
const requireQuill = ({
|
|
269
269
|
privateKey,
|
|
270
270
|
databaseConnectionString,
|
|
271
271
|
databaseConfig,
|
|
@@ -276,11 +276,11 @@ const Quill = ({
|
|
|
276
276
|
privateKey: string;
|
|
277
277
|
databaseConnectionString: string;
|
|
278
278
|
cache?: Partial<CacheCredentials>;
|
|
279
|
-
databaseType:
|
|
279
|
+
databaseType: "postgresql" | "snowflake" | "bigquery" | "mysql";
|
|
280
280
|
databaseConfig: any;
|
|
281
281
|
metadataServerURL?: string;
|
|
282
282
|
}) => {
|
|
283
|
-
return new
|
|
283
|
+
return new Quill({
|
|
284
284
|
privateKey,
|
|
285
285
|
databaseType,
|
|
286
286
|
databaseConnectionString,
|
|
@@ -290,9 +290,9 @@ const Quill = ({
|
|
|
290
290
|
});
|
|
291
291
|
};
|
|
292
292
|
|
|
293
|
-
module.exports =
|
|
293
|
+
module.exports = requireQuill;
|
|
294
|
+
module.exports.default = requireQuill;
|
|
294
295
|
module.exports.Quill = Quill;
|
|
295
|
-
module.exports.default = Quill;
|
|
296
296
|
module.exports.getTablesBySchemaByDatabase = getTablesBySchemaByDatabase;
|
|
297
297
|
module.exports.getDatabaseCredentials = getDatabaseCredentials;
|
|
298
298
|
module.exports.getColumnsByTableByDatabase = getColumnsByTableByDatabase;
|