fiberx-backend-toolkit 0.0.70 → 0.0.72
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.
|
@@ -30,27 +30,29 @@ ${objectToType(db_obj, 8)}
|
|
|
30
30
|
exports.GENERATE_NOTIFICATION_CODE_TYPE = GENERATE_NOTIFICATION_CODE_TYPE;
|
|
31
31
|
const GENERATE_UTIL_METHOD_CODE = (interface_name, method_name, code) => {
|
|
32
32
|
return `
|
|
33
|
-
/**
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
public static async ${method_name}(params: {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}): Promise {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
33
|
+
/**
|
|
34
|
+
* @generated-notification-code: ${code}
|
|
35
|
+
*/
|
|
36
|
+
public static async ${method_name}(params: {
|
|
37
|
+
recipient_email: string;
|
|
38
|
+
created_by?: number | null;
|
|
39
|
+
payload: Types.${interface_name};
|
|
40
|
+
}): Promise<boolean> {
|
|
41
|
+
try {
|
|
42
|
+
const enqueued = await EmailEnqueueProcessor?.getInstance()?.enqueue<Types.${interface_name}>({
|
|
43
|
+
notification_code: "${code}",
|
|
44
|
+
recipient_email: params.recipient_email,
|
|
45
|
+
created_by: params.created_by ?? null,
|
|
46
|
+
payload: params.payload,
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
return (!enqueued);
|
|
50
|
+
}
|
|
51
|
+
catch(error: any) {
|
|
52
|
+
this.logger.error("Failed to enqueue email in method ${method_name}", { error });
|
|
53
|
+
throw error;
|
|
54
|
+
}
|
|
52
55
|
}
|
|
53
|
-
}
|
|
54
56
|
`;
|
|
55
57
|
};
|
|
56
58
|
exports.GENERATE_UTIL_METHOD_CODE = GENERATE_UTIL_METHOD_CODE;
|
|
@@ -58,12 +60,11 @@ const GENERATE_UTIL_CLASS_CODE = (types_file_name, generated_content) => {
|
|
|
58
60
|
return `
|
|
59
61
|
import { EmailEnqueueProcessor } from "fiberx-backend-toolkit/dist/mailer/main";
|
|
60
62
|
import { LoggerUtil } from "fiberx-backend-toolkit/dist/utils/main";
|
|
61
|
-
import * as Types from "@/${types_file_name}";
|
|
63
|
+
import * as Types from "@/${types_file_name.replace(".ts", "")}";
|
|
62
64
|
|
|
63
65
|
class GeneratedEmailEnqueueUtil {
|
|
64
66
|
private static readonly name: string = "generated_email_enqueue_util";
|
|
65
67
|
private static readonly logger: LoggerUtil = new LoggerUtil(this.name);
|
|
66
|
-
private static email_enqueue_processor: EmailEnqueueProcessor = EmailEnqueueProcessor.getInstance();
|
|
67
68
|
|
|
68
69
|
|
|
69
70
|
${generated_content}
|
|
@@ -109,8 +109,8 @@ class EmailEnqueueGenerator {
|
|
|
109
109
|
try {
|
|
110
110
|
const notification = this.provider.getNotificationFromTemplate(template);
|
|
111
111
|
const code = this.provider.getNotificationCode(notification);
|
|
112
|
-
const interface_name = main_1.InputTransformerUtil.toPascalCase(code) + "EmailPayload";
|
|
113
|
-
const method_name = "send" + main_1.InputTransformerUtil.toPascalCase(code);
|
|
112
|
+
const interface_name = main_1.InputTransformerUtil.toPascalCase(code.toLowerCase()) + "EmailPayload";
|
|
113
|
+
const method_name = "send" + main_1.InputTransformerUtil.toPascalCase(code.toLowerCase()) + "Email";
|
|
114
114
|
const placeholders = this.provider.getRequiredPlaceholders(template) ?? {};
|
|
115
115
|
const static_obj = main_1.InputTransformerUtil.buildNestedObject(placeholders.static_content ?? []);
|
|
116
116
|
const db_obj = main_1.InputTransformerUtil.buildNestedObject(placeholders.db_content ?? []);
|
|
@@ -122,7 +122,7 @@ class TOTPServiceUtil {
|
|
|
122
122
|
generateAppSecret(member_email, custom_app_name = "") {
|
|
123
123
|
const app_name = this.env_manager.getEnvVar("APP_NAME", custom_app_name) ?? custom_app_name;
|
|
124
124
|
const name = member_email;
|
|
125
|
-
const issuer = input_validator_util_1.default.isProduction() ? `${app_name}
|
|
125
|
+
const issuer = input_validator_util_1.default.isProduction() ? `${app_name}` : `Dev ${app_name}`;
|
|
126
126
|
return this.generateSecret({ name, issuer });
|
|
127
127
|
}
|
|
128
128
|
// ===============================
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fiberx-backend-toolkit",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.72",
|
|
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",
|