@orion-studios/payload-studio 0.5.0-beta.113 → 0.5.0-beta.115
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/dist/admin/client.js +1880 -502
- package/dist/admin/client.mjs +1164 -329
- package/dist/admin/index.d.mts +2 -1
- package/dist/admin/index.d.ts +2 -1
- package/dist/admin/index.js +267 -59
- package/dist/admin/index.mjs +1 -1
- package/dist/admin-app/client.d.mts +1 -0
- package/dist/admin-app/client.d.ts +1 -0
- package/dist/admin-app/client.js +266 -105
- package/dist/admin-app/client.mjs +105 -456
- package/dist/admin-app/index.d.mts +2 -1
- package/dist/admin-app/index.d.ts +2 -1
- package/dist/admin-app/styles.css +351 -0
- package/dist/admin.css +9 -0
- package/dist/chunk-6NE7GIVT.mjs +555 -0
- package/dist/{chunk-DAIZDGHL.mjs → chunk-T5PBXPES.mjs} +267 -59
- package/dist/{chunk-3T2P6SDM.mjs → chunk-XKUTZ7IU.mjs} +215 -6
- package/dist/index-3jBpt6ZT.d.ts +385 -0
- package/dist/index-C3FgxbEL.d.mts +385 -0
- package/dist/{index-DUi_XND6.d.ts → index-Crx_MtPw.d.ts} +33 -3
- package/dist/{index-gLl_358v.d.mts → index-Cv-6qnrw.d.mts} +33 -3
- package/dist/{index-BzKOThsI.d.mts → index-DWmudwDm.d.mts} +1 -1
- package/dist/{index-BzKOThsI.d.ts → index-DWmudwDm.d.ts} +1 -1
- package/dist/{index-7lxTrxSG.d.mts → index-c5-qTRbH.d.mts} +7 -1
- package/dist/{index-7lxTrxSG.d.ts → index-yfpxsgUu.d.ts} +7 -1
- package/dist/index.d.mts +5 -4
- package/dist/index.d.ts +5 -4
- package/dist/index.js +473 -65
- package/dist/index.mjs +6 -6
- package/dist/nextjs/index.mjs +2 -2
- package/dist/sitePreviewTypes-BECnq9xI.d.mts +41 -0
- package/dist/sitePreviewTypes-BECnq9xI.d.ts +41 -0
- package/dist/studio/index.d.mts +1 -1
- package/dist/studio/index.d.ts +1 -1
- package/dist/studio-pages/index.d.mts +3 -3
- package/dist/studio-pages/index.d.ts +3 -3
- package/dist/studio-pages/index.js +330 -7
- package/dist/studio-pages/index.mjs +10 -3
- package/package.json +1 -1
- package/dist/index-B7QvY3yF.d.mts +0 -245
- package/dist/index-BK03FiEM.d.ts +0 -245
- package/dist/{chunk-BET2YLAS.mjs → chunk-OTHERBGX.mjs} +3 -3
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
admin_exports
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-T5PBXPES.mjs";
|
|
4
4
|
import {
|
|
5
5
|
admin_app_exports
|
|
6
6
|
} from "./chunk-XVH5SCBD.mjs";
|
|
@@ -9,16 +9,16 @@ import {
|
|
|
9
9
|
} from "./chunk-JQAHXYAM.mjs";
|
|
10
10
|
import {
|
|
11
11
|
nextjs_exports
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-OTHERBGX.mjs";
|
|
13
13
|
import "./chunk-ZTXJG4K5.mjs";
|
|
14
|
-
import {
|
|
15
|
-
studio_exports
|
|
16
|
-
} from "./chunk-ADIIWIYL.mjs";
|
|
17
14
|
import {
|
|
18
15
|
studio_pages_exports
|
|
19
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-XKUTZ7IU.mjs";
|
|
20
17
|
import "./chunk-OQSEJXC4.mjs";
|
|
21
18
|
import "./chunk-PF3EBZXF.mjs";
|
|
19
|
+
import {
|
|
20
|
+
studio_exports
|
|
21
|
+
} from "./chunk-ADIIWIYL.mjs";
|
|
22
22
|
import "./chunk-6BWS3CLP.mjs";
|
|
23
23
|
export {
|
|
24
24
|
admin_exports as admin,
|
package/dist/nextjs/index.mjs
CHANGED
|
@@ -5,10 +5,10 @@ import {
|
|
|
5
5
|
createSiteQueries,
|
|
6
6
|
resolveMedia,
|
|
7
7
|
resolveSocialMediaLinks
|
|
8
|
-
} from "../chunk-
|
|
8
|
+
} from "../chunk-OTHERBGX.mjs";
|
|
9
9
|
import "../chunk-ZTXJG4K5.mjs";
|
|
10
|
-
import "../chunk-ADIIWIYL.mjs";
|
|
11
10
|
import "../chunk-PF3EBZXF.mjs";
|
|
11
|
+
import "../chunk-ADIIWIYL.mjs";
|
|
12
12
|
import "../chunk-6BWS3CLP.mjs";
|
|
13
13
|
export {
|
|
14
14
|
WEBSITE_CONTENT_TAG,
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
type SitePreviewLink = {
|
|
2
|
+
href: string;
|
|
3
|
+
label: string;
|
|
4
|
+
};
|
|
5
|
+
type SitePreviewLocationSummary = {
|
|
6
|
+
address?: string;
|
|
7
|
+
hours?: string;
|
|
8
|
+
phone?: string;
|
|
9
|
+
};
|
|
10
|
+
type SitePreviewSocialLink = {
|
|
11
|
+
label: string;
|
|
12
|
+
platform: string;
|
|
13
|
+
url: string;
|
|
14
|
+
};
|
|
15
|
+
type SiteHeaderPreviewData = {
|
|
16
|
+
activePath?: string;
|
|
17
|
+
actionHref?: string;
|
|
18
|
+
actionLabel?: string;
|
|
19
|
+
locationSummary?: Pick<SitePreviewLocationSummary, 'address' | 'hours'>;
|
|
20
|
+
logoUrl?: string;
|
|
21
|
+
navItems: SitePreviewLink[];
|
|
22
|
+
siteName: string;
|
|
23
|
+
socialLinks?: SitePreviewSocialLink[];
|
|
24
|
+
tagline?: string;
|
|
25
|
+
};
|
|
26
|
+
type SiteFooterPreviewData = {
|
|
27
|
+
builtByHref?: string;
|
|
28
|
+
builtByLabel?: string;
|
|
29
|
+
contactEmail: string;
|
|
30
|
+
copyright: string;
|
|
31
|
+
description?: string;
|
|
32
|
+
footerCategories: string[];
|
|
33
|
+
footerLinks: SitePreviewLink[];
|
|
34
|
+
locationSummary: SitePreviewLocationSummary;
|
|
35
|
+
logoUrl?: string;
|
|
36
|
+
siteName: string;
|
|
37
|
+
socialLinks?: SitePreviewSocialLink[];
|
|
38
|
+
tagline?: string;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export type { SitePreviewLink as S, SitePreviewLocationSummary as a, SiteFooterPreviewData as b, SiteHeaderPreviewData as c, SitePreviewSocialLink as d };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
type SitePreviewLink = {
|
|
2
|
+
href: string;
|
|
3
|
+
label: string;
|
|
4
|
+
};
|
|
5
|
+
type SitePreviewLocationSummary = {
|
|
6
|
+
address?: string;
|
|
7
|
+
hours?: string;
|
|
8
|
+
phone?: string;
|
|
9
|
+
};
|
|
10
|
+
type SitePreviewSocialLink = {
|
|
11
|
+
label: string;
|
|
12
|
+
platform: string;
|
|
13
|
+
url: string;
|
|
14
|
+
};
|
|
15
|
+
type SiteHeaderPreviewData = {
|
|
16
|
+
activePath?: string;
|
|
17
|
+
actionHref?: string;
|
|
18
|
+
actionLabel?: string;
|
|
19
|
+
locationSummary?: Pick<SitePreviewLocationSummary, 'address' | 'hours'>;
|
|
20
|
+
logoUrl?: string;
|
|
21
|
+
navItems: SitePreviewLink[];
|
|
22
|
+
siteName: string;
|
|
23
|
+
socialLinks?: SitePreviewSocialLink[];
|
|
24
|
+
tagline?: string;
|
|
25
|
+
};
|
|
26
|
+
type SiteFooterPreviewData = {
|
|
27
|
+
builtByHref?: string;
|
|
28
|
+
builtByLabel?: string;
|
|
29
|
+
contactEmail: string;
|
|
30
|
+
copyright: string;
|
|
31
|
+
description?: string;
|
|
32
|
+
footerCategories: string[];
|
|
33
|
+
footerLinks: SitePreviewLink[];
|
|
34
|
+
locationSummary: SitePreviewLocationSummary;
|
|
35
|
+
logoUrl?: string;
|
|
36
|
+
siteName: string;
|
|
37
|
+
socialLinks?: SitePreviewSocialLink[];
|
|
38
|
+
tagline?: string;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export type { SitePreviewLink as S, SitePreviewLocationSummary as a, SiteFooterPreviewData as b, SiteHeaderPreviewData as c, SitePreviewSocialLink as d };
|
package/dist/studio/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { I as ImageUploadOptimizationOptions,
|
|
1
|
+
export { I as ImageUploadOptimizationOptions, d as StudioCompileResult, S as StudioDocumentV1, e as StudioInspectorField, f as StudioInspectorPanel, g as StudioMigration, a as StudioModuleManifest, h as StudioNode, j as StudioNodeData, c as StudioNodeTypeDefinition, b as StudioPageService, k as StudioPaletteGroup, l as StudioPaletteItem, m as StudioPermission, n as StudioRegistry, o as StudioValidationIssue, p as SupportedImageMimeType, q as assertStudioDocumentV1, r as compileStudioDocument, s as createEmptyStudioDocument, t as createImageUploadOptimizationHook, u as createStudioRegistry, v as migrateStudioDocument, w as validateStudioDocument, x as withImageUploadOptimization } from '../index-DWmudwDm.mjs';
|
|
2
2
|
import 'payload';
|
package/dist/studio/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { I as ImageUploadOptimizationOptions,
|
|
1
|
+
export { I as ImageUploadOptimizationOptions, d as StudioCompileResult, S as StudioDocumentV1, e as StudioInspectorField, f as StudioInspectorPanel, g as StudioMigration, a as StudioModuleManifest, h as StudioNode, j as StudioNodeData, c as StudioNodeTypeDefinition, b as StudioPageService, k as StudioPaletteGroup, l as StudioPaletteItem, m as StudioPermission, n as StudioRegistry, o as StudioValidationIssue, p as SupportedImageMimeType, q as assertStudioDocumentV1, r as compileStudioDocument, s as createEmptyStudioDocument, t as createImageUploadOptimizationHook, u as createStudioRegistry, v as migrateStudioDocument, w as validateStudioDocument, x as withImageUploadOptimization } from '../index-DWmudwDm.js';
|
|
2
2
|
import 'payload';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { B as BuilderBlock, a as BuilderBlockPreviewRenderArgs, b as BuilderBlockPreviewRenderer, c as BuilderBlockSettingsV2, d as BuilderInlineTextComponentProps, e as BuilderPreviewEditingHelpers, f as BuilderPreviewTextFieldOptions, g as BuilderRenderWithSectionShell, h as BuilderSettingsPanelMode, j as BuilderThemeTokenOverrides, k as BuilderThemeTokens, S as SectionPreset, l as createDefaultStudioDocument, m as
|
|
2
|
-
import '../index-
|
|
3
|
-
import 'react';
|
|
1
|
+
export { B as BuilderBlock, a as BuilderBlockPreviewRenderArgs, b as BuilderBlockPreviewRenderer, c as BuilderBlockSettingsV2, d as BuilderInlineTextComponentProps, e as BuilderPreviewEditingHelpers, f as BuilderPreviewTextFieldOptions, g as BuilderRenderWithSectionShell, h as BuilderSettingsPanelMode, j as BuilderThemeTokenOverrides, k as BuilderThemeTokens, S as SectionPreset, l as createDefaultStudioDocument, m as createStudioPageService, n as defaultBuilderThemeTokens, o as getStudioDocumentFromPage, p as layoutToStudioDocument, q as pageInspectorPanels, r as pageNodeTypes, s as pagePaletteGroups, t as pageStudioModuleManifest, u as resolveBuilderThemeTokens, v as studioDocumentToLayout, w as toEditorInitialDoc } from '../index-Cv-6qnrw.mjs';
|
|
2
|
+
import '../index-DWmudwDm.mjs';
|
|
4
3
|
import 'payload';
|
|
4
|
+
import 'react';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { B as BuilderBlock, a as BuilderBlockPreviewRenderArgs, b as BuilderBlockPreviewRenderer, c as BuilderBlockSettingsV2, d as BuilderInlineTextComponentProps, e as BuilderPreviewEditingHelpers, f as BuilderPreviewTextFieldOptions, g as BuilderRenderWithSectionShell, h as BuilderSettingsPanelMode, j as BuilderThemeTokenOverrides, k as BuilderThemeTokens, S as SectionPreset, l as createDefaultStudioDocument, m as
|
|
2
|
-
import '../index-
|
|
3
|
-
import 'react';
|
|
1
|
+
export { B as BuilderBlock, a as BuilderBlockPreviewRenderArgs, b as BuilderBlockPreviewRenderer, c as BuilderBlockSettingsV2, d as BuilderInlineTextComponentProps, e as BuilderPreviewEditingHelpers, f as BuilderPreviewTextFieldOptions, g as BuilderRenderWithSectionShell, h as BuilderSettingsPanelMode, j as BuilderThemeTokenOverrides, k as BuilderThemeTokens, S as SectionPreset, l as createDefaultStudioDocument, m as createStudioPageService, n as defaultBuilderThemeTokens, o as getStudioDocumentFromPage, p as layoutToStudioDocument, q as pageInspectorPanels, r as pageNodeTypes, s as pagePaletteGroups, t as pageStudioModuleManifest, u as resolveBuilderThemeTokens, v as studioDocumentToLayout, w as toEditorInitialDoc } from '../index-Crx_MtPw.js';
|
|
2
|
+
import '../index-DWmudwDm.js';
|
|
4
3
|
import 'payload';
|
|
4
|
+
import 'react';
|
|
@@ -21,14 +21,17 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var studio_pages_exports = {};
|
|
22
22
|
__export(studio_pages_exports, {
|
|
23
23
|
createDefaultStudioDocument: () => createDefaultStudioDocument,
|
|
24
|
+
createStudioPageService: () => createStudioPageService,
|
|
24
25
|
defaultBuilderThemeTokens: () => defaultBuilderThemeTokens,
|
|
26
|
+
getStudioDocumentFromPage: () => getStudioDocumentFromPage,
|
|
25
27
|
layoutToStudioDocument: () => layoutToStudioDocument,
|
|
26
28
|
pageInspectorPanels: () => pageInspectorPanels,
|
|
27
29
|
pageNodeTypes: () => pageNodeTypes,
|
|
28
30
|
pagePaletteGroups: () => pagePaletteGroups,
|
|
29
31
|
pageStudioModuleManifest: () => pageStudioModuleManifest,
|
|
30
32
|
resolveBuilderThemeTokens: () => resolveBuilderThemeTokens,
|
|
31
|
-
studioDocumentToLayout: () => studioDocumentToLayout
|
|
33
|
+
studioDocumentToLayout: () => studioDocumentToLayout,
|
|
34
|
+
toEditorInitialDoc: () => toEditorInitialDoc
|
|
32
35
|
});
|
|
33
36
|
module.exports = __toCommonJS(studio_pages_exports);
|
|
34
37
|
|
|
@@ -745,10 +748,327 @@ var createDefaultStudioDocument = (title) => ({
|
|
|
745
748
|
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
746
749
|
});
|
|
747
750
|
|
|
748
|
-
// src/studio
|
|
751
|
+
// src/studio/index.ts
|
|
749
752
|
var isRecord3 = (value) => Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
753
|
+
var makeIssue = (message, path, code = "studio.invalid") => ({
|
|
754
|
+
code,
|
|
755
|
+
message,
|
|
756
|
+
path,
|
|
757
|
+
severity: "error"
|
|
758
|
+
});
|
|
759
|
+
var createEmptyStudioDocument = (title) => ({
|
|
760
|
+
metadata: {},
|
|
761
|
+
schemaVersion: 1,
|
|
762
|
+
title,
|
|
763
|
+
nodes: [],
|
|
764
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
765
|
+
});
|
|
766
|
+
function assertStudioDocumentV1(input) {
|
|
767
|
+
if (!isRecord3(input)) {
|
|
768
|
+
throw new Error("Studio document must be an object");
|
|
769
|
+
}
|
|
770
|
+
if (input.schemaVersion !== 1) {
|
|
771
|
+
throw new Error("Unsupported studio schemaVersion");
|
|
772
|
+
}
|
|
773
|
+
if (!Array.isArray(input.nodes)) {
|
|
774
|
+
throw new Error("Studio document nodes must be an array");
|
|
775
|
+
}
|
|
776
|
+
const nodes = input.nodes.map((node, index) => {
|
|
777
|
+
if (!isRecord3(node)) {
|
|
778
|
+
throw new Error(`Node at index ${index} must be an object`);
|
|
779
|
+
}
|
|
780
|
+
if (typeof node.id !== "string" || node.id.length === 0) {
|
|
781
|
+
throw new Error(`Node at index ${index} has invalid id`);
|
|
782
|
+
}
|
|
783
|
+
if (typeof node.type !== "string" || node.type.length === 0) {
|
|
784
|
+
throw new Error(`Node at index ${index} has invalid type`);
|
|
785
|
+
}
|
|
786
|
+
if (!isRecord3(node.data)) {
|
|
787
|
+
throw new Error(`Node at index ${index} has invalid data`);
|
|
788
|
+
}
|
|
789
|
+
return {
|
|
790
|
+
id: node.id,
|
|
791
|
+
type: node.type,
|
|
792
|
+
data: node.data
|
|
793
|
+
};
|
|
794
|
+
});
|
|
795
|
+
return {
|
|
796
|
+
metadata: isRecord3(input.metadata) ? input.metadata : void 0,
|
|
797
|
+
schemaVersion: 1,
|
|
798
|
+
title: typeof input.title === "string" ? input.title : void 0,
|
|
799
|
+
nodes,
|
|
800
|
+
updatedAt: typeof input.updatedAt === "string" ? input.updatedAt : void 0
|
|
801
|
+
};
|
|
802
|
+
}
|
|
803
|
+
function createStudioRegistry(modules) {
|
|
804
|
+
const moduleByID = new Map(modules.map((mod) => [mod.id, mod]));
|
|
805
|
+
const nodeTypes = modules.flatMap((mod) => mod.nodeTypes);
|
|
806
|
+
const nodeTypeByName = new Map(nodeTypes.map((definition) => [definition.type, definition]));
|
|
807
|
+
return {
|
|
808
|
+
getModuleByID: (id) => moduleByID.get(id),
|
|
809
|
+
getNodeTypeByName: (type) => nodeTypeByName.get(type),
|
|
810
|
+
listInspectorPanels: () => modules.flatMap((mod) => mod.inspectorPanels),
|
|
811
|
+
listModules: () => [...modules],
|
|
812
|
+
listPaletteGroups: () => modules.flatMap((mod) => mod.paletteGroups),
|
|
813
|
+
listNodeTypes: () => [...nodeTypes]
|
|
814
|
+
};
|
|
815
|
+
}
|
|
816
|
+
function validateStudioDocument(document, modules) {
|
|
817
|
+
const issues = [];
|
|
818
|
+
if (document.schemaVersion !== 1) {
|
|
819
|
+
issues.push(makeIssue("Unsupported schema version", "schemaVersion", "studio.schemaVersion"));
|
|
820
|
+
}
|
|
821
|
+
if (!Array.isArray(document.nodes)) {
|
|
822
|
+
issues.push(makeIssue("Nodes must be an array", "nodes", "studio.nodes"));
|
|
823
|
+
return issues;
|
|
824
|
+
}
|
|
825
|
+
const registry = createStudioRegistry(modules);
|
|
826
|
+
const nodeIDs = /* @__PURE__ */ new Set();
|
|
827
|
+
document.nodes.forEach((node, index) => {
|
|
828
|
+
if (!node.id) {
|
|
829
|
+
issues.push(makeIssue("Node id is required", `nodes.${index}.id`, "studio.node.id"));
|
|
830
|
+
}
|
|
831
|
+
if (nodeIDs.has(node.id)) {
|
|
832
|
+
issues.push(makeIssue("Node id must be unique", `nodes.${index}.id`, "studio.node.id.duplicate"));
|
|
833
|
+
}
|
|
834
|
+
nodeIDs.add(node.id);
|
|
835
|
+
if (!registry.getNodeTypeByName(node.type)) {
|
|
836
|
+
issues.push(makeIssue("Unsupported node type", `nodes.${index}.type`, "studio.node.type"));
|
|
837
|
+
}
|
|
838
|
+
});
|
|
839
|
+
for (const module2 of modules) {
|
|
840
|
+
for (const validate of module2.validators) {
|
|
841
|
+
issues.push(...validate(document));
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
return issues;
|
|
845
|
+
}
|
|
846
|
+
function compileStudioDocument(document, modules) {
|
|
847
|
+
const issues = validateStudioDocument(document, modules);
|
|
848
|
+
const compilerEntries = modules.filter((mod) => typeof mod.compiler?.compileNode === "function").map((mod) => mod.compiler?.compileNode);
|
|
849
|
+
const layout = document.nodes.map((node) => {
|
|
850
|
+
for (const compileNode of compilerEntries) {
|
|
851
|
+
if (!compileNode) {
|
|
852
|
+
continue;
|
|
853
|
+
}
|
|
854
|
+
const compiled = compileNode(node);
|
|
855
|
+
if (compiled) {
|
|
856
|
+
return compiled;
|
|
857
|
+
}
|
|
858
|
+
}
|
|
859
|
+
return {
|
|
860
|
+
id: node.id,
|
|
861
|
+
blockType: node.type,
|
|
862
|
+
...node.data
|
|
863
|
+
};
|
|
864
|
+
});
|
|
865
|
+
return {
|
|
866
|
+
issues,
|
|
867
|
+
layout
|
|
868
|
+
};
|
|
869
|
+
}
|
|
870
|
+
|
|
871
|
+
// src/studio-pages/pageService.ts
|
|
872
|
+
var isRecord4 = (value) => Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
873
|
+
var toRecordArray = (value) => Array.isArray(value) ? value.filter((item) => isRecord4(item)) : [];
|
|
874
|
+
var getRelationID = (value) => {
|
|
875
|
+
if (typeof value === "number" || typeof value === "string") {
|
|
876
|
+
return value;
|
|
877
|
+
}
|
|
878
|
+
if (!isRecord4(value)) {
|
|
879
|
+
return null;
|
|
880
|
+
}
|
|
881
|
+
const id = value.id;
|
|
882
|
+
return typeof id === "number" || typeof id === "string" ? id : null;
|
|
883
|
+
};
|
|
884
|
+
var asLayoutArray = (value) => toRecordArray(value);
|
|
885
|
+
var hydrateRelationship = (valueFromStudio, valueFromLayout) => {
|
|
886
|
+
if (isRecord4(valueFromStudio)) {
|
|
887
|
+
return valueFromStudio;
|
|
888
|
+
}
|
|
889
|
+
if (!isRecord4(valueFromLayout)) {
|
|
890
|
+
return valueFromStudio;
|
|
891
|
+
}
|
|
892
|
+
const studioID = getRelationID(valueFromStudio);
|
|
893
|
+
const layoutID = getRelationID(valueFromLayout);
|
|
894
|
+
if (studioID === null || layoutID === null || String(studioID) !== String(layoutID)) {
|
|
895
|
+
return valueFromStudio;
|
|
896
|
+
}
|
|
897
|
+
return valueFromLayout;
|
|
898
|
+
};
|
|
899
|
+
var hydrateDocumentWithLayoutRelations = (document, layout) => {
|
|
900
|
+
const nextNodes = document.nodes.map((node, index) => {
|
|
901
|
+
const layoutBlock = layout[index];
|
|
902
|
+
if (!isRecord4(layoutBlock)) {
|
|
903
|
+
return node;
|
|
904
|
+
}
|
|
905
|
+
if (typeof layoutBlock.blockType !== "string" || layoutBlock.blockType !== node.type) {
|
|
906
|
+
return node;
|
|
907
|
+
}
|
|
908
|
+
const nextData = { ...node.data };
|
|
909
|
+
if (node.type === "hero") {
|
|
910
|
+
nextData.media = hydrateRelationship(nextData.media, layoutBlock.media);
|
|
911
|
+
}
|
|
912
|
+
if (node.type === "media") {
|
|
913
|
+
nextData.image = hydrateRelationship(nextData.image, layoutBlock.image);
|
|
914
|
+
}
|
|
915
|
+
if (node.type === "featureGrid" || node.type === "logoWall" || node.type === "beforeAfter") {
|
|
916
|
+
const studioItems = Array.isArray(nextData.items) ? nextData.items : [];
|
|
917
|
+
const layoutItems = Array.isArray(layoutBlock.items) ? layoutBlock.items : [];
|
|
918
|
+
nextData.items = studioItems.map((rawStudioItem, itemIndex) => {
|
|
919
|
+
if (!isRecord4(rawStudioItem)) {
|
|
920
|
+
return rawStudioItem;
|
|
921
|
+
}
|
|
922
|
+
const layoutItem = layoutItems[itemIndex];
|
|
923
|
+
if (!isRecord4(layoutItem)) {
|
|
924
|
+
return rawStudioItem;
|
|
925
|
+
}
|
|
926
|
+
const nextItem = { ...rawStudioItem };
|
|
927
|
+
nextItem.media = hydrateRelationship(nextItem.media, layoutItem.media);
|
|
928
|
+
nextItem.beforeMedia = hydrateRelationship(nextItem.beforeMedia, layoutItem.beforeMedia);
|
|
929
|
+
nextItem.afterMedia = hydrateRelationship(nextItem.afterMedia, layoutItem.afterMedia);
|
|
930
|
+
return nextItem;
|
|
931
|
+
});
|
|
932
|
+
}
|
|
933
|
+
return {
|
|
934
|
+
...node,
|
|
935
|
+
data: nextData
|
|
936
|
+
};
|
|
937
|
+
});
|
|
938
|
+
return {
|
|
939
|
+
...document,
|
|
940
|
+
nodes: nextNodes
|
|
941
|
+
};
|
|
942
|
+
};
|
|
943
|
+
var normalizeDocument = (document) => ({
|
|
944
|
+
...document,
|
|
945
|
+
schemaVersion: 1,
|
|
946
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
947
|
+
});
|
|
948
|
+
var normalizeLegacyHeroDefaults = (document) => {
|
|
949
|
+
const nodes = document.nodes.map((node) => {
|
|
950
|
+
if (node.type !== "hero" || !isRecord4(node.data)) {
|
|
951
|
+
return node;
|
|
952
|
+
}
|
|
953
|
+
const nextData = { ...node.data };
|
|
954
|
+
const heroBackgroundColor = typeof nextData.backgroundColor === "string" ? nextData.backgroundColor.trim().toLowerCase() : "";
|
|
955
|
+
const sectionBackgroundMode = typeof nextData.sectionBackgroundMode === "string" ? nextData.sectionBackgroundMode : "none";
|
|
956
|
+
const hasBackgroundImageURL = typeof nextData.backgroundImageURL === "string" && nextData.backgroundImageURL.trim().length > 0;
|
|
957
|
+
const mediaRelation = getRelationID(nextData.media);
|
|
958
|
+
if (heroBackgroundColor === "#124a37" && sectionBackgroundMode === "none" && !hasBackgroundImageURL && mediaRelation === null) {
|
|
959
|
+
nextData.backgroundColor = "";
|
|
960
|
+
}
|
|
961
|
+
return {
|
|
962
|
+
...node,
|
|
963
|
+
data: nextData
|
|
964
|
+
};
|
|
965
|
+
});
|
|
966
|
+
return {
|
|
967
|
+
...document,
|
|
968
|
+
nodes
|
|
969
|
+
};
|
|
970
|
+
};
|
|
971
|
+
var assertCanPublish = (issues) => {
|
|
972
|
+
const publishErrors = issues.filter((issue) => issue.severity === "error");
|
|
973
|
+
if (publishErrors.length > 0) {
|
|
974
|
+
throw new Error(`Cannot publish page: ${publishErrors[0].message}`);
|
|
975
|
+
}
|
|
976
|
+
};
|
|
977
|
+
var getStudioDocumentFromPage = (doc) => {
|
|
978
|
+
const title = typeof doc.title === "string" ? doc.title : void 0;
|
|
979
|
+
const layout = asLayoutArray(doc.layout);
|
|
980
|
+
try {
|
|
981
|
+
const studioDocument = assertStudioDocumentV1(doc.studioDocument);
|
|
982
|
+
if (layout.length > 0) {
|
|
983
|
+
return hydrateDocumentWithLayoutRelations(studioDocument, layout);
|
|
984
|
+
}
|
|
985
|
+
return studioDocument;
|
|
986
|
+
} catch {
|
|
987
|
+
if (layout.length > 0) {
|
|
988
|
+
return layoutToStudioDocument(layout, title);
|
|
989
|
+
}
|
|
990
|
+
return createEmptyStudioDocument(title);
|
|
991
|
+
}
|
|
992
|
+
};
|
|
993
|
+
var createStudioPageService = ({
|
|
994
|
+
collectionSlug = "pages",
|
|
995
|
+
modules,
|
|
996
|
+
payload,
|
|
997
|
+
user
|
|
998
|
+
}) => ({
|
|
999
|
+
getPageForStudio: async (pageID) => {
|
|
1000
|
+
const page = await payload.findByID({
|
|
1001
|
+
collection: collectionSlug,
|
|
1002
|
+
depth: 2,
|
|
1003
|
+
draft: true,
|
|
1004
|
+
id: pageID,
|
|
1005
|
+
overrideAccess: false,
|
|
1006
|
+
user
|
|
1007
|
+
});
|
|
1008
|
+
const studioDocument = getStudioDocumentFromPage(page);
|
|
1009
|
+
return {
|
|
1010
|
+
id: String(page.id),
|
|
1011
|
+
slug: typeof page.slug === "string" ? page.slug : "",
|
|
1012
|
+
studioDocument,
|
|
1013
|
+
title: typeof page.title === "string" ? page.title : "Untitled Page"
|
|
1014
|
+
};
|
|
1015
|
+
},
|
|
1016
|
+
validateStudioDocument: (document) => validateStudioDocument(document, modules),
|
|
1017
|
+
saveDraft: async (pageID, document, _metadata) => {
|
|
1018
|
+
const normalizedDocument = normalizeLegacyHeroDefaults(normalizeDocument(document));
|
|
1019
|
+
const compileResult = compileStudioDocument(normalizedDocument, modules);
|
|
1020
|
+
await payload.update({
|
|
1021
|
+
collection: collectionSlug,
|
|
1022
|
+
data: {
|
|
1023
|
+
_status: "draft",
|
|
1024
|
+
layout: compileResult.layout,
|
|
1025
|
+
studioDocument: normalizedDocument,
|
|
1026
|
+
studioValidationIssues: compileResult.issues,
|
|
1027
|
+
title: normalizedDocument.title
|
|
1028
|
+
},
|
|
1029
|
+
id: pageID,
|
|
1030
|
+
overrideAccess: false,
|
|
1031
|
+
user
|
|
1032
|
+
});
|
|
1033
|
+
return {
|
|
1034
|
+
id: pageID,
|
|
1035
|
+
status: "draft"
|
|
1036
|
+
};
|
|
1037
|
+
},
|
|
1038
|
+
publish: async (pageID, document, _metadata) => {
|
|
1039
|
+
const normalizedDocument = normalizeLegacyHeroDefaults(normalizeDocument(document));
|
|
1040
|
+
const compileResult = compileStudioDocument(normalizedDocument, modules);
|
|
1041
|
+
assertCanPublish(compileResult.issues);
|
|
1042
|
+
await payload.update({
|
|
1043
|
+
collection: collectionSlug,
|
|
1044
|
+
data: {
|
|
1045
|
+
_status: "published",
|
|
1046
|
+
layout: compileResult.layout,
|
|
1047
|
+
studioDocument: normalizedDocument,
|
|
1048
|
+
studioValidationIssues: compileResult.issues,
|
|
1049
|
+
title: normalizedDocument.title
|
|
1050
|
+
},
|
|
1051
|
+
id: pageID,
|
|
1052
|
+
overrideAccess: false,
|
|
1053
|
+
user
|
|
1054
|
+
});
|
|
1055
|
+
return {
|
|
1056
|
+
id: pageID,
|
|
1057
|
+
status: "published"
|
|
1058
|
+
};
|
|
1059
|
+
}
|
|
1060
|
+
});
|
|
1061
|
+
var toEditorInitialDoc = (payloadPage) => ({
|
|
1062
|
+
layout: studioDocumentToLayout(payloadPage.studioDocument),
|
|
1063
|
+
slug: typeof payloadPage.slug === "string" ? payloadPage.slug : "",
|
|
1064
|
+
studioDocument: payloadPage.studioDocument,
|
|
1065
|
+
title: payloadPage.title
|
|
1066
|
+
});
|
|
1067
|
+
|
|
1068
|
+
// src/studio-pages/migrations.ts
|
|
1069
|
+
var isRecord5 = (value) => Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
750
1070
|
var assertPageStudioDocumentV1 = (value) => {
|
|
751
|
-
if (!
|
|
1071
|
+
if (!isRecord5(value)) {
|
|
752
1072
|
throw new Error("Studio document must be an object");
|
|
753
1073
|
}
|
|
754
1074
|
if (value.schemaVersion !== 1) {
|
|
@@ -758,7 +1078,7 @@ var assertPageStudioDocumentV1 = (value) => {
|
|
|
758
1078
|
throw new Error("Studio document nodes must be an array");
|
|
759
1079
|
}
|
|
760
1080
|
const nodes = value.nodes.map((node, index) => {
|
|
761
|
-
if (!
|
|
1081
|
+
if (!isRecord5(node)) {
|
|
762
1082
|
throw new Error(`Node at index ${index} must be an object`);
|
|
763
1083
|
}
|
|
764
1084
|
if (typeof node.id !== "string" || node.id.length === 0) {
|
|
@@ -767,7 +1087,7 @@ var assertPageStudioDocumentV1 = (value) => {
|
|
|
767
1087
|
if (typeof node.type !== "string" || node.type.length === 0) {
|
|
768
1088
|
throw new Error(`Node at index ${index} has invalid type`);
|
|
769
1089
|
}
|
|
770
|
-
if (!
|
|
1090
|
+
if (!isRecord5(node.data)) {
|
|
771
1091
|
throw new Error(`Node at index ${index} has invalid data`);
|
|
772
1092
|
}
|
|
773
1093
|
return {
|
|
@@ -777,7 +1097,7 @@ var assertPageStudioDocumentV1 = (value) => {
|
|
|
777
1097
|
};
|
|
778
1098
|
});
|
|
779
1099
|
return {
|
|
780
|
-
metadata:
|
|
1100
|
+
metadata: isRecord5(value.metadata) ? value.metadata : void 0,
|
|
781
1101
|
nodes,
|
|
782
1102
|
schemaVersion: 1,
|
|
783
1103
|
title: typeof value.title === "string" ? value.title : void 0,
|
|
@@ -1100,12 +1420,15 @@ var pageStudioModuleManifest = {
|
|
|
1100
1420
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1101
1421
|
0 && (module.exports = {
|
|
1102
1422
|
createDefaultStudioDocument,
|
|
1423
|
+
createStudioPageService,
|
|
1103
1424
|
defaultBuilderThemeTokens,
|
|
1425
|
+
getStudioDocumentFromPage,
|
|
1104
1426
|
layoutToStudioDocument,
|
|
1105
1427
|
pageInspectorPanels,
|
|
1106
1428
|
pageNodeTypes,
|
|
1107
1429
|
pagePaletteGroups,
|
|
1108
1430
|
pageStudioModuleManifest,
|
|
1109
1431
|
resolveBuilderThemeTokens,
|
|
1110
|
-
studioDocumentToLayout
|
|
1432
|
+
studioDocumentToLayout,
|
|
1433
|
+
toEditorInitialDoc
|
|
1111
1434
|
});
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
|
+
createStudioPageService,
|
|
3
|
+
getStudioDocumentFromPage,
|
|
2
4
|
pageInspectorPanels,
|
|
3
5
|
pageNodeTypes,
|
|
4
6
|
pagePaletteGroups,
|
|
5
7
|
pageStudioModuleManifest,
|
|
6
|
-
resolveBuilderThemeTokens
|
|
7
|
-
|
|
8
|
+
resolveBuilderThemeTokens,
|
|
9
|
+
toEditorInitialDoc
|
|
10
|
+
} from "../chunk-XKUTZ7IU.mjs";
|
|
8
11
|
import "../chunk-OQSEJXC4.mjs";
|
|
9
12
|
import {
|
|
10
13
|
createDefaultStudioDocument,
|
|
@@ -12,15 +15,19 @@ import {
|
|
|
12
15
|
layoutToStudioDocument,
|
|
13
16
|
studioDocumentToLayout
|
|
14
17
|
} from "../chunk-PF3EBZXF.mjs";
|
|
18
|
+
import "../chunk-ADIIWIYL.mjs";
|
|
15
19
|
import "../chunk-6BWS3CLP.mjs";
|
|
16
20
|
export {
|
|
17
21
|
createDefaultStudioDocument,
|
|
22
|
+
createStudioPageService,
|
|
18
23
|
defaultBuilderThemeTokens,
|
|
24
|
+
getStudioDocumentFromPage,
|
|
19
25
|
layoutToStudioDocument,
|
|
20
26
|
pageInspectorPanels,
|
|
21
27
|
pageNodeTypes,
|
|
22
28
|
pagePaletteGroups,
|
|
23
29
|
pageStudioModuleManifest,
|
|
24
30
|
resolveBuilderThemeTokens,
|
|
25
|
-
studioDocumentToLayout
|
|
31
|
+
studioDocumentToLayout,
|
|
32
|
+
toEditorInitialDoc
|
|
26
33
|
};
|
package/package.json
CHANGED