@optimiser/common 1.0.365 → 1.0.367

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.
Files changed (69) hide show
  1. package/dist/aws/awsservices.d.ts +39 -39
  2. package/dist/aws/awsservices.js +398 -398
  3. package/dist/constants.d.ts +35 -35
  4. package/dist/constants.js +36 -36
  5. package/dist/enums/databasetype.enum.d.ts +7 -7
  6. package/dist/enums/databasetype.enum.js +11 -11
  7. package/dist/enums/log.enum.d.ts +22 -22
  8. package/dist/enums/log.enum.js +26 -26
  9. package/dist/index.d.ts +25 -25
  10. package/dist/index.js +69 -61
  11. package/dist/lib/activity.d.ts +1 -1
  12. package/dist/lib/activity.js +44 -44
  13. package/dist/lib/calculatedbsize.d.ts +15 -15
  14. package/dist/lib/calculatedbsize.js +75 -75
  15. package/dist/lib/connection.d.ts +116 -116
  16. package/dist/lib/connection.js +595 -595
  17. package/dist/lib/convertfilesize.d.ts +2 -2
  18. package/dist/lib/convertfilesize.js +15 -15
  19. package/dist/lib/countrycode.d.ts +2 -2
  20. package/dist/lib/countrycode.js +255 -255
  21. package/dist/lib/event.d.ts +26 -26
  22. package/dist/lib/event.js +252 -248
  23. package/dist/lib/helper.d.ts +94 -93
  24. package/dist/lib/helper.js +1016 -1009
  25. package/dist/lib/memoryserverclient.d.ts +40 -40
  26. package/dist/lib/memoryserverclient.js +256 -252
  27. package/dist/lib/operautilitycommon.d.ts +65 -65
  28. package/dist/lib/operautilitycommon.js +620 -620
  29. package/dist/lib/redis.d.ts +21 -21
  30. package/dist/lib/redis.js +46 -46
  31. package/dist/lib/socketidfromredis.d.ts +3 -3
  32. package/dist/lib/socketidfromredis.js +5 -5
  33. package/dist/lib/taskutils.d.ts +40 -40
  34. package/dist/lib/taskutils.js +656 -656
  35. package/dist/lib/utility.d.ts +300 -298
  36. package/dist/lib/utility.js +5626 -5621
  37. package/dist/lib/validateRequest.d.ts +3 -3
  38. package/dist/lib/validateRequest.js +13 -13
  39. package/dist/logs/auditlog.d.ts +25 -25
  40. package/dist/logs/auditlog.js +1033 -1029
  41. package/dist/logs/checklogtable.d.ts +3 -3
  42. package/dist/logs/checklogtable.js +67 -67
  43. package/dist/logs/log.table.d.ts +7 -7
  44. package/dist/logs/log.table.js +127 -127
  45. package/dist/modals/connection.modal.d.ts +32 -32
  46. package/dist/modals/connection.modal.js +2 -2
  47. package/dist/modals/globalNotification.modal.d.ts +8 -8
  48. package/dist/modals/globalNotification.modal.js +2 -2
  49. package/dist/modals/log.modal.d.ts +64 -64
  50. package/dist/modals/log.modal.js +2 -2
  51. package/dist/modals/mail.modal.d.ts +6 -6
  52. package/dist/modals/mail.modal.js +2 -2
  53. package/dist/modals/notificationData.modal.d.ts +29 -29
  54. package/dist/modals/notificationData.modal.js +2 -2
  55. package/dist/modals/redisconfig.modal.d.ts +6 -6
  56. package/dist/modals/redisconfig.modal.js +2 -2
  57. package/dist/modals/sqsconfig.modal.d.ts +8 -8
  58. package/dist/modals/sqsconfig.modal.js +2 -2
  59. package/dist/modals/utility.modal.d.ts +17 -17
  60. package/dist/modals/utility.modal.js +2 -2
  61. package/dist/utility/crypto.d.ts +4 -4
  62. package/dist/utility/crypto.js +43 -43
  63. package/dist/utility/errorHandler.d.ts +30 -30
  64. package/dist/utility/errorHandler.js +24 -24
  65. package/dist/utility/errorHandlerForServices.d.ts +22 -22
  66. package/dist/utility/errorHandlerForServices.js +19 -19
  67. package/dist/utility/mail.d.ts +21 -21
  68. package/dist/utility/mail.js +91 -87
  69. package/package.json +3 -3
@@ -1,75 +1,75 @@
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 (_) 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
- Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.calculatedbsize = void 0;
40
- /**
41
- *
42
- * @name Calculates total Database Size with Document and Drive Size in bytes
43
- * @author Ansh Nagrath
44
- * @param db(database connection) , next Function (Error handlinf=g purpose)
45
- * @returns object with integers { Database:38349875 , Drive:8978 ,Document : 234232 }
46
- */
47
- var calculatedbsize = function (db, next) {
48
- return __awaiter(this, void 0, void 0, function () {
49
- var documentSize, totalDbSize, driveSize, driveData, i;
50
- return __generator(this, function (_a) {
51
- switch (_a.label) {
52
- case 0:
53
- documentSize = 0;
54
- return [4 /*yield*/, db.stats().catch(next)];
55
- case 1:
56
- totalDbSize = (_a.sent()).dataSize;
57
- return [4 /*yield*/, db.collection('Company').findOne({}, { projection: { Setting: 1 } }).catch(next)];
58
- case 2:
59
- driveSize = (_a.sent()).Setting.DriveSetting.SpaceUsed;
60
- return [4 /*yield*/, db.collection('Drive').find({ ObjectType: { $exists: false }, IsActive: true, Size: { $exists: true } }).toArray().catch(next)];
61
- case 3:
62
- driveData = _a.sent();
63
- if (driveData && driveData.length > 0) {
64
- for (i = 0; i < driveData.length; ++i) {
65
- if (!driveData[i].ObjectType && driveData[i].Size && driveData[i].IsActive) {
66
- documentSize += parseInt(driveData[i].Size);
67
- }
68
- }
69
- }
70
- return [2 /*return*/, { Database: parseInt(totalDbSize), Drive: parseInt(driveSize), Document: documentSize }];
71
- }
72
- });
73
- });
74
- };
75
- exports.calculatedbsize = calculatedbsize;
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
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.calculatedbsize = void 0;
40
+ /**
41
+ *
42
+ * @name Calculates total Database Size with Document and Drive Size in bytes
43
+ * @author Ansh Nagrath
44
+ * @param db(database connection) , next Function (Error handlinf=g purpose)
45
+ * @returns object with integers { Database:38349875 , Drive:8978 ,Document : 234232 }
46
+ */
47
+ var calculatedbsize = function (db, next) {
48
+ return __awaiter(this, void 0, void 0, function () {
49
+ var documentSize, totalDbSize, driveSize, driveData, i;
50
+ return __generator(this, function (_a) {
51
+ switch (_a.label) {
52
+ case 0:
53
+ documentSize = 0;
54
+ return [4 /*yield*/, db.stats().catch(next)];
55
+ case 1:
56
+ totalDbSize = (_a.sent()).dataSize;
57
+ return [4 /*yield*/, db.collection('Company').findOne({}, { projection: { Setting: 1 } }).catch(next)];
58
+ case 2:
59
+ driveSize = (_a.sent()).Setting.DriveSetting.SpaceUsed;
60
+ return [4 /*yield*/, db.collection('Drive').find({ ObjectType: { $exists: false }, IsActive: true, Size: { $exists: true } }).toArray().catch(next)];
61
+ case 3:
62
+ driveData = _a.sent();
63
+ if (driveData && driveData.length > 0) {
64
+ for (i = 0; i < driveData.length; ++i) {
65
+ if (!driveData[i].ObjectType && driveData[i].Size && driveData[i].IsActive) {
66
+ documentSize += parseInt(driveData[i].Size);
67
+ }
68
+ }
69
+ }
70
+ return [2 /*return*/, { Database: parseInt(totalDbSize), Drive: parseInt(driveSize), Document: documentSize }];
71
+ }
72
+ });
73
+ });
74
+ };
75
+ exports.calculatedbsize = calculatedbsize;
@@ -1,116 +1,116 @@
1
- import { Db, MongoClient, ClientSession } from "mongodb";
2
- import { NextFunction, Response } from "express";
3
- import IORedis from "ioredis";
4
- import { Sequelize } from "sequelize";
5
- import { masterConnectionConfig, tokenConfig, OPT_Request, ResponseStructure, OPT_ERROR } from "../modals/connection.modal";
6
- import { DatabaseTypes } from '../enums/databasetype.enum';
7
- declare class Connection {
8
- private masterConfig;
9
- private redisClient?;
10
- private connections;
11
- /**
12
- * @param masterConfig Master Connectivity Object
13
- * @param redisClient Redisclient
14
- * @description connect to master database and maintain master config and redis client for furture ref
15
- */
16
- constructor(masterConfig: masterConnectionConfig, redisClient?: IORedis.Redis | undefined);
17
- /**
18
- * @param tokenData contains connection details of database
19
- * @param next
20
- * @return Promise
21
- * @description make connection to database when url and dbname is passed
22
- */
23
- ConnectToDb(tokenData: tokenConfig, next?: NextFunction): Promise<void>;
24
- /**
25
- *
26
- * @param req
27
- * @param res
28
- * @param next
29
- * @description middleware function : create database connection if not present
30
- */
31
- DbConnection: (req: OPT_Request, res: Response, next: NextFunction) => null | void;
32
- /**
33
- *
34
- * @param resolve
35
- * @param reject
36
- * @param DBName
37
- * @description helper middleware function: find connection details from Master DB and create connection
38
- */
39
- GetCompanyConnection(resolve: NextFunction, reject: NextFunction, DBName: string): void;
40
- /**
41
- *
42
- * @param DBName
43
- * @description helper function
44
- */
45
- private FindAndReturnDBConnection;
46
- /**
47
- * @param DBName
48
- * @returns Promise
49
- * @description return connection when dbName is passed, if connection is available it will create the connection
50
- */
51
- ConnectToCompanyDB(DBName: string, DBAddress?: string): Promise<Db>;
52
- /**
53
- *
54
- * @param req
55
- * @param res
56
- * @param next
57
- * @description middleware function : to validate the cookies that are passed in request
58
- */
59
- ValidateSession: (req: OPT_Request, res: Response, next: NextFunction) => void;
60
- /**
61
- *
62
- * @param req
63
- * @param res
64
- * @description helper function: To send error if validation failed
65
- */
66
- SendErrorResponse(req: OPT_Request, res: Response): Promise<void>;
67
- /**
68
- *
69
- * @param DBName optional parameter : if not present then connection will be stablished from the db in request
70
- * @description Sync method to get the connection from the already created connections
71
- * @returns connection || undefined
72
- */
73
- GetConnection(req: OPT_Request, DBName?: string, DBAddress?: string): Db | Error;
74
- /**
75
- * @description Get the name of companies which connection are available
76
- */
77
- GetActiveDBConnections(): string[];
78
- /**
79
- * @param Error
80
- * @param req
81
- * @param res
82
- * @param next
83
- * @description middleware: To handle Unexpected Error
84
- */
85
- ErrorHandler: (Error: OPT_ERROR, req: OPT_Request, res: Response, next: NextFunction) => Promise<any>;
86
- /**
87
- * @param LogsDasbaseType
88
- * @param LogsDatabaseHost
89
- * @param LogsDabaseName
90
- * @param LogsDatabaseUserName
91
- * @param LogsDatabasePassword
92
- * @param LogsDatabasePort
93
- * @description Helper function to send response
94
- */
95
- ConnectToLogsDB: (LogsDasbaseType: DatabaseTypes, LogsDatabaseHost: string, LogsDabaseName: string, LogsDatabaseUserName: string, LogsDatabasePassword: string, LogsDatabasePort: number) => Promise<Sequelize>;
96
- /**
97
- * @param req
98
- * @param res
99
- * @param params
100
- * @description Helper function to send response
101
- */
102
- ReturnJsonResponse: (req: OPT_Request, res: Response, params: ResponseStructure) => void;
103
- /**
104
- * @param DBName
105
- * @returns Promise
106
- * @description return session from client
107
- */
108
- GetDBSession(dbName: string, dbAddress: string): Promise<[Error?, ClientSession?]>;
109
- /**
110
- * @param DBName
111
- * @returns Promise
112
- * @description return session from client
113
- */
114
- GetDBClient(dbName: string, dbAddress: string): Promise<[Error?, MongoClient?]>;
115
- }
116
- export { Connection };
1
+ import { Db, MongoClient, ClientSession } from "mongodb";
2
+ import { NextFunction, Response } from "express";
3
+ import IORedis from "ioredis";
4
+ import { Sequelize } from "sequelize";
5
+ import { masterConnectionConfig, tokenConfig, OPT_Request, ResponseStructure, OPT_ERROR } from "../modals/connection.modal";
6
+ import { DatabaseTypes } from '../enums/databasetype.enum';
7
+ declare class Connection {
8
+ private masterConfig;
9
+ private redisClient?;
10
+ private connections;
11
+ /**
12
+ * @param masterConfig Master Connectivity Object
13
+ * @param redisClient Redisclient
14
+ * @description connect to master database and maintain master config and redis client for furture ref
15
+ */
16
+ constructor(masterConfig: masterConnectionConfig, redisClient?: IORedis.Redis | undefined);
17
+ /**
18
+ * @param tokenData contains connection details of database
19
+ * @param next
20
+ * @return Promise
21
+ * @description make connection to database when url and dbname is passed
22
+ */
23
+ ConnectToDb(tokenData: tokenConfig, next?: NextFunction): Promise<void>;
24
+ /**
25
+ *
26
+ * @param req
27
+ * @param res
28
+ * @param next
29
+ * @description middleware function : create database connection if not present
30
+ */
31
+ DbConnection: (req: OPT_Request, res: Response, next: NextFunction) => null | void;
32
+ /**
33
+ *
34
+ * @param resolve
35
+ * @param reject
36
+ * @param DBName
37
+ * @description helper middleware function: find connection details from Master DB and create connection
38
+ */
39
+ GetCompanyConnection(resolve: NextFunction, reject: NextFunction, DBName: string): void;
40
+ /**
41
+ *
42
+ * @param DBName
43
+ * @description helper function
44
+ */
45
+ private FindAndReturnDBConnection;
46
+ /**
47
+ * @param DBName
48
+ * @returns Promise
49
+ * @description return connection when dbName is passed, if connection is available it will create the connection
50
+ */
51
+ ConnectToCompanyDB(DBName: string, DBAddress?: string): Promise<Db>;
52
+ /**
53
+ *
54
+ * @param req
55
+ * @param res
56
+ * @param next
57
+ * @description middleware function : to validate the cookies that are passed in request
58
+ */
59
+ ValidateSession: (req: OPT_Request, res: Response, next: NextFunction) => void;
60
+ /**
61
+ *
62
+ * @param req
63
+ * @param res
64
+ * @description helper function: To send error if validation failed
65
+ */
66
+ SendErrorResponse(req: OPT_Request, res: Response): Promise<void>;
67
+ /**
68
+ *
69
+ * @param DBName optional parameter : if not present then connection will be stablished from the db in request
70
+ * @description Sync method to get the connection from the already created connections
71
+ * @returns connection || undefined
72
+ */
73
+ GetConnection(req: OPT_Request, DBName?: string, DBAddress?: string): Db | Error;
74
+ /**
75
+ * @description Get the name of companies which connection are available
76
+ */
77
+ GetActiveDBConnections(): string[];
78
+ /**
79
+ * @param Error
80
+ * @param req
81
+ * @param res
82
+ * @param next
83
+ * @description middleware: To handle Unexpected Error
84
+ */
85
+ ErrorHandler: (Error: OPT_ERROR, req: OPT_Request, res: Response, next: NextFunction) => Promise<any>;
86
+ /**
87
+ * @param LogsDasbaseType
88
+ * @param LogsDatabaseHost
89
+ * @param LogsDabaseName
90
+ * @param LogsDatabaseUserName
91
+ * @param LogsDatabasePassword
92
+ * @param LogsDatabasePort
93
+ * @description Helper function to send response
94
+ */
95
+ ConnectToLogsDB: (LogsDasbaseType: DatabaseTypes, LogsDatabaseHost: string, LogsDabaseName: string, LogsDatabaseUserName: string, LogsDatabasePassword: string, LogsDatabasePort: number) => Promise<Sequelize>;
96
+ /**
97
+ * @param req
98
+ * @param res
99
+ * @param params
100
+ * @description Helper function to send response
101
+ */
102
+ ReturnJsonResponse: (req: OPT_Request, res: Response, params: ResponseStructure) => void;
103
+ /**
104
+ * @param DBName
105
+ * @returns Promise
106
+ * @description return session from client
107
+ */
108
+ GetDBSession(dbName: string, dbAddress: string): Promise<[Error?, ClientSession?]>;
109
+ /**
110
+ * @param DBName
111
+ * @returns Promise
112
+ * @description return session from client
113
+ */
114
+ GetDBClient(dbName: string, dbAddress: string): Promise<[Error?, MongoClient?]>;
115
+ }
116
+ export { Connection };