@pi-r/oci 0.3.0 → 0.3.3

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 Lisa Mishima
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/oci
1
+ # @pi-r/oci
2
2
 
3
- ### LICENSE
3
+ PEP 402 - Forever
4
+
5
+ ## LICENSE
4
6
 
5
7
  MIT
package/client/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.executeBatchQuery = exports.executeQuery = exports.deleteObjectsV2 = exports.deleteObjects = exports.setBucketWebsite = exports.setBucketPolicy = exports.createBucketV2 = exports.createBucket = exports.createDatabaseClient = exports.setStorageCredential = exports.validateDatabase = exports.validateStorage = void 0;
4
+ const oracledb = require("oracledb");
4
5
  const types_1 = require("@e-mc/types");
5
6
  const aws_1 = require("@pi-r/aws");
6
7
  const util_1 = require("@e-mc/cloud/util");
@@ -14,29 +15,23 @@ function validateDatabase(credential, data) {
14
15
  }
15
16
  exports.validateDatabase = validateDatabase;
16
17
  function setStorageCredential(credential) {
17
- if (credential.endpoint) {
18
- credential.region || (credential.region = /([^.]+)\.oraclecloud\.com$/.exec(credential.endpoint)?.[1]);
18
+ const { endpoint, namespace, region } = credential;
19
+ if (endpoint) {
20
+ credential.region || (credential.region = /([^.]+)\.oraclecloud\.com$/.exec(endpoint)?.[1]);
19
21
  }
20
- else {
21
- credential.endpoint || (credential.endpoint = `https://${credential.namespace}.compat.objectstorage.${credential.region}.oraclecloud.com`);
22
+ else if (namespace && region) {
23
+ credential.endpoint || (credential.endpoint = `https://${namespace}.compat.objectstorage.${region}.oraclecloud.com`);
22
24
  }
23
25
  credential.s3ForcePathStyle = true;
24
26
  credential.signatureVersion = 'v4';
25
27
  }
26
28
  exports.setStorageCredential = setStorageCredential;
27
29
  function createDatabaseClient(credential) {
28
- try {
29
- if (credential.username) {
30
- credential.user || (credential.user = credential.username);
31
- delete credential.username;
32
- }
33
- const { getConnection } = require('oracledb');
34
- return getConnection(credential);
35
- }
36
- catch (err) {
37
- this.checkPackage(err, 'oracledb', { passThrough: true });
38
- throw err;
30
+ if (credential.username) {
31
+ credential.user || (credential.user = credential.username);
32
+ delete credential.username;
39
33
  }
34
+ return oracledb.getConnection(credential);
40
35
  }
41
36
  exports.createDatabaseClient = createDatabaseClient;
42
37
  function createBucket(credential, bucket, publicRead) {
@@ -81,7 +76,7 @@ async function executeBatchQuery(credential, batch, sessionKey) {
81
76
  const { service, table, id, query, ignoreCache } = item;
82
77
  if (!table) {
83
78
  closeClient();
84
- throw (0, util_1.formatError)(item, "Missing database table" /* ERR_DB.TABLE */);
79
+ throw (0, util_1.formatError)(item, "Missing database table");
85
80
  }
86
81
  const renewCache = ignoreCache === 0;
87
82
  const getCache = (value) => {
@@ -105,7 +100,7 @@ async function executeBatchQuery(credential, batch, sessionKey) {
105
100
  const db = await (client || (client = await createClient())).getSodaDatabase().openCollection(table);
106
101
  if (!db) {
107
102
  closeClient();
108
- throw (0, util_1.formatError)(item, "Missing database table" /* ERR_DB.TABLE */);
103
+ throw (0, util_1.formatError)(item, "Missing database table");
109
104
  }
110
105
  const row = db.find().key(id);
111
106
  let document = await row.getOne();
@@ -153,7 +148,7 @@ async function executeBatchQuery(credential, batch, sessionKey) {
153
148
  const db = await (client || (client = await createClient())).getSodaDatabase().openCollection(table);
154
149
  if (!db) {
155
150
  closeClient();
156
- throw (0, util_1.formatError)(item, "Missing database table" /* ERR_DB.TABLE */);
151
+ throw (0, util_1.formatError)(item, "Missing database table");
157
152
  }
158
153
  let operation = db.find().filter(query);
159
154
  if (maxRows) {
@@ -167,12 +162,12 @@ async function executeBatchQuery(credential, batch, sessionKey) {
167
162
  result[i] = rows;
168
163
  continue;
169
164
  }
170
- ({ rows } = await (client || (client = await createClient())).execute(query, params || [], { ...options, outFormat: 4002 /* OUT_FORMAT.OBJECT */, maxRows, resultSet: false, autoCommit: true }));
165
+ ({ rows } = await (client || (client = await createClient())).execute(query, params || [], { ...options, outFormat: 4002, maxRows, resultSet: false, autoCommit: true }));
171
166
  }
172
167
  }
173
168
  else {
174
169
  closeClient();
175
- throw (0, util_1.formatError)(item, "Missing database query" /* ERR_DB.QUERY */);
170
+ throw (0, util_1.formatError)(item, "Missing database query");
176
171
  }
177
172
  }
178
173
  result[i] = this.setQueryResult(service, credential, queryString, rows, cacheValue);
package/download/index.js CHANGED
@@ -1,9 +1,8 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const client_1 = require("../client");
2
+ const client_1 = require("@pi-r/oci");
4
3
  function download(credential, service = 'oci') {
5
4
  (0, client_1.setStorageCredential)(credential);
6
- return require('../../aws/download').call(this, credential, service);
5
+ return require("@pi-r/aws/download").call(this, credential, service);
7
6
  }
8
7
 
9
8
  module.exports = download;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-r/oci",
3
- "version": "0.3.0",
3
+ "version": "0.3.3",
4
4
  "description": "Oracle (OCI) cloud functions for E-mc.",
5
5
  "main": "client/index.js",
6
6
  "publishConfig": {
@@ -8,7 +8,7 @@
8
8
  },
9
9
  "repository": {
10
10
  "type": "git",
11
- "url": "https://github.com/anpham6/pi-r.git",
11
+ "url": "git+https://github.com/anpham6/pi-r.git",
12
12
  "directory": "src/cloud/oci"
13
13
  },
14
14
  "keywords": [
@@ -20,11 +20,11 @@
20
20
  "license": "MIT",
21
21
  "homepage": "https://github.com/anpham6/pi-r#readme",
22
22
  "dependencies": {
23
- "@e-mc/cloud": "^0.5.3",
24
- "@e-mc/module": "^0.5.3",
25
- "@e-mc/types": "^0.5.3",
26
- "@pi-r/aws": "^0.2.2",
27
- "aws-sdk": "^2.1385.0",
28
- "oracledb": "^6.0.0"
23
+ "@e-mc/cloud": "^0.6.2",
24
+ "@e-mc/module": "^0.6.2",
25
+ "@e-mc/types": "^0.6.2",
26
+ "@pi-r/aws": "^0.3.3",
27
+ "aws-sdk": "^2.1591.0",
28
+ "oracledb": "^6.4.0"
29
29
  }
30
30
  }
package/upload/index.js CHANGED
@@ -1,9 +1,8 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const client_1 = require("../client");
2
+ const client_1 = require("@pi-r/oci");
4
3
  function upload(credential, service = 'oci') {
5
4
  (0, client_1.setStorageCredential)(credential);
6
- return require('../../aws/upload').call(this, credential, service);
5
+ return require("@pi-r/aws/upload").call(this, credential, service);
7
6
  }
8
7
 
9
8
  module.exports = upload;