@quillsql/node 0.4.6 → 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,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
|
@@ -26,7 +26,7 @@ export default class QuillClass {
|
|
|
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/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.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",
|
|
@@ -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
|
@@ -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
|
) {
|
|
@@ -276,7 +276,7 @@ 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
|
}) => {
|