@webstudio-is/sdk 0.269.0 → 0.271.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/lib/schema.js ADDED
@@ -0,0 +1,902 @@
1
+ // src/schema/assets.ts
2
+ import { z } from "zod";
3
+ import { FontFormat, FontMeta } from "@webstudio-is/fonts";
4
+ var AssetId = z.string();
5
+ var baseAsset = {
6
+ id: AssetId,
7
+ projectId: z.string(),
8
+ size: z.number(),
9
+ name: z.string(),
10
+ filename: z.string().optional(),
11
+ description: z.union([z.string().optional(), z.null()]),
12
+ createdAt: z.string()
13
+ };
14
+ var FontAsset = z.object({
15
+ ...baseAsset,
16
+ format: FontFormat,
17
+ meta: FontMeta,
18
+ type: z.literal("font")
19
+ });
20
+ var ImageMeta = z.object({
21
+ width: z.number(),
22
+ height: z.number()
23
+ });
24
+ var ImageAsset = z.object({
25
+ ...baseAsset,
26
+ format: z.string(),
27
+ meta: ImageMeta,
28
+ type: z.literal("image")
29
+ });
30
+ var FileAsset = z.object({
31
+ ...baseAsset,
32
+ format: z.string(),
33
+ meta: z.object({}),
34
+ type: z.literal("file")
35
+ });
36
+ var Asset = z.union([FontAsset, ImageAsset, FileAsset]);
37
+ var Assets = z.map(AssetId, Asset);
38
+
39
+ // src/schema/breakpoints.ts
40
+ import { z as z2 } from "zod";
41
+ var BreakpointId = z2.string();
42
+ var Breakpoint = z2.object({
43
+ id: BreakpointId,
44
+ label: z2.string(),
45
+ minWidth: z2.number().optional(),
46
+ maxWidth: z2.number().optional(),
47
+ condition: z2.string().optional()
48
+ }).transform((data) => {
49
+ if (data.condition !== void 0 && data.condition.trim() === "") {
50
+ return { ...data, condition: void 0 };
51
+ }
52
+ return data;
53
+ }).refine(({ minWidth, maxWidth, condition }) => {
54
+ if (condition !== void 0) {
55
+ return minWidth === void 0 && maxWidth === void 0;
56
+ }
57
+ if (minWidth !== void 0 && maxWidth !== void 0) {
58
+ return minWidth < maxWidth;
59
+ }
60
+ return true;
61
+ }, "Width-based (minWidth/maxWidth) and condition are mutually exclusive, and minWidth must be less than maxWidth");
62
+ var Breakpoints = z2.map(BreakpointId, Breakpoint);
63
+ var initialBreakpoints = [
64
+ { id: "placeholder", label: "Base" },
65
+ { id: "placeholder", label: "Tablet", maxWidth: 991 },
66
+ { id: "placeholder", label: "Mobile landscape", maxWidth: 767 },
67
+ { id: "placeholder", label: "Mobile portrait", maxWidth: 479 }
68
+ ];
69
+
70
+ // src/schema/data-sources.ts
71
+ import { z as z3 } from "zod";
72
+ var DataSourceId = z3.string();
73
+ var DataSourceVariableValue = z3.union([
74
+ z3.object({
75
+ type: z3.literal("number"),
76
+ // initial value of variable store
77
+ value: z3.number()
78
+ }),
79
+ z3.object({
80
+ type: z3.literal("string"),
81
+ value: z3.string()
82
+ }),
83
+ z3.object({
84
+ type: z3.literal("boolean"),
85
+ value: z3.boolean()
86
+ }),
87
+ z3.object({
88
+ type: z3.literal("string[]"),
89
+ value: z3.array(z3.string())
90
+ }),
91
+ z3.object({
92
+ type: z3.literal("json"),
93
+ value: z3.unknown()
94
+ })
95
+ ]);
96
+ var DataSource = z3.union([
97
+ z3.object({
98
+ type: z3.literal("variable"),
99
+ id: DataSourceId,
100
+ // The instance should always be specified for variables,
101
+ // however, there was a bug in the embed template
102
+ // which produced variables without an instance
103
+ // and these variables will fail validation
104
+ // if we make it required
105
+ scopeInstanceId: z3.string().optional(),
106
+ name: z3.string(),
107
+ value: DataSourceVariableValue
108
+ }),
109
+ z3.object({
110
+ type: z3.literal("parameter"),
111
+ id: DataSourceId,
112
+ scopeInstanceId: z3.string().optional(),
113
+ name: z3.string()
114
+ }),
115
+ z3.object({
116
+ type: z3.literal("resource"),
117
+ id: DataSourceId,
118
+ scopeInstanceId: z3.string().optional(),
119
+ name: z3.string(),
120
+ resourceId: z3.string()
121
+ })
122
+ ]);
123
+ var DataSources = z3.map(DataSourceId, DataSource);
124
+
125
+ // src/schema/deployment.ts
126
+ import { z as z4 } from "zod";
127
+ var Templates = z4.enum([
128
+ "docker",
129
+ "vercel",
130
+ "netlify",
131
+ "ssg",
132
+ "ssg-netlify",
133
+ "ssg-vercel"
134
+ ]);
135
+ var Deployment = z4.union([
136
+ z4.object({
137
+ destination: z4.literal("static"),
138
+ name: z4.string(),
139
+ assetsDomain: z4.string(),
140
+ // Must be validated very strictly
141
+ templates: z4.array(Templates)
142
+ }),
143
+ z4.object({
144
+ destination: z4.literal("saas").optional(),
145
+ domains: z4.array(z4.string()),
146
+ assetsDomain: z4.string().optional(),
147
+ /**
148
+ * @deprecated This field is deprecated, use `domains` instead.
149
+ */
150
+ projectDomain: z4.string().optional(),
151
+ excludeWstdDomainFromSearch: z4.boolean().optional()
152
+ })
153
+ ]);
154
+
155
+ // src/schema/instances.ts
156
+ import { z as z5 } from "zod";
157
+ var TextChild = z5.object({
158
+ type: z5.literal("text"),
159
+ value: z5.string(),
160
+ placeholder: z5.boolean().optional()
161
+ });
162
+ var InstanceId = z5.string();
163
+ var IdChild = z5.object({
164
+ type: z5.literal("id"),
165
+ value: InstanceId
166
+ });
167
+ var ExpressionChild = z5.object({
168
+ type: z5.literal("expression"),
169
+ value: z5.string()
170
+ });
171
+ var InstanceChild = z5.union([IdChild, TextChild, ExpressionChild]);
172
+ var Instance = z5.object({
173
+ type: z5.literal("instance"),
174
+ id: InstanceId,
175
+ component: z5.string(),
176
+ tag: z5.string().optional(),
177
+ label: z5.string().optional(),
178
+ children: z5.array(InstanceChild)
179
+ });
180
+ var Instances = z5.map(InstanceId, Instance);
181
+
182
+ // src/schema/pages.ts
183
+ import { z as z6 } from "zod";
184
+ import { validateBasicAuth } from "@webstudio-is/wsauth";
185
+ var MIN_TITLE_LENGTH = 2;
186
+ var PageId = z6.string();
187
+ var FolderId = z6.string();
188
+ var FolderName = z6.string().refine((value) => value.trim() !== "", "Can't be empty");
189
+ var Slug = z6.string().refine(
190
+ (path) => /^[-a-z0-9]*$/.test(path),
191
+ "Only a-z, 0-9 and - are allowed"
192
+ );
193
+ var Folder = z6.object({
194
+ id: FolderId,
195
+ name: FolderName,
196
+ slug: Slug,
197
+ children: z6.array(z6.union([FolderId, PageId]))
198
+ });
199
+ var PageName = z6.string().refine((value) => value.trim() !== "", "Can't be empty");
200
+ var PageTitle = z6.string().refine(
201
+ (val) => val.length >= MIN_TITLE_LENGTH,
202
+ `Minimum ${MIN_TITLE_LENGTH} characters required`
203
+ );
204
+ var documentTypes = ["html", "xml", "text"];
205
+ var BasicAuthFields = {
206
+ login: z6.string(),
207
+ password: z6.string()
208
+ };
209
+ var validateBasicAuthFields = ({
210
+ login,
211
+ password
212
+ }, context) => {
213
+ for (const issue of validateBasicAuth({ login, password }).issues ?? []) {
214
+ context.addIssue({
215
+ code: z6.ZodIssueCode.custom,
216
+ path: issue.path,
217
+ message: issue.message
218
+ });
219
+ }
220
+ };
221
+ var PageBasicAuth = z6.object({
222
+ method: z6.literal("basic"),
223
+ ...BasicAuthFields
224
+ }).superRefine(validateBasicAuthFields);
225
+ var LegacyPageBasicAuth = z6.object({
226
+ type: z6.literal("basic"),
227
+ ...BasicAuthFields
228
+ }).superRefine(validateBasicAuthFields).transform(({ login, password }) => ({
229
+ method: "basic",
230
+ login,
231
+ password
232
+ }));
233
+ var PageAuth = z6.union([PageBasicAuth, LegacyPageBasicAuth]);
234
+ var commonPageFields = {
235
+ id: PageId,
236
+ name: PageName,
237
+ title: PageTitle,
238
+ history: z6.optional(z6.array(z6.string())),
239
+ rootInstanceId: z6.string(),
240
+ systemDataSourceId: z6.string().optional(),
241
+ meta: z6.object({
242
+ description: z6.string().optional(),
243
+ title: z6.string().optional(),
244
+ excludePageFromSearch: z6.string().optional(),
245
+ language: z6.string().optional(),
246
+ socialImageAssetId: z6.string().optional(),
247
+ socialImageUrl: z6.string().optional(),
248
+ status: z6.string().optional(),
249
+ redirect: z6.string().optional(),
250
+ documentType: z6.optional(z6.enum(documentTypes)),
251
+ content: z6.string().optional(),
252
+ auth: PageAuth.optional(),
253
+ custom: z6.array(
254
+ z6.object({
255
+ property: z6.string(),
256
+ content: z6.string()
257
+ })
258
+ ).optional()
259
+ }),
260
+ marketplace: z6.optional(
261
+ z6.object({
262
+ include: z6.optional(z6.boolean()),
263
+ category: z6.optional(z6.string()),
264
+ thumbnailAssetId: z6.optional(z6.string())
265
+ })
266
+ )
267
+ };
268
+ var HomePagePath = z6.string().refine((path) => path === "", "Home page path must be empty");
269
+ var DefaultPagePage = z6.string().refine((path) => path !== "", "Can't be empty").refine((path) => path !== "/", "Can't be just a /").refine((path) => path.endsWith("/") === false, "Can't end with a /").refine((path) => path.includes("//") === false, "Can't contain repeating /").refine(
270
+ (path) => /^[-_a-z0-9*:?\\/.]*$/.test(path),
271
+ "Only a-z, 0-9, -, _, /, :, ?, . and * are allowed"
272
+ ).refine(
273
+ // We use /s for our system stuff like /s/css or /s/uploads
274
+ (path) => path !== "/s" && path.startsWith("/s/") === false,
275
+ "/s prefix is reserved for the system"
276
+ ).refine(
277
+ // Remix serves build artefacts like JS bundles from /build
278
+ // And we cannot customize it due to bug in Remix: https://github.com/remix-run/remix/issues/2933
279
+ (path) => path !== "/build" && path.startsWith("/build/") === false,
280
+ "/build prefix is reserved for the system"
281
+ ).refine((path) => path.length <= 255, "Path can't exceed 255 characters");
282
+ var RedirectSourcePath = z6.string().refine((path) => path !== "", "Can't be empty").refine((path) => path !== "/", "Can't be just a /").refine(
283
+ (path) => path.startsWith("/") && path.startsWith("//") === false,
284
+ "Must start with a /"
285
+ ).refine((path) => {
286
+ if (/[\\\u0000-\u001f\u007f]/.test(path)) {
287
+ return false;
288
+ }
289
+ try {
290
+ new URL(path, "https://example.com");
291
+ return true;
292
+ } catch {
293
+ return false;
294
+ }
295
+ }, "Must be a valid URL path").refine(
296
+ (path) => path !== "/s" && path.startsWith("/s/") === false,
297
+ "/s prefix is reserved for the system"
298
+ ).refine(
299
+ (path) => path !== "/build" && path.startsWith("/build/") === false,
300
+ "/build prefix is reserved for the system"
301
+ );
302
+ var PagePath = DefaultPagePage.refine(
303
+ (path) => path === "" || path.startsWith("/"),
304
+ "Must start with a / or a full URL e.g. https://website.org"
305
+ );
306
+ var Page = z6.object({
307
+ ...commonPageFields,
308
+ path: z6.union([HomePagePath, PagePath])
309
+ });
310
+ var PageTemplate = z6.object({
311
+ id: PageId,
312
+ name: PageName,
313
+ title: PageTitle,
314
+ rootInstanceId: z6.string(),
315
+ systemDataSourceId: z6.string().optional(),
316
+ meta: commonPageFields.meta
317
+ });
318
+ var ProjectMeta = z6.object({
319
+ // All fields are optional to ensure consistency and allow for the addition of new fields without requiring migration
320
+ siteName: z6.string().optional(),
321
+ contactEmail: z6.string().optional(),
322
+ faviconAssetId: z6.string().optional(),
323
+ code: z6.string().optional(),
324
+ auth: z6.string().optional()
325
+ });
326
+ var ProjectNewRedirectPath = z6.string().min(1, "Path is required").refine((data) => {
327
+ try {
328
+ new URL(data, "http://url.com");
329
+ return true;
330
+ } catch {
331
+ return false;
332
+ }
333
+ }, "Must be a valid URL");
334
+ var PageRedirect = z6.object({
335
+ old: RedirectSourcePath,
336
+ new: ProjectNewRedirectPath,
337
+ status: z6.enum(["301", "302"]).optional()
338
+ });
339
+ var CompilerSettings = z6.object({
340
+ // All fields are optional to ensure consistency and allow for the addition of new fields without requiring migration
341
+ atomicStyles: z6.boolean().optional()
342
+ });
343
+ var Pages = z6.object({
344
+ meta: ProjectMeta.optional(),
345
+ compiler: CompilerSettings.optional(),
346
+ redirects: z6.array(PageRedirect).optional(),
347
+ homePageId: PageId,
348
+ rootFolderId: FolderId,
349
+ pages: z6.map(PageId, Page),
350
+ pageTemplates: z6.map(PageId, PageTemplate).optional(),
351
+ folders: z6.map(FolderId, Folder).refine((folders) => folders.size > 0, "Folders can't be empty")
352
+ }).superRefine((pages, context) => {
353
+ const homePage = pages.pages.get(pages.homePageId);
354
+ const rootFolder = pages.folders.get(pages.rootFolderId);
355
+ if (homePage === void 0) {
356
+ context.addIssue({
357
+ code: z6.ZodIssueCode.custom,
358
+ path: ["homePageId"],
359
+ message: "Home page must reference an existing page"
360
+ });
361
+ }
362
+ if (rootFolder === void 0) {
363
+ context.addIssue({
364
+ code: z6.ZodIssueCode.custom,
365
+ path: ["rootFolderId"],
366
+ message: "Root folder must reference an existing folder"
367
+ });
368
+ }
369
+ if (homePage !== void 0 && homePage.path !== "") {
370
+ context.addIssue({
371
+ code: z6.ZodIssueCode.custom,
372
+ path: ["pages", pages.homePageId, "path"],
373
+ message: "Home page path must be empty"
374
+ });
375
+ }
376
+ for (const [pageId, page] of pages.pages) {
377
+ if (page.id !== pageId) {
378
+ context.addIssue({
379
+ code: z6.ZodIssueCode.custom,
380
+ path: ["pages", pageId, "id"],
381
+ message: "Page id must match its record key"
382
+ });
383
+ }
384
+ if (pageId !== pages.homePageId && page.path === "") {
385
+ context.addIssue({
386
+ code: z6.ZodIssueCode.custom,
387
+ path: ["pages", pageId, "path"],
388
+ message: "Page path can't be empty"
389
+ });
390
+ }
391
+ }
392
+ for (const [templateId, template] of pages.pageTemplates ?? []) {
393
+ if (template.id !== templateId) {
394
+ context.addIssue({
395
+ code: z6.ZodIssueCode.custom,
396
+ path: ["pageTemplates", templateId, "id"],
397
+ message: "Page template id must match its record key"
398
+ });
399
+ }
400
+ if (pages.pages.has(templateId)) {
401
+ context.addIssue({
402
+ code: z6.ZodIssueCode.custom,
403
+ path: ["pageTemplates", templateId, "id"],
404
+ message: "Page template id must not match an existing page id"
405
+ });
406
+ }
407
+ }
408
+ for (const [folderId, folder] of pages.folders) {
409
+ if (folder.id !== folderId) {
410
+ context.addIssue({
411
+ code: z6.ZodIssueCode.custom,
412
+ path: ["folders", folderId, "id"],
413
+ message: "Folder id must match its record key"
414
+ });
415
+ }
416
+ for (const [index, childId] of folder.children.entries()) {
417
+ if (pages.pages.has(childId) === false && pages.folders.has(childId) === false) {
418
+ context.addIssue({
419
+ code: z6.ZodIssueCode.custom,
420
+ path: ["folders", folderId, "children", index],
421
+ message: "Folder child must reference an existing page or folder"
422
+ });
423
+ }
424
+ if (childId === pages.rootFolderId) {
425
+ context.addIssue({
426
+ code: z6.ZodIssueCode.custom,
427
+ path: ["folders", folderId, "children", index],
428
+ message: "Root folder can't be nested"
429
+ });
430
+ }
431
+ }
432
+ }
433
+ if (rootFolder !== void 0 && rootFolder.children[0] !== pages.homePageId) {
434
+ context.addIssue({
435
+ code: z6.ZodIssueCode.custom,
436
+ path: ["folders", pages.rootFolderId, "children"],
437
+ message: "Root folder must start with the home page"
438
+ });
439
+ }
440
+ const childParents = /* @__PURE__ */ new Map();
441
+ for (const [folderId, folder] of pages.folders) {
442
+ for (const [index, childId] of folder.children.entries()) {
443
+ const parentId = childParents.get(childId);
444
+ if (parentId !== void 0) {
445
+ context.addIssue({
446
+ code: z6.ZodIssueCode.custom,
447
+ path: ["folders", folderId, "children", index],
448
+ message: `Child is already registered in folder "${parentId}"`
449
+ });
450
+ continue;
451
+ }
452
+ childParents.set(childId, folderId);
453
+ }
454
+ }
455
+ const hasFolderCycle = (folderId, path = /* @__PURE__ */ new Set()) => {
456
+ if (path.has(folderId)) {
457
+ return true;
458
+ }
459
+ const folder = pages.folders.get(folderId);
460
+ if (folder === void 0) {
461
+ return false;
462
+ }
463
+ path.add(folderId);
464
+ for (const childId of folder.children) {
465
+ if (pages.folders.has(childId) && hasFolderCycle(childId, path)) {
466
+ return true;
467
+ }
468
+ }
469
+ path.delete(folderId);
470
+ return false;
471
+ };
472
+ for (const folderId of pages.folders.keys()) {
473
+ if (hasFolderCycle(folderId)) {
474
+ context.addIssue({
475
+ code: z6.ZodIssueCode.custom,
476
+ path: ["folders", folderId, "children"],
477
+ message: "Folders can't contain cycles"
478
+ });
479
+ }
480
+ }
481
+ });
482
+
483
+ // src/schema/props.ts
484
+ import { z as z8 } from "zod";
485
+
486
+ // src/schema/animation-schema.ts
487
+ import { StyleValue } from "@webstudio-is/css-engine";
488
+ import { z as z7 } from "zod";
489
+ var literalUnion = (arr) => z7.union(
490
+ arr.map((val) => z7.literal(val))
491
+ );
492
+ var RANGE_UNITS = [
493
+ "%",
494
+ "px",
495
+ "cm",
496
+ "mm",
497
+ "q",
498
+ "in",
499
+ "pt",
500
+ "pc",
501
+ "em",
502
+ "rem",
503
+ "ex",
504
+ "rex",
505
+ "cap",
506
+ "rcap",
507
+ "ch",
508
+ "rch",
509
+ "lh",
510
+ "rlh",
511
+ "vw",
512
+ "svw",
513
+ "lvw",
514
+ "dvw",
515
+ "vh",
516
+ "svh",
517
+ "lvh",
518
+ "dvh",
519
+ "vi",
520
+ "svi",
521
+ "lvi",
522
+ "dvi",
523
+ "vb",
524
+ "svb",
525
+ "lvb",
526
+ "dvb",
527
+ "vmin",
528
+ "svmin",
529
+ "lvmin",
530
+ "dvmin",
531
+ "vmax",
532
+ "svmax",
533
+ "lvmax",
534
+ "dvmax"
535
+ ];
536
+ var rangeUnitSchema = literalUnion(RANGE_UNITS);
537
+ var rangeUnitValueSchema = z7.union([
538
+ z7.object({
539
+ type: z7.literal("unit"),
540
+ value: z7.number(),
541
+ unit: rangeUnitSchema
542
+ }),
543
+ z7.object({
544
+ type: z7.literal("unparsed"),
545
+ value: z7.string()
546
+ }),
547
+ z7.object({
548
+ type: z7.literal("var"),
549
+ value: z7.string()
550
+ })
551
+ ]);
552
+ var TIME_UNITS = ["ms", "s"];
553
+ var timeUnitSchema = literalUnion(TIME_UNITS);
554
+ var durationUnitValueSchema = z7.union([
555
+ z7.object({
556
+ type: z7.literal("unit"),
557
+ value: z7.number(),
558
+ unit: timeUnitSchema
559
+ }),
560
+ z7.object({
561
+ type: z7.literal("var"),
562
+ value: z7.string()
563
+ })
564
+ ]);
565
+ var iterationsUnitValueSchema = z7.union([z7.number(), z7.literal("infinite")]);
566
+ var insetUnitValueSchema = z7.union([
567
+ rangeUnitValueSchema,
568
+ z7.object({
569
+ type: z7.literal("keyword"),
570
+ value: z7.literal("auto")
571
+ })
572
+ ]);
573
+ var keyframeStylesSchema = z7.record(StyleValue);
574
+ var animationKeyframeSchema = z7.object({
575
+ offset: z7.number().optional(),
576
+ styles: keyframeStylesSchema
577
+ });
578
+ var keyframeEffectOptionsSchema = z7.object({
579
+ easing: z7.string().optional(),
580
+ fill: z7.union([
581
+ z7.literal("none"),
582
+ z7.literal("forwards"),
583
+ z7.literal("backwards"),
584
+ z7.literal("both")
585
+ ]).optional(),
586
+ // FillMode
587
+ duration: durationUnitValueSchema.optional(),
588
+ delay: durationUnitValueSchema.optional(),
589
+ iterations: iterationsUnitValueSchema.optional()
590
+ });
591
+ var scrollNamedRangeSchema = z7.union([
592
+ z7.literal("start"),
593
+ z7.literal("end")
594
+ ]);
595
+ var scrollRangeValueSchema = z7.tuple([
596
+ scrollNamedRangeSchema,
597
+ rangeUnitValueSchema
598
+ ]);
599
+ var scrollRangeOptionsSchema = z7.object({
600
+ rangeStart: scrollRangeValueSchema.optional(),
601
+ rangeEnd: scrollRangeValueSchema.optional()
602
+ });
603
+ var animationAxisSchema = z7.union([
604
+ z7.literal("block"),
605
+ z7.literal("inline"),
606
+ z7.literal("x"),
607
+ z7.literal("y")
608
+ ]);
609
+ var viewNamedRangeSchema = z7.union([
610
+ z7.literal("contain"),
611
+ z7.literal("cover"),
612
+ z7.literal("entry"),
613
+ z7.literal("exit"),
614
+ z7.literal("entry-crossing"),
615
+ z7.literal("exit-crossing")
616
+ ]);
617
+ var viewRangeValueSchema = z7.tuple([
618
+ viewNamedRangeSchema,
619
+ rangeUnitValueSchema
620
+ ]);
621
+ var viewRangeOptionsSchema = z7.object({
622
+ rangeStart: viewRangeValueSchema.optional(),
623
+ rangeEnd: viewRangeValueSchema.optional()
624
+ });
625
+ var baseAnimation = z7.object({
626
+ name: z7.string().optional(),
627
+ description: z7.string().optional(),
628
+ enabled: z7.array(z7.tuple([z7.string().describe("breakpointId"), z7.boolean()])).optional(),
629
+ keyframes: z7.array(animationKeyframeSchema)
630
+ });
631
+ var scrollAnimationSchema = baseAnimation.merge(
632
+ z7.object({
633
+ timing: keyframeEffectOptionsSchema.merge(scrollRangeOptionsSchema)
634
+ })
635
+ );
636
+ var scrollActionSchema = z7.object({
637
+ type: z7.literal("scroll"),
638
+ source: z7.union([z7.literal("closest"), z7.literal("nearest"), z7.literal("root")]).optional(),
639
+ axis: animationAxisSchema.optional(),
640
+ animations: z7.array(scrollAnimationSchema),
641
+ isPinned: z7.boolean().optional(),
642
+ debug: z7.boolean().optional()
643
+ });
644
+ var viewAnimationSchema = baseAnimation.merge(
645
+ z7.object({
646
+ timing: keyframeEffectOptionsSchema.merge(viewRangeOptionsSchema)
647
+ })
648
+ );
649
+ var viewActionSchema = z7.object({
650
+ type: z7.literal("view"),
651
+ subject: z7.string().optional(),
652
+ axis: animationAxisSchema.optional(),
653
+ animations: z7.array(viewAnimationSchema),
654
+ insetStart: insetUnitValueSchema.optional(),
655
+ insetEnd: insetUnitValueSchema.optional(),
656
+ isPinned: z7.boolean().optional(),
657
+ debug: z7.boolean().optional()
658
+ });
659
+ var animationActionSchema = z7.discriminatedUnion("type", [
660
+ scrollActionSchema,
661
+ viewActionSchema
662
+ ]);
663
+
664
+ // src/schema/props.ts
665
+ var PropId = z8.string();
666
+ var baseProp = {
667
+ id: PropId,
668
+ instanceId: z8.string(),
669
+ name: z8.string(),
670
+ required: z8.optional(z8.boolean())
671
+ };
672
+ var Prop = z8.union([
673
+ z8.object({
674
+ ...baseProp,
675
+ type: z8.literal("number"),
676
+ value: z8.number()
677
+ }),
678
+ z8.object({
679
+ ...baseProp,
680
+ type: z8.literal("string"),
681
+ value: z8.string()
682
+ }),
683
+ z8.object({
684
+ ...baseProp,
685
+ type: z8.literal("boolean"),
686
+ value: z8.boolean()
687
+ }),
688
+ z8.object({
689
+ ...baseProp,
690
+ type: z8.literal("json"),
691
+ value: z8.unknown()
692
+ }),
693
+ z8.object({
694
+ ...baseProp,
695
+ type: z8.literal("asset"),
696
+ value: z8.string()
697
+ // asset id
698
+ }),
699
+ z8.object({
700
+ ...baseProp,
701
+ type: z8.literal("page"),
702
+ value: z8.union([
703
+ z8.string(),
704
+ // page id
705
+ z8.object({
706
+ pageId: z8.string(),
707
+ instanceId: z8.string()
708
+ })
709
+ ])
710
+ }),
711
+ z8.object({
712
+ ...baseProp,
713
+ type: z8.literal("string[]"),
714
+ value: z8.array(z8.string())
715
+ }),
716
+ z8.object({
717
+ ...baseProp,
718
+ type: z8.literal("parameter"),
719
+ // data source id
720
+ value: z8.string()
721
+ }),
722
+ z8.object({
723
+ ...baseProp,
724
+ type: z8.literal("resource"),
725
+ // resource id
726
+ value: z8.string()
727
+ }),
728
+ z8.object({
729
+ ...baseProp,
730
+ type: z8.literal("expression"),
731
+ // expression code
732
+ value: z8.string()
733
+ }),
734
+ z8.object({
735
+ ...baseProp,
736
+ type: z8.literal("action"),
737
+ value: z8.array(
738
+ z8.object({
739
+ type: z8.literal("execute"),
740
+ args: z8.array(z8.string()),
741
+ code: z8.string()
742
+ })
743
+ )
744
+ }),
745
+ z8.object({
746
+ ...baseProp,
747
+ type: z8.literal("animationAction"),
748
+ value: animationActionSchema
749
+ })
750
+ ]);
751
+ var Props = z8.map(PropId, Prop);
752
+
753
+ // src/schema/resources.ts
754
+ import { z as z9 } from "zod";
755
+ var ResourceId = z9.string();
756
+ var Method = z9.union([
757
+ z9.literal("get"),
758
+ z9.literal("post"),
759
+ z9.literal("put"),
760
+ z9.literal("delete")
761
+ ]);
762
+ var Resource = z9.object({
763
+ id: ResourceId,
764
+ name: z9.string(),
765
+ control: z9.optional(z9.union([z9.literal("system"), z9.literal("graphql")])),
766
+ method: Method,
767
+ // expression
768
+ url: z9.string(),
769
+ searchParams: z9.array(
770
+ z9.object({
771
+ name: z9.string(),
772
+ // expression
773
+ value: z9.string()
774
+ })
775
+ ).optional(),
776
+ headers: z9.array(
777
+ z9.object({
778
+ name: z9.string(),
779
+ // expression
780
+ value: z9.string()
781
+ })
782
+ ),
783
+ // expression
784
+ body: z9.optional(z9.string())
785
+ });
786
+ var ResourceRequest = z9.object({
787
+ name: z9.string(),
788
+ method: Method,
789
+ url: z9.string(),
790
+ searchParams: z9.array(
791
+ z9.object({
792
+ name: z9.string(),
793
+ // can be string or object which should be serialized
794
+ value: z9.unknown()
795
+ })
796
+ ),
797
+ headers: z9.array(
798
+ z9.object({
799
+ name: z9.string(),
800
+ // can be string or object which should be serialized
801
+ value: z9.unknown()
802
+ })
803
+ ),
804
+ body: z9.optional(z9.unknown())
805
+ });
806
+ var Resources = z9.map(ResourceId, Resource);
807
+
808
+ // src/schema/style-source-selections.ts
809
+ import { z as z10 } from "zod";
810
+ var InstanceId2 = z10.string();
811
+ var StyleSourceId = z10.string();
812
+ var StyleSourceSelection = z10.object({
813
+ instanceId: InstanceId2,
814
+ values: z10.array(StyleSourceId)
815
+ });
816
+ var StyleSourceSelections = z10.map(InstanceId2, StyleSourceSelection);
817
+
818
+ // src/schema/style-sources.ts
819
+ import { z as z11 } from "zod";
820
+ var StyleSourceId2 = z11.string();
821
+ var StyleSourceToken = z11.object({
822
+ type: z11.literal("token"),
823
+ id: StyleSourceId2,
824
+ name: z11.string(),
825
+ locked: z11.boolean().optional()
826
+ });
827
+ var StyleSourceLocal = z11.object({
828
+ type: z11.literal("local"),
829
+ id: StyleSourceId2
830
+ });
831
+ var StyleSource = z11.union([StyleSourceToken, StyleSourceLocal]);
832
+ var StyleSources = z11.map(StyleSourceId2, StyleSource);
833
+
834
+ // src/schema/styles.ts
835
+ import { z as z12 } from "zod";
836
+ import { StyleValue as StyleValue2 } from "@webstudio-is/css-engine";
837
+ var StyleDeclRaw = z12.object({
838
+ styleSourceId: z12.string(),
839
+ breakpointId: z12.string(),
840
+ state: z12.optional(z12.string()),
841
+ // @todo can't figure out how to make property to be enum
842
+ property: z12.string(),
843
+ value: StyleValue2,
844
+ listed: z12.boolean().optional().describe("Whether the style is from the Advanced panel")
845
+ });
846
+ var StyleDecl = StyleDeclRaw;
847
+ var getStyleDeclKey = (styleDecl) => {
848
+ return `${styleDecl.styleSourceId}:${styleDecl.breakpointId}:${styleDecl.property}:${styleDecl.state ?? ""}`;
849
+ };
850
+ var Styles = z12.map(z12.string(), StyleDecl);
851
+ export {
852
+ Asset,
853
+ Assets,
854
+ Breakpoint,
855
+ Breakpoints,
856
+ CompilerSettings,
857
+ DataSource,
858
+ DataSourceVariableValue,
859
+ DataSources,
860
+ Deployment,
861
+ ExpressionChild,
862
+ FileAsset,
863
+ Folder,
864
+ FolderId,
865
+ FolderName,
866
+ FontAsset,
867
+ HomePagePath,
868
+ IdChild,
869
+ ImageAsset,
870
+ ImageMeta,
871
+ Instance,
872
+ InstanceChild,
873
+ Instances,
874
+ Page,
875
+ PageAuth,
876
+ PageId,
877
+ PageName,
878
+ PagePath,
879
+ PageRedirect,
880
+ PageTemplate,
881
+ PageTitle,
882
+ Pages,
883
+ ProjectMeta,
884
+ ProjectNewRedirectPath,
885
+ Prop,
886
+ Props,
887
+ RedirectSourcePath,
888
+ Resource,
889
+ ResourceRequest,
890
+ Resources,
891
+ StyleDecl,
892
+ StyleSource,
893
+ StyleSourceSelection,
894
+ StyleSourceSelections,
895
+ StyleSources,
896
+ Styles,
897
+ Templates,
898
+ TextChild,
899
+ documentTypes,
900
+ getStyleDeclKey,
901
+ initialBreakpoints
902
+ };