@pi-r/aws 0.3.0 → 0.3.2

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 An Pham
1
+ Copyright 2023 Studio Trigger
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,5 +1,7 @@
1
- ### @pi-r/aws
1
+ # @pi-r/aws
2
2
 
3
- ### LICENSE
3
+ PEP 402 - Forever Aina
4
+
5
+ ## LICENSE
4
6
 
5
7
  MIT
package/client/index.js CHANGED
@@ -18,15 +18,15 @@ async function setCannedAcl(S3, Bucket, ACL, service = 'aws', recursive) {
18
18
  }
19
19
  const callback = (err) => {
20
20
  if (!err) {
21
- this.formatMessage(64 /* LOG_TYPE.CLOUD */, service, ['Grant ' + ACL, Bucket], '', { ...recursive ? Cloud.LOG_CLOUD_DELAYED : Cloud.LOG_CLOUD_COMMAND });
21
+ this.formatMessage(64, service, ['Grant ' + ACL, Bucket], '', { ...recursive ? Cloud.LOG_CLOUD_DELAYED : Cloud.LOG_CLOUD_COMMAND });
22
22
  }
23
23
  else if (!recursive) {
24
24
  if (err instanceof Error && err.code === 'OperationAborted') {
25
- setTimeout(() => setCannedAcl.call(this, S3, Bucket, ACL, service, true), 60000 /* TIME.m */);
26
- this.formatMessage(64 /* LOG_TYPE.CLOUD */, service, [`Grant ${ACL} (delayed)`, Bucket], err, { ...Cloud.LOG_CLOUD_DELAYED });
25
+ setTimeout(() => setCannedAcl.call(this, S3, Bucket, ACL, service, true), 60000);
26
+ this.formatMessage(64, service, [`Grant ${ACL} (delayed)`, Bucket], err, { ...Cloud.LOG_CLOUD_DELAYED });
27
27
  }
28
28
  else {
29
- this.formatMessage(64 /* LOG_TYPE.CLOUD */, service, ['Unable to grant ' + ACL, Bucket], err, { ...Cloud.LOG_CLOUD_WARN });
29
+ this.formatMessage(64, service, ['Unable to grant ' + ACL, Bucket], err, { ...Cloud.LOG_CLOUD_WARN });
30
30
  }
31
31
  }
32
32
  };
@@ -180,7 +180,7 @@ function createBucketV2(credential, Bucket, ACL, options, service = 'aws', sdk =
180
180
  }
181
181
  return S3.createBucket(input).promise()
182
182
  .then(async () => {
183
- this.formatMessage(64 /* LOG_TYPE.CLOUD */, service, ["Bucket created" /* VAL_CLOUD.CREATE_BUCKET */, Bucket], '', { ...Cloud.LOG_CLOUD_COMMAND });
183
+ this.formatMessage(64, service, ["Bucket created", Bucket], '', { ...Cloud.LOG_CLOUD_COMMAND });
184
184
  if (ACL) {
185
185
  await setCannedAcl.call(this, S3, Bucket, ACL, service);
186
186
  }
@@ -195,7 +195,7 @@ function createBucketV2(credential, Bucket, ACL, options, service = 'aws', sdk =
195
195
  }
196
196
  return true;
197
197
  default:
198
- this.formatFail(64 /* LOG_TYPE.CLOUD */, service, ["Unable to create bucket" /* ERR_CLOUD.CREATE_BUCKET */, Bucket], err, { ...Cloud.LOG_CLOUD_FAIL });
198
+ this.formatFail(64, service, ["Unable to create bucket", Bucket], err, { ...Cloud.LOG_CLOUD_FAIL });
199
199
  return false;
200
200
  }
201
201
  });
@@ -212,12 +212,12 @@ function setBucketPolicy(credential, Bucket, options, service = 'aws', sdk = 'aw
212
212
  }
213
213
  return ('PublicAccessBlockConfiguration' in options ? S3.putPublicAccessBlock(options) : 'Policy' in options && (0, types_1.isString)(options.Policy) && !ibm ? S3.putBucketPolicy(options) : S3.putBucketAcl(options)).promise()
214
214
  .then(() => {
215
- this.formatMessage(64 /* LOG_TYPE.CLOUD */, service, ["Bucket policy configured" /* VAL_CLOUD.POLICY_BUCKET */, Bucket], '', { ...Cloud.LOG_CLOUD_COMMAND });
215
+ this.formatMessage(64, service, ["Bucket policy configured", Bucket], '', { ...Cloud.LOG_CLOUD_COMMAND });
216
216
  return true;
217
217
  })
218
218
  .catch(err => {
219
219
  if (!(0, exports.isNoSuchBucket)(err)) {
220
- this.formatFail(64 /* LOG_TYPE.CLOUD */, service, ["Unable to update bucket policy" /* ERR_CLOUD.POLICY_BUCKET */, Bucket], err, { ...Cloud.LOG_CLOUD_FAIL, fatal: false });
220
+ this.formatFail(64, service, ["Unable to update bucket policy", Bucket], err, { ...Cloud.LOG_CLOUD_FAIL, fatal: false });
221
221
  }
222
222
  return false;
223
223
  });
@@ -235,12 +235,12 @@ function setBucketWebsite(credential, Bucket, options, service = 'aws', sdk = 'a
235
235
  }
236
236
  return S3.putBucketWebsite({ Bucket, WebsiteConfiguration }).promise()
237
237
  .then(() => {
238
- this.formatMessage(64 /* LOG_TYPE.CLOUD */, service, ["Bucket configured" /* VAL_CLOUD.CONFIGURE_BUCKET */, Bucket], WebsiteConfiguration, { ...Cloud.LOG_CLOUD_COMMAND });
238
+ this.formatMessage(64, service, ["Bucket configured", Bucket], WebsiteConfiguration, { ...Cloud.LOG_CLOUD_COMMAND });
239
239
  return true;
240
240
  })
241
241
  .catch(err => {
242
242
  if (!(0, exports.isNoSuchBucket)(err)) {
243
- this.formatFail(64 /* LOG_TYPE.CLOUD */, service, ["Unable to configure bucket" /* ERR_CLOUD.CONFIGURE_BUCKET */, Bucket], err, { ...Cloud.LOG_CLOUD_FAIL, fatal: false });
243
+ this.formatFail(64, service, ["Unable to configure bucket", Bucket], err, { ...Cloud.LOG_CLOUD_FAIL, fatal: false });
244
244
  }
245
245
  return false;
246
246
  });
@@ -264,17 +264,17 @@ async function deleteObjectsV2(credential, Bucket, recursive = true, service = '
264
264
  const Deleted = data.Deleted;
265
265
  if ((0, types_1.isArray)(Deleted)) {
266
266
  const files = Deleted.length + ' files';
267
- this.formatMessage(64 /* LOG_TYPE.CLOUD */, service, ["Bucket emptied" /* VAL_CLOUD.EMPTY_BUCKET */ + ` (${recursive ? 'recursive' : files})`, Bucket], recursive ? files : '', { ...Cloud.LOG_CLOUD_COMMAND });
267
+ this.formatMessage(64, service, ["Bucket emptied" + ` (${recursive ? 'recursive' : files})`, Bucket], recursive ? files : '', { ...Cloud.LOG_CLOUD_COMMAND });
268
268
  }
269
269
  })
270
270
  .catch(err => {
271
- this.formatFail(64 /* LOG_TYPE.CLOUD */, service, ["Unable to empty bucket" /* ERR_CLOUD.DELETE_BUCKET */, Bucket], err, { ...Cloud.LOG_CLOUD_FAIL, fatal: false });
271
+ this.formatFail(64, service, ["Unable to empty bucket", Bucket], err, { ...Cloud.LOG_CLOUD_FAIL, fatal: false });
272
272
  });
273
273
  }
274
274
  })
275
275
  .catch(err => {
276
276
  if (!(0, exports.isNoSuchBucket)(err)) {
277
- this.formatFail(64 /* LOG_TYPE.CLOUD */, service, ["Unable to list bucket" /* ERR_CLOUD.LIST_BUCKET */, Bucket], err, { ...Cloud.LOG_CLOUD_FAIL, fatal: false });
277
+ this.formatFail(64, service, ["Unable to list bucket", Bucket], err, { ...Cloud.LOG_CLOUD_FAIL, fatal: false });
278
278
  }
279
279
  });
280
280
  }
@@ -297,7 +297,7 @@ async function executeBatchQuery(credential, batch, sessionKey) {
297
297
  const item = batch[i];
298
298
  const { service, table, id = '', query, partitionKey, key = partitionKey, limit = 0, update, ignoreCache } = item;
299
299
  if (!table) {
300
- throw (0, util_1.formatError)(item, "Missing database table" /* ERR_DB.TABLE */);
300
+ throw (0, util_1.formatError)(item, "Missing database table");
301
301
  }
302
302
  const renewCache = ignoreCache === 0;
303
303
  const getCache = (value) => {
@@ -342,7 +342,7 @@ async function executeBatchQuery(credential, batch, sessionKey) {
342
342
  }
343
343
  }
344
344
  else {
345
- throw (0, util_1.formatError)(item, "Missing database query" /* ERR_DB.QUERY */);
345
+ throw (0, util_1.formatError)(item, "Missing database query");
346
346
  }
347
347
  result[i] = this.setQueryResult(service, credential, queryString, rows, cacheValue);
348
348
  }
package/download/index.js CHANGED
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const types_1 = require("@e-mc/types");
4
4
  const Module = require("@e-mc/module");
5
5
  const Cloud = require("@e-mc/cloud");
6
- const client_1 = require("../client");
6
+ const client_1 = require("@pi-r/aws");
7
7
  function download(credential, service = 'aws', sdk = 'aws-sdk/clients/s3') {
8
8
  const s3 = client_1.createStorageClient.call(this, credential, service, sdk);
9
9
  return (data, callback) => {
@@ -22,10 +22,10 @@ function download(credential, service = 'aws', sdk = 'aws-sdk/clients/s3') {
22
22
  if (deleteObject) {
23
23
  s3.deleteObject((0, types_1.isPlainObject)(deleteObject) ? Object.assign(deleteObject, params) : params, error => {
24
24
  if (!error) {
25
- this.formatMessage(64 /* LOG_TYPE.CLOUD */, service, "Delete success" /* VAL_CLOUD.DELETE_FILE */, location, { ...Cloud.LOG_CLOUD_DELETE });
25
+ this.formatMessage(64, service, "Delete success", location, { ...Cloud.LOG_CLOUD_DELETE });
26
26
  }
27
27
  else {
28
- this.formatFail(64 /* LOG_TYPE.CLOUD */, service, ["Delete failed" /* ERR_CLOUD.DELETE_FAIL */, location], error, { ...Cloud.LOG_CLOUD_FAIL, fatal: !!target.active });
28
+ this.formatFail(64, service, ["Delete failed", location], error, { ...Cloud.LOG_CLOUD_FAIL, fatal: !!target.active });
29
29
  }
30
30
  });
31
31
  }
@@ -36,5 +36,9 @@ function download(credential, service = 'aws', sdk = 'aws-sdk/clients/s3') {
36
36
  });
37
37
  };
38
38
  }
39
+ exports.default = download;
39
40
 
40
- module.exports = download;
41
+ if (exports.default) {
42
+ module.exports = exports.default;
43
+ module.exports.default = exports.default;
44
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-r/aws",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "description": "AWS V2 cloud functions for E-mc.",
5
5
  "main": "client/index.js",
6
6
  "types": "client/index.d.ts",
@@ -9,7 +9,7 @@
9
9
  },
10
10
  "repository": {
11
11
  "type": "git",
12
- "url": "https://github.com/anpham6/pi-r.git",
12
+ "url": "git+https://github.com/anpham6/pi-r.git",
13
13
  "directory": "src/cloud/aws"
14
14
  },
15
15
  "keywords": [
@@ -21,9 +21,9 @@
21
21
  "license": "MIT",
22
22
  "homepage": "https://github.com/anpham6/pi-r#readme",
23
23
  "dependencies": {
24
- "@e-mc/cloud": "^0.6.0",
25
- "@e-mc/module": "^0.6.0",
26
- "@e-mc/types": "^0.6.0",
27
- "aws-sdk": "^2.1430.0"
24
+ "@e-mc/cloud": "^0.6.1",
25
+ "@e-mc/module": "^0.6.1",
26
+ "@e-mc/types": "^0.6.1",
27
+ "aws-sdk": "^2.1570.0"
28
28
  }
29
29
  }
package/upload/index.js CHANGED
@@ -6,7 +6,7 @@ const util_1 = require("@e-mc/cloud/util");
6
6
  const types_1 = require("@e-mc/types");
7
7
  const Module = require("@e-mc/module");
8
8
  const Cloud = require("@e-mc/cloud");
9
- const client_1 = require("../client");
9
+ const client_1 = require("@pi-r/aws");
10
10
  const BUCKET_SESSION = new Set();
11
11
  const BUCKET_RESPONSE = {};
12
12
  function upload(credential, service = 'aws', sdk = 'aws-sdk/clients/s3') {
@@ -56,7 +56,7 @@ function upload(credential, service = 'aws', sdk = 'aws-sdk/clients/s3') {
56
56
  });
57
57
  } while (exists && ++i);
58
58
  if (i > 0) {
59
- this.formatMessage(64 /* LOG_TYPE.CLOUD */, service, ["File renamed" /* VAL_CLOUD.RENAME_FILE */, current], filename, { ...Cloud.LOG_CLOUD_WARN });
59
+ this.formatMessage(64, service, ["File renamed", current], filename, { ...Cloud.LOG_CLOUD_WARN });
60
60
  }
61
61
  }
62
62
  if (pathname) {
@@ -113,7 +113,7 @@ function upload(credential, service = 'aws', sdk = 'aws-sdk/clients/s3') {
113
113
  s3.upload(params, (err, result) => {
114
114
  if (!err) {
115
115
  const url = endpoint ? Module.joinPath(endpoint, result.Key) : result.Location;
116
- this.formatMessage(64 /* LOG_TYPE.CLOUD */, service, "Upload success" /* VAL_CLOUD.UPLOAD_FILE */, url, { ...Cloud.LOG_CLOUD_UPLOAD });
116
+ this.formatMessage(64, service, "Upload success", url, { ...Cloud.LOG_CLOUD_UPLOAD });
117
117
  if (first) {
118
118
  cleanup();
119
119
  callback(null, url);
@@ -129,5 +129,9 @@ function upload(credential, service = 'aws', sdk = 'aws-sdk/clients/s3') {
129
129
  }
130
130
  };
131
131
  }
132
+ exports.default = upload;
132
133
 
133
- module.exports = upload;
134
+ if (exports.default) {
135
+ module.exports = exports.default;
136
+ module.exports.default = exports.default;
137
+ }