@webstudio-is/sdk 0.145.0 → 0.163.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 +238 -133
- package/lib/types/expression.d.ts +10 -0
- package/lib/types/index.d.ts +1 -0
- package/lib/types/page-utils.d.ts +4 -0
- package/lib/types/resource-loader.d.ts +1 -1
- package/lib/types/schema/assets.d.ts +9 -9
- package/lib/types/schema/pages.d.ts +55 -13
- package/lib/types/schema/resources.d.ts +11 -0
- package/lib/types/schema/webstudio.d.ts +10 -5
- package/lib/types/url-pattern.d.ts +2 -0
- package/lib/types/url-pattern.test.d.ts +1 -0
- package/package.json +4 -5
package/lib/index.js
CHANGED
|
@@ -50,10 +50,12 @@ var PageTitle = z2.string().refine(
|
|
|
50
50
|
(val) => val.length >= MIN_TITLE_LENGTH,
|
|
51
51
|
`Minimum ${MIN_TITLE_LENGTH} characters required`
|
|
52
52
|
);
|
|
53
|
+
var documentTypes = ["html", "xml"];
|
|
53
54
|
var commonPageFields = {
|
|
54
55
|
id: PageId,
|
|
55
56
|
name: PageName,
|
|
56
57
|
title: PageTitle,
|
|
58
|
+
history: z2.optional(z2.array(z2.string())),
|
|
57
59
|
meta: z2.object({
|
|
58
60
|
description: z2.string().optional(),
|
|
59
61
|
title: z2.string().optional(),
|
|
@@ -63,6 +65,7 @@ var commonPageFields = {
|
|
|
63
65
|
socialImageUrl: z2.string().optional(),
|
|
64
66
|
status: z2.string().optional(),
|
|
65
67
|
redirect: z2.string().optional(),
|
|
68
|
+
documentType: z2.optional(z2.enum(documentTypes)),
|
|
66
69
|
custom: z2.array(
|
|
67
70
|
z2.object({
|
|
68
71
|
property: z2.string(),
|
|
@@ -71,8 +74,7 @@ var commonPageFields = {
|
|
|
71
74
|
).optional()
|
|
72
75
|
}),
|
|
73
76
|
rootInstanceId: z2.string(),
|
|
74
|
-
|
|
75
|
-
systemDataSourceId: z2.optional(z2.string())
|
|
77
|
+
systemDataSourceId: z2.string()
|
|
76
78
|
};
|
|
77
79
|
var HomePagePath = z2.string().refine((path) => path === "", "Home page path must be empty");
|
|
78
80
|
var HomePage = z2.object({
|
|
@@ -80,8 +82,8 @@ var HomePage = z2.object({
|
|
|
80
82
|
path: HomePagePath
|
|
81
83
|
});
|
|
82
84
|
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(
|
|
83
|
-
(path) => /^[-_a-z0-9
|
|
84
|
-
"Only a-z, 0-9, -, _, /, :,
|
|
85
|
+
(path) => /^[-_a-z0-9*:?\\/.]*$/.test(path),
|
|
86
|
+
"Only a-z, 0-9, -, _, /, :, ?, . and * are allowed"
|
|
85
87
|
).refine(
|
|
86
88
|
// We use /s for our system stuff like /s/css or /s/uploads
|
|
87
89
|
(path) => path !== "/s" && path.startsWith("/s/") === false,
|
|
@@ -99,11 +101,15 @@ var Page = z2.object({
|
|
|
99
101
|
var ProjectMeta = z2.object({
|
|
100
102
|
// All fields are optional to ensure consistency and allow for the addition of new fields without requiring migration
|
|
101
103
|
siteName: z2.string().optional(),
|
|
104
|
+
contactEmail: z2.string().optional(),
|
|
102
105
|
faviconAssetId: z2.string().optional(),
|
|
103
106
|
code: z2.string().optional()
|
|
104
107
|
});
|
|
105
108
|
var ProjectNewRedirectPath = PagePath.or(
|
|
106
109
|
z2.string().refine((data) => {
|
|
110
|
+
if (data === "/") {
|
|
111
|
+
return true;
|
|
112
|
+
}
|
|
107
113
|
try {
|
|
108
114
|
new URL(data);
|
|
109
115
|
return true;
|
|
@@ -222,6 +228,7 @@ var Header = z5.object({
|
|
|
222
228
|
var Resource = z5.object({
|
|
223
229
|
id: ResourceId,
|
|
224
230
|
name: z5.string(),
|
|
231
|
+
control: z5.optional(z5.union([z5.literal("system"), z5.literal("graphql")])),
|
|
225
232
|
method: Method,
|
|
226
233
|
// expression
|
|
227
234
|
url: z5.string(),
|
|
@@ -238,6 +245,15 @@ var ResourceRequest = z5.object({
|
|
|
238
245
|
body: z5.optional(z5.unknown())
|
|
239
246
|
});
|
|
240
247
|
var Resources = z5.map(ResourceId, Resource);
|
|
248
|
+
var LOCAL_RESOURCE_PREFIX = "$resources";
|
|
249
|
+
var isLocalResource = (pathname, resourceName) => {
|
|
250
|
+
const segments = pathname.split("/").filter(Boolean);
|
|
251
|
+
if (resourceName === void 0) {
|
|
252
|
+
return segments[0] === LOCAL_RESOURCE_PREFIX;
|
|
253
|
+
}
|
|
254
|
+
return segments.join("/") === `${LOCAL_RESOURCE_PREFIX}/${resourceName}`;
|
|
255
|
+
};
|
|
256
|
+
var sitemapResourceUrl = `/${LOCAL_RESOURCE_PREFIX}/sitemap.xml`;
|
|
241
257
|
|
|
242
258
|
// src/schema/props.ts
|
|
243
259
|
import { z as z6 } from "zod";
|
|
@@ -451,133 +467,6 @@ var parseComponentName = (componentName) => {
|
|
|
451
467
|
return [namespace, name];
|
|
452
468
|
};
|
|
453
469
|
|
|
454
|
-
// src/page-utils.ts
|
|
455
|
-
var ROOT_FOLDER_ID = "root";
|
|
456
|
-
var isRoot = (folder) => folder.id === ROOT_FOLDER_ID;
|
|
457
|
-
var findPageByIdOrPath = (idOrPath, pages) => {
|
|
458
|
-
if (idOrPath === "" || idOrPath === "/" || idOrPath === pages.homePage.id) {
|
|
459
|
-
return pages.homePage;
|
|
460
|
-
}
|
|
461
|
-
return pages.pages.find(
|
|
462
|
-
(page) => page.id === idOrPath || getPagePath(page.id, pages) === idOrPath
|
|
463
|
-
);
|
|
464
|
-
};
|
|
465
|
-
var findParentFolderByChildId = (id, folders) => {
|
|
466
|
-
for (const folder of folders) {
|
|
467
|
-
if (folder.children.includes(id)) {
|
|
468
|
-
return folder;
|
|
469
|
-
}
|
|
470
|
-
}
|
|
471
|
-
};
|
|
472
|
-
var getPagePath = (id, pages) => {
|
|
473
|
-
const foldersMap = /* @__PURE__ */ new Map();
|
|
474
|
-
const childParentMap = /* @__PURE__ */ new Map();
|
|
475
|
-
for (const folder of pages.folders) {
|
|
476
|
-
foldersMap.set(folder.id, folder);
|
|
477
|
-
for (const childId of folder.children) {
|
|
478
|
-
childParentMap.set(childId, folder.id);
|
|
479
|
-
}
|
|
480
|
-
}
|
|
481
|
-
const paths = [];
|
|
482
|
-
let currentId = id;
|
|
483
|
-
const allPages = [pages.homePage, ...pages.pages];
|
|
484
|
-
for (const page of allPages) {
|
|
485
|
-
if (page.id === id) {
|
|
486
|
-
paths.push(page.path);
|
|
487
|
-
currentId = childParentMap.get(page.id);
|
|
488
|
-
break;
|
|
489
|
-
}
|
|
490
|
-
}
|
|
491
|
-
while (currentId) {
|
|
492
|
-
const folder = foldersMap.get(currentId);
|
|
493
|
-
if (folder === void 0) {
|
|
494
|
-
break;
|
|
495
|
-
}
|
|
496
|
-
paths.push(folder.slug);
|
|
497
|
-
currentId = childParentMap.get(currentId);
|
|
498
|
-
}
|
|
499
|
-
return paths.reverse().join("/").replace(/\/+/g, "/");
|
|
500
|
-
};
|
|
501
|
-
|
|
502
|
-
// src/scope.ts
|
|
503
|
-
var normalizeName = (name) => {
|
|
504
|
-
name = name.replaceAll(/[^\w$]/g, "");
|
|
505
|
-
if (name.length === 0) {
|
|
506
|
-
return "_";
|
|
507
|
-
}
|
|
508
|
-
if (/[A-Za-z_$]/.test(name[0]) === false) {
|
|
509
|
-
name = `_${name}`;
|
|
510
|
-
}
|
|
511
|
-
return name;
|
|
512
|
-
};
|
|
513
|
-
var createScope = (occupiedIdentifiers = []) => {
|
|
514
|
-
const freeIndexByPreferredName = /* @__PURE__ */ new Map();
|
|
515
|
-
const scopedNameByIdMap = /* @__PURE__ */ new Map();
|
|
516
|
-
for (const identifier of occupiedIdentifiers) {
|
|
517
|
-
freeIndexByPreferredName.set(identifier, 1);
|
|
518
|
-
}
|
|
519
|
-
const getName = (id, preferredName) => {
|
|
520
|
-
const cachedName = scopedNameByIdMap.get(id);
|
|
521
|
-
if (cachedName !== void 0) {
|
|
522
|
-
return cachedName;
|
|
523
|
-
}
|
|
524
|
-
preferredName = normalizeName(preferredName);
|
|
525
|
-
const index = freeIndexByPreferredName.get(preferredName);
|
|
526
|
-
freeIndexByPreferredName.set(preferredName, (index ?? 0) + 1);
|
|
527
|
-
let scopedName = preferredName;
|
|
528
|
-
if (index !== void 0) {
|
|
529
|
-
scopedName = `${preferredName}_${index}`;
|
|
530
|
-
}
|
|
531
|
-
scopedNameByIdMap.set(id, scopedName);
|
|
532
|
-
return scopedName;
|
|
533
|
-
};
|
|
534
|
-
return {
|
|
535
|
-
getName
|
|
536
|
-
};
|
|
537
|
-
};
|
|
538
|
-
|
|
539
|
-
// src/resource-loader.ts
|
|
540
|
-
var loadResource = async (resourceData) => {
|
|
541
|
-
const { url, method, headers, body } = resourceData;
|
|
542
|
-
const requestHeaders = new Headers(
|
|
543
|
-
headers.map(({ name, value }) => [name, value])
|
|
544
|
-
);
|
|
545
|
-
const requestInit = {
|
|
546
|
-
method,
|
|
547
|
-
headers: requestHeaders
|
|
548
|
-
};
|
|
549
|
-
if (method !== "get" && body !== void 0) {
|
|
550
|
-
if (typeof body === "string") {
|
|
551
|
-
requestInit.body = body;
|
|
552
|
-
}
|
|
553
|
-
if (typeof body === "object") {
|
|
554
|
-
requestInit.body = JSON.stringify(body);
|
|
555
|
-
}
|
|
556
|
-
}
|
|
557
|
-
try {
|
|
558
|
-
const response = await fetch(url.trim(), requestInit);
|
|
559
|
-
let data;
|
|
560
|
-
if (response.ok && // accept json by default and when specified explicitly
|
|
561
|
-
(requestHeaders.has("accept") === false || requestHeaders.get("accept") === "application/json")) {
|
|
562
|
-
data = await response.json();
|
|
563
|
-
} else {
|
|
564
|
-
data = await response.text();
|
|
565
|
-
}
|
|
566
|
-
return {
|
|
567
|
-
data,
|
|
568
|
-
status: response.status,
|
|
569
|
-
statusText: response.statusText
|
|
570
|
-
};
|
|
571
|
-
} catch (error) {
|
|
572
|
-
const message = error.message;
|
|
573
|
-
return {
|
|
574
|
-
data: void 0,
|
|
575
|
-
status: 500,
|
|
576
|
-
statusText: message
|
|
577
|
-
};
|
|
578
|
-
}
|
|
579
|
-
};
|
|
580
|
-
|
|
581
470
|
// src/expression.ts
|
|
582
471
|
import { parseExpressionAt } from "acorn";
|
|
583
472
|
import { simple } from "acorn-walk";
|
|
@@ -777,6 +666,50 @@ var transpileExpression = ({
|
|
|
777
666
|
}
|
|
778
667
|
return expression;
|
|
779
668
|
};
|
|
669
|
+
var parseObjectExpression = (expression) => {
|
|
670
|
+
const map = /* @__PURE__ */ new Map();
|
|
671
|
+
let root;
|
|
672
|
+
try {
|
|
673
|
+
root = parseExpressionAt(expression, 0, { ecmaVersion: "latest" });
|
|
674
|
+
} catch (error) {
|
|
675
|
+
return map;
|
|
676
|
+
}
|
|
677
|
+
if (root.type !== "ObjectExpression") {
|
|
678
|
+
return map;
|
|
679
|
+
}
|
|
680
|
+
for (const property of root.properties) {
|
|
681
|
+
if (property.type === "SpreadElement") {
|
|
682
|
+
continue;
|
|
683
|
+
}
|
|
684
|
+
if (property.computed) {
|
|
685
|
+
continue;
|
|
686
|
+
}
|
|
687
|
+
let key;
|
|
688
|
+
if (property.key.type === "Identifier") {
|
|
689
|
+
key = property.key.name;
|
|
690
|
+
} else if (property.key.type === "Literal" && typeof property.key.value === "string") {
|
|
691
|
+
key = property.key.value;
|
|
692
|
+
} else {
|
|
693
|
+
continue;
|
|
694
|
+
}
|
|
695
|
+
const valueExpression = expression.slice(
|
|
696
|
+
property.value.start,
|
|
697
|
+
property.value.end
|
|
698
|
+
);
|
|
699
|
+
map.set(key, valueExpression);
|
|
700
|
+
}
|
|
701
|
+
return map;
|
|
702
|
+
};
|
|
703
|
+
var generateObjectExpression = (map) => {
|
|
704
|
+
let generated = "{\n";
|
|
705
|
+
for (const [key, valueExpression] of map) {
|
|
706
|
+
const keyExpression = JSON.stringify(key);
|
|
707
|
+
generated += ` ${keyExpression}: ${valueExpression},
|
|
708
|
+
`;
|
|
709
|
+
}
|
|
710
|
+
generated += `}`;
|
|
711
|
+
return generated;
|
|
712
|
+
};
|
|
780
713
|
var dataSourceVariablePrefix = "$ws$dataSource$";
|
|
781
714
|
var encodeDataSourceVariable = (id) => {
|
|
782
715
|
const encoded = id.replaceAll("-", "__DASH__");
|
|
@@ -816,6 +749,150 @@ var executeExpression = (expression) => {
|
|
|
816
749
|
}
|
|
817
750
|
};
|
|
818
751
|
|
|
752
|
+
// src/url-pattern.ts
|
|
753
|
+
var tokenRegex = /:(?<name>\w+)(?<modifier>[?*]?)|(?<wildcard>(?<!:\w+)\*)/;
|
|
754
|
+
var isPathnamePattern = (pathname) => tokenRegex.test(pathname);
|
|
755
|
+
var tokenRegexGlobal = new RegExp(tokenRegex.source, "g");
|
|
756
|
+
var matchPathnameParams = (pathname) => {
|
|
757
|
+
return pathname.matchAll(tokenRegexGlobal);
|
|
758
|
+
};
|
|
759
|
+
|
|
760
|
+
// src/page-utils.ts
|
|
761
|
+
var ROOT_FOLDER_ID = "root";
|
|
762
|
+
var isRoot = (folder) => folder.id === ROOT_FOLDER_ID;
|
|
763
|
+
var findPageByIdOrPath = (idOrPath, pages) => {
|
|
764
|
+
if (idOrPath === "" || idOrPath === "/" || idOrPath === pages.homePage.id) {
|
|
765
|
+
return pages.homePage;
|
|
766
|
+
}
|
|
767
|
+
return pages.pages.find(
|
|
768
|
+
(page) => page.id === idOrPath || getPagePath(page.id, pages) === idOrPath
|
|
769
|
+
);
|
|
770
|
+
};
|
|
771
|
+
var findParentFolderByChildId = (id, folders) => {
|
|
772
|
+
for (const folder of folders) {
|
|
773
|
+
if (folder.children.includes(id)) {
|
|
774
|
+
return folder;
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
};
|
|
778
|
+
var getPagePath = (id, pages) => {
|
|
779
|
+
const foldersMap = /* @__PURE__ */ new Map();
|
|
780
|
+
const childParentMap = /* @__PURE__ */ new Map();
|
|
781
|
+
for (const folder of pages.folders) {
|
|
782
|
+
foldersMap.set(folder.id, folder);
|
|
783
|
+
for (const childId of folder.children) {
|
|
784
|
+
childParentMap.set(childId, folder.id);
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
const paths = [];
|
|
788
|
+
let currentId = id;
|
|
789
|
+
const allPages = [pages.homePage, ...pages.pages];
|
|
790
|
+
for (const page of allPages) {
|
|
791
|
+
if (page.id === id) {
|
|
792
|
+
paths.push(page.path);
|
|
793
|
+
currentId = childParentMap.get(page.id);
|
|
794
|
+
break;
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
while (currentId) {
|
|
798
|
+
const folder = foldersMap.get(currentId);
|
|
799
|
+
if (folder === void 0) {
|
|
800
|
+
break;
|
|
801
|
+
}
|
|
802
|
+
paths.push(folder.slug);
|
|
803
|
+
currentId = childParentMap.get(currentId);
|
|
804
|
+
}
|
|
805
|
+
return paths.reverse().join("/").replace(/\/+/g, "/");
|
|
806
|
+
};
|
|
807
|
+
var getStaticSiteMapXml = (pages, updatedAt) => {
|
|
808
|
+
const allPages = [pages.homePage, ...pages.pages];
|
|
809
|
+
return allPages.filter((page) => (page.meta.documentType ?? "html") === "html").filter(
|
|
810
|
+
(page) => executeExpression(page.meta.excludePageFromSearch) !== true
|
|
811
|
+
).filter((page) => false === isPathnamePattern(page.path)).map((page) => ({
|
|
812
|
+
path: getPagePath(page.id, pages),
|
|
813
|
+
lastModified: updatedAt.split("T")[0]
|
|
814
|
+
}));
|
|
815
|
+
};
|
|
816
|
+
|
|
817
|
+
// src/scope.ts
|
|
818
|
+
var normalizeName = (name) => {
|
|
819
|
+
name = name.replaceAll(/[^\w$]/g, "");
|
|
820
|
+
if (name.length === 0) {
|
|
821
|
+
return "_";
|
|
822
|
+
}
|
|
823
|
+
if (/[A-Za-z_$]/.test(name[0]) === false) {
|
|
824
|
+
name = `_${name}`;
|
|
825
|
+
}
|
|
826
|
+
return name;
|
|
827
|
+
};
|
|
828
|
+
var createScope = (occupiedIdentifiers = []) => {
|
|
829
|
+
const freeIndexByPreferredName = /* @__PURE__ */ new Map();
|
|
830
|
+
const scopedNameByIdMap = /* @__PURE__ */ new Map();
|
|
831
|
+
for (const identifier of occupiedIdentifiers) {
|
|
832
|
+
freeIndexByPreferredName.set(identifier, 1);
|
|
833
|
+
}
|
|
834
|
+
const getName = (id, preferredName) => {
|
|
835
|
+
const cachedName = scopedNameByIdMap.get(id);
|
|
836
|
+
if (cachedName !== void 0) {
|
|
837
|
+
return cachedName;
|
|
838
|
+
}
|
|
839
|
+
preferredName = normalizeName(preferredName);
|
|
840
|
+
const index = freeIndexByPreferredName.get(preferredName);
|
|
841
|
+
freeIndexByPreferredName.set(preferredName, (index ?? 0) + 1);
|
|
842
|
+
let scopedName = preferredName;
|
|
843
|
+
if (index !== void 0) {
|
|
844
|
+
scopedName = `${preferredName}_${index}`;
|
|
845
|
+
}
|
|
846
|
+
scopedNameByIdMap.set(id, scopedName);
|
|
847
|
+
return scopedName;
|
|
848
|
+
};
|
|
849
|
+
return {
|
|
850
|
+
getName
|
|
851
|
+
};
|
|
852
|
+
};
|
|
853
|
+
|
|
854
|
+
// src/resource-loader.ts
|
|
855
|
+
var loadResource = async (customFetch, resourceData) => {
|
|
856
|
+
const { url, method, headers, body } = resourceData;
|
|
857
|
+
const requestHeaders = new Headers(
|
|
858
|
+
headers.map(({ name, value }) => [name, value])
|
|
859
|
+
);
|
|
860
|
+
const requestInit = {
|
|
861
|
+
method,
|
|
862
|
+
headers: requestHeaders
|
|
863
|
+
};
|
|
864
|
+
if (method !== "get" && body !== void 0) {
|
|
865
|
+
if (typeof body === "string") {
|
|
866
|
+
requestInit.body = body;
|
|
867
|
+
}
|
|
868
|
+
if (typeof body === "object") {
|
|
869
|
+
requestInit.body = JSON.stringify(body);
|
|
870
|
+
}
|
|
871
|
+
}
|
|
872
|
+
try {
|
|
873
|
+
const response = await customFetch(url.trim(), requestInit);
|
|
874
|
+
let data;
|
|
875
|
+
if (response.ok && // accept json by default and when specified explicitly
|
|
876
|
+
(requestHeaders.has("accept") === false || requestHeaders.get("accept") === "application/json")) {
|
|
877
|
+
data = await response.json();
|
|
878
|
+
} else {
|
|
879
|
+
data = await response.text();
|
|
880
|
+
}
|
|
881
|
+
return {
|
|
882
|
+
data,
|
|
883
|
+
status: response.status,
|
|
884
|
+
statusText: response.statusText
|
|
885
|
+
};
|
|
886
|
+
} catch (error) {
|
|
887
|
+
const message = error.message;
|
|
888
|
+
return {
|
|
889
|
+
data: void 0,
|
|
890
|
+
status: 500,
|
|
891
|
+
statusText: message
|
|
892
|
+
};
|
|
893
|
+
}
|
|
894
|
+
};
|
|
895
|
+
|
|
819
896
|
// src/forms-generator.ts
|
|
820
897
|
var generateFormsProperties = (props) => {
|
|
821
898
|
const formsProperties = /* @__PURE__ */ new Map();
|
|
@@ -861,7 +938,7 @@ var generateResourcesLoader = ({
|
|
|
861
938
|
const resourceName = scope.getName(resource.id, dataSource.name);
|
|
862
939
|
generatedOutput += `${resourceName},
|
|
863
940
|
`;
|
|
864
|
-
generatedLoaders += `loadResource({
|
|
941
|
+
generatedLoaders += `loadResource(customFetch, {
|
|
865
942
|
`;
|
|
866
943
|
generatedLoaders += `id: "${resource.id}",
|
|
867
944
|
`;
|
|
@@ -923,12 +1000,32 @@ var generateResourcesLoader = ({
|
|
|
923
1000
|
}
|
|
924
1001
|
}
|
|
925
1002
|
let generated = "";
|
|
926
|
-
generated += `import { loadResource, type System } from "@webstudio-is/sdk";
|
|
1003
|
+
generated += `import { loadResource, isLocalResource, type System } from "@webstudio-is/sdk";
|
|
927
1004
|
`;
|
|
1005
|
+
if (hasResources) {
|
|
1006
|
+
generated += `import { sitemap } from "./$resources.sitemap.xml";
|
|
1007
|
+
`;
|
|
1008
|
+
}
|
|
928
1009
|
generated += `export const loadResources = async (_props: { system: System }) => {
|
|
929
1010
|
`;
|
|
930
1011
|
generated += generatedVariables;
|
|
931
1012
|
if (hasResources) {
|
|
1013
|
+
generated += `
|
|
1014
|
+
const customFetch: typeof fetch = (input, init) => {
|
|
1015
|
+
if (typeof input !== "string") {
|
|
1016
|
+
return fetch(input, init);
|
|
1017
|
+
}
|
|
1018
|
+
|
|
1019
|
+
if (isLocalResource(input, "sitemap.xml")) {
|
|
1020
|
+
// @todo: dynamic import sitemap ???
|
|
1021
|
+
const response = new Response(JSON.stringify(sitemap));
|
|
1022
|
+
response.headers.set('content-type', 'application/json; charset=utf-8');
|
|
1023
|
+
return Promise.resolve(response);
|
|
1024
|
+
}
|
|
1025
|
+
|
|
1026
|
+
return fetch(input, init);
|
|
1027
|
+
};
|
|
1028
|
+
`;
|
|
932
1029
|
generated += `const [
|
|
933
1030
|
`;
|
|
934
1031
|
generated += generatedOutput;
|
|
@@ -1136,6 +1233,7 @@ export {
|
|
|
1136
1233
|
WebstudioFragment,
|
|
1137
1234
|
createScope,
|
|
1138
1235
|
decodeDataSourceVariable,
|
|
1236
|
+
documentTypes,
|
|
1139
1237
|
encodeDataSourceVariable,
|
|
1140
1238
|
executeExpression,
|
|
1141
1239
|
findPageByIdOrPath,
|
|
@@ -1144,16 +1242,23 @@ export {
|
|
|
1144
1242
|
findTreeInstanceIdsExcludingSlotDescendants,
|
|
1145
1243
|
generateExpression,
|
|
1146
1244
|
generateFormsProperties,
|
|
1245
|
+
generateObjectExpression,
|
|
1147
1246
|
generatePageMeta,
|
|
1148
1247
|
generateResourcesLoader,
|
|
1149
1248
|
getExpressionIdentifiers,
|
|
1150
1249
|
getPagePath,
|
|
1250
|
+
getStaticSiteMapXml,
|
|
1151
1251
|
getStyleDeclKey,
|
|
1152
1252
|
initialBreakpoints,
|
|
1153
1253
|
isLiteralExpression,
|
|
1254
|
+
isLocalResource,
|
|
1255
|
+
isPathnamePattern,
|
|
1154
1256
|
isRoot,
|
|
1155
1257
|
lintExpression,
|
|
1156
1258
|
loadResource,
|
|
1259
|
+
matchPathnameParams,
|
|
1157
1260
|
parseComponentName,
|
|
1261
|
+
parseObjectExpression,
|
|
1262
|
+
sitemapResourceUrl,
|
|
1158
1263
|
transpileExpression
|
|
1159
1264
|
};
|
|
@@ -32,6 +32,16 @@ export declare const transpileExpression: ({ expression, executable, replaceVari
|
|
|
32
32
|
executable?: boolean;
|
|
33
33
|
replaceVariable?: (identifier: string, assignee: boolean) => string | undefined | void;
|
|
34
34
|
}) => string;
|
|
35
|
+
/**
|
|
36
|
+
* parse object expression into key value map
|
|
37
|
+
* where each value is expression
|
|
38
|
+
*/
|
|
39
|
+
export declare const parseObjectExpression: (expression: string) => Map<string, string>;
|
|
40
|
+
/**
|
|
41
|
+
* generate key value map into object expression
|
|
42
|
+
* after updating individual value expressions
|
|
43
|
+
*/
|
|
44
|
+
export declare const generateObjectExpression: (map: Map<string, string>) => string;
|
|
35
45
|
export declare const encodeDataSourceVariable: (id: string) => string;
|
|
36
46
|
export declare const decodeDataSourceVariable: (name: string) => string | undefined;
|
|
37
47
|
export declare const generateExpression: ({ expression, dataSources, usedDataSources, scope, }: {
|
package/lib/types/index.d.ts
CHANGED
|
@@ -16,3 +16,7 @@ export declare const findParentFolderByChildId: (id: Folder["id"] | Page["id"],
|
|
|
16
16
|
* Get a path from all folder slugs from root to the current folder or page.
|
|
17
17
|
*/
|
|
18
18
|
export declare const getPagePath: (id: Folder["id"] | Page["id"], pages: Pages) => string;
|
|
19
|
+
export declare const getStaticSiteMapXml: (pages: Pages, updatedAt: string) => {
|
|
20
|
+
path: string;
|
|
21
|
+
lastModified: string;
|
|
22
|
+
}[];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ResourceRequest } from "./schema/resources";
|
|
2
|
-
export declare const loadResource: (resourceData: ResourceRequest) => Promise<{
|
|
2
|
+
export declare const loadResource: (customFetch: typeof fetch, resourceData: ResourceRequest) => Promise<{
|
|
3
3
|
data: any;
|
|
4
4
|
status: number;
|
|
5
5
|
statusText: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
export declare const FontAsset: z.ZodObject<{
|
|
3
|
-
format: z.ZodUnion<[z.ZodLiteral<"ttf">, z.ZodLiteral<"woff">, z.ZodLiteral<"woff2"
|
|
3
|
+
format: z.ZodUnion<[z.ZodLiteral<"ttf">, z.ZodLiteral<"woff">, z.ZodLiteral<"woff2">]>;
|
|
4
4
|
meta: z.ZodUnion<[z.ZodObject<{
|
|
5
5
|
family: z.ZodString;
|
|
6
6
|
style: z.ZodEnum<["normal", "italic", "oblique"]>;
|
|
@@ -59,7 +59,7 @@ export declare const FontAsset: z.ZodObject<{
|
|
|
59
59
|
type: "font";
|
|
60
60
|
id: string;
|
|
61
61
|
name: string;
|
|
62
|
-
format: "ttf" | "woff" | "woff2"
|
|
62
|
+
format: "ttf" | "woff" | "woff2";
|
|
63
63
|
meta: ({
|
|
64
64
|
family: string;
|
|
65
65
|
style: "normal" | "italic" | "oblique";
|
|
@@ -93,7 +93,7 @@ export declare const FontAsset: z.ZodObject<{
|
|
|
93
93
|
type: "font";
|
|
94
94
|
id: string;
|
|
95
95
|
name: string;
|
|
96
|
-
format: "ttf" | "woff" | "woff2"
|
|
96
|
+
format: "ttf" | "woff" | "woff2";
|
|
97
97
|
meta: ({
|
|
98
98
|
family: string;
|
|
99
99
|
style: "normal" | "italic" | "oblique";
|
|
@@ -184,7 +184,7 @@ export declare const ImageAsset: z.ZodObject<{
|
|
|
184
184
|
}>;
|
|
185
185
|
export type ImageAsset = z.infer<typeof ImageAsset>;
|
|
186
186
|
export declare const Asset: z.ZodUnion<[z.ZodObject<{
|
|
187
|
-
format: z.ZodUnion<[z.ZodLiteral<"ttf">, z.ZodLiteral<"woff">, z.ZodLiteral<"woff2"
|
|
187
|
+
format: z.ZodUnion<[z.ZodLiteral<"ttf">, z.ZodLiteral<"woff">, z.ZodLiteral<"woff2">]>;
|
|
188
188
|
meta: z.ZodUnion<[z.ZodObject<{
|
|
189
189
|
family: z.ZodString;
|
|
190
190
|
style: z.ZodEnum<["normal", "italic", "oblique"]>;
|
|
@@ -243,7 +243,7 @@ export declare const Asset: z.ZodUnion<[z.ZodObject<{
|
|
|
243
243
|
type: "font";
|
|
244
244
|
id: string;
|
|
245
245
|
name: string;
|
|
246
|
-
format: "ttf" | "woff" | "woff2"
|
|
246
|
+
format: "ttf" | "woff" | "woff2";
|
|
247
247
|
meta: ({
|
|
248
248
|
family: string;
|
|
249
249
|
style: "normal" | "italic" | "oblique";
|
|
@@ -277,7 +277,7 @@ export declare const Asset: z.ZodUnion<[z.ZodObject<{
|
|
|
277
277
|
type: "font";
|
|
278
278
|
id: string;
|
|
279
279
|
name: string;
|
|
280
|
-
format: "ttf" | "woff" | "woff2"
|
|
280
|
+
format: "ttf" | "woff" | "woff2";
|
|
281
281
|
meta: ({
|
|
282
282
|
family: string;
|
|
283
283
|
style: "normal" | "italic" | "oblique";
|
|
@@ -355,7 +355,7 @@ export declare const Asset: z.ZodUnion<[z.ZodObject<{
|
|
|
355
355
|
}>]>;
|
|
356
356
|
export type Asset = z.infer<typeof Asset>;
|
|
357
357
|
export declare const Assets: z.ZodMap<z.ZodString, z.ZodUnion<[z.ZodObject<{
|
|
358
|
-
format: z.ZodUnion<[z.ZodLiteral<"ttf">, z.ZodLiteral<"woff">, z.ZodLiteral<"woff2"
|
|
358
|
+
format: z.ZodUnion<[z.ZodLiteral<"ttf">, z.ZodLiteral<"woff">, z.ZodLiteral<"woff2">]>;
|
|
359
359
|
meta: z.ZodUnion<[z.ZodObject<{
|
|
360
360
|
family: z.ZodString;
|
|
361
361
|
style: z.ZodEnum<["normal", "italic", "oblique"]>;
|
|
@@ -414,7 +414,7 @@ export declare const Assets: z.ZodMap<z.ZodString, z.ZodUnion<[z.ZodObject<{
|
|
|
414
414
|
type: "font";
|
|
415
415
|
id: string;
|
|
416
416
|
name: string;
|
|
417
|
-
format: "ttf" | "woff" | "woff2"
|
|
417
|
+
format: "ttf" | "woff" | "woff2";
|
|
418
418
|
meta: ({
|
|
419
419
|
family: string;
|
|
420
420
|
style: "normal" | "italic" | "oblique";
|
|
@@ -448,7 +448,7 @@ export declare const Assets: z.ZodMap<z.ZodString, z.ZodUnion<[z.ZodObject<{
|
|
|
448
448
|
type: "font";
|
|
449
449
|
id: string;
|
|
450
450
|
name: string;
|
|
451
|
-
format: "ttf" | "woff" | "woff2"
|
|
451
|
+
format: "ttf" | "woff" | "woff2";
|
|
452
452
|
meta: ({
|
|
453
453
|
family: string;
|
|
454
454
|
style: "normal" | "italic" | "oblique";
|
|
@@ -2,6 +2,7 @@ import { z } from "zod";
|
|
|
2
2
|
export type System = {
|
|
3
3
|
params: Record<string, string | undefined>;
|
|
4
4
|
search: Record<string, string | undefined>;
|
|
5
|
+
origin: string;
|
|
5
6
|
};
|
|
6
7
|
export declare const FolderName: z.ZodEffects<z.ZodString, string, string>;
|
|
7
8
|
export declare const Folder: z.ZodObject<{
|
|
@@ -23,6 +24,7 @@ export declare const Folder: z.ZodObject<{
|
|
|
23
24
|
export type Folder = z.infer<typeof Folder>;
|
|
24
25
|
export declare const PageName: z.ZodEffects<z.ZodString, string, string>;
|
|
25
26
|
export declare const PageTitle: z.ZodEffects<z.ZodString, string, string>;
|
|
27
|
+
export declare const documentTypes: readonly ["html", "xml"];
|
|
26
28
|
export declare const HomePagePath: z.ZodEffects<z.ZodString, string, string>;
|
|
27
29
|
export declare const PagePath: 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>;
|
|
28
30
|
declare const Page: z.ZodObject<{
|
|
@@ -30,6 +32,7 @@ declare const Page: z.ZodObject<{
|
|
|
30
32
|
id: z.ZodString;
|
|
31
33
|
name: z.ZodEffects<z.ZodString, string, string>;
|
|
32
34
|
title: z.ZodEffects<z.ZodString, string, string>;
|
|
35
|
+
history: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
33
36
|
meta: z.ZodObject<{
|
|
34
37
|
description: z.ZodOptional<z.ZodString>;
|
|
35
38
|
title: z.ZodOptional<z.ZodString>;
|
|
@@ -39,6 +42,7 @@ declare const Page: z.ZodObject<{
|
|
|
39
42
|
socialImageUrl: z.ZodOptional<z.ZodString>;
|
|
40
43
|
status: z.ZodOptional<z.ZodString>;
|
|
41
44
|
redirect: z.ZodOptional<z.ZodString>;
|
|
45
|
+
documentType: z.ZodOptional<z.ZodEnum<["html", "xml"]>>;
|
|
42
46
|
custom: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
43
47
|
property: z.ZodString;
|
|
44
48
|
content: z.ZodString;
|
|
@@ -58,6 +62,7 @@ declare const Page: z.ZodObject<{
|
|
|
58
62
|
socialImageUrl?: string | undefined;
|
|
59
63
|
status?: string | undefined;
|
|
60
64
|
redirect?: string | undefined;
|
|
65
|
+
documentType?: "html" | "xml" | undefined;
|
|
61
66
|
custom?: {
|
|
62
67
|
property: string;
|
|
63
68
|
content: string;
|
|
@@ -71,13 +76,14 @@ declare const Page: z.ZodObject<{
|
|
|
71
76
|
socialImageUrl?: string | undefined;
|
|
72
77
|
status?: string | undefined;
|
|
73
78
|
redirect?: string | undefined;
|
|
79
|
+
documentType?: "html" | "xml" | undefined;
|
|
74
80
|
custom?: {
|
|
75
81
|
property: string;
|
|
76
82
|
content: string;
|
|
77
83
|
}[] | undefined;
|
|
78
84
|
}>;
|
|
79
85
|
rootInstanceId: z.ZodString;
|
|
80
|
-
systemDataSourceId: z.
|
|
86
|
+
systemDataSourceId: z.ZodString;
|
|
81
87
|
}, "strip", z.ZodTypeAny, {
|
|
82
88
|
path: string;
|
|
83
89
|
id: string;
|
|
@@ -91,6 +97,7 @@ declare const Page: z.ZodObject<{
|
|
|
91
97
|
socialImageUrl?: string | undefined;
|
|
92
98
|
status?: string | undefined;
|
|
93
99
|
redirect?: string | undefined;
|
|
100
|
+
documentType?: "html" | "xml" | undefined;
|
|
94
101
|
custom?: {
|
|
95
102
|
property: string;
|
|
96
103
|
content: string;
|
|
@@ -98,7 +105,8 @@ declare const Page: z.ZodObject<{
|
|
|
98
105
|
};
|
|
99
106
|
title: string;
|
|
100
107
|
rootInstanceId: string;
|
|
101
|
-
systemDataSourceId
|
|
108
|
+
systemDataSourceId: string;
|
|
109
|
+
history?: string[] | undefined;
|
|
102
110
|
}, {
|
|
103
111
|
path: string;
|
|
104
112
|
id: string;
|
|
@@ -112,6 +120,7 @@ declare const Page: z.ZodObject<{
|
|
|
112
120
|
socialImageUrl?: string | undefined;
|
|
113
121
|
status?: string | undefined;
|
|
114
122
|
redirect?: string | undefined;
|
|
123
|
+
documentType?: "html" | "xml" | undefined;
|
|
115
124
|
custom?: {
|
|
116
125
|
property: string;
|
|
117
126
|
content: string;
|
|
@@ -119,18 +128,22 @@ declare const Page: z.ZodObject<{
|
|
|
119
128
|
};
|
|
120
129
|
title: string;
|
|
121
130
|
rootInstanceId: string;
|
|
122
|
-
systemDataSourceId
|
|
131
|
+
systemDataSourceId: string;
|
|
132
|
+
history?: string[] | undefined;
|
|
123
133
|
}>;
|
|
124
134
|
declare const ProjectMeta: z.ZodObject<{
|
|
125
135
|
siteName: z.ZodOptional<z.ZodString>;
|
|
136
|
+
contactEmail: z.ZodOptional<z.ZodString>;
|
|
126
137
|
faviconAssetId: z.ZodOptional<z.ZodString>;
|
|
127
138
|
code: z.ZodOptional<z.ZodString>;
|
|
128
139
|
}, "strip", z.ZodTypeAny, {
|
|
129
140
|
siteName?: string | undefined;
|
|
141
|
+
contactEmail?: string | undefined;
|
|
130
142
|
faviconAssetId?: string | undefined;
|
|
131
143
|
code?: string | undefined;
|
|
132
144
|
}, {
|
|
133
145
|
siteName?: string | undefined;
|
|
146
|
+
contactEmail?: string | undefined;
|
|
134
147
|
faviconAssetId?: string | undefined;
|
|
135
148
|
code?: string | undefined;
|
|
136
149
|
}>;
|
|
@@ -162,14 +175,17 @@ export type Page = z.infer<typeof Page>;
|
|
|
162
175
|
export declare const Pages: z.ZodObject<{
|
|
163
176
|
meta: z.ZodOptional<z.ZodObject<{
|
|
164
177
|
siteName: z.ZodOptional<z.ZodString>;
|
|
178
|
+
contactEmail: z.ZodOptional<z.ZodString>;
|
|
165
179
|
faviconAssetId: z.ZodOptional<z.ZodString>;
|
|
166
180
|
code: z.ZodOptional<z.ZodString>;
|
|
167
181
|
}, "strip", z.ZodTypeAny, {
|
|
168
182
|
siteName?: string | undefined;
|
|
183
|
+
contactEmail?: string | undefined;
|
|
169
184
|
faviconAssetId?: string | undefined;
|
|
170
185
|
code?: string | undefined;
|
|
171
186
|
}, {
|
|
172
187
|
siteName?: string | undefined;
|
|
188
|
+
contactEmail?: string | undefined;
|
|
173
189
|
faviconAssetId?: string | undefined;
|
|
174
190
|
code?: string | undefined;
|
|
175
191
|
}>>;
|
|
@@ -198,6 +214,7 @@ export declare const Pages: z.ZodObject<{
|
|
|
198
214
|
id: z.ZodString;
|
|
199
215
|
name: z.ZodEffects<z.ZodString, string, string>;
|
|
200
216
|
title: z.ZodEffects<z.ZodString, string, string>;
|
|
217
|
+
history: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
201
218
|
meta: z.ZodObject<{
|
|
202
219
|
description: z.ZodOptional<z.ZodString>;
|
|
203
220
|
title: z.ZodOptional<z.ZodString>;
|
|
@@ -207,6 +224,7 @@ export declare const Pages: z.ZodObject<{
|
|
|
207
224
|
socialImageUrl: z.ZodOptional<z.ZodString>;
|
|
208
225
|
status: z.ZodOptional<z.ZodString>;
|
|
209
226
|
redirect: z.ZodOptional<z.ZodString>;
|
|
227
|
+
documentType: z.ZodOptional<z.ZodEnum<["html", "xml"]>>;
|
|
210
228
|
custom: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
211
229
|
property: z.ZodString;
|
|
212
230
|
content: z.ZodString;
|
|
@@ -226,6 +244,7 @@ export declare const Pages: z.ZodObject<{
|
|
|
226
244
|
socialImageUrl?: string | undefined;
|
|
227
245
|
status?: string | undefined;
|
|
228
246
|
redirect?: string | undefined;
|
|
247
|
+
documentType?: "html" | "xml" | undefined;
|
|
229
248
|
custom?: {
|
|
230
249
|
property: string;
|
|
231
250
|
content: string;
|
|
@@ -239,13 +258,14 @@ export declare const Pages: z.ZodObject<{
|
|
|
239
258
|
socialImageUrl?: string | undefined;
|
|
240
259
|
status?: string | undefined;
|
|
241
260
|
redirect?: string | undefined;
|
|
261
|
+
documentType?: "html" | "xml" | undefined;
|
|
242
262
|
custom?: {
|
|
243
263
|
property: string;
|
|
244
264
|
content: string;
|
|
245
265
|
}[] | undefined;
|
|
246
266
|
}>;
|
|
247
267
|
rootInstanceId: z.ZodString;
|
|
248
|
-
systemDataSourceId: z.
|
|
268
|
+
systemDataSourceId: z.ZodString;
|
|
249
269
|
}, "strip", z.ZodTypeAny, {
|
|
250
270
|
path: string;
|
|
251
271
|
id: string;
|
|
@@ -259,6 +279,7 @@ export declare const Pages: z.ZodObject<{
|
|
|
259
279
|
socialImageUrl?: string | undefined;
|
|
260
280
|
status?: string | undefined;
|
|
261
281
|
redirect?: string | undefined;
|
|
282
|
+
documentType?: "html" | "xml" | undefined;
|
|
262
283
|
custom?: {
|
|
263
284
|
property: string;
|
|
264
285
|
content: string;
|
|
@@ -266,7 +287,8 @@ export declare const Pages: z.ZodObject<{
|
|
|
266
287
|
};
|
|
267
288
|
title: string;
|
|
268
289
|
rootInstanceId: string;
|
|
269
|
-
systemDataSourceId
|
|
290
|
+
systemDataSourceId: string;
|
|
291
|
+
history?: string[] | undefined;
|
|
270
292
|
}, {
|
|
271
293
|
path: string;
|
|
272
294
|
id: string;
|
|
@@ -280,6 +302,7 @@ export declare const Pages: z.ZodObject<{
|
|
|
280
302
|
socialImageUrl?: string | undefined;
|
|
281
303
|
status?: string | undefined;
|
|
282
304
|
redirect?: string | undefined;
|
|
305
|
+
documentType?: "html" | "xml" | undefined;
|
|
283
306
|
custom?: {
|
|
284
307
|
property: string;
|
|
285
308
|
content: string;
|
|
@@ -287,13 +310,15 @@ export declare const Pages: z.ZodObject<{
|
|
|
287
310
|
};
|
|
288
311
|
title: string;
|
|
289
312
|
rootInstanceId: string;
|
|
290
|
-
systemDataSourceId
|
|
313
|
+
systemDataSourceId: string;
|
|
314
|
+
history?: string[] | undefined;
|
|
291
315
|
}>;
|
|
292
316
|
pages: z.ZodArray<z.ZodObject<{
|
|
293
317
|
path: 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>;
|
|
294
318
|
id: z.ZodString;
|
|
295
319
|
name: z.ZodEffects<z.ZodString, string, string>;
|
|
296
320
|
title: z.ZodEffects<z.ZodString, string, string>;
|
|
321
|
+
history: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
297
322
|
meta: z.ZodObject<{
|
|
298
323
|
description: z.ZodOptional<z.ZodString>;
|
|
299
324
|
title: z.ZodOptional<z.ZodString>;
|
|
@@ -303,6 +328,7 @@ export declare const Pages: z.ZodObject<{
|
|
|
303
328
|
socialImageUrl: z.ZodOptional<z.ZodString>;
|
|
304
329
|
status: z.ZodOptional<z.ZodString>;
|
|
305
330
|
redirect: z.ZodOptional<z.ZodString>;
|
|
331
|
+
documentType: z.ZodOptional<z.ZodEnum<["html", "xml"]>>;
|
|
306
332
|
custom: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
307
333
|
property: z.ZodString;
|
|
308
334
|
content: z.ZodString;
|
|
@@ -322,6 +348,7 @@ export declare const Pages: z.ZodObject<{
|
|
|
322
348
|
socialImageUrl?: string | undefined;
|
|
323
349
|
status?: string | undefined;
|
|
324
350
|
redirect?: string | undefined;
|
|
351
|
+
documentType?: "html" | "xml" | undefined;
|
|
325
352
|
custom?: {
|
|
326
353
|
property: string;
|
|
327
354
|
content: string;
|
|
@@ -335,13 +362,14 @@ export declare const Pages: z.ZodObject<{
|
|
|
335
362
|
socialImageUrl?: string | undefined;
|
|
336
363
|
status?: string | undefined;
|
|
337
364
|
redirect?: string | undefined;
|
|
365
|
+
documentType?: "html" | "xml" | undefined;
|
|
338
366
|
custom?: {
|
|
339
367
|
property: string;
|
|
340
368
|
content: string;
|
|
341
369
|
}[] | undefined;
|
|
342
370
|
}>;
|
|
343
371
|
rootInstanceId: z.ZodString;
|
|
344
|
-
systemDataSourceId: z.
|
|
372
|
+
systemDataSourceId: z.ZodString;
|
|
345
373
|
}, "strip", z.ZodTypeAny, {
|
|
346
374
|
path: string;
|
|
347
375
|
id: string;
|
|
@@ -355,6 +383,7 @@ export declare const Pages: z.ZodObject<{
|
|
|
355
383
|
socialImageUrl?: string | undefined;
|
|
356
384
|
status?: string | undefined;
|
|
357
385
|
redirect?: string | undefined;
|
|
386
|
+
documentType?: "html" | "xml" | undefined;
|
|
358
387
|
custom?: {
|
|
359
388
|
property: string;
|
|
360
389
|
content: string;
|
|
@@ -362,7 +391,8 @@ export declare const Pages: z.ZodObject<{
|
|
|
362
391
|
};
|
|
363
392
|
title: string;
|
|
364
393
|
rootInstanceId: string;
|
|
365
|
-
systemDataSourceId
|
|
394
|
+
systemDataSourceId: string;
|
|
395
|
+
history?: string[] | undefined;
|
|
366
396
|
}, {
|
|
367
397
|
path: string;
|
|
368
398
|
id: string;
|
|
@@ -376,6 +406,7 @@ export declare const Pages: z.ZodObject<{
|
|
|
376
406
|
socialImageUrl?: string | undefined;
|
|
377
407
|
status?: string | undefined;
|
|
378
408
|
redirect?: string | undefined;
|
|
409
|
+
documentType?: "html" | "xml" | undefined;
|
|
379
410
|
custom?: {
|
|
380
411
|
property: string;
|
|
381
412
|
content: string;
|
|
@@ -383,7 +414,8 @@ export declare const Pages: z.ZodObject<{
|
|
|
383
414
|
};
|
|
384
415
|
title: string;
|
|
385
416
|
rootInstanceId: string;
|
|
386
|
-
systemDataSourceId
|
|
417
|
+
systemDataSourceId: string;
|
|
418
|
+
history?: string[] | undefined;
|
|
387
419
|
}>, "many">;
|
|
388
420
|
folders: z.ZodEffects<z.ZodArray<z.ZodObject<{
|
|
389
421
|
id: z.ZodString;
|
|
@@ -425,6 +457,7 @@ export declare const Pages: z.ZodObject<{
|
|
|
425
457
|
socialImageUrl?: string | undefined;
|
|
426
458
|
status?: string | undefined;
|
|
427
459
|
redirect?: string | undefined;
|
|
460
|
+
documentType?: "html" | "xml" | undefined;
|
|
428
461
|
custom?: {
|
|
429
462
|
property: string;
|
|
430
463
|
content: string;
|
|
@@ -432,7 +465,8 @@ export declare const Pages: z.ZodObject<{
|
|
|
432
465
|
};
|
|
433
466
|
title: string;
|
|
434
467
|
rootInstanceId: string;
|
|
435
|
-
systemDataSourceId
|
|
468
|
+
systemDataSourceId: string;
|
|
469
|
+
history?: string[] | undefined;
|
|
436
470
|
};
|
|
437
471
|
pages: {
|
|
438
472
|
path: string;
|
|
@@ -447,6 +481,7 @@ export declare const Pages: z.ZodObject<{
|
|
|
447
481
|
socialImageUrl?: string | undefined;
|
|
448
482
|
status?: string | undefined;
|
|
449
483
|
redirect?: string | undefined;
|
|
484
|
+
documentType?: "html" | "xml" | undefined;
|
|
450
485
|
custom?: {
|
|
451
486
|
property: string;
|
|
452
487
|
content: string;
|
|
@@ -454,7 +489,8 @@ export declare const Pages: z.ZodObject<{
|
|
|
454
489
|
};
|
|
455
490
|
title: string;
|
|
456
491
|
rootInstanceId: string;
|
|
457
|
-
systemDataSourceId
|
|
492
|
+
systemDataSourceId: string;
|
|
493
|
+
history?: string[] | undefined;
|
|
458
494
|
}[];
|
|
459
495
|
folders: {
|
|
460
496
|
id: string;
|
|
@@ -464,6 +500,7 @@ export declare const Pages: z.ZodObject<{
|
|
|
464
500
|
}[];
|
|
465
501
|
meta?: {
|
|
466
502
|
siteName?: string | undefined;
|
|
503
|
+
contactEmail?: string | undefined;
|
|
467
504
|
faviconAssetId?: string | undefined;
|
|
468
505
|
code?: string | undefined;
|
|
469
506
|
} | undefined;
|
|
@@ -489,6 +526,7 @@ export declare const Pages: z.ZodObject<{
|
|
|
489
526
|
socialImageUrl?: string | undefined;
|
|
490
527
|
status?: string | undefined;
|
|
491
528
|
redirect?: string | undefined;
|
|
529
|
+
documentType?: "html" | "xml" | undefined;
|
|
492
530
|
custom?: {
|
|
493
531
|
property: string;
|
|
494
532
|
content: string;
|
|
@@ -496,7 +534,8 @@ export declare const Pages: z.ZodObject<{
|
|
|
496
534
|
};
|
|
497
535
|
title: string;
|
|
498
536
|
rootInstanceId: string;
|
|
499
|
-
systemDataSourceId
|
|
537
|
+
systemDataSourceId: string;
|
|
538
|
+
history?: string[] | undefined;
|
|
500
539
|
};
|
|
501
540
|
pages: {
|
|
502
541
|
path: string;
|
|
@@ -511,6 +550,7 @@ export declare const Pages: z.ZodObject<{
|
|
|
511
550
|
socialImageUrl?: string | undefined;
|
|
512
551
|
status?: string | undefined;
|
|
513
552
|
redirect?: string | undefined;
|
|
553
|
+
documentType?: "html" | "xml" | undefined;
|
|
514
554
|
custom?: {
|
|
515
555
|
property: string;
|
|
516
556
|
content: string;
|
|
@@ -518,7 +558,8 @@ export declare const Pages: z.ZodObject<{
|
|
|
518
558
|
};
|
|
519
559
|
title: string;
|
|
520
560
|
rootInstanceId: string;
|
|
521
|
-
systemDataSourceId
|
|
561
|
+
systemDataSourceId: string;
|
|
562
|
+
history?: string[] | undefined;
|
|
522
563
|
}[];
|
|
523
564
|
folders: {
|
|
524
565
|
id: string;
|
|
@@ -528,6 +569,7 @@ export declare const Pages: z.ZodObject<{
|
|
|
528
569
|
}[];
|
|
529
570
|
meta?: {
|
|
530
571
|
siteName?: string | undefined;
|
|
572
|
+
contactEmail?: string | undefined;
|
|
531
573
|
faviconAssetId?: string | undefined;
|
|
532
574
|
code?: string | undefined;
|
|
533
575
|
} | undefined;
|
|
@@ -2,6 +2,7 @@ import { z } from "zod";
|
|
|
2
2
|
export declare const Resource: z.ZodObject<{
|
|
3
3
|
id: z.ZodString;
|
|
4
4
|
name: z.ZodString;
|
|
5
|
+
control: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"system">, z.ZodLiteral<"graphql">]>>;
|
|
5
6
|
method: z.ZodUnion<[z.ZodLiteral<"get">, z.ZodLiteral<"post">, z.ZodLiteral<"put">, z.ZodLiteral<"delete">]>;
|
|
6
7
|
url: z.ZodString;
|
|
7
8
|
headers: z.ZodArray<z.ZodObject<{
|
|
@@ -24,6 +25,7 @@ export declare const Resource: z.ZodObject<{
|
|
|
24
25
|
value: string;
|
|
25
26
|
name: string;
|
|
26
27
|
}[];
|
|
28
|
+
control?: "system" | "graphql" | undefined;
|
|
27
29
|
body?: string | undefined;
|
|
28
30
|
}, {
|
|
29
31
|
id: string;
|
|
@@ -34,6 +36,7 @@ export declare const Resource: z.ZodObject<{
|
|
|
34
36
|
value: string;
|
|
35
37
|
name: string;
|
|
36
38
|
}[];
|
|
39
|
+
control?: "system" | "graphql" | undefined;
|
|
37
40
|
body?: string | undefined;
|
|
38
41
|
}>;
|
|
39
42
|
export type Resource = z.infer<typeof Resource>;
|
|
@@ -78,6 +81,7 @@ export type ResourceRequest = z.infer<typeof ResourceRequest>;
|
|
|
78
81
|
export declare const Resources: z.ZodMap<z.ZodString, z.ZodObject<{
|
|
79
82
|
id: z.ZodString;
|
|
80
83
|
name: z.ZodString;
|
|
84
|
+
control: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"system">, z.ZodLiteral<"graphql">]>>;
|
|
81
85
|
method: z.ZodUnion<[z.ZodLiteral<"get">, z.ZodLiteral<"post">, z.ZodLiteral<"put">, z.ZodLiteral<"delete">]>;
|
|
82
86
|
url: z.ZodString;
|
|
83
87
|
headers: z.ZodArray<z.ZodObject<{
|
|
@@ -100,6 +104,7 @@ export declare const Resources: z.ZodMap<z.ZodString, z.ZodObject<{
|
|
|
100
104
|
value: string;
|
|
101
105
|
name: string;
|
|
102
106
|
}[];
|
|
107
|
+
control?: "system" | "graphql" | undefined;
|
|
103
108
|
body?: string | undefined;
|
|
104
109
|
}, {
|
|
105
110
|
id: string;
|
|
@@ -110,6 +115,12 @@ export declare const Resources: z.ZodMap<z.ZodString, z.ZodObject<{
|
|
|
110
115
|
value: string;
|
|
111
116
|
name: string;
|
|
112
117
|
}[];
|
|
118
|
+
control?: "system" | "graphql" | undefined;
|
|
113
119
|
body?: string | undefined;
|
|
114
120
|
}>>;
|
|
115
121
|
export type Resources = z.infer<typeof Resources>;
|
|
122
|
+
/**
|
|
123
|
+
* Prevents fetch cycles by prefixing local resources.
|
|
124
|
+
*/
|
|
125
|
+
export declare const isLocalResource: (pathname: string, resourceName?: string) => boolean;
|
|
126
|
+
export declare const sitemapResourceUrl = "/$resources/sitemap.xml";
|
|
@@ -107,7 +107,7 @@ export declare const WebstudioFragment: z.ZodObject<{
|
|
|
107
107
|
label?: string | undefined;
|
|
108
108
|
}>, "many">;
|
|
109
109
|
assets: z.ZodArray<z.ZodUnion<[z.ZodObject<{
|
|
110
|
-
format: z.ZodUnion<[z.ZodLiteral<"ttf">, z.ZodLiteral<"woff">, z.ZodLiteral<"woff2"
|
|
110
|
+
format: z.ZodUnion<[z.ZodLiteral<"ttf">, z.ZodLiteral<"woff">, z.ZodLiteral<"woff2">]>;
|
|
111
111
|
meta: z.ZodUnion<[z.ZodObject<{
|
|
112
112
|
family: z.ZodString;
|
|
113
113
|
style: z.ZodEnum<["normal", "italic", "oblique"]>;
|
|
@@ -166,7 +166,7 @@ export declare const WebstudioFragment: z.ZodObject<{
|
|
|
166
166
|
type: "font";
|
|
167
167
|
id: string;
|
|
168
168
|
name: string;
|
|
169
|
-
format: "ttf" | "woff" | "woff2"
|
|
169
|
+
format: "ttf" | "woff" | "woff2";
|
|
170
170
|
meta: ({
|
|
171
171
|
family: string;
|
|
172
172
|
style: "normal" | "italic" | "oblique";
|
|
@@ -200,7 +200,7 @@ export declare const WebstudioFragment: z.ZodObject<{
|
|
|
200
200
|
type: "font";
|
|
201
201
|
id: string;
|
|
202
202
|
name: string;
|
|
203
|
-
format: "ttf" | "woff" | "woff2"
|
|
203
|
+
format: "ttf" | "woff" | "woff2";
|
|
204
204
|
meta: ({
|
|
205
205
|
family: string;
|
|
206
206
|
style: "normal" | "italic" | "oblique";
|
|
@@ -406,6 +406,7 @@ export declare const WebstudioFragment: z.ZodObject<{
|
|
|
406
406
|
resources: z.ZodArray<z.ZodObject<{
|
|
407
407
|
id: z.ZodString;
|
|
408
408
|
name: z.ZodString;
|
|
409
|
+
control: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"system">, z.ZodLiteral<"graphql">]>>;
|
|
409
410
|
method: z.ZodUnion<[z.ZodLiteral<"get">, z.ZodLiteral<"post">, z.ZodLiteral<"put">, z.ZodLiteral<"delete">]>;
|
|
410
411
|
url: z.ZodString;
|
|
411
412
|
headers: z.ZodArray<z.ZodObject<{
|
|
@@ -428,6 +429,7 @@ export declare const WebstudioFragment: z.ZodObject<{
|
|
|
428
429
|
value: string;
|
|
429
430
|
name: string;
|
|
430
431
|
}[];
|
|
432
|
+
control?: "system" | "graphql" | undefined;
|
|
431
433
|
body?: string | undefined;
|
|
432
434
|
}, {
|
|
433
435
|
id: string;
|
|
@@ -438,6 +440,7 @@ export declare const WebstudioFragment: z.ZodObject<{
|
|
|
438
440
|
value: string;
|
|
439
441
|
name: string;
|
|
440
442
|
}[];
|
|
443
|
+
control?: "system" | "graphql" | undefined;
|
|
441
444
|
body?: string | undefined;
|
|
442
445
|
}>, "many">;
|
|
443
446
|
props: z.ZodArray<z.ZodUnion<[z.ZodObject<{
|
|
@@ -1685,7 +1688,7 @@ export declare const WebstudioFragment: z.ZodObject<{
|
|
|
1685
1688
|
type: "font";
|
|
1686
1689
|
id: string;
|
|
1687
1690
|
name: string;
|
|
1688
|
-
format: "ttf" | "woff" | "woff2"
|
|
1691
|
+
format: "ttf" | "woff" | "woff2";
|
|
1689
1692
|
meta: ({
|
|
1690
1693
|
family: string;
|
|
1691
1694
|
style: "normal" | "italic" | "oblique";
|
|
@@ -1738,6 +1741,7 @@ export declare const WebstudioFragment: z.ZodObject<{
|
|
|
1738
1741
|
value: string;
|
|
1739
1742
|
name: string;
|
|
1740
1743
|
}[];
|
|
1744
|
+
control?: "system" | "graphql" | undefined;
|
|
1741
1745
|
body?: string | undefined;
|
|
1742
1746
|
}[];
|
|
1743
1747
|
props: ({
|
|
@@ -2339,7 +2343,7 @@ export declare const WebstudioFragment: z.ZodObject<{
|
|
|
2339
2343
|
type: "font";
|
|
2340
2344
|
id: string;
|
|
2341
2345
|
name: string;
|
|
2342
|
-
format: "ttf" | "woff" | "woff2"
|
|
2346
|
+
format: "ttf" | "woff" | "woff2";
|
|
2343
2347
|
meta: ({
|
|
2344
2348
|
family: string;
|
|
2345
2349
|
style: "normal" | "italic" | "oblique";
|
|
@@ -2392,6 +2396,7 @@ export declare const WebstudioFragment: z.ZodObject<{
|
|
|
2392
2396
|
value: string;
|
|
2393
2397
|
name: string;
|
|
2394
2398
|
}[];
|
|
2399
|
+
control?: "system" | "graphql" | undefined;
|
|
2395
2400
|
body?: string | undefined;
|
|
2396
2401
|
}[];
|
|
2397
2402
|
props: ({
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webstudio-is/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.163.0",
|
|
4
4
|
"description": "Webstudio project data schema",
|
|
5
5
|
"author": "Webstudio <github@webstudio.is>",
|
|
6
6
|
"homepage": "https://webstudio.is",
|
|
@@ -9,8 +9,7 @@
|
|
|
9
9
|
"exports": {
|
|
10
10
|
"webstudio": "./src/index.ts",
|
|
11
11
|
"types": "./lib/types/index.d.ts",
|
|
12
|
-
"import": "./lib/index.js"
|
|
13
|
-
"require": "./lib/index.js"
|
|
12
|
+
"import": "./lib/index.js"
|
|
14
13
|
},
|
|
15
14
|
"files": [
|
|
16
15
|
"lib/*",
|
|
@@ -22,8 +21,8 @@
|
|
|
22
21
|
"acorn-walk": "^8.3.2",
|
|
23
22
|
"type-fest": "^4.3.1",
|
|
24
23
|
"zod": "^3.22.4",
|
|
25
|
-
"@webstudio-is/css-engine": "0.
|
|
26
|
-
"@webstudio-is/fonts": "0.
|
|
24
|
+
"@webstudio-is/css-engine": "0.163.0",
|
|
25
|
+
"@webstudio-is/fonts": "0.163.0"
|
|
27
26
|
},
|
|
28
27
|
"devDependencies": {
|
|
29
28
|
"@jest/globals": "^29.7.0",
|