@betterinternship/core 2.16.9 → 2.18.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/README.md +26 -26
- package/dist/lib/email/email.d.ts +6 -4
- package/dist/lib/email/email.js +96 -67
- package/dist/lib/email/email.js.map +1 -1
- package/dist/lib/forms/field-preset-templates.js +8 -8
- package/dist/lib/pdf-viewer/form-previewer-rendering.js +7 -7
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +80 -79
- package/dist/lib/broker/base.process.d.ts +0 -2
- package/dist/lib/broker/base.process.js +0 -3
- package/dist/lib/broker/base.process.js.map +0 -1
- package/dist/lib/broker/base.task.d.ts +0 -40
- package/dist/lib/broker/base.task.js +0 -88
- package/dist/lib/broker/base.task.js.map +0 -1
- package/dist/lib/broker/broker.d.ts +0 -28
- package/dist/lib/broker/broker.js +0 -112
- package/dist/lib/broker/broker.js.map +0 -1
- package/dist/lib/broker/index.d.ts +0 -2
- package/dist/lib/broker/index.js +0 -3
- package/dist/lib/broker/index.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
# Package.Core
|
|
2
|
-
|
|
3
|
-
Contains dependencies shared between the different services of the site.
|
|
4
|
-
|
|
5
|
-
## How to update
|
|
6
|
-
|
|
7
|
-
1. Build the package:
|
|
8
|
-
|
|
9
|
-
```bash
|
|
10
|
-
npm run build
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
2. Commit the build:
|
|
14
|
-
|
|
15
|
-
```bash
|
|
16
|
-
git add .
|
|
17
|
-
git commit -m "<follow conventional commits, k thanks>"
|
|
18
|
-
git push
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
3. Update the version and publish the package to NPM:
|
|
22
|
-
|
|
23
|
-
```bash
|
|
24
|
-
npm version <patch|minor|major>
|
|
25
|
-
npm publish
|
|
26
|
-
```
|
|
1
|
+
# Package.Core
|
|
2
|
+
|
|
3
|
+
Contains dependencies shared between the different services of the site.
|
|
4
|
+
|
|
5
|
+
## How to update
|
|
6
|
+
|
|
7
|
+
1. Build the package:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm run build
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
2. Commit the build:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
git add .
|
|
17
|
+
git commit -m "<follow conventional commits, k thanks>"
|
|
18
|
+
git push
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
3. Update the version and publish the package to NPM:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npm version <patch|minor|major>
|
|
25
|
+
npm publish
|
|
26
|
+
```
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { SESClient } from '@aws-sdk/client-ses';
|
|
2
|
-
export declare const sesClient: SESClient;
|
|
3
1
|
type EmailAlias = 'otp' | 'applications' | 'sign' | 'hello' | 'apply';
|
|
4
2
|
export interface IEmailParams {
|
|
5
3
|
sender?: string;
|
|
@@ -7,6 +5,8 @@ export interface IEmailParams {
|
|
|
7
5
|
recipient: string;
|
|
8
6
|
content: string;
|
|
9
7
|
alias?: EmailAlias;
|
|
8
|
+
configurationSetName?: string;
|
|
9
|
+
tags?: Record<string, string>;
|
|
10
10
|
}
|
|
11
11
|
export interface IMultiEmailParams {
|
|
12
12
|
sender?: string;
|
|
@@ -16,12 +16,14 @@ export interface IMultiEmailParams {
|
|
|
16
16
|
bcc?: string | string[];
|
|
17
17
|
content: string;
|
|
18
18
|
alias?: EmailAlias;
|
|
19
|
+
configurationSetName?: string;
|
|
20
|
+
tags?: Record<string, string>;
|
|
19
21
|
}
|
|
20
|
-
export declare const
|
|
22
|
+
export declare const sendMultiEmail: ({ sender, subject, to, cc, bcc, content, alias, configurationSetName, tags, }: IMultiEmailParams) => Promise<{
|
|
21
23
|
messageId: string | undefined;
|
|
22
24
|
response: string;
|
|
23
25
|
} | undefined>;
|
|
24
|
-
export declare const
|
|
26
|
+
export declare const sendSingleEmail: (params: IEmailParams) => Promise<{
|
|
25
27
|
messageId: string | undefined;
|
|
26
28
|
response: string;
|
|
27
29
|
} | undefined>;
|
package/dist/lib/email/email.js
CHANGED
|
@@ -1,30 +1,61 @@
|
|
|
1
|
-
import { SendEmailCommand } from '@aws-sdk/client-ses';
|
|
2
|
-
import {
|
|
1
|
+
import { SendEmailCommand, SESClient, } from '@aws-sdk/client-ses';
|
|
2
|
+
import { randomUUID } from 'crypto';
|
|
3
3
|
import { ENV } from '../env.js';
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
if (!
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const AWS_REGION = ENV.AWS_REGION;
|
|
11
|
-
const AWS_DISABLED = !AWS_ACCESS_KEY_ID || !AWS_SECRET_ACCESS_KEY || !AWS_REGION;
|
|
12
|
-
if (AWS_DISABLED)
|
|
13
|
-
console.error('[ERROR:ENV]: Missing Amazon setup.');
|
|
14
|
-
export const sesClient = new SESClient({
|
|
15
|
-
region: ENV.AWS_REGION,
|
|
16
|
-
});
|
|
17
|
-
const onEmailError = (recipient, resolve) => (error, info) => {
|
|
18
|
-
if (error) {
|
|
19
|
-
console.error('[ERROR:EMAIL] Could not send email.');
|
|
20
|
-
console.error('[-----] ' + error.message);
|
|
4
|
+
let _sesClient = null;
|
|
5
|
+
const getSesClient = () => {
|
|
6
|
+
if (!_sesClient) {
|
|
7
|
+
if (!ENV.AWS_ACCESS_KEY_ID || !ENV.AWS_SECRET_ACCESS_KEY || !ENV.AWS_REGION)
|
|
8
|
+
console.error('[ERROR:ENV]: Missing Amazon setup.');
|
|
9
|
+
_sesClient = new SESClient({ region: ENV.AWS_REGION, maxAttempts: 1 });
|
|
21
10
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
11
|
+
return _sesClient;
|
|
12
|
+
};
|
|
13
|
+
const RETRY_BASE_DELAY_MS = 500;
|
|
14
|
+
const RETRY_DELAY_FACTOR = 3;
|
|
15
|
+
const getMaxAttempts = () => {
|
|
16
|
+
const parsed = parseInt(ENV.EMAIL_SEND_MAX_ATTEMPTS ?? '', 10);
|
|
17
|
+
return Number.isFinite(parsed) && parsed >= 1 ? parsed : 3;
|
|
18
|
+
};
|
|
19
|
+
const getRetryDelayMs = (attempt) => {
|
|
20
|
+
const base = RETRY_BASE_DELAY_MS * RETRY_DELAY_FACTOR ** (attempt - 1);
|
|
21
|
+
const jitter = base * 0.25 * (Math.random() * 2 - 1);
|
|
22
|
+
return Math.round(base + jitter);
|
|
23
|
+
};
|
|
24
|
+
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
25
|
+
const isRetryableSendError = (error) => {
|
|
26
|
+
const err = error;
|
|
27
|
+
if (err.name === 'ThrottlingException')
|
|
28
|
+
return true;
|
|
29
|
+
if (err.name === 'TooManyRequestsException')
|
|
30
|
+
return true;
|
|
31
|
+
const status = err.$metadata?.httpStatusCode;
|
|
32
|
+
if (status === undefined)
|
|
33
|
+
return true;
|
|
34
|
+
return status === 429 || status >= 500;
|
|
35
|
+
};
|
|
36
|
+
const describeError = (error) => {
|
|
37
|
+
const err = error;
|
|
38
|
+
return `${err.name ?? 'Error'}: ${err.message ?? String(error)}`;
|
|
39
|
+
};
|
|
40
|
+
const recordSendFailure = async (failure) => {
|
|
41
|
+
if (!ENV.DB_URL) {
|
|
42
|
+
console.warn('[EMAIL] DB_URL not set; send failure not recorded.');
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
try {
|
|
46
|
+
const { emailDeliveryEvents } = await import('@betterinternship/db');
|
|
47
|
+
await emailDeliveryEvents.create({
|
|
48
|
+
data: {
|
|
49
|
+
event_type: 'send_failure',
|
|
50
|
+
recipient_email: failure.recipient,
|
|
51
|
+
feedback_id: randomUUID(),
|
|
52
|
+
attempts: failure.attempts,
|
|
53
|
+
error_message: describeError(failure.error),
|
|
54
|
+
},
|
|
26
55
|
});
|
|
27
|
-
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
console.error('[ERROR:EMAIL] Could not record send failure.', error);
|
|
28
59
|
}
|
|
29
60
|
};
|
|
30
61
|
const normalizeRecipients = (value) => {
|
|
@@ -35,34 +66,41 @@ const normalizeRecipients = (value) => {
|
|
|
35
66
|
...new Set(list.map((recipient) => recipient.trim()).filter(Boolean)),
|
|
36
67
|
];
|
|
37
68
|
};
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
69
|
+
const toSesTags = (tags) => Object.entries(tags).map(([name, value]) => ({
|
|
70
|
+
Name: name,
|
|
71
|
+
Value: value.trim().slice(0, 256).replaceAll(' ', ''),
|
|
72
|
+
}));
|
|
73
|
+
const sendWithRetries = async (params, logRecipients) => {
|
|
74
|
+
const maxAttempts = getMaxAttempts();
|
|
75
|
+
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
|
|
76
|
+
try {
|
|
77
|
+
const command = new SendEmailCommand(params);
|
|
78
|
+
const result = await getSesClient().send(command);
|
|
79
|
+
console.warn('[AWSSES] Email sent to ' + logRecipients.join(', '));
|
|
80
|
+
return {
|
|
81
|
+
messageId: result.MessageId,
|
|
82
|
+
response: 'Successfully sent via Amazon SES.',
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
catch (error) {
|
|
86
|
+
if (isRetryableSendError(error) && attempt < maxAttempts) {
|
|
87
|
+
const delay = getRetryDelayMs(attempt);
|
|
88
|
+
console.error(`[ERROR:AWSSES] Send failed (attempt ${attempt}/${maxAttempts}), retrying in ${delay}ms: ${describeError(error)}`);
|
|
89
|
+
await sleep(delay);
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
console.error(`[ERROR:AWSSES] Send failed permanently after ${attempt} attempt(s) to ${logRecipients.join(', ')}: ${describeError(error)}`);
|
|
93
|
+
await recordSendFailure({
|
|
94
|
+
recipient: logRecipients[0],
|
|
95
|
+
attempts: attempt,
|
|
96
|
+
error,
|
|
97
|
+
});
|
|
98
|
+
return undefined;
|
|
99
|
+
}
|
|
63
100
|
}
|
|
101
|
+
return undefined;
|
|
64
102
|
};
|
|
65
|
-
const
|
|
103
|
+
export const sendMultiEmail = async ({ sender, subject, to, cc, bcc, content, alias = 'hello', configurationSetName, tags, }) => {
|
|
66
104
|
const toRecipients = normalizeRecipients(to);
|
|
67
105
|
if (!toRecipients.length)
|
|
68
106
|
throw Error('[ERROR:EMAIL] No recipients provided for email.');
|
|
@@ -82,25 +120,16 @@ const amazonMultiEmailRoute = async ({ sender, subject, to, cc, bcc, content, al
|
|
|
82
120
|
},
|
|
83
121
|
},
|
|
84
122
|
Source: `"${sender ?? 'BetterInternship'}" <${alias}@betterinternship.com>`,
|
|
123
|
+
ConfigurationSetName: configurationSetName,
|
|
124
|
+
Tags: tags ? toSesTags(tags) : undefined,
|
|
85
125
|
};
|
|
86
|
-
|
|
87
|
-
const command = new SendEmailCommand(params);
|
|
88
|
-
const result = await sesClient.send(command);
|
|
89
|
-
console.warn('[AWSSES] Email sent to ' + logRecipients.join(', '));
|
|
90
|
-
return {
|
|
91
|
-
messageId: result.MessageId,
|
|
92
|
-
response: 'Successfully sent via Amazon SES.',
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
catch (error) {
|
|
96
|
-
console.error('[ERROR:AWSSES] Could not send email.');
|
|
97
|
-
console.error('[-----] ' + error);
|
|
98
|
-
}
|
|
126
|
+
return await sendWithRetries(params, logRecipients);
|
|
99
127
|
};
|
|
100
128
|
export const sendSingleEmail = async (params) => {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
129
|
+
if (!normalizeRecipients(params.recipient).length) {
|
|
130
|
+
console.error('[ERROR:EMAIL] No recipient provided for email.');
|
|
131
|
+
return undefined;
|
|
132
|
+
}
|
|
133
|
+
return await sendMultiEmail({ ...params, to: params.recipient });
|
|
105
134
|
};
|
|
106
135
|
//# sourceMappingURL=email.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"email.js","sourceRoot":"","sources":["../../../lib/email/email.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"email.js","sourceRoot":"","sources":["../../../lib/email/email.ts"],"names":[],"mappings":"AAaA,OAAO,EAEL,gBAAgB,EAEhB,SAAS,GACV,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAmChC,IAAI,UAAU,GAAqB,IAAI,CAAC;AACxC,MAAM,YAAY,GAAG,GAAc,EAAE;IACnC,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,IAAI,CAAC,GAAG,CAAC,iBAAiB,IAAI,CAAC,GAAG,CAAC,qBAAqB,IAAI,CAAC,GAAG,CAAC,UAAU;YACzE,OAAO,CAAC,KAAK,CAAC,oCAAoC,CAAC,CAAC;QACtD,UAAU,GAAG,IAAI,SAAS,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,UAAU,EAAE,WAAW,EAAE,CAAC,EAAE,CAAC,CAAC;IACzE,CAAC;IACD,OAAO,UAAU,CAAC;AACpB,CAAC,CAAC;AAEF,MAAM,mBAAmB,GAAG,GAAG,CAAC;AAChC,MAAM,kBAAkB,GAAG,CAAC,CAAC;AAE7B,MAAM,cAAc,GAAG,GAAG,EAAE;IAC1B,MAAM,MAAM,GAAG,QAAQ,CAAC,GAAG,CAAC,uBAAuB,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;IAC/D,OAAO,MAAM,CAAC,QAAQ,CAAC,MA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AC1C,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS;KACzC,CAAC;IAEF,OAAO,MAAM,eAAe,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;AACtD,CAAC,CAAC;AAQF,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,EAAE,MAAoB,EAAE,EAAE;IAG5D,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,MAAM,EAAE,CAAC;QAClD,OAAO,CAAC,KAAK,CAAC,gDAAgD,CAAC,CAAC;QAChE,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,OAAO,MAAM,cAAc,CAAC,EAAE,GAAG,MAAM,EAAE,EAAE,EAAE,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC;AACnE,CAAC,CAAC"}
|
|
@@ -5,14 +5,14 @@ const LONG_TEXT_VALIDATOR = `${TEXT_PREPROCESS}z.string().describe("textarea"))`
|
|
|
5
5
|
const NUMBER_VALIDATOR = 'z.number()';
|
|
6
6
|
const SIGNATURE_VALIDATOR = `${TEXT_PREPROCESS}z.string().nonempty({ message: "This field is required." }))`;
|
|
7
7
|
const DROPDOWN_VALIDATOR = `z.enum(["Option 1", "Option 2"], {message:"This field is required."})`;
|
|
8
|
-
const MULTISELECT_VALIDATOR = `z.array(
|
|
9
|
-
z.enum(
|
|
10
|
-
[
|
|
11
|
-
"Option 1",
|
|
12
|
-
"Option 2"
|
|
13
|
-
],
|
|
14
|
-
{ message: "This field is required." }
|
|
15
|
-
)
|
|
8
|
+
const MULTISELECT_VALIDATOR = `z.array(
|
|
9
|
+
z.enum(
|
|
10
|
+
[
|
|
11
|
+
"Option 1",
|
|
12
|
+
"Option 2"
|
|
13
|
+
],
|
|
14
|
+
{ message: "This field is required." }
|
|
15
|
+
)
|
|
16
16
|
).describe("multiselect")`;
|
|
17
17
|
const DATE_VALIDATOR = 'z.coerce.date()';
|
|
18
18
|
const TIME_VALIDATOR = 'z.string().describe("time")';
|
|
@@ -77,13 +77,13 @@ export const ensurePreviewFontsLoaded = () => {
|
|
|
77
77
|
if (!document.getElementById(PREVIEW_FONT_STYLE_ID)) {
|
|
78
78
|
const style = document.createElement("style");
|
|
79
79
|
style.id = PREVIEW_FONT_STYLE_ID;
|
|
80
|
-
style.textContent = `
|
|
81
|
-
@font-face {
|
|
82
|
-
font-family: "MegastinaPreview";
|
|
83
|
-
src: url("/fonts/megastina.regular.ttf") format("truetype");
|
|
84
|
-
font-weight: 400;
|
|
85
|
-
font-style: normal;
|
|
86
|
-
font-display: block;
|
|
80
|
+
style.textContent = `
|
|
81
|
+
@font-face {
|
|
82
|
+
font-family: "MegastinaPreview";
|
|
83
|
+
src: url("/fonts/megastina.regular.ttf") format("truetype");
|
|
84
|
+
font-weight: 400;
|
|
85
|
+
font-style: normal;
|
|
86
|
+
font-display: block;
|
|
87
87
|
}`;
|
|
88
88
|
document.head.appendChild(style);
|
|
89
89
|
}
|