@purpleschool/gptbot 0.8.6 → 0.8.7

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.
@@ -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 = {}));
@@ -17,7 +17,11 @@ function matchesCondition(condition, params) {
17
17
  });
18
18
  }
19
19
  function calculateVideoGenerationPrice({ pricePerSecond, params, rules, }) {
20
- const base = pricePerSecond * params.duration;
20
+ const perSecondRule = rules
21
+ .filter((r) => r.type === constants_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 !== constants_1.VIDEO_PRICING_RULE_TYPE.FLAT) {
23
27
  return sum;
@@ -20,15 +20,22 @@ exports.VideoModelParamsSchema = zod_1.z.object({
20
20
  })
21
21
  .optional(),
22
22
  quality: zod_1.z.string().optional(),
23
+ resolution: zod_1.z
24
+ .object({
25
+ options: zod_1.z.array(zod_1.z.string()),
26
+ })
27
+ .optional(),
23
28
  });
24
29
  exports.VideoGenerationRequestParamsSchema = zod_1.z.object({
25
30
  imageUrls: zod_1.z.string().array().optional(),
26
31
  duration: zod_1.z.number(),
27
32
  aspectRatio: zod_1.z.string().optional(),
28
33
  quality: zod_1.z.string().optional(),
34
+ resolution: zod_1.z.string().optional(),
29
35
  });
30
36
  exports.VideoModelPricingRuleConditionSchema = zod_1.z.object({
31
- aspectRatio: zod_1.z.string(),
37
+ aspectRatio: zod_1.z.string().optional(),
38
+ resolution: zod_1.z.string().optional(),
32
39
  });
33
40
  exports.VideoModelPricingRulesSchema = zod_1.z.array(zod_1.z.object({
34
41
  type: zod_1.z.nativeEnum(constants_1.VIDEO_PRICING_RULE_TYPE),
@@ -1,3 +1,4 @@
1
1
  export enum VIDEO_PRICING_RULE_TYPE {
2
2
  FLAT = 'flat',
3
+ PER_SECOND = 'per_second',
3
4
  }
@@ -36,7 +36,13 @@ export function calculateVideoGenerationPrice({
36
36
  params: VideoGenerationRequestParams;
37
37
  rules: VideoModelPricingRules;
38
38
  }) {
39
- const base = pricePerSecond * params.duration;
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) {
@@ -18,6 +18,11 @@ export const VideoModelParamsSchema = z.object({
18
18
  })
19
19
  .optional(),
20
20
  quality: z.string().optional(),
21
+ resolution: z
22
+ .object({
23
+ options: z.array(z.string()),
24
+ })
25
+ .optional(),
21
26
  });
22
27
 
23
28
  export const VideoGenerationRequestParamsSchema = z.object({
@@ -25,11 +30,13 @@ export const VideoGenerationRequestParamsSchema = z.object({
25
30
  duration: z.number(),
26
31
  aspectRatio: z.string().optional(),
27
32
  quality: z.string().optional(),
33
+ resolution: z.string().optional(),
28
34
  });
29
35
  export type VideoGenerationRequestParams = z.infer<typeof VideoGenerationRequestParamsSchema>;
30
36
 
31
37
  export const VideoModelPricingRuleConditionSchema = z.object({
32
- aspectRatio: z.string(),
38
+ aspectRatio: z.string().optional(),
39
+ resolution: z.string().optional(),
33
40
  });
34
41
  export type VideoModelPricingRuleCondition = z.infer<typeof VideoModelPricingRuleConditionSchema>;
35
42
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@purpleschool/gptbot",
3
- "version": "0.8.6",
3
+ "version": "0.8.7",
4
4
  "description": "",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",