@platform-x/hep-notification-client 1.0.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/dist/src/common/service/requestService.js +96 -0
- package/dist/src/common/service/twilioService.js +55 -0
- package/dist/src/common/util/commonUtil.js +44 -0
- package/dist/src/common/util/errorHandler.js +89 -0
- package/dist/src/common/util/logger.js +193 -0
- package/dist/src/common/util/requestTracer.js +17 -0
- package/dist/src/common/util/solrConnector.js +157 -0
- package/dist/src/config/index.js +52 -0
- package/dist/src/index.js +8 -0
- package/dist/src/platform-x/constants/index.js +15 -0
- package/dist/src/platform-x/constants/style.js +103 -0
- package/dist/src/platform-x/dataSource/emailDataSource.js +36 -0
- package/dist/src/platform-x/database/connection.js +51 -0
- package/dist/src/platform-x/database/dao/formBuilder.dao.js +51 -0
- package/dist/src/platform-x/database/index.js +9 -0
- package/dist/src/platform-x/database/models/formBuilder.model.js +35 -0
- package/dist/src/platform-x/util/emailHandler.js +458 -0
- package/dist/src/platform-x/util/emailTemplate.js +82 -0
- package/dist/src/platform-x/util/solr-data-source/SolrHttpDataSource.js +75 -0
- package/package.json +61 -0
- package/templates/orderPlaced.ejs +173 -0
- package/templates/orderPlaced.html +190 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
var _a;
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
const dotenv_1 = __importDefault(require("dotenv"));
|
|
8
|
+
const constants_1 = require("../platform-x/constants");
|
|
9
|
+
dotenv_1.default.config();
|
|
10
|
+
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
|
|
11
|
+
exports.default = {
|
|
12
|
+
LOG_LEVELS: ((_a = process.env.LOG_LEVELS) === null || _a === void 0 ? void 0 : _a.split(',')) || [],
|
|
13
|
+
APP_NAME: process.env.npm_package_name || constants_1.DEFAULT_APP_NAME,
|
|
14
|
+
NODE_ENV: process.env.NODE_ENV,
|
|
15
|
+
SOLR_IMAGE_HOST_URL: process.env.SOLR_IMAGE_HOST_URL || '',
|
|
16
|
+
SENDGRID_API_KEY: process.env.SENDGRID_API_KEY || '',
|
|
17
|
+
EMAIL_FROM: process.env.EMAIL_FROM || '',
|
|
18
|
+
SOLR: {
|
|
19
|
+
HOST: process.env.SOLR_HOST,
|
|
20
|
+
PORT: process.env.SOLR_PORT,
|
|
21
|
+
PATH: process.env.SOLR_PATH,
|
|
22
|
+
CORE: process.env.SOLR_CORE,
|
|
23
|
+
SECURE: Boolean(process.env.SOLR_SECURE),
|
|
24
|
+
},
|
|
25
|
+
TWILIO: {
|
|
26
|
+
ACCOUNT_SID: process.env.TWILIO_ACCOUNT_SID || '',
|
|
27
|
+
AUTH_TOKEN: process.env.TWILIO_AUTH_TOKEN || '',
|
|
28
|
+
SENDER_NUMBER: process.env.TWILIO_SENDER_NUMBER || '',
|
|
29
|
+
},
|
|
30
|
+
MONGO: {
|
|
31
|
+
HOST: process.env.MONGO_HOST,
|
|
32
|
+
PORT: process.env.MONGO_PORT,
|
|
33
|
+
DB_NAME: process.env.MONGO_DB,
|
|
34
|
+
USER: process.env.MONGO_USER,
|
|
35
|
+
PASS: process.env.MONGO_PASS,
|
|
36
|
+
},
|
|
37
|
+
MULTISITE_WITH_SOLR: process.env.MULTISITE_WITH_SOLR || false,
|
|
38
|
+
APPLICATION_FORM_COLLECTION: process.env.APPLICATION_FORM_COLLECTION || '',
|
|
39
|
+
MAIL_ID: process.env.MAIL_ID || '',
|
|
40
|
+
CFF_MAIL_FROM: process.env.CFF_MAIL_FROM || '',
|
|
41
|
+
USER_NAME: process.env.USER_NAME || '',
|
|
42
|
+
CONTACT_FORM_COLLECTION: process.env.CONTACT_FORM_COLLECTION || '',
|
|
43
|
+
NEWS_LETTER_FORM_COLLECTION: process.env.NEWS_LETTER_FORM_COLLECTION || '',
|
|
44
|
+
CFF_WEEKLY_DAYS: process.env.CFF_WEEKLY_DAYS || 0,
|
|
45
|
+
CFF_LAST_WEEK_HOURS: process.env.CFF_LAST_WEEK_HOURS || 0,
|
|
46
|
+
RENDERING_API_GATEWAY_URL: process.env.RENDERING_API_GATEWAY_URL || '',
|
|
47
|
+
CFF_INFO_MAIL: process.env.CFF_INFO_MAIL || '',
|
|
48
|
+
CFF_CC_EMAIL: process.env.CFF_CC_EMAIL || '',
|
|
49
|
+
SITE_HOST: process.env.SITE_HOST || '',
|
|
50
|
+
DELIVERY_API_URL: process.env.DELIVERY_API_URL || '',
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TwilioService = exports.EmailHandler = void 0;
|
|
4
|
+
const emailHandler_1 = require("./platform-x/util/emailHandler");
|
|
5
|
+
Object.defineProperty(exports, "EmailHandler", { enumerable: true, get: function () { return emailHandler_1.EmailHandler; } });
|
|
6
|
+
const twilioService_1 = require("./common/service/twilioService");
|
|
7
|
+
Object.defineProperty(exports, "TwilioService", { enumerable: true, get: function () { return twilioService_1.TwilioService; } });
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEFAULT_REALM_NAME = exports.DEFAULT_APP_NAME = exports.DEFAULT_APP_PORT = exports.TRACE_ID_HEADER_NAME = exports.HTTP_CONTENT_TYPE_JSON = exports.CREATE_USER_EMAIL_TEMPLATE = exports.DEFAULT_SOLR_ROWS = void 0;
|
|
4
|
+
exports.DEFAULT_SOLR_ROWS = 2147483647;
|
|
5
|
+
exports.CREATE_USER_EMAIL_TEMPLATE = [{
|
|
6
|
+
subject: 'Plat-x User Registration',
|
|
7
|
+
hclplatformx_Body: "<!DOCTYPE html>\r\n<html lang=\"en\">\r\n<head>\r\n <meta charset=\"UTF-8\">\r\n <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">\r\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\r\n <link href=\"https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap\" rel=\"stylesheet\">\r\n <title>Document</title>\r\n <style>\r\n body {\r\n font-family: 'Inter', sans-serif;\r\n }\r\n @media (max-width: 697px) {\r\n .rw-100 {\r\n width: 100% !important;\r\n padding: 20px !important\r\n }\r\n .padding29 {\r\n padding-left: 29px !important;\r\n padding-right: 29px !important;\r\n }\r\n .padding15 {\r\n padding-left: 15px !important;\r\n padding-right: 15px !important;\r\n }\r\n }\r\n </style>\r\n</head>\r\n<body style=\"margin: 0; padding: 0;\">\r\n <table class=\"rw-100\" style=\"width: 698px; margin: auto; padding: 32px;\">\r\n <thead>\r\n <tr>\r\n <th style=\"padding-bottom: 30px; text-align: left;\"><img src=\"https://platx-dspace-dev.fanuep.com/server/api/core/bitstreams/792c4406-ae39-4cfd-9627-d4af2d2033bd/content\" alt=\"X\" /></th>\r\n </tr>\r\n </thead>\r\n <tbody>\r\n <tr>\r\n <td>\r\n <table style=\"text-align: center; width: 100%; background-color: #fbfaff; padding: 32px; border-radius: 18px;\">\r\n <tr>\r\n <td style=\"padding-bottom: 42px;\"><img src=\"https://platx-dspace-dev.fanuep.com/server/api/core/bitstreams/c1118d01-f887-4612-a1d4-19276ef7fe56/content\" style=\"max-width: 100%;\" alt=\"X\" /></td>\r\n </tr>\r\n <tr>\r\n <td style=\"font-size: 24px; font-weight: bold; color: #000;\">Hi, {{FIRST_NAME}}</td>\r\n </tr>\r\n <tr>\r\n <td style=\"font-size: 16px; font-weight: 500; color: #333; padding-top: 20px;\">We’re so happy to have you.</td>\r\n </tr>\r\n </table>\r\n </td>\r\n </tr>\r\n <tr>\r\n <td>\r\n <table style=\"text-align: center; width: 100%;\">\r\n <tr>\r\n <td style=\"font-size: 24px; font-weight: bold; color: #000; padding: 30px 0\">Your team is waiting for you to join them</td>\r\n </tr>\r\n <tr>\r\n <td style=\"padding-bottom: 20px;\"><img src=\"{{PROFILE_IMAGE}}\" alt=\"X\" width=\"50px\" height=\"50px\" /></td>\r\n </tr>\r\n <tr>\r\n <td style=\"font-size: 14px; font-weight: 600; color: #2d2d39;\">{{CREATED_BY}} has invited you to collaborate on</td>\r\n </tr>\r\n <tr>\r\n <td style=\"padding: 10px 0; font-size: 12px; font-weight: bold; color: #5256b7;\">Platform X</td>\r\n </tr>\r\n <tr>\r\n <td style=\"font-size: 12px; font-weight: 400; color: #2d2d39; padding-bottom: 20px;\">Your Role: {{ROLE}}</td>\r\n </tr>\r\n <tr>\r\n <td style=\"padding-bottom: 20px;\">\r\n <a href=\"{{URL}}\" style=\"display: inline-block; padding: 12.4px 40px; border-radius: 4px; background-color: #2d2d39; color: #fff; font-size: 16px; text-decoration: none;\">Join the team</a>\r\n </td>\r\n </tr>\r\n </table>\r\n </td>\r\n </tr>\r\n <tr>\r\n <td style=\"padding: 0 44px;\" class=\"padding29\">\r\n <table style=\"text-align: center; width: 100%; background-color: #fbfaff; padding: 10px\">\r\n <tr>\r\n <td style=\"font-size: 12px; font-weight: 400; color: #2d2d39;\">Your login information</td>\r\n </tr>\r\n <tr>\r\n <td style=\"font-size: 14px; font-weight: 400; color: #5256b7; padding: 10px 0;\">“Email : <span style=\"font-weight: 600;\"> {{USERNAME}}”</span></td>\r\n </tr>\r\n <tr>\r\n <td style=\"font-size: 14px; font-weight: 400; color: #5256b7;\">“Password : <span style=\"font-weight: 600;\">{{PASSWORD}}”</span></td>\r\n </tr>\r\n </table>\r\n </td>\r\n </tr>\r\n </tbody>\r\n <tfoot>\r\n <tr>\r\n <td>\r\n <table style=\"width: 100%; padding: 30px; text-align: center;\" class=\"padding15\">\r\n <tr>\r\n <td style=\" border-top: 1px solid rgba(0, 0, 0, 0.2); padding: 15px 0; font-size: 24px; font-weight: bold; color: #2d2d39;\">Thank You!</td>\r\n </tr>\r\n <tr>\r\n <td style=\"color: #5c6574; font-size: 12px;\">Copyright © 2023</td>\r\n </tr>\r\n </table>\r\n </td>\r\n </tr>\r\n </tfoot>\r\n </table>\r\n</body>\r\n</html>"
|
|
8
|
+
}];
|
|
9
|
+
/** HTTP Request related constants */
|
|
10
|
+
exports.HTTP_CONTENT_TYPE_JSON = 'application/json';
|
|
11
|
+
exports.TRACE_ID_HEADER_NAME = 'Platform-X-Trace-Id';
|
|
12
|
+
exports.DEFAULT_APP_PORT = 8080;
|
|
13
|
+
exports.DEFAULT_APP_NAME = 'api-gateway';
|
|
14
|
+
exports.DEFAULT_REALM_NAME = 'platform-x';
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.style = void 0;
|
|
4
|
+
exports.style = `<style>
|
|
5
|
+
.username {
|
|
6
|
+
font-size:24px;
|
|
7
|
+
}
|
|
8
|
+
.main_div {
|
|
9
|
+
background-color: #dff3ff;
|
|
10
|
+
box-sizing: border-box;
|
|
11
|
+
font-family: Segoe, "Segoe UI", "DejaVu Sans", "Trebuchet MS", Verdana, "sans-serif"
|
|
12
|
+
}
|
|
13
|
+
table {
|
|
14
|
+
height: 100%;
|
|
15
|
+
margin-left: auto;
|
|
16
|
+
margin-right: auto;
|
|
17
|
+
}
|
|
18
|
+
.table_div {
|
|
19
|
+
max-width: 600px;
|
|
20
|
+
width: 100%;
|
|
21
|
+
background-color: #fff;
|
|
22
|
+
padding: 40px;
|
|
23
|
+
border-radius: 5px;
|
|
24
|
+
box-shadow: 8px 8px 16px 0 #b4e3ff;
|
|
25
|
+
box-sizing: border-box;
|
|
26
|
+
}
|
|
27
|
+
.table_2 {
|
|
28
|
+
width: 100%;
|
|
29
|
+
padding-bottom: 30px;
|
|
30
|
+
border-bottom: solid 1px #bfbfbf;
|
|
31
|
+
margin-bottom: 30px;
|
|
32
|
+
}
|
|
33
|
+
.w-400 {
|
|
34
|
+
width: 402px;
|
|
35
|
+
}
|
|
36
|
+
.w_h_30 {
|
|
37
|
+
width: 40px;
|
|
38
|
+
height: auto;
|
|
39
|
+
}
|
|
40
|
+
h1 {
|
|
41
|
+
font-size: 24px;
|
|
42
|
+
color: #000;
|
|
43
|
+
text-transform: capitalize;
|
|
44
|
+
margin: 0 0 20px;
|
|
45
|
+
}
|
|
46
|
+
.main_text {
|
|
47
|
+
font-size: 16px;
|
|
48
|
+
line-height: 1.5;
|
|
49
|
+
color: #000000;
|
|
50
|
+
margin: 0 0 30px;
|
|
51
|
+
}
|
|
52
|
+
a {
|
|
53
|
+
color: #0077b5;
|
|
54
|
+
}
|
|
55
|
+
.mb_20 {
|
|
56
|
+
margin-bottom: 20px;
|
|
57
|
+
}
|
|
58
|
+
.btn {
|
|
59
|
+
display: block;
|
|
60
|
+
width: 100px;
|
|
61
|
+
padding: 15px 30px;
|
|
62
|
+
font-size: 18px;
|
|
63
|
+
font-weight: 600;
|
|
64
|
+
color: #ffffff;
|
|
65
|
+
text-align: center;
|
|
66
|
+
background-color: #2D2D39;
|
|
67
|
+
border-radius: 4px;
|
|
68
|
+
text-decoration: none;
|
|
69
|
+
}
|
|
70
|
+
.border {
|
|
71
|
+
margin-bottom: 30px;
|
|
72
|
+
border-bottom: solid 1px #bfbfbf;
|
|
73
|
+
padding-bottom: 30px;
|
|
74
|
+
}
|
|
75
|
+
.mb_pb_20 {
|
|
76
|
+
margin-bottom: 30px;
|
|
77
|
+
padding-bottom: 30px;
|
|
78
|
+
}
|
|
79
|
+
.sub_text {
|
|
80
|
+
font-size: 14px;
|
|
81
|
+
line-height: 1.5;
|
|
82
|
+
color: #000000;
|
|
83
|
+
margin: 26.5px 16px 15px 1px;
|
|
84
|
+
}
|
|
85
|
+
.link {
|
|
86
|
+
font-size: 14px;
|
|
87
|
+
font-weight: 600;
|
|
88
|
+
color: #0077b5;
|
|
89
|
+
margin-bottom: 20px;
|
|
90
|
+
margin-right: 15px;
|
|
91
|
+
}
|
|
92
|
+
.thanks{
|
|
93
|
+
font-size: 16px;
|
|
94
|
+
line-height: 1.5;
|
|
95
|
+
color: #000000;
|
|
96
|
+
margin-top:40px
|
|
97
|
+
}
|
|
98
|
+
.mt_10{
|
|
99
|
+
margin-top:10px
|
|
100
|
+
}
|
|
101
|
+
</style>
|
|
102
|
+
`;
|
|
103
|
+
//# sourceMappingURL=style.js.map
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.EmailDataSource = void 0;
|
|
13
|
+
const logger_1 = require("../../common/util/logger");
|
|
14
|
+
const SolrHttpDataSource_1 = require("../util/solr-data-source/SolrHttpDataSource");
|
|
15
|
+
// NOSONAR-NEXT-LINE
|
|
16
|
+
class EmailDataSource extends SolrHttpDataSource_1.SolrHttpDataSource {
|
|
17
|
+
constructor() {
|
|
18
|
+
super();
|
|
19
|
+
}
|
|
20
|
+
fetchPageModel(tagName) {
|
|
21
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
logger_1.Logger.info('emailModelDataSource: Reached fetchPageModel', 'fetchPageModel');
|
|
23
|
+
logger_1.Logger.debug('Before calling createQuery method', 'fetchPageModel', tagName);
|
|
24
|
+
let queryRequest = {
|
|
25
|
+
query: `hclplatformx_TagName:"email" AND name:"${tagName}"`,
|
|
26
|
+
};
|
|
27
|
+
this.createQuery(queryRequest);
|
|
28
|
+
logger_1.Logger.debug('Reached fetchPageModel', 'fetchPageModel', queryRequest);
|
|
29
|
+
let response = yield this.executeSearch();
|
|
30
|
+
logger_1.Logger.debug('Reached fetchPageModel', 'fetchPageModel', response);
|
|
31
|
+
return response;
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
exports.EmailDataSource = EmailDataSource;
|
|
36
|
+
//# sourceMappingURL=emailDataSource.js.map
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const mongoose_1 = __importDefault(require("mongoose"));
|
|
16
|
+
const logger_1 = require("../../common/util/logger");
|
|
17
|
+
const index_1 = __importDefault(require("../../config/index"));
|
|
18
|
+
let database = mongoose_1.default.connection;
|
|
19
|
+
// Exit on error
|
|
20
|
+
mongoose_1.default.connection.on('error', (err) => {
|
|
21
|
+
logger_1.Logger.info(`MongoDB connection error: ${err}`, 'mongoose');
|
|
22
|
+
process.exit(-1);
|
|
23
|
+
});
|
|
24
|
+
const connect = () => {
|
|
25
|
+
if (database.readyState) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
mongoose_1.default.connect(`mongodb://${index_1.default.MONGO.USER}:${index_1.default.MONGO.PASS}@${index_1.default.MONGO.HOST}:${index_1.default.MONGO.PORT}/${index_1.default.MONGO.DB_NAME}?directConnection=true&authMechanism=DEFAULT&authSource=${index_1.default.MONGO.DB_NAME}`);
|
|
29
|
+
database = mongoose_1.default.connection;
|
|
30
|
+
database.once('open', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
31
|
+
logger_1.Logger.info(`[Server] connected to MongoDB`, 'connect');
|
|
32
|
+
}));
|
|
33
|
+
database.on('error', (err = {}) => {
|
|
34
|
+
logger_1.Logger.error(`[Server] error connecting to MongoDB`, 'connect', err);
|
|
35
|
+
process.exit(-1);
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
const disconnect = () => {
|
|
39
|
+
if (!database) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
logger_1.Logger.info(`Disconnected to MongoDB`, 'disconnect');
|
|
43
|
+
mongoose_1.default.disconnect();
|
|
44
|
+
};
|
|
45
|
+
exports.default = {
|
|
46
|
+
database,
|
|
47
|
+
mongoose: mongoose_1.default,
|
|
48
|
+
connect,
|
|
49
|
+
disconnect,
|
|
50
|
+
};
|
|
51
|
+
//# sourceMappingURL=connection.js.map
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const formBuilder_model_1 = __importDefault(require("../models/formBuilder.model"));
|
|
16
|
+
const logger_1 = require("../../../common/util/logger");
|
|
17
|
+
class FormBuilderDao {
|
|
18
|
+
/**
|
|
19
|
+
* Get data based on collectionName collection
|
|
20
|
+
* @param email
|
|
21
|
+
* @returns
|
|
22
|
+
*/
|
|
23
|
+
fetch(collectionName, data) {
|
|
24
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
+
try {
|
|
26
|
+
logger_1.Logger.info('FormBuilder Dao:: fetch', 'fetch');
|
|
27
|
+
let DynamicModel = yield (0, formBuilder_model_1.default)(collectionName);
|
|
28
|
+
return yield DynamicModel.find(data).sort({ updatedAt: -1 });
|
|
29
|
+
}
|
|
30
|
+
catch (err) {
|
|
31
|
+
logger_1.Logger.error('Error in FormBuilder Dao:', 'fetch', err);
|
|
32
|
+
throw err;
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
details(collectionName, filter, sort) {
|
|
37
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
+
try {
|
|
39
|
+
logger_1.Logger.info('FormBuilder Dao: details', 'details');
|
|
40
|
+
let DynamicModel = yield (0, formBuilder_model_1.default)(collectionName);
|
|
41
|
+
return yield DynamicModel.findOne(filter).sort(sort);
|
|
42
|
+
}
|
|
43
|
+
catch (err) {
|
|
44
|
+
logger_1.Logger.error('Error in FormBuilder Dao:', 'details', err);
|
|
45
|
+
throw err;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.default = FormBuilderDao;
|
|
51
|
+
//# sourceMappingURL=formBuilder.dao.js.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const connection_1 = __importDefault(require("./connection"));
|
|
7
|
+
const db = Object.assign({}, connection_1.default);
|
|
8
|
+
exports.default = db;
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const mongoose_1 = __importDefault(require("mongoose"));
|
|
16
|
+
/**
|
|
17
|
+
* Function for create model with dynamic collection name
|
|
18
|
+
* @param collectionName
|
|
19
|
+
* @returns
|
|
20
|
+
*/
|
|
21
|
+
const dynamicModelName = (collectionName) => __awaiter(void 0, void 0, void 0, function* () {
|
|
22
|
+
if (mongoose_1.default.modelNames().includes(collectionName)) {
|
|
23
|
+
return mongoose_1.default.model(collectionName);
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
const schema = new mongoose_1.default.Schema({}, {
|
|
27
|
+
timestamps: true,
|
|
28
|
+
minimize: false,
|
|
29
|
+
strict: false,
|
|
30
|
+
});
|
|
31
|
+
return mongoose_1.default.model(collectionName, schema, collectionName);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
exports.default = dynamicModelName;
|
|
35
|
+
//# sourceMappingURL=formBuilder.model.js.map
|