@shotstack/schemas 1.3.2 → 1.3.4

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.
@@ -61,13 +61,13 @@ export const captionMarginSchema = captionpropertiesCaptionMarginSchema;
61
61
  *
62
62
  */
63
63
  export const captionassetCaptionAssetSchema = z.object({
64
- type: z.string().default("caption"),
64
+ type: z.enum(["caption"]),
65
65
  src: z.string(),
66
66
  font: z.optional(captionpropertiesCaptionFontSchema),
67
67
  background: z.optional(captionpropertiesCaptionBackgroundSchema),
68
68
  margin: z.optional(captionpropertiesCaptionMarginSchema),
69
- trim: z.optional(z.number()),
70
- speed: z.optional(z.number().gte(0).lte(10)),
69
+ trim: z.optional(z.preprocess((val) => typeof val === 'string' && val !== '' && !isNaN(Number(val)) ? Number(val) : val, z.number())),
70
+ speed: z.optional(z.preprocess((val) => typeof val === 'string' && val !== '' && !isNaN(Number(val)) ? Number(val) : val, z.number().gte(0).lte(10))),
71
71
  });
72
72
  export const captionAssetSchema = captionassetCaptionAssetSchema;
73
73
  /**
@@ -828,7 +828,7 @@ export const fontSchema = fontFontSchema;
828
828
  * @deprecated
829
829
  */
830
830
  export const htmlassetHtmlAssetSchema = z.object({
831
- type: z.string().default("html"),
831
+ type: z.enum(["html"]),
832
832
  html: z.string(),
833
833
  css: z.optional(z.string()),
834
834
  width: z.optional(z.int()),
@@ -851,7 +851,7 @@ export const htmlAssetSchema = htmlassetHtmlAssetSchema;
851
851
  * The ImageAsset is used to create video from images to compose an image. The src must be a publicly accessible URL to an image resource such as a jpg or png file.
852
852
  */
853
853
  export const imageassetImageAssetSchema = z.object({
854
- type: z.string().default("image"),
854
+ type: z.enum(["image"]),
855
855
  src: z.string(),
856
856
  crop: z.optional(cropCropSchema),
857
857
  });
@@ -864,7 +864,7 @@ export const imagetovideoassetImageToVideoAssetSchema = z.object({
864
864
  src: z.optional(z.string()),
865
865
  prompt: z.optional(z.string()),
866
866
  aspectRatio: z.optional(z.enum(["1:1", "4:3", "16:9", "9:16", "3:4", "21:9", "9:21"])),
867
- speed: z.optional(z.number().gte(0).lte(10)),
867
+ speed: z.optional(z.preprocess((val) => typeof val === 'string' && val !== '' && !isNaN(Number(val)) ? Number(val) : val, z.number().gte(0).lte(10))),
868
868
  crop: z.optional(cropCropSchema),
869
869
  });
870
870
  export const imageToVideoAssetSchema = imagetovideoassetImageToVideoAssetSchema;
@@ -972,7 +972,7 @@ export const uploadResponseSchema = uploadresponseUploadResponseSchema;
972
972
  * Set the playback speed of a video or audio file. Allows you to preserve the pitch of the audio so that it is sped up without sounding too high pitched or too low.
973
973
  */
974
974
  export const speedSpeedSchema = z.object({
975
- speed: z.optional(z.number().gte(0).lte(10)),
975
+ speed: z.optional(z.preprocess((val) => typeof val === 'string' && val !== '' && !isNaN(Number(val)) ? Number(val) : val, z.number().gte(0).lte(10))),
976
976
  preservePitch: z.optional(z.boolean()),
977
977
  });
978
978
  export const speedSchema = speedSpeedSchema;
@@ -987,9 +987,9 @@ export const transcriptionSchema = transcriptionTranscriptionSchema;
987
987
  * The LumaAsset is used to create luma matte masks, transitions and effects between other assets. A luma matte is a grey scale image or animated video where the black areas are transparent and the white areas solid. The luma matte animation should be provided as an mp4 video file. The src must be a publicly accessible URL to the file.
988
988
  */
989
989
  export const lumaassetLumaAssetSchema = z.object({
990
- type: z.string().default("luma"),
990
+ type: z.enum(["luma"]),
991
991
  src: z.string(),
992
- trim: z.optional(z.number()),
992
+ trim: z.optional(z.preprocess((val) => typeof val === 'string' && val !== '' && !isNaN(Number(val)) ? Number(val) : val, z.number())),
993
993
  });
994
994
  export const lumaAssetSchema = lumaassetLumaAssetSchema;
995
995
  /**
@@ -1240,7 +1240,7 @@ export const richTextStyleSchema = richtextpropertiesRichTextStyleSchema;
1240
1240
  *
1241
1241
  */
1242
1242
  export const richtextassetRichTextAssetSchema = z.object({
1243
- type: z.string().default("rich-text"),
1243
+ type: z.enum(["rich-text"]),
1244
1244
  text: z.string().max(5000),
1245
1245
  font: z.optional(richtextpropertiesRichTextFontSchema),
1246
1246
  style: z.optional(richtextpropertiesRichTextStyleSchema),
@@ -1292,7 +1292,7 @@ export const transferSchema = transferTransferSchema;
1292
1292
  *
1293
1293
  */
1294
1294
  export const shapeassetShapeAssetSchema = z.object({
1295
- type: z.string().default("shape"),
1295
+ type: z.enum(["shape"]),
1296
1296
  shape: z.enum(["rectangle", "circle", "line"]),
1297
1297
  width: z.optional(z.int()),
1298
1298
  height: z.optional(z.int()),
@@ -1528,7 +1528,7 @@ export const textpropertiesTextStrokeSchema = z.object({
1528
1528
  *
1529
1529
  */
1530
1530
  export const textassetTextAssetSchema = z.object({
1531
- type: z.string().default("text"),
1531
+ type: z.enum(["text"]),
1532
1532
  text: z.string(),
1533
1533
  width: z.optional(z.int()),
1534
1534
  height: z.optional(z.int()),
@@ -1546,8 +1546,8 @@ export const textAssetSchema = textassetTextAssetSchema;
1546
1546
  export const texttoimageassetTextToImageAssetSchema = z.object({
1547
1547
  type: z.enum(["text-to-image"]),
1548
1548
  prompt: z.string(),
1549
- width: z.int(),
1550
- height: z.int(),
1549
+ width: z.optional(z.int()),
1550
+ height: z.optional(z.int()),
1551
1551
  crop: z.optional(cropCropSchema),
1552
1552
  });
1553
1553
  export const textToImageAssetSchema = texttoimageassetTextToImageAssetSchema;
@@ -1776,11 +1776,11 @@ export const tweenSchema = tweenTweenSchema;
1776
1776
  * The AudioAsset is used to add sound effects and audio at specific intervals on the timeline. The src must be a publicly accessible URL to an audio resource such as an mp3 file.
1777
1777
  */
1778
1778
  export const audioassetAudioAssetSchema = z.object({
1779
- type: z.string().default("audio"),
1779
+ type: z.enum(["audio"]),
1780
1780
  src: z.string(),
1781
- trim: z.optional(z.number()),
1781
+ trim: z.optional(z.preprocess((val) => typeof val === 'string' && val !== '' && !isNaN(Number(val)) ? Number(val) : val, z.number())),
1782
1782
  volume: z.optional(z.union([z.number().gte(0).lte(1), z.array(tweenTweenSchema)])),
1783
- speed: z.optional(z.number().gte(0).lte(10)),
1783
+ speed: z.optional(z.preprocess((val) => typeof val === 'string' && val !== '' && !isNaN(Number(val)) ? Number(val) : val, z.number().gte(0).lte(10))),
1784
1784
  effect: z.optional(z.enum(["none", "fadeIn", "fadeOut", "fadeInFadeOut"])),
1785
1785
  });
1786
1786
  export const audioAssetSchema = audioassetAudioAssetSchema;
@@ -1816,7 +1816,7 @@ export const skewTransformationSchema = skewtransformationSkewTransformationSche
1816
1816
  * @deprecated
1817
1817
  */
1818
1818
  export const titleassetTitleAssetSchema = z.object({
1819
- type: z.string().default("title"),
1819
+ type: z.enum(["title"]),
1820
1820
  text: z.string(),
1821
1821
  style: z.optional(z.enum([
1822
1822
  "minimal",
@@ -1868,13 +1868,13 @@ export const transformationSchema = transformationTransformationSchema;
1868
1868
  * The VideoAsset is used to create video sequences from video files. The src must be a publicly accessible URL to a video resource such as an mp4 file.
1869
1869
  */
1870
1870
  export const videoassetVideoAssetSchema = z.object({
1871
- type: z.string().default("video"),
1871
+ type: z.enum(["video"]),
1872
1872
  src: z.string(),
1873
1873
  transcode: z.optional(z.boolean()).default(false),
1874
- trim: z.optional(z.number()),
1874
+ trim: z.optional(z.preprocess((val) => typeof val === 'string' && val !== '' && !isNaN(Number(val)) ? Number(val) : val, z.number())),
1875
1875
  volume: z.optional(z.union([z.number().gte(0).lte(1), z.array(tweenTweenSchema)])),
1876
1876
  volumeEffect: z.optional(z.enum(["none", "fadeIn", "fadeOut", "fadeInFadeOut"])),
1877
- speed: z.optional(z.number().gte(0).lte(10)),
1877
+ speed: z.optional(z.preprocess((val) => typeof val === 'string' && val !== '' && !isNaN(Number(val)) ? Number(val) : val, z.number().gte(0).lte(10))),
1878
1878
  crop: z.optional(cropCropSchema),
1879
1879
  chromaKey: z.optional(chromakeyChromaKeySchema),
1880
1880
  });
@@ -1882,67 +1882,19 @@ export const videoAssetSchema = videoassetVideoAssetSchema;
1882
1882
  /**
1883
1883
  * The type of asset to display for the duration of the Clip, i.e. a video clip or an image. Choose from one of the available asset types below.
1884
1884
  */
1885
- export const assetAssetSchema = z.union([
1886
- z
1887
- .object({
1888
- asset: z.literal("videoasset_VideoAsset"),
1889
- })
1890
- .and(videoassetVideoAssetSchema),
1891
- z
1892
- .object({
1893
- asset: z.literal("imageasset_ImageAsset"),
1894
- })
1895
- .and(imageassetImageAssetSchema),
1896
- z
1897
- .object({
1898
- asset: z.literal("textasset_TextAsset"),
1899
- })
1900
- .and(textassetTextAssetSchema),
1901
- z
1902
- .object({
1903
- asset: z.literal("richtextasset_RichTextAsset"),
1904
- })
1905
- .and(richtextassetRichTextAssetSchema),
1906
- z
1907
- .object({
1908
- asset: z.literal("audioasset_AudioAsset"),
1909
- })
1910
- .and(audioassetAudioAssetSchema),
1911
- z
1912
- .object({
1913
- asset: z.literal("lumaasset_LumaAsset"),
1914
- })
1915
- .and(lumaassetLumaAssetSchema),
1916
- z
1917
- .object({
1918
- asset: z.literal("captionasset_CaptionAsset"),
1919
- })
1920
- .and(captionassetCaptionAssetSchema),
1921
- z
1922
- .object({
1923
- asset: z.literal("htmlasset_HtmlAsset"),
1924
- })
1925
- .and(htmlassetHtmlAssetSchema),
1926
- z
1927
- .object({
1928
- asset: z.literal("titleasset_TitleAsset"),
1929
- })
1930
- .and(titleassetTitleAssetSchema),
1931
- z
1932
- .object({
1933
- asset: z.literal("shapeasset_ShapeAsset"),
1934
- })
1935
- .and(shapeassetShapeAssetSchema),
1936
- z
1937
- .object({
1938
- asset: z.literal("texttoimageasset_TextToImageAsset"),
1939
- })
1940
- .and(texttoimageassetTextToImageAssetSchema),
1941
- z
1942
- .object({
1943
- asset: z.literal("imagetovideoasset_ImageToVideoAsset"),
1944
- })
1945
- .and(imagetovideoassetImageToVideoAssetSchema),
1885
+ export const assetAssetSchema = z.discriminatedUnion("type", [
1886
+ videoassetVideoAssetSchema,
1887
+ imageassetImageAssetSchema,
1888
+ textassetTextAssetSchema,
1889
+ richtextassetRichTextAssetSchema,
1890
+ audioassetAudioAssetSchema,
1891
+ lumaassetLumaAssetSchema,
1892
+ captionassetCaptionAssetSchema,
1893
+ htmlassetHtmlAssetSchema,
1894
+ titleassetTitleAssetSchema,
1895
+ shapeassetShapeAssetSchema,
1896
+ texttoimageassetTextToImageAssetSchema,
1897
+ imagetovideoassetImageToVideoAssetSchema,
1946
1898
  ]);
1947
1899
  export const assetSchema = assetAssetSchema;
1948
1900
  /**
@@ -1950,10 +1902,10 @@ export const assetSchema = assetAssetSchema;
1950
1902
  */
1951
1903
  export const clipClipSchema = z.object({
1952
1904
  asset: assetAssetSchema,
1953
- start: z.union([z.number(), z.enum(["auto"])]),
1954
- length: z.union([z.number(), z.literal("auto"), z.literal("end")]),
1905
+ start: z.union([z.preprocess((val) => typeof val === 'string' && val !== '' && !isNaN(Number(val)) ? Number(val) : val, z.number()), z.enum(["auto"])]),
1906
+ length: z.union([z.preprocess((val) => typeof val === 'string' && val !== '' && !isNaN(Number(val)) ? Number(val) : val, z.number()), z.literal("auto"), z.literal("end")]),
1955
1907
  fit: z.optional(z.enum(["cover", "contain", "crop", "none"])),
1956
- scale: z.optional(z.number()),
1908
+ scale: z.optional(z.preprocess((val) => typeof val === 'string' && val !== '' && !isNaN(Number(val)) ? Number(val) : val, z.number())),
1957
1909
  width: z.optional(z.int().gte(1).lte(3840)),
1958
1910
  height: z.optional(z.int().gte(1).lte(2160)),
1959
1911
  position: z.optional(z.enum([
@@ -1990,6 +1942,7 @@ export const clipClipSchema = z.object({
1990
1942
  "slideDownFast",
1991
1943
  ])),
1992
1944
  filter: z.optional(z.enum([
1945
+ "none",
1993
1946
  "blur",
1994
1947
  "boost",
1995
1948
  "contrast",
@@ -85,13 +85,13 @@ export const captionMarginSchema = captionpropertiesCaptionMarginSchema;
85
85
  *
86
86
  */
87
87
  export const captionassetCaptionAssetSchema = z.object({
88
- type: z.string().default("caption"),
88
+ type: z.enum(["caption"]),
89
89
  src: z.string(),
90
90
  font: z.optional(captionpropertiesCaptionFontSchema),
91
91
  background: z.optional(captionpropertiesCaptionBackgroundSchema),
92
92
  margin: z.optional(captionpropertiesCaptionMarginSchema),
93
- trim: z.optional(z.number()),
94
- speed: z.optional(z.number().gte(0).lte(10)),
93
+ trim: z.optional(z.preprocess((val) => typeof val === 'string' && val !== '' && !isNaN(Number(val)) ? Number(val) : val, z.number())),
94
+ speed: z.optional(z.preprocess((val) => typeof val === 'string' && val !== '' && !isNaN(Number(val)) ? Number(val) : val, z.number().gte(0).lte(10))),
95
95
  });
96
96
 
97
97
  export const captionAssetSchema = captionassetCaptionAssetSchema;
@@ -1037,7 +1037,7 @@ export const fontSchema = fontFontSchema;
1037
1037
  * @deprecated
1038
1038
  */
1039
1039
  export const htmlassetHtmlAssetSchema = z.object({
1040
- type: z.string().default("html"),
1040
+ type: z.enum(["html"]),
1041
1041
  html: z.string(),
1042
1042
  css: z.optional(z.string()),
1043
1043
  width: z.optional(z.int()),
@@ -1064,7 +1064,7 @@ export const htmlAssetSchema = htmlassetHtmlAssetSchema;
1064
1064
  * The ImageAsset is used to create video from images to compose an image. The src must be a publicly accessible URL to an image resource such as a jpg or png file.
1065
1065
  */
1066
1066
  export const imageassetImageAssetSchema = z.object({
1067
- type: z.string().default("image"),
1067
+ type: z.enum(["image"]),
1068
1068
  src: z.string(),
1069
1069
  crop: z.optional(cropCropSchema),
1070
1070
  });
@@ -1081,7 +1081,7 @@ export const imagetovideoassetImageToVideoAssetSchema = z.object({
1081
1081
  aspectRatio: z.optional(
1082
1082
  z.enum(["1:1", "4:3", "16:9", "9:16", "3:4", "21:9", "9:21"])
1083
1083
  ),
1084
- speed: z.optional(z.number().gte(0).lte(10)),
1084
+ speed: z.optional(z.preprocess((val) => typeof val === 'string' && val !== '' && !isNaN(Number(val)) ? Number(val) : val, z.number().gte(0).lte(10))),
1085
1085
  crop: z.optional(cropCropSchema),
1086
1086
  });
1087
1087
 
@@ -1220,7 +1220,7 @@ export const uploadResponseSchema = uploadresponseUploadResponseSchema;
1220
1220
  * Set the playback speed of a video or audio file. Allows you to preserve the pitch of the audio so that it is sped up without sounding too high pitched or too low.
1221
1221
  */
1222
1222
  export const speedSpeedSchema = z.object({
1223
- speed: z.optional(z.number().gte(0).lte(10)),
1223
+ speed: z.optional(z.preprocess((val) => typeof val === 'string' && val !== '' && !isNaN(Number(val)) ? Number(val) : val, z.number().gte(0).lte(10))),
1224
1224
  preservePitch: z.optional(z.boolean()),
1225
1225
  });
1226
1226
 
@@ -1239,9 +1239,9 @@ export const transcriptionSchema = transcriptionTranscriptionSchema;
1239
1239
  * The LumaAsset is used to create luma matte masks, transitions and effects between other assets. A luma matte is a grey scale image or animated video where the black areas are transparent and the white areas solid. The luma matte animation should be provided as an mp4 video file. The src must be a publicly accessible URL to the file.
1240
1240
  */
1241
1241
  export const lumaassetLumaAssetSchema = z.object({
1242
- type: z.string().default("luma"),
1242
+ type: z.enum(["luma"]),
1243
1243
  src: z.string(),
1244
- trim: z.optional(z.number()),
1244
+ trim: z.optional(z.preprocess((val) => typeof val === 'string' && val !== '' && !isNaN(Number(val)) ? Number(val) : val, z.number())),
1245
1245
  });
1246
1246
 
1247
1247
  export const lumaAssetSchema = lumaassetLumaAssetSchema;
@@ -1556,7 +1556,7 @@ export const richTextStyleSchema = richtextpropertiesRichTextStyleSchema;
1556
1556
  *
1557
1557
  */
1558
1558
  export const richtextassetRichTextAssetSchema = z.object({
1559
- type: z.string().default("rich-text"),
1559
+ type: z.enum(["rich-text"]),
1560
1560
  text: z.string().max(5000),
1561
1561
  font: z.optional(richtextpropertiesRichTextFontSchema),
1562
1562
  style: z.optional(richtextpropertiesRichTextStyleSchema),
@@ -1625,7 +1625,7 @@ export const transferSchema = transferTransferSchema;
1625
1625
  *
1626
1626
  */
1627
1627
  export const shapeassetShapeAssetSchema = z.object({
1628
- type: z.string().default("shape"),
1628
+ type: z.enum(["shape"]),
1629
1629
  shape: z.enum(["rectangle", "circle", "line"]),
1630
1630
  width: z.optional(z.int()),
1631
1631
  height: z.optional(z.int()),
@@ -1920,7 +1920,7 @@ export const textpropertiesTextStrokeSchema = z.object({
1920
1920
  *
1921
1921
  */
1922
1922
  export const textassetTextAssetSchema = z.object({
1923
- type: z.string().default("text"),
1923
+ type: z.enum(["text"]),
1924
1924
  text: z.string(),
1925
1925
  width: z.optional(z.int()),
1926
1926
  height: z.optional(z.int()),
@@ -1940,8 +1940,8 @@ export const textAssetSchema = textassetTextAssetSchema;
1940
1940
  export const texttoimageassetTextToImageAssetSchema = z.object({
1941
1941
  type: z.enum(["text-to-image"]),
1942
1942
  prompt: z.string(),
1943
- width: z.int(),
1944
- height: z.int(),
1943
+ width: z.optional(z.int()),
1944
+ height: z.optional(z.int()),
1945
1945
  crop: z.optional(cropCropSchema),
1946
1946
  });
1947
1947
 
@@ -2190,13 +2190,13 @@ export const tweenSchema = tweenTweenSchema;
2190
2190
  * The AudioAsset is used to add sound effects and audio at specific intervals on the timeline. The src must be a publicly accessible URL to an audio resource such as an mp3 file.
2191
2191
  */
2192
2192
  export const audioassetAudioAssetSchema = z.object({
2193
- type: z.string().default("audio"),
2193
+ type: z.enum(["audio"]),
2194
2194
  src: z.string(),
2195
- trim: z.optional(z.number()),
2195
+ trim: z.optional(z.preprocess((val) => typeof val === 'string' && val !== '' && !isNaN(Number(val)) ? Number(val) : val, z.number())),
2196
2196
  volume: z.optional(
2197
2197
  z.union([z.number().gte(0).lte(1), z.array(tweenTweenSchema)])
2198
2198
  ),
2199
- speed: z.optional(z.number().gte(0).lte(10)),
2199
+ speed: z.optional(z.preprocess((val) => typeof val === 'string' && val !== '' && !isNaN(Number(val)) ? Number(val) : val, z.number().gte(0).lte(10))),
2200
2200
  effect: z.optional(z.enum(["none", "fadeIn", "fadeOut", "fadeInFadeOut"])),
2201
2201
  });
2202
2202
 
@@ -2252,7 +2252,7 @@ export const skewTransformationSchema =
2252
2252
  * @deprecated
2253
2253
  */
2254
2254
  export const titleassetTitleAssetSchema = z.object({
2255
- type: z.string().default("title"),
2255
+ type: z.enum(["title"]),
2256
2256
  text: z.string(),
2257
2257
  style: z.optional(
2258
2258
  z.enum([
@@ -2314,17 +2314,17 @@ export const transformationSchema = transformationTransformationSchema;
2314
2314
  * The VideoAsset is used to create video sequences from video files. The src must be a publicly accessible URL to a video resource such as an mp4 file.
2315
2315
  */
2316
2316
  export const videoassetVideoAssetSchema = z.object({
2317
- type: z.string().default("video"),
2317
+ type: z.enum(["video"]),
2318
2318
  src: z.string(),
2319
2319
  transcode: z.optional(z.boolean()).default(false),
2320
- trim: z.optional(z.number()),
2320
+ trim: z.optional(z.preprocess((val) => typeof val === 'string' && val !== '' && !isNaN(Number(val)) ? Number(val) : val, z.number())),
2321
2321
  volume: z.optional(
2322
2322
  z.union([z.number().gte(0).lte(1), z.array(tweenTweenSchema)])
2323
2323
  ),
2324
2324
  volumeEffect: z.optional(
2325
2325
  z.enum(["none", "fadeIn", "fadeOut", "fadeInFadeOut"])
2326
2326
  ),
2327
- speed: z.optional(z.number().gte(0).lte(10)),
2327
+ speed: z.optional(z.preprocess((val) => typeof val === 'string' && val !== '' && !isNaN(Number(val)) ? Number(val) : val, z.number().gte(0).lte(10))),
2328
2328
  crop: z.optional(cropCropSchema),
2329
2329
  chromaKey: z.optional(chromakeyChromaKeySchema),
2330
2330
  });
@@ -2334,67 +2334,19 @@ export const videoAssetSchema = videoassetVideoAssetSchema;
2334
2334
  /**
2335
2335
  * The type of asset to display for the duration of the Clip, i.e. a video clip or an image. Choose from one of the available asset types below.
2336
2336
  */
2337
- export const assetAssetSchema = z.union([
2338
- z
2339
- .object({
2340
- asset: z.literal("videoasset_VideoAsset"),
2341
- })
2342
- .and(videoassetVideoAssetSchema),
2343
- z
2344
- .object({
2345
- asset: z.literal("imageasset_ImageAsset"),
2346
- })
2347
- .and(imageassetImageAssetSchema),
2348
- z
2349
- .object({
2350
- asset: z.literal("textasset_TextAsset"),
2351
- })
2352
- .and(textassetTextAssetSchema),
2353
- z
2354
- .object({
2355
- asset: z.literal("richtextasset_RichTextAsset"),
2356
- })
2357
- .and(richtextassetRichTextAssetSchema),
2358
- z
2359
- .object({
2360
- asset: z.literal("audioasset_AudioAsset"),
2361
- })
2362
- .and(audioassetAudioAssetSchema),
2363
- z
2364
- .object({
2365
- asset: z.literal("lumaasset_LumaAsset"),
2366
- })
2367
- .and(lumaassetLumaAssetSchema),
2368
- z
2369
- .object({
2370
- asset: z.literal("captionasset_CaptionAsset"),
2371
- })
2372
- .and(captionassetCaptionAssetSchema),
2373
- z
2374
- .object({
2375
- asset: z.literal("htmlasset_HtmlAsset"),
2376
- })
2377
- .and(htmlassetHtmlAssetSchema),
2378
- z
2379
- .object({
2380
- asset: z.literal("titleasset_TitleAsset"),
2381
- })
2382
- .and(titleassetTitleAssetSchema),
2383
- z
2384
- .object({
2385
- asset: z.literal("shapeasset_ShapeAsset"),
2386
- })
2387
- .and(shapeassetShapeAssetSchema),
2388
- z
2389
- .object({
2390
- asset: z.literal("texttoimageasset_TextToImageAsset"),
2391
- })
2392
- .and(texttoimageassetTextToImageAssetSchema),
2393
- z
2394
- .object({
2395
- asset: z.literal("imagetovideoasset_ImageToVideoAsset"),
2396
- })
2397
- .and(imagetovideoassetImageToVideoAssetSchema),
2337
+ export const assetAssetSchema = z.discriminatedUnion("type", [
2338
+ videoassetVideoAssetSchema,
2339
+ imageassetImageAssetSchema,
2340
+ textassetTextAssetSchema,
2341
+ richtextassetRichTextAssetSchema,
2342
+ audioassetAudioAssetSchema,
2343
+ lumaassetLumaAssetSchema,
2344
+ captionassetCaptionAssetSchema,
2345
+ htmlassetHtmlAssetSchema,
2346
+ titleassetTitleAssetSchema,
2347
+ shapeassetShapeAssetSchema,
2348
+ texttoimageassetTextToImageAssetSchema,
2349
+ imagetovideoassetImageToVideoAssetSchema,
2398
2350
  ]);
2399
2351
 
2400
2352
  export const assetSchema = assetAssetSchema;
@@ -2404,10 +2356,10 @@ export const assetSchema = assetAssetSchema;
2404
2356
  */
2405
2357
  export const clipClipSchema = z.object({
2406
2358
  asset: assetAssetSchema,
2407
- start: z.union([z.number(), z.enum(["auto"])]),
2408
- length: z.union([z.number(), z.literal("auto"), z.literal("end")]),
2359
+ start: z.union([z.preprocess((val) => typeof val === 'string' && val !== '' && !isNaN(Number(val)) ? Number(val) : val, z.number()), z.enum(["auto"])]),
2360
+ length: z.union([z.preprocess((val) => typeof val === 'string' && val !== '' && !isNaN(Number(val)) ? Number(val) : val, z.number()), z.literal("auto"), z.literal("end")]),
2409
2361
  fit: z.optional(z.enum(["cover", "contain", "crop", "none"])),
2410
- scale: z.optional(z.number()),
2362
+ scale: z.optional(z.preprocess((val) => typeof val === 'string' && val !== '' && !isNaN(Number(val)) ? Number(val) : val, z.number())),
2411
2363
  width: z.optional(z.int().gte(1).lte(3840)),
2412
2364
  height: z.optional(z.int().gte(1).lte(2160)),
2413
2365
  position: z.optional(
@@ -2449,6 +2401,7 @@ export const clipClipSchema = z.object({
2449
2401
  ),
2450
2402
  filter: z.optional(
2451
2403
  z.enum([
2404
+ "none",
2452
2405
  "blur",
2453
2406
  "boost",
2454
2407
  "contrast",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shotstack/schemas",
3
- "version": "1.3.2",
3
+ "version": "1.3.4",
4
4
  "description": "Centralized OpenAPI schemas and TypeScript types for Shotstack API",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -28,8 +28,9 @@
28
28
  "compile:zod:cjs": "tsc --declaration false --module commonjs --moduleResolution node --target ES2022 --outDir dist/zod --skipLibCheck dist/zod/zod.gen.ts && node -e \"require('fs').renameSync('dist/zod/zod.gen.js','dist/zod/zod.gen.cjs')\"",
29
29
  "compile:zod:esm": "tsc --declaration --module nodenext --moduleResolution nodenext --target ES2022 --outDir dist/zod --skipLibCheck dist/zod/zod.gen.ts",
30
30
  "compile:zod": "npm run compile:zod:cjs && npm run compile:zod:esm",
31
+ "fix:discriminator": "node scripts/fix-discriminator.cjs",
31
32
  "copy:index": "node -e \"require('fs').writeFileSync('dist/index.d.ts','export type * from \\\"./schema\\\";');require('fs').writeFileSync('dist/index.js','// Type-only package\\nexport {};');\"",
32
- "build": "npm run clean && node -e \"require('fs').mkdirSync('dist',{recursive:true})\" && npm run bundle && npm run generate:types && npm run generate:zod && npm run compile:zod && npm run copy:index",
33
+ "build": "npm run clean && node -e \"require('fs').mkdirSync('dist',{recursive:true})\" && npm run bundle && npm run generate:types && npm run generate:zod && npm run fix:discriminator && npm run compile:zod && npm run copy:index",
33
34
  "build:docs": "cross-env ./build-docs.sh",
34
35
  "build:sdks": "cross-env ./build-sdks.sh",
35
36
  "start": "cross-env ./build-docs.sh && http-server build/docs/ -o -c-1",