biz-slide-core 1.2.85 → 1.2.87
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/entity/analytic.entity.js +4 -4
- package/dist/entity/config.enity.js +2 -2
- package/dist/entity/cron.entity.js +2 -2
- package/dist/entity/customer.entity.js +3 -3
- package/dist/entity/image.entity.js +2 -2
- package/dist/entity/logs.entity.js +2 -2
- package/dist/entity/png-svg.entity.js +2 -2
- package/dist/entity/ppt-email-queue.entity.js +2 -2
- package/dist/entity/ppt-event.entity.js +2 -2
- package/dist/entity/ppt-slide.entity.js +2 -2
- package/dist/entity/ppt.entity.d.ts +1 -0
- package/dist/entity/ppt.entity.d.ts.map +1 -1
- package/dist/entity/ppt.entity.js +2 -2
- package/dist/entity/slide-layout.entity.js +4 -4
- package/dist/entity/slide.entity.js +3 -3
- package/dist/entity/socket.entity.js +2 -2
- package/dist/entity/template-type.entity.js +6 -6
- package/dist/entity/template.entity.js +2 -2
- package/dist/entity/training-queue.entity.js +2 -2
- package/dist/entity/user.entity.js +2 -2
- package/dist/middleware/authentication.js +112 -215
- package/dist/middleware/schemaValidate.js +10 -52
- package/dist/resHandler/errorHandler.js +20 -42
- package/dist/resHandler/successHandler.js +1 -1
- package/dist/utilities/callWithRetries.js +9 -67
- package/dist/utilities/createFolder.js +10 -51
- package/dist/utilities/encryptionUtils.js +14 -54
- package/dist/utilities/hasAbusiveWords.js +4 -5
- package/package.json +3 -1
- package/src/entity/analytic.entity.ts +0 -62
- package/src/entity/common.ts +0 -19
- package/src/entity/config.enity.ts +0 -18
- package/src/entity/cron.entity.ts +0 -22
- package/src/entity/customer.entity.ts +0 -40
- package/src/entity/image.entity.ts +0 -32
- package/src/entity/index.ts +0 -20
- package/src/entity/logs.entity.ts +0 -20
- package/src/entity/png-svg.entity.ts +0 -44
- package/src/entity/ppt-email-queue.entity.ts +0 -22
- package/src/entity/ppt-event.entity.ts +0 -25
- package/src/entity/ppt-slide.entity.ts +0 -40
- package/src/entity/ppt.entity.ts +0 -79
- package/src/entity/slide-layout.entity.ts +0 -56
- package/src/entity/slide.entity.ts +0 -61
- package/src/entity/socket.entity.ts +0 -20
- package/src/entity/template-type.entity.ts +0 -87
- package/src/entity/template.entity.ts +0 -38
- package/src/entity/training-queue.entity.ts +0 -26
- package/src/entity/user.entity.ts +0 -24
- package/src/index.ts +0 -6
- package/src/middleware/authentication.ts +0 -150
- package/src/middleware/index.ts +0 -3
- package/src/middleware/role.ts +0 -5
- package/src/middleware/schemaValidate.ts +0 -20
- package/src/resHandler/errorHandler.ts +0 -66
- package/src/resHandler/index.ts +0 -2
- package/src/resHandler/successHandler.ts +0 -11
- package/src/types/IController.ts +0 -6
- package/src/types/IRequest.ts +0 -8
- package/src/types/index.ts +0 -11
- package/src/utilities/callWithRetries.ts +0 -9
- package/src/utilities/createFolder.ts +0 -11
- package/src/utilities/encryptionUtils.ts +0 -26
- package/src/utilities/hasAbusiveWords.ts +0 -33
- package/src/utilities/index.ts +0 -5
- package/src/utilities/pngSvgCategories.ts +0 -167
- package/tsconfig.json +0 -11
| @@ -1,51 +1,4 @@ | |
| 1 1 | 
             
            "use strict";
         | 
| 2 | 
            -
            var __assign = (this && this.__assign) || function () {
         | 
| 3 | 
            -
                __assign = Object.assign || function(t) {
         | 
| 4 | 
            -
                    for (var s, i = 1, n = arguments.length; i < n; i++) {
         | 
| 5 | 
            -
                        s = arguments[i];
         | 
| 6 | 
            -
                        for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
         | 
| 7 | 
            -
                            t[p] = s[p];
         | 
| 8 | 
            -
                    }
         | 
| 9 | 
            -
                    return t;
         | 
| 10 | 
            -
                };
         | 
| 11 | 
            -
                return __assign.apply(this, arguments);
         | 
| 12 | 
            -
            };
         | 
| 13 | 
            -
            var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
         | 
| 14 | 
            -
                function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
         | 
| 15 | 
            -
                return new (P || (P = Promise))(function (resolve, reject) {
         | 
| 16 | 
            -
                    function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
         | 
| 17 | 
            -
                    function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
         | 
| 18 | 
            -
                    function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
         | 
| 19 | 
            -
                    step((generator = generator.apply(thisArg, _arguments || [])).next());
         | 
| 20 | 
            -
                });
         | 
| 21 | 
            -
            };
         | 
| 22 | 
            -
            var __generator = (this && this.__generator) || function (thisArg, body) {
         | 
| 23 | 
            -
                var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
         | 
| 24 | 
            -
                return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
         | 
| 25 | 
            -
                function verb(n) { return function (v) { return step([n, v]); }; }
         | 
| 26 | 
            -
                function step(op) {
         | 
| 27 | 
            -
                    if (f) throw new TypeError("Generator is already executing.");
         | 
| 28 | 
            -
                    while (g && (g = 0, op[0] && (_ = 0)), _) try {
         | 
| 29 | 
            -
                        if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
         | 
| 30 | 
            -
                        if (y = 0, t) op = [op[0] & 2, t.value];
         | 
| 31 | 
            -
                        switch (op[0]) {
         | 
| 32 | 
            -
                            case 0: case 1: t = op; break;
         | 
| 33 | 
            -
                            case 4: _.label++; return { value: op[1], done: false };
         | 
| 34 | 
            -
                            case 5: _.label++; y = op[1]; op = [0]; continue;
         | 
| 35 | 
            -
                            case 7: op = _.ops.pop(); _.trys.pop(); continue;
         | 
| 36 | 
            -
                            default:
         | 
| 37 | 
            -
                                if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
         | 
| 38 | 
            -
                                if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
         | 
| 39 | 
            -
                                if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
         | 
| 40 | 
            -
                                if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
         | 
| 41 | 
            -
                                if (t[2]) _.ops.pop();
         | 
| 42 | 
            -
                                _.trys.pop(); continue;
         | 
| 43 | 
            -
                        }
         | 
| 44 | 
            -
                        op = body.call(thisArg, _);
         | 
| 45 | 
            -
                    } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
         | 
| 46 | 
            -
                    if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
         | 
| 47 | 
            -
                }
         | 
| 48 | 
            -
            };
         | 
| 49 2 | 
             
            var __rest = (this && this.__rest) || function (s, e) {
         | 
| 50 3 | 
             
                var t = {};
         | 
| 51 4 | 
             
                for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
         | 
| @@ -59,186 +12,130 @@ var __rest = (this && this.__rest) || function (s, e) { | |
| 59 12 | 
             
            };
         | 
| 60 13 | 
             
            Object.defineProperty(exports, "__esModule", { value: true });
         | 
| 61 14 | 
             
            exports.authorizeWithGpt = exports.nonAuthorizeWithSlideApp = exports.authorizeWithSlideApp = exports.authorize = void 0;
         | 
| 62 | 
            -
             | 
| 63 | 
            -
             | 
| 64 | 
            -
             | 
| 65 | 
            -
                return function (req, res, next) {
         | 
| 66 | 
            -
                     | 
| 67 | 
            -
                         | 
| 68 | 
            -
             | 
| 69 | 
            -
             | 
| 70 | 
            -
             | 
| 71 | 
            -
             | 
| 72 | 
            -
             | 
| 73 | 
            -
             | 
| 74 | 
            -
             | 
| 75 | 
            -
             | 
| 76 | 
            -
             | 
| 77 | 
            -
             | 
| 78 | 
            -
             | 
| 79 | 
            -
             | 
| 80 | 
            -
             | 
| 81 | 
            -
             | 
| 82 | 
            -
             | 
| 83 | 
            -
             | 
| 84 | 
            -
             | 
| 85 | 
            -
             | 
| 86 | 
            -
             | 
| 87 | 
            -
             | 
| 88 | 
            -
             | 
| 89 | 
            -
                                    }
         | 
| 90 | 
            -
                                    hasAccess = roles.find(function (role) { return role === user_1.role; });
         | 
| 91 | 
            -
                                    if (!hasAccess) {
         | 
| 92 | 
            -
                                        return [2 /*return*/, res.status(403).json({ message: 'Forbbiden' })];
         | 
| 93 | 
            -
                                    }
         | 
| 94 | 
            -
                                    _a = user_1.toObject(), createdAt = _a.createdAt, updatedAt = _a.updatedAt, deletedAt = _a.deletedAt, password = _a.password, rest = __rest(_a, ["createdAt", "updatedAt", "deletedAt", "password"]);
         | 
| 95 | 
            -
                                    req.user = __assign(__assign({}, rest), { userId: rest.email });
         | 
| 96 | 
            -
                                    next();
         | 
| 97 | 
            -
                                    _b.label = 3;
         | 
| 98 | 
            -
                                case 3: return [2 /*return*/];
         | 
| 99 | 
            -
                            }
         | 
| 100 | 
            -
                        });
         | 
| 101 | 
            -
                    });
         | 
| 15 | 
            +
            const utilities_1 = require("../utilities");
         | 
| 16 | 
            +
            const entity_1 = require("../entity");
         | 
| 17 | 
            +
            const authorize = (roles) => {
         | 
| 18 | 
            +
                return async function (req, res, next) {
         | 
| 19 | 
            +
                    if (!req.headers.authorization) {
         | 
| 20 | 
            +
                        return res.status(401).json({ message: 'Unauthorized' });
         | 
| 21 | 
            +
                    }
         | 
| 22 | 
            +
                    if (!roles.length) {
         | 
| 23 | 
            +
                        return res.status(401).json({ message: 'Unauthorized' });
         | 
| 24 | 
            +
                    }
         | 
| 25 | 
            +
                    if (req.headers.authorization) {
         | 
| 26 | 
            +
                        const token = await (0, utilities_1.verifyUid)(req.headers.authorization);
         | 
| 27 | 
            +
                        if (!token) {
         | 
| 28 | 
            +
                            return res.status(401).json({ message: 'Session Expired' });
         | 
| 29 | 
            +
                        }
         | 
| 30 | 
            +
                        let user = await entity_1.UserModel.findOne({ email: token.value.email });
         | 
| 31 | 
            +
                        if (!user) {
         | 
| 32 | 
            +
                            return res.status(401).json({ message: 'No User Found' });
         | 
| 33 | 
            +
                        }
         | 
| 34 | 
            +
                        const hasAccess = roles.find(role => role === user.role);
         | 
| 35 | 
            +
                        if (!hasAccess) {
         | 
| 36 | 
            +
                            return res.status(403).json({ message: 'Forbbiden' });
         | 
| 37 | 
            +
                        }
         | 
| 38 | 
            +
                        const _a = user.toObject(), { createdAt, updatedAt, deletedAt, password } = _a, rest = __rest(_a, ["createdAt", "updatedAt", "deletedAt", "password"]);
         | 
| 39 | 
            +
                        req.user = Object.assign(Object.assign({}, rest), { userId: rest.email });
         | 
| 40 | 
            +
                        next();
         | 
| 41 | 
            +
                    }
         | 
| 102 42 | 
             
                };
         | 
| 103 43 | 
             
            };
         | 
| 104 44 | 
             
            exports.authorize = authorize;
         | 
| 105 | 
            -
             | 
| 106 | 
            -
                 | 
| 107 | 
            -
                 | 
| 108 | 
            -
                     | 
| 109 | 
            -
                         | 
| 110 | 
            -
                         | 
| 111 | 
            -
             | 
| 112 | 
            -
             | 
| 113 | 
            -
                            newCustomer = new entity_1.CustomerModel({
         | 
| 114 | 
            -
                                appName: appName || "default",
         | 
| 115 | 
            -
                                emailId: emailId,
         | 
| 116 | 
            -
                                emailTemplateStatus: {},
         | 
| 117 | 
            -
                                userId: userId
         | 
| 118 | 
            -
                            });
         | 
| 119 | 
            -
                            return [4 /*yield*/, newCustomer.save()];
         | 
| 120 | 
            -
                        case 2:
         | 
| 121 | 
            -
                            _a.sent();
         | 
| 122 | 
            -
                            _a.label = 3;
         | 
| 123 | 
            -
                        case 3: return [2 /*return*/];
         | 
| 124 | 
            -
                    }
         | 
| 125 | 
            -
                });
         | 
| 126 | 
            -
            }); };
         | 
| 127 | 
            -
            var authorizeWithSlideApp = function () {
         | 
| 128 | 
            -
                return function (req, res, next) {
         | 
| 129 | 
            -
                    var _a;
         | 
| 130 | 
            -
                    return __awaiter(this, void 0, void 0, function () {
         | 
| 131 | 
            -
                        var ipAddress, sessionId, token, userId;
         | 
| 132 | 
            -
                        return __generator(this, function (_b) {
         | 
| 133 | 
            -
                            switch (_b.label) {
         | 
| 134 | 
            -
                                case 0:
         | 
| 135 | 
            -
                                    ipAddress = req.headers['x-forwarded-for'] || req.connection.remoteAddress;
         | 
| 136 | 
            -
                                    sessionId = req.headers['x-fingerprint-key'];
         | 
| 137 | 
            -
                                    if (!req.headers.authorization) {
         | 
| 138 | 
            -
                                        return [2 /*return*/, res.status(401).json({ message: 'Unauthorized' })];
         | 
| 139 | 
            -
                                    }
         | 
| 140 | 
            -
                                    if (!req.headers.authorization) return [3 /*break*/, 3];
         | 
| 141 | 
            -
                                    return [4 /*yield*/, (0, utilities_1.verifyUid)(req.headers.authorization)];
         | 
| 142 | 
            -
                                case 1:
         | 
| 143 | 
            -
                                    token = _b.sent();
         | 
| 144 | 
            -
                                    if (!token) {
         | 
| 145 | 
            -
                                        return [2 /*return*/, res.status(401).json({ message: 'Session Expired' })];
         | 
| 146 | 
            -
                                    }
         | 
| 147 | 
            -
                                    userId = (token === null || token === void 0 ? void 0 : token.customer_id) || ((_a = token === null || token === void 0 ? void 0 : token.value) === null || _a === void 0 ? void 0 : _a.email);
         | 
| 148 | 
            -
                                    if (!userId) {
         | 
| 149 | 
            -
                                        return [2 /*return*/, res.status(401).json({ message: 'userId not found' })];
         | 
| 150 | 
            -
                                    }
         | 
| 151 | 
            -
                                    req.user = {
         | 
| 152 | 
            -
                                        userId: userId,
         | 
| 153 | 
            -
                                        sessionId: sessionId,
         | 
| 154 | 
            -
                                        ipAddress: ipAddress,
         | 
| 155 | 
            -
                                        appName: req.headers['x-app-name'],
         | 
| 156 | 
            -
                                        email: (token === null || token === void 0 ? void 0 : token.customer_email) || ""
         | 
| 157 | 
            -
                                    };
         | 
| 158 | 
            -
                                    return [4 /*yield*/, createUser(req.user.email, req.user.userId, req.user.appName)];
         | 
| 159 | 
            -
                                case 2:
         | 
| 160 | 
            -
                                    _b.sent();
         | 
| 161 | 
            -
                                    next();
         | 
| 162 | 
            -
                                    _b.label = 3;
         | 
| 163 | 
            -
                                case 3: return [2 /*return*/];
         | 
| 164 | 
            -
                            }
         | 
| 165 | 
            -
                        });
         | 
| 45 | 
            +
            const createUser = async (emailId, userId, appName) => {
         | 
| 46 | 
            +
                const customer = await entity_1.CustomerModel.findOne({ userId });
         | 
| 47 | 
            +
                if (!customer) {
         | 
| 48 | 
            +
                    const newCustomer = new entity_1.CustomerModel({
         | 
| 49 | 
            +
                        appName: appName || "default",
         | 
| 50 | 
            +
                        emailId,
         | 
| 51 | 
            +
                        emailTemplateStatus: {},
         | 
| 52 | 
            +
                        userId
         | 
| 166 53 | 
             
                    });
         | 
| 54 | 
            +
                    await newCustomer.save();
         | 
| 55 | 
            +
                }
         | 
| 56 | 
            +
            };
         | 
| 57 | 
            +
            const authorizeWithSlideApp = () => {
         | 
| 58 | 
            +
                return async function (req, res, next) {
         | 
| 59 | 
            +
                    var _a;
         | 
| 60 | 
            +
                    const ipAddress = req.headers['x-forwarded-for'] || req.connection.remoteAddress;
         | 
| 61 | 
            +
                    const sessionId = req.headers['x-fingerprint-key'];
         | 
| 62 | 
            +
                    if (!req.headers.authorization) {
         | 
| 63 | 
            +
                        return res.status(401).json({ message: 'Unauthorized' });
         | 
| 64 | 
            +
                    }
         | 
| 65 | 
            +
                    if (req.headers.authorization) {
         | 
| 66 | 
            +
                        const token = await (0, utilities_1.verifyUid)(req.headers.authorization);
         | 
| 67 | 
            +
                        if (!token) {
         | 
| 68 | 
            +
                            return res.status(401).json({ message: 'Session Expired' });
         | 
| 69 | 
            +
                        }
         | 
| 70 | 
            +
                        const userId = (token === null || token === void 0 ? void 0 : token.customer_id) || ((_a = token === null || token === void 0 ? void 0 : token.value) === null || _a === void 0 ? void 0 : _a.email);
         | 
| 71 | 
            +
                        if (!userId) {
         | 
| 72 | 
            +
                            return res.status(401).json({ message: 'userId not found' });
         | 
| 73 | 
            +
                        }
         | 
| 74 | 
            +
                        req.user = {
         | 
| 75 | 
            +
                            userId: userId,
         | 
| 76 | 
            +
                            sessionId,
         | 
| 77 | 
            +
                            ipAddress,
         | 
| 78 | 
            +
                            appName: req.headers['x-app-name'],
         | 
| 79 | 
            +
                            email: (token === null || token === void 0 ? void 0 : token.customer_email) || ""
         | 
| 80 | 
            +
                        };
         | 
| 81 | 
            +
                        await createUser(req.user.email, req.user.userId, req.user.appName);
         | 
| 82 | 
            +
                        next();
         | 
| 83 | 
            +
                    }
         | 
| 167 84 | 
             
                };
         | 
| 168 85 | 
             
            };
         | 
| 169 86 | 
             
            exports.authorizeWithSlideApp = authorizeWithSlideApp;
         | 
| 170 | 
            -
             | 
| 171 | 
            -
                return function (req, res, next) {
         | 
| 87 | 
            +
            const nonAuthorizeWithSlideApp = () => {
         | 
| 88 | 
            +
                return async function (req, res, next) {
         | 
| 172 89 | 
             
                    var _a;
         | 
| 173 | 
            -
                     | 
| 174 | 
            -
             | 
| 175 | 
            -
             | 
| 176 | 
            -
             | 
| 177 | 
            -
             | 
| 178 | 
            -
             | 
| 179 | 
            -
             | 
| 180 | 
            -
             | 
| 181 | 
            -
             | 
| 182 | 
            -
             | 
| 183 | 
            -
             | 
| 184 | 
            -
             | 
| 185 | 
            -
             | 
| 186 | 
            -
             | 
| 187 | 
            -
             | 
| 188 | 
            -
             | 
| 189 | 
            -
             | 
| 190 | 
            -
             | 
| 191 | 
            -
             | 
| 192 | 
            -
             | 
| 193 | 
            -
             | 
| 194 | 
            -
             | 
| 195 | 
            -
             | 
| 196 | 
            -
             | 
| 197 | 
            -
             | 
| 198 | 
            -
             | 
| 199 | 
            -
             | 
| 200 | 
            -
             | 
| 201 | 
            -
             | 
| 202 | 
            -
                                    _b.label = 4;
         | 
| 203 | 
            -
                                case 4:
         | 
| 204 | 
            -
                                    req.user = {
         | 
| 205 | 
            -
                                        userId: userId,
         | 
| 206 | 
            -
                                        sessionId: sessionId,
         | 
| 207 | 
            -
                                        ipAddress: ipAddress,
         | 
| 208 | 
            -
                                        appName: req.headers['x-app-name'],
         | 
| 209 | 
            -
                                        email: email
         | 
| 210 | 
            -
                                    };
         | 
| 211 | 
            -
                                    next();
         | 
| 212 | 
            -
                                    return [2 /*return*/];
         | 
| 213 | 
            -
                            }
         | 
| 214 | 
            -
                        });
         | 
| 215 | 
            -
                    });
         | 
| 90 | 
            +
                    const ipAddress = req.headers['x-forwarded-for'] || req.connection.remoteAddress;
         | 
| 91 | 
            +
                    const sessionId = req.headers['x-fingerprint-key'];
         | 
| 92 | 
            +
                    let userId = "guest";
         | 
| 93 | 
            +
                    let email = "";
         | 
| 94 | 
            +
                    if (req.headers.authorization) {
         | 
| 95 | 
            +
                        const token = await (0, utilities_1.verifyUid)(req.headers.authorization);
         | 
| 96 | 
            +
                        if (!token) {
         | 
| 97 | 
            +
                            return res.status(401).json({ message: 'Session Expired' });
         | 
| 98 | 
            +
                        }
         | 
| 99 | 
            +
                        userId = (token === null || token === void 0 ? void 0 : token.customer_id) || ((_a = token === null || token === void 0 ? void 0 : token.value) === null || _a === void 0 ? void 0 : _a.email);
         | 
| 100 | 
            +
                        email = (token === null || token === void 0 ? void 0 : token.customer_email) || "";
         | 
| 101 | 
            +
                        if (!userId) {
         | 
| 102 | 
            +
                            return res.status(401).json({ message: 'userId not found' });
         | 
| 103 | 
            +
                        }
         | 
| 104 | 
            +
                        await createUser(email, userId, req.headers['x-app-name']);
         | 
| 105 | 
            +
                    }
         | 
| 106 | 
            +
                    else {
         | 
| 107 | 
            +
                        if (!ipAddress || !sessionId) {
         | 
| 108 | 
            +
                            return res.status(401).json({ message: 'We are not able to track your actions' });
         | 
| 109 | 
            +
                        }
         | 
| 110 | 
            +
                    }
         | 
| 111 | 
            +
                    req.user = {
         | 
| 112 | 
            +
                        userId,
         | 
| 113 | 
            +
                        sessionId,
         | 
| 114 | 
            +
                        ipAddress,
         | 
| 115 | 
            +
                        appName: req.headers['x-app-name'],
         | 
| 116 | 
            +
                        email
         | 
| 117 | 
            +
                    };
         | 
| 118 | 
            +
                    next();
         | 
| 216 119 | 
             
                };
         | 
| 217 120 | 
             
            };
         | 
| 218 121 | 
             
            exports.nonAuthorizeWithSlideApp = nonAuthorizeWithSlideApp;
         | 
| 219 122 | 
             
            // TODO: Delete It 
         | 
| 220 | 
            -
             | 
| 221 | 
            -
                return function (req, res, next) {
         | 
| 222 | 
            -
                     | 
| 223 | 
            -
             | 
| 224 | 
            -
             | 
| 225 | 
            -
             | 
| 226 | 
            -
             | 
| 227 | 
            -
             | 
| 228 | 
            -
             | 
| 229 | 
            -
             | 
| 230 | 
            -
             | 
| 231 | 
            -
             | 
| 232 | 
            -
             | 
| 233 | 
            -
             | 
| 234 | 
            -
             | 
| 235 | 
            -
             | 
| 236 | 
            -
                                navigateFromGPT: true
         | 
| 237 | 
            -
                            };
         | 
| 238 | 
            -
                            next();
         | 
| 239 | 
            -
                            return [2 /*return*/];
         | 
| 240 | 
            -
                        });
         | 
| 241 | 
            -
                    });
         | 
| 123 | 
            +
            const authorizeWithGpt = () => {
         | 
| 124 | 
            +
                return async function (req, res, next) {
         | 
| 125 | 
            +
                    const secret = req.headers['authorization'];
         | 
| 126 | 
            +
                    const secretKey = secret ? secret.split(":") : undefined;
         | 
| 127 | 
            +
                    if (secretKey && secretKey.length === 2 && secretKey[0] !== `Bearer ${process.env.GPT_API_KEY}`) {
         | 
| 128 | 
            +
                        return res.status(401).json({ message: 'keys not matching' });
         | 
| 129 | 
            +
                    }
         | 
| 130 | 
            +
                    const ipAddress = req.headers['x-forwarded-for'] || req.connection.remoteAddress;
         | 
| 131 | 
            +
                    let userId = "guest";
         | 
| 132 | 
            +
                    req.user = {
         | 
| 133 | 
            +
                        userId,
         | 
| 134 | 
            +
                        ipAddress,
         | 
| 135 | 
            +
                        appName: secretKey[1],
         | 
| 136 | 
            +
                        navigateFromGPT: true
         | 
| 137 | 
            +
                    };
         | 
| 138 | 
            +
                    next();
         | 
| 242 139 | 
             
                };
         | 
| 243 140 | 
             
            };
         | 
| 244 141 | 
             
            exports.authorizeWithGpt = authorizeWithGpt;
         | 
| @@ -1,58 +1,16 @@ | |
| 1 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 __generator = (this && this.__generator) || function (thisArg, body) {
         | 
| 12 | 
            -
                var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
         | 
| 13 | 
            -
                return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
         | 
| 14 | 
            -
                function verb(n) { return function (v) { return step([n, v]); }; }
         | 
| 15 | 
            -
                function step(op) {
         | 
| 16 | 
            -
                    if (f) throw new TypeError("Generator is already executing.");
         | 
| 17 | 
            -
                    while (g && (g = 0, op[0] && (_ = 0)), _) try {
         | 
| 18 | 
            -
                        if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
         | 
| 19 | 
            -
                        if (y = 0, t) op = [op[0] & 2, t.value];
         | 
| 20 | 
            -
                        switch (op[0]) {
         | 
| 21 | 
            -
                            case 0: case 1: t = op; break;
         | 
| 22 | 
            -
                            case 4: _.label++; return { value: op[1], done: false };
         | 
| 23 | 
            -
                            case 5: _.label++; y = op[1]; op = [0]; continue;
         | 
| 24 | 
            -
                            case 7: op = _.ops.pop(); _.trys.pop(); continue;
         | 
| 25 | 
            -
                            default:
         | 
| 26 | 
            -
                                if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
         | 
| 27 | 
            -
                                if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
         | 
| 28 | 
            -
                                if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
         | 
| 29 | 
            -
                                if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
         | 
| 30 | 
            -
                                if (t[2]) _.ops.pop();
         | 
| 31 | 
            -
                                _.trys.pop(); continue;
         | 
| 32 | 
            -
                        }
         | 
| 33 | 
            -
                        op = body.call(thisArg, _);
         | 
| 34 | 
            -
                    } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
         | 
| 35 | 
            -
                    if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
         | 
| 36 | 
            -
                }
         | 
| 37 | 
            -
            };
         | 
| 38 2 | 
             
            Object.defineProperty(exports, "__esModule", { value: true });
         | 
| 39 3 | 
             
            exports.validateSchema = void 0;
         | 
| 40 | 
            -
             | 
| 41 | 
            -
                return function (req, res, next) {
         | 
| 42 | 
            -
                     | 
| 43 | 
            -
             | 
| 44 | 
            -
                         | 
| 45 | 
            -
             | 
| 46 | 
            -
             | 
| 47 | 
            -
             | 
| 48 | 
            -
             | 
| 49 | 
            -
             | 
| 50 | 
            -
                            else {
         | 
| 51 | 
            -
                                next();
         | 
| 52 | 
            -
                            }
         | 
| 53 | 
            -
                            return [2 /*return*/];
         | 
| 54 | 
            -
                        });
         | 
| 55 | 
            -
                    });
         | 
| 4 | 
            +
            const validateSchema = (schema) => {
         | 
| 5 | 
            +
                return async function (req, res, next) {
         | 
| 6 | 
            +
                    const { error } = schema.validate(req.body, { abortEarly: false });
         | 
| 7 | 
            +
                    if (error) {
         | 
| 8 | 
            +
                        const errorMessage = error.details.map((err) => err.message).join(', ');
         | 
| 9 | 
            +
                        return res.status(400).json({ message: errorMessage });
         | 
| 10 | 
            +
                    }
         | 
| 11 | 
            +
                    else {
         | 
| 12 | 
            +
                        next();
         | 
| 13 | 
            +
                    }
         | 
| 56 14 | 
             
                };
         | 
| 57 15 | 
             
            };
         | 
| 58 16 | 
             
            exports.validateSchema = validateSchema;
         | 
| @@ -1,58 +1,36 @@ | |
| 1 1 | 
             
            "use strict";
         | 
| 2 | 
            -
            var __extends = (this && this.__extends) || (function () {
         | 
| 3 | 
            -
                var extendStatics = function (d, b) {
         | 
| 4 | 
            -
                    extendStatics = Object.setPrototypeOf ||
         | 
| 5 | 
            -
                        ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
         | 
| 6 | 
            -
                        function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
         | 
| 7 | 
            -
                    return extendStatics(d, b);
         | 
| 8 | 
            -
                };
         | 
| 9 | 
            -
                return function (d, b) {
         | 
| 10 | 
            -
                    if (typeof b !== "function" && b !== null)
         | 
| 11 | 
            -
                        throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
         | 
| 12 | 
            -
                    extendStatics(d, b);
         | 
| 13 | 
            -
                    function __() { this.constructor = d; }
         | 
| 14 | 
            -
                    d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
         | 
| 15 | 
            -
                };
         | 
| 16 | 
            -
            })();
         | 
| 17 2 | 
             
            Object.defineProperty(exports, "__esModule", { value: true });
         | 
| 18 3 | 
             
            exports.errorHandler = exports.CustomRequestError = exports.NotFoundRequestError = exports.BadRequestError = void 0;
         | 
| 19 | 
            -
             | 
| 20 | 
            -
                 | 
| 21 | 
            -
             | 
| 22 | 
            -
                     | 
| 23 | 
            -
                     | 
| 24 | 
            -
                    _this.name = 'BadRequestError';
         | 
| 25 | 
            -
                    return _this;
         | 
| 4 | 
            +
            class BadRequestError extends Error {
         | 
| 5 | 
            +
                constructor(message) {
         | 
| 6 | 
            +
                    super(message);
         | 
| 7 | 
            +
                    Object.setPrototypeOf(this, BadRequestError.prototype);
         | 
| 8 | 
            +
                    this.name = 'BadRequestError';
         | 
| 26 9 | 
             
                }
         | 
| 27 | 
            -
             | 
| 28 | 
            -
            }(Error));
         | 
| 10 | 
            +
            }
         | 
| 29 11 | 
             
            exports.BadRequestError = BadRequestError;
         | 
| 30 | 
            -
             | 
| 31 | 
            -
                 | 
| 32 | 
            -
             | 
| 33 | 
            -
                     | 
| 34 | 
            -
                     | 
| 35 | 
            -
                    _this.name = 'NotFoundRequestError';
         | 
| 36 | 
            -
                    return _this;
         | 
| 12 | 
            +
            class NotFoundRequestError extends Error {
         | 
| 13 | 
            +
                constructor(message) {
         | 
| 14 | 
            +
                    super(message);
         | 
| 15 | 
            +
                    Object.setPrototypeOf(this, NotFoundRequestError.prototype);
         | 
| 16 | 
            +
                    this.name = 'NotFoundRequestError';
         | 
| 37 17 | 
             
                }
         | 
| 38 | 
            -
             | 
| 39 | 
            -
            }(Error));
         | 
| 18 | 
            +
            }
         | 
| 40 19 | 
             
            exports.NotFoundRequestError = NotFoundRequestError;
         | 
| 41 | 
            -
             | 
| 42 | 
            -
                 | 
| 20 | 
            +
            class CustomRequestError {
         | 
| 21 | 
            +
                constructor(title, description) {
         | 
| 43 22 | 
             
                    this.name = 'CustomRequestError';
         | 
| 44 23 | 
             
                    this.message = {
         | 
| 45 | 
            -
                        title | 
| 46 | 
            -
                        description | 
| 24 | 
            +
                        title,
         | 
| 25 | 
            +
                        description
         | 
| 47 26 | 
             
                    };
         | 
| 48 27 | 
             
                }
         | 
| 49 | 
            -
             | 
| 50 | 
            -
            }());
         | 
| 28 | 
            +
            }
         | 
| 51 29 | 
             
            exports.CustomRequestError = CustomRequestError;
         | 
| 52 30 | 
             
            // Custom error handler middleware
         | 
| 53 | 
            -
             | 
| 54 | 
            -
                 | 
| 55 | 
            -
                 | 
| 31 | 
            +
            const errorHandler = (err, req, res, next) => {
         | 
| 32 | 
            +
                let statusCode = 500; // Default status code
         | 
| 33 | 
            +
                let errorMessage = 'Internal Server Error'; // Default error message
         | 
| 56 34 | 
             
                if (err instanceof BadRequestError) {
         | 
| 57 35 | 
             
                    statusCode = 400;
         | 
| 58 36 | 
             
                    errorMessage = err.message;
         | 
| @@ -2,7 +2,7 @@ | |
| 2 2 | 
             
            Object.defineProperty(exports, "__esModule", { value: true });
         | 
| 3 3 | 
             
            exports.successHandler = void 0;
         | 
| 4 4 | 
             
            // Generic success handler middleware
         | 
| 5 | 
            -
             | 
| 5 | 
            +
            const successHandler = (data, req, res, next) => {
         | 
| 6 6 | 
             
                res.status(200).json(data);
         | 
| 7 7 | 
             
            };
         | 
| 8 8 | 
             
            exports.successHandler = successHandler;
         | 
| @@ -1,73 +1,15 @@ | |
| 1 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 __generator = (this && this.__generator) || function (thisArg, body) {
         | 
| 12 | 
            -
                var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
         | 
| 13 | 
            -
                return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
         | 
| 14 | 
            -
                function verb(n) { return function (v) { return step([n, v]); }; }
         | 
| 15 | 
            -
                function step(op) {
         | 
| 16 | 
            -
                    if (f) throw new TypeError("Generator is already executing.");
         | 
| 17 | 
            -
                    while (g && (g = 0, op[0] && (_ = 0)), _) try {
         | 
| 18 | 
            -
                        if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
         | 
| 19 | 
            -
                        if (y = 0, t) op = [op[0] & 2, t.value];
         | 
| 20 | 
            -
                        switch (op[0]) {
         | 
| 21 | 
            -
                            case 0: case 1: t = op; break;
         | 
| 22 | 
            -
                            case 4: _.label++; return { value: op[1], done: false };
         | 
| 23 | 
            -
                            case 5: _.label++; y = op[1]; op = [0]; continue;
         | 
| 24 | 
            -
                            case 7: op = _.ops.pop(); _.trys.pop(); continue;
         | 
| 25 | 
            -
                            default:
         | 
| 26 | 
            -
                                if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
         | 
| 27 | 
            -
                                if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
         | 
| 28 | 
            -
                                if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
         | 
| 29 | 
            -
                                if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
         | 
| 30 | 
            -
                                if (t[2]) _.ops.pop();
         | 
| 31 | 
            -
                                _.trys.pop(); continue;
         | 
| 32 | 
            -
                        }
         | 
| 33 | 
            -
                        op = body.call(thisArg, _);
         | 
| 34 | 
            -
                    } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
         | 
| 35 | 
            -
                    if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
         | 
| 36 | 
            -
                }
         | 
| 37 | 
            -
            };
         | 
| 38 | 
            -
            var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
         | 
| 39 | 
            -
                if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
         | 
| 40 | 
            -
                    if (ar || !(i in from)) {
         | 
| 41 | 
            -
                        if (!ar) ar = Array.prototype.slice.call(from, 0, i);
         | 
| 42 | 
            -
                        ar[i] = from[i];
         | 
| 43 | 
            -
                    }
         | 
| 44 | 
            -
                }
         | 
| 45 | 
            -
                return to.concat(ar || Array.prototype.slice.call(from));
         | 
| 46 | 
            -
            };
         | 
| 47 2 | 
             
            Object.defineProperty(exports, "__esModule", { value: true });
         | 
| 48 3 | 
             
            exports.callWithRetries = void 0;
         | 
| 49 | 
            -
            function callWithRetries(retryCount, failedMessage, functionRef) {
         | 
| 50 | 
            -
                 | 
| 51 | 
            -
             | 
| 52 | 
            -
             | 
| 4 | 
            +
            async function callWithRetries(retryCount, failedMessage, functionRef, ...args) {
         | 
| 5 | 
            +
                try {
         | 
| 6 | 
            +
                    return await functionRef(...args);
         | 
| 7 | 
            +
                }
         | 
| 8 | 
            +
                catch (error) {
         | 
| 9 | 
            +
                    if (retryCount <= 0)
         | 
| 10 | 
            +
                        throw error;
         | 
| 11 | 
            +
                    console.log("callWithRetries", (error === null || error === void 0 ? void 0 : error.message) || error);
         | 
| 12 | 
            +
                    return callWithRetries(retryCount - 1, failedMessage, functionRef, ...args);
         | 
| 53 13 | 
             
                }
         | 
| 54 | 
            -
                return __awaiter(this, void 0, void 0, function () {
         | 
| 55 | 
            -
                    var error_1;
         | 
| 56 | 
            -
                    return __generator(this, function (_a) {
         | 
| 57 | 
            -
                        switch (_a.label) {
         | 
| 58 | 
            -
                            case 0:
         | 
| 59 | 
            -
                                _a.trys.push([0, 2, , 3]);
         | 
| 60 | 
            -
                                return [4 /*yield*/, functionRef.apply(void 0, args)];
         | 
| 61 | 
            -
                            case 1: return [2 /*return*/, _a.sent()];
         | 
| 62 | 
            -
                            case 2:
         | 
| 63 | 
            -
                                error_1 = _a.sent();
         | 
| 64 | 
            -
                                if (retryCount <= 0)
         | 
| 65 | 
            -
                                    throw error_1;
         | 
| 66 | 
            -
                                console.log("callWithRetries", (error_1 === null || error_1 === void 0 ? void 0 : error_1.message) || error_1);
         | 
| 67 | 
            -
                                return [2 /*return*/, callWithRetries.apply(void 0, __spreadArray([retryCount - 1, failedMessage, functionRef], args, false))];
         | 
| 68 | 
            -
                            case 3: return [2 /*return*/];
         | 
| 69 | 
            -
                        }
         | 
| 70 | 
            -
                    });
         | 
| 71 | 
            -
                });
         | 
| 72 14 | 
             
            }
         | 
| 73 15 | 
             
            exports.callWithRetries = callWithRetries;
         |