@pi-r/mssql 0.2.1 → 0.2.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/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2023 An Pham
1
+ Copyright 2023 Mile Square Park
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
4
 
package/README.md CHANGED
@@ -1,5 +1,7 @@
1
- ### @pi-r/mssql
1
+ # @pi-r/mssql
2
2
 
3
- ### LICENSE
3
+ PEP 402 - Forever
4
+
5
+ ## LICENSE
4
6
 
5
7
  MIT
package/client/index.js CHANGED
@@ -132,9 +132,10 @@ function setCredential(item) {
132
132
  ({ username, password, hostname, port, database } = (0, util_1.parseServerAuth)(credential, true));
133
133
  }
134
134
  else {
135
+ const uri = item.uri;
135
136
  credential = {};
136
- if (item.uri) {
137
- const connection = (0, util_1.parseConnectionString)(item.uri);
137
+ if (uri) {
138
+ const connection = (0, util_1.parseConnectionString)(uri);
138
139
  if (connection) {
139
140
  ({ username, password, hostname, port, database } = connection);
140
141
  }
@@ -169,7 +170,7 @@ function setCredential(item) {
169
170
  errors.push('authentication.options.password');
170
171
  }
171
172
  if (errors.length) {
172
- throw (0, types_1.errorMessage)("mssql" /* STRINGS.MODULE_NAME */, 'Not defined - ' + errors.join(' | '));
173
+ throw (0, types_1.errorMessage)("mssql", 'Not defined - ' + errors.join(' | '));
173
174
  }
174
175
  const options = credential.options;
175
176
  if (options) {
@@ -199,8 +200,8 @@ function setCredential(item) {
199
200
  }
200
201
  const poolKey = getPoolKey(credential);
201
202
  if (!(pool = POOL_STATE[poolKey]) || pool.closed) {
202
- const Pool = require("tedious-connection-pool2" /* STRINGS.PACKAGE_POOL */);
203
- const config = this.getPoolConfig("mssql" /* STRINGS.MODULE_NAME */, password);
203
+ const Pool = require("tedious-connection-pool2");
204
+ const config = this.getPoolConfig("mssql", password);
204
205
  const poolConfig = (0, types_1.isPlainObject)(item.usePool) ? item.usePool : {};
205
206
  if (config) {
206
207
  const { min, max, idle, queue_idle } = config;
@@ -234,7 +235,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
234
235
  if (length === 0) {
235
236
  return [];
236
237
  }
237
- const db = require("tedious" /* STRINGS.PACKAGE_NAME */);
238
+ const db = require("tedious");
238
239
  let parallel, connectOnce, errorQuery, sessionKey, outCacheMiss;
239
240
  if ((0, types_1.isPlainObject)(options)) {
240
241
  ({ parallel, connectOnce, errorQuery, sessionKey, outCacheMiss } = options);
@@ -255,17 +256,17 @@ async function executeBatchQuery(batch, options = '', outResult) {
255
256
  if (!parallel) {
256
257
  outResult || (outResult = new Array(length));
257
258
  }
258
- const caching = this.hasCache("mssql" /* STRINGS.MODULE_NAME */, sessionKey);
259
+ const caching = this.hasCache("mssql", sessionKey);
259
260
  const tasks = new Array(length);
260
261
  const clients = [];
261
262
  const pools = [];
262
263
  let mssqlPool, mssqlClient, mssqlCredential, onceCredential = connectOnce ? batch[0].credential : undefined;
263
264
  const getConnection = async (item, credential) => {
264
- item.transactionState = 64 /* DB_TRANSACTION.AUTH */;
265
+ item.transactionState = 64;
265
266
  let client;
266
267
  if (mssqlPool) {
267
268
  pools.push(client = await mssqlPool.getConnection());
268
- item.transactionState &= ~64 /* DB_TRANSACTION.AUTH */;
269
+ item.transactionState &= ~64;
269
270
  return client;
270
271
  }
271
272
  const pool = item.usePool && DbPool.findKey(POOL_STATE, item.usePool, getPoolKey(credential), ...connectOnce ? [item, batch[0]] : [item]);
@@ -317,14 +318,14 @@ async function executeBatchQuery(batch, options = '', outResult) {
317
318
  }
318
319
  mssqlCredential = credential;
319
320
  }
320
- item.transactionState &= ~64 /* DB_TRANSACTION.AUTH */;
321
+ item.transactionState &= ~64;
321
322
  return client;
322
323
  };
323
324
  for (let i = 0; i < length; ++i) {
324
325
  const item = batch[i];
325
326
  const { source, query, ignoreCache } = item;
326
327
  let credential = mssqlCredential || onceCredential, error;
327
- if (!credential && !(0, types_1.isPlainObject)(credential = item.credential) && (error = (0, types_1.errorMessage)(source, "Invalid credentials" /* ERR_DB.CREDENTIALS */)) || !query && (error = (0, types_1.errorMessage)(source, "Missing database query" /* ERR_DB.QUERY */))) {
328
+ if (!credential && !(0, types_1.isPlainObject)(credential = item.credential) && (error = (0, types_1.errorMessage)(source, "Invalid credentials")) || !query && (error = (0, types_1.errorMessage)(source, "Missing database query"))) {
328
329
  if (this.handleFail(error, item, { errorQuery })) {
329
330
  if (!parallel) {
330
331
  tasks.length = 0;
@@ -340,8 +341,8 @@ async function executeBatchQuery(batch, options = '', outResult) {
340
341
  }
341
342
  continue;
342
343
  }
343
- item.transactionState = 1 /* DB_TRANSACTION.ACTIVE */;
344
- const streamRow = typeof item.streamRow === 'string' ? this.hasCoerce("mssql" /* STRINGS.MODULE_NAME */, 'options', null, credential) && (0, types_1.asFunction)(item.streamRow) : item.streamRow;
344
+ item.transactionState = 1;
345
+ const streamRow = typeof item.streamRow === 'string' ? this.hasCoerce("mssql", 'options', null, credential) && (0, types_1.asFunction)(item.streamRow) : item.streamRow;
345
346
  const renewCache = ignoreCache === 0;
346
347
  const cacheValue = renewCache ? { sessionKey, renewCache } : sessionKey;
347
348
  let params = item.params, queryString = '';
@@ -356,7 +357,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
356
357
  else {
357
358
  outResult[i] = result;
358
359
  }
359
- this.add(item, 4 /* DB_TRANSACTION.COMMIT */ | 128 /* DB_TRANSACTION.CACHE */);
360
+ this.add(item, 4 | 128);
360
361
  continue;
361
362
  }
362
363
  if (!ignoreCache && outCacheMiss) {
@@ -390,7 +391,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
390
391
  reject(error);
391
392
  }
392
393
  else {
393
- this.add(item, 4 /* DB_TRANSACTION.COMMIT */);
394
+ this.add(item, 4);
394
395
  if (output) {
395
396
  output['__recordset__'] = 0;
396
397
  output['__returnvalue__'] = true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-r/mssql",
3
- "version": "0.2.1",
3
+ "version": "0.2.8",
4
4
  "description": "MSSQL client driver for E-mc.",
5
5
  "main": "client/index.js",
6
6
  "types": "client/index.d.ts",
@@ -9,7 +9,7 @@
9
9
  },
10
10
  "repository": {
11
11
  "type": "git",
12
- "url": "https://github.com/anpham6/pi-r.git",
12
+ "url": "git+https://github.com/anpham6/pi-r.git",
13
13
  "directory": "src/db/mssql"
14
14
  },
15
15
  "keywords": [
@@ -21,9 +21,9 @@
21
21
  "license": "MIT",
22
22
  "homepage": "https://github.com/anpham6/pi-r#readme",
23
23
  "dependencies": {
24
- "@e-mc/db": "^0.5.2",
25
- "@e-mc/types": "^0.5.2",
26
- "tedious": "^15.1.3",
27
- "tedious-connection-pool": "^1.0.5"
24
+ "@e-mc/db": "^0.5.4",
25
+ "@e-mc/types": "^0.5.4",
26
+ "tedious": "^16.7.1",
27
+ "tedious-connection-pool2": "^2.1.0"
28
28
  }
29
29
  }