@kipicore/dbcore 1.1.669 → 1.1.670

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 (163) hide show
  1. package/dist/configs/env.d.ts +0 -2
  2. package/dist/configs/env.js +0 -4
  3. package/dist/configs/index.d.ts +0 -2
  4. package/dist/configs/index.js +0 -2
  5. package/dist/constants/app.d.ts +13 -20
  6. package/dist/constants/app.js +23 -31
  7. package/dist/constants/errorMessages.d.ts +0 -17
  8. package/dist/constants/errorMessages.js +1 -20
  9. package/dist/constants/successMessages.d.ts +0 -14
  10. package/dist/constants/successMessages.js +1 -17
  11. package/dist/db/psql/migrations/20260714095754-create-arena-models.js +642 -0
  12. package/dist/db/psql/migrations/20260720092201-replace-facility-sports-with-sport-group-data.d.ts +2 -0
  13. package/dist/db/psql/migrations/20260720092201-replace-facility-sports-with-sport-group-data.js +138 -0
  14. package/dist/helpers/index.d.ts +0 -3
  15. package/dist/helpers/index.js +0 -3
  16. package/dist/helpers/utils.d.ts +3 -5
  17. package/dist/helpers/utils.js +31 -58
  18. package/dist/index.d.ts +0 -4
  19. package/dist/index.js +0 -4
  20. package/dist/interfaces/ageGroupInterface.d.ts +12 -0
  21. package/dist/interfaces/assessmentTestInterface.d.ts +24 -0
  22. package/dist/interfaces/categoriesInterface.d.ts +1 -2
  23. package/dist/interfaces/equipmentInterface.d.ts +10 -0
  24. package/dist/interfaces/equipmentInterface.js +2 -0
  25. package/dist/interfaces/facilityMasterInterface.d.ts +9 -0
  26. package/dist/interfaces/facilityMasterInterface.js +2 -0
  27. package/dist/interfaces/index.d.ts +12 -1
  28. package/dist/interfaces/index.js +13 -1
  29. package/dist/interfaces/instituteInterface.d.ts +0 -1
  30. package/dist/interfaces/skillInterface.d.ts +15 -0
  31. package/dist/interfaces/skillInterface.js +2 -0
  32. package/dist/interfaces/sportCategoryInterface.d.ts +9 -0
  33. package/dist/interfaces/sportCategoryInterface.js +2 -0
  34. package/dist/interfaces/sportGroupDataInterface.d.ts +7 -0
  35. package/dist/interfaces/sportGroupDataInterface.js +2 -0
  36. package/dist/interfaces/sportInfoInterface.d.ts +23 -0
  37. package/dist/interfaces/sportInfoInterface.js +2 -0
  38. package/dist/interfaces/sportInterface.d.ts +10 -0
  39. package/dist/interfaces/sportInterface.js +2 -0
  40. package/dist/interfaces/sportRoleInterface.d.ts +11 -0
  41. package/dist/interfaces/sportRoleInterface.js +2 -0
  42. package/dist/interfaces/sportSubCategoryInterface.d.ts +10 -0
  43. package/dist/interfaces/sportSubCategoryInterface.js +2 -0
  44. package/dist/interfaces/subCategoriesInterface.d.ts +1 -2
  45. package/dist/interfaces/subscriptionPlanInterface.d.ts +1 -2
  46. package/dist/interfaces/unitInterface.d.ts +10 -0
  47. package/dist/interfaces/unitInterface.js +2 -0
  48. package/dist/interfaces/userInterface.d.ts +1 -2
  49. package/dist/interfaces/vendorCompanyMetaInterface.d.ts +1 -2
  50. package/dist/models/mongodb/assessmentTestModel.d.ts +4 -0
  51. package/dist/models/mongodb/assessmentTestModel.js +72 -0
  52. package/dist/models/mongodb/index.d.ts +2 -0
  53. package/dist/models/mongodb/index.js +6 -1
  54. package/dist/models/mongodb/productMetaModel.js +0 -8
  55. package/dist/models/mongodb/sportInfoModel.d.ts +4 -0
  56. package/dist/models/mongodb/sportInfoModel.js +71 -0
  57. package/dist/models/mongodb/subscriptionPlanModel.js +0 -5
  58. package/dist/models/mongodb/vendorCompanyMetaModel.js +1 -6
  59. package/dist/models/psql/SubCategoriesModel.d.ts +1 -2
  60. package/dist/models/psql/SubCategoriesModel.js +0 -5
  61. package/dist/models/psql/ageGroupModel.d.ts +22 -0
  62. package/dist/models/psql/ageGroupModel.js +76 -0
  63. package/dist/models/psql/categoriesModel.d.ts +1 -2
  64. package/dist/models/psql/categoriesModel.js +0 -5
  65. package/dist/models/psql/equipmentModel.d.ts +20 -0
  66. package/dist/models/psql/equipmentModel.js +57 -0
  67. package/dist/models/psql/facilityMasterModel.d.ts +18 -0
  68. package/dist/models/psql/facilityMasterModel.js +64 -0
  69. package/dist/models/psql/fileStorageModel.js +4 -3
  70. package/dist/models/psql/index.d.ts +10 -1
  71. package/dist/models/psql/index.js +23 -4
  72. package/dist/models/psql/instituteModel.d.ts +0 -1
  73. package/dist/models/psql/instituteModel.js +2 -5
  74. package/dist/models/psql/skillModel.d.ts +25 -0
  75. package/dist/models/psql/skillModel.js +99 -0
  76. package/dist/models/psql/sportCategoryModel.d.ts +19 -0
  77. package/dist/models/psql/sportCategoryModel.js +53 -0
  78. package/dist/models/psql/sportGroupDataModel.d.ts +13 -0
  79. package/dist/models/psql/sportGroupDataModel.js +64 -0
  80. package/dist/models/psql/sportModel.d.ts +20 -0
  81. package/dist/models/psql/sportModel.js +58 -0
  82. package/dist/models/psql/sportRoleModel.d.ts +21 -0
  83. package/dist/models/psql/sportRoleModel.js +71 -0
  84. package/dist/models/psql/sportSubCategoryModel.d.ts +20 -0
  85. package/dist/models/psql/sportSubCategoryModel.js +75 -0
  86. package/dist/models/psql/unitModel.d.ts +20 -0
  87. package/dist/models/psql/unitModel.js +57 -0
  88. package/dist/models/psql/userModel.d.ts +1 -2
  89. package/dist/models/psql/userModel.js +0 -1
  90. package/dist/types/ageGroupType.d.ts +2 -0
  91. package/dist/types/ageGroupType.js +2 -0
  92. package/dist/types/assessmentTestType.d.ts +2 -0
  93. package/dist/types/assessmentTestType.js +2 -0
  94. package/dist/types/commonType.d.ts +1 -29
  95. package/dist/types/equipmentType.d.ts +2 -0
  96. package/dist/types/equipmentType.js +2 -0
  97. package/dist/types/facilityMasterType.d.ts +3 -0
  98. package/dist/types/facilityMasterType.js +2 -0
  99. package/dist/types/index.d.ts +12 -1
  100. package/dist/types/index.js +13 -1
  101. package/dist/types/skillType.d.ts +2 -0
  102. package/dist/types/skillType.js +2 -0
  103. package/dist/types/sportCategoryType.d.ts +2 -0
  104. package/dist/types/sportCategoryType.js +2 -0
  105. package/dist/types/sportGroupDataType.d.ts +3 -0
  106. package/dist/types/sportGroupDataType.js +2 -0
  107. package/dist/types/sportInfoType.d.ts +2 -0
  108. package/dist/types/sportInfoType.js +2 -0
  109. package/dist/types/sportRoleType.d.ts +2 -0
  110. package/dist/types/sportRoleType.js +2 -0
  111. package/dist/types/sportSubCategoryType.d.ts +2 -0
  112. package/dist/types/sportSubCategoryType.js +2 -0
  113. package/dist/types/sportType.d.ts +2 -0
  114. package/dist/types/sportType.js +2 -0
  115. package/dist/types/unitType.d.ts +2 -0
  116. package/dist/types/unitType.js +2 -0
  117. package/package.json +3 -11
  118. package/dist/commonValidator/commandValidator.d.ts +0 -27
  119. package/dist/commonValidator/commandValidator.js +0 -225
  120. package/dist/commonValidator/index.d.ts +0 -3
  121. package/dist/commonValidator/index.js +0 -24
  122. package/dist/commonValidator/joiCommonValidator.d.ts +0 -12
  123. package/dist/commonValidator/joiCommonValidator.js +0 -47
  124. package/dist/commonValidator/joiSchemaBuilder.d.ts +0 -6
  125. package/dist/commonValidator/joiSchemaBuilder.js +0 -70
  126. package/dist/configs/logger.d.ts +0 -2
  127. package/dist/configs/logger.js +0 -44
  128. package/dist/configs/redisConfig.d.ts +0 -4
  129. package/dist/configs/redisConfig.js +0 -32
  130. package/dist/db/psql/migrations/20260714111425-change_status_enum_to_string_in_institutes.js +0 -46
  131. package/dist/db/psql/migrations/20260714131500-add_note_to_institutes.d.ts +0 -2
  132. package/dist/db/psql/migrations/20260714131500-add_note_to_institutes.js +0 -20
  133. package/dist/db/psql/migrations/20260715150000-create-ai-model-keys.d.ts +0 -2
  134. package/dist/db/psql/migrations/20260715150000-create-ai-model-keys.js +0 -156
  135. package/dist/db/psql/migrations/20260717071354-add_type_to_categories.d.ts +0 -2
  136. package/dist/db/psql/migrations/20260717071354-add_type_to_categories.js +0 -19
  137. package/dist/db/psql/migrations/20260717072745-add_type_to_sub_categories.d.ts +0 -2
  138. package/dist/db/psql/migrations/20260717072745-add_type_to_sub_categories.js +0 -19
  139. package/dist/db/psql/migrations/20260717095051-add_status_to_users.d.ts +0 -2
  140. package/dist/db/psql/migrations/20260717095051-add_status_to_users.js +0 -19
  141. package/dist/db/psql/migrations/20260721000001-add-deleted-at-to-rms-maintenance-activities.d.ts +0 -2
  142. package/dist/db/psql/migrations/20260721000001-add-deleted-at-to-rms-maintenance-activities.js +0 -12
  143. package/dist/db/psql/migrations/20260721000002-change-uploaded-from-enum-to-string-in-file-storage.d.ts +0 -2
  144. package/dist/db/psql/migrations/20260721000002-change-uploaded-from-enum-to-string-in-file-storage.js +0 -42
  145. package/dist/helpers/sendEmail.d.ts +0 -3
  146. package/dist/helpers/sendEmail.js +0 -117
  147. package/dist/helpers/sendNotification.d.ts +0 -4
  148. package/dist/helpers/sendNotification.js +0 -34
  149. package/dist/helpers/sendSMS.d.ts +0 -5
  150. package/dist/helpers/sendSMS.js +0 -34
  151. package/dist/interfaces/aiModelKeysInterface.d.ts +0 -15
  152. package/dist/models/psql/aiModelKeysModel.d.ts +0 -20
  153. package/dist/models/psql/aiModelKeysModel.js +0 -70
  154. package/dist/queues/emailQueue.d.ts +0 -3
  155. package/dist/queues/emailQueue.js +0 -22
  156. package/dist/queues/emailWorker.d.ts +0 -3
  157. package/dist/queues/emailWorker.js +0 -33
  158. package/dist/queues/index.d.ts +0 -2
  159. package/dist/queues/index.js +0 -18
  160. package/dist/types/aiModelKeysType.d.ts +0 -3
  161. /package/dist/db/psql/migrations/{20260714111425-change_status_enum_to_string_in_institutes.d.ts → 20260714095754-create-arena-models.d.ts} +0 -0
  162. /package/dist/interfaces/{aiModelKeysInterface.js → ageGroupInterface.js} +0 -0
  163. /package/dist/{types/aiModelKeysType.js → interfaces/assessmentTestInterface.js} +0 -0
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UnitModel = void 0;
4
+ const sequelize_1 = require("sequelize");
5
+ const index_1 = require("./index");
6
+ class UnitModel extends sequelize_1.Model {
7
+ static associate(models) {
8
+ const { UserModel } = models;
9
+ UnitModel.belongsTo(UserModel, {
10
+ foreignKey: { name: 'createdBy', allowNull: true, field: 'created_by' },
11
+ as: 'createdByUser',
12
+ });
13
+ UnitModel.belongsTo(UserModel, {
14
+ foreignKey: { name: 'updatedBy', allowNull: true, field: 'updated_by' },
15
+ as: 'updatedByUser',
16
+ });
17
+ UnitModel.belongsTo(UserModel, {
18
+ foreignKey: { name: 'deletedBy', allowNull: true, field: 'deleted_by' },
19
+ as: 'deletedByUser',
20
+ });
21
+ }
22
+ }
23
+ exports.UnitModel = UnitModel;
24
+ UnitModel.init({
25
+ id: {
26
+ type: sequelize_1.DataTypes.UUID,
27
+ defaultValue: sequelize_1.DataTypes.UUIDV4,
28
+ allowNull: false,
29
+ primaryKey: true,
30
+ },
31
+ name: {
32
+ type: sequelize_1.DataTypes.STRING,
33
+ allowNull: true,
34
+ },
35
+ code: {
36
+ type: sequelize_1.DataTypes.STRING,
37
+ allowNull: true,
38
+ },
39
+ symbol: {
40
+ type: sequelize_1.DataTypes.STRING,
41
+ allowNull: true,
42
+ },
43
+ description: {
44
+ type: sequelize_1.DataTypes.TEXT,
45
+ allowNull: true,
46
+ },
47
+ status: {
48
+ type: sequelize_1.DataTypes.STRING,
49
+ allowNull: true,
50
+ },
51
+ }, {
52
+ modelName: 'UnitModel',
53
+ tableName: 'units',
54
+ timestamps: true,
55
+ sequelize: index_1.sequelize,
56
+ });
57
+ exports.default = UnitModel;
@@ -1,5 +1,5 @@
1
1
  import { Model } from 'sequelize';
2
- import { APP_TYPE, EMAIL_VERIFICATION, MOBILE_VERIFICATION, USER_STATUS, USER_TYPES } from '../../constants/app';
2
+ import { APP_TYPE, EMAIL_VERIFICATION, MOBILE_VERIFICATION, USER_TYPES } from '../../constants/app';
3
3
  import { IUserAttributes } from '../../interfaces/userInterface';
4
4
  import { TUserCreationAttributes } from '../../types/userType';
5
5
  declare class UserModel extends Model<IUserAttributes, TUserCreationAttributes> implements IUserAttributes {
@@ -44,7 +44,6 @@ declare class UserModel extends Model<IUserAttributes, TUserCreationAttributes>
44
44
  district?: string;
45
45
  area?: string;
46
46
  taluka?: string;
47
- status?: USER_STATUS;
48
47
  readonly createdAt: Date;
49
48
  readonly deletedAt: string;
50
49
  readonly updatedAt: Date;
@@ -186,7 +186,6 @@ UserModel.init({
186
186
  medications: { type: sequelize_1.DataTypes.STRING, allowNull: true, field: 'medications' },
187
187
  relation: { type: sequelize_1.DataTypes.STRING, allowNull: true },
188
188
  taluka: { type: sequelize_1.DataTypes.STRING, allowNull: true },
189
- status: { type: sequelize_1.DataTypes.STRING, allowNull: true, defaultValue: app_1.USER_STATUS.ACTIVE },
190
189
  }, {
191
190
  modelName: 'UserModel',
192
191
  tableName: 'users',
@@ -0,0 +1,2 @@
1
+ import { IAgeGroupModelAttributes } from '../interfaces/ageGroupInterface';
2
+ export type TAgeGroupModelCreationAttributes = Partial<IAgeGroupModelAttributes>;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ import { IAssessmentTestModelAttributes } from '../interfaces/assessmentTestInterface';
2
+ export type TAssessmentTestModelCreationAttributes = Partial<IAssessmentTestModelAttributes>;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,13 +1,3 @@
1
- import Joi from 'joi';
2
- import { APP_TYPE } from '../constants/app';
3
- export type TCustomHeaders = {
4
- appType?: APP_TYPE;
5
- token?: string;
6
- deviceId?: string;
7
- deviceToken?: string;
8
- academicCalendarId?: string;
9
- instituteId?: string;
10
- };
11
1
  export type TPaginationOptions<T> = {
12
2
  limit: number | undefined;
13
3
  totalRecords: number;
@@ -15,23 +5,5 @@ export type TPaginationOptions<T> = {
15
5
  hasPreviousPage: boolean;
16
6
  hasNextPage: boolean;
17
7
  currentPage: number;
18
- recordList?: T[];
19
- };
20
- export type SchemaRules<TField> = {
21
- required?: TField[];
22
- optional?: TField[];
23
- allowNull?: TField[];
24
- forbidden?: TField[];
25
- singleOrArray?: TField[];
26
- singleOrArrayOrNull?: TField[];
27
- customFields?: Record<string, Joi.Schema>;
28
- nestedRequired?: string[];
8
+ recordList: T[];
29
9
  };
30
- export interface CrudValidatorRules<TField> {
31
- create?: SchemaRules<TField>;
32
- update?: SchemaRules<TField>;
33
- getAll?: SchemaRules<TField>;
34
- getAllWithPagination?: SchemaRules<TField>;
35
- getById?: SchemaRules<TField>;
36
- delete?: SchemaRules<TField>;
37
- }
@@ -0,0 +1,2 @@
1
+ import { IEquipmentModelAttributes } from '../interfaces/equipmentInterface';
2
+ export type TEquipmentModelCreationAttributes = Partial<IEquipmentModelAttributes>;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,3 @@
1
+ import { Optional } from 'sequelize';
2
+ import { IFacilityMasterModelAttributes } from '../interfaces/facilityMasterInterface';
3
+ export type TFacilityMasterModelCreationAttributes = Optional<IFacilityMasterModelAttributes, 'id' | 'createdBy' | 'updatedBy' | 'deletedBy' | 'createdAt' | 'updatedAt' | 'deletedAt'>;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -233,7 +233,6 @@ export * from './userFinalResultType';
233
233
  export * from './refundType';
234
234
  export * from './kipiverseContactFormType';
235
235
  export * from './moduleDocsType';
236
- export * from './aiModelKeysType';
237
236
  export * from './accountFinancialYearType';
238
237
  export * from './accountPeriodLockType';
239
238
  export * from './accountNumberSequenceType';
@@ -244,3 +243,15 @@ export * from './accountCostCenterType';
244
243
  export * from './accountVoucherTypeType';
245
244
  export * from './vendorCompanyMetaType';
246
245
  export * from './productMetaType';
246
+ export * from './sportType';
247
+ export * from './sportCategoryType';
248
+ export * from './sportSubCategoryType';
249
+ export * from './sportRoleType';
250
+ export * from './equipmentType';
251
+ export * from './facilityMasterType';
252
+ export * from './sportGroupDataType';
253
+ export * from './unitType';
254
+ export * from './skillType';
255
+ export * from './ageGroupType';
256
+ export * from './assessmentTestType';
257
+ export * from './sportInfoType';
@@ -249,7 +249,6 @@ __exportStar(require("./userFinalResultType"), exports);
249
249
  __exportStar(require("./refundType"), exports);
250
250
  __exportStar(require("./kipiverseContactFormType"), exports);
251
251
  __exportStar(require("./moduleDocsType"), exports);
252
- __exportStar(require("./aiModelKeysType"), exports);
253
252
  __exportStar(require("./accountFinancialYearType"), exports);
254
253
  __exportStar(require("./accountPeriodLockType"), exports);
255
254
  __exportStar(require("./accountNumberSequenceType"), exports);
@@ -260,3 +259,16 @@ __exportStar(require("./accountCostCenterType"), exports);
260
259
  __exportStar(require("./accountVoucherTypeType"), exports);
261
260
  __exportStar(require("./vendorCompanyMetaType"), exports);
262
261
  __exportStar(require("./productMetaType"), exports);
262
+ // Arena Module
263
+ __exportStar(require("./sportType"), exports);
264
+ __exportStar(require("./sportCategoryType"), exports);
265
+ __exportStar(require("./sportSubCategoryType"), exports);
266
+ __exportStar(require("./sportRoleType"), exports);
267
+ __exportStar(require("./equipmentType"), exports);
268
+ __exportStar(require("./facilityMasterType"), exports);
269
+ __exportStar(require("./sportGroupDataType"), exports);
270
+ __exportStar(require("./unitType"), exports);
271
+ __exportStar(require("./skillType"), exports);
272
+ __exportStar(require("./ageGroupType"), exports);
273
+ __exportStar(require("./assessmentTestType"), exports);
274
+ __exportStar(require("./sportInfoType"), exports);
@@ -0,0 +1,2 @@
1
+ import { ISkillModelAttributes } from '../interfaces/skillInterface';
2
+ export type TSkillModelCreationAttributes = Partial<ISkillModelAttributes>;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ import { ISportCategoryModelAttributes } from '../interfaces/sportCategoryInterface';
2
+ export type TSportCategoryModelCreationAttributes = Partial<ISportCategoryModelAttributes>;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,3 @@
1
+ import { Optional } from "sequelize";
2
+ import { ISportGroupDataModelAttributes } from "../interfaces/sportGroupDataInterface";
3
+ export type TSportGroupDataModelCreationAttributes = Optional<ISportGroupDataModelAttributes, "id" | "createdAt" | "updatedAt">;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ import { ISportInfoModelAttributes } from '../interfaces/sportInfoInterface';
2
+ export type TSportInfoModelCreationAttributes = Partial<ISportInfoModelAttributes>;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ import { ISportRoleModelAttributes } from '../interfaces/sportRoleInterface';
2
+ export type TSportRoleModelCreationAttributes = Partial<ISportRoleModelAttributes>;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ import { ISportSubCategoryModelAttributes } from '../interfaces/sportSubCategoryInterface';
2
+ export type TSportSubCategoryModelCreationAttributes = Partial<ISportSubCategoryModelAttributes>;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ import { ISportModelAttributes } from '../interfaces/sportInterface';
2
+ export type TSportModelCreationAttributes = Partial<ISportModelAttributes>;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ import { IUnitModelAttributes } from '../interfaces/unitInterface';
2
+ export type TUnitModelCreationAttributes = Partial<IUnitModelAttributes>;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kipicore/dbcore",
3
- "version": "1.1.669",
3
+ "version": "1.1.670",
4
4
  "description": "Reusable DB core package with Postgres, MongoDB, models, services, interfaces, and types",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
@@ -44,24 +44,16 @@
44
44
  "@aws-sdk/client-sts": "^3.1017.0",
45
45
  "@aws-sdk/s3-request-presigner": "^3.895.0",
46
46
  "axios": "^1.12.2",
47
- "bullmq": "^5.80.9",
48
47
  "date-fns": "^4.1.0",
49
48
  "dotenv": "^17.2.2",
50
- "ejs": "^3.1.10",
51
- "firebase-admin": "^13.4.0",
52
- "ioredis": "^5.11.1",
53
49
  "joi": "^18.0.1",
54
50
  "mongoose": "^8.5.2",
55
51
  "pg": "^8.12.0",
56
52
  "sequelize": "^6.37.3",
57
- "uuid": "^8.3.2",
58
- "winston": "^3.19.0",
59
- "winston-daily-rotate-file": "^5.0.0"
53
+ "uuid": "^8.3.2"
60
54
  },
61
55
  "devDependencies": {
62
56
  "@eslint/js": "^9.17.0",
63
- "@types/ejs": "^3.1.5",
64
- "@types/express": "^5.0.6",
65
57
  "@types/mongoose": "^5.11.97",
66
58
  "@types/node": "^24.5.2",
67
59
  "@types/sequelize": "^4.28.14",
@@ -80,4 +72,4 @@
80
72
  "LICENSE",
81
73
  ".sequelizerc"
82
74
  ]
83
- }
75
+ }
@@ -1,27 +0,0 @@
1
- import Joi from 'joi';
2
- import { Request, Response, NextFunction } from 'express';
3
- import BaseValidator from './joiSchemaBuilder';
4
- import { CrudValidatorRules } from '../types/commonType';
5
- export default class BaseCrudValidator<TModel extends Record<string, any>, TKeys extends Extract<keyof TModel, string> = Extract<keyof TModel, string>> extends BaseValidator {
6
- protected baseSchema: Joi.ObjectSchema<any>;
7
- protected rules: CrudValidatorRules<TKeys>;
8
- constructor(baseSchema: Joi.ObjectSchema<any>, rules?: CrudValidatorRules<TKeys>);
9
- /** MERGE RULES */
10
- private mergeRules;
11
- /** APPLY DEFAULT ID RULE */
12
- private applyDefaultIdRule;
13
- /** Nested Required for */
14
- private applyNestedRequired;
15
- /** CREATE */
16
- createValidator: (req: Request, res: Response, next: NextFunction) => void;
17
- /** UPDATE */
18
- updateValidator: (req: Request, res: Response, next: NextFunction) => void;
19
- /** DELETE */
20
- deleteValidator: (req: Request, res: Response, next: NextFunction) => void;
21
- /** GET BY ID */
22
- getByIdValidator: (req: Request, res: Response, next: NextFunction) => void;
23
- /** GET ALL */
24
- getAllValidator: (req: Request, res: Response, next: NextFunction) => void;
25
- /** GET ALL WITH PAGINATION */
26
- getAllWithPaginationValidator: (req: Request, res: Response, next: NextFunction) => void;
27
- }
@@ -1,225 +0,0 @@
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 () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- var __importDefault = (this && this.__importDefault) || function (mod) {
36
- return (mod && mod.__esModule) ? mod : { "default": mod };
37
- };
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- const joi_1 = __importDefault(require("joi"));
40
- const joiSchemaBuilder_1 = __importStar(require("./joiSchemaBuilder"));
41
- const joiCommonValidator_1 = require("./joiCommonValidator");
42
- class BaseCrudValidator extends joiSchemaBuilder_1.default {
43
- constructor(baseSchema, rules = {}) {
44
- super();
45
- /** CREATE */
46
- this.createValidator = (req, res, next) => {
47
- try {
48
- const mergedRules = this.mergeRules({}, this.rules.create);
49
- let schema = (0, joiSchemaBuilder_1.buildSchema)(this.baseSchema, mergedRules);
50
- if (mergedRules.nestedRequired?.length) {
51
- schema = this.applyNestedRequired(schema, mergedRules.nestedRequired);
52
- }
53
- this.validate(schema, req);
54
- next();
55
- }
56
- catch (err) {
57
- next(err);
58
- }
59
- };
60
- /** UPDATE */
61
- this.updateValidator = (req, res, next) => {
62
- try {
63
- const idRules = this.applyDefaultIdRule(this.rules.update);
64
- const mergedRules = this.mergeRules({}, idRules);
65
- let schema = (0, joiSchemaBuilder_1.buildSchema)(this.baseSchema, mergedRules);
66
- if (mergedRules.nestedRequired?.length) {
67
- schema = this.applyNestedRequired(schema, mergedRules.nestedRequired);
68
- }
69
- this.validate(schema, req);
70
- next();
71
- }
72
- catch (err) {
73
- next(err);
74
- }
75
- };
76
- /** DELETE */
77
- this.deleteValidator = (req, res, next) => {
78
- try {
79
- const idRules = this.applyDefaultIdRule(this.rules.delete);
80
- const mergedRules = this.mergeRules({}, idRules);
81
- const schema = (0, joiSchemaBuilder_1.buildSchema)(this.baseSchema, mergedRules);
82
- this.validate(schema, req);
83
- next();
84
- }
85
- catch (err) {
86
- next(err);
87
- }
88
- };
89
- /** GET BY ID */
90
- this.getByIdValidator = (req, res, next) => {
91
- try {
92
- const idRules = this.applyDefaultIdRule(this.rules.getById);
93
- const mergedRules = this.mergeRules({}, idRules);
94
- const schema = (0, joiSchemaBuilder_1.buildSchema)(this.baseSchema, mergedRules);
95
- this.validate(schema, req);
96
- next();
97
- }
98
- catch (err) {
99
- next(err);
100
- }
101
- };
102
- /** GET ALL */
103
- this.getAllValidator = (req, res, next) => {
104
- try {
105
- const mergedRules = this.mergeRules({}, this.rules.getAll);
106
- const schema = (0, joiSchemaBuilder_1.buildSchema)(this.baseSchema, mergedRules);
107
- this.validate(schema, req);
108
- next();
109
- }
110
- catch (err) {
111
- next(err);
112
- }
113
- };
114
- /** GET ALL WITH PAGINATION */
115
- this.getAllWithPaginationValidator = (req, res, next) => {
116
- try {
117
- const mergedRules = this.mergeRules({ customFields: joiCommonValidator_1.paginationValidators }, this.rules.getAllWithPagination ?? this.rules.getAll);
118
- const schema = (0, joiSchemaBuilder_1.buildSchema)(this.baseSchema, mergedRules);
119
- this.validate(schema, req);
120
- next();
121
- }
122
- catch (err) {
123
- next(err);
124
- }
125
- };
126
- this.baseSchema = baseSchema;
127
- this.rules = rules;
128
- }
129
- /** MERGE RULES */
130
- mergeRules(defaultRules, overrideRules) {
131
- const defaultCustomFields = {
132
- search: joi_1.default.string().optional().allow(null),
133
- };
134
- return {
135
- ...defaultRules,
136
- ...overrideRules,
137
- required: [...(defaultRules.required || []), ...(overrideRules?.required || [])],
138
- optional: [...(defaultRules.optional || []), ...(overrideRules?.optional || [])],
139
- allowNull: [...(defaultRules.allowNull || []), ...(overrideRules?.allowNull || [])],
140
- forbidden: [...(defaultRules.forbidden || []), ...(overrideRules?.forbidden || [])],
141
- singleOrArray: [...(defaultRules.singleOrArray || []), ...(overrideRules?.singleOrArray || [])],
142
- singleOrArrayOrNull: [...(defaultRules.singleOrArrayOrNull || []), ...(overrideRules?.singleOrArrayOrNull || [])],
143
- nestedRequired: [...(defaultRules.nestedRequired || []), ...(overrideRules?.nestedRequired || [])],
144
- customFields: {
145
- ...defaultCustomFields,
146
- ...(defaultRules.customFields || {}),
147
- ...(overrideRules?.customFields || {}),
148
- },
149
- };
150
- }
151
- /** APPLY DEFAULT ID RULE */
152
- applyDefaultIdRule(override) {
153
- const overrideHasId = override?.required?.includes('id') ||
154
- override?.optional?.includes('id') ||
155
- override?.forbidden?.includes('id');
156
- if (override && overrideHasId)
157
- return override;
158
- if (override)
159
- return override;
160
- return { required: ['id'] };
161
- }
162
- /** Nested Required for */
163
- // private applyNestedRequired(schema: Joi.ObjectSchema, paths: string[]): Joi.ObjectSchema {
164
- // return schema.custom((value, helpers) => {
165
- // for (const path of paths) {
166
- // const keys = path.split('.');
167
- // let current: any = value;
168
- // let fullPath = '';
169
- // for (const key of keys) {
170
- // if (Array.isArray(current)) {
171
- // if (!current.length) {
172
- // return helpers.message(`"${fullPath || path}" is required`);
173
- // }
174
- // current = current[0];
175
- // fullPath += '[0]';
176
- // }
177
- // fullPath = fullPath ? `${fullPath}.${key}` : key;
178
- // if (current?.[key] === undefined) {
179
- // return helpers.message(`"${fullPath}" is required`);
180
- // }
181
- // current = current[key];
182
- // }
183
- // }
184
- // return value;
185
- // });
186
- // }
187
- applyNestedRequired(schema, paths) {
188
- return schema
189
- .custom((value, helpers) => {
190
- const checkPath = (current, keys, basePath = '') => {
191
- if (!keys.length)
192
- return null;
193
- const [key, ...rest] = keys;
194
- if (Array.isArray(current)) {
195
- for (let i = 0; i < current.length; i++) {
196
- const result = checkPath(current[i], keys, `${basePath}[${i}]`);
197
- if (result)
198
- return result;
199
- }
200
- return null;
201
- }
202
- const nextValue = current?.[key];
203
- const currentPath = basePath ? `${basePath}.${key}` : key;
204
- if (nextValue === undefined) {
205
- return currentPath;
206
- }
207
- return checkPath(nextValue, rest, currentPath);
208
- };
209
- for (const path of paths) {
210
- const keys = path.split('.');
211
- const missingPath = checkPath(value, keys);
212
- if (missingPath) {
213
- return helpers.error('any.custom', {
214
- path: missingPath,
215
- });
216
- }
217
- }
218
- return value;
219
- })
220
- .messages({
221
- 'any.custom': '"{{#path}}" is required',
222
- });
223
- }
224
- }
225
- exports.default = BaseCrudValidator;
@@ -1,3 +0,0 @@
1
- export * from './joiSchemaBuilder';
2
- export * from './joiCommonValidator';
3
- export { default as BaseValidator } from './joiSchemaBuilder';
@@ -1,24 +0,0 @@
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- var __importDefault = (this && this.__importDefault) || function (mod) {
17
- return (mod && mod.__esModule) ? mod : { "default": mod };
18
- };
19
- Object.defineProperty(exports, "__esModule", { value: true });
20
- exports.BaseValidator = void 0;
21
- __exportStar(require("./joiSchemaBuilder"), exports);
22
- __exportStar(require("./joiCommonValidator"), exports);
23
- var joiSchemaBuilder_1 = require("./joiSchemaBuilder");
24
- Object.defineProperty(exports, "BaseValidator", { enumerable: true, get: function () { return __importDefault(joiSchemaBuilder_1).default; } });
@@ -1,12 +0,0 @@
1
- import Joi from 'joi';
2
- export declare const paginationValidators: {
3
- page: Joi.NumberSchema<number>;
4
- limit: Joi.NumberSchema<number>;
5
- search: Joi.StringSchema<string>;
6
- isPaginate: Joi.BooleanSchema<boolean>;
7
- order: Joi.ArraySchema<string[][]>;
8
- sort: Joi.StringSchema<string>;
9
- };
10
- export declare const enumAlternatives: (enumObj: Record<string, string>, isRequired?: boolean, allowArray?: boolean) => Joi.StringSchema<string> | Joi.AlternativesSchema<any>;
11
- export declare const objectIdAlternatives: (isRequired?: boolean, allowArray?: boolean) => Joi.AlternativesSchema<any> | undefined;
12
- export declare const uuidIdAlternatives: (isRequired?: boolean, allowArray?: boolean) => Joi.AlternativesSchema<any> | undefined;