@pi-r/azure 0.3.3 → 0.3.4
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/LICENSE +1 -1
- package/client/index.js +4 -3
- package/package.json +4 -4
- package/upload/index.js +4 -3
package/LICENSE
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Copyright
|
|
1
|
+
Copyright 2024 An Pham
|
|
2
2
|
|
|
3
3
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
4
|
|
package/client/index.js
CHANGED
|
@@ -22,14 +22,15 @@ function validateDatabase(credential, data) {
|
|
|
22
22
|
}
|
|
23
23
|
exports.validateDatabase = validateDatabase;
|
|
24
24
|
function createStorageClient(credential) {
|
|
25
|
+
var _a, _b;
|
|
25
26
|
const { BlobServiceClient, StorageSharedKeyCredential } = storage;
|
|
26
27
|
const { accountName, accountKey, connectionString, sharedAccessSignature } = credential;
|
|
27
28
|
if (connectionString) {
|
|
28
|
-
credential.accountName || (credential.accountName = /AccountName=([^;]+);/.exec(connectionString)
|
|
29
|
+
credential.accountName || (credential.accountName = (_a = /AccountName=([^;]+);/.exec(connectionString)) === null || _a === void 0 ? void 0 : _a[1]);
|
|
29
30
|
return BlobServiceClient.fromConnectionString(connectionString);
|
|
30
31
|
}
|
|
31
32
|
if (sharedAccessSignature) {
|
|
32
|
-
credential.accountName || (credential.accountName = /^https:\/\/([a-z\d]+)\./.exec(sharedAccessSignature)
|
|
33
|
+
credential.accountName || (credential.accountName = (_b = /^https:\/\/([a-z\d]+)\./.exec(sharedAccessSignature)) === null || _b === void 0 ? void 0 : _b[1]);
|
|
33
34
|
return new BlobServiceClient(sharedAccessSignature);
|
|
34
35
|
}
|
|
35
36
|
let azureCredential;
|
|
@@ -160,7 +161,7 @@ async function executeBatchQuery(credential, batch, sessionKey) {
|
|
|
160
161
|
client || (client = createDatabaseClient.call(this, length === 1 ? credential : { ...credential }));
|
|
161
162
|
return client.database(name).container(table);
|
|
162
163
|
};
|
|
163
|
-
const closeClient = () => client
|
|
164
|
+
const closeClient = () => client === null || client === void 0 ? void 0 : client.dispose();
|
|
164
165
|
for (let i = 0; i < length; ++i) {
|
|
165
166
|
const item = batch[i];
|
|
166
167
|
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.3.
|
|
3
|
+
"version": "0.3.4",
|
|
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.6.
|
|
24
|
-
"@e-mc/module": "^0.6.
|
|
25
|
-
"@e-mc/types": "^0.6.
|
|
23
|
+
"@e-mc/cloud": "^0.6.3",
|
|
24
|
+
"@e-mc/module": "^0.6.3",
|
|
25
|
+
"@e-mc/types": "^0.6.3",
|
|
26
26
|
"@azure/cosmos": "^3.17.3",
|
|
27
27
|
"@azure/identity": "^3.4.2",
|
|
28
28
|
"@azure/storage-blob": "^12.17.0"
|
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;
|