@pi-r/oci 0.6.6 → 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
@@ -11,26 +11,25 @@ function validateStorage(credential) {
11
11
  }
12
12
  exports.validateStorage = validateStorage;
13
13
  function validateDatabase(credential, data) {
14
- 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));
15
15
  }
16
16
  exports.validateDatabase = validateDatabase;
17
17
  function setStorageCredential(credential) {
18
18
  const { endpoint, namespace, region } = credential;
19
19
  if (endpoint) {
20
- credential.region || (credential.region = /([^.]+)\.oraclecloud\.com$/.exec(endpoint)?.[1]);
20
+ credential.region ||= /([^.]+)\.oraclecloud\.com$/.exec(endpoint)?.[1];
21
21
  }
22
22
  else if (namespace && region) {
23
- 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;
24
27
  }
25
28
  credential.s3ForcePathStyle = true;
26
29
  credential.signatureVersion = 'v4';
27
30
  }
28
31
  exports.setStorageCredential = setStorageCredential;
29
32
  async function createDatabaseClient(credential) {
30
- if (credential.username) {
31
- credential.user || (credential.user = credential.username);
32
- delete credential.username;
33
- }
34
33
  oracle_1.initOracleClient.call(this, credential, this.logType.CLOUD);
35
34
  return oracledb.getConnection(credential);
36
35
  }
@@ -97,7 +96,7 @@ async function executeBatchQuery(credential, batch, sessionKey) {
97
96
  continue;
98
97
  }
99
98
  }
100
- const db = await (client || (client = await createClient())).getSodaDatabase().openCollection(table);
99
+ const db = await (client ||= await createClient()).getSodaDatabase().openCollection(table);
101
100
  if (!db) {
102
101
  closeClient();
103
102
  throw (0, util_1.formatError)(item, "Missing database table");
@@ -149,7 +148,7 @@ async function executeBatchQuery(credential, batch, sessionKey) {
149
148
  result[i] = rows;
150
149
  continue;
151
150
  }
152
- const db = await (client || (client = await createClient())).getSodaDatabase().openCollection(table);
151
+ const db = await (client ||= await createClient()).getSodaDatabase().openCollection(table);
153
152
  if (!db) {
154
153
  closeClient();
155
154
  throw (0, util_1.formatError)(item, "Missing database table");
@@ -191,7 +190,7 @@ async function executeBatchQuery(credential, batch, sessionKey) {
191
190
  result[i] = rows;
192
191
  continue;
193
192
  }
194
- client || (client = await createClient());
193
+ client ||= await createClient();
195
194
  const executeOptions = { ...options, outFormat: 4002, maxRows, resultSet: false, autoCommit: true };
196
195
  if (item.streamRow) {
197
196
  rows = [];
@@ -215,7 +214,7 @@ async function executeBatchQuery(credential, batch, sessionKey) {
215
214
  stream.destroy();
216
215
  });
217
216
  })
218
- .catch(err => {
217
+ .catch((err) => {
219
218
  closeClient();
220
219
  throw (0, util_1.formatError)(item, err instanceof Error ? err.message : "Missing database query");
221
220
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-r/oci",
3
- "version": "0.6.6",
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.7",
24
- "@e-mc/module": "^0.8.7",
25
- "@e-mc/types": "^0.8.7",
26
- "@pi-r/aws": "^0.6.6",
27
- "@pi-r/oracle": "^0.6.6",
28
- "aws-sdk": "^2.1591.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
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 {}