@pi-r/azure 0.6.5 → 0.6.7

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 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.createBucketV2 = exports.createBucket = exports.createDatabaseClient = exports.createStorageClient = exports.validateDatabase = exports.validateStorage = void 0;
4
3
  const path = require("path");
5
4
  const storage = require("@azure/storage-blob");
@@ -21,10 +20,11 @@ function validateDatabase(credential, data) {
21
20
  }
22
21
  exports.validateDatabase = validateDatabase;
23
22
  function createStorageClient(credential) {
23
+ var _a, _b;
24
24
  let { accountName, accountKey, connectionString, sharedAccessSignature } = credential;
25
25
  if (connectionString) {
26
26
  if (!accountName) {
27
- credential.accountName = /AccountName=([^;]+);/.exec(connectionString)?.[1];
27
+ credential.accountName = (_a = /AccountName=([^;]+);/.exec(connectionString)) === null || _a === void 0 ? void 0 : _a[1];
28
28
  }
29
29
  return storage.BlobServiceClient.fromConnectionString(connectionString);
30
30
  }
@@ -36,7 +36,7 @@ function createStorageClient(credential) {
36
36
  }
37
37
  }
38
38
  else {
39
- credential.accountName || (credential.accountName = /^https:\/\/([a-z\d]+)\./.exec(sharedAccessSignature)?.[1]);
39
+ credential.accountName || (credential.accountName = (_b = /^https:\/\/([a-z\d]+)\./.exec(sharedAccessSignature)) === null || _b === void 0 ? void 0 : _b[1]);
40
40
  }
41
41
  return new storage.BlobServiceClient(sharedAccessSignature);
42
42
  }
@@ -175,7 +175,7 @@ async function executeBatchQuery(credential, batch, sessionKey) {
175
175
  client || (client = createDatabaseClient.call(this, credential));
176
176
  return client.database(name).container(table);
177
177
  };
178
- const closeClient = () => client?.dispose();
178
+ const closeClient = () => client === null || client === void 0 ? void 0 : client.dispose();
179
179
  for (let i = 0; i < length; ++i) {
180
180
  const item = batch[i];
181
181
  const { service, name, table, id, query, storedProcedureId, partitionKey = null, params, limit = 0, update, ignoreCache } = item;
package/download/index.js CHANGED
@@ -3,7 +3,7 @@ const types_1 = require("@e-mc/types");
3
3
  const Module = require("@e-mc/module");
4
4
  const Cloud = require("@e-mc/cloud");
5
5
  const client_1 = require("@pi-r/azure");
6
- function download(credential, service = 'azure') {
6
+ module.exports = function download(credential, service = 'azure') {
7
7
  const blobServiceClient = client_1.createStorageClient.call(this, credential);
8
8
  return (data, callback) => {
9
9
  const { bucket: Bucket, download: target } = data;
@@ -30,6 +30,4 @@ function download(credential, service = 'azure') {
30
30
  })
31
31
  .catch(err => callback(err));
32
32
  };
33
- }
34
-
35
- module.exports = download;
33
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-r/azure",
3
- "version": "0.6.5",
3
+ "version": "0.6.7",
4
4
  "description": "Azure cloud functions for E-mc.",
5
5
  "main": "client/index.js",
6
6
  "publishConfig": {
@@ -20,9 +20,9 @@
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",
23
+ "@e-mc/cloud": "^0.8.8",
24
+ "@e-mc/module": "^0.8.8",
25
+ "@e-mc/types": "^0.8.8",
26
26
  "@azure/cosmos": "^4.0.0",
27
27
  "@azure/identity": "^4.0.1",
28
28
  "@azure/storage-blob": "^12.17.0"
package/upload/index.js CHANGED
@@ -8,7 +8,7 @@ const client_1 = require("@pi-r/azure");
8
8
  const BUCKET_SESSION = new Set();
9
9
  const BUCKET_RESPONSE = {};
10
10
  const getBucketKey = (credential, bucket, acl = '') => Module.asString(credential, true) + bucket + '_' + acl;
11
- function upload(credential, service = 'azure') {
11
+ module.exports = function upload(credential, service = 'azure') {
12
12
  const blobServiceClient = client_1.createStorageClient.call(this, credential);
13
13
  return async (data, callback) => {
14
14
  var _a, _b;
@@ -30,14 +30,14 @@ function upload(credential, service = 'azure') {
30
30
  const configBucket = admin.configBucket;
31
31
  if (!BUCKET_SESSION.has(bucket)) {
32
32
  const bucketAcl = admin.publicRead ? 'blob' : admin.acl;
33
- const response = BUCKET_RESPONSE[_a = bucketKey = getBucketKey(credential, bucket, bucketAcl)] || (BUCKET_RESPONSE[_a] = client_1.createBucketV2.call(this, credential, bucket, bucketAcl, configBucket?.create));
33
+ const response = BUCKET_RESPONSE[_a = bucketKey = getBucketKey(credential, bucket, bucketAcl)] || (BUCKET_RESPONSE[_a] = client_1.createBucketV2.call(this, credential, bucket, bucketAcl, configBucket === null || configBucket === void 0 ? void 0 : configBucket.create));
34
34
  if (!await response) {
35
35
  errorResponse(null);
36
36
  return;
37
37
  }
38
38
  BUCKET_SESSION.add(bucket);
39
39
  }
40
- let retentionPolicy = configBucket?.retentionPolicy;
40
+ let retentionPolicy = configBucket === null || configBucket === void 0 ? void 0 : configBucket.retentionPolicy;
41
41
  if (retentionPolicy) {
42
42
  if (!Array.isArray(retentionPolicy)) {
43
43
  retentionPolicy = [retentionPolicy];
@@ -126,6 +126,4 @@ function upload(credential, service = 'azure') {
126
126
  });
127
127
  }
128
128
  };
129
- }
130
-
131
- module.exports = upload;
129
+ };