@kipicore/dbcore 1.1.592 → 1.1.593

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.
@@ -1462,6 +1462,7 @@ export declare enum RMS_TRANSACTION_TYPE {
1462
1462
  DAMAGE = "DAMAGE",
1463
1463
  LOST = "LOST",
1464
1464
  EXPIRED = "EXPIRED",
1465
+ SCRAP = "SCRAP",
1465
1466
  RESERVE = "RESERVE",
1466
1467
  UNRESERVE = "UNRESERVE",
1467
1468
  ISSUE = "ISSUE"
@@ -1503,7 +1504,8 @@ export declare enum RMS_ASSET_LIFECYCLE {
1503
1504
  UNDER_MAINTENANCE = "UNDER_MAINTENANCE",
1504
1505
  RETIRED = "RETIRED",
1505
1506
  DISPOSED = "DISPOSED",
1506
- LOST = "LOST"
1507
+ LOST = "LOST",
1508
+ DAMAGE = "DAMAGE"
1507
1509
  }
1508
1510
  export declare enum RMS_BOOK_COPY_STATUS {
1509
1511
  AVAILABLE = "AVAILABLE",
@@ -1767,6 +1767,7 @@ var RMS_TRANSACTION_TYPE;
1767
1767
  RMS_TRANSACTION_TYPE["DAMAGE"] = "DAMAGE";
1768
1768
  RMS_TRANSACTION_TYPE["LOST"] = "LOST";
1769
1769
  RMS_TRANSACTION_TYPE["EXPIRED"] = "EXPIRED";
1770
+ RMS_TRANSACTION_TYPE["SCRAP"] = "SCRAP";
1770
1771
  RMS_TRANSACTION_TYPE["RESERVE"] = "RESERVE";
1771
1772
  RMS_TRANSACTION_TYPE["UNRESERVE"] = "UNRESERVE";
1772
1773
  RMS_TRANSACTION_TYPE["ISSUE"] = "ISSUE";
@@ -1815,6 +1816,7 @@ var RMS_ASSET_LIFECYCLE;
1815
1816
  RMS_ASSET_LIFECYCLE["RETIRED"] = "RETIRED";
1816
1817
  RMS_ASSET_LIFECYCLE["DISPOSED"] = "DISPOSED";
1817
1818
  RMS_ASSET_LIFECYCLE["LOST"] = "LOST";
1819
+ RMS_ASSET_LIFECYCLE["DAMAGE"] = "DAMAGE";
1818
1820
  })(RMS_ASSET_LIFECYCLE || (exports.RMS_ASSET_LIFECYCLE = RMS_ASSET_LIFECYCLE = {}));
1819
1821
  var RMS_BOOK_COPY_STATUS;
1820
1822
  (function (RMS_BOOK_COPY_STATUS) {
@@ -0,0 +1,2 @@
1
+ declare const _exports: import("sequelize-cli").Migration;
2
+ export = _exports;
@@ -0,0 +1,84 @@
1
+ 'use strict';
2
+ /** @type {import('sequelize-cli').Migration} */
3
+ module.exports = {
4
+ async up(queryInterface, Sequelize) {
5
+ const tableName = 'rms_resources';
6
+ // 1. Drop the foreign key constraint on custodian_id if it exists
7
+ try {
8
+ // Sequelize default naming convention for FKs
9
+ await queryInterface.removeConstraint(tableName, 'rms_resources_custodian_id_fkey');
10
+ }
11
+ catch (error) {
12
+ console.log('Constraint rms_resources_custodian_id_fkey not found or already dropped. Continuing...');
13
+ }
14
+ // 2. Change custodian_id to ARRAY(STRING)
15
+ try {
16
+ await queryInterface.sequelize.query(`
17
+ ALTER TABLE "${tableName}"
18
+ ALTER COLUMN custodian_id TYPE STRING[]
19
+ USING ARRAY[custodian_id]::STRING[];
20
+ `);
21
+ }
22
+ catch (error) {
23
+ console.log('Error altering custodian_id to STRING[]:', error.message);
24
+ }
25
+ // 3. Drop unwanted columns if they exist
26
+ const tableDescription = await queryInterface.describeTable(tableName);
27
+ if (tableDescription.reorder_level) {
28
+ await queryInterface.removeColumn(tableName, 'reorder_level');
29
+ }
30
+ if (tableDescription.is_batch_tracked) {
31
+ await queryInterface.removeColumn(tableName, 'is_batch_tracked');
32
+ }
33
+ if (tableDescription.is_expiry_tracked) {
34
+ await queryInterface.removeColumn(tableName, 'is_expiry_tracked');
35
+ }
36
+ },
37
+ async down(queryInterface, Sequelize) {
38
+ const tableName = 'rms_resources';
39
+ // Re-add removed columns
40
+ await queryInterface.addColumn(tableName, 'reorder_level', {
41
+ type: Sequelize.INTEGER,
42
+ allowNull: false,
43
+ defaultValue: 0,
44
+ });
45
+ await queryInterface.addColumn(tableName, 'is_batch_tracked', {
46
+ type: Sequelize.BOOLEAN,
47
+ allowNull: false,
48
+ defaultValue: false,
49
+ });
50
+ await queryInterface.addColumn(tableName, 'is_expiry_tracked', {
51
+ type: Sequelize.BOOLEAN,
52
+ allowNull: false,
53
+ defaultValue: false,
54
+ });
55
+ // Revert custodian_id array to single element
56
+ try {
57
+ await queryInterface.sequelize.query(`
58
+ ALTER TABLE "${tableName}"
59
+ ALTER COLUMN custodian_id TYPE UUID
60
+ USING custodian_id[1];
61
+ `);
62
+ }
63
+ catch (error) {
64
+ console.log('Error reverting custodian_id to UUID:', error.message);
65
+ }
66
+ // Try adding foreign key back
67
+ try {
68
+ await queryInterface.addConstraint(tableName, {
69
+ fields: ['custodian_id'],
70
+ type: 'foreign key',
71
+ name: 'rms_resources_custodian_id_fkey',
72
+ references: {
73
+ table: 'users',
74
+ field: 'id'
75
+ },
76
+ onDelete: 'SET NULL',
77
+ onUpdate: 'CASCADE'
78
+ });
79
+ }
80
+ catch (error) {
81
+ console.log('Error adding constraint back:', error.message);
82
+ }
83
+ }
84
+ };
@@ -0,0 +1,2 @@
1
+ declare const _exports: import("sequelize-cli").Migration;
2
+ export = _exports;
@@ -0,0 +1,34 @@
1
+ 'use strict';
2
+ /** @type {import('sequelize-cli').Migration} */
3
+ module.exports = {
4
+ async up(queryInterface, Sequelize) {
5
+ // Add columns to rms_assets
6
+ await queryInterface.addColumn('rms_assets', 'is_expiry_tracked', {
7
+ type: Sequelize.BOOLEAN,
8
+ allowNull: true,
9
+ defaultValue: false,
10
+ });
11
+ await queryInterface.addColumn('rms_assets', 'expiry_date', {
12
+ type: Sequelize.DATE,
13
+ allowNull: true,
14
+ });
15
+ // Add columns to rms_grn_items
16
+ await queryInterface.addColumn('rms_grn_items', 'is_expiry_tracked', {
17
+ type: Sequelize.BOOLEAN,
18
+ allowNull: true,
19
+ defaultValue: false,
20
+ });
21
+ await queryInterface.addColumn('rms_grn_items', 'expiry_date', {
22
+ type: Sequelize.DATE,
23
+ allowNull: true,
24
+ });
25
+ },
26
+ async down(queryInterface, Sequelize) {
27
+ // Remove columns from rms_assets
28
+ await queryInterface.removeColumn('rms_assets', 'is_expiry_tracked');
29
+ await queryInterface.removeColumn('rms_assets', 'expiry_date');
30
+ // Remove columns from rms_grn_items
31
+ await queryInterface.removeColumn('rms_grn_items', 'is_expiry_tracked');
32
+ await queryInterface.removeColumn('rms_grn_items', 'expiry_date');
33
+ }
34
+ };
@@ -10,6 +10,8 @@ export interface IRmsAssetAttributes extends IDefaultAttributes {
10
10
  condition?: string | null;
11
11
  assignedTo?: string | null;
12
12
  locationId?: string | null;
13
+ isExpiryTracked?: boolean | null;
14
+ expiryDate?: Date | null;
13
15
  lifecycleStatus: RMS_ASSET_LIFECYCLE;
14
16
  status: string;
15
17
  }
@@ -9,5 +9,7 @@ export interface IRmsGrnItemAttributes extends IDefaultAttributes {
9
9
  receivedQuantity: number;
10
10
  acceptedQuantity: number;
11
11
  rejectedQuantity: number;
12
+ isExpiryTracked?: boolean | null;
13
+ expiryDate?: Date | null;
12
14
  remarks?: string | null;
13
15
  }
@@ -12,12 +12,9 @@ export interface IRmsResourceAttributes extends IDefaultAttributes {
12
12
  unit: RMS_RESOURCE_UNIT;
13
13
  departmentId?: string | null;
14
14
  defaultLocationId?: string | null;
15
- custodianId?: string | null;
15
+ custodianId?: string[] | null;
16
16
  description?: string | null;
17
17
  minStockLevel: number;
18
- reorderLevel: number;
19
- isBatchTracked: boolean;
20
- isExpiryTracked: boolean;
21
18
  metadata?: object | null;
22
19
  status: COMMAN_STATUS;
23
20
  }
@@ -12,6 +12,8 @@ declare class RmsAssetModel extends Model<IRmsAssetAttributes, TRmsAssetCreation
12
12
  condition?: string | null;
13
13
  assignedTo?: string | null;
14
14
  locationId?: string | null;
15
+ isExpiryTracked?: boolean | null;
16
+ expiryDate?: Date | null;
15
17
  lifecycleStatus: RMS_ASSET_LIFECYCLE;
16
18
  status: COMMAN_STATUS;
17
19
  createdBy?: string | null;
@@ -60,6 +60,17 @@ RmsAssetModel.init({
60
60
  type: sequelize_1.DataTypes.UUID,
61
61
  allowNull: true,
62
62
  },
63
+ isExpiryTracked: {
64
+ type: sequelize_1.DataTypes.BOOLEAN,
65
+ allowNull: true,
66
+ defaultValue: false,
67
+ field: 'is_expiry_tracked',
68
+ },
69
+ expiryDate: {
70
+ type: sequelize_1.DataTypes.DATE,
71
+ allowNull: true,
72
+ field: 'expiry_date',
73
+ },
63
74
  lifecycleStatus: {
64
75
  type: sequelize_1.DataTypes.STRING,
65
76
  allowNull: false,
@@ -11,6 +11,8 @@ declare class RmsGrnItemModel extends Model<IRmsGrnItemAttributes, TRmsGrnItemCr
11
11
  receivedQuantity: number;
12
12
  acceptedQuantity: number;
13
13
  rejectedQuantity: number;
14
+ isExpiryTracked?: boolean | null;
15
+ expiryDate?: Date | null;
14
16
  remarks?: string | null;
15
17
  createdBy?: string | null;
16
18
  updatedBy?: string | null;
@@ -61,6 +61,17 @@ RmsGrnItemModel.init({
61
61
  allowNull: false,
62
62
  defaultValue: 0,
63
63
  },
64
+ isExpiryTracked: {
65
+ type: sequelize_1.DataTypes.BOOLEAN,
66
+ allowNull: true,
67
+ defaultValue: false,
68
+ field: 'is_expiry_tracked',
69
+ },
70
+ expiryDate: {
71
+ type: sequelize_1.DataTypes.DATE,
72
+ allowNull: true,
73
+ field: 'expiry_date',
74
+ },
64
75
  remarks: {
65
76
  type: sequelize_1.DataTypes.TEXT,
66
77
  allowNull: true,
@@ -14,12 +14,9 @@ declare class RmsResourceModel extends Model<IRmsResourceAttributes, TRmsResourc
14
14
  unit: RMS_RESOURCE_UNIT;
15
15
  departmentId?: string | null;
16
16
  defaultLocationId?: string | null;
17
- custodianId?: string | null;
17
+ custodianId?: string[] | null;
18
18
  description?: string | null;
19
19
  minStockLevel: number;
20
- reorderLevel: number;
21
- isBatchTracked: boolean;
22
- isExpiryTracked: boolean;
23
20
  metadata?: object | null;
24
21
  status: COMMAN_STATUS;
25
22
  createdBy: string;
@@ -12,13 +12,11 @@ class RmsResourceModel extends sequelize_1.Model {
12
12
  RmsResourceModel.belongsTo(ProductModel, { foreignKey: 'productId', as: 'product' });
13
13
  RmsResourceModel.belongsTo(RmsDepartmentModel, { foreignKey: 'departmentId', as: 'department' });
14
14
  RmsResourceModel.belongsTo(RmsLocationModel, { foreignKey: 'defaultLocationId', as: 'defaultLocation' });
15
- RmsResourceModel.belongsTo(UserModel, { foreignKey: 'custodianId', as: 'custodian' });
16
15
  CategoriesModel.hasMany(RmsResourceModel, { foreignKey: 'categoryId', as: 'resources' });
17
16
  SubCategoriesModel.hasMany(RmsResourceModel, { foreignKey: 'subCategoryId', as: 'resources' });
18
17
  ProductModel.hasMany(RmsResourceModel, { foreignKey: 'productId', as: 'resources' });
19
18
  RmsDepartmentModel.hasMany(RmsResourceModel, { foreignKey: 'departmentId', as: 'resources' });
20
19
  RmsLocationModel.hasMany(RmsResourceModel, { foreignKey: 'defaultLocationId', as: 'resources' });
21
- UserModel.hasMany(RmsResourceModel, { foreignKey: 'custodianId', as: 'resources' });
22
20
  InstituteModel.hasMany(RmsResourceModel, { foreignKey: 'instituteId', as: 'resources' });
23
21
  RmsResourceModel.belongsTo(UserModel, { foreignKey: { name: 'createdBy', field: 'created_by', allowNull: true }, as: 'createdByUser' });
24
22
  RmsResourceModel.belongsTo(UserModel, { foreignKey: { name: 'updatedBy', field: 'updated_by', allowNull: true }, as: 'updatedByUser' });
@@ -81,7 +79,7 @@ RmsResourceModel.init({
81
79
  field: 'default_location_id',
82
80
  },
83
81
  custodianId: {
84
- type: sequelize_1.DataTypes.UUID,
82
+ type: sequelize_1.DataTypes.ARRAY(sequelize_1.DataTypes.STRING),
85
83
  allowNull: true,
86
84
  field: 'custodian_id',
87
85
  },
@@ -95,24 +93,6 @@ RmsResourceModel.init({
95
93
  defaultValue: 0,
96
94
  field: 'min_stock_level',
97
95
  },
98
- reorderLevel: {
99
- type: sequelize_1.DataTypes.INTEGER,
100
- allowNull: false,
101
- defaultValue: 0,
102
- field: 'reorder_level',
103
- },
104
- isBatchTracked: {
105
- type: sequelize_1.DataTypes.BOOLEAN,
106
- allowNull: false,
107
- defaultValue: false,
108
- field: 'is_batch_tracked',
109
- },
110
- isExpiryTracked: {
111
- type: sequelize_1.DataTypes.BOOLEAN,
112
- allowNull: false,
113
- defaultValue: false,
114
- field: 'is_expiry_tracked',
115
- },
116
96
  metadata: {
117
97
  type: sequelize_1.DataTypes.JSONB,
118
98
  allowNull: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kipicore/dbcore",
3
- "version": "1.1.592",
3
+ "version": "1.1.593",
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",