@purpleschool/gptbot 0.7.52 → 0.7.54-presentations

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 (47) hide show
  1. package/api/controllers/http/presentation.ts +5 -0
  2. package/build/api/controllers/http/presentation.js +4 -0
  3. package/build/commands/chat/create-chat.command.js +1 -3
  4. package/build/commands/chat/find-chat-by-uuid.command.js +1 -1
  5. package/build/commands/chat/find-chats.command.js +1 -3
  6. package/build/commands/chat/get-last-active-chat-command.js +1 -1
  7. package/build/commands/folder/find-folder-by-uuid-with-chats.command.js +1 -3
  8. package/build/commands/tools/presentation/build-blank-slide.command.js +21 -0
  9. package/build/commands/tools/presentation/generate-and-insert-slide.command.js +22 -0
  10. package/build/commands/tools/presentation/index.js +4 -0
  11. package/build/commands/tools/presentation/update-presentation-slides.command.js +25 -0
  12. package/build/commands/tools/presentation/update-presentation.command.js +4 -3
  13. package/build/commands/tools/presentation/update-slide-image-slot.command.js +36 -0
  14. package/build/constants/errors/errors.js +7 -2
  15. package/build/constants/presentation/enums/index.js +1 -0
  16. package/build/constants/presentation/enums/slide-image-slot-action.enum.js +8 -0
  17. package/build/constants/task/enums/task-type.enum.js +1 -0
  18. package/build/models/chat-with-messages.schema.js +9 -0
  19. package/build/models/chat.schema.js +0 -2
  20. package/build/models/index.js +1 -0
  21. package/build/models/tools/presentation/presentation.schema.js +2 -0
  22. package/build/models/tools/presentation/slide-content-edit.schema.js +135 -0
  23. package/build/models/tools/presentation/slide-content.schema.js +22 -20
  24. package/build/models/tools/presentation/slide.schema.js +32 -1
  25. package/commands/chat/create-chat.command.ts +2 -4
  26. package/commands/chat/find-chat-by-uuid.command.ts +2 -2
  27. package/commands/chat/find-chats.command.ts +2 -6
  28. package/commands/chat/get-last-active-chat-command.ts +2 -2
  29. package/commands/folder/find-folder-by-uuid-with-chats.command.ts +2 -6
  30. package/commands/tools/presentation/build-blank-slide.command.ts +23 -0
  31. package/commands/tools/presentation/generate-and-insert-slide.command.ts +27 -0
  32. package/commands/tools/presentation/index.ts +4 -0
  33. package/commands/tools/presentation/update-presentation-slides.command.ts +32 -0
  34. package/commands/tools/presentation/update-presentation.command.ts +5 -4
  35. package/commands/tools/presentation/update-slide-image-slot.command.ts +41 -0
  36. package/constants/errors/errors.ts +7 -2
  37. package/constants/presentation/enums/index.ts +1 -0
  38. package/constants/presentation/enums/slide-image-slot-action.enum.ts +4 -0
  39. package/constants/task/enums/task-type.enum.ts +1 -0
  40. package/models/chat-with-messages.schema.ts +7 -0
  41. package/models/chat.schema.ts +0 -2
  42. package/models/index.ts +1 -0
  43. package/models/tools/presentation/presentation.schema.ts +2 -0
  44. package/models/tools/presentation/slide-content-edit.schema.ts +160 -0
  45. package/models/tools/presentation/slide-content.schema.ts +119 -32
  46. package/models/tools/presentation/slide.schema.ts +38 -0
  47. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- import { ChatSchema } from '../../models';
1
+ import { ChatSchema, ChatWithMessagesSchema } from '../../models';
2
2
  import { z } from 'zod';
3
3
 
4
4
  export namespace GetLastActiveChatCommand {
@@ -8,7 +8,7 @@ export namespace GetLastActiveChatCommand {
8
8
  });
9
9
 
10
10
  export const Response = z.object({
11
- data: ChatSchema,
11
+ data: ChatWithMessagesSchema,
12
12
  });
13
13
 
14
14
  export type Response = z.infer<typeof Response>;
@@ -1,5 +1,5 @@
1
1
  import z from 'zod';
2
- import { ChatSchema, FolderSchema, MessageSchema } from '../../models';
2
+ import { ChatSchema, FolderSchema } from '../../models';
3
3
 
4
4
  export namespace FindFolderByUuidWithChatsCommand {
5
5
  export const RequestParamSchema = FolderSchema.pick({
@@ -17,11 +17,7 @@ export namespace FindFolderByUuidWithChatsCommand {
17
17
 
18
18
  export const ResponseSchema = z.object({
19
19
  data: FolderSchema.extend({
20
- chats: z.array(
21
- ChatSchema.extend({
22
- messages: z.array(MessageSchema),
23
- }),
24
- ),
20
+ chats: z.array(ChatSchema),
25
21
  }),
26
22
  page: z.number(),
27
23
  totalPages: z.number(),
@@ -0,0 +1,23 @@
1
+ import { z } from 'zod';
2
+
3
+ export namespace BuildBlankSlideCommand {
4
+ export const RequestSchema = z.object({
5
+ slideContentType: z.string(),
6
+ });
7
+
8
+ export type Request = z.infer<typeof RequestSchema>;
9
+
10
+ export const ResponseSchema = z.object({
11
+ data: z.object({
12
+ uuid: z.string().uuid(),
13
+ order: z.number(),
14
+ contentTypeId: z.string(),
15
+ layoutId: z.string(),
16
+ content: z.record(z.any()),
17
+ createdAt: z.date(),
18
+ updatedAt: z.date(),
19
+ }),
20
+ });
21
+
22
+ export type Response = z.infer<typeof ResponseSchema>;
23
+ }
@@ -0,0 +1,27 @@
1
+ import { z } from 'zod';
2
+ import { SlideSchema } from '../../../models/tools/presentation';
3
+ import { SLIDE_CONTENT_TYPE, SLIDE_LAYOUT } from '../../../constants';
4
+
5
+ export namespace GenerateAndInsertSlideCommand {
6
+ export const RequestSchema = z.object({
7
+ contentTypeId: z.nativeEnum(SLIDE_CONTENT_TYPE),
8
+ prompt: z.string().min(1).max(10000),
9
+ title: z.string().min(1).max(80),
10
+ position: z.number().min(0),
11
+ layoutId: z.nativeEnum(SLIDE_LAYOUT).optional(),
12
+ });
13
+
14
+ export type Request = z.infer<typeof RequestSchema>;
15
+
16
+ export const RequestParamsSchema = z.object({
17
+ uuid: z.string().uuid(),
18
+ });
19
+
20
+ export type RequestParams = z.infer<typeof RequestParamsSchema>;
21
+
22
+ export const ResponseSchema = z.object({
23
+ data: z.array(SlideSchema),
24
+ });
25
+
26
+ export type Response = z.infer<typeof ResponseSchema>;
27
+ }
@@ -1,3 +1,4 @@
1
+ export * from './build-blank-slide.command';
1
2
  export * from './create-presentation.command';
2
3
  export * from './delete-all-user-presentations.command';
3
4
  export * from './delete-slide-outline.command';
@@ -7,9 +8,12 @@ export * from './find-presentation-by-uuid.command';
7
8
  export * from './find-presentation-outline.command';
8
9
  export * from './find-presentations.command';
9
10
  export * from './generate-presentation-slides.command';
11
+ export * from './generate-and-insert-slide.command';
10
12
  export * from './get-presentation-config.command';
11
13
  export * from './reposition-slide-outline.command';
12
14
  export * from './update-slide-outline.command';
13
15
  export * from './update-presentation-outline.command';
14
16
  export * from './update-presentation.command';
17
+ export * from './update-presentation-slides.command';
18
+ export * from './update-slide-image-slot.command';
15
19
  export * from './update-slide-outline.command';
@@ -0,0 +1,32 @@
1
+ import { z } from 'zod';
2
+ import { SlideBulkUpdateSchema } from '../../../models/tools/presentation';
3
+
4
+ export namespace UpdatePresentationSlidesCommand {
5
+ export const RequestSchema = z.object({
6
+ data: SlideBulkUpdateSchema,
7
+ });
8
+
9
+ export type Request = z.infer<typeof RequestSchema>;
10
+
11
+ export const RequestParamsSchema = z.object({
12
+ uuid: z.string().uuid(),
13
+ });
14
+
15
+ export type RequestParams = z.infer<typeof RequestParamsSchema>;
16
+
17
+ export const ResponseSchema = z.object({
18
+ data: z.array(
19
+ z.object({
20
+ uuid: z.string().uuid(),
21
+ order: z.number(),
22
+ contentTypeId: z.string(),
23
+ layoutId: z.string(),
24
+ content: z.record(z.any()),
25
+ createdAt: z.date(),
26
+ updatedAt: z.date(),
27
+ }),
28
+ ),
29
+ });
30
+
31
+ export type Response = z.infer<typeof ResponseSchema>;
32
+ }
@@ -5,11 +5,12 @@ export namespace UpdatePresentationCommand {
5
5
  export const RequestParamsSchema = z.object({
6
6
  uuid: z.string().uuid(),
7
7
  });
8
+ export type RequestParams = z.infer<typeof RequestParamsSchema>;
8
9
 
9
- export const RequestBodySchema = z.object({
10
- title: z.string(),
11
- });
12
-
10
+ export const RequestBodySchema = PresentationSchema.pick({
11
+ title: true,
12
+ templateId: true,
13
+ }).partial();
13
14
  export type Request = z.infer<typeof RequestBodySchema>;
14
15
 
15
16
  export const ResponseSchema = z.object({
@@ -0,0 +1,41 @@
1
+ import { z } from 'zod';
2
+ import { SLIDE_IMAGE_SLOT_ACTION } from '../../../constants';
3
+ import { SlideImageSlotSchema } from '../../../models/tools/presentation/slide-image-slot.schema';
4
+
5
+ export namespace UpdateSlideImageSlotCommand {
6
+ const ReplacePayload = z.object({
7
+ action: z.literal(SLIDE_IMAGE_SLOT_ACTION.REPLACE),
8
+ url: z.string().url(),
9
+ });
10
+
11
+ const GeneratePayload = z.object({
12
+ action: z.literal(SLIDE_IMAGE_SLOT_ACTION.GENERATE),
13
+ prompt: z.string().min(1).max(1000).optional(),
14
+ });
15
+
16
+ const UpdateImageSlotPayload = z.discriminatedUnion('action', [
17
+ ReplacePayload,
18
+ GeneratePayload,
19
+ ]);
20
+
21
+ export const RequestSchema = z.object({
22
+ payload: UpdateImageSlotPayload,
23
+ });
24
+ export type Request = z.infer<typeof RequestSchema>;
25
+
26
+ export const RequestParamsSchema = z.object({
27
+ presentationId: z.string().uuid(),
28
+ slideId: z.string().uuid(),
29
+ slotId: z.string().uuid().optional(),
30
+ });
31
+ export type RequestParams = z.infer<typeof RequestParamsSchema>;
32
+
33
+ export const ResponseSchema = z.object({
34
+ data: z.object({
35
+ oldImage: z.string().url().optional(),
36
+ newImage: z.string().url(),
37
+ imageSlot: SlideImageSlotSchema,
38
+ }),
39
+ });
40
+ export type Response = z.infer<typeof ResponseSchema>;
41
+ }
@@ -1999,13 +1999,18 @@ export const ERRORS = {
1999
1999
  message: 'Запрос был отклонен, т.к. может не соответствовать политике безопасности сервиса',
2000
2000
  httpCode: 400,
2001
2001
  },
2002
- FAILED_TO_SAVE_USER_STATISTICS: {
2002
+ REVIEW_ALREADY_EXISTS: {
2003
2003
  code: 'A409',
2004
+ message: 'Отзыв уже существует',
2005
+ httpCode: 400,
2006
+ },
2007
+ FAILED_TO_SAVE_USER_STATISTICS: {
2008
+ code: 'A410',
2004
2009
  message: 'не удалось сохранить статистику пользователя',
2005
2010
  httpCode: 500,
2006
2011
  },
2007
2012
  FAILED_TO_GET_USER_STATISTICS: {
2008
- code: 'A410',
2013
+ code: 'A411',
2009
2014
  message: 'не удалось получить статистику пользователя',
2010
2015
  httpCode: 500,
2011
2016
  },
@@ -3,3 +3,4 @@ export * from './slide-content-type.enum';
3
3
  export * from './slide-icon-slot-status.enum';
4
4
  export * from './slide-image-slot.status.enum';
5
5
  export * from './slide-layout.enum';
6
+ export * from './slide-image-slot-action.enum';
@@ -0,0 +1,4 @@
1
+ export enum SLIDE_IMAGE_SLOT_ACTION {
2
+ REPLACE = 'REPLACE',
3
+ GENERATE = 'GENERATE',
4
+ }
@@ -1,4 +1,5 @@
1
1
  export enum TASK_TYPE {
2
2
  CLICK = 'click',
3
3
  TELEGRAM_CHANNEL_INVITE = 'telegram_channel_invite',
4
+ REVIEW = 'review',
4
5
  }
@@ -0,0 +1,7 @@
1
+ import { z } from 'zod';
2
+ import { ChatSchema } from './chat.schema';
3
+ import { MessageSchema } from './message.schema';
4
+
5
+ export const ChatWithMessagesSchema = ChatSchema.extend({
6
+ messages: z.array(MessageSchema),
7
+ });
@@ -1,6 +1,5 @@
1
1
  import { z } from 'zod';
2
2
  import { CHAT_STATUS_ENUM, TChatStatusEnum } from '../constants';
3
- import { MessageSchema } from './message.schema';
4
3
 
5
4
  export const ChatSchema = z.object({
6
5
  uuid: z.string().uuid(),
@@ -10,7 +9,6 @@ export const ChatSchema = z.object({
10
9
  aIModelId: z.string().uuid(),
11
10
  title: z.string(),
12
11
  chatStatus: z.enum(Object.values(CHAT_STATUS_ENUM) as [TChatStatusEnum]),
13
- messages: z.array(MessageSchema),
14
12
  folderId: z.string().nullable(),
15
13
 
16
14
  createdAt: z.date(),
package/models/index.ts CHANGED
@@ -4,6 +4,7 @@ export * from './ai-model-formatted.schema';
4
4
  export * from './ai-model.schema';
5
5
  export * from './ai-vendor.schema';
6
6
  export * from './category.schema';
7
+ export * from './chat-with-messages.schema';
7
8
  export * from './chat.schema';
8
9
  export * from './cloud-payments-receipt.schema';
9
10
  export * from './course-author.schema';
@@ -13,6 +13,8 @@ export const PresentationSchema = z.object({
13
13
  templateId: z.string(),
14
14
  downloadUrl: z.string().nullable(),
15
15
  slideCount: z.number(),
16
+ lastContentUpdateAt: z.date().nullable(),
17
+ lastPptxExportedAt: z.date().nullable(),
16
18
  createdAt: z.date(),
17
19
  updatedAt: z.date(),
18
20
  });
@@ -0,0 +1,160 @@
1
+ import z from 'zod';
2
+ import {
3
+ ICoverSlideDataStructure,
4
+ IThankYouSlideDataStructure,
5
+ ITextSlideDataStructure,
6
+ IStructuredListSlideDataStructure,
7
+ IContentsSlideDataStructure,
8
+ IImageSlideDataStructure,
9
+ ISectionBreakSlideDataStructure,
10
+ ITableSlideDataStructure,
11
+ SLIDE_CHART_TYPE,
12
+ IBarChartSlideDataStructure,
13
+ IChartSlideDataStructure,
14
+ ImageSlotSchema,
15
+ } from './slide-content.schema';
16
+ import { SLIDE_CONTENT_TYPE } from '../../../constants';
17
+
18
+ export const CoverSlideDataUserEditSchema = z.object({
19
+ contentType: z.literal(SLIDE_CONTENT_TYPE.COVER),
20
+ title: z.string().min(1).max(500),
21
+ author: z.object({
22
+ label: z.string().min(1).max(100),
23
+ value: z.string().min(1).max(200),
24
+ }),
25
+ date: z.object({
26
+ label: z.string().min(1).max(100),
27
+ value: z.string().min(1).max(200),
28
+ }),
29
+ email: z.object({
30
+ label: z.string().min(1).max(100),
31
+ value: z.string().min(1).max(200),
32
+ }),
33
+ version: z.literal(1),
34
+ }) satisfies z.ZodType<ICoverSlideDataStructure>;
35
+
36
+ export const ThankYouSlideDataUserEditSchema = z.object({
37
+ contentType: z.literal(SLIDE_CONTENT_TYPE.THANK_YOU),
38
+ title: z.string().min(1).max(500),
39
+ author: z.object({
40
+ label: z.string().min(1).max(100),
41
+ value: z.string().min(1).max(200),
42
+ }),
43
+ date: z.object({
44
+ label: z.string().min(1).max(100),
45
+ value: z.string().min(1).max(200),
46
+ }),
47
+ email: z.object({
48
+ label: z.string().min(1).max(100),
49
+ value: z.string().min(1).max(200),
50
+ }),
51
+ version: z.literal(1),
52
+ }) satisfies z.ZodType<IThankYouSlideDataStructure>;
53
+
54
+ export const TextSlideDataUserEditSchema = z.object({
55
+ contentType: z.literal(SLIDE_CONTENT_TYPE.TEXT),
56
+ title: z.string().min(1).max(500),
57
+ description: z.string().min(1).max(3000),
58
+ version: z.literal(1),
59
+ }) satisfies z.ZodType<ITextSlideDataStructure>;
60
+
61
+ export const StructuredListSlideDataUserEditSchema = z.object({
62
+ contentType: z.literal(SLIDE_CONTENT_TYPE.STRUCTURED_LIST),
63
+ title: z.string().min(1).max(500),
64
+ description: z.string().min(1).max(1000),
65
+ list: z
66
+ .array(
67
+ z.object({
68
+ title: z.string().min(1).max(200),
69
+ description: z.string().min(1).max(500),
70
+ }),
71
+ )
72
+ .min(1)
73
+ .max(10),
74
+ version: z.literal(1),
75
+ }) satisfies z.ZodType<IStructuredListSlideDataStructure>;
76
+
77
+ export const ContentsSlideDataUserEditSchema = z.object({
78
+ contentType: z.literal(SLIDE_CONTENT_TYPE.CONTENTS),
79
+ title: z.string().min(1).max(500),
80
+ items: z
81
+ .array(
82
+ z.object({
83
+ pageNumber: z.number(),
84
+ title: z.string().min(1).max(500),
85
+ }),
86
+ )
87
+ .min(1)
88
+ .max(50),
89
+ version: z.literal(1),
90
+ }) satisfies z.ZodType<IContentsSlideDataStructure>;
91
+
92
+ export const ImageSlideDataUserEditSchema = z.object({
93
+ contentType: z.literal(SLIDE_CONTENT_TYPE.TEXT_WITH_IMAGE),
94
+ title: z.string().min(1).max(500),
95
+ description: z.string().min(1).max(2000),
96
+ imageSlot: ImageSlotSchema,
97
+ version: z.literal(1),
98
+ }) satisfies z.ZodType<IImageSlideDataStructure>;
99
+
100
+ export const SectionBreakSlideDataUserEditSchema = z.object({
101
+ contentType: z.literal(SLIDE_CONTENT_TYPE.SECTION_BREAK),
102
+ title: z.string().min(1).max(500),
103
+ description: z.string().min(1).max(500),
104
+ version: z.literal(1),
105
+ }) satisfies z.ZodType<ISectionBreakSlideDataStructure>;
106
+
107
+ export const TableSlideDataUserEditSchema = z.object({
108
+ contentType: z.literal(SLIDE_CONTENT_TYPE.TABLE),
109
+ title: z.string().min(1).max(500),
110
+ description: z.string().min(1).max(1000),
111
+ table: z.object({
112
+ columnHeaders: z.array(z.string().min(1).max(200)).min(1).max(20),
113
+ rows: z
114
+ .array(z.array(z.string().min(1).max(500)))
115
+ .min(1)
116
+ .max(20),
117
+ hasRowHeaders: z.boolean(),
118
+ hasSummaryRow: z.boolean(),
119
+ }),
120
+ version: z.literal(1),
121
+ }) satisfies z.ZodType<ITableSlideDataStructure>;
122
+
123
+ export const BarChartSlideDataUserEditSchema = z.object({
124
+ type: z.literal(SLIDE_CHART_TYPE.BAR),
125
+ categories: z.array(z.string().min(1).max(200)).min(1).max(50),
126
+ series: z
127
+ .array(
128
+ z.object({
129
+ name: z.string().min(1).max(200),
130
+ data: z.array(z.number()),
131
+ type: z.number().min(0).max(11),
132
+ }),
133
+ )
134
+ .min(1)
135
+ .max(5),
136
+ yAxisLabel: z.string().max(200).optional(),
137
+ unit: z.string().max(50).optional(),
138
+ version: z.literal(1),
139
+ }) satisfies z.ZodType<IBarChartSlideDataStructure>;
140
+
141
+ export const ChartSlideDataUserEditSchema = z.object({
142
+ contentType: z.literal(SLIDE_CONTENT_TYPE.CHART),
143
+ title: z.string().min(1).max(500),
144
+ description: z.string().min(1).max(2000),
145
+ chart: z.discriminatedUnion('type', [BarChartSlideDataUserEditSchema]),
146
+ version: z.literal(1),
147
+ }) satisfies z.ZodType<IChartSlideDataStructure>;
148
+
149
+ export const SlideContentUserEditSchema = z.discriminatedUnion('contentType', [
150
+ CoverSlideDataUserEditSchema,
151
+ StructuredListSlideDataUserEditSchema,
152
+ TextSlideDataUserEditSchema,
153
+ ContentsSlideDataUserEditSchema,
154
+ SectionBreakSlideDataUserEditSchema,
155
+ ImageSlideDataUserEditSchema,
156
+ ThankYouSlideDataUserEditSchema,
157
+ TableSlideDataUserEditSchema,
158
+ ChartSlideDataUserEditSchema,
159
+ ]);
160
+ export type SlideContentUserEdit = z.infer<typeof SlideContentUserEditSchema>;