@purpleschool/gptbot 0.8.11 → 0.8.14

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 (81) hide show
  1. package/api/controllers/http/community.ts +22 -0
  2. package/api/controllers/http/index.ts +1 -0
  3. package/api/controllers/http/paraphrase.ts +6 -0
  4. package/api/routes.ts +46 -0
  5. package/build/api/controllers/http/community.js +23 -0
  6. package/build/api/controllers/http/index.js +1 -0
  7. package/build/api/controllers/http/paraphrase.js +6 -0
  8. package/build/api/routes.js +30 -0
  9. package/build/commands/community/archive-community-post.command.js +13 -0
  10. package/build/commands/community/create-community-post.command.js +35 -0
  11. package/build/commands/community/delete-community-post.command.js +13 -0
  12. package/build/commands/community/get-all-community-posts-by-criteria.command.js +25 -0
  13. package/build/commands/community/get-community-post-by-uuid.command.js +14 -0
  14. package/build/commands/community/get-my-community-posts-by-criteria.command.js +32 -0
  15. package/build/commands/community/get-my-favorite-community-posts.command.js +19 -0
  16. package/build/commands/community/get-my-likes-community-posts.command.js +19 -0
  17. package/build/commands/community/index.js +27 -0
  18. package/build/commands/community/set-favorite-community-post.command.js +13 -0
  19. package/build/commands/community/set-like-community-post.command.js +14 -0
  20. package/build/commands/community/share-my-community-post.command.js +13 -0
  21. package/build/commands/index.js +1 -0
  22. package/build/commands/tools/paraphrase/delete-all-paraphrase-jobs.command.js +8 -0
  23. package/build/commands/tools/paraphrase/delete-paraphrase-job-by-uuid.command.js +11 -0
  24. package/build/commands/tools/paraphrase/find-paraphrase-jobs.command.js +18 -0
  25. package/build/commands/tools/paraphrase/index.js +7 -1
  26. package/build/commands/tools/paraphrase/retry-paraphrase-job.command.js +14 -0
  27. package/build/commands/tools/paraphrase/set-reaction-to-paraphrase-job.command.js +18 -0
  28. package/build/commands/tools/paraphrase/update-paraphrase-job-title.command.js +17 -0
  29. package/build/constants/community/default-pagination.constant.js +6 -0
  30. package/build/constants/community/enums/community-aspect-ratio.enum.js +11 -0
  31. package/build/constants/community/enums/community-post-visibility.enum.js +8 -0
  32. package/build/constants/community/enums/community-status.enum.js +9 -0
  33. package/build/constants/community/enums/community-tool-type.enum.js +10 -0
  34. package/build/constants/community/enums/community-type.enum.js +11 -0
  35. package/build/constants/community/enums/index.js +21 -0
  36. package/build/constants/community/index.js +18 -0
  37. package/build/constants/errors/errors.js +115 -0
  38. package/build/constants/index.js +1 -0
  39. package/build/constants/tool/enums/tool-job-status.enum.js +1 -0
  40. package/build/models/community/community-post-media-data.schema.js +53 -0
  41. package/build/models/community/community-post.schema.js +43 -0
  42. package/build/models/community/index.js +18 -0
  43. package/build/models/index.js +1 -0
  44. package/build/models/tools/paraphrase/paraphrase-job.schema.js +3 -0
  45. package/commands/community/archive-community-post.command.ts +13 -0
  46. package/commands/community/create-community-post.command.ts +45 -0
  47. package/commands/community/delete-community-post.command.ts +13 -0
  48. package/commands/community/get-all-community-posts-by-criteria.command.ts +29 -0
  49. package/commands/community/get-community-post-by-uuid.command.ts +16 -0
  50. package/commands/community/get-my-community-posts-by-criteria.command.ts +40 -0
  51. package/commands/community/get-my-favorite-community-posts.command.ts +19 -0
  52. package/commands/community/get-my-likes-community-posts.command.ts +19 -0
  53. package/commands/community/index.ts +11 -0
  54. package/commands/community/set-favorite-community-post.command.ts +13 -0
  55. package/commands/community/set-like-community-post.command.ts +14 -0
  56. package/commands/community/share-my-community-post.command.ts +13 -0
  57. package/commands/index.ts +1 -0
  58. package/commands/tools/paraphrase/delete-all-paraphrase-jobs.command.ts +6 -0
  59. package/commands/tools/paraphrase/delete-paraphrase-job-by-uuid.command.ts +11 -0
  60. package/commands/tools/paraphrase/find-paraphrase-jobs.command.ts +18 -0
  61. package/commands/tools/paraphrase/index.ts +7 -1
  62. package/commands/tools/paraphrase/retry-paraphrase-job.command.ts +14 -0
  63. package/commands/tools/paraphrase/set-reaction-to-paraphrase-job.command.ts +20 -0
  64. package/commands/tools/paraphrase/update-paraphrase-job-title.command.ts +19 -0
  65. package/constants/community/default-pagination.constant.ts +4 -0
  66. package/constants/community/enums/community-aspect-ratio.enum.ts +7 -0
  67. package/constants/community/enums/community-post-visibility.enum.ts +4 -0
  68. package/constants/community/enums/community-status.enum.ts +5 -0
  69. package/constants/community/enums/community-tool-type.enum.ts +6 -0
  70. package/constants/community/enums/community-type.enum.ts +7 -0
  71. package/constants/community/enums/index.ts +5 -0
  72. package/constants/community/index.ts +2 -0
  73. package/constants/errors/errors.ts +115 -0
  74. package/constants/index.ts +1 -0
  75. package/constants/tool/enums/tool-job-status.enum.ts +1 -0
  76. package/models/community/community-post-media-data.schema.ts +65 -0
  77. package/models/community/community-post.schema.ts +47 -0
  78. package/models/community/index.ts +2 -0
  79. package/models/index.ts +1 -0
  80. package/models/tools/paraphrase/paraphrase-job.schema.ts +3 -0
  81. package/package.json +1 -1
@@ -1,3 +1,9 @@
1
+ export * from './paraphrase.command';
2
+ export * from './delete-paraphrase-job-by-uuid.command';
3
+ export * from './delete-all-paraphrase-jobs.command';
4
+ export * from './set-reaction-to-paraphrase-job.command';
5
+ export * from './update-paraphrase-job-title.command';
6
+ export * from './retry-paraphrase-job.command';
1
7
  export * from './find-paraphrase-job-by-uuid.command';
8
+ export * from './find-paraphrase-jobs.command';
2
9
  export * from './get-paraphrase-tool-config.command';
3
- export * from './paraphrase.command';
@@ -0,0 +1,14 @@
1
+ import { z } from 'zod';
2
+ import { ParaphraseToolJobSchema } from '../../../models';
3
+
4
+ export namespace RetryParaphraseJobCommand {
5
+ export const RequestParamsSchema = z.object({
6
+ uuid: z.string().uuid(),
7
+ });
8
+ export type RequestParams = z.infer<typeof RequestParamsSchema>;
9
+
10
+ export const ResponseSchema = z.object({
11
+ data: ParaphraseToolJobSchema,
12
+ });
13
+ export type Response = z.infer<typeof ResponseSchema>;
14
+ }
@@ -0,0 +1,20 @@
1
+ import { z } from 'zod';
2
+ import { ParaphraseToolJobSchema } from '../../../models';
3
+ import { USER_REACTION } from '../../../constants';
4
+
5
+ export namespace SetReactionToParaphraseJobCommand {
6
+ export const RequestSchema = z.object({
7
+ reaction: z.nativeEnum(USER_REACTION).nullable(),
8
+ });
9
+ export type Request = z.infer<typeof RequestSchema>;
10
+
11
+ export const RequestParamsSchema = z.object({
12
+ uuid: z.string().uuid(),
13
+ });
14
+ export type RequestParams = z.infer<typeof RequestParamsSchema>;
15
+
16
+ export const ResponseSchema = z.object({
17
+ data: ParaphraseToolJobSchema,
18
+ });
19
+ export type Response = z.infer<typeof ResponseSchema>;
20
+ }
@@ -0,0 +1,19 @@
1
+ import { z } from 'zod';
2
+ import { ParaphraseToolJobSchema } from '../../../models';
3
+
4
+ export namespace UpdateParaphraseJobTitleCommand {
5
+ export const RequestSchema = z.object({
6
+ title: z.string().min(1).max(40).trim(),
7
+ });
8
+ export type Request = z.infer<typeof RequestSchema>;
9
+
10
+ export const RequestParamsSchema = z.object({
11
+ uuid: z.string().uuid(),
12
+ });
13
+ export type RequestParams = z.infer<typeof RequestParamsSchema>;
14
+
15
+ export const ResponseSchema = z.object({
16
+ data: ParaphraseToolJobSchema,
17
+ });
18
+ export type Response = z.infer<typeof ResponseSchema>;
19
+ }
@@ -0,0 +1,4 @@
1
+ export const DEFAULT_PAGINATION_LIMIT = 30;
2
+ export const DEFAULT_PAGINATION_SORT_ORDER = 'desc' as const;
3
+
4
+ export const DEFAULT_PAGINATION_SORT_BY = 'publishedAt' as const;
@@ -0,0 +1,7 @@
1
+ export enum COMMUNITY_POST_ASPECT_RATIO {
2
+ HORIZONTAL_16_9 = '16:9',
3
+ VERTICAL_9_16 = '9:16',
4
+ SQUARE = '1:1',
5
+ HORIZONTAL_4_3 = '4:3',
6
+ VERTICAL_3_4 = '3:4',
7
+ }
@@ -0,0 +1,4 @@
1
+ export enum COMMUNITY_POST_VISIBILITY {
2
+ PUBLIC = 'public',
3
+ UNLISTED = 'unlisted',
4
+ }
@@ -0,0 +1,5 @@
1
+ export enum COMMUNITY_POST_STATUS {
2
+ PUBLISHED = 'published',
3
+ ARCHIVED = 'archived',
4
+ DELETED = 'deleted',
5
+ }
@@ -0,0 +1,6 @@
1
+ export enum COMMUNITY_TOOL_TYPE {
2
+ IMAGE_EDITOR = 'image_editor',
3
+ VIDEO = 'video',
4
+ VIDEO_EDITOR = 'video_editor',
5
+ MUSIC = 'music',
6
+ }
@@ -0,0 +1,7 @@
1
+ export enum COMMUNITY_POST_TYPE {
2
+ IMAGE = 'image',
3
+ IMAGE_EDITOR = 'image_editor',
4
+ VIDEO = 'video',
5
+ VIDEO_EDITOR = 'video_editor',
6
+ MUSIC = 'music',
7
+ }
@@ -0,0 +1,5 @@
1
+ export * from './community-status.enum';
2
+ export * from './community-type.enum';
3
+ export * from './community-aspect-ratio.enum';
4
+ export * from './community-tool-type.enum';
5
+ export * from './community-post-visibility.enum';
@@ -0,0 +1,2 @@
1
+ export * from './enums';
2
+ export * from './default-pagination.constant';
@@ -2375,4 +2375,119 @@ export const ERRORS = {
2375
2375
  message: 'Ошибка при обновлении профиля пользователя',
2376
2376
  httpCode: 500,
2377
2377
  },
2378
+ COMMUNITY_POST_CREATE_ERROR: {
2379
+ code: 'A484',
2380
+ message: 'Произошла ошибка при создании поста в сообществе',
2381
+ httpCode: 500,
2382
+ },
2383
+ COMMUNITY_POST_UPDATE_ERROR: {
2384
+ code: 'A485',
2385
+ message: 'Произошла ошибка при обновлении поста в сообществе',
2386
+ httpCode: 500,
2387
+ },
2388
+ COMMUNITY_POST_FIND_ERROR: {
2389
+ code: 'A486',
2390
+ message: 'Произошла ошибка при получении поста в сообществе',
2391
+ httpCode: 500,
2392
+ },
2393
+ COMMUNITY_POST_SET_LIKE_ERROR: {
2394
+ code: 'A487',
2395
+ message: 'Произошла ошибка при установке лайка к посту в сообществе',
2396
+ httpCode: 500,
2397
+ },
2398
+ COMMUNITY_POST_SET_FAVORITE_ERROR: {
2399
+ code: 'A488',
2400
+ message: 'Произошла ошибка при переключении избранного поста в сообществе',
2401
+ httpCode: 500,
2402
+ },
2403
+ COMMUNITY_POST_OWNERSHIP_ERROR: {
2404
+ code: 'A489',
2405
+ message: 'Вы не можете переключать избранное для своего поста',
2406
+ httpCode: 403,
2407
+ },
2408
+ COMMUNITY_POST_PERMISSION_ERROR: {
2409
+ code: 'A490',
2410
+ message: 'У вас нет доступа к этому посту в сообществе',
2411
+ httpCode: 403,
2412
+ },
2413
+ COMMUNITY_POST_DELETE_ERROR: {
2414
+ code: 'A491',
2415
+ message: 'Произошла ошибка при удалении поста в сообществе',
2416
+ httpCode: 500,
2417
+ },
2418
+ COMMUNITY_TOOL_TYPE_REQUIRED: {
2419
+ code: 'A492',
2420
+ message: 'Тип инструмента обязателен',
2421
+ httpCode: 400,
2422
+ },
2423
+ COMMUNITY_TOOL_TYPE_NOT_SUPPORTED: {
2424
+ code: 'A493',
2425
+ message: 'Неподдерживаемый тип инструмента',
2426
+ httpCode: 400,
2427
+ },
2428
+ VIDEO_MODEL_FIND_ERROR: {
2429
+ code: 'A494',
2430
+ message: 'Произошла ошибка при получении модели для генерации видео',
2431
+ httpCode: 500,
2432
+ },
2433
+ VIDEO_EDITOR_MODEL_FIND_ERROR: {
2434
+ code: 'A495',
2435
+ message: 'Произошла ошибка при получении модели для редактирования видео',
2436
+ httpCode: 500,
2437
+ },
2438
+ IMAGE_EDITOR_MODEL_FIND_ERROR: {
2439
+ code: 'A496',
2440
+ message: 'Произошла ошибка при получении модели для редактирования изображения',
2441
+ httpCode: 500,
2442
+ },
2443
+ MUSIC_MODEL_FIND_ERROR: {
2444
+ code: 'A497',
2445
+ message: 'Произошла ошибка при получении модели для генерации музыки',
2446
+ httpCode: 500,
2447
+ },
2448
+ COMMUNITY_POST_NOT_AVAILABLE: {
2449
+ code: 'A498',
2450
+ message: 'Пост в сообществе недоступен',
2451
+ httpCode: 400,
2452
+ },
2453
+ COMMUNITY_POST_NOT_FOUND: {
2454
+ code: 'A499',
2455
+ message: 'Пост в сообществе не найден',
2456
+ httpCode: 404,
2457
+ },
2458
+ COMMUNITY_POST_JOB_NOT_READY: {
2459
+ code: 'A500',
2460
+ message: 'Работа не готова к публикации',
2461
+ httpCode: 404,
2462
+ },
2463
+ MESSAGE_STATUS_ERROR: {
2464
+ code: 'A501',
2465
+ message: 'Статус неудовлетворительный',
2466
+ httpCode: 400,
2467
+ },
2468
+ MESSAGE_ROLE_ERROR: {
2469
+ code: 'A502',
2470
+ message: 'Статус не удовлетворительный',
2471
+ httpCode: 400,
2472
+ },
2473
+ PARAPHRASE_JOB_DELETE_ERROR: {
2474
+ code: 'A503',
2475
+ message: 'Произошла ошибка при удалении задачи перефразирования',
2476
+ httpCode: 500,
2477
+ },
2478
+ PARAPHRASE_SET_REACTION_ERROR: {
2479
+ code: 'A504',
2480
+ message: 'Произошла ошибка при установке оценки задачи перефразирования',
2481
+ httpCode: 500,
2482
+ },
2483
+ PARAPHRASE_UPDATE_TITLE_ERROR: {
2484
+ code: 'A505',
2485
+ message: 'Произошла ошибка при обновлении названия задачи перефразирования',
2486
+ httpCode: 500,
2487
+ },
2488
+ PARAPHRASE_RETRY_REQUEST_ERROR: {
2489
+ code: 'A506',
2490
+ message: 'Произошла ошибка при повторном запросе перефразирования',
2491
+ httpCode: 500,
2492
+ },
2378
2493
  };
@@ -40,4 +40,5 @@ export * from './cabinet';
40
40
  export * from './webmaster';
41
41
  export * from './webmaster-balance';
42
42
  export * from './tool-music';
43
+ export * from './community';
43
44
  export * from './user-profile';
@@ -1,5 +1,6 @@
1
1
  export enum TOOL_JOB_STATUS {
2
2
  PENDING = 'pending',
3
+ PROCESSING = 'processing',
3
4
  COMPLETED = 'completed',
4
5
  FAILED = 'failed',
5
6
  }
@@ -0,0 +1,65 @@
1
+ import { z } from 'zod';
2
+ import { COMMUNITY_POST_TYPE, IMAGE_FORMAT } from '../../constants';
3
+ import { MusicTrackSchema } from '../tools/music/music-track.schema';
4
+ import { VideoJobParamsSchema } from '../tools/video/video-job.schema';
5
+ import { FileSchema } from '../file.schema';
6
+ import { MusicJobParamsSchema } from '../tools';
7
+
8
+ export const ImageCommunityMediaSchema = z.object({
9
+ type: z.literal(COMMUNITY_POST_TYPE.IMAGE),
10
+ text: z.string().max(10000),
11
+ files: z.array(FileSchema.pick({ url: true })),
12
+ imageFormat: z.nativeEnum(IMAGE_FORMAT).nullable(),
13
+ });
14
+
15
+ export const ImageEditorCommunityMediaSchema = z.object({
16
+ type: z.literal(COMMUNITY_POST_TYPE.IMAGE_EDITOR),
17
+ prompt: z.string(),
18
+ imageUrls: z.array(z.string()).nullable(),
19
+ });
20
+
21
+ export const VideoCommunityMediaSchema = z.object({
22
+ type: z.literal(COMMUNITY_POST_TYPE.VIDEO),
23
+ title: z.string(),
24
+ prompt: z.string(),
25
+ videoUrl: z.string().nullable(),
26
+ params: VideoJobParamsSchema,
27
+ });
28
+
29
+ export const VideoEditorCommunityMediaSchema = z.object({
30
+ type: z.literal(COMMUNITY_POST_TYPE.VIDEO_EDITOR),
31
+ title: z.string(),
32
+ prompt: z.string(),
33
+ inputVideoUrl: z.string(),
34
+ outputVideoUrl: z.string().nullable(),
35
+ });
36
+
37
+ export const MusicCommunityMediaSchema = z.object({
38
+ type: z.literal(COMMUNITY_POST_TYPE.MUSIC),
39
+ params: MusicJobParamsSchema,
40
+ prompt: z.string(),
41
+ tracks: z.array(
42
+ MusicTrackSchema.pick({
43
+ audioUrl: true,
44
+ coverUrl: true,
45
+ duration: true,
46
+ title: true,
47
+ tags: true,
48
+ }),
49
+ ),
50
+ });
51
+
52
+ export const CommunityPostMediaDataSchema = z.discriminatedUnion('type', [
53
+ ImageCommunityMediaSchema,
54
+ ImageEditorCommunityMediaSchema,
55
+ VideoCommunityMediaSchema,
56
+ VideoEditorCommunityMediaSchema,
57
+ MusicCommunityMediaSchema,
58
+ ]);
59
+
60
+ export type CommunityPostMediaData = z.infer<typeof CommunityPostMediaDataSchema>;
61
+ export type ImageCommunityMedia = z.infer<typeof ImageCommunityMediaSchema>;
62
+ export type ImageEditorCommunityMedia = z.infer<typeof ImageEditorCommunityMediaSchema>;
63
+ export type VideoCommunityMedia = z.infer<typeof VideoCommunityMediaSchema>;
64
+ export type VideoEditorCommunityMedia = z.infer<typeof VideoEditorCommunityMediaSchema>;
65
+ export type MusicCommunityMedia = z.infer<typeof MusicCommunityMediaSchema>;
@@ -0,0 +1,47 @@
1
+ import { z } from 'zod';
2
+ import {
3
+ COMMUNITY_POST_STATUS,
4
+ COMMUNITY_POST_TYPE,
5
+ COMMUNITY_POST_VISIBILITY,
6
+ COMMUNITY_TOOL_TYPE,
7
+ } from '../../constants';
8
+ import { CommunityPostMediaDataSchema } from './community-post-media-data.schema';
9
+ import { IconVariantsSchema } from '../icon-variants.schema';
10
+
11
+ export const CommunityPostSchema = z.object({
12
+ uuid: z.string().uuid(),
13
+ userId: z.string().uuid(),
14
+ caption: z.string().nullable(),
15
+ status: z.nativeEnum(COMMUNITY_POST_STATUS),
16
+ visibility: z.nativeEnum(COMMUNITY_POST_VISIBILITY),
17
+ type: z.nativeEnum(COMMUNITY_POST_TYPE),
18
+ mediaData: CommunityPostMediaDataSchema,
19
+ aiModelId: z.string().uuid(),
20
+ aiModelTitle: z.string(),
21
+ aiModelIcons: IconVariantsSchema,
22
+ messageId: z.string().nullable(),
23
+ toolJobId: z.string().nullable(),
24
+ toolType: z.nativeEnum(COMMUNITY_TOOL_TYPE).nullable(),
25
+ views: z.number(),
26
+ likesCount: z.number(),
27
+ publishedAt: z.date().nullable(),
28
+ archivedAt: z.date().nullable(),
29
+ createdAt: z.date(),
30
+ updatedAt: z.date(),
31
+ });
32
+
33
+ export const ResponseCommunityPostSchema = z.object({
34
+ uuid: z.string().uuid(),
35
+ userId: z.string().uuid(),
36
+ caption: z.string().nullable(),
37
+ status: z.nativeEnum(COMMUNITY_POST_STATUS),
38
+ visibility: z.nativeEnum(COMMUNITY_POST_VISIBILITY),
39
+ type: z.nativeEnum(COMMUNITY_POST_TYPE),
40
+ mediaData: CommunityPostMediaDataSchema,
41
+ aiModelId: z.string().uuid(),
42
+ aiModelTitle: z.string(),
43
+ aiModelIcons: IconVariantsSchema,
44
+ views: z.number(),
45
+ likesCount: z.number(),
46
+ publishedAt: z.date().nullable(),
47
+ });
@@ -0,0 +1,2 @@
1
+ export * from './community-post.schema';
2
+ export * from './community-post-media-data.schema';
package/models/index.ts CHANGED
@@ -54,4 +54,5 @@ export * from './webmaster.schema';
54
54
  export * from './webmaster-balance.schema';
55
55
  export * from './user-referrals.schema';
56
56
  export * from './webmaster-click.schema';
57
+ export * from './community';
57
58
  export * from './user-profile.schema';
@@ -1,9 +1,12 @@
1
1
  import { z } from 'zod';
2
2
  import { ToolJobSchema } from '../../tool-job.schema';
3
+ import { USER_REACTION } from '../../../constants';
3
4
 
4
5
  export const ParaphraseToolJobSchema = ToolJobSchema.extend({
5
6
  styleId: z.string().uuid().nullable().optional(),
6
7
  modelId: z.string().uuid().nullable().optional(),
7
8
  userInput: z.string(),
9
+ title: z.string(),
10
+ reaction: z.nativeEnum(USER_REACTION).nullable(),
8
11
  aiOutput: z.string().nullable().optional(),
9
12
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@purpleschool/gptbot",
3
- "version": "0.8.11",
3
+ "version": "0.8.14",
4
4
  "description": "",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",