@platform-x/hep-notification-client 1.1.1 → 1.1.4

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.
@@ -0,0 +1,26 @@
1
+ interface RequestHandlerPostOptions {
2
+ url: string;
3
+ body: any;
4
+ options?: any;
5
+ }
6
+ interface RequestHandlerGetOptions {
7
+ url: string;
8
+ options?: any;
9
+ }
10
+ export declare class HttpRequestHandler {
11
+ private requestTimeout;
12
+ constructor();
13
+ /**
14
+ * post - handler to do post api calls
15
+ * @param requestConfig
16
+ * @returns
17
+ */
18
+ post(requestConfig: RequestHandlerPostOptions): Promise<any>;
19
+ /**
20
+ * get - handler to do get api calls
21
+ * @param requestConfig
22
+ * @returns
23
+ */
24
+ get(requestConfig: RequestHandlerGetOptions): Promise<any>;
25
+ }
26
+ export {};
@@ -0,0 +1,18 @@
1
+ export declare class TwilioService {
2
+ private client;
3
+ private senderNumber;
4
+ /**
5
+ * Constructor to initialize Twilio client and sender number
6
+ * @param accountSid - Twilio Account SID
7
+ * @param authToken - Twilio Auth Token
8
+ * @param senderNumber - Twilio Sender Phone Number
9
+ */
10
+ constructor(accountSid: string, authToken: string, senderNumber: string);
11
+ /**
12
+ * Send an SMS using Twilio
13
+ * @param to - Recipient's phone number
14
+ * @param message - Message content
15
+ * @returns Promise resolving with the Twilio response
16
+ */
17
+ sendSMS(to: string, message: string): Promise<import("twilio/lib/rest/api/v2010/account/message").MessageInstance>;
18
+ }
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Validate a phone number for format and length
3
+ * @param phoneNumber
4
+ * @returns
5
+ */
6
+ export declare const validatePhoneNumber: (phoneNumber: string) => boolean;
7
+ /**
8
+ * Validate a message for length and content
9
+ * @param message
10
+ * @returns
11
+ */
12
+ export declare const validateMessage: (message: string) => boolean;
13
+ /**
14
+ * Validate both phone number and message
15
+ * @param phoneNumber
16
+ * @param message
17
+ * @returns
18
+ */
19
+ export declare const validate: (phoneNumber: string, message: string) => {
20
+ valid: boolean;
21
+ errors: any;
22
+ };
@@ -0,0 +1,44 @@
1
+ export declare const enum HTTP_STATUS_CODE {
2
+ INTERNAL_SERVER_ERROR = 500
3
+ }
4
+ export declare const HTTP_STATUS_MAP: Map<number, string>;
5
+ export declare const enum HTTP_STATUS_TYPE {
6
+ INTERNAL_SERVER_ERROR = "Internal Server Error"
7
+ }
8
+ export declare class CommonErrorTemplate extends Error {
9
+ code: number;
10
+ type: string;
11
+ constructor(msg: string, code?: number);
12
+ toJSON(): {
13
+ code: number;
14
+ type: string;
15
+ message: string;
16
+ };
17
+ }
18
+ export declare class ApiError extends CommonErrorTemplate {
19
+ constructor(msg: string, code?: number);
20
+ }
21
+ export declare class SolrError extends CommonErrorTemplate {
22
+ constructor(msg: string, code?: number);
23
+ }
24
+ export declare class CustomError {
25
+ code: number | undefined;
26
+ type: string | undefined;
27
+ message: string | undefined;
28
+ stack: string | undefined;
29
+ errorObj: Error | undefined | null;
30
+ constructor(errObj?: any, code?: number, type?: string, message?: string, stack?: string);
31
+ toJSON(): {
32
+ code: number | undefined;
33
+ type: string | undefined;
34
+ message: string | undefined;
35
+ };
36
+ }
37
+ /**
38
+ * errorMapper - to map error object to custom error
39
+ */
40
+ export declare const errorMapper: (err: any, statusCode?: number, type?: string) => any;
41
+ /**
42
+ * throwError - to throw custome error
43
+ */
44
+ export declare const throwError: (err: any, statusCode?: number, type?: string) => never;
@@ -0,0 +1,68 @@
1
+ export interface payLoadInterface {
2
+ statusCode?: number;
3
+ data?: any;
4
+ }
5
+ export interface LoggerInterface {
6
+ info(message: string, method: string): void;
7
+ warn(message: string, method: string, payload?: object): void;
8
+ error(message: string, method: string, payload?: object): void;
9
+ debug(message: string, method: string, payload?: object): void;
10
+ }
11
+ export declare class LoggerClass implements LoggerInterface {
12
+ private logger;
13
+ private infoLevel;
14
+ private debugLevel;
15
+ private errorLevel;
16
+ private warnLevel;
17
+ private blockedKeywords;
18
+ constructor();
19
+ /**
20
+ * It's written to handle JSON.circular error
21
+ * @param obj
22
+ * @returns
23
+ */
24
+ customstringify(obj: any): string;
25
+ /**
26
+ * for info log
27
+ * @param message
28
+ * @param payload
29
+ * @param method
30
+ * @returns
31
+ */
32
+ info(message: string, method: string): void;
33
+ /**
34
+ * for warn log
35
+ * @param message
36
+ * @param payload
37
+ * @param method
38
+ * @returns
39
+ */
40
+ warn(message: string, method: string, payload?: any): void;
41
+ /**
42
+ * for error log
43
+ * @param message
44
+ * @param payload
45
+ * @param method
46
+ * @returns
47
+ */
48
+ error(message: string, method: string, payload?: any): void;
49
+ /**
50
+ * for debug log
51
+ * @param message
52
+ * @param payload
53
+ * @param method
54
+ * @returns
55
+ */
56
+ debug(message: string, method: string, payload?: any): void;
57
+ /**
58
+ * to map log levels and handle from config
59
+ */
60
+ private mapLogLevels;
61
+ /**
62
+ * to sanitize logs from unwanted fields to be shown
63
+ * @param request
64
+ * @returns
65
+ */
66
+ private sanitizeLog;
67
+ }
68
+ export declare const Logger: LoggerClass;
@@ -0,0 +1,2 @@
1
+ export declare const getTraceId: () => any;
2
+ export declare const getSpanId: () => any;
@@ -0,0 +1,35 @@
1
+ interface SolrQuery {
2
+ query(query: string | object | null | undefined): any;
3
+ paginate(start?: number, rows?: number): any;
4
+ filterList(fields: any): any;
5
+ sort(fields: any): any;
6
+ filterQuery(fields: any): any;
7
+ }
8
+ export declare class SolrClient {
9
+ private host;
10
+ private port;
11
+ private core;
12
+ private path;
13
+ private secure;
14
+ private solrNodeClient;
15
+ private solrQuery;
16
+ constructor(core?: string);
17
+ getQuery(): any;
18
+ createQuery(): SolrQuery;
19
+ executeSearch(): Promise<any>;
20
+ /**
21
+ * solrSearch- fn to call solr search
22
+ * @param queryParams
23
+ * @param fields
24
+ * @param fieldType
25
+ * @param sortData
26
+ * @returns
27
+ */
28
+ solrSearch(queryParams: any, fields?: any, fieldType?: any, sortData?: any, filterQuery?: any): Promise<unknown>;
29
+ private query;
30
+ private paginate;
31
+ private filterList;
32
+ private sort;
33
+ private filterQuery;
34
+ }
35
+ export {};
@@ -0,0 +1,42 @@
1
+ declare const _default: {
2
+ LOG_LEVELS: string[];
3
+ APP_NAME: string;
4
+ NODE_ENV: string | undefined;
5
+ SOLR_IMAGE_HOST_URL: string;
6
+ SENDGRID_API_KEY: string;
7
+ EMAIL_FROM: string;
8
+ SOLR: {
9
+ HOST: string | undefined;
10
+ PORT: string | undefined;
11
+ PATH: string | undefined;
12
+ CORE: string | undefined;
13
+ SECURE: boolean;
14
+ };
15
+ TWILIO: {
16
+ ACCOUNT_SID: string;
17
+ AUTH_TOKEN: string;
18
+ SENDER_NUMBER: string;
19
+ };
20
+ MONGO: {
21
+ HOST: string | undefined;
22
+ PORT: string | undefined;
23
+ DB_NAME: string | undefined;
24
+ USER: string | undefined;
25
+ PASS: string | undefined;
26
+ };
27
+ MULTISITE_WITH_SOLR: string | boolean;
28
+ APPLICATION_FORM_COLLECTION: string;
29
+ MAIL_ID: string;
30
+ CFF_MAIL_FROM: string;
31
+ USER_NAME: string;
32
+ CONTACT_FORM_COLLECTION: string;
33
+ NEWS_LETTER_FORM_COLLECTION: string;
34
+ CFF_WEEKLY_DAYS: string | number;
35
+ CFF_LAST_WEEK_HOURS: string | number;
36
+ RENDERING_API_GATEWAY_URL: string;
37
+ CFF_INFO_MAIL: string;
38
+ CFF_CC_EMAIL: string;
39
+ SITE_HOST: string;
40
+ DELIVERY_API_URL: string;
41
+ };
42
+ export default _default;
@@ -0,0 +1,3 @@
1
+ import { EmailHandler } from "./platform-x/util/emailHandler";
2
+ import { TwilioService } from "./common/service/twilioService";
3
+ export { EmailHandler, TwilioService };
@@ -0,0 +1,11 @@
1
+ export declare const DEFAULT_SOLR_ROWS = 2147483647;
2
+ export declare const CREATE_USER_EMAIL_TEMPLATE: {
3
+ subject: string;
4
+ hclplatformx_Body: string;
5
+ }[];
6
+ /** HTTP Request related constants */
7
+ export declare const HTTP_CONTENT_TYPE_JSON = "application/json";
8
+ export declare const TRACE_ID_HEADER_NAME = "Platform-X-Trace-Id";
9
+ export declare const DEFAULT_APP_PORT = 8080;
10
+ export declare const DEFAULT_APP_NAME = "api-gateway";
11
+ export declare const DEFAULT_REALM_NAME = "platform-x";
@@ -0,0 +1 @@
1
+ export declare const style = "<style>\n .username {\n font-size:24px;\n }\n .main_div {\n background-color: #dff3ff;\n box-sizing: border-box;\n\t\t\t\t\t\t\tfont-family: Segoe, \"Segoe UI\", \"DejaVu Sans\", \"Trebuchet MS\", Verdana, \"sans-serif\"\n }\n table {\n height: 100%;\n margin-left: auto;\n margin-right: auto;\n }\n .table_div {\n max-width: 600px;\n width: 100%;\n background-color: #fff;\n padding: 40px;\n border-radius: 5px;\n box-shadow: 8px 8px 16px 0 #b4e3ff;\n box-sizing: border-box;\n }\n .table_2 {\n width: 100%;\n padding-bottom: 30px;\n border-bottom: solid 1px #bfbfbf;\n margin-bottom: 30px;\n }\n .w-400 {\n width: 402px;\n }\n .w_h_30 {\n width: 40px;\n height: auto;\n }\n h1 {\n font-size: 24px;\n color: #000;\n text-transform: capitalize;\n margin: 0 0 20px;\n }\n .main_text {\n font-size: 16px;\n line-height: 1.5;\n color: #000000;\n margin: 0 0 30px;\n }\n a {\n color: #0077b5;\n }\n .mb_20 {\n margin-bottom: 20px;\n }\n .btn {\n display: block;\n width: 100px;\n padding: 15px 30px;\n font-size: 18px;\n font-weight: 600;\n color: #ffffff;\n text-align: center;\n background-color: #2D2D39;\n border-radius: 4px;\n text-decoration: none;\n }\n .border {\n margin-bottom: 30px;\n border-bottom: solid 1px #bfbfbf;\n padding-bottom: 30px;\n }\n .mb_pb_20 {\n margin-bottom: 30px;\n padding-bottom: 30px;\n }\n .sub_text {\n font-size: 14px;\n line-height: 1.5;\n color: #000000;\n margin: 26.5px 16px 15px 1px;\n }\n .link {\n font-size: 14px;\n font-weight: 600;\n color: #0077b5;\n margin-bottom: 20px;\n margin-right: 15px;\n }\n .thanks{\n font-size: 16px;\n line-height: 1.5;\n color: #000000;\n margin-top:40px\n }\n .mt_10{\n margin-top:10px\n }\n </style>\n";
@@ -0,0 +1,5 @@
1
+ import { SolrHttpDataSource } from '../util/solr-data-source/SolrHttpDataSource';
2
+ export declare class EmailDataSource extends SolrHttpDataSource {
3
+ constructor();
4
+ fetchPageModel(tagName: string): Promise<any>;
5
+ }
@@ -0,0 +1,8 @@
1
+ import mongoose from 'mongoose';
2
+ declare const _default: {
3
+ database: mongoose.Connection;
4
+ mongoose: typeof mongoose;
5
+ connect: () => void;
6
+ disconnect: () => void;
7
+ };
8
+ export default _default;
@@ -0,0 +1,9 @@
1
+ export default class FormBuilderDao {
2
+ /**
3
+ * Get data based on collectionName collection
4
+ * @param email
5
+ * @returns
6
+ */
7
+ fetch(collectionName: string, data: any): Promise<any>;
8
+ details(collectionName: string, filter: any, sort: any): Promise<any>;
9
+ }
@@ -0,0 +1,7 @@
1
+ declare const db: {
2
+ database: import("mongoose").Connection;
3
+ mongoose: typeof import("mongoose");
4
+ connect: () => void;
5
+ disconnect: () => void;
6
+ };
7
+ export default db;
@@ -0,0 +1,38 @@
1
+ import mongoose from 'mongoose';
2
+ /**
3
+ * Function for create model with dynamic collection name
4
+ * @param collectionName
5
+ * @returns
6
+ */
7
+ declare const dynamicModelName: (collectionName: string) => Promise<mongoose.Model<any, unknown, unknown, unknown, any, any> | mongoose.Model<{
8
+ createdAt: NativeDate;
9
+ updatedAt: NativeDate;
10
+ } & {}, {}, {}, {}, mongoose.Document<unknown, {}, {
11
+ createdAt: NativeDate;
12
+ updatedAt: NativeDate;
13
+ } & {}, {}> & {
14
+ createdAt: NativeDate;
15
+ updatedAt: NativeDate;
16
+ } & {} & {
17
+ _id: mongoose.Types.ObjectId;
18
+ } & {
19
+ __v: number;
20
+ }, mongoose.Schema<any, mongoose.Model<any, any, any, any, any, any>, {}, {}, {}, {}, {
21
+ timestamps: true;
22
+ minimize: false;
23
+ strict: false;
24
+ }, {
25
+ createdAt: NativeDate;
26
+ updatedAt: NativeDate;
27
+ } & {}, mongoose.Document<unknown, {}, mongoose.FlatRecord<{
28
+ createdAt: NativeDate;
29
+ updatedAt: NativeDate;
30
+ } & {}>, {}> & mongoose.FlatRecord<{
31
+ createdAt: NativeDate;
32
+ updatedAt: NativeDate;
33
+ } & {}> & {
34
+ _id: mongoose.Types.ObjectId;
35
+ } & {
36
+ __v: number;
37
+ }>>>;
38
+ export default dynamicModelName;
@@ -0,0 +1,55 @@
1
+ interface EmailOptions {
2
+ email: string;
3
+ emailTemplate: string;
4
+ subject: string;
5
+ bcc?: string;
6
+ personalizations?: Personalize;
7
+ }
8
+ interface Personalize {
9
+ to: [ToWithSubstitutions];
10
+ cc?: [ToWithSubstitutions];
11
+ bcc?: [ToWithSubstitutions];
12
+ }
13
+ interface ToWithSubstitutions {
14
+ to: string;
15
+ substitutions?: [string];
16
+ }
17
+ export declare class EmailHandler {
18
+ constructor();
19
+ /**
20
+ * post - handler to do emails triggering
21
+ * @param emailConfig
22
+ * @returns
23
+ */
24
+ sendEmail(emailConfig: EmailOptions): Promise<unknown>;
25
+ prepareEmailRequest(reqBody: any, emailType: any): Promise<any>;
26
+ /**
27
+ *
28
+ * @param reqBody
29
+ * @param emailType
30
+ * @returns
31
+ */
32
+ prepareSendEmailRequest(reqBody: any, emailType: any): Promise<any>;
33
+ /**
34
+ *
35
+ * @param emailConfiguration
36
+ * @returns
37
+ */
38
+ pushEmails(emailConfiguration: any): Promise<any>;
39
+ /**
40
+ * Function to send email with personalize data using sendgrid
41
+ * @param emailConfig
42
+ * @returns
43
+ */
44
+ sendEmailWithPersonalizations(emailConfig: any, isCFF?: any): Promise<unknown>;
45
+ /**
46
+ * prepare personalize email request to send email through sendgrid
47
+ * @param reqBody
48
+ * @returns
49
+ */
50
+ sendPersonalizeEmailRequest(reqBody: any): Promise<any>;
51
+ sendPlaceOrderEmail(reqBody: any): Promise<any>;
52
+ sendPlaceOrderEmailv1(reqBody: any): Promise<any>;
53
+ private fetchEmailTemplateData;
54
+ }
55
+ export {};
@@ -62,6 +62,8 @@ const formBuilder_dao_1 = __importDefault(require("../database/dao/formBuilder.d
62
62
  const dompurify_1 = __importDefault(require("dompurify"));
63
63
  const jsdom_1 = require("jsdom");
64
64
  const logger_1 = require("../../common/util/logger");
65
+ const path_1 = __importDefault(require("path"));
66
+ const fs_1 = __importDefault(require("fs"));
65
67
  const window = new jsdom_1.JSDOM('').window;
66
68
  const DOMPurify = (0, dompurify_1.default)(window);
67
69
  // NOSONAR-NEXT-LINE
@@ -377,7 +379,8 @@ class EmailHandler {
377
379
  const start = moment.tz(reqBody.dateTime, 'UTC'); // original timezone
378
380
  let curentTimeZone = start;
379
381
  curentTimeZone.tz(reqBody.timezoneOffset).format('Do MMMM YYYY, h:mm a');
380
- let emailTemplate = 'templates/orderPlaced.ejs';
382
+ const emailTemplatePath = path_1.default.resolve(__dirname, '../templates/orderPlaced.ejs');
383
+ const emailTemplate = fs_1.default.readFileSync(emailTemplatePath, 'utf-8');
381
384
  let billingStr = '';
382
385
  billingStr +=
383
386
  Object.keys(reqBody.billing_address).length !== 0
@@ -0,0 +1,4 @@
1
+ export declare class EmailTemplateHandler {
2
+ constructor();
3
+ static prepareEmailTemplate(reqBody: any): Promise<string>;
4
+ }
@@ -0,0 +1,26 @@
1
+ export interface Pagination {
2
+ start: number;
3
+ rows: number;
4
+ }
5
+ export interface FilterQueryType {
6
+ field: string;
7
+ value: string;
8
+ }
9
+ export interface SolrQueryRequest {
10
+ query: string | object;
11
+ filterQuery?: FilterQueryType[] | null | any;
12
+ pagination?: Pagination;
13
+ filter?: object | string[];
14
+ sort?: object;
15
+ }
16
+ export declare class SolrHttpDataSource<TContext = any> {
17
+ private solr;
18
+ context: TContext;
19
+ private cache;
20
+ private memoizedResults;
21
+ constructor();
22
+ cacheKey(id: string): string;
23
+ memoizedCacheKey(): string;
24
+ createQuery(queryRequest: SolrQueryRequest): void;
25
+ executeSearch(): Promise<any>;
26
+ }
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@platform-x/hep-notification-client",
3
- "version": "1.1.1",
3
+ "version": "1.1.4",
4
4
  "description": "@platform-x/hep-notification-client",
5
5
  "main": "dist/src/index.js",
6
6
  "types": "dist/src/index.d.ts",
7
7
  "scripts": {
8
- "build": "tsc",
9
- "prepare": "npm run build"
8
+ "build": "tsc && npm run copy-static",
9
+ "copy-static": "xcopy src\\templates dist\\templates /E /I /Y"
10
10
  },
11
11
  "author": "",
12
12
  "license": "ISC",
@@ -41,6 +41,7 @@
41
41
  "dotenv": "^10.0.0",
42
42
  "ejs": "^3.1.10",
43
43
  "express": "^4.17.1",
44
+ "fs": "^0.0.1-security",
44
45
  "jsdom": "^26.1.0",
45
46
  "lodash": "^4.17.21",
46
47
  "moment": "^2.30.1",
File without changes
File without changes