@orion-studios/payload-studio 0.5.0-beta.75 → 0.5.0-beta.77

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.
@@ -299,9 +299,6 @@ function compileStudioDocument(document, modules) {
299
299
  }
300
300
  function migrateStudioDocument(value, migrations) {
301
301
  const sorted = [...migrations].sort((a, b) => a.fromVersion - b.fromVersion);
302
- if (isRecord(value) && value.schemaVersion === 1) {
303
- return assertStudioDocumentV1(value);
304
- }
305
302
  let current = value;
306
303
  for (const migration of sorted) {
307
304
  if (!isRecord(current) || current.schemaVersion !== migration.fromVersion) {
@@ -745,6 +745,71 @@ var inspectorDefinitionByBlockType = {
745
745
  // src/studio-pages/builder/settings-v2/BlockInspectorRenderer.tsx
746
746
  import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
747
747
 
748
+ // src/studio-pages/migrations.ts
749
+ var isRecord3 = (value) => Boolean(value) && typeof value === "object" && !Array.isArray(value);
750
+ var assertPageStudioDocumentV1 = (value) => {
751
+ if (!isRecord3(value)) {
752
+ throw new Error("Studio document must be an object");
753
+ }
754
+ if (value.schemaVersion !== 1) {
755
+ throw new Error("Unsupported studio schemaVersion");
756
+ }
757
+ if (!Array.isArray(value.nodes)) {
758
+ throw new Error("Studio document nodes must be an array");
759
+ }
760
+ const nodes = value.nodes.map((node, index) => {
761
+ if (!isRecord3(node)) {
762
+ throw new Error(`Node at index ${index} must be an object`);
763
+ }
764
+ if (typeof node.id !== "string" || node.id.length === 0) {
765
+ throw new Error(`Node at index ${index} has invalid id`);
766
+ }
767
+ if (typeof node.type !== "string" || node.type.length === 0) {
768
+ throw new Error(`Node at index ${index} has invalid type`);
769
+ }
770
+ if (!isRecord3(node.data)) {
771
+ throw new Error(`Node at index ${index} has invalid data`);
772
+ }
773
+ return {
774
+ data: node.data,
775
+ id: node.id,
776
+ type: node.type
777
+ };
778
+ });
779
+ return {
780
+ metadata: isRecord3(value.metadata) ? value.metadata : void 0,
781
+ nodes,
782
+ schemaVersion: 1,
783
+ title: typeof value.title === "string" ? value.title : void 0,
784
+ updatedAt: typeof value.updatedAt === "string" ? value.updatedAt : void 0
785
+ };
786
+ };
787
+ var migratePageNodeToSettingsV2 = (node) => {
788
+ const normalized = migrateBlockToSettingsV2({
789
+ blockType: node.type,
790
+ ...node.data
791
+ });
792
+ const { blockType: _ignoredBlockType, ...data } = normalized;
793
+ return {
794
+ ...node,
795
+ data
796
+ };
797
+ };
798
+ var migratePageDocumentSettingsToV2 = (value) => {
799
+ const current = assertPageStudioDocumentV1(value);
800
+ return {
801
+ ...current,
802
+ nodes: current.nodes.map(migratePageNodeToSettingsV2)
803
+ };
804
+ };
805
+ var pageStudioMigrations = [
806
+ {
807
+ fromVersion: 1,
808
+ migrate: migratePageDocumentSettingsToV2,
809
+ toVersion: 1
810
+ }
811
+ ];
812
+
748
813
  // src/studio-pages/index.ts
749
814
  var withSectionStyleDefaults = (value) => ({
750
815
  ...sectionStyleDefaults,
@@ -994,7 +1059,7 @@ var pageStudioModuleManifest = {
994
1059
  paletteGroups: pagePaletteGroups,
995
1060
  inspectorPanels: pageInspectorPanels,
996
1061
  validators: [validatePageDocument],
997
- migrations: [],
1062
+ migrations: pageStudioMigrations,
998
1063
  compiler: {
999
1064
  compileNode: (node) => {
1000
1065
  const normalized = migrateBlockToSettingsV2({
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  assertStudioDocumentV1
3
- } from "./chunk-HXGAG6I7.mjs";
3
+ } from "./chunk-ADIIWIYL.mjs";
4
4
  import {
5
5
  studioDocumentToLayout
6
- } from "./chunk-C6VEFZVY.mjs";
6
+ } from "./chunk-YSH3KLUU.mjs";
7
7
  import {
8
8
  __export
9
9
  } from "./chunk-6BWS3CLP.mjs";
package/dist/index.js CHANGED
@@ -2685,9 +2685,6 @@ function compileStudioDocument(document, modules) {
2685
2685
  }
2686
2686
  function migrateStudioDocument(value, migrations) {
2687
2687
  const sorted = [...migrations].sort((a, b) => a.fromVersion - b.fromVersion);
2688
- if (isRecord(value) && value.schemaVersion === 1) {
2689
- return assertStudioDocumentV1(value);
2690
- }
2691
2688
  let current = value;
2692
2689
  for (const migration of sorted) {
2693
2690
  if (!isRecord(current) || current.schemaVersion !== migration.fromVersion) {
@@ -3438,6 +3435,71 @@ var inspectorDefinitionByBlockType = {
3438
3435
  // src/studio-pages/builder/settings-v2/BlockInspectorRenderer.tsx
3439
3436
  var import_jsx_runtime6 = require("react/jsx-runtime");
3440
3437
 
3438
+ // src/studio-pages/migrations.ts
3439
+ var isRecord4 = (value) => Boolean(value) && typeof value === "object" && !Array.isArray(value);
3440
+ var assertPageStudioDocumentV1 = (value) => {
3441
+ if (!isRecord4(value)) {
3442
+ throw new Error("Studio document must be an object");
3443
+ }
3444
+ if (value.schemaVersion !== 1) {
3445
+ throw new Error("Unsupported studio schemaVersion");
3446
+ }
3447
+ if (!Array.isArray(value.nodes)) {
3448
+ throw new Error("Studio document nodes must be an array");
3449
+ }
3450
+ const nodes = value.nodes.map((node, index) => {
3451
+ if (!isRecord4(node)) {
3452
+ throw new Error(`Node at index ${index} must be an object`);
3453
+ }
3454
+ if (typeof node.id !== "string" || node.id.length === 0) {
3455
+ throw new Error(`Node at index ${index} has invalid id`);
3456
+ }
3457
+ if (typeof node.type !== "string" || node.type.length === 0) {
3458
+ throw new Error(`Node at index ${index} has invalid type`);
3459
+ }
3460
+ if (!isRecord4(node.data)) {
3461
+ throw new Error(`Node at index ${index} has invalid data`);
3462
+ }
3463
+ return {
3464
+ data: node.data,
3465
+ id: node.id,
3466
+ type: node.type
3467
+ };
3468
+ });
3469
+ return {
3470
+ metadata: isRecord4(value.metadata) ? value.metadata : void 0,
3471
+ nodes,
3472
+ schemaVersion: 1,
3473
+ title: typeof value.title === "string" ? value.title : void 0,
3474
+ updatedAt: typeof value.updatedAt === "string" ? value.updatedAt : void 0
3475
+ };
3476
+ };
3477
+ var migratePageNodeToSettingsV2 = (node) => {
3478
+ const normalized = migrateBlockToSettingsV2({
3479
+ blockType: node.type,
3480
+ ...node.data
3481
+ });
3482
+ const { blockType: _ignoredBlockType, ...data } = normalized;
3483
+ return {
3484
+ ...node,
3485
+ data
3486
+ };
3487
+ };
3488
+ var migratePageDocumentSettingsToV2 = (value) => {
3489
+ const current = assertPageStudioDocumentV1(value);
3490
+ return {
3491
+ ...current,
3492
+ nodes: current.nodes.map(migratePageNodeToSettingsV2)
3493
+ };
3494
+ };
3495
+ var pageStudioMigrations = [
3496
+ {
3497
+ fromVersion: 1,
3498
+ migrate: migratePageDocumentSettingsToV2,
3499
+ toVersion: 1
3500
+ }
3501
+ ];
3502
+
3441
3503
  // src/studio-pages/index.ts
3442
3504
  var withSectionStyleDefaults = (value) => ({
3443
3505
  ...sectionStyleDefaults,
@@ -3687,7 +3749,7 @@ var pageStudioModuleManifest = {
3687
3749
  paletteGroups: pagePaletteGroups,
3688
3750
  inspectorPanels: pageInspectorPanels,
3689
3751
  validators: [validatePageDocument],
3690
- migrations: [],
3752
+ migrations: pageStudioMigrations,
3691
3753
  compiler: {
3692
3754
  compileNode: (node) => {
3693
3755
  const normalized = migrateBlockToSettingsV2({
package/dist/index.mjs CHANGED
@@ -9,13 +9,13 @@ import {
9
9
  } from "./chunk-XK3K5GRP.mjs";
10
10
  import {
11
11
  nextjs_exports
12
- } from "./chunk-6H4JTVPY.mjs";
12
+ } from "./chunk-ZYKHJFXY.mjs";
13
13
  import {
14
14
  studio_exports
15
- } from "./chunk-HXGAG6I7.mjs";
15
+ } from "./chunk-ADIIWIYL.mjs";
16
16
  import {
17
17
  studio_pages_exports
18
- } from "./chunk-C6VEFZVY.mjs";
18
+ } from "./chunk-YSH3KLUU.mjs";
19
19
  import "./chunk-SIL2J5MF.mjs";
20
20
  import "./chunk-6BWS3CLP.mjs";
21
21
  export {
@@ -4,9 +4,9 @@ import {
4
4
  createPayloadClient,
5
5
  createSiteQueries,
6
6
  resolveMedia
7
- } from "../chunk-6H4JTVPY.mjs";
8
- import "../chunk-HXGAG6I7.mjs";
9
- import "../chunk-C6VEFZVY.mjs";
7
+ } from "../chunk-ZYKHJFXY.mjs";
8
+ import "../chunk-ADIIWIYL.mjs";
9
+ import "../chunk-YSH3KLUU.mjs";
10
10
  import "../chunk-SIL2J5MF.mjs";
11
11
  import "../chunk-6BWS3CLP.mjs";
12
12
  export {
@@ -315,9 +315,6 @@ function compileStudioDocument(document, modules) {
315
315
  }
316
316
  function migrateStudioDocument(value, migrations) {
317
317
  const sorted = [...migrations].sort((a, b) => a.fromVersion - b.fromVersion);
318
- if (isRecord(value) && value.schemaVersion === 1) {
319
- return assertStudioDocumentV1(value);
320
- }
321
318
  let current = value;
322
319
  for (const migration of sorted) {
323
320
  if (!isRecord(current) || current.schemaVersion !== migration.fromVersion) {
@@ -7,7 +7,7 @@ import {
7
7
  migrateStudioDocument,
8
8
  validateStudioDocument,
9
9
  withImageUploadOptimization
10
- } from "../chunk-HXGAG6I7.mjs";
10
+ } from "../chunk-ADIIWIYL.mjs";
11
11
  import "../chunk-6BWS3CLP.mjs";
12
12
  export {
13
13
  assertStudioDocumentV1,