@kipicore/dbcore 1.1.237 → 1.1.239

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.
@@ -485,7 +485,8 @@ export declare enum USER_CHAPTER_INDEX_STATUS {
485
485
  }
486
486
  export declare enum FEE_HISTORY_STATUS {
487
487
  COMPLETED = "COMPLETED",
488
- PENDING = "PENDING"
488
+ PENDING = "PENDING",
489
+ DELETED = "DELETED"
489
490
  }
490
491
  export declare enum CHAPTER_INDEX_FILE_TYPE {
491
492
  VIDEO = "VIDEO",
@@ -590,6 +590,7 @@ var FEE_HISTORY_STATUS;
590
590
  (function (FEE_HISTORY_STATUS) {
591
591
  FEE_HISTORY_STATUS["COMPLETED"] = "COMPLETED";
592
592
  FEE_HISTORY_STATUS["PENDING"] = "PENDING";
593
+ FEE_HISTORY_STATUS["DELETED"] = "DELETED";
593
594
  })(FEE_HISTORY_STATUS || (exports.FEE_HISTORY_STATUS = FEE_HISTORY_STATUS = {}));
594
595
  var CHAPTER_INDEX_FILE_TYPE;
595
596
  (function (CHAPTER_INDEX_FILE_TYPE) {
@@ -0,0 +1,2 @@
1
+ export function up(queryInterface: any, Sequelize: any): Promise<void>;
2
+ export function down(queryInterface: any, Sequelize: any): Promise<void>;
@@ -0,0 +1,102 @@
1
+ 'use strict';
2
+ const up = async (queryInterface, Sequelize) => {
3
+ const table = await queryInterface.describeTable('entity_wise_calendar');
4
+ // Add parent_id (self reference)
5
+ if (!table.parent_id) {
6
+ await queryInterface.addColumn('entity_wise_calendar', 'parent_id', {
7
+ type: Sequelize.UUID,
8
+ allowNull: true,
9
+ defaultValue: null,
10
+ field: 'parent_id',
11
+ references: {
12
+ model: 'entity_wise_calendar',
13
+ key: 'id',
14
+ },
15
+ onUpdate: 'CASCADE',
16
+ onDelete: 'SET NULL',
17
+ });
18
+ }
19
+ // Add start_date
20
+ if (!table.start_date) {
21
+ await queryInterface.addColumn('entity_wise_calendar', 'start_date', {
22
+ type: Sequelize.DATE,
23
+ allowNull: true,
24
+ field: 'start_date',
25
+ });
26
+ }
27
+ // Add end_date
28
+ if (!table.end_date) {
29
+ await queryInterface.addColumn('entity_wise_calendar', 'end_date', {
30
+ type: Sequelize.DATE,
31
+ allowNull: true,
32
+ field: 'end_date',
33
+ });
34
+ }
35
+ // Add start_year
36
+ if (!table.start_year) {
37
+ await queryInterface.addColumn('entity_wise_calendar', 'start_year', {
38
+ type: Sequelize.INTEGER,
39
+ allowNull: true,
40
+ field: 'start_year',
41
+ });
42
+ }
43
+ // Add end_year
44
+ if (!table.end_year) {
45
+ await queryInterface.addColumn('entity_wise_calendar', 'end_year', {
46
+ type: Sequelize.INTEGER,
47
+ allowNull: true,
48
+ field: 'end_year',
49
+ });
50
+ }
51
+ // Remove academic_calendar_id (old design)
52
+ if (table.academic_calendar_id) {
53
+ await queryInterface.removeColumn('entity_wise_calendar', 'academic_calendar_id');
54
+ }
55
+ // Remove institute_id (old design)
56
+ if (table.institute_id) {
57
+ await queryInterface.removeColumn('entity_wise_calendar', 'institute_id');
58
+ }
59
+ };
60
+ const down = async (queryInterface, Sequelize) => {
61
+ const table = await queryInterface.describeTable('entity_wise_calendar');
62
+ // Re-add academic_calendar_id
63
+ if (!table.academic_calendar_id) {
64
+ await queryInterface.addColumn('entity_wise_calendar', 'academic_calendar_id', {
65
+ type: Sequelize.UUID,
66
+ allowNull: true,
67
+ field: 'academic_calendar_id',
68
+ });
69
+ }
70
+ // Re-add institute_id
71
+ if (!table.institute_id) {
72
+ await queryInterface.addColumn('entity_wise_calendar', 'institute_id', {
73
+ type: Sequelize.UUID,
74
+ allowNull: true,
75
+ field: 'institute_id',
76
+ });
77
+ }
78
+ // Remove parent_id
79
+ if (table.parent_id) {
80
+ await queryInterface.removeColumn('entity_wise_calendar', 'parent_id');
81
+ }
82
+ // Remove start_date
83
+ if (table.start_date) {
84
+ await queryInterface.removeColumn('entity_wise_calendar', 'start_date');
85
+ }
86
+ // Remove end_date
87
+ if (table.end_date) {
88
+ await queryInterface.removeColumn('entity_wise_calendar', 'end_date');
89
+ }
90
+ // Remove start_year
91
+ if (table.start_year) {
92
+ await queryInterface.removeColumn('entity_wise_calendar', 'start_year');
93
+ }
94
+ // Remove end_year
95
+ if (table.end_year) {
96
+ await queryInterface.removeColumn('entity_wise_calendar', 'end_year');
97
+ }
98
+ };
99
+ module.exports = {
100
+ up,
101
+ down,
102
+ };
@@ -0,0 +1,2 @@
1
+ export function up(queryInterface: any, Sequelize: any): Promise<void>;
2
+ export function down(queryInterface: any, Sequelize: any): Promise<void>;
@@ -0,0 +1,90 @@
1
+ 'use strict';
2
+ const up = async (queryInterface, Sequelize) => {
3
+ const table = await queryInterface.describeTable('academic_calendars');
4
+ // start_year
5
+ if (!table.start_year) {
6
+ await queryInterface.addColumn('academic_calendars', 'start_year', {
7
+ type: Sequelize.INTEGER,
8
+ allowNull: true,
9
+ field: 'start_year',
10
+ });
11
+ }
12
+ // end_year
13
+ if (!table.end_year) {
14
+ await queryInterface.addColumn('academic_calendars', 'end_year', {
15
+ type: Sequelize.INTEGER,
16
+ allowNull: true,
17
+ field: 'end_year',
18
+ });
19
+ }
20
+ // parent_id (self reference)
21
+ if (!table.parent_id) {
22
+ await queryInterface.addColumn('academic_calendars', 'parent_id', {
23
+ type: Sequelize.UUID,
24
+ allowNull: true,
25
+ field: 'parent_id',
26
+ references: {
27
+ model: 'academic_calendars',
28
+ key: 'id',
29
+ },
30
+ onUpdate: 'CASCADE',
31
+ onDelete: 'SET NULL',
32
+ });
33
+ }
34
+ // entity_id (InstituteEntityModel)
35
+ if (!table.entity_id) {
36
+ await queryInterface.addColumn('academic_calendars', 'entity_id', {
37
+ type: Sequelize.UUID,
38
+ allowNull: true,
39
+ field: 'entity_id',
40
+ references: {
41
+ model: 'institute_entities',
42
+ key: 'id',
43
+ },
44
+ onUpdate: 'CASCADE',
45
+ onDelete: 'SET NULL',
46
+ });
47
+ }
48
+ // base_id (logical root / grouping)
49
+ if (!table.base_id) {
50
+ await queryInterface.addColumn('academic_calendars', 'base_id', {
51
+ type: Sequelize.UUID,
52
+ allowNull: true,
53
+ field: 'base_id',
54
+ });
55
+ }
56
+ // is_updated flag
57
+ if (!table.is_updated) {
58
+ await queryInterface.addColumn('academic_calendars', 'is_updated', {
59
+ type: Sequelize.BOOLEAN,
60
+ allowNull: false,
61
+ defaultValue: false,
62
+ field: 'is_updated',
63
+ });
64
+ }
65
+ };
66
+ const down = async (queryInterface, Sequelize) => {
67
+ const table = await queryInterface.describeTable('academic_calendars');
68
+ if (table.is_updated) {
69
+ await queryInterface.removeColumn('academic_calendars', 'is_updated');
70
+ }
71
+ if (table.base_id) {
72
+ await queryInterface.removeColumn('academic_calendars', 'base_id');
73
+ }
74
+ if (table.entity_id) {
75
+ await queryInterface.removeColumn('academic_calendars', 'entity_id');
76
+ }
77
+ if (table.parent_id) {
78
+ await queryInterface.removeColumn('academic_calendars', 'parent_id');
79
+ }
80
+ if (table.end_year) {
81
+ await queryInterface.removeColumn('academic_calendars', 'end_year');
82
+ }
83
+ if (table.start_year) {
84
+ await queryInterface.removeColumn('academic_calendars', 'start_year');
85
+ }
86
+ };
87
+ module.exports = {
88
+ up,
89
+ down,
90
+ };
@@ -6,4 +6,10 @@ export interface IAcademicCalendarModelAttributes extends IDefaultAttributes {
6
6
  endDate: Date;
7
7
  instituteId: string;
8
8
  status: ACADEMIC_CALENDARS_STATUS;
9
+ parentId: string;
10
+ entityId: string;
11
+ baseId: string;
12
+ startYear: number;
13
+ endYear: number;
14
+ isUpdated?: boolean;
9
15
  }
@@ -2,8 +2,11 @@ import { ACADEMIC_CALENDARS_STATUS } from '../constants/app';
2
2
  import { IDefaultAttributes } from './commonInterface';
3
3
  export interface IEntityWiseCalendarModelAttributes extends IDefaultAttributes {
4
4
  id: string;
5
+ parentId?: string;
5
6
  entityId: string;
6
- instituteId?: string;
7
- academicCalendarId?: string;
8
7
  status: ACADEMIC_CALENDARS_STATUS;
8
+ startDate: Date;
9
+ endDate: Date;
10
+ startYear: number;
11
+ endYear: number;
9
12
  }
@@ -8,6 +8,11 @@ export declare class AcademicCalendarModel extends Model<IAcademicCalendarModelA
8
8
  startDate: Date;
9
9
  endDate: Date;
10
10
  status: ACADEMIC_CALENDARS_STATUS;
11
+ parentId: string;
12
+ entityId: string;
13
+ baseId: string;
14
+ startYear: number;
15
+ endYear: number;
11
16
  createdBy: string;
12
17
  updatedBy: string;
13
18
  deletedBy: string;
@@ -6,7 +6,7 @@ const app_1 = require("../../constants/app");
6
6
  const index_1 = require("./index");
7
7
  class AcademicCalendarModel extends sequelize_1.Model {
8
8
  static associate(models) {
9
- const { InstituteModel, UserModel } = models;
9
+ const { InstituteModel, UserModel, InstituteEntityModel } = models;
10
10
  AcademicCalendarModel.belongsTo(InstituteModel, {
11
11
  foreignKey: {
12
12
  name: 'instituteId',
@@ -42,6 +42,24 @@ class AcademicCalendarModel extends sequelize_1.Model {
42
42
  foreignKey: 'instituteId',
43
43
  as: 'instituteHasAcademicCalendars',
44
44
  });
45
+ // Self-referencing hierarchy
46
+ AcademicCalendarModel.belongsTo(AcademicCalendarModel, {
47
+ foreignKey: { name: 'parentId', field: 'parent_id' },
48
+ as: 'parentAcademicCalendar',
49
+ });
50
+ AcademicCalendarModel.hasMany(AcademicCalendarModel, {
51
+ foreignKey: { name: 'parentId', field: 'parent_id' },
52
+ as: 'subAcademicCalendarList',
53
+ });
54
+ // Entity relation
55
+ AcademicCalendarModel.belongsTo(InstituteEntityModel, {
56
+ foreignKey: { name: 'entityId', field: 'entity_id' },
57
+ as: 'academicCalendarEntity',
58
+ });
59
+ InstituteEntityModel.hasMany(AcademicCalendarModel, {
60
+ foreignKey: { name: 'entityId', field: 'entity_id' },
61
+ as: 'academicCalendarEntityList',
62
+ });
45
63
  }
46
64
  }
47
65
  exports.AcademicCalendarModel = AcademicCalendarModel;
@@ -73,6 +91,36 @@ AcademicCalendarModel.init({
73
91
  allowNull: false,
74
92
  defaultValue: app_1.ACADEMIC_CALENDARS_STATUS.FUTURE_ACADEMIC_CALENDAR,
75
93
  },
94
+ startYear: {
95
+ type: sequelize_1.DataTypes.INTEGER,
96
+ field: 'start_year',
97
+ allowNull: true,
98
+ },
99
+ endYear: {
100
+ type: sequelize_1.DataTypes.INTEGER,
101
+ field: 'end_year',
102
+ allowNull: true,
103
+ },
104
+ parentId: {
105
+ type: sequelize_1.DataTypes.UUID,
106
+ field: 'parent_id',
107
+ allowNull: true,
108
+ },
109
+ entityId: {
110
+ type: sequelize_1.DataTypes.UUID,
111
+ field: 'entity_id',
112
+ allowNull: true,
113
+ },
114
+ baseId: {
115
+ type: sequelize_1.DataTypes.UUID,
116
+ field: 'base_id',
117
+ allowNull: true,
118
+ },
119
+ isUpdated: {
120
+ type: sequelize_1.DataTypes.BOOLEAN,
121
+ field: 'is_updated',
122
+ defaultValue: false,
123
+ },
76
124
  }, {
77
125
  modelName: 'AcademicCalendarModel',
78
126
  tableName: 'academic_calendars',
@@ -4,10 +4,13 @@ import { TEntityWiseCalendarModelCreationAttributes } from '../../types/entityWi
4
4
  import { ACADEMIC_CALENDARS_STATUS } from '../../constants/app';
5
5
  declare class EntityWiseCalendarModel extends Model<IEntityWiseCalendarModelAttributes, TEntityWiseCalendarModelCreationAttributes> {
6
6
  id: string;
7
- instituteId?: string;
8
- academicCalendarId?: string;
7
+ parentId?: string;
9
8
  entityId: string;
10
9
  status: ACADEMIC_CALENDARS_STATUS;
10
+ startDate: Date;
11
+ endDate: Date;
12
+ startYear: number;
13
+ endYear: number;
11
14
  createdBy: string;
12
15
  updatedBy: string;
13
16
  deletedBy: string;
@@ -5,54 +5,36 @@ const index_1 = require("./index");
5
5
  const app_1 = require("../../constants/app");
6
6
  class EntityWiseCalendarModel extends sequelize_1.Model {
7
7
  static associate(models) {
8
- const { UserModel, InstituteModel, AcademicCalendarModel, InstituteEntityModel } = models;
8
+ const { UserModel, InstituteEntityModel } = models;
9
9
  EntityWiseCalendarModel.belongsTo(UserModel, {
10
- foreignKey: {
11
- name: 'createdBy',
12
- allowNull: true,
13
- field: 'created_by',
14
- },
10
+ foreignKey: { name: 'createdBy', field: 'created_by' },
15
11
  as: 'createdByUser',
16
12
  });
17
13
  EntityWiseCalendarModel.belongsTo(UserModel, {
18
- foreignKey: {
19
- name: 'updatedBy',
20
- allowNull: true,
21
- field: 'updated_by',
22
- },
14
+ foreignKey: { name: 'updatedBy', field: 'updated_by' },
23
15
  as: 'updatedByUser',
24
16
  });
25
17
  EntityWiseCalendarModel.belongsTo(UserModel, {
26
- foreignKey: {
27
- name: 'deletedBy',
28
- allowNull: true,
29
- field: 'deleted_by',
30
- },
18
+ foreignKey: { name: 'deletedBy', field: 'deleted_by' },
31
19
  as: 'deletedByUser',
32
20
  });
33
- EntityWiseCalendarModel.belongsTo(InstituteModel, {
34
- foreignKey: { name: 'instituteId', field: 'institute_id' },
35
- as: 'entityWiseCalendarInstitute',
21
+ // Self-referencing hierarchy
22
+ EntityWiseCalendarModel.belongsTo(EntityWiseCalendarModel, {
23
+ foreignKey: { name: 'parentId', field: 'parent_id' },
24
+ as: 'parentEntityWiseCalendar',
36
25
  });
37
- InstituteModel.hasMany(EntityWiseCalendarModel, {
38
- foreignKey: { name: 'instituteId', field: 'institute_id' },
39
- as: 'instituteHasEntityWiseCalendar',
40
- });
41
- EntityWiseCalendarModel.belongsTo(AcademicCalendarModel, {
42
- foreignKey: { name: 'academicCalendarId', field: 'academic_calendar_id' },
43
- as: 'entityWiseAcademicCalendar',
44
- });
45
- AcademicCalendarModel.hasMany(EntityWiseCalendarModel, {
46
- foreignKey: { name: 'academicCalendarId', field: 'academic_calendar_id' },
47
- as: 'academicCalendarIdHasEntityWiseCalendar',
26
+ EntityWiseCalendarModel.hasMany(EntityWiseCalendarModel, {
27
+ foreignKey: { name: 'parentId', field: 'parent_id' },
28
+ as: 'subEntityWiseCalendarList',
48
29
  });
30
+ // Entity relation
49
31
  EntityWiseCalendarModel.belongsTo(InstituteEntityModel, {
50
32
  foreignKey: { name: 'entityId', field: 'entity_id' },
51
33
  as: 'entityWiseCalendarEntity',
52
34
  });
53
35
  InstituteEntityModel.hasMany(EntityWiseCalendarModel, {
54
36
  foreignKey: { name: 'entityId', field: 'entity_id' },
55
- as: 'entityWiseCalendarHasEntity',
37
+ as: 'entityWiseCalendarEntityList',
56
38
  });
57
39
  }
58
40
  }
@@ -63,14 +45,9 @@ EntityWiseCalendarModel.init({
63
45
  allowNull: false,
64
46
  primaryKey: true,
65
47
  },
66
- academicCalendarId: {
67
- type: sequelize_1.DataTypes.UUID,
68
- field: 'academic_calendar_id',
69
- allowNull: true,
70
- },
71
- instituteId: {
48
+ parentId: {
72
49
  type: sequelize_1.DataTypes.UUID,
73
- field: 'institute_id',
50
+ field: 'parent_id',
74
51
  allowNull: true,
75
52
  },
76
53
  entityId: {
@@ -80,8 +57,28 @@ EntityWiseCalendarModel.init({
80
57
  },
81
58
  status: {
82
59
  type: sequelize_1.DataTypes.STRING,
60
+ allowNull: false,
83
61
  defaultValue: app_1.ACADEMIC_CALENDARS_STATUS.CURRENT_ACADEMIC_CALENDAR,
84
- allowNull: true,
62
+ },
63
+ startDate: {
64
+ type: sequelize_1.DataTypes.DATE,
65
+ field: 'start_date',
66
+ allowNull: false,
67
+ },
68
+ endDate: {
69
+ type: sequelize_1.DataTypes.DATE,
70
+ field: 'end_date',
71
+ allowNull: false,
72
+ },
73
+ startYear: {
74
+ type: sequelize_1.DataTypes.INTEGER,
75
+ field: 'start_year',
76
+ allowNull: false,
77
+ },
78
+ endYear: {
79
+ type: sequelize_1.DataTypes.INTEGER,
80
+ field: 'end_year',
81
+ allowNull: false,
85
82
  },
86
83
  }, {
87
84
  modelName: 'EntityWiseCalendar',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kipicore/dbcore",
3
- "version": "1.1.237",
3
+ "version": "1.1.239",
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",