@8ms/helpers 2.4.10 → 2.4.12
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/_class/BaseClass.cjs +31 -21
- package/dist/_class/BaseClass.mjs +31 -21
- package/dist/_class/BaseNamespace.cjs +10 -9
- package/dist/_class/BaseNamespace.mjs +10 -9
- package/dist/_virtual/_rolldown/runtime.cjs +1 -1
- package/dist/_virtual/_rolldown/runtime.mjs +1 -1
- package/dist/api/ApiResponseClass.cjs +96 -96
- package/dist/api/ApiResponseClass.mjs +96 -96
- package/dist/aws/cloudWatchLog/server/AwsCloudWatchLogNamespace.cjs +70 -60
- package/dist/aws/cloudWatchLog/server/AwsCloudWatchLogNamespace.mjs +70 -60
- package/dist/aws/cloudWatchMetric/server/AwsCloudWatchMetricNamespace.cjs +30 -28
- package/dist/aws/cloudWatchMetric/server/AwsCloudWatchMetricNamespace.mjs +30 -28
- package/dist/aws/ec2/server/AwsEc2Namespace.cjs +29 -32
- package/dist/aws/ec2/server/AwsEc2Namespace.mjs +29 -32
- package/dist/aws/ecs/server/AwsEcsNamespace.cjs +92 -78
- package/dist/aws/ecs/server/AwsEcsNamespace.mjs +92 -78
- package/dist/aws/glue/server/AwsGlueNamespace.cjs +17 -17
- package/dist/aws/glue/server/AwsGlueNamespace.mjs +17 -17
- package/dist/aws/lambda/server/AwsLambdaNamespace.cjs +33 -31
- package/dist/aws/lambda/server/AwsLambdaNamespace.mjs +33 -31
- package/dist/aws/s3/server/AwsS3Namespace.cjs +280 -265
- package/dist/aws/s3/server/AwsS3Namespace.mjs +280 -265
- package/dist/aws/ses/server/AwsSesNamespace.cjs +27 -30
- package/dist/aws/ses/server/AwsSesNamespace.mjs +27 -30
- package/dist/aws/ses/server/SimpleEmail.cjs +202 -199
- package/dist/aws/ses/server/SimpleEmail.mjs +202 -199
- package/dist/aws/sqs/server/AwsSqsNamespace.cjs +35 -38
- package/dist/aws/sqs/server/AwsSqsNamespace.mjs +35 -38
- package/dist/aws/ssm/server/AwsSsmNamespace.cjs +24 -23
- package/dist/aws/ssm/server/AwsSsmNamespace.mjs +24 -23
- package/dist/date/index.cjs +1 -1
- package/dist/date/index.mjs +1 -1
- package/dist/drizzle/server/DrizzleNamespace.cjs +39 -42
- package/dist/drizzle/server/DrizzleNamespace.d.cts +1 -0
- package/dist/drizzle/server/DrizzleNamespace.mjs +39 -42
- package/dist/googleAds/server/GoogleAdsNamespace.cjs +21 -24
- package/dist/googleAds/server/GoogleAdsNamespace.mjs +21 -24
- package/dist/googleCloud/bigquery/server/GoogleCloudBigqueryNamespace.cjs +87 -70
- package/dist/googleCloud/bigquery/server/GoogleCloudBigqueryNamespace.mjs +87 -70
- package/dist/googleCloud/sheets/server/GoogleCloudSheetsNamespace.cjs +22 -25
- package/dist/googleCloud/sheets/server/GoogleCloudSheetsNamespace.mjs +22 -25
- package/dist/googleCloud/storage/server/GoogleCloudStorageNamespace.cjs +45 -38
- package/dist/googleCloud/storage/server/GoogleCloudStorageNamespace.mjs +45 -38
- package/dist/googlePageSpeed/server/GooglePageSpeedNamespace.cjs +12 -15
- package/dist/googlePageSpeed/server/GooglePageSpeedNamespace.mjs +12 -15
- package/dist/littleWarden/server/LittleWardenNamespace.cjs +12 -15
- package/dist/littleWarden/server/LittleWardenNamespace.mjs +12 -15
- package/dist/nextJs/client/index.cjs +2 -0
- package/dist/nextJs/client/index.d.cts +2 -1
- package/dist/nextJs/client/index.d.mts +2 -1
- package/dist/nextJs/client/index.mjs +2 -1
- package/dist/nextJs/client/useAsyncEffect.cjs +23 -0
- package/dist/nextJs/client/useAsyncEffect.d.cts +4 -0
- package/dist/nextJs/client/useAsyncEffect.d.mts +4 -0
- package/dist/nextJs/client/useAsyncEffect.mjs +21 -0
- package/dist/onePassword/server/OnePasswordNamespace.cjs +30 -33
- package/dist/onePassword/server/OnePasswordNamespace.mjs +30 -33
- package/dist/openAi/server/OpenAiNamespace.cjs +20 -20
- package/dist/openAi/server/OpenAiNamespace.mjs +20 -20
- package/dist/prisma/server/PrismaNamespace.cjs +35 -38
- package/dist/prisma/server/PrismaNamespace.mjs +35 -38
- package/dist/snapchat/server/SnapchatNamespace.cjs +12 -12
- package/dist/snapchat/server/SnapchatNamespace.mjs +12 -12
- package/dist/upTimeRobot/server/UpTimeRobotNamespace.cjs +19 -19
- package/dist/upTimeRobot/server/UpTimeRobotNamespace.mjs +19 -19
- package/package.json +4 -12
- package/dist/nextJs/index.cjs +0 -4
- package/dist/nextJs/index.d.cts +0 -2
- package/dist/nextJs/index.d.mts +0 -2
- package/dist/nextJs/index.mjs +0 -2
- package/dist/nextJs/nextJs.cjs +0 -13
- package/dist/nextJs/nextJs.d.cts +0 -19
- package/dist/nextJs/nextJs.d.mts +0 -19
- package/dist/nextJs/nextJs.mjs +0 -11
- package/dist/nextJs/tests/getIp.cjs +0 -9
- package/dist/nextJs/tests/getIp.d.cts +0 -1
- package/dist/nextJs/tests/getIp.d.mts +0 -1
- package/dist/nextJs/tests/getIp.mjs +0 -10
|
@@ -4,207 +4,15 @@ import { BaseClass } from "../../../_class/BaseClass.mjs";
|
|
|
4
4
|
* Class to build and send an AWS SES email.
|
|
5
5
|
*/
|
|
6
6
|
var SimpleEmail = class extends BaseClass {
|
|
7
|
+
from;
|
|
8
|
+
to = [];
|
|
9
|
+
cc = [];
|
|
10
|
+
bcc = [];
|
|
11
|
+
html;
|
|
12
|
+
subject;
|
|
13
|
+
attachments = [];
|
|
7
14
|
constructor({ bcc, cc, from, html, subject, to, attachments }) {
|
|
8
15
|
super();
|
|
9
|
-
this.to = [];
|
|
10
|
-
this.cc = [];
|
|
11
|
-
this.bcc = [];
|
|
12
|
-
this.attachments = [];
|
|
13
|
-
this.setFrom = (from) => {
|
|
14
|
-
return this._setValue("from", from);
|
|
15
|
-
};
|
|
16
|
-
this.setHtml = (html) => {
|
|
17
|
-
return this._setValue("html", html);
|
|
18
|
-
};
|
|
19
|
-
this.setSubject = (subject) => {
|
|
20
|
-
return this._setValue("subject", subject);
|
|
21
|
-
};
|
|
22
|
-
this.setAttachments = (attachments) => {
|
|
23
|
-
return this._setValue("attachments", attachments);
|
|
24
|
-
};
|
|
25
|
-
this.addAttachment = (attachment) => {
|
|
26
|
-
this.attachments.push(attachment);
|
|
27
|
-
return this;
|
|
28
|
-
};
|
|
29
|
-
this.addAttachmentFromdata = (filename, data, contentType) => {
|
|
30
|
-
return this.addAttachment({
|
|
31
|
-
filename,
|
|
32
|
-
data,
|
|
33
|
-
contentType: contentType || this._getContentTypeFromFilename(filename)
|
|
34
|
-
});
|
|
35
|
-
};
|
|
36
|
-
this.addAttachmentFromUrl = (filename, url, contentType) => {
|
|
37
|
-
return this.addAttachment({
|
|
38
|
-
filename,
|
|
39
|
-
url,
|
|
40
|
-
contentType: contentType || this._getContentTypeFromFilename(filename)
|
|
41
|
-
});
|
|
42
|
-
};
|
|
43
|
-
this.clearAttachments = () => {
|
|
44
|
-
this.attachments = [];
|
|
45
|
-
return this;
|
|
46
|
-
};
|
|
47
|
-
this.pushBcc = (recipient) => {
|
|
48
|
-
return this._push("bcc", recipient);
|
|
49
|
-
};
|
|
50
|
-
this.pushCc = (recipient) => {
|
|
51
|
-
return this._push("cc", recipient);
|
|
52
|
-
};
|
|
53
|
-
this.pushTo = (recipient) => {
|
|
54
|
-
return this._push("to", recipient);
|
|
55
|
-
};
|
|
56
|
-
this.setBcc = (recipient) => {
|
|
57
|
-
return this._setArray("bcc", recipient);
|
|
58
|
-
};
|
|
59
|
-
this.setCc = (recipient) => {
|
|
60
|
-
return this._setArray("cc", recipient);
|
|
61
|
-
};
|
|
62
|
-
this.setTo = (recipient) => {
|
|
63
|
-
return this._setArray("to", recipient);
|
|
64
|
-
};
|
|
65
|
-
this.getSendParam = async () => {
|
|
66
|
-
if (this.attachments.length > 0) return await this._getRawEmailParams();
|
|
67
|
-
return {
|
|
68
|
-
Destination: {
|
|
69
|
-
BccAddresses: this._filterRecipients("bcc"),
|
|
70
|
-
CcAddresses: this._filterRecipients("cc"),
|
|
71
|
-
ToAddresses: this._filterRecipients("to")
|
|
72
|
-
},
|
|
73
|
-
Message: {
|
|
74
|
-
Body: {
|
|
75
|
-
Html: {
|
|
76
|
-
Charset: "UTF-8",
|
|
77
|
-
Data: this.html
|
|
78
|
-
},
|
|
79
|
-
Text: {
|
|
80
|
-
Charset: "UTF-8",
|
|
81
|
-
Data: this.html
|
|
82
|
-
}
|
|
83
|
-
},
|
|
84
|
-
Subject: {
|
|
85
|
-
Charset: "UTF-8",
|
|
86
|
-
Data: this.subject
|
|
87
|
-
}
|
|
88
|
-
},
|
|
89
|
-
Source: this.from
|
|
90
|
-
};
|
|
91
|
-
};
|
|
92
|
-
this._getRawEmailParams = async () => {
|
|
93
|
-
const boundary = `----=_NextPart_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
|
|
94
|
-
const allRecipients = [
|
|
95
|
-
...this._filterRecipients("to"),
|
|
96
|
-
...this._filterRecipients("cc"),
|
|
97
|
-
...this._filterRecipients("bcc")
|
|
98
|
-
];
|
|
99
|
-
let rawMessage = "";
|
|
100
|
-
rawMessage += `From: ${this.from}\r\n`;
|
|
101
|
-
if (this._filterRecipients("to").length > 0) rawMessage += `To: ${this._filterRecipients("to").join(", ")}\r\n`;
|
|
102
|
-
if (this._filterRecipients("cc").length > 0) rawMessage += `Cc: ${this._filterRecipients("cc").join(", ")}\r\n`;
|
|
103
|
-
rawMessage += `Subject: ${this.subject}\r\n`;
|
|
104
|
-
rawMessage += `MIME-Version: 1.0\r\n`;
|
|
105
|
-
rawMessage += `Content-Type: multipart/mixed; boundary="${boundary}"\r\n\r\n`;
|
|
106
|
-
rawMessage += `--${boundary}\r\n`;
|
|
107
|
-
rawMessage += `Content-Type: text/html; charset=UTF-8\r\n`;
|
|
108
|
-
rawMessage += `Content-Transfer-Encoding: 7bit\r\n\r\n`;
|
|
109
|
-
rawMessage += `${this.html}\r\n\r\n`;
|
|
110
|
-
for (const attachment of this.attachments) {
|
|
111
|
-
const isTextFile = this._isTextFile(attachment.contentType || this._getContentTypeFromFilename(attachment.filename));
|
|
112
|
-
rawMessage += `--${boundary}\r\n`;
|
|
113
|
-
rawMessage += `Content-Type: ${attachment.contentType || "application/octet-stream"}\r\n`;
|
|
114
|
-
rawMessage += `Content-Disposition: attachment; filename="${attachment.filename}"\r\n`;
|
|
115
|
-
if (isTextFile) {
|
|
116
|
-
rawMessage += `Content-Transfer-Encoding: 7bit\r\n\r\n`;
|
|
117
|
-
const textData = await this._getAttachmentTextData(attachment);
|
|
118
|
-
rawMessage += `${textData}\r\n\r\n`;
|
|
119
|
-
} else {
|
|
120
|
-
rawMessage += `Content-Transfer-Encoding: base64\r\n\r\n`;
|
|
121
|
-
const attachmentData = await this._getAttachmentData(attachment);
|
|
122
|
-
rawMessage += `${attachmentData}\r\n\r\n`;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
rawMessage += `--${boundary}--\r\n`;
|
|
126
|
-
return {
|
|
127
|
-
Destinations: allRecipients,
|
|
128
|
-
RawMessage: { Data: rawMessage },
|
|
129
|
-
Source: this.from
|
|
130
|
-
};
|
|
131
|
-
};
|
|
132
|
-
this._isTextFile = (contentType) => {
|
|
133
|
-
return [
|
|
134
|
-
"text/csv",
|
|
135
|
-
"text/plain",
|
|
136
|
-
"text/html",
|
|
137
|
-
"application/json",
|
|
138
|
-
"application/xml",
|
|
139
|
-
"text/xml"
|
|
140
|
-
].some((type) => contentType.startsWith(type));
|
|
141
|
-
};
|
|
142
|
-
this._getAttachmentTextData = async (attachment) => {
|
|
143
|
-
if (attachment.data) {
|
|
144
|
-
const base64Data = attachment.data.replace(/^data:[^;]+;base64,/, "");
|
|
145
|
-
if (this._isBase64(base64Data)) return Buffer.from(base64Data, "base64").toString("utf-8");
|
|
146
|
-
return attachment.data;
|
|
147
|
-
}
|
|
148
|
-
if (attachment.url) return await (await (await import("../../../node_modules/node-fetch/src/index.mjs").then((mod) => mod.default))(attachment.url)).text();
|
|
149
|
-
throw new Error(`No valid data source provided for attachment: ${attachment.filename}`);
|
|
150
|
-
};
|
|
151
|
-
this._getAttachmentData = async (attachment) => {
|
|
152
|
-
if (attachment.data) {
|
|
153
|
-
const cleanData = attachment.data.replace(/^data:[^;]+;base64,/, "");
|
|
154
|
-
if (this._isBase64(cleanData)) return cleanData;
|
|
155
|
-
return Buffer.from(attachment.data, "utf-8").toString("base64");
|
|
156
|
-
}
|
|
157
|
-
if (attachment.url) return (await (await (await import("../../../node_modules/node-fetch/src/index.mjs").then((mod) => mod.default))(attachment.url)).buffer()).toString("base64");
|
|
158
|
-
throw new Error(`No valid data source provided for attachment: ${attachment.filename}`);
|
|
159
|
-
};
|
|
160
|
-
this._isBase64 = (str) => {
|
|
161
|
-
try {
|
|
162
|
-
return Buffer.from(str, "base64").toString("base64") === str;
|
|
163
|
-
} catch {
|
|
164
|
-
return false;
|
|
165
|
-
}
|
|
166
|
-
};
|
|
167
|
-
this._getContentTypeFromFilename = (filename) => {
|
|
168
|
-
return {
|
|
169
|
-
"jpg": "image/jpeg",
|
|
170
|
-
"jpeg": "image/jpeg",
|
|
171
|
-
"png": "image/png",
|
|
172
|
-
"gif": "image/gif",
|
|
173
|
-
"svg": "image/svg+xml",
|
|
174
|
-
"webp": "image/webp",
|
|
175
|
-
"bmp": "image/bmp",
|
|
176
|
-
"ico": "image/x-icon",
|
|
177
|
-
"pdf": "application/pdf",
|
|
178
|
-
"doc": "application/msword",
|
|
179
|
-
"docx": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
180
|
-
"xls": "application/vnd.ms-excel",
|
|
181
|
-
"xlsx": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
182
|
-
"ppt": "application/vnd.ms-powerpoint",
|
|
183
|
-
"pptx": "application/vnd.openxmlformats-officedocument.presentationml.presentation",
|
|
184
|
-
"csv": "text/csv",
|
|
185
|
-
"tsv": "text/tab-separated-values",
|
|
186
|
-
"json": "application/json",
|
|
187
|
-
"xml": "application/xml",
|
|
188
|
-
"txt": "text/plain",
|
|
189
|
-
"zip": "application/zip",
|
|
190
|
-
"rar": "application/x-rar-compressed",
|
|
191
|
-
"7z": "application/x-7z-compressed",
|
|
192
|
-
"tar": "application/x-tar",
|
|
193
|
-
"gz": "application/gzip",
|
|
194
|
-
"mp3": "audio/mpeg",
|
|
195
|
-
"wav": "audio/wav",
|
|
196
|
-
"mp4": "video/mp4",
|
|
197
|
-
"avi": "video/x-msvideo",
|
|
198
|
-
"mov": "video/quicktime"
|
|
199
|
-
}[filename.split(".").pop()?.toLowerCase() || ""] || "application/octet-stream";
|
|
200
|
-
};
|
|
201
|
-
this._filterRecipients = (field) => {
|
|
202
|
-
let response = this[field].filter((recipient) => recipient && null !== recipient);
|
|
203
|
-
response = response.map((recipient) => recipient.toLowerCase().trim());
|
|
204
|
-
response = response.filter((recipient) => "" !== recipient);
|
|
205
|
-
response = [...new Set(response)];
|
|
206
|
-
return response;
|
|
207
|
-
};
|
|
208
16
|
if (bcc) this.setBcc(bcc);
|
|
209
17
|
if (cc) this.setCc(cc);
|
|
210
18
|
if (from) this.setFrom(from);
|
|
@@ -214,6 +22,201 @@ var SimpleEmail = class extends BaseClass {
|
|
|
214
22
|
if (attachments) this.setAttachments(attachments);
|
|
215
23
|
return this;
|
|
216
24
|
}
|
|
25
|
+
setFrom = (from) => {
|
|
26
|
+
return this._setValue("from", from);
|
|
27
|
+
};
|
|
28
|
+
setHtml = (html) => {
|
|
29
|
+
return this._setValue("html", html);
|
|
30
|
+
};
|
|
31
|
+
setSubject = (subject) => {
|
|
32
|
+
return this._setValue("subject", subject);
|
|
33
|
+
};
|
|
34
|
+
setAttachments = (attachments) => {
|
|
35
|
+
return this._setValue("attachments", attachments);
|
|
36
|
+
};
|
|
37
|
+
addAttachment = (attachment) => {
|
|
38
|
+
this.attachments.push(attachment);
|
|
39
|
+
return this;
|
|
40
|
+
};
|
|
41
|
+
addAttachmentFromdata = (filename, data, contentType) => {
|
|
42
|
+
return this.addAttachment({
|
|
43
|
+
filename,
|
|
44
|
+
data,
|
|
45
|
+
contentType: contentType || this._getContentTypeFromFilename(filename)
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
addAttachmentFromUrl = (filename, url, contentType) => {
|
|
49
|
+
return this.addAttachment({
|
|
50
|
+
filename,
|
|
51
|
+
url,
|
|
52
|
+
contentType: contentType || this._getContentTypeFromFilename(filename)
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
clearAttachments = () => {
|
|
56
|
+
this.attachments = [];
|
|
57
|
+
return this;
|
|
58
|
+
};
|
|
59
|
+
pushBcc = (recipient) => {
|
|
60
|
+
return this._push("bcc", recipient);
|
|
61
|
+
};
|
|
62
|
+
pushCc = (recipient) => {
|
|
63
|
+
return this._push("cc", recipient);
|
|
64
|
+
};
|
|
65
|
+
pushTo = (recipient) => {
|
|
66
|
+
return this._push("to", recipient);
|
|
67
|
+
};
|
|
68
|
+
setBcc = (recipient) => {
|
|
69
|
+
return this._setArray("bcc", recipient);
|
|
70
|
+
};
|
|
71
|
+
setCc = (recipient) => {
|
|
72
|
+
return this._setArray("cc", recipient);
|
|
73
|
+
};
|
|
74
|
+
setTo = (recipient) => {
|
|
75
|
+
return this._setArray("to", recipient);
|
|
76
|
+
};
|
|
77
|
+
getSendParam = async () => {
|
|
78
|
+
if (this.attachments.length > 0) return await this._getRawEmailParams();
|
|
79
|
+
return {
|
|
80
|
+
Destination: {
|
|
81
|
+
BccAddresses: this._filterRecipients("bcc"),
|
|
82
|
+
CcAddresses: this._filterRecipients("cc"),
|
|
83
|
+
ToAddresses: this._filterRecipients("to")
|
|
84
|
+
},
|
|
85
|
+
Message: {
|
|
86
|
+
Body: {
|
|
87
|
+
Html: {
|
|
88
|
+
Charset: "UTF-8",
|
|
89
|
+
Data: this.html
|
|
90
|
+
},
|
|
91
|
+
Text: {
|
|
92
|
+
Charset: "UTF-8",
|
|
93
|
+
Data: this.html
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
Subject: {
|
|
97
|
+
Charset: "UTF-8",
|
|
98
|
+
Data: this.subject
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
Source: this.from
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
_getRawEmailParams = async () => {
|
|
105
|
+
const boundary = `----=_NextPart_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
|
|
106
|
+
const allRecipients = [
|
|
107
|
+
...this._filterRecipients("to"),
|
|
108
|
+
...this._filterRecipients("cc"),
|
|
109
|
+
...this._filterRecipients("bcc")
|
|
110
|
+
];
|
|
111
|
+
let rawMessage = "";
|
|
112
|
+
rawMessage += `From: ${this.from}\r\n`;
|
|
113
|
+
if (this._filterRecipients("to").length > 0) rawMessage += `To: ${this._filterRecipients("to").join(", ")}\r\n`;
|
|
114
|
+
if (this._filterRecipients("cc").length > 0) rawMessage += `Cc: ${this._filterRecipients("cc").join(", ")}\r\n`;
|
|
115
|
+
rawMessage += `Subject: ${this.subject}\r\n`;
|
|
116
|
+
rawMessage += `MIME-Version: 1.0\r\n`;
|
|
117
|
+
rawMessage += `Content-Type: multipart/mixed; boundary="${boundary}"\r\n\r\n`;
|
|
118
|
+
rawMessage += `--${boundary}\r\n`;
|
|
119
|
+
rawMessage += `Content-Type: text/html; charset=UTF-8\r\n`;
|
|
120
|
+
rawMessage += `Content-Transfer-Encoding: 7bit\r\n\r\n`;
|
|
121
|
+
rawMessage += `${this.html}\r\n\r\n`;
|
|
122
|
+
for (const attachment of this.attachments) {
|
|
123
|
+
const isTextFile = this._isTextFile(attachment.contentType || this._getContentTypeFromFilename(attachment.filename));
|
|
124
|
+
rawMessage += `--${boundary}\r\n`;
|
|
125
|
+
rawMessage += `Content-Type: ${attachment.contentType || "application/octet-stream"}\r\n`;
|
|
126
|
+
rawMessage += `Content-Disposition: attachment; filename="${attachment.filename}"\r\n`;
|
|
127
|
+
if (isTextFile) {
|
|
128
|
+
rawMessage += `Content-Transfer-Encoding: 7bit\r\n\r\n`;
|
|
129
|
+
const textData = await this._getAttachmentTextData(attachment);
|
|
130
|
+
rawMessage += `${textData}\r\n\r\n`;
|
|
131
|
+
} else {
|
|
132
|
+
rawMessage += `Content-Transfer-Encoding: base64\r\n\r\n`;
|
|
133
|
+
const attachmentData = await this._getAttachmentData(attachment);
|
|
134
|
+
rawMessage += `${attachmentData}\r\n\r\n`;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
rawMessage += `--${boundary}--\r\n`;
|
|
138
|
+
return {
|
|
139
|
+
Destinations: allRecipients,
|
|
140
|
+
RawMessage: { Data: rawMessage },
|
|
141
|
+
Source: this.from
|
|
142
|
+
};
|
|
143
|
+
};
|
|
144
|
+
_isTextFile = (contentType) => {
|
|
145
|
+
return [
|
|
146
|
+
"text/csv",
|
|
147
|
+
"text/plain",
|
|
148
|
+
"text/html",
|
|
149
|
+
"application/json",
|
|
150
|
+
"application/xml",
|
|
151
|
+
"text/xml"
|
|
152
|
+
].some((type) => contentType.startsWith(type));
|
|
153
|
+
};
|
|
154
|
+
_getAttachmentTextData = async (attachment) => {
|
|
155
|
+
if (attachment.data) {
|
|
156
|
+
const base64Data = attachment.data.replace(/^data:[^;]+;base64,/, "");
|
|
157
|
+
if (this._isBase64(base64Data)) return Buffer.from(base64Data, "base64").toString("utf-8");
|
|
158
|
+
return attachment.data;
|
|
159
|
+
}
|
|
160
|
+
if (attachment.url) return await (await (await import("../../../node_modules/node-fetch/src/index.mjs").then((mod) => mod.default))(attachment.url)).text();
|
|
161
|
+
throw new Error(`No valid data source provided for attachment: ${attachment.filename}`);
|
|
162
|
+
};
|
|
163
|
+
_getAttachmentData = async (attachment) => {
|
|
164
|
+
if (attachment.data) {
|
|
165
|
+
const cleanData = attachment.data.replace(/^data:[^;]+;base64,/, "");
|
|
166
|
+
if (this._isBase64(cleanData)) return cleanData;
|
|
167
|
+
return Buffer.from(attachment.data, "utf-8").toString("base64");
|
|
168
|
+
}
|
|
169
|
+
if (attachment.url) return (await (await (await import("../../../node_modules/node-fetch/src/index.mjs").then((mod) => mod.default))(attachment.url)).buffer()).toString("base64");
|
|
170
|
+
throw new Error(`No valid data source provided for attachment: ${attachment.filename}`);
|
|
171
|
+
};
|
|
172
|
+
_isBase64 = (str) => {
|
|
173
|
+
try {
|
|
174
|
+
return Buffer.from(str, "base64").toString("base64") === str;
|
|
175
|
+
} catch {
|
|
176
|
+
return false;
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
_getContentTypeFromFilename = (filename) => {
|
|
180
|
+
return {
|
|
181
|
+
"jpg": "image/jpeg",
|
|
182
|
+
"jpeg": "image/jpeg",
|
|
183
|
+
"png": "image/png",
|
|
184
|
+
"gif": "image/gif",
|
|
185
|
+
"svg": "image/svg+xml",
|
|
186
|
+
"webp": "image/webp",
|
|
187
|
+
"bmp": "image/bmp",
|
|
188
|
+
"ico": "image/x-icon",
|
|
189
|
+
"pdf": "application/pdf",
|
|
190
|
+
"doc": "application/msword",
|
|
191
|
+
"docx": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
192
|
+
"xls": "application/vnd.ms-excel",
|
|
193
|
+
"xlsx": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
194
|
+
"ppt": "application/vnd.ms-powerpoint",
|
|
195
|
+
"pptx": "application/vnd.openxmlformats-officedocument.presentationml.presentation",
|
|
196
|
+
"csv": "text/csv",
|
|
197
|
+
"tsv": "text/tab-separated-values",
|
|
198
|
+
"json": "application/json",
|
|
199
|
+
"xml": "application/xml",
|
|
200
|
+
"txt": "text/plain",
|
|
201
|
+
"zip": "application/zip",
|
|
202
|
+
"rar": "application/x-rar-compressed",
|
|
203
|
+
"7z": "application/x-7z-compressed",
|
|
204
|
+
"tar": "application/x-tar",
|
|
205
|
+
"gz": "application/gzip",
|
|
206
|
+
"mp3": "audio/mpeg",
|
|
207
|
+
"wav": "audio/wav",
|
|
208
|
+
"mp4": "video/mp4",
|
|
209
|
+
"avi": "video/x-msvideo",
|
|
210
|
+
"mov": "video/quicktime"
|
|
211
|
+
}[filename.split(".").pop()?.toLowerCase() || ""] || "application/octet-stream";
|
|
212
|
+
};
|
|
213
|
+
_filterRecipients = (field) => {
|
|
214
|
+
let response = this[field].filter((recipient) => recipient && null !== recipient);
|
|
215
|
+
response = response.map((recipient) => recipient.toLowerCase().trim());
|
|
216
|
+
response = response.filter((recipient) => "" !== recipient);
|
|
217
|
+
response = [...new Set(response)];
|
|
218
|
+
return response;
|
|
219
|
+
};
|
|
217
220
|
};
|
|
218
221
|
//#endregion
|
|
219
222
|
export { SimpleEmail };
|
|
@@ -2,46 +2,43 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
2
2
|
const require__class_BaseNamespace = require("../../../_class/BaseNamespace.cjs");
|
|
3
3
|
//#region src/aws/sqs/server/AwsSqsNamespace.ts
|
|
4
4
|
var AwsSqsNamespace = class extends require__class_BaseNamespace.BaseNamespace {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
5
|
+
ensureInit = async () => {
|
|
6
|
+
if (!this.client) try {
|
|
7
|
+
const { SQSClient } = await import("@aws-sdk/client-sqs");
|
|
8
|
+
this.client = new SQSClient(this.config);
|
|
9
|
+
} catch (e) {
|
|
10
|
+
throw new Error("AWS SQS Client not installed");
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
addToQueue = async (props) => {
|
|
14
|
+
await this.ensureInit();
|
|
15
|
+
const { SendMessageCommand } = await import("@aws-sdk/client-sqs");
|
|
16
|
+
let params = {
|
|
17
|
+
MessageBody: JSON.stringify({
|
|
18
|
+
queueId: props.queueId,
|
|
19
|
+
data: props.data
|
|
20
|
+
}),
|
|
21
|
+
QueueUrl: props.queueUrl
|
|
14
22
|
};
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
if (void 0 !== props?.dedupeId) params["MessageDeduplicationId"] = props.dedupeId;
|
|
26
|
-
if (void 0 !== props?.groupId) params["MessageGroupId"] = props.dedupeId;
|
|
27
|
-
return await this.client.send(new SendMessageCommand(params));
|
|
23
|
+
if (void 0 !== props?.dedupeId) params["MessageDeduplicationId"] = props.dedupeId;
|
|
24
|
+
if (void 0 !== props?.groupId) params["MessageGroupId"] = props.dedupeId;
|
|
25
|
+
return await this.client.send(new SendMessageCommand(params));
|
|
26
|
+
};
|
|
27
|
+
deleteFromQueue = async (queueUrl, recipientHandle) => {
|
|
28
|
+
await this.ensureInit();
|
|
29
|
+
const { DeleteMessageCommand } = await import("@aws-sdk/client-sqs");
|
|
30
|
+
const params = {
|
|
31
|
+
QueueUrl: queueUrl,
|
|
32
|
+
ReceiptHandle: recipientHandle
|
|
28
33
|
};
|
|
29
|
-
this.
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
};
|
|
38
|
-
this.isEventSqs = async (event) => {
|
|
39
|
-
await this.ensureInit();
|
|
40
|
-
let response = false;
|
|
41
|
-
if (void 0 !== event["Records"]) for (let i = 0; i < event["Records"].length; i++);
|
|
42
|
-
return response;
|
|
43
|
-
};
|
|
44
|
-
}
|
|
34
|
+
return await this.client.send(new DeleteMessageCommand(params));
|
|
35
|
+
};
|
|
36
|
+
isEventSqs = async (event) => {
|
|
37
|
+
await this.ensureInit();
|
|
38
|
+
let response = false;
|
|
39
|
+
if (void 0 !== event["Records"]) for (let i = 0; i < event["Records"].length; i++);
|
|
40
|
+
return response;
|
|
41
|
+
};
|
|
45
42
|
};
|
|
46
43
|
//#endregion
|
|
47
44
|
exports.AwsSqsNamespace = AwsSqsNamespace;
|
|
@@ -1,46 +1,43 @@
|
|
|
1
1
|
import { BaseNamespace } from "../../../_class/BaseNamespace.mjs";
|
|
2
2
|
//#region src/aws/sqs/server/AwsSqsNamespace.ts
|
|
3
3
|
var AwsSqsNamespace = class extends BaseNamespace {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
4
|
+
ensureInit = async () => {
|
|
5
|
+
if (!this.client) try {
|
|
6
|
+
const { SQSClient } = await import("@aws-sdk/client-sqs");
|
|
7
|
+
this.client = new SQSClient(this.config);
|
|
8
|
+
} catch (e) {
|
|
9
|
+
throw new Error("AWS SQS Client not installed");
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
addToQueue = async (props) => {
|
|
13
|
+
await this.ensureInit();
|
|
14
|
+
const { SendMessageCommand } = await import("@aws-sdk/client-sqs");
|
|
15
|
+
let params = {
|
|
16
|
+
MessageBody: JSON.stringify({
|
|
17
|
+
queueId: props.queueId,
|
|
18
|
+
data: props.data
|
|
19
|
+
}),
|
|
20
|
+
QueueUrl: props.queueUrl
|
|
13
21
|
};
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
if (void 0 !== props?.dedupeId) params["MessageDeduplicationId"] = props.dedupeId;
|
|
25
|
-
if (void 0 !== props?.groupId) params["MessageGroupId"] = props.dedupeId;
|
|
26
|
-
return await this.client.send(new SendMessageCommand(params));
|
|
22
|
+
if (void 0 !== props?.dedupeId) params["MessageDeduplicationId"] = props.dedupeId;
|
|
23
|
+
if (void 0 !== props?.groupId) params["MessageGroupId"] = props.dedupeId;
|
|
24
|
+
return await this.client.send(new SendMessageCommand(params));
|
|
25
|
+
};
|
|
26
|
+
deleteFromQueue = async (queueUrl, recipientHandle) => {
|
|
27
|
+
await this.ensureInit();
|
|
28
|
+
const { DeleteMessageCommand } = await import("@aws-sdk/client-sqs");
|
|
29
|
+
const params = {
|
|
30
|
+
QueueUrl: queueUrl,
|
|
31
|
+
ReceiptHandle: recipientHandle
|
|
27
32
|
};
|
|
28
|
-
this.
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
};
|
|
37
|
-
this.isEventSqs = async (event) => {
|
|
38
|
-
await this.ensureInit();
|
|
39
|
-
let response = false;
|
|
40
|
-
if (void 0 !== event["Records"]) for (let i = 0; i < event["Records"].length; i++);
|
|
41
|
-
return response;
|
|
42
|
-
};
|
|
43
|
-
}
|
|
33
|
+
return await this.client.send(new DeleteMessageCommand(params));
|
|
34
|
+
};
|
|
35
|
+
isEventSqs = async (event) => {
|
|
36
|
+
await this.ensureInit();
|
|
37
|
+
let response = false;
|
|
38
|
+
if (void 0 !== event["Records"]) for (let i = 0; i < event["Records"].length; i++);
|
|
39
|
+
return response;
|
|
40
|
+
};
|
|
44
41
|
};
|
|
45
42
|
//#endregion
|
|
46
43
|
export { AwsSqsNamespace };
|
|
@@ -2,33 +2,34 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
2
2
|
const require__class_BaseNamespace = require("../../../_class/BaseNamespace.cjs");
|
|
3
3
|
//#region src/aws/ssm/server/AwsSsmNamespace.ts
|
|
4
4
|
var AwsSsmNamespace = class extends require__class_BaseNamespace.BaseNamespace {
|
|
5
|
+
parameters;
|
|
5
6
|
constructor(key, config) {
|
|
6
7
|
super(key, config);
|
|
7
|
-
this.ensureInit = async () => {
|
|
8
|
-
if (!this.client) try {
|
|
9
|
-
const { SSMClient } = await import("@aws-sdk/client-ssm");
|
|
10
|
-
this.client = new SSMClient(this.config);
|
|
11
|
-
} catch (e) {
|
|
12
|
-
throw new Error("AWS SSM Client not installed");
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
this.getParameter = async (name, withDecryption = false, isJson = true) => {
|
|
16
|
-
await this.ensureInit();
|
|
17
|
-
if (!this.parameters.has(name)) {
|
|
18
|
-
const { GetParameterCommand } = await import("@aws-sdk/client-ssm");
|
|
19
|
-
const apiResponse = await this.client.send(new GetParameterCommand({
|
|
20
|
-
Name: name,
|
|
21
|
-
WithDecryption: void 0 === withDecryption ? true : withDecryption
|
|
22
|
-
}));
|
|
23
|
-
if (apiResponse.Parameter.Value) if (void 0 === apiResponse.Parameter.Value) this.parameters.set(name, null);
|
|
24
|
-
else if (void 0 === isJson || true === isJson) this.parameters.set(name, JSON.parse(apiResponse.Parameter.Value) || null);
|
|
25
|
-
else this.parameters.set(name, apiResponse.Parameter.Value);
|
|
26
|
-
else this.parameters.set(name, null);
|
|
27
|
-
}
|
|
28
|
-
return this.parameters.get(name);
|
|
29
|
-
};
|
|
30
8
|
this.parameters = /* @__PURE__ */ new Map();
|
|
31
9
|
}
|
|
10
|
+
ensureInit = async () => {
|
|
11
|
+
if (!this.client) try {
|
|
12
|
+
const { SSMClient } = await import("@aws-sdk/client-ssm");
|
|
13
|
+
this.client = new SSMClient(this.config);
|
|
14
|
+
} catch (e) {
|
|
15
|
+
throw new Error("AWS SSM Client not installed");
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
getParameter = async (name, withDecryption = false, isJson = true) => {
|
|
19
|
+
await this.ensureInit();
|
|
20
|
+
if (!this.parameters.has(name)) {
|
|
21
|
+
const { GetParameterCommand } = await import("@aws-sdk/client-ssm");
|
|
22
|
+
const apiResponse = await this.client.send(new GetParameterCommand({
|
|
23
|
+
Name: name,
|
|
24
|
+
WithDecryption: void 0 === withDecryption ? true : withDecryption
|
|
25
|
+
}));
|
|
26
|
+
if (apiResponse.Parameter.Value) if (void 0 === apiResponse.Parameter.Value) this.parameters.set(name, null);
|
|
27
|
+
else if (void 0 === isJson || true === isJson) this.parameters.set(name, JSON.parse(apiResponse.Parameter.Value) || null);
|
|
28
|
+
else this.parameters.set(name, apiResponse.Parameter.Value);
|
|
29
|
+
else this.parameters.set(name, null);
|
|
30
|
+
}
|
|
31
|
+
return this.parameters.get(name);
|
|
32
|
+
};
|
|
32
33
|
};
|
|
33
34
|
//#endregion
|
|
34
35
|
exports.AwsSsmNamespace = AwsSsmNamespace;
|