fiberx-backend-toolkit 0.1.0 → 0.1.2
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.
|
@@ -19,7 +19,6 @@ const GENERATE_NOTIFICATION_CODE_TYPE = (interface_name, db_obj, code) => {
|
|
|
19
19
|
*/
|
|
20
20
|
export interface ${interface_name} {
|
|
21
21
|
${objectToType(db_obj, 8)}
|
|
22
|
-
attachment?s: EmailAttachmentInterface[]
|
|
23
22
|
}
|
|
24
23
|
`;
|
|
25
24
|
};
|
|
@@ -33,6 +32,7 @@ const GENERATE_UTIL_METHOD_CODE = (interface_name, method_name, code) => {
|
|
|
33
32
|
recipient_email: string;
|
|
34
33
|
created_by?: number | null;
|
|
35
34
|
payload: Types.${interface_name};
|
|
35
|
+
attachments?: EmailAttachmentInterface[];
|
|
36
36
|
}): Promise<boolean> {
|
|
37
37
|
try {
|
|
38
38
|
const enqueued = await EmailEnqueueProcessor?.getInstance()?.enqueue<Types.${interface_name}>({
|
|
@@ -40,6 +40,7 @@ const GENERATE_UTIL_METHOD_CODE = (interface_name, method_name, code) => {
|
|
|
40
40
|
recipient_email: params.recipient_email,
|
|
41
41
|
created_by: params.created_by ?? null,
|
|
42
42
|
payload: params.payload,
|
|
43
|
+
attachments: params.attachments
|
|
43
44
|
});
|
|
44
45
|
|
|
45
46
|
return (!enqueued);
|
|
@@ -63,7 +64,6 @@ class GeneratedEmailEnqueueUtil {
|
|
|
63
64
|
private static readonly name: string = "generated_email_enqueue_util";
|
|
64
65
|
private static readonly logger: LoggerUtil = new LoggerUtil(this.name);
|
|
65
66
|
|
|
66
|
-
|
|
67
67
|
${generated_content}
|
|
68
68
|
}
|
|
69
69
|
|
package/dist/mailer/main.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import EmailEnqueueGenerator from "./generators/email_enqueue_generator";
|
|
2
2
|
import EmailEnqueueProcessor from "./processors/email_enqueue_processor";
|
|
3
|
+
import EmailDeliveryProcessor from "./processors/email_delivery_processor";
|
|
3
4
|
import MailerDataLoaderUtil from "./utils/mailer_data_loader_util";
|
|
4
|
-
export { EmailEnqueueGenerator, EmailEnqueueProcessor, MailerDataLoaderUtil };
|
|
5
|
+
export { EmailEnqueueGenerator, EmailEnqueueProcessor, EmailDeliveryProcessor, MailerDataLoaderUtil };
|
package/dist/mailer/main.js
CHANGED
|
@@ -3,10 +3,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.MailerDataLoaderUtil = exports.EmailEnqueueProcessor = exports.EmailEnqueueGenerator = void 0;
|
|
6
|
+
exports.MailerDataLoaderUtil = exports.EmailDeliveryProcessor = exports.EmailEnqueueProcessor = exports.EmailEnqueueGenerator = void 0;
|
|
7
7
|
const email_enqueue_generator_1 = __importDefault(require("./generators/email_enqueue_generator"));
|
|
8
8
|
exports.EmailEnqueueGenerator = email_enqueue_generator_1.default;
|
|
9
9
|
const email_enqueue_processor_1 = __importDefault(require("./processors/email_enqueue_processor"));
|
|
10
10
|
exports.EmailEnqueueProcessor = email_enqueue_processor_1.default;
|
|
11
|
+
const email_delivery_processor_1 = __importDefault(require("./processors/email_delivery_processor"));
|
|
12
|
+
exports.EmailDeliveryProcessor = email_delivery_processor_1.default;
|
|
11
13
|
const mailer_data_loader_util_1 = __importDefault(require("./utils/mailer_data_loader_util"));
|
|
12
14
|
exports.MailerDataLoaderUtil = mailer_data_loader_util_1.default;
|
|
@@ -67,7 +67,7 @@ class EmailEnqueueProcessor {
|
|
|
67
67
|
// ==============================
|
|
68
68
|
async enqueue(input) {
|
|
69
69
|
try {
|
|
70
|
-
const { notification_code, payload: data_payload, recipient_email, created_by, scheduled_at = null, } = input;
|
|
70
|
+
const { notification_code, payload: data_payload, recipient_email, created_by, scheduled_at = null, attachments = [] } = input;
|
|
71
71
|
this.logger.info("Enqueue email request received", { notification_code, recipient_email, scheduled_at });
|
|
72
72
|
// 1️⃣ Resolve notification
|
|
73
73
|
const template = await this.provider.fetchActiveTemplate(notification_code);
|
|
@@ -83,7 +83,7 @@ class EmailEnqueueProcessor {
|
|
|
83
83
|
}
|
|
84
84
|
this.logger.info("Notification record resolved", { notification_code });
|
|
85
85
|
const content_payload = await this.LoadEmailContentPayload(`${notification_code}_email`);
|
|
86
|
-
const full_payload = { static_content: content_payload, db_content: data_payload };
|
|
86
|
+
const full_payload = { static_content: content_payload, db_content: data_payload, attachments };
|
|
87
87
|
// 4️⃣ Validate
|
|
88
88
|
this.validate(this.provider.getRequiredPlaceholders(template), full_payload);
|
|
89
89
|
// 5️⃣ Resolve mailer config
|
|
@@ -35,6 +35,7 @@ export interface EmailEnqueueInput<TPayload> {
|
|
|
35
35
|
recipient_email: string;
|
|
36
36
|
created_by?: number | null;
|
|
37
37
|
scheduled_at?: Date | null;
|
|
38
|
+
attachments?: EmailAttachmentInterface[];
|
|
38
39
|
}
|
|
39
40
|
export interface EmailEnqueueProcessorDataProvider<TNotification, TTemplate, TMailerConfig> {
|
|
40
41
|
fetchActiveTemplate(notification_code: string): Promise<TTemplate | null>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fiberx-backend-toolkit",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "A TypeScript backend toolkit providing shared domain logic, infrastructure helpers, and utilities for FiberX server-side applications and services.",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "./dist/index.js",
|