@pi-r/oci 0.6.5 → 0.7.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/README.md CHANGED
@@ -1,10 +1,7 @@
1
- # @pi-r/oci
1
+ ### @pi-r/oci
2
2
 
3
- ## Documentation
3
+ https://e-mc.readthedocs.io/en/latest/cloud/oci.html
4
4
 
5
- - [E-mc](https://e-mc.readthedocs.io/en/latest/cloud/oci.html)
6
- - [squared](https://squared.readthedocs.io)
7
-
8
- ## LICENSE
5
+ ### LICENSE
9
6
 
10
7
  MIT
package/client/index.js CHANGED
@@ -1,5 +1,4 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
2
  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
3
  const oracledb = require("oracledb");
5
4
  const types_1 = require("@e-mc/types");
@@ -12,26 +11,25 @@ function validateStorage(credential) {
12
11
  }
13
12
  exports.validateStorage = validateStorage;
14
13
  function validateDatabase(credential, data) {
15
- return !!(data.table && (credential.password && (credential.user || credential.username) && (credential.connectString || credential.connectionString) || credential.poolAlias));
14
+ return !!(data.table && (credential.user && credential.password && (credential.connectString || credential.connectionString) || credential.poolAlias));
16
15
  }
17
16
  exports.validateDatabase = validateDatabase;
18
17
  function setStorageCredential(credential) {
19
18
  const { endpoint, namespace, region } = credential;
20
19
  if (endpoint) {
21
- credential.region || (credential.region = /([^.]+)\.oraclecloud\.com$/.exec(endpoint)?.[1]);
20
+ credential.region ||= /([^.]+)\.oraclecloud\.com$/.exec(endpoint)?.[1];
22
21
  }
23
22
  else if (namespace && region) {
24
- credential.endpoint || (credential.endpoint = `https://${namespace}.compat.objectstorage.${region}.oraclecloud.com`);
23
+ credential.endpoint ||= `https://${namespace}.compat.objectstorage.${region}.oraclecloud.com`;
24
+ }
25
+ if (namespace) {
26
+ delete credential.namespace;
25
27
  }
26
28
  credential.s3ForcePathStyle = true;
27
29
  credential.signatureVersion = 'v4';
28
30
  }
29
31
  exports.setStorageCredential = setStorageCredential;
30
32
  async function createDatabaseClient(credential) {
31
- if (credential.username) {
32
- credential.user || (credential.user = credential.username);
33
- delete credential.username;
34
- }
35
33
  oracle_1.initOracleClient.call(this, credential, this.logType.CLOUD);
36
34
  return oracledb.getConnection(credential);
37
35
  }
@@ -98,7 +96,7 @@ async function executeBatchQuery(credential, batch, sessionKey) {
98
96
  continue;
99
97
  }
100
98
  }
101
- const db = await (client || (client = await createClient())).getSodaDatabase().openCollection(table);
99
+ const db = await (client ||= await createClient()).getSodaDatabase().openCollection(table);
102
100
  if (!db) {
103
101
  closeClient();
104
102
  throw (0, util_1.formatError)(item, "Missing database table");
@@ -150,7 +148,7 @@ async function executeBatchQuery(credential, batch, sessionKey) {
150
148
  result[i] = rows;
151
149
  continue;
152
150
  }
153
- const db = await (client || (client = await createClient())).getSodaDatabase().openCollection(table);
151
+ const db = await (client ||= await createClient()).getSodaDatabase().openCollection(table);
154
152
  if (!db) {
155
153
  closeClient();
156
154
  throw (0, util_1.formatError)(item, "Missing database table");
@@ -192,7 +190,7 @@ async function executeBatchQuery(credential, batch, sessionKey) {
192
190
  result[i] = rows;
193
191
  continue;
194
192
  }
195
- client || (client = await createClient());
193
+ client ||= await createClient();
196
194
  const executeOptions = { ...options, outFormat: 4002, maxRows, resultSet: false, autoCommit: true };
197
195
  if (item.streamRow) {
198
196
  rows = [];
@@ -216,7 +214,7 @@ async function executeBatchQuery(credential, batch, sessionKey) {
216
214
  stream.destroy();
217
215
  });
218
216
  })
219
- .catch(err => {
217
+ .catch((err) => {
220
218
  closeClient();
221
219
  throw (0, util_1.formatError)(item, err instanceof Error ? err.message : "Missing database query");
222
220
  });
package/download/index.js CHANGED
@@ -1,8 +1,6 @@
1
1
  "use strict";
2
2
  const client_1 = require("@pi-r/oci");
3
- function download(credential, service = 'oci') {
3
+ module.exports = function download(credential, service = 'oci') {
4
4
  (0, client_1.setStorageCredential)(credential);
5
5
  return require("@pi-r/aws/download").call(this, credential, service);
6
- }
7
-
8
- module.exports = download;
6
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-r/oci",
3
- "version": "0.6.5",
3
+ "version": "0.7.0",
4
4
  "description": "Oracle (OCI) cloud functions for E-mc.",
5
5
  "main": "client/index.js",
6
6
  "publishConfig": {
@@ -20,12 +20,12 @@
20
20
  "license": "MIT",
21
21
  "homepage": "https://github.com/anpham6/pi-r#readme",
22
22
  "dependencies": {
23
- "@e-mc/cloud": "^0.8.6",
24
- "@e-mc/module": "^0.8.6",
25
- "@e-mc/types": "^0.8.6",
26
- "@pi-r/aws": "^0.6.5",
27
- "@pi-r/oracle": "^0.6.5",
28
- "aws-sdk": "^2.1570.0",
29
- "oracledb": "^6.3.0"
23
+ "@e-mc/cloud": "^0.9.0",
24
+ "@e-mc/module": "^0.9.0",
25
+ "@e-mc/types": "^0.9.0",
26
+ "@pi-r/aws": "^0.7.0",
27
+ "@pi-r/oracle": "^0.7.0",
28
+ "aws-sdk": "^2.1607.0",
29
+ "oracledb": "^6.4.0"
30
30
  }
31
31
  }
@@ -0,0 +1,19 @@
1
+ import type { CloudDatabase, CloudStorage } from '@e-mc/types/lib/cloud';
2
+
3
+ import type { BindParameters, ConnectionAttributes, ExecuteOptions, InitialiseOptions } from 'oracledb';
4
+ import type { ConfigurationOptions } from 'aws-sdk/lib/core';
5
+
6
+ export type OCIStorage = CloudStorage<OCIStorageCredential, "oci">;
7
+
8
+ export interface OCIStorageCredential extends ConfigurationOptions {
9
+ namespace?: string;
10
+ endpoint?: string;
11
+ }
12
+
13
+ export interface OCIDatabaseQuery extends CloudDatabase<PlainObject | string, ExecuteOptions, StandardMap, BindParameters, OCIDatabaseCredential> {
14
+ source: "cloud";
15
+ service: "oci";
16
+ streamRow?: boolean;
17
+ }
18
+
19
+ export interface OCIDatabaseCredential extends ConnectionAttributes, InitialiseOptions {}
package/upload/index.js CHANGED
@@ -1,8 +1,6 @@
1
1
  "use strict";
2
2
  const client_1 = require("@pi-r/oci");
3
- function upload(credential, service = 'oci') {
3
+ module.exports = function upload(credential, service = 'oci') {
4
4
  (0, client_1.setStorageCredential)(credential);
5
5
  return require("@pi-r/aws/upload").call(this, credential, service);
6
- }
7
-
8
- module.exports = upload;
6
+ };