@pi-r/oci 0.5.2 → 0.6.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/client/index.js +14 -30
- package/package.json +8 -7
package/client/index.js
CHANGED
|
@@ -4,6 +4,7 @@ exports.executeBatchQuery = exports.executeQuery = exports.deleteObjectsV2 = exp
|
|
|
4
4
|
const oracledb = require("oracledb");
|
|
5
5
|
const types_1 = require("@e-mc/types");
|
|
6
6
|
const aws_1 = require("@pi-r/aws");
|
|
7
|
+
const oracle_1 = require("@pi-r/oracle");
|
|
7
8
|
const util_1 = require("@e-mc/cloud/util");
|
|
8
9
|
const Module = require("@e-mc/module");
|
|
9
10
|
function validateStorage(credential) {
|
|
@@ -26,52 +27,36 @@ function setStorageCredential(credential) {
|
|
|
26
27
|
credential.signatureVersion = 'v4';
|
|
27
28
|
}
|
|
28
29
|
exports.setStorageCredential = setStorageCredential;
|
|
29
|
-
function createDatabaseClient(credential) {
|
|
30
|
+
async function createDatabaseClient(credential) {
|
|
30
31
|
if (credential.username) {
|
|
31
32
|
credential.user || (credential.user = credential.username);
|
|
32
33
|
delete credential.username;
|
|
33
34
|
}
|
|
34
|
-
|
|
35
|
-
try {
|
|
36
|
-
oracledb.initOracleClient({ libDir: credential.libDir, driverName: credential.driverName, errorUrl: credential.errorUrl });
|
|
37
|
-
}
|
|
38
|
-
catch (err) {
|
|
39
|
-
if (err instanceof Error) {
|
|
40
|
-
switch (err.code) {
|
|
41
|
-
case 'NJS-090':
|
|
42
|
-
this.addLog(this.statusType.WARN, err, 'oracledb', credential.libDir);
|
|
43
|
-
break;
|
|
44
|
-
default:
|
|
45
|
-
this.writeFail(["Unable to configure client" /* ERR_DB.CLIENT */, 'oracledb'], err, { type: this.logType.CLOUD, fatal: false });
|
|
46
|
-
break;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
35
|
+
oracle_1.initOracleClient.call(this, credential, this.logType.CLOUD);
|
|
51
36
|
return oracledb.getConnection(credential);
|
|
52
37
|
}
|
|
53
38
|
exports.createDatabaseClient = createDatabaseClient;
|
|
54
|
-
function createBucket(credential, bucket, publicRead) {
|
|
39
|
+
async function createBucket(credential, bucket, publicRead) {
|
|
55
40
|
return aws_1.createBucketV2.call(this, credential, bucket, publicRead ? 'public-read' : undefined, undefined, 'oci');
|
|
56
41
|
}
|
|
57
42
|
exports.createBucket = createBucket;
|
|
58
|
-
function createBucketV2(credential, bucket, ACL, options) {
|
|
43
|
+
async function createBucketV2(credential, bucket, ACL, options) {
|
|
59
44
|
return aws_1.createBucketV2.call(this, credential, bucket, ACL, options, 'oci');
|
|
60
45
|
}
|
|
61
46
|
exports.createBucketV2 = createBucketV2;
|
|
62
|
-
function setBucketPolicy(credential, bucket, options) {
|
|
47
|
+
async function setBucketPolicy(credential, bucket, options) {
|
|
63
48
|
return aws_1.setBucketPolicy.call(this, credential, bucket, options, 'oci');
|
|
64
49
|
}
|
|
65
50
|
exports.setBucketPolicy = setBucketPolicy;
|
|
66
|
-
function setBucketWebsite(credential, bucket, options) {
|
|
51
|
+
async function setBucketWebsite(credential, bucket, options) {
|
|
67
52
|
return aws_1.setBucketWebsite.call(this, credential, bucket, options, 'oci');
|
|
68
53
|
}
|
|
69
54
|
exports.setBucketWebsite = setBucketWebsite;
|
|
70
|
-
function deleteObjects(credential, bucket) {
|
|
55
|
+
async function deleteObjects(credential, bucket) {
|
|
71
56
|
return deleteObjectsV2.call(this, credential, bucket, true);
|
|
72
57
|
}
|
|
73
58
|
exports.deleteObjects = deleteObjects;
|
|
74
|
-
function deleteObjectsV2(credential, bucket, recursive = true) {
|
|
59
|
+
async function deleteObjectsV2(credential, bucket, recursive = true) {
|
|
75
60
|
setStorageCredential(credential);
|
|
76
61
|
return aws_1.deleteObjectsV2.call(this, credential, bucket, recursive, 'oci');
|
|
77
62
|
}
|
|
@@ -86,8 +71,8 @@ async function executeBatchQuery(credential, batch, sessionKey) {
|
|
|
86
71
|
const caching = length > 0 && this.hasCache(batch[0].service, sessionKey);
|
|
87
72
|
const cacheValue = { value: this.valueOfKey(credential, 'cache'), sessionKey };
|
|
88
73
|
let client;
|
|
89
|
-
const createClient = () => createDatabaseClient.call(this, length === 1 ? credential : { ...credential });
|
|
90
|
-
const closeClient = () => client?.close();
|
|
74
|
+
const createClient = async () => createDatabaseClient.call(this, length === 1 ? credential : { ...credential });
|
|
75
|
+
const closeClient = async () => client?.close();
|
|
91
76
|
for (let i = 0; i < length; ++i) {
|
|
92
77
|
const item = batch[i];
|
|
93
78
|
const { service, table, id, query, ignoreCache } = item;
|
|
@@ -97,11 +82,10 @@ async function executeBatchQuery(credential, batch, sessionKey) {
|
|
|
97
82
|
}
|
|
98
83
|
const renewCache = ignoreCache === 0;
|
|
99
84
|
const getCache = (value) => {
|
|
100
|
-
if (ignoreCache
|
|
101
|
-
|
|
85
|
+
if (ignoreCache !== 1) {
|
|
86
|
+
cacheValue.renewCache = renewCache;
|
|
87
|
+
return this.getQueryResult(service, credential, value, cacheValue);
|
|
102
88
|
}
|
|
103
|
-
cacheValue.renewCache = renewCache;
|
|
104
|
-
return this.getQueryResult(service, credential, value, cacheValue);
|
|
105
89
|
};
|
|
106
90
|
let rows, queryString = caching && ignoreCache !== true || ignoreCache === false || ignoreCache === 1 || renewCache ? table + '_' : '';
|
|
107
91
|
invalid: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pi-r/oci",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Oracle (OCI) cloud functions for E-mc.",
|
|
5
5
|
"main": "client/index.js",
|
|
6
6
|
"publishConfig": {
|
|
@@ -20,11 +20,12 @@
|
|
|
20
20
|
"license": "MIT",
|
|
21
21
|
"homepage": "https://github.com/anpham6/pi-r#readme",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@e-mc/cloud": "^0.
|
|
24
|
-
"@e-mc/module": "^0.
|
|
25
|
-
"@e-mc/types": "^0.
|
|
26
|
-
"@pi-r/aws": "^0.
|
|
27
|
-
"
|
|
28
|
-
"
|
|
23
|
+
"@e-mc/cloud": "^0.8.0",
|
|
24
|
+
"@e-mc/module": "^0.8.0",
|
|
25
|
+
"@e-mc/types": "^0.8.0",
|
|
26
|
+
"@pi-r/aws": "^0.6.0",
|
|
27
|
+
"@pi-r/oracle": "^0.6.0",
|
|
28
|
+
"aws-sdk": "^2.1524.0",
|
|
29
|
+
"oracledb": "^6.3.0"
|
|
29
30
|
}
|
|
30
31
|
}
|