@orion-studios/payload-studio 0.5.0-beta.18 → 0.5.0-beta.19

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.
@@ -33,6 +33,7 @@ function createPayloadClient(config) {
33
33
 
34
34
  // src/nextjs/queries/pages.ts
35
35
  import { unstable_cache } from "next/cache";
36
+ var PAGE_QUERY_CACHE_VERSION = "v2-studio-layout-published-only";
36
37
  function withStudioDocumentLayout(page) {
37
38
  if (!page) {
38
39
  return null;
@@ -58,33 +59,40 @@ function normalizePath(segments) {
58
59
  return cleaned.length > 0 ? `/${cleaned}` : "/";
59
60
  }
60
61
  async function queryPageByPath(payload, path, draft) {
62
+ const pathWhere = {
63
+ path: {
64
+ equals: path
65
+ }
66
+ };
67
+ const publishedWhere = {
68
+ _status: {
69
+ equals: "published"
70
+ }
71
+ };
61
72
  const result = await payload.find({
62
73
  collection: "pages",
63
74
  depth: 2,
64
75
  draft,
65
76
  limit: 1,
66
77
  overrideAccess: false,
67
- where: {
68
- path: {
69
- equals: path
70
- }
71
- }
78
+ where: draft ? pathWhere : { and: [pathWhere, publishedWhere] }
72
79
  });
73
80
  if (result.docs.length > 0) {
74
81
  return withStudioDocumentLayout(result.docs[0] || null);
75
82
  }
76
83
  if (path === "/") {
84
+ const homeWhere = {
85
+ slug: {
86
+ equals: "home"
87
+ }
88
+ };
77
89
  const homeResult = await payload.find({
78
90
  collection: "pages",
79
91
  depth: 2,
80
92
  draft,
81
93
  limit: 1,
82
94
  overrideAccess: false,
83
- where: {
84
- slug: {
85
- equals: "home"
86
- }
87
- }
95
+ where: draft ? homeWhere : { and: [homeWhere, publishedWhere] }
88
96
  });
89
97
  return withStudioDocumentLayout(homeResult.docs[0] || null);
90
98
  }
@@ -96,7 +104,7 @@ function createPageQueries(getPayloadClient, contentTag = "website-content") {
96
104
  const payload = await getPayloadClient();
97
105
  return queryPageByPath(payload, path, false);
98
106
  },
99
- ["page-by-path"],
107
+ ["page-by-path", PAGE_QUERY_CACHE_VERSION],
100
108
  { tags: [contentTag] }
101
109
  );
102
110
  async function getPageBySegments(segments, draft = false) {
package/dist/index.js CHANGED
@@ -1976,6 +1976,7 @@ var createDefaultStudioDocument = (title) => ({
1976
1976
  });
1977
1977
 
1978
1978
  // src/nextjs/queries/pages.ts
1979
+ var PAGE_QUERY_CACHE_VERSION = "v2-studio-layout-published-only";
1979
1980
  function withStudioDocumentLayout(page) {
1980
1981
  if (!page) {
1981
1982
  return null;
@@ -2001,33 +2002,40 @@ function normalizePath(segments) {
2001
2002
  return cleaned.length > 0 ? `/${cleaned}` : "/";
2002
2003
  }
2003
2004
  async function queryPageByPath(payload, path2, draft) {
2005
+ const pathWhere = {
2006
+ path: {
2007
+ equals: path2
2008
+ }
2009
+ };
2010
+ const publishedWhere = {
2011
+ _status: {
2012
+ equals: "published"
2013
+ }
2014
+ };
2004
2015
  const result = await payload.find({
2005
2016
  collection: "pages",
2006
2017
  depth: 2,
2007
2018
  draft,
2008
2019
  limit: 1,
2009
2020
  overrideAccess: false,
2010
- where: {
2011
- path: {
2012
- equals: path2
2013
- }
2014
- }
2021
+ where: draft ? pathWhere : { and: [pathWhere, publishedWhere] }
2015
2022
  });
2016
2023
  if (result.docs.length > 0) {
2017
2024
  return withStudioDocumentLayout(result.docs[0] || null);
2018
2025
  }
2019
2026
  if (path2 === "/") {
2027
+ const homeWhere = {
2028
+ slug: {
2029
+ equals: "home"
2030
+ }
2031
+ };
2020
2032
  const homeResult = await payload.find({
2021
2033
  collection: "pages",
2022
2034
  depth: 2,
2023
2035
  draft,
2024
2036
  limit: 1,
2025
2037
  overrideAccess: false,
2026
- where: {
2027
- slug: {
2028
- equals: "home"
2029
- }
2030
- }
2038
+ where: draft ? homeWhere : { and: [homeWhere, publishedWhere] }
2031
2039
  });
2032
2040
  return withStudioDocumentLayout(homeResult.docs[0] || null);
2033
2041
  }
@@ -2039,7 +2047,7 @@ function createPageQueries(getPayloadClient, contentTag = "website-content") {
2039
2047
  const payload = await getPayloadClient();
2040
2048
  return queryPageByPath(payload, path2, false);
2041
2049
  },
2042
- ["page-by-path"],
2050
+ ["page-by-path", PAGE_QUERY_CACHE_VERSION],
2043
2051
  { tags: [contentTag] }
2044
2052
  );
2045
2053
  async function getPageBySegments(segments, draft = false) {
package/dist/index.mjs CHANGED
@@ -1,21 +1,21 @@
1
- import {
2
- admin_app_exports
3
- } from "./chunk-AAOHJDNS.mjs";
4
1
  import {
5
2
  admin_exports
6
3
  } from "./chunk-J7W5EE3B.mjs";
7
- import {
8
- blocks_exports
9
- } from "./chunk-L36VUYHE.mjs";
10
4
  import {
11
5
  nextjs_exports
12
- } from "./chunk-D73AVVLT.mjs";
6
+ } from "./chunk-GTMO62N3.mjs";
7
+ import {
8
+ admin_app_exports
9
+ } from "./chunk-AAOHJDNS.mjs";
13
10
  import {
14
11
  studio_exports
15
12
  } from "./chunk-N67KVM2S.mjs";
16
13
  import {
17
14
  studio_pages_exports
18
15
  } from "./chunk-NIRXZKDV.mjs";
16
+ import {
17
+ blocks_exports
18
+ } from "./chunk-L36VUYHE.mjs";
19
19
  import "./chunk-ETRRXURT.mjs";
20
20
  import "./chunk-6BWS3CLP.mjs";
21
21
  export {
@@ -273,6 +273,7 @@ var studioDocumentToLayout = (document) => document.nodes.map((node) => ({
273
273
  }));
274
274
 
275
275
  // src/nextjs/queries/pages.ts
276
+ var PAGE_QUERY_CACHE_VERSION = "v2-studio-layout-published-only";
276
277
  function withStudioDocumentLayout(page) {
277
278
  if (!page) {
278
279
  return null;
@@ -298,33 +299,40 @@ function normalizePath(segments) {
298
299
  return cleaned.length > 0 ? `/${cleaned}` : "/";
299
300
  }
300
301
  async function queryPageByPath(payload, path, draft) {
302
+ const pathWhere = {
303
+ path: {
304
+ equals: path
305
+ }
306
+ };
307
+ const publishedWhere = {
308
+ _status: {
309
+ equals: "published"
310
+ }
311
+ };
301
312
  const result = await payload.find({
302
313
  collection: "pages",
303
314
  depth: 2,
304
315
  draft,
305
316
  limit: 1,
306
317
  overrideAccess: false,
307
- where: {
308
- path: {
309
- equals: path
310
- }
311
- }
318
+ where: draft ? pathWhere : { and: [pathWhere, publishedWhere] }
312
319
  });
313
320
  if (result.docs.length > 0) {
314
321
  return withStudioDocumentLayout(result.docs[0] || null);
315
322
  }
316
323
  if (path === "/") {
324
+ const homeWhere = {
325
+ slug: {
326
+ equals: "home"
327
+ }
328
+ };
317
329
  const homeResult = await payload.find({
318
330
  collection: "pages",
319
331
  depth: 2,
320
332
  draft,
321
333
  limit: 1,
322
334
  overrideAccess: false,
323
- where: {
324
- slug: {
325
- equals: "home"
326
- }
327
- }
335
+ where: draft ? homeWhere : { and: [homeWhere, publishedWhere] }
328
336
  });
329
337
  return withStudioDocumentLayout(homeResult.docs[0] || null);
330
338
  }
@@ -336,7 +344,7 @@ function createPageQueries(getPayloadClient, contentTag = "website-content") {
336
344
  const payload = await getPayloadClient();
337
345
  return queryPageByPath(payload, path, false);
338
346
  },
339
- ["page-by-path"],
347
+ ["page-by-path", PAGE_QUERY_CACHE_VERSION],
340
348
  { tags: [contentTag] }
341
349
  );
342
350
  async function getPageBySegments(segments, draft = false) {
@@ -4,7 +4,7 @@ import {
4
4
  createPayloadClient,
5
5
  createSiteQueries,
6
6
  resolveMedia
7
- } from "../chunk-D73AVVLT.mjs";
7
+ } from "../chunk-GTMO62N3.mjs";
8
8
  import "../chunk-N67KVM2S.mjs";
9
9
  import "../chunk-NIRXZKDV.mjs";
10
10
  import "../chunk-ETRRXURT.mjs";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orion-studios/payload-studio",
3
- "version": "0.5.0-beta.18",
3
+ "version": "0.5.0-beta.19",
4
4
  "description": "Unified Payload CMS toolkit for Orion Studios",
5
5
  "types": "./dist/index.d.ts",
6
6
  "exports": {