@purpleschool/gptbot-tools 0.0.74 → 0.0.76
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 +5 -0
- package/build/presentation/constants/slide-layout-map.constant.js +1 -0
- package/build/presentation/enums/slide-content-type.enum.js +1 -0
- package/build/presentation/models/slide-content-edit.schema.js +18 -1
- package/build/presentation/models/slide-content.schema.js +26 -1
- package/build/video/enums/video-pricing-rule-type.enum.js +1 -0
- package/build/video/enums/video-strategy.enum.js +1 -0
- package/build/video/models/video-model.schema.js +8 -1
- package/build/video/routes/video.http.routes.js +1 -0
- package/build/video/utils/calculate-video-generation-price.util.js +5 -1
- package/common/errors/errors.ts +5 -0
- package/package.json +1 -1
- package/presentation/constants/slide-layout-map.constant.ts +1 -0
- package/presentation/enums/slide-content-type.enum.ts +1 -0
- package/presentation/models/slide-content-edit.schema.ts +21 -0
- package/presentation/models/slide-content.schema.ts +45 -0
- package/video/enums/video-pricing-rule-type.enum.ts +1 -0
- package/video/enums/video-strategy.enum.ts +1 -0
- package/video/models/video-model.schema.ts +8 -1
- package/video/routes/video.http.routes.ts +1 -0
- package/video/utils/calculate-video-generation-price.util.ts +7 -1
|
@@ -578,6 +578,11 @@ exports.ERRORS = {
|
|
|
578
578
|
message: 'Некорректное соотношение сторон',
|
|
579
579
|
httpCode: 400,
|
|
580
580
|
},
|
|
581
|
+
INVALID_RESOLUTION: {
|
|
582
|
+
code: 'VIDEO.INVALID_RESOLUTION',
|
|
583
|
+
message: 'Некорректное разрешение видео',
|
|
584
|
+
httpCode: 400,
|
|
585
|
+
},
|
|
581
586
|
RUNWAY_CONTENT_POLICY: {
|
|
582
587
|
code: 'VIDEO.RUNWAY_CONTENT_POLICY',
|
|
583
588
|
message: 'Запрос на создание видео был отклонен, т.к. он не соответствует требованиям политики безопасности Runway.',
|
|
@@ -13,4 +13,5 @@ exports.SLIDE_LAYOUT_MAP = new Map([
|
|
|
13
13
|
[enums_1.SLIDE_CONTENT_TYPE.THANK_YOU, [slide_layout_enum_1.SLIDE_LAYOUT.TYPE_1]],
|
|
14
14
|
[enums_1.SLIDE_CONTENT_TYPE.TABLE, [slide_layout_enum_1.SLIDE_LAYOUT.TYPE_1]],
|
|
15
15
|
[enums_1.SLIDE_CONTENT_TYPE.CHART, [slide_layout_enum_1.SLIDE_LAYOUT.TYPE_1]],
|
|
16
|
+
[enums_1.SLIDE_CONTENT_TYPE.TIMELINE, [slide_layout_enum_1.SLIDE_LAYOUT.TYPE_1]],
|
|
16
17
|
]);
|
|
@@ -12,4 +12,5 @@ var SLIDE_CONTENT_TYPE;
|
|
|
12
12
|
SLIDE_CONTENT_TYPE["THANK_YOU"] = "THANK_YOU";
|
|
13
13
|
SLIDE_CONTENT_TYPE["TABLE"] = "TABLE";
|
|
14
14
|
SLIDE_CONTENT_TYPE["CHART"] = "CHART";
|
|
15
|
+
SLIDE_CONTENT_TYPE["TIMELINE"] = "TIMELINE";
|
|
15
16
|
})(SLIDE_CONTENT_TYPE || (exports.SLIDE_CONTENT_TYPE = SLIDE_CONTENT_TYPE = {}));
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.SlideContentUserEditSchema = exports.ChartSlideDataUserEditSchema = exports.BarChartSlideDataUserEditSchema = exports.TableSlideDataUserEditSchema = exports.SectionBreakSlideDataUserEditSchema = exports.ImageSlideDataUserEditSchema = exports.ContentsSlideDataUserEditSchema = exports.StructuredListSlideDataUserEditSchema = exports.TextSlideDataUserEditSchema = exports.ThankYouSlideDataUserEditSchema = exports.CoverSlideDataUserEditSchema = void 0;
|
|
6
|
+
exports.SlideContentUserEditSchema = exports.TimelineSlideDataUserEditSchema = exports.ChartSlideDataUserEditSchema = exports.BarChartSlideDataUserEditSchema = exports.TableSlideDataUserEditSchema = exports.SectionBreakSlideDataUserEditSchema = exports.ImageSlideDataUserEditSchema = exports.ContentsSlideDataUserEditSchema = exports.StructuredListSlideDataUserEditSchema = exports.TextSlideDataUserEditSchema = exports.ThankYouSlideDataUserEditSchema = exports.CoverSlideDataUserEditSchema = void 0;
|
|
7
7
|
const zod_1 = __importDefault(require("zod"));
|
|
8
8
|
const enums_1 = require("../enums");
|
|
9
9
|
const slide_content_schema_1 = require("./slide-content.schema");
|
|
@@ -122,6 +122,22 @@ exports.ChartSlideDataUserEditSchema = zod_1.default.object({
|
|
|
122
122
|
chart: zod_1.default.discriminatedUnion('type', [exports.BarChartSlideDataUserEditSchema]),
|
|
123
123
|
version: zod_1.default.literal(1),
|
|
124
124
|
});
|
|
125
|
+
exports.TimelineSlideDataUserEditSchema = zod_1.default.object({
|
|
126
|
+
contentType: zod_1.default.literal(enums_1.SLIDE_CONTENT_TYPE.TIMELINE),
|
|
127
|
+
title: zod_1.default.string().min(1).max(500),
|
|
128
|
+
description: zod_1.default.string().min(1).max(1000),
|
|
129
|
+
timeline: zod_1.default.object({
|
|
130
|
+
events: zod_1.default
|
|
131
|
+
.array(zod_1.default.object({
|
|
132
|
+
date: zod_1.default.string().min(1).max(100),
|
|
133
|
+
title: zod_1.default.string().min(1).max(200),
|
|
134
|
+
description: zod_1.default.string().min(1).max(500),
|
|
135
|
+
}))
|
|
136
|
+
.min(2)
|
|
137
|
+
.max(10),
|
|
138
|
+
}),
|
|
139
|
+
version: zod_1.default.literal(1),
|
|
140
|
+
});
|
|
125
141
|
exports.SlideContentUserEditSchema = zod_1.default.discriminatedUnion('contentType', [
|
|
126
142
|
exports.CoverSlideDataUserEditSchema,
|
|
127
143
|
exports.StructuredListSlideDataUserEditSchema,
|
|
@@ -132,4 +148,5 @@ exports.SlideContentUserEditSchema = zod_1.default.discriminatedUnion('contentTy
|
|
|
132
148
|
exports.ThankYouSlideDataUserEditSchema,
|
|
133
149
|
exports.TableSlideDataUserEditSchema,
|
|
134
150
|
exports.ChartSlideDataUserEditSchema,
|
|
151
|
+
exports.TimelineSlideDataUserEditSchema,
|
|
135
152
|
]);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SlideContentSchema = exports.ChartSlideDataSchema = exports.BarChartSlideDataSchema = exports.TableSlideDataSchema = exports.SectionBreakSlideDataSchema = exports.ImageSlideDataSchema = exports.ContentsSlideDataSchema = exports.TextSlideDataSchema = exports.StructuredListSlideDataSchema = exports.ThankYouSlideDataSchema = exports.CoverSlideDataSchema = exports.IconSlotSchema = exports.ImageSlotSchema = exports.SLIDE_CHART_TYPE = void 0;
|
|
3
|
+
exports.SlideContentSchema = exports.TimelineSlideDataSchema = exports.ChartSlideDataSchema = exports.BarChartSlideDataSchema = exports.TableSlideDataSchema = exports.SectionBreakSlideDataSchema = exports.ImageSlideDataSchema = exports.ContentsSlideDataSchema = exports.TextSlideDataSchema = exports.StructuredListSlideDataSchema = exports.ThankYouSlideDataSchema = exports.CoverSlideDataSchema = exports.IconSlotSchema = exports.ImageSlotSchema = exports.SLIDE_CHART_TYPE = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const enums_1 = require("../enums");
|
|
6
6
|
var SLIDE_CHART_TYPE;
|
|
@@ -184,6 +184,30 @@ exports.ChartSlideDataSchema = zod_1.z.object({
|
|
|
184
184
|
chart: zod_1.z.discriminatedUnion('type', [exports.BarChartSlideDataSchema]),
|
|
185
185
|
version: zod_1.z.literal(1),
|
|
186
186
|
});
|
|
187
|
+
exports.TimelineSlideDataSchema = zod_1.z.object({
|
|
188
|
+
contentType: zod_1.z.literal(enums_1.SLIDE_CONTENT_TYPE.TIMELINE),
|
|
189
|
+
title: zod_1.z.string().describe('Slide title in about 6 words').min(10).max(150),
|
|
190
|
+
description: zod_1.z.string().describe('Brief context for the timeline').min(10).max(200),
|
|
191
|
+
timeline: zod_1.z.object({
|
|
192
|
+
events: zod_1.z
|
|
193
|
+
.array(zod_1.z.object({
|
|
194
|
+
date: zod_1.z
|
|
195
|
+
.string()
|
|
196
|
+
.describe('Date or time period label. MUST be general/approximate if exact date unknown (e.g., "Early 2020s", "Mid-1990s", "Recent years")')
|
|
197
|
+
.min(2)
|
|
198
|
+
.max(50),
|
|
199
|
+
title: zod_1.z.string().describe('Event title in 2-4 words').min(5).max(80),
|
|
200
|
+
description: zod_1.z
|
|
201
|
+
.string()
|
|
202
|
+
.describe('Brief description of the event or milestone')
|
|
203
|
+
.min(20)
|
|
204
|
+
.max(150),
|
|
205
|
+
}))
|
|
206
|
+
.length(5)
|
|
207
|
+
.describe('Timeline must contain exactly 5 chronological events'),
|
|
208
|
+
}),
|
|
209
|
+
version: zod_1.z.literal(1),
|
|
210
|
+
});
|
|
187
211
|
exports.SlideContentSchema = zod_1.z.discriminatedUnion('contentType', [
|
|
188
212
|
exports.CoverSlideDataSchema,
|
|
189
213
|
exports.StructuredListSlideDataSchema,
|
|
@@ -194,4 +218,5 @@ exports.SlideContentSchema = zod_1.z.discriminatedUnion('contentType', [
|
|
|
194
218
|
exports.ThankYouSlideDataSchema,
|
|
195
219
|
exports.TableSlideDataSchema,
|
|
196
220
|
exports.ChartSlideDataSchema,
|
|
221
|
+
exports.TimelineSlideDataSchema,
|
|
197
222
|
]);
|
|
@@ -4,4 +4,5 @@ exports.VIDEO_PRICING_RULE_TYPE = void 0;
|
|
|
4
4
|
var VIDEO_PRICING_RULE_TYPE;
|
|
5
5
|
(function (VIDEO_PRICING_RULE_TYPE) {
|
|
6
6
|
VIDEO_PRICING_RULE_TYPE["FLAT"] = "flat";
|
|
7
|
+
VIDEO_PRICING_RULE_TYPE["PER_SECOND"] = "per_second";
|
|
7
8
|
})(VIDEO_PRICING_RULE_TYPE || (exports.VIDEO_PRICING_RULE_TYPE = VIDEO_PRICING_RULE_TYPE = {}));
|
|
@@ -9,4 +9,5 @@ var VIDEO_GENERATION_STRATEGY;
|
|
|
9
9
|
VIDEO_GENERATION_STRATEGY["RUNWAY_CALLBACK"] = "RUNWAY_CALLBACK";
|
|
10
10
|
VIDEO_GENERATION_STRATEGY["SORA_2_VIDEO_GENERATION_POLLING"] = "SORA_2_VIDEO_GENERATION_POLLING";
|
|
11
11
|
VIDEO_GENERATION_STRATEGY["SORA_2_VIDEO_GENERATION_CALLBACK"] = "SORA_2_VIDEO_GENERATION_CALLBACK";
|
|
12
|
+
VIDEO_GENERATION_STRATEGY["SEEDANCE_VIDEO_GENERATION_CALLBACK"] = "SEEDANCE_VIDEO_GENERATION_CALLBACK";
|
|
12
13
|
})(VIDEO_GENERATION_STRATEGY || (exports.VIDEO_GENERATION_STRATEGY = VIDEO_GENERATION_STRATEGY = {}));
|
|
@@ -18,15 +18,22 @@ exports.VideoModelParamsSchema = zod_1.z.object({
|
|
|
18
18
|
})
|
|
19
19
|
.optional(),
|
|
20
20
|
quality: zod_1.z.string().optional(),
|
|
21
|
+
resolution: zod_1.z
|
|
22
|
+
.object({
|
|
23
|
+
options: zod_1.z.array(zod_1.z.string()),
|
|
24
|
+
})
|
|
25
|
+
.optional(),
|
|
21
26
|
});
|
|
22
27
|
exports.VideoGenerationRequestParamsSchema = zod_1.z.object({
|
|
23
28
|
imageUrls: zod_1.z.string().array().optional(),
|
|
24
29
|
duration: zod_1.z.number(),
|
|
25
30
|
aspectRatio: zod_1.z.string().optional(),
|
|
26
31
|
quality: zod_1.z.string().optional(),
|
|
32
|
+
resolution: zod_1.z.string().optional(),
|
|
27
33
|
});
|
|
28
34
|
exports.VideoModelPricingRuleConditionSchema = zod_1.z.object({
|
|
29
|
-
aspectRatio: zod_1.z.string(),
|
|
35
|
+
aspectRatio: zod_1.z.string().optional(),
|
|
36
|
+
resolution: zod_1.z.string().optional(),
|
|
30
37
|
});
|
|
31
38
|
exports.VideoModelPricingRulesSchema = zod_1.z.array(zod_1.z.object({
|
|
32
39
|
type: zod_1.z.nativeEnum(enums_1.VIDEO_PRICING_RULE_TYPE),
|
|
@@ -17,7 +17,11 @@ function matchesCondition(condition, params) {
|
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
19
|
function calculateVideoGenerationPrice({ pricePerSecond, params, rules, }) {
|
|
20
|
-
const
|
|
20
|
+
const perSecondRule = rules
|
|
21
|
+
.filter((r) => r.type === enums_1.VIDEO_PRICING_RULE_TYPE.PER_SECOND)
|
|
22
|
+
.find((r) => matchesCondition(r.condition, params));
|
|
23
|
+
const effectivePricePerSecond = perSecondRule ? perSecondRule.value : pricePerSecond;
|
|
24
|
+
const base = effectivePricePerSecond * params.duration;
|
|
21
25
|
const flatMarkup = rules.reduce((sum, r) => {
|
|
22
26
|
if (r.type !== enums_1.VIDEO_PRICING_RULE_TYPE.FLAT) {
|
|
23
27
|
return sum;
|
package/common/errors/errors.ts
CHANGED
|
@@ -577,6 +577,11 @@ export const ERRORS = {
|
|
|
577
577
|
message: 'Некорректное соотношение сторон',
|
|
578
578
|
httpCode: 400,
|
|
579
579
|
},
|
|
580
|
+
INVALID_RESOLUTION: {
|
|
581
|
+
code: 'VIDEO.INVALID_RESOLUTION',
|
|
582
|
+
message: 'Некорректное разрешение видео',
|
|
583
|
+
httpCode: 400,
|
|
584
|
+
},
|
|
580
585
|
RUNWAY_CONTENT_POLICY: {
|
|
581
586
|
code: 'VIDEO.RUNWAY_CONTENT_POLICY',
|
|
582
587
|
message:
|
package/package.json
CHANGED
|
@@ -11,4 +11,5 @@ export const SLIDE_LAYOUT_MAP = new Map<SLIDE_CONTENT_TYPE, SLIDE_LAYOUT[]>([
|
|
|
11
11
|
[SLIDE_CONTENT_TYPE.THANK_YOU, [SLIDE_LAYOUT.TYPE_1]],
|
|
12
12
|
[SLIDE_CONTENT_TYPE.TABLE, [SLIDE_LAYOUT.TYPE_1]],
|
|
13
13
|
[SLIDE_CONTENT_TYPE.CHART, [SLIDE_LAYOUT.TYPE_1]],
|
|
14
|
+
[SLIDE_CONTENT_TYPE.TIMELINE, [SLIDE_LAYOUT.TYPE_1]],
|
|
14
15
|
]);
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
IBarChartSlideDataStructure,
|
|
14
14
|
IChartSlideDataStructure,
|
|
15
15
|
ImageSlotSchema,
|
|
16
|
+
ITimelineSlideDataStructure,
|
|
16
17
|
} from './slide-content.schema';
|
|
17
18
|
|
|
18
19
|
export const CoverSlideDataUserEditSchema = z.object({
|
|
@@ -146,6 +147,25 @@ export const ChartSlideDataUserEditSchema = z.object({
|
|
|
146
147
|
version: z.literal(1),
|
|
147
148
|
}) satisfies z.ZodType<IChartSlideDataStructure>;
|
|
148
149
|
|
|
150
|
+
export const TimelineSlideDataUserEditSchema = z.object({
|
|
151
|
+
contentType: z.literal(SLIDE_CONTENT_TYPE.TIMELINE),
|
|
152
|
+
title: z.string().min(1).max(500),
|
|
153
|
+
description: z.string().min(1).max(1000),
|
|
154
|
+
timeline: z.object({
|
|
155
|
+
events: z
|
|
156
|
+
.array(
|
|
157
|
+
z.object({
|
|
158
|
+
date: z.string().min(1).max(100),
|
|
159
|
+
title: z.string().min(1).max(200),
|
|
160
|
+
description: z.string().min(1).max(500),
|
|
161
|
+
}),
|
|
162
|
+
)
|
|
163
|
+
.min(2)
|
|
164
|
+
.max(10),
|
|
165
|
+
}),
|
|
166
|
+
version: z.literal(1),
|
|
167
|
+
}) satisfies z.ZodType<ITimelineSlideDataStructure>;
|
|
168
|
+
|
|
149
169
|
export const SlideContentUserEditSchema = z.discriminatedUnion('contentType', [
|
|
150
170
|
CoverSlideDataUserEditSchema,
|
|
151
171
|
StructuredListSlideDataUserEditSchema,
|
|
@@ -156,5 +176,6 @@ export const SlideContentUserEditSchema = z.discriminatedUnion('contentType', [
|
|
|
156
176
|
ThankYouSlideDataUserEditSchema,
|
|
157
177
|
TableSlideDataUserEditSchema,
|
|
158
178
|
ChartSlideDataUserEditSchema,
|
|
179
|
+
TimelineSlideDataUserEditSchema,
|
|
159
180
|
]);
|
|
160
181
|
export type SlideContentUserEdit = z.infer<typeof SlideContentUserEditSchema>;
|
|
@@ -108,6 +108,20 @@ export interface IChartSlideDataStructure {
|
|
|
108
108
|
version: 1;
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
+
export interface ITimelineSlideDataStructure {
|
|
112
|
+
contentType: SLIDE_CONTENT_TYPE.TIMELINE;
|
|
113
|
+
title: string;
|
|
114
|
+
description: string;
|
|
115
|
+
timeline: {
|
|
116
|
+
events: Array<{
|
|
117
|
+
date: string;
|
|
118
|
+
title: string;
|
|
119
|
+
description: string;
|
|
120
|
+
}>;
|
|
121
|
+
};
|
|
122
|
+
version: 1;
|
|
123
|
+
}
|
|
124
|
+
|
|
111
125
|
export const CoverSlideDataSchema = z.object({
|
|
112
126
|
contentType: z.literal(SLIDE_CONTENT_TYPE.COVER),
|
|
113
127
|
title: z.string().describe('Slide title in about 6 words').min(10).max(150),
|
|
@@ -313,6 +327,36 @@ export const ChartSlideDataSchema = z.object({
|
|
|
313
327
|
}) satisfies z.ZodType<IChartSlideDataStructure>;
|
|
314
328
|
export type ChartSlideData = z.infer<typeof ChartSlideDataSchema>;
|
|
315
329
|
|
|
330
|
+
export const TimelineSlideDataSchema = z.object({
|
|
331
|
+
contentType: z.literal(SLIDE_CONTENT_TYPE.TIMELINE),
|
|
332
|
+
title: z.string().describe('Slide title in about 6 words').min(10).max(150),
|
|
333
|
+
description: z.string().describe('Brief context for the timeline').min(10).max(200),
|
|
334
|
+
timeline: z.object({
|
|
335
|
+
events: z
|
|
336
|
+
.array(
|
|
337
|
+
z.object({
|
|
338
|
+
date: z
|
|
339
|
+
.string()
|
|
340
|
+
.describe(
|
|
341
|
+
'Date or time period label. MUST be general/approximate if exact date unknown (e.g., "Early 2020s", "Mid-1990s", "Recent years")',
|
|
342
|
+
)
|
|
343
|
+
.min(2)
|
|
344
|
+
.max(50),
|
|
345
|
+
title: z.string().describe('Event title in 2-4 words').min(5).max(80),
|
|
346
|
+
description: z
|
|
347
|
+
.string()
|
|
348
|
+
.describe('Brief description of the event or milestone')
|
|
349
|
+
.min(20)
|
|
350
|
+
.max(150),
|
|
351
|
+
}),
|
|
352
|
+
)
|
|
353
|
+
.length(5)
|
|
354
|
+
.describe('Timeline must contain exactly 5 chronological events'),
|
|
355
|
+
}),
|
|
356
|
+
version: z.literal(1),
|
|
357
|
+
}) satisfies z.ZodType<ITimelineSlideDataStructure>;
|
|
358
|
+
export type TimelineSlideData = z.infer<typeof TimelineSlideDataSchema>;
|
|
359
|
+
|
|
316
360
|
export const SlideContentSchema = z.discriminatedUnion('contentType', [
|
|
317
361
|
CoverSlideDataSchema,
|
|
318
362
|
StructuredListSlideDataSchema,
|
|
@@ -323,5 +367,6 @@ export const SlideContentSchema = z.discriminatedUnion('contentType', [
|
|
|
323
367
|
ThankYouSlideDataSchema,
|
|
324
368
|
TableSlideDataSchema,
|
|
325
369
|
ChartSlideDataSchema,
|
|
370
|
+
TimelineSlideDataSchema,
|
|
326
371
|
]);
|
|
327
372
|
export type SlideContent = z.infer<typeof SlideContentSchema>;
|
|
@@ -5,4 +5,5 @@ export enum VIDEO_GENERATION_STRATEGY {
|
|
|
5
5
|
RUNWAY_CALLBACK = 'RUNWAY_CALLBACK',
|
|
6
6
|
SORA_2_VIDEO_GENERATION_POLLING = 'SORA_2_VIDEO_GENERATION_POLLING',
|
|
7
7
|
SORA_2_VIDEO_GENERATION_CALLBACK = 'SORA_2_VIDEO_GENERATION_CALLBACK',
|
|
8
|
+
SEEDANCE_VIDEO_GENERATION_CALLBACK = 'SEEDANCE_VIDEO_GENERATION_CALLBACK',
|
|
8
9
|
}
|
|
@@ -20,6 +20,11 @@ export const VideoModelParamsSchema = z.object({
|
|
|
20
20
|
})
|
|
21
21
|
.optional(),
|
|
22
22
|
quality: z.string().optional(),
|
|
23
|
+
resolution: z
|
|
24
|
+
.object({
|
|
25
|
+
options: z.array(z.string()),
|
|
26
|
+
})
|
|
27
|
+
.optional(),
|
|
23
28
|
});
|
|
24
29
|
|
|
25
30
|
export type VideoModelParams = z.infer<typeof VideoModelParamsSchema>;
|
|
@@ -29,11 +34,13 @@ export const VideoGenerationRequestParamsSchema = z.object({
|
|
|
29
34
|
duration: z.number(),
|
|
30
35
|
aspectRatio: z.string().optional(),
|
|
31
36
|
quality: z.string().optional(),
|
|
37
|
+
resolution: z.string().optional(),
|
|
32
38
|
});
|
|
33
39
|
export type VideoGenerationRequestParams = z.infer<typeof VideoGenerationRequestParamsSchema>;
|
|
34
40
|
|
|
35
41
|
export const VideoModelPricingRuleConditionSchema = z.object({
|
|
36
|
-
aspectRatio: z.string(),
|
|
42
|
+
aspectRatio: z.string().optional(),
|
|
43
|
+
resolution: z.string().optional(),
|
|
37
44
|
});
|
|
38
45
|
export type VideoModelPricingRuleCondition = z.infer<typeof VideoModelPricingRuleConditionSchema>;
|
|
39
46
|
|
|
@@ -36,7 +36,13 @@ export function calculateVideoGenerationPrice({
|
|
|
36
36
|
params: VideoGenerationRequestParams;
|
|
37
37
|
rules: VideoModelPricingRules;
|
|
38
38
|
}) {
|
|
39
|
-
const
|
|
39
|
+
const perSecondRule = rules
|
|
40
|
+
.filter((r) => r.type === VIDEO_PRICING_RULE_TYPE.PER_SECOND)
|
|
41
|
+
.find((r) => matchesCondition(r.condition, params));
|
|
42
|
+
|
|
43
|
+
const effectivePricePerSecond = perSecondRule ? perSecondRule.value : pricePerSecond;
|
|
44
|
+
|
|
45
|
+
const base = effectivePricePerSecond * params.duration;
|
|
40
46
|
|
|
41
47
|
const flatMarkup = rules.reduce((sum, r) => {
|
|
42
48
|
if (r.type !== VIDEO_PRICING_RULE_TYPE.FLAT) {
|