@pi-r/azure 0.12.0 → 0.12.2

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
@@ -264,7 +264,12 @@ async function executeBatchQuery(credential, batch, sessionKey) {
264
264
  const { update, options = {} } = item;
265
265
  const items = createClient(name, table).items;
266
266
  if (Array.isArray(params)) {
267
- await items.executeBulkOperations(params, options);
267
+ if (partitionKey) {
268
+ await items.batch(params, partitionKey, options);
269
+ }
270
+ else {
271
+ await items.executeBulkOperations(params, options);
272
+ }
268
273
  }
269
274
  if (update) {
270
275
  await items.upsert(update, { accessCondition: options.accessCondition, sessionToken: options.sessionToken, initialHeaders: options.initialHeaders, priorityLevel: options.priorityLevel, abortSignal: this.signal });
package/download/index.js CHANGED
@@ -14,18 +14,19 @@ function download(credential, service = "azure") {
14
14
  callback(errorValue('Missing property', !bucket ? 'Container' : 'Name'));
15
15
  return;
16
16
  }
17
- const { flags = 0 } = target;
17
+ const { encryptionKey, flags = 0 } = target;
18
18
  const containerClient = blobServiceClient.getContainerClient(bucket);
19
19
  const blobClient = containerClient.getBlockBlobClient(key);
20
+ const customerProvidedKey = encryptionKey ? { encryptionKey: encryptionKey.toString() } : target.options?.customerProvidedKey;
20
21
  const blockSize = (flags & 4) && alignSize(target.chunkSize, 1024) || 0;
21
22
  const tempDir = blockSize >= 2097152000 ? getTempDir(true, service) : null;
22
23
  let diskClient, destination;
23
24
  if (tempDir) {
24
25
  destination = path.join(tempDir, path.basename(target.filename || key));
25
- diskClient = blobClient.downloadToFile(destination, 0, undefined, { snapshot: target.versionId, abortSignal: this.signal });
26
+ diskClient = blobClient.downloadToFile(destination, 0, undefined, { snapshot: target.versionId, customerProvidedKey, abortSignal: this.signal });
26
27
  }
27
28
  else {
28
- diskClient = blobClient.downloadToBuffer(0, 0, { ...target.options, blockSize, concurrency: blockSize > 0 ? target.chunkLimit : undefined, abortSignal: this.signal });
29
+ diskClient = blobClient.downloadToBuffer(0, 0, { ...target.options, customerProvidedKey, blockSize, concurrency: blockSize > 0 ? target.chunkLimit : undefined, abortSignal: this.signal });
29
30
  }
30
31
  diskClient
31
32
  .then(async (value) => {
package/package.json CHANGED
@@ -1,11 +1,8 @@
1
1
  {
2
2
  "name": "@pi-r/azure",
3
- "version": "0.12.0",
3
+ "version": "0.12.2",
4
4
  "description": "Azure cloud functions for E-mc.",
5
5
  "main": "client/index.js",
6
- "publishConfig": {
7
- "access": "public"
8
- },
9
6
  "repository": {
10
7
  "type": "git",
11
8
  "url": "git+https://github.com/anpham6/pi-r.git",
@@ -19,11 +16,11 @@
19
16
  "license": "MIT",
20
17
  "homepage": "https://github.com/anpham6/pi-r#readme",
21
18
  "dependencies": {
22
- "@e-mc/cloud": "^0.14.0",
23
- "@e-mc/module": "^0.14.0",
24
- "@e-mc/types": "^0.14.0",
19
+ "@e-mc/cloud": "^0.14.3",
20
+ "@e-mc/module": "^0.14.3",
21
+ "@e-mc/types": "^0.14.3",
25
22
  "@azure/cosmos": "^4.9.3",
26
23
  "@azure/identity": "*",
27
- "@azure/storage-blob": "^12.31.0"
24
+ "@azure/storage-blob": "^12.32.0"
28
25
  }
29
26
  }
package/upload/index.js CHANGED
@@ -16,6 +16,7 @@ function upload(credential, service = "azure") {
16
16
  const { bucket, localUri } = data;
17
17
  const { pathname, flags = 0, fileGroup, descendantsGroup, contentType, metadata, tags, endpoint, admin = {}, overwrite, options } = data.upload;
18
18
  const containerClient = blobServiceClient.getContainerClient(bucket);
19
+ const encryptionKey = data.upload.encryptionKey?.toString();
19
20
  let filename = data.upload.filename || path.basename(localUri), bucketKey;
20
21
  const complete = (err, url) => {
21
22
  BUCKET_SESSION.delete(bucket);
@@ -82,7 +83,7 @@ function upload(credential, service = "azure") {
82
83
  return;
83
84
  }
84
85
  }
85
- const chunkSize = flags & 4 ? alignSize(data.upload.chunkSize, 1024) : 0;
86
+ const chunkSize = (flags & 4) && !encryptionKey ? alignSize(data.upload.chunkSize, 1024) : 0;
86
87
  const maxSingleShotSize = Math.max(chunkSize, 8388608);
87
88
  const Key = [filename];
88
89
  const Body = [data.buffer];
@@ -150,6 +151,9 @@ function upload(credential, service = "azure") {
150
151
  else {
151
152
  headers.blobContentType = ContentType[i];
152
153
  }
154
+ if (encryptionKey) {
155
+ params.customerProvidedKey = { encryptionKey };
156
+ }
153
157
  const blobClient = containerClient.getBlockBlobClient(blobName);
154
158
  let uploadClient;
155
159
  if (Stream[i]) {