@purpleschool/gptbot-tools 0.0.52-presentation → 0.0.53-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.
- package/build/common/errors/errors.js +49 -0
- package/build/presentation/commands/index.js +3 -0
- package/build/presentation/commands/presentation-generate-report.command.js +18 -0
- package/build/presentation/commands/presentation-paraphrase.command.js +19 -0
- package/build/presentation/commands/update-slide.command.js +17 -0
- package/build/presentation/enums/index.js +3 -0
- package/build/presentation/enums/presentation-ai-action-call-status.enum.js +9 -0
- package/build/presentation/enums/presentation-ai-action-pricing-type.enum.js +8 -0
- package/build/presentation/enums/presentation-ai-action-type.enum.js +8 -0
- package/build/presentation/index.js +1 -0
- package/build/presentation/models/index.js +1 -0
- package/build/presentation/models/presentation-ai-action.schema.js +27 -0
- package/build/presentation/models/presentation-config.schema.js +3 -0
- package/build/presentation/models/slide-content.schema.js +5 -1
- package/build/presentation/models/slide.schema.js +8 -1
- package/build/presentation/routes/presentation.routes.js +3 -0
- package/build/presentation/utils/calculate-presentation-ai-action-price.util.js +16 -0
- package/build/presentation/utils/index.js +17 -0
- package/build/tools/enums/tool-type.enum.js +2 -0
- package/common/errors/errors.ts +49 -0
- package/package.json +1 -1
- package/presentation/commands/index.ts +3 -0
- package/presentation/commands/presentation-generate-report.command.ts +20 -0
- package/presentation/commands/presentation-paraphrase.command.ts +21 -0
- package/presentation/commands/update-slide.command.ts +17 -0
- package/presentation/enums/index.ts +3 -0
- package/presentation/enums/presentation-ai-action-call-status.enum.ts +5 -0
- package/presentation/enums/presentation-ai-action-pricing-type.enum.ts +4 -0
- package/presentation/enums/presentation-ai-action-type.enum.ts +4 -0
- package/presentation/index.ts +1 -0
- package/presentation/models/index.ts +1 -0
- package/presentation/models/presentation-ai-action.schema.ts +30 -0
- package/presentation/models/presentation-config.schema.ts +3 -0
- package/presentation/models/slide-content.schema.ts +7 -1
- package/presentation/models/slide.schema.ts +9 -0
- package/presentation/routes/presentation.routes.ts +3 -0
- package/presentation/utils/calculate-presentation-ai-action-price.util.ts +20 -0
- package/presentation/utils/index.ts +1 -0
- package/tools/enums/tool-type.enum.ts +2 -0
|
@@ -384,6 +384,55 @@ exports.ERRORS = {
|
|
|
384
384
|
httpCode: 400,
|
|
385
385
|
},
|
|
386
386
|
},
|
|
387
|
+
PRESENTATION_AI_ACTION: {
|
|
388
|
+
NOT_FOUND: {
|
|
389
|
+
code: 'PRESENTATION_AI_ACTION.NOT_FOUND',
|
|
390
|
+
message: 'ИИ операция для презентации не найдено',
|
|
391
|
+
httpCode: 404,
|
|
392
|
+
},
|
|
393
|
+
PROMPT_TOO_LONG: {
|
|
394
|
+
code: 'PRESENTATION_AI_ACTION.PROMPT_TOO_LONG',
|
|
395
|
+
message: 'Превышена максимальная длина запроса',
|
|
396
|
+
httpCode: 400,
|
|
397
|
+
},
|
|
398
|
+
INSUFFICIENT_BALANCE: {
|
|
399
|
+
code: 'PRESENTATION_AI_ACTION.INSUFFICIENT_BALANCE',
|
|
400
|
+
message: 'У пользователя недостаточно средств для выполнения операции',
|
|
401
|
+
httpCode: 400,
|
|
402
|
+
},
|
|
403
|
+
AI_ERROR: {
|
|
404
|
+
code: 'PRESENTATION_AI_ACTION.AI_ERROR',
|
|
405
|
+
message: 'Произошла ошибка во время запроса к ИИ',
|
|
406
|
+
httpCode: 500,
|
|
407
|
+
},
|
|
408
|
+
SAVE_ERROR: {
|
|
409
|
+
code: 'PRESENTATION_AI_ACTION.SAVE_ERROR',
|
|
410
|
+
message: 'Произошла ошибка при сохранении ИИ операции для презентации',
|
|
411
|
+
httpCode: 500,
|
|
412
|
+
},
|
|
413
|
+
FIND_ERROR: {
|
|
414
|
+
code: 'PRESENTATION_AI_ACTION.FIND_ERROR',
|
|
415
|
+
message: 'Произошла ошибка при поиске ИИ операций для презентации',
|
|
416
|
+
httpCode: 500,
|
|
417
|
+
},
|
|
418
|
+
},
|
|
419
|
+
PRESENTATION_AI_ACTION_CALL: {
|
|
420
|
+
NOT_FOUND: {
|
|
421
|
+
code: 'PRESENTATION_AI_ACTION_CALL.NOT_FOUND',
|
|
422
|
+
message: 'Вызов ИИ операции для презентации не найден',
|
|
423
|
+
httpCode: 404,
|
|
424
|
+
},
|
|
425
|
+
SAVE_ERROR: {
|
|
426
|
+
code: 'PRESENTATION_AI_ACTION_CALL.SAVE_ERROR',
|
|
427
|
+
message: 'Произошла ошибка при сохранении вызова ИИ операции для презентации',
|
|
428
|
+
httpCode: 500,
|
|
429
|
+
},
|
|
430
|
+
FIND_ERROR: {
|
|
431
|
+
code: 'PRESENTATION_AI_ACTION_CALL.FIND_ERROR',
|
|
432
|
+
message: 'Произошла ошибка при поиске вызова ИИ операции для презентации',
|
|
433
|
+
httpCode: 500,
|
|
434
|
+
},
|
|
435
|
+
},
|
|
387
436
|
SLIDE_OUTLINE: {
|
|
388
437
|
DELETE_ERROR: {
|
|
389
438
|
code: 'SLIDE_OUTLINE.DELETE_ERROR',
|
|
@@ -29,3 +29,6 @@ __exportStar(require("./update-presentation.command"), exports);
|
|
|
29
29
|
__exportStar(require("./update-presentation-outline.command"), exports);
|
|
30
30
|
__exportStar(require("./update-presentation-slides.command"), exports);
|
|
31
31
|
__exportStar(require("./update-slide-image-slot.command"), exports);
|
|
32
|
+
__exportStar(require("./update-slide.command"), exports);
|
|
33
|
+
__exportStar(require("./presentation-paraphrase.command"), exports);
|
|
34
|
+
__exportStar(require("./presentation-generate-report.command"), exports);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PresentationGenerateReportCommand = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const common_1 = require("../../common");
|
|
6
|
+
var PresentationGenerateReportCommand;
|
|
7
|
+
(function (PresentationGenerateReportCommand) {
|
|
8
|
+
PresentationGenerateReportCommand.RequestSchema = zod_1.z.object({
|
|
9
|
+
userId: zod_1.z.string().uuid().nullable().optional(),
|
|
10
|
+
unregisteredUserId: zod_1.z.string().uuid().nullable().optional(),
|
|
11
|
+
presentationId: zod_1.z.string().uuid(),
|
|
12
|
+
userBalance: zod_1.z.number(),
|
|
13
|
+
});
|
|
14
|
+
PresentationGenerateReportCommand.ResponseSchema = (0, common_1.ICommandResponseSchema)(zod_1.z.object({
|
|
15
|
+
output: zod_1.z.string(),
|
|
16
|
+
docxUrl: zod_1.z.string(),
|
|
17
|
+
}));
|
|
18
|
+
})(PresentationGenerateReportCommand || (exports.PresentationGenerateReportCommand = PresentationGenerateReportCommand = {}));
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PresentationParaphraseCommand = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const common_1 = require("../../common");
|
|
6
|
+
var PresentationParaphraseCommand;
|
|
7
|
+
(function (PresentationParaphraseCommand) {
|
|
8
|
+
PresentationParaphraseCommand.RequestSchema = zod_1.z.object({
|
|
9
|
+
userId: zod_1.z.string().uuid().nullable().optional(),
|
|
10
|
+
unregisteredUserId: zod_1.z.string().uuid().nullable().optional(),
|
|
11
|
+
presentationId: zod_1.z.string().uuid(),
|
|
12
|
+
slideId: zod_1.z.string().uuid(),
|
|
13
|
+
selectionText: zod_1.z.string(),
|
|
14
|
+
userBalance: zod_1.z.number(),
|
|
15
|
+
});
|
|
16
|
+
PresentationParaphraseCommand.ResponseSchema = (0, common_1.ICommandResponseSchema)(zod_1.z.object({
|
|
17
|
+
output: zod_1.z.string(),
|
|
18
|
+
}));
|
|
19
|
+
})(PresentationParaphraseCommand || (exports.PresentationParaphraseCommand = PresentationParaphraseCommand = {}));
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UpdateSlideCommand = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const models_1 = require("../models");
|
|
6
|
+
const common_1 = require("../../common");
|
|
7
|
+
var UpdateSlideCommand;
|
|
8
|
+
(function (UpdateSlideCommand) {
|
|
9
|
+
UpdateSlideCommand.RequestSchema = zod_1.z.object({
|
|
10
|
+
userId: zod_1.z.string().uuid().nullable().optional(),
|
|
11
|
+
unregisteredUserId: zod_1.z.string().uuid().nullable().optional(),
|
|
12
|
+
presentationId: zod_1.z.string().uuid(),
|
|
13
|
+
slideId: zod_1.z.string().uuid(),
|
|
14
|
+
data: models_1.SlideUpdateSchema,
|
|
15
|
+
});
|
|
16
|
+
UpdateSlideCommand.ResponseSchema = (0, common_1.ICommandResponseSchema)(models_1.SlideSchema);
|
|
17
|
+
})(UpdateSlideCommand || (exports.UpdateSlideCommand = UpdateSlideCommand = {}));
|
|
@@ -21,3 +21,6 @@ __exportStar(require("./slide-image-slot-status.enum"), exports);
|
|
|
21
21
|
__exportStar(require("./slide-icon-slot-status.enum"), exports);
|
|
22
22
|
__exportStar(require("./slide-layout.enum"), exports);
|
|
23
23
|
__exportStar(require("./slide-image-slot-action.enum"), exports);
|
|
24
|
+
__exportStar(require("./presentation-ai-action-call-status.enum"), exports);
|
|
25
|
+
__exportStar(require("./presentation-ai-action-type.enum"), exports);
|
|
26
|
+
__exportStar(require("./presentation-ai-action-pricing-type.enum"), exports);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PRESENTATION_AI_ACTION_CALL_STATUS = void 0;
|
|
4
|
+
var PRESENTATION_AI_ACTION_CALL_STATUS;
|
|
5
|
+
(function (PRESENTATION_AI_ACTION_CALL_STATUS) {
|
|
6
|
+
PRESENTATION_AI_ACTION_CALL_STATUS["PROCESSING"] = "processing";
|
|
7
|
+
PRESENTATION_AI_ACTION_CALL_STATUS["COMPLETED"] = "completed";
|
|
8
|
+
PRESENTATION_AI_ACTION_CALL_STATUS["FAILED"] = "failed";
|
|
9
|
+
})(PRESENTATION_AI_ACTION_CALL_STATUS || (exports.PRESENTATION_AI_ACTION_CALL_STATUS = PRESENTATION_AI_ACTION_CALL_STATUS = {}));
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PRESENTATION_AI_ACTION_PRICING_TYPE = void 0;
|
|
4
|
+
var PRESENTATION_AI_ACTION_PRICING_TYPE;
|
|
5
|
+
(function (PRESENTATION_AI_ACTION_PRICING_TYPE) {
|
|
6
|
+
PRESENTATION_AI_ACTION_PRICING_TYPE["PER_CHARACTER"] = "PER_CHARACTER";
|
|
7
|
+
PRESENTATION_AI_ACTION_PRICING_TYPE["FLAT"] = "FLAT";
|
|
8
|
+
})(PRESENTATION_AI_ACTION_PRICING_TYPE || (exports.PRESENTATION_AI_ACTION_PRICING_TYPE = PRESENTATION_AI_ACTION_PRICING_TYPE = {}));
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PRESENTATION_AI_ACTION_TYPE = void 0;
|
|
4
|
+
var PRESENTATION_AI_ACTION_TYPE;
|
|
5
|
+
(function (PRESENTATION_AI_ACTION_TYPE) {
|
|
6
|
+
PRESENTATION_AI_ACTION_TYPE["PARAPHRASE"] = "PARAPHRASE";
|
|
7
|
+
PRESENTATION_AI_ACTION_TYPE["GENERATE_REPORT"] = "GENERATE_REPORT";
|
|
8
|
+
})(PRESENTATION_AI_ACTION_TYPE || (exports.PRESENTATION_AI_ACTION_TYPE = PRESENTATION_AI_ACTION_TYPE = {}));
|
|
@@ -23,3 +23,4 @@ __exportStar(require("./slide-outline.schema"), exports);
|
|
|
23
23
|
__exportStar(require("./slide.schema"), exports);
|
|
24
24
|
__exportStar(require("./slide-image-slot.schema"), exports);
|
|
25
25
|
__exportStar(require("./slide-content.schema"), exports);
|
|
26
|
+
__exportStar(require("./presentation-ai-action.schema"), exports);
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PresentationAiActionSchema = exports.PresentationAiActionPricingRulesSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const enums_1 = require("../enums");
|
|
6
|
+
exports.PresentationAiActionPricingRulesSchema = zod_1.z.discriminatedUnion('type', [
|
|
7
|
+
zod_1.z.object({
|
|
8
|
+
type: zod_1.z.literal(enums_1.PRESENTATION_AI_ACTION_PRICING_TYPE.PER_CHARACTER),
|
|
9
|
+
price: zod_1.z.number(),
|
|
10
|
+
}),
|
|
11
|
+
zod_1.z.object({
|
|
12
|
+
type: zod_1.z.literal(enums_1.PRESENTATION_AI_ACTION_PRICING_TYPE.FLAT),
|
|
13
|
+
price: zod_1.z.number(),
|
|
14
|
+
}),
|
|
15
|
+
]);
|
|
16
|
+
exports.PresentationAiActionSchema = zod_1.z.object({
|
|
17
|
+
uuid: zod_1.z.string(),
|
|
18
|
+
type: zod_1.z.nativeEnum(enums_1.PRESENTATION_AI_ACTION_TYPE),
|
|
19
|
+
pricingRules: exports.PresentationAiActionPricingRulesSchema,
|
|
20
|
+
maxPromptLength: zod_1.z.number(),
|
|
21
|
+
aiModel: zod_1.z.string(),
|
|
22
|
+
title: zod_1.z.string(),
|
|
23
|
+
icon: zod_1.z.string(),
|
|
24
|
+
order: zod_1.z.number(),
|
|
25
|
+
createdAt: zod_1.z.date(),
|
|
26
|
+
updatedAt: zod_1.z.date(),
|
|
27
|
+
});
|
|
@@ -5,14 +5,17 @@ const zod_1 = require("zod");
|
|
|
5
5
|
const slide_content_type_schema_1 = require("./slide-content-type.schema");
|
|
6
6
|
const language_1 = require("../../language");
|
|
7
7
|
const presentation_template_schema_1 = require("./presentation-template.schema");
|
|
8
|
+
const presentation_ai_action_schema_1 = require("./presentation-ai-action.schema");
|
|
8
9
|
exports.PresentationConfigSchema = zod_1.z.object({
|
|
9
10
|
slideContentTypes: zod_1.z.array(slide_content_type_schema_1.SlideContentTypeSchema),
|
|
10
11
|
languages: zod_1.z.array(language_1.LanguageSchema),
|
|
11
12
|
templates: zod_1.z.array(presentation_template_schema_1.PresentationTemplateSchema),
|
|
13
|
+
aiActions: zod_1.z.array(presentation_ai_action_schema_1.PresentationAiActionSchema),
|
|
12
14
|
slideGenerationPrice: zod_1.z.number(),
|
|
13
15
|
maxSlides: zod_1.z.number(),
|
|
14
16
|
minSlides: zod_1.z.number(),
|
|
15
17
|
maxSlideTitleLength: zod_1.z.number(),
|
|
16
18
|
maxSlideOutlineLength: zod_1.z.number(),
|
|
17
19
|
maxPromptLength: zod_1.z.number(),
|
|
20
|
+
imageGenerationPrice: zod_1.z.number(),
|
|
18
21
|
});
|
|
@@ -72,7 +72,11 @@ exports.StructuredListSlideDataSchema = zod_1.z.object({
|
|
|
72
72
|
list: zod_1.z
|
|
73
73
|
.array(zod_1.z.object({
|
|
74
74
|
title: zod_1.z.string().describe('2–4 words, concrete'),
|
|
75
|
-
description: zod_1.z
|
|
75
|
+
description: zod_1.z
|
|
76
|
+
.string()
|
|
77
|
+
.describe("One clear short framing sentence. DON'T CUT THE TEXT SHORT MID WORD/SENTENCE!. Generate less content if that happened")
|
|
78
|
+
.min(50)
|
|
79
|
+
.max(120),
|
|
76
80
|
}))
|
|
77
81
|
.length(4),
|
|
78
82
|
version: zod_1.z.literal(1),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SlideBulkUpdateSchema = exports.SlideSchema = void 0;
|
|
3
|
+
exports.SlideBulkUpdateSchema = exports.SlideUpdateSchema = exports.SlideSchema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const slide_content_schema_1 = require("./slide-content.schema");
|
|
6
6
|
const enums_1 = require("../enums");
|
|
@@ -19,6 +19,13 @@ exports.SlideSchema = zod_1.z.object({
|
|
|
19
19
|
createdAt: zod_1.z.date(),
|
|
20
20
|
updatedAt: zod_1.z.date(),
|
|
21
21
|
});
|
|
22
|
+
exports.SlideUpdateSchema = exports.SlideSchema.pick({
|
|
23
|
+
layoutId: true,
|
|
24
|
+
})
|
|
25
|
+
.extend({
|
|
26
|
+
content: slide_content_edit_schema_1.SlideContentUserEditSchema,
|
|
27
|
+
})
|
|
28
|
+
.partial();
|
|
22
29
|
exports.SlideBulkUpdateSchema = exports.SlideSchema.pick({
|
|
23
30
|
order: true,
|
|
24
31
|
contentTypeId: true,
|
|
@@ -18,6 +18,9 @@ exports.PRESENTATION_AMQP_ROUTES = {
|
|
|
18
18
|
BUILD_BLANK_SLIDE: 'tools.presentation.build-blank-slide.rpc',
|
|
19
19
|
UPDATE_PRESENTATION_SLIDES: 'tools.presentation.update-presentation-slides.rpc',
|
|
20
20
|
UPDATE_SLIDE_IMAGE_SLOT: 'tools.presentation.update-slide-image-slot.rpc',
|
|
21
|
+
UPDATE_SLIDE: 'tools.presentation.update-slide.rpc',
|
|
22
|
+
PARAPHRASE: 'tools.presentation.actions.paraphrase.rpc',
|
|
23
|
+
GENERATE_REPORT: 'tools.presentation.actions.generate-report.rpc',
|
|
21
24
|
};
|
|
22
25
|
exports.PRESENTATION_SLIDE_OUTLINE_AMQP_ROUTES = {
|
|
23
26
|
REPOSITION: 'tools.presentation.slide-outline.reposition-slide-outline.rpc',
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.calculatePresentationAiActionPrice = calculatePresentationAiActionPrice;
|
|
4
|
+
const enums_1 = require("../enums");
|
|
5
|
+
function calculatePresentationAiActionPrice(pricingRules, selectionText) {
|
|
6
|
+
switch (pricingRules.type) {
|
|
7
|
+
case enums_1.PRESENTATION_AI_ACTION_PRICING_TYPE.PER_CHARACTER:
|
|
8
|
+
const characterCount = selectionText.length;
|
|
9
|
+
const price = characterCount * pricingRules.price;
|
|
10
|
+
return Math.max(1, Math.ceil(price));
|
|
11
|
+
case enums_1.PRESENTATION_AI_ACTION_PRICING_TYPE.FLAT:
|
|
12
|
+
return Math.max(1, Math.ceil(pricingRules.price));
|
|
13
|
+
default:
|
|
14
|
+
throw new Error(`Unknown pricing type`);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -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("./calculate-presentation-ai-action-price.util"), exports);
|
|
@@ -11,4 +11,6 @@ var TOOL_TYPE;
|
|
|
11
11
|
TOOL_TYPE["PRESENTATION_AI_ACTION"] = "PRESENTATION_AI_ACTION";
|
|
12
12
|
TOOL_TYPE["WRITER"] = "WRITER";
|
|
13
13
|
TOOL_TYPE["PARAPHRASE"] = "PARAPHRASE";
|
|
14
|
+
TOOL_TYPE["WRITER_ACTION"] = "WRITER_ACTION";
|
|
15
|
+
TOOL_TYPE["VIDEO_EDITOR"] = "VIDEO_EDITOR";
|
|
14
16
|
})(TOOL_TYPE || (exports.TOOL_TYPE = TOOL_TYPE = {}));
|
package/common/errors/errors.ts
CHANGED
|
@@ -383,6 +383,55 @@ export const ERRORS = {
|
|
|
383
383
|
httpCode: 400,
|
|
384
384
|
},
|
|
385
385
|
},
|
|
386
|
+
PRESENTATION_AI_ACTION: {
|
|
387
|
+
NOT_FOUND: {
|
|
388
|
+
code: 'PRESENTATION_AI_ACTION.NOT_FOUND',
|
|
389
|
+
message: 'ИИ операция для презентации не найдено',
|
|
390
|
+
httpCode: 404,
|
|
391
|
+
},
|
|
392
|
+
PROMPT_TOO_LONG: {
|
|
393
|
+
code: 'PRESENTATION_AI_ACTION.PROMPT_TOO_LONG',
|
|
394
|
+
message: 'Превышена максимальная длина запроса',
|
|
395
|
+
httpCode: 400,
|
|
396
|
+
},
|
|
397
|
+
INSUFFICIENT_BALANCE: {
|
|
398
|
+
code: 'PRESENTATION_AI_ACTION.INSUFFICIENT_BALANCE',
|
|
399
|
+
message: 'У пользователя недостаточно средств для выполнения операции',
|
|
400
|
+
httpCode: 400,
|
|
401
|
+
},
|
|
402
|
+
AI_ERROR: {
|
|
403
|
+
code: 'PRESENTATION_AI_ACTION.AI_ERROR',
|
|
404
|
+
message: 'Произошла ошибка во время запроса к ИИ',
|
|
405
|
+
httpCode: 500,
|
|
406
|
+
},
|
|
407
|
+
SAVE_ERROR: {
|
|
408
|
+
code: 'PRESENTATION_AI_ACTION.SAVE_ERROR',
|
|
409
|
+
message: 'Произошла ошибка при сохранении ИИ операции для презентации',
|
|
410
|
+
httpCode: 500,
|
|
411
|
+
},
|
|
412
|
+
FIND_ERROR: {
|
|
413
|
+
code: 'PRESENTATION_AI_ACTION.FIND_ERROR',
|
|
414
|
+
message: 'Произошла ошибка при поиске ИИ операций для презентации',
|
|
415
|
+
httpCode: 500,
|
|
416
|
+
},
|
|
417
|
+
},
|
|
418
|
+
PRESENTATION_AI_ACTION_CALL: {
|
|
419
|
+
NOT_FOUND: {
|
|
420
|
+
code: 'PRESENTATION_AI_ACTION_CALL.NOT_FOUND',
|
|
421
|
+
message: 'Вызов ИИ операции для презентации не найден',
|
|
422
|
+
httpCode: 404,
|
|
423
|
+
},
|
|
424
|
+
SAVE_ERROR: {
|
|
425
|
+
code: 'PRESENTATION_AI_ACTION_CALL.SAVE_ERROR',
|
|
426
|
+
message: 'Произошла ошибка при сохранении вызова ИИ операции для презентации',
|
|
427
|
+
httpCode: 500,
|
|
428
|
+
},
|
|
429
|
+
FIND_ERROR: {
|
|
430
|
+
code: 'PRESENTATION_AI_ACTION_CALL.FIND_ERROR',
|
|
431
|
+
message: 'Произошла ошибка при поиске вызова ИИ операции для презентации',
|
|
432
|
+
httpCode: 500,
|
|
433
|
+
},
|
|
434
|
+
},
|
|
386
435
|
SLIDE_OUTLINE: {
|
|
387
436
|
DELETE_ERROR: {
|
|
388
437
|
code: 'SLIDE_OUTLINE.DELETE_ERROR',
|
package/package.json
CHANGED
|
@@ -13,3 +13,6 @@ export * from './update-presentation.command';
|
|
|
13
13
|
export * from './update-presentation-outline.command';
|
|
14
14
|
export * from './update-presentation-slides.command';
|
|
15
15
|
export * from './update-slide-image-slot.command';
|
|
16
|
+
export * from './update-slide.command';
|
|
17
|
+
export * from './presentation-paraphrase.command';
|
|
18
|
+
export * from './presentation-generate-report.command';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ICommandResponseSchema } from '../../common';
|
|
3
|
+
|
|
4
|
+
export namespace PresentationGenerateReportCommand {
|
|
5
|
+
export const RequestSchema = z.object({
|
|
6
|
+
userId: z.string().uuid().nullable().optional(),
|
|
7
|
+
unregisteredUserId: z.string().uuid().nullable().optional(),
|
|
8
|
+
presentationId: z.string().uuid(),
|
|
9
|
+
userBalance: z.number(),
|
|
10
|
+
});
|
|
11
|
+
export type Request = z.infer<typeof RequestSchema>;
|
|
12
|
+
|
|
13
|
+
export const ResponseSchema = ICommandResponseSchema(
|
|
14
|
+
z.object({
|
|
15
|
+
output: z.string(),
|
|
16
|
+
docxUrl: z.string(),
|
|
17
|
+
}),
|
|
18
|
+
);
|
|
19
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
20
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ICommandResponseSchema } from '../../common';
|
|
3
|
+
|
|
4
|
+
export namespace PresentationParaphraseCommand {
|
|
5
|
+
export const RequestSchema = z.object({
|
|
6
|
+
userId: z.string().uuid().nullable().optional(),
|
|
7
|
+
unregisteredUserId: z.string().uuid().nullable().optional(),
|
|
8
|
+
presentationId: z.string().uuid(),
|
|
9
|
+
slideId: z.string().uuid(),
|
|
10
|
+
selectionText: z.string(),
|
|
11
|
+
userBalance: z.number(),
|
|
12
|
+
});
|
|
13
|
+
export type Request = z.infer<typeof RequestSchema>;
|
|
14
|
+
|
|
15
|
+
export const ResponseSchema = ICommandResponseSchema(
|
|
16
|
+
z.object({
|
|
17
|
+
output: z.string(),
|
|
18
|
+
}),
|
|
19
|
+
);
|
|
20
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
21
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { SlideSchema, SlideUpdateSchema } from '../models';
|
|
3
|
+
import { ICommandResponseSchema } from '../../common';
|
|
4
|
+
|
|
5
|
+
export namespace UpdateSlideCommand {
|
|
6
|
+
export const RequestSchema = z.object({
|
|
7
|
+
userId: z.string().uuid().nullable().optional(),
|
|
8
|
+
unregisteredUserId: z.string().uuid().nullable().optional(),
|
|
9
|
+
presentationId: z.string().uuid(),
|
|
10
|
+
slideId: z.string().uuid(),
|
|
11
|
+
data: SlideUpdateSchema,
|
|
12
|
+
});
|
|
13
|
+
export type Request = z.infer<typeof RequestSchema>;
|
|
14
|
+
|
|
15
|
+
export const ResponseSchema = ICommandResponseSchema(SlideSchema);
|
|
16
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
17
|
+
}
|
|
@@ -5,3 +5,6 @@ export * from './slide-image-slot-status.enum';
|
|
|
5
5
|
export * from './slide-icon-slot-status.enum';
|
|
6
6
|
export * from './slide-layout.enum';
|
|
7
7
|
export * from './slide-image-slot-action.enum';
|
|
8
|
+
export * from './presentation-ai-action-call-status.enum';
|
|
9
|
+
export * from './presentation-ai-action-type.enum';
|
|
10
|
+
export * from './presentation-ai-action-pricing-type.enum';
|
package/presentation/index.ts
CHANGED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { PRESENTATION_AI_ACTION_PRICING_TYPE, PRESENTATION_AI_ACTION_TYPE } from '../enums';
|
|
3
|
+
|
|
4
|
+
export const PresentationAiActionPricingRulesSchema = z.discriminatedUnion('type', [
|
|
5
|
+
z.object({
|
|
6
|
+
type: z.literal(PRESENTATION_AI_ACTION_PRICING_TYPE.PER_CHARACTER),
|
|
7
|
+
price: z.number(),
|
|
8
|
+
}),
|
|
9
|
+
z.object({
|
|
10
|
+
type: z.literal(PRESENTATION_AI_ACTION_PRICING_TYPE.FLAT),
|
|
11
|
+
price: z.number(),
|
|
12
|
+
}),
|
|
13
|
+
]);
|
|
14
|
+
export type PresentationAiActionPricingRules = z.infer<
|
|
15
|
+
typeof PresentationAiActionPricingRulesSchema
|
|
16
|
+
>;
|
|
17
|
+
|
|
18
|
+
export const PresentationAiActionSchema = z.object({
|
|
19
|
+
uuid: z.string(),
|
|
20
|
+
type: z.nativeEnum(PRESENTATION_AI_ACTION_TYPE),
|
|
21
|
+
pricingRules: PresentationAiActionPricingRulesSchema,
|
|
22
|
+
maxPromptLength: z.number(),
|
|
23
|
+
aiModel: z.string(),
|
|
24
|
+
title: z.string(),
|
|
25
|
+
icon: z.string(),
|
|
26
|
+
order: z.number(),
|
|
27
|
+
createdAt: z.date(),
|
|
28
|
+
updatedAt: z.date(),
|
|
29
|
+
});
|
|
30
|
+
export type PresentationAiAction = z.infer<typeof PresentationAiActionSchema>;
|
|
@@ -2,16 +2,19 @@ import { z } from 'zod';
|
|
|
2
2
|
import { SlideContentTypeSchema } from './slide-content-type.schema';
|
|
3
3
|
import { LanguageSchema } from '../../language';
|
|
4
4
|
import { PresentationTemplateSchema } from './presentation-template.schema';
|
|
5
|
+
import { PresentationAiActionSchema } from './presentation-ai-action.schema';
|
|
5
6
|
|
|
6
7
|
export const PresentationConfigSchema = z.object({
|
|
7
8
|
slideContentTypes: z.array(SlideContentTypeSchema),
|
|
8
9
|
languages: z.array(LanguageSchema),
|
|
9
10
|
templates: z.array(PresentationTemplateSchema),
|
|
11
|
+
aiActions: z.array(PresentationAiActionSchema),
|
|
10
12
|
slideGenerationPrice: z.number(),
|
|
11
13
|
maxSlides: z.number(),
|
|
12
14
|
minSlides: z.number(),
|
|
13
15
|
maxSlideTitleLength: z.number(),
|
|
14
16
|
maxSlideOutlineLength: z.number(),
|
|
15
17
|
maxPromptLength: z.number(),
|
|
18
|
+
imageGenerationPrice: z.number(),
|
|
16
19
|
});
|
|
17
20
|
export type PresentationConfig = z.infer<typeof PresentationConfigSchema>;
|
|
@@ -168,7 +168,13 @@ export const StructuredListSlideDataSchema = z.object({
|
|
|
168
168
|
.array(
|
|
169
169
|
z.object({
|
|
170
170
|
title: z.string().describe('2–4 words, concrete'),
|
|
171
|
-
description: z
|
|
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),
|
|
172
178
|
}),
|
|
173
179
|
)
|
|
174
180
|
.length(4),
|
|
@@ -19,6 +19,15 @@ export const SlideSchema = z.object({
|
|
|
19
19
|
});
|
|
20
20
|
export type Slide = z.infer<typeof SlideSchema>;
|
|
21
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
|
+
|
|
22
31
|
export const SlideBulkUpdateSchema = SlideSchema.pick({
|
|
23
32
|
order: true,
|
|
24
33
|
contentTypeId: true,
|
|
@@ -15,6 +15,9 @@ export const PRESENTATION_AMQP_ROUTES = {
|
|
|
15
15
|
BUILD_BLANK_SLIDE: 'tools.presentation.build-blank-slide.rpc',
|
|
16
16
|
UPDATE_PRESENTATION_SLIDES: 'tools.presentation.update-presentation-slides.rpc',
|
|
17
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',
|
|
18
21
|
} as const;
|
|
19
22
|
|
|
20
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';
|