@shotstack/schemas 1.4.0 → 1.4.1

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