@kipicore/dbcore 1.1.295 → 1.1.296

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.
@@ -0,0 +1,2 @@
1
+ export function up(queryInterface: any): Promise<void>;
2
+ export function down(queryInterface: any): Promise<void>;
@@ -0,0 +1,39 @@
1
+ 'use strict';
2
+ module.exports = {
3
+ async up(queryInterface) {
4
+ const transaction = await queryInterface.sequelize.transaction();
5
+ try {
6
+ // Update modules table
7
+ await queryInterface.bulkUpdate('modules', {
8
+ name: 'Kipi Storage',
9
+ updated_at: new Date(),
10
+ code: 'KIPI'
11
+ }, {
12
+ code: ' KIPI',
13
+ }, { transaction });
14
+ // Update module_features table
15
+ await queryInterface.bulkUpdate('module_features', {
16
+ name: 'Kipi Store Management',
17
+ updated_at: new Date(),
18
+ code: 'KIPI.STORAGE',
19
+ }, {
20
+ code: ' KIPI.STORAGE',
21
+ }, { transaction });
22
+ await transaction.commit();
23
+ }
24
+ catch (error) {
25
+ await transaction.rollback();
26
+ throw error;
27
+ }
28
+ },
29
+ async down(queryInterface) {
30
+ const transaction = await queryInterface.sequelize.transaction();
31
+ try {
32
+ await transaction.commit();
33
+ }
34
+ catch (error) {
35
+ await transaction.rollback();
36
+ throw error;
37
+ }
38
+ },
39
+ };
@@ -0,0 +1,2 @@
1
+ export function up(queryInterface: any): Promise<void>;
2
+ export function down(queryInterface: any): Promise<void>;
@@ -0,0 +1,37 @@
1
+ 'use strict';
2
+ module.exports = {
3
+ async up(queryInterface) {
4
+ const transaction = await queryInterface.sequelize.transaction();
5
+ try {
6
+ // Update modules table
7
+ await queryInterface.bulkUpdate('modules', {
8
+ name: 'Kipi Storage',
9
+ updated_at: new Date(),
10
+ }, {
11
+ code: 'KIPI'
12
+ }, { transaction });
13
+ // Update module_features table
14
+ await queryInterface.bulkUpdate('module_features', {
15
+ name: 'Kipi Store Management',
16
+ updated_at: new Date(),
17
+ }, {
18
+ code: 'KIPI.STORAGE',
19
+ }, { transaction });
20
+ await transaction.commit();
21
+ }
22
+ catch (error) {
23
+ await transaction.rollback();
24
+ throw error;
25
+ }
26
+ },
27
+ async down(queryInterface) {
28
+ const transaction = await queryInterface.sequelize.transaction();
29
+ try {
30
+ await transaction.commit();
31
+ }
32
+ catch (error) {
33
+ await transaction.rollback();
34
+ throw error;
35
+ }
36
+ },
37
+ };
@@ -2,19 +2,19 @@
2
2
  // eslint-disable-next-line @typescript-eslint/no-require-imports
3
3
  const appTypeEnum = require('./appType');
4
4
  const KipiStorageModule = {
5
- name: 'Kip Storage',
6
- code: ' KIPI',
5
+ name: 'Kipi Storage',
6
+ code: 'KIPI',
7
7
  appType: [appTypeEnum.SCHOOL_APP],
8
8
  features: [
9
9
  {
10
- name: 'Kip Store Management',
11
- code: ' KIPI.STORAGE',
10
+ name: 'Kipi Store Management',
11
+ code: 'KIPI.STORAGE',
12
12
  appType: [appTypeEnum.SCHOOL_APP],
13
13
  actions: [
14
- { name: 'Add', code: ' KIPI.STORAGE.ADD', appType: [appTypeEnum.SCHOOL_APP] },
15
- { name: 'Update', code: ' KIPI.STORAGE.UPDATE', appType: [appTypeEnum.SCHOOL_APP] },
16
- { name: 'View', code: ' KIPI.STORAGE.VIEW', appType: [appTypeEnum.SCHOOL_APP] },
17
- { name: 'Delete', code: ' KIPI.STORAGE.DELETE', appType: [appTypeEnum.SCHOOL_APP] },
14
+ { name: 'Add', code: 'KIPI.STORAGE.ADD', appType: [appTypeEnum.SCHOOL_APP] },
15
+ { name: 'Update', code: 'KIPI.STORAGE.UPDATE', appType: [appTypeEnum.SCHOOL_APP] },
16
+ { name: 'View', code: 'KIPI.STORAGE.VIEW', appType: [appTypeEnum.SCHOOL_APP] },
17
+ { name: 'Delete', code: 'KIPI.STORAGE.DELETE', appType: [appTypeEnum.SCHOOL_APP] },
18
18
  ],
19
19
  },
20
20
  ],
@@ -91,22 +91,17 @@ class LectureModel extends sequelize_1.Model {
91
91
  };
92
92
  if (lecture.id)
93
93
  where = { ...where, id: { [sequelize_1.Op.ne]: lecture.id } };
94
- if (lecture.batchId) {
95
- if (lecture.slotId)
96
- where.slotId = lecture.slotId;
97
- const batchConflict = await LectureModel.findOne({ where: { ...where, batchId: lecture.batchId }, ...options });
98
- if (batchConflict)
99
- throw new Error(errorMessages_1.LECTURE_ERROR_MESSAGES.BATCH_OCCUPIED);
100
- }
101
94
  if (lecture.classRoomId) {
102
- const classRoomConflict = await LectureModel.findOne({ where: { ...(0, utils_1.omit)(where, ['slotId']), classRoomId: lecture.classRoomId }, ...options });
95
+ const classRoomConflict = await LectureModel.findOne({
96
+ where: { ...where, classRoomId: lecture.classRoomId },
97
+ ...options,
98
+ });
103
99
  if (classRoomConflict)
104
100
  throw new Error(errorMessages_1.LECTURE_ERROR_MESSAGES.CLASSROOM_OCCUPIED);
105
101
  }
106
- // const teacherConflictWhere = omit(where, ['slotId']);
107
102
  if (lecture.primaryUserId) {
108
103
  const teacherConflict = await LectureModel.findOne({
109
- where: { ...(0, utils_1.omit)(where, ['slotId']), primaryUserId: lecture.primaryUserId },
104
+ where: { ...where, primaryUserId: lecture.primaryUserId },
110
105
  ...options,
111
106
  });
112
107
  if (teacherConflict)
@@ -114,12 +109,20 @@ class LectureModel extends sequelize_1.Model {
114
109
  }
115
110
  if (lecture.secondaryUserId) {
116
111
  const teacherConflict = await LectureModel.findOne({
117
- where: { ...(0, utils_1.omit)(where, ['slotId']), secondaryUserId: lecture.secondaryUserId },
112
+ where: { ...where, secondaryUserId: lecture.secondaryUserId },
118
113
  ...options,
119
114
  });
120
115
  if (teacherConflict)
121
116
  throw new Error(errorMessages_1.LECTURE_ERROR_MESSAGES.TEACHER_OCCUPIED);
122
117
  }
118
+ if (lecture.batchId) {
119
+ if (lecture.slotId)
120
+ where.slotId = lecture.slotId;
121
+ const batchConflict = await LectureModel.findOne({ where: { ...where, batchId: lecture.batchId }, ...options });
122
+ if (batchConflict)
123
+ throw new Error(errorMessages_1.LECTURE_ERROR_MESSAGES.BATCH_OCCUPIED);
124
+ }
125
+ // const teacherConflictWhere = omit(where, ['slotId']);
123
126
  }
124
127
  if (lecture.batchId) {
125
128
  const batchWhere = { id: lecture.batchId };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kipicore/dbcore",
3
- "version": "1.1.295",
3
+ "version": "1.1.296",
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",