@webstudio-is/sdk 0.126.0 → 0.128.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 +39 -13
- package/lib/types/schema/pages.d.ts +38 -0
- package/package.json +5 -5
package/lib/index.js
CHANGED
|
@@ -97,9 +97,24 @@ var ProjectMeta = z2.object({
|
|
|
97
97
|
faviconAssetId: z2.string().optional(),
|
|
98
98
|
code: z2.string().optional()
|
|
99
99
|
});
|
|
100
|
+
var ProjectNewRedirectPathSchema = PagePath.or(
|
|
101
|
+
z2.string().refine((data) => {
|
|
102
|
+
try {
|
|
103
|
+
new URL(data);
|
|
104
|
+
return true;
|
|
105
|
+
} catch {
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
108
|
+
}, "Must be a valid URL")
|
|
109
|
+
);
|
|
110
|
+
var PageRedirectSchema = z2.object({
|
|
111
|
+
old: PagePath,
|
|
112
|
+
new: ProjectNewRedirectPathSchema
|
|
113
|
+
});
|
|
100
114
|
var ProjectSettings = z2.object({
|
|
101
115
|
// All fields are optional to ensure consistency and allow for the addition of new fields without requiring migration
|
|
102
|
-
atomicStyles: z2.boolean().optional()
|
|
116
|
+
atomicStyles: z2.boolean().optional(),
|
|
117
|
+
redirects: z2.array(PageRedirectSchema).optional()
|
|
103
118
|
});
|
|
104
119
|
var Pages = z2.object({
|
|
105
120
|
meta: ProjectMeta.optional(),
|
|
@@ -522,19 +537,28 @@ var loadResource = async (resourceData) => {
|
|
|
522
537
|
if (method !== "get" && body !== void 0) {
|
|
523
538
|
requestInit.body = body;
|
|
524
539
|
}
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
540
|
+
try {
|
|
541
|
+
const response = await fetch(url, requestInit);
|
|
542
|
+
let data;
|
|
543
|
+
if (response.ok && // accept json by default and when specified explicitly
|
|
544
|
+
(requestHeaders.has("accept") === false || requestHeaders.get("accept") === "application/json")) {
|
|
545
|
+
data = await response.json();
|
|
546
|
+
} else {
|
|
547
|
+
data = await response.text();
|
|
548
|
+
}
|
|
549
|
+
return {
|
|
550
|
+
data,
|
|
551
|
+
status: response.status,
|
|
552
|
+
statusText: response.statusText
|
|
553
|
+
};
|
|
554
|
+
} catch (error) {
|
|
555
|
+
const message = error.message;
|
|
556
|
+
return {
|
|
557
|
+
data: void 0,
|
|
558
|
+
status: 500,
|
|
559
|
+
statusText: message
|
|
560
|
+
};
|
|
532
561
|
}
|
|
533
|
-
return {
|
|
534
|
-
data,
|
|
535
|
-
status: response.status,
|
|
536
|
-
statusText: response.statusText
|
|
537
|
-
};
|
|
538
562
|
};
|
|
539
563
|
export {
|
|
540
564
|
Asset,
|
|
@@ -558,8 +582,10 @@ export {
|
|
|
558
582
|
Instances,
|
|
559
583
|
PageName,
|
|
560
584
|
PagePath,
|
|
585
|
+
PageRedirectSchema,
|
|
561
586
|
PageTitle,
|
|
562
587
|
Pages,
|
|
588
|
+
ProjectNewRedirectPathSchema,
|
|
563
589
|
Prop,
|
|
564
590
|
Props,
|
|
565
591
|
ROOT_FOLDER_ID,
|
|
@@ -110,6 +110,18 @@ declare const ProjectMeta: z.ZodObject<{
|
|
|
110
110
|
faviconAssetId?: string | undefined;
|
|
111
111
|
code?: string | undefined;
|
|
112
112
|
}>;
|
|
113
|
+
export declare const ProjectNewRedirectPathSchema: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>, string, string>, string, string>, string, string>, string, string>, string, string>, string, string>, z.ZodEffects<z.ZodString, string, string>]>;
|
|
114
|
+
export declare const PageRedirectSchema: z.ZodObject<{
|
|
115
|
+
old: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>, string, string>, string, string>, string, string>, string, string>, string, string>, string, string>;
|
|
116
|
+
new: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>, string, string>, string, string>, string, string>, string, string>, string, string>, string, string>, z.ZodEffects<z.ZodString, string, string>]>;
|
|
117
|
+
}, "strip", z.ZodTypeAny, {
|
|
118
|
+
old: string;
|
|
119
|
+
new: string;
|
|
120
|
+
}, {
|
|
121
|
+
old: string;
|
|
122
|
+
new: string;
|
|
123
|
+
}>;
|
|
124
|
+
export type PageRedirect = z.infer<typeof PageRedirectSchema>;
|
|
113
125
|
export type ProjectMeta = z.infer<typeof ProjectMeta>;
|
|
114
126
|
export type Page = z.infer<typeof Page>;
|
|
115
127
|
export declare const Pages: z.ZodObject<{
|
|
@@ -128,10 +140,28 @@ export declare const Pages: z.ZodObject<{
|
|
|
128
140
|
}>>;
|
|
129
141
|
settings: z.ZodOptional<z.ZodObject<{
|
|
130
142
|
atomicStyles: z.ZodOptional<z.ZodBoolean>;
|
|
143
|
+
redirects: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
144
|
+
old: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>, string, string>, string, string>, string, string>, string, string>, string, string>, string, string>;
|
|
145
|
+
new: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>, string, string>, string, string>, string, string>, string, string>, string, string>, string, string>, z.ZodEffects<z.ZodString, string, string>]>;
|
|
146
|
+
}, "strip", z.ZodTypeAny, {
|
|
147
|
+
old: string;
|
|
148
|
+
new: string;
|
|
149
|
+
}, {
|
|
150
|
+
old: string;
|
|
151
|
+
new: string;
|
|
152
|
+
}>, "many">>;
|
|
131
153
|
}, "strip", z.ZodTypeAny, {
|
|
132
154
|
atomicStyles?: boolean | undefined;
|
|
155
|
+
redirects?: {
|
|
156
|
+
old: string;
|
|
157
|
+
new: string;
|
|
158
|
+
}[] | undefined;
|
|
133
159
|
}, {
|
|
134
160
|
atomicStyles?: boolean | undefined;
|
|
161
|
+
redirects?: {
|
|
162
|
+
old: string;
|
|
163
|
+
new: string;
|
|
164
|
+
}[] | undefined;
|
|
135
165
|
}>>;
|
|
136
166
|
homePage: z.ZodObject<{
|
|
137
167
|
path: z.ZodEffects<z.ZodString, string, string>;
|
|
@@ -395,6 +425,10 @@ export declare const Pages: z.ZodObject<{
|
|
|
395
425
|
} | undefined;
|
|
396
426
|
settings?: {
|
|
397
427
|
atomicStyles?: boolean | undefined;
|
|
428
|
+
redirects?: {
|
|
429
|
+
old: string;
|
|
430
|
+
new: string;
|
|
431
|
+
}[] | undefined;
|
|
398
432
|
} | undefined;
|
|
399
433
|
}, {
|
|
400
434
|
homePage: {
|
|
@@ -446,6 +480,10 @@ export declare const Pages: z.ZodObject<{
|
|
|
446
480
|
} | undefined;
|
|
447
481
|
settings?: {
|
|
448
482
|
atomicStyles?: boolean | undefined;
|
|
483
|
+
redirects?: {
|
|
484
|
+
old: string;
|
|
485
|
+
new: string;
|
|
486
|
+
}[] | undefined;
|
|
449
487
|
} | undefined;
|
|
450
488
|
}>;
|
|
451
489
|
export type Pages = z.infer<typeof Pages>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webstudio-is/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.128.0",
|
|
4
4
|
"description": "Webstudio project data schema",
|
|
5
5
|
"author": "Webstudio <github@webstudio.is>",
|
|
6
6
|
"homepage": "https://webstudio.is",
|
|
@@ -19,13 +19,13 @@
|
|
|
19
19
|
"sideEffects": false,
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"zod": "^3.21.4",
|
|
22
|
-
"@webstudio-is/
|
|
23
|
-
"@webstudio-is/
|
|
22
|
+
"@webstudio-is/css-engine": "0.128.0",
|
|
23
|
+
"@webstudio-is/fonts": "0.128.0"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@jest/globals": "^29.7.0",
|
|
27
|
-
"@webstudio-is/
|
|
28
|
-
"@webstudio-is/
|
|
27
|
+
"@webstudio-is/jest-config": "1.0.7",
|
|
28
|
+
"@webstudio-is/tsconfig": "1.0.7"
|
|
29
29
|
},
|
|
30
30
|
"scripts": {
|
|
31
31
|
"typecheck": "tsc",
|