@purpleschool/gptbot 0.4.2 → 0.5.0

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 (59) hide show
  1. package/api/controllers/chat-private.ts +1 -0
  2. package/api/controllers/chat-public.ts +1 -0
  3. package/api/controllers/index.ts +1 -0
  4. package/api/controllers/message.ts +2 -0
  5. package/build/api/controllers/chat-private.js +1 -0
  6. package/build/api/controllers/chat-public.js +1 -0
  7. package/build/api/controllers/index.js +1 -0
  8. package/build/api/controllers/message.js +5 -0
  9. package/build/commands/chat/archive-all.command.js +12 -0
  10. package/build/commands/chat/check-limit.command.v2.js +12 -0
  11. package/build/commands/chat/create-chat.command.v2.js +17 -0
  12. package/build/commands/chat/delete-chat.command.v2.js +14 -0
  13. package/build/commands/chat/find-chat-by-uuid.command.js +14 -0
  14. package/build/commands/chat/find-chats.command.js +26 -0
  15. package/build/commands/chat/get-my-last-active-chat-command.v2.js +17 -0
  16. package/build/commands/chat/index.js +6 -0
  17. package/build/commands/message/create-image-message.command.js +18 -0
  18. package/build/commands/message/create-text-message.command.js +17 -0
  19. package/build/commands/message/index.js +3 -0
  20. package/build/commands/message/rate-message.command.js +17 -0
  21. package/build/commands/payment/pay.command.js +2 -2
  22. package/build/constants/ai-model/enums/ai-model-content-type.enum.js +7 -0
  23. package/build/constants/ai-model/enums/index.js +17 -0
  24. package/build/constants/ai-model/index.js +17 -0
  25. package/build/constants/chat/enums/dalle-image-size.enum.js +9 -0
  26. package/build/constants/chat/enums/index.js +1 -0
  27. package/build/constants/errors/errors.js +50 -5
  28. package/build/constants/index.js +2 -0
  29. package/build/constants/message/enums/index.js +17 -0
  30. package/build/constants/message/enums/user-reaction.enum.js +7 -0
  31. package/build/constants/message/index.js +17 -0
  32. package/build/models/ai-model.schema.js +2 -0
  33. package/build/models/message.schema.js +2 -0
  34. package/commands/chat/archive-all.command.ts +11 -0
  35. package/commands/chat/check-limit.command.v2.ts +10 -0
  36. package/commands/chat/create-chat.command.v2.ts +19 -0
  37. package/commands/chat/delete-chat.command.v2.ts +15 -0
  38. package/commands/chat/find-chat-by-uuid.command.ts +16 -0
  39. package/commands/chat/find-chats.command.ts +38 -0
  40. package/commands/chat/get-my-last-active-chat-command.v2.ts +20 -0
  41. package/commands/chat/index.ts +6 -0
  42. package/commands/message/create-image-message.command.ts +24 -0
  43. package/commands/message/create-text-message.command.ts +20 -0
  44. package/commands/message/index.ts +3 -0
  45. package/commands/message/rate-message.command.ts +20 -0
  46. package/commands/payment/pay.command.ts +2 -2
  47. package/constants/ai-model/enums/ai-model-content-type.enum.ts +7 -0
  48. package/constants/ai-model/enums/index.ts +1 -0
  49. package/constants/ai-model/index.ts +1 -0
  50. package/constants/chat/enums/dalle-image-size.enum.ts +5 -0
  51. package/constants/chat/enums/index.ts +1 -0
  52. package/constants/errors/errors.ts +50 -5
  53. package/constants/index.ts +2 -0
  54. package/constants/message/enums/index.ts +1 -0
  55. package/constants/message/enums/user-reaction.enum.ts +6 -0
  56. package/constants/message/index.ts +1 -0
  57. package/models/ai-model.schema.ts +2 -1
  58. package/models/message.schema.ts +2 -0
  59. package/package.json +1 -1
@@ -8,4 +8,5 @@ export const CHAT_PRIVATE_ROUTES = {
8
8
  GET_LIMIT: 'limits',
9
9
  CREATE_MESSAGE: (uuid: string) => `my/${uuid}/send`,
10
10
  ARCHIVE: 'archive',
11
+ FIND_MANY: 'find',
11
12
  } as const;
@@ -5,4 +5,5 @@ export const CHAT_PUBLIC_ROUTES = {
5
5
  GET_MY: 'get/my',
6
6
  CREATE_MESSAGE: (uuid: string) => `my/${uuid}/send`,
7
7
  CHECK_LIMIT: 'limits',
8
+ GET_LAST_ACTIVE_CHAT: `last-active-chat`,
8
9
  } as const;
@@ -11,3 +11,4 @@ export * from './product';
11
11
  export * from './subscription';
12
12
  export * from './files';
13
13
  export * from './blog';
14
+ export * from './message';
@@ -0,0 +1,2 @@
1
+ export const MESSAGE_CONTROLLER_PRIVATE = 'private/message' as const;
2
+ export const MESSAGE_CONTROLLER_PUBLIC = 'public/message' as const;
@@ -10,4 +10,5 @@ exports.CHAT_PRIVATE_ROUTES = {
10
10
  GET_LIMIT: 'limits',
11
11
  CREATE_MESSAGE: (uuid) => `my/${uuid}/send`,
12
12
  ARCHIVE: 'archive',
13
+ FIND_MANY: 'find',
13
14
  };
@@ -8,4 +8,5 @@ exports.CHAT_PUBLIC_ROUTES = {
8
8
  GET_MY: 'get/my',
9
9
  CREATE_MESSAGE: (uuid) => `my/${uuid}/send`,
10
10
  CHECK_LIMIT: 'limits',
11
+ GET_LAST_ACTIVE_CHAT: `last-active-chat`,
11
12
  };
@@ -27,3 +27,4 @@ __exportStar(require("./product"), exports);
27
27
  __exportStar(require("./subscription"), exports);
28
28
  __exportStar(require("./files"), exports);
29
29
  __exportStar(require("./blog"), exports);
30
+ __exportStar(require("./message"), exports);
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MESSAGE_CONTROLLER_PUBLIC = exports.MESSAGE_CONTROLLER_PRIVATE = void 0;
4
+ exports.MESSAGE_CONTROLLER_PRIVATE = 'private/message';
5
+ exports.MESSAGE_CONTROLLER_PUBLIC = 'public/message';
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ArchiveAllCommand = void 0;
4
+ const zod_1 = require("zod");
5
+ var ArchiveAllCommand;
6
+ (function (ArchiveAllCommand) {
7
+ ArchiveAllCommand.ResponseSchema = zod_1.z.object({
8
+ data: zod_1.z.object({
9
+ isArchived: zod_1.z.boolean(),
10
+ }),
11
+ });
12
+ })(ArchiveAllCommand || (exports.ArchiveAllCommand = ArchiveAllCommand = {}));
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CheckLimitV2Command = void 0;
4
+ const zod_1 = require("zod");
5
+ var CheckLimitV2Command;
6
+ (function (CheckLimitV2Command) {
7
+ CheckLimitV2Command.ResponseSchema = zod_1.z.object({
8
+ data: zod_1.z.object({
9
+ totalTokenBalance: zod_1.z.number(),
10
+ }),
11
+ });
12
+ })(CheckLimitV2Command || (exports.CheckLimitV2Command = CheckLimitV2Command = {}));
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CreateChatV2Command = void 0;
4
+ const models_1 = require("../../models");
5
+ const zod_1 = require("zod");
6
+ var CreateChatV2Command;
7
+ (function (CreateChatV2Command) {
8
+ CreateChatV2Command.RequestSchema = models_1.ChatSchema.pick({
9
+ aIModelId: true,
10
+ categoryId: true,
11
+ });
12
+ CreateChatV2Command.ResponseSchema = zod_1.z.object({
13
+ data: models_1.ChatSchema.extend({
14
+ messages: zod_1.z.array(models_1.MessageSchema),
15
+ }),
16
+ });
17
+ })(CreateChatV2Command || (exports.CreateChatV2Command = CreateChatV2Command = {}));
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DeleteChatV2Command = void 0;
4
+ const zod_1 = require("zod");
5
+ const models_1 = require("../../models");
6
+ var DeleteChatV2Command;
7
+ (function (DeleteChatV2Command) {
8
+ DeleteChatV2Command.RequestSchema = models_1.ChatSchema.pick({
9
+ uuid: true,
10
+ });
11
+ DeleteChatV2Command.ResponseSchema = zod_1.z.object({
12
+ isDeleted: zod_1.z.boolean(),
13
+ });
14
+ })(DeleteChatV2Command || (exports.DeleteChatV2Command = DeleteChatV2Command = {}));
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FindChatByUUIDCommand = void 0;
4
+ const models_1 = require("../../models");
5
+ const zod_1 = require("zod");
6
+ var FindChatByUUIDCommand;
7
+ (function (FindChatByUUIDCommand) {
8
+ FindChatByUUIDCommand.RequestByParamSchema = models_1.ChatSchema.pick({
9
+ uuid: true,
10
+ });
11
+ FindChatByUUIDCommand.ResponseSchema = zod_1.z.object({
12
+ data: models_1.ChatSchema,
13
+ });
14
+ })(FindChatByUUIDCommand || (exports.FindChatByUUIDCommand = FindChatByUUIDCommand = {}));
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FindChatsCommand = void 0;
4
+ const models_1 = require("../../models");
5
+ const zod_1 = require("zod");
6
+ var FindChatsCommand;
7
+ (function (FindChatsCommand) {
8
+ const PaginationQuerySchema = zod_1.z.object({
9
+ limit: zod_1.z.string().regex(/^\d+$/, { message: 'Limit должен быть числом' }).transform(Number),
10
+ offset: zod_1.z
11
+ .string()
12
+ .regex(/^\d+$/, { message: 'Offset должен быть числом' })
13
+ .transform(Number),
14
+ });
15
+ const QuerySchema = zod_1.z.intersection(models_1.ChatSchema.pick({ categoryId: true, aIModelId: true }).partial(), models_1.AiModelSchema.pick({ contentType: true }).partial());
16
+ FindChatsCommand.RequestByQuerySchema = zod_1.z.intersection(QuerySchema, PaginationQuerySchema);
17
+ FindChatsCommand.ResponseSchema = zod_1.z.object({
18
+ data: zod_1.z.array(models_1.ChatSchema.extend({
19
+ messages: zod_1.z.array(models_1.MessageSchema),
20
+ })),
21
+ count: zod_1.z.number(),
22
+ });
23
+ FindChatsCommand.ResponseByUUIDSchema = zod_1.z.object({
24
+ data: models_1.ChatSchema,
25
+ });
26
+ })(FindChatsCommand || (exports.FindChatsCommand = FindChatsCommand = {}));
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GetLastActiveChatV2Command = void 0;
4
+ const models_1 = require("../../models");
5
+ const zod_1 = require("zod");
6
+ var GetLastActiveChatV2Command;
7
+ (function (GetLastActiveChatV2Command) {
8
+ GetLastActiveChatV2Command.RequestQuerySchema = zod_1.z.intersection(models_1.ChatSchema.pick({
9
+ categoryId: true,
10
+ aIModelId: true,
11
+ }).partial(), models_1.AiModelSchema.pick({ contentType: true }).partial());
12
+ GetLastActiveChatV2Command.Response = zod_1.z.object({
13
+ data: models_1.ChatSchema.extend({
14
+ messages: zod_1.z.array(models_1.MessageSchema),
15
+ }),
16
+ });
17
+ })(GetLastActiveChatV2Command || (exports.GetLastActiveChatV2Command = GetLastActiveChatV2Command = {}));
@@ -20,3 +20,9 @@ __exportStar(require("./create-chat.command"), exports);
20
20
  __exportStar(require("./find-chat.command"), exports);
21
21
  __exportStar(require("./get-my-last-active-chat.command"), exports);
22
22
  __exportStar(require("./check-limit.command"), exports);
23
+ __exportStar(require("./check-limit.command.v2"), exports);
24
+ __exportStar(require("./get-my-last-active-chat-command.v2"), exports);
25
+ __exportStar(require("./create-chat.command.v2"), exports);
26
+ __exportStar(require("./find-chat-by-uuid.command"), exports);
27
+ __exportStar(require("./archive-all.command"), exports);
28
+ __exportStar(require("./delete-chat.command.v2"), exports);
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CreateImageMessageCommand = void 0;
4
+ const models_1 = require("../../models");
5
+ const zod_1 = require("zod");
6
+ const constants_1 = require("../../constants");
7
+ var CreateImageMessageCommand;
8
+ (function (CreateImageMessageCommand) {
9
+ CreateImageMessageCommand.RequestSchema = zod_1.z.intersection(models_1.MessageSchema.pick({ text: true }), zod_1.z.object({
10
+ size: zod_1.z.nativeEnum(constants_1.DALLE_IMAGE_SIZE),
11
+ }));
12
+ CreateImageMessageCommand.RequestParamSchema = models_1.ChatSchema.pick({
13
+ uuid: true,
14
+ });
15
+ CreateImageMessageCommand.ResponseSchema = zod_1.z.object({
16
+ data: models_1.MessageSchema,
17
+ });
18
+ })(CreateImageMessageCommand || (exports.CreateImageMessageCommand = CreateImageMessageCommand = {}));
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CreateTextMessageCommand = void 0;
4
+ const models_1 = require("../../models");
5
+ const zod_1 = require("zod");
6
+ var CreateTextMessageCommand;
7
+ (function (CreateTextMessageCommand) {
8
+ CreateTextMessageCommand.RequestSchema = models_1.MessageSchema.pick({
9
+ text: true,
10
+ });
11
+ CreateTextMessageCommand.RequestParamSchema = models_1.ChatSchema.pick({
12
+ uuid: true,
13
+ });
14
+ CreateTextMessageCommand.ResponseSchema = zod_1.z.object({
15
+ data: models_1.MessageSchema,
16
+ });
17
+ })(CreateTextMessageCommand || (exports.CreateTextMessageCommand = CreateTextMessageCommand = {}));
@@ -15,3 +15,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./create-message.command"), exports);
18
+ __exportStar(require("./create-text-message.command"), exports);
19
+ __exportStar(require("./create-image-message.command"), exports);
20
+ __exportStar(require("./rate-message.command"), exports);
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RateMessageCommand = void 0;
4
+ const models_1 = require("../../models");
5
+ const zod_1 = require("zod");
6
+ var RateMessageCommand;
7
+ (function (RateMessageCommand) {
8
+ RateMessageCommand.RequestSchema = models_1.MessageSchema.pick({
9
+ userReaction: true,
10
+ });
11
+ RateMessageCommand.RequestParamSchema = models_1.MessageSchema.pick({
12
+ uuid: true,
13
+ });
14
+ RateMessageCommand.ResponseSchema = zod_1.z.object({
15
+ data: models_1.MessageSchema,
16
+ });
17
+ })(RateMessageCommand || (exports.RateMessageCommand = RateMessageCommand = {}));
@@ -14,13 +14,13 @@ var PayCommand;
14
14
  DateTime: zod_1.z.string(),
15
15
  CardFirstSix: zod_1.z.string(),
16
16
  CardLastFour: zod_1.z.string(),
17
- SubscriptionId: zod_1.z.string(),
17
+ SubscriptionId: zod_1.z.string().optional(),
18
18
  CardType: zod_1.z.string(),
19
19
  CardExpDate: zod_1.z.string(),
20
20
  TestMode: zod_1.z.string().transform((testMode) => parseInt(testMode, 10)),
21
21
  Status: zod_1.z.string(),
22
22
  OperationType: zod_1.z.string(),
23
- InvoiceId: zod_1.z.string(),
23
+ InvoiceId: zod_1.z.string().optional(),
24
24
  AccountId: zod_1.z.string(),
25
25
  })
26
26
  .transform((data) => ({
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AI_MODEL_CONTENT_TYPE = void 0;
4
+ exports.AI_MODEL_CONTENT_TYPE = {
5
+ TEXT: 'TEXT',
6
+ IMAGE: 'IMAGE',
7
+ };
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./ai-model-content-type.enum"), exports);
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./enums"), exports);
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DALLE_IMAGE_SIZE = void 0;
4
+ var DALLE_IMAGE_SIZE;
5
+ (function (DALLE_IMAGE_SIZE) {
6
+ DALLE_IMAGE_SIZE["_1024x1024"] = "1024x1024";
7
+ DALLE_IMAGE_SIZE["_1024x1792"] = "1024x1792";
8
+ DALLE_IMAGE_SIZE["_1792x1024"] = "1792x1024";
9
+ })(DALLE_IMAGE_SIZE || (exports.DALLE_IMAGE_SIZE = DALLE_IMAGE_SIZE = {}));
@@ -15,3 +15,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./chat-status.enum"), exports);
18
+ __exportStar(require("./dalle-image-size.enum"), exports);
@@ -244,6 +244,11 @@ exports.ERRORS = {
244
244
  message: 'Заказ с таким uuid не найден',
245
245
  httpCode: 404,
246
246
  },
247
+ ORDER_NOT_FOUND: {
248
+ code: 'A152',
249
+ message: 'Заказ не найден',
250
+ httpCode: 404,
251
+ },
247
252
  ORDER_DELETE_ERROR: { code: 'A057', message: 'Заказ не был удален', httpCode: 500 },
248
253
  ORDER_CREATE_ERROR: { code: 'A058', message: 'Заказ не был создан', httpCode: 500 },
249
254
  ORDER_FIND_ERROR: { code: 'A059', message: 'Заказ не найден', httpCode: 404 },
@@ -415,11 +420,6 @@ exports.ERRORS = {
415
420
  message: 'Не удалось получить количество сообщений',
416
421
  httpCode: 500,
417
422
  },
418
- VERIFY_EMAIL: {
419
- code: 'A097',
420
- message: 'Не удалось подтвердить почту',
421
- httpCode: 500,
422
- },
423
423
  VALIDATE_EMAIL_ERROR: {
424
424
  code: 'A098',
425
425
  message: 'Не удалось валидировать почту',
@@ -435,4 +435,49 @@ exports.ERRORS = {
435
435
  message: 'Не удалось закрыть подписку',
436
436
  httpCode: 500,
437
437
  },
438
+ SEND_EMAIL: {
439
+ code: 'A101',
440
+ message: 'Не удалось отправить email',
441
+ httpCode: 500,
442
+ },
443
+ VERIFY_EMAIL: {
444
+ code: 'A102',
445
+ message: 'Не удалось подтвердить почту',
446
+ httpCode: 500,
447
+ },
448
+ CHAT_CHECK_LIMIT: {
449
+ code: 'A103',
450
+ message: 'Не удалось проверить баланс для доступа к чату',
451
+ httpCode: 500,
452
+ },
453
+ CHAT_OWNERSHIP_ERROR: {
454
+ code: 'A104',
455
+ message: 'Вы не являетесь владельцем чата',
456
+ httpCode: 403,
457
+ },
458
+ CHAT_INCORRECT_CONTENT_TYPE: {
459
+ code: 'A105',
460
+ message: 'Чат не поддерживает данный тип контента',
461
+ httpCode: 400,
462
+ },
463
+ MESSAGE_REACTION_ERROR: {
464
+ code: 'A106',
465
+ message: 'Произошла ошибка при оценке сообщения',
466
+ httpCode: 500,
467
+ },
468
+ MESSAGE_NOT_FOUND: {
469
+ code: 'A107',
470
+ message: 'Сообщение не найдено',
471
+ httpCode: 404,
472
+ },
473
+ MESSAGE_INVALID_TYPE: {
474
+ code: 'A108',
475
+ message: 'Неверный тип сообщения',
476
+ httpCode: 400,
477
+ },
478
+ INSUFFICIENT_BALANCE: {
479
+ code: 'A109',
480
+ message: 'Недосточный баланс',
481
+ httpCode: 403,
482
+ },
438
483
  };
@@ -22,3 +22,5 @@ __exportStar(require("./chat"), exports);
22
22
  __exportStar(require("./subscription"), exports);
23
23
  __exportStar(require("./product"), exports);
24
24
  __exportStar(require("./category"), exports);
25
+ __exportStar(require("./ai-model"), exports);
26
+ __exportStar(require("./message"), exports);
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./user-reaction.enum"), exports);
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.USER_REACTION = void 0;
4
+ exports.USER_REACTION = {
5
+ LIKED: 'LIKED',
6
+ DISLIKED: 'DISLIKED',
7
+ };
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./enums"), exports);
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AiModelSchema = void 0;
4
4
  const zod_1 = require("zod");
5
+ const constants_1 = require("../constants");
5
6
  exports.AiModelSchema = zod_1.z.object({
6
7
  uuid: zod_1.z.string().uuid(),
7
8
  title: zod_1.z.string(),
@@ -11,6 +12,7 @@ exports.AiModelSchema = zod_1.z.object({
11
12
  tokenMultiplicator: zod_1.z.number(),
12
13
  order: zod_1.z.number(),
13
14
  canUse: zod_1.z.optional(zod_1.z.boolean()),
15
+ contentType: zod_1.z.enum(Object.values(constants_1.AI_MODEL_CONTENT_TYPE)),
14
16
  createdAt: zod_1.z.date(),
15
17
  updatedAt: zod_1.z.date(),
16
18
  });
@@ -2,12 +2,14 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MessageSchema = void 0;
4
4
  const zod_1 = require("zod");
5
+ const constants_1 = require("../constants");
5
6
  exports.MessageSchema = zod_1.z.object({
6
7
  uuid: zod_1.z.string().uuid(),
7
8
  text: zod_1.z.string(),
8
9
  chatId: zod_1.z.nullable(zod_1.z.string().uuid()),
9
10
  role: zod_1.z.string(),
10
11
  tokenUsage: zod_1.z.number(),
12
+ userReaction: zod_1.z.nullable(zod_1.z.enum(Object.values(constants_1.USER_REACTION))),
11
13
  createdAt: zod_1.z.date(),
12
14
  updatedAt: zod_1.z.date(),
13
15
  });
@@ -0,0 +1,11 @@
1
+ import { z } from 'zod';
2
+
3
+ export namespace ArchiveAllCommand {
4
+ export const ResponseSchema = z.object({
5
+ data: z.object({
6
+ isArchived: z.boolean(),
7
+ }),
8
+ });
9
+
10
+ export type Response = z.infer<typeof ResponseSchema>;
11
+ }
@@ -0,0 +1,10 @@
1
+ import { z } from 'zod';
2
+
3
+ export namespace CheckLimitV2Command {
4
+ export const ResponseSchema = z.object({
5
+ data: z.object({
6
+ totalTokenBalance: z.number(),
7
+ }),
8
+ });
9
+ export type Response = z.infer<typeof ResponseSchema>;
10
+ }
@@ -0,0 +1,19 @@
1
+ import { ChatSchema, MessageSchema } from '../../models';
2
+ import { z } from 'zod';
3
+
4
+ export namespace CreateChatV2Command {
5
+ export const RequestSchema = ChatSchema.pick({
6
+ aIModelId: true,
7
+ categoryId: true,
8
+ });
9
+
10
+ export type RequestSchema = z.infer<typeof RequestSchema>;
11
+
12
+ export const ResponseSchema = z.object({
13
+ data: ChatSchema.extend({
14
+ messages: z.array(MessageSchema),
15
+ }),
16
+ });
17
+
18
+ export type Response = z.infer<typeof ResponseSchema>;
19
+ }
@@ -0,0 +1,15 @@
1
+ import { z } from 'zod';
2
+ import { ChatSchema } from '../../models';
3
+
4
+ export namespace DeleteChatV2Command {
5
+ export const RequestSchema = ChatSchema.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,16 @@
1
+ import { ChatSchema } from '../../models';
2
+ import { z } from 'zod';
3
+
4
+ export namespace FindChatByUUIDCommand {
5
+ export const RequestByParamSchema = ChatSchema.pick({
6
+ uuid: true,
7
+ });
8
+
9
+ export type Request = z.infer<typeof RequestByParamSchema>;
10
+
11
+ export const ResponseSchema = z.object({
12
+ data: ChatSchema,
13
+ });
14
+
15
+ export type Response = z.infer<typeof ResponseSchema>;
16
+ }
@@ -0,0 +1,38 @@
1
+ import { AiModelSchema, ChatSchema, MessageSchema } from '../../models';
2
+ import { z } from 'zod';
3
+
4
+ export namespace FindChatsCommand {
5
+ const PaginationQuerySchema = z.object({
6
+ limit: z.string().regex(/^\d+$/, { message: 'Limit должен быть числом' }).transform(Number),
7
+ offset: z
8
+ .string()
9
+ .regex(/^\d+$/, { message: 'Offset должен быть числом' })
10
+ .transform(Number),
11
+ });
12
+
13
+ const QuerySchema = z.intersection(
14
+ ChatSchema.pick({ categoryId: true, aIModelId: true }).partial(),
15
+ AiModelSchema.pick({ contentType: true }).partial(),
16
+ );
17
+
18
+ export const RequestByQuerySchema = z.intersection(QuerySchema, PaginationQuerySchema);
19
+
20
+ export type RequestByQuery = z.infer<typeof RequestByQuerySchema>;
21
+
22
+ export const ResponseSchema = z.object({
23
+ data: z.array(
24
+ ChatSchema.extend({
25
+ messages: z.array(MessageSchema),
26
+ }),
27
+ ),
28
+ count: z.number(),
29
+ });
30
+
31
+ export type Response = z.infer<typeof ResponseSchema>;
32
+
33
+ export const ResponseByUUIDSchema = z.object({
34
+ data: ChatSchema,
35
+ });
36
+
37
+ export type ResponseByUUID = z.infer<typeof ResponseByUUIDSchema>;
38
+ }
@@ -0,0 +1,20 @@
1
+ import { AiModelSchema, ChatSchema, MessageSchema } from '../../models';
2
+ import { z } from 'zod';
3
+
4
+ export namespace GetLastActiveChatV2Command {
5
+ export const RequestQuerySchema = z.intersection(
6
+ ChatSchema.pick({
7
+ categoryId: true,
8
+ aIModelId: true,
9
+ }).partial(),
10
+ AiModelSchema.pick({ contentType: true }).partial(),
11
+ );
12
+
13
+ export const Response = z.object({
14
+ data: ChatSchema.extend({
15
+ messages: z.array(MessageSchema),
16
+ }),
17
+ });
18
+
19
+ export type Response = z.infer<typeof Response>;
20
+ }
@@ -4,3 +4,9 @@ export * from './create-chat.command';
4
4
  export * from './find-chat.command';
5
5
  export * from './get-my-last-active-chat.command';
6
6
  export * from './check-limit.command';
7
+ export * from './check-limit.command.v2';
8
+ export * from './get-my-last-active-chat-command.v2';
9
+ export * from './create-chat.command.v2';
10
+ export * from './find-chat-by-uuid.command';
11
+ export * from './archive-all.command';
12
+ export * from './delete-chat.command.v2';
@@ -0,0 +1,24 @@
1
+ import { ChatSchema, MessageSchema } from '../../models';
2
+ import { z } from 'zod';
3
+ import { DALLE_IMAGE_SIZE } from '../../constants';
4
+
5
+ export namespace CreateImageMessageCommand {
6
+ export const RequestSchema = z.intersection(
7
+ MessageSchema.pick({ text: true }),
8
+ z.object({
9
+ size: z.nativeEnum(DALLE_IMAGE_SIZE),
10
+ }),
11
+ );
12
+
13
+ export const RequestParamSchema = ChatSchema.pick({
14
+ uuid: true,
15
+ });
16
+
17
+ export type Request = z.infer<typeof RequestSchema>;
18
+
19
+ export const ResponseSchema = z.object({
20
+ data: MessageSchema,
21
+ });
22
+
23
+ export type Response = z.infer<typeof ResponseSchema>;
24
+ }
@@ -0,0 +1,20 @@
1
+ import { ChatSchema, MessageSchema } from '../../models';
2
+ import { z } from 'zod';
3
+
4
+ export namespace CreateTextMessageCommand {
5
+ export const RequestSchema = MessageSchema.pick({
6
+ text: true,
7
+ });
8
+
9
+ export const RequestParamSchema = ChatSchema.pick({
10
+ uuid: true,
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
+ }
@@ -1 +1,4 @@
1
1
  export * from './create-message.command';
2
+ export * from './create-text-message.command';
3
+ export * from './create-image-message.command';
4
+ export * from './rate-message.command';
@@ -0,0 +1,20 @@
1
+ import { MessageSchema } from '../../models';
2
+ import { z } from 'zod';
3
+
4
+ export namespace RateMessageCommand {
5
+ export const RequestSchema = MessageSchema.pick({
6
+ userReaction: true,
7
+ });
8
+
9
+ export const RequestParamSchema = MessageSchema.pick({
10
+ uuid: true,
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
+ }
@@ -11,13 +11,13 @@ export namespace PayCommand {
11
11
  DateTime: z.string(),
12
12
  CardFirstSix: z.string(),
13
13
  CardLastFour: z.string(),
14
- SubscriptionId: z.string(),
14
+ SubscriptionId: z.string().optional(),
15
15
  CardType: z.string(),
16
16
  CardExpDate: z.string(),
17
17
  TestMode: z.string().transform((testMode) => parseInt(testMode, 10)),
18
18
  Status: z.string(),
19
19
  OperationType: z.string(),
20
- InvoiceId: z.string(),
20
+ InvoiceId: z.string().optional(),
21
21
  AccountId: z.string(),
22
22
  })
23
23
  .transform((data) => ({
@@ -0,0 +1,7 @@
1
+ export const AI_MODEL_CONTENT_TYPE = {
2
+ TEXT: 'TEXT',
3
+ IMAGE: 'IMAGE',
4
+ } as const;
5
+
6
+ export type TAIModelContentTypeEnum =
7
+ (typeof AI_MODEL_CONTENT_TYPE)[keyof typeof AI_MODEL_CONTENT_TYPE];
@@ -0,0 +1 @@
1
+ export * from './ai-model-content-type.enum';
@@ -0,0 +1 @@
1
+ export * from './enums';
@@ -0,0 +1,5 @@
1
+ export enum DALLE_IMAGE_SIZE {
2
+ _1024x1024 = '1024x1024',
3
+ _1024x1792 = '1024x1792',
4
+ _1792x1024 = '1792x1024',
5
+ }
@@ -1 +1,2 @@
1
1
  export * from './chat-status.enum';
2
+ export * from './dalle-image-size.enum';
@@ -243,6 +243,11 @@ export const ERRORS = {
243
243
  message: 'Заказ с таким uuid не найден',
244
244
  httpCode: 404,
245
245
  },
246
+ ORDER_NOT_FOUND: {
247
+ code: 'A152',
248
+ message: 'Заказ не найден',
249
+ httpCode: 404,
250
+ },
246
251
  ORDER_DELETE_ERROR: { code: 'A057', message: 'Заказ не был удален', httpCode: 500 },
247
252
  ORDER_CREATE_ERROR: { code: 'A058', message: 'Заказ не был создан', httpCode: 500 },
248
253
  ORDER_FIND_ERROR: { code: 'A059', message: 'Заказ не найден', httpCode: 404 },
@@ -414,11 +419,6 @@ export const ERRORS = {
414
419
  message: 'Не удалось получить количество сообщений',
415
420
  httpCode: 500,
416
421
  },
417
- VERIFY_EMAIL: {
418
- code: 'A097',
419
- message: 'Не удалось подтвердить почту',
420
- httpCode: 500,
421
- },
422
422
  VALIDATE_EMAIL_ERROR: {
423
423
  code: 'A098',
424
424
  message: 'Не удалось валидировать почту',
@@ -434,4 +434,49 @@ export const ERRORS = {
434
434
  message: 'Не удалось закрыть подписку',
435
435
  httpCode: 500,
436
436
  },
437
+ SEND_EMAIL: {
438
+ code: 'A101',
439
+ message: 'Не удалось отправить email',
440
+ httpCode: 500,
441
+ },
442
+ VERIFY_EMAIL: {
443
+ code: 'A102',
444
+ message: 'Не удалось подтвердить почту',
445
+ httpCode: 500,
446
+ },
447
+ CHAT_CHECK_LIMIT: {
448
+ code: 'A103',
449
+ message: 'Не удалось проверить баланс для доступа к чату',
450
+ httpCode: 500,
451
+ },
452
+ CHAT_OWNERSHIP_ERROR: {
453
+ code: 'A104',
454
+ message: 'Вы не являетесь владельцем чата',
455
+ httpCode: 403,
456
+ },
457
+ CHAT_INCORRECT_CONTENT_TYPE: {
458
+ code: 'A105',
459
+ message: 'Чат не поддерживает данный тип контента',
460
+ httpCode: 400,
461
+ },
462
+ MESSAGE_REACTION_ERROR: {
463
+ code: 'A106',
464
+ message: 'Произошла ошибка при оценке сообщения',
465
+ httpCode: 500,
466
+ },
467
+ MESSAGE_NOT_FOUND: {
468
+ code: 'A107',
469
+ message: 'Сообщение не найдено',
470
+ httpCode: 404,
471
+ },
472
+ MESSAGE_INVALID_TYPE: {
473
+ code: 'A108',
474
+ message: 'Неверный тип сообщения',
475
+ httpCode: 400,
476
+ },
477
+ INSUFFICIENT_BALANCE: {
478
+ code: 'A109',
479
+ message: 'Недосточный баланс',
480
+ httpCode: 403,
481
+ },
437
482
  };
@@ -6,3 +6,5 @@ export * from './chat';
6
6
  export * from './subscription';
7
7
  export * from './product';
8
8
  export * from './category';
9
+ export * from './ai-model';
10
+ export * from './message';
@@ -0,0 +1 @@
1
+ export * from './user-reaction.enum';
@@ -0,0 +1,6 @@
1
+ export const USER_REACTION = {
2
+ LIKED: 'LIKED',
3
+ DISLIKED: 'DISLIKED',
4
+ } as const;
5
+
6
+ export type TUserReactionEnum = (typeof USER_REACTION)[keyof typeof USER_REACTION];
@@ -0,0 +1 @@
1
+ export * from './enums';
@@ -1,4 +1,5 @@
1
1
  import { z } from 'zod';
2
+ import { AI_MODEL_CONTENT_TYPE, TAIModelContentTypeEnum } from '../constants';
2
3
 
3
4
  export const AiModelSchema = z.object({
4
5
  uuid: z.string().uuid(),
@@ -9,7 +10,7 @@ export const AiModelSchema = z.object({
9
10
  tokenMultiplicator: z.number(),
10
11
  order: z.number(),
11
12
  canUse: z.optional(z.boolean()),
12
-
13
+ contentType: z.enum(Object.values(AI_MODEL_CONTENT_TYPE) as [TAIModelContentTypeEnum]),
13
14
  createdAt: z.date(),
14
15
  updatedAt: z.date(),
15
16
  });
@@ -1,4 +1,5 @@
1
1
  import { z } from 'zod';
2
+ import { TUserReactionEnum, USER_REACTION } from '../constants';
2
3
 
3
4
  export const MessageSchema = z.object({
4
5
  uuid: z.string().uuid(),
@@ -6,6 +7,7 @@ export const MessageSchema = z.object({
6
7
  chatId: z.nullable(z.string().uuid()),
7
8
  role: z.string(),
8
9
  tokenUsage: z.number(),
10
+ userReaction: z.nullable(z.enum(Object.values(USER_REACTION) as [TUserReactionEnum])),
9
11
 
10
12
  createdAt: z.date(),
11
13
  updatedAt: z.date(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@purpleschool/gptbot",
3
- "version": "0.4.2",
3
+ "version": "0.5.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {