@pi-r/azure 0.10.1 → 0.10.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
@@ -245,13 +245,20 @@ async function executeBatchQuery(credential, batch, sessionKey) {
245
245
  }
246
246
  else {
247
247
  const { update, options = {} } = item;
248
- if (partitionKey) {
249
- options.partitionKey = partitionKey;
248
+ const items = createClient(name, table).items;
249
+ if (Array.isArray(params)) {
250
+ await items.executeBulkOperations(params, options);
250
251
  }
251
- if (limit > 0) {
252
- options.maxItemCount = limit;
252
+ if (update) {
253
+ await items.upsert(update, { accessCondition: options.accessCondition, sessionToken: options.sessionToken, initialHeaders: options.initialHeaders, priorityLevel: options.priorityLevel, abortSignal: this.signal });
253
254
  }
254
255
  if (query || Object.keys(options).length > 0) {
256
+ if (partitionKey) {
257
+ options.partitionKey = partitionKey;
258
+ }
259
+ if (limit > 0) {
260
+ options.maxItemCount = limit;
261
+ }
255
262
  if (queryString) {
256
263
  queryString += (query ? Cloud.asString(query, true) : '') + Cloud.asString(options, true);
257
264
  if (!update && (rows = this.getCacheResult(service, credential, queryString, cacheValue, ignoreCache))) {
@@ -259,11 +266,13 @@ async function executeBatchQuery(credential, batch, sessionKey) {
259
266
  continue;
260
267
  }
261
268
  }
262
- const items = createClient(name, table).items;
263
- if (update) {
264
- await items.upsert(update, { accessCondition: options.accessCondition, sessionToken: options.sessionToken, initialHeaders: options.initialHeaders, priorityLevel: options.priorityLevel, abortSignal: this.signal });
269
+ if (query) {
270
+ const iter = items.query(query, attachSignal(options));
271
+ ({ resources: rows } = await (options.maxItemCount ? iter.fetchNext() : iter.fetchAll()));
272
+ }
273
+ else {
274
+ ({ resources: rows } = await items.readAll(attachSignal(options)).fetchAll());
265
275
  }
266
- ({ resources: rows } = await (query ? items.query(query, attachSignal(options)).fetchAll() : items.readAll(attachSignal(options)).fetchAll()));
267
276
  }
268
277
  else {
269
278
  closeClient();
package/download/index.js CHANGED
@@ -12,21 +12,13 @@ function download(credential, service = 'azure') {
12
12
  callback((0, types_1.errorValue)('Missing property', !Bucket ? 'Container' : 'Name'));
13
13
  return;
14
14
  }
15
- let tempDir;
16
- const downloadResponse = (err, url) => {
17
- callback(err, url);
18
- if (tempDir) {
19
- setImmediate(() => {
20
- Cloud.removeDir(tempDir);
21
- });
22
- }
23
- };
24
15
  const { flags = 0 } = target;
25
16
  const containerClient = blobServiceClient.getContainerClient(Bucket);
26
17
  const blobClient = containerClient.getBlockBlobClient(Key);
27
18
  const blockSize = (flags & 4) && (0, types_1.alignSize)(target.chunkSize, 1024) || 0;
19
+ const tempDir = blockSize >= 2097152000 ? (0, types_1.getTempDir)(true, service) : null;
28
20
  let diskClient, destination;
29
- if (blockSize >= 2097152000 && (tempDir = this.getTempDir({ uuidDir: true }))) {
21
+ if (tempDir) {
30
22
  destination = path.join(tempDir, path.basename(target.filename || Key));
31
23
  diskClient = blobClient.downloadToFile(destination, 0, undefined, { snapshot: target.versionId, abortSignal: this.signal });
32
24
  }
@@ -35,7 +27,7 @@ function download(credential, service = 'azure') {
35
27
  }
36
28
  diskClient
37
29
  .then((value) => {
38
- downloadResponse(null, destination || value);
30
+ callback(null, destination || value);
39
31
  const deleteObject = target.deleteObject;
40
32
  if (deleteObject) {
41
33
  const location = Cloud.joinPath(Bucket, Key);
@@ -51,7 +43,7 @@ function download(credential, service = 'azure') {
51
43
  });
52
44
  }
53
45
  })
54
- .catch(downloadResponse);
46
+ .catch(callback);
55
47
  };
56
48
  }
57
49
  module.exports = download;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-r/azure",
3
- "version": "0.10.1",
3
+ "version": "0.10.2",
4
4
  "description": "Azure cloud functions for E-mc.",
5
5
  "main": "client/index.js",
6
6
  "publishConfig": {
@@ -19,11 +19,11 @@
19
19
  "license": "MIT",
20
20
  "homepage": "https://github.com/anpham6/pi-r#readme",
21
21
  "dependencies": {
22
- "@e-mc/cloud": "^0.12.3",
23
- "@e-mc/module": "^0.12.3",
24
- "@e-mc/types": "^0.12.3",
25
- "@azure/cosmos": "^4.3.0",
22
+ "@e-mc/cloud": "^0.12.5",
23
+ "@e-mc/module": "^0.12.5",
24
+ "@e-mc/types": "^0.12.5",
25
+ "@azure/cosmos": "^4.5.0",
26
26
  "@azure/identity": "*",
27
- "@azure/storage-blob": "^12.27.0"
27
+ "@azure/storage-blob": "^12.28.0"
28
28
  }
29
29
  }