@hestia-earth/pipeline-utils 0.16.2 → 0.16.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/dist/gitlab.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import { Readable } from 'stream';
3
2
  export interface IGitlabTreeFile {
4
3
  id?: string;
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export * from './ec2';
2
2
  export * from './lambda';
3
3
  export * from './log';
4
+ export * from './mail';
4
5
  export * from './mongodb';
5
6
  export * from './progress';
6
7
  export * from './s3';
package/dist/index.js CHANGED
@@ -17,6 +17,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./ec2"), exports);
18
18
  __exportStar(require("./lambda"), exports);
19
19
  __exportStar(require("./log"), exports);
20
+ __exportStar(require("./mail"), exports);
20
21
  __exportStar(require("./mongodb"), exports);
21
22
  __exportStar(require("./progress"), exports);
22
23
  __exportStar(require("./s3"), exports);
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wCAAsB;AACtB,2CAAyB;AACzB,wCAAsB;AACtB,4CAA0B;AAC1B,6CAA2B;AAC3B,uCAAqB;AACrB,0CAAwB;AACxB,wCAAsB;AACtB,wCAAsB;AACtB,0CAAwB;AACxB,sDAAoC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wCAAsB;AACtB,2CAAyB;AACzB,wCAAsB;AACtB,yCAAuB;AACvB,4CAA0B;AAC1B,6CAA2B;AAC3B,uCAAqB;AACrB,0CAAwB;AACxB,wCAAsB;AACtB,wCAAsB;AACtB,0CAAwB;AACxB,sDAAoC"}
package/dist/mail.d.ts ADDED
@@ -0,0 +1 @@
1
+ export declare const sendTemplatedEmail: (template: string, emails: string[], data?: {}) => Promise<import("@aws-sdk/client-ses").SendTemplatedEmailCommandOutput>;
package/dist/mail.js ADDED
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sendTemplatedEmail = void 0;
4
+ const client_ses_1 = require("@aws-sdk/client-ses");
5
+ const utils_1 = require("./utils");
6
+ const fromEmail = 'no-reply@hestia.earth';
7
+ const fromName = 'Hestia Earth Team';
8
+ const sendTemplatedEmail = async (template, emails, data = {}) => {
9
+ const params = {
10
+ Source: fromEmail,
11
+ Destination: {
12
+ ToAddresses: emails
13
+ },
14
+ Template: template,
15
+ TemplateData: JSON.stringify({
16
+ ...data,
17
+ baseUrl: utils_1.baseUrl,
18
+ fromName
19
+ })
20
+ };
21
+ return await new client_ses_1.SESClient({ region: 'us-east-1' }).send(new client_ses_1.SendTemplatedEmailCommand(params));
22
+ };
23
+ exports.sendTemplatedEmail = sendTemplatedEmail;
24
+ //# sourceMappingURL=mail.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mail.js","sourceRoot":"","sources":["../src/mail.ts"],"names":[],"mappings":";;;AAAA,oDAA2G;AAE3G,mCAAkC;AAElC,MAAM,SAAS,GAAG,uBAAuB,CAAC;AAC1C,MAAM,QAAQ,GAAG,mBAAmB,CAAC;AAE9B,MAAM,kBAAkB,GAAG,KAAK,EAAE,QAAgB,EAAE,MAAgB,EAAE,IAAI,GAAG,EAAE,EAAE,EAAE;IACxF,MAAM,MAAM,GAAmC;QAC7C,MAAM,EAAE,SAAS;QACjB,WAAW,EAAE;YACX,WAAW,EAAE,MAAM;SACpB;QACD,QAAQ,EAAE,QAAQ;QAClB,YAAY,EAAE,IAAI,CAAC,SAAS,CAAC;YAC3B,GAAG,IAAI;YACP,OAAO,EAAP,eAAO;YACP,QAAQ;SACT,CAAC;KACH,CAAC;IACF,OAAO,MAAM,IAAI,sBAAS,CAAC,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,sCAAyB,CAAC,MAAM,CAAC,CAAC,CAAC;AAClG,CAAC,CAAC;AAdW,QAAA,kBAAkB,sBAc7B"}
package/dist/mongodb.d.ts CHANGED
@@ -2,111 +2,17 @@ import { Db } from 'mongodb';
2
2
  import { Aggregation, File, User, FileStatus, Reconciliation, Setting, SettingKey, Migration, MigrationType } from '@hestia-earth/api';
3
3
  export declare const transaction: <T>(query: (db: Db) => Promise<T>, defaultValue?: T) => Promise<T>;
4
4
  export declare const idsQuery: (ids: string[]) => any;
5
- export declare const getAggregations: <U extends keyof Aggregation>(conditions: {
6
- folder?: any;
7
- filename?: any;
8
- filepath?: any;
9
- validatedAt?: any;
10
- status?: any;
11
- pipelineStatus?: any;
12
- readonly productId?: any;
13
- readonly countryId?: any;
14
- readonly startYear?: any;
15
- readonly endYear?: any;
16
- id?: any;
17
- createdAt?: any;
18
- updatedAt?: any;
19
- }, props: U[], limit?: number) => Promise<Pick<Aggregation, U>[]>;
5
+ export declare const getAggregations: <U extends keyof Aggregation>(conditions: { [key in keyof Partial<Aggregation>]: any; }, props: U[], limit?: number) => Promise<Pick<Aggregation, U>[]>;
20
6
  export declare const upsertAggregation: (filepath: string, data?: Partial<Aggregation>) => Promise<import("mongodb").UpdateWriteOpResult>;
21
7
  export declare const removeAggregations: (ids: string[]) => Promise<import("mongodb").DeleteWriteOpResultObject>;
22
8
  export declare const removeAggregationsByTerms: (termId: string | string[]) => Promise<import("mongodb").DeleteWriteOpResultObject>;
23
- export declare const getFiles: <U extends keyof File>(conditions: {
24
- filename?: any;
25
- filepath?: any;
26
- folder?: any;
27
- user?: any;
28
- assignedUsers?: any;
29
- authorizedUsers?: any;
30
- contentType?: any;
31
- archived?: any;
32
- status?: any;
33
- pipelineStatus?: any;
34
- userValidatedAt?: any;
35
- validatedAt?: any;
36
- schemaVersion?: any;
37
- schemaOutdated?: any;
38
- glossaryOutdated?: any;
39
- comments?: any;
40
- todos?: any;
41
- metadata?: any;
42
- isPrivate?: any;
43
- skipValidation?: any;
44
- study?: any;
45
- fromDraft?: any;
46
- readonly isOwner?: any;
47
- readonly isAuthorized?: any;
48
- readonly isAssignedToMe?: any;
49
- readonly isValidated?: any;
50
- readonly isDraft?: any;
51
- readonly originalPath?: any;
52
- readonly hestiaPath?: any;
53
- readonly progressPath?: any;
54
- readonly studyPath?: any;
55
- readonly dataPath?: any;
56
- readonly dataProgressPath?: any;
57
- readonly dataCsvPath?: any;
58
- readonly dataRecalculatedCsvPath?: any;
59
- readonly logPath?: any;
60
- readonly errorPath?: any;
61
- readonly sources?: any;
62
- readonly nbCycles?: any;
63
- readonly nbImpactAssessments?: any;
64
- readonly hestiaDataPath?: any;
65
- id?: any;
66
- createdAt?: any;
67
- updatedAt?: any;
68
- }, props: U[], limit?: number) => Promise<Pick<File, U>[]>;
9
+ export declare const getFiles: <U extends keyof File>(conditions: { [key in keyof Partial<File>]: any; }, props: U[], limit?: number) => Promise<Pick<File, U>[]>;
69
10
  export declare const getFile: (filepath: string) => Promise<Partial<File>>;
70
11
  export declare const updateFile: (filepath: string, data?: Partial<File>) => Promise<import("mongodb").UpdateWriteOpResult>;
71
12
  export declare const updateFiles: (ids: string[], data?: Partial<File>) => Promise<import("mongodb").UpdateWriteOpResult>;
72
13
  export declare const removeFile: (id: string) => Promise<import("mongodb").DeleteWriteOpResultObject>;
73
14
  export declare const countUserFiles: (userId: string, statuses?: FileStatus[]) => Promise<number>;
74
- export declare const getUsers: <U extends keyof User>(conditions: {
75
- email?: any;
76
- firstName?: any;
77
- lastName?: any;
78
- displayName?: any;
79
- password?: any;
80
- token?: any;
81
- role?: any;
82
- maxUploads?: any;
83
- maxApiCalls?: any;
84
- dataPrivate?: any;
85
- validFilesCount?: any;
86
- canCommitHestiaData?: any;
87
- permissions?: any;
88
- emailNotificationsSuccess?: any;
89
- emailNotificationsFailure?: any;
90
- emailNotificationsFeedback?: any;
91
- autoSubmitPrivateSubmissions?: any;
92
- confirmToken?: any;
93
- confirmedAt?: any;
94
- lastActiveAt?: any;
95
- scopusID?: any;
96
- googleID?: any;
97
- linkedInID?: any;
98
- orcid?: any;
99
- website?: any;
100
- city?: any;
101
- country?: any;
102
- primaryInstitution?: any;
103
- readonly admin?: any;
104
- readonly name?: any;
105
- readonly actorId?: any;
106
- id?: any;
107
- createdAt?: any;
108
- updatedAt?: any;
109
- }, props: U[], limit?: number) => Promise<Pick<User, U>[]>;
15
+ export declare const getUsers: <U extends keyof User>(conditions: { [key in keyof Partial<User>]: any; }, props: U[], limit?: number) => Promise<Pick<User, U>[]>;
110
16
  export declare const getUser: (userId: string) => Promise<Partial<User>>;
111
17
  export declare const getUserFromFilepath: (filepath?: string) => Promise<Partial<User>>;
112
18
  export declare const updateUser: (userId: string, data?: Partial<User>) => Promise<import("mongodb").UpdateWriteOpResult>;
@@ -123,13 +29,7 @@ export declare const updateReconciliation: ({ id, ...query }?: Partial<Reconcili
123
29
  export declare const updateReconciliations: (data: Partial<Reconciliation>[]) => Promise<import("mongodb").BulkWriteResult>;
124
30
  export declare const upsertReconciliation: (filter: Partial<Reconciliation>, data?: Partial<Reconciliation>) => Promise<import("mongodb").UpdateWriteOpResult>;
125
31
  export declare const removeReconciliations: (ids: string[]) => Promise<import("mongodb").DeleteWriteOpResultObject>;
126
- export declare const getMigrations: <U extends keyof Migration>(type: MigrationType, conditions: {
127
- filenames?: any;
128
- type?: any;
129
- id?: any;
130
- createdAt?: any;
131
- updatedAt?: any;
132
- }, props: U[], limit?: number) => Promise<Pick<Migration, U>[]>;
32
+ export declare const getMigrations: <U extends keyof Migration>(type: MigrationType, conditions: { [key in keyof Partial<Migration>]: any; }, props: U[], limit?: number) => Promise<Pick<Migration, U>[]>;
133
33
  export declare const addMigration: (type: MigrationType, filenames: string[]) => Promise<import("mongodb").InsertOneWriteOpResult<any>>;
134
34
  export declare const getSetting: (key: SettingKey) => Promise<Setting>;
135
35
  export declare const updateSetting: (key: SettingKey, data: Partial<Setting>) => Promise<import("mongodb").UpdateWriteOpResult>;
package/dist/s3.d.ts CHANGED
@@ -1,6 +1,3 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
- /// <reference types="node" />
4
1
  import { S3Client, GetObjectCommandInput, PutObjectCommandInput, MetadataDirective, _Object, ObjectIdentifier, DeletedObject } from '@aws-sdk/client-s3';
5
2
  import { Observable } from 'rxjs';
6
3
  import { Readable } from 'stream';
@@ -26,7 +23,7 @@ export declare const copyObject: (fromParams: {
26
23
  key: string;
27
24
  }, metadata?: any, metadataDirective?: MetadataDirective) => Observable<import("@aws-sdk/client-s3").CopyObjectCommandOutput>;
28
25
  export declare const loadStream: (key: string, Bucket?: string) => Readable;
29
- export declare const loadFile: (key: string, Bucket?: string) => Observable<Buffer>;
26
+ export declare const loadFile: (key: string, Bucket?: string) => Observable<Buffer<ArrayBufferLike>>;
30
27
  export declare const streamJSONFile: <T>(key: string, Bucket?: string) => Observable<T>;
31
28
  export declare const loadTextFile: (key: string, Bucket?: string) => Observable<string>;
32
29
  export declare const loadJSONFile: <T>(key: string, Bucket?: string) => Observable<T>;
package/dist/sqs.d.ts CHANGED
@@ -3,5 +3,5 @@ import { IFunctionParam } from './s3';
3
3
  type attributes = {
4
4
  [key: string]: string;
5
5
  };
6
- export declare const sendSqsMessage: (functionName: string, params: IFunctionParam | Record<string, any>, queueUrl?: string, extras?: attributes, requestParams?: Partial<Omit<SendMessageCommandInput, 'QueueUrl' | 'MessageBody' | 'MessageAttributes'>>) => import("rxjs").Observable<import("@aws-sdk/client-sqs").SendMessageCommandOutput>;
6
+ export declare const sendSqsMessage: (functionName: string, params: IFunctionParam | Record<string, any>, queueUrl?: string, extras?: attributes, requestParams?: Partial<Omit<SendMessageCommandInput, "QueueUrl" | "MessageBody" | "MessageAttributes">>) => import("rxjs").Observable<import("@aws-sdk/client-sqs").SendMessageCommandOutput>;
7
7
  export {};
package/dist/utils.d.ts CHANGED
@@ -20,7 +20,6 @@ export declare const returnError: (err: any) => {
20
20
  };
21
21
  body: string;
22
22
  };
23
- export declare const spliceAndProcess: <T, R>(docs: T[], func: (p: T[]) => Promise<R>, count?: number) => Promise<void | R>;
24
23
  export declare const isEmpty: (value: any, minKeys?: number) => boolean;
25
24
  export declare const refToSchemaType: (ref: any) => any;
26
25
  export declare const prependWithKey: (data: any, key: string) => {};
package/dist/utils.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.byteSize = exports.stripBOM = exports.prependWithKey = exports.refToSchemaType = exports.isEmpty = exports.spliceAndProcess = exports.returnError = exports.returnResponse = exports.functionParamToSNSRecord = exports.functionParamToS3Record = exports.recordToFunctionParam = exports.baseUrl = void 0;
3
+ exports.byteSize = exports.stripBOM = exports.prependWithKey = exports.refToSchemaType = exports.isEmpty = exports.returnError = exports.returnResponse = exports.functionParamToSNSRecord = exports.functionParamToS3Record = exports.recordToFunctionParam = exports.baseUrl = void 0;
4
4
  const utils_1 = require("@hestia-earth/utils");
5
5
  const log_1 = require("./log");
6
6
  exports.baseUrl = process.env.DOMAIN || '';
@@ -53,16 +53,6 @@ const returnError = err => {
53
53
  return (0, exports.returnResponse)({ error: errorContent }, status || defaultErrorStatus);
54
54
  };
55
55
  exports.returnError = returnError;
56
- const spliceAndProcess = (docs, func, count = 1) => new Promise(resolve => {
57
- if (!docs.length) {
58
- return resolve();
59
- }
60
- const remaining = docs.splice(docs.length - count);
61
- void func(remaining)
62
- .then(() => (0, exports.spliceAndProcess)(docs, func, count))
63
- .then(resolve);
64
- });
65
- exports.spliceAndProcess = spliceAndProcess;
66
56
  const isEmpty = (value, minKeys = 1) => typeof value === 'object'
67
57
  ? Array.isArray(value)
68
58
  ? !value.length
package/dist/utils.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;AACA,+CAA4D;AAG5D,+BAA8B;AAEjB,QAAA,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,M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C,OAAO,KAAK,KAAK,WAAW,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,EAAE,CAAC;AALxD,QAAA,OAAO,WAKiD;AAE9D,MAAM,eAAe,GAAG,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;AAAhE,QAAA,eAAe,mBAAiD;AAEtE,MAAM,cAAc,GAAG,CAAC,IAAS,EAAE,GAAW,EAAE,EAAE,CACvD,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,CAAC,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;AADjF,QAAA,cAAc,kBACmE;AAEvF,MAAM,QAAQ,GAAG,CAAC,OAAe,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;AAAhG,QAAA,QAAQ,YAAwF;AAEtG,MAAM,QAAQ,GAAG,CAAC,KAAsB,EAAE,EAAE,CACjD,MAAM,CAAC,UAAU,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;AADlE,QAAA,QAAQ,YAC0D"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hestia-earth/pipeline-utils",
3
- "version": "0.16.2",
3
+ "version": "0.16.4",
4
4
  "description": "Utilities for running pipelines",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -28,23 +28,24 @@
28
28
  },
29
29
  "homepage": "https://gitlab.com/hestia-earth/hestia-pipeline-utils#readme",
30
30
  "dependencies": {
31
- "@aws-sdk/client-ec2": "^3.525.0",
32
- "@aws-sdk/client-lambda": "^3.525.0",
33
- "@aws-sdk/client-s3": "^3.525.0",
34
- "@aws-sdk/client-sns": "^3.525.0",
35
- "@aws-sdk/client-sqs": "^3.525.0",
36
- "@aws-sdk/lib-storage": "^3.525.0",
31
+ "@aws-sdk/client-ec2": "^3.962.0",
32
+ "@aws-sdk/client-lambda": "^3.962.0",
33
+ "@aws-sdk/client-s3": "^3.962.0",
34
+ "@aws-sdk/client-ses": "^3.962.0",
35
+ "@aws-sdk/client-sns": "^3.962.0",
36
+ "@aws-sdk/client-sqs": "^3.962.0",
37
+ "@aws-sdk/lib-storage": "^3.962.0",
37
38
  "@aws-sdk/util-utf8-node": "^3.259.0",
38
39
  "@elastic/elasticsearch": "7.13.0",
39
- "@slack/web-api": "^7.7.0",
40
- "axios": "^1.4.0",
40
+ "@slack/web-api": "^7.13.0",
41
+ "axios": "^1.13.2",
41
42
  "bson": "^4.7.2",
42
43
  "lodash.get": "^4.4.2",
43
44
  "lodash.omit": "^4.5.0",
44
45
  "lodash.pick": "^4.4.0",
45
46
  "memory-cache": "^0.2.0",
46
47
  "mongodb": "^3.7.4",
47
- "rxjs": "^7.8.1"
48
+ "rxjs": "^7.8.2"
48
49
  },
49
50
  "peerDependencies": {
50
51
  "@hestia-earth/api": ">=0.21.0",
@@ -55,12 +56,12 @@
55
56
  "devDependencies": {
56
57
  "@commitlint/cli": "^17.8.1",
57
58
  "@commitlint/config-conventional": "^17.8.1",
58
- "@hestia-earth/api": "^0.24.50",
59
- "@hestia-earth/eslint-config": "^0.1.0",
60
- "@hestia-earth/json-schema": "^30.3.2",
61
- "@hestia-earth/schema": "^30.3.2",
62
- "@hestia-earth/utils": "^0.13.9",
63
- "@types/aws-lambda": "^8.10.130",
59
+ "@hestia-earth/api": "^0.24.82",
60
+ "@hestia-earth/eslint-config": "^0.1.1",
61
+ "@hestia-earth/json-schema": "^30.7.3",
62
+ "@hestia-earth/schema": "^30.7.3",
63
+ "@hestia-earth/utils": "^0.13.30",
64
+ "@types/aws-lambda": "^8.10.159",
64
65
  "@types/jest": "^30.0.0",
65
66
  "@types/lodash.get": "^4.4.9",
66
67
  "@types/lodash.omit": "^4.5.9",
@@ -69,16 +70,16 @@
69
70
  "@types/node": "^22.19.3",
70
71
  "@typescript-eslint/eslint-plugin": "^5.62.0",
71
72
  "@typescript-eslint/parser": "^5.62.0",
72
- "dotenv": "^16.4.7",
73
+ "dotenv": "^16.6.1",
73
74
  "eslint": "^7.32.0",
74
75
  "eslint-plugin-jsdoc": "^30.7.13",
75
76
  "husky": "^4.3.8",
76
77
  "jest": "^30.2.0",
77
- "prettier": "^3.1.1",
78
+ "prettier": "^3.7.4",
78
79
  "standard-version": "^9.5.0",
79
80
  "ts-jest": "^29.4.6",
80
81
  "ts-node": "^10.9.2",
81
- "typescript": "^5.3.3"
82
+ "typescript": "^5.9.3"
82
83
  },
83
84
  "husky": {
84
85
  "hooks": {
package/src/index.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export * from './ec2';
2
2
  export * from './lambda';
3
3
  export * from './log';
4
+ export * from './mail';
4
5
  export * from './mongodb';
5
6
  export * from './progress';
6
7
  export * from './s3';
package/src/mail.ts ADDED
@@ -0,0 +1,22 @@
1
+ import { SESClient, SendTemplatedEmailCommand, SendTemplatedEmailCommandInput } from '@aws-sdk/client-ses';
2
+
3
+ import { baseUrl } from './utils';
4
+
5
+ const fromEmail = 'no-reply@hestia.earth';
6
+ const fromName = 'Hestia Earth Team';
7
+
8
+ export const sendTemplatedEmail = async (template: string, emails: string[], data = {}) => {
9
+ const params: SendTemplatedEmailCommandInput = {
10
+ Source: fromEmail,
11
+ Destination: {
12
+ ToAddresses: emails
13
+ },
14
+ Template: template,
15
+ TemplateData: JSON.stringify({
16
+ ...data,
17
+ baseUrl,
18
+ fromName
19
+ })
20
+ };
21
+ return await new SESClient({ region: 'us-east-1' }).send(new SendTemplatedEmailCommand(params));
22
+ };
package/src/utils.ts CHANGED
@@ -62,18 +62,6 @@ export const returnError = err => {
62
62
  return returnResponse({ error: errorContent }, status || defaultErrorStatus);
63
63
  };
64
64
 
65
- export const spliceAndProcess = <T, R>(docs: T[], func: (p: T[]) => Promise<R>, count = 1) =>
66
- new Promise<R | void>(resolve => {
67
- if (!docs.length) {
68
- return resolve();
69
- }
70
- const remaining = docs.splice(docs.length - count);
71
-
72
- void func(remaining)
73
- .then(() => spliceAndProcess(docs, func, count))
74
- .then(resolve);
75
- });
76
-
77
65
  export const isEmpty = (value: any, minKeys = 1) =>
78
66
  typeof value === 'object'
79
67
  ? Array.isArray(value)