@purpleschool/gptbot-tools 0.0.53 → 0.0.54-presentation

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 (54) hide show
  1. package/build/common/errors/errors.js +89 -10
  2. package/build/presentation/commands/build-blank-slide.command.js +15 -0
  3. package/build/presentation/commands/generate-and-insert-slide.command.js +22 -0
  4. package/build/presentation/commands/index.js +7 -0
  5. package/build/presentation/commands/presentation-generate-report.command.js +18 -0
  6. package/build/presentation/commands/presentation-paraphrase.command.js +19 -0
  7. package/build/presentation/commands/update-presentation-slides.command.js +16 -0
  8. package/build/presentation/commands/update-slide-image-slot.command.js +34 -0
  9. package/build/presentation/commands/update-slide.command.js +17 -0
  10. package/build/presentation/enums/index.js +4 -0
  11. package/build/presentation/enums/presentation-ai-action-call-status.enum.js +9 -0
  12. package/build/presentation/enums/presentation-ai-action-pricing-type.enum.js +8 -0
  13. package/build/presentation/enums/presentation-ai-action-type.enum.js +8 -0
  14. package/build/presentation/enums/slide-image-slot-action.enum.js +8 -0
  15. package/build/presentation/index.js +1 -0
  16. package/build/presentation/models/index.js +1 -0
  17. package/build/presentation/models/presentation-ai-action.schema.js +27 -0
  18. package/build/presentation/models/presentation-config.schema.js +3 -0
  19. package/build/presentation/models/presentation.schema.js +4 -1
  20. package/build/presentation/models/slide-content-edit.schema.js +135 -0
  21. package/build/presentation/models/slide-content.schema.js +5 -1
  22. package/build/presentation/models/slide.schema.js +39 -1
  23. package/build/presentation/routes/presentation.routes.js +7 -0
  24. package/build/presentation/utils/calculate-presentation-ai-action-price.util.js +16 -0
  25. package/build/presentation/utils/index.js +17 -0
  26. package/build/tools/enums/tool-type.enum.js +2 -0
  27. package/common/errors/errors.ts +89 -13
  28. package/package.json +1 -1
  29. package/presentation/commands/build-blank-slide.command.ts +15 -0
  30. package/presentation/commands/generate-and-insert-slide.command.ts +22 -0
  31. package/presentation/commands/index.ts +7 -0
  32. package/presentation/commands/presentation-generate-report.command.ts +20 -0
  33. package/presentation/commands/presentation-paraphrase.command.ts +21 -0
  34. package/presentation/commands/update-presentation-slides.command.ts +16 -0
  35. package/presentation/commands/update-slide-image-slot.command.ts +39 -0
  36. package/presentation/commands/update-slide.command.ts +17 -0
  37. package/presentation/enums/index.ts +4 -0
  38. package/presentation/enums/presentation-ai-action-call-status.enum.ts +5 -0
  39. package/presentation/enums/presentation-ai-action-pricing-type.enum.ts +4 -0
  40. package/presentation/enums/presentation-ai-action-type.enum.ts +4 -0
  41. package/presentation/enums/slide-image-slot-action.enum.ts +4 -0
  42. package/presentation/index.ts +1 -0
  43. package/presentation/models/index.ts +1 -0
  44. package/presentation/models/presentation-ai-action.schema.ts +30 -0
  45. package/presentation/models/presentation-config.schema.ts +3 -0
  46. package/presentation/models/presentation.schema.ts +4 -1
  47. package/presentation/models/slide-content-edit.schema.ts +160 -0
  48. package/presentation/models/slide-content.schema.ts +104 -11
  49. package/presentation/models/slide-image-slot.schema.ts +1 -0
  50. package/presentation/models/slide.schema.ts +47 -0
  51. package/presentation/routes/presentation.routes.ts +7 -0
  52. package/presentation/utils/calculate-presentation-ai-action-price.util.ts +20 -0
  53. package/presentation/utils/index.ts +1 -0
  54. package/tools/enums/tool-type.enum.ts +2 -0
@@ -23,6 +23,91 @@ export const IconSlotSchema = z.object({
23
23
  });
24
24
  export type IconSlot = z.infer<typeof IconSlotSchema>;
25
25
 
26
+ export interface ICoverSlideDataStructure {
27
+ contentType: SLIDE_CONTENT_TYPE.COVER;
28
+ title: string;
29
+ author: { label: string; value: string };
30
+ date: { label: string; value: string };
31
+ email: { label: string; value: string };
32
+ version: 1;
33
+ }
34
+
35
+ export interface IThankYouSlideDataStructure {
36
+ contentType: SLIDE_CONTENT_TYPE.THANK_YOU;
37
+ title: string;
38
+ author: { label: string; value: string };
39
+ date: { label: string; value: string };
40
+ email: { label: string; value: string };
41
+ version: 1;
42
+ }
43
+
44
+ export interface ITextSlideDataStructure {
45
+ contentType: SLIDE_CONTENT_TYPE.TEXT;
46
+ title: string;
47
+ description: string;
48
+ version: 1;
49
+ }
50
+
51
+ export interface IStructuredListSlideDataStructure {
52
+ contentType: SLIDE_CONTENT_TYPE.STRUCTURED_LIST;
53
+ title: string;
54
+ description: string;
55
+ list: Array<{ title: string; description: string }>;
56
+ version: 1;
57
+ }
58
+
59
+ export interface IContentsSlideDataStructure {
60
+ contentType: SLIDE_CONTENT_TYPE.CONTENTS;
61
+ title: string;
62
+ items: Array<{ pageNumber: number; title: string }>;
63
+ version: 1;
64
+ }
65
+
66
+ export interface IImageSlideDataStructure {
67
+ contentType: SLIDE_CONTENT_TYPE.TEXT_WITH_IMAGE;
68
+ title: string;
69
+ description: string;
70
+ imageSlot?: ImageSlot;
71
+ version: 1;
72
+ }
73
+
74
+ export interface ISectionBreakSlideDataStructure {
75
+ contentType: SLIDE_CONTENT_TYPE.SECTION_BREAK;
76
+ title: string;
77
+ description: string;
78
+ version: 1;
79
+ }
80
+
81
+ export interface ITableSlideDataStructure {
82
+ contentType: SLIDE_CONTENT_TYPE.TABLE;
83
+ title: string;
84
+ description: string;
85
+ table: {
86
+ columnHeaders: string[];
87
+ rows: string[][];
88
+ hasRowHeaders: boolean;
89
+ hasSummaryRow: boolean;
90
+ };
91
+ version: 1;
92
+ }
93
+
94
+ export interface IBarChartSlideDataStructure {
95
+ type: SLIDE_CHART_TYPE.BAR;
96
+ categories: string[];
97
+ series: Array<{ name: string; data: number[]; type: number }>;
98
+ yAxisLabel?: string;
99
+ unit?: string;
100
+ version: 1;
101
+ }
102
+
103
+ export interface IChartSlideDataStructure {
104
+ contentType: SLIDE_CONTENT_TYPE.CHART;
105
+ title: string;
106
+ description: string;
107
+ chart: IBarChartSlideDataStructure;
108
+ version: 1;
109
+ }
110
+
26
111
  export const CoverSlideDataSchema = z.object({
27
112
  contentType: z.literal(SLIDE_CONTENT_TYPE.COVER),
28
113
  title: z.string().describe('Slide title in about 6 words').min(10).max(150),
@@ -45,7 +130,7 @@ export const CoverSlideDataSchema = z.object({
45
130
  value: z.string().describe('Just default "email@example.com"'),
46
131
  }),
47
132
  version: z.literal(1),
48
- });
133
+ }) satisfies z.ZodType<ICoverSlideDataStructure>;
49
134
  export type CoverSlideData = z.infer<typeof CoverSlideDataSchema>;
50
135
 
51
136
  export const ThankYouSlideDataSchema = z.object({
@@ -72,7 +157,7 @@ export const ThankYouSlideDataSchema = z.object({
72
157
  value: z.string().describe('Just default "email@example.com"'),
73
158
  }),
74
159
  version: z.literal(1),
75
- });
160
+ }) satisfies z.ZodType<IThankYouSlideDataStructure>;
76
161
  export type ThankYouSlideData = z.infer<typeof ThankYouSlideDataSchema>;
77
162
 
78
163
  export const StructuredListSlideDataSchema = z.object({
@@ -83,12 +168,18 @@ export const StructuredListSlideDataSchema = z.object({
83
168
  .array(
84
169
  z.object({
85
170
  title: z.string().describe('2–4 words, concrete'),
86
- description: z.string().describe('One clear short framing sentence').max(100),
171
+ description: z
172
+ .string()
173
+ .describe(
174
+ "One clear short framing sentence. DON'T CUT THE TEXT SHORT MID WORD/SENTENCE!. Generate less content if that happened",
175
+ )
176
+ .min(50)
177
+ .max(120),
87
178
  }),
88
179
  )
89
180
  .length(4),
90
181
  version: z.literal(1),
91
- });
182
+ }) satisfies z.ZodType<IStructuredListSlideDataStructure>;
92
183
  export type StructuredListSlideData = z.infer<typeof StructuredListSlideDataSchema>;
93
184
 
94
185
  export const TextSlideDataSchema = z.object({
@@ -102,7 +193,7 @@ export const TextSlideDataSchema = z.object({
102
193
  .min(300)
103
194
  .max(600),
104
195
  version: z.literal(1),
105
- });
196
+ }) satisfies z.ZodType<ITextSlideDataStructure>;
106
197
  export type TextSlideData = z.infer<typeof TextSlideDataSchema>;
107
198
 
108
199
  export const ContentsSlideDataSchema = z.object({
@@ -126,7 +217,7 @@ export const ContentsSlideDataSchema = z.object({
126
217
  'List of slide titles. Must be relevant and generated after all the slides are generated',
127
218
  ),
128
219
  version: z.literal(1),
129
- });
220
+ }) satisfies z.ZodType<IContentsSlideDataStructure>;
130
221
  export type ContentsSlideData = z.infer<typeof ContentsSlideDataSchema>;
131
222
 
132
223
  export const ImageSlideDataSchema = z
@@ -141,7 +232,9 @@ export const ImageSlideDataSchema = z
141
232
  imageSlot: ImageSlotSchema,
142
233
  version: z.literal(1),
143
234
  })
144
- .describe('Slide that contains a title, description of the title');
235
+ .describe(
236
+ 'Slide that contains a title, description of the title',
237
+ ) satisfies z.ZodType<IImageSlideDataStructure>;
145
238
  export type ImageSlideData = z.infer<typeof ImageSlideDataSchema>;
146
239
 
147
240
  export const SectionBreakSlideDataSchema = z.object({
@@ -149,7 +242,7 @@ export const SectionBreakSlideDataSchema = z.object({
149
242
  title: z.string().describe('Slide title in about 6 words').min(10).max(200),
150
243
  description: z.string().describe('Description of the slide in about 6 words').min(10).max(200),
151
244
  version: z.literal(1),
152
- });
245
+ }) satisfies z.ZodType<ISectionBreakSlideDataStructure>;
153
246
  export type SectionBreakSlideData = z.infer<typeof SectionBreakSlideDataSchema>;
154
247
 
155
248
  export const TableSlideDataSchema = z.object({
@@ -177,7 +270,7 @@ export const TableSlideDataSchema = z.object({
177
270
  hasSummaryRow: z.boolean().describe('If table needs a summary row, set this to true'),
178
271
  }),
179
272
  version: z.literal(1),
180
- });
273
+ }) satisfies z.ZodType<ITableSlideDataStructure>;
181
274
  export type TableSlideData = z.infer<typeof TableSlideDataSchema>;
182
275
 
183
276
  // Charts
@@ -208,7 +301,7 @@ export const BarChartSlideDataSchema = z.object({
208
301
  yAxisLabel: z.string().max(40).optional().describe('Y-axis label'),
209
302
  unit: z.string().max(10).optional().describe('Unit symbol (%, $, etc.)'),
210
303
  version: z.literal(1),
211
- });
304
+ }) satisfies z.ZodType<IBarChartSlideDataStructure>;
212
305
  export type BarChartSlideData = z.infer<typeof BarChartSlideDataSchema>;
213
306
 
214
307
  export const ChartSlideDataSchema = z.object({
@@ -217,7 +310,7 @@ export const ChartSlideDataSchema = z.object({
217
310
  description: z.string().describe("Information on slide's topic").max(600),
218
311
  chart: z.discriminatedUnion('type', [BarChartSlideDataSchema]),
219
312
  version: z.literal(1),
220
- });
313
+ }) satisfies z.ZodType<IChartSlideDataStructure>;
221
314
  export type ChartSlideData = z.infer<typeof ChartSlideDataSchema>;
222
315
 
223
316
  export const SlideContentSchema = z.discriminatedUnion('contentType', [
@@ -12,3 +12,4 @@ export const SlideImageSlotSchema = z.object({
12
12
  createdAt: z.date(),
13
13
  updatedAt: z.date(),
14
14
  });
15
+ export type SlideImageSlot = z.infer<typeof SlideImageSlotSchema>;
@@ -3,6 +3,7 @@ import { SlideContentSchema } from './slide-content.schema';
3
3
  import { SLIDE_CONTENT_TYPE, SLIDE_LAYOUT } from '../enums';
4
4
  import { SlideIconSlotSchema } from './slide-icon-slot.schema';
5
5
  import { SlideImageSlotSchema } from './slide-image-slot.schema';
6
+ import { SlideContentUserEditSchema } from './slide-content-edit.schema';
6
7
 
7
8
  export const SlideSchema = z.object({
8
9
  uuid: z.string().uuid(),
@@ -17,3 +18,49 @@ export const SlideSchema = z.object({
17
18
  updatedAt: z.date(),
18
19
  });
19
20
  export type Slide = z.infer<typeof SlideSchema>;
21
+
22
+ export const SlideUpdateSchema = SlideSchema.pick({
23
+ layoutId: true,
24
+ })
25
+ .extend({
26
+ content: SlideContentUserEditSchema,
27
+ })
28
+ .partial();
29
+ export type SlideUpdate = z.infer<typeof SlideUpdateSchema>;
30
+
31
+ export const SlideBulkUpdateSchema = SlideSchema.pick({
32
+ order: true,
33
+ contentTypeId: true,
34
+ layoutId: true,
35
+ presentationId: true,
36
+ })
37
+ .extend({
38
+ uuid: z.string().uuid().optional(),
39
+ content: SlideContentUserEditSchema,
40
+ })
41
+ .array()
42
+ .min(1, 'Must include at least one slide')
43
+ .refine(
44
+ (arr) => {
45
+ const orders = arr.map((s) => s.order);
46
+ const unique = new Set(orders);
47
+ if (unique.size !== orders.length) return false;
48
+ const sorted = [...orders].sort((a, b) => a - b);
49
+ return sorted.every((val, idx) => val === idx);
50
+ },
51
+ {
52
+ message: 'Slide orders must be unique and sequential starting at 0',
53
+ path: ['order'],
54
+ },
55
+ )
56
+ .refine(
57
+ (arr) => {
58
+ const [firstId, ...rest] = arr.map((s) => s.presentationId);
59
+ return rest.every((id) => id === firstId);
60
+ },
61
+ {
62
+ message: 'All slides must belong to the same presentation',
63
+ path: ['presentationId'],
64
+ },
65
+ );
66
+ export type SlideBulkUpdate = z.infer<typeof SlideBulkUpdateSchema>;
@@ -4,6 +4,7 @@ export const PRESENTATION_AMQP_ROUTES = {
4
4
  FIND_BY_UUID: 'tools.presentation.find-by-uuid.rpc',
5
5
  GENERATE_PRESENTATION_OUTLINE: 'tools.presentation.generate-outline.rpc',
6
6
  GENERATE_PRESENTATION_SLIDES: 'tools.presentation.generate-slides.rpc',
7
+ GENERATE_AND_INSERT_SLIDE: 'tools.presentation.generate-and-insert-slide.rpc',
7
8
  UPDATE_PRESENTATION_OUTLINE: 'tools.presentation.update-presentation-outline.rpc',
8
9
  LIST_PRESENTATIONS: 'tools.presentation.list-presentations.rpc',
9
10
  DELETE_PRESENTATION: 'tools.presentation.delete-presentation.rpc',
@@ -11,6 +12,12 @@ export const PRESENTATION_AMQP_ROUTES = {
11
12
  EXPORT_AS_PPTX: 'tools.presentation.export-as-pptx.rpc',
12
13
  UPDATE_PRESENTATION: 'tools.presentation.update-presentation.rpc',
13
14
  DELETE_ALL_USER_PRESENTATIONS: 'tools.presentation.delete-all-user-presentations.rpc',
15
+ BUILD_BLANK_SLIDE: 'tools.presentation.build-blank-slide.rpc',
16
+ UPDATE_PRESENTATION_SLIDES: 'tools.presentation.update-presentation-slides.rpc',
17
+ UPDATE_SLIDE_IMAGE_SLOT: 'tools.presentation.update-slide-image-slot.rpc',
18
+ UPDATE_SLIDE: 'tools.presentation.update-slide.rpc',
19
+ PARAPHRASE: 'tools.presentation.actions.paraphrase.rpc',
20
+ GENERATE_REPORT: 'tools.presentation.actions.generate-report.rpc',
14
21
  } as const;
15
22
 
16
23
  export const PRESENTATION_SLIDE_OUTLINE_AMQP_ROUTES = {
@@ -0,0 +1,20 @@
1
+ import { PRESENTATION_AI_ACTION_PRICING_TYPE } from '../enums';
2
+ import { PresentationAiActionPricingRules } from '../models';
3
+
4
+ export function calculatePresentationAiActionPrice(
5
+ pricingRules: PresentationAiActionPricingRules,
6
+ selectionText: string,
7
+ ): number {
8
+ switch (pricingRules.type) {
9
+ case PRESENTATION_AI_ACTION_PRICING_TYPE.PER_CHARACTER:
10
+ const characterCount = selectionText.length;
11
+ const price = characterCount * pricingRules.price;
12
+ return Math.max(1, Math.ceil(price));
13
+
14
+ case PRESENTATION_AI_ACTION_PRICING_TYPE.FLAT:
15
+ return Math.max(1, Math.ceil(pricingRules.price));
16
+
17
+ default:
18
+ throw new Error(`Unknown pricing type`);
19
+ }
20
+ }
@@ -0,0 +1 @@
1
+ export * from './calculate-presentation-ai-action-price.util';
@@ -4,7 +4,9 @@ export enum TOOL_TYPE {
4
4
  VIDEO = 'VIDEO',
5
5
  AUDIO = 'AUDIO',
6
6
  PRESENTATION = 'PRESENTATION',
7
+ PRESENTATION_AI_ACTION = 'PRESENTATION_AI_ACTION',
7
8
  WRITER = 'WRITER',
8
9
  PARAPHRASE = 'PARAPHRASE',
9
10
  WRITER_ACTION = 'WRITER_ACTION',
11
+ VIDEO_EDITOR = 'VIDEO_EDITOR',
10
12
  }