@webstudio-is/sdk 0.91.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/src/assets.ts ADDED
@@ -0,0 +1,41 @@
1
+ import { z } from "zod";
2
+ import { FontFormat, FontMeta } from "@webstudio-is/fonts";
3
+
4
+ const AssetId = z.string();
5
+
6
+ const baseAsset = {
7
+ id: AssetId,
8
+ projectId: z.string(),
9
+ size: z.number(),
10
+ name: z.string(),
11
+ description: z.union([z.string(), z.null()]),
12
+ createdAt: z.string(),
13
+ };
14
+
15
+ export const FontAsset = z.object({
16
+ ...baseAsset,
17
+ format: FontFormat,
18
+ meta: FontMeta,
19
+ type: z.literal("font"),
20
+ });
21
+ export type FontAsset = z.infer<typeof FontAsset>;
22
+
23
+ export const ImageMeta = z.object({
24
+ width: z.number(),
25
+ height: z.number(),
26
+ });
27
+ export type ImageMeta = z.infer<typeof ImageMeta>;
28
+
29
+ export const ImageAsset = z.object({
30
+ ...baseAsset,
31
+ format: z.string(),
32
+ meta: ImageMeta,
33
+ type: z.literal("image"),
34
+ });
35
+ export type ImageAsset = z.infer<typeof ImageAsset>;
36
+
37
+ export const Asset = z.union([FontAsset, ImageAsset]);
38
+ export type Asset = z.infer<typeof Asset>;
39
+
40
+ export const Assets = z.map(AssetId, Asset);
41
+ export type Assets = z.infer<typeof Assets>;
package/src/index.ts ADDED
@@ -0,0 +1 @@
1
+ export * from "./assets";