@pi-r/aws-v3 0.3.2 → 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/README.md +1 -1
- package/client/index.js +4 -3
- package/download/index.js +1 -6
- package/package.json +8 -8
- package/upload/index.js +3 -7
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/README.md
CHANGED
package/client/index.js
CHANGED
|
@@ -56,9 +56,10 @@ function sanitizeCredentials(credential) {
|
|
|
56
56
|
}
|
|
57
57
|
const isNoSuchBucket = (err) => err instanceof Error && err.name === 'NoSuchBucket';
|
|
58
58
|
function createStorageClient(credential, service = 'aws-v3', sdk = '@aws-sdk/client-s3') {
|
|
59
|
+
var _a;
|
|
59
60
|
try {
|
|
60
61
|
sanitizeCredentials(credential);
|
|
61
|
-
const expiration = credential.credentials
|
|
62
|
+
const expiration = (_a = credential.credentials) === null || _a === void 0 ? void 0 : _a.expiration;
|
|
62
63
|
if (expiration && !(expiration instanceof Date)) {
|
|
63
64
|
delete credential.expiration;
|
|
64
65
|
}
|
|
@@ -183,7 +184,7 @@ async function deleteObjectsV2(credential, Bucket, recursive = true, service = '
|
|
|
183
184
|
const [client, AWS] = createStorageClient.call(this, credential, service, sdk);
|
|
184
185
|
return client.send(new AWS.ListObjectsCommand({ Bucket }))
|
|
185
186
|
.then(({ Contents }) => {
|
|
186
|
-
if (Contents
|
|
187
|
+
if (Contents === null || Contents === void 0 ? void 0 : Contents.length) {
|
|
187
188
|
let Objects = Contents.map(data => ({ Key: data.Key }));
|
|
188
189
|
if (!recursive) {
|
|
189
190
|
Objects = Objects.filter(value => value.Key.indexOf('/') === -1);
|
|
@@ -219,7 +220,7 @@ async function executeBatchQuery(credential, batch, sessionKey) {
|
|
|
219
220
|
const cacheValue = { value: this.valueOfKey(credential, 'cache'), sessionKey };
|
|
220
221
|
let client;
|
|
221
222
|
const createClient = () => client || (client = createDatabaseClient.call(this, length === 1 ? credential : { ...credential }));
|
|
222
|
-
const closeClient = () => client
|
|
223
|
+
const closeClient = () => client === null || client === void 0 ? void 0 : client[0].destroy();
|
|
223
224
|
for (let i = 0; i < length; ++i) {
|
|
224
225
|
const item = batch[i];
|
|
225
226
|
const { service, table, id = '', query, partitionKey, key = partitionKey, limit = 0, update, ignoreCache } = item;
|
package/download/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
2
|
const util_1 = require("@e-mc/cloud/util");
|
|
4
3
|
const types_1 = require("@e-mc/types");
|
|
5
4
|
const Module = require("@e-mc/module");
|
|
@@ -33,9 +32,5 @@ function download(config, service = 'aws-v3', sdk = '@aws-sdk/client-s3') {
|
|
|
33
32
|
.catch(err => callback(err));
|
|
34
33
|
};
|
|
35
34
|
}
|
|
36
|
-
exports.default = download;
|
|
37
35
|
|
|
38
|
-
|
|
39
|
-
module.exports = exports.default;
|
|
40
|
-
module.exports.default = exports.default;
|
|
41
|
-
}
|
|
36
|
+
module.exports = download;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pi-r/aws-v3",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.4",
|
|
4
4
|
"description": "AWS V3 cloud functions for E-mc.",
|
|
5
5
|
"main": "client/index.js",
|
|
6
6
|
"publishConfig": {
|
|
@@ -20,12 +20,12 @@
|
|
|
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.
|
|
26
|
-
"@pi-r/aws": "^0.3.
|
|
27
|
-
"@aws-sdk/client-dynamodb": "^3.
|
|
28
|
-
"@aws-sdk/client-s3": "^3.
|
|
29
|
-
"@aws-sdk/lib-dynamodb": "^3.
|
|
23
|
+
"@e-mc/cloud": "^0.6.3",
|
|
24
|
+
"@e-mc/module": "^0.6.3",
|
|
25
|
+
"@e-mc/types": "^0.6.3",
|
|
26
|
+
"@pi-r/aws": "^0.3.4",
|
|
27
|
+
"@aws-sdk/client-dynamodb": "^3.540.0",
|
|
28
|
+
"@aws-sdk/client-s3": "^3.540.0",
|
|
29
|
+
"@aws-sdk/lib-dynamodb": "^3.540.0"
|
|
30
30
|
}
|
|
31
31
|
}
|
package/upload/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
2
|
const path = require("path");
|
|
4
3
|
const fs = require("fs");
|
|
5
4
|
const stream = require("stream");
|
|
@@ -15,6 +14,7 @@ function upload(credential, service = 'aws-v3', sdk = '@aws-sdk/client-s3') {
|
|
|
15
14
|
const [client, AWS] = client_1.createStorageClient.call(this, credential, service, sdk);
|
|
16
15
|
return async (data, callback) => {
|
|
17
16
|
var _a;
|
|
17
|
+
var _b;
|
|
18
18
|
const { bucket: Bucket, localUri } = data;
|
|
19
19
|
const { pathname = '', fileGroup, contentType, metadata, endpoint, active, publicRead, acl, admin = {}, overwrite, options } = data.upload;
|
|
20
20
|
let filename = data.upload.filename || path.basename(localUri), bucketKey;
|
|
@@ -31,7 +31,7 @@ function upload(credential, service = 'aws-v3', sdk = '@aws-sdk/client-s3') {
|
|
|
31
31
|
};
|
|
32
32
|
if (!BUCKET_SESSION.has(service + Bucket)) {
|
|
33
33
|
const bucketAcl = admin.publicRead ? 'public-read' : admin.acl;
|
|
34
|
-
const response = BUCKET_RESPONSE[
|
|
34
|
+
const response = BUCKET_RESPONSE[_b = bucketKey = (0, aws_1.getBucketKey)(credential, Bucket, bucketAcl, service, sdk)] || (BUCKET_RESPONSE[_b] = client_1.createBucketV2.call(this, credential, Bucket, bucketAcl, (_a = admin.configBucket) === null || _a === void 0 ? void 0 : _a.create, service, sdk));
|
|
35
35
|
if (!await response) {
|
|
36
36
|
errorResponse(null);
|
|
37
37
|
return;
|
|
@@ -148,9 +148,5 @@ function upload(credential, service = 'aws-v3', sdk = '@aws-sdk/client-s3') {
|
|
|
148
148
|
}
|
|
149
149
|
};
|
|
150
150
|
}
|
|
151
|
-
exports.default = upload;
|
|
152
151
|
|
|
153
|
-
|
|
154
|
-
module.exports = exports.default;
|
|
155
|
-
module.exports.default = exports.default;
|
|
156
|
-
}
|
|
152
|
+
module.exports = upload;
|