@purpleschool/student-works 1.2.2 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (121) hide show
  1. package/api/controller/http/index.ts +1 -0
  2. package/api/controller/http/presentation.ts +37 -0
  3. package/api/routes.ts +90 -0
  4. package/build/api/controller/http/index.js +1 -0
  5. package/build/api/controller/http/presentation.js +33 -0
  6. package/build/api/routes.js +52 -0
  7. package/build/commands/index.js +1 -0
  8. package/build/commands/presentation/build-blank-slide.command.js +16 -0
  9. package/build/commands/presentation/create-presentation.command.js +17 -0
  10. package/build/commands/presentation/delete-all-user-presentations.command.js +9 -0
  11. package/build/commands/presentation/delete-presentation.command.js +11 -0
  12. package/build/commands/presentation/delete-slide-outline.command.js +12 -0
  13. package/build/commands/presentation/export-presentation-as-pptx.command.js +17 -0
  14. package/build/commands/presentation/find-presentation-by-uuid.command.js +14 -0
  15. package/build/commands/presentation/find-presentation-outline.command.js +14 -0
  16. package/build/commands/presentation/find-presentations.command.js +18 -0
  17. package/build/commands/presentation/generate-and-insert-slide.command.js +22 -0
  18. package/build/commands/presentation/generate-presentation-slides.command.js +14 -0
  19. package/build/commands/presentation/get-presentation-config.command.js +11 -0
  20. package/build/commands/presentation/index.js +39 -0
  21. package/build/commands/presentation/presentation-generate-report.command.js +17 -0
  22. package/build/commands/presentation/presentation-paraphrase.command.js +20 -0
  23. package/build/commands/presentation/reposition-slide-outline.command.js +15 -0
  24. package/build/commands/presentation/set-reaction-to-presentation.command.js +28 -0
  25. package/build/commands/presentation/update-presentation-outline.command.js +15 -0
  26. package/build/commands/presentation/update-presentation-slides.command.js +25 -0
  27. package/build/commands/presentation/update-presentation.command.js +18 -0
  28. package/build/commands/presentation/update-slide-image-slot.command.js +34 -0
  29. package/build/commands/presentation/update-slide-outline.command.js +23 -0
  30. package/build/commands/presentation/update-slide.command.js +19 -0
  31. package/build/constants/errors/errors.js +236 -0
  32. package/build/constants/index.js +1 -0
  33. package/build/constants/presentation/enums/index.js +26 -0
  34. package/build/constants/presentation/enums/presentation-ai-action-call-status.enum.js +9 -0
  35. package/build/constants/presentation/enums/presentation-ai-action-pricing-type.enum.js +8 -0
  36. package/build/constants/presentation/enums/presentation-ai-action-type.enum.js +8 -0
  37. package/build/constants/presentation/enums/presentation-stage.enum.js +14 -0
  38. package/build/constants/presentation/enums/slide-content-type.enum.js +16 -0
  39. package/build/constants/presentation/enums/slide-icon-slot-status.enum.js +10 -0
  40. package/build/constants/presentation/enums/slide-image-slot-action.enum.js +8 -0
  41. package/build/constants/presentation/enums/slide-image-slot.status.enum.js +10 -0
  42. package/build/constants/presentation/enums/slide-layout.enum.js +8 -0
  43. package/build/constants/presentation/index.js +18 -0
  44. package/build/constants/presentation/maps/index.js +17 -0
  45. package/build/constants/presentation/maps/slide-layout-map.constant.js +17 -0
  46. package/build/helpers/index.js +1 -0
  47. package/build/helpers/presentation/calculate-presentation-ai-action-price.util.js +16 -0
  48. package/build/helpers/presentation/index.js +17 -0
  49. package/build/models/index.js +1 -0
  50. package/build/models/language.schema.js +11 -0
  51. package/build/models/presentation/index.js +24 -0
  52. package/build/models/presentation/pptx-export-payload.schema.js +216 -0
  53. package/build/models/presentation/presentation-ai-action.schema.js +27 -0
  54. package/build/models/presentation/presentation-config.schema.js +21 -0
  55. package/build/models/presentation/presentation-template.schema.js +13 -0
  56. package/build/models/presentation/presentation.schema.js +28 -0
  57. package/build/models/presentation/slide-content-edit.schema.js +146 -0
  58. package/build/models/presentation/slide-content-type.schema.js +14 -0
  59. package/build/models/presentation/slide-content.schema.js +358 -0
  60. package/build/models/presentation/slide-icon-slot.schema.js +15 -0
  61. package/build/models/presentation/slide-image-slot.schema.js +16 -0
  62. package/build/models/presentation/slide-outline.schema.js +50 -0
  63. package/build/models/presentation/slide.schema.js +58 -0
  64. package/commands/index.ts +1 -0
  65. package/commands/presentation/build-blank-slide.command.ts +18 -0
  66. package/commands/presentation/create-presentation.command.ts +19 -0
  67. package/commands/presentation/delete-all-user-presentations.command.ts +9 -0
  68. package/commands/presentation/delete-presentation.command.ts +13 -0
  69. package/commands/presentation/delete-slide-outline.command.ts +12 -0
  70. package/commands/presentation/export-presentation-as-pptx.command.ts +20 -0
  71. package/commands/presentation/find-presentation-by-uuid.command.ts +16 -0
  72. package/commands/presentation/find-presentation-outline.command.ts +16 -0
  73. package/commands/presentation/find-presentations.command.ts +18 -0
  74. package/commands/presentation/generate-and-insert-slide.command.ts +27 -0
  75. package/commands/presentation/generate-presentation-slides.command.ts +16 -0
  76. package/commands/presentation/get-presentation-config.command.ts +10 -0
  77. package/commands/presentation/index.ts +23 -0
  78. package/commands/presentation/presentation-generate-report.command.ts +21 -0
  79. package/commands/presentation/presentation-paraphrase.command.ts +26 -0
  80. package/commands/presentation/reposition-slide-outline.command.ts +17 -0
  81. package/commands/presentation/set-reaction-to-presentation.command.ts +33 -0
  82. package/commands/presentation/update-presentation-outline.command.ts +18 -0
  83. package/commands/presentation/update-presentation-slides.command.ts +32 -0
  84. package/commands/presentation/update-presentation.command.ts +21 -0
  85. package/commands/presentation/update-slide-image-slot.command.ts +40 -0
  86. package/commands/presentation/update-slide-outline.command.ts +26 -0
  87. package/commands/presentation/update-slide.command.ts +25 -0
  88. package/constants/errors/errors.ts +236 -0
  89. package/constants/index.ts +1 -0
  90. package/constants/presentation/enums/index.ts +10 -0
  91. package/constants/presentation/enums/presentation-ai-action-call-status.enum.ts +5 -0
  92. package/constants/presentation/enums/presentation-ai-action-pricing-type.enum.ts +4 -0
  93. package/constants/presentation/enums/presentation-ai-action-type.enum.ts +4 -0
  94. package/constants/presentation/enums/presentation-stage.enum.ts +13 -0
  95. package/constants/presentation/enums/slide-content-type.enum.ts +12 -0
  96. package/constants/presentation/enums/slide-icon-slot-status.enum.ts +6 -0
  97. package/constants/presentation/enums/slide-image-slot-action.enum.ts +4 -0
  98. package/constants/presentation/enums/slide-image-slot.status.enum.ts +6 -0
  99. package/constants/presentation/enums/slide-layout.enum.ts +4 -0
  100. package/constants/presentation/index.ts +2 -0
  101. package/constants/presentation/maps/index.ts +1 -0
  102. package/constants/presentation/maps/slide-layout-map.constant.ts +15 -0
  103. package/helpers/index.ts +1 -0
  104. package/helpers/presentation/calculate-presentation-ai-action-price.util.ts +20 -0
  105. package/helpers/presentation/index.ts +1 -0
  106. package/models/index.ts +1 -0
  107. package/models/language.schema.ts +9 -0
  108. package/models/presentation/index.ts +8 -0
  109. package/models/presentation/pptx-export-payload.schema.ts +246 -0
  110. package/models/presentation/presentation-ai-action.schema.ts +30 -0
  111. package/models/presentation/presentation-config.schema.ts +20 -0
  112. package/models/presentation/presentation-template.schema.ts +11 -0
  113. package/models/presentation/presentation.schema.ts +29 -0
  114. package/models/presentation/slide-content-edit.schema.ts +175 -0
  115. package/models/presentation/slide-content-type.schema.ts +13 -0
  116. package/models/presentation/slide-content.schema.ts +571 -0
  117. package/models/presentation/slide-icon-slot.schema.ts +13 -0
  118. package/models/presentation/slide-image-slot.schema.ts +14 -0
  119. package/models/presentation/slide-outline.schema.ts +58 -0
  120. package/models/presentation/slide.schema.ts +66 -0
  121. package/package.json +2 -2
@@ -0,0 +1,571 @@
1
+ import { z } from 'zod';
2
+ import { SLIDE_CONTENT_TYPE } from '../../constants';
3
+ export enum SLIDE_CHART_TYPE {
4
+ BAR = 'BAR',
5
+ }
6
+
7
+ export const ImageSlotSchema = z.object({
8
+ uuid: z
9
+ .string()
10
+ .uuid()
11
+ .describe('Generate a valid uuid for image slot, that will be used for future lookups'),
12
+ prompt: z
13
+ .string()
14
+ .describe(
15
+ 'Image generation prompt. MUST be written in ENGLISH regardless of the presentation language. ' +
16
+ 'AI image generators excel at: atmospheric scenes, landscapes, cityscapes, architecture, nature, abstract light and texture, anonymous silhouettes, artistic photography. ' +
17
+ 'AI fundamentally cannot render accurately: legible text on any surface, complex diagrams or flowcharts, data charts/graphs, specific product logos, clocks, precise mechanical parts. ' +
18
+ 'Choose scene types from the first category. Avoid anything in the second. ' +
19
+ 'Structure: [subject/scene] → [mood/atmosphere] → [lighting] → [visual style]. ' +
20
+ 'Evoke the emotional register of the slide — do not illustrate the topic literally. ' +
21
+ 'MODERATION: if the slide topic involves conflict, suffering, politics, or crime, redirect to abstract/atmospheric imagery (fog, ruins, empty landscapes) rather than depicting the subject directly — flagged prompts produce empty placeholders. ' +
22
+ 'GOOD: "A lone figure on an observation deck at dusk gazing over an illuminated city. Cinematic wide-angle, golden-hour light, photorealistic." ' +
23
+ 'BAD: "A bar chart showing quarterly growth. A robot at a laptop with code on the screen."',
24
+ ),
25
+ });
26
+ export type ImageSlot = z.infer<typeof ImageSlotSchema>;
27
+
28
+ export const IconSlotSchema = z.object({
29
+ uuid: z
30
+ .string()
31
+ .uuid()
32
+ .describe('Generate a valid uuid for icon slot, that will be used for future lookups'),
33
+ prompt: z.string().describe('Provide a search query for an fitting icon. MUST BE IN ENGLISH'),
34
+ });
35
+ export type IconSlot = z.infer<typeof IconSlotSchema>;
36
+
37
+ export interface ICoverSlideDataStructure {
38
+ contentType: SLIDE_CONTENT_TYPE.COVER;
39
+ title: string;
40
+ author: { label: string; value: string };
41
+ date: { label: string; value: string };
42
+ email: { label: string; value: string };
43
+ version: 1;
44
+ }
45
+
46
+ export interface IThankYouSlideDataStructure {
47
+ contentType: SLIDE_CONTENT_TYPE.THANK_YOU;
48
+ title: string;
49
+ author: { label: string; value: string };
50
+ date: { label: string; value: string };
51
+ email: { label: string; value: string };
52
+ version: 1;
53
+ }
54
+
55
+ export interface ITextSlideDataStructure {
56
+ contentType: SLIDE_CONTENT_TYPE.TEXT;
57
+ title: string;
58
+ description: string;
59
+ version: 1;
60
+ }
61
+
62
+ export interface IStructuredListSlideDataStructure {
63
+ contentType: SLIDE_CONTENT_TYPE.STRUCTURED_LIST;
64
+ title: string;
65
+ description: string;
66
+ list: Array<{ title: string; description: string }>;
67
+ version: 1;
68
+ }
69
+
70
+ export interface IContentsSlideDataStructure {
71
+ contentType: SLIDE_CONTENT_TYPE.CONTENTS;
72
+ title: string;
73
+ items: Array<{ pageNumber: number; title: string }>;
74
+ version: 1;
75
+ }
76
+
77
+ export interface IImageSlideDataStructure {
78
+ contentType: SLIDE_CONTENT_TYPE.TEXT_WITH_IMAGE;
79
+ title: string;
80
+ description: string;
81
+ imageSlot?: ImageSlot;
82
+ version: 1;
83
+ }
84
+
85
+ export interface ISectionBreakSlideDataStructure {
86
+ contentType: SLIDE_CONTENT_TYPE.SECTION_BREAK;
87
+ title: string;
88
+ description: string;
89
+ version: 1;
90
+ }
91
+
92
+ export interface ITableSlideDataStructure {
93
+ contentType: SLIDE_CONTENT_TYPE.TABLE;
94
+ title: string;
95
+ description: string;
96
+ table: {
97
+ columnHeaders: string[];
98
+ rows: string[][];
99
+ hasRowHeaders: boolean;
100
+ hasSummaryRow: boolean;
101
+ };
102
+ version: 1;
103
+ }
104
+
105
+ export interface IBarChartSlideDataStructure {
106
+ type: SLIDE_CHART_TYPE.BAR;
107
+ categories: string[];
108
+ series: Array<{ name: string; data: number[]; type: number }>;
109
+ yAxisLabel?: string;
110
+ unit?: string;
111
+ version: 1;
112
+ }
113
+
114
+ export interface IChartSlideDataStructure {
115
+ contentType: SLIDE_CONTENT_TYPE.CHART;
116
+ title: string;
117
+ description: string;
118
+ chart: IBarChartSlideDataStructure;
119
+ version: 1;
120
+ }
121
+
122
+ export interface ITimelineSlideDataStructure {
123
+ contentType: SLIDE_CONTENT_TYPE.TIMELINE;
124
+ title: string;
125
+ description: string;
126
+ timeline: {
127
+ events: Array<{
128
+ date: string;
129
+ title: string;
130
+ description: string;
131
+ }>;
132
+ };
133
+ version: 1;
134
+ }
135
+
136
+ export const CoverSlideDataSchema = z.object({
137
+ contentType: z.literal(SLIDE_CONTENT_TYPE.COVER),
138
+ title: z.string().describe('Slide title in about 6 words').min(10).max(150),
139
+ author: z.object({
140
+ label: z.string().describe('Literal "Author" in presentation\'s language'),
141
+ value: z
142
+ .string()
143
+ .describe('Literal "Author of the presentation" in presentation\'s language'),
144
+ }),
145
+ date: z.object({
146
+ label: z.string().describe('Literal "Date" in presentation\'s language'),
147
+ value: z
148
+ .string()
149
+ .describe(
150
+ 'Date of the presentation in the "dd month yyyy" format in presentation\'s locale',
151
+ ),
152
+ }),
153
+ email: z.object({
154
+ label: z.string().describe('Just default word "Email"'),
155
+ value: z.string().describe('Just default "email@example.com"'),
156
+ }),
157
+ version: z.literal(1),
158
+ }) satisfies z.ZodType<ICoverSlideDataStructure>;
159
+ export type CoverSlideData = z.infer<typeof CoverSlideDataSchema>;
160
+
161
+ export const ThankYouSlideDataSchema = z.object({
162
+ contentType: z.literal(SLIDE_CONTENT_TYPE.THANK_YOU),
163
+ title: z
164
+ .string()
165
+ .describe('"Thank you for your attention" in presentation\'s language')
166
+ .min(10)
167
+ .max(150),
168
+ author: z.object({
169
+ label: z.string().describe('"Author" in presentation\'s language'),
170
+ value: z.string().describe('"Author of the presentation" in presentation\'s language'),
171
+ }),
172
+ date: z.object({
173
+ label: z.string().describe('"Date" in presentation\'s language'),
174
+ value: z
175
+ .string()
176
+ .describe(
177
+ 'Date of the presentation in the "dd month yyyy" format in presentation\'s locale',
178
+ ),
179
+ }),
180
+ email: z.object({
181
+ label: z.string().describe('Just default word "Email"'),
182
+ value: z.string().describe('Just default "email@example.com"'),
183
+ }),
184
+ version: z.literal(1),
185
+ }) satisfies z.ZodType<IThankYouSlideDataStructure>;
186
+ export type ThankYouSlideData = z.infer<typeof ThankYouSlideDataSchema>;
187
+
188
+ export const StructuredListSlideDataSchema = z.object({
189
+ contentType: z.literal(SLIDE_CONTENT_TYPE.STRUCTURED_LIST),
190
+ title: z
191
+ .string()
192
+ .describe(
193
+ 'Slide headline — 2–4 words naming the group. A noun phrase, NOT a full sentence. Displayed in very large font on the left panel.',
194
+ )
195
+ .min(5)
196
+ .max(40),
197
+ description: z
198
+ .string()
199
+ .describe(
200
+ 'One framing sentence answering "What are these 4 things about?". Displayed in small text below the title on the left panel.',
201
+ )
202
+ .min(30)
203
+ .max(80),
204
+ list: z
205
+ .array(
206
+ z.object({
207
+ title: z
208
+ .string()
209
+ .describe(
210
+ '2–4 concrete words. A noun phrase or short verb phrase. All 4 titles MUST be grammatically parallel. Displayed in bold next to a large number (01–04).',
211
+ )
212
+ .min(3)
213
+ .max(30),
214
+ description: z
215
+ .string()
216
+ .describe(
217
+ 'ONE complete sentence that expands on the title with a specific fact or benefit. NEVER just restate the title. NEVER cut short mid-word or mid-sentence. All 4 descriptions must be roughly equal in length.',
218
+ )
219
+ .min(50)
220
+ .max(100),
221
+ }),
222
+ )
223
+ .length(4),
224
+ version: z.literal(1),
225
+ }) satisfies z.ZodType<IStructuredListSlideDataStructure>;
226
+ export type StructuredListSlideData = z.infer<typeof StructuredListSlideDataSchema>;
227
+
228
+ export const TextSlideDataSchema = z.object({
229
+ contentType: z.literal(SLIDE_CONTENT_TYPE.TEXT),
230
+ title: z
231
+ .string()
232
+ .describe(
233
+ 'Slide headline rendered in very large bold font. Keep to 3–7 words (max 70 characters). It should name the topic or thesis — not summarise all content.',
234
+ )
235
+ .min(10)
236
+ .max(70),
237
+ description: z
238
+ .string()
239
+ .describe(
240
+ 'Expository prose split into 2–3 paragraphs separated by \\n\\n (double newline). Total length 300–800 characters. ' +
241
+ 'Use **bold** to highlight 1–3 key terms per paragraph (NOT entire sentences). ' +
242
+ 'Use *italics* for definitions, counter-points, or light emphasis (1 per paragraph max). ' +
243
+ 'NO bullet points, NO markdown headers, NO numbered lists. ' +
244
+ 'Each paragraph covers ONE focused idea: e.g. context → main argument → implication. ' +
245
+ 'Do NOT start consecutive paragraphs with the same word. Do NOT cut text short mid-sentence.',
246
+ )
247
+ .min(300)
248
+ .max(800),
249
+ version: z.literal(1),
250
+ }) satisfies z.ZodType<ITextSlideDataStructure>;
251
+ export type TextSlideData = z.infer<typeof TextSlideDataSchema>;
252
+
253
+ export const ContentsSlideDataSchema = z.object({
254
+ contentType: z.literal(SLIDE_CONTENT_TYPE.CONTENTS),
255
+ title: z
256
+ .string()
257
+ .describe(
258
+ 'This slide represents table of contents for the presentation and must be named "Contents" in the presentation language',
259
+ )
260
+ .min(10)
261
+ .max(200),
262
+ items: z
263
+ .array(
264
+ z.object({
265
+ pageNumber: z.number().describe('Page number of the slide'),
266
+ title: z.string().min(1).describe('Title of the slide on said page'),
267
+ }),
268
+ )
269
+ .min(1)
270
+ .describe(
271
+ 'List of slide titles. Must be relevant and generated after all the slides are generated',
272
+ ),
273
+ version: z.literal(1),
274
+ }) satisfies z.ZodType<IContentsSlideDataStructure>;
275
+ export type ContentsSlideData = z.infer<typeof ContentsSlideDataSchema>;
276
+
277
+ export const ImageSlideDataSchema = z
278
+ .object({
279
+ contentType: z.literal(SLIDE_CONTENT_TYPE.TEXT_WITH_IMAGE),
280
+ title: z
281
+ .string()
282
+ .describe(
283
+ 'Slide headline rendered in very large bold font on the LEFT column. Keep to 3–7 words (max 70 characters). Aim for under 50 characters to avoid overflow. A noun phrase or short declarative phrase — NOT a full sentence.',
284
+ )
285
+ .min(10)
286
+ .max(70),
287
+ description: z
288
+ .string()
289
+ .describe(
290
+ 'Expository prose in 2 paragraphs separated by \\n\\n (double newline). Total length 150–500 characters. ' +
291
+ 'Use **bold** for 1–2 key terms per paragraph (NOT entire sentences). ' +
292
+ 'Use *italics* for definitions or emphasis at most once per paragraph. ' +
293
+ 'NO bullet points, NO headers, NO numbered lists. ' +
294
+ 'Each paragraph covers ONE focused idea. NEVER reference or describe the image in the text. ' +
295
+ 'The image provides visual atmosphere — the text must stand alone as complete, readable prose.',
296
+ )
297
+ .min(150)
298
+ .max(500),
299
+ imageSlot: ImageSlotSchema,
300
+ version: z.literal(1),
301
+ })
302
+ .describe(
303
+ 'Slide with a large title and prose description on the left, and a full-bleed supporting image on the right.',
304
+ ) satisfies z.ZodType<IImageSlideDataStructure>;
305
+ export type ImageSlideData = z.infer<typeof ImageSlideDataSchema>;
306
+
307
+ export const SectionBreakSlideDataSchema = z.object({
308
+ contentType: z.literal(SLIDE_CONTENT_TYPE.SECTION_BREAK),
309
+ title: z
310
+ .string()
311
+ .describe(
312
+ 'The section name — a clean noun phrase of 3–6 words that names the thematic block which follows. ' +
313
+ 'NEVER prefix with "Раздел:", "Section:", "Part:", "Глава:", or any structural label. ' +
314
+ 'NEVER include numbers. Just the name itself. ' +
315
+ 'GOOD: "Технологические достижения". BAD: "Раздел 2: Технологические достижения".',
316
+ )
317
+ .min(5)
318
+ .max(60),
319
+ description: z
320
+ .string()
321
+ .describe(
322
+ 'One sentence (up to 100 characters) that briefly hints at the content of the upcoming section. ' +
323
+ 'Should complement the title without repeating it. No markdown, no labels.',
324
+ )
325
+ .min(10)
326
+ .max(120),
327
+ version: z.literal(1),
328
+ }) satisfies z.ZodType<ISectionBreakSlideDataStructure>;
329
+ export type SectionBreakSlideData = z.infer<typeof SectionBreakSlideDataSchema>;
330
+
331
+ export const TableSlideDataSchema = z.object({
332
+ contentType: z.literal(SLIDE_CONTENT_TYPE.TABLE),
333
+ title: z
334
+ .string()
335
+ .describe(
336
+ 'Table name — 2–4 words rendered as large bold heading above the table. ' +
337
+ 'Doubles as both the slide title and the table heading. Keep concise.',
338
+ )
339
+ .min(5)
340
+ .max(55),
341
+ description: z
342
+ .string()
343
+ .describe(
344
+ 'One short sentence (max 80 characters) describing what the table shows. ' +
345
+ 'Rendered in small gray text below the title. No markdown.',
346
+ )
347
+ .min(10)
348
+ .max(100),
349
+ table: z.object({
350
+ columnHeaders: z
351
+ .array(
352
+ z
353
+ .string()
354
+ .min(1)
355
+ .max(20)
356
+ .describe(
357
+ 'Column label. Keep SHORT — 1–3 words. Include units here (e.g., "Сумма, ₽"), not in cells. ' +
358
+ 'When hasRowHeaders is true, the first header should be a single space " " or a short category label.',
359
+ ),
360
+ )
361
+ .min(2)
362
+ .max(5)
363
+ .describe(
364
+ 'Column header labels. MAXIMUM 5 columns total. Recommended 3–4 data columns. ' +
365
+ 'More columns will overflow the slide — NEVER exceed 5.',
366
+ ),
367
+ rows: z
368
+ .array(
369
+ z
370
+ .array(
371
+ z
372
+ .string()
373
+ .min(1)
374
+ .max(40)
375
+ .describe(
376
+ 'Cell content. NUMERIC tables: numbers only (e.g., "1 200", "85%"). ' +
377
+ 'TEXTUAL tables: 1–3 words maximum — keywords or short phrases ONLY, NEVER full sentences. ' +
378
+ 'Row header cells (first cell when hasRowHeaders=true): category label, max 22 characters.',
379
+ ),
380
+ )
381
+ .describe('One row. Cell count MUST equal columnHeaders length exactly.'),
382
+ )
383
+ .min(2)
384
+ .max(4)
385
+ .describe(
386
+ 'Table rows. Max 4 rows total. ' +
387
+ 'When hasSummaryRow is true, the LAST row is the summary row — so at most 3 regular rows + 1 summary = 4 total. ' +
388
+ 'NEVER exceed 4 rows.',
389
+ ),
390
+ hasRowHeaders: z
391
+ .boolean()
392
+ .describe(
393
+ 'True when the first cell of each row is a descriptive label or category (pivot table). ' +
394
+ 'False for plain data tables where all cells are equivalent data.',
395
+ ),
396
+ hasSummaryRow: z
397
+ .boolean()
398
+ .describe(
399
+ 'True when the last row contains totals, averages, or aggregated values. ' +
400
+ 'That summary row must be the last element of the rows array.',
401
+ ),
402
+ }),
403
+ version: z.literal(1),
404
+ }) satisfies z.ZodType<ITableSlideDataStructure>;
405
+ export type TableSlideData = z.infer<typeof TableSlideDataSchema>;
406
+
407
+ // Charts
408
+ export const BarChartSlideDataSchema = z.object({
409
+ type: z.literal(SLIDE_CHART_TYPE.BAR),
410
+ categories: z
411
+ .array(z.string().min(1).max(20))
412
+ .min(3)
413
+ .max(10)
414
+ .describe(
415
+ 'Category labels (e.g., months, product names, departments). ' +
416
+ 'Recommended: 4–8 items. Keep each label SHORT — 1–3 words, max 15 characters. ' +
417
+ 'Categories work best when naturally ordered: time periods, rankings, or comparable groups.',
418
+ ),
419
+ series: z
420
+ .array(
421
+ z.object({
422
+ name: z
423
+ .string()
424
+ .max(40)
425
+ .describe(
426
+ 'Series name shown in the chart legend. Do NOT include units here — units belong in the unit field. ' +
427
+ 'GOOD: "Рост продаж". BAD: "Рост продаж (%)" or "Выручка (₽)".',
428
+ ),
429
+ data: z
430
+ .array(z.number())
431
+ .min(3)
432
+ .describe(
433
+ 'Numeric values corresponding to categories. ' +
434
+ 'MUST have EXACTLY the same number of values as categories — mismatch will break the chart. ' +
435
+ 'Use round numbers or simple approximations. NEVER hallucinate precise figures. ' +
436
+ 'Values should show meaningful variation — avoid all bars being the same height.',
437
+ ),
438
+ type: z
439
+ .number()
440
+ .min(0)
441
+ .max(11)
442
+ .describe(
443
+ 'Color index from the theme palette. ALWAYS use 0 (primary blue). Never change this value.',
444
+ ),
445
+ }),
446
+ )
447
+ .min(1)
448
+ .max(1)
449
+ .describe('Data series. Only ONE series is supported. Never add more than one.'),
450
+ yAxisLabel: z
451
+ .string()
452
+ .max(30)
453
+ .optional()
454
+ .describe(
455
+ 'Y-axis label. Include ONLY when the axis needs a descriptor that is not already covered by the unit field. ' +
456
+ 'GOOD use: "Количество студентов" (when there is no unit symbol). ' +
457
+ 'OMIT when unit is set (e.g., "%", "₽") — the unit already contextualises the values.',
458
+ ),
459
+ unit: z
460
+ .string()
461
+ .max(10)
462
+ .optional()
463
+ .describe(
464
+ 'Unit symbol displayed with each bar value (e.g., "%", "₽", "шт.", "млн"). ' +
465
+ 'ALWAYS include when values represent percentages, currency, or any measurable quantity with a unit. ' +
466
+ 'Omit only for dimensionless counts that are self-explanatory (e.g., raw ranking scores without a fixed scale).',
467
+ ),
468
+ version: z.literal(1),
469
+ }) satisfies z.ZodType<IBarChartSlideDataStructure>;
470
+ export type BarChartSlideData = z.infer<typeof BarChartSlideDataSchema>;
471
+
472
+ export const ChartSlideDataSchema = z.object({
473
+ contentType: z.literal(SLIDE_CONTENT_TYPE.CHART),
474
+ title: z
475
+ .string()
476
+ .describe(
477
+ 'Chart name — 2–4 words rendered as large bold heading on the LEFT panel of the slide. ' +
478
+ 'Keep short: the left panel is narrow and the title font is very large.',
479
+ )
480
+ .min(5)
481
+ .max(50),
482
+ description: z
483
+ .string()
484
+ .describe(
485
+ '1–2 sentences (max 120 characters) explaining what the chart shows. ' +
486
+ 'Rendered in small gray text below the title on the LEFT panel. No markdown.',
487
+ )
488
+ .min(10)
489
+ .max(150),
490
+ chart: z.discriminatedUnion('type', [BarChartSlideDataSchema]),
491
+ version: z.literal(1),
492
+ }) satisfies z.ZodType<IChartSlideDataStructure>;
493
+ export type ChartSlideData = z.infer<typeof ChartSlideDataSchema>;
494
+
495
+ export const TimelineSlideDataSchema = z.object({
496
+ contentType: z.literal(SLIDE_CONTENT_TYPE.TIMELINE),
497
+ title: z
498
+ .string()
499
+ .describe(
500
+ 'Timeline name — 2–5 words, rendered as large bold heading above the timeline. ' +
501
+ 'Names the subject or scope of the chronological sequence.',
502
+ )
503
+ .min(5)
504
+ .max(65),
505
+ description: z
506
+ .string()
507
+ .describe(
508
+ 'One sentence (max 100 characters) providing context for the timeline. ' +
509
+ 'Rendered in small gray text below the title. No markdown.',
510
+ )
511
+ .min(10)
512
+ .max(120),
513
+ timeline: z.object({
514
+ events: z
515
+ .array(
516
+ z.object({
517
+ date: z
518
+ .string()
519
+ .describe(
520
+ 'Temporal label displayed inside the arrow/chevron shape at the top of each column. ' +
521
+ 'MUST be SHORT — max 20 characters — to fit inside the arrow. ' +
522
+ 'Use a year ("2015"), a range ("2010–2015"), a quarter ("Q1 2023"), ' +
523
+ 'an approximate period ("Early 2020s", "Середина 2010-х"), ' +
524
+ 'or a phase label ("Этап 1", "Запуск") for process timelines. ' +
525
+ 'NEVER fabricate specific dates you are not certain about.',
526
+ )
527
+ .min(2)
528
+ .max(25),
529
+ title: z
530
+ .string()
531
+ .describe(
532
+ 'Event name in bold below the arrow. 2–3 words maximum. ' +
533
+ 'Short and punchy — the column is narrow, long titles wrap to many lines. ' +
534
+ 'GOOD: "Первый запуск", "Выход на рынок". BAD: "Успешный выход компании на международный рынок".',
535
+ )
536
+ .min(3)
537
+ .max(35),
538
+ description: z
539
+ .string()
540
+ .describe(
541
+ 'Brief description below the event title. 1–2 sentences, max 100 characters. ' +
542
+ 'The column is narrow — text wraps to ~5 lines at this limit. ' +
543
+ 'Do NOT exceed 100 characters or the description will overflow off the slide.',
544
+ )
545
+ .min(20)
546
+ .max(110),
547
+ }),
548
+ )
549
+ .length(5)
550
+ .describe(
551
+ 'Exactly 5 chronological events in sequential order (oldest → newest). ' +
552
+ 'The template renders exactly 5 equal columns — NEVER generate fewer or more.',
553
+ ),
554
+ }),
555
+ version: z.literal(1),
556
+ }) satisfies z.ZodType<ITimelineSlideDataStructure>;
557
+ export type TimelineSlideData = z.infer<typeof TimelineSlideDataSchema>;
558
+
559
+ export const SlideContentSchema = z.discriminatedUnion('contentType', [
560
+ CoverSlideDataSchema,
561
+ StructuredListSlideDataSchema,
562
+ TextSlideDataSchema,
563
+ ContentsSlideDataSchema,
564
+ SectionBreakSlideDataSchema,
565
+ ImageSlideDataSchema,
566
+ ThankYouSlideDataSchema,
567
+ TableSlideDataSchema,
568
+ ChartSlideDataSchema,
569
+ TimelineSlideDataSchema,
570
+ ]);
571
+ export type SlideContent = z.infer<typeof SlideContentSchema>;
@@ -0,0 +1,13 @@
1
+ import { z } from 'zod';
2
+ import { SLIDE_ICON_SLOT_STATUS } from '../../constants';
3
+
4
+ export const SlideIconSlotSchema = z.object({
5
+ uuid: z.string().uuid(),
6
+ prompt: z.string(),
7
+ alt: z.string(),
8
+ url: z.string().nullable(),
9
+ slideId: z.string(),
10
+ status: z.nativeEnum(SLIDE_ICON_SLOT_STATUS),
11
+ createdAt: z.date(),
12
+ updatedAt: z.date(),
13
+ });
@@ -0,0 +1,14 @@
1
+ import { z } from 'zod';
2
+ import { SLIDE_IMAGE_SLOT_STATUS } from '../../constants';
3
+
4
+ export const SlideImageSlotSchema = z.object({
5
+ uuid: z.string().uuid(),
6
+ prompt: z.string(),
7
+ alt: z.string(),
8
+ url: z.string().nullable(),
9
+ placeholder: z.string(),
10
+ slideId: z.string(),
11
+ status: z.nativeEnum(SLIDE_IMAGE_SLOT_STATUS),
12
+ createdAt: z.date(),
13
+ updatedAt: z.date(),
14
+ });
@@ -0,0 +1,58 @@
1
+ import { z } from 'zod';
2
+ import { SLIDE_CONTENT_TYPE } from '../../constants';
3
+
4
+ export const SlideOutlineSchema = z.object({
5
+ uuid: z.string(),
6
+ order: z.number(),
7
+ title: z.string().max(80),
8
+ body: z.string().max(500),
9
+ contentTypeId: z.nativeEnum(SLIDE_CONTENT_TYPE),
10
+ presentationId: z.string(),
11
+ createdAt: z.date(),
12
+ updatedAt: z.date(),
13
+ });
14
+ export type SlideOutline = z.infer<typeof SlideOutlineSchema>;
15
+
16
+ export const SlideOutlineUpdateSchema = SlideOutlineSchema.pick({
17
+ title: true,
18
+ body: true,
19
+ contentTypeId: true,
20
+ }).partial();
21
+ export type SlideOutlineUpdate = z.infer<typeof SlideOutlineUpdateSchema>;
22
+
23
+ export const SlideOutlineBulkUpdateSchema = SlideOutlineSchema.pick({
24
+ order: true,
25
+ title: true,
26
+ body: true,
27
+ contentTypeId: true,
28
+ presentationId: true,
29
+ })
30
+ .extend({
31
+ uuid: z.string().uuid().optional(),
32
+ })
33
+ .array()
34
+ .min(1, 'Must include at least one slide outline')
35
+ .refine(
36
+ (arr) => {
37
+ const orders = arr.map((s) => s.order);
38
+ const unique = new Set(orders);
39
+ if (unique.size !== orders.length) return false;
40
+ const sorted = [...orders].sort((a, b) => a - b);
41
+ return sorted.every((val, idx) => val === idx);
42
+ },
43
+ {
44
+ message: 'Slide orders must be unique and sequential starting at 0',
45
+ path: ['order'],
46
+ },
47
+ )
48
+ .refine(
49
+ (arr) => {
50
+ const [firstId, ...rest] = arr.map((s) => s.presentationId);
51
+ return rest.every((id) => id === firstId);
52
+ },
53
+ {
54
+ message: 'All slide outlines must belong to the same presentation',
55
+ path: ['presentationId'],
56
+ },
57
+ );
58
+ export type SlideOutlineBulkUpdate = z.infer<typeof SlideOutlineBulkUpdateSchema>;