@pi-r/mssql 0.6.3 → 0.6.5

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 2024 An Pham
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,7 +1,10 @@
1
- ### @pi-r/mssql
1
+ # @pi-r/mssql
2
2
 
3
- https://e-mc.readthedocs.io/en/latest/db/mssql.html
3
+ ## Documentation
4
4
 
5
- ### LICENSE
5
+ - [E-mc](https://e-mc.readthedocs.io/en/latest/db/mssql.html)
6
+ - [squared](https://squared.readthedocs.io)
7
+
8
+ ## LICENSE
6
9
 
7
10
  MIT
package/client/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import type { MSSQLDataSource } from '@e-mc/types/lib/db';
2
-
3
1
  import type { IDbSourceClient } from '@e-mc/db/types';
4
2
 
3
+ import type { MSSQLDataSource } from '../types';
4
+
5
5
  declare const MSSQL: IDbSourceClient<MSSQLDataSource>;
6
6
 
7
7
  export = MSSQL;
package/client/index.js CHANGED
@@ -181,7 +181,7 @@ function setCredential(item) {
181
181
  errors.push('authentication.options.password');
182
182
  }
183
183
  if (errors.length) {
184
- throw (0, types_1.errorMessage)("mssql" /* STRINGS.MODULE_NAME */, 'Not defined - ' + errors.join(' | '));
184
+ throw (0, types_1.errorMessage)("mssql", 'Not defined - ' + errors.join(' | '));
185
185
  }
186
186
  const options = credential.options;
187
187
  if (options) {
@@ -217,7 +217,7 @@ function setCredential(item) {
217
217
  return;
218
218
  }
219
219
  }
220
- const config = this.getPoolConfig("mssql" /* STRINGS.MODULE_NAME */, password);
220
+ const config = this.getPoolConfig("mssql", password);
221
221
  const poolConfig = (0, types_1.isPlainObject)(item.usePool) ? item.usePool : {};
222
222
  if (config) {
223
223
  const { min, max, idle, queue_idle } = config;
@@ -271,17 +271,17 @@ async function executeBatchQuery(batch, options = '', outResult) {
271
271
  if (!parallel) {
272
272
  outResult || (outResult = new Array(length));
273
273
  }
274
- const caching = this.hasCache("mssql" /* STRINGS.MODULE_NAME */, sessionKey);
274
+ const caching = this.hasCache("mssql", sessionKey);
275
275
  const tasks = new Array(length);
276
276
  const clients = [];
277
277
  const pools = [];
278
278
  let mssqlPool, mssqlClient, mssqlCredential, onceCredential = connectOnce ? batch[0].credential : undefined;
279
279
  const getConnection = async (item, credential) => {
280
- item.transactionState = 64 /* DB_TRANSACTION.AUTH */;
280
+ item.transactionState = 64;
281
281
  let client;
282
282
  if (mssqlPool) {
283
283
  pools.push(client = await mssqlPool.getConnection());
284
- item.transactionState &= ~64 /* DB_TRANSACTION.AUTH */;
284
+ item.transactionState &= ~64;
285
285
  return client;
286
286
  }
287
287
  const pool = item.usePool && DbPool.findKey(POOL_STATE, item.usePool, getPoolKey(credential), ...connectOnce ? [item, batch[0]] : [item]);
@@ -333,7 +333,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
333
333
  }
334
334
  mssqlCredential = credential;
335
335
  }
336
- item.transactionState &= ~64 /* DB_TRANSACTION.AUTH */;
336
+ item.transactionState &= ~64;
337
337
  return client;
338
338
  };
339
339
  if (this.host?.username) {
@@ -343,7 +343,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
343
343
  const item = batch[i];
344
344
  const { source, query, ignoreCache } = item;
345
345
  let credential = mssqlCredential || onceCredential, error;
346
- 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 */))) {
346
+ 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"))) {
347
347
  if (this.handleFail(error, item, { errorQuery })) {
348
348
  if (!parallel) {
349
349
  tasks.length = 0;
@@ -359,8 +359,8 @@ async function executeBatchQuery(batch, options = '', outResult) {
359
359
  }
360
360
  continue;
361
361
  }
362
- item.transactionState = 1 /* DB_TRANSACTION.ACTIVE */;
363
- const streamRow = typeof item.streamRow === 'string' ? this.hasCoerce("mssql" /* STRINGS.MODULE_NAME */, 'options', null, credential) && (0, types_1.asFunction)(item.streamRow) : item.streamRow;
362
+ item.transactionState = 1;
363
+ const streamRow = typeof item.streamRow === 'string' ? this.hasCoerce("mssql", 'options', null, credential) && (0, types_1.asFunction)(item.streamRow) : item.streamRow;
364
364
  const cacheValue = ignoreCache === undefined ? sessionKey : Array.isArray(ignoreCache) ? { sessionKey, exclusiveOf: ignoreCache } : { sessionKey, renewCache: ignoreCache === 0 };
365
365
  let params = item.params, queryString = '';
366
366
  if (caching && ignoreCache !== true && !streamRow) {
@@ -374,7 +374,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
374
374
  else {
375
375
  outResult[i] = result;
376
376
  }
377
- this.add(item, 4 /* DB_TRANSACTION.COMMIT */ | 128 /* DB_TRANSACTION.CACHE */);
377
+ this.add(item, 4 | 128);
378
378
  continue;
379
379
  }
380
380
  if (!ignoreCache && outCacheMiss) {
@@ -408,7 +408,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
408
408
  reject(error);
409
409
  }
410
410
  else {
411
- this.add(item, 4 /* DB_TRANSACTION.COMMIT */);
411
+ this.add(item, 4);
412
412
  if (output) {
413
413
  output.__recordset__ = 0;
414
414
  output.__returnvalue__ = true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-r/mssql",
3
- "version": "0.6.3",
3
+ "version": "0.6.5",
4
4
  "description": "MSSQL client driver for E-mc.",
5
5
  "main": "client/index.js",
6
6
  "types": "client/index.d.ts",
@@ -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.8.3",
25
- "@e-mc/types": "^0.8.3",
26
- "tedious": "^16.6.1",
24
+ "@e-mc/db": "^0.8.6",
25
+ "@e-mc/types": "^0.8.6",
26
+ "tedious": "^16.7.1",
27
27
  "tedious-connection-pool2": "^2.1.0"
28
28
  }
29
29
  }
package/types/index.d.ts CHANGED
@@ -2,7 +2,9 @@ import type { DbDataSource } from '@e-mc/types/lib/squared';
2
2
 
3
3
  import type { ExecuteAction, ServerAuth } from '@e-mc/types/lib/db';
4
4
 
5
+ // @ts-ignore
5
6
  import type { ConnectionConfig, ParameterOptions, TediousType, TediousTypes } from 'tedious';
7
+ // @ts-ignore
6
8
  import type { PoolConfig } from 'tedious-connection-pool';
7
9
 
8
10
  export interface MSSQLDataSource extends DbDataSource<string, unknown, unknown, string | MSSQLCredential, string | PoolConfig>, ExecuteAction<MSSQLRequestParameters | MSSQLRequestWithOutputParameters> {