@purpleschool/gptbot 0.5.33 → 0.5.35

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 (97) hide show
  1. package/api/controllers/http/chat-private.ts +9 -7
  2. package/api/controllers/http/chat-public.ts +7 -4
  3. package/api/controllers/http/files.ts +1 -0
  4. package/api/controllers/http/index.ts +1 -0
  5. package/api/controllers/http/message.ts +10 -0
  6. package/api/controllers/http/midjourney.ts +5 -0
  7. package/api/routes.ts +20 -15
  8. package/build/api/controllers/http/chat-private.js +9 -7
  9. package/build/api/controllers/http/chat-public.js +7 -5
  10. package/build/api/controllers/http/files.js +1 -0
  11. package/build/api/controllers/http/index.js +1 -0
  12. package/build/api/controllers/http/message.js +9 -1
  13. package/build/api/controllers/http/midjourney.js +7 -0
  14. package/build/api/routes.js +14 -8
  15. package/build/commands/chat/check-limit.command.js +3 -1
  16. package/build/commands/chat/create-chat.command.js +2 -4
  17. package/build/commands/chat/delete-chat.command.js +1 -2
  18. package/build/commands/chat/find-chat-by-uuid.command.js +1 -1
  19. package/build/commands/chat/find-chats.command.js +1 -1
  20. package/build/commands/chat/get-chats-config.command.js +14 -0
  21. package/build/commands/chat/{get-my-last-active-chat.command.js → get-last-active-chat-command.js} +2 -1
  22. package/build/commands/chat/index.js +2 -7
  23. package/build/commands/file/index.js +17 -0
  24. package/build/commands/file/upload.command.js +11 -0
  25. package/build/commands/index.js +2 -0
  26. package/build/commands/message/create-text-message.command.js +3 -2
  27. package/build/commands/message/find-message-by-uuid.command.js +14 -0
  28. package/build/commands/message/index.js +1 -1
  29. package/build/commands/midjourney/index.js +17 -0
  30. package/build/commands/midjourney/midjourney-callback.command.js +10 -0
  31. package/build/commands/user/get-me.command.js +1 -0
  32. package/build/constants/ai-model/enums/ai-model-feature.enum.js +7 -0
  33. package/build/constants/ai-model/enums/ai-model-strategy.enum.js +11 -0
  34. package/build/constants/ai-model/enums/index.js +2 -0
  35. package/build/constants/errors/errors.js +30 -0
  36. package/build/constants/file/enums/file-type.enum.js +8 -0
  37. package/build/constants/file/enums/index.js +17 -0
  38. package/build/constants/file/index.js +17 -0
  39. package/build/constants/index.js +2 -0
  40. package/build/constants/message/enums/index.js +1 -0
  41. package/build/constants/message/enums/message-status.enum.js +9 -0
  42. package/build/constants/midjourney/enums/index.js +17 -0
  43. package/build/constants/midjourney/enums/midjournet-job-status.enum.js +10 -0
  44. package/build/constants/midjourney/index.js +17 -0
  45. package/build/models/ai-model.schema.js +1 -0
  46. package/build/models/file.schema.js +16 -0
  47. package/build/models/index.js +2 -0
  48. package/build/models/message.schema.js +3 -0
  49. package/build/models/midjourney-job.schema.js +23 -0
  50. package/commands/chat/check-limit.command.ts +3 -1
  51. package/commands/chat/create-chat.command.ts +3 -6
  52. package/commands/chat/delete-chat.command.ts +2 -4
  53. package/commands/chat/find-chat-by-uuid.command.ts +2 -2
  54. package/commands/chat/find-chats.command.ts +2 -2
  55. package/commands/chat/get-chats-config.command.ts +13 -0
  56. package/commands/chat/{get-my-last-active-chat-command.v2.ts → get-last-active-chat-command.ts} +1 -1
  57. package/commands/chat/index.ts +2 -7
  58. package/commands/file/index.ts +1 -0
  59. package/commands/{chat/check-limit.command.v2.ts → file/upload.command.ts} +4 -4
  60. package/commands/index.ts +2 -0
  61. package/commands/message/create-text-message.command.ts +3 -2
  62. package/commands/message/find-message-by-uuid.command.ts +16 -0
  63. package/commands/message/index.ts +1 -1
  64. package/commands/midjourney/index.ts +1 -0
  65. package/commands/{chat/delete-chat.command.v2.ts → midjourney/midjourney-callback.command.ts} +3 -6
  66. package/commands/user/get-me.command.ts +2 -1
  67. package/constants/ai-model/enums/ai-model-feature.enum.ts +3 -0
  68. package/constants/ai-model/enums/ai-model-strategy.enum.ts +7 -0
  69. package/constants/ai-model/enums/index.ts +2 -0
  70. package/constants/errors/errors.ts +30 -0
  71. package/constants/file/enums/file-type.enum.ts +4 -0
  72. package/constants/file/enums/index.ts +1 -0
  73. package/constants/file/index.ts +1 -0
  74. package/constants/index.ts +2 -0
  75. package/constants/message/enums/index.ts +1 -0
  76. package/constants/message/enums/message-status.enum.ts +5 -0
  77. package/constants/midjourney/enums/index.ts +1 -0
  78. package/constants/midjourney/enums/midjournet-job-status.enum.ts +6 -0
  79. package/constants/midjourney/index.ts +1 -0
  80. package/models/ai-model.schema.ts +2 -1
  81. package/models/file.schema.ts +14 -0
  82. package/models/index.ts +2 -0
  83. package/models/message.schema.ts +4 -0
  84. package/models/midjourney-job.schema.ts +24 -0
  85. package/package.json +1 -1
  86. package/build/commands/chat/check-limit.command.v2.js +0 -12
  87. package/build/commands/chat/create-chat.command.v2.js +0 -17
  88. package/build/commands/chat/delete-chat.command.v2.js +0 -12
  89. package/build/commands/chat/find-chat.command.js +0 -30
  90. package/build/commands/chat/get-my-last-active-chat-command.v2.js +0 -17
  91. package/build/commands/chat/update-chat.command.js +0 -22
  92. package/build/commands/message/create-message.command.js +0 -18
  93. package/commands/chat/create-chat.command.v2.ts +0 -19
  94. package/commands/chat/find-chat.command.ts +0 -39
  95. package/commands/chat/get-my-last-active-chat.command.ts +0 -18
  96. package/commands/chat/update-chat.command.ts +0 -27
  97. package/commands/message/create-message.command.ts +0 -21
@@ -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("./midjournet-job-status.enum"), exports);
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MIDJOURNEY_JOB_STATUS = void 0;
4
+ var MIDJOURNEY_JOB_STATUS;
5
+ (function (MIDJOURNEY_JOB_STATUS) {
6
+ MIDJOURNEY_JOB_STATUS["PENDING"] = "pending";
7
+ MIDJOURNEY_JOB_STATUS["IN_PROGRESS"] = "in-progress";
8
+ MIDJOURNEY_JOB_STATUS["COMPLETED"] = "completed";
9
+ MIDJOURNEY_JOB_STATUS["FAILED"] = "failed";
10
+ })(MIDJOURNEY_JOB_STATUS || (exports.MIDJOURNEY_JOB_STATUS = MIDJOURNEY_JOB_STATUS = {}));
@@ -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);
@@ -14,6 +14,7 @@ exports.AiModelSchema = zod_1.z.object({
14
14
  canUse: zod_1.z.optional(zod_1.z.boolean()),
15
15
  icon: zod_1.z.nullable(zod_1.z.string()),
16
16
  contentType: zod_1.z.enum(Object.values(constants_1.AI_MODEL_CONTENT_TYPE)),
17
+ features: zod_1.z.array(zod_1.z.nativeEnum(constants_1.AI_MODEL_FEATURE)),
17
18
  createdAt: zod_1.z.date(),
18
19
  updatedAt: zod_1.z.date(),
19
20
  });
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FileSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const constants_1 = require("../constants");
6
+ exports.FileSchema = zod_1.z.object({
7
+ uuid: zod_1.z.string().uuid(),
8
+ name: zod_1.z.string(),
9
+ size: zod_1.z.number(),
10
+ mimeType: zod_1.z.string(),
11
+ url: zod_1.z.string(),
12
+ type: zod_1.z.nativeEnum(constants_1.FILE_TYPE),
13
+ attachmentCost: zod_1.z.number(),
14
+ createdAt: zod_1.z.date(),
15
+ updatedAt: zod_1.z.date(),
16
+ });
@@ -22,8 +22,10 @@ __exportStar(require("./cloud-payments-receipt.schema"), exports);
22
22
  __exportStar(require("./course-author.schema"), exports);
23
23
  __exportStar(require("./course.schema"), exports);
24
24
  __exportStar(require("./feedback.schema"), exports);
25
+ __exportStar(require("./file.schema"), exports);
25
26
  __exportStar(require("./lesson.schema"), exports);
26
27
  __exportStar(require("./message.schema"), exports);
28
+ __exportStar(require("./midjourney-job.schema"), exports);
27
29
  __exportStar(require("./order.schema"), exports);
28
30
  __exportStar(require("./page.schema"), exports);
29
31
  __exportStar(require("./payment-history-item.schema"), exports);
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MessageSchema = void 0;
4
4
  const zod_1 = require("zod");
5
5
  const constants_1 = require("../constants");
6
+ const file_schema_1 = require("./file.schema");
6
7
  exports.MessageSchema = zod_1.z.object({
7
8
  uuid: zod_1.z.string().uuid(),
8
9
  text: zod_1.z.string().max(10000),
@@ -10,7 +11,9 @@ exports.MessageSchema = zod_1.z.object({
10
11
  role: zod_1.z.string(),
11
12
  tokenUsage: zod_1.z.number(),
12
13
  userReaction: zod_1.z.nullable(zod_1.z.enum(Object.values(constants_1.USER_REACTION))),
14
+ files: zod_1.z.array(file_schema_1.FileSchema),
13
15
  imageFormat: zod_1.z.nullable(zod_1.z.enum(Object.values(constants_1.DALLE_IMAGE_FORMAT_ENUM))),
16
+ status: zod_1.z.nativeEnum(constants_1.MESSAGE_STATUS),
14
17
  createdAt: zod_1.z.date(),
15
18
  updatedAt: zod_1.z.date(),
16
19
  });
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MidjourneyWebhookSchema = exports.MidjourneyJobSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const constants_1 = require("../constants");
6
+ exports.MidjourneyJobSchema = zod_1.z.object({
7
+ id: zod_1.z.string(),
8
+ prompt: zod_1.z.string(),
9
+ results: zod_1.z.string().nullable(),
10
+ user_created: zod_1.z.string(),
11
+ date_created: zod_1.z.string(),
12
+ status: zod_1.z.nativeEnum(constants_1.MIDJOURNEY_JOB_STATUS),
13
+ progress: zod_1.z.number().nullable(),
14
+ error: zod_1.z.string().nullable(),
15
+ upscaled_urls: zod_1.z.array(zod_1.z.string()).nullable(),
16
+ upscaled: zod_1.z.array(zod_1.z.string()),
17
+ url: zod_1.z.string().nullable().optional(),
18
+ ref: zod_1.z.string().nullable().optional(),
19
+ });
20
+ exports.MidjourneyWebhookSchema = zod_1.z.object({
21
+ event: zod_1.z.string(),
22
+ payload: exports.MidjourneyJobSchema,
23
+ });
@@ -2,7 +2,9 @@ import { z } from 'zod';
2
2
 
3
3
  export namespace CheckLimitCommand {
4
4
  export const ResponseSchema = z.object({
5
- totalTokenBalance: z.number(),
5
+ data: z.object({
6
+ totalTokenBalance: z.number(),
7
+ }),
6
8
  });
7
9
  export type Response = z.infer<typeof ResponseSchema>;
8
10
  }
@@ -2,15 +2,12 @@ import { ChatSchema, MessageSchema } from '../../models';
2
2
  import { z } from 'zod';
3
3
 
4
4
  export namespace CreateChatCommand {
5
- export const RequestSchemaByParam = ChatSchema.pick({
5
+ export const RequestSchema = ChatSchema.pick({
6
+ aIModelId: true,
6
7
  categoryId: true,
7
8
  });
8
9
 
9
- export type RequestByParam = z.infer<typeof RequestSchemaByParam>;
10
-
11
- export const RequestSchema = z.object({
12
- aiModelUUID: z.string().uuid(),
13
- });
10
+ export type RequestSchema = z.infer<typeof RequestSchema>;
14
11
 
15
12
  export const ResponseSchema = z.object({
16
13
  data: ChatSchema.extend({
@@ -2,12 +2,10 @@ import { z } from 'zod';
2
2
  import { ChatSchema } from '../../models';
3
3
 
4
4
  export namespace DeleteChatCommand {
5
- export const RequestSchema = ChatSchema.pick({
5
+ export const RequestParamsSchema = ChatSchema.pick({
6
6
  uuid: true,
7
- categoryId: true,
8
7
  });
9
-
10
- export type Request = z.infer<typeof RequestSchema>;
8
+ export type Request = z.infer<typeof RequestParamsSchema>;
11
9
 
12
10
  export const ResponseSchema = z.void();
13
11
  export type Response = z.infer<typeof ResponseSchema>;
@@ -2,11 +2,11 @@ import { ChatSchema } from '../../models';
2
2
  import { z } from 'zod';
3
3
 
4
4
  export namespace FindChatByUUIDCommand {
5
- export const RequestByParamSchema = ChatSchema.pick({
5
+ export const RequestParamsSchema = ChatSchema.pick({
6
6
  uuid: true,
7
7
  });
8
8
 
9
- export type Request = z.infer<typeof RequestByParamSchema>;
9
+ export type Request = z.infer<typeof RequestParamsSchema>;
10
10
 
11
11
  export const ResponseSchema = z.object({
12
12
  data: ChatSchema,
@@ -15,9 +15,9 @@ export namespace FindChatsCommand {
15
15
  AiModelSchema.pick({ contentType: true }).partial(),
16
16
  );
17
17
 
18
- export const RequestByQuerySchema = z.intersection(QuerySchema, PaginationQuerySchema);
18
+ export const RequestQuerySchema = z.intersection(QuerySchema, PaginationQuerySchema);
19
19
 
20
- export type RequestByQuery = z.infer<typeof RequestByQuerySchema>;
20
+ export type RequestByQuery = z.infer<typeof RequestQuerySchema>;
21
21
 
22
22
  export const ResponseSchema = z.object({
23
23
  data: z.array(
@@ -0,0 +1,13 @@
1
+ import { z } from 'zod';
2
+
3
+ export namespace GetChatsConfigCommand {
4
+ export const ResponseSchema = z.object({
5
+ data: z.object({
6
+ maxFileAttachments: z.number(),
7
+ imageAttachmentCost: z.number(),
8
+ imagePollingInterval: z.number(),
9
+ }),
10
+ });
11
+
12
+ export type Response = z.infer<typeof ResponseSchema>;
13
+ }
@@ -1,7 +1,7 @@
1
1
  import { ChatSchema, MessageSchema } from '../../models';
2
2
  import { z } from 'zod';
3
3
 
4
- export namespace GetLastActiveChatV2Command {
4
+ export namespace GetLastActiveChatCommand {
5
5
  export const RequestQuerySchema = ChatSchema.pick({
6
6
  categoryId: true,
7
7
  aIModelId: true,
@@ -1,13 +1,8 @@
1
1
  export * from './archive-all.command';
2
2
  export * from './check-limit.command';
3
- export * from './check-limit.command.v2';
4
3
  export * from './create-chat.command';
5
- export * from './create-chat.command.v2';
6
4
  export * from './delete-chat.command';
7
- export * from './delete-chat.command.v2';
8
5
  export * from './find-chat-by-uuid.command';
9
- export * from './find-chat.command';
10
6
  export * from './find-chats.command';
11
- export * from './get-my-last-active-chat-command.v2';
12
- export * from './get-my-last-active-chat.command';
13
- export * from './update-chat.command';
7
+ export * from './get-chats-config.command';
8
+ export * from './get-last-active-chat-command';
@@ -0,0 +1 @@
1
+ export * from './upload.command';
@@ -1,10 +1,10 @@
1
+ import { FileSchema } from '../../models';
1
2
  import { z } from 'zod';
2
3
 
3
- export namespace CheckLimitV2Command {
4
+ export namespace UploadFileCommand {
4
5
  export const ResponseSchema = z.object({
5
- data: z.object({
6
- totalTokenBalance: z.number(),
7
- }),
6
+ data: FileSchema,
8
7
  });
8
+
9
9
  export type Response = z.infer<typeof ResponseSchema>;
10
10
  }
package/commands/index.ts CHANGED
@@ -6,7 +6,9 @@ export * from './category';
6
6
  export * from './chat';
7
7
  export * from './course';
8
8
  export * from './feedback';
9
+ export * from './file';
9
10
  export * from './message';
11
+ export * from './midjourney';
10
12
  export * from './page';
11
13
  export * from './payment';
12
14
  export * from './product';
@@ -2,8 +2,9 @@ import { ChatSchema, MessageSchema } from '../../models';
2
2
  import { z } from 'zod';
3
3
 
4
4
  export namespace CreateTextMessageCommand {
5
- export const RequestSchema = MessageSchema.pick({
6
- text: true,
5
+ export const RequestSchema = z.object({
6
+ text: z.string(),
7
+ files: z.array(z.string().uuid()).optional().default([]),
7
8
  });
8
9
 
9
10
  export const RequestParamSchema = ChatSchema.pick({
@@ -0,0 +1,16 @@
1
+ import { MessageSchema, PageSchema } from '../../models';
2
+ import { z } from 'zod';
3
+
4
+ export namespace FindMessageByUUIDCommand {
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: MessageSchema,
13
+ });
14
+
15
+ export type Response = z.infer<typeof ResponseSchema>;
16
+ }
@@ -1,4 +1,4 @@
1
1
  export * from './create-image-message.command';
2
- export * from './create-message.command';
3
2
  export * from './create-text-message.command';
3
+ export * from './find-message-by-uuid.command';
4
4
  export * from './rate-message.command';
@@ -0,0 +1 @@
1
+ export * from './midjourney-callback.command';
@@ -1,11 +1,8 @@
1
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
- });
2
+ import { MidjourneyWebhookSchema } from '../../models';
8
3
 
4
+ export namespace MidjourneyCallbackCommand {
5
+ export const RequestSchema = MidjourneyWebhookSchema;
9
6
  export type Request = z.infer<typeof RequestSchema>;
10
7
 
11
8
  export const ResponseSchema = z.void();
@@ -1,4 +1,4 @@
1
- import { ROLE, USER_STATUS } from '../../constants';
1
+ import { ROLE, SIGNUP_METHOD, USER_STATUS } from '../../constants';
2
2
  import { z } from 'zod';
3
3
 
4
4
  export namespace GetMeCommand {
@@ -12,6 +12,7 @@ export namespace GetMeCommand {
12
12
  email: z.string().email(),
13
13
  status: z.nativeEnum(USER_STATUS),
14
14
  role: z.nativeEnum(ROLE),
15
+ signupMethod: z.nativeEnum(SIGNUP_METHOD),
15
16
  telegramId: z.number().nullable(),
16
17
  }),
17
18
  });
@@ -0,0 +1,3 @@
1
+ export enum AI_MODEL_FEATURE {
2
+ IMAGE_ATTACHMENT = 'image_attachment',
3
+ }
@@ -0,0 +1,7 @@
1
+ export enum AI_MODEL_STRATEGY {
2
+ OPENAI_TEXT_GENERATION = 'openai_text_generation',
3
+ DALLE_IMAGE_GENERATION = 'dalle_image_generation',
4
+ MIDJOURNEY_IMAGE_GENERATION = 'midjourney_image_generation',
5
+ DEEPSEEK_TEXT_GENERATION = 'deepseek_text_generation',
6
+ GROK_TEXT_GENERATION = 'grok_text_generation',
7
+ }
@@ -1 +1,3 @@
1
1
  export * from './ai-model-content-type.enum';
2
+ export * from './ai-model-feature.enum';
3
+ export * from './ai-model-strategy.enum';
@@ -842,4 +842,34 @@ export const ERRORS = {
842
842
  message: 'Произошла ошибка при отправке чека в Telegram',
843
843
  httpCode: 500,
844
844
  },
845
+ FILE_SAVE_ERROR: {
846
+ code: 'A193',
847
+ message: 'Произошла ошибка при сохранении файла',
848
+ httpCode: 500,
849
+ },
850
+ FILE_NOT_FOUND_INTERNAL: {
851
+ code: 'A194',
852
+ message: 'Произошла ошибка при поиске файла',
853
+ httpCode: 500,
854
+ },
855
+ FILE_DELETE_ERROR: {
856
+ code: 'A195',
857
+ message: 'Произошла ошибка при удалении файла',
858
+ httpCode: 500,
859
+ },
860
+ FILE_DELETE_FROM_STORE_ERROR: {
861
+ code: 'A196',
862
+ message: 'Произошла ошибка при удалении файла из хранилища',
863
+ httpCode: 500,
864
+ },
865
+ AI_MODEL_DOES_NOT_SUPPORT_FILES: {
866
+ code: 'A197',
867
+ message: 'ИИ модель не поддерживает загрузку файлов',
868
+ httpCode: 400,
869
+ },
870
+ CHAT_MAX_FILES_COUNT_EXCEEDED: {
871
+ code: 'A198',
872
+ message: 'Превышено максимальное количество прикрепленных файлов',
873
+ httpCode: 400,
874
+ },
845
875
  };
@@ -0,0 +1,4 @@
1
+ export enum FILE_TYPE {
2
+ IMAGE = 'image',
3
+ OTHER = 'other',
4
+ }
@@ -0,0 +1 @@
1
+ export * from './file-type.enum';
@@ -0,0 +1 @@
1
+ export * from './enums';
@@ -6,7 +6,9 @@ export * from './course';
6
6
  export * from './domains';
7
7
  export * from './email';
8
8
  export * from './errors';
9
+ export * from './file';
9
10
  export * from './message';
11
+ export * from './midjourney';
10
12
  export * from './order';
11
13
  export * from './page';
12
14
  export * from './payment';
@@ -1 +1,2 @@
1
1
  export * from './user-reaction.enum';
2
+ export * from './message-status.enum';
@@ -0,0 +1,5 @@
1
+ export enum MESSAGE_STATUS {
2
+ SUCCESS = 'success',
3
+ LOADING = 'loading',
4
+ FAILED = 'failed',
5
+ }
@@ -0,0 +1 @@
1
+ export * from './midjournet-job-status.enum';
@@ -0,0 +1,6 @@
1
+ export enum MIDJOURNEY_JOB_STATUS {
2
+ PENDING = 'pending',
3
+ IN_PROGRESS = 'in-progress',
4
+ COMPLETED = 'completed',
5
+ FAILED = 'failed',
6
+ }
@@ -0,0 +1 @@
1
+ export * from './enums';
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- import { AI_MODEL_CONTENT_TYPE, TAIModelContentTypeEnum } from '../constants';
2
+ import { AI_MODEL_CONTENT_TYPE, AI_MODEL_FEATURE, TAIModelContentTypeEnum } from '../constants';
3
3
 
4
4
  export const AiModelSchema = z.object({
5
5
  uuid: z.string().uuid(),
@@ -12,6 +12,7 @@ export const AiModelSchema = z.object({
12
12
  canUse: z.optional(z.boolean()),
13
13
  icon: z.nullable(z.string()),
14
14
  contentType: z.enum(Object.values(AI_MODEL_CONTENT_TYPE) as [TAIModelContentTypeEnum]),
15
+ features: z.array(z.nativeEnum(AI_MODEL_FEATURE)),
15
16
  createdAt: z.date(),
16
17
  updatedAt: z.date(),
17
18
  });
@@ -0,0 +1,14 @@
1
+ import { z } from 'zod';
2
+ import { FILE_TYPE } from '../constants';
3
+
4
+ export const FileSchema = z.object({
5
+ uuid: z.string().uuid(),
6
+ name: z.string(),
7
+ size: z.number(),
8
+ mimeType: z.string(),
9
+ url: z.string(),
10
+ type: z.nativeEnum(FILE_TYPE),
11
+ attachmentCost: z.number(),
12
+ createdAt: z.date(),
13
+ updatedAt: z.date(),
14
+ });
package/models/index.ts CHANGED
@@ -6,8 +6,10 @@ export * from './cloud-payments-receipt.schema';
6
6
  export * from './course-author.schema';
7
7
  export * from './course.schema';
8
8
  export * from './feedback.schema';
9
+ export * from './file.schema';
9
10
  export * from './lesson.schema';
10
11
  export * from './message.schema';
12
+ export * from './midjourney-job.schema';
11
13
  export * from './order.schema';
12
14
  export * from './page.schema';
13
15
  export * from './payment-history-item.schema';
@@ -1,10 +1,12 @@
1
1
  import { z } from 'zod';
2
2
  import {
3
3
  DALLE_IMAGE_FORMAT_ENUM,
4
+ MESSAGE_STATUS,
4
5
  TDalleImageFormatEnum,
5
6
  TUserReactionEnum,
6
7
  USER_REACTION,
7
8
  } from '../constants';
9
+ import { FileSchema } from './file.schema';
8
10
 
9
11
  export const MessageSchema = z.object({
10
12
  uuid: z.string().uuid(),
@@ -13,9 +15,11 @@ export const MessageSchema = z.object({
13
15
  role: z.string(),
14
16
  tokenUsage: z.number(),
15
17
  userReaction: z.nullable(z.enum(Object.values(USER_REACTION) as [TUserReactionEnum])),
18
+ files: z.array(FileSchema),
16
19
  imageFormat: z.nullable(
17
20
  z.enum(Object.values(DALLE_IMAGE_FORMAT_ENUM) as [TDalleImageFormatEnum]),
18
21
  ),
22
+ status: z.nativeEnum(MESSAGE_STATUS),
19
23
 
20
24
  createdAt: z.date(),
21
25
  updatedAt: z.date(),
@@ -0,0 +1,24 @@
1
+ import { z } from 'zod';
2
+ import { MIDJOURNEY_JOB_STATUS } from '../constants';
3
+
4
+ export const MidjourneyJobSchema = z.object({
5
+ id: z.string(),
6
+ prompt: z.string(),
7
+ results: z.string().nullable(),
8
+ user_created: z.string(),
9
+ date_created: z.string(),
10
+ status: z.nativeEnum(MIDJOURNEY_JOB_STATUS),
11
+ progress: z.number().nullable(),
12
+ error: z.string().nullable(),
13
+ upscaled_urls: z.array(z.string()).nullable(),
14
+ upscaled: z.array(z.string()),
15
+ url: z.string().nullable().optional(),
16
+ ref: z.string().nullable().optional(),
17
+ });
18
+
19
+ export const MidjourneyWebhookSchema = z.object({
20
+ event: z.string(),
21
+ payload: MidjourneyJobSchema,
22
+ });
23
+
24
+ export type MidjourneyJob = z.infer<typeof MidjourneyJobSchema>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@purpleschool/gptbot",
3
- "version": "0.5.33",
3
+ "version": "0.5.35",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -1,12 +0,0 @@
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 = {}));
@@ -1,17 +0,0 @@
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 = {}));
@@ -1,12 +0,0 @@
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.void();
12
- })(DeleteChatV2Command || (exports.DeleteChatV2Command = DeleteChatV2Command = {}));
@@ -1,30 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FindChatCommand = void 0;
4
- const models_1 = require("../../models");
5
- const zod_1 = require("zod");
6
- var FindChatCommand;
7
- (function (FindChatCommand) {
8
- FindChatCommand.RequestSchema = models_1.ChatSchema.pick({
9
- uuid: true,
10
- });
11
- FindChatCommand.RequestSchemaByParam = models_1.ChatSchema.pick({
12
- categoryId: true,
13
- });
14
- FindChatCommand.RequestSchemaByQuery = zod_1.z.object({
15
- limit: zod_1.z.string().regex(/^\d+$/, { message: 'Limit должен быть числом' }).transform(Number),
16
- offset: zod_1.z
17
- .string()
18
- .regex(/^\d+$/, { message: 'Offset должен быть числом' })
19
- .transform(Number),
20
- });
21
- FindChatCommand.ResponseSchema = zod_1.z.object({
22
- data: zod_1.z.array(models_1.ChatSchema.extend({
23
- messages: zod_1.z.array(models_1.MessageSchema),
24
- })),
25
- count: zod_1.z.number(),
26
- });
27
- FindChatCommand.ResponseByUUIDSchema = zod_1.z.object({
28
- data: models_1.ChatSchema,
29
- });
30
- })(FindChatCommand || (exports.FindChatCommand = FindChatCommand = {}));