@pi-r/aws-v3 0.6.5 → 0.6.7
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 +2 -3
- package/download/index.js +2 -4
- package/package.json +9 -9
- package/upload/index.js +5 -7
package/client/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
2
|
exports.executeBatchQuery = exports.executeQuery = exports.deleteObjectsV2 = exports.deleteObjects = exports.setBucketWebsite = exports.setBucketPolicy = exports.createBucketV2 = exports.createBucket = exports.validateDatabase = exports.validateStorage = exports.createDatabaseClient = exports.createStorageClient = void 0;
|
|
4
3
|
const Lib = require("@aws-sdk/lib-dynamodb");
|
|
5
4
|
const Client = require("@aws-sdk/client-dynamodb");
|
|
@@ -247,7 +246,7 @@ async function deleteObjectsV2(credential, Bucket, recursive = true, service = '
|
|
|
247
246
|
const [client, AWS] = createStorageClient.call(this, credential, service, sdk);
|
|
248
247
|
return client.send(new AWS.ListObjectsCommand({ Bucket }))
|
|
249
248
|
.then(async ({ Contents }) => {
|
|
250
|
-
if (Contents
|
|
249
|
+
if (Contents === null || Contents === void 0 ? void 0 : Contents.length) {
|
|
251
250
|
let Objects = Contents.map(data => ({ Key: data.Key }));
|
|
252
251
|
if (!recursive) {
|
|
253
252
|
Objects = Objects.filter(value => !value.Key.includes('/'));
|
|
@@ -284,7 +283,7 @@ async function executeBatchQuery(credential, batch, sessionKey) {
|
|
|
284
283
|
const cacheValue = { value: this.valueOfKey(credential, 'cache'), sessionKey };
|
|
285
284
|
let client;
|
|
286
285
|
const createClient = () => client || (client = createDatabaseClient.call(this, credential));
|
|
287
|
-
const closeClient = () => client
|
|
286
|
+
const closeClient = () => client === null || client === void 0 ? void 0 : client[0].destroy();
|
|
288
287
|
(0, aws_1.setDatabaseEndpoint)(credential);
|
|
289
288
|
for (let i = 0; i < length; ++i) {
|
|
290
289
|
const item = batch[i];
|
package/download/index.js
CHANGED
|
@@ -4,7 +4,7 @@ const types_1 = require("@e-mc/types");
|
|
|
4
4
|
const Module = require("@e-mc/module");
|
|
5
5
|
const Cloud = require("@e-mc/cloud");
|
|
6
6
|
const client_1 = require("@pi-r/aws-v3");
|
|
7
|
-
function download(config, service = 'aws-v3', sdk = '@aws-sdk/client-s3') {
|
|
7
|
+
module.exports = function download(config, service = 'aws-v3', sdk = '@aws-sdk/client-s3') {
|
|
8
8
|
const [client, AWS] = client_1.createStorageClient.call(this, config, service, sdk);
|
|
9
9
|
return (data, callback) => {
|
|
10
10
|
const { bucket: Bucket, download: target } = data;
|
|
@@ -30,6 +30,4 @@ function download(config, service = 'aws-v3', sdk = '@aws-sdk/client-s3') {
|
|
|
30
30
|
})
|
|
31
31
|
.catch(err => callback(err));
|
|
32
32
|
};
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
module.exports = download;
|
|
33
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pi-r/aws-v3",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.7",
|
|
4
4
|
"description": "AWS V3 cloud functions for E-mc.",
|
|
5
5
|
"main": "client/index.js",
|
|
6
6
|
"publishConfig": {
|
|
@@ -20,13 +20,13 @@
|
|
|
20
20
|
"license": "MIT",
|
|
21
21
|
"homepage": "https://github.com/anpham6/pi-r#readme",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@e-mc/cloud": "^0.8.
|
|
24
|
-
"@e-mc/module": "^0.8.
|
|
25
|
-
"@e-mc/types": "^0.8.
|
|
26
|
-
"@pi-r/aws": "^0.6.
|
|
27
|
-
"@aws-sdk/client-dynamodb": "^3.
|
|
28
|
-
"@aws-sdk/client-s3": "^3.
|
|
29
|
-
"@aws-sdk/credential-providers": "^3.
|
|
30
|
-
"@aws-sdk/lib-dynamodb": "^3.
|
|
23
|
+
"@e-mc/cloud": "^0.8.8",
|
|
24
|
+
"@e-mc/module": "^0.8.8",
|
|
25
|
+
"@e-mc/types": "^0.8.8",
|
|
26
|
+
"@pi-r/aws": "^0.6.7",
|
|
27
|
+
"@aws-sdk/client-dynamodb": "^3.540.0",
|
|
28
|
+
"@aws-sdk/client-s3": "^3.540.0",
|
|
29
|
+
"@aws-sdk/credential-providers": "^3.540.0",
|
|
30
|
+
"@aws-sdk/lib-dynamodb": "^3.540.0"
|
|
31
31
|
}
|
|
32
32
|
}
|
package/upload/index.js
CHANGED
|
@@ -9,7 +9,7 @@ const Cloud = require("@e-mc/cloud");
|
|
|
9
9
|
const client_1 = require("@pi-r/aws-v3");
|
|
10
10
|
const BUCKET_SESSION = new Set();
|
|
11
11
|
const BUCKET_RESPONSE = {};
|
|
12
|
-
function upload(credential, service = 'aws-v3', sdk = '@aws-sdk/client-s3') {
|
|
12
|
+
module.exports = function upload(credential, service = 'aws-v3', sdk = '@aws-sdk/client-s3') {
|
|
13
13
|
const [client, AWS] = client_1.createStorageClient.call(this, credential, service, sdk);
|
|
14
14
|
return async (data, callback) => {
|
|
15
15
|
var _a;
|
|
@@ -31,16 +31,16 @@ function upload(credential, service = 'aws-v3', sdk = '@aws-sdk/client-s3') {
|
|
|
31
31
|
const configBucket = admin.configBucket;
|
|
32
32
|
if (!BUCKET_SESSION.has(service + Bucket)) {
|
|
33
33
|
const bucketAcl = admin.publicRead ? 'public-read' : admin.acl;
|
|
34
|
-
const response = BUCKET_RESPONSE[_a = bucketKey = (0, aws_1.getBucketKey)(credential, Bucket, bucketAcl, service, sdk)] || (BUCKET_RESPONSE[_a] = client_1.createBucketV2.call(this, credential, Bucket, bucketAcl, configBucket
|
|
34
|
+
const response = BUCKET_RESPONSE[_a = bucketKey = (0, aws_1.getBucketKey)(credential, Bucket, bucketAcl, service, sdk)] || (BUCKET_RESPONSE[_a] = client_1.createBucketV2.call(this, credential, Bucket, bucketAcl, configBucket === null || configBucket === void 0 ? void 0 : configBucket.create, service, sdk));
|
|
35
35
|
if (!await response) {
|
|
36
36
|
errorResponse(null);
|
|
37
37
|
return;
|
|
38
38
|
}
|
|
39
39
|
BUCKET_SESSION.add(service + Bucket);
|
|
40
40
|
}
|
|
41
|
-
const DefaultRetention = configBucket
|
|
41
|
+
const DefaultRetention = configBucket === null || configBucket === void 0 ? void 0 : configBucket.retentionPolicy;
|
|
42
42
|
if ((0, types_1.isPlainObject)(DefaultRetention)) {
|
|
43
|
-
client.send(new AWS.PutObjectLockConfigurationCommand({ Bucket, ObjectLockConfiguration: { ObjectLockEnabled: 'Enabled', Rule: { DefaultRetention } }, ExpectedBucketOwner: options
|
|
43
|
+
client.send(new AWS.PutObjectLockConfigurationCommand({ Bucket, ObjectLockConfiguration: { ObjectLockEnabled: 'Enabled', Rule: { DefaultRetention } }, ExpectedBucketOwner: options === null || options === void 0 ? void 0 : options.ExpectedBucketOwner, RequestPayer: options === null || options === void 0 ? void 0 : options.RequestPayer }))
|
|
44
44
|
.then(() => {
|
|
45
45
|
aws_1.writeMessageDefaultRetention.call(this, Bucket, DefaultRetention, service);
|
|
46
46
|
})
|
|
@@ -175,6 +175,4 @@ function upload(credential, service = 'aws-v3', sdk = '@aws-sdk/client-s3') {
|
|
|
175
175
|
});
|
|
176
176
|
}
|
|
177
177
|
};
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
module.exports = upload;
|
|
178
|
+
};
|