@eventista/ticketing-common 1.0.3 → 1.0.5

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.
Files changed (45) hide show
  1. package/dist/cluster/services/cluster.service.js +2 -2
  2. package/dist/cluster/services/cluster.service.js.map +1 -1
  3. package/dist/tsconfig.tsbuildinfo +1 -1
  4. package/package.json +6 -3
  5. package/src/cluster/config/cluster.config.ts +0 -6
  6. package/src/cluster/index.ts +0 -2
  7. package/src/cluster/modules/cluster.module.ts +0 -9
  8. package/src/cluster/services/cluster.service.ts +0 -76
  9. package/src/database/index.ts +0 -2
  10. package/src/database/mongodb/index.ts +0 -2
  11. package/src/database/mongodb/mongodb.module.ts +0 -42
  12. package/src/database/mongodb/mongodb.service.ts +0 -111
  13. package/src/database/redis/index.ts +0 -2
  14. package/src/database/redis/redis.module.ts +0 -45
  15. package/src/database/redis/redis.service.ts +0 -142
  16. package/src/exception/exception.filter.ts +0 -36
  17. package/src/generic-repository/index.ts +0 -7
  18. package/src/generic-repository/repositories/base.repository.interface.ts +0 -78
  19. package/src/generic-repository/repositories/base.repository.ts +0 -199
  20. package/src/generic-repository/services/base.service.interface.ts +0 -78
  21. package/src/generic-repository/services/base.service.ts +0 -165
  22. package/src/index.ts +0 -13
  23. package/src/logger/custom.logger.ts +0 -83
  24. package/src/logger/index.ts +0 -2
  25. package/src/logger/logger.module.ts +0 -14
  26. package/src/pipes/custom-validation.pipe.ts +0 -61
  27. package/src/response/response.interceptor.ts +0 -26
  28. package/src/schemas/base.schema.ts +0 -19
  29. package/src/schemas/event/event.interfaces.ts +0 -74
  30. package/src/schemas/event/event.schema.ts +0 -195
  31. package/src/schemas/index.ts +0 -16
  32. package/src/schemas/order/order.interfaces.ts +0 -78
  33. package/src/schemas/order/order.schema.ts +0 -120
  34. package/src/schemas/promotions/promotions.interfaces.ts +0 -34
  35. package/src/schemas/promotions/promotions.schema.ts +0 -71
  36. package/src/schemas/rows/rows.interfaces.ts +0 -14
  37. package/src/schemas/rows/rows.schema.ts +0 -47
  38. package/src/schemas/schema.helper.ts +0 -103
  39. package/src/schemas/ticket-classes/ticket-classes.interfaces.ts +0 -18
  40. package/src/schemas/ticket-classes/ticket-classes.schemas.ts +0 -51
  41. package/src/schemas/ticket-summary/ticket-summary.interfaces.ts +0 -20
  42. package/src/schemas/ticket-summary/ticket-summary.schema.ts +0 -46
  43. package/src/schemas/user-fanpass/user-fanpass.interfaces.ts +0 -28
  44. package/src/schemas/user-fanpass/user-fanpass.schemas.ts +0 -86
  45. package/tsconfig.json +0 -17
@@ -1,103 +0,0 @@
1
- import { Schema, SchemaOptions } from 'mongoose';
2
-
3
- export const defaultSchemaOptions: SchemaOptions = {
4
- timestamps: { createdAt: 'createdAt', updatedAt: 'updatedAt' },
5
- toJSON: {
6
- virtuals: true,
7
- transform: (_, ret) => {
8
- delete ret.__v;
9
- return ret;
10
- },
11
- },
12
- toObject: {
13
- virtuals: true,
14
- transform: (_, ret) => {
15
- delete ret.__v;
16
- return ret;
17
- },
18
- },
19
- };
20
-
21
- export const addSoftDeleteHooks = (schema: Schema): void => {
22
- // Thêm middleware để không trả về các document đã bị xóa mềm
23
- schema.pre('find', function() {
24
- if (!this.getQuery().includeDeleted) {
25
- this.where({ isDeleted: { $ne: true } });
26
- }
27
- delete this.getQuery().includeDeleted;
28
- });
29
-
30
- schema.pre('findOne', function() {
31
- if (!this.getQuery().includeDeleted) {
32
- this.where({ isDeleted: { $ne: true } });
33
- }
34
- delete this.getQuery().includeDeleted;
35
- });
36
-
37
- schema.pre('countDocuments', function() {
38
- if (!this.getQuery().includeDeleted) {
39
- this.where({ isDeleted: { $ne: true } });
40
- }
41
- delete this.getQuery().includeDeleted;
42
- });
43
-
44
- // Thêm method để thực hiện xóa mềm
45
- schema.methods.softDelete = async function() {
46
- this.isDeleted = true;
47
- this.updatedAt = new Date();
48
- return this.save();
49
- };
50
-
51
- // Thêm method để khôi phục document đã xóa mềm
52
- schema.methods.restore = async function() {
53
- this.isDeleted = false;
54
- return this.save();
55
- };
56
-
57
- // Thêm static method để thực hiện xóa mềm nhiều document
58
- schema.statics.softDeleteMany = async function(filter = {}) {
59
- return this.updateMany(
60
- filter,
61
- {
62
- $set: {
63
- isDeleted: true,
64
- updatedAt: new Date(),
65
- },
66
- },
67
- );
68
- };
69
-
70
- // Thêm static method để khôi phục nhiều document đã xóa mềm
71
- schema.statics.restoreMany = async function(filter = {}) {
72
- return this.updateMany(
73
- filter,
74
- {
75
- $set: {
76
- isDeleted: false,
77
- },
78
- },
79
- );
80
- };
81
- };
82
-
83
- export const addUpdateHooks = (schema: Schema): void => {
84
- // Cập nhật updatedAt khi document được cập nhật
85
- schema.pre('save', function(next) {
86
- if (this.isModified()) {
87
- this.updatedAt = new Date();
88
- }
89
- next();
90
- });
91
-
92
- schema.pre('updateOne', function() {
93
- this.set({ updatedAt: new Date() });
94
- });
95
-
96
- schema.pre('updateMany', function() {
97
- this.set({ updatedAt: new Date() });
98
- });
99
-
100
- schema.pre('findOneAndUpdate', function() {
101
- this.set({ updatedAt: new Date() });
102
- });
103
- };
@@ -1,18 +0,0 @@
1
- export interface ITicketClass {
2
- _id?: string;
3
- eventId: string;
4
- calendarId: string;
5
- name: string;
6
- color: string;
7
- originalPriceVn: number;
8
- originalPriceUsd: number;
9
- finalPriceVn: number;
10
- finalPriceUsd: number;
11
- description: string;
12
- seatType: string;
13
- maxTicketPerUser: number;
14
- prototypeUrl: string;
15
- createdAt?: Date;
16
- updatedAt?: Date;
17
- isDeleted?: boolean;
18
- }
@@ -1,51 +0,0 @@
1
- import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
2
- import { HydratedDocument } from 'mongoose';
3
- import { BaseDocument, BaseSchema, addSoftDeleteHooks, addUpdateHooks, defaultSchemaOptions } from '../index';
4
-
5
- export type TicketClassDocument = HydratedDocument<TicketClass> & BaseDocument;
6
-
7
- @Schema({
8
- collection: 'ticket_classes',
9
- ...defaultSchemaOptions,
10
- })
11
- export class TicketClass extends BaseSchema {
12
- @Prop({ required: true, index: true })
13
- eventId: string;
14
-
15
- @Prop({ required: true, index: true })
16
- calendarId: string;
17
-
18
- @Prop({})
19
- name: string;
20
-
21
- @Prop({})
22
- color: string;
23
-
24
- @Prop({})
25
- originalPriceVn: number;
26
-
27
- @Prop({})
28
- originalPriceUsd: number;
29
-
30
- @Prop({})
31
- finalPriceVn: number;
32
-
33
- @Prop({})
34
- finalPriceUsd: number;
35
-
36
- @Prop({})
37
- description: string;
38
-
39
- @Prop({})
40
- seatType: string;
41
-
42
- @Prop({})
43
- maxTicketPerUser: number;
44
-
45
- @Prop({})
46
- prototypeUrl: string;
47
- }
48
-
49
- export const TicketClassSchema = SchemaFactory.createForClass(TicketClass);
50
- addUpdateHooks(TicketClassSchema);
51
- addSoftDeleteHooks(TicketClassSchema);
@@ -1,20 +0,0 @@
1
- export enum ITicketSummaryType {
2
- ZONE = 'zone',
3
- TICKET_CLASS = 'ticketClass',
4
- }
5
-
6
- export interface ITicketSummary {
7
- _id?: string;
8
- eventId: string;
9
- type: ITicketSummaryType;
10
- referenceId: string;
11
- ticketClassId: string;
12
- totalTickets: number;
13
- holdTickets: number;
14
- soldTickets: number;
15
- blockedTickets: number;
16
- availableTickets: number;
17
- createdAt?: Date;
18
- updatedAt?: Date;
19
- isDeleted?: boolean;
20
- }
@@ -1,46 +0,0 @@
1
- import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
2
- import { HydratedDocument } from 'mongoose';
3
- import { BaseDocument, BaseSchema, addSoftDeleteHooks, addUpdateHooks, defaultSchemaOptions } from '../index';
4
- import { ITicketSummaryType } from './ticket-summary.interfaces';
5
-
6
- export type TicketSummaryDocument = HydratedDocument<TicketSummary> & BaseDocument;
7
-
8
- @Schema({
9
- collection: 'ticket_summaries',
10
- ...defaultSchemaOptions,
11
- })
12
- export class TicketSummary extends BaseSchema {
13
-
14
- @Prop({ required: true, index: true })
15
- eventId: string;
16
-
17
- @Prop({ required: true, enum: Object.values(ITicketSummaryType), index: true })
18
- type: string;
19
-
20
- @Prop({ required: true, index: true })
21
- referenceId: string;
22
-
23
- @Prop({ required: false })
24
- ticketClassId: string;
25
-
26
- @Prop({ required: true, default: 0 })
27
- totalTickets: number;
28
-
29
- @Prop({ default: 0 })
30
- holdTickets: number;
31
-
32
- @Prop({ default: 0 })
33
- soldTickets: number;
34
-
35
- @Prop({ default: 0 })
36
- blockedTickets: number;
37
-
38
- @Prop({ required: true, default: 0 })
39
- availableTickets: number;
40
- }
41
-
42
- export const TicketSummarySchema = SchemaFactory.createForClass(TicketSummary);
43
- addUpdateHooks(TicketSummarySchema);
44
- addSoftDeleteHooks(TicketSummarySchema);
45
-
46
- TicketSummarySchema.index({ eventId: 1, type: 1, referenceId: 1 }, { unique: true });
@@ -1,28 +0,0 @@
1
- export enum IUserFanpassStatus {
2
- ACTIVE = 'ACTIVE',
3
- INACTIVE = 'INACTIVE',
4
- }
5
-
6
- export interface IUserFanpassPaymentInfo{
7
- name: string;
8
- email: string;
9
- phoneNumber: string;
10
- address: string;
11
- }
12
-
13
- export interface IUserFanpass {
14
- _id?: string;
15
- orderId: string;
16
- ticketId: string;
17
- ticketType: string;
18
- ticketDescription: string;
19
- ticketPrice: number;
20
- userId: string;
21
- status: IUserFanpassStatus;
22
- paymentTime?: Date;
23
- paymentGateway?: string;
24
- paymentInfo: IUserFanpassPaymentInfo;
25
- createdAt?: Date;
26
- updatedAt?: Date;
27
- isDeleted?: boolean;
28
- }
@@ -1,86 +0,0 @@
1
- import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
2
- import { HydratedDocument } from 'mongoose';
3
- import { BaseDocument, BaseSchema, addSoftDeleteHooks, addUpdateHooks, defaultSchemaOptions } from '../index';
4
- import { IUserFanpassPaymentInfo, IUserFanpassStatus } from './user-fanpass.interfaces';
5
-
6
- export type UserFanpassDocument = HydratedDocument<UserFanpass> & BaseDocument;
7
- @Schema({
8
- collection: 'user_fanpass',
9
- ...defaultSchemaOptions,
10
- })
11
- export class UserFanpass extends BaseSchema {
12
- @Prop()
13
- fanpassId: string;
14
-
15
- @Prop()
16
- refId: string;
17
-
18
- @Prop({
19
- type: String,
20
- required: true,
21
- index: true,
22
- })
23
- orderId: string;
24
-
25
- @Prop({
26
- type: String,
27
- required: true,
28
- index: true,
29
- })
30
- ticketId: string;
31
-
32
- @Prop({
33
- type: String,
34
- required: true,
35
- })
36
- ticketType: string;
37
-
38
- @Prop({})
39
- ticketDescription: string;
40
-
41
- @Prop({})
42
- ticketPrice: number;
43
-
44
- @Prop({
45
- type: String,
46
- required: true,
47
- index: true,
48
- })
49
- userId: string;
50
-
51
- @Prop({
52
- enum: Object.values(IUserFanpassStatus),
53
- default: IUserFanpassStatus.ACTIVE,
54
- })
55
- status: string;
56
-
57
- @Prop({
58
- type: Date,
59
- index: true
60
- })
61
- paymentTime: Date;
62
-
63
- @Prop()
64
- paymentGateway: string;
65
-
66
- @Prop({
67
- type: {
68
- name: { type: String },
69
- email: { type: String },
70
- phoneNumber: { type: String },
71
- address: { type: String },
72
- },
73
- required: true,
74
- })
75
- paymentInfo: IUserFanpassPaymentInfo;
76
-
77
- @Prop({})
78
- discountPercent: number;
79
-
80
- @Prop({})
81
- totalAmount: number;
82
- }
83
-
84
- export const UserFanpassSchema = SchemaFactory.createForClass(UserFanpass);
85
- addUpdateHooks(UserFanpassSchema);
86
- addSoftDeleteHooks(UserFanpassSchema);
package/tsconfig.json DELETED
@@ -1,17 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "module": "commonjs",
4
- "declaration": true,
5
- "removeComments": true,
6
- "emitDecoratorMetadata": true,
7
- "experimentalDecorators": true,
8
- "target": "es2020",
9
- "sourceMap": true,
10
- "outDir": "./dist",
11
- "baseUrl": "./",
12
- "incremental": true,
13
- "skipLibCheck": true
14
- },
15
- "include": ["src/**/*"],
16
- "exclude": ["node_modules", "dist"]
17
- }