@common_ch/common 1.0.42 → 1.0.46
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.
- package/build/events/app/feedback/feedback-create-event.d.ts +17 -0
- package/build/events/app/feedback/feedback-create-event.js +9 -0
- package/build/events/{app → portal}/ticket/ticket-answered-event.ts.d.ts +1 -1
- package/build/events/subjects.d.ts +2 -1
- package/build/events/subjects.js +1 -0
- package/build/index.d.ts +12 -1
- package/build/index.js +12 -1
- package/build/models/app/ai.d.ts +26 -0
- package/build/models/app/ai.js +52 -0
- package/build/models/app/blog.d.ts +36 -0
- package/build/models/app/blog.js +64 -0
- package/build/models/app/discount.d.ts +37 -0
- package/build/models/app/discount.js +56 -0
- package/build/models/app/feedback.d.ts +27 -0
- package/build/models/app/feedback.js +52 -0
- package/build/models/app/image.d.ts +39 -0
- package/build/models/app/image.js +61 -0
- package/build/models/app/message.d.ts +41 -0
- package/build/models/app/message.js +66 -0
- package/build/models/app/plan.d.ts +34 -0
- package/build/models/app/plan.js +63 -0
- package/build/models/app/ticket.d.ts +31 -0
- package/build/models/app/ticket.js +58 -0
- package/build/models/app/user.d.ts +47 -0
- package/build/models/app/user.js +82 -0
- package/build/models/app/voice.d.ts +40 -0
- package/build/models/app/voice.js +62 -0
- package/package.json +3 -1
- /package/build/events/{app → portal}/ticket/ticket-answered-event.ts.js +0 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Subjects } from "../../subjects";
|
|
2
|
+
export declare enum FeedbackTypeEnum {
|
|
3
|
+
suggestion = "suggestion",
|
|
4
|
+
complaint = "complaint",
|
|
5
|
+
review = "review"
|
|
6
|
+
}
|
|
7
|
+
export interface FeedbackCreatedEvent {
|
|
8
|
+
subject: Subjects.FeedbackCreatedEvent;
|
|
9
|
+
data: {
|
|
10
|
+
id: string;
|
|
11
|
+
userId: string;
|
|
12
|
+
aiId?: string;
|
|
13
|
+
comment?: string;
|
|
14
|
+
rating?: number;
|
|
15
|
+
type: FeedbackTypeEnum;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FeedbackTypeEnum = void 0;
|
|
4
|
+
var FeedbackTypeEnum;
|
|
5
|
+
(function (FeedbackTypeEnum) {
|
|
6
|
+
FeedbackTypeEnum["suggestion"] = "suggestion";
|
|
7
|
+
FeedbackTypeEnum["complaint"] = "complaint";
|
|
8
|
+
FeedbackTypeEnum["review"] = "review";
|
|
9
|
+
})(FeedbackTypeEnum || (exports.FeedbackTypeEnum = FeedbackTypeEnum = {}));
|
|
@@ -13,5 +13,6 @@ export declare enum Subjects {
|
|
|
13
13
|
DiscountUpdated = "discount:updated",
|
|
14
14
|
DiscountChangeStatus = "discount:change-status",
|
|
15
15
|
TicketCreated = "ticket:created",
|
|
16
|
-
TicketAnswered = "ticket:answered"
|
|
16
|
+
TicketAnswered = "ticket:answered",
|
|
17
|
+
FeedbackCreatedEvent = "feedback:created"
|
|
17
18
|
}
|
package/build/events/subjects.js
CHANGED
|
@@ -18,4 +18,5 @@ var Subjects;
|
|
|
18
18
|
Subjects["DiscountChangeStatus"] = "discount:change-status";
|
|
19
19
|
Subjects["TicketCreated"] = "ticket:created";
|
|
20
20
|
Subjects["TicketAnswered"] = "ticket:answered";
|
|
21
|
+
Subjects["FeedbackCreatedEvent"] = "feedback:created";
|
|
21
22
|
})(Subjects || (exports.Subjects = Subjects = {}));
|
package/build/index.d.ts
CHANGED
|
@@ -9,6 +9,16 @@ export * from './middlewares/current-admin';
|
|
|
9
9
|
export * from './middlewares/error-handler';
|
|
10
10
|
export * from './middlewares/require-auth';
|
|
11
11
|
export * from './middlewares/require-auth-admin';
|
|
12
|
+
export * from './models/app/ai';
|
|
13
|
+
export * from './models/app/blog';
|
|
14
|
+
export * from './models/app/discount';
|
|
15
|
+
export * from './models/app/feedback';
|
|
16
|
+
export * from './models/app/image';
|
|
17
|
+
export * from './models/app/message';
|
|
18
|
+
export * from './models/app/plan';
|
|
19
|
+
export * from './models/app/ticket';
|
|
20
|
+
export * from './models/app/user';
|
|
21
|
+
export * from './models/app/voice';
|
|
12
22
|
export * from './events/base-listener';
|
|
13
23
|
export * from './events/base-publisher';
|
|
14
24
|
export * from './events/subjects';
|
|
@@ -27,5 +37,6 @@ export * from './events/portal/blog/blog-change-status-event';
|
|
|
27
37
|
export * from './events/portal/discount/discount-create-event';
|
|
28
38
|
export * from './events/portal/discount/discount-update-event';
|
|
29
39
|
export * from './events/portal/discount/discount-change-status-event';
|
|
30
|
-
export * from './events/
|
|
40
|
+
export * from './events/portal/ticket/ticket-answered-event.ts';
|
|
31
41
|
export * from './events/app/ticket/ticket-created-event';
|
|
42
|
+
export * from './events/app/feedback/feedback-create-event';
|
package/build/index.js
CHANGED
|
@@ -25,6 +25,16 @@ __exportStar(require("./middlewares/current-admin"), exports);
|
|
|
25
25
|
__exportStar(require("./middlewares/error-handler"), exports);
|
|
26
26
|
__exportStar(require("./middlewares/require-auth"), exports);
|
|
27
27
|
__exportStar(require("./middlewares/require-auth-admin"), exports);
|
|
28
|
+
__exportStar(require("./models/app/ai"), exports);
|
|
29
|
+
__exportStar(require("./models/app/blog"), exports);
|
|
30
|
+
__exportStar(require("./models/app/discount"), exports);
|
|
31
|
+
__exportStar(require("./models/app/feedback"), exports);
|
|
32
|
+
__exportStar(require("./models/app/image"), exports);
|
|
33
|
+
__exportStar(require("./models/app/message"), exports);
|
|
34
|
+
__exportStar(require("./models/app/plan"), exports);
|
|
35
|
+
__exportStar(require("./models/app/ticket"), exports);
|
|
36
|
+
__exportStar(require("./models/app/user"), exports);
|
|
37
|
+
__exportStar(require("./models/app/voice"), exports);
|
|
28
38
|
__exportStar(require("./events/base-listener"), exports);
|
|
29
39
|
__exportStar(require("./events/base-publisher"), exports);
|
|
30
40
|
__exportStar(require("./events/subjects"), exports);
|
|
@@ -43,5 +53,6 @@ __exportStar(require("./events/portal/blog/blog-change-status-event"), exports);
|
|
|
43
53
|
__exportStar(require("./events/portal/discount/discount-create-event"), exports);
|
|
44
54
|
__exportStar(require("./events/portal/discount/discount-update-event"), exports);
|
|
45
55
|
__exportStar(require("./events/portal/discount/discount-change-status-event"), exports);
|
|
46
|
-
__exportStar(require("./events/
|
|
56
|
+
__exportStar(require("./events/portal/ticket/ticket-answered-event.ts"), exports);
|
|
47
57
|
__exportStar(require("./events/app/ticket/ticket-created-event"), exports);
|
|
58
|
+
__exportStar(require("./events/app/feedback/feedback-create-event"), exports);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import mongoose from 'mongoose';
|
|
2
|
+
import { AiStatusEnum } from '../../events/types_/ai';
|
|
3
|
+
export interface AiAttrs {
|
|
4
|
+
_id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
status?: AiStatusEnum;
|
|
7
|
+
createdAt?: number;
|
|
8
|
+
updatedAt?: number;
|
|
9
|
+
}
|
|
10
|
+
export interface AiDoc extends mongoose.Document {
|
|
11
|
+
_id: string;
|
|
12
|
+
name: string;
|
|
13
|
+
status: AiStatusEnum;
|
|
14
|
+
version: number;
|
|
15
|
+
createdAt?: number;
|
|
16
|
+
updatedAt?: number;
|
|
17
|
+
}
|
|
18
|
+
interface AiModel extends mongoose.Model<AiDoc> {
|
|
19
|
+
build(attrs: AiAttrs): AiDoc;
|
|
20
|
+
findByEvent(event: {
|
|
21
|
+
id: string;
|
|
22
|
+
version: number;
|
|
23
|
+
}): Promise<AiDoc | null>;
|
|
24
|
+
}
|
|
25
|
+
declare const Ai: AiModel;
|
|
26
|
+
export { Ai };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Ai = void 0;
|
|
7
|
+
const mongoose_1 = __importDefault(require("mongoose"));
|
|
8
|
+
const ai_1 = require("../../events/types_/ai");
|
|
9
|
+
const aiSchema = new mongoose_1.default.Schema({
|
|
10
|
+
name: {
|
|
11
|
+
type: String,
|
|
12
|
+
required: true,
|
|
13
|
+
},
|
|
14
|
+
status: {
|
|
15
|
+
type: String,
|
|
16
|
+
enum: ai_1.AiStatusEnum,
|
|
17
|
+
default: ai_1.AiStatusEnum.active,
|
|
18
|
+
},
|
|
19
|
+
createdAt: {
|
|
20
|
+
type: mongoose_1.default.Schema.Types.Date,
|
|
21
|
+
},
|
|
22
|
+
updatedAt: {
|
|
23
|
+
type: mongoose_1.default.Schema.Types.Date,
|
|
24
|
+
},
|
|
25
|
+
}, {
|
|
26
|
+
timestamps: true,
|
|
27
|
+
});
|
|
28
|
+
aiSchema.set('versionKey', 'version');
|
|
29
|
+
aiSchema.pre('save', function (done) {
|
|
30
|
+
// @ts-ignore
|
|
31
|
+
this.$where = {
|
|
32
|
+
version: this.get('version') - 1,
|
|
33
|
+
};
|
|
34
|
+
done();
|
|
35
|
+
});
|
|
36
|
+
aiSchema.statics.build = (attrs) => {
|
|
37
|
+
return new Ai({
|
|
38
|
+
_id: attrs._id,
|
|
39
|
+
status: attrs.status,
|
|
40
|
+
name: attrs.name,
|
|
41
|
+
createdAt: attrs.createdAt,
|
|
42
|
+
updatedAt: attrs.updatedAt,
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
aiSchema.statics.findByEvent = (event) => {
|
|
46
|
+
return Ai.findOne({
|
|
47
|
+
_id: event.id,
|
|
48
|
+
version: event.version - 1,
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
const Ai = mongoose_1.default.model('Ai', aiSchema);
|
|
52
|
+
exports.Ai = Ai;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import mongoose from 'mongoose';
|
|
2
|
+
import { BlogStatusEnum } from '../../events/portal/blog/blog-create-event';
|
|
3
|
+
export interface BlogAttrs {
|
|
4
|
+
_id: string;
|
|
5
|
+
title: string;
|
|
6
|
+
publishDate?: number;
|
|
7
|
+
shortDescription: string;
|
|
8
|
+
description: string;
|
|
9
|
+
status: BlogStatusEnum;
|
|
10
|
+
category: string;
|
|
11
|
+
mainPic: string;
|
|
12
|
+
alt: string;
|
|
13
|
+
anotherPics?: string[];
|
|
14
|
+
createdAt?: number;
|
|
15
|
+
updatedAt?: number;
|
|
16
|
+
}
|
|
17
|
+
interface BlogModel extends mongoose.Model<BlogDoc> {
|
|
18
|
+
build(attrs: BlogAttrs): BlogDoc;
|
|
19
|
+
}
|
|
20
|
+
export interface BlogDoc extends mongoose.Document {
|
|
21
|
+
_id: string;
|
|
22
|
+
version: number;
|
|
23
|
+
title: string;
|
|
24
|
+
publishDate?: number;
|
|
25
|
+
shortDescription: string;
|
|
26
|
+
description: string;
|
|
27
|
+
status: BlogStatusEnum;
|
|
28
|
+
category: string;
|
|
29
|
+
mainPic: string;
|
|
30
|
+
alt: string;
|
|
31
|
+
anotherPics?: string[];
|
|
32
|
+
createdAt?: number;
|
|
33
|
+
updatedAt?: number;
|
|
34
|
+
}
|
|
35
|
+
declare const Blog: BlogModel;
|
|
36
|
+
export { Blog };
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Blog = void 0;
|
|
7
|
+
const mongoose_1 = __importDefault(require("mongoose"));
|
|
8
|
+
const mongoose_update_if_current_1 = require("mongoose-update-if-current");
|
|
9
|
+
const blog_create_event_1 = require("../../events/portal/blog/blog-create-event");
|
|
10
|
+
const blogSchema = new mongoose_1.default.Schema({
|
|
11
|
+
title: {
|
|
12
|
+
type: String,
|
|
13
|
+
required: true,
|
|
14
|
+
},
|
|
15
|
+
publishDate: {
|
|
16
|
+
type: mongoose_1.default.Schema.Types.Date,
|
|
17
|
+
},
|
|
18
|
+
shortDescription: {
|
|
19
|
+
type: String,
|
|
20
|
+
required: true,
|
|
21
|
+
},
|
|
22
|
+
description: {
|
|
23
|
+
type: String,
|
|
24
|
+
required: true,
|
|
25
|
+
},
|
|
26
|
+
category: {
|
|
27
|
+
type: String,
|
|
28
|
+
required: true,
|
|
29
|
+
},
|
|
30
|
+
mainPic: {
|
|
31
|
+
type: String,
|
|
32
|
+
required: true,
|
|
33
|
+
},
|
|
34
|
+
alt: {
|
|
35
|
+
type: String,
|
|
36
|
+
required: true,
|
|
37
|
+
},
|
|
38
|
+
anotherPics: [
|
|
39
|
+
{
|
|
40
|
+
type: String,
|
|
41
|
+
required: false,
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
status: {
|
|
45
|
+
type: String,
|
|
46
|
+
enum: blog_create_event_1.BlogStatusEnum,
|
|
47
|
+
default: blog_create_event_1.BlogStatusEnum.active,
|
|
48
|
+
},
|
|
49
|
+
createdAt: {
|
|
50
|
+
type: mongoose_1.default.Schema.Types.Date,
|
|
51
|
+
},
|
|
52
|
+
updatedAt: {
|
|
53
|
+
type: mongoose_1.default.Schema.Types.Date,
|
|
54
|
+
},
|
|
55
|
+
}, {
|
|
56
|
+
timestamps: true,
|
|
57
|
+
});
|
|
58
|
+
blogSchema.set('versionKey', 'version');
|
|
59
|
+
blogSchema.plugin(mongoose_update_if_current_1.updateIfCurrentPlugin);
|
|
60
|
+
blogSchema.statics.build = (attrs) => {
|
|
61
|
+
return new Blog(attrs);
|
|
62
|
+
};
|
|
63
|
+
const Blog = mongoose_1.default.model('Blog', blogSchema);
|
|
64
|
+
exports.Blog = Blog;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import mongoose from 'mongoose';
|
|
2
|
+
import { UserDoc } from './user';
|
|
3
|
+
import { PlanDoc } from './plan';
|
|
4
|
+
import { DiscountStatusEnum, DiscountType } from '../../events/portal/discount/discount-create-event';
|
|
5
|
+
export interface DiscountAttrs {
|
|
6
|
+
_id: string;
|
|
7
|
+
title: string;
|
|
8
|
+
type: DiscountType;
|
|
9
|
+
amount: string;
|
|
10
|
+
startDate: Date;
|
|
11
|
+
endDate: Date;
|
|
12
|
+
users: string[] | UserDoc[];
|
|
13
|
+
version: number;
|
|
14
|
+
plan?: PlanDoc | string;
|
|
15
|
+
status?: DiscountStatusEnum;
|
|
16
|
+
createdAt?: string;
|
|
17
|
+
updatedAt?: string;
|
|
18
|
+
}
|
|
19
|
+
interface DiscountModel extends mongoose.Model<DiscountDoc> {
|
|
20
|
+
build(attrs: DiscountAttrs): DiscountDoc;
|
|
21
|
+
}
|
|
22
|
+
export interface DiscountDoc extends mongoose.Document {
|
|
23
|
+
_id: string;
|
|
24
|
+
title: string;
|
|
25
|
+
type: DiscountType;
|
|
26
|
+
amount: string;
|
|
27
|
+
startDate: Date;
|
|
28
|
+
endDate: Date;
|
|
29
|
+
users: UserDoc[] | string[];
|
|
30
|
+
plan?: PlanDoc | string;
|
|
31
|
+
status: DiscountStatusEnum;
|
|
32
|
+
version: number;
|
|
33
|
+
createdAt?: string;
|
|
34
|
+
updatedAt?: string;
|
|
35
|
+
}
|
|
36
|
+
declare const Discount: DiscountModel;
|
|
37
|
+
export { Discount };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Discount = void 0;
|
|
7
|
+
const mongoose_1 = __importDefault(require("mongoose"));
|
|
8
|
+
const mongoose_update_if_current_1 = require("mongoose-update-if-current");
|
|
9
|
+
const discount_create_event_1 = require("../../events/portal/discount/discount-create-event");
|
|
10
|
+
const discountSchema = new mongoose_1.default.Schema({
|
|
11
|
+
title: {
|
|
12
|
+
type: String,
|
|
13
|
+
required: true,
|
|
14
|
+
},
|
|
15
|
+
type: {
|
|
16
|
+
type: String,
|
|
17
|
+
enum: discount_create_event_1.DiscountType,
|
|
18
|
+
required: true,
|
|
19
|
+
},
|
|
20
|
+
amount: {
|
|
21
|
+
type: String,
|
|
22
|
+
required: true,
|
|
23
|
+
},
|
|
24
|
+
startDate: {
|
|
25
|
+
type: mongoose_1.default.Schema.Types.Date,
|
|
26
|
+
},
|
|
27
|
+
endDate: {
|
|
28
|
+
type: mongoose_1.default.Schema.Types.Date,
|
|
29
|
+
},
|
|
30
|
+
status: {
|
|
31
|
+
type: String,
|
|
32
|
+
enum: discount_create_event_1.DiscountStatusEnum,
|
|
33
|
+
default: discount_create_event_1.DiscountStatusEnum.active,
|
|
34
|
+
},
|
|
35
|
+
users: [{ type: mongoose_1.default.Schema.Types.ObjectId, ref: 'User' }],
|
|
36
|
+
plan: {
|
|
37
|
+
type: mongoose_1.default.Schema.Types.ObjectId,
|
|
38
|
+
ref: 'Plan',
|
|
39
|
+
required: false,
|
|
40
|
+
},
|
|
41
|
+
createdAt: {
|
|
42
|
+
type: mongoose_1.default.Schema.Types.Date,
|
|
43
|
+
},
|
|
44
|
+
updatedAt: {
|
|
45
|
+
type: mongoose_1.default.Schema.Types.Date,
|
|
46
|
+
},
|
|
47
|
+
}, {
|
|
48
|
+
timestamps: true,
|
|
49
|
+
});
|
|
50
|
+
discountSchema.set('versionKey', 'version');
|
|
51
|
+
discountSchema.plugin(mongoose_update_if_current_1.updateIfCurrentPlugin);
|
|
52
|
+
discountSchema.statics.build = (attrs) => {
|
|
53
|
+
return new Discount(attrs);
|
|
54
|
+
};
|
|
55
|
+
const Discount = mongoose_1.default.model('Discount', discountSchema);
|
|
56
|
+
exports.Discount = Discount;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import mongoose from 'mongoose';
|
|
2
|
+
import { FeedbackTypeEnum } from '../../events/app/feedback/feedback-create-event';
|
|
3
|
+
export interface FeedbackAttrs {
|
|
4
|
+
userId: string;
|
|
5
|
+
aiId?: string;
|
|
6
|
+
comment?: string;
|
|
7
|
+
rating?: number;
|
|
8
|
+
type: FeedbackTypeEnum;
|
|
9
|
+
createdAt?: number;
|
|
10
|
+
updatedAt?: number;
|
|
11
|
+
}
|
|
12
|
+
interface FeedbackModel extends mongoose.Model<FeedbackDoc> {
|
|
13
|
+
build(attrs: FeedbackAttrs): FeedbackDoc;
|
|
14
|
+
}
|
|
15
|
+
export interface FeedbackDoc extends mongoose.Document {
|
|
16
|
+
_id: string;
|
|
17
|
+
userId: string;
|
|
18
|
+
aiId?: string;
|
|
19
|
+
comment?: string;
|
|
20
|
+
rating?: number;
|
|
21
|
+
type: FeedbackTypeEnum;
|
|
22
|
+
createdAt?: number;
|
|
23
|
+
updatedAt?: number;
|
|
24
|
+
version: number;
|
|
25
|
+
}
|
|
26
|
+
declare const Feedback: FeedbackModel;
|
|
27
|
+
export { Feedback };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Feedback = void 0;
|
|
7
|
+
const mongoose_1 = __importDefault(require("mongoose"));
|
|
8
|
+
const mongoose_update_if_current_1 = require("mongoose-update-if-current");
|
|
9
|
+
const feedback_create_event_1 = require("../../events/app/feedback/feedback-create-event");
|
|
10
|
+
const feedbackSchema = new mongoose_1.default.Schema({
|
|
11
|
+
userId: {
|
|
12
|
+
type: mongoose_1.default.Schema.Types.ObjectId,
|
|
13
|
+
ref: 'User',
|
|
14
|
+
required: true,
|
|
15
|
+
},
|
|
16
|
+
aiId: {
|
|
17
|
+
type: mongoose_1.default.Schema.Types.ObjectId,
|
|
18
|
+
ref: 'Ai',
|
|
19
|
+
required: false,
|
|
20
|
+
},
|
|
21
|
+
comment: {
|
|
22
|
+
type: String,
|
|
23
|
+
trim: true,
|
|
24
|
+
required: false,
|
|
25
|
+
},
|
|
26
|
+
rating: {
|
|
27
|
+
type: Number,
|
|
28
|
+
min: 1,
|
|
29
|
+
max: 5,
|
|
30
|
+
required: false,
|
|
31
|
+
},
|
|
32
|
+
type: {
|
|
33
|
+
type: String,
|
|
34
|
+
enum: feedback_create_event_1.FeedbackTypeEnum,
|
|
35
|
+
required: true,
|
|
36
|
+
},
|
|
37
|
+
createdAt: {
|
|
38
|
+
type: mongoose_1.default.Schema.Types.Date,
|
|
39
|
+
},
|
|
40
|
+
updatedAt: {
|
|
41
|
+
type: mongoose_1.default.Schema.Types.Date,
|
|
42
|
+
},
|
|
43
|
+
}, {
|
|
44
|
+
timestamps: true,
|
|
45
|
+
});
|
|
46
|
+
feedbackSchema.set('versionKey', 'version');
|
|
47
|
+
feedbackSchema.plugin(mongoose_update_if_current_1.updateIfCurrentPlugin);
|
|
48
|
+
feedbackSchema.statics.build = (attrs) => {
|
|
49
|
+
return new Feedback(attrs);
|
|
50
|
+
};
|
|
51
|
+
const Feedback = mongoose_1.default.model('Feedback', feedbackSchema);
|
|
52
|
+
exports.Feedback = Feedback;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import mongoose from 'mongoose';
|
|
2
|
+
import { AiAttrs, AiDoc } from './ai';
|
|
3
|
+
export declare enum ImageRoleEnum {
|
|
4
|
+
system = "system",
|
|
5
|
+
user = "user",
|
|
6
|
+
assistant = "assistant"
|
|
7
|
+
}
|
|
8
|
+
export interface ImageAttrs {
|
|
9
|
+
userId: string;
|
|
10
|
+
imageName: string;
|
|
11
|
+
planId?: string;
|
|
12
|
+
images: {
|
|
13
|
+
ai: string | AiAttrs;
|
|
14
|
+
role: ImageRoleEnum;
|
|
15
|
+
content: string;
|
|
16
|
+
createdAt: string;
|
|
17
|
+
}[];
|
|
18
|
+
createdAt?: string;
|
|
19
|
+
updatedAt?: string;
|
|
20
|
+
}
|
|
21
|
+
interface ImageModel extends mongoose.Model<ImageDoc> {
|
|
22
|
+
build(attrs: ImageAttrs): ImageDoc;
|
|
23
|
+
}
|
|
24
|
+
interface ImageDoc extends mongoose.Document {
|
|
25
|
+
_id: string;
|
|
26
|
+
userId: string;
|
|
27
|
+
imageName: string;
|
|
28
|
+
planId?: string;
|
|
29
|
+
images: {
|
|
30
|
+
ai: string | AiDoc;
|
|
31
|
+
role: ImageRoleEnum;
|
|
32
|
+
content: string;
|
|
33
|
+
createdAt: string;
|
|
34
|
+
}[];
|
|
35
|
+
createdAt?: number;
|
|
36
|
+
updatedAt?: number;
|
|
37
|
+
}
|
|
38
|
+
declare const ImageModel: ImageModel;
|
|
39
|
+
export { ImageModel };
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ImageModel = exports.ImageRoleEnum = void 0;
|
|
7
|
+
const mongoose_1 = __importDefault(require("mongoose"));
|
|
8
|
+
const mongoose_update_if_current_1 = require("mongoose-update-if-current");
|
|
9
|
+
var ImageRoleEnum;
|
|
10
|
+
(function (ImageRoleEnum) {
|
|
11
|
+
ImageRoleEnum["system"] = "system";
|
|
12
|
+
ImageRoleEnum["user"] = "user";
|
|
13
|
+
ImageRoleEnum["assistant"] = "assistant";
|
|
14
|
+
})(ImageRoleEnum || (exports.ImageRoleEnum = ImageRoleEnum = {}));
|
|
15
|
+
const ImageSchema = new mongoose_1.default.Schema({
|
|
16
|
+
userId: {
|
|
17
|
+
type: String,
|
|
18
|
+
required: true,
|
|
19
|
+
},
|
|
20
|
+
imageName: {
|
|
21
|
+
type: String,
|
|
22
|
+
required: true,
|
|
23
|
+
},
|
|
24
|
+
planId: {
|
|
25
|
+
type: mongoose_1.default.Schema.Types.ObjectId,
|
|
26
|
+
ref: 'Plan',
|
|
27
|
+
required: false,
|
|
28
|
+
},
|
|
29
|
+
images: [
|
|
30
|
+
{
|
|
31
|
+
ai: {
|
|
32
|
+
type: mongoose_1.default.Schema.Types.ObjectId,
|
|
33
|
+
ref: 'Ai',
|
|
34
|
+
},
|
|
35
|
+
role: {
|
|
36
|
+
type: String,
|
|
37
|
+
required: true,
|
|
38
|
+
enum: Object.values(ImageRoleEnum),
|
|
39
|
+
},
|
|
40
|
+
content: {
|
|
41
|
+
type: String,
|
|
42
|
+
required: true,
|
|
43
|
+
},
|
|
44
|
+
createdAt: {
|
|
45
|
+
type: mongoose_1.default.Schema.Types.Date,
|
|
46
|
+
required: true,
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
],
|
|
50
|
+
createdAt: mongoose_1.default.Schema.Types.Date,
|
|
51
|
+
updatedAt: mongoose_1.default.Schema.Types.Date,
|
|
52
|
+
}, {
|
|
53
|
+
timestamps: true,
|
|
54
|
+
});
|
|
55
|
+
ImageSchema.set('versionKey', 'version');
|
|
56
|
+
ImageSchema.plugin(mongoose_update_if_current_1.updateIfCurrentPlugin);
|
|
57
|
+
ImageSchema.statics.build = (attrs) => {
|
|
58
|
+
return new ImageModel(attrs);
|
|
59
|
+
};
|
|
60
|
+
const ImageModel = mongoose_1.default.model('Image', ImageSchema);
|
|
61
|
+
exports.ImageModel = ImageModel;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import mongoose from 'mongoose';
|
|
2
|
+
import { AiAttrs, AiDoc } from './ai';
|
|
3
|
+
export declare enum MessageRoleEnum {
|
|
4
|
+
system = "system",
|
|
5
|
+
user = "user",
|
|
6
|
+
assistant = "assistant"
|
|
7
|
+
}
|
|
8
|
+
export interface MessageAttrs {
|
|
9
|
+
userId: string;
|
|
10
|
+
messageName: string;
|
|
11
|
+
planId?: string;
|
|
12
|
+
threadChatgptId?: string;
|
|
13
|
+
messages: {
|
|
14
|
+
ai: string | AiAttrs;
|
|
15
|
+
role: MessageRoleEnum;
|
|
16
|
+
content: string;
|
|
17
|
+
createdAt: string;
|
|
18
|
+
}[];
|
|
19
|
+
createdAt?: string;
|
|
20
|
+
updatedAt?: string;
|
|
21
|
+
}
|
|
22
|
+
interface MessageModel extends mongoose.Model<MessageDoc> {
|
|
23
|
+
build(attrs: MessageAttrs): MessageDoc;
|
|
24
|
+
}
|
|
25
|
+
interface MessageDoc extends mongoose.Document {
|
|
26
|
+
_id: string;
|
|
27
|
+
userId: string;
|
|
28
|
+
messageName: string;
|
|
29
|
+
planId?: string;
|
|
30
|
+
threadChatgptId?: string;
|
|
31
|
+
messages: {
|
|
32
|
+
ai: string | AiDoc;
|
|
33
|
+
role: MessageRoleEnum;
|
|
34
|
+
content: string;
|
|
35
|
+
createdAt: string;
|
|
36
|
+
}[];
|
|
37
|
+
createdAt?: number;
|
|
38
|
+
updatedAt?: number;
|
|
39
|
+
}
|
|
40
|
+
declare const Message: MessageModel;
|
|
41
|
+
export { Message };
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Message = exports.MessageRoleEnum = void 0;
|
|
7
|
+
const mongoose_1 = __importDefault(require("mongoose"));
|
|
8
|
+
const mongoose_update_if_current_1 = require("mongoose-update-if-current");
|
|
9
|
+
var MessageRoleEnum;
|
|
10
|
+
(function (MessageRoleEnum) {
|
|
11
|
+
MessageRoleEnum["system"] = "system";
|
|
12
|
+
MessageRoleEnum["user"] = "user";
|
|
13
|
+
MessageRoleEnum["assistant"] = "assistant";
|
|
14
|
+
})(MessageRoleEnum || (exports.MessageRoleEnum = MessageRoleEnum = {}));
|
|
15
|
+
const messageSchema = new mongoose_1.default.Schema({
|
|
16
|
+
userId: {
|
|
17
|
+
type: String,
|
|
18
|
+
required: true,
|
|
19
|
+
},
|
|
20
|
+
messageName: {
|
|
21
|
+
type: String,
|
|
22
|
+
required: true,
|
|
23
|
+
},
|
|
24
|
+
planId: {
|
|
25
|
+
type: mongoose_1.default.Schema.Types.ObjectId,
|
|
26
|
+
ref: 'Plan',
|
|
27
|
+
required: false,
|
|
28
|
+
},
|
|
29
|
+
threadChatgptId: {
|
|
30
|
+
type: String,
|
|
31
|
+
required: false,
|
|
32
|
+
default: null,
|
|
33
|
+
},
|
|
34
|
+
messages: [
|
|
35
|
+
{
|
|
36
|
+
ai: {
|
|
37
|
+
type: mongoose_1.default.Schema.Types.ObjectId,
|
|
38
|
+
ref: 'Ai',
|
|
39
|
+
},
|
|
40
|
+
role: {
|
|
41
|
+
type: String,
|
|
42
|
+
required: true,
|
|
43
|
+
enum: Object.values(MessageRoleEnum),
|
|
44
|
+
},
|
|
45
|
+
content: {
|
|
46
|
+
type: String,
|
|
47
|
+
required: true,
|
|
48
|
+
},
|
|
49
|
+
createdAt: {
|
|
50
|
+
type: mongoose_1.default.Schema.Types.Date,
|
|
51
|
+
required: true,
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
],
|
|
55
|
+
createdAt: mongoose_1.default.Schema.Types.Date,
|
|
56
|
+
updatedAt: mongoose_1.default.Schema.Types.Date,
|
|
57
|
+
}, {
|
|
58
|
+
timestamps: true,
|
|
59
|
+
});
|
|
60
|
+
messageSchema.set('versionKey', 'version');
|
|
61
|
+
messageSchema.plugin(mongoose_update_if_current_1.updateIfCurrentPlugin);
|
|
62
|
+
messageSchema.statics.build = (attrs) => {
|
|
63
|
+
return new Message(attrs);
|
|
64
|
+
};
|
|
65
|
+
const Message = mongoose_1.default.model('Message', messageSchema);
|
|
66
|
+
exports.Message = Message;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import mongoose from 'mongoose';
|
|
2
|
+
import { AisEnum } from '../../events/types_/ai';
|
|
3
|
+
export declare enum PlanStatusEnum {
|
|
4
|
+
active = "active",
|
|
5
|
+
deactive = "deactive"
|
|
6
|
+
}
|
|
7
|
+
export interface PlanAttrs {
|
|
8
|
+
price: string;
|
|
9
|
+
name: string;
|
|
10
|
+
limitOfRequest: number;
|
|
11
|
+
limitUploadFiles: number;
|
|
12
|
+
ais: AisEnum[];
|
|
13
|
+
description?: string;
|
|
14
|
+
status?: PlanStatusEnum;
|
|
15
|
+
createdAt?: number;
|
|
16
|
+
updatedAt?: number;
|
|
17
|
+
}
|
|
18
|
+
interface PlanModel extends mongoose.Model<PlanDoc> {
|
|
19
|
+
build(attrs: PlanAttrs): PlanDoc;
|
|
20
|
+
}
|
|
21
|
+
export interface PlanDoc extends mongoose.Document {
|
|
22
|
+
_id: string;
|
|
23
|
+
price: string;
|
|
24
|
+
name: string;
|
|
25
|
+
limitOfRequest: number;
|
|
26
|
+
limitUploadFiles: number;
|
|
27
|
+
ais: AisEnum[];
|
|
28
|
+
description?: string;
|
|
29
|
+
status?: PlanStatusEnum;
|
|
30
|
+
createdAt?: number;
|
|
31
|
+
updatedAt?: number;
|
|
32
|
+
}
|
|
33
|
+
declare const Plan: PlanModel;
|
|
34
|
+
export { Plan };
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Plan = exports.PlanStatusEnum = void 0;
|
|
7
|
+
const mongoose_1 = __importDefault(require("mongoose"));
|
|
8
|
+
const mongoose_update_if_current_1 = require("mongoose-update-if-current");
|
|
9
|
+
const ai_1 = require("../../events/types_/ai");
|
|
10
|
+
var PlanStatusEnum;
|
|
11
|
+
(function (PlanStatusEnum) {
|
|
12
|
+
PlanStatusEnum["active"] = "active";
|
|
13
|
+
PlanStatusEnum["deactive"] = "deactive";
|
|
14
|
+
})(PlanStatusEnum || (exports.PlanStatusEnum = PlanStatusEnum = {}));
|
|
15
|
+
const planSchema = new mongoose_1.default.Schema({
|
|
16
|
+
price: {
|
|
17
|
+
type: String,
|
|
18
|
+
required: true,
|
|
19
|
+
},
|
|
20
|
+
name: {
|
|
21
|
+
type: String,
|
|
22
|
+
required: true,
|
|
23
|
+
},
|
|
24
|
+
limitOfRequest: {
|
|
25
|
+
type: Number,
|
|
26
|
+
required: true,
|
|
27
|
+
},
|
|
28
|
+
limitUploadFiles: {
|
|
29
|
+
type: Number,
|
|
30
|
+
required: true,
|
|
31
|
+
},
|
|
32
|
+
ais: [
|
|
33
|
+
{
|
|
34
|
+
type: String,
|
|
35
|
+
required: true,
|
|
36
|
+
enum: Object.values(ai_1.AisEnum),
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
description: {
|
|
40
|
+
type: String,
|
|
41
|
+
required: false,
|
|
42
|
+
},
|
|
43
|
+
status: {
|
|
44
|
+
type: String,
|
|
45
|
+
enum: PlanStatusEnum,
|
|
46
|
+
default: PlanStatusEnum.active,
|
|
47
|
+
},
|
|
48
|
+
createdAt: {
|
|
49
|
+
type: mongoose_1.default.Schema.Types.Date,
|
|
50
|
+
},
|
|
51
|
+
updatedAt: {
|
|
52
|
+
type: mongoose_1.default.Schema.Types.Date,
|
|
53
|
+
},
|
|
54
|
+
}, {
|
|
55
|
+
timestamps: true,
|
|
56
|
+
});
|
|
57
|
+
planSchema.set('versionKey', 'version');
|
|
58
|
+
planSchema.plugin(mongoose_update_if_current_1.updateIfCurrentPlugin);
|
|
59
|
+
planSchema.statics.build = (attrs) => {
|
|
60
|
+
return new Plan(attrs);
|
|
61
|
+
};
|
|
62
|
+
const Plan = mongoose_1.default.model('Plan', planSchema);
|
|
63
|
+
exports.Plan = Plan;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import mongoose from 'mongoose';
|
|
2
|
+
import { TicketStatusEnum, TicketTypeEnum } from '../../events/app/ticket/ticket-created-event';
|
|
3
|
+
export interface TicketAttrs {
|
|
4
|
+
userId: string;
|
|
5
|
+
title: string;
|
|
6
|
+
description: string;
|
|
7
|
+
file: string;
|
|
8
|
+
type: TicketTypeEnum;
|
|
9
|
+
response?: string;
|
|
10
|
+
status?: TicketStatusEnum;
|
|
11
|
+
createdAt?: number;
|
|
12
|
+
updatedAt?: number;
|
|
13
|
+
}
|
|
14
|
+
interface TicketModel extends mongoose.Model<TicketDoc> {
|
|
15
|
+
build(attrs: TicketAttrs): TicketDoc;
|
|
16
|
+
}
|
|
17
|
+
export interface TicketDoc extends mongoose.Document {
|
|
18
|
+
_id: string;
|
|
19
|
+
userId: string;
|
|
20
|
+
title: string;
|
|
21
|
+
description: string;
|
|
22
|
+
file: string;
|
|
23
|
+
type: TicketTypeEnum;
|
|
24
|
+
version: number;
|
|
25
|
+
response?: string;
|
|
26
|
+
status?: TicketStatusEnum;
|
|
27
|
+
createdAt?: number;
|
|
28
|
+
updatedAt?: number;
|
|
29
|
+
}
|
|
30
|
+
declare const Ticket: TicketModel;
|
|
31
|
+
export { Ticket };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Ticket = void 0;
|
|
7
|
+
const mongoose_1 = __importDefault(require("mongoose"));
|
|
8
|
+
const mongoose_update_if_current_1 = require("mongoose-update-if-current");
|
|
9
|
+
const ticket_created_event_1 = require("../../events/app/ticket/ticket-created-event");
|
|
10
|
+
const ticketSchema = new mongoose_1.default.Schema({
|
|
11
|
+
userId: {
|
|
12
|
+
type: mongoose_1.default.Schema.Types.ObjectId,
|
|
13
|
+
ref: 'User',
|
|
14
|
+
required: true,
|
|
15
|
+
},
|
|
16
|
+
title: {
|
|
17
|
+
type: String,
|
|
18
|
+
required: true,
|
|
19
|
+
},
|
|
20
|
+
description: {
|
|
21
|
+
type: String,
|
|
22
|
+
required: true,
|
|
23
|
+
},
|
|
24
|
+
file: {
|
|
25
|
+
type: String,
|
|
26
|
+
required: true,
|
|
27
|
+
},
|
|
28
|
+
response: {
|
|
29
|
+
type: String,
|
|
30
|
+
required: false,
|
|
31
|
+
},
|
|
32
|
+
type: {
|
|
33
|
+
type: String,
|
|
34
|
+
enum: Object.values(ticket_created_event_1.TicketTypeEnum),
|
|
35
|
+
required: true,
|
|
36
|
+
default: ticket_created_event_1.TicketTypeEnum.general,
|
|
37
|
+
},
|
|
38
|
+
status: {
|
|
39
|
+
type: String,
|
|
40
|
+
enum: ticket_created_event_1.TicketStatusEnum,
|
|
41
|
+
default: ticket_created_event_1.TicketStatusEnum.active,
|
|
42
|
+
},
|
|
43
|
+
createdAt: {
|
|
44
|
+
type: mongoose_1.default.Schema.Types.Date,
|
|
45
|
+
},
|
|
46
|
+
updatedAt: {
|
|
47
|
+
type: mongoose_1.default.Schema.Types.Date,
|
|
48
|
+
},
|
|
49
|
+
}, {
|
|
50
|
+
timestamps: true,
|
|
51
|
+
});
|
|
52
|
+
ticketSchema.set('versionKey', 'version');
|
|
53
|
+
ticketSchema.plugin(mongoose_update_if_current_1.updateIfCurrentPlugin);
|
|
54
|
+
ticketSchema.statics.build = (attrs) => {
|
|
55
|
+
return new Ticket(attrs);
|
|
56
|
+
};
|
|
57
|
+
const Ticket = mongoose_1.default.model('Ticket', ticketSchema);
|
|
58
|
+
exports.Ticket = Ticket;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import mongoose from 'mongoose';
|
|
2
|
+
export declare enum userStatusEnum {
|
|
3
|
+
active = "active",
|
|
4
|
+
deactive = "deactive"
|
|
5
|
+
}
|
|
6
|
+
export interface UserAttrs {
|
|
7
|
+
_id: string;
|
|
8
|
+
walletBalance?: mongoose.Types.Decimal128;
|
|
9
|
+
planId?: string;
|
|
10
|
+
startTimePlan?: string;
|
|
11
|
+
exTimePlan?: string;
|
|
12
|
+
amountApiExistPlan?: number;
|
|
13
|
+
email?: string;
|
|
14
|
+
username?: string;
|
|
15
|
+
mobile?: string;
|
|
16
|
+
status?: userStatusEnum;
|
|
17
|
+
name?: string;
|
|
18
|
+
family?: string;
|
|
19
|
+
createdAt?: number;
|
|
20
|
+
updatedAt?: number;
|
|
21
|
+
}
|
|
22
|
+
interface UserModel extends mongoose.Model<UserDoc> {
|
|
23
|
+
build(attrs: UserAttrs): UserDoc;
|
|
24
|
+
}
|
|
25
|
+
export interface UserDoc extends mongoose.Document {
|
|
26
|
+
walletBalance: mongoose.Types.Decimal128;
|
|
27
|
+
version: number;
|
|
28
|
+
planId?: string;
|
|
29
|
+
startTimePlan?: string;
|
|
30
|
+
exTimePlan?: string;
|
|
31
|
+
amountApiExistPlan?: number;
|
|
32
|
+
email?: string;
|
|
33
|
+
username?: string;
|
|
34
|
+
mobile?: string;
|
|
35
|
+
status?: string;
|
|
36
|
+
name?: string;
|
|
37
|
+
family?: string;
|
|
38
|
+
apiUsed?: string;
|
|
39
|
+
createdAt?: number;
|
|
40
|
+
updatedAt?: number;
|
|
41
|
+
updateWalletBalance(amount: number): Promise<{
|
|
42
|
+
newBalance: string;
|
|
43
|
+
version: number;
|
|
44
|
+
}>;
|
|
45
|
+
}
|
|
46
|
+
declare const User: UserModel;
|
|
47
|
+
export { User };
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.User = exports.userStatusEnum = void 0;
|
|
16
|
+
const mongoose_1 = __importDefault(require("mongoose"));
|
|
17
|
+
const mongoose_update_if_current_1 = require("mongoose-update-if-current");
|
|
18
|
+
var userStatusEnum;
|
|
19
|
+
(function (userStatusEnum) {
|
|
20
|
+
userStatusEnum["active"] = "active";
|
|
21
|
+
userStatusEnum["deactive"] = "deactive";
|
|
22
|
+
})(userStatusEnum || (exports.userStatusEnum = userStatusEnum = {}));
|
|
23
|
+
const userSchema = new mongoose_1.default.Schema({
|
|
24
|
+
email: {
|
|
25
|
+
type: String,
|
|
26
|
+
required: false,
|
|
27
|
+
},
|
|
28
|
+
mobile: {
|
|
29
|
+
type: String,
|
|
30
|
+
required: true,
|
|
31
|
+
},
|
|
32
|
+
username: {
|
|
33
|
+
type: String,
|
|
34
|
+
required: false,
|
|
35
|
+
},
|
|
36
|
+
name: {
|
|
37
|
+
type: String,
|
|
38
|
+
required: false,
|
|
39
|
+
},
|
|
40
|
+
family: {
|
|
41
|
+
type: String,
|
|
42
|
+
required: false,
|
|
43
|
+
},
|
|
44
|
+
walletBalance: {
|
|
45
|
+
type: mongoose_1.default.Schema.Types.Decimal128,
|
|
46
|
+
default: mongoose_1.default.Types.Decimal128.fromString('0.00'),
|
|
47
|
+
},
|
|
48
|
+
apiUsed: {
|
|
49
|
+
type: String,
|
|
50
|
+
required: false,
|
|
51
|
+
default: '0',
|
|
52
|
+
},
|
|
53
|
+
status: {
|
|
54
|
+
type: String,
|
|
55
|
+
enum: userStatusEnum,
|
|
56
|
+
default: userStatusEnum.active,
|
|
57
|
+
},
|
|
58
|
+
createdAt: {
|
|
59
|
+
type: Number,
|
|
60
|
+
},
|
|
61
|
+
updatedAt: {
|
|
62
|
+
type: Number,
|
|
63
|
+
},
|
|
64
|
+
}, {
|
|
65
|
+
timestamps: true,
|
|
66
|
+
});
|
|
67
|
+
userSchema.set('versionKey', 'version');
|
|
68
|
+
userSchema.plugin(mongoose_update_if_current_1.updateIfCurrentPlugin);
|
|
69
|
+
userSchema.statics.build = (attrs) => {
|
|
70
|
+
return new User(attrs);
|
|
71
|
+
};
|
|
72
|
+
userSchema.methods.updateWalletBalance = function (amount) {
|
|
73
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
74
|
+
const currentBalance = parseFloat(this.walletBalance.toString());
|
|
75
|
+
const newBalance = currentBalance + amount;
|
|
76
|
+
this.walletBalance = mongoose_1.default.Types.Decimal128.fromString(newBalance.toFixed(2)); //2 ragham ashar
|
|
77
|
+
yield this.save();
|
|
78
|
+
return { newBalance: this.walletBalance.toString(), version: this.version };
|
|
79
|
+
});
|
|
80
|
+
};
|
|
81
|
+
const User = mongoose_1.default.model('User', userSchema);
|
|
82
|
+
exports.User = User;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import mongoose from 'mongoose';
|
|
2
|
+
import { AiAttrs, AiDoc } from './ai';
|
|
3
|
+
export declare enum SpeechTypeEnum {
|
|
4
|
+
textToSpeech = "textToSpeech",
|
|
5
|
+
speechToText = "speechToText"
|
|
6
|
+
}
|
|
7
|
+
export interface SpeechAttrs {
|
|
8
|
+
userId: string;
|
|
9
|
+
speechName: string;
|
|
10
|
+
planId?: string;
|
|
11
|
+
speech: {
|
|
12
|
+
ai: string | AiAttrs;
|
|
13
|
+
type: SpeechTypeEnum;
|
|
14
|
+
file: string;
|
|
15
|
+
content: string;
|
|
16
|
+
createdAt: string;
|
|
17
|
+
};
|
|
18
|
+
createdAt?: string;
|
|
19
|
+
updatedAt?: string;
|
|
20
|
+
}
|
|
21
|
+
interface SpeechModel extends mongoose.Model<SpeechDoc> {
|
|
22
|
+
build(attrs: SpeechAttrs): SpeechDoc;
|
|
23
|
+
}
|
|
24
|
+
interface SpeechDoc extends mongoose.Document {
|
|
25
|
+
_id: string;
|
|
26
|
+
userId: string;
|
|
27
|
+
speechName: string;
|
|
28
|
+
planId?: string;
|
|
29
|
+
speech: {
|
|
30
|
+
ai: string | AiDoc;
|
|
31
|
+
type: SpeechTypeEnum;
|
|
32
|
+
file: string;
|
|
33
|
+
content: string;
|
|
34
|
+
createdAt: string;
|
|
35
|
+
}[];
|
|
36
|
+
createdAt?: number;
|
|
37
|
+
updatedAt?: number;
|
|
38
|
+
}
|
|
39
|
+
declare const SpeechModel: SpeechModel;
|
|
40
|
+
export { SpeechModel };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.SpeechModel = exports.SpeechTypeEnum = void 0;
|
|
7
|
+
const mongoose_1 = __importDefault(require("mongoose"));
|
|
8
|
+
const mongoose_update_if_current_1 = require("mongoose-update-if-current");
|
|
9
|
+
var SpeechTypeEnum;
|
|
10
|
+
(function (SpeechTypeEnum) {
|
|
11
|
+
SpeechTypeEnum["textToSpeech"] = "textToSpeech";
|
|
12
|
+
SpeechTypeEnum["speechToText"] = "speechToText";
|
|
13
|
+
})(SpeechTypeEnum || (exports.SpeechTypeEnum = SpeechTypeEnum = {}));
|
|
14
|
+
const SpeechSchema = new mongoose_1.default.Schema({
|
|
15
|
+
userId: {
|
|
16
|
+
type: String,
|
|
17
|
+
required: true,
|
|
18
|
+
},
|
|
19
|
+
speechName: {
|
|
20
|
+
type: String,
|
|
21
|
+
required: true,
|
|
22
|
+
},
|
|
23
|
+
planId: {
|
|
24
|
+
type: mongoose_1.default.Schema.Types.ObjectId,
|
|
25
|
+
ref: 'Plan',
|
|
26
|
+
required: false,
|
|
27
|
+
},
|
|
28
|
+
speech: {
|
|
29
|
+
ai: {
|
|
30
|
+
type: mongoose_1.default.Schema.Types.ObjectId,
|
|
31
|
+
ref: 'Ai',
|
|
32
|
+
},
|
|
33
|
+
type: {
|
|
34
|
+
type: String,
|
|
35
|
+
required: true,
|
|
36
|
+
enum: Object.values(SpeechTypeEnum),
|
|
37
|
+
},
|
|
38
|
+
content: {
|
|
39
|
+
type: String,
|
|
40
|
+
required: true,
|
|
41
|
+
},
|
|
42
|
+
file: {
|
|
43
|
+
type: String,
|
|
44
|
+
required: true,
|
|
45
|
+
},
|
|
46
|
+
createdAt: {
|
|
47
|
+
type: mongoose_1.default.Schema.Types.Date,
|
|
48
|
+
required: true,
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
createdAt: mongoose_1.default.Schema.Types.Date,
|
|
52
|
+
updatedAt: mongoose_1.default.Schema.Types.Date,
|
|
53
|
+
}, {
|
|
54
|
+
timestamps: true,
|
|
55
|
+
});
|
|
56
|
+
SpeechSchema.set('versionKey', 'version');
|
|
57
|
+
SpeechSchema.plugin(mongoose_update_if_current_1.updateIfCurrentPlugin);
|
|
58
|
+
SpeechSchema.statics.build = (attrs) => {
|
|
59
|
+
return new SpeechModel(attrs);
|
|
60
|
+
};
|
|
61
|
+
const SpeechModel = mongoose_1.default.model('Speech', SpeechSchema);
|
|
62
|
+
exports.SpeechModel = SpeechModel;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@common_ch/common",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.46",
|
|
4
4
|
"main": "./build/index.js",
|
|
5
5
|
"types": "./build/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -28,6 +28,8 @@
|
|
|
28
28
|
"express": "^4.21.2",
|
|
29
29
|
"joi": "^17.13.3",
|
|
30
30
|
"jsonwebtoken": "^9.0.2",
|
|
31
|
+
"mongoose": "^8.12.1",
|
|
32
|
+
"mongoose-update-if-current": "^1.4.0",
|
|
31
33
|
"node-nats-streaming": "^0.3.2"
|
|
32
34
|
}
|
|
33
35
|
}
|
|
File without changes
|