@8ms/helpers 1.1.8 → 1.1.11

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.
Files changed (37) hide show
  1. package/dist/Class/BaseClass.d.ts +16 -4
  2. package/dist/Class/BaseClass.js +16 -37
  3. package/dist/aws/s3/deleteFile.d.ts +2 -2
  4. package/dist/aws/s3/deleteFile.js +2 -2
  5. package/dist/aws/s3/deleteFiles.d.ts +2 -2
  6. package/dist/aws/s3/deleteFiles.js +3 -3
  7. package/dist/aws/s3/{deleteDirectory.d.ts → deleteFolder.d.ts} +2 -2
  8. package/dist/aws/s3/{deleteDirectory.js → deleteFolder.js} +3 -3
  9. package/dist/aws/s3/getPresignedPost.d.ts +2 -2
  10. package/dist/aws/s3/getPresignedPost.js +2 -2
  11. package/dist/aws/s3/getSignedUrl.d.ts +2 -2
  12. package/dist/aws/s3/getSignedUrl.js +2 -2
  13. package/dist/aws/s3/index.d.ts +4 -5
  14. package/dist/aws/s3/index.js +3 -3
  15. package/dist/aws/s3/readBuffer.d.ts +6 -3
  16. package/dist/aws/s3/readBuffer.js +2 -2
  17. package/dist/aws/s3/readFile.d.ts +21 -3
  18. package/dist/aws/s3/readFile.js +2 -2
  19. package/dist/aws/s3/writeFile.d.ts +3 -3
  20. package/dist/aws/s3/writeFile.js +3 -3
  21. package/dist/aws/s3/writeGlueJsonFile.d.ts +3 -3
  22. package/dist/aws/s3/writeGlueJsonFile.js +3 -3
  23. package/dist/aws/s3/writePresignedPost.d.ts +2 -2
  24. package/dist/aws/s3/writePresignedPost.js +2 -2
  25. package/dist/aws/s3cache/getCache.js +1 -1
  26. package/dist/aws/s3cache/saveCache.js +1 -1
  27. package/dist/aws/s3cache/updateCache.js +1 -1
  28. package/dist/aws/ses/SimpleEmail.js +9 -9
  29. package/dist/boolean/getBoolean.d.ts +3 -1
  30. package/dist/boolean/getBoolean.js +2 -1
  31. package/dist/crypto/getDecrypt.d.ts +3 -3
  32. package/dist/crypto/getDecrypt.js +2 -2
  33. package/dist/crypto/getEncrypt.d.ts +3 -3
  34. package/dist/crypto/getEncrypt.js +2 -2
  35. package/package.json +1 -1
  36. package/dist/aws/s3/types.d.ts +0 -22
  37. package/dist/aws/s3/types.js +0 -2
@@ -2,18 +2,30 @@ declare class BaseClass {
2
2
  /**
3
3
  * Shortcut to set a value to an array and return the instance.
4
4
  */
5
- protected _setArray(value: any | any[], ...fields: string[]): this;
5
+ protected _setArray({ input, fields }: {
6
+ input: any | any[];
7
+ fields: any | any[];
8
+ }): this;
6
9
  /**
7
10
  * Shortcut to set a value and return the instance.
8
11
  */
9
- protected _setValue(value: any, ...fields: any[]): this;
12
+ protected _setValue({ input, fields }: {
13
+ input: any;
14
+ fields: any | any[];
15
+ }): this;
10
16
  /**
11
17
  * Shortcut to add a value to an existing array.
12
18
  */
13
- protected _push(value: any | any[], ...fields: any[]): this;
19
+ protected _push({ input, fields }: {
20
+ input: any | any[];
21
+ fields: any | any[];
22
+ }): this;
14
23
  /**
15
24
  * Shortcut to get a value, but default if the fields don't exist.
16
25
  */
17
- protected _get(defaultValue: any, ...fields: any[]): any;
26
+ protected _get({ defaultValue, fields }: {
27
+ defaultValue: any;
28
+ fields: any | any[];
29
+ }): any;
18
30
  }
19
31
  export default BaseClass;
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
3
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
4
- if (ar || !(i in from)) {
5
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
6
- ar[i] = from[i];
7
- }
8
- }
9
- return to.concat(ar || Array.prototype.slice.call(from));
10
- };
11
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
4
  };
@@ -21,44 +12,35 @@ var BaseClass = /** @class */ (function () {
21
12
  /**
22
13
  * Shortcut to set a value to an array and return the instance.
23
14
  */
24
- BaseClass.prototype._setArray = function (value) {
25
- var fields = [];
26
- for (var _i = 1; _i < arguments.length; _i++) {
27
- fields[_i - 1] = arguments[_i];
28
- }
29
- if ((0, isArray_1.default)(value)) {
30
- (0, set_1.default)(this, fields, value);
15
+ BaseClass.prototype._setArray = function (_a) {
16
+ var input = _a.input, fields = _a.fields;
17
+ if ((0, isArray_1.default)(input)) {
18
+ (0, set_1.default)(this, fields, input);
31
19
  }
32
20
  else {
33
- (0, set_1.default)(this, fields, [value]);
21
+ (0, set_1.default)(this, fields, [input]);
34
22
  }
35
23
  return this;
36
24
  };
37
25
  /**
38
26
  * Shortcut to set a value and return the instance.
39
27
  */
40
- BaseClass.prototype._setValue = function (value) {
41
- var fields = [];
42
- for (var _i = 1; _i < arguments.length; _i++) {
43
- fields[_i - 1] = arguments[_i];
44
- }
45
- (0, set_1.default)(this, fields, value);
28
+ BaseClass.prototype._setValue = function (_a) {
29
+ var input = _a.input, fields = _a.fields;
30
+ (0, set_1.default)(this, fields, input);
46
31
  return this;
47
32
  };
48
33
  /**
49
34
  * Shortcut to add a value to an existing array.
50
35
  */
51
- BaseClass.prototype._push = function (value) {
52
- var fields = [];
53
- for (var _i = 1; _i < arguments.length; _i++) {
54
- fields[_i - 1] = arguments[_i];
55
- }
56
- var temp = this._get.apply(this, __spreadArray([[]], fields, false));
57
- if ((0, isArray_1.default)(value)) {
58
- temp = temp.concat(value);
36
+ BaseClass.prototype._push = function (_a) {
37
+ var input = _a.input, fields = _a.fields;
38
+ var temp = this._get({ defaultValue: [], fields: fields });
39
+ if ((0, isArray_1.default)(input)) {
40
+ temp = temp.concat(input);
59
41
  }
60
42
  else {
61
- temp = temp.push(value);
43
+ temp = temp.push(input);
62
44
  }
63
45
  (0, set_1.default)(this, fields, temp);
64
46
  return this;
@@ -66,11 +48,8 @@ var BaseClass = /** @class */ (function () {
66
48
  /**
67
49
  * Shortcut to get a value, but default if the fields don't exist.
68
50
  */
69
- BaseClass.prototype._get = function (defaultValue) {
70
- var fields = [];
71
- for (var _i = 1; _i < arguments.length; _i++) {
72
- fields[_i - 1] = arguments[_i];
73
- }
51
+ BaseClass.prototype._get = function (_a) {
52
+ var defaultValue = _a.defaultValue, fields = _a.fields;
74
53
  return (0, defaultTo_1.default)({ defaultValue: defaultValue, instance: this, keys: fields });
75
54
  };
76
55
  return BaseClass;
@@ -1,10 +1,10 @@
1
1
  /**
2
2
  * Delete a single file.
3
3
  */
4
- declare const deleteFile: ({ S3Lib, bucket, client, file }: {
4
+ declare const deleteFile: ({ S3Lib, bucket, client, key }: {
5
5
  S3Lib: any;
6
6
  bucket: string;
7
7
  client: any;
8
- file: string;
8
+ key: string;
9
9
  }) => Promise<void>;
10
10
  export default deleteFile;
@@ -40,7 +40,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
40
40
  * Delete a single file.
41
41
  */
42
42
  var deleteFile = function (_a) {
43
- var S3Lib = _a.S3Lib, bucket = _a.bucket, client = _a.client, file = _a.file;
43
+ var S3Lib = _a.S3Lib, bucket = _a.bucket, client = _a.client, key = _a.key;
44
44
  return __awaiter(void 0, void 0, void 0, function () {
45
45
  var DeleteObjectCommand;
46
46
  return __generator(this, function (_b) {
@@ -49,7 +49,7 @@ var deleteFile = function (_a) {
49
49
  DeleteObjectCommand = S3Lib.DeleteObjectCommand;
50
50
  return [4 /*yield*/, client.send(new DeleteObjectCommand({
51
51
  Bucket: bucket,
52
- Key: file,
52
+ Key: key,
53
53
  }))];
54
54
  case 1:
55
55
  _b.sent();
@@ -1,10 +1,10 @@
1
1
  /**
2
2
  * Delete multiple files.
3
3
  */
4
- declare const deleteFiles: ({ S3Lib, bucket, client, files }: {
4
+ declare const deleteFiles: ({ S3Lib, bucket, client, keys }: {
5
5
  S3Lib: any;
6
6
  bucket: string;
7
7
  client: any;
8
- files: string[];
8
+ keys: string[];
9
9
  }) => Promise<void>;
10
10
  export default deleteFiles;
@@ -40,7 +40,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
40
40
  * Delete multiple files.
41
41
  */
42
42
  var deleteFiles = function (_a) {
43
- var S3Lib = _a.S3Lib, bucket = _a.bucket, client = _a.client, files = _a.files;
43
+ var S3Lib = _a.S3Lib, bucket = _a.bucket, client = _a.client, keys = _a.keys;
44
44
  return __awaiter(void 0, void 0, void 0, function () {
45
45
  var DeleteObjectsCommand;
46
46
  return __generator(this, function (_b) {
@@ -50,8 +50,8 @@ var deleteFiles = function (_a) {
50
50
  return [4 /*yield*/, client.send(new DeleteObjectsCommand({
51
51
  Bucket: bucket,
52
52
  Delete: {
53
- Objects: files.map(function (file) { return ({
54
- Key: file,
53
+ Objects: keys.map(function (key) { return ({
54
+ Key: key,
55
55
  }); }),
56
56
  },
57
57
  }))];
@@ -1,10 +1,10 @@
1
1
  /**
2
2
  * Iteratively delete all the files within a directory and delete the directory.
3
3
  */
4
- declare const deleteDirectory: ({ S3Lib, bucket, client, folder }: {
4
+ declare const deleteFolder: ({ S3Lib, bucket, client, folder }: {
5
5
  S3Lib: any;
6
6
  bucket: string;
7
7
  client: any;
8
8
  folder: string;
9
9
  }) => Promise<void>;
10
- export default deleteDirectory;
10
+ export default deleteFolder;
@@ -40,7 +40,7 @@ var string_1 = require("../../string");
40
40
  /**
41
41
  * Iteratively delete all the files within a directory and delete the directory.
42
42
  */
43
- var deleteDirectory = function (_a) {
43
+ var deleteFolder = function (_a) {
44
44
  var S3Lib = _a.S3Lib, bucket = _a.bucket, client = _a.client, folder = _a.folder;
45
45
  return __awaiter(void 0, void 0, void 0, function () {
46
46
  var cleanFolder, ListObjectsV2Command, DeleteObjectsCommand, apiResponse, keys;
@@ -71,7 +71,7 @@ var deleteDirectory = function (_a) {
71
71
  // Delete the files
72
72
  _b.sent();
73
73
  if (!apiResponse.IsTruncated) return [3 /*break*/, 4];
74
- return [4 /*yield*/, deleteDirectory({ S3Lib: S3Lib, bucket: bucket, client: client, folder: folder })];
74
+ return [4 /*yield*/, deleteFolder({ S3Lib: S3Lib, bucket: bucket, client: client, folder: folder })];
75
75
  case 3:
76
76
  _b.sent();
77
77
  _b.label = 4;
@@ -80,4 +80,4 @@ var deleteDirectory = function (_a) {
80
80
  });
81
81
  });
82
82
  };
83
- exports.default = deleteDirectory;
83
+ exports.default = deleteFolder;
@@ -4,17 +4,17 @@ declare type PresignedPostType = {
4
4
  client: any;
5
5
  conditions: any[];
6
6
  expires: number;
7
- file: string;
8
7
  fields: {
9
8
  [key: string]: string;
10
9
  };
10
+ key: string;
11
11
  };
12
12
  /**
13
13
  * Returns a presigned post to upload a file directly to S3.
14
14
  * https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/modules/_aws_sdk_s3_presigned_post.html
15
15
  * https://github.com/8millionstories-organisation/test-vercel-upload-2/blob/50eb12fcb3870a59ab455811bfaa1bdcb886edf2/pages/api/upload-url.js
16
16
  */
17
- declare const getPresignedPost: ({ S3Lib, bucket, client, conditions, expires, file, fields }: PresignedPostType) => Promise<{
17
+ declare const getPresignedPost: ({ S3Lib, bucket, client, conditions, expires, fields, key }: PresignedPostType) => Promise<{
18
18
  url: any;
19
19
  fields: any;
20
20
  }>;
@@ -42,7 +42,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
42
42
  * https://github.com/8millionstories-organisation/test-vercel-upload-2/blob/50eb12fcb3870a59ab455811bfaa1bdcb886edf2/pages/api/upload-url.js
43
43
  */
44
44
  var getPresignedPost = function (_a) {
45
- var S3Lib = _a.S3Lib, bucket = _a.bucket, client = _a.client, conditions = _a.conditions, expires = _a.expires, file = _a.file, fields = _a.fields;
45
+ var S3Lib = _a.S3Lib, bucket = _a.bucket, client = _a.client, conditions = _a.conditions, expires = _a.expires, fields = _a.fields, key = _a.key;
46
46
  return __awaiter(void 0, void 0, void 0, function () {
47
47
  var createPresignedPost, apiResponse;
48
48
  return __generator(this, function (_b) {
@@ -51,7 +51,7 @@ var getPresignedPost = function (_a) {
51
51
  createPresignedPost = S3Lib.createPresignedPost;
52
52
  return [4 /*yield*/, createPresignedPost(client, {
53
53
  Bucket: bucket,
54
- Key: file,
54
+ Key: key,
55
55
  Conditions: undefined === conditions ? [] : conditions,
56
56
  Fields: undefined === fields ? {} : fields,
57
57
  Expires: undefined === expires ? 60 : expires, // Seconds
@@ -5,11 +5,11 @@ declare type GetSignedUrlType = {
5
5
  bucket: string;
6
6
  client: any;
7
7
  expires: number;
8
- file: string;
8
+ key: string;
9
9
  };
10
10
  /**
11
11
  * Returns a signed for URL to allow download of private buckets for a given duration.
12
12
  * Library: @aws-sdk/s3-request-presigner
13
13
  */
14
- declare const getSignedUrl: ({ S3Lib, S3PresignerLib, bucket, client, expires, file }: GetSignedUrlType) => Promise<ResponseType>;
14
+ declare const getSignedUrl: ({ S3Lib, S3PresignerLib, bucket, client, expires, key }: GetSignedUrlType) => Promise<ResponseType>;
15
15
  export default getSignedUrl;
@@ -53,7 +53,7 @@ var api_1 = require("../../api");
53
53
  * Library: @aws-sdk/s3-request-presigner
54
54
  */
55
55
  var getSignedUrl = function (_a) {
56
- var S3Lib = _a.S3Lib, S3PresignerLib = _a.S3PresignerLib, bucket = _a.bucket, client = _a.client, expires = _a.expires, file = _a.file;
56
+ var S3Lib = _a.S3Lib, S3PresignerLib = _a.S3PresignerLib, bucket = _a.bucket, client = _a.client, expires = _a.expires, key = _a.key;
57
57
  return __awaiter(void 0, void 0, void 0, function () {
58
58
  var response, GetObjectCommand, getSignedUrl, command, awsResponse;
59
59
  return __generator(this, function (_b) {
@@ -64,7 +64,7 @@ var getSignedUrl = function (_a) {
64
64
  getSignedUrl = S3PresignerLib.getSignedUrl;
65
65
  command = new GetObjectCommand({
66
66
  Bucket: bucket,
67
- Key: file,
67
+ Key: key,
68
68
  });
69
69
  return [4 /*yield*/, getSignedUrl(client, command, { expiresIn: expires })];
70
70
  case 1:
@@ -1,16 +1,15 @@
1
- import deleteDirectory from './deleteDirectory';
2
1
  import deleteFile from './deleteFile';
3
2
  import deleteFiles from './deleteFiles';
3
+ import deleteFolder from './deleteFolder';
4
4
  import getClient from './getClient';
5
5
  import getPresignedPost from './getPresignedPost';
6
6
  import getSignedUrl from './getSignedUrl';
7
7
  import listFiles from './listFiles';
8
8
  import listFolders from './listFolders';
9
- import readBuffer from './readBuffer';
10
- import readFile from './readFile';
11
- import { ReadBufferType, ReadFileType, ReadType } from './types';
9
+ import readBuffer, { ReadBufferType } from './readBuffer';
10
+ import readFile, { ReadFileType, ReadType } from './readFile';
12
11
  import writeFile from './writeFile';
13
12
  import writeGlueJsonFile from './writeGlueJsonFile';
14
13
  import writePresignedPost from './writePresignedPost';
15
14
  export type { ReadType, ReadBufferType, ReadFileType, };
16
- export { deleteDirectory, deleteFile, deleteFiles, getClient, getPresignedPost, getSignedUrl, listFiles, listFolders, readBuffer, readFile, writeFile, writeGlueJsonFile, writePresignedPost, };
15
+ export { deleteFolder, deleteFile, deleteFiles, getClient, getPresignedPost, getSignedUrl, listFiles, listFolders, readBuffer, readFile, writeFile, writeGlueJsonFile, writePresignedPost, };
@@ -3,13 +3,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.writePresignedPost = exports.writeGlueJsonFile = exports.writeFile = exports.readFile = exports.readBuffer = exports.listFolders = exports.listFiles = exports.getSignedUrl = exports.getPresignedPost = exports.getClient = exports.deleteFiles = exports.deleteFile = exports.deleteDirectory = void 0;
7
- var deleteDirectory_1 = __importDefault(require("./deleteDirectory"));
8
- exports.deleteDirectory = deleteDirectory_1.default;
6
+ exports.writePresignedPost = exports.writeGlueJsonFile = exports.writeFile = exports.readFile = exports.readBuffer = exports.listFolders = exports.listFiles = exports.getSignedUrl = exports.getPresignedPost = exports.getClient = exports.deleteFiles = exports.deleteFile = exports.deleteFolder = void 0;
9
7
  var deleteFile_1 = __importDefault(require("./deleteFile"));
10
8
  exports.deleteFile = deleteFile_1.default;
11
9
  var deleteFiles_1 = __importDefault(require("./deleteFiles"));
12
10
  exports.deleteFiles = deleteFiles_1.default;
11
+ var deleteFolder_1 = __importDefault(require("./deleteFolder"));
12
+ exports.deleteFolder = deleteFolder_1.default;
13
13
  var getClient_1 = __importDefault(require("./getClient"));
14
14
  exports.getClient = getClient_1.default;
15
15
  var getPresignedPost_1 = __importDefault(require("./getPresignedPost"));
@@ -1,11 +1,14 @@
1
- import { ReadBufferType } from './types';
1
+ import { ReadType } from './readFile';
2
+ export declare type ReadBufferType = ReadType & {
3
+ buffer: any;
4
+ };
2
5
  /**
3
6
  * Similar function to reading the S3 file, but instead of a text file return a buffer.
4
7
  */
5
- declare const readBuffer: ({ S3Lib, bucket, client, file }: {
8
+ declare const readBuffer: ({ S3Lib, bucket, client, key }: {
6
9
  S3Lib: any;
7
10
  bucket: string;
8
11
  client: any;
9
- file: string;
12
+ key: string;
10
13
  }) => Promise<ReadBufferType>;
11
14
  export default readBuffer;
@@ -45,7 +45,7 @@ var isResponse200_1 = __importDefault(require("../isResponse200"));
45
45
  * Similar function to reading the S3 file, but instead of a text file return a buffer.
46
46
  */
47
47
  var readBuffer = function (_a) {
48
- var S3Lib = _a.S3Lib, bucket = _a.bucket, client = _a.client, file = _a.file;
48
+ var S3Lib = _a.S3Lib, bucket = _a.bucket, client = _a.client, key = _a.key;
49
49
  return __awaiter(void 0, void 0, void 0, function () {
50
50
  var response, GetObjectCommand, apiResponse, chunks_1, _b;
51
51
  return __generator(this, function (_c) {
@@ -71,7 +71,7 @@ var readBuffer = function (_a) {
71
71
  GetObjectCommand = S3Lib.GetObjectCommand;
72
72
  return [4 /*yield*/, client.send(new GetObjectCommand({
73
73
  Bucket: bucket,
74
- Key: file,
74
+ Key: key,
75
75
  }))];
76
76
  case 1:
77
77
  apiResponse = _c.sent();
@@ -1,12 +1,30 @@
1
- import { ReadFileType } from './types';
1
+ export declare type ReadType = {
2
+ now: number;
3
+ modified: {
4
+ unix: null | number;
5
+ vsNow: {
6
+ months: number;
7
+ days: number;
8
+ hours: number;
9
+ minutes: number;
10
+ };
11
+ vsMidnight: {
12
+ hours: number;
13
+ minutes: number;
14
+ };
15
+ };
16
+ };
17
+ export declare type ReadFileType = ReadType & {
18
+ body: any;
19
+ };
2
20
  /**
3
21
  * Read a file from S3 and return either null, the content or JSON decoded.
4
22
  */
5
- declare const readFile: ({ S3Lib, bucket, client, file, isJson }: {
23
+ declare const readFile: ({ S3Lib, bucket, client, key, isJson }: {
6
24
  S3Lib: any;
7
25
  bucket: string;
8
26
  client: any;
9
- file: string;
27
+ key: string;
10
28
  isJson: boolean;
11
29
  }) => Promise<ReadFileType>;
12
30
  export default readFile;
@@ -52,7 +52,7 @@ var isResponse200_1 = __importDefault(require("../isResponse200"));
52
52
  * Read a file from S3 and return either null, the content or JSON decoded.
53
53
  */
54
54
  var readFile = function (_a) {
55
- var S3Lib = _a.S3Lib, bucket = _a.bucket, client = _a.client, file = _a.file, isJson = _a.isJson;
55
+ var S3Lib = _a.S3Lib, bucket = _a.bucket, client = _a.client, key = _a.key, isJson = _a.isJson;
56
56
  return __awaiter(void 0, void 0, void 0, function () {
57
57
  var response, GetObjectCommand, apiResponse, now, modified, _b;
58
58
  return __generator(this, function (_c) {
@@ -78,7 +78,7 @@ var readFile = function (_a) {
78
78
  GetObjectCommand = S3Lib.GetObjectCommand;
79
79
  return [4 /*yield*/, client.send(new GetObjectCommand({
80
80
  Bucket: bucket,
81
- Key: file,
81
+ Key: key,
82
82
  }))];
83
83
  case 1:
84
84
  apiResponse = _c.sent();
@@ -1,11 +1,11 @@
1
1
  /**
2
2
  * Write a file to S3.
3
3
  */
4
- export declare const writeFile: ({ S3Lib, bucket, client, file, content }: {
4
+ export declare const writeFile: ({ S3Lib, bucket, client, data, key }: {
5
5
  S3Lib: any;
6
6
  bucket: string;
7
7
  client: any;
8
- file: string;
9
- content: any;
8
+ data: any;
9
+ key: string;
10
10
  }) => Promise<any>;
11
11
  export default writeFile;
@@ -41,7 +41,7 @@ exports.writeFile = void 0;
41
41
  * Write a file to S3.
42
42
  */
43
43
  var writeFile = function (_a) {
44
- var S3Lib = _a.S3Lib, bucket = _a.bucket, client = _a.client, file = _a.file, content = _a.content;
44
+ var S3Lib = _a.S3Lib, bucket = _a.bucket, client = _a.client, data = _a.data, key = _a.key;
45
45
  return __awaiter(void 0, void 0, void 0, function () {
46
46
  var PutObjectCommand, apiResponse;
47
47
  return __generator(this, function (_b) {
@@ -50,8 +50,8 @@ var writeFile = function (_a) {
50
50
  PutObjectCommand = S3Lib.PutObjectCommand;
51
51
  return [4 /*yield*/, client.send(new PutObjectCommand({
52
52
  Bucket: bucket,
53
- Body: content,
54
- Key: file,
53
+ Body: data,
54
+ Key: key,
55
55
  }))];
56
56
  case 1:
57
57
  apiResponse = _b.sent();
@@ -3,11 +3,11 @@
3
3
  * Input: Must be an array of objects that are the same.
4
4
  * Output: No array [] brackets, each object must on its own new line.
5
5
  */
6
- export declare const writeGlueJsonFile: ({ S3Lib, bucket, client, file, input }: {
6
+ export declare const writeGlueJsonFile: ({ S3Lib, bucket, client, data, key }: {
7
7
  S3Lib: any;
8
8
  bucket: string;
9
9
  client: any;
10
- file: string;
11
- input: object[];
10
+ data: object[];
11
+ key: string;
12
12
  }) => Promise<any>;
13
13
  export default writeGlueJsonFile;
@@ -45,16 +45,16 @@ var writeFile_1 = require("./writeFile");
45
45
  * Output: No array [] brackets, each object must on its own new line.
46
46
  */
47
47
  var writeGlueJsonFile = function (_a) {
48
- var S3Lib = _a.S3Lib, bucket = _a.bucket, client = _a.client, file = _a.file, input = _a.input;
48
+ var S3Lib = _a.S3Lib, bucket = _a.bucket, client = _a.client, data = _a.data, key = _a.key;
49
49
  return __awaiter(void 0, void 0, void 0, function () {
50
50
  var inputArray, stringRows, concatString;
51
51
  return __generator(this, function (_b) {
52
52
  switch (_b.label) {
53
53
  case 0:
54
- inputArray = (0, array_1.getArray)({ input: input });
54
+ inputArray = (0, array_1.getArray)({ input: data });
55
55
  stringRows = inputArray.map(function (row) { return JSON.stringify(row); });
56
56
  concatString = stringRows.join("\n");
57
- return [4 /*yield*/, (0, writeFile_1.writeFile)({ S3Lib: S3Lib, bucket: bucket, client: client, file: file, content: concatString })];
57
+ return [4 /*yield*/, (0, writeFile_1.writeFile)({ S3Lib: S3Lib, bucket: bucket, client: client, data: concatString, key: key })];
58
58
  case 1: return [2 /*return*/, _b.sent()];
59
59
  }
60
60
  });
@@ -5,11 +5,11 @@ declare type WritePresignedPostType = {
5
5
  config: ConfigType;
6
6
  fields: any;
7
7
  file: any;
8
- fileName: string;
8
+ key: string;
9
9
  url: string;
10
10
  };
11
11
  /**
12
12
  * Get a presigned post URL so we can upload directly to S3 via frontend.
13
13
  */
14
- declare const writePresignedPost: ({ bucket, config, fields, file, fileName, url }: WritePresignedPostType) => Promise<ResponseType>;
14
+ declare const writePresignedPost: ({ bucket, config, fields, file, key, url }: WritePresignedPostType) => Promise<ResponseType>;
15
15
  export default writePresignedPost;
@@ -52,7 +52,7 @@ var api_1 = require("../../api");
52
52
  * Get a presigned post URL so we can upload directly to S3 via frontend.
53
53
  */
54
54
  var writePresignedPost = function (_a) {
55
- var bucket = _a.bucket, config = _a.config, fields = _a.fields, file = _a.file, fileName = _a.fileName, url = _a.url;
55
+ var bucket = _a.bucket, config = _a.config, fields = _a.fields, file = _a.file, key = _a.key, url = _a.url;
56
56
  return __awaiter(void 0, void 0, void 0, function () {
57
57
  return __generator(this, function (_b) {
58
58
  return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(void 0, void 0, void 0, function () {
@@ -78,7 +78,7 @@ var writePresignedPost = function (_a) {
78
78
  if (upload.ok) {
79
79
  response.state = api_1.states.SUCCESS;
80
80
  response.body = {
81
- url: "https://".concat(bucket, ".s3.").concat(config.region, ".amazonaws.com/").concat(fileName),
81
+ url: "https://".concat(bucket, ".s3.").concat(config.region, ".amazonaws.com/").concat(key),
82
82
  };
83
83
  resolve(response);
84
84
  }
@@ -48,7 +48,7 @@ var getCache = function (_a) {
48
48
  switch (_b.label) {
49
49
  case 0:
50
50
  client = (0, s3_1.getClient)({ S3Lib: S3Lib, config: config });
51
- return [4 /*yield*/, (0, s3_1.readFile)({ S3Lib: S3Lib, bucket: bucket, client: client, file: key, isJson: isJson })];
51
+ return [4 /*yield*/, (0, s3_1.readFile)({ S3Lib: S3Lib, bucket: bucket, client: client, key: key, isJson: isJson })];
52
52
  case 1:
53
53
  _b.sent();
54
54
  return [2 /*return*/];
@@ -48,7 +48,7 @@ var saveCache = function (_a) {
48
48
  switch (_b.label) {
49
49
  case 0:
50
50
  client = (0, s3_1.getClient)({ S3Lib: S3Lib, config: config });
51
- return [4 /*yield*/, (0, s3_1.writeFile)({ S3Lib: S3Lib, bucket: bucket, client: client, file: key, content: data })];
51
+ return [4 /*yield*/, (0, s3_1.writeFile)({ S3Lib: S3Lib, bucket: bucket, client: client, data: data, key: key })];
52
52
  case 1:
53
53
  _b.sent();
54
54
  return [2 /*return*/];
@@ -52,7 +52,7 @@ var updateCache = function (_a) {
52
52
  switch (_b.label) {
53
53
  case 0:
54
54
  client = (0, s3_1.getClient)({ S3Lib: S3Lib, config: config });
55
- return [4 /*yield*/, (0, s3_1.deleteFile)({ S3Lib: S3Lib, bucket: bucket, client: client, file: key })];
55
+ return [4 /*yield*/, (0, s3_1.deleteFile)({ S3Lib: S3Lib, bucket: bucket, client: client, key: key })];
56
56
  case 1:
57
57
  _b.sent();
58
58
  return [4 /*yield*/, (0, saveCache_1.default)({ S3Lib: S3Lib, bucket: bucket, config: config, data: data, key: key })];
@@ -105,39 +105,39 @@ var SimpleEmail = /** @class */ (function (_super) {
105
105
  }
106
106
  SimpleEmail.prototype.setFrom = function (_a) {
107
107
  var from = _a.from;
108
- return this._setValue(from, 'from');
108
+ return this._setValue({ input: from, fields: 'from' });
109
109
  };
110
110
  SimpleEmail.prototype.setHtml = function (_a) {
111
111
  var html = _a.html;
112
- return this._setValue(html, 'html');
112
+ return this._setValue({ input: html, fields: 'html' });
113
113
  };
114
114
  SimpleEmail.prototype.setSubject = function (_a) {
115
115
  var subject = _a.subject;
116
- return this._setValue(subject, 'subject');
116
+ return this._setValue({ input: subject, fields: 'subject' });
117
117
  };
118
118
  SimpleEmail.prototype.pushBcc = function (_a) {
119
119
  var recipient = _a.recipient;
120
- return this._push(recipient, 'bcc');
120
+ return this._push({ input: recipient, fields: 'bcc' });
121
121
  };
122
122
  SimpleEmail.prototype.pushCc = function (_a) {
123
123
  var recipient = _a.recipient;
124
- return this._push(recipient, 'cc');
124
+ return this._push({ input: recipient, fields: 'cc' });
125
125
  };
126
126
  SimpleEmail.prototype.pushTo = function (_a) {
127
127
  var recipient = _a.recipient;
128
- return this._push(recipient, 'to');
128
+ return this._push({ input: recipient, fields: 'to' });
129
129
  };
130
130
  SimpleEmail.prototype.setBcc = function (_a) {
131
131
  var recipient = _a.recipient;
132
- return this._setArray(recipient, 'bcc');
132
+ return this._setArray({ input: recipient, fields: 'bcc' });
133
133
  };
134
134
  SimpleEmail.prototype.setCc = function (_a) {
135
135
  var recipient = _a.recipient;
136
- return this._setArray(recipient, 'cc');
136
+ return this._setArray({ input: recipient, fields: 'cc' });
137
137
  };
138
138
  SimpleEmail.prototype.setTo = function (_a) {
139
139
  var recipient = _a.recipient;
140
- return this._setArray(recipient, 'to');
140
+ return this._setArray({ input: recipient, fields: 'to' });
141
141
  };
142
142
  SimpleEmail.prototype.send = function (_a) {
143
143
  var SesLib = _a.SesLib, client = _a.client;
@@ -1,5 +1,7 @@
1
1
  /**
2
2
  * Convert an input from a variety of forms into boolean.
3
3
  */
4
- declare const getBoolean: (input: any) => boolean;
4
+ declare const getBoolean: ({ input }: {
5
+ input: any;
6
+ }) => boolean;
5
7
  export default getBoolean;
@@ -7,7 +7,8 @@ var isBoolean_1 = __importDefault(require("lodash/isBoolean"));
7
7
  /**
8
8
  * Convert an input from a variety of forms into boolean.
9
9
  */
10
- var getBoolean = function (input) {
10
+ var getBoolean = function (_a) {
11
+ var input = _a.input;
11
12
  if ((0, isBoolean_1.default)(input)) {
12
13
  return input;
13
14
  }
@@ -2,10 +2,10 @@
2
2
  * Decrypt an encoding string using a salt
3
3
  * Library: crypto-js
4
4
  */
5
- declare const getDecrypt: ({ CryptoLib, appSalt, salt, value }: {
5
+ declare const getDecrypt: ({ CryptoLib, appSalt, input, salt }: {
6
6
  CryptoLib: any;
7
- value: string;
8
- salt: string;
9
7
  appSalt: string;
8
+ input: string;
9
+ salt: string;
10
10
  }) => string;
11
11
  export default getDecrypt;
@@ -5,9 +5,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
5
5
  * Library: crypto-js
6
6
  */
7
7
  var getDecrypt = function (_a) {
8
- var CryptoLib = _a.CryptoLib, appSalt = _a.appSalt, salt = _a.salt, value = _a.value;
8
+ var CryptoLib = _a.CryptoLib, appSalt = _a.appSalt, input = _a.input, salt = _a.salt;
9
9
  var customSalt = "".concat(appSalt, "-").concat(salt);
10
- return CryptoLib.AES.decrypt(value, customSalt)
10
+ return CryptoLib.AES.decrypt(input, customSalt)
11
11
  .toString(CryptoLib.enc.Utf8);
12
12
  };
13
13
  exports.default = getDecrypt;
@@ -2,10 +2,10 @@
2
2
  * Encrypt an encoding string using a salt
3
3
  * Library: crypto-js
4
4
  */
5
- declare const getEncrypt: ({ CryptoLib, appSalt, salt, value }: {
5
+ declare const getEncrypt: ({ CryptoLib, appSalt, input, salt }: {
6
6
  CryptoLib: any;
7
- value: string;
8
- salt: string;
9
7
  appSalt: string;
8
+ input: string;
9
+ salt: string;
10
10
  }) => string;
11
11
  export default getEncrypt;
@@ -5,9 +5,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
5
5
  * Library: crypto-js
6
6
  */
7
7
  var getEncrypt = function (_a) {
8
- var CryptoLib = _a.CryptoLib, appSalt = _a.appSalt, salt = _a.salt, value = _a.value;
8
+ var CryptoLib = _a.CryptoLib, appSalt = _a.appSalt, input = _a.input, salt = _a.salt;
9
9
  var customSalt = "".concat(appSalt, "-").concat(salt);
10
- return CryptoLib.AES.encrypt(value, customSalt)
10
+ return CryptoLib.AES.encrypt(input, customSalt)
11
11
  .toString();
12
12
  };
13
13
  exports.default = getEncrypt;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@8ms/helpers",
3
- "version": "1.1.8",
3
+ "version": "1.1.11",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/8millionstories-organisation/8ms-helpers-ts.git"
@@ -1,22 +0,0 @@
1
- export declare type ReadType = {
2
- now: number;
3
- modified: {
4
- unix: null | number;
5
- vsNow: {
6
- months: number;
7
- days: number;
8
- hours: number;
9
- minutes: number;
10
- };
11
- vsMidnight: {
12
- hours: number;
13
- minutes: number;
14
- };
15
- };
16
- };
17
- export declare type ReadBufferType = ReadType & {
18
- buffer: any;
19
- };
20
- export declare type ReadFileType = ReadType & {
21
- body: any;
22
- };
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });