@kipicore/dbcore 1.1.409 → 1.1.411

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, Sequelize: any): Promise<void>;
2
+ export function down(queryInterface: any): Promise<void>;
@@ -0,0 +1,32 @@
1
+ 'use strict';
2
+ const up = async (queryInterface, Sequelize) => {
3
+ const table = await queryInterface.describeTable('terms_and_condition');
4
+ if (!table.app_type) {
5
+ await queryInterface.addColumn('terms_and_condition', 'app_type', {
6
+ type: Sequelize.STRING,
7
+ allowNull: true,
8
+ field: 'app_type',
9
+ });
10
+ }
11
+ if (!table.user_type) {
12
+ await queryInterface.addColumn('terms_and_condition', 'user_type', {
13
+ type: Sequelize.STRING,
14
+ allowNull: true,
15
+ field: 'user_type',
16
+ });
17
+ }
18
+ };
19
+ const down = async (queryInterface) => {
20
+ const table = await queryInterface.describeTable('terms_and_condition');
21
+ // Remove only if column exists
22
+ if (table.app_type) {
23
+ await queryInterface.removeColumn('terms_and_condition', 'app_type');
24
+ }
25
+ if (table.user_type) {
26
+ await queryInterface.removeColumn('terms_and_condition', 'user_type');
27
+ }
28
+ };
29
+ module.exports = {
30
+ up,
31
+ down,
32
+ };
@@ -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,125 @@
1
+ "use strict";
2
+ const { type } = require("os");
3
+ const up = async (queryInterface, Sequelize) => {
4
+ const tableName = 'user_accepted_terms_and_condition';
5
+ const tableExists = await queryInterface
6
+ .describeTable(tableName)
7
+ .then(() => true)
8
+ .catch(() => false);
9
+ if (!tableExists) {
10
+ await queryInterface.createTable(tableName, {
11
+ id: { type: Sequelize.UUID, defaultValue: Sequelize.UUIDV4, allowNull: false, primaryKey: true },
12
+ userId: { type: Sequelize.UUID, field: 'user_id', allowNull: true },
13
+ termsAndConditionId: { type: Sequelize.UUID, field: 'terms_and_condition_id', allowNull: true },
14
+ userType: {
15
+ type: Sequelize.STRING,
16
+ field: 'user_type',
17
+ allowNull: true,
18
+ },
19
+ appType: {
20
+ type: Sequelize.STRING,
21
+ field: 'app_type',
22
+ allowNull: true,
23
+ },
24
+ createdBy: {
25
+ type: Sequelize.UUID,
26
+ allowNull: true,
27
+ field: 'created_by',
28
+ },
29
+ updatedBy: {
30
+ type: Sequelize.UUID,
31
+ allowNull: true,
32
+ field: 'updated_by',
33
+ },
34
+ deletedBy: {
35
+ type: Sequelize.UUID,
36
+ allowNull: true,
37
+ field: 'deleted_by',
38
+ },
39
+ createdAt: {
40
+ type: Sequelize.DATE,
41
+ allowNull: false,
42
+ field: 'created_at',
43
+ },
44
+ updatedAt: {
45
+ type: Sequelize.DATE,
46
+ allowNull: false,
47
+ field: 'updated_at',
48
+ },
49
+ deletedAt: {
50
+ type: Sequelize.DATE,
51
+ allowNull: true,
52
+ field: 'deleted_at',
53
+ },
54
+ });
55
+ }
56
+ else {
57
+ const tableDefinition = await queryInterface.describeTable(tableName);
58
+ const columnsToAdd = {
59
+ id: { type: Sequelize.UUID, defaultValue: Sequelize.UUIDV4, allowNull: false, primaryKey: true },
60
+ termsAndConditionId: { type: Sequelize.UUID, field: 'terms_and_condition_id', allowNull: true },
61
+ userId: { type: Sequelize.UUID, field: 'user_id', allowNull: true },
62
+ userType: {
63
+ type: Sequelize.STRING,
64
+ field: 'user_type',
65
+ allowNull: true,
66
+ },
67
+ appType: {
68
+ type: Sequelize.STRING,
69
+ field: 'app_type',
70
+ allowNull: true,
71
+ },
72
+ createdBy: {
73
+ type: Sequelize.UUID,
74
+ allowNull: true,
75
+ field: 'created_by',
76
+ },
77
+ updatedBy: {
78
+ type: Sequelize.UUID,
79
+ allowNull: true,
80
+ field: 'updated_by',
81
+ },
82
+ deletedBy: {
83
+ type: Sequelize.UUID,
84
+ allowNull: true,
85
+ field: 'deleted_by',
86
+ },
87
+ createdAt: {
88
+ type: Sequelize.DATE,
89
+ allowNull: false,
90
+ field: 'created_at',
91
+ },
92
+ updatedAt: {
93
+ type: Sequelize.DATE,
94
+ allowNull: false,
95
+ field: 'updated_at',
96
+ },
97
+ deletedAt: {
98
+ type: Sequelize.DATE,
99
+ allowNull: true,
100
+ field: 'deleted_at',
101
+ },
102
+ };
103
+ for (const column of Object.keys(columnsToAdd)) {
104
+ const columnToAdd = columnsToAdd[column];
105
+ const tableColumn = columnToAdd.field || column;
106
+ if (!tableDefinition[tableColumn]) {
107
+ await queryInterface.addColumn(tableName, tableColumn, columnToAdd);
108
+ }
109
+ }
110
+ }
111
+ };
112
+ const down = async (queryInterface) => {
113
+ const tableName = 'fee_history';
114
+ const tableExists = await queryInterface
115
+ .describeTable(tableName)
116
+ .then(() => true)
117
+ .catch(() => false);
118
+ if (tableExists) {
119
+ await queryInterface.dropTable(tableName);
120
+ }
121
+ };
122
+ module.exports = {
123
+ up,
124
+ down,
125
+ };
@@ -2,7 +2,7 @@ import { BLOG_STATUS } from '../constants/app';
2
2
  import { IDefaultAttributes } from './commonInterface';
3
3
  import { Document } from 'mongoose';
4
4
  export interface ICommentSchema {
5
- id: string;
5
+ commentId: string;
6
6
  userId: string;
7
7
  text: string;
8
8
  parentCommentId?: string;
@@ -5,6 +5,8 @@ export interface IModulePriceList {
5
5
  moduleCode: string;
6
6
  price: number;
7
7
  expiredDate?: Date;
8
+ buyDate?: Date;
9
+ totalPrice?: number;
8
10
  }
9
11
  export interface IModulePriceModelAttributes extends IDefaultAttributes, Document {
10
12
  id: string;
@@ -1,4 +1,4 @@
1
- import { TERM_AND_CONDITION_STATUS } from '../constants/app';
1
+ import { APP_TYPE, TERM_AND_CONDITION_STATUS, USER_TYPES } from '../constants/app';
2
2
  import { IDefaultAttributes } from './commonInterface';
3
3
  export interface ITermsAndConditionAttributes extends IDefaultAttributes {
4
4
  id: string;
@@ -6,4 +6,6 @@ export interface ITermsAndConditionAttributes extends IDefaultAttributes {
6
6
  status: TERM_AND_CONDITION_STATUS;
7
7
  startDate: Date;
8
8
  endDate: Date;
9
+ userType: USER_TYPES;
10
+ appType: APP_TYPE;
9
11
  }
@@ -0,0 +1,9 @@
1
+ import { APP_TYPE, USER_TYPES } from '../constants/app';
2
+ import { IDefaultAttributes } from './commonInterface';
3
+ export interface IUserAcceptedTermsAndConditionAttributes extends IDefaultAttributes {
4
+ id: string;
5
+ userId: string;
6
+ termsAndConditionId: string;
7
+ userType: USER_TYPES;
8
+ appType: APP_TYPE;
9
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -41,7 +41,7 @@ const CommentSchema = new mongoose_1.Schema({
41
41
  parentCommentId: { type: String, required: false },
42
42
  createdAt: { type: Date, default: Date.now },
43
43
  isHide: { type: Boolean, default: false },
44
- id: { type: String, required: true },
44
+ commentId: { type: String, required: true },
45
45
  }, { _id: false });
46
46
  const LikeSchema = new mongoose_1.Schema({
47
47
  likeId: { type: String, required: true },
@@ -1,5 +1,5 @@
1
1
  import { Model } from 'sequelize';
2
- import { TERM_AND_CONDITION_STATUS } from '../../constants/app';
2
+ import { APP_TYPE, TERM_AND_CONDITION_STATUS, USER_TYPES } from '../../constants/app';
3
3
  import { ITermsAndConditionAttributes } from '../../interfaces/termsAndConditionInterface';
4
4
  import { TTermsAndConditionCreationAttributes } from '../../types/termsAndConditionType';
5
5
  declare class TermsAndConditionModel extends Model<ITermsAndConditionAttributes, TTermsAndConditionCreationAttributes> {
@@ -8,6 +8,8 @@ declare class TermsAndConditionModel extends Model<ITermsAndConditionAttributes,
8
8
  fileStorageId: string;
9
9
  startDate: Date;
10
10
  endDate: Date;
11
+ userType: USER_TYPES;
12
+ appType: APP_TYPE;
11
13
  createdBy: string;
12
14
  updatedBy: string;
13
15
  deletedBy: string;
@@ -47,6 +47,16 @@ TermsAndConditionModel.init({
47
47
  allowNull: true,
48
48
  field: 'end_date',
49
49
  },
50
+ userType: {
51
+ type: sequelize_1.DataTypes.STRING,
52
+ allowNull: true,
53
+ field: 'user_type',
54
+ },
55
+ appType: {
56
+ type: sequelize_1.DataTypes.STRING,
57
+ allowNull: true,
58
+ field: 'app_type',
59
+ },
50
60
  }, {
51
61
  modelName: 'TermAndConditionModel',
52
62
  tableName: 'terms_and_condition',
@@ -0,0 +1,19 @@
1
+ import { Model } from 'sequelize';
2
+ import { APP_TYPE, USER_TYPES } from '../../constants/app';
3
+ import { IUserAcceptedTermsAndConditionAttributes } from '../../interfaces/userAcceptedTermsAndConditionInterface';
4
+ import { TUserAcceptedTermsAndConditionCreationAttributes } from '../../types/userAcceptedTermsAndConditionType';
5
+ declare class UserAcceptedTermsAndCondition extends Model<IUserAcceptedTermsAndConditionAttributes, TUserAcceptedTermsAndConditionCreationAttributes> {
6
+ id: string;
7
+ userId: string;
8
+ appType: APP_TYPE;
9
+ userType: USER_TYPES;
10
+ termsAndConditionId: string;
11
+ createdBy: string;
12
+ updatedBy: string;
13
+ deletedBy: string;
14
+ readonly createdAt: Date;
15
+ readonly updatedAt: Date;
16
+ readonly deletedAt: string;
17
+ static associate(models: any): void;
18
+ }
19
+ export default UserAcceptedTermsAndCondition;
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const sequelize_1 = require("sequelize");
4
+ const index_1 = require("./index");
5
+ class UserAcceptedTermsAndCondition extends sequelize_1.Model {
6
+ static associate(models) {
7
+ const { UserModel, TermAndConditionModel } = models;
8
+ UserAcceptedTermsAndCondition.belongsTo(UserModel, {
9
+ foreignKey: { name: 'createdBy', allowNull: true, field: 'created_by' },
10
+ as: 'createdByUser',
11
+ });
12
+ UserAcceptedTermsAndCondition.belongsTo(UserModel, {
13
+ foreignKey: { name: 'updatedBy', allowNull: true, field: 'updated_by' },
14
+ as: 'updatedByUser',
15
+ });
16
+ UserAcceptedTermsAndCondition.belongsTo(UserModel, {
17
+ foreignKey: { name: 'deletedBy', allowNull: true, field: 'deleted_by' },
18
+ as: 'deletedByUser',
19
+ });
20
+ UserAcceptedTermsAndCondition.belongsTo(TermAndConditionModel, {
21
+ foreignKey: { name: 'termsAndConditionId', allowNull: true, field: 'terms_and_condition_id' },
22
+ as: 'userAcceptedTermsOfTermsAndCondition',
23
+ });
24
+ TermAndConditionModel.hasMany(UserAcceptedTermsAndCondition, {
25
+ foreignKey: { name: 'termsAndConditionId', allowNull: true, field: 'terms_and_condition_id' },
26
+ as: 'TermsAndConditionOfUserAcceptedTerms',
27
+ });
28
+ }
29
+ }
30
+ UserAcceptedTermsAndCondition.init({
31
+ id: {
32
+ type: sequelize_1.DataTypes.UUID,
33
+ defaultValue: sequelize_1.DataTypes.UUIDV4,
34
+ allowNull: false,
35
+ primaryKey: true,
36
+ },
37
+ termsAndConditionId: {
38
+ type: sequelize_1.DataTypes.UUID,
39
+ allowNull: true,
40
+ field: 'terms_and_condition_id',
41
+ },
42
+ userId: {
43
+ type: sequelize_1.DataTypes.UUID,
44
+ allowNull: true,
45
+ field: 'user_id',
46
+ },
47
+ userType: {
48
+ type: sequelize_1.DataTypes.STRING,
49
+ allowNull: true,
50
+ field: 'user_type',
51
+ },
52
+ appType: {
53
+ type: sequelize_1.DataTypes.STRING,
54
+ allowNull: true,
55
+ field: 'app_type',
56
+ },
57
+ }, {
58
+ modelName: 'UserAcceptedTermsAndCondition',
59
+ tableName: 'user_accepted_terms_and_condition',
60
+ timestamps: true,
61
+ sequelize: index_1.sequelize,
62
+ });
63
+ exports.default = UserAcceptedTermsAndCondition;
@@ -0,0 +1,3 @@
1
+ import { Optional } from 'sequelize';
2
+ import { IUserAcceptedTermsAndConditionAttributes } from '../interfaces/userAcceptedTermsAndConditionInterface';
3
+ export type TUserAcceptedTermsAndConditionCreationAttributes = Optional<IUserAcceptedTermsAndConditionAttributes, 'id'>;
@@ -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.409",
3
+ "version": "1.1.411",
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",