@purpleschool/gptbot-tools 0.0.39 → 0.0.40-texteditor
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/enums/index.js +0 -1
- package/build/common/errors/errors.js +126 -0
- package/build/image-editor/models/image-editor-model.schema.js +0 -1
- package/build/index.js +3 -0
- package/build/stt/models/stt-model.schema.js +0 -1
- package/build/tts/models/tts-model.schema.js +0 -1
- package/build/video/models/video-model.schema.js +0 -1
- package/build/writer/commands/create-writer-document.command.js +17 -0
- package/build/writer/commands/delete-all-user-writer-documents.command.js +18 -0
- package/build/writer/commands/delete-writer-document.command.js +14 -0
- package/build/writer/commands/export-writer-document-as-docx.command.js +16 -0
- package/build/writer/commands/generate-document-contents.command.js +16 -0
- package/build/writer/commands/index.js +28 -0
- package/build/writer/commands/update-writer-document-contents.command.js +17 -0
- package/build/writer/commands/update-writer-document-final-md.command.js +17 -0
- package/build/writer/commands/update-writer-document-outline.command.js +16 -0
- package/build/writer/commands/writer-extend-text.command.js +18 -0
- package/build/writer/commands/writer-fix-errors.command.js +18 -0
- package/build/writer/commands/writer-generate-text.command.js +21 -0
- package/build/writer/commands/writer-paraphrase.command.js +18 -0
- package/build/writer/commands/writer-shorten-text.command.js +18 -0
- package/build/writer/enums/index.js +21 -0
- package/build/writer/enums/writer-ai-action-call.enum.js +9 -0
- package/build/writer/enums/writer-ai-action-pricing-type.enum.js +8 -0
- package/build/writer/enums/writer-ai-action-type.enum.js +11 -0
- package/build/writer/enums/writer-document-section-type.enum.js +9 -0
- package/build/writer/enums/writer-document-stage.enum.js +14 -0
- package/build/writer/index.js +22 -0
- package/build/writer/models/index.js +21 -0
- package/build/writer/models/writer-ai-action.schema.js +26 -0
- package/build/writer/models/writer-config.schema.js +13 -0
- package/build/writer/models/writer-document-outline.schema.js +21 -0
- package/build/writer/models/writer-document-type.schema.js +15 -0
- package/build/writer/models/writer-document.schema.js +23 -0
- package/build/writer/queries/find-writer-document-by-uuid.query.js +11 -0
- package/build/writer/queries/find-writer-documents.query.js +21 -0
- package/build/writer/queries/get-writer-config.query.js +9 -0
- package/build/writer/queries/index.js +19 -0
- package/build/writer/routes/index.js +17 -0
- package/build/writer/routes/writer.routes.js +20 -0
- package/build/writer/utils/calculate-writer-ai-action-price.util.js +16 -0
- package/build/writer/utils/calculate-writer-content-generation-price.util.js +6 -0
- package/build/writer/utils/index.js +18 -0
- package/common/enums/index.ts +0 -1
- package/common/errors/errors.ts +126 -0
- package/image-editor/models/image-editor-model.schema.ts +1 -2
- package/index.ts +3 -0
- package/package.json +1 -1
- package/stt/models/stt-model.schema.ts +1 -2
- package/tts/models/tts-model.schema.ts +1 -2
- package/video/models/video-model.schema.ts +1 -2
- package/writer/commands/create-writer-document.command.ts +17 -0
- package/writer/commands/delete-all-user-writer-documents.command.ts +18 -0
- package/writer/commands/delete-writer-document.command.ts +14 -0
- package/writer/commands/export-writer-document-as-docx.command.ts +18 -0
- package/writer/commands/generate-document-contents.command.ts +16 -0
- package/writer/commands/index.ts +12 -0
- package/writer/commands/update-writer-document-contents.command.ts +19 -0
- package/writer/commands/update-writer-document-final-md.command.ts +19 -0
- package/writer/commands/update-writer-document-outline.command.ts +16 -0
- package/writer/commands/writer-extend-text.command.ts +20 -0
- package/writer/commands/writer-fix-errors.command.ts +20 -0
- package/writer/commands/writer-generate-text.command.ts +23 -0
- package/writer/commands/writer-paraphrase.command.ts +20 -0
- package/writer/commands/writer-shorten-text.command.ts +20 -0
- package/writer/enums/index.ts +5 -0
- package/writer/enums/writer-ai-action-call.enum.ts +5 -0
- package/writer/enums/writer-ai-action-pricing-type.enum.ts +4 -0
- package/writer/enums/writer-ai-action-type.enum.ts +7 -0
- package/writer/enums/writer-document-section-type.enum.ts +5 -0
- package/writer/enums/writer-document-stage.enum.ts +13 -0
- package/writer/index.ts +6 -0
- package/writer/models/index.ts +5 -0
- package/writer/models/writer-ai-action.schema.ts +27 -0
- package/writer/models/writer-config.schema.ts +12 -0
- package/writer/models/writer-document-outline.schema.ts +27 -0
- package/writer/models/writer-document-type.schema.ts +14 -0
- package/writer/models/writer-document.schema.ts +22 -0
- package/writer/queries/find-writer-document-by-uuid.query.ts +11 -0
- package/writer/queries/find-writer-documents.query.ts +24 -0
- package/writer/queries/get-writer-config.query.ts +8 -0
- package/writer/queries/index.ts +3 -0
- package/writer/routes/index.ts +1 -0
- package/writer/routes/writer.routes.ts +17 -0
- package/writer/utils/calculate-writer-ai-action-price.util.ts +20 -0
- package/writer/utils/calculate-writer-content-generation-price.util.ts +3 -0
- package/writer/utils/index.ts +2 -0
- package/build/common/enums/tool-model-status.enum.js +0 -8
- package/common/enums/tool-model-status.enum.ts +0 -4
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WriterDocumentOutlineSchema = exports.WriterDocumentOutlineSectionSchema = exports.WriterDocumentOutlineSubsectionSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const enums_1 = require("../enums");
|
|
6
|
+
exports.WriterDocumentOutlineSubsectionSchema = zod_1.z.object({
|
|
7
|
+
title: zod_1.z
|
|
8
|
+
.string()
|
|
9
|
+
.min(3)
|
|
10
|
+
.max(120)
|
|
11
|
+
.describe(`Concise title of the subsection. Meant to elaborate on its parent section's title.`),
|
|
12
|
+
});
|
|
13
|
+
exports.WriterDocumentOutlineSectionSchema = zod_1.z.object({
|
|
14
|
+
title: zod_1.z.string().min(3).max(120).describe(`Concise title of the paper section.`),
|
|
15
|
+
type: zod_1.z.nativeEnum(enums_1.WRITER_DOCUMENT_SECTION_TYPE),
|
|
16
|
+
subsections: zod_1.z
|
|
17
|
+
.array(exports.WriterDocumentOutlineSubsectionSchema)
|
|
18
|
+
.optional()
|
|
19
|
+
.describe(`Subsections of the paper section. Each subsection is a single idea that is a part of the parent section.`),
|
|
20
|
+
});
|
|
21
|
+
exports.WriterDocumentOutlineSchema = zod_1.z.array(exports.WriterDocumentOutlineSectionSchema);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WriterDocumentTypeSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
exports.WriterDocumentTypeSchema = zod_1.z.object({
|
|
6
|
+
uuid: zod_1.z.string().uuid(),
|
|
7
|
+
title: zod_1.z.string(),
|
|
8
|
+
icon: zod_1.z.string(),
|
|
9
|
+
order: zod_1.z.number(),
|
|
10
|
+
minPages: zod_1.z.number(),
|
|
11
|
+
maxPages: zod_1.z.number(),
|
|
12
|
+
needsTableOfContents: zod_1.z.boolean(),
|
|
13
|
+
createdAt: zod_1.z.date(),
|
|
14
|
+
updatedAt: zod_1.z.date(),
|
|
15
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WriterDocumentSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const writer_document_outline_schema_1 = require("./writer-document-outline.schema");
|
|
6
|
+
const enums_1 = require("../enums");
|
|
7
|
+
exports.WriterDocumentSchema = zod_1.z.object({
|
|
8
|
+
uuid: zod_1.z.string().uuid(),
|
|
9
|
+
prompt: zod_1.z.string(),
|
|
10
|
+
topic: zod_1.z.string(),
|
|
11
|
+
typeId: zod_1.z.string(),
|
|
12
|
+
stage: zod_1.z.nativeEnum(enums_1.WRITER_DOCUMENT_STAGE),
|
|
13
|
+
outline: writer_document_outline_schema_1.WriterDocumentOutlineSchema,
|
|
14
|
+
sourceMd: zod_1.z.string().nullable(),
|
|
15
|
+
finalMd: zod_1.z.string().nullable(),
|
|
16
|
+
userId: zod_1.z.string().nullable(),
|
|
17
|
+
unregisteredUserId: zod_1.z.string().nullable(),
|
|
18
|
+
pages: zod_1.z.number(),
|
|
19
|
+
isDeleted: zod_1.z.boolean(),
|
|
20
|
+
createdAt: zod_1.z.date(),
|
|
21
|
+
updatedAt: zod_1.z.date(),
|
|
22
|
+
completedAt: zod_1.z.date().nullable(),
|
|
23
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FindWriterDocumentByUuidQueryContract = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const common_1 = require("../../common");
|
|
6
|
+
const models_1 = require("../models");
|
|
7
|
+
var FindWriterDocumentByUuidQueryContract;
|
|
8
|
+
(function (FindWriterDocumentByUuidQueryContract) {
|
|
9
|
+
FindWriterDocumentByUuidQueryContract.RequestSchema = zod_1.z.object({ uuid: zod_1.z.string().uuid() });
|
|
10
|
+
FindWriterDocumentByUuidQueryContract.ResponseSchema = (0, common_1.ICommandResponseSchema)(models_1.WriterDocumentSchema);
|
|
11
|
+
})(FindWriterDocumentByUuidQueryContract || (exports.FindWriterDocumentByUuidQueryContract = FindWriterDocumentByUuidQueryContract = {}));
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FindWriterDocumentsQuery = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const command_response_schema_1 = require("../../common/models/command-response.schema");
|
|
6
|
+
const models_1 = require("../models");
|
|
7
|
+
var FindWriterDocumentsQuery;
|
|
8
|
+
(function (FindWriterDocumentsQuery) {
|
|
9
|
+
FindWriterDocumentsQuery.RequestSchema = zod_1.z.object({
|
|
10
|
+
userId: zod_1.z.string().uuid().optional(),
|
|
11
|
+
unregisteredUserId: zod_1.z.string().uuid().optional(),
|
|
12
|
+
title: zod_1.z.string().optional(),
|
|
13
|
+
limit: zod_1.z.coerce.number().min(1).optional(),
|
|
14
|
+
offset: zod_1.z.coerce.number().min(0).optional(),
|
|
15
|
+
});
|
|
16
|
+
FindWriterDocumentsQuery.ResponseSchema = (0, command_response_schema_1.ICommandResponseSchema)(zod_1.z.object({
|
|
17
|
+
data: zod_1.z.array(models_1.WriterDocumentSchema),
|
|
18
|
+
page: zod_1.z.number(),
|
|
19
|
+
totalPages: zod_1.z.number(),
|
|
20
|
+
}));
|
|
21
|
+
})(FindWriterDocumentsQuery || (exports.FindWriterDocumentsQuery = FindWriterDocumentsQuery = {}));
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GetWriterConfigQuery = void 0;
|
|
4
|
+
const common_1 = require("../../common");
|
|
5
|
+
const models_1 = require("../models");
|
|
6
|
+
var GetWriterConfigQuery;
|
|
7
|
+
(function (GetWriterConfigQuery) {
|
|
8
|
+
GetWriterConfigQuery.ResponseSchema = (0, common_1.ICommandResponseSchema)(models_1.WriterConfigSchema);
|
|
9
|
+
})(GetWriterConfigQuery || (exports.GetWriterConfigQuery = GetWriterConfigQuery = {}));
|
|
@@ -0,0 +1,19 @@
|
|
|
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("./find-writer-documents.query"), exports);
|
|
18
|
+
__exportStar(require("./get-writer-config.query"), exports);
|
|
19
|
+
__exportStar(require("./find-writer-document-by-uuid.query"), exports);
|
|
@@ -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("./writer.routes"), exports);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WRITER_AMQP_ROUTES = void 0;
|
|
4
|
+
exports.WRITER_AMQP_ROUTES = {
|
|
5
|
+
CONFIG: 'tools.writer.config.rpc',
|
|
6
|
+
CREATE_DOCUMENT: 'tools.writer.create-document.rpc',
|
|
7
|
+
FIND_BY_UUID: 'tools.writer.find-by-uuid.rpc',
|
|
8
|
+
FIND_DOCUMENTS: 'tools.writer.find-documents.rpc',
|
|
9
|
+
DELETE_DOCUMENT: 'tools.writer.delete-document.rpc',
|
|
10
|
+
DELETE_ALL_USER_DOCUMENTS: 'tools.writer.delete-all-user-documents.rpc',
|
|
11
|
+
UPDATE_DOCUMENT_OUTLINE: 'tools.writer.update-document-outline.rpc',
|
|
12
|
+
UPDATE_DOCUMENT_CONTENTS: 'tools.writer.update-document-contents.rpc',
|
|
13
|
+
GENERATE_DOCUMENT_CONTENTS: 'tools.writer.generate-document-contents.rpc',
|
|
14
|
+
PARAPHRASE: 'tools.writer.actions.paraphrase.rpc',
|
|
15
|
+
EXTEND_TEXT: 'tools.writer.actions.extend-text.rpc',
|
|
16
|
+
SHORTEN_TEXT: 'tools.writer.actions.shorten-text.rpc',
|
|
17
|
+
FIX_ERRORS: 'tools.writer.actions.fix-errors.rpc',
|
|
18
|
+
GENERATE_TEXT: 'tools.writer.actions.generate-text.rpc',
|
|
19
|
+
EXPORT_DOCX: 'tools.writer.export-docx.rpc',
|
|
20
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.calculateWriterAiActionPrice = calculateWriterAiActionPrice;
|
|
4
|
+
const enums_1 = require("../enums");
|
|
5
|
+
function calculateWriterAiActionPrice(pricingRules, selectionText) {
|
|
6
|
+
switch (pricingRules.type) {
|
|
7
|
+
case enums_1.WRITER_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.WRITER_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,18 @@
|
|
|
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-writer-ai-action-price.util"), exports);
|
|
18
|
+
__exportStar(require("./calculate-writer-content-generation-price.util"), exports);
|
package/common/enums/index.ts
CHANGED
package/common/errors/errors.ts
CHANGED
|
@@ -528,6 +528,132 @@ export const ERRORS = {
|
|
|
528
528
|
httpCode: 500,
|
|
529
529
|
},
|
|
530
530
|
},
|
|
531
|
+
WRITER_DOCUMENT: {
|
|
532
|
+
SAVE_ERROR: {
|
|
533
|
+
code: 'WRITER_DOCUMENT.SAVE_ERROR',
|
|
534
|
+
message: 'Произошла ошибка при сохранении документа',
|
|
535
|
+
httpCode: 500,
|
|
536
|
+
},
|
|
537
|
+
FIND_ERROR: {
|
|
538
|
+
code: 'WRITER_DOCUMENT.FIND_ERROR',
|
|
539
|
+
message: 'Произошла ошибка при поиске документа',
|
|
540
|
+
httpCode: 500,
|
|
541
|
+
},
|
|
542
|
+
NOT_FOUND: {
|
|
543
|
+
code: 'WRITER_DOCUMENT.NOT_FOUND',
|
|
544
|
+
message: 'Документ не найден',
|
|
545
|
+
httpCode: 404,
|
|
546
|
+
},
|
|
547
|
+
DELETE_ERROR: {
|
|
548
|
+
code: 'WRITER_DOCUMENT.DELETE_ERROR',
|
|
549
|
+
message: 'Произошла ошибка при удалении документа',
|
|
550
|
+
httpCode: 500,
|
|
551
|
+
},
|
|
552
|
+
GENERATE_OUTLINE_ERROR: {
|
|
553
|
+
code: 'WRITER_DOCUMENT.GENERATE_OUTLINE_AI_ERROR',
|
|
554
|
+
message: 'Произошла ошибка при генерации макета документа',
|
|
555
|
+
httpCode: 500,
|
|
556
|
+
},
|
|
557
|
+
GENERATE_CONTENT_ERROR: {
|
|
558
|
+
code: 'WRITER_DOCUMENT.GENERATE_CONTENT_ERROR',
|
|
559
|
+
message: 'Произошла ошибка при генерации содержимого документа',
|
|
560
|
+
httpCode: 500,
|
|
561
|
+
},
|
|
562
|
+
GENERATE_CONTENT_AI_ERROR: {
|
|
563
|
+
code: 'WRITER_DOCUMENT.GENERATE_CONTENT_AI_ERROR',
|
|
564
|
+
message: 'Произошла ошибка во время запроса к ИИ при генерации содержимого',
|
|
565
|
+
httpCode: 500,
|
|
566
|
+
},
|
|
567
|
+
OUTLINE_UPDATE_ERROR: {
|
|
568
|
+
code: 'WRITER_DOCUMENT.OUTLINE_UPDATE_ERROR',
|
|
569
|
+
message: 'Произошла ошибка при обновлении макета документа',
|
|
570
|
+
httpCode: 500,
|
|
571
|
+
},
|
|
572
|
+
STAGE_OUTLINE_GENERATED_REQUIRED: {
|
|
573
|
+
code: 'WRITER_DOCUMENT.STAGE_OUTLINE_GENERATED_REQUIRED',
|
|
574
|
+
message: 'Данная операция доступна только сразу же после этапа генерации макета',
|
|
575
|
+
httpCode: 400,
|
|
576
|
+
},
|
|
577
|
+
STAGE_CONTENT_GENERATED_REQUIRED: {
|
|
578
|
+
code: 'WRITER_DOCUMENT.STAGE_CONTENT_GENERATED_REQUIRED',
|
|
579
|
+
message: 'Данная операция доступна только после генерации содержимого документа',
|
|
580
|
+
httpCode: 400,
|
|
581
|
+
},
|
|
582
|
+
NOT_AN_OWNER: {
|
|
583
|
+
code: 'WRITER_DOCUMENT.NOT_AN_OWNER',
|
|
584
|
+
message: 'Пользователь не является владельцем документа',
|
|
585
|
+
httpCode: 403,
|
|
586
|
+
},
|
|
587
|
+
TOO_MANY_PAGES: {
|
|
588
|
+
code: 'WRITER_DOCUMENT.TOO_MANY_PAGES',
|
|
589
|
+
message: 'Превышено максимальное количество страниц',
|
|
590
|
+
httpCode: 400,
|
|
591
|
+
},
|
|
592
|
+
TOO_FEW_PAGES: {
|
|
593
|
+
code: 'WRITER_DOCUMENT.TOO_FEW_PAGES',
|
|
594
|
+
message: 'Минимальное количество страниц не достигнуто',
|
|
595
|
+
httpCode: 400,
|
|
596
|
+
},
|
|
597
|
+
TOPIC_TOO_LONG: {
|
|
598
|
+
code: 'WRITER_DOCUMENT.TOPIC_TOO_LONG',
|
|
599
|
+
message: 'Тема слишком длинная',
|
|
600
|
+
httpCode: 400,
|
|
601
|
+
},
|
|
602
|
+
DOCUMENT_TYPE_NOT_FOUND: {
|
|
603
|
+
code: 'WRITER_DOCUMENT.DOCUMENT_TYPE_NOT_FOUND',
|
|
604
|
+
message: 'Тип документа не найден',
|
|
605
|
+
httpCode: 404,
|
|
606
|
+
},
|
|
607
|
+
},
|
|
608
|
+
WRITER_AI_ACTION: {
|
|
609
|
+
AI_ERROR: {
|
|
610
|
+
code: 'WRITER_AI_ACTION.AI_ERROR',
|
|
611
|
+
message: 'Произошла ошибка во время запроса к ИИ',
|
|
612
|
+
httpCode: 500,
|
|
613
|
+
},
|
|
614
|
+
SAVE_ERROR: {
|
|
615
|
+
code: 'WRITER_AI_ACTION.SAVE_ERROR',
|
|
616
|
+
message: 'Произошла ошибка при сохранении операции',
|
|
617
|
+
httpCode: 500,
|
|
618
|
+
},
|
|
619
|
+
FIND_ERROR: {
|
|
620
|
+
code: 'WRITER_AI_ACTION.FIND_ERROR',
|
|
621
|
+
message: 'Произошла ошибка при поиске операции',
|
|
622
|
+
httpCode: 500,
|
|
623
|
+
},
|
|
624
|
+
NOT_FOUND: {
|
|
625
|
+
code: 'WRITER_AI_ACTION.NOT_FOUND',
|
|
626
|
+
message: 'Операция не найдена',
|
|
627
|
+
httpCode: 404,
|
|
628
|
+
},
|
|
629
|
+
INSUFFICIENT_BALANCE: {
|
|
630
|
+
code: 'WRITER_AI_ACTION.INSUFFICIENT_BALANCE',
|
|
631
|
+
message: 'У пользователя недостаточно средств для выполнения операции',
|
|
632
|
+
httpCode: 400,
|
|
633
|
+
},
|
|
634
|
+
PROMPT_TOO_LONG: {
|
|
635
|
+
code: 'WRITER_AI_ACTION.PROMPT_TOO_LONG',
|
|
636
|
+
message: 'Выделенный текст превышает максимально допустимую длину для данной операции',
|
|
637
|
+
httpCode: 400,
|
|
638
|
+
},
|
|
639
|
+
},
|
|
640
|
+
WRITER_AI_ACTION_CALL: {
|
|
641
|
+
SAVE_ERROR: {
|
|
642
|
+
code: 'WRITER_AI_ACTION_CALL.SAVE_ERROR',
|
|
643
|
+
message: 'Произошла ошибка при сохранении вызова операции',
|
|
644
|
+
httpCode: 500,
|
|
645
|
+
},
|
|
646
|
+
FIND_ERROR: {
|
|
647
|
+
code: 'WRITER_AI_ACTION_CALL.FIND_ERROR',
|
|
648
|
+
message: 'Произошла ошибка при поиске вызова операции',
|
|
649
|
+
httpCode: 500,
|
|
650
|
+
},
|
|
651
|
+
NOT_FOUND: {
|
|
652
|
+
code: 'WRITER_AI_ACTION_CALL.NOT_FOUND',
|
|
653
|
+
message: 'Вызов операции не найден',
|
|
654
|
+
httpCode: 404,
|
|
655
|
+
},
|
|
656
|
+
},
|
|
531
657
|
PROMPT_MODERATION: {
|
|
532
658
|
AI_ERROR: {
|
|
533
659
|
code: 'PROMPT_MODERATION.AI_ERROR',
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import {
|
|
2
|
+
import { IconVariantsSchema } from '../../common';
|
|
3
3
|
import { IMAGE_EDITING_STRATEGY } from '../enums';
|
|
4
4
|
|
|
5
5
|
export const ImageEditorModelParamsSchema = z.object({
|
|
@@ -19,7 +19,6 @@ export const ImageEditorModelSchema = z.object({
|
|
|
19
19
|
aiModel: z.string(),
|
|
20
20
|
pricePerImage: z.number(),
|
|
21
21
|
order: z.number(),
|
|
22
|
-
status: z.nativeEnum(TOOL_MODEL_STATUS),
|
|
23
22
|
icons: IconVariantsSchema,
|
|
24
23
|
strategy: z.nativeEnum(IMAGE_EDITING_STRATEGY),
|
|
25
24
|
maxInputLength: z.number(),
|
package/index.ts
CHANGED
|
@@ -5,6 +5,7 @@ export * from './stt';
|
|
|
5
5
|
export * from './tts';
|
|
6
6
|
export * from './language';
|
|
7
7
|
export * from './video';
|
|
8
|
+
export * from './writer';
|
|
8
9
|
export * from './image-editor';
|
|
9
10
|
|
|
10
11
|
import * as common from './common';
|
|
@@ -15,6 +16,7 @@ import * as tts from './tts';
|
|
|
15
16
|
import * as presentation from './presentation';
|
|
16
17
|
import * as language from './language';
|
|
17
18
|
import * as video from './video';
|
|
19
|
+
import * as writer from './writer';
|
|
18
20
|
import * as imageEditor from './image-editor';
|
|
19
21
|
|
|
20
22
|
export namespace ToolService {
|
|
@@ -26,5 +28,6 @@ export namespace ToolService {
|
|
|
26
28
|
export import Presentation = presentation;
|
|
27
29
|
export import Language = language;
|
|
28
30
|
export import Video = video;
|
|
31
|
+
export import Writer = writer;
|
|
29
32
|
export import ImageEditor = imageEditor;
|
|
30
33
|
}
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import {
|
|
2
|
+
import { IconVariantsSchema } from '../../common';
|
|
3
3
|
|
|
4
4
|
export const STTModelSchema = z.object({
|
|
5
5
|
uuid: z.string(),
|
|
@@ -8,7 +8,6 @@ export const STTModelSchema = z.object({
|
|
|
8
8
|
aiModel: z.string(),
|
|
9
9
|
pricePerSecond: z.number(),
|
|
10
10
|
order: z.number(),
|
|
11
|
-
status: z.nativeEnum(TOOL_MODEL_STATUS),
|
|
12
11
|
icons: IconVariantsSchema,
|
|
13
12
|
strategy: z.string().optional(),
|
|
14
13
|
maxDurationSeconds: z.number(),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IconVariantsSchema } from '../../common';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
|
|
4
4
|
export const TTSVoiceSchema = z.object({
|
|
@@ -50,7 +50,6 @@ export const TTSModelSchema = z.object({
|
|
|
50
50
|
aiModel: z.string(),
|
|
51
51
|
pricePerSymbol: z.number(),
|
|
52
52
|
order: z.number(),
|
|
53
|
-
status: z.nativeEnum(TOOL_MODEL_STATUS),
|
|
54
53
|
icons: IconVariantsSchema,
|
|
55
54
|
strategy: z.string().optional(),
|
|
56
55
|
maxInputLength: z.number(),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import {
|
|
2
|
+
import { IconVariantsSchema } from '../../common';
|
|
3
3
|
import { VIDEO_GENERATION_STRATEGY, VIDEO_PRICING_RULE_TYPE } from '../enums';
|
|
4
4
|
|
|
5
5
|
export const VideoModelParamsSchema = z.object({
|
|
@@ -49,7 +49,6 @@ export const VideoModelSchema = z.object({
|
|
|
49
49
|
aiModel: z.string(),
|
|
50
50
|
pricePerSecond: z.number(),
|
|
51
51
|
order: z.number(),
|
|
52
|
-
status: z.nativeEnum(TOOL_MODEL_STATUS),
|
|
53
52
|
icons: IconVariantsSchema,
|
|
54
53
|
strategy: z.nativeEnum(VIDEO_GENERATION_STRATEGY),
|
|
55
54
|
maxInputLength: z.number(),
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ICommandResponseSchema } from '../../common';
|
|
3
|
+
import { WriterDocumentSchema } from '../models';
|
|
4
|
+
|
|
5
|
+
export namespace CreateWriterDocumentCommand {
|
|
6
|
+
export const RequestSchema = z.object({
|
|
7
|
+
userId: z.string().uuid().nullable().optional(),
|
|
8
|
+
unregisteredUserId: z.string().uuid().nullable().optional(),
|
|
9
|
+
prompt: z.string(),
|
|
10
|
+
numPages: z.number(),
|
|
11
|
+
documentTypeId: z.string().uuid(),
|
|
12
|
+
});
|
|
13
|
+
export type Request = z.infer<typeof RequestSchema>;
|
|
14
|
+
|
|
15
|
+
export const ResponseSchema = ICommandResponseSchema(WriterDocumentSchema);
|
|
16
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ICommandResponseSchema } from '../../common';
|
|
3
|
+
|
|
4
|
+
export namespace DeleteAllUserWriterDocumentsCommandContract {
|
|
5
|
+
export const RequestSchema = z
|
|
6
|
+
.object({
|
|
7
|
+
userId: z.string().uuid().nullable().optional(),
|
|
8
|
+
unregisteredUserId: z.string().uuid().nullable().optional(),
|
|
9
|
+
})
|
|
10
|
+
.refine((v) => !!v.userId !== !!v.unregisteredUserId, {
|
|
11
|
+
message: 'Provide either userId or unregisteredUserId',
|
|
12
|
+
path: ['userId', 'unregisteredUserId'],
|
|
13
|
+
});
|
|
14
|
+
export type Request = z.infer<typeof RequestSchema>;
|
|
15
|
+
|
|
16
|
+
export const ResponseSchema = ICommandResponseSchema(z.boolean());
|
|
17
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ICommandResponseSchema } from '../../common';
|
|
3
|
+
|
|
4
|
+
export namespace DeleteWriterDocumentCommandContract {
|
|
5
|
+
export const RequestSchema = z.object({
|
|
6
|
+
documentId: z.string().uuid(),
|
|
7
|
+
userId: z.string().uuid().nullable().optional(),
|
|
8
|
+
unregisteredUserId: z.string().uuid().nullable().optional(),
|
|
9
|
+
});
|
|
10
|
+
export type Request = z.infer<typeof RequestSchema>;
|
|
11
|
+
|
|
12
|
+
export const ResponseSchema = ICommandResponseSchema(z.boolean());
|
|
13
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ICommandResponseSchema } from '../../common';
|
|
3
|
+
|
|
4
|
+
export namespace ExportWriterDocumentAsDocxCommand {
|
|
5
|
+
export const RequestSchema = z.object({
|
|
6
|
+
userId: z.string().uuid().nullable().optional(),
|
|
7
|
+
unregisteredUserId: z.string().uuid().nullable().optional(),
|
|
8
|
+
documentId: z.string().uuid(),
|
|
9
|
+
});
|
|
10
|
+
export type Request = z.infer<typeof RequestSchema>;
|
|
11
|
+
|
|
12
|
+
export const ResponseSchema = ICommandResponseSchema(
|
|
13
|
+
z.object({
|
|
14
|
+
url: z.string().url(),
|
|
15
|
+
}),
|
|
16
|
+
);
|
|
17
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ICommandResponseSchema } from '../../common';
|
|
3
|
+
import { WriterDocumentSchema } from '../models';
|
|
4
|
+
|
|
5
|
+
export namespace GenerateWriterDocumentContentsCommand {
|
|
6
|
+
export const RequestSchema = z.object({
|
|
7
|
+
documentId: z.string().uuid(),
|
|
8
|
+
userId: z.string().uuid().nullable().optional(),
|
|
9
|
+
unregisteredUserId: z.string().uuid().nullable().optional(),
|
|
10
|
+
userBalance: z.number(),
|
|
11
|
+
});
|
|
12
|
+
export type Request = z.infer<typeof RequestSchema>;
|
|
13
|
+
|
|
14
|
+
export const ResponseSchema = ICommandResponseSchema(WriterDocumentSchema);
|
|
15
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export * from './create-writer-document.command';
|
|
2
|
+
export * from './delete-writer-document.command';
|
|
3
|
+
export * from './delete-all-user-writer-documents.command';
|
|
4
|
+
export * from './update-writer-document-outline.command';
|
|
5
|
+
export * from './export-writer-document-as-docx.command';
|
|
6
|
+
export * from './generate-document-contents.command';
|
|
7
|
+
export * from './writer-paraphrase.command';
|
|
8
|
+
export * from './writer-extend-text.command';
|
|
9
|
+
export * from './writer-shorten-text.command';
|
|
10
|
+
export * from './writer-fix-errors.command';
|
|
11
|
+
export * from './writer-generate-text.command';
|
|
12
|
+
export * from './update-writer-document-contents.command';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ICommandResponseSchema } from '../../common';
|
|
3
|
+
|
|
4
|
+
export namespace UpdateWriterDocumentContentsCommand {
|
|
5
|
+
export const RequestSchema = z.object({
|
|
6
|
+
userId: z.string().uuid().nullable().optional(),
|
|
7
|
+
unregisteredUserId: z.string().uuid().nullable().optional(),
|
|
8
|
+
documentId: z.string().uuid(),
|
|
9
|
+
contents: z.string(),
|
|
10
|
+
});
|
|
11
|
+
export type Request = z.infer<typeof RequestSchema>;
|
|
12
|
+
|
|
13
|
+
export const ResponseSchema = ICommandResponseSchema(
|
|
14
|
+
z.object({
|
|
15
|
+
success: z.boolean(),
|
|
16
|
+
}),
|
|
17
|
+
);
|
|
18
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ICommandResponseSchema } from '../../common';
|
|
3
|
+
|
|
4
|
+
export namespace UpdateWriterDocumentContentsCommand {
|
|
5
|
+
export const RequestSchema = z.object({
|
|
6
|
+
userId: z.string().uuid().nullable().optional(),
|
|
7
|
+
unregisteredUserId: z.string().uuid().nullable().optional(),
|
|
8
|
+
documentId: z.string().uuid(),
|
|
9
|
+
contents: z.string(),
|
|
10
|
+
});
|
|
11
|
+
export type Request = z.infer<typeof RequestSchema>;
|
|
12
|
+
|
|
13
|
+
export const ResponseSchema = ICommandResponseSchema(
|
|
14
|
+
z.object({
|
|
15
|
+
success: z.boolean(),
|
|
16
|
+
}),
|
|
17
|
+
);
|
|
18
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ICommandResponseSchema } from '../../common';
|
|
3
|
+
import { WriterDocumentOutlineSchema } from '../models';
|
|
4
|
+
|
|
5
|
+
export namespace UpdateWriterDocumentOutlineCommand {
|
|
6
|
+
export const RequestSchema = z.object({
|
|
7
|
+
userId: z.string().uuid().nullable().optional(),
|
|
8
|
+
unregisteredUserId: z.string().uuid().nullable().optional(),
|
|
9
|
+
documentId: z.string().uuid(),
|
|
10
|
+
data: WriterDocumentOutlineSchema,
|
|
11
|
+
});
|
|
12
|
+
export type Request = z.infer<typeof RequestSchema>;
|
|
13
|
+
|
|
14
|
+
export const ResponseSchema = ICommandResponseSchema(WriterDocumentOutlineSchema);
|
|
15
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ICommandResponseSchema } from '../../common';
|
|
3
|
+
|
|
4
|
+
export namespace WriterExtendTextCommand {
|
|
5
|
+
export const RequestSchema = z.object({
|
|
6
|
+
userId: z.string().uuid().nullable().optional(),
|
|
7
|
+
unregisteredUserId: z.string().uuid().nullable().optional(),
|
|
8
|
+
documentId: z.string().uuid(),
|
|
9
|
+
selectionText: z.string(),
|
|
10
|
+
userBalance: z.number(),
|
|
11
|
+
});
|
|
12
|
+
export type Request = z.infer<typeof RequestSchema>;
|
|
13
|
+
|
|
14
|
+
export const ResponseSchema = ICommandResponseSchema(
|
|
15
|
+
z.object({
|
|
16
|
+
output: z.string(),
|
|
17
|
+
}),
|
|
18
|
+
);
|
|
19
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
20
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ICommandResponseSchema } from '../../common';
|
|
3
|
+
|
|
4
|
+
export namespace WriterFixErrorsCommand {
|
|
5
|
+
export const RequestSchema = z.object({
|
|
6
|
+
userId: z.string().uuid().nullable().optional(),
|
|
7
|
+
unregisteredUserId: z.string().uuid().nullable().optional(),
|
|
8
|
+
documentId: z.string().uuid(),
|
|
9
|
+
selectionText: z.string(),
|
|
10
|
+
userBalance: z.number(),
|
|
11
|
+
});
|
|
12
|
+
export type Request = z.infer<typeof RequestSchema>;
|
|
13
|
+
|
|
14
|
+
export const ResponseSchema = ICommandResponseSchema(
|
|
15
|
+
z.object({
|
|
16
|
+
output: z.string(),
|
|
17
|
+
}),
|
|
18
|
+
);
|
|
19
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
20
|
+
}
|