@webstudio-is/sdk 0.123.0 → 0.125.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/index.js +181 -89
- package/lib/types/index.d.ts +2 -0
- package/lib/types/instances-utils.d.ts +8 -2
- package/lib/types/resource-loader.d.ts +6 -0
- package/lib/types/schema/data-sources.d.ts +36 -0
- package/lib/types/schema/instances.d.ts +49 -8
- package/lib/types/schema/pages.d.ts +72 -2
- package/lib/types/schema/resources.d.ts +77 -0
- package/package.json +4 -4
package/lib/index.js
CHANGED
|
@@ -32,13 +32,26 @@ var Assets = z.map(AssetId, Asset);
|
|
|
32
32
|
// src/schema/pages.ts
|
|
33
33
|
import { z as z2 } from "zod";
|
|
34
34
|
var MIN_TITLE_LENGTH = 2;
|
|
35
|
+
var PageId = z2.string();
|
|
36
|
+
var FolderId = z2.string();
|
|
37
|
+
var FolderName = z2.string().refine((value) => value.trim() !== "", "Can't be empty");
|
|
38
|
+
var FolderSlug = z2.string().refine((slug) => slug !== "", "Can't be empty").refine((slug) => slug.includes("/") === false, "Can't contain a /").refine(
|
|
39
|
+
(path) => /^[-a-z0-9]*$/.test(path),
|
|
40
|
+
"Only a-z, 0-9 and - are allowed"
|
|
41
|
+
);
|
|
42
|
+
var Folder = z2.object({
|
|
43
|
+
id: FolderId,
|
|
44
|
+
name: FolderName,
|
|
45
|
+
slug: z2.string(),
|
|
46
|
+
children: z2.array(z2.union([FolderId, PageId]))
|
|
47
|
+
});
|
|
35
48
|
var PageName = z2.string().refine((value) => value.trim() !== "", "Can't be empty");
|
|
36
49
|
var PageTitle = z2.string().refine(
|
|
37
50
|
(val) => val.length >= MIN_TITLE_LENGTH,
|
|
38
51
|
`Minimum ${MIN_TITLE_LENGTH} characters required`
|
|
39
52
|
);
|
|
40
53
|
var commonPageFields = {
|
|
41
|
-
id:
|
|
54
|
+
id: PageId,
|
|
42
55
|
name: PageName,
|
|
43
56
|
title: PageTitle,
|
|
44
57
|
meta: z2.object({
|
|
@@ -62,8 +75,8 @@ var HomePage = z2.object({
|
|
|
62
75
|
path: HomePagePath
|
|
63
76
|
});
|
|
64
77
|
var PagePath = z2.string().refine((path) => path !== "", "Can't be empty").refine((path) => path !== "/", "Can't be just a /").refine((path) => path === "" || path.startsWith("/"), "Must start with a /").refine((path) => path.endsWith("/") === false, "Can't end with a /").refine((path) => path.includes("//") === false, "Can't contain repeating /").refine(
|
|
65
|
-
(path) => /^[-_a-z0-9
|
|
66
|
-
"Only a-z, 0-9, -, _, /,
|
|
78
|
+
(path) => /^[-_a-z0-9*:?\\/]*$/.test(path),
|
|
79
|
+
"Only a-z, 0-9, -, _, /, :, ? and * are allowed"
|
|
67
80
|
).refine(
|
|
68
81
|
// We use /s for our system stuff like /s/css or /s/uploads
|
|
69
82
|
(path) => path !== "/s" && path.startsWith("/s/") === false,
|
|
@@ -78,37 +91,48 @@ var Page = z2.object({
|
|
|
78
91
|
...commonPageFields,
|
|
79
92
|
path: PagePath
|
|
80
93
|
});
|
|
81
|
-
var
|
|
94
|
+
var ProjectMeta = z2.object({
|
|
95
|
+
// All fields are optional to ensure consistency and allow for the addition of new fields without requiring migration
|
|
82
96
|
siteName: z2.string().optional(),
|
|
83
97
|
faviconAssetId: z2.string().optional(),
|
|
84
98
|
code: z2.string().optional()
|
|
85
99
|
});
|
|
100
|
+
var ProjectSettings = z2.object({
|
|
101
|
+
// All fields are optional to ensure consistency and allow for the addition of new fields without requiring migration
|
|
102
|
+
atomicStyles: z2.boolean().optional()
|
|
103
|
+
});
|
|
86
104
|
var Pages = z2.object({
|
|
87
|
-
meta:
|
|
105
|
+
meta: ProjectMeta.optional(),
|
|
106
|
+
settings: ProjectSettings.optional(),
|
|
88
107
|
homePage: HomePage,
|
|
89
108
|
pages: z2.array(Page).refine(
|
|
90
109
|
(array) => new Set(array.map((page) => page.path)).size === array.length,
|
|
91
110
|
"All paths must be unique"
|
|
92
|
-
)
|
|
111
|
+
),
|
|
112
|
+
folders: z2.array(Folder).refine((folders) => folders.length > 0, "Folders can't be empty")
|
|
93
113
|
});
|
|
94
114
|
|
|
95
115
|
// src/schema/instances.ts
|
|
96
116
|
import { z as z3 } from "zod";
|
|
97
|
-
var
|
|
117
|
+
var TextChild = z3.object({
|
|
98
118
|
type: z3.literal("text"),
|
|
99
119
|
value: z3.string()
|
|
100
120
|
});
|
|
101
121
|
var InstanceId = z3.string();
|
|
102
|
-
var
|
|
122
|
+
var IdChild = z3.object({
|
|
103
123
|
type: z3.literal("id"),
|
|
104
124
|
value: InstanceId
|
|
105
125
|
});
|
|
126
|
+
var ExpressionChild = z3.object({
|
|
127
|
+
type: z3.literal("expression"),
|
|
128
|
+
value: z3.string()
|
|
129
|
+
});
|
|
106
130
|
var Instance = z3.object({
|
|
107
131
|
type: z3.literal("instance"),
|
|
108
132
|
id: InstanceId,
|
|
109
133
|
component: z3.string(),
|
|
110
134
|
label: z3.string().optional(),
|
|
111
|
-
children: z3.array(z3.union([
|
|
135
|
+
children: z3.array(z3.union([IdChild, TextChild, ExpressionChild]))
|
|
112
136
|
});
|
|
113
137
|
var Instances = z3.map(InstanceId, Instance);
|
|
114
138
|
|
|
@@ -151,97 +175,130 @@ var DataSource = z4.union([
|
|
|
151
175
|
id: DataSourceId,
|
|
152
176
|
scopeInstanceId: z4.optional(z4.string()),
|
|
153
177
|
name: z4.string()
|
|
178
|
+
}),
|
|
179
|
+
z4.object({
|
|
180
|
+
type: z4.literal("resource"),
|
|
181
|
+
id: DataSourceId,
|
|
182
|
+
scopeInstanceId: z4.optional(z4.string()),
|
|
183
|
+
name: z4.string(),
|
|
184
|
+
resourceId: z4.string()
|
|
154
185
|
})
|
|
155
186
|
]);
|
|
156
187
|
var DataSources = z4.map(DataSourceId, DataSource);
|
|
157
188
|
|
|
158
|
-
// src/schema/
|
|
189
|
+
// src/schema/resources.ts
|
|
159
190
|
import { z as z5 } from "zod";
|
|
160
|
-
var
|
|
191
|
+
var ResourceId = z5.string();
|
|
192
|
+
var Method = z5.union([
|
|
193
|
+
z5.literal("get"),
|
|
194
|
+
z5.literal("post"),
|
|
195
|
+
z5.literal("put"),
|
|
196
|
+
z5.literal("delete")
|
|
197
|
+
]);
|
|
198
|
+
var Header = z5.object({
|
|
199
|
+
name: z5.string(),
|
|
200
|
+
// expression
|
|
201
|
+
value: z5.string()
|
|
202
|
+
});
|
|
203
|
+
var Resource = z5.object({
|
|
204
|
+
id: ResourceId,
|
|
205
|
+
name: z5.string(),
|
|
206
|
+
method: Method,
|
|
207
|
+
// expression
|
|
208
|
+
url: z5.string(),
|
|
209
|
+
headers: z5.array(Header),
|
|
210
|
+
// expression
|
|
211
|
+
body: z5.optional(z5.string())
|
|
212
|
+
});
|
|
213
|
+
var Resources = z5.map(ResourceId, Resource);
|
|
214
|
+
|
|
215
|
+
// src/schema/props.ts
|
|
216
|
+
import { z as z6 } from "zod";
|
|
217
|
+
var PropId = z6.string();
|
|
161
218
|
var baseProp = {
|
|
162
219
|
id: PropId,
|
|
163
|
-
instanceId:
|
|
164
|
-
name:
|
|
165
|
-
required:
|
|
220
|
+
instanceId: z6.string(),
|
|
221
|
+
name: z6.string(),
|
|
222
|
+
required: z6.optional(z6.boolean())
|
|
166
223
|
};
|
|
167
|
-
var Prop =
|
|
168
|
-
|
|
224
|
+
var Prop = z6.union([
|
|
225
|
+
z6.object({
|
|
169
226
|
...baseProp,
|
|
170
|
-
type:
|
|
171
|
-
value:
|
|
227
|
+
type: z6.literal("number"),
|
|
228
|
+
value: z6.number()
|
|
172
229
|
}),
|
|
173
|
-
|
|
230
|
+
z6.object({
|
|
174
231
|
...baseProp,
|
|
175
|
-
type:
|
|
176
|
-
value:
|
|
232
|
+
type: z6.literal("string"),
|
|
233
|
+
value: z6.string()
|
|
177
234
|
}),
|
|
178
|
-
|
|
235
|
+
z6.object({
|
|
179
236
|
...baseProp,
|
|
180
|
-
type:
|
|
181
|
-
value:
|
|
237
|
+
type: z6.literal("boolean"),
|
|
238
|
+
value: z6.boolean()
|
|
182
239
|
}),
|
|
183
|
-
|
|
240
|
+
z6.object({
|
|
184
241
|
...baseProp,
|
|
185
|
-
type:
|
|
186
|
-
value:
|
|
242
|
+
type: z6.literal("json"),
|
|
243
|
+
value: z6.unknown()
|
|
187
244
|
}),
|
|
188
|
-
|
|
245
|
+
z6.object({
|
|
189
246
|
...baseProp,
|
|
190
|
-
type:
|
|
191
|
-
value:
|
|
247
|
+
type: z6.literal("asset"),
|
|
248
|
+
value: z6.string()
|
|
192
249
|
// asset id
|
|
193
250
|
}),
|
|
194
|
-
|
|
251
|
+
z6.object({
|
|
195
252
|
...baseProp,
|
|
196
|
-
type:
|
|
197
|
-
value:
|
|
198
|
-
|
|
253
|
+
type: z6.literal("page"),
|
|
254
|
+
value: z6.union([
|
|
255
|
+
z6.string(),
|
|
199
256
|
// page id
|
|
200
|
-
|
|
201
|
-
pageId:
|
|
202
|
-
instanceId:
|
|
257
|
+
z6.object({
|
|
258
|
+
pageId: z6.string(),
|
|
259
|
+
instanceId: z6.string()
|
|
203
260
|
})
|
|
204
261
|
])
|
|
205
262
|
}),
|
|
206
|
-
|
|
263
|
+
z6.object({
|
|
207
264
|
...baseProp,
|
|
208
|
-
type:
|
|
209
|
-
value:
|
|
265
|
+
type: z6.literal("string[]"),
|
|
266
|
+
value: z6.array(z6.string())
|
|
210
267
|
}),
|
|
211
|
-
|
|
268
|
+
z6.object({
|
|
212
269
|
...baseProp,
|
|
213
|
-
type:
|
|
270
|
+
type: z6.literal("parameter"),
|
|
214
271
|
// data source id
|
|
215
|
-
value:
|
|
272
|
+
value: z6.string()
|
|
216
273
|
}),
|
|
217
|
-
|
|
274
|
+
z6.object({
|
|
218
275
|
...baseProp,
|
|
219
|
-
type:
|
|
276
|
+
type: z6.literal("expression"),
|
|
220
277
|
// expression code
|
|
221
|
-
value:
|
|
278
|
+
value: z6.string()
|
|
222
279
|
}),
|
|
223
|
-
|
|
280
|
+
z6.object({
|
|
224
281
|
...baseProp,
|
|
225
|
-
type:
|
|
226
|
-
value:
|
|
227
|
-
|
|
228
|
-
type:
|
|
229
|
-
args:
|
|
230
|
-
code:
|
|
282
|
+
type: z6.literal("action"),
|
|
283
|
+
value: z6.array(
|
|
284
|
+
z6.object({
|
|
285
|
+
type: z6.literal("execute"),
|
|
286
|
+
args: z6.array(z6.string()),
|
|
287
|
+
code: z6.string()
|
|
231
288
|
})
|
|
232
289
|
)
|
|
233
290
|
})
|
|
234
291
|
]);
|
|
235
|
-
var Props =
|
|
292
|
+
var Props = z6.map(PropId, Prop);
|
|
236
293
|
|
|
237
294
|
// src/schema/breakpoints.ts
|
|
238
|
-
import { z as
|
|
239
|
-
var BreakpointId =
|
|
240
|
-
var Breakpoint =
|
|
295
|
+
import { z as z7 } from "zod";
|
|
296
|
+
var BreakpointId = z7.string();
|
|
297
|
+
var Breakpoint = z7.object({
|
|
241
298
|
id: BreakpointId,
|
|
242
|
-
label:
|
|
243
|
-
minWidth:
|
|
244
|
-
maxWidth:
|
|
299
|
+
label: z7.string(),
|
|
300
|
+
minWidth: z7.number().optional(),
|
|
301
|
+
maxWidth: z7.number().optional()
|
|
245
302
|
}).refine(({ minWidth, maxWidth }) => {
|
|
246
303
|
return (
|
|
247
304
|
// Either min or max width have to be defined
|
|
@@ -249,7 +306,7 @@ var Breakpoint = z6.object({
|
|
|
249
306
|
minWidth === void 0 && maxWidth === void 0
|
|
250
307
|
);
|
|
251
308
|
}, "Either minWidth or maxWidth should be defined");
|
|
252
|
-
var Breakpoints =
|
|
309
|
+
var Breakpoints = z7.map(BreakpointId, Breakpoint);
|
|
253
310
|
var initialBreakpoints = [
|
|
254
311
|
{ id: "placeholder", label: "Base" },
|
|
255
312
|
{ id: "placeholder", label: "Tablet", maxWidth: 991 },
|
|
@@ -258,52 +315,52 @@ var initialBreakpoints = [
|
|
|
258
315
|
];
|
|
259
316
|
|
|
260
317
|
// src/schema/style-sources.ts
|
|
261
|
-
import { z as
|
|
262
|
-
var StyleSourceId =
|
|
263
|
-
var StyleSourceToken =
|
|
264
|
-
type:
|
|
318
|
+
import { z as z8 } from "zod";
|
|
319
|
+
var StyleSourceId = z8.string();
|
|
320
|
+
var StyleSourceToken = z8.object({
|
|
321
|
+
type: z8.literal("token"),
|
|
265
322
|
id: StyleSourceId,
|
|
266
|
-
name:
|
|
323
|
+
name: z8.string()
|
|
267
324
|
});
|
|
268
|
-
var StyleSourceLocal =
|
|
269
|
-
type:
|
|
325
|
+
var StyleSourceLocal = z8.object({
|
|
326
|
+
type: z8.literal("local"),
|
|
270
327
|
id: StyleSourceId
|
|
271
328
|
});
|
|
272
|
-
var StyleSource =
|
|
273
|
-
var StyleSources =
|
|
329
|
+
var StyleSource = z8.union([StyleSourceToken, StyleSourceLocal]);
|
|
330
|
+
var StyleSources = z8.map(StyleSourceId, StyleSource);
|
|
274
331
|
|
|
275
332
|
// src/schema/style-source-selections.ts
|
|
276
|
-
import { z as
|
|
277
|
-
var InstanceId2 =
|
|
278
|
-
var StyleSourceId2 =
|
|
279
|
-
var StyleSourceSelection =
|
|
333
|
+
import { z as z9 } from "zod";
|
|
334
|
+
var InstanceId2 = z9.string();
|
|
335
|
+
var StyleSourceId2 = z9.string();
|
|
336
|
+
var StyleSourceSelection = z9.object({
|
|
280
337
|
instanceId: InstanceId2,
|
|
281
|
-
values:
|
|
338
|
+
values: z9.array(StyleSourceId2)
|
|
282
339
|
});
|
|
283
|
-
var StyleSourceSelections =
|
|
340
|
+
var StyleSourceSelections = z9.map(InstanceId2, StyleSourceSelection);
|
|
284
341
|
|
|
285
342
|
// src/schema/styles.ts
|
|
286
|
-
import { z as
|
|
343
|
+
import { z as z10 } from "zod";
|
|
287
344
|
import { StyleValue } from "@webstudio-is/css-engine";
|
|
288
|
-
var StyleDeclRaw =
|
|
289
|
-
styleSourceId:
|
|
290
|
-
breakpointId:
|
|
291
|
-
state:
|
|
345
|
+
var StyleDeclRaw = z10.object({
|
|
346
|
+
styleSourceId: z10.string(),
|
|
347
|
+
breakpointId: z10.string(),
|
|
348
|
+
state: z10.optional(z10.string()),
|
|
292
349
|
// @todo can't figure out how to make property to be enum
|
|
293
|
-
property:
|
|
350
|
+
property: z10.string(),
|
|
294
351
|
value: StyleValue
|
|
295
352
|
});
|
|
296
353
|
var StyleDecl = StyleDeclRaw;
|
|
297
354
|
var getStyleDeclKey = (styleDecl) => {
|
|
298
355
|
return `${styleDecl.styleSourceId}:${styleDecl.breakpointId}:${styleDecl.property}:${styleDecl.state ?? ""}`;
|
|
299
356
|
};
|
|
300
|
-
var Styles =
|
|
357
|
+
var Styles = z10.map(z10.string(), StyleDecl);
|
|
301
358
|
|
|
302
359
|
// src/schema/deployment.ts
|
|
303
|
-
import { z as
|
|
304
|
-
var Deployment =
|
|
305
|
-
domains:
|
|
306
|
-
projectDomain:
|
|
360
|
+
import { z as z11 } from "zod";
|
|
361
|
+
var Deployment = z11.object({
|
|
362
|
+
domains: z11.array(z11.string()),
|
|
363
|
+
projectDomain: z11.string()
|
|
307
364
|
});
|
|
308
365
|
|
|
309
366
|
// src/instances-utils.ts
|
|
@@ -387,6 +444,34 @@ var createScope = (occupiedIdentifiers = []) => {
|
|
|
387
444
|
getName
|
|
388
445
|
};
|
|
389
446
|
};
|
|
447
|
+
|
|
448
|
+
// src/resource-loader.ts
|
|
449
|
+
var loadResource = async (resourceData) => {
|
|
450
|
+
const { url, method, headers, body } = resourceData;
|
|
451
|
+
const requestHeaders = new Headers(
|
|
452
|
+
headers.map(({ name, value }) => [name, value])
|
|
453
|
+
);
|
|
454
|
+
const requestInit = {
|
|
455
|
+
method,
|
|
456
|
+
headers: requestHeaders
|
|
457
|
+
};
|
|
458
|
+
if (method !== "get" && body !== void 0) {
|
|
459
|
+
requestInit.body = body;
|
|
460
|
+
}
|
|
461
|
+
const response = await fetch(url, requestInit);
|
|
462
|
+
let data;
|
|
463
|
+
if (response.ok && // accept json by default and when specified explicitly
|
|
464
|
+
(requestHeaders.has("accept") === false || requestHeaders.get("accept") === "application/json")) {
|
|
465
|
+
data = await response.json();
|
|
466
|
+
} else {
|
|
467
|
+
data = await response.text();
|
|
468
|
+
}
|
|
469
|
+
return {
|
|
470
|
+
data,
|
|
471
|
+
status: response.status,
|
|
472
|
+
statusText: response.statusText
|
|
473
|
+
};
|
|
474
|
+
};
|
|
390
475
|
export {
|
|
391
476
|
Asset,
|
|
392
477
|
Assets,
|
|
@@ -396,9 +481,13 @@ export {
|
|
|
396
481
|
DataSourceVariableValue,
|
|
397
482
|
DataSources,
|
|
398
483
|
Deployment,
|
|
484
|
+
ExpressionChild,
|
|
485
|
+
Folder,
|
|
486
|
+
FolderName,
|
|
487
|
+
FolderSlug,
|
|
399
488
|
FontAsset,
|
|
400
489
|
HomePagePath,
|
|
401
|
-
|
|
490
|
+
IdChild,
|
|
402
491
|
ImageAsset,
|
|
403
492
|
ImageMeta,
|
|
404
493
|
Instance,
|
|
@@ -409,17 +498,20 @@ export {
|
|
|
409
498
|
Pages,
|
|
410
499
|
Prop,
|
|
411
500
|
Props,
|
|
501
|
+
Resource,
|
|
502
|
+
Resources,
|
|
412
503
|
StyleDecl,
|
|
413
504
|
StyleSource,
|
|
414
505
|
StyleSourceSelection,
|
|
415
506
|
StyleSourceSelections,
|
|
416
507
|
StyleSources,
|
|
417
508
|
Styles,
|
|
418
|
-
|
|
509
|
+
TextChild,
|
|
419
510
|
createScope,
|
|
420
511
|
findTreeInstanceIds,
|
|
421
512
|
findTreeInstanceIdsExcludingSlotDescendants,
|
|
422
513
|
getStyleDeclKey,
|
|
423
514
|
initialBreakpoints,
|
|
515
|
+
loadResource,
|
|
424
516
|
parseComponentName
|
|
425
517
|
};
|
package/lib/types/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export * from "./schema/assets";
|
|
|
2
2
|
export * from "./schema/pages";
|
|
3
3
|
export * from "./schema/instances";
|
|
4
4
|
export * from "./schema/data-sources";
|
|
5
|
+
export * from "./schema/resources";
|
|
5
6
|
export * from "./schema/props";
|
|
6
7
|
export * from "./schema/breakpoints";
|
|
7
8
|
export * from "./schema/style-sources";
|
|
@@ -10,3 +11,4 @@ export * from "./schema/styles";
|
|
|
10
11
|
export * from "./schema/deployment";
|
|
11
12
|
export * from "./instances-utils";
|
|
12
13
|
export * from "./scope";
|
|
14
|
+
export * from "./resource-loader";
|
|
@@ -2,27 +2,33 @@ import type { Instance } from "./schema/instances";
|
|
|
2
2
|
export declare const findTreeInstanceIds: (instances: Map<string, {
|
|
3
3
|
type: "instance";
|
|
4
4
|
id: string;
|
|
5
|
-
component: string;
|
|
6
5
|
children: ({
|
|
7
6
|
value: string;
|
|
8
7
|
type: "text";
|
|
9
8
|
} | {
|
|
10
9
|
value: string;
|
|
11
10
|
type: "id";
|
|
11
|
+
} | {
|
|
12
|
+
value: string;
|
|
13
|
+
type: "expression";
|
|
12
14
|
})[];
|
|
15
|
+
component: string;
|
|
13
16
|
label?: string | undefined;
|
|
14
17
|
}>, rootInstanceId: Instance["id"]) => Set<string>;
|
|
15
18
|
export declare const findTreeInstanceIdsExcludingSlotDescendants: (instances: Map<string, {
|
|
16
19
|
type: "instance";
|
|
17
20
|
id: string;
|
|
18
|
-
component: string;
|
|
19
21
|
children: ({
|
|
20
22
|
value: string;
|
|
21
23
|
type: "text";
|
|
22
24
|
} | {
|
|
23
25
|
value: string;
|
|
24
26
|
type: "id";
|
|
27
|
+
} | {
|
|
28
|
+
value: string;
|
|
29
|
+
type: "expression";
|
|
25
30
|
})[];
|
|
31
|
+
component: string;
|
|
26
32
|
label?: string | undefined;
|
|
27
33
|
}>, rootInstanceId: Instance["id"]) => Set<string>;
|
|
28
34
|
export declare const parseComponentName: (componentName: string) => readonly [string | undefined, string];
|
|
@@ -153,6 +153,24 @@ export declare const DataSource: z.ZodUnion<[z.ZodObject<{
|
|
|
153
153
|
name: string;
|
|
154
154
|
id: string;
|
|
155
155
|
scopeInstanceId?: string | undefined;
|
|
156
|
+
}>, z.ZodObject<{
|
|
157
|
+
type: z.ZodLiteral<"resource">;
|
|
158
|
+
id: z.ZodString;
|
|
159
|
+
scopeInstanceId: z.ZodOptional<z.ZodString>;
|
|
160
|
+
name: z.ZodString;
|
|
161
|
+
resourceId: z.ZodString;
|
|
162
|
+
}, "strip", z.ZodTypeAny, {
|
|
163
|
+
type: "resource";
|
|
164
|
+
name: string;
|
|
165
|
+
id: string;
|
|
166
|
+
resourceId: string;
|
|
167
|
+
scopeInstanceId?: string | undefined;
|
|
168
|
+
}, {
|
|
169
|
+
type: "resource";
|
|
170
|
+
name: string;
|
|
171
|
+
id: string;
|
|
172
|
+
resourceId: string;
|
|
173
|
+
scopeInstanceId?: string | undefined;
|
|
156
174
|
}>]>;
|
|
157
175
|
export type DataSource = z.infer<typeof DataSource>;
|
|
158
176
|
export declare const DataSources: z.ZodMap<z.ZodString, z.ZodUnion<[z.ZodObject<{
|
|
@@ -263,5 +281,23 @@ export declare const DataSources: z.ZodMap<z.ZodString, z.ZodUnion<[z.ZodObject<
|
|
|
263
281
|
name: string;
|
|
264
282
|
id: string;
|
|
265
283
|
scopeInstanceId?: string | undefined;
|
|
284
|
+
}>, z.ZodObject<{
|
|
285
|
+
type: z.ZodLiteral<"resource">;
|
|
286
|
+
id: z.ZodString;
|
|
287
|
+
scopeInstanceId: z.ZodOptional<z.ZodString>;
|
|
288
|
+
name: z.ZodString;
|
|
289
|
+
resourceId: z.ZodString;
|
|
290
|
+
}, "strip", z.ZodTypeAny, {
|
|
291
|
+
type: "resource";
|
|
292
|
+
name: string;
|
|
293
|
+
id: string;
|
|
294
|
+
resourceId: string;
|
|
295
|
+
scopeInstanceId?: string | undefined;
|
|
296
|
+
}, {
|
|
297
|
+
type: "resource";
|
|
298
|
+
name: string;
|
|
299
|
+
id: string;
|
|
300
|
+
resourceId: string;
|
|
301
|
+
scopeInstanceId?: string | undefined;
|
|
266
302
|
}>]>>;
|
|
267
303
|
export type DataSources = z.infer<typeof DataSources>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const TextChild: z.ZodObject<{
|
|
3
3
|
type: z.ZodLiteral<"text">;
|
|
4
4
|
value: z.ZodString;
|
|
5
5
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -9,8 +9,8 @@ export declare const Text: z.ZodObject<{
|
|
|
9
9
|
value: string;
|
|
10
10
|
type: "text";
|
|
11
11
|
}>;
|
|
12
|
-
export type
|
|
13
|
-
export declare const
|
|
12
|
+
export type TextChild = z.infer<typeof TextChild>;
|
|
13
|
+
export declare const IdChild: z.ZodObject<{
|
|
14
14
|
type: z.ZodLiteral<"id">;
|
|
15
15
|
value: z.ZodString;
|
|
16
16
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -20,7 +20,18 @@ export declare const Id: z.ZodObject<{
|
|
|
20
20
|
value: string;
|
|
21
21
|
type: "id";
|
|
22
22
|
}>;
|
|
23
|
-
export type
|
|
23
|
+
export type IdChild = z.infer<typeof IdChild>;
|
|
24
|
+
export declare const ExpressionChild: z.ZodObject<{
|
|
25
|
+
type: z.ZodLiteral<"expression">;
|
|
26
|
+
value: z.ZodString;
|
|
27
|
+
}, "strip", z.ZodTypeAny, {
|
|
28
|
+
value: string;
|
|
29
|
+
type: "expression";
|
|
30
|
+
}, {
|
|
31
|
+
value: string;
|
|
32
|
+
type: "expression";
|
|
33
|
+
}>;
|
|
34
|
+
export type ExpressionChild = z.infer<typeof ExpressionChild>;
|
|
24
35
|
export declare const Instance: z.ZodObject<{
|
|
25
36
|
type: z.ZodLiteral<"instance">;
|
|
26
37
|
id: z.ZodString;
|
|
@@ -44,30 +55,45 @@ export declare const Instance: z.ZodObject<{
|
|
|
44
55
|
}, {
|
|
45
56
|
value: string;
|
|
46
57
|
type: "text";
|
|
58
|
+
}>, z.ZodObject<{
|
|
59
|
+
type: z.ZodLiteral<"expression">;
|
|
60
|
+
value: z.ZodString;
|
|
61
|
+
}, "strip", z.ZodTypeAny, {
|
|
62
|
+
value: string;
|
|
63
|
+
type: "expression";
|
|
64
|
+
}, {
|
|
65
|
+
value: string;
|
|
66
|
+
type: "expression";
|
|
47
67
|
}>]>, "many">;
|
|
48
68
|
}, "strip", z.ZodTypeAny, {
|
|
49
69
|
type: "instance";
|
|
50
70
|
id: string;
|
|
51
|
-
component: string;
|
|
52
71
|
children: ({
|
|
53
72
|
value: string;
|
|
54
73
|
type: "text";
|
|
55
74
|
} | {
|
|
56
75
|
value: string;
|
|
57
76
|
type: "id";
|
|
77
|
+
} | {
|
|
78
|
+
value: string;
|
|
79
|
+
type: "expression";
|
|
58
80
|
})[];
|
|
81
|
+
component: string;
|
|
59
82
|
label?: string | undefined;
|
|
60
83
|
}, {
|
|
61
84
|
type: "instance";
|
|
62
85
|
id: string;
|
|
63
|
-
component: string;
|
|
64
86
|
children: ({
|
|
65
87
|
value: string;
|
|
66
88
|
type: "text";
|
|
67
89
|
} | {
|
|
68
90
|
value: string;
|
|
69
91
|
type: "id";
|
|
92
|
+
} | {
|
|
93
|
+
value: string;
|
|
94
|
+
type: "expression";
|
|
70
95
|
})[];
|
|
96
|
+
component: string;
|
|
71
97
|
label?: string | undefined;
|
|
72
98
|
}>;
|
|
73
99
|
export type Instance = z.infer<typeof Instance>;
|
|
@@ -94,30 +120,45 @@ export declare const Instances: z.ZodMap<z.ZodString, z.ZodObject<{
|
|
|
94
120
|
}, {
|
|
95
121
|
value: string;
|
|
96
122
|
type: "text";
|
|
123
|
+
}>, z.ZodObject<{
|
|
124
|
+
type: z.ZodLiteral<"expression">;
|
|
125
|
+
value: z.ZodString;
|
|
126
|
+
}, "strip", z.ZodTypeAny, {
|
|
127
|
+
value: string;
|
|
128
|
+
type: "expression";
|
|
129
|
+
}, {
|
|
130
|
+
value: string;
|
|
131
|
+
type: "expression";
|
|
97
132
|
}>]>, "many">;
|
|
98
133
|
}, "strip", z.ZodTypeAny, {
|
|
99
134
|
type: "instance";
|
|
100
135
|
id: string;
|
|
101
|
-
component: string;
|
|
102
136
|
children: ({
|
|
103
137
|
value: string;
|
|
104
138
|
type: "text";
|
|
105
139
|
} | {
|
|
106
140
|
value: string;
|
|
107
141
|
type: "id";
|
|
142
|
+
} | {
|
|
143
|
+
value: string;
|
|
144
|
+
type: "expression";
|
|
108
145
|
})[];
|
|
146
|
+
component: string;
|
|
109
147
|
label?: string | undefined;
|
|
110
148
|
}, {
|
|
111
149
|
type: "instance";
|
|
112
150
|
id: string;
|
|
113
|
-
component: string;
|
|
114
151
|
children: ({
|
|
115
152
|
value: string;
|
|
116
153
|
type: "text";
|
|
117
154
|
} | {
|
|
118
155
|
value: string;
|
|
119
156
|
type: "id";
|
|
157
|
+
} | {
|
|
158
|
+
value: string;
|
|
159
|
+
type: "expression";
|
|
120
160
|
})[];
|
|
161
|
+
component: string;
|
|
121
162
|
label?: string | undefined;
|
|
122
163
|
}>>;
|
|
123
164
|
export type Instances = z.infer<typeof Instances>;
|
|
@@ -1,4 +1,23 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
export declare const FolderName: z.ZodEffects<z.ZodString, string, string>;
|
|
3
|
+
export declare const FolderSlug: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>, string, string>;
|
|
4
|
+
export declare const Folder: z.ZodObject<{
|
|
5
|
+
id: z.ZodString;
|
|
6
|
+
name: z.ZodEffects<z.ZodString, string, string>;
|
|
7
|
+
slug: z.ZodString;
|
|
8
|
+
children: z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodString]>, "many">;
|
|
9
|
+
}, "strip", z.ZodTypeAny, {
|
|
10
|
+
name: string;
|
|
11
|
+
id: string;
|
|
12
|
+
slug: string;
|
|
13
|
+
children: string[];
|
|
14
|
+
}, {
|
|
15
|
+
name: string;
|
|
16
|
+
id: string;
|
|
17
|
+
slug: string;
|
|
18
|
+
children: string[];
|
|
19
|
+
}>;
|
|
20
|
+
export type Folder = z.infer<typeof Folder>;
|
|
2
21
|
export declare const PageName: z.ZodEffects<z.ZodString, string, string>;
|
|
3
22
|
export declare const PageTitle: z.ZodEffects<z.ZodString, string, string>;
|
|
4
23
|
export declare const HomePagePath: z.ZodEffects<z.ZodString, string, string>;
|
|
@@ -79,7 +98,7 @@ declare const Page: z.ZodObject<{
|
|
|
79
98
|
rootInstanceId: string;
|
|
80
99
|
pathVariableId?: string | undefined;
|
|
81
100
|
}>;
|
|
82
|
-
declare const
|
|
101
|
+
declare const ProjectMeta: z.ZodObject<{
|
|
83
102
|
siteName: z.ZodOptional<z.ZodString>;
|
|
84
103
|
faviconAssetId: z.ZodOptional<z.ZodString>;
|
|
85
104
|
code: z.ZodOptional<z.ZodString>;
|
|
@@ -92,7 +111,7 @@ declare const SiteMeta: z.ZodObject<{
|
|
|
92
111
|
faviconAssetId?: string | undefined;
|
|
93
112
|
code?: string | undefined;
|
|
94
113
|
}>;
|
|
95
|
-
export type
|
|
114
|
+
export type ProjectMeta = z.infer<typeof ProjectMeta>;
|
|
96
115
|
export type Page = z.infer<typeof Page>;
|
|
97
116
|
export declare const Pages: z.ZodObject<{
|
|
98
117
|
meta: z.ZodOptional<z.ZodObject<{
|
|
@@ -108,6 +127,13 @@ export declare const Pages: z.ZodObject<{
|
|
|
108
127
|
faviconAssetId?: string | undefined;
|
|
109
128
|
code?: string | undefined;
|
|
110
129
|
}>>;
|
|
130
|
+
settings: z.ZodOptional<z.ZodObject<{
|
|
131
|
+
atomicStyles: z.ZodOptional<z.ZodBoolean>;
|
|
132
|
+
}, "strip", z.ZodTypeAny, {
|
|
133
|
+
atomicStyles?: boolean | undefined;
|
|
134
|
+
}, {
|
|
135
|
+
atomicStyles?: boolean | undefined;
|
|
136
|
+
}>>;
|
|
111
137
|
homePage: z.ZodObject<{
|
|
112
138
|
path: z.ZodEffects<z.ZodString, string, string>;
|
|
113
139
|
id: z.ZodString;
|
|
@@ -294,6 +320,32 @@ export declare const Pages: z.ZodObject<{
|
|
|
294
320
|
rootInstanceId: string;
|
|
295
321
|
pathVariableId?: string | undefined;
|
|
296
322
|
}[]>;
|
|
323
|
+
folders: z.ZodEffects<z.ZodArray<z.ZodObject<{
|
|
324
|
+
id: z.ZodString;
|
|
325
|
+
name: z.ZodEffects<z.ZodString, string, string>;
|
|
326
|
+
slug: z.ZodString;
|
|
327
|
+
children: z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodString]>, "many">;
|
|
328
|
+
}, "strip", z.ZodTypeAny, {
|
|
329
|
+
name: string;
|
|
330
|
+
id: string;
|
|
331
|
+
slug: string;
|
|
332
|
+
children: string[];
|
|
333
|
+
}, {
|
|
334
|
+
name: string;
|
|
335
|
+
id: string;
|
|
336
|
+
slug: string;
|
|
337
|
+
children: string[];
|
|
338
|
+
}>, "many">, {
|
|
339
|
+
name: string;
|
|
340
|
+
id: string;
|
|
341
|
+
slug: string;
|
|
342
|
+
children: string[];
|
|
343
|
+
}[], {
|
|
344
|
+
name: string;
|
|
345
|
+
id: string;
|
|
346
|
+
slug: string;
|
|
347
|
+
children: string[];
|
|
348
|
+
}[]>;
|
|
297
349
|
}, "strip", z.ZodTypeAny, {
|
|
298
350
|
homePage: {
|
|
299
351
|
path: string;
|
|
@@ -331,11 +383,20 @@ export declare const Pages: z.ZodObject<{
|
|
|
331
383
|
rootInstanceId: string;
|
|
332
384
|
pathVariableId?: string | undefined;
|
|
333
385
|
}[];
|
|
386
|
+
folders: {
|
|
387
|
+
name: string;
|
|
388
|
+
id: string;
|
|
389
|
+
slug: string;
|
|
390
|
+
children: string[];
|
|
391
|
+
}[];
|
|
334
392
|
meta?: {
|
|
335
393
|
siteName?: string | undefined;
|
|
336
394
|
faviconAssetId?: string | undefined;
|
|
337
395
|
code?: string | undefined;
|
|
338
396
|
} | undefined;
|
|
397
|
+
settings?: {
|
|
398
|
+
atomicStyles?: boolean | undefined;
|
|
399
|
+
} | undefined;
|
|
339
400
|
}, {
|
|
340
401
|
homePage: {
|
|
341
402
|
path: string;
|
|
@@ -373,11 +434,20 @@ export declare const Pages: z.ZodObject<{
|
|
|
373
434
|
rootInstanceId: string;
|
|
374
435
|
pathVariableId?: string | undefined;
|
|
375
436
|
}[];
|
|
437
|
+
folders: {
|
|
438
|
+
name: string;
|
|
439
|
+
id: string;
|
|
440
|
+
slug: string;
|
|
441
|
+
children: string[];
|
|
442
|
+
}[];
|
|
376
443
|
meta?: {
|
|
377
444
|
siteName?: string | undefined;
|
|
378
445
|
faviconAssetId?: string | undefined;
|
|
379
446
|
code?: string | undefined;
|
|
380
447
|
} | undefined;
|
|
448
|
+
settings?: {
|
|
449
|
+
atomicStyles?: boolean | undefined;
|
|
450
|
+
} | undefined;
|
|
381
451
|
}>;
|
|
382
452
|
export type Pages = z.infer<typeof Pages>;
|
|
383
453
|
export {};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const Resource: z.ZodObject<{
|
|
3
|
+
id: z.ZodString;
|
|
4
|
+
name: z.ZodString;
|
|
5
|
+
method: z.ZodUnion<[z.ZodLiteral<"get">, z.ZodLiteral<"post">, z.ZodLiteral<"put">, z.ZodLiteral<"delete">]>;
|
|
6
|
+
url: z.ZodString;
|
|
7
|
+
headers: z.ZodArray<z.ZodObject<{
|
|
8
|
+
name: z.ZodString;
|
|
9
|
+
value: z.ZodString;
|
|
10
|
+
}, "strip", z.ZodTypeAny, {
|
|
11
|
+
value: string;
|
|
12
|
+
name: string;
|
|
13
|
+
}, {
|
|
14
|
+
value: string;
|
|
15
|
+
name: string;
|
|
16
|
+
}>, "many">;
|
|
17
|
+
body: z.ZodOptional<z.ZodString>;
|
|
18
|
+
}, "strip", z.ZodTypeAny, {
|
|
19
|
+
name: string;
|
|
20
|
+
id: string;
|
|
21
|
+
method: "get" | "post" | "put" | "delete";
|
|
22
|
+
url: string;
|
|
23
|
+
headers: {
|
|
24
|
+
value: string;
|
|
25
|
+
name: string;
|
|
26
|
+
}[];
|
|
27
|
+
body?: string | undefined;
|
|
28
|
+
}, {
|
|
29
|
+
name: string;
|
|
30
|
+
id: string;
|
|
31
|
+
method: "get" | "post" | "put" | "delete";
|
|
32
|
+
url: string;
|
|
33
|
+
headers: {
|
|
34
|
+
value: string;
|
|
35
|
+
name: string;
|
|
36
|
+
}[];
|
|
37
|
+
body?: string | undefined;
|
|
38
|
+
}>;
|
|
39
|
+
export type Resource = z.infer<typeof Resource>;
|
|
40
|
+
export declare const Resources: z.ZodMap<z.ZodString, z.ZodObject<{
|
|
41
|
+
id: z.ZodString;
|
|
42
|
+
name: z.ZodString;
|
|
43
|
+
method: z.ZodUnion<[z.ZodLiteral<"get">, z.ZodLiteral<"post">, z.ZodLiteral<"put">, z.ZodLiteral<"delete">]>;
|
|
44
|
+
url: z.ZodString;
|
|
45
|
+
headers: z.ZodArray<z.ZodObject<{
|
|
46
|
+
name: z.ZodString;
|
|
47
|
+
value: z.ZodString;
|
|
48
|
+
}, "strip", z.ZodTypeAny, {
|
|
49
|
+
value: string;
|
|
50
|
+
name: string;
|
|
51
|
+
}, {
|
|
52
|
+
value: string;
|
|
53
|
+
name: string;
|
|
54
|
+
}>, "many">;
|
|
55
|
+
body: z.ZodOptional<z.ZodString>;
|
|
56
|
+
}, "strip", z.ZodTypeAny, {
|
|
57
|
+
name: string;
|
|
58
|
+
id: string;
|
|
59
|
+
method: "get" | "post" | "put" | "delete";
|
|
60
|
+
url: string;
|
|
61
|
+
headers: {
|
|
62
|
+
value: string;
|
|
63
|
+
name: string;
|
|
64
|
+
}[];
|
|
65
|
+
body?: string | undefined;
|
|
66
|
+
}, {
|
|
67
|
+
name: string;
|
|
68
|
+
id: string;
|
|
69
|
+
method: "get" | "post" | "put" | "delete";
|
|
70
|
+
url: string;
|
|
71
|
+
headers: {
|
|
72
|
+
value: string;
|
|
73
|
+
name: string;
|
|
74
|
+
}[];
|
|
75
|
+
body?: string | undefined;
|
|
76
|
+
}>>;
|
|
77
|
+
export type Resources = z.infer<typeof Resources>;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webstudio-is/sdk",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Webstudio
|
|
3
|
+
"version": "0.125.0",
|
|
4
|
+
"description": "Webstudio project data schema",
|
|
5
5
|
"author": "Webstudio <github@webstudio.is>",
|
|
6
6
|
"homepage": "https://webstudio.is",
|
|
7
7
|
"license": "AGPL-3.0-or-later",
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
"sideEffects": false,
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"zod": "^3.21.4",
|
|
22
|
-
"@webstudio-is/css-engine": "0.
|
|
23
|
-
"@webstudio-is/fonts": "0.
|
|
22
|
+
"@webstudio-is/css-engine": "0.125.0",
|
|
23
|
+
"@webstudio-is/fonts": "0.125.0"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@jest/globals": "^29.7.0",
|