@dbml/connector 3.11.0-alpha-0 → 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.
Files changed (53) hide show
  1. package/.babelrc +0 -0
  2. package/LICENSE +0 -0
  3. package/README.md +0 -0
  4. package/__tests__/connector.test.ts +0 -0
  5. package/__tests__/connectors/mssql/connection.json +0 -0
  6. package/__tests__/connectors/mssql/expect-out-files/schema.json +0 -0
  7. package/__tests__/connectors/mysql/connection.json +0 -0
  8. package/__tests__/connectors/mysql/expect-out-files/schema.json +0 -0
  9. package/__tests__/connectors/postgres/connection.json +0 -0
  10. package/__tests__/connectors/postgres/expect-out-files/schema.json +0 -0
  11. package/dist/connectors/bigqueryConnector.d.ts +0 -0
  12. package/dist/connectors/bigqueryConnector.js +0 -0
  13. package/dist/connectors/connector.d.ts +0 -0
  14. package/dist/connectors/connector.js +0 -0
  15. package/dist/connectors/mssqlConnector.d.ts +0 -0
  16. package/dist/connectors/mssqlConnector.js +0 -0
  17. package/dist/connectors/mysqlConnector.d.ts +0 -0
  18. package/dist/connectors/mysqlConnector.js +0 -0
  19. package/dist/connectors/postgresConnector.d.ts +0 -0
  20. package/dist/connectors/postgresConnector.js +0 -0
  21. package/dist/connectors/snowflakeConnector.d.ts +0 -0
  22. package/dist/connectors/snowflakeConnector.js +30 -13
  23. package/dist/connectors/types.d.ts +0 -0
  24. package/dist/connectors/types.js +0 -0
  25. package/dist/index.d.ts +0 -0
  26. package/dist/index.js +0 -0
  27. package/dist/utils/credential-loader.d.ts +0 -0
  28. package/dist/utils/credential-loader.js +0 -0
  29. package/dist/utils/helpers.d.ts +0 -0
  30. package/dist/utils/helpers.js +0 -0
  31. package/dist/utils/parseSchema.d.ts +0 -0
  32. package/dist/utils/parseSchema.js +0 -0
  33. package/jest.config.ts +0 -0
  34. package/jestHelpers.ts +0 -0
  35. package/package.json +3 -3
  36. package/src/connectors/bigqueryConnector.ts +0 -0
  37. package/src/connectors/connector.ts +0 -0
  38. package/src/connectors/mssqlConnector.ts +0 -0
  39. package/src/connectors/mysqlConnector.ts +0 -0
  40. package/src/connectors/postgresConnector.ts +0 -0
  41. package/src/connectors/snowflakeConnector.ts +36 -14
  42. package/src/connectors/types.ts +0 -0
  43. package/src/ddl_samples/bigquery.sql +0 -0
  44. package/src/ddl_samples/snowflake.sql +0 -0
  45. package/src/index.ts +0 -0
  46. package/src/utils/credential-loader.ts +0 -0
  47. package/src/utils/helpers.ts +0 -0
  48. package/src/utils/parseSchema.ts +0 -0
  49. package/tsconfig.json +0 -0
  50. package/__tests__/connectors/bigquery/out-files/schema.json +0 -565
  51. package/__tests__/connectors/mssql/out-files/schema.json +0 -1858
  52. package/__tests__/connectors/mysql/out-files/schema.json +0 -1390
  53. 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
@@ -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 connection = snowflake_sdk_1.default.createConnection({
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
- try {
79
- // Connect to Snowflake
80
- await connect(connection);
81
- // Execute the query
82
- await executeQuery(connection, 'SELECT CURRENT_VERSION();');
83
- return connection;
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
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
File without changes
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.11.0-alpha-0",
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": "^1.12.0"
38
+ "snowflake-sdk": "^2.0.3"
39
39
  },
40
40
  "engines": {
41
41
  "node": ">=18"
42
42
  },
43
- "gitHead": "b090782ba29b03837d87d4d6478bd3f2ca403efc"
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, { Connection, LogLevel } from 'snowflake-sdk';
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 connection = snowflake.createConnection({
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
- try {
108
- // Connect to Snowflake
109
- await connect(connection);
132
+ const connection = snowflake.createConnection(connectionOptions);
110
133
 
111
- // Execute the query
112
- await executeQuery(connection, 'SELECT CURRENT_VERSION();');
134
+ // Connect to Snowflake
135
+ await connect(connection);
113
136
 
114
- return connection;
115
- } catch (err) {
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
 
File without changes
File without changes
File without changes
package/src/index.ts CHANGED
File without changes
File without changes
File without changes
File without changes
package/tsconfig.json CHANGED
File without changes