@pi-r/oracle 0.5.0 → 0.5.2

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 Wit Studio
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/oracle
1
+ # @pi-r/oracle
2
2
 
3
- ### LICENSE
3
+ PEP 402 - Forever Vivy
4
+
5
+ ## LICENSE
4
6
 
5
7
  MIT
package/client/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import type { OracleDataSource } from '@e-mc/types/lib/db';
2
-
3
1
  import type { IDbSourceClient } from '@e-mc/db/types';
4
2
 
3
+ import type { OracleDataSource } from '../types';
4
+
5
5
  declare const Oracle: IDbSourceClient<OracleDataSource>;
6
6
 
7
7
  export = Oracle;
package/client/index.js CHANGED
@@ -18,10 +18,10 @@ class OraclePool extends DbPool {
18
18
  return this.closed || connectionsInUse === 0 && currentQueueLength === 0;
19
19
  }
20
20
  get closeable() {
21
- return super.closeable || this.client.status === 6001 /* POOL_STATUS.DRAINING */;
21
+ return super.closeable || this.client.status === 6001;
22
22
  }
23
23
  get closed() {
24
- return this.client.status === 6002 /* POOL_STATUS.CLOSED */;
24
+ return this.client.status === 6002;
25
25
  }
26
26
  }
27
27
  const POOL_STATE = {};
@@ -96,7 +96,7 @@ async function setCredential(item) {
96
96
  errors.push('connectString');
97
97
  }
98
98
  if (errors.length) {
99
- throw (0, types_1.errorMessage)("oracle" /* STRINGS.MODULE_NAME */, 'Not defined - ' + errors.join(' | '));
99
+ throw (0, types_1.errorMessage)("oracle", 'Not defined - ' + errors.join(' | '));
100
100
  }
101
101
  }
102
102
  const usePool = item.usePool;
@@ -126,7 +126,7 @@ async function setCredential(item) {
126
126
  const poolKey = getPoolKey(credential);
127
127
  if (poolKey) {
128
128
  if (!(pool = POOL_STATE[poolKey]) || pool.closed) {
129
- const config = this.getPoolConfig("oracle" /* STRINGS.MODULE_NAME */, password);
129
+ const config = this.getPoolConfig("oracle", password);
130
130
  if (config) {
131
131
  const { min, max, idle, queue_max, queue_idle, timeout } = config;
132
132
  if (min >= 0) {
@@ -189,16 +189,16 @@ async function executeBatchQuery(batch, options = '', outResult) {
189
189
  if (!parallel) {
190
190
  outResult || (outResult = new Array(length));
191
191
  }
192
- const caching = this.hasCache("oracle" /* STRINGS.MODULE_NAME */, sessionKey);
192
+ const caching = this.hasCache("oracle", sessionKey);
193
193
  const tasks = new Array(length);
194
194
  const clients = [];
195
195
  let oraclePool, oracleClient, oracleCredential, onceCredential = connectOnce ? batch[0].credential : undefined;
196
196
  const getConnection = async (item, credential) => {
197
- item.transactionState = 64 /* DB_TRANSACTION.AUTH */;
197
+ item.transactionState = 64;
198
198
  let client;
199
199
  if (oraclePool) {
200
200
  clients.push(client = await oraclePool.getConnection());
201
- item.transactionState &= ~64 /* DB_TRANSACTION.AUTH */;
201
+ item.transactionState &= ~64;
202
202
  return client;
203
203
  }
204
204
  const pool = item.usePool && DbPool.findKey(POOL_STATE, item.usePool, getPoolKey(credential), ...connectOnce ? [item, batch[0]] : [item]);
@@ -236,14 +236,14 @@ async function executeBatchQuery(batch, options = '', outResult) {
236
236
  }
237
237
  oracleCredential = credential;
238
238
  }
239
- item.transactionState &= ~64 /* DB_TRANSACTION.AUTH */;
239
+ item.transactionState &= ~64;
240
240
  return client;
241
241
  };
242
242
  for (let i = 0; i < length; ++i) {
243
243
  const item = batch[i];
244
244
  const { source, query, params, ignoreCache, options: clientOptions } = item;
245
245
  let credential = oracleCredential || onceCredential, error;
246
- 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 */))) {
246
+ 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"))) {
247
247
  if (this.handleFail(error, item, { errorQuery })) {
248
248
  if (!parallel) {
249
249
  tasks.length = 0;
@@ -259,8 +259,8 @@ async function executeBatchQuery(batch, options = '', outResult) {
259
259
  }
260
260
  continue;
261
261
  }
262
- item.transactionState = 1 /* DB_TRANSACTION.ACTIVE */;
263
- const streamRow = typeof item.streamRow === 'string' ? this.hasCoerce("oracle" /* STRINGS.MODULE_NAME */, 'options', null, credential) && (0, types_1.asFunction)(item.streamRow) : item.streamRow;
262
+ item.transactionState = 1;
263
+ const streamRow = typeof item.streamRow === 'string' ? this.hasCoerce("oracle", 'options', null, credential) && (0, types_1.asFunction)(item.streamRow) : item.streamRow;
264
264
  const renewCache = ignoreCache === 0;
265
265
  const cacheValue = renewCache ? { sessionKey, renewCache } : sessionKey;
266
266
  let queryString = '';
@@ -275,7 +275,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
275
275
  else {
276
276
  outResult[i] = result;
277
277
  }
278
- this.add(item, 4 /* DB_TRANSACTION.COMMIT */ | 128 /* DB_TRANSACTION.CACHE */);
278
+ this.add(item, 4 | 128);
279
279
  continue;
280
280
  }
281
281
  if (!ignoreCache && outCacheMiss) {
@@ -326,7 +326,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
326
326
  reject(error);
327
327
  }
328
328
  else {
329
- this.add(item, 4 /* DB_TRANSACTION.COMMIT */);
329
+ this.add(item, 4);
330
330
  resolve(!error ? this.setQueryResult(source, removePoolProperties(credential), queryString, rows, cacheValue) : rows);
331
331
  }
332
332
  })
@@ -334,7 +334,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
334
334
  }
335
335
  else {
336
336
  const { rows } = await client.execute(query, params || [], executeOptions);
337
- this.add(item, 4 /* DB_TRANSACTION.COMMIT */);
337
+ this.add(item, 4);
338
338
  resolve(rows ? this.setQueryResult(source, removePoolProperties(credential), queryString, rows, cacheValue) : null);
339
339
  }
340
340
  }
@@ -358,7 +358,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
358
358
  }
359
359
  }
360
360
  return this.processRows(batch, tasks, {
361
- disconnect: () => clients.forEach(item => item.close(err => err && this.writeFail(["Unable to close connnection" /* ERR_DB.CONNECTION_CLOSE */, "oracle" /* STRINGS.MODULE_NAME */], err, { type: 65536 /* LOG_TYPE.DB */, fatal: false }))),
361
+ disconnect: () => clients.forEach(item => item.close(err => err && this.writeFail(["Unable to close connnection", "oracle"], err, { type: 65536, fatal: false }))),
362
362
  parallel
363
363
  }, outResult);
364
364
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-r/oracle",
3
- "version": "0.5.0",
3
+ "version": "0.5.2",
4
4
  "description": "Oracle 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/oracle"
14
14
  },
15
15
  "keywords": [
@@ -21,8 +21,8 @@
21
21
  "license": "MIT",
22
22
  "homepage": "https://github.com/anpham6/pi-r#readme",
23
23
  "dependencies": {
24
- "@e-mc/db": "^0.7.0",
25
- "@e-mc/types": "^0.7.0",
26
- "oracledb": "^6.2.0"
24
+ "@e-mc/db": "^0.7.2",
25
+ "@e-mc/types": "^0.7.2",
26
+ "oracledb": "^6.3.0"
27
27
  }
28
28
  }