@purpleschool/gptbot-tools 0.0.55 → 0.0.56
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 +81 -0
- package/build/index.js +3 -0
- package/build/tools/enums/tool-type.enum.js +1 -0
- package/build/video/enums/video-strategy.enum.js +1 -0
- package/build/video-editor/commands/delete-all-video-editor-jobs.command.js +13 -0
- package/build/video-editor/commands/delete-video-editor-job-by-uuid.command.js +14 -0
- package/build/video-editor/commands/edit-video.command.js +19 -0
- package/build/video-editor/commands/index.js +22 -0
- package/build/video-editor/commands/retry-video-editor-job.command.js +16 -0
- package/build/video-editor/commands/set-reaction-to-video-editor-job.command.js +17 -0
- package/build/video-editor/commands/update-video-editor-job-title.command.js +16 -0
- package/build/video-editor/enums/index.js +17 -0
- package/build/video-editor/enums/video-editor-model-strategy.enum.js +8 -0
- package/build/video-editor/index.js +22 -0
- package/build/video-editor/models/index.js +19 -0
- package/build/video-editor/models/video-editor-config.schema.js +11 -0
- package/build/video-editor/models/video-editor-job.schema.js +27 -0
- package/build/video-editor/models/video-editor-model.schema.js +24 -0
- package/build/video-editor/queries/find-video-editor-job-by-id.query.js +19 -0
- package/build/video-editor/queries/find-video-editor-jobs.query.js +28 -0
- package/build/video-editor/queries/get-video-editor-config.query.js +11 -0
- package/build/video-editor/queries/index.js +19 -0
- package/build/video-editor/routes/index.js +18 -0
- package/build/video-editor/routes/video-editor.amqp.routes.js +14 -0
- package/build/video-editor/routes/video-editor.http.routes.js +4 -0
- package/build/video-editor/utils/calculate-video-editing-price.js +10 -0
- package/build/video-editor/utils/index.js +17 -0
- package/common/errors/errors.ts +82 -0
- package/index.ts +3 -0
- package/package.json +1 -1
- package/tools/enums/tool-type.enum.ts +1 -0
- package/video/enums/video-strategy.enum.ts +1 -0
- package/video-editor/commands/delete-all-video-editor-jobs.command.ts +13 -0
- package/video-editor/commands/delete-video-editor-job-by-uuid.command.ts +14 -0
- package/video-editor/commands/edit-video.command.ts +19 -0
- package/video-editor/commands/index.ts +6 -0
- package/video-editor/commands/retry-video-editor-job.command.ts +16 -0
- package/video-editor/commands/set-reaction-to-video-editor-job.command.ts +17 -0
- package/video-editor/commands/update-video-editor-job-title.command.ts +16 -0
- package/video-editor/enums/index.ts +1 -0
- package/video-editor/enums/video-editor-model-strategy.enum.ts +4 -0
- package/video-editor/index.ts +6 -0
- package/video-editor/models/index.ts +3 -0
- package/video-editor/models/video-editor-config.schema.ts +7 -0
- package/video-editor/models/video-editor-job.schema.ts +27 -0
- package/video-editor/models/video-editor-model.schema.ts +23 -0
- package/video-editor/queries/find-video-editor-job-by-id.query.ts +19 -0
- package/video-editor/queries/find-video-editor-jobs.query.ts +33 -0
- package/video-editor/queries/get-video-editor-config.query.ts +11 -0
- package/video-editor/queries/index.ts +3 -0
- package/video-editor/routes/index.ts +2 -0
- package/video-editor/routes/video-editor.amqp.routes.ts +11 -0
- package/video-editor/routes/video-editor.http.routes.ts +1 -0
- package/video-editor/utils/calculate-video-editing-price.ts +12 -0
- package/video-editor/utils/index.ts +1 -0
|
@@ -676,6 +676,11 @@ exports.ERRORS = {
|
|
|
676
676
|
message: 'Запрос был отклонен, т.к. может не соответствовать правилам сервиса',
|
|
677
677
|
httpCode: 400,
|
|
678
678
|
},
|
|
679
|
+
PROCESSING_ERROR: {
|
|
680
|
+
code: 'PROMPT_MODERATION.PROCESSING_ERROR',
|
|
681
|
+
message: 'Произошла ошибка при обработке запроса',
|
|
682
|
+
httpCode: 500,
|
|
683
|
+
},
|
|
679
684
|
GOOGLE_CONTENT_POLICY: {
|
|
680
685
|
code: 'PROMPT_MODERATION.GOOGLE_CONTENT_POLICY',
|
|
681
686
|
message: 'Запрос был отклонен, т.к. он не соответствует требованиям политики безопасности Google.',
|
|
@@ -770,4 +775,80 @@ exports.ERRORS = {
|
|
|
770
775
|
httpCode: 500,
|
|
771
776
|
},
|
|
772
777
|
},
|
|
778
|
+
VIDEO_EDITOR: {
|
|
779
|
+
AI_ERROR: {
|
|
780
|
+
code: 'VIDEO_EDITOR.AI_ERROR',
|
|
781
|
+
message: 'Произошла ошибка во время запроса к ИИ',
|
|
782
|
+
httpCode: 500,
|
|
783
|
+
},
|
|
784
|
+
INSUFFICIENT_BALANCE: {
|
|
785
|
+
code: 'VIDEO_EDITOR.INSUFFICIENT_BALANCE',
|
|
786
|
+
message: 'У пользователя недостаточно средств',
|
|
787
|
+
httpCode: 400,
|
|
788
|
+
},
|
|
789
|
+
DELETE_ERROR: {
|
|
790
|
+
code: 'VIDEO_EDITOR.DELETE_ERROR',
|
|
791
|
+
message: 'Произошла ошибка при удалении',
|
|
792
|
+
httpCode: 500,
|
|
793
|
+
},
|
|
794
|
+
MAX_PROMPT_LENGTH_EXCEEDED: {
|
|
795
|
+
code: 'VIDEO_EDITOR.MAX_PROMPT_LENGTH_EXCEEDED',
|
|
796
|
+
message: 'Превышена максимальная длина запроса',
|
|
797
|
+
httpCode: 400,
|
|
798
|
+
},
|
|
799
|
+
MAX_DURATION_EXCEEDED: {
|
|
800
|
+
code: 'VIDEO_EDITOR.MAX_DURATION_EXCEEDED',
|
|
801
|
+
message: 'Превышена максимальная длительность видео',
|
|
802
|
+
httpCode: 400,
|
|
803
|
+
},
|
|
804
|
+
},
|
|
805
|
+
VIDEO_EDITOR_MODEL: {
|
|
806
|
+
SAVE_ERROR: {
|
|
807
|
+
code: 'VIDEO_EDITOR_MODEL.SAVE_ERROR',
|
|
808
|
+
message: 'Произошла ошибка при сохранении модели для редактирования видео',
|
|
809
|
+
httpCode: 500,
|
|
810
|
+
},
|
|
811
|
+
FIND_ERROR: {
|
|
812
|
+
code: 'VIDEO_EDITOR_MODEL.FIND_ERROR',
|
|
813
|
+
message: 'Произошла ошибка при поиске модели для редактирования видео',
|
|
814
|
+
httpCode: 500,
|
|
815
|
+
},
|
|
816
|
+
NOT_FOUND: {
|
|
817
|
+
code: 'VIDEO_EDITOR_MODEL.NOT_FOUND',
|
|
818
|
+
message: 'Модель для редактирования видео не найдена',
|
|
819
|
+
httpCode: 404,
|
|
820
|
+
},
|
|
821
|
+
},
|
|
822
|
+
VIDEO_EDITOR_JOB: {
|
|
823
|
+
SAVE_ERROR: {
|
|
824
|
+
code: 'VIDEO_EDITOR_JOB.SAVE_ERROR',
|
|
825
|
+
message: 'Произошла ошибка при сохранении задания на редактирование видео',
|
|
826
|
+
httpCode: 500,
|
|
827
|
+
},
|
|
828
|
+
FIND_ERROR: {
|
|
829
|
+
code: 'VIDEO_EDITOR_JOB.FIND_ERROR',
|
|
830
|
+
message: 'Произошла ошибка при поиске задания на редактирование видео',
|
|
831
|
+
httpCode: 500,
|
|
832
|
+
},
|
|
833
|
+
NOT_FOUND: {
|
|
834
|
+
code: 'VIDEO_EDITOR_JOB.NOT_FOUND',
|
|
835
|
+
message: 'Задание на редактирование видео не найдено',
|
|
836
|
+
httpCode: 404,
|
|
837
|
+
},
|
|
838
|
+
NOT_AN_OWNER: {
|
|
839
|
+
code: 'VIDEO_EDITOR_JOB.NOT_AN_OWNER',
|
|
840
|
+
message: 'Пользователь не является владельцем задания на редактирование видео',
|
|
841
|
+
httpCode: 403,
|
|
842
|
+
},
|
|
843
|
+
NOT_IN_FAILED_STATE_TO_RETRY: {
|
|
844
|
+
code: 'VIDEO_EDITOR_JOB.NOT_IN_FAILED_STATE_TO_RETRY',
|
|
845
|
+
message: 'Задание на редактирование видео не в состоянии "failed". Невозможно повторить',
|
|
846
|
+
httpCode: 400,
|
|
847
|
+
},
|
|
848
|
+
DELETE_ERROR: {
|
|
849
|
+
code: 'VIDEO_EDITOR_JOB.DELETE_ERROR',
|
|
850
|
+
message: 'Произошла ошибка при удалении задания на редактирование видео',
|
|
851
|
+
httpCode: 500,
|
|
852
|
+
},
|
|
853
|
+
},
|
|
773
854
|
};
|
package/build/index.js
CHANGED
|
@@ -46,6 +46,7 @@ __exportStar(require("./language"), exports);
|
|
|
46
46
|
__exportStar(require("./video"), exports);
|
|
47
47
|
__exportStar(require("./writer"), exports);
|
|
48
48
|
__exportStar(require("./image-editor"), exports);
|
|
49
|
+
__exportStar(require("./video-editor"), exports);
|
|
49
50
|
const common = __importStar(require("./common"));
|
|
50
51
|
const paraphrase = __importStar(require("./paraphrase"));
|
|
51
52
|
const tools = __importStar(require("./tools"));
|
|
@@ -56,6 +57,7 @@ const language = __importStar(require("./language"));
|
|
|
56
57
|
const video = __importStar(require("./video"));
|
|
57
58
|
const writer = __importStar(require("./writer"));
|
|
58
59
|
const imageEditor = __importStar(require("./image-editor"));
|
|
60
|
+
const videoEditor = __importStar(require("./video-editor"));
|
|
59
61
|
var ToolService;
|
|
60
62
|
(function (ToolService) {
|
|
61
63
|
ToolService.Common = common;
|
|
@@ -68,4 +70,5 @@ var ToolService;
|
|
|
68
70
|
ToolService.Video = video;
|
|
69
71
|
ToolService.Writer = writer;
|
|
70
72
|
ToolService.ImageEditor = imageEditor;
|
|
73
|
+
ToolService.VideoEditor = videoEditor;
|
|
71
74
|
})(ToolService || (exports.ToolService = ToolService = {}));
|
|
@@ -7,4 +7,5 @@ var VIDEO_GENERATION_STRATEGY;
|
|
|
7
7
|
VIDEO_GENERATION_STRATEGY["VEO_CALLBACK"] = "VEO_CALLBACK";
|
|
8
8
|
VIDEO_GENERATION_STRATEGY["RUNWAY_POLLING"] = "RUNWAY_POLLING";
|
|
9
9
|
VIDEO_GENERATION_STRATEGY["RUNWAY_CALLBACK"] = "RUNWAY_CALLBACK";
|
|
10
|
+
VIDEO_GENERATION_STRATEGY["SORA_2_VIDEO_GENERATION_POLLING"] = "SORA_2_VIDEO_GENERATION_POLLING";
|
|
10
11
|
})(VIDEO_GENERATION_STRATEGY || (exports.VIDEO_GENERATION_STRATEGY = VIDEO_GENERATION_STRATEGY = {}));
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DeleteAllVideoEditorJobsCommand = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const command_response_schema_1 = require("../../common/models/command-response.schema");
|
|
6
|
+
var DeleteAllVideoEditorJobsCommand;
|
|
7
|
+
(function (DeleteAllVideoEditorJobsCommand) {
|
|
8
|
+
DeleteAllVideoEditorJobsCommand.RequestSchema = zod_1.z.object({
|
|
9
|
+
userId: zod_1.z.string().uuid().nullable().optional(),
|
|
10
|
+
unregisteredUserId: zod_1.z.string().uuid().nullable().optional(),
|
|
11
|
+
});
|
|
12
|
+
DeleteAllVideoEditorJobsCommand.ResponseSchema = (0, command_response_schema_1.ICommandResponseSchema)(zod_1.z.boolean());
|
|
13
|
+
})(DeleteAllVideoEditorJobsCommand || (exports.DeleteAllVideoEditorJobsCommand = DeleteAllVideoEditorJobsCommand = {}));
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DeleteVideoEditorJobByUuidCommand = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const command_response_schema_1 = require("../../common/models/command-response.schema");
|
|
6
|
+
var DeleteVideoEditorJobByUuidCommand;
|
|
7
|
+
(function (DeleteVideoEditorJobByUuidCommand) {
|
|
8
|
+
DeleteVideoEditorJobByUuidCommand.RequestSchema = zod_1.z.object({
|
|
9
|
+
userId: zod_1.z.string().uuid().nullable().optional(),
|
|
10
|
+
unregisteredUserId: zod_1.z.string().uuid().nullable().optional(),
|
|
11
|
+
uuid: zod_1.z.string(),
|
|
12
|
+
});
|
|
13
|
+
DeleteVideoEditorJobByUuidCommand.ResponseSchema = (0, command_response_schema_1.ICommandResponseSchema)(zod_1.z.boolean());
|
|
14
|
+
})(DeleteVideoEditorJobByUuidCommand || (exports.DeleteVideoEditorJobByUuidCommand = DeleteVideoEditorJobByUuidCommand = {}));
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EditVideoCommand = 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 EditVideoCommand;
|
|
8
|
+
(function (EditVideoCommand) {
|
|
9
|
+
EditVideoCommand.RequestSchema = zod_1.z.object({
|
|
10
|
+
userId: zod_1.z.string().uuid().nullable().optional(),
|
|
11
|
+
unregisteredUserId: zod_1.z.string().uuid().nullable().optional(),
|
|
12
|
+
prompt: zod_1.z.string(),
|
|
13
|
+
inputVideoUrl: zod_1.z.string(),
|
|
14
|
+
duration: zod_1.z.number(),
|
|
15
|
+
userBalance: zod_1.z.number(),
|
|
16
|
+
modelId: zod_1.z.string(),
|
|
17
|
+
});
|
|
18
|
+
EditVideoCommand.ResponseSchema = (0, command_response_schema_1.ICommandResponseSchema)(models_1.VideoEditorJobSchema);
|
|
19
|
+
})(EditVideoCommand || (exports.EditVideoCommand = EditVideoCommand = {}));
|
|
@@ -0,0 +1,22 @@
|
|
|
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("./delete-all-video-editor-jobs.command"), exports);
|
|
18
|
+
__exportStar(require("./delete-video-editor-job-by-uuid.command"), exports);
|
|
19
|
+
__exportStar(require("./retry-video-editor-job.command"), exports);
|
|
20
|
+
__exportStar(require("./set-reaction-to-video-editor-job.command"), exports);
|
|
21
|
+
__exportStar(require("./update-video-editor-job-title.command"), exports);
|
|
22
|
+
__exportStar(require("./edit-video.command"), exports);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RetryVideoEditorJobCommand = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const command_response_schema_1 = require("../../common/models/command-response.schema");
|
|
6
|
+
const video_editor_job_schema_1 = require("../models/video-editor-job.schema");
|
|
7
|
+
var RetryVideoEditorJobCommand;
|
|
8
|
+
(function (RetryVideoEditorJobCommand) {
|
|
9
|
+
RetryVideoEditorJobCommand.RequestSchema = zod_1.z.object({
|
|
10
|
+
uuid: zod_1.z.string().uuid(),
|
|
11
|
+
userBalance: zod_1.z.number(),
|
|
12
|
+
userId: zod_1.z.string().uuid().nullable().optional(),
|
|
13
|
+
unregisteredUserId: zod_1.z.string().uuid().nullable().optional(),
|
|
14
|
+
});
|
|
15
|
+
RetryVideoEditorJobCommand.ResponseSchema = (0, command_response_schema_1.ICommandResponseSchema)(video_editor_job_schema_1.VideoEditorJobSchema);
|
|
16
|
+
})(RetryVideoEditorJobCommand || (exports.RetryVideoEditorJobCommand = RetryVideoEditorJobCommand = {}));
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SetReactionToVideoEditorJobCommand = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const command_response_schema_1 = require("../../common/models/command-response.schema");
|
|
6
|
+
const video_editor_job_schema_1 = require("../models/video-editor-job.schema");
|
|
7
|
+
const common_1 = require("../../common");
|
|
8
|
+
var SetReactionToVideoEditorJobCommand;
|
|
9
|
+
(function (SetReactionToVideoEditorJobCommand) {
|
|
10
|
+
SetReactionToVideoEditorJobCommand.RequestSchema = zod_1.z.object({
|
|
11
|
+
userId: zod_1.z.string().uuid().nullable().optional(),
|
|
12
|
+
unregisteredUserId: zod_1.z.string().uuid().nullable().optional(),
|
|
13
|
+
uuid: zod_1.z.string(),
|
|
14
|
+
reaction: zod_1.z.nativeEnum(common_1.USER_REACTION).nullable(),
|
|
15
|
+
});
|
|
16
|
+
SetReactionToVideoEditorJobCommand.ResponseSchema = (0, command_response_schema_1.ICommandResponseSchema)(video_editor_job_schema_1.VideoEditorJobSchema);
|
|
17
|
+
})(SetReactionToVideoEditorJobCommand || (exports.SetReactionToVideoEditorJobCommand = SetReactionToVideoEditorJobCommand = {}));
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UpdateVideoEditorJobTitleCommand = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const command_response_schema_1 = require("../../common/models/command-response.schema");
|
|
6
|
+
const video_editor_job_schema_1 = require("../models/video-editor-job.schema");
|
|
7
|
+
var UpdateVideoEditorJobTitleCommand;
|
|
8
|
+
(function (UpdateVideoEditorJobTitleCommand) {
|
|
9
|
+
UpdateVideoEditorJobTitleCommand.RequestSchema = zod_1.z.object({
|
|
10
|
+
userId: zod_1.z.string().uuid().nullable().optional(),
|
|
11
|
+
unregisteredUserId: zod_1.z.string().uuid().nullable().optional(),
|
|
12
|
+
uuid: zod_1.z.string(),
|
|
13
|
+
title: zod_1.z.string(),
|
|
14
|
+
});
|
|
15
|
+
UpdateVideoEditorJobTitleCommand.ResponseSchema = (0, command_response_schema_1.ICommandResponseSchema)(video_editor_job_schema_1.VideoEditorJobSchema);
|
|
16
|
+
})(UpdateVideoEditorJobTitleCommand || (exports.UpdateVideoEditorJobTitleCommand = UpdateVideoEditorJobTitleCommand = {}));
|
|
@@ -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("./video-editor-model-strategy.enum"), exports);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VIDEO_EDITOR_MODEL_STRATEGY = void 0;
|
|
4
|
+
var VIDEO_EDITOR_MODEL_STRATEGY;
|
|
5
|
+
(function (VIDEO_EDITOR_MODEL_STRATEGY) {
|
|
6
|
+
VIDEO_EDITOR_MODEL_STRATEGY["LUMA_MODIFY_POLLING"] = "LUMA_MODIFY_POLLING";
|
|
7
|
+
VIDEO_EDITOR_MODEL_STRATEGY["ALEPH_EDITING_POLLING"] = "ALEPH_EDITING_POLLING";
|
|
8
|
+
})(VIDEO_EDITOR_MODEL_STRATEGY || (exports.VIDEO_EDITOR_MODEL_STRATEGY = VIDEO_EDITOR_MODEL_STRATEGY = {}));
|
|
@@ -0,0 +1,22 @@
|
|
|
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("./commands"), exports);
|
|
18
|
+
__exportStar(require("./enums"), exports);
|
|
19
|
+
__exportStar(require("./models"), exports);
|
|
20
|
+
__exportStar(require("./queries"), exports);
|
|
21
|
+
__exportStar(require("./routes"), exports);
|
|
22
|
+
__exportStar(require("./utils"), exports);
|
|
@@ -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("./video-editor-config.schema"), exports);
|
|
18
|
+
__exportStar(require("./video-editor-model.schema"), exports);
|
|
19
|
+
__exportStar(require("./video-editor-job.schema"), exports);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.VideoEditorConfigSchema = void 0;
|
|
7
|
+
const zod_1 = __importDefault(require("zod"));
|
|
8
|
+
const video_editor_model_schema_1 = require("./video-editor-model.schema");
|
|
9
|
+
exports.VideoEditorConfigSchema = zod_1.default.object({
|
|
10
|
+
models: zod_1.default.array(video_editor_model_schema_1.VideoEditorModelSchema),
|
|
11
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VideoEditorJobSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const tools_1 = require("../../tools");
|
|
6
|
+
const common_1 = require("../../common");
|
|
7
|
+
exports.VideoEditorJobSchema = zod_1.z.object({
|
|
8
|
+
uuid: zod_1.z.string(),
|
|
9
|
+
prompt: zod_1.z.string(),
|
|
10
|
+
title: zod_1.z.string(),
|
|
11
|
+
status: zod_1.z.nativeEnum(tools_1.JOB_STATUS),
|
|
12
|
+
error: zod_1.z.string().nullable(),
|
|
13
|
+
price: zod_1.z.number(),
|
|
14
|
+
reaction: zod_1.z.nativeEnum(common_1.USER_REACTION).nullable(),
|
|
15
|
+
externalId: zod_1.z.string().nullable(),
|
|
16
|
+
modelId: zod_1.z.string(),
|
|
17
|
+
inputVideoUrl: zod_1.z.string(),
|
|
18
|
+
outputVideoUrl: zod_1.z.string().nullable(),
|
|
19
|
+
duration: zod_1.z.number(),
|
|
20
|
+
attempts: zod_1.z.array(zod_1.z.any()),
|
|
21
|
+
userId: zod_1.z.string().nullable().optional(),
|
|
22
|
+
unregisteredUserId: zod_1.z.string().nullable().optional(),
|
|
23
|
+
isDeleted: zod_1.z.boolean(),
|
|
24
|
+
createdAt: zod_1.z.date(),
|
|
25
|
+
completedAt: zod_1.z.date().nullable().optional(),
|
|
26
|
+
updatedAt: zod_1.z.date(),
|
|
27
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VideoEditorModelSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const common_1 = require("../../common");
|
|
6
|
+
const enums_1 = require("../enums");
|
|
7
|
+
exports.VideoEditorModelSchema = zod_1.z.object({
|
|
8
|
+
uuid: zod_1.z.string(),
|
|
9
|
+
title: zod_1.z.string(),
|
|
10
|
+
description: zod_1.z.string(),
|
|
11
|
+
aiModel: zod_1.z.string(),
|
|
12
|
+
pricePerSecond: zod_1.z.number(),
|
|
13
|
+
order: zod_1.z.number(),
|
|
14
|
+
status: zod_1.z.nativeEnum(common_1.TOOL_MODEL_STATUS),
|
|
15
|
+
icons: common_1.IconVariantsSchema,
|
|
16
|
+
strategy: zod_1.z.nativeEnum(enums_1.VIDEO_EDITOR_MODEL_STRATEGY),
|
|
17
|
+
maxPromptLength: zod_1.z.number(),
|
|
18
|
+
maxInputVideoSizeBytes: zod_1.z.number(),
|
|
19
|
+
maxInputVideoDurationInSeconds: zod_1.z.number(),
|
|
20
|
+
supportedFormats: zod_1.z.array(zod_1.z.string()),
|
|
21
|
+
needsTranslation: zod_1.z.boolean(),
|
|
22
|
+
createdAt: zod_1.z.date(),
|
|
23
|
+
updatedAt: zod_1.z.date(),
|
|
24
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FindVideoEditorJobByIdQuery = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const command_response_schema_1 = require("../../common/models/command-response.schema");
|
|
6
|
+
const video_editor_job_schema_1 = require("../models/video-editor-job.schema");
|
|
7
|
+
var FindVideoEditorJobByIdQuery;
|
|
8
|
+
(function (FindVideoEditorJobByIdQuery) {
|
|
9
|
+
FindVideoEditorJobByIdQuery.RequestSchema = zod_1.z
|
|
10
|
+
.object({
|
|
11
|
+
uuid: zod_1.z.string(),
|
|
12
|
+
userId: zod_1.z.string().uuid().nullable().optional(),
|
|
13
|
+
unregisteredUserId: zod_1.z.string().uuid().nullable().optional(),
|
|
14
|
+
})
|
|
15
|
+
.refine((data) => data.userId || data.unregisteredUserId, {
|
|
16
|
+
message: 'Either userId or unregisteredUserId must be provided',
|
|
17
|
+
});
|
|
18
|
+
FindVideoEditorJobByIdQuery.ResponseSchema = (0, command_response_schema_1.ICommandResponseSchema)(video_editor_job_schema_1.VideoEditorJobSchema);
|
|
19
|
+
})(FindVideoEditorJobByIdQuery || (exports.FindVideoEditorJobByIdQuery = FindVideoEditorJobByIdQuery = {}));
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FindVideoEditorJobsQuery = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const command_response_schema_1 = require("../../common/models/command-response.schema");
|
|
6
|
+
const video_editor_job_schema_1 = require("../models/video-editor-job.schema");
|
|
7
|
+
var FindVideoEditorJobsQuery;
|
|
8
|
+
(function (FindVideoEditorJobsQuery) {
|
|
9
|
+
FindVideoEditorJobsQuery.RequestSchema = zod_1.z
|
|
10
|
+
.object({
|
|
11
|
+
userId: zod_1.z.string().uuid().optional(),
|
|
12
|
+
unregisteredUserId: zod_1.z.string().uuid().optional(),
|
|
13
|
+
title: zod_1.z.string().optional(),
|
|
14
|
+
limit: zod_1.z.coerce.number().min(1).optional(),
|
|
15
|
+
offset: zod_1.z.coerce.number().min(0).default(0).optional(),
|
|
16
|
+
})
|
|
17
|
+
.refine((data) => {
|
|
18
|
+
return Boolean(data.userId) !== Boolean(data.unregisteredUserId);
|
|
19
|
+
}, {
|
|
20
|
+
message: 'At least userId or unregisteredUserId must be present',
|
|
21
|
+
path: ['userId', 'unregisteredUserId'],
|
|
22
|
+
});
|
|
23
|
+
FindVideoEditorJobsQuery.ResponseSchema = (0, command_response_schema_1.ICommandResponseSchema)(zod_1.z.object({
|
|
24
|
+
data: zod_1.z.array(video_editor_job_schema_1.VideoEditorJobSchema),
|
|
25
|
+
page: zod_1.z.number(),
|
|
26
|
+
totalPages: zod_1.z.number(),
|
|
27
|
+
}));
|
|
28
|
+
})(FindVideoEditorJobsQuery || (exports.FindVideoEditorJobsQuery = FindVideoEditorJobsQuery = {}));
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GetVideoEditorConfigQuery = 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 GetVideoEditorConfigQuery;
|
|
8
|
+
(function (GetVideoEditorConfigQuery) {
|
|
9
|
+
GetVideoEditorConfigQuery.RequestSchema = zod_1.z.object({});
|
|
10
|
+
GetVideoEditorConfigQuery.ResponseSchema = (0, command_response_schema_1.ICommandResponseSchema)(models_1.VideoEditorConfigSchema);
|
|
11
|
+
})(GetVideoEditorConfigQuery || (exports.GetVideoEditorConfigQuery = GetVideoEditorConfigQuery = {}));
|
|
@@ -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-video-editor-job-by-id.query"), exports);
|
|
18
|
+
__exportStar(require("./find-video-editor-jobs.query"), exports);
|
|
19
|
+
__exportStar(require("./get-video-editor-config.query"), exports);
|
|
@@ -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("./video-editor.amqp.routes"), exports);
|
|
18
|
+
__exportStar(require("./video-editor.http.routes"), exports);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VIDEO_EDITOR_AMQP_ROUTES = void 0;
|
|
4
|
+
exports.VIDEO_EDITOR_AMQP_ROUTES = {
|
|
5
|
+
EXECUTE: 'tools.video-editor.execute.rpc',
|
|
6
|
+
CONFIG: 'tools.video-editor.config.rpc',
|
|
7
|
+
GET_JOB: 'tools.video-editor.jobs.get.rpc',
|
|
8
|
+
LIST_JOBS: 'tools.video-editor.jobs.list.rpc',
|
|
9
|
+
SET_REACTION: 'tools.video-editor.jobs.set-reaction.rpc',
|
|
10
|
+
UPDATE_TITLE: 'tools.video-editor.jobs.update-title.rpc',
|
|
11
|
+
SOFT_DELETE: 'tools.video-editor.jobs.soft-delete.rpc',
|
|
12
|
+
SOFT_DELETE_ALL: 'tools.video-editor.jobs.soft-delete-all.rpc',
|
|
13
|
+
RETRY: 'tools.video-editor.jobs.retry.rpc',
|
|
14
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.calculateVideoEditingPrice = calculateVideoEditingPrice;
|
|
4
|
+
function calculateVideoEditingPrice({ duration, pricePerSecond, }) {
|
|
5
|
+
if (duration <= 0)
|
|
6
|
+
throw new Error('Duration must be positive');
|
|
7
|
+
if (pricePerSecond < 0)
|
|
8
|
+
throw new Error('Price per second cannot be negative');
|
|
9
|
+
return Math.ceil(duration * pricePerSecond);
|
|
10
|
+
}
|
|
@@ -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-video-editing-price"), exports);
|
package/common/errors/errors.ts
CHANGED
|
@@ -677,6 +677,11 @@ export const ERRORS = {
|
|
|
677
677
|
message: 'Запрос был отклонен, т.к. может не соответствовать правилам сервиса',
|
|
678
678
|
httpCode: 400,
|
|
679
679
|
},
|
|
680
|
+
PROCESSING_ERROR: {
|
|
681
|
+
code: 'PROMPT_MODERATION.PROCESSING_ERROR',
|
|
682
|
+
message: 'Произошла ошибка при обработке запроса',
|
|
683
|
+
httpCode: 500,
|
|
684
|
+
},
|
|
680
685
|
GOOGLE_CONTENT_POLICY: {
|
|
681
686
|
code: 'PROMPT_MODERATION.GOOGLE_CONTENT_POLICY',
|
|
682
687
|
message:
|
|
@@ -773,4 +778,81 @@ export const ERRORS = {
|
|
|
773
778
|
httpCode: 500,
|
|
774
779
|
},
|
|
775
780
|
},
|
|
781
|
+
VIDEO_EDITOR: {
|
|
782
|
+
AI_ERROR: {
|
|
783
|
+
code: 'VIDEO_EDITOR.AI_ERROR',
|
|
784
|
+
message: 'Произошла ошибка во время запроса к ИИ',
|
|
785
|
+
httpCode: 500,
|
|
786
|
+
},
|
|
787
|
+
INSUFFICIENT_BALANCE: {
|
|
788
|
+
code: 'VIDEO_EDITOR.INSUFFICIENT_BALANCE',
|
|
789
|
+
message: 'У пользователя недостаточно средств',
|
|
790
|
+
httpCode: 400,
|
|
791
|
+
},
|
|
792
|
+
DELETE_ERROR: {
|
|
793
|
+
code: 'VIDEO_EDITOR.DELETE_ERROR',
|
|
794
|
+
message: 'Произошла ошибка при удалении',
|
|
795
|
+
httpCode: 500,
|
|
796
|
+
},
|
|
797
|
+
MAX_PROMPT_LENGTH_EXCEEDED: {
|
|
798
|
+
code: 'VIDEO_EDITOR.MAX_PROMPT_LENGTH_EXCEEDED',
|
|
799
|
+
message: 'Превышена максимальная длина запроса',
|
|
800
|
+
httpCode: 400,
|
|
801
|
+
},
|
|
802
|
+
MAX_DURATION_EXCEEDED: {
|
|
803
|
+
code: 'VIDEO_EDITOR.MAX_DURATION_EXCEEDED',
|
|
804
|
+
message: 'Превышена максимальная длительность видео',
|
|
805
|
+
httpCode: 400,
|
|
806
|
+
},
|
|
807
|
+
},
|
|
808
|
+
VIDEO_EDITOR_MODEL: {
|
|
809
|
+
SAVE_ERROR: {
|
|
810
|
+
code: 'VIDEO_EDITOR_MODEL.SAVE_ERROR',
|
|
811
|
+
message: 'Произошла ошибка при сохранении модели для редактирования видео',
|
|
812
|
+
httpCode: 500,
|
|
813
|
+
},
|
|
814
|
+
FIND_ERROR: {
|
|
815
|
+
code: 'VIDEO_EDITOR_MODEL.FIND_ERROR',
|
|
816
|
+
message: 'Произошла ошибка при поиске модели для редактирования видео',
|
|
817
|
+
httpCode: 500,
|
|
818
|
+
},
|
|
819
|
+
NOT_FOUND: {
|
|
820
|
+
code: 'VIDEO_EDITOR_MODEL.NOT_FOUND',
|
|
821
|
+
message: 'Модель для редактирования видео не найдена',
|
|
822
|
+
httpCode: 404,
|
|
823
|
+
},
|
|
824
|
+
},
|
|
825
|
+
VIDEO_EDITOR_JOB: {
|
|
826
|
+
SAVE_ERROR: {
|
|
827
|
+
code: 'VIDEO_EDITOR_JOB.SAVE_ERROR',
|
|
828
|
+
message: 'Произошла ошибка при сохранении задания на редактирование видео',
|
|
829
|
+
httpCode: 500,
|
|
830
|
+
},
|
|
831
|
+
FIND_ERROR: {
|
|
832
|
+
code: 'VIDEO_EDITOR_JOB.FIND_ERROR',
|
|
833
|
+
message: 'Произошла ошибка при поиске задания на редактирование видео',
|
|
834
|
+
httpCode: 500,
|
|
835
|
+
},
|
|
836
|
+
NOT_FOUND: {
|
|
837
|
+
code: 'VIDEO_EDITOR_JOB.NOT_FOUND',
|
|
838
|
+
message: 'Задание на редактирование видео не найдено',
|
|
839
|
+
httpCode: 404,
|
|
840
|
+
},
|
|
841
|
+
NOT_AN_OWNER: {
|
|
842
|
+
code: 'VIDEO_EDITOR_JOB.NOT_AN_OWNER',
|
|
843
|
+
message: 'Пользователь не является владельцем задания на редактирование видео',
|
|
844
|
+
httpCode: 403,
|
|
845
|
+
},
|
|
846
|
+
NOT_IN_FAILED_STATE_TO_RETRY: {
|
|
847
|
+
code: 'VIDEO_EDITOR_JOB.NOT_IN_FAILED_STATE_TO_RETRY',
|
|
848
|
+
message:
|
|
849
|
+
'Задание на редактирование видео не в состоянии "failed". Невозможно повторить',
|
|
850
|
+
httpCode: 400,
|
|
851
|
+
},
|
|
852
|
+
DELETE_ERROR: {
|
|
853
|
+
code: 'VIDEO_EDITOR_JOB.DELETE_ERROR',
|
|
854
|
+
message: 'Произошла ошибка при удалении задания на редактирование видео',
|
|
855
|
+
httpCode: 500,
|
|
856
|
+
},
|
|
857
|
+
},
|
|
776
858
|
} as const;
|
package/index.ts
CHANGED
|
@@ -7,6 +7,7 @@ export * from './language';
|
|
|
7
7
|
export * from './video';
|
|
8
8
|
export * from './writer';
|
|
9
9
|
export * from './image-editor';
|
|
10
|
+
export * from './video-editor';
|
|
10
11
|
|
|
11
12
|
import * as common from './common';
|
|
12
13
|
import * as paraphrase from './paraphrase';
|
|
@@ -18,6 +19,7 @@ import * as language from './language';
|
|
|
18
19
|
import * as video from './video';
|
|
19
20
|
import * as writer from './writer';
|
|
20
21
|
import * as imageEditor from './image-editor';
|
|
22
|
+
import * as videoEditor from './video-editor';
|
|
21
23
|
|
|
22
24
|
export namespace ToolService {
|
|
23
25
|
export import Common = common;
|
|
@@ -30,4 +32,5 @@ export namespace ToolService {
|
|
|
30
32
|
export import Video = video;
|
|
31
33
|
export import Writer = writer;
|
|
32
34
|
export import ImageEditor = imageEditor;
|
|
35
|
+
export import VideoEditor = videoEditor;
|
|
33
36
|
}
|
package/package.json
CHANGED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ICommandResponseSchema } from '../../common/models/command-response.schema';
|
|
3
|
+
|
|
4
|
+
export namespace DeleteAllVideoEditorJobsCommand {
|
|
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 DeleteVideoEditorJobByUuidCommand {
|
|
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,19 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ICommandResponseSchema } from '../../common/models/command-response.schema';
|
|
3
|
+
import { VideoEditorJobSchema } from '../models';
|
|
4
|
+
|
|
5
|
+
export namespace EditVideoCommand {
|
|
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
|
+
inputVideoUrl: z.string(),
|
|
11
|
+
duration: z.number(),
|
|
12
|
+
userBalance: z.number(),
|
|
13
|
+
modelId: z.string(),
|
|
14
|
+
});
|
|
15
|
+
export type Request = z.infer<typeof RequestSchema>;
|
|
16
|
+
|
|
17
|
+
export const ResponseSchema = ICommandResponseSchema(VideoEditorJobSchema);
|
|
18
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export * from './delete-all-video-editor-jobs.command';
|
|
2
|
+
export * from './delete-video-editor-job-by-uuid.command';
|
|
3
|
+
export * from './retry-video-editor-job.command';
|
|
4
|
+
export * from './set-reaction-to-video-editor-job.command';
|
|
5
|
+
export * from './update-video-editor-job-title.command';
|
|
6
|
+
export * from './edit-video.command';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ICommandResponseSchema } from '../../common/models/command-response.schema';
|
|
3
|
+
import { VideoEditorJobSchema } from '../models/video-editor-job.schema';
|
|
4
|
+
|
|
5
|
+
export namespace RetryVideoEditorJobCommand {
|
|
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(VideoEditorJobSchema);
|
|
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 { VideoEditorJobSchema } from '../models/video-editor-job.schema';
|
|
4
|
+
import { USER_REACTION } from '../../common';
|
|
5
|
+
|
|
6
|
+
export namespace SetReactionToVideoEditorJobCommand {
|
|
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(VideoEditorJobSchema);
|
|
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 { VideoEditorJobSchema } from '../models/video-editor-job.schema';
|
|
4
|
+
|
|
5
|
+
export namespace UpdateVideoEditorJobTitleCommand {
|
|
6
|
+
export const RequestSchema = z.object({
|
|
7
|
+
userId: z.string().uuid().nullable().optional(),
|
|
8
|
+
unregisteredUserId: z.string().uuid().nullable().optional(),
|
|
9
|
+
uuid: z.string(),
|
|
10
|
+
title: z.string(),
|
|
11
|
+
});
|
|
12
|
+
export type Request = z.infer<typeof RequestSchema>;
|
|
13
|
+
|
|
14
|
+
export const ResponseSchema = ICommandResponseSchema(VideoEditorJobSchema);
|
|
15
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './video-editor-model-strategy.enum';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import z from 'zod';
|
|
2
|
+
import { VideoEditorModelSchema } from './video-editor-model.schema';
|
|
3
|
+
|
|
4
|
+
export const VideoEditorConfigSchema = z.object({
|
|
5
|
+
models: z.array(VideoEditorModelSchema),
|
|
6
|
+
});
|
|
7
|
+
export type VideoEditorConfig = z.infer<typeof VideoEditorConfigSchema>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { JOB_STATUS } from '../../tools';
|
|
3
|
+
import { USER_REACTION } from '../../common';
|
|
4
|
+
|
|
5
|
+
export const VideoEditorJobSchema = z.object({
|
|
6
|
+
uuid: z.string(),
|
|
7
|
+
prompt: z.string(),
|
|
8
|
+
title: z.string(),
|
|
9
|
+
status: z.nativeEnum(JOB_STATUS),
|
|
10
|
+
error: z.string().nullable(),
|
|
11
|
+
price: z.number(),
|
|
12
|
+
reaction: z.nativeEnum(USER_REACTION).nullable(),
|
|
13
|
+
externalId: z.string().nullable(),
|
|
14
|
+
modelId: z.string(),
|
|
15
|
+
inputVideoUrl: z.string(),
|
|
16
|
+
outputVideoUrl: z.string().nullable(),
|
|
17
|
+
duration: z.number(),
|
|
18
|
+
attempts: z.array(z.any()),
|
|
19
|
+
userId: z.string().nullable().optional(),
|
|
20
|
+
unregisteredUserId: z.string().nullable().optional(),
|
|
21
|
+
isDeleted: z.boolean(),
|
|
22
|
+
createdAt: z.date(),
|
|
23
|
+
completedAt: z.date().nullable().optional(),
|
|
24
|
+
updatedAt: z.date(),
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
export type VideoEditorJob = z.infer<typeof VideoEditorJobSchema>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { IconVariantsSchema, TOOL_MODEL_STATUS } from '../../common';
|
|
3
|
+
import { VIDEO_EDITOR_MODEL_STRATEGY } from '../enums';
|
|
4
|
+
|
|
5
|
+
export const VideoEditorModelSchema = z.object({
|
|
6
|
+
uuid: z.string(),
|
|
7
|
+
title: z.string(),
|
|
8
|
+
description: z.string(),
|
|
9
|
+
aiModel: z.string(),
|
|
10
|
+
pricePerSecond: z.number(),
|
|
11
|
+
order: z.number(),
|
|
12
|
+
status: z.nativeEnum(TOOL_MODEL_STATUS),
|
|
13
|
+
icons: IconVariantsSchema,
|
|
14
|
+
strategy: z.nativeEnum(VIDEO_EDITOR_MODEL_STRATEGY),
|
|
15
|
+
maxPromptLength: z.number(),
|
|
16
|
+
maxInputVideoSizeBytes: z.number(),
|
|
17
|
+
maxInputVideoDurationInSeconds: z.number(),
|
|
18
|
+
supportedFormats: z.array(z.string()),
|
|
19
|
+
needsTranslation: z.boolean(),
|
|
20
|
+
createdAt: z.date(),
|
|
21
|
+
updatedAt: z.date(),
|
|
22
|
+
});
|
|
23
|
+
export type VideoEditorModel = z.infer<typeof VideoEditorModelSchema>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ICommandResponseSchema } from '../../common/models/command-response.schema';
|
|
3
|
+
import { VideoEditorJobSchema } from '../models/video-editor-job.schema';
|
|
4
|
+
|
|
5
|
+
export namespace FindVideoEditorJobByIdQuery {
|
|
6
|
+
export const RequestSchema = z
|
|
7
|
+
.object({
|
|
8
|
+
uuid: z.string(),
|
|
9
|
+
userId: z.string().uuid().nullable().optional(),
|
|
10
|
+
unregisteredUserId: z.string().uuid().nullable().optional(),
|
|
11
|
+
})
|
|
12
|
+
.refine((data) => data.userId || data.unregisteredUserId, {
|
|
13
|
+
message: 'Either userId or unregisteredUserId must be provided',
|
|
14
|
+
});
|
|
15
|
+
export type Request = z.infer<typeof RequestSchema>;
|
|
16
|
+
|
|
17
|
+
export const ResponseSchema = ICommandResponseSchema(VideoEditorJobSchema);
|
|
18
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ICommandResponseSchema } from '../../common/models/command-response.schema';
|
|
3
|
+
import { VideoEditorJobSchema } from '../models/video-editor-job.schema';
|
|
4
|
+
|
|
5
|
+
export namespace FindVideoEditorJobsQuery {
|
|
6
|
+
export const RequestSchema = z
|
|
7
|
+
.object({
|
|
8
|
+
userId: z.string().uuid().optional(),
|
|
9
|
+
unregisteredUserId: z.string().uuid().optional(),
|
|
10
|
+
title: z.string().optional(),
|
|
11
|
+
limit: z.coerce.number().min(1).optional(),
|
|
12
|
+
offset: z.coerce.number().min(0).default(0).optional(),
|
|
13
|
+
})
|
|
14
|
+
.refine(
|
|
15
|
+
(data) => {
|
|
16
|
+
return Boolean(data.userId) !== Boolean(data.unregisteredUserId);
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
message: 'At least userId or unregisteredUserId must be present',
|
|
20
|
+
path: ['userId', 'unregisteredUserId'],
|
|
21
|
+
},
|
|
22
|
+
);
|
|
23
|
+
export type Request = z.infer<typeof RequestSchema>;
|
|
24
|
+
|
|
25
|
+
export const ResponseSchema = ICommandResponseSchema(
|
|
26
|
+
z.object({
|
|
27
|
+
data: z.array(VideoEditorJobSchema),
|
|
28
|
+
page: z.number(),
|
|
29
|
+
totalPages: z.number(),
|
|
30
|
+
}),
|
|
31
|
+
);
|
|
32
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
33
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ICommandResponseSchema } from '../../common/models/command-response.schema';
|
|
3
|
+
import { VideoEditorConfigSchema } from '../models';
|
|
4
|
+
|
|
5
|
+
export namespace GetVideoEditorConfigQuery {
|
|
6
|
+
export const RequestSchema = z.object({});
|
|
7
|
+
export type Request = z.infer<typeof RequestSchema>;
|
|
8
|
+
|
|
9
|
+
export const ResponseSchema = ICommandResponseSchema(VideoEditorConfigSchema);
|
|
10
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export const VIDEO_EDITOR_AMQP_ROUTES = {
|
|
2
|
+
EXECUTE: 'tools.video-editor.execute.rpc',
|
|
3
|
+
CONFIG: 'tools.video-editor.config.rpc',
|
|
4
|
+
GET_JOB: 'tools.video-editor.jobs.get.rpc',
|
|
5
|
+
LIST_JOBS: 'tools.video-editor.jobs.list.rpc',
|
|
6
|
+
SET_REACTION: 'tools.video-editor.jobs.set-reaction.rpc',
|
|
7
|
+
UPDATE_TITLE: 'tools.video-editor.jobs.update-title.rpc',
|
|
8
|
+
SOFT_DELETE: 'tools.video-editor.jobs.soft-delete.rpc',
|
|
9
|
+
SOFT_DELETE_ALL: 'tools.video-editor.jobs.soft-delete-all.rpc',
|
|
10
|
+
RETRY: 'tools.video-editor.jobs.retry.rpc',
|
|
11
|
+
} as const;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const VIDEO_EDITOR_CONTROLLER = 'video-editor';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export function calculateVideoEditingPrice({
|
|
2
|
+
duration,
|
|
3
|
+
pricePerSecond,
|
|
4
|
+
}: {
|
|
5
|
+
duration: number;
|
|
6
|
+
pricePerSecond: number;
|
|
7
|
+
}): number {
|
|
8
|
+
if (duration <= 0) throw new Error('Duration must be positive');
|
|
9
|
+
if (pricePerSecond < 0) throw new Error('Price per second cannot be negative');
|
|
10
|
+
|
|
11
|
+
return Math.ceil(duration * pricePerSecond);
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './calculate-video-editing-price';
|