@pi-r/azure 0.2.10 → 0.2.12
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 +4 -3
- package/package.json +5 -5
- package/upload/index.js +4 -3
package/client/index.js
CHANGED
|
@@ -19,16 +19,17 @@ function validateDatabase(credential, data) {
|
|
|
19
19
|
}
|
|
20
20
|
exports.validateDatabase = validateDatabase;
|
|
21
21
|
function createStorageClient(credential) {
|
|
22
|
+
var _a, _b;
|
|
22
23
|
let packageName = '';
|
|
23
24
|
try {
|
|
24
25
|
const { BlobServiceClient, StorageSharedKeyCredential } = require(packageName = '@azure/storage-blob');
|
|
25
26
|
const { accountName, accountKey, connectionString, sharedAccessSignature } = credential;
|
|
26
27
|
if (connectionString) {
|
|
27
|
-
credential.accountName || (credential.accountName = /AccountName=([^;]+);/.exec(connectionString)
|
|
28
|
+
credential.accountName || (credential.accountName = (_a = /AccountName=([^;]+);/.exec(connectionString)) === null || _a === void 0 ? void 0 : _a[1]);
|
|
28
29
|
return BlobServiceClient.fromConnectionString(connectionString);
|
|
29
30
|
}
|
|
30
31
|
if (sharedAccessSignature) {
|
|
31
|
-
credential.accountName || (credential.accountName = /^https:\/\/([a-z\d]+)\./.exec(sharedAccessSignature)
|
|
32
|
+
credential.accountName || (credential.accountName = (_b = /^https:\/\/([a-z\d]+)\./.exec(sharedAccessSignature)) === null || _b === void 0 ? void 0 : _b[1]);
|
|
32
33
|
return new BlobServiceClient(sharedAccessSignature);
|
|
33
34
|
}
|
|
34
35
|
let azureCredential;
|
|
@@ -170,7 +171,7 @@ async function executeBatchQuery(credential, batch, sessionKey) {
|
|
|
170
171
|
client || (client = createDatabaseClient.call(this, length === 1 ? credential : { ...credential }));
|
|
171
172
|
return client.database(name).container(table);
|
|
172
173
|
};
|
|
173
|
-
const closeClient = () => client
|
|
174
|
+
const closeClient = () => client === null || client === void 0 ? void 0 : client.dispose();
|
|
174
175
|
for (let i = 0; i < length; ++i) {
|
|
175
176
|
const item = batch[i];
|
|
176
177
|
const { service, name, table, id, query, storedProcedureId, partitionKey, params, limit = 0, update, ignoreCache } = item;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pi-r/azure",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.12",
|
|
4
4
|
"description": "Azure cloud functions for E-mc.",
|
|
5
5
|
"main": "client/index.js",
|
|
6
6
|
"publishConfig": {
|
|
@@ -20,11 +20,11 @@
|
|
|
20
20
|
"license": "MIT",
|
|
21
21
|
"homepage": "https://github.com/anpham6/pi-r#readme",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@e-mc/cloud": "^0.5.
|
|
24
|
-
"@e-mc/module": "^0.5.
|
|
25
|
-
"@e-mc/types": "^0.5.
|
|
23
|
+
"@e-mc/cloud": "^0.5.10",
|
|
24
|
+
"@e-mc/module": "^0.5.10",
|
|
25
|
+
"@e-mc/types": "^0.5.10",
|
|
26
26
|
"@azure/cosmos": "^3.17.3",
|
|
27
27
|
"@azure/identity": "^3.4.2",
|
|
28
|
-
"@azure/storage-blob": "^12.
|
|
28
|
+
"@azure/storage-blob": "^12.23.0"
|
|
29
29
|
}
|
|
30
30
|
}
|
package/upload/index.js
CHANGED
|
@@ -12,7 +12,8 @@ const getBucketKey = (credential, bucket, acl = '') => Module.asString(credentia
|
|
|
12
12
|
function upload(credential, service = 'azure') {
|
|
13
13
|
const blobServiceClient = client_1.createStorageClient.call(this, credential);
|
|
14
14
|
return async (data, callback) => {
|
|
15
|
-
var _a
|
|
15
|
+
var _a;
|
|
16
|
+
var _b, _c;
|
|
16
17
|
const { bucket, localUri } = data;
|
|
17
18
|
const { pathname = '', fileGroup, contentType, metadata, endpoint, admin = {}, overwrite, options } = data.upload;
|
|
18
19
|
const containerClient = blobServiceClient.getContainerClient(bucket);
|
|
@@ -29,7 +30,7 @@ function upload(credential, service = 'azure') {
|
|
|
29
30
|
};
|
|
30
31
|
if (!BUCKET_SESSION.has(bucket)) {
|
|
31
32
|
const bucketAcl = admin.publicRead ? 'blob' : admin.acl;
|
|
32
|
-
const response = BUCKET_RESPONSE[
|
|
33
|
+
const response = BUCKET_RESPONSE[_b = bucketKey = getBucketKey(credential, bucket, bucketAcl)] || (BUCKET_RESPONSE[_b] = client_1.createBucketV2.call(this, credential, bucket, bucketAcl, (_a = admin.configBucket) === null || _a === void 0 ? void 0 : _a.create));
|
|
33
34
|
if (!await response) {
|
|
34
35
|
errorResponse(null);
|
|
35
36
|
return;
|
|
@@ -93,7 +94,7 @@ function upload(credential, service = 'azure') {
|
|
|
93
94
|
if (first && metadata) {
|
|
94
95
|
params.metadata = metadata;
|
|
95
96
|
}
|
|
96
|
-
(
|
|
97
|
+
(_c = (params.blobHTTPHeaders || (params.blobHTTPHeaders = {}))).blobContentType || (_c.blobContentType = ContentType[i]);
|
|
97
98
|
containerClient.getBlockBlobClient(blobName).upload(Body[i], Body[i].byteLength, params)
|
|
98
99
|
.then(result => {
|
|
99
100
|
let requestUrl = result._response.request.url;
|