@dbml/connector 3.10.2 → 3.11.0
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/.babelrc +0 -0
- package/LICENSE +0 -0
- package/README.md +0 -0
- package/__tests__/connector.test.ts +0 -0
- package/__tests__/connectors/mssql/connection.json +0 -0
- package/__tests__/connectors/mssql/expect-out-files/schema.json +0 -0
- package/__tests__/connectors/mysql/connection.json +0 -0
- package/__tests__/connectors/mysql/expect-out-files/schema.json +0 -0
- package/__tests__/connectors/postgres/connection.json +0 -0
- package/__tests__/connectors/postgres/expect-out-files/schema.json +0 -0
- package/dist/connectors/bigqueryConnector.d.ts +0 -0
- package/dist/connectors/bigqueryConnector.js +0 -0
- package/dist/connectors/connector.d.ts +0 -0
- package/dist/connectors/connector.js +0 -0
- package/dist/connectors/mssqlConnector.d.ts +0 -0
- package/dist/connectors/mssqlConnector.js +0 -0
- package/dist/connectors/mysqlConnector.d.ts +0 -0
- package/dist/connectors/mysqlConnector.js +0 -0
- package/dist/connectors/postgresConnector.d.ts +0 -0
- package/dist/connectors/postgresConnector.js +0 -0
- package/dist/connectors/snowflakeConnector.d.ts +0 -0
- package/dist/connectors/snowflakeConnector.js +30 -13
- package/dist/connectors/types.d.ts +0 -0
- package/dist/connectors/types.js +0 -0
- package/dist/index.d.ts +0 -0
- package/dist/index.js +0 -0
- package/dist/utils/credential-loader.d.ts +0 -0
- package/dist/utils/credential-loader.js +0 -0
- package/dist/utils/helpers.d.ts +0 -0
- package/dist/utils/helpers.js +0 -0
- package/dist/utils/parseSchema.d.ts +0 -0
- package/dist/utils/parseSchema.js +0 -0
- package/jest.config.ts +0 -0
- package/jestHelpers.ts +0 -0
- package/package.json +3 -3
- package/src/connectors/bigqueryConnector.ts +0 -0
- package/src/connectors/connector.ts +0 -0
- package/src/connectors/mssqlConnector.ts +0 -0
- package/src/connectors/mysqlConnector.ts +0 -0
- package/src/connectors/postgresConnector.ts +0 -0
- package/src/connectors/snowflakeConnector.ts +36 -14
- package/src/connectors/types.ts +0 -0
- package/src/ddl_samples/bigquery.sql +0 -0
- package/src/ddl_samples/snowflake.sql +0 -0
- package/src/index.ts +0 -0
- package/src/utils/credential-loader.ts +0 -0
- package/src/utils/helpers.ts +0 -0
- package/src/utils/parseSchema.ts +0 -0
- package/tsconfig.json +0 -0
- package/__tests__/connectors/bigquery/out-files/schema.json +0 -565
- package/__tests__/connectors/mssql/out-files/schema.json +0 -1858
- package/__tests__/connectors/mysql/out-files/schema.json +0 -1390
- package/__tests__/connectors/postgres/out-files/schema.json +0 -1774
package/.babelrc
CHANGED
|
File without changes
|
package/LICENSE
CHANGED
|
File without changes
|
package/README.md
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -65,26 +65,43 @@ const connectToSnowflake = async (config) => {
|
|
|
65
65
|
logLevel,
|
|
66
66
|
additionalLogToConsole: isDebugMode,
|
|
67
67
|
});
|
|
68
|
+
// https://docs.snowflake.com/en/developer-guide/node-js/nodejs-driver-options#authentication-options
|
|
69
|
+
let authConfig = {};
|
|
70
|
+
switch (config.AUTHENTICATOR) {
|
|
71
|
+
case 'SNOWFLAKE_JWT':
|
|
72
|
+
// https://docs.snowflake.com/en/developer-guide/node-js/nodejs-driver-authenticate#label-nodejs-key-pair-authentication
|
|
73
|
+
// Support private key file
|
|
74
|
+
authConfig = {
|
|
75
|
+
privateKeyPath: config.PRIVATE_KEY_PATH,
|
|
76
|
+
privateKeyPass: config.PASSPHRASE,
|
|
77
|
+
};
|
|
78
|
+
break;
|
|
79
|
+
case 'SNOWFLAKE':
|
|
80
|
+
case undefined:
|
|
81
|
+
authConfig = {
|
|
82
|
+
password: config.PWD,
|
|
83
|
+
};
|
|
84
|
+
break;
|
|
85
|
+
default:
|
|
86
|
+
throw new Error('Unsupported authenticator');
|
|
87
|
+
}
|
|
68
88
|
// "SERVER=myaccount.snowflakecomputing.com;UID=myusername;PWD=mypassword;DATABASE=mydatabase;WAREHOUSE=mywarehouse;ROLE=myrole";
|
|
69
|
-
const
|
|
89
|
+
const connectionOptions = {
|
|
90
|
+
authenticator: config.AUTHENTICATOR,
|
|
70
91
|
account: config.SERVER,
|
|
71
92
|
username: config.UID,
|
|
72
|
-
password: config.PWD,
|
|
73
93
|
database: config.DATABASE,
|
|
74
94
|
warehouse: config.WAREHOUSE,
|
|
75
95
|
sfRetryMaxLoginRetries: 3,
|
|
76
96
|
timeout: 10000,
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
catch (err) {
|
|
86
|
-
throw err;
|
|
87
|
-
}
|
|
97
|
+
...authConfig,
|
|
98
|
+
};
|
|
99
|
+
const connection = snowflake_sdk_1.default.createConnection(connectionOptions);
|
|
100
|
+
// Connect to Snowflake
|
|
101
|
+
await connect(connection);
|
|
102
|
+
// Execute the query
|
|
103
|
+
await executeQuery(connection, 'SELECT CURRENT_VERSION();');
|
|
104
|
+
return connection;
|
|
88
105
|
};
|
|
89
106
|
const convertQueryBoolean = (val) => val === 'YES';
|
|
90
107
|
const getFieldType = (data_type, character_maximum_length, numeric_precision, numeric_scale) => {
|
|
File without changes
|
package/dist/connectors/types.js
CHANGED
|
File without changes
|
package/dist/index.d.ts
CHANGED
|
File without changes
|
package/dist/index.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/dist/utils/helpers.d.ts
CHANGED
|
File without changes
|
package/dist/utils/helpers.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/jest.config.ts
CHANGED
|
File without changes
|
package/jestHelpers.ts
CHANGED
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dbml/connector",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.11.0",
|
|
4
4
|
"description": "This package was created to fetch the schema JSON from many kind of databases.",
|
|
5
5
|
"author": "huy.phung.sw@gmail.com",
|
|
6
6
|
"license": "MIT",
|
|
@@ -35,10 +35,10 @@
|
|
|
35
35
|
"mssql": "^11.0.1",
|
|
36
36
|
"mysql2": "^3.11.0",
|
|
37
37
|
"pg": "^8.12.0",
|
|
38
|
-
"snowflake-sdk": "^
|
|
38
|
+
"snowflake-sdk": "^2.0.3"
|
|
39
39
|
},
|
|
40
40
|
"engines": {
|
|
41
41
|
"node": ">=18"
|
|
42
42
|
},
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "eb05b8cd85092e62152c6a994d9c0568a1d898de"
|
|
44
44
|
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
// Snowflake does not support indexes for standard tables.
|
|
8
8
|
//
|
|
9
9
|
|
|
10
|
-
import snowflake
|
|
10
|
+
import snowflake from 'snowflake-sdk';
|
|
11
|
+
import type { Connection, LogLevel, ConnectionOptions } from 'snowflake-sdk';
|
|
11
12
|
import { parseSchema } from '../utils/parseSchema';
|
|
12
13
|
import {
|
|
13
14
|
DatabaseSchema,
|
|
@@ -93,30 +94,51 @@ const connectToSnowflake = async (config: Record<string, string>): Promise<Conne
|
|
|
93
94
|
additionalLogToConsole: isDebugMode,
|
|
94
95
|
});
|
|
95
96
|
|
|
97
|
+
// https://docs.snowflake.com/en/developer-guide/node-js/nodejs-driver-options#authentication-options
|
|
98
|
+
let authConfig = {};
|
|
99
|
+
switch (config.AUTHENTICATOR) {
|
|
100
|
+
case 'SNOWFLAKE_JWT':
|
|
101
|
+
// https://docs.snowflake.com/en/developer-guide/node-js/nodejs-driver-authenticate#label-nodejs-key-pair-authentication
|
|
102
|
+
// Support private key file
|
|
103
|
+
authConfig = {
|
|
104
|
+
privateKeyPath: config.PRIVATE_KEY_PATH,
|
|
105
|
+
privateKeyPass: config.PASSPHRASE,
|
|
106
|
+
};
|
|
107
|
+
break;
|
|
108
|
+
|
|
109
|
+
case 'SNOWFLAKE':
|
|
110
|
+
case undefined:
|
|
111
|
+
authConfig = {
|
|
112
|
+
password: config.PWD,
|
|
113
|
+
};
|
|
114
|
+
break;
|
|
115
|
+
|
|
116
|
+
default:
|
|
117
|
+
throw new Error('Unsupported authenticator');
|
|
118
|
+
}
|
|
119
|
+
|
|
96
120
|
// "SERVER=myaccount.snowflakecomputing.com;UID=myusername;PWD=mypassword;DATABASE=mydatabase;WAREHOUSE=mywarehouse;ROLE=myrole";
|
|
97
|
-
const
|
|
121
|
+
const connectionOptions: ConnectionOptions = {
|
|
122
|
+
authenticator: config.AUTHENTICATOR,
|
|
98
123
|
account: config.SERVER,
|
|
99
124
|
username: config.UID,
|
|
100
|
-
password: config.PWD,
|
|
101
125
|
database: config.DATABASE,
|
|
102
126
|
warehouse: config.WAREHOUSE,
|
|
103
127
|
sfRetryMaxLoginRetries: 3,
|
|
104
128
|
timeout: 10000,
|
|
105
|
-
|
|
129
|
+
...authConfig,
|
|
130
|
+
};
|
|
106
131
|
|
|
107
|
-
|
|
108
|
-
// Connect to Snowflake
|
|
109
|
-
await connect(connection);
|
|
132
|
+
const connection = snowflake.createConnection(connectionOptions);
|
|
110
133
|
|
|
111
|
-
|
|
112
|
-
|
|
134
|
+
// Connect to Snowflake
|
|
135
|
+
await connect(connection);
|
|
113
136
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
throw err;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
137
|
+
// Execute the query
|
|
138
|
+
await executeQuery(connection, 'SELECT CURRENT_VERSION();');
|
|
119
139
|
|
|
140
|
+
return connection;
|
|
141
|
+
};
|
|
120
142
|
|
|
121
143
|
const convertQueryBoolean = (val: string | null) => val === 'YES';
|
|
122
144
|
|
package/src/connectors/types.ts
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/src/index.ts
CHANGED
|
File without changes
|
|
File without changes
|
package/src/utils/helpers.ts
CHANGED
|
File without changes
|
package/src/utils/parseSchema.ts
CHANGED
|
File without changes
|
package/tsconfig.json
CHANGED
|
File without changes
|