@purpleschool/gptbot-tools 0.0.36 → 0.0.37-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/errors/errors.js +104 -8
- package/build/image-editor/commands/delete-all-image-editor-jobs.command.js +13 -0
- package/build/image-editor/commands/delete-image-editor-job-by-uuid.command.js +14 -0
- package/build/image-editor/commands/image-editor.command.js +21 -0
- package/build/image-editor/commands/index.js +22 -0
- package/build/image-editor/commands/retry-image-editor-job.command.js +16 -0
- package/build/image-editor/commands/set-reaction-to-image-editor-job.command.js +17 -0
- package/build/image-editor/commands/update-image-editor-job-title.command.js +16 -0
- package/build/image-editor/enums/image-editor-model-type.enum.js +7 -0
- package/build/image-editor/enums/image-editor-strategy.enum.js +8 -0
- package/build/image-editor/enums/index.js +18 -0
- package/build/image-editor/index.js +21 -0
- package/build/image-editor/models/image-editor-config.schema.js +32 -0
- package/build/image-editor/models/image-editor-job.schema.js +30 -0
- package/build/image-editor/models/image-editor-model.schema.js +27 -0
- package/build/image-editor/models/index.js +19 -0
- package/build/image-editor/queries/find-image-editor-job-by-id.query.js +10 -0
- package/build/image-editor/queries/find-image-editor-jobs.query.js +21 -0
- package/build/image-editor/queries/find-image-jobs.query.js +21 -0
- package/build/image-editor/queries/get-image-editor-config.query.js +9 -0
- package/build/image-editor/queries/index.js +19 -0
- package/build/image-editor/routes/image-editor.amqp.routes.js +14 -0
- package/build/image-editor/routes/image-editor.http.routes.js +7 -0
- package/build/image-editor/routes/index.js +18 -0
- package/build/index.js +3 -0
- package/build/writer/commands/create-writer-document.command.js +1 -1
- package/build/writer/commands/generate-document-contents.command.js +1 -0
- package/build/writer/commands/index.js +6 -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/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 +3 -2
- 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/index.js +1 -0
- package/build/writer/models/index.js +1 -1
- package/build/writer/models/writer-ai-action.schema.js +26 -0
- package/build/writer/models/writer-config.schema.js +3 -3
- package/build/writer/routes/writer.routes.js +6 -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/errors/errors.ts +105 -8
- package/image-editor/commands/delete-all-image-editor-jobs.command.ts +13 -0
- package/image-editor/commands/delete-image-editor-job-by-uuid.command.ts +14 -0
- package/image-editor/commands/image-editor.command.ts +21 -0
- package/image-editor/commands/index.ts +6 -0
- package/image-editor/commands/retry-image-editor-job.command.ts +16 -0
- package/image-editor/commands/set-reaction-to-image-editor-job.command.ts +17 -0
- package/image-editor/commands/update-image-editor-job-title.command.ts +16 -0
- package/image-editor/enums/image-editor-model-type.enum.ts +3 -0
- package/image-editor/enums/image-editor-strategy.enum.ts +4 -0
- package/image-editor/enums/index.ts +2 -0
- package/image-editor/index.ts +5 -0
- package/image-editor/models/image-editor-config.schema.ts +34 -0
- package/image-editor/models/image-editor-job.schema.ts +33 -0
- package/image-editor/models/image-editor-model.schema.ts +30 -0
- package/image-editor/models/index.ts +3 -0
- package/image-editor/queries/find-image-editor-job-by-id.query.ts +11 -0
- package/image-editor/queries/find-image-editor-jobs.query.ts +23 -0
- package/image-editor/queries/find-image-jobs.query.ts +23 -0
- package/image-editor/queries/get-image-editor-config.query.ts +8 -0
- package/image-editor/queries/index.ts +3 -0
- package/image-editor/routes/image-editor.amqp.routes.ts +11 -0
- package/image-editor/routes/image-editor.http.routes.ts +5 -0
- package/image-editor/routes/index.ts +2 -0
- package/index.ts +3 -0
- package/package.json +1 -1
- package/writer/commands/create-writer-document.command.ts +1 -1
- package/writer/commands/generate-document-contents.command.ts +1 -0
- package/writer/commands/index.ts +6 -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/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 +3 -2
- package/writer/enums/writer-ai-action-call.enum.ts +5 -0
- package/writer/enums/{writer-ai-operation-pricing-type.enum.ts → writer-ai-action-pricing-type.enum.ts} +1 -1
- package/writer/enums/{writer-ai-operation-type.enum.ts → writer-ai-action-type.enum.ts} +3 -1
- package/writer/index.ts +1 -0
- package/writer/models/index.ts +1 -1
- package/writer/models/writer-ai-action.schema.ts +27 -0
- package/writer/models/writer-config.schema.ts +4 -4
- package/writer/routes/writer.routes.ts +6 -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/writer/enums/writer-ai-operation-pricing-type.enum.js +0 -8
- package/build/writer/enums/writer-ai-operation-type.enum.js +0 -9
- package/build/writer/models/writer-ai-operation.schema.js +0 -26
- package/writer/models/writer-ai-operation.schema.ts +0 -27
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UpdateWriterDocumentContentsCommand = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const common_1 = require("../../common");
|
|
6
|
+
var UpdateWriterDocumentContentsCommand;
|
|
7
|
+
(function (UpdateWriterDocumentContentsCommand) {
|
|
8
|
+
UpdateWriterDocumentContentsCommand.RequestSchema = zod_1.z.object({
|
|
9
|
+
userId: zod_1.z.string().uuid().nullable().optional(),
|
|
10
|
+
unregisteredUserId: zod_1.z.string().uuid().nullable().optional(),
|
|
11
|
+
documentId: zod_1.z.string().uuid(),
|
|
12
|
+
contents: zod_1.z.string(),
|
|
13
|
+
});
|
|
14
|
+
UpdateWriterDocumentContentsCommand.ResponseSchema = (0, common_1.ICommandResponseSchema)(zod_1.z.object({
|
|
15
|
+
success: zod_1.z.boolean(),
|
|
16
|
+
}));
|
|
17
|
+
})(UpdateWriterDocumentContentsCommand || (exports.UpdateWriterDocumentContentsCommand = UpdateWriterDocumentContentsCommand = {}));
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UpdateWriterDocumentContentsCommand = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const common_1 = require("../../common");
|
|
6
|
+
var UpdateWriterDocumentContentsCommand;
|
|
7
|
+
(function (UpdateWriterDocumentContentsCommand) {
|
|
8
|
+
UpdateWriterDocumentContentsCommand.RequestSchema = zod_1.z.object({
|
|
9
|
+
userId: zod_1.z.string().uuid().nullable().optional(),
|
|
10
|
+
unregisteredUserId: zod_1.z.string().uuid().nullable().optional(),
|
|
11
|
+
documentId: zod_1.z.string().uuid(),
|
|
12
|
+
contents: zod_1.z.string(),
|
|
13
|
+
});
|
|
14
|
+
UpdateWriterDocumentContentsCommand.ResponseSchema = (0, common_1.ICommandResponseSchema)(zod_1.z.object({
|
|
15
|
+
success: zod_1.z.boolean(),
|
|
16
|
+
}));
|
|
17
|
+
})(UpdateWriterDocumentContentsCommand || (exports.UpdateWriterDocumentContentsCommand = UpdateWriterDocumentContentsCommand = {}));
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WriterExtendTextCommand = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const common_1 = require("../../common");
|
|
6
|
+
var WriterExtendTextCommand;
|
|
7
|
+
(function (WriterExtendTextCommand) {
|
|
8
|
+
WriterExtendTextCommand.RequestSchema = zod_1.z.object({
|
|
9
|
+
userId: zod_1.z.string().uuid().nullable().optional(),
|
|
10
|
+
unregisteredUserId: zod_1.z.string().uuid().nullable().optional(),
|
|
11
|
+
documentId: zod_1.z.string().uuid(),
|
|
12
|
+
selectionText: zod_1.z.string(),
|
|
13
|
+
userBalance: zod_1.z.number(),
|
|
14
|
+
});
|
|
15
|
+
WriterExtendTextCommand.ResponseSchema = (0, common_1.ICommandResponseSchema)(zod_1.z.object({
|
|
16
|
+
output: zod_1.z.string(),
|
|
17
|
+
}));
|
|
18
|
+
})(WriterExtendTextCommand || (exports.WriterExtendTextCommand = WriterExtendTextCommand = {}));
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WriterFixErrorsCommand = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const common_1 = require("../../common");
|
|
6
|
+
var WriterFixErrorsCommand;
|
|
7
|
+
(function (WriterFixErrorsCommand) {
|
|
8
|
+
WriterFixErrorsCommand.RequestSchema = zod_1.z.object({
|
|
9
|
+
userId: zod_1.z.string().uuid().nullable().optional(),
|
|
10
|
+
unregisteredUserId: zod_1.z.string().uuid().nullable().optional(),
|
|
11
|
+
documentId: zod_1.z.string().uuid(),
|
|
12
|
+
selectionText: zod_1.z.string(),
|
|
13
|
+
userBalance: zod_1.z.number(),
|
|
14
|
+
});
|
|
15
|
+
WriterFixErrorsCommand.ResponseSchema = (0, common_1.ICommandResponseSchema)(zod_1.z.object({
|
|
16
|
+
output: zod_1.z.string(),
|
|
17
|
+
}));
|
|
18
|
+
})(WriterFixErrorsCommand || (exports.WriterFixErrorsCommand = WriterFixErrorsCommand = {}));
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WriterGenerateTextCommand = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const common_1 = require("../../common");
|
|
6
|
+
var WriterGenerateTextCommand;
|
|
7
|
+
(function (WriterGenerateTextCommand) {
|
|
8
|
+
WriterGenerateTextCommand.RequestSchema = zod_1.z.object({
|
|
9
|
+
documentId: zod_1.z.string().uuid(),
|
|
10
|
+
prompt: zod_1.z.string().min(1).max(500),
|
|
11
|
+
selectionText: zod_1.z.string(),
|
|
12
|
+
contextBefore: zod_1.z.string().optional(),
|
|
13
|
+
contextAfter: zod_1.z.string().optional(),
|
|
14
|
+
userId: zod_1.z.string().uuid().nullable().optional(),
|
|
15
|
+
unregisteredUserId: zod_1.z.string().uuid().nullable().optional(),
|
|
16
|
+
userBalance: zod_1.z.number(),
|
|
17
|
+
});
|
|
18
|
+
WriterGenerateTextCommand.ResponseSchema = (0, common_1.ICommandResponseSchema)(zod_1.z.object({
|
|
19
|
+
output: zod_1.z.string(),
|
|
20
|
+
}));
|
|
21
|
+
})(WriterGenerateTextCommand || (exports.WriterGenerateTextCommand = WriterGenerateTextCommand = {}));
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WriterParaphraseCommand = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const common_1 = require("../../common");
|
|
6
|
+
var WriterParaphraseCommand;
|
|
7
|
+
(function (WriterParaphraseCommand) {
|
|
8
|
+
WriterParaphraseCommand.RequestSchema = zod_1.z.object({
|
|
9
|
+
userId: zod_1.z.string().uuid().nullable().optional(),
|
|
10
|
+
unregisteredUserId: zod_1.z.string().uuid().nullable().optional(),
|
|
11
|
+
documentId: zod_1.z.string().uuid(),
|
|
12
|
+
selectionText: zod_1.z.string(),
|
|
13
|
+
userBalance: zod_1.z.number(),
|
|
14
|
+
});
|
|
15
|
+
WriterParaphraseCommand.ResponseSchema = (0, common_1.ICommandResponseSchema)(zod_1.z.object({
|
|
16
|
+
output: zod_1.z.string(),
|
|
17
|
+
}));
|
|
18
|
+
})(WriterParaphraseCommand || (exports.WriterParaphraseCommand = WriterParaphraseCommand = {}));
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WriterShortenTextCommand = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const common_1 = require("../../common");
|
|
6
|
+
var WriterShortenTextCommand;
|
|
7
|
+
(function (WriterShortenTextCommand) {
|
|
8
|
+
WriterShortenTextCommand.RequestSchema = zod_1.z.object({
|
|
9
|
+
userId: zod_1.z.string().uuid().nullable().optional(),
|
|
10
|
+
unregisteredUserId: zod_1.z.string().uuid().nullable().optional(),
|
|
11
|
+
documentId: zod_1.z.string().uuid(),
|
|
12
|
+
selectionText: zod_1.z.string(),
|
|
13
|
+
userBalance: zod_1.z.number(),
|
|
14
|
+
});
|
|
15
|
+
WriterShortenTextCommand.ResponseSchema = (0, common_1.ICommandResponseSchema)(zod_1.z.object({
|
|
16
|
+
output: zod_1.z.string(),
|
|
17
|
+
}));
|
|
18
|
+
})(WriterShortenTextCommand || (exports.WriterShortenTextCommand = WriterShortenTextCommand = {}));
|
|
@@ -14,7 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./writer-ai-
|
|
18
|
-
__exportStar(require("./writer-ai-
|
|
17
|
+
__exportStar(require("./writer-ai-action-call.enum"), exports);
|
|
18
|
+
__exportStar(require("./writer-ai-action-pricing-type.enum"), exports);
|
|
19
|
+
__exportStar(require("./writer-ai-action-type.enum"), exports);
|
|
19
20
|
__exportStar(require("./writer-document-section-type.enum"), exports);
|
|
20
21
|
__exportStar(require("./writer-document-stage.enum"), exports);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WRITER_AI_ACTION_CALL_STATUS = void 0;
|
|
4
|
+
var WRITER_AI_ACTION_CALL_STATUS;
|
|
5
|
+
(function (WRITER_AI_ACTION_CALL_STATUS) {
|
|
6
|
+
WRITER_AI_ACTION_CALL_STATUS["PROCESSING"] = "processing";
|
|
7
|
+
WRITER_AI_ACTION_CALL_STATUS["COMPLETED"] = "completed";
|
|
8
|
+
WRITER_AI_ACTION_CALL_STATUS["FAILED"] = "failed";
|
|
9
|
+
})(WRITER_AI_ACTION_CALL_STATUS || (exports.WRITER_AI_ACTION_CALL_STATUS = WRITER_AI_ACTION_CALL_STATUS = {}));
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WRITER_AI_ACTION_PRICING_TYPE = void 0;
|
|
4
|
+
var WRITER_AI_ACTION_PRICING_TYPE;
|
|
5
|
+
(function (WRITER_AI_ACTION_PRICING_TYPE) {
|
|
6
|
+
WRITER_AI_ACTION_PRICING_TYPE["PER_CHARACTER"] = "PER_CHARACTER";
|
|
7
|
+
WRITER_AI_ACTION_PRICING_TYPE["FLAT"] = "FLAT";
|
|
8
|
+
})(WRITER_AI_ACTION_PRICING_TYPE || (exports.WRITER_AI_ACTION_PRICING_TYPE = WRITER_AI_ACTION_PRICING_TYPE = {}));
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WRITER_AI_ACTION_TYPE = void 0;
|
|
4
|
+
var WRITER_AI_ACTION_TYPE;
|
|
5
|
+
(function (WRITER_AI_ACTION_TYPE) {
|
|
6
|
+
WRITER_AI_ACTION_TYPE["PARAPHRASE"] = "PARAPHRASE";
|
|
7
|
+
WRITER_AI_ACTION_TYPE["EXTEND_TEXT"] = "EXTEND_TEXT";
|
|
8
|
+
WRITER_AI_ACTION_TYPE["SHORTEN_TEXT"] = "SHORTEN_TEXT";
|
|
9
|
+
WRITER_AI_ACTION_TYPE["GENERATE_TEXT"] = "GENERATE_TEXT";
|
|
10
|
+
WRITER_AI_ACTION_TYPE["FIX_ERRORS"] = "FIX_ERRORS";
|
|
11
|
+
})(WRITER_AI_ACTION_TYPE || (exports.WRITER_AI_ACTION_TYPE = WRITER_AI_ACTION_TYPE = {}));
|
package/build/writer/index.js
CHANGED
|
@@ -15,7 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./writer-config.schema"), exports);
|
|
18
|
-
__exportStar(require("./writer-ai-
|
|
18
|
+
__exportStar(require("./writer-ai-action.schema"), exports);
|
|
19
19
|
__exportStar(require("./writer-document-outline.schema"), exports);
|
|
20
20
|
__exportStar(require("./writer-document.schema"), exports);
|
|
21
21
|
__exportStar(require("./writer-document-type.schema"), exports);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WriterAiActionSchema = exports.WriterAiActionPricingRulesSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const enums_1 = require("../enums");
|
|
6
|
+
exports.WriterAiActionPricingRulesSchema = zod_1.z.discriminatedUnion('type', [
|
|
7
|
+
zod_1.z.object({
|
|
8
|
+
type: zod_1.z.literal(enums_1.WRITER_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.WRITER_AI_ACTION_PRICING_TYPE.FLAT),
|
|
13
|
+
price: zod_1.z.number(),
|
|
14
|
+
}),
|
|
15
|
+
]);
|
|
16
|
+
exports.WriterAiActionSchema = zod_1.z.object({
|
|
17
|
+
uuid: zod_1.z.string(),
|
|
18
|
+
type: zod_1.z.nativeEnum(enums_1.WRITER_AI_ACTION_TYPE),
|
|
19
|
+
pricingRules: exports.WriterAiActionPricingRulesSchema,
|
|
20
|
+
maxPromptLength: zod_1.z.number(),
|
|
21
|
+
title: zod_1.z.string(),
|
|
22
|
+
icon: zod_1.z.string(),
|
|
23
|
+
order: zod_1.z.number(),
|
|
24
|
+
createdAt: zod_1.z.date(),
|
|
25
|
+
updatedAt: zod_1.z.date(),
|
|
26
|
+
});
|
|
@@ -3,11 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.WriterConfigSchema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const writer_document_type_schema_1 = require("./writer-document-type.schema");
|
|
6
|
-
const
|
|
6
|
+
const writer_ai_action_schema_1 = require("./writer-ai-action.schema");
|
|
7
7
|
exports.WriterConfigSchema = zod_1.z.object({
|
|
8
8
|
minPages: zod_1.z.number(),
|
|
9
9
|
maxPages: zod_1.z.number(),
|
|
10
|
-
|
|
10
|
+
maxPromptLength: zod_1.z.number(),
|
|
11
11
|
documentTypes: zod_1.z.array(writer_document_type_schema_1.WriterDocumentTypeSchema),
|
|
12
|
-
|
|
12
|
+
aiActions: zod_1.z.array(writer_ai_action_schema_1.WriterAiActionSchema),
|
|
13
13
|
});
|
|
@@ -9,5 +9,11 @@ exports.WRITER_AMQP_ROUTES = {
|
|
|
9
9
|
DELETE_DOCUMENT: 'tools.writer.delete-document.rpc',
|
|
10
10
|
DELETE_ALL_USER_DOCUMENTS: 'tools.writer.delete-all-user-documents.rpc',
|
|
11
11
|
UPDATE_DOCUMENT_OUTLINE: 'tools.writer.update-document-outline.rpc',
|
|
12
|
+
UPDATE_DOCUMENT_CONTENTS: 'tools.writer.update-document-contents.rpc',
|
|
12
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',
|
|
13
19
|
};
|
|
@@ -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/errors/errors.ts
CHANGED
|
@@ -574,6 +574,11 @@ export const ERRORS = {
|
|
|
574
574
|
message: 'Данная операция доступна только сразу же после этапа генерации макета',
|
|
575
575
|
httpCode: 400,
|
|
576
576
|
},
|
|
577
|
+
STAGE_CONTENT_GENERATED_REQUIRED: {
|
|
578
|
+
code: 'WRITER_DOCUMENT.STAGE_CONTENT_GENERATED_REQUIRED',
|
|
579
|
+
message: 'Данная операция доступна только после генерации содержимого документа',
|
|
580
|
+
httpCode: 400,
|
|
581
|
+
},
|
|
577
582
|
NOT_AN_OWNER: {
|
|
578
583
|
code: 'WRITER_DOCUMENT.NOT_AN_OWNER',
|
|
579
584
|
message: 'Пользователь не является владельцем документа',
|
|
@@ -600,36 +605,46 @@ export const ERRORS = {
|
|
|
600
605
|
httpCode: 404,
|
|
601
606
|
},
|
|
602
607
|
},
|
|
603
|
-
|
|
608
|
+
WRITER_AI_ACTION: {
|
|
604
609
|
SAVE_ERROR: {
|
|
605
|
-
code: '
|
|
610
|
+
code: 'WRITER_AI_ACTION.SAVE_ERROR',
|
|
606
611
|
message: 'Произошла ошибка при сохранении операции',
|
|
607
612
|
httpCode: 500,
|
|
608
613
|
},
|
|
609
614
|
FIND_ERROR: {
|
|
610
|
-
code: '
|
|
615
|
+
code: 'WRITER_AI_ACTION.FIND_ERROR',
|
|
611
616
|
message: 'Произошла ошибка при поиске операции',
|
|
612
617
|
httpCode: 500,
|
|
613
618
|
},
|
|
614
619
|
NOT_FOUND: {
|
|
615
|
-
code: '
|
|
620
|
+
code: 'WRITER_AI_ACTION.NOT_FOUND',
|
|
616
621
|
message: 'Операция не найдена',
|
|
617
622
|
httpCode: 404,
|
|
618
623
|
},
|
|
624
|
+
INSUFFICIENT_BALANCE: {
|
|
625
|
+
code: 'WRITER_AI_ACTION.INSUFFICIENT_BALANCE',
|
|
626
|
+
message: 'У пользователя недостаточно средств для выполнения операции',
|
|
627
|
+
httpCode: 400,
|
|
628
|
+
},
|
|
629
|
+
PROMPT_TOO_LONG: {
|
|
630
|
+
code: 'WRITER_AI_ACTION.PROMPT_TOO_LONG',
|
|
631
|
+
message: 'Выделенный текст превышает максимально допустимую длину для данной операции',
|
|
632
|
+
httpCode: 400,
|
|
633
|
+
},
|
|
619
634
|
},
|
|
620
|
-
|
|
635
|
+
WRITER_AI_ACTION_CALL: {
|
|
621
636
|
SAVE_ERROR: {
|
|
622
|
-
code: '
|
|
637
|
+
code: 'WRITER_AI_ACTION_CALL.SAVE_ERROR',
|
|
623
638
|
message: 'Произошла ошибка при сохранении вызова операции',
|
|
624
639
|
httpCode: 500,
|
|
625
640
|
},
|
|
626
641
|
FIND_ERROR: {
|
|
627
|
-
code: '
|
|
642
|
+
code: 'WRITER_AI_ACTION_CALL.FIND_ERROR',
|
|
628
643
|
message: 'Произошла ошибка при поиске вызова операции',
|
|
629
644
|
httpCode: 500,
|
|
630
645
|
},
|
|
631
646
|
NOT_FOUND: {
|
|
632
|
-
code: '
|
|
647
|
+
code: 'WRITER_AI_ACTION_CALL.NOT_FOUND',
|
|
633
648
|
message: 'Вызов операции не найден',
|
|
634
649
|
httpCode: 404,
|
|
635
650
|
},
|
|
@@ -653,4 +668,86 @@ export const ERRORS = {
|
|
|
653
668
|
httpCode: 500,
|
|
654
669
|
},
|
|
655
670
|
},
|
|
671
|
+
IMAGE_EDITOR: {
|
|
672
|
+
AI_ERROR: {
|
|
673
|
+
code: 'IMAGE_EDITOR.AI_ERROR',
|
|
674
|
+
message: 'Произошла ошибка во время запроса к ИИ',
|
|
675
|
+
httpCode: 500,
|
|
676
|
+
},
|
|
677
|
+
INSUFFICIENT_BALANCE: {
|
|
678
|
+
code: 'IMAGE_EDITOR.INSUFFICIENT_BALANCE',
|
|
679
|
+
message: 'У пользователя недостаточно средств',
|
|
680
|
+
httpCode: 400,
|
|
681
|
+
},
|
|
682
|
+
INVALID_PARAMS: {
|
|
683
|
+
code: 'IMAGE_EDITOR.INVALID_PARAMS',
|
|
684
|
+
message: 'Некорректные параметры картинки',
|
|
685
|
+
httpCode: 400,
|
|
686
|
+
},
|
|
687
|
+
DELETE_ERROR: {
|
|
688
|
+
code: 'IMAGE_EDITOR.DELETE_ERROR',
|
|
689
|
+
message: 'Произошла ошибка при удалении редактирования картинки',
|
|
690
|
+
httpCode: 500,
|
|
691
|
+
},
|
|
692
|
+
MAX_PROMPT_LENGTH_EXCEEDED: {
|
|
693
|
+
code: 'IMAGE_EDITOR.MAX_PROMPT_LENGTH_EXCEEDED',
|
|
694
|
+
message: 'Превышена максимальная длина запроса',
|
|
695
|
+
httpCode: 400,
|
|
696
|
+
},
|
|
697
|
+
SYSTEM_PROMPT_NOT_FOUND: {
|
|
698
|
+
code: 'IMAGE_EDITOR.SYSTEM_PROMPT_NOT_FOUND',
|
|
699
|
+
message: 'Произошла ошибка при поиске системного запроса',
|
|
700
|
+
httpCode: 404,
|
|
701
|
+
},
|
|
702
|
+
},
|
|
703
|
+
IMAGE_EDITOR_MODEL: {
|
|
704
|
+
SAVE_ERROR: {
|
|
705
|
+
code: 'IMAGE_EDITOR_MODEL.SAVE_ERROR',
|
|
706
|
+
message: 'Произошла ошибка при сохранении модели для редактирования картинки',
|
|
707
|
+
httpCode: 500,
|
|
708
|
+
},
|
|
709
|
+
FIND_ERROR: {
|
|
710
|
+
code: 'IMAGE_EDITOR_MODEL.FIND_ERROR',
|
|
711
|
+
message: 'Произошла ошибка при поиске модели для редактирования картинки',
|
|
712
|
+
httpCode: 500,
|
|
713
|
+
},
|
|
714
|
+
NOT_FOUND: {
|
|
715
|
+
code: 'IMAGE_EDITOR_MODEL.NOT_FOUND',
|
|
716
|
+
message: 'Модель для редактирования картинки не найдена',
|
|
717
|
+
httpCode: 404,
|
|
718
|
+
},
|
|
719
|
+
},
|
|
720
|
+
IMAGE_EDITOR_JOB: {
|
|
721
|
+
SAVE_ERROR: {
|
|
722
|
+
code: 'IMAGE_EDITOR_JOB.SAVE_ERROR',
|
|
723
|
+
message: 'Произошла ошибка при сохранении задания на редактирование картинки',
|
|
724
|
+
httpCode: 500,
|
|
725
|
+
},
|
|
726
|
+
FIND_ERROR: {
|
|
727
|
+
code: 'IMAGE_EDITOR_JOB.FIND_ERROR',
|
|
728
|
+
message: 'Произошла ошибка при поиске задания на редактирование картинки',
|
|
729
|
+
httpCode: 500,
|
|
730
|
+
},
|
|
731
|
+
NOT_FOUND: {
|
|
732
|
+
code: 'IMAGE_EDITOR_JOB.NOT_FOUND',
|
|
733
|
+
message: 'Задание на редактирование картинки не найдено',
|
|
734
|
+
httpCode: 404,
|
|
735
|
+
},
|
|
736
|
+
NOT_AN_OWNER: {
|
|
737
|
+
code: 'IMAGE_EDITOR_JOB.NOT_AN_OWNER',
|
|
738
|
+
message: 'Пользователь не является владельцем задания на редактирование картинки',
|
|
739
|
+
httpCode: 403,
|
|
740
|
+
},
|
|
741
|
+
NOT_IN_FAILED_STATE_TO_RETRY: {
|
|
742
|
+
code: 'IMAGE_EDITOR_JOB.NOT_IN_FAILED_STATE_TO_RETRY',
|
|
743
|
+
message:
|
|
744
|
+
'Задание на редактирование картинки не в состоянии "failed". Невозможно повторить',
|
|
745
|
+
httpCode: 400,
|
|
746
|
+
},
|
|
747
|
+
DELETE_ERROR: {
|
|
748
|
+
code: 'IMAGE_EDITOR_JOB.DELETE_ERROR',
|
|
749
|
+
message: 'Произошла ошибка при удалении задания на редактирование картинки',
|
|
750
|
+
httpCode: 500,
|
|
751
|
+
},
|
|
752
|
+
},
|
|
656
753
|
} as const;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ICommandResponseSchema } from '../../common/models/command-response.schema';
|
|
3
|
+
|
|
4
|
+
export namespace DeleteAllImageEditorJobsCommand {
|
|
5
|
+
export const RequestSchema = z.object({
|
|
6
|
+
userId: z.string().uuid().nullable().optional(),
|
|
7
|
+
unregisteredUserId: z.string().uuid().nullable().optional(),
|
|
8
|
+
});
|
|
9
|
+
export type Request = z.infer<typeof RequestSchema>;
|
|
10
|
+
|
|
11
|
+
export const ResponseSchema = ICommandResponseSchema(z.boolean());
|
|
12
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ICommandResponseSchema } from '../../common/models/command-response.schema';
|
|
3
|
+
|
|
4
|
+
export namespace DeleteImageEditorJobByUuidCommand {
|
|
5
|
+
export const RequestSchema = z.object({
|
|
6
|
+
userId: z.string().uuid().nullable().optional(),
|
|
7
|
+
unregisteredUserId: z.string().uuid().nullable().optional(),
|
|
8
|
+
uuid: z.string(),
|
|
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,21 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ICommandResponseSchema } from '../../common/models/command-response.schema';
|
|
3
|
+
import { ImageEditorJobSchema } from '../models';
|
|
4
|
+
|
|
5
|
+
export namespace ImageEditorCommand {
|
|
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
|
+
userBalance: z.number(),
|
|
11
|
+
modelId: z.string(),
|
|
12
|
+
params: z.object({
|
|
13
|
+
imageUrls: z.array(z.string()),
|
|
14
|
+
systemPromptId: z.string().optional(),
|
|
15
|
+
}),
|
|
16
|
+
});
|
|
17
|
+
export type Request = z.infer<typeof RequestSchema>;
|
|
18
|
+
|
|
19
|
+
export const ResponseSchema = ICommandResponseSchema(ImageEditorJobSchema);
|
|
20
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
21
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export * from './delete-image-editor-job-by-uuid.command';
|
|
2
|
+
export * from './delete-all-image-editor-jobs.command';
|
|
3
|
+
export * from './retry-image-editor-job.command';
|
|
4
|
+
export * from './set-reaction-to-image-editor-job.command';
|
|
5
|
+
export * from './image-editor.command';
|
|
6
|
+
export * from './update-image-editor-job-title.command';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ICommandResponseSchema } from '../../common/models/command-response.schema';
|
|
3
|
+
import { ImageEditorJobSchema } from '../models';
|
|
4
|
+
|
|
5
|
+
export namespace RetryImageEditorJobCommand {
|
|
6
|
+
export const RequestSchema = z.object({
|
|
7
|
+
uuid: z.string().uuid(),
|
|
8
|
+
userBalance: z.number(),
|
|
9
|
+
userId: z.string().uuid().nullable().optional(),
|
|
10
|
+
unregisteredUserId: z.string().uuid().nullable().optional(),
|
|
11
|
+
});
|
|
12
|
+
export type Request = z.infer<typeof RequestSchema>;
|
|
13
|
+
|
|
14
|
+
export const ResponseSchema = ICommandResponseSchema(ImageEditorJobSchema);
|
|
15
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ICommandResponseSchema } from '../../common/models/command-response.schema';
|
|
3
|
+
import { ImageEditorJobSchema } from '../models';
|
|
4
|
+
import { USER_REACTION } from '../../common';
|
|
5
|
+
|
|
6
|
+
export namespace SetReactionToImageEditorJobCommand {
|
|
7
|
+
export const RequestSchema = z.object({
|
|
8
|
+
userId: z.string().uuid().nullable().optional(),
|
|
9
|
+
unregisteredUserId: z.string().uuid().nullable().optional(),
|
|
10
|
+
uuid: z.string(),
|
|
11
|
+
reaction: z.nativeEnum(USER_REACTION).nullable(),
|
|
12
|
+
});
|
|
13
|
+
export type Request = z.infer<typeof RequestSchema>;
|
|
14
|
+
|
|
15
|
+
export const ResponseSchema = ICommandResponseSchema(ImageEditorJobSchema);
|
|
16
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ICommandResponseSchema } from '../../common/models/command-response.schema';
|
|
3
|
+
import { ImageEditorJobSchema } from '../models';
|
|
4
|
+
|
|
5
|
+
export namespace UpdateImageEditorJobTitleCommand {
|
|
6
|
+
export const RequestSchema = z.object({
|
|
7
|
+
uuid: z.string().uuid(),
|
|
8
|
+
userId: z.string().uuid().nullable().optional(),
|
|
9
|
+
unregisteredUserId: z.string().uuid().nullable().optional(),
|
|
10
|
+
title: z.string().min(1).max(40),
|
|
11
|
+
});
|
|
12
|
+
export type Request = z.infer<typeof RequestSchema>;
|
|
13
|
+
|
|
14
|
+
export const ResponseSchema = ICommandResponseSchema(ImageEditorJobSchema);
|
|
15
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ImageEditorModelSchema } from './image-editor-model.schema';
|
|
3
|
+
import { IconVariantsSchema } from '../../common';
|
|
4
|
+
|
|
5
|
+
export const SystemPromptSchema = z.object({
|
|
6
|
+
uuid: z.string(),
|
|
7
|
+
title: z.string(),
|
|
8
|
+
description: z.string(),
|
|
9
|
+
prompt: z.string(),
|
|
10
|
+
allowUserPrompt: z.boolean(),
|
|
11
|
+
groupId: z.string().uuid(),
|
|
12
|
+
preview: z
|
|
13
|
+
.object({
|
|
14
|
+
before: z.string(),
|
|
15
|
+
after: z.string(),
|
|
16
|
+
})
|
|
17
|
+
.nullable(),
|
|
18
|
+
order: z.number(),
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
export const ImageEditorActionGroup = z.object({
|
|
22
|
+
uuid: z.string(),
|
|
23
|
+
title: z.string(),
|
|
24
|
+
icons: IconVariantsSchema,
|
|
25
|
+
prompts: z.array(SystemPromptSchema),
|
|
26
|
+
order: z.number(),
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
export const ImageEditorConfigSchema = z.object({
|
|
30
|
+
models: z.array(ImageEditorModelSchema),
|
|
31
|
+
promptGroups: z.array(ImageEditorActionGroup),
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
export type ImageEditorConfig = z.infer<typeof ImageEditorConfigSchema>;
|