@pi-r/azure 0.10.1 → 0.10.3
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 +18 -8
- package/download/index.js +5 -13
- package/package.json +6 -6
package/client/index.js
CHANGED
|
@@ -170,6 +170,7 @@ async function deleteObjectsV3(credential, bucket, options = {}, service = 'azur
|
|
|
170
170
|
recursive = options.recursive;
|
|
171
171
|
delete options.recursive;
|
|
172
172
|
}
|
|
173
|
+
options.abortSignal = this.signal;
|
|
173
174
|
options.includeUncommitedBlobs ??= true;
|
|
174
175
|
const tasks = [];
|
|
175
176
|
let fileCount = 0;
|
|
@@ -245,13 +246,20 @@ async function executeBatchQuery(credential, batch, sessionKey) {
|
|
|
245
246
|
}
|
|
246
247
|
else {
|
|
247
248
|
const { update, options = {} } = item;
|
|
248
|
-
|
|
249
|
-
|
|
249
|
+
const items = createClient(name, table).items;
|
|
250
|
+
if (Array.isArray(params)) {
|
|
251
|
+
await items.executeBulkOperations(params, options);
|
|
250
252
|
}
|
|
251
|
-
if (
|
|
252
|
-
options.
|
|
253
|
+
if (update) {
|
|
254
|
+
await items.upsert(update, { accessCondition: options.accessCondition, sessionToken: options.sessionToken, initialHeaders: options.initialHeaders, priorityLevel: options.priorityLevel, abortSignal: this.signal });
|
|
253
255
|
}
|
|
254
256
|
if (query || Object.keys(options).length > 0) {
|
|
257
|
+
if (partitionKey) {
|
|
258
|
+
options.partitionKey = partitionKey;
|
|
259
|
+
}
|
|
260
|
+
if (limit > 0) {
|
|
261
|
+
options.maxItemCount = limit;
|
|
262
|
+
}
|
|
255
263
|
if (queryString) {
|
|
256
264
|
queryString += (query ? Cloud.asString(query, true) : '') + Cloud.asString(options, true);
|
|
257
265
|
if (!update && (rows = this.getCacheResult(service, credential, queryString, cacheValue, ignoreCache))) {
|
|
@@ -259,11 +267,13 @@ async function executeBatchQuery(credential, batch, sessionKey) {
|
|
|
259
267
|
continue;
|
|
260
268
|
}
|
|
261
269
|
}
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
270
|
+
if (query) {
|
|
271
|
+
const iter = items.query(query, attachSignal(options));
|
|
272
|
+
({ resources: rows } = await (options.maxItemCount ? iter.fetchNext() : iter.fetchAll()));
|
|
273
|
+
}
|
|
274
|
+
else {
|
|
275
|
+
({ resources: rows } = await items.readAll(attachSignal(options)).fetchAll());
|
|
265
276
|
}
|
|
266
|
-
({ resources: rows } = await (query ? items.query(query, attachSignal(options)).fetchAll() : items.readAll(attachSignal(options)).fetchAll()));
|
|
267
277
|
}
|
|
268
278
|
else {
|
|
269
279
|
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 (
|
|
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,11 +27,11 @@ function download(credential, service = 'azure') {
|
|
|
35
27
|
}
|
|
36
28
|
diskClient
|
|
37
29
|
.then((value) => {
|
|
38
|
-
|
|
30
|
+
callback(null, destination || value);
|
|
39
31
|
const deleteObject = target.deleteObject;
|
|
40
32
|
if (deleteObject) {
|
|
41
33
|
const location = Cloud.joinPath(Bucket, Key);
|
|
42
|
-
containerClient.delete((0, types_1.isPlainObject)(deleteObject) ?
|
|
34
|
+
containerClient.delete((0, types_1.isPlainObject)(deleteObject) ? { ...deleteObject, abortSignal: this.signal } : { abortSignal: this.signal })
|
|
43
35
|
.then(() => {
|
|
44
36
|
this.formatMessage(64, service, "Delete success", location, { ...Cloud.LOG_CLOUD_DELETE });
|
|
45
37
|
})
|
|
@@ -51,7 +43,7 @@ function download(credential, service = 'azure') {
|
|
|
51
43
|
});
|
|
52
44
|
}
|
|
53
45
|
})
|
|
54
|
-
.catch(
|
|
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.
|
|
3
|
+
"version": "0.10.3",
|
|
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.
|
|
23
|
-
"@e-mc/module": "^0.12.
|
|
24
|
-
"@e-mc/types": "^0.12.
|
|
25
|
-
"@azure/cosmos": "^4.
|
|
22
|
+
"@e-mc/cloud": "^0.12.7",
|
|
23
|
+
"@e-mc/module": "^0.12.7",
|
|
24
|
+
"@e-mc/types": "^0.12.7",
|
|
25
|
+
"@azure/cosmos": "^4.5.1",
|
|
26
26
|
"@azure/identity": "*",
|
|
27
|
-
"@azure/storage-blob": "^12.
|
|
27
|
+
"@azure/storage-blob": "^12.28.0"
|
|
28
28
|
}
|
|
29
29
|
}
|