@shotstack/schemas 1.0.1 → 1.1.0

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
@@ -5,11 +5,13 @@ Centralized OpenAPI schemas and TypeScript types for the Shotstack API.
5
5
  ## Installation
6
6
 
7
7
  ```bash
8
- npm install @shotstack/schemas
8
+ npm install @shotstack/schemas zod
9
9
  ```
10
10
 
11
11
  ## Usage
12
12
 
13
+ ### TypeScript Types
14
+
13
15
  ```typescript
14
16
  import type { components } from '@shotstack/schemas';
15
17
 
@@ -19,7 +21,55 @@ type Clip = components['schemas']['Clip'];
19
21
  type Output = components['schemas']['Output'];
20
22
  ```
21
23
 
22
- ## Available Types
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
23
73
 
24
74
  - Edit, Timeline, Track, Clip, Output
25
75
  - Assets: VideoAsset, ImageAsset, AudioAsset, HtmlAsset, TextAsset, TitleAsset, LumaAsset, CaptionAsset, ShapeAsset, RichTextAsset
package/dist/index.d.ts CHANGED
@@ -1 +1 @@
1
- export type * from './schema';
1
+ export type * from '../dist/schema';