@kipicore/dbcore 1.1.296 → 1.1.298

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.
@@ -66,7 +66,7 @@ const CampusCarnivalModule = require('./seeders/Data/campusCarnival');
66
66
  const TransportModule = require('./seeders/Data/transportModule');
67
67
  const GreetingModule = require('./seeders/Data/greetingModule');
68
68
  const TaskManagementModule = require('./seeders/Data/taskManagementModule');
69
- const UserRoleModule = require('./seeders/Data/UserRoleModule');
69
+ // const UserRoleModule = require('./seeders/Data/UserRoleModule');
70
70
  const ReportManagementModule = require('./seeders/Data/ReportManagementModule');
71
71
  const DashboardManagementModule = require('./seeders/Data/dashboardManagementModule'); // Need to uncomment dashboard module is ready
72
72
  const CertificateManagementModule = require('./seeders/Data/certificateManagementModule'); // Need to uncomment certificate module is ready
@@ -137,7 +137,7 @@ const allModules = [
137
137
  TaskManagementModule,
138
138
  DashboardManagementModule, // Need to uncomment dashboard module is ready
139
139
  CertificateManagementModule, // Need to uncomment certificate module is ready
140
- UserRoleModule,
140
+ // UserRoleModule,
141
141
  ReportManagementModule,
142
142
  ];
143
143
  module.exports = allModules;
@@ -0,0 +1,2 @@
1
+ export function up(queryInterface: any): Promise<void>;
2
+ export function down(queryInterface: any): Promise<void>;
@@ -0,0 +1,43 @@
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: 'User Role',
9
+ deleted_at: new Date(),
10
+ }, {
11
+ code: 'USERROLE'
12
+ }, { transaction });
13
+ // Update module_features table
14
+ await queryInterface.bulkUpdate('module_features', {
15
+ name: 'User Role Management',
16
+ deleted_at: new Date(),
17
+ }, {
18
+ code: 'USERROLE.USERROLEMANAGEMENT',
19
+ }, { transaction });
20
+ await queryInterface.bulkUpdate('feature_actions', {
21
+ name: 'Principle',
22
+ deleted_at: new Date(),
23
+ }, {
24
+ code: 'USERROLE.USERROLEMANAGEMENT.PRINCIPLE',
25
+ }, { transaction });
26
+ await transaction.commit();
27
+ }
28
+ catch (error) {
29
+ await transaction.rollback();
30
+ throw error;
31
+ }
32
+ },
33
+ async down(queryInterface) {
34
+ const transaction = await queryInterface.sequelize.transaction();
35
+ try {
36
+ await transaction.commit();
37
+ }
38
+ catch (error) {
39
+ await transaction.rollback();
40
+ throw error;
41
+ }
42
+ },
43
+ };
@@ -0,0 +1,2 @@
1
+ export function up(queryInterface: any, Sequelize: any): Promise<void>;
2
+ export function down(queryInterface: any): Promise<void>;
@@ -0,0 +1,22 @@
1
+ 'use strict';
2
+ const up = async (queryInterface, Sequelize) => {
3
+ const table = await queryInterface.describeTable('user_has_batches');
4
+ if (!table.is_teaching_batch) {
5
+ await queryInterface.addColumn('user_has_batches', 'is_teaching_batch', {
6
+ type: Sequelize.STRING,
7
+ allowNull: true,
8
+ defaultValue: 'YES',
9
+ field: 'is_teaching_batch',
10
+ });
11
+ }
12
+ };
13
+ const down = async (queryInterface) => {
14
+ const table = await queryInterface.describeTable('user_has_batches');
15
+ if (table.is_teaching_batch) {
16
+ await queryInterface.removeColumn('user_has_batches', 'is_teaching_batch');
17
+ }
18
+ };
19
+ module.exports = {
20
+ up,
21
+ down,
22
+ };
@@ -104,59 +104,27 @@ module.exports = {
104
104
  if (newActions.length > 0) {
105
105
  await queryInterface.bulkInsert('feature_actions', newActions, { transaction });
106
106
  }
107
- // const modulesToDelete = existingModules.filter(m => !allModulesListCode.modules.has(m.code)).map(m => m.code);
108
- // // Find features to delete
109
- // const featuresToDelete = existingFeatures.filter(f => !allModulesListCode.features.has(f.code)).map(f => f.code);
110
- // // Find actions to delete
111
- // const actionsToDelete = existingActions.filter(a => !allModulesListCode.actions.has(a.code)).map(a => a.code);
112
- // if (actionsToDelete.length) {
113
- // await queryInterface.sequelize.query(`DELETE FROM feature_actions WHERE code IN (:codes)`, {
114
- // replacements: { codes: actionsToDelete },
115
- // transaction,
116
- // });
117
- // }
118
- // if (featuresToDelete.length) {
119
- // await queryInterface.sequelize.query(`DELETE FROM module_features WHERE code IN (:codes)`, {
120
- // replacements: { codes: featuresToDelete },
121
- // transaction,
122
- // });
123
- // }
124
- // if (modulesToDelete.length) {
125
- // await queryInterface.sequelize.query(`DELETE FROM modules WHERE code IN (:codes)`, {
126
- // replacements: { codes: modulesToDelete },
127
- // transaction,
128
- // });
129
- // }
130
- async function findOldCodes(queryInterface, table, validCodes) {
131
- if (validCodes.length === 0) {
132
- // If no codes in the new list, return all old ones
133
- return (await queryInterface.sequelize.query(`SELECT code FROM ${table} WHERE is_default=true`, { raw: true, transaction }))[0];
134
- }
135
- return (await queryInterface.sequelize.query(`SELECT code FROM ${table} WHERE is_default=true AND code NOT IN (:codes)`, {
136
- replacements: { codes: validCodes },
137
- raw: true,
138
- }))[0];
107
+ const modulesToDelete = existingModules.filter(m => !allModulesListCode.modules.has(m.code)).map(m => m.code);
108
+ const featuresToDelete = existingFeatures.filter(f => !allModulesListCode.features.has(f.code)).map(f => f.code);
109
+ const actionsToDelete = existingActions.filter(a => !allModulesListCode.actions.has(a.code)).map(a => a.code);
110
+ if (actionsToDelete.length) {
111
+ await queryInterface.sequelize.query(`DELETE FROM feature_actions WHERE code IN (:codes)`, {
112
+ replacements: { codes: actionsToDelete },
113
+ transaction,
114
+ });
115
+ }
116
+ if (featuresToDelete.length) {
117
+ await queryInterface.sequelize.query(`DELETE FROM module_features WHERE code IN (:codes)`, {
118
+ replacements: { codes: featuresToDelete },
119
+ transaction,
120
+ });
121
+ }
122
+ if (modulesToDelete.length) {
123
+ await queryInterface.sequelize.query(`DELETE FROM modules WHERE code IN (:codes)`, {
124
+ replacements: { codes: modulesToDelete },
125
+ transaction,
126
+ });
139
127
  }
140
- // ✅ Delete old entries not in allModulesListCode
141
- // await queryInterface.sequelize.query(`DELETE FROM feature_actions WHERE code NOT IN (:codes)`, {
142
- // replacements: { codes: [...allModulesListCode.actions] },
143
- // transaction,
144
- // });
145
- // await queryInterface.sequelize.query(`DELETE FROM module_features WHERE code NOT IN (:codes)`, {
146
- // replacements: { codes: [...allModulesListCode.features] },
147
- // transaction,
148
- // });
149
- // await queryInterface.sequelize.query(`DELETE FROM modules WHERE code NOT IN (:codes)`, {
150
- // replacements: { codes: [...allModulesListCode.modules] },
151
- // transaction,
152
- // });
153
- await findOldCodes(queryInterface, 'feature_actions', [...allModulesListCode.actions]);
154
- await findOldCodes(queryInterface, 'module_features', [...allModulesListCode.features]);
155
- await findOldCodes(queryInterface, 'modules', [...allModulesListCode.modules]);
156
- // 2️⃣ Log them (or handle however you want)
157
- // console.log('🚨 Old Actions not in new list:', oldActionsNotInNew);
158
- // console.log('🚨 Old Features not in new list:', oldFeaturesNotInNew);
159
- // console.log('🚨 Old Modules not in new list:', oldModulesNotInNew);
160
128
  await transaction.commit();
161
129
  }
162
130
  catch (error) {
@@ -167,9 +135,9 @@ module.exports = {
167
135
  async down(queryInterface) {
168
136
  const transaction = await queryInterface.sequelize.transaction();
169
137
  try {
170
- await queryInterface.bulkDelete('feature_actions', { is_default: true }, { transaction });
171
- await queryInterface.bulkDelete('module_features', { is_default: true }, { transaction });
172
- await queryInterface.bulkDelete('modules', { is_default: true }, { transaction });
138
+ // await queryInterface.bulkDelete('feature_actions', { is_default: true }, { transaction });
139
+ // await queryInterface.bulkDelete('module_features', { is_default: true }, { transaction });
140
+ // await queryInterface.bulkDelete('modules', { is_default: true }, { transaction });
173
141
  await transaction.commit();
174
142
  }
175
143
  catch (error) {
@@ -17,6 +17,7 @@ const BatchModule = {
17
17
  { name: 'Delete', code: 'BATCH.MANAGEMENT.DELETE', appType: [appTypeEnum.INSTITUTE_APP] },
18
18
  { name: 'Print', code: 'BATCH.MANAGEMENT.PRINT', appType: [appTypeEnum.INSTITUTE_APP] },
19
19
  { name: 'Approval', code: 'BATCH.MANAGEMENT.APPROVAL', appType: [appTypeEnum.INSTITUTE_APP] },
20
+ { name: 'Assign Not Teaching Batch', code: 'BATCH.MANAGEMENT.ASSIGNNONTEACHING', appType: [appTypeEnum.INSTITUTE_APP] },
20
21
  ],
21
22
  },
22
23
  // {
@@ -18,6 +18,7 @@ const BatchModule = {
18
18
  { name: 'Print', code: 'BATCH.MANAGEMENT.PRINT', appType: [appTypeEnum.SCHOOL_APP] },
19
19
  { name: 'Approval', code: 'BATCH.MANAGEMENT.APPROVAL', appType: [appTypeEnum.SCHOOL_APP] },
20
20
  { name: 'Assign Teacher', code: 'BATCH.MANAGEMENT.ASSIGN', appType: [appTypeEnum.SCHOOL_APP] },
21
+ { name: 'Assign Not Teaching Division', code: 'BATCH.MANAGEMENT.ASSIGNNONTEACHING', appType: [appTypeEnum.SCHOOL_APP] },
21
22
  ],
22
23
  },
23
24
  ],
@@ -1,3 +1,4 @@
1
+ import { BOOLEAN_STATUS } from '../constants';
1
2
  import { IDefaultAttributes } from './commonInterface';
2
3
  export interface IUserHasBatchModelAttributes extends IDefaultAttributes {
3
4
  id: string;
@@ -5,4 +6,5 @@ export interface IUserHasBatchModelAttributes extends IDefaultAttributes {
5
6
  userId: string;
6
7
  subjects: string[];
7
8
  academicCalendarId?: string;
9
+ isTeachingBatch?: BOOLEAN_STATUS;
8
10
  }
@@ -1,12 +1,14 @@
1
1
  import { Model } from 'sequelize';
2
2
  import { IUserHasBatchModelAttributes } from '../../interfaces/userHasBatchInterface';
3
3
  import { TUserHasBatchModelCreationAttributes } from '../../types/userHasBatchType';
4
+ import { BOOLEAN_STATUS } from '../../constants';
4
5
  declare class UserHasBatchModel extends Model<IUserHasBatchModelAttributes, TUserHasBatchModelCreationAttributes> {
5
6
  id: string;
6
7
  userId: string;
7
8
  batchId: string;
8
9
  subjects: string[];
9
10
  academicCalendarId: string;
11
+ isTeachingBatch: BOOLEAN_STATUS;
10
12
  createdBy: string;
11
13
  updatedBy: string;
12
14
  deletedBy: string;
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const sequelize_1 = require("sequelize");
4
4
  const index_1 = require("./index");
5
+ const constants_1 = require("../../constants");
5
6
  class UserHasBatchModel extends sequelize_1.Model {
6
7
  static associate(models) {
7
8
  const { UserModel, BatchModel, AcademicCalendarModel } = models;
@@ -100,6 +101,11 @@ UserHasBatchModel.init({
100
101
  field: 'academic_calendar_id',
101
102
  allowNull: true,
102
103
  },
104
+ isTeachingBatch: {
105
+ type: sequelize_1.DataTypes.STRING,
106
+ field: 'is_teaching_batch',
107
+ defaultValue: constants_1.BOOLEAN_STATUS.YES,
108
+ },
103
109
  }, {
104
110
  modelName: 'UserHasBatchModel',
105
111
  tableName: 'user_has_batches',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kipicore/dbcore",
3
- "version": "1.1.296",
3
+ "version": "1.1.298",
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",