@pi-r/aws-v3 0.5.2 → 0.5.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 CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2023 Wit Studio
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
@@ -1,6 +1,6 @@
1
1
  # @pi-r/aws-v3
2
2
 
3
- PEP 402 - Forever Vivy
3
+ PEP 402 - Forever
4
4
 
5
5
  ## LICENSE
6
6
 
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?.expiration;
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?.length) {
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?.[0].destroy();
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");
@@ -32,9 +31,5 @@ function download(config, service = 'aws-v3', sdk = '@aws-sdk/client-s3') {
32
31
  .catch(err => callback(err));
33
32
  };
34
33
  }
35
- exports.default = download;
36
34
 
37
- if (exports.default) {
38
- module.exports = exports.default;
39
- module.exports.default = exports.default;
40
- }
35
+ module.exports = download;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-r/aws-v3",
3
- "version": "0.5.2",
3
+ "version": "0.5.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.7.2",
24
- "@e-mc/module": "^0.7.2",
25
- "@e-mc/types": "^0.7.2",
26
- "@pi-r/aws": "^0.5.2",
27
- "@aws-sdk/client-dynamodb": "^3.525.0",
28
- "@aws-sdk/client-s3": "^3.525.0",
29
- "@aws-sdk/lib-dynamodb": "^3.525.0"
23
+ "@e-mc/cloud": "^0.7.5",
24
+ "@e-mc/module": "^0.7.5",
25
+ "@e-mc/types": "^0.7.5",
26
+ "@pi-r/aws": "^0.5.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");
@@ -33,16 +32,16 @@ function upload(credential, service = 'aws-v3', sdk = '@aws-sdk/client-s3') {
33
32
  const configBucket = admin.configBucket;
34
33
  if (!BUCKET_SESSION.has(service + Bucket)) {
35
34
  const bucketAcl = admin.publicRead ? 'public-read' : admin.acl;
36
- 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?.create, service, sdk));
35
+ 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));
37
36
  if (!await response) {
38
37
  errorResponse(null);
39
38
  return;
40
39
  }
41
40
  BUCKET_SESSION.add(service + Bucket);
42
41
  }
43
- const DefaultRetention = configBucket?.retentionPolicy;
42
+ const DefaultRetention = configBucket === null || configBucket === void 0 ? void 0 : configBucket.retentionPolicy;
44
43
  if ((0, types_1.isPlainObject)(DefaultRetention)) {
45
- client.send(new AWS.PutObjectLockConfigurationCommand({ Bucket, ObjectLockConfiguration: { ObjectLockEnabled: 'Enabled', Rule: { DefaultRetention } }, ExpectedBucketOwner: options?.ExpectedBucketOwner, RequestPayer: options?.RequestPayer }))
44
+ 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 }))
46
45
  .then(() => {
47
46
  aws_1.writeMessageDefaultRetention.call(this, Bucket, DefaultRetention, service);
48
47
  })
@@ -181,9 +180,5 @@ function upload(credential, service = 'aws-v3', sdk = '@aws-sdk/client-s3') {
181
180
  }
182
181
  };
183
182
  }
184
- exports.default = upload;
185
183
 
186
- if (exports.default) {
187
- module.exports = exports.default;
188
- module.exports.default = exports.default;
189
- }
184
+ module.exports = upload;