@purpleschool/gptbot 0.0.1
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/api/controllers/ai-model.ts +6 -0
- package/api/controllers/auth.ts +9 -0
- package/api/controllers/category.ts +6 -0
- package/api/controllers/chat-private.ts +8 -0
- package/api/controllers/chat-public.ts +8 -0
- package/api/controllers/index.ts +9 -0
- package/api/controllers/page.ts +6 -0
- package/api/controllers/question.ts +5 -0
- package/api/controllers/unregistered-user.ts +1 -0
- package/api/controllers/user.ts +5 -0
- package/api/index.ts +2 -0
- package/api/routes.ts +71 -0
- package/build/api/controllers/ai-model.js +8 -0
- package/build/api/controllers/auth.js +11 -0
- package/build/api/controllers/category.js +8 -0
- package/build/api/controllers/chat-private.js +10 -0
- package/build/api/controllers/chat-public.js +10 -0
- package/build/api/controllers/index.js +25 -0
- package/build/api/controllers/page.js +8 -0
- package/build/api/controllers/question.js +8 -0
- package/build/api/controllers/unregistered-user.js +4 -0
- package/build/api/controllers/user.js +7 -0
- package/build/api/index.js +18 -0
- package/build/api/routes.js +87 -0
- package/build/commands/ai-model/create-ai-model.command.js +16 -0
- package/build/commands/ai-model/delete-ai-model.command.js +14 -0
- package/build/commands/ai-model/find-ai-model.command.js +17 -0
- package/build/commands/ai-model/index.js +20 -0
- package/build/commands/ai-model/update-ai-model.command.js +19 -0
- package/build/commands/auth/create-user.command.js +16 -0
- package/build/commands/auth/index.js +21 -0
- package/build/commands/auth/login.command.js +17 -0
- package/build/commands/auth/register-user.command.js +17 -0
- package/build/commands/auth/reset-paasword.command.js +19 -0
- package/build/commands/auth/restore-password.command.js +16 -0
- package/build/commands/category/create-category.command.js +16 -0
- package/build/commands/category/delete-category.command.js +14 -0
- package/build/commands/category/find-category.command.js +17 -0
- package/build/commands/category/index.js +20 -0
- package/build/commands/category/update-category.command.js +19 -0
- package/build/commands/chat/create-chat.command.js +15 -0
- package/build/commands/chat/delete-chat.command.js +14 -0
- package/build/commands/chat/find-chat.command.js +25 -0
- package/build/commands/chat/get-my-last-active-chat.command.js +11 -0
- package/build/commands/chat/index.js +21 -0
- package/build/commands/chat/update-chat.command.js +19 -0
- package/build/commands/index.js +25 -0
- package/build/commands/message/create-message.command.js +17 -0
- package/build/commands/message/index.js +17 -0
- package/build/commands/page/create-page.command.js +16 -0
- package/build/commands/page/delete-page.command.js +14 -0
- package/build/commands/page/find-page.command.js +17 -0
- package/build/commands/page/index.js +20 -0
- package/build/commands/page/update-page.command.js +19 -0
- package/build/commands/question/create-question.command.js +16 -0
- package/build/commands/question/delete-question.command.js +14 -0
- package/build/commands/question/find-question.command.js +17 -0
- package/build/commands/question/index.js +20 -0
- package/build/commands/question/update-question.command.js +19 -0
- package/build/commands/unregistered-user/create-unregistered-user.command.js +12 -0
- package/build/commands/unregistered-user/index.js +17 -0
- package/build/commands/user/find-user.command.js +14 -0
- package/build/commands/user/index.js +17 -0
- package/build/constants/errors/errors.js +185 -0
- package/build/constants/errors/index.js +18 -0
- package/build/constants/errors/verbose.js +9 -0
- package/build/constants/index.js +18 -0
- package/build/constants/roles/index.js +17 -0
- package/build/constants/roles/role.js +7 -0
- package/build/index.js +17 -0
- package/build/models/ai-model.schema.js +13 -0
- package/build/models/category.schema.js +12 -0
- package/build/models/chat.schema.js +13 -0
- package/build/models/index.js +24 -0
- package/build/models/message.schema.js +13 -0
- package/build/models/page.schema.js +16 -0
- package/build/models/question.schema.js +12 -0
- package/build/models/unregistered-user.schema.js +10 -0
- package/build/models/user.schema.js +16 -0
- package/commands/ai-model/create-ai-model.command.ts +18 -0
- package/commands/ai-model/delete-ai-model.command.ts +15 -0
- package/commands/ai-model/find-ai-model.command.ts +22 -0
- package/commands/ai-model/index.ts +4 -0
- package/commands/ai-model/update-ai-model.command.ts +24 -0
- package/commands/auth/create-user.command.ts +17 -0
- package/commands/auth/index.ts +5 -0
- package/commands/auth/login.command.ts +18 -0
- package/commands/auth/register-user.command.ts +18 -0
- package/commands/auth/reset-paasword.command.ts +20 -0
- package/commands/auth/restore-password.command.ts +16 -0
- package/commands/category/create-category.command.ts +18 -0
- package/commands/category/delete-category.command.ts +15 -0
- package/commands/category/find-category.command.ts +22 -0
- package/commands/category/index.ts +4 -0
- package/commands/category/update-category.command.ts +24 -0
- package/commands/chat/create-chat.command.ts +17 -0
- package/commands/chat/delete-chat.command.ts +15 -0
- package/commands/chat/find-chat.command.ts +31 -0
- package/commands/chat/get-my-last-active-chat.command.ts +10 -0
- package/commands/chat/index.ts +5 -0
- package/commands/chat/update-chat.command.ts +24 -0
- package/commands/index.ts +9 -0
- package/commands/message/create-message.command.ts +20 -0
- package/commands/message/index.ts +1 -0
- package/commands/page/create-page.command.ts +18 -0
- package/commands/page/delete-page.command.ts +15 -0
- package/commands/page/find-page.command.ts +22 -0
- package/commands/page/index.ts +4 -0
- package/commands/page/update-page.command.ts +24 -0
- package/commands/question/create-question.command.ts +18 -0
- package/commands/question/delete-question.command.ts +15 -0
- package/commands/question/find-question.command.ts +22 -0
- package/commands/question/index.ts +4 -0
- package/commands/question/update-question.command.ts +24 -0
- package/commands/unregistered-user/create-unregistered-user.command.ts +10 -0
- package/commands/unregistered-user/index.ts +1 -0
- package/commands/user/find-user.command.ts +16 -0
- package/commands/user/index.ts +1 -0
- package/constants/errors/errors.ts +183 -0
- package/constants/errors/index.ts +2 -0
- package/constants/errors/verbose.ts +7 -0
- package/constants/index.ts +2 -0
- package/constants/roles/index.ts +1 -0
- package/constants/roles/role.ts +7 -0
- package/index.ts +1 -0
- package/models/ai-model.schema.ts +12 -0
- package/models/category.schema.ts +11 -0
- package/models/chat.schema.ts +12 -0
- package/models/index.ts +8 -0
- package/models/message.schema.ts +12 -0
- package/models/page.schema.ts +15 -0
- package/models/question.schema.ts +11 -0
- package/models/unregistered-user.schema.ts +9 -0
- package/models/user.schema.ts +15 -0
- package/package.json +16 -0
- package/tsconfig.json +103 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { MessageSchema } from '../../models';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
export namespace CreateMessageCommand {
|
|
5
|
+
export const RequestSchema = MessageSchema.pick({
|
|
6
|
+
text: true,
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
export const RequestParamSchema = z.object({
|
|
10
|
+
uuid: z.string().uuid(),
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
export type Request = z.infer<typeof RequestSchema>;
|
|
14
|
+
|
|
15
|
+
export const ResponseSchema = z.object({
|
|
16
|
+
data: MessageSchema,
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './create-message.command';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { PageSchema } from '../../models';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
export namespace CreatePageCommand {
|
|
5
|
+
export const RequestSchema = PageSchema.omit({
|
|
6
|
+
uuid: true,
|
|
7
|
+
createdAt: true,
|
|
8
|
+
updatedAt: true,
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
export type Request = z.infer<typeof RequestSchema>;
|
|
12
|
+
|
|
13
|
+
export const ResponseSchema = z.object({
|
|
14
|
+
data: PageSchema,
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { PageSchema } from '../../models';
|
|
3
|
+
|
|
4
|
+
export namespace DeletePageCommand {
|
|
5
|
+
export const RequestSchema = PageSchema.pick({
|
|
6
|
+
uuid: true,
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
export type Request = z.infer<typeof RequestSchema>;
|
|
10
|
+
|
|
11
|
+
export const ResponseSchema = z.object({
|
|
12
|
+
isDeleted: z.boolean(),
|
|
13
|
+
});
|
|
14
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { PageSchema } from '../../models';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
export namespace FindPageCommand {
|
|
5
|
+
export const RequestSchema = PageSchema.pick({
|
|
6
|
+
uuid: true,
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
export type Request = z.infer<typeof RequestSchema>;
|
|
10
|
+
|
|
11
|
+
export const ResponseSchema = z.object({
|
|
12
|
+
data: z.array(PageSchema),
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
16
|
+
|
|
17
|
+
export const ResponseByUUIDSchema = z.object({
|
|
18
|
+
data: PageSchema,
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
export type ResponseByUUID = z.infer<typeof ResponseByUUIDSchema>;
|
|
22
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { PageSchema } from '../../models';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
export namespace UpdatePageCommand {
|
|
5
|
+
export const RequestSchema = PageSchema.omit({
|
|
6
|
+
createdAt: true,
|
|
7
|
+
updatedAt: true,
|
|
8
|
+
uuid: true,
|
|
9
|
+
}).partial();
|
|
10
|
+
|
|
11
|
+
export type Request = z.infer<typeof RequestSchema>;
|
|
12
|
+
|
|
13
|
+
export const RequestParamSchema = z.object({
|
|
14
|
+
uuid: z.string().uuid(),
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
export type RequestParam = z.infer<typeof RequestParamSchema>;
|
|
18
|
+
|
|
19
|
+
export const ResponseSchema = z.object({
|
|
20
|
+
data: PageSchema,
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
24
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { QuestionSchema } from '../../models';
|
|
3
|
+
|
|
4
|
+
export namespace CreateQuestionCommand {
|
|
5
|
+
export const RequestSchema = QuestionSchema.omit({
|
|
6
|
+
uuid: true,
|
|
7
|
+
createdAt: true,
|
|
8
|
+
updatedAt: true,
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
export type Request = z.infer<typeof RequestSchema>;
|
|
12
|
+
|
|
13
|
+
export const ResponseSchema = z.object({
|
|
14
|
+
data: QuestionSchema,
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { QuestionSchema } from '../../models';
|
|
3
|
+
|
|
4
|
+
export namespace DeleteQuestionCommand {
|
|
5
|
+
export const RequestSchema = QuestionSchema.pick({
|
|
6
|
+
uuid: true,
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
export type Request = z.infer<typeof RequestSchema>;
|
|
10
|
+
|
|
11
|
+
export const ResponseSchema = z.object({
|
|
12
|
+
isDeleted: z.boolean(),
|
|
13
|
+
});
|
|
14
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { QuestionSchema } from '../../models';
|
|
3
|
+
|
|
4
|
+
export namespace FindQuestionCommand {
|
|
5
|
+
export const RequestSchema = QuestionSchema.pick({
|
|
6
|
+
uuid: true,
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
export type Request = z.infer<typeof RequestSchema>;
|
|
10
|
+
|
|
11
|
+
export const ResponseSchema = z.object({
|
|
12
|
+
data: z.array(QuestionSchema),
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
16
|
+
|
|
17
|
+
export const ResponseByUUIDSchema = z.object({
|
|
18
|
+
data: QuestionSchema,
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
export type ResponseByUUID = z.infer<typeof ResponseByUUIDSchema>;
|
|
22
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { QuestionSchema } from '../../models';
|
|
3
|
+
|
|
4
|
+
export namespace UpdateQuestionCommand {
|
|
5
|
+
export const RequestSchema = QuestionSchema.omit({
|
|
6
|
+
createdAt: true,
|
|
7
|
+
updatedAt: true,
|
|
8
|
+
uuid: true,
|
|
9
|
+
}).partial();
|
|
10
|
+
|
|
11
|
+
export type Request = z.infer<typeof RequestSchema>;
|
|
12
|
+
|
|
13
|
+
export const RequestParamSchema = z.object({
|
|
14
|
+
uuid: z.string().uuid(),
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
export type RequestParam = z.infer<typeof RequestParamSchema>;
|
|
18
|
+
|
|
19
|
+
export const ResponseSchema = z.object({
|
|
20
|
+
data: QuestionSchema,
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
24
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './create-unregistered-user.command';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { UserSchema } from '../../models';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
export namespace FindUserCommand {
|
|
5
|
+
export const RequestSchema = z.object({
|
|
6
|
+
uuid: z.string().uuid(),
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
export type Request = z.infer<typeof RequestSchema>;
|
|
10
|
+
|
|
11
|
+
export const ResponseSchema = z.object({
|
|
12
|
+
data: UserSchema,
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './find-user.command';
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
export const ERRORS = {
|
|
2
|
+
INTERNAL_SERVER_ERROR: { code: 'A001', message: 'Ошибка севера', httpCode: 500 },
|
|
3
|
+
FORBIDDEN_API: { code: 'C001', message: 'Ошибка авторизации', httpCode: 403 },
|
|
4
|
+
CREATE_USER: {
|
|
5
|
+
code: 'U01',
|
|
6
|
+
message: 'Произошла ошибка при создании пользователя',
|
|
7
|
+
httpCode: 500,
|
|
8
|
+
},
|
|
9
|
+
LOGIN_ERROR: { code: 'U02', message: 'Неверный логин или пароль', httpCode: 401 },
|
|
10
|
+
RESTORE_PASSWORD: {
|
|
11
|
+
code: 'U03',
|
|
12
|
+
message: 'Возникла ошибка при восстановлении пароля',
|
|
13
|
+
httpCode: 401,
|
|
14
|
+
},
|
|
15
|
+
AUTH_INCORRECT_PASSWORD: {
|
|
16
|
+
code: 'U02',
|
|
17
|
+
message: 'Неверный пароль',
|
|
18
|
+
httpCode: 401,
|
|
19
|
+
},
|
|
20
|
+
REGISTER_ERROR: { code: 'U01', message: 'Произошла ошибка при регистрации', httpCode: 500 },
|
|
21
|
+
REGISTER_CONFLICT: { code: 'U04', message: 'Пользователь уже зарегистрирован', httpCode: 409 },
|
|
22
|
+
USER_NOT_FOUND: { code: 'A002', message: 'Пользователь не найден', httpCode: 404 },
|
|
23
|
+
USER_CONFLICT: { code: 'A003', message: 'Пользователь не найден', httpCode: 409 },
|
|
24
|
+
|
|
25
|
+
USER_NOT_CREATED: {
|
|
26
|
+
code: 'A004',
|
|
27
|
+
message: 'Произошла ошибка при создании пользователя',
|
|
28
|
+
httpCode: 500,
|
|
29
|
+
},
|
|
30
|
+
PASSWORD_NOT_RESET: {
|
|
31
|
+
code: 'A005',
|
|
32
|
+
message: 'Произошла ошибка при сбросе пароля',
|
|
33
|
+
httpCode: 500,
|
|
34
|
+
},
|
|
35
|
+
USER_NOT_UPDATED: {
|
|
36
|
+
code: 'A006',
|
|
37
|
+
message: 'Произошла ошибка при обновлении пользователя',
|
|
38
|
+
httpCode: 500,
|
|
39
|
+
},
|
|
40
|
+
USER_NOT_EMAIL: {
|
|
41
|
+
code: 'A007',
|
|
42
|
+
message: 'Произошла ошибка при поиске пользователя по Email',
|
|
43
|
+
httpCode: 500,
|
|
44
|
+
},
|
|
45
|
+
USER_NOT_ID: {
|
|
46
|
+
code: 'A008',
|
|
47
|
+
message: 'Произошла ошибка при поиске пользователя по uuid',
|
|
48
|
+
httpCode: 500,
|
|
49
|
+
},
|
|
50
|
+
PAGE_NOT_FOUND_BY_UUID: {
|
|
51
|
+
code: 'A009',
|
|
52
|
+
message: 'Страница с таким uuid не найдена',
|
|
53
|
+
httpCode: 404,
|
|
54
|
+
},
|
|
55
|
+
PAGE_DELETE_ERROR: { code: 'A010', message: 'Страница не была удалена', httpCode: 500 },
|
|
56
|
+
PAGE_CREATE_ERROR: { code: 'A011', message: 'Страница не была создана', httpCode: 500 },
|
|
57
|
+
PAGE_CREATE_ALIAS_CONFLICT: {
|
|
58
|
+
code: 'A012',
|
|
59
|
+
message: 'alias должен быть уникальный',
|
|
60
|
+
httpCode: 409,
|
|
61
|
+
},
|
|
62
|
+
PAGE_FIND_ERROR: { code: 'A013', message: 'Страница не найдена', httpCode: 404 },
|
|
63
|
+
PAGES_FIND_ERROR: { code: 'A014', message: 'Страницы не найдены', httpCode: 404 },
|
|
64
|
+
PAGE_UPDATE_ERROR: { code: 'A015', message: 'Страница не была обновлена', httpCode: 500 },
|
|
65
|
+
CATEGORY_NOT_FOUND_BY_UUID: {
|
|
66
|
+
code: 'A016',
|
|
67
|
+
message: 'Категория с таким uuid не найдена',
|
|
68
|
+
httpCode: 404,
|
|
69
|
+
},
|
|
70
|
+
CATEGORY_DELETE_ERROR: { code: 'A017', message: 'Категория не была удалена', httpCode: 500 },
|
|
71
|
+
CATEGORY_CREATE_ERROR: { code: 'A018', message: 'Категория не была создана', httpCode: 500 },
|
|
72
|
+
CATEGORY_FIND_ERROR: { code: 'A019', message: 'Категория не найдена', httpCode: 404 },
|
|
73
|
+
CATEGORIES_FIND_ERROR: {
|
|
74
|
+
code: 'A020',
|
|
75
|
+
message: 'Категории не найдены',
|
|
76
|
+
httpCode: 404,
|
|
77
|
+
},
|
|
78
|
+
CATEGORY_UPDATE_ERROR: { code: 'A021', message: 'Страница не была обновлена', httpCode: 500 },
|
|
79
|
+
QUESTION_NOT_FOUND_BY_UUID: {
|
|
80
|
+
code: 'A022',
|
|
81
|
+
message: 'Вопрос с таким uuid не найден',
|
|
82
|
+
httpCode: 404,
|
|
83
|
+
},
|
|
84
|
+
QUESTION_DELETE_ERROR: { code: 'A023', message: 'Вопрос не был удалён', httpCode: 500 },
|
|
85
|
+
QUESTION_CREATE_ERROR: { code: 'A024', message: 'Вопрос не был создан', httpCode: 500 },
|
|
86
|
+
QUESTION_FIND_ERROR: { code: 'A025', message: 'Категория не найдена', httpCode: 404 },
|
|
87
|
+
QUESTIONS_FIND_ERROR: {
|
|
88
|
+
code: 'A026',
|
|
89
|
+
message: 'Вопросы не найдены',
|
|
90
|
+
httpCode: 404,
|
|
91
|
+
},
|
|
92
|
+
QUESTION_UPDATE_ERROR: { code: 'A027', message: 'Вопрос не был обновлен', httpCode: 500 },
|
|
93
|
+
SESSION_CREATE_ERROR: {
|
|
94
|
+
code: 'A028',
|
|
95
|
+
message: 'Недоступно по юридическим причинам',
|
|
96
|
+
httpCode: 451,
|
|
97
|
+
},
|
|
98
|
+
AI_MODULE_DELETE_ERROR: {
|
|
99
|
+
code: 'A029',
|
|
100
|
+
message: 'Модель искусственного интеллекта не была удалена',
|
|
101
|
+
httpCode: 500,
|
|
102
|
+
},
|
|
103
|
+
AI_MODULE_CREATE_ERROR: {
|
|
104
|
+
code: 'A030',
|
|
105
|
+
message: 'Модель искусственного интеллекта не была создана',
|
|
106
|
+
httpCode: 500,
|
|
107
|
+
},
|
|
108
|
+
AI_MODULE_FIND_ERROR: {
|
|
109
|
+
code: 'A031',
|
|
110
|
+
message: 'Модель искусственного интеллекта не найдена',
|
|
111
|
+
httpCode: 404,
|
|
112
|
+
},
|
|
113
|
+
AI_MODULES_FIND_ERROR: {
|
|
114
|
+
code: 'A032',
|
|
115
|
+
message: 'Модели искусственного интеллекта не найдены',
|
|
116
|
+
httpCode: 404,
|
|
117
|
+
},
|
|
118
|
+
AI_MODULE_UPDATE_ERROR: {
|
|
119
|
+
code: 'A033',
|
|
120
|
+
message: 'Модель искусственного интеллекта не была обновлена',
|
|
121
|
+
httpCode: 500,
|
|
122
|
+
},
|
|
123
|
+
AI_MODULE_NOT_FOUND_BY_UUID: {
|
|
124
|
+
code: 'A034',
|
|
125
|
+
message: 'Модель искусственного интеллекта с таким uuid не найдена',
|
|
126
|
+
httpCode: 404,
|
|
127
|
+
},
|
|
128
|
+
CHAT_DELETE_ERROR: {
|
|
129
|
+
code: 'A035',
|
|
130
|
+
message: 'Чат не был удалён',
|
|
131
|
+
httpCode: 500,
|
|
132
|
+
},
|
|
133
|
+
CHAT_CREATE_ERROR: {
|
|
134
|
+
code: 'A036',
|
|
135
|
+
message: 'Чат не был создан',
|
|
136
|
+
httpCode: 500,
|
|
137
|
+
},
|
|
138
|
+
CHAT_FIND_ERROR: {
|
|
139
|
+
code: 'A037',
|
|
140
|
+
message: 'Чат не найден',
|
|
141
|
+
httpCode: 404,
|
|
142
|
+
},
|
|
143
|
+
CHATS_FIND_ERROR: {
|
|
144
|
+
code: 'A038',
|
|
145
|
+
message: 'Чаты не найдены',
|
|
146
|
+
httpCode: 404,
|
|
147
|
+
},
|
|
148
|
+
CHAT_UPDATE_ERROR: {
|
|
149
|
+
code: 'A039',
|
|
150
|
+
message: 'Чат не был обновлен',
|
|
151
|
+
httpCode: 500,
|
|
152
|
+
},
|
|
153
|
+
CHAT_NOT_FOUND_BY_UUID: {
|
|
154
|
+
code: 'A040',
|
|
155
|
+
message: 'Чат с таким uuid не найден',
|
|
156
|
+
httpCode: 404,
|
|
157
|
+
},
|
|
158
|
+
MESSAGE_CREATE_ERROR: {
|
|
159
|
+
code: 'A041',
|
|
160
|
+
message: 'Сообщение не было создано',
|
|
161
|
+
httpCode: 500,
|
|
162
|
+
},
|
|
163
|
+
FORBIDDEN_ROLE_ERROR: {
|
|
164
|
+
code: 'E000',
|
|
165
|
+
message: 'Forbidden',
|
|
166
|
+
httpCode: 403,
|
|
167
|
+
},
|
|
168
|
+
FORBIDDEN_CHAT_LIMIT_ERROR: {
|
|
169
|
+
code: 'E000',
|
|
170
|
+
message: 'Forbidden',
|
|
171
|
+
httpCode: 403,
|
|
172
|
+
},
|
|
173
|
+
FORBIDDEN_MESSAGES_LIMIT_ERROR: {
|
|
174
|
+
code: 'E000',
|
|
175
|
+
message: 'Forbidden',
|
|
176
|
+
httpCode: 403,
|
|
177
|
+
},
|
|
178
|
+
MESSAGE_UPDATE_ERROR: {
|
|
179
|
+
code: 'A042',
|
|
180
|
+
message: 'Сообщение не было создано',
|
|
181
|
+
httpCode: 500,
|
|
182
|
+
},
|
|
183
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './role';
|
package/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './constants';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
export const AiModelSchema = z.object({
|
|
4
|
+
uuid: z.string().uuid(),
|
|
5
|
+
title: z.string(),
|
|
6
|
+
description: z.nullable(z.string()),
|
|
7
|
+
model: z.string(),
|
|
8
|
+
tokenMultiplicator: z.number(),
|
|
9
|
+
|
|
10
|
+
createdAt: z.date(),
|
|
11
|
+
updatedAt: z.date(),
|
|
12
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
export const CategorySchema = z.object({
|
|
4
|
+
uuid: z.string().uuid(),
|
|
5
|
+
mainCategory: z.nullable(z.string().uuid()),
|
|
6
|
+
name: z.string().min(3).max(16384),
|
|
7
|
+
prompt: z.string().min(3).max(16384),
|
|
8
|
+
|
|
9
|
+
createdAt: z.date(),
|
|
10
|
+
updatedAt: z.date(),
|
|
11
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
export const ChatSchema = z.object({
|
|
4
|
+
uuid: z.string().uuid(),
|
|
5
|
+
userId: z.nullable(z.string().uuid()),
|
|
6
|
+
unregisteredUserId: z.nullable(z.string().uuid()),
|
|
7
|
+
categoryId: z.string().uuid(),
|
|
8
|
+
aIModelId: z.string().uuid(),
|
|
9
|
+
|
|
10
|
+
createdAt: z.date(),
|
|
11
|
+
updatedAt: z.date(),
|
|
12
|
+
});
|
package/models/index.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './user.schema';
|
|
2
|
+
export * from './page.schema';
|
|
3
|
+
export * from './category.schema';
|
|
4
|
+
export * from './question.schema';
|
|
5
|
+
export * from './unregistered-user.schema';
|
|
6
|
+
export * from './chat.schema';
|
|
7
|
+
export * from './message.schema';
|
|
8
|
+
export * from './ai-model.schema';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
export const MessageSchema = z.object({
|
|
4
|
+
uuid: z.string().uuid(),
|
|
5
|
+
text: z.string(),
|
|
6
|
+
chatId: z.nullable(z.string().uuid()),
|
|
7
|
+
role: z.string(),
|
|
8
|
+
tokenUsage: z.number(),
|
|
9
|
+
|
|
10
|
+
createdAt: z.date(),
|
|
11
|
+
updatedAt: z.date(),
|
|
12
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
export const PageSchema = z.object({
|
|
4
|
+
uuid: z.string().uuid(),
|
|
5
|
+
metaTitle: z.string().min(3).max(16384),
|
|
6
|
+
metaDescription: z.string().min(3).max(16384),
|
|
7
|
+
title: z.string().min(3).max(16384),
|
|
8
|
+
subTitle: z.string().min(3).max(16384),
|
|
9
|
+
seoTextMd: z.string().min(3).max(16384),
|
|
10
|
+
alias: z.string().min(3).max(16384),
|
|
11
|
+
categoryId: z.string().uuid(),
|
|
12
|
+
|
|
13
|
+
createdAt: z.date(),
|
|
14
|
+
updatedAt: z.date(),
|
|
15
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
export const QuestionSchema = z.object({
|
|
4
|
+
uuid: z.string().uuid(),
|
|
5
|
+
question: z.string().min(3).max(16384),
|
|
6
|
+
answer: z.string().min(3).max(16384),
|
|
7
|
+
pageId: z.string().uuid(),
|
|
8
|
+
|
|
9
|
+
createdAt: z.date(),
|
|
10
|
+
updatedAt: z.date(),
|
|
11
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
export const UserSchema = z.object({
|
|
4
|
+
uuid: z.string().uuid(),
|
|
5
|
+
email: z.string().email(),
|
|
6
|
+
ip: z.string(),
|
|
7
|
+
password: z.string(),
|
|
8
|
+
passwordHash: z.string(),
|
|
9
|
+
restoreTokenHash: z.string(),
|
|
10
|
+
tokenBonusBalance: z.string(),
|
|
11
|
+
role: z.string(),
|
|
12
|
+
|
|
13
|
+
createdAt: z.date(),
|
|
14
|
+
updatedAt: z.date(),
|
|
15
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@purpleschool/gptbot",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"prepublish": "rm -rf build && tsc",
|
|
8
|
+
"build": "tsc"
|
|
9
|
+
},
|
|
10
|
+
"keywords": [],
|
|
11
|
+
"author": "",
|
|
12
|
+
"license": "ISC",
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"zod": "^3.22.4"
|
|
15
|
+
}
|
|
16
|
+
}
|