@shotstack/schemas 1.4.0 → 1.4.2

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/README.md CHANGED
@@ -1,89 +1,89 @@
1
- # @shotstack/schemas
2
-
3
- Centralized OpenAPI schemas and TypeScript types for the Shotstack API.
4
-
5
- ## Installation
6
-
7
- ```bash
8
- npm install @shotstack/schemas zod
9
- ```
10
-
11
- ## Usage
12
-
13
- ### TypeScript Types
14
-
15
- ```typescript
16
- import type { components } from '@shotstack/schemas';
17
-
18
- type Edit = components['schemas']['Edit'];
19
- type Timeline = components['schemas']['Timeline'];
20
- type Clip = components['schemas']['Clip'];
21
- type Output = components['schemas']['Output'];
22
- ```
23
-
24
- ### Zod Schemas
25
-
26
- ```typescript
27
- import { z } from 'zod';
28
- import { richTextAssetSchema, editSchema, timelineSchema } from '@shotstack/schemas/zod';
29
-
30
- const result = richTextAssetSchema.safeParse(inputData);
31
- if (result.success) {
32
- console.log(result.data);
33
- }
34
- ```
35
-
36
- ### Extending Schemas
37
-
38
- ```typescript
39
- import { z } from 'zod';
40
- import { richTextAssetSchema } from '@shotstack/schemas/zod';
41
-
42
- const ExtendedAsset = richTextAssetSchema.extend({
43
- customFonts: z.array(z.object({
44
- src: z.string().url(),
45
- family: z.string(),
46
- })).optional(),
47
- border: z.object({
48
- width: z.number().min(0),
49
- color: z.string(),
50
- }).optional(),
51
- });
52
-
53
- type ExtendedAssetType = z.infer<typeof ExtendedAsset>;
54
- ```
55
-
56
- ### Custom Validation
57
-
58
- ```typescript
59
- import { richTextAnimationSchema } from '@shotstack/schemas/zod';
60
-
61
- const AnimationWithDirection = richTextAnimationSchema.refine(
62
- (data) => {
63
- if (data.preset === 'slideIn' && !data.direction) {
64
- return false;
65
- }
66
- return true;
67
- },
68
- { message: 'direction is required for slideIn preset' }
69
- );
70
- ```
71
-
72
- ## Available Schemas
73
-
74
- - Edit, Timeline, Track, Clip, Output
75
- - Assets: VideoAsset, ImageAsset, AudioAsset, HtmlAsset, TextAsset, TitleAsset, LumaAsset, CaptionAsset, ShapeAsset, RichTextAsset
76
- - Destinations: ShotstackDestination, S3Destination, MuxDestination, VimeoDestination, GoogleDriveDestination, GoogleCloudStorageDestination
77
- - Transforms, Transitions, Fonts, MergeFields, and more
78
-
79
- ## Development
80
-
81
- ```bash
82
- pnpm install
83
- pnpm run build
84
- pnpm run test
85
- ```
86
-
87
- ## License
88
-
89
- MIT
1
+ # @shotstack/schemas
2
+
3
+ Centralized OpenAPI schemas and TypeScript types for the Shotstack API.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @shotstack/schemas zod
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ### TypeScript Types
14
+
15
+ ```typescript
16
+ import type { components } from '@shotstack/schemas';
17
+
18
+ type Edit = components['schemas']['Edit'];
19
+ type Timeline = components['schemas']['Timeline'];
20
+ type Clip = components['schemas']['Clip'];
21
+ type Output = components['schemas']['Output'];
22
+ ```
23
+
24
+ ### Zod Schemas
25
+
26
+ ```typescript
27
+ import { z } from 'zod';
28
+ import { richTextAssetSchema, editSchema, timelineSchema } from '@shotstack/schemas/zod';
29
+
30
+ const result = richTextAssetSchema.safeParse(inputData);
31
+ if (result.success) {
32
+ console.log(result.data);
33
+ }
34
+ ```
35
+
36
+ ### Extending Schemas
37
+
38
+ ```typescript
39
+ import { z } from 'zod';
40
+ import { richTextAssetSchema } from '@shotstack/schemas/zod';
41
+
42
+ const ExtendedAsset = richTextAssetSchema.extend({
43
+ customFonts: z.array(z.object({
44
+ src: z.string().url(),
45
+ family: z.string(),
46
+ })).optional(),
47
+ border: z.object({
48
+ width: z.number().min(0),
49
+ color: z.string(),
50
+ }).optional(),
51
+ });
52
+
53
+ type ExtendedAssetType = z.infer<typeof ExtendedAsset>;
54
+ ```
55
+
56
+ ### Custom Validation
57
+
58
+ ```typescript
59
+ import { richTextAnimationSchema } from '@shotstack/schemas/zod';
60
+
61
+ const AnimationWithDirection = richTextAnimationSchema.refine(
62
+ (data) => {
63
+ if (data.preset === 'slideIn' && !data.direction) {
64
+ return false;
65
+ }
66
+ return true;
67
+ },
68
+ { message: 'direction is required for slideIn preset' }
69
+ );
70
+ ```
71
+
72
+ ## Available Schemas
73
+
74
+ - Edit, Timeline, Track, Clip, Output
75
+ - Assets: VideoAsset, ImageAsset, AudioAsset, HtmlAsset, TextAsset, TitleAsset, LumaAsset, CaptionAsset, ShapeAsset, RichTextAsset
76
+ - Destinations: ShotstackDestination, S3Destination, MuxDestination, VimeoDestination, GoogleDriveDestination, GoogleCloudStorageDestination
77
+ - Transforms, Transitions, Fonts, MergeFields, and more
78
+
79
+ ## Development
80
+
81
+ ```bash
82
+ pnpm install
83
+ pnpm run build
84
+ pnpm run test
85
+ ```
86
+
87
+ ## License
88
+
89
+ MIT
@@ -1062,9 +1062,22 @@
1062
1062
  "type": "string"
1063
1063
  },
1064
1064
  "scale": {
1065
- "description": "Scale the asset to a fraction of the viewport size - i.e. setting the scale to 0.5 will scale asset to half the size of the viewport. This is useful for picture-in-picture video and scaling images such as logos and watermarks.",
1066
- "type": "number",
1067
- "example": 0
1065
+ "description": "Scale the asset to a fraction of the viewport size - i.e. setting the scale to 0.5 will scale asset to half the size of the viewport. This is useful for picture-in-picture video and scaling images such as logos and watermarks. Use a number or an array of [Tween](./#tocs_tween) objects to create a custom animation.",
1066
+ "oneOf": [
1067
+ {
1068
+ "type": "number",
1069
+ "description": "Scale the asset to a fraction of the viewport size. For example, 0.5 will scale the asset to half the size of the viewport.",
1070
+ "format": "float",
1071
+ "example": 0.5
1072
+ },
1073
+ {
1074
+ "type": "array",
1075
+ "description": "An array of [Tween](./#tocs_tween) objects used to create a custom animation. Animate the scale of an asset over time.",
1076
+ "items": {
1077
+ "$ref": "#/components/schemas/Tween"
1078
+ }
1079
+ }
1080
+ ]
1068
1081
  },
1069
1082
  "width": {
1070
1083
  "description": "Set the width of the clip bounding box in pixels. This constrains the width of the clip, overriding the default behavior where clips fill the viewport width.",
package/dist/schema.d.ts CHANGED
@@ -512,11 +512,8 @@ export interface components {
512
512
  * @enum {string}
513
513
  */
514
514
  fit?: "cover" | "contain" | "crop" | "none";
515
- /**
516
- * @description Scale the asset to a fraction of the viewport size - i.e. setting the scale to 0.5 will scale asset to half the size of the viewport. This is useful for picture-in-picture video and scaling images such as logos and watermarks.
517
- * @example 0
518
- */
519
- scale?: number;
515
+ /** @description Scale the asset to a fraction of the viewport size - i.e. setting the scale to 0.5 will scale asset to half the size of the viewport. This is useful for picture-in-picture video and scaling images such as logos and watermarks. Use a number or an array of [Tween](./#tocs_tween) objects to create a custom animation. */
516
+ scale?: number | components["schemas"]["Tween"][];
520
517
  /**
521
518
  * @description Set the width of the clip bounding box in pixels. This constrains the width of the clip, overriding the default behavior where clips fill the viewport width.
522
519
  * @example 800