@campxdev/server-shared 1.1.22-alpha.4 → 1.1.23

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 (84) hide show
  1. package/dist/common/config/mongo.config.d.ts +3 -3
  2. package/dist/common/config/mongo.config.js +23 -23
  3. package/dist/common/databases/mongoose.repository.d.ts +40 -40
  4. package/dist/common/databases/mongoose.repository.js +94 -94
  5. package/dist/common/decorators/request.decorators.d.ts +5 -5
  6. package/dist/common/decorators/request.decorators.js +36 -36
  7. package/dist/common/decorators/time-validation.decorator.d.ts +2 -2
  8. package/dist/common/decorators/time-validation.decorator.js +26 -26
  9. package/dist/common/filters/unhandled-exception.filter.d.ts +4 -4
  10. package/dist/common/filters/unhandled-exception.filter.js +38 -38
  11. package/dist/common/guards/guard.d.ts +8 -8
  12. package/dist/common/guards/guard.js +24 -24
  13. package/dist/common/index.d.ts +11 -11
  14. package/dist/common/index.js +27 -27
  15. package/dist/common/interceptors/request.interceptor.d.ts +17 -17
  16. package/dist/common/interceptors/request.interceptor.js +132 -132
  17. package/dist/common/interfaces/context.interface.d.ts +102 -102
  18. package/dist/common/interfaces/context.interface.js +2 -2
  19. package/dist/common/store/request-store.d.ts +32 -32
  20. package/dist/common/store/request-store.js +125 -125
  21. package/dist/common/store/store-config.d.ts +6 -6
  22. package/dist/common/store/store-config.js +23 -23
  23. package/dist/common/store/store.interceptor.d.ts +5 -5
  24. package/dist/common/store/store.interceptor.js +37 -37
  25. package/dist/domain/db-connection.module.d.ts +3 -3
  26. package/dist/domain/db-connection.module.js +29 -29
  27. package/dist/domain/entities/department.entity.d.ts +9 -9
  28. package/dist/domain/entities/department.entity.js +50 -50
  29. package/dist/domain/entities/evaluator.entity.d.ts +17 -17
  30. package/dist/domain/entities/evaluator.entity.js +112 -112
  31. package/dist/domain/entities/leads.entity.d.ts +26 -26
  32. package/dist/domain/entities/leads.entity.js +161 -161
  33. package/dist/domain/entities/profile-permission.entity.d.ts +13 -13
  34. package/dist/domain/entities/profile-permission.entity.js +70 -70
  35. package/dist/domain/entities/profile.entity.d.ts +25 -25
  36. package/dist/domain/entities/profile.entity.js +98 -98
  37. package/dist/domain/entities/program.entity.d.ts +13 -13
  38. package/dist/domain/entities/program.entity.js +70 -70
  39. package/dist/domain/entities/student.entity.d.ts +57 -57
  40. package/dist/domain/entities/student.entity.js +279 -279
  41. package/dist/domain/entities/user.entity.d.ts +23 -23
  42. package/dist/domain/entities/user.entity.js +147 -147
  43. package/dist/domain/index.d.ts +12 -12
  44. package/dist/domain/index.js +28 -28
  45. package/dist/domain/schemas/global-users.schema.d.ts +58 -58
  46. package/dist/domain/schemas/global-users.schema.js +145 -145
  47. package/dist/domain/schemas/tenant.schema.d.ts +114 -114
  48. package/dist/domain/schemas/tenant.schema.js +387 -387
  49. package/dist/domain/shared-domain.module.d.ts +2 -2
  50. package/dist/domain/shared-domain.module.js +27 -27
  51. package/dist/index.d.ts +5 -5
  52. package/dist/index.js +21 -21
  53. package/dist/permissions/app-permissions/enroll-x-permissions.d.ts +390 -390
  54. package/dist/permissions/app-permissions/enroll-x-permissions.js +458 -458
  55. package/dist/permissions/app-permissions/enroll-x-permissions.js.map +1 -1
  56. package/dist/permissions/app-permissions/exams-permissions.d.ts +745 -745
  57. package/dist/permissions/app-permissions/exams-permissions.js +1213 -1213
  58. package/dist/permissions/app-permissions/hostels-permissions.d.ts +241 -241
  59. package/dist/permissions/app-permissions/hostels-permissions.js +251 -251
  60. package/dist/permissions/app-permissions/payments-permissions.d.ts +352 -352
  61. package/dist/permissions/app-permissions/payments-permissions.js +474 -474
  62. package/dist/permissions/app-permissions/square-permissions.d.ts +1123 -1123
  63. package/dist/permissions/app-permissions/square-permissions.js +2085 -2085
  64. package/dist/permissions/check-permission.guard.d.ts +52 -52
  65. package/dist/permissions/check-permission.guard.js +58 -58
  66. package/dist/permissions/index.d.ts +7 -7
  67. package/dist/permissions/index.js +28 -28
  68. package/dist/permissions/permissions.d.ts +5708 -5708
  69. package/dist/permissions/permissions.js +116 -116
  70. package/dist/shared-module/index.d.ts +2 -2
  71. package/dist/shared-module/index.js +7 -7
  72. package/dist/shared-module/shared.module.d.ts +10 -10
  73. package/dist/shared-module/shared.module.js +37 -37
  74. package/dist/shared-module/shared.service.d.ts +67 -67
  75. package/dist/shared-module/shared.service.d.ts.map +1 -1
  76. package/dist/shared-module/shared.service.js +209 -210
  77. package/dist/shared-module/shared.service.js.map +1 -1
  78. package/dist/utils/constants.d.ts +25 -25
  79. package/dist/utils/constants.js +28 -28
  80. package/dist/utils/index.d.ts +2 -2
  81. package/dist/utils/index.js +18 -18
  82. package/dist/utils/utils.d.ts +24 -24
  83. package/dist/utils/utils.js +234 -234
  84. package/package.json +46 -46
@@ -1,25 +1,25 @@
1
- /// <reference types="multer" />
2
- import Joi from 'joi';
3
- import * as mongoose from 'mongoose';
4
- export declare function getReceiptNo(letter: string): string;
5
- export declare function xlsxToJson<T>(file: Express.Multer.File, schema?: Joi.ArraySchema<any[]>): Promise<T[]>;
6
- export declare function joiDefault(val: any): Joi.StringSchema<string>;
7
- export declare function validateBatches(batches: string[]): string[];
8
- export declare function getBool(str: string, defaultValue: boolean): boolean;
9
- export declare function getGenderWithDefault(str: string, defaultValue: string): "other" | "male" | "female";
10
- export declare function getGender(str: string): "other" | "male" | "female";
11
- export declare function getValue(val: any, defaultValue: any): any;
12
- export declare function getDate(date: any, defaultValue: any): any;
13
- export declare function romanize(num: any): string | false;
14
- export declare function ordinalSuffixOf(i: number): string;
15
- export declare function getYearFromSem(sem: number): number;
16
- export declare function convertKeysToCamelCase(obj: any): any;
17
- export declare const removeSpecialChars: (str: string) => string;
18
- export declare function getObjectId(id: any): mongoose.Types.ObjectId;
19
- export declare function getTitle(val: string): string;
20
- export declare function generateObjectId(): mongoose.Types.ObjectId;
21
- export declare function getTime(date: any): number;
22
- export declare function getMonth(date: any): number;
23
- export declare function timeLessThan(time1: string, time2: string): boolean;
24
- export declare function checkEqual(id1: any, id2: any): boolean;
1
+ /// <reference types="multer" />
2
+ import Joi from 'joi';
3
+ import * as mongoose from 'mongoose';
4
+ export declare function getReceiptNo(letter: string): string;
5
+ export declare function xlsxToJson<T>(file: Express.Multer.File, schema?: Joi.ArraySchema<any[]>): Promise<T[]>;
6
+ export declare function joiDefault(val: any): Joi.StringSchema<string>;
7
+ export declare function validateBatches(batches: string[]): string[];
8
+ export declare function getBool(str: string, defaultValue: boolean): boolean;
9
+ export declare function getGenderWithDefault(str: string, defaultValue: string): "other" | "male" | "female";
10
+ export declare function getGender(str: string): "other" | "male" | "female";
11
+ export declare function getValue(val: any, defaultValue: any): any;
12
+ export declare function getDate(date: any, defaultValue: any): any;
13
+ export declare function romanize(num: any): string | false;
14
+ export declare function ordinalSuffixOf(i: number): string;
15
+ export declare function getYearFromSem(sem: number): number;
16
+ export declare function convertKeysToCamelCase(obj: any): any;
17
+ export declare const removeSpecialChars: (str: string) => string;
18
+ export declare function getObjectId(id: any): mongoose.Types.ObjectId;
19
+ export declare function getTitle(val: string): string;
20
+ export declare function generateObjectId(): mongoose.Types.ObjectId;
21
+ export declare function getTime(date: any): number;
22
+ export declare function getMonth(date: any): number;
23
+ export declare function timeLessThan(time1: string, time2: string): boolean;
24
+ export declare function checkEqual(id1: any, id2: any): boolean;
25
25
  //# sourceMappingURL=utils.d.ts.map
@@ -1,235 +1,235 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.checkEqual = exports.timeLessThan = exports.getMonth = exports.getTime = exports.generateObjectId = exports.getTitle = exports.getObjectId = exports.removeSpecialChars = exports.convertKeysToCamelCase = exports.getYearFromSem = exports.ordinalSuffixOf = exports.romanize = exports.getDate = exports.getValue = exports.getGender = exports.getGenderWithDefault = exports.getBool = exports.validateBatches = exports.joiDefault = exports.xlsxToJson = exports.getReceiptNo = void 0;
30
- const common_1 = require("@nestjs/common");
31
- const joi_1 = __importDefault(require("joi"));
32
- const lodash_1 = require("lodash");
33
- const moment_1 = __importDefault(require("moment"));
34
- const mongoose = __importStar(require("mongoose"));
35
- const XLSX = __importStar(require("xlsx"));
36
- function getReceiptNo(letter) {
37
- const year = `${new Date().getFullYear()}`.slice(2);
38
- const receiptNo = year + letter;
39
- return receiptNo;
40
- }
41
- exports.getReceiptNo = getReceiptNo;
42
- async function xlsxToJson(file, schema) {
43
- if (!file)
44
- throw new common_1.UnprocessableEntityException('File not found');
45
- const workbook = XLSX.read(Buffer.from(file.buffer));
46
- const sheet_name_list = workbook.SheetNames;
47
- let xlData = XLSX.utils.sheet_to_json(workbook.Sheets[sheet_name_list[0]]);
48
- if (schema) {
49
- try {
50
- xlData = await schema.validateAsync(xlData);
51
- }
52
- catch (err) {
53
- console.log(err);
54
- throw new common_1.UnprocessableEntityException(err.message);
55
- }
56
- }
57
- return xlData;
58
- }
59
- exports.xlsxToJson = xlsxToJson;
60
- function joiDefault(val) {
61
- return joi_1.default.string()
62
- .custom(() => val)
63
- .default(val);
64
- }
65
- exports.joiDefault = joiDefault;
66
- function validateBatches(batches) {
67
- const invalidBatches = batches.filter((e) => {
68
- const batch = e.split(' - ');
69
- return batch.length !== 2 || isNaN(+batch[0]) || isNaN(+batch[1]);
70
- });
71
- if (invalidBatches.length) {
72
- throw new common_1.BadRequestException(`Invalid batches: ${(0, lodash_1.uniq)(invalidBatches).join(', ')}`);
73
- }
74
- return (0, lodash_1.uniq)(batches);
75
- }
76
- exports.validateBatches = validateBatches;
77
- function getBool(str, defaultValue) {
78
- if (!str)
79
- return defaultValue;
80
- return str.toLowerCase() == 'yes' ? true : false;
81
- }
82
- exports.getBool = getBool;
83
- function getGenderWithDefault(str, defaultValue) {
84
- const value = !str ? defaultValue : str;
85
- return getGender(value);
86
- }
87
- exports.getGenderWithDefault = getGenderWithDefault;
88
- function getGender(str) {
89
- switch (str.toUpperCase()) {
90
- case 'M':
91
- case 'MALE':
92
- return 'male';
93
- case 'F':
94
- case 'FEMALE':
95
- return 'female';
96
- default:
97
- return 'other';
98
- }
99
- }
100
- exports.getGender = getGender;
101
- function getValue(val, defaultValue) {
102
- if (!val)
103
- return defaultValue;
104
- return `${val}`.trim();
105
- }
106
- exports.getValue = getValue;
107
- function getDate(date, defaultValue) {
108
- if (!date)
109
- return defaultValue;
110
- return (0, moment_1.default)(new Date(date)).format('YYYY-MM-DD');
111
- }
112
- exports.getDate = getDate;
113
- function romanize(num) {
114
- if (!+num)
115
- return false;
116
- const digits = String(+num).split('');
117
- const key = [
118
- '',
119
- 'C',
120
- 'CC',
121
- 'CCC',
122
- 'CD',
123
- 'D',
124
- 'DC',
125
- 'DCC',
126
- 'DCCC',
127
- 'CM',
128
- '',
129
- 'X',
130
- 'XX',
131
- 'XXX',
132
- 'XL',
133
- 'L',
134
- 'LX',
135
- 'LXX',
136
- 'LXXX',
137
- 'XC',
138
- '',
139
- 'I',
140
- 'II',
141
- 'III',
142
- 'IV',
143
- 'V',
144
- 'VI',
145
- 'VII',
146
- 'VIII',
147
- 'IX',
148
- ];
149
- let roman = '', i = 3;
150
- while (i--)
151
- roman = (key[+digits.pop() + i * 10] || '') + roman;
152
- return Array(+digits.join('') + 1).join('M') + roman;
153
- }
154
- exports.romanize = romanize;
155
- function ordinalSuffixOf(i) {
156
- const j = i % 10, k = i % 100;
157
- if (j == 1 && k != 11) {
158
- return i + 'st';
159
- }
160
- if (j == 2 && k != 12) {
161
- return i + 'nd';
162
- }
163
- if (j == 3 && k != 13) {
164
- return i + 'rd';
165
- }
166
- return i + 'th';
167
- }
168
- exports.ordinalSuffixOf = ordinalSuffixOf;
169
- function getYearFromSem(sem) {
170
- return Math.ceil(sem / 2);
171
- }
172
- exports.getYearFromSem = getYearFromSem;
173
- function convertKeysToCamelCase(obj) {
174
- const newObj = {};
175
- for (const key in obj) {
176
- newObj[(0, lodash_1.camelCase)(key)] = obj[key];
177
- }
178
- return newObj;
179
- }
180
- exports.convertKeysToCamelCase = convertKeysToCamelCase;
181
- const removeSpecialChars = (str) => str?.replace(/[^\w\s]/gi, '');
182
- exports.removeSpecialChars = removeSpecialChars;
183
- function getObjectId(id) {
184
- if (id instanceof mongoose.Types.ObjectId) {
185
- return id;
186
- }
187
- try {
188
- return new mongoose.Types.ObjectId(id);
189
- }
190
- catch (e) {
191
- throw new common_1.UnprocessableEntityException('Invalid ID');
192
- }
193
- }
194
- exports.getObjectId = getObjectId;
195
- function getTitle(val) {
196
- return val
197
- .toLowerCase()
198
- .split('_')
199
- .map((word) => word.charAt(0).toUpperCase() + word.slice(1))
200
- .join(' ');
201
- }
202
- exports.getTitle = getTitle;
203
- function generateObjectId() {
204
- return new mongoose.Types.ObjectId();
205
- }
206
- exports.generateObjectId = generateObjectId;
207
- function getTime(date) {
208
- return new Date(date).getTime();
209
- }
210
- exports.getTime = getTime;
211
- function getMonth(date) {
212
- return new Date(date).getMonth();
213
- }
214
- exports.getMonth = getMonth;
215
- function timeLessThan(time1, time2) {
216
- const [h1, m1, s1] = time1.split(':').map((e) => +e);
217
- const [h2, m2, s2] = time2.split(':').map((e) => +e);
218
- if (h1 !== h2)
219
- return h1 < h2;
220
- if (m1 !== m2)
221
- return m1 < m2;
222
- return s1 < s2;
223
- }
224
- exports.timeLessThan = timeLessThan;
225
- function checkEqual(id1, id2) {
226
- if (id1 instanceof mongoose.Types.ObjectId) {
227
- return id1.equals(id2);
228
- }
229
- if (id2 instanceof mongoose.Types.ObjectId) {
230
- return id2.equals(id1);
231
- }
232
- return id1 === id2;
233
- }
234
- exports.checkEqual = checkEqual;
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.checkEqual = exports.timeLessThan = exports.getMonth = exports.getTime = exports.generateObjectId = exports.getTitle = exports.getObjectId = exports.removeSpecialChars = exports.convertKeysToCamelCase = exports.getYearFromSem = exports.ordinalSuffixOf = exports.romanize = exports.getDate = exports.getValue = exports.getGender = exports.getGenderWithDefault = exports.getBool = exports.validateBatches = exports.joiDefault = exports.xlsxToJson = exports.getReceiptNo = void 0;
30
+ const common_1 = require("@nestjs/common");
31
+ const joi_1 = __importDefault(require("joi"));
32
+ const lodash_1 = require("lodash");
33
+ const moment_1 = __importDefault(require("moment"));
34
+ const mongoose = __importStar(require("mongoose"));
35
+ const XLSX = __importStar(require("xlsx"));
36
+ function getReceiptNo(letter) {
37
+ const year = `${new Date().getFullYear()}`.slice(2);
38
+ const receiptNo = year + letter;
39
+ return receiptNo;
40
+ }
41
+ exports.getReceiptNo = getReceiptNo;
42
+ async function xlsxToJson(file, schema) {
43
+ if (!file)
44
+ throw new common_1.UnprocessableEntityException('File not found');
45
+ const workbook = XLSX.read(Buffer.from(file.buffer));
46
+ const sheet_name_list = workbook.SheetNames;
47
+ let xlData = XLSX.utils.sheet_to_json(workbook.Sheets[sheet_name_list[0]]);
48
+ if (schema) {
49
+ try {
50
+ xlData = await schema.validateAsync(xlData);
51
+ }
52
+ catch (err) {
53
+ console.log(err);
54
+ throw new common_1.UnprocessableEntityException(err.message);
55
+ }
56
+ }
57
+ return xlData;
58
+ }
59
+ exports.xlsxToJson = xlsxToJson;
60
+ function joiDefault(val) {
61
+ return joi_1.default.string()
62
+ .custom(() => val)
63
+ .default(val);
64
+ }
65
+ exports.joiDefault = joiDefault;
66
+ function validateBatches(batches) {
67
+ const invalidBatches = batches.filter((e) => {
68
+ const batch = e.split(' - ');
69
+ return batch.length !== 2 || isNaN(+batch[0]) || isNaN(+batch[1]);
70
+ });
71
+ if (invalidBatches.length) {
72
+ throw new common_1.BadRequestException(`Invalid batches: ${(0, lodash_1.uniq)(invalidBatches).join(', ')}`);
73
+ }
74
+ return (0, lodash_1.uniq)(batches);
75
+ }
76
+ exports.validateBatches = validateBatches;
77
+ function getBool(str, defaultValue) {
78
+ if (!str)
79
+ return defaultValue;
80
+ return str.toLowerCase() == 'yes' ? true : false;
81
+ }
82
+ exports.getBool = getBool;
83
+ function getGenderWithDefault(str, defaultValue) {
84
+ const value = !str ? defaultValue : str;
85
+ return getGender(value);
86
+ }
87
+ exports.getGenderWithDefault = getGenderWithDefault;
88
+ function getGender(str) {
89
+ switch (str.toUpperCase()) {
90
+ case 'M':
91
+ case 'MALE':
92
+ return 'male';
93
+ case 'F':
94
+ case 'FEMALE':
95
+ return 'female';
96
+ default:
97
+ return 'other';
98
+ }
99
+ }
100
+ exports.getGender = getGender;
101
+ function getValue(val, defaultValue) {
102
+ if (!val)
103
+ return defaultValue;
104
+ return `${val}`.trim();
105
+ }
106
+ exports.getValue = getValue;
107
+ function getDate(date, defaultValue) {
108
+ if (!date)
109
+ return defaultValue;
110
+ return (0, moment_1.default)(new Date(date)).format('YYYY-MM-DD');
111
+ }
112
+ exports.getDate = getDate;
113
+ function romanize(num) {
114
+ if (!+num)
115
+ return false;
116
+ const digits = String(+num).split('');
117
+ const key = [
118
+ '',
119
+ 'C',
120
+ 'CC',
121
+ 'CCC',
122
+ 'CD',
123
+ 'D',
124
+ 'DC',
125
+ 'DCC',
126
+ 'DCCC',
127
+ 'CM',
128
+ '',
129
+ 'X',
130
+ 'XX',
131
+ 'XXX',
132
+ 'XL',
133
+ 'L',
134
+ 'LX',
135
+ 'LXX',
136
+ 'LXXX',
137
+ 'XC',
138
+ '',
139
+ 'I',
140
+ 'II',
141
+ 'III',
142
+ 'IV',
143
+ 'V',
144
+ 'VI',
145
+ 'VII',
146
+ 'VIII',
147
+ 'IX',
148
+ ];
149
+ let roman = '', i = 3;
150
+ while (i--)
151
+ roman = (key[+digits.pop() + i * 10] || '') + roman;
152
+ return Array(+digits.join('') + 1).join('M') + roman;
153
+ }
154
+ exports.romanize = romanize;
155
+ function ordinalSuffixOf(i) {
156
+ const j = i % 10, k = i % 100;
157
+ if (j == 1 && k != 11) {
158
+ return i + 'st';
159
+ }
160
+ if (j == 2 && k != 12) {
161
+ return i + 'nd';
162
+ }
163
+ if (j == 3 && k != 13) {
164
+ return i + 'rd';
165
+ }
166
+ return i + 'th';
167
+ }
168
+ exports.ordinalSuffixOf = ordinalSuffixOf;
169
+ function getYearFromSem(sem) {
170
+ return Math.ceil(sem / 2);
171
+ }
172
+ exports.getYearFromSem = getYearFromSem;
173
+ function convertKeysToCamelCase(obj) {
174
+ const newObj = {};
175
+ for (const key in obj) {
176
+ newObj[(0, lodash_1.camelCase)(key)] = obj[key];
177
+ }
178
+ return newObj;
179
+ }
180
+ exports.convertKeysToCamelCase = convertKeysToCamelCase;
181
+ const removeSpecialChars = (str) => str?.replace(/[^\w\s]/gi, '');
182
+ exports.removeSpecialChars = removeSpecialChars;
183
+ function getObjectId(id) {
184
+ if (id instanceof mongoose.Types.ObjectId) {
185
+ return id;
186
+ }
187
+ try {
188
+ return new mongoose.Types.ObjectId(id);
189
+ }
190
+ catch (e) {
191
+ throw new common_1.UnprocessableEntityException('Invalid ID');
192
+ }
193
+ }
194
+ exports.getObjectId = getObjectId;
195
+ function getTitle(val) {
196
+ return val
197
+ .toLowerCase()
198
+ .split('_')
199
+ .map((word) => word.charAt(0).toUpperCase() + word.slice(1))
200
+ .join(' ');
201
+ }
202
+ exports.getTitle = getTitle;
203
+ function generateObjectId() {
204
+ return new mongoose.Types.ObjectId();
205
+ }
206
+ exports.generateObjectId = generateObjectId;
207
+ function getTime(date) {
208
+ return new Date(date).getTime();
209
+ }
210
+ exports.getTime = getTime;
211
+ function getMonth(date) {
212
+ return new Date(date).getMonth();
213
+ }
214
+ exports.getMonth = getMonth;
215
+ function timeLessThan(time1, time2) {
216
+ const [h1, m1, s1] = time1.split(':').map((e) => +e);
217
+ const [h2, m2, s2] = time2.split(':').map((e) => +e);
218
+ if (h1 !== h2)
219
+ return h1 < h2;
220
+ if (m1 !== m2)
221
+ return m1 < m2;
222
+ return s1 < s2;
223
+ }
224
+ exports.timeLessThan = timeLessThan;
225
+ function checkEqual(id1, id2) {
226
+ if (id1 instanceof mongoose.Types.ObjectId) {
227
+ return id1.equals(id2);
228
+ }
229
+ if (id2 instanceof mongoose.Types.ObjectId) {
230
+ return id2.equals(id1);
231
+ }
232
+ return id1 === id2;
233
+ }
234
+ exports.checkEqual = checkEqual;
235
235
  //# sourceMappingURL=utils.js.map
package/package.json CHANGED
@@ -1,46 +1,46 @@
1
- {
2
- "name": "@campxdev/server-shared",
3
- "version": "1.1.22-alpha.4",
4
- "description": "Campx server shared files",
5
- "main": "dist/index.js",
6
- "license": "MIT",
7
- "files": [
8
- "dist"
9
- ],
10
- "scripts": {
11
- "build": "tsc",
12
- "prepublish": "npm run build",
13
- "premig": "mkdir -p src/migrations",
14
- "mig": "cd src/migrations && npx typeorm migration:create"
15
- },
16
- "dependencies": {
17
- "@nestjs/common": "^9.3.9",
18
- "@nestjs/core": "^9.3.9",
19
- "@nestjs/microservices": "^9.3.9",
20
- "@nestjs/mongoose": "^9.2.1",
21
- "bcrypt": "^5.1.0",
22
- "class-transformer": "^0.5.1",
23
- "class-validator": "^0.14.0",
24
- "joi": "^17.8.3",
25
- "jsonwebtoken": "^9.0.0",
26
- "lodash": "^4.17.21",
27
- "moment": "^2.29.4",
28
- "mongoose": "^7.0.1",
29
- "mysql2": "^3.2.0",
30
- "reflect-metadata": "^0.1.13",
31
- "rxjs": "^7.8.0",
32
- "typeorm": "^0.3.12",
33
- "typeorm-naming-strategies": "^4.1.0",
34
- "xlsx": "^0.18.5"
35
- },
36
- "devDependencies": {
37
- "@types/bcrypt": "^5.0.0",
38
- "@types/express": "^4.17.17",
39
- "@types/lodash": "^4.14.191",
40
- "@types/mongoose": "^5.11.97",
41
- "@types/multer": "^1.4.7",
42
- "@types/node": "^18.14.6",
43
- "rimraf": "^4.4.0",
44
- "typescript": "^4.9.5"
45
- }
46
- }
1
+ {
2
+ "name": "@campxdev/server-shared",
3
+ "version": "1.1.23",
4
+ "description": "Campx server shared files",
5
+ "main": "dist/index.js",
6
+ "license": "MIT",
7
+ "files": [
8
+ "dist"
9
+ ],
10
+ "scripts": {
11
+ "build": "rm -rf dist && tsc",
12
+ "prepublish": "npm run build",
13
+ "premig": "mkdir -p src/migrations",
14
+ "mig": "cd src/migrations && npx typeorm migration:create"
15
+ },
16
+ "dependencies": {
17
+ "@nestjs/common": "^9.3.9",
18
+ "@nestjs/core": "^9.3.9",
19
+ "@nestjs/microservices": "^9.3.9",
20
+ "@nestjs/mongoose": "^9.2.1",
21
+ "bcrypt": "^5.1.0",
22
+ "class-transformer": "^0.5.1",
23
+ "class-validator": "^0.14.0",
24
+ "joi": "^17.8.3",
25
+ "jsonwebtoken": "^9.0.0",
26
+ "lodash": "^4.17.21",
27
+ "moment": "^2.29.4",
28
+ "mongoose": "^7.0.1",
29
+ "mysql2": "^3.2.0",
30
+ "reflect-metadata": "^0.1.13",
31
+ "rxjs": "^7.8.0",
32
+ "typeorm": "^0.3.12",
33
+ "typeorm-naming-strategies": "^4.1.0",
34
+ "xlsx": "^0.18.5"
35
+ },
36
+ "devDependencies": {
37
+ "@types/bcrypt": "^5.0.0",
38
+ "@types/express": "^4.17.17",
39
+ "@types/lodash": "^4.14.191",
40
+ "@types/mongoose": "^5.11.97",
41
+ "@types/multer": "^1.4.7",
42
+ "@types/node": "^18.14.6",
43
+ "rimraf": "^4.4.0",
44
+ "typescript": "^4.9.5"
45
+ }
46
+ }