@8ms/helpers 2.3.26 → 2.3.28
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/index.d.mts +2 -0
- package/dist/_class/index.mjs +61 -0
- package/dist/adverity/index.d.mts +2 -0
- package/dist/adverity/index.mjs +64 -0
- package/dist/adverity/server/index.d.mts +18 -0
- package/dist/adverity/server/index.mjs +25 -0
- package/dist/api/index.d.mts +2 -0
- package/dist/api/index.mjs +3 -0
- package/dist/api-DGKJDAfb.mjs +139 -0
- package/dist/array/index.d.mts +11 -0
- package/dist/array/index.mjs +12 -0
- package/dist/atInternet/index.d.mts +20 -0
- package/dist/atInternet/index.mjs +18 -0
- package/dist/aws/ec2/server/index.d.mts +18 -0
- package/dist/aws/ec2/server/index.mjs +48 -0
- package/dist/aws/ecs/server/index.d.mts +59 -0
- package/dist/aws/ecs/server/index.mjs +113 -0
- package/dist/aws/glue/server/index.d.mts +19 -0
- package/dist/aws/glue/server/index.mjs +36 -0
- package/dist/aws/lambda/server/index.d.mts +28 -0
- package/dist/aws/lambda/server/index.mjs +57 -0
- package/dist/aws/s3/server/index.d.mts +124 -0
- package/dist/aws/s3/server/index.mjs +360 -0
- package/dist/aws/server/index.d.mts +2 -0
- package/dist/aws/server/index.mjs +3 -0
- package/dist/aws/ses/server/index.d.mts +105 -0
- package/dist/aws/ses/server/index.mjs +268 -0
- package/dist/aws/sqs/server/index.d.mts +41 -0
- package/dist/aws/sqs/server/index.mjs +56 -0
- package/dist/aws/ssm/server/index.d.mts +18 -0
- package/dist/aws/ssm/server/index.mjs +47 -0
- package/dist/axios/index.d.mts +22 -0
- package/dist/axios/index.mjs +50 -0
- package/dist/boolean/index.d.mts +7 -0
- package/dist/boolean/index.mjs +13 -0
- package/dist/brightData/serpApi/server/index.d.mts +93 -0
- package/dist/brightData/serpApi/server/index.mjs +229 -0
- package/dist/brightData/server/index.d.mts +2 -0
- package/dist/brightData/server/index.mjs +18 -0
- package/dist/brightData/webScraperIde/server/index.d.mts +19 -0
- package/dist/brightData/webScraperIde/server/index.mjs +50 -0
- package/dist/cache/server/index.d.mts +10 -0
- package/dist/cache/server/index.mjs +31 -0
- package/dist/chunk-DDarj8oW.mjs +7 -0
- package/dist/crud/index.d.mts +10 -0
- package/dist/crud/index.mjs +10 -0
- package/dist/crypto/index.d.mts +25 -0
- package/dist/crypto/index.mjs +57 -0
- package/dist/date/index.d.mts +2 -0
- package/dist/date/index.mjs +471 -0
- package/dist/drizzle/server/index.d.mts +22 -0
- package/dist/drizzle/server/index.mjs +69 -0
- package/dist/environment/index.d.mts +37 -0
- package/dist/environment/index.mjs +60 -0
- package/dist/eskimi/index.d.mts +52 -0
- package/dist/eskimi/index.mjs +90 -0
- package/dist/eskimi/server/index.d.mts +25 -0
- package/dist/eskimi/server/index.mjs +50 -0
- package/dist/file/index.d.mts +7 -0
- package/dist/file/index.mjs +20 -0
- package/dist/file/server/index.d.mts +8 -0
- package/dist/file/server/index.mjs +16 -0
- package/dist/geo/index.d.mts +26 -0
- package/dist/geo/index.mjs +1591 -0
- package/dist/getDecimal-CafxtLhH.mjs +40 -0
- package/dist/googleAds/keywordPlanner/server/index.d.mts +45 -0
- package/dist/googleAds/keywordPlanner/server/index.mjs +51 -0
- package/dist/googleAds/server/index.d.mts +27 -0
- package/dist/googleAds/server/index.mjs +48 -0
- package/dist/googleCloud/bigquery/server/index.d.mts +82 -0
- package/dist/googleCloud/bigquery/server/index.mjs +133 -0
- package/dist/googleCloud/server/index.d.mts +2 -0
- package/dist/googleCloud/server/index.mjs +24 -0
- package/dist/googleCloud/sheets/server/index.d.mts +22 -0
- package/dist/googleCloud/sheets/server/index.mjs +31 -0
- package/dist/googleCloud/storage/server/index.d.mts +31 -0
- package/dist/googleCloud/storage/server/index.mjs +79 -0
- package/dist/googlePageSpeed/server/index.d.mts +34 -0
- package/dist/googlePageSpeed/server/index.mjs +53 -0
- package/dist/googleSearchIncidents/server/index.d.mts +73 -0
- package/dist/googleSearchIncidents/server/index.mjs +55 -0
- package/dist/greenDomain/server/index.d.mts +25 -0
- package/dist/greenDomain/server/index.mjs +31 -0
- package/dist/index-1fBbJGQz.d.mts +246 -0
- package/dist/index-BHuvb_7y.d.mts +116 -0
- package/dist/index-BfyGIdDD.d.mts +18 -0
- package/dist/index-CqTOMR8f.d.mts +17 -0
- package/dist/index-DW9yJLtI.d.mts +67 -0
- package/dist/index-DmCSxHCc.d.mts +32 -0
- package/dist/index-DwB8X1lz.d.mts +32 -0
- package/dist/inngest/index.d.mts +10 -0
- package/dist/inngest/index.mjs +10 -0
- package/dist/json/index.d.mts +7 -0
- package/dist/json/index.mjs +27 -0
- package/dist/littleWarden/server/index.d.mts +56 -0
- package/dist/littleWarden/server/index.mjs +79 -0
- package/dist/lodash/index.d.mts +45 -0
- package/dist/lodash/index.mjs +177 -0
- package/dist/lumar/api/server/index.d.mts +66 -0
- package/dist/lumar/api/server/index.mjs +111 -0
- package/dist/lumar/graphql/server/index.d.mts +308 -0
- package/dist/lumar/graphql/server/index.mjs +172 -0
- package/dist/myTarget/server/index.d.mts +9 -0
- package/dist/myTarget/server/index.mjs +16 -0
- package/dist/nextAuth/index.d.mts +12 -0
- package/dist/nextAuth/index.mjs +15 -0
- package/dist/nextJs/client/index.d.mts +10 -0
- package/dist/nextJs/client/index.mjs +12 -0
- package/dist/nextJs/index.d.mts +19 -0
- package/dist/nextJs/index.mjs +12 -0
- package/dist/number/index.d.mts +54 -0
- package/dist/number/index.mjs +75 -0
- package/dist/object/index.d.mts +8 -0
- package/dist/object/index.mjs +22 -0
- package/dist/onePassword/server/index.d.mts +24 -0
- package/dist/onePassword/server/index.mjs +50 -0
- package/dist/openAi/server/index.d.mts +20 -0
- package/dist/openAi/server/index.mjs +46 -0
- package/dist/prisma/index.d.mts +7 -0
- package/dist/prisma/index.mjs +15 -0
- package/dist/prisma/server/index.d.mts +31 -0
- package/dist/prisma/server/index.mjs +64 -0
- package/dist/server-Bwy4JI8Z.mjs +33 -0
- package/dist/snapchat/server/index.d.mts +25 -0
- package/dist/snapchat/server/index.mjs +39 -0
- package/dist/sorting/index.d.mts +25 -0
- package/dist/sorting/index.mjs +50 -0
- package/dist/stream/server/index.d.mts +15 -0
- package/dist/stream/server/index.mjs +48 -0
- package/dist/string/index.d.mts +107 -0
- package/dist/string/index.mjs +187 -0
- package/dist/swr/client/index.d.mts +46 -0
- package/dist/swr/client/index.mjs +40 -0
- package/dist/upTimeRobot/server/index.d.mts +72 -0
- package/dist/upTimeRobot/server/index.mjs +82 -0
- package/dist/url/index.d.mts +29 -0
- package/dist/url/index.mjs +52 -0
- package/dist/url/server/index.d.mts +9 -0
- package/dist/url/server/index.mjs +35 -0
- package/dist/util/index.d.mts +50 -0
- package/dist/util/index.mjs +107 -0
- package/dist/util/server/index.d.mts +27 -0
- package/dist/util/server/index.mjs +61 -0
- package/dist/webWorker/index.d.mts +11 -0
- package/dist/webWorker/index.mjs +11 -0
- package/dist/xml/server/index.d.mts +4 -0
- package/dist/xml/server/index.mjs +17 -0
- package/package.json +189 -118
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { n as BaseClass, t as BaseNamespace } from "../../../index-DwB8X1lz.mjs";
|
|
2
|
+
import { t as AwsConfig } from "../../../index-CqTOMR8f.mjs";
|
|
3
|
+
import { SESClient, SendEmailCommandInput, SendRawEmailCommandInput } from "@aws-sdk/client-ses";
|
|
4
|
+
|
|
5
|
+
//#region src/aws/ses/server/AwsSesNamespace.d.ts
|
|
6
|
+
declare class AwsSesNamespace extends BaseNamespace {
|
|
7
|
+
client: SESClient;
|
|
8
|
+
config: AwsConfig;
|
|
9
|
+
ensureInit: () => Promise<void>;
|
|
10
|
+
send: (input: SendEmailCommandInput | SendRawEmailCommandInput) => Promise<any>;
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
//#region src/aws/ses/server/SimpleEmail.d.ts
|
|
14
|
+
type AttachmentSource = {
|
|
15
|
+
filename: string;
|
|
16
|
+
contentType?: string;
|
|
17
|
+
data?: string;
|
|
18
|
+
url?: string;
|
|
19
|
+
};
|
|
20
|
+
type ConstructorProps = {
|
|
21
|
+
bcc?: string[];
|
|
22
|
+
cc?: string[];
|
|
23
|
+
from?: string;
|
|
24
|
+
html?: string;
|
|
25
|
+
subject?: string;
|
|
26
|
+
to?: string | string[];
|
|
27
|
+
attachments?: AttachmentSource[];
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Class to build and send an AWS SES email.
|
|
31
|
+
*/
|
|
32
|
+
declare class SimpleEmail extends BaseClass {
|
|
33
|
+
from?: string;
|
|
34
|
+
to: string[];
|
|
35
|
+
cc: string[];
|
|
36
|
+
bcc: string[];
|
|
37
|
+
html?: string;
|
|
38
|
+
subject?: string;
|
|
39
|
+
attachments: AttachmentSource[];
|
|
40
|
+
constructor({
|
|
41
|
+
bcc,
|
|
42
|
+
cc,
|
|
43
|
+
from,
|
|
44
|
+
html,
|
|
45
|
+
subject,
|
|
46
|
+
to,
|
|
47
|
+
attachments
|
|
48
|
+
}: ConstructorProps);
|
|
49
|
+
setFrom: (from: string) => this;
|
|
50
|
+
setHtml: (html: string) => this;
|
|
51
|
+
setSubject: (subject: string) => this;
|
|
52
|
+
setAttachments: (attachments: AttachmentSource[]) => this;
|
|
53
|
+
addAttachment: (attachment: AttachmentSource) => this;
|
|
54
|
+
addAttachmentFromdata: (filename: string, data: string, contentType?: string) => this;
|
|
55
|
+
addAttachmentFromUrl: (filename: string, url: string, contentType?: string) => this;
|
|
56
|
+
clearAttachments: () => this;
|
|
57
|
+
pushBcc: (recipient: string | string[]) => this;
|
|
58
|
+
pushCc: (recipient: string | string[]) => this;
|
|
59
|
+
pushTo: (recipient: string | string[]) => this;
|
|
60
|
+
setBcc: (recipient: string | string[]) => this;
|
|
61
|
+
setCc: (recipient: string | string[]) => this;
|
|
62
|
+
setTo: (recipient: string | string[]) => this;
|
|
63
|
+
getSendParam: () => Promise<{
|
|
64
|
+
Destinations: string[];
|
|
65
|
+
RawMessage: {
|
|
66
|
+
Data: string;
|
|
67
|
+
};
|
|
68
|
+
Source: string;
|
|
69
|
+
} | {
|
|
70
|
+
Destination: {
|
|
71
|
+
BccAddresses: string[];
|
|
72
|
+
CcAddresses: string[];
|
|
73
|
+
ToAddresses: string[];
|
|
74
|
+
};
|
|
75
|
+
Message: {
|
|
76
|
+
Body: {
|
|
77
|
+
Html: {
|
|
78
|
+
Charset: string;
|
|
79
|
+
Data: string;
|
|
80
|
+
};
|
|
81
|
+
Text: {
|
|
82
|
+
Charset: string;
|
|
83
|
+
Data: string;
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
Subject: {
|
|
87
|
+
Charset: string;
|
|
88
|
+
Data: string;
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
Source: string;
|
|
92
|
+
}>;
|
|
93
|
+
private _getRawEmailParams;
|
|
94
|
+
private _isTextFile;
|
|
95
|
+
private _getAttachmentTextData;
|
|
96
|
+
private _getAttachmentData;
|
|
97
|
+
private _isBase64;
|
|
98
|
+
private _getContentTypeFromFilename;
|
|
99
|
+
private _filterRecipients;
|
|
100
|
+
}
|
|
101
|
+
//#endregion
|
|
102
|
+
//#region src/aws/ses/server/awsSes.d.ts
|
|
103
|
+
declare const awsSesClient: (key?: string, config?: AwsConfig, vaultId?: string, itemId?: string) => Promise<AwsSesNamespace>;
|
|
104
|
+
//#endregion
|
|
105
|
+
export { AwsSesNamespace, SimpleEmail, awsSesClient };
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
import { BaseClass, BaseNamespace } from "../../../_class/index.mjs";
|
|
2
|
+
import { t as getConfig } from "../../../server-Bwy4JI8Z.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/aws/ses/server/AwsSesNamespace.ts
|
|
5
|
+
var AwsSesNamespace = class extends BaseNamespace {
|
|
6
|
+
ensureInit = async () => {
|
|
7
|
+
if (!this.client) try {
|
|
8
|
+
const { SESClient } = await import("@aws-sdk/client-ses");
|
|
9
|
+
this.client = new SESClient(this.config);
|
|
10
|
+
} catch (e) {
|
|
11
|
+
throw new Error("AWS SES Client not installed");
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
send = async (input) => {
|
|
15
|
+
await this.ensureInit();
|
|
16
|
+
let response;
|
|
17
|
+
if (input?.Message?.Body?.Html?.Data) try {
|
|
18
|
+
const { SendEmailCommand } = await import("@aws-sdk/client-ses");
|
|
19
|
+
const command = new SendEmailCommand(input);
|
|
20
|
+
response = await this.client.send(command);
|
|
21
|
+
} catch (exception) {
|
|
22
|
+
response = exception;
|
|
23
|
+
}
|
|
24
|
+
else try {
|
|
25
|
+
const { SendRawEmailCommand } = await import("@aws-sdk/client-ses");
|
|
26
|
+
const command = new SendRawEmailCommand(input);
|
|
27
|
+
response = await this.client.send(command);
|
|
28
|
+
} catch (exception) {
|
|
29
|
+
response = exception;
|
|
30
|
+
}
|
|
31
|
+
return response;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
//#endregion
|
|
36
|
+
//#region src/aws/ses/server/SimpleEmail.ts
|
|
37
|
+
/**
|
|
38
|
+
* Class to build and send an AWS SES email.
|
|
39
|
+
*/
|
|
40
|
+
var SimpleEmail = class extends BaseClass {
|
|
41
|
+
from;
|
|
42
|
+
to = [];
|
|
43
|
+
cc = [];
|
|
44
|
+
bcc = [];
|
|
45
|
+
html;
|
|
46
|
+
subject;
|
|
47
|
+
attachments = [];
|
|
48
|
+
constructor({ bcc, cc, from, html, subject, to, attachments }) {
|
|
49
|
+
super();
|
|
50
|
+
if (bcc) this.setBcc(bcc);
|
|
51
|
+
if (cc) this.setCc(cc);
|
|
52
|
+
if (from) this.setFrom(from);
|
|
53
|
+
if (html) this.setHtml(html);
|
|
54
|
+
if (subject) this.setSubject(subject);
|
|
55
|
+
if (to) this.setTo(to);
|
|
56
|
+
if (attachments) this.setAttachments(attachments);
|
|
57
|
+
return this;
|
|
58
|
+
}
|
|
59
|
+
setFrom = (from) => {
|
|
60
|
+
return this._setValue("from", from);
|
|
61
|
+
};
|
|
62
|
+
setHtml = (html) => {
|
|
63
|
+
return this._setValue("html", html);
|
|
64
|
+
};
|
|
65
|
+
setSubject = (subject) => {
|
|
66
|
+
return this._setValue("subject", subject);
|
|
67
|
+
};
|
|
68
|
+
setAttachments = (attachments) => {
|
|
69
|
+
return this._setValue("attachments", attachments);
|
|
70
|
+
};
|
|
71
|
+
addAttachment = (attachment) => {
|
|
72
|
+
this.attachments.push(attachment);
|
|
73
|
+
return this;
|
|
74
|
+
};
|
|
75
|
+
addAttachmentFromdata = (filename, data, contentType) => {
|
|
76
|
+
return this.addAttachment({
|
|
77
|
+
filename,
|
|
78
|
+
data,
|
|
79
|
+
contentType: contentType || this._getContentTypeFromFilename(filename)
|
|
80
|
+
});
|
|
81
|
+
};
|
|
82
|
+
addAttachmentFromUrl = (filename, url, contentType) => {
|
|
83
|
+
return this.addAttachment({
|
|
84
|
+
filename,
|
|
85
|
+
url,
|
|
86
|
+
contentType: contentType || this._getContentTypeFromFilename(filename)
|
|
87
|
+
});
|
|
88
|
+
};
|
|
89
|
+
clearAttachments = () => {
|
|
90
|
+
this.attachments = [];
|
|
91
|
+
return this;
|
|
92
|
+
};
|
|
93
|
+
pushBcc = (recipient) => {
|
|
94
|
+
return this._push("bcc", recipient);
|
|
95
|
+
};
|
|
96
|
+
pushCc = (recipient) => {
|
|
97
|
+
return this._push("cc", recipient);
|
|
98
|
+
};
|
|
99
|
+
pushTo = (recipient) => {
|
|
100
|
+
return this._push("to", recipient);
|
|
101
|
+
};
|
|
102
|
+
setBcc = (recipient) => {
|
|
103
|
+
return this._setArray("bcc", recipient);
|
|
104
|
+
};
|
|
105
|
+
setCc = (recipient) => {
|
|
106
|
+
return this._setArray("cc", recipient);
|
|
107
|
+
};
|
|
108
|
+
setTo = (recipient) => {
|
|
109
|
+
return this._setArray("to", recipient);
|
|
110
|
+
};
|
|
111
|
+
getSendParam = async () => {
|
|
112
|
+
if (this.attachments.length > 0) return await this._getRawEmailParams();
|
|
113
|
+
return {
|
|
114
|
+
Destination: {
|
|
115
|
+
BccAddresses: this._filterRecipients("bcc"),
|
|
116
|
+
CcAddresses: this._filterRecipients("cc"),
|
|
117
|
+
ToAddresses: this._filterRecipients("to")
|
|
118
|
+
},
|
|
119
|
+
Message: {
|
|
120
|
+
Body: {
|
|
121
|
+
Html: {
|
|
122
|
+
Charset: "UTF-8",
|
|
123
|
+
Data: this.html
|
|
124
|
+
},
|
|
125
|
+
Text: {
|
|
126
|
+
Charset: "UTF-8",
|
|
127
|
+
Data: this.html
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
Subject: {
|
|
131
|
+
Charset: "UTF-8",
|
|
132
|
+
Data: this.subject
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
Source: this.from
|
|
136
|
+
};
|
|
137
|
+
};
|
|
138
|
+
_getRawEmailParams = async () => {
|
|
139
|
+
const boundary = `----=_NextPart_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
|
|
140
|
+
const allRecipients = [
|
|
141
|
+
...this._filterRecipients("to"),
|
|
142
|
+
...this._filterRecipients("cc"),
|
|
143
|
+
...this._filterRecipients("bcc")
|
|
144
|
+
];
|
|
145
|
+
let rawMessage = "";
|
|
146
|
+
rawMessage += `From: ${this.from}\r\n`;
|
|
147
|
+
if (this._filterRecipients("to").length > 0) rawMessage += `To: ${this._filterRecipients("to").join(", ")}\r\n`;
|
|
148
|
+
if (this._filterRecipients("cc").length > 0) rawMessage += `Cc: ${this._filterRecipients("cc").join(", ")}\r\n`;
|
|
149
|
+
rawMessage += `Subject: ${this.subject}\r\n`;
|
|
150
|
+
rawMessage += `MIME-Version: 1.0\r\n`;
|
|
151
|
+
rawMessage += `Content-Type: multipart/mixed; boundary="${boundary}"\r\n\r\n`;
|
|
152
|
+
rawMessage += `--${boundary}\r\n`;
|
|
153
|
+
rawMessage += `Content-Type: text/html; charset=UTF-8\r\n`;
|
|
154
|
+
rawMessage += `Content-Transfer-Encoding: 7bit\r\n\r\n`;
|
|
155
|
+
rawMessage += `${this.html}\r\n\r\n`;
|
|
156
|
+
for (const attachment of this.attachments) {
|
|
157
|
+
const isTextFile = this._isTextFile(attachment.contentType || this._getContentTypeFromFilename(attachment.filename));
|
|
158
|
+
rawMessage += `--${boundary}\r\n`;
|
|
159
|
+
rawMessage += `Content-Type: ${attachment.contentType || "application/octet-stream"}\r\n`;
|
|
160
|
+
rawMessage += `Content-Disposition: attachment; filename="${attachment.filename}"\r\n`;
|
|
161
|
+
if (isTextFile) {
|
|
162
|
+
rawMessage += `Content-Transfer-Encoding: 7bit\r\n\r\n`;
|
|
163
|
+
const textData = await this._getAttachmentTextData(attachment);
|
|
164
|
+
rawMessage += `${textData}\r\n\r\n`;
|
|
165
|
+
} else {
|
|
166
|
+
rawMessage += `Content-Transfer-Encoding: base64\r\n\r\n`;
|
|
167
|
+
const attachmentData = await this._getAttachmentData(attachment);
|
|
168
|
+
rawMessage += `${attachmentData}\r\n\r\n`;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
rawMessage += `--${boundary}--\r\n`;
|
|
172
|
+
return {
|
|
173
|
+
Destinations: allRecipients,
|
|
174
|
+
RawMessage: { Data: rawMessage },
|
|
175
|
+
Source: this.from
|
|
176
|
+
};
|
|
177
|
+
};
|
|
178
|
+
_isTextFile = (contentType) => {
|
|
179
|
+
return [
|
|
180
|
+
"text/csv",
|
|
181
|
+
"text/plain",
|
|
182
|
+
"text/html",
|
|
183
|
+
"application/json",
|
|
184
|
+
"application/xml",
|
|
185
|
+
"text/xml"
|
|
186
|
+
].some((type) => contentType.startsWith(type));
|
|
187
|
+
};
|
|
188
|
+
_getAttachmentTextData = async (attachment) => {
|
|
189
|
+
if (attachment.data) {
|
|
190
|
+
const base64Data = attachment.data.replace(/^data:[^;]+;base64,/, "");
|
|
191
|
+
if (this._isBase64(base64Data)) return Buffer.from(base64Data, "base64").toString("utf-8");
|
|
192
|
+
return attachment.data;
|
|
193
|
+
}
|
|
194
|
+
if (attachment.url) return await (await (await import("node-fetch").then((mod) => mod.default))(attachment.url)).text();
|
|
195
|
+
throw new Error(`No valid data source provided for attachment: ${attachment.filename}`);
|
|
196
|
+
};
|
|
197
|
+
_getAttachmentData = async (attachment) => {
|
|
198
|
+
if (attachment.data) {
|
|
199
|
+
const cleanData = attachment.data.replace(/^data:[^;]+;base64,/, "");
|
|
200
|
+
if (this._isBase64(cleanData)) return cleanData;
|
|
201
|
+
return Buffer.from(attachment.data, "utf-8").toString("base64");
|
|
202
|
+
}
|
|
203
|
+
if (attachment.url) return (await (await (await import("node-fetch").then((mod) => mod.default))(attachment.url)).buffer()).toString("base64");
|
|
204
|
+
throw new Error(`No valid data source provided for attachment: ${attachment.filename}`);
|
|
205
|
+
};
|
|
206
|
+
_isBase64 = (str) => {
|
|
207
|
+
try {
|
|
208
|
+
return Buffer.from(str, "base64").toString("base64") === str;
|
|
209
|
+
} catch {
|
|
210
|
+
return false;
|
|
211
|
+
}
|
|
212
|
+
};
|
|
213
|
+
_getContentTypeFromFilename = (filename) => {
|
|
214
|
+
const extension = filename.split(".").pop()?.toLowerCase();
|
|
215
|
+
return {
|
|
216
|
+
"jpg": "image/jpeg",
|
|
217
|
+
"jpeg": "image/jpeg",
|
|
218
|
+
"png": "image/png",
|
|
219
|
+
"gif": "image/gif",
|
|
220
|
+
"svg": "image/svg+xml",
|
|
221
|
+
"webp": "image/webp",
|
|
222
|
+
"bmp": "image/bmp",
|
|
223
|
+
"ico": "image/x-icon",
|
|
224
|
+
"pdf": "application/pdf",
|
|
225
|
+
"doc": "application/msword",
|
|
226
|
+
"docx": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
227
|
+
"xls": "application/vnd.ms-excel",
|
|
228
|
+
"xlsx": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
229
|
+
"ppt": "application/vnd.ms-powerpoint",
|
|
230
|
+
"pptx": "application/vnd.openxmlformats-officedocument.presentationml.presentation",
|
|
231
|
+
"csv": "text/csv",
|
|
232
|
+
"tsv": "text/tab-separated-values",
|
|
233
|
+
"json": "application/json",
|
|
234
|
+
"xml": "application/xml",
|
|
235
|
+
"txt": "text/plain",
|
|
236
|
+
"zip": "application/zip",
|
|
237
|
+
"rar": "application/x-rar-compressed",
|
|
238
|
+
"7z": "application/x-7z-compressed",
|
|
239
|
+
"tar": "application/x-tar",
|
|
240
|
+
"gz": "application/gzip",
|
|
241
|
+
"mp3": "audio/mpeg",
|
|
242
|
+
"wav": "audio/wav",
|
|
243
|
+
"mp4": "video/mp4",
|
|
244
|
+
"avi": "video/x-msvideo",
|
|
245
|
+
"mov": "video/quicktime"
|
|
246
|
+
}[extension || ""] || "application/octet-stream";
|
|
247
|
+
};
|
|
248
|
+
_filterRecipients = (field) => {
|
|
249
|
+
let response = this[field].filter((recipient) => recipient && null !== recipient);
|
|
250
|
+
response = response.map((recipient) => recipient.toLowerCase().trim());
|
|
251
|
+
response = response.filter((recipient) => "" !== recipient);
|
|
252
|
+
response = [...new Set(response)];
|
|
253
|
+
return response;
|
|
254
|
+
};
|
|
255
|
+
};
|
|
256
|
+
|
|
257
|
+
//#endregion
|
|
258
|
+
//#region src/aws/ses/server/awsSes.ts
|
|
259
|
+
const awsSesNamespaces = /* @__PURE__ */ new Map();
|
|
260
|
+
const awsSesClient = async (key = "default", config, vaultId, itemId) => {
|
|
261
|
+
if (awsSesNamespaces.has(key)) return awsSesNamespaces.get(key);
|
|
262
|
+
const namespace = new AwsSesNamespace(key, await getConfig(key, config, vaultId, itemId));
|
|
263
|
+
awsSesNamespaces.set(key, namespace);
|
|
264
|
+
return namespace;
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
//#endregion
|
|
268
|
+
export { AwsSesNamespace, SimpleEmail, awsSesClient };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { t as BaseNamespace } from "../../../index-DwB8X1lz.mjs";
|
|
2
|
+
import { t as AwsConfig } from "../../../index-CqTOMR8f.mjs";
|
|
3
|
+
import * as _aws_sdk_client_sqs0 from "@aws-sdk/client-sqs";
|
|
4
|
+
import { SQSClient } from "@aws-sdk/client-sqs";
|
|
5
|
+
|
|
6
|
+
//#region src/aws/sqs/server/AwsSqsNamespace.d.ts
|
|
7
|
+
type SqsEventRecord = {
|
|
8
|
+
messageId: string;
|
|
9
|
+
receiptHandle: string;
|
|
10
|
+
body: any;
|
|
11
|
+
attributes: object;
|
|
12
|
+
messageAttributes: object;
|
|
13
|
+
md5OfMessageAttributes: string;
|
|
14
|
+
md5OfBody: string;
|
|
15
|
+
eventSource: string;
|
|
16
|
+
eventSourceARN: string;
|
|
17
|
+
awsRegion: string;
|
|
18
|
+
};
|
|
19
|
+
type SqsEvent = {
|
|
20
|
+
Records: SqsEventRecord[];
|
|
21
|
+
};
|
|
22
|
+
type AddToQueue = {
|
|
23
|
+
data: any;
|
|
24
|
+
dedupeId: string;
|
|
25
|
+
groupId?: string;
|
|
26
|
+
queueId?: string;
|
|
27
|
+
queueUrl: string;
|
|
28
|
+
};
|
|
29
|
+
declare class AwsSqsNamespace extends BaseNamespace {
|
|
30
|
+
client: SQSClient;
|
|
31
|
+
config: AwsConfig;
|
|
32
|
+
ensureInit: () => Promise<void>;
|
|
33
|
+
addToQueue: (props: AddToQueue) => Promise<_aws_sdk_client_sqs0.SendMessageCommandOutput>;
|
|
34
|
+
deleteFromQueue: (queueUrl: string, recipientHandle: string) => Promise<_aws_sdk_client_sqs0.DeleteMessageCommandOutput>;
|
|
35
|
+
isEventSqs: (event: SqsEvent) => Promise<boolean>;
|
|
36
|
+
}
|
|
37
|
+
//#endregion
|
|
38
|
+
//#region src/aws/sqs/server/awsSqs.d.ts
|
|
39
|
+
declare const awsSqsClient: (key?: string, config?: AwsConfig, vaultId?: string, itemId?: string) => Promise<AwsSqsNamespace>;
|
|
40
|
+
//#endregion
|
|
41
|
+
export { AwsSqsNamespace, awsSqsClient };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { BaseNamespace } from "../../../_class/index.mjs";
|
|
2
|
+
import { t as getConfig } from "../../../server-Bwy4JI8Z.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/aws/sqs/server/AwsSqsNamespace.ts
|
|
5
|
+
var AwsSqsNamespace = class extends BaseNamespace {
|
|
6
|
+
ensureInit = async () => {
|
|
7
|
+
if (!this.client) try {
|
|
8
|
+
const { SQSClient } = await import("@aws-sdk/client-sqs");
|
|
9
|
+
this.client = new SQSClient(this.config);
|
|
10
|
+
} catch (e) {
|
|
11
|
+
throw new Error("AWS SQS Client not installed");
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
addToQueue = async (props) => {
|
|
15
|
+
await this.ensureInit();
|
|
16
|
+
const { SendMessageCommand } = await import("@aws-sdk/client-sqs");
|
|
17
|
+
let params = {
|
|
18
|
+
MessageBody: JSON.stringify({
|
|
19
|
+
queueId: props.queueId,
|
|
20
|
+
data: props.data
|
|
21
|
+
}),
|
|
22
|
+
QueueUrl: props.queueUrl
|
|
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));
|
|
27
|
+
};
|
|
28
|
+
deleteFromQueue = async (queueUrl, recipientHandle) => {
|
|
29
|
+
await this.ensureInit();
|
|
30
|
+
const { DeleteMessageCommand } = await import("@aws-sdk/client-sqs");
|
|
31
|
+
const params = {
|
|
32
|
+
QueueUrl: queueUrl,
|
|
33
|
+
ReceiptHandle: recipientHandle
|
|
34
|
+
};
|
|
35
|
+
return await this.client.send(new DeleteMessageCommand(params));
|
|
36
|
+
};
|
|
37
|
+
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
|
+
};
|
|
44
|
+
|
|
45
|
+
//#endregion
|
|
46
|
+
//#region src/aws/sqs/server/awsSqs.ts
|
|
47
|
+
const awsSqsNamespaces = /* @__PURE__ */ new Map();
|
|
48
|
+
const awsSqsClient = async (key = "default", config, vaultId, itemId) => {
|
|
49
|
+
if (awsSqsNamespaces.has(key)) return awsSqsNamespaces.get(key);
|
|
50
|
+
const namespace = new AwsSqsNamespace(key, await getConfig(key, config, vaultId, itemId));
|
|
51
|
+
awsSqsNamespaces.set(key, namespace);
|
|
52
|
+
return namespace;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
//#endregion
|
|
56
|
+
export { AwsSqsNamespace, awsSqsClient };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { t as BaseNamespace } from "../../../index-DwB8X1lz.mjs";
|
|
2
|
+
import { t as AwsConfig } from "../../../index-CqTOMR8f.mjs";
|
|
3
|
+
import { SSMClient } from "@aws-sdk/client-ssm";
|
|
4
|
+
|
|
5
|
+
//#region src/aws/ssm/server/AwsSsmNamespace.d.ts
|
|
6
|
+
declare class AwsSsmNamespace extends BaseNamespace {
|
|
7
|
+
client: SSMClient;
|
|
8
|
+
config: AwsConfig;
|
|
9
|
+
parameters: Map<string, any>;
|
|
10
|
+
constructor(key: string, config: any);
|
|
11
|
+
ensureInit: () => Promise<void>;
|
|
12
|
+
getParameter: (name: string, withDecryption?: boolean, isJson?: boolean) => Promise<any>;
|
|
13
|
+
}
|
|
14
|
+
//#endregion
|
|
15
|
+
//#region src/aws/ssm/server/awsSsm.d.ts
|
|
16
|
+
declare const awsSsmClient: (key?: string, config?: AwsConfig, vaultId?: string, itemId?: string) => Promise<AwsSsmNamespace>;
|
|
17
|
+
//#endregion
|
|
18
|
+
export { AwsSsmNamespace, awsSsmClient };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { BaseNamespace } from "../../../_class/index.mjs";
|
|
2
|
+
import { t as getConfig } from "../../../server-Bwy4JI8Z.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/aws/ssm/server/AwsSsmNamespace.ts
|
|
5
|
+
var AwsSsmNamespace = class extends BaseNamespace {
|
|
6
|
+
parameters;
|
|
7
|
+
constructor(key, config) {
|
|
8
|
+
super(key, config);
|
|
9
|
+
this.parameters = /* @__PURE__ */ new Map();
|
|
10
|
+
}
|
|
11
|
+
ensureInit = async () => {
|
|
12
|
+
if (!this.client) try {
|
|
13
|
+
const { SSMClient } = await import("@aws-sdk/client-ssm");
|
|
14
|
+
this.client = new SSMClient(this.config);
|
|
15
|
+
} catch (e) {
|
|
16
|
+
throw new Error("AWS SSM Client not installed");
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
getParameter = async (name, withDecryption = false, isJson = true) => {
|
|
20
|
+
await this.ensureInit();
|
|
21
|
+
if (!this.parameters.has(name)) {
|
|
22
|
+
const { GetParameterCommand } = await import("@aws-sdk/client-ssm");
|
|
23
|
+
const apiResponse = await this.client.send(new GetParameterCommand({
|
|
24
|
+
Name: name,
|
|
25
|
+
WithDecryption: void 0 === withDecryption ? true : withDecryption
|
|
26
|
+
}));
|
|
27
|
+
if (apiResponse.Parameter.Value) if (void 0 === apiResponse.Parameter.Value) this.parameters.set(name, null);
|
|
28
|
+
else if (void 0 === isJson || true === isJson) this.parameters.set(name, JSON.parse(apiResponse.Parameter.Value) || null);
|
|
29
|
+
else this.parameters.set(name, apiResponse.Parameter.Value);
|
|
30
|
+
else this.parameters.set(name, null);
|
|
31
|
+
}
|
|
32
|
+
return this.parameters.get(name);
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
//#endregion
|
|
37
|
+
//#region src/aws/ssm/server/awsSsm.ts
|
|
38
|
+
const awsSsmNamespaces = /* @__PURE__ */ new Map();
|
|
39
|
+
const awsSsmClient = async (key = "default", config, vaultId, itemId) => {
|
|
40
|
+
if (awsSsmNamespaces.has(key)) return awsSsmNamespaces.get(key);
|
|
41
|
+
const namespace = new AwsSsmNamespace(key, await getConfig(key, config, vaultId, itemId));
|
|
42
|
+
awsSsmNamespaces.set(key, namespace);
|
|
43
|
+
return namespace;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
//#endregion
|
|
47
|
+
export { AwsSsmNamespace, awsSsmClient };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { f as ApiResponseClass } from "../index-DW9yJLtI.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/axios/deleteRequest.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Make a DELETE request.
|
|
6
|
+
* Can't use the function name delete as it's reserved
|
|
7
|
+
*/
|
|
8
|
+
declare const deleteRequest: (url: string, config?: {}) => Promise<ApiResponseClass>;
|
|
9
|
+
//#endregion
|
|
10
|
+
//#region src/axios/get.d.ts
|
|
11
|
+
/**
|
|
12
|
+
* Make a GET request.
|
|
13
|
+
*/
|
|
14
|
+
declare const get: (url: string, config?: {}) => Promise<ApiResponseClass>;
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region src/axios/post.d.ts
|
|
17
|
+
/**
|
|
18
|
+
* Make a POST request.
|
|
19
|
+
*/
|
|
20
|
+
declare const post: (url: string, data?: {}, config?: {}) => Promise<ApiResponseClass>;
|
|
21
|
+
//#endregion
|
|
22
|
+
export { deleteRequest, get, post };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { u as ApiResponseClass } from "../api-DGKJDAfb.mjs";
|
|
2
|
+
import axios from "axios";
|
|
3
|
+
|
|
4
|
+
//#region src/axios/deleteRequest.ts
|
|
5
|
+
/**
|
|
6
|
+
* Make a DELETE request.
|
|
7
|
+
* Can't use the function name delete as it's reserved
|
|
8
|
+
*/
|
|
9
|
+
const deleteRequest = async (url, config = {}) => {
|
|
10
|
+
return await axios.delete(url, config).then(async (response) => {
|
|
11
|
+
if (void 0 !== response.data.body && void 0 !== response.data.error && void 0 !== response.data.state) return new ApiResponseClass(response.data);
|
|
12
|
+
else if (response.status >= 200 && response.status <= 299) return new ApiResponseClass().setToSuccess(response.data);
|
|
13
|
+
return new ApiResponseClass().setToError(response.data, response.statusText);
|
|
14
|
+
}).catch((error) => {
|
|
15
|
+
return new ApiResponseClass().setToError(null, error.message);
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
//#endregion
|
|
20
|
+
//#region src/axios/get.ts
|
|
21
|
+
/**
|
|
22
|
+
* Make a GET request.
|
|
23
|
+
*/
|
|
24
|
+
const get = async (url, config = {}) => {
|
|
25
|
+
return await axios.get(url, config).then(async (response) => {
|
|
26
|
+
if (void 0 !== response.data.body && void 0 !== response.data.error && void 0 !== response.data.state) return new ApiResponseClass(response.data);
|
|
27
|
+
else if (response.status >= 200 && response.status <= 299) return new ApiResponseClass().setToSuccess(response.data);
|
|
28
|
+
return new ApiResponseClass().setToError(response.data, response.statusText);
|
|
29
|
+
}).catch((error) => {
|
|
30
|
+
return new ApiResponseClass().setToError(null, error.message);
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
//#endregion
|
|
35
|
+
//#region src/axios/post.ts
|
|
36
|
+
/**
|
|
37
|
+
* Make a POST request.
|
|
38
|
+
*/
|
|
39
|
+
const post = async (url, data = {}, config = {}) => {
|
|
40
|
+
return await axios.post(url, data, config).then(async (response) => {
|
|
41
|
+
if (void 0 !== response.data.body && void 0 !== response.data.error && void 0 !== response.data.state) return new ApiResponseClass(response.data);
|
|
42
|
+
else if (response.status >= 200 && response.status <= 299) return new ApiResponseClass().setToSuccess(response.data);
|
|
43
|
+
return new ApiResponseClass().setToError(response.data, response.statusText);
|
|
44
|
+
}).catch((error) => {
|
|
45
|
+
return new ApiResponseClass().setToError(null, error.message);
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
//#endregion
|
|
50
|
+
export { deleteRequest, get, post };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region src/boolean/boolean.ts
|
|
2
|
+
/**
|
|
3
|
+
* Convert an input from a variety of forms into boolean.
|
|
4
|
+
*/
|
|
5
|
+
const getBoolean = (input, defaultValue = false) => {
|
|
6
|
+
if ("boolean" === typeof input) return input;
|
|
7
|
+
else if ("string" === typeof input) return "true" === input || "1" === input || "yes" === input || "y" === input;
|
|
8
|
+
else if ("number" === typeof input) return 1 === input;
|
|
9
|
+
return defaultValue;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
13
|
+
export { getBoolean };
|