@8ms/helpers 1.0.21 → 1.1.0
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/dist/api/index.d.ts +5 -4
- package/dist/api/index.js +7 -5
- package/dist/api/response.d.ts +7 -0
- package/dist/api/response.js +9 -0
- package/dist/api/states.d.ts +8 -0
- package/dist/api/states.js +10 -0
- package/dist/api/unexpectedError.d.ts +1 -0
- package/dist/api/unexpectedError.js +4 -0
- package/dist/array/tests/contains.test.d.ts +1 -0
- package/dist/array/tests/contains.test.js +18 -0
- package/dist/aws/athenaExpress/getClient.d.ts +2 -2
- package/dist/aws/{types.d.ts → config.d.ts} +1 -1
- package/dist/{api/types.js → aws/config.js} +0 -0
- package/dist/aws/getConfig.d.ts +2 -2
- package/dist/aws/glue/getClient.d.ts +2 -2
- package/dist/aws/index.d.ts +2 -2
- package/dist/aws/lambda/getClient.d.ts +2 -2
- package/dist/aws/s3/deleteDirectory.js +1 -1
- package/dist/aws/s3/getClient.d.ts +2 -2
- package/dist/aws/s3/getSignedUrl.d.ts +2 -2
- package/dist/aws/s3/getSignedUrl.js +17 -6
- package/dist/aws/s3/listFiles.js +1 -1
- package/dist/aws/s3/listFolders.js +1 -1
- package/dist/aws/s3/readFile.js +1 -1
- package/dist/aws/s3/writePresignedPost.d.ts +4 -4
- package/dist/aws/s3/writePresignedPost.js +14 -3
- package/dist/aws/s3cache/cache.d.ts +6 -0
- package/dist/aws/s3cache/{types.js → cache.js} +0 -0
- package/dist/aws/s3cache/getCache.d.ts +2 -2
- package/dist/aws/s3cache/getKey.d.ts +2 -2
- package/dist/aws/s3cache/index.d.ts +2 -2
- package/dist/aws/s3cache/saveCache.d.ts +2 -2
- package/dist/aws/s3cache/updateCache.d.ts +2 -2
- package/dist/aws/ses/SimpleEmail.d.ts +3 -2
- package/dist/aws/ses/SimpleEmail.js +23 -15
- package/dist/aws/ses/getClient.d.ts +2 -2
- package/dist/aws/ssm/getClient.d.ts +2 -2
- package/dist/axios/get.d.ts +6 -1
- package/dist/axios/get.js +1 -1
- package/dist/axios/index.d.ts +2 -3
- package/dist/axios/post.d.ts +7 -1
- package/dist/axios/post.js +1 -1
- package/dist/crud/index.d.ts +3 -4
- package/dist/crud/index.js +3 -3
- package/dist/crud/states.d.ts +7 -0
- package/dist/crud/{constants.js → states.js} +2 -2
- package/dist/date/date.d.ts +4 -0
- package/dist/{aws/types.js → date/date.js} +0 -0
- package/dist/date/duration.d.ts +5 -0
- package/dist/{axios/types.js → date/duration.js} +0 -0
- package/dist/date/durationComparisons.d.ts +4 -0
- package/dist/date/durationComparisons.js +7 -0
- package/dist/date/durations.d.ts +7 -0
- package/dist/date/durations.js +10 -0
- package/dist/date/financialYear.d.ts +4 -0
- package/dist/{crud/types.js → date/financialYear.js} +0 -0
- package/dist/date/financialYearWeek.d.ts +6 -0
- package/dist/date/{types.js → financialYearWeek.js} +0 -0
- package/dist/date/format.d.ts +1 -1
- package/dist/date/getDate.d.ts +1 -1
- package/dist/date/getFinancialYear.d.ts +1 -1
- package/dist/date/getFinancialYearToDate.d.ts +1 -1
- package/dist/date/getFinancialYearWeeks.d.ts +1 -1
- package/dist/date/getLastWeek.d.ts +1 -1
- package/dist/date/getMax.d.ts +1 -1
- package/dist/date/getMin.d.ts +1 -1
- package/dist/date/getMonday.d.ts +1 -1
- package/dist/date/getNumber.d.ts +1 -1
- package/dist/date/getPredefinedTimeframe.d.ts +3 -2
- package/dist/date/getPredefinedTimeframe.js +4 -4
- package/dist/date/getSunday.d.ts +1 -1
- package/dist/date/getThisWeek.d.ts +1 -1
- package/dist/date/getTwoWeeksAgo.d.ts +1 -1
- package/dist/date/getWeeksAgo.d.ts +1 -1
- package/dist/date/index.d.ts +11 -4
- package/dist/date/index.js +9 -6
- package/dist/date/isLastWeek.d.ts +1 -1
- package/dist/date/isThisWeek.d.ts +1 -1
- package/dist/date/predefinedTimeframes.d.ts +7 -0
- package/dist/date/predefinedTimeframes.js +9 -0
- package/dist/date/timeframe.d.ts +8 -0
- package/dist/{environment/types.js → date/timeframe.js} +0 -0
- package/dist/date/timeframes.d.ts +4 -0
- package/dist/date/timeframes.js +7 -0
- package/dist/environment/environments.d.ts +6 -0
- package/dist/environment/{constants.js → environments.js} +2 -6
- package/dist/environment/getEnvironment.d.ts +4 -3
- package/dist/environment/getEnvironment.js +4 -4
- package/dist/environment/index.d.ts +4 -4
- package/dist/environment/index.js +5 -4
- package/dist/environment/isAws.d.ts +2 -2
- package/dist/environment/isAws.js +2 -2
- package/dist/environment/isDevelopment.d.ts +2 -2
- package/dist/environment/isDevelopment.js +2 -2
- package/dist/environment/isLocalhost.d.ts +2 -2
- package/dist/environment/isProduction.d.ts +2 -2
- package/dist/environment/isProduction.js +2 -2
- package/dist/environment/isStaging.d.ts +2 -2
- package/dist/environment/isStaging.js +2 -2
- package/dist/environment/isVercel.d.ts +2 -2
- package/dist/environment/isVercel.js +2 -2
- package/dist/environment/platforms.d.ts +5 -0
- package/dist/environment/platforms.js +7 -0
- package/dist/eskimi/accessToken.d.ts +9 -0
- package/dist/eskimi/{types.js → accessToken.js} +0 -0
- package/dist/eskimi/ageGroups.d.ts +4 -0
- package/dist/eskimi/ageGroups.js +41 -0
- package/dist/eskimi/{types.d.ts → campaign.d.ts} +0 -0
- package/dist/{google/types.js → eskimi/campaign.js} +0 -0
- package/dist/eskimi/devices.d.ts +4 -0
- package/dist/eskimi/devices.js +13 -0
- package/dist/eskimi/{constants.d.ts → endpoints.d.ts} +1 -13
- package/dist/eskimi/endpoints.js +18 -0
- package/dist/eskimi/genders.d.ts +4 -0
- package/dist/eskimi/genders.js +13 -0
- package/dist/eskimi/getAccessToken.d.ts +1 -9
- package/dist/eskimi/getAgeGroup.js +2 -2
- package/dist/eskimi/getDevice.js +2 -2
- package/dist/eskimi/getGender.js +2 -2
- package/dist/eskimi/index.d.ts +8 -4
- package/dist/eskimi/index.js +9 -6
- package/dist/google/getCredentials.d.ts +18 -1
- package/dist/google/index.d.ts +2 -3
- package/dist/google/sheets/getAuth.d.ts +1 -1
- package/dist/google/sheets/getAuth.js +5 -2
- package/dist/googleAds/{types.d.ts → client.d.ts} +0 -0
- package/dist/googleAds/{types.js → client.js} +0 -0
- package/dist/googleAds/getClient.d.ts +3 -3
- package/dist/googleAds/index.d.ts +1 -1
- package/dist/myTarget/getAccessToken.d.ts +2 -2
- package/dist/nextAuth/{constants.d.ts → authStates.d.ts} +1 -1
- package/dist/nextAuth/{constants.js → authStates.js} +2 -2
- package/dist/nextAuth/index.d.ts +2 -2
- package/dist/nextAuth/index.js +3 -3
- package/dist/number/getNumber.d.ts +1 -1
- package/dist/number/getNumber.js +15 -4
- package/dist/number/tests/getNumber.test.d.ts +1 -0
- package/dist/number/tests/getNumber.test.js +21 -0
- package/dist/snapchat/getAccessToken.d.ts +2 -2
- package/dist/string/getCleanFolder.d.ts +3 -1
- package/dist/string/getCleanFolder.js +5 -2
- package/dist/string/getStringFromStream.d.ts +3 -1
- package/dist/string/getStringFromStream.js +2 -1
- package/dist/string/tests/getCleanFolder.test.js +1 -1
- package/dist/url/buildUrl.d.ts +3 -3
- package/dist/url/index.d.ts +1 -1
- package/dist/url/{types.d.ts → url.d.ts} +0 -0
- package/dist/url/{types.js → url.js} +0 -0
- package/dist/util/defaultTo.d.ts +3 -0
- package/dist/util/defaultTo.js +1 -1
- package/dist/util/tests/defaultTo.test.d.ts +1 -0
- package/dist/util/tests/defaultTo.test.js +27 -0
- package/dist/webWorker/index.d.ts +3 -4
- package/dist/webWorker/index.js +3 -3
- package/dist/webWorker/states.d.ts +6 -0
- package/dist/webWorker/{constant.js → states.js} +2 -2
- package/package.json +2 -2
- package/dist/api/constants.d.ts +0 -10
- package/dist/api/constants.js +0 -16
- package/dist/api/types.d.ts +0 -7
- package/dist/aws/s3cache/types.d.ts +0 -6
- package/dist/axios/types.d.ts +0 -13
- package/dist/crud/constants.d.ts +0 -6
- package/dist/crud/types.d.ts +0 -2
- package/dist/date/constants.d.ts +0 -21
- package/dist/date/constants.js +0 -24
- package/dist/date/types.d.ts +0 -28
- package/dist/environment/constants.d.ts +0 -9
- package/dist/environment/types.d.ts +0 -3
- package/dist/eskimi/constants.js +0 -76
- package/dist/google/types.d.ts +0 -18
- package/dist/webWorker/constant.d.ts +0 -5
- package/dist/webWorker/types.d.ts +0 -2
- package/dist/webWorker/types.js +0 -2
package/dist/api/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
export {
|
|
1
|
+
import { response, ResponseType } from './response';
|
|
2
|
+
import { states, StateType } from './states';
|
|
3
|
+
import { unexpectedError } from './unexpectedError';
|
|
4
|
+
export type { ResponseType, StateType, };
|
|
5
|
+
export { response, states, unexpectedError, };
|
package/dist/api/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
var
|
|
5
|
-
Object.defineProperty(exports, "
|
|
6
|
-
|
|
7
|
-
Object.defineProperty(exports, "
|
|
3
|
+
exports.unexpectedError = exports.states = exports.response = void 0;
|
|
4
|
+
var response_1 = require("./response");
|
|
5
|
+
Object.defineProperty(exports, "response", { enumerable: true, get: function () { return response_1.response; } });
|
|
6
|
+
var states_1 = require("./states");
|
|
7
|
+
Object.defineProperty(exports, "states", { enumerable: true, get: function () { return states_1.states; } });
|
|
8
|
+
var unexpectedError_1 = require("./unexpectedError");
|
|
9
|
+
Object.defineProperty(exports, "unexpectedError", { enumerable: true, get: function () { return unexpectedError_1.unexpectedError; } });
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const states: {
|
|
2
|
+
ERROR: string;
|
|
3
|
+
IDLE: string;
|
|
4
|
+
PENDING: string;
|
|
5
|
+
SUCCESS: string;
|
|
6
|
+
VALIDATION_ERROR: string;
|
|
7
|
+
};
|
|
8
|
+
export declare type StateType = typeof states.ERROR | typeof states.IDLE | typeof states.PENDING | typeof states.SUCCESS | typeof states.VALIDATION_ERROR;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const unexpectedError: string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var index_1 = require("../index");
|
|
4
|
+
test('contains - does contain', function () {
|
|
5
|
+
var haystack = [1, 2, 3, 4];
|
|
6
|
+
expect((0, index_1.contains)({ haystack: haystack, needle: 1 }))
|
|
7
|
+
.toBeTruthy();
|
|
8
|
+
expect((0, index_1.contains)({ haystack: haystack, needle: 2 }))
|
|
9
|
+
.toBeTruthy();
|
|
10
|
+
expect((0, index_1.contains)({ haystack: haystack, needle: 3 }))
|
|
11
|
+
.toBeTruthy();
|
|
12
|
+
expect((0, index_1.contains)({ haystack: haystack, needle: 4 }))
|
|
13
|
+
.toBeTruthy();
|
|
14
|
+
});
|
|
15
|
+
test('contains - does not contain', function () {
|
|
16
|
+
expect((0, index_1.contains)({ haystack: [1, 2, 3, 4], needle: 9 }))
|
|
17
|
+
.toBeFalsy();
|
|
18
|
+
});
|
|
File without changes
|
package/dist/aws/getConfig.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ConfigType } from './config';
|
|
2
2
|
/**
|
|
3
3
|
* The config must be in a specific structure, if the properties aren't defined don't specify them as they could be inferred (e.g. Lambda).
|
|
4
4
|
*/
|
|
5
5
|
declare const getConfig: ({ config, isAthenaExpress }: {
|
|
6
|
-
config:
|
|
6
|
+
config: ConfigType;
|
|
7
7
|
isAthenaExpress: boolean;
|
|
8
8
|
}) => object;
|
|
9
9
|
export default getConfig;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ConfigType } from '../config';
|
|
2
2
|
/**
|
|
3
3
|
* Shorthand function to get the Glue Client.
|
|
4
4
|
* Library: @aws-sdk/client-glue
|
|
5
5
|
*/
|
|
6
6
|
declare const getClient: ({ GlueLib, config }: {
|
|
7
7
|
GlueLib: any;
|
|
8
|
-
config:
|
|
8
|
+
config: ConfigType;
|
|
9
9
|
}) => any;
|
|
10
10
|
export default getClient;
|
package/dist/aws/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ConfigType } from '../config';
|
|
2
2
|
/**
|
|
3
3
|
* Shorthand function to get the Lambda Client.
|
|
4
4
|
* Library: @aws-sdk/client-lambda
|
|
5
5
|
*/
|
|
6
6
|
declare const getClient: ({ LambdaLib, config }: {
|
|
7
7
|
LambdaLib: any;
|
|
8
|
-
config:
|
|
8
|
+
config: ConfigType;
|
|
9
9
|
}) => any;
|
|
10
10
|
export default getClient;
|
|
@@ -47,7 +47,7 @@ var deleteDirectory = function (_a) {
|
|
|
47
47
|
return __generator(this, function (_b) {
|
|
48
48
|
switch (_b.label) {
|
|
49
49
|
case 0:
|
|
50
|
-
cleanFolder = (0, string_1.getCleanFolder)(folder);
|
|
50
|
+
cleanFolder = (0, string_1.getCleanFolder)({ input: folder });
|
|
51
51
|
ListObjectsV2Command = S3Lib.ListObjectsV2Command, DeleteObjectsCommand = S3Lib.DeleteObjectsCommand;
|
|
52
52
|
return [4 /*yield*/, client.send(new ListObjectsV2Command({
|
|
53
53
|
Bucket: bucket,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ConfigType } from '../config';
|
|
2
2
|
/**
|
|
3
3
|
* Shorthand function to get the S3 Client.
|
|
4
4
|
* Library: @aws-sdk/client-s3
|
|
5
5
|
*/
|
|
6
6
|
declare const getClient: ({ S3Lib, config }: {
|
|
7
7
|
S3Lib: any;
|
|
8
|
-
config:
|
|
8
|
+
config: ConfigType;
|
|
9
9
|
}) => any;
|
|
10
10
|
export default getClient;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ResponseType } from '../../api';
|
|
2
2
|
declare type GetSignedUrlType = {
|
|
3
3
|
S3Lib: any;
|
|
4
4
|
S3PresignerLib: any;
|
|
@@ -11,5 +11,5 @@ declare type GetSignedUrlType = {
|
|
|
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<
|
|
14
|
+
declare const getSignedUrl: ({ S3Lib, S3PresignerLib, bucket, client, expires, file }: GetSignedUrlType) => Promise<ResponseType>;
|
|
15
15
|
export default getSignedUrl;
|
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
2
13
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
14
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
15
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -44,11 +55,11 @@ var api_1 = require("../../api");
|
|
|
44
55
|
var getSignedUrl = function (_a) {
|
|
45
56
|
var S3Lib = _a.S3Lib, S3PresignerLib = _a.S3PresignerLib, bucket = _a.bucket, client = _a.client, expires = _a.expires, file = _a.file;
|
|
46
57
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
47
|
-
var response, GetObjectCommand, getSignedUrl, command,
|
|
58
|
+
var response, GetObjectCommand, getSignedUrl, command, awsResponse;
|
|
48
59
|
return __generator(this, function (_b) {
|
|
49
60
|
switch (_b.label) {
|
|
50
61
|
case 0:
|
|
51
|
-
response = api_1.
|
|
62
|
+
response = __assign({}, api_1.response);
|
|
52
63
|
GetObjectCommand = S3Lib.GetObjectCommand;
|
|
53
64
|
getSignedUrl = S3PresignerLib.getSignedUrl;
|
|
54
65
|
command = new GetObjectCommand({
|
|
@@ -57,10 +68,10 @@ var getSignedUrl = function (_a) {
|
|
|
57
68
|
});
|
|
58
69
|
return [4 /*yield*/, getSignedUrl(client, command, { expiresIn: expires })];
|
|
59
70
|
case 1:
|
|
60
|
-
|
|
61
|
-
if (
|
|
62
|
-
response.status = api_1.
|
|
63
|
-
response.body =
|
|
71
|
+
awsResponse = _b.sent();
|
|
72
|
+
if (awsResponse && 'string' === typeof awsResponse) {
|
|
73
|
+
response.status = api_1.states.SUCCESS;
|
|
74
|
+
response.body = awsResponse;
|
|
64
75
|
}
|
|
65
76
|
return [2 /*return*/, response];
|
|
66
77
|
}
|
package/dist/aws/s3/listFiles.js
CHANGED
|
@@ -47,7 +47,7 @@ var listFiles = function (_a) {
|
|
|
47
47
|
return __generator(this, function (_c) {
|
|
48
48
|
switch (_c.label) {
|
|
49
49
|
case 0:
|
|
50
|
-
cleanFolder = (0, string_1.getCleanFolder)(folder);
|
|
50
|
+
cleanFolder = (0, string_1.getCleanFolder)({ input: folder });
|
|
51
51
|
response = [];
|
|
52
52
|
valid = [];
|
|
53
53
|
ListObjectsV2Command = S3Lib.ListObjectsV2Command;
|
|
@@ -47,7 +47,7 @@ var listFolders = function (_a) {
|
|
|
47
47
|
return __generator(this, function (_c) {
|
|
48
48
|
switch (_c.label) {
|
|
49
49
|
case 0:
|
|
50
|
-
cleanFolder = (0, string_1.getCleanFolder)(folder);
|
|
50
|
+
cleanFolder = (0, string_1.getCleanFolder)({ input: folder });
|
|
51
51
|
response = [];
|
|
52
52
|
ListObjectsV2Command = S3Lib.ListObjectsV2Command;
|
|
53
53
|
return [4 /*yield*/, client.send(new ListObjectsV2Command({
|
package/dist/aws/s3/readFile.js
CHANGED
|
@@ -97,7 +97,7 @@ var readFile = function (_a) {
|
|
|
97
97
|
response.modified.vsMidnight.minutes = (0, getMinutes_1.default)(now);
|
|
98
98
|
// Convert stream into a string
|
|
99
99
|
_b = response;
|
|
100
|
-
return [4 /*yield*/, (0, string_1.getStringFromStream)(apiResponse.Body)];
|
|
100
|
+
return [4 /*yield*/, (0, string_1.getStringFromStream)({ stream: apiResponse.Body })];
|
|
101
101
|
case 2:
|
|
102
102
|
// Convert stream into a string
|
|
103
103
|
_b.body = _c.sent();
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { ResponseType } from '../../api';
|
|
2
|
+
import { ConfigType } from '../config';
|
|
3
3
|
declare type WritePresignedPostType = {
|
|
4
4
|
bucket: string;
|
|
5
|
-
config:
|
|
5
|
+
config: ConfigType;
|
|
6
6
|
fields: any;
|
|
7
7
|
file: any;
|
|
8
8
|
fileName: string;
|
|
@@ -11,5 +11,5 @@ declare type WritePresignedPostType = {
|
|
|
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<
|
|
14
|
+
declare const writePresignedPost: ({ bucket, config, fields, file, fileName, url }: WritePresignedPostType) => Promise<ResponseType>;
|
|
15
15
|
export default writePresignedPost;
|
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
2
13
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
14
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
15
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -49,7 +60,7 @@ var writePresignedPost = function (_a) {
|
|
|
49
60
|
return __generator(this, function (_a) {
|
|
50
61
|
switch (_a.label) {
|
|
51
62
|
case 0:
|
|
52
|
-
response = api_1.
|
|
63
|
+
response = __assign({}, api_1.response);
|
|
53
64
|
formData = new FormData();
|
|
54
65
|
Object.entries({ fields: fields, file: file })
|
|
55
66
|
.forEach(function (_a) {
|
|
@@ -65,7 +76,7 @@ var writePresignedPost = function (_a) {
|
|
|
65
76
|
upload = _a.sent();
|
|
66
77
|
// Uploaded to S3
|
|
67
78
|
if (upload.ok) {
|
|
68
|
-
response.status = api_1.
|
|
79
|
+
response.status = api_1.states.SUCCESS;
|
|
69
80
|
response.body = {
|
|
70
81
|
url: "https://".concat(bucket, ".s3.").concat(config.region, ".amazonaws.com/").concat(fileName),
|
|
71
82
|
};
|
|
@@ -73,7 +84,7 @@ var writePresignedPost = function (_a) {
|
|
|
73
84
|
}
|
|
74
85
|
// Failed to upload to S3
|
|
75
86
|
else {
|
|
76
|
-
response.status = api_1.
|
|
87
|
+
response.status = api_1.states.ERROR;
|
|
77
88
|
response.error = 'Failed to upload file, please try again.';
|
|
78
89
|
reject(response);
|
|
79
90
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { durationComparisons, durations } from '../../date';
|
|
2
|
+
export declare type CacheType = {
|
|
3
|
+
duration: number;
|
|
4
|
+
from: typeof durationComparisons.VS_MIDNIGHT | typeof durationComparisons.VS_NOW;
|
|
5
|
+
timeframe: typeof durations.FOREVER | typeof durations.MONTHS | typeof durations.DAYS | typeof durations.HOURS | typeof durations.MINUTES;
|
|
6
|
+
};
|
|
File without changes
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ConfigType } from '../config';
|
|
2
2
|
/**
|
|
3
3
|
* Get the stored cache if it exists.
|
|
4
4
|
*/
|
|
@@ -6,7 +6,7 @@ declare const getCache: {
|
|
|
6
6
|
({ S3Lib, bucket, config, key, isJson }: {
|
|
7
7
|
S3Lib: any;
|
|
8
8
|
bucket: string;
|
|
9
|
-
config:
|
|
9
|
+
config: ConfigType;
|
|
10
10
|
key: string;
|
|
11
11
|
isJson: boolean;
|
|
12
12
|
}): Promise<any>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PlatformsType } from '../../environment/platforms';
|
|
2
2
|
/**
|
|
3
3
|
* Take an input and return the key.
|
|
4
4
|
* Always in the "_cache" folder with the "environment" followed by the optional folder then the key.
|
|
@@ -7,6 +7,6 @@ declare const getKey: ({ CryptoLib, fileName, folder, platform }: {
|
|
|
7
7
|
CryptoLib: any;
|
|
8
8
|
fileName: any;
|
|
9
9
|
folder: string;
|
|
10
|
-
platform:
|
|
10
|
+
platform: PlatformsType;
|
|
11
11
|
}) => string;
|
|
12
12
|
export default getKey;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import getCache from './getCache';
|
|
2
2
|
import getKey from './getKey';
|
|
3
3
|
import saveCache from './saveCache';
|
|
4
|
-
import {
|
|
4
|
+
import { CacheType } from './cache';
|
|
5
5
|
import updateCache from './updateCache';
|
|
6
|
-
export type {
|
|
6
|
+
export type { CacheType, };
|
|
7
7
|
export { getCache, getKey, saveCache, updateCache, };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ConfigType } from '../config';
|
|
2
2
|
/**
|
|
3
3
|
* Save the cache.
|
|
4
4
|
*/
|
|
5
5
|
declare const saveCache: ({ S3Lib, bucket, config, data, key }: {
|
|
6
6
|
S3Lib: any;
|
|
7
7
|
bucket: string;
|
|
8
|
-
config:
|
|
8
|
+
config: ConfigType;
|
|
9
9
|
key: string;
|
|
10
10
|
data: any;
|
|
11
11
|
}) => Promise<void>;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ConfigType } from '../config';
|
|
2
2
|
/**
|
|
3
3
|
* Delete other caches if present, then save the new file.
|
|
4
4
|
*/
|
|
5
5
|
declare const updateCache: ({ S3Lib, bucket, config, data, key }: {
|
|
6
6
|
S3Lib: any;
|
|
7
7
|
bucket: string;
|
|
8
|
-
config:
|
|
8
|
+
config: ConfigType;
|
|
9
9
|
data: any;
|
|
10
10
|
key: string;
|
|
11
11
|
}) => Promise<void>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ResponseType } from '../../api';
|
|
2
2
|
import { BaseClass } from '../../Class';
|
|
3
3
|
/**
|
|
4
4
|
* Class to build and send an AWS SES email.
|
|
@@ -48,6 +48,7 @@ declare class SimpleEmail extends BaseClass {
|
|
|
48
48
|
send({ SesLib, client }: {
|
|
49
49
|
SesLib: any;
|
|
50
50
|
client: any;
|
|
51
|
-
}): Promise<
|
|
51
|
+
}): Promise<ResponseType>;
|
|
52
|
+
private _filterRecipients;
|
|
52
53
|
}
|
|
53
54
|
export default SimpleEmail;
|
|
@@ -142,22 +142,17 @@ var SimpleEmail = /** @class */ (function (_super) {
|
|
|
142
142
|
SimpleEmail.prototype.send = function (_a) {
|
|
143
143
|
var SesLib = _a.SesLib, client = _a.client;
|
|
144
144
|
return __awaiter(this, void 0, void 0, function () {
|
|
145
|
-
var SendEmailCommand, response,
|
|
145
|
+
var SendEmailCommand, response, params, command, apiResponse_1, error_1;
|
|
146
146
|
return __generator(this, function (_b) {
|
|
147
147
|
switch (_b.label) {
|
|
148
148
|
case 0:
|
|
149
149
|
SendEmailCommand = SesLib.SendEmailCommand;
|
|
150
|
-
response = __assign({}, api_1.
|
|
151
|
-
clean = {
|
|
152
|
-
bcc: (0, uniq_1.default)(this.bcc.filter(function (value) { return value !== undefined && value !== null; })),
|
|
153
|
-
cc: (0, uniq_1.default)(this.cc.filter(function (value) { return value !== undefined && value !== null; })),
|
|
154
|
-
to: (0, uniq_1.default)(this.to.filter(function (value) { return value !== undefined && value !== null; })),
|
|
155
|
-
};
|
|
150
|
+
response = __assign({}, api_1.response);
|
|
156
151
|
params = {
|
|
157
152
|
Destination: {
|
|
158
|
-
BccAddresses:
|
|
159
|
-
CcAddresses:
|
|
160
|
-
ToAddresses:
|
|
153
|
+
BccAddresses: this._filterRecipients({ field: 'bcc' }),
|
|
154
|
+
CcAddresses: this._filterRecipients({ field: 'cc' }),
|
|
155
|
+
ToAddresses: this._filterRecipients({ field: 'to' }),
|
|
161
156
|
},
|
|
162
157
|
Message: {
|
|
163
158
|
Body: {
|
|
@@ -183,19 +178,19 @@ var SimpleEmail = /** @class */ (function (_super) {
|
|
|
183
178
|
command = new SendEmailCommand(params);
|
|
184
179
|
return [4 /*yield*/, client.send(command)];
|
|
185
180
|
case 2:
|
|
186
|
-
|
|
187
|
-
if ((0, isResponse200_1.default)({ apiResponse:
|
|
188
|
-
response.status = api_1.
|
|
181
|
+
apiResponse_1 = _b.sent();
|
|
182
|
+
if ((0, isResponse200_1.default)({ apiResponse: apiResponse_1 })) {
|
|
183
|
+
response.status = api_1.states.SUCCESS;
|
|
189
184
|
}
|
|
190
185
|
else {
|
|
191
|
-
response.status = api_1.
|
|
186
|
+
response.status = api_1.states.ERROR;
|
|
192
187
|
// @ts-ignore
|
|
193
188
|
response.error = "An unexpected error occurred.";
|
|
194
189
|
}
|
|
195
190
|
return [3 /*break*/, 4];
|
|
196
191
|
case 3:
|
|
197
192
|
error_1 = _b.sent();
|
|
198
|
-
response.status = api_1.
|
|
193
|
+
response.status = api_1.states.ERROR;
|
|
199
194
|
// @ts-ignore
|
|
200
195
|
response.error = error_1.message;
|
|
201
196
|
return [3 /*break*/, 4];
|
|
@@ -204,6 +199,19 @@ var SimpleEmail = /** @class */ (function (_super) {
|
|
|
204
199
|
});
|
|
205
200
|
});
|
|
206
201
|
};
|
|
202
|
+
SimpleEmail.prototype._filterRecipients = function (_a) {
|
|
203
|
+
var field = _a.field;
|
|
204
|
+
// Remove all undefined and null values
|
|
205
|
+
var response = this[field].filter(function (recipient) { return undefined !== recipient && null !== recipient; });
|
|
206
|
+
// Clean all the values
|
|
207
|
+
response = response.map(function (recipient) { return recipient.toLowerCase()
|
|
208
|
+
.trim(); });
|
|
209
|
+
// Remove all empty values
|
|
210
|
+
response = response.filter(function (recipient) { return '' !== recipient; });
|
|
211
|
+
// Return only unique values
|
|
212
|
+
response = (0, uniq_1.default)(response);
|
|
213
|
+
return response;
|
|
214
|
+
};
|
|
207
215
|
return SimpleEmail;
|
|
208
216
|
}(Class_1.BaseClass));
|
|
209
217
|
exports.default = SimpleEmail;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ConfigType } from '../config';
|
|
2
2
|
/**
|
|
3
3
|
* Shorthand function to get the SES Client.
|
|
4
4
|
* Library: @aws-sdk/client-ses
|
|
5
5
|
*/
|
|
6
6
|
declare const getClient: ({ SesLib, config }: {
|
|
7
7
|
SesLib: any;
|
|
8
|
-
config:
|
|
8
|
+
config: ConfigType;
|
|
9
9
|
}) => any;
|
|
10
10
|
export default getClient;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ConfigType } from '../config';
|
|
2
2
|
/**
|
|
3
3
|
* Shorthand function to get the Lambda Client.
|
|
4
4
|
* Library: @aws-sdk/client-ssm
|
|
5
5
|
*/
|
|
6
6
|
declare const getClient: ({ SsmLib, config }: {
|
|
7
7
|
SsmLib: any;
|
|
8
|
-
config:
|
|
8
|
+
config: ConfigType;
|
|
9
9
|
}) => any;
|
|
10
10
|
export default getClient;
|
package/dist/axios/get.d.ts
CHANGED
package/dist/axios/get.js
CHANGED
|
@@ -55,7 +55,7 @@ var get = function (_a) {
|
|
|
55
55
|
case 0:
|
|
56
56
|
if (!(200 === response.status)) return [3 /*break*/, 12];
|
|
57
57
|
if (!(undefined !== response.data.body && undefined !== response.data.error && undefined !== response.data.status)) return [3 /*break*/, 8];
|
|
58
|
-
if (!(api_1.
|
|
58
|
+
if (!(api_1.states.SUCCESS === response.data.status)) return [3 /*break*/, 4];
|
|
59
59
|
if (!onSuccess) return [3 /*break*/, 2];
|
|
60
60
|
return [4 /*yield*/, onSuccess(response.data.body)];
|
|
61
61
|
case 1:
|
package/dist/axios/index.d.ts
CHANGED
package/dist/axios/post.d.ts
CHANGED
package/dist/axios/post.js
CHANGED
|
@@ -58,7 +58,7 @@ var post = function (_a) {
|
|
|
58
58
|
case 0:
|
|
59
59
|
if (!(200 === response.status)) return [3 /*break*/, 12];
|
|
60
60
|
if (!(undefined !== response.data.body && undefined !== response.data.error && undefined !== response.data.status)) return [3 /*break*/, 8];
|
|
61
|
-
if (!(api_1.
|
|
61
|
+
if (!(api_1.states.SUCCESS === response.data.status)) return [3 /*break*/, 4];
|
|
62
62
|
if (!onSuccess) return [3 /*break*/, 2];
|
|
63
63
|
return [4 /*yield*/, onSuccess(response.data.body)];
|
|
64
64
|
case 1:
|
package/dist/crud/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export
|
|
4
|
-
export { CrudStatus, };
|
|
1
|
+
import { states, StateType } from './states';
|
|
2
|
+
export type { StateType, };
|
|
3
|
+
export { states, };
|
package/dist/crud/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
var
|
|
5
|
-
Object.defineProperty(exports, "
|
|
3
|
+
exports.states = void 0;
|
|
4
|
+
var states_1 = require("./states");
|
|
5
|
+
Object.defineProperty(exports, "states", { enumerable: true, get: function () { return states_1.states; } });
|