@cmssy/react 0.4.0 → 0.5.1

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/client.d.cts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { B as BlockSchema, a as BlockMeta, C as CmssyPageData, b as BlockDefinition, c as CmssyFormDefinition, d as CmssyLayoutGroup, e as CmssyLocaleContext, f as CmssyCart, g as CmssyOrder, h as CmssyProduct } from './commerce-queries-CNsuz7zE.cjs';
3
- export { i as CmssyCartDiscount, j as CmssyCartItem, k as CmssyCartItemSnapshot, l as CmssyOrderItem, m as CmssyProductVariant } from './commerce-queries-CNsuz7zE.cjs';
2
+ import { B as BlockSchema, a as BlockMeta, C as CmssyPageData, b as BlockDefinition, c as CmssyFormDefinition, d as CmssyLayoutGroup, e as CmssyLocaleContext, f as CmssyCart, g as CmssyOrder, h as CmssyProduct } from './commerce-queries-MXclVwc1.cjs';
3
+ export { i as CmssyCartDiscount, j as CmssyCartItem, k as CmssyCartItemSnapshot, l as CmssyOrderItem, m as CmssyProductVariant } from './commerce-queries-MXclVwc1.cjs';
4
4
  import { ReactNode } from 'react';
5
5
 
6
6
  interface EditBridgeConfig {
package/dist/client.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { B as BlockSchema, a as BlockMeta, C as CmssyPageData, b as BlockDefinition, c as CmssyFormDefinition, d as CmssyLayoutGroup, e as CmssyLocaleContext, f as CmssyCart, g as CmssyOrder, h as CmssyProduct } from './commerce-queries-CNsuz7zE.js';
3
- export { i as CmssyCartDiscount, j as CmssyCartItem, k as CmssyCartItemSnapshot, l as CmssyOrderItem, m as CmssyProductVariant } from './commerce-queries-CNsuz7zE.js';
2
+ import { B as BlockSchema, a as BlockMeta, C as CmssyPageData, b as BlockDefinition, c as CmssyFormDefinition, d as CmssyLayoutGroup, e as CmssyLocaleContext, f as CmssyCart, g as CmssyOrder, h as CmssyProduct } from './commerce-queries-MXclVwc1.js';
3
+ export { i as CmssyCartDiscount, j as CmssyCartItem, k as CmssyCartItemSnapshot, l as CmssyOrderItem, m as CmssyProductVariant } from './commerce-queries-MXclVwc1.js';
4
4
  import { ReactNode } from 'react';
5
5
 
6
6
  interface EditBridgeConfig {
@@ -43,6 +43,12 @@ interface CmssyLayoutGroup {
43
43
  declare function normalizeSlug(path: string | string[] | undefined): string;
44
44
  declare function fetchPage(config: CmssyClientConfig, path: string | string[] | undefined, options?: FetchPageOptions): Promise<CmssyPageData | null>;
45
45
  declare function fetchPageById(config: CmssyClientConfig, pageId: string, options?: Pick<FetchPageOptions, "fetch" | "signal">): Promise<CmssyPageData | null>;
46
+ interface CmssyPageSummary {
47
+ slug: string;
48
+ updatedAt: string | null;
49
+ publishedAt: string | null;
50
+ }
51
+ declare function fetchPages(config: CmssyClientConfig, options?: Pick<FetchPageOptions, "fetch" | "signal">): Promise<CmssyPageSummary[]>;
46
52
  declare function fetchLayouts(config: CmssyClientConfig, path: string | string[] | undefined, options?: FetchPageOptions): Promise<CmssyLayoutGroup[]>;
47
53
 
48
54
  interface CmssyBranding {
@@ -409,4 +415,4 @@ interface CmssyOrder {
409
415
  createdAt?: string;
410
416
  }
411
417
 
412
- export { defineBlock as $, type AppToEditorMessage as A, type BlockSchema as B, type CmssyPageData as C, type CmssyModelRecord as D, type EditorToAppMessage as E, type FieldDefinition as F, type CmssyRecordList as G, FORM_QUERY as H, type FetchLikeResponse as I, type FetchPageOptions as J, type FieldType as K, MODEL_RECORDS_QUERY as L, MODEL_DEFINITIONS_QUERY as M, type ParentReadyMessage as N, type PatchMessage as O, PROTOCOL_VERSION as P, type RawLayoutBlock as Q, type RawBlock as R, type ReadyMessage as S, SITE_CONFIG_QUERY as T, SUBMIT_FORM_MUTATION as U, type SelectMessage as V, type SubmitFormInput as W, blocksToMeta as X, blocksToSchemas as Y, buildBlockContext as Z, buildBlockMap as _, type BlockMeta as a, fetchLayouts as a0, fetchPage as a1, fetchPageById as a2, isProtocolCompatible as a3, normalizeSlug as a4, type BlockDefinition as b, type CmssyFormDefinition as c, type CmssyLayoutGroup as d, type CmssyLocaleContext as e, type CmssyCart as f, type CmssyOrder as g, type CmssyProduct as h, type CmssyCartDiscount as i, type CmssyCartItem as j, type CmssyCartItemSnapshot as k, type CmssyOrderItem as l, type CmssyProductVariant as m, type FetchLike as n, type CmssyClientConfig as o, type CmssySiteConfig as p, type BlockMap as q, type CmssyBlockContext as r, type BlockRect as s, type BoundsMessage as t, type ClickMessage as u, type CmssyBranding as v, type CmssyFormField as w, type CmssyFormSettings as x, type CmssyFormSubmitResponse as y, type CmssyModelDefinition as z };
418
+ export { buildBlockMap as $, type AppToEditorMessage as A, type BlockSchema as B, type CmssyPageData as C, type CmssyModelRecord as D, type EditorToAppMessage as E, type FieldDefinition as F, type CmssyPageSummary as G, type CmssyRecordList as H, FORM_QUERY as I, type FetchLikeResponse as J, type FetchPageOptions as K, type FieldType as L, MODEL_DEFINITIONS_QUERY as M, MODEL_RECORDS_QUERY as N, type ParentReadyMessage as O, PROTOCOL_VERSION as P, type PatchMessage as Q, type RawBlock as R, type RawLayoutBlock as S, type ReadyMessage as T, SITE_CONFIG_QUERY as U, SUBMIT_FORM_MUTATION as V, type SelectMessage as W, type SubmitFormInput as X, blocksToMeta as Y, blocksToSchemas as Z, buildBlockContext as _, type BlockMeta as a, defineBlock as a0, fetchLayouts as a1, fetchPage as a2, fetchPageById as a3, fetchPages as a4, isProtocolCompatible as a5, normalizeSlug as a6, type BlockDefinition as b, type CmssyFormDefinition as c, type CmssyLayoutGroup as d, type CmssyLocaleContext as e, type CmssyCart as f, type CmssyOrder as g, type CmssyProduct as h, type CmssyCartDiscount as i, type CmssyCartItem as j, type CmssyCartItemSnapshot as k, type CmssyOrderItem as l, type CmssyProductVariant as m, type FetchLike as n, type CmssyClientConfig as o, type CmssySiteConfig as p, type BlockMap as q, type CmssyBlockContext as r, type BlockRect as s, type BoundsMessage as t, type ClickMessage as u, type CmssyBranding as v, type CmssyFormField as w, type CmssyFormSettings as x, type CmssyFormSubmitResponse as y, type CmssyModelDefinition as z };
@@ -43,6 +43,12 @@ interface CmssyLayoutGroup {
43
43
  declare function normalizeSlug(path: string | string[] | undefined): string;
44
44
  declare function fetchPage(config: CmssyClientConfig, path: string | string[] | undefined, options?: FetchPageOptions): Promise<CmssyPageData | null>;
45
45
  declare function fetchPageById(config: CmssyClientConfig, pageId: string, options?: Pick<FetchPageOptions, "fetch" | "signal">): Promise<CmssyPageData | null>;
46
+ interface CmssyPageSummary {
47
+ slug: string;
48
+ updatedAt: string | null;
49
+ publishedAt: string | null;
50
+ }
51
+ declare function fetchPages(config: CmssyClientConfig, options?: Pick<FetchPageOptions, "fetch" | "signal">): Promise<CmssyPageSummary[]>;
46
52
  declare function fetchLayouts(config: CmssyClientConfig, path: string | string[] | undefined, options?: FetchPageOptions): Promise<CmssyLayoutGroup[]>;
47
53
 
48
54
  interface CmssyBranding {
@@ -409,4 +415,4 @@ interface CmssyOrder {
409
415
  createdAt?: string;
410
416
  }
411
417
 
412
- export { defineBlock as $, type AppToEditorMessage as A, type BlockSchema as B, type CmssyPageData as C, type CmssyModelRecord as D, type EditorToAppMessage as E, type FieldDefinition as F, type CmssyRecordList as G, FORM_QUERY as H, type FetchLikeResponse as I, type FetchPageOptions as J, type FieldType as K, MODEL_RECORDS_QUERY as L, MODEL_DEFINITIONS_QUERY as M, type ParentReadyMessage as N, type PatchMessage as O, PROTOCOL_VERSION as P, type RawLayoutBlock as Q, type RawBlock as R, type ReadyMessage as S, SITE_CONFIG_QUERY as T, SUBMIT_FORM_MUTATION as U, type SelectMessage as V, type SubmitFormInput as W, blocksToMeta as X, blocksToSchemas as Y, buildBlockContext as Z, buildBlockMap as _, type BlockMeta as a, fetchLayouts as a0, fetchPage as a1, fetchPageById as a2, isProtocolCompatible as a3, normalizeSlug as a4, type BlockDefinition as b, type CmssyFormDefinition as c, type CmssyLayoutGroup as d, type CmssyLocaleContext as e, type CmssyCart as f, type CmssyOrder as g, type CmssyProduct as h, type CmssyCartDiscount as i, type CmssyCartItem as j, type CmssyCartItemSnapshot as k, type CmssyOrderItem as l, type CmssyProductVariant as m, type FetchLike as n, type CmssyClientConfig as o, type CmssySiteConfig as p, type BlockMap as q, type CmssyBlockContext as r, type BlockRect as s, type BoundsMessage as t, type ClickMessage as u, type CmssyBranding as v, type CmssyFormField as w, type CmssyFormSettings as x, type CmssyFormSubmitResponse as y, type CmssyModelDefinition as z };
418
+ export { buildBlockMap as $, type AppToEditorMessage as A, type BlockSchema as B, type CmssyPageData as C, type CmssyModelRecord as D, type EditorToAppMessage as E, type FieldDefinition as F, type CmssyPageSummary as G, type CmssyRecordList as H, FORM_QUERY as I, type FetchLikeResponse as J, type FetchPageOptions as K, type FieldType as L, MODEL_DEFINITIONS_QUERY as M, MODEL_RECORDS_QUERY as N, type ParentReadyMessage as O, PROTOCOL_VERSION as P, type PatchMessage as Q, type RawBlock as R, type RawLayoutBlock as S, type ReadyMessage as T, SITE_CONFIG_QUERY as U, SUBMIT_FORM_MUTATION as V, type SelectMessage as W, type SubmitFormInput as X, blocksToMeta as Y, blocksToSchemas as Z, buildBlockContext as _, type BlockMeta as a, defineBlock as a0, fetchLayouts as a1, fetchPage as a2, fetchPageById as a3, fetchPages as a4, isProtocolCompatible as a5, normalizeSlug as a6, type BlockDefinition as b, type CmssyFormDefinition as c, type CmssyLayoutGroup as d, type CmssyLocaleContext as e, type CmssyCart as f, type CmssyOrder as g, type CmssyProduct as h, type CmssyCartDiscount as i, type CmssyCartItem as j, type CmssyCartItemSnapshot as k, type CmssyOrderItem as l, type CmssyProductVariant as m, type FetchLike as n, type CmssyClientConfig as o, type CmssySiteConfig as p, type BlockMap as q, type CmssyBlockContext as r, type BlockRect as s, type BoundsMessage as t, type ClickMessage as u, type CmssyBranding as v, type CmssyFormField as w, type CmssyFormSettings as x, type CmssyFormSubmitResponse as y, type CmssyModelDefinition as z };
package/dist/index.cjs CHANGED
@@ -296,6 +296,13 @@ var PUBLIC_PAGE_BY_ID_QUERY = `query PublicPageById($workspaceSlug: String!, $pa
296
296
  publishedBlocks { id type content }
297
297
  }
298
298
  }`;
299
+ var PUBLIC_PAGES_QUERY = `query PublicPages($workspaceSlug: String!) {
300
+ publicPages(workspaceSlug: $workspaceSlug) {
301
+ slug
302
+ updatedAt
303
+ publishedAt
304
+ }
305
+ }`;
299
306
  var PUBLIC_PAGE_LAYOUTS_QUERY = `query PublicPageLayouts($workspaceSlug: String!, $pageSlug: String!, $previewSecret: String) {
300
307
  publicPageLayouts(workspaceSlug: $workspaceSlug, pageSlug: $pageSlug, previewSecret: $previewSecret) {
301
308
  position
@@ -405,6 +412,37 @@ async function fetchPageById(config, pageId, options = {}) {
405
412
  if (!page) return null;
406
413
  return { id: page.id, blocks: page.publishedBlocks ?? [] };
407
414
  }
415
+ async function fetchPages(config, options = {}) {
416
+ const doFetch = options.fetch ?? globalThis.fetch;
417
+ if (typeof doFetch !== "function") {
418
+ throw new Error(
419
+ "cmssy: no fetch implementation available - pass options.fetch"
420
+ );
421
+ }
422
+ const response = await doFetch(config.apiUrl, {
423
+ method: "POST",
424
+ headers: { "content-type": "application/json" },
425
+ body: JSON.stringify({
426
+ query: PUBLIC_PAGES_QUERY,
427
+ variables: { workspaceSlug: config.workspaceSlug }
428
+ }),
429
+ signal: options.signal
430
+ });
431
+ if (!response.ok) {
432
+ throw new Error(`cmssy: pages fetch failed (${response.status})`);
433
+ }
434
+ let json;
435
+ try {
436
+ json = await response.json();
437
+ } catch {
438
+ throw new Error("cmssy: invalid JSON response from the pages query");
439
+ }
440
+ if (json.errors && json.errors.length > 0) {
441
+ const message = json.errors.map((error) => error.message ?? "GraphQL error").join("; ");
442
+ throw new Error(`cmssy: pages fetch error - ${message}`);
443
+ }
444
+ return json.data?.publicPages ?? [];
445
+ }
408
446
  async function fetchLayouts(config, path, options = {}) {
409
447
  const pageSlug = normalizeSlug(path);
410
448
  const doFetch = options.fetch ?? globalThis.fetch;
@@ -773,6 +811,7 @@ exports.defineBlock = defineBlock;
773
811
  exports.fetchLayouts = fetchLayouts;
774
812
  exports.fetchPage = fetchPage;
775
813
  exports.fetchPageById = fetchPageById;
814
+ exports.fetchPages = fetchPages;
776
815
  exports.fetchSiteConfig = fetchSiteConfig;
777
816
  exports.fields = fields;
778
817
  exports.getBlockContentForLanguage = getBlockContentForLanguage;
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { F as FieldDefinition, C as CmssyPageData, b as BlockDefinition, c as CmssyFormDefinition, d as CmssyLayoutGroup, E as EditorToAppMessage, A as AppToEditorMessage, n as FetchLike, o as CmssyClientConfig, p as CmssySiteConfig, R as RawBlock, e as CmssyLocaleContext, q as BlockMap, r as CmssyBlockContext } from './commerce-queries-CNsuz7zE.cjs';
2
- export { a as BlockMeta, s as BlockRect, B as BlockSchema, t as BoundsMessage, u as ClickMessage, v as CmssyBranding, f as CmssyCart, i as CmssyCartDiscount, j as CmssyCartItem, k as CmssyCartItemSnapshot, w as CmssyFormField, x as CmssyFormSettings, y as CmssyFormSubmitResponse, z as CmssyModelDefinition, D as CmssyModelRecord, g as CmssyOrder, h as CmssyProduct, m as CmssyProductVariant, G as CmssyRecordList, H as FORM_QUERY, I as FetchLikeResponse, J as FetchPageOptions, K as FieldType, M as MODEL_DEFINITIONS_QUERY, L as MODEL_RECORDS_QUERY, P as PROTOCOL_VERSION, N as ParentReadyMessage, O as PatchMessage, Q as RawLayoutBlock, S as ReadyMessage, T as SITE_CONFIG_QUERY, U as SUBMIT_FORM_MUTATION, V as SelectMessage, W as SubmitFormInput, X as blocksToMeta, Y as blocksToSchemas, Z as buildBlockContext, _ as buildBlockMap, $ as defineBlock, a0 as fetchLayouts, a1 as fetchPage, a2 as fetchPageById, a3 as isProtocolCompatible, a4 as normalizeSlug } from './commerce-queries-CNsuz7zE.cjs';
1
+ import { F as FieldDefinition, C as CmssyPageData, b as BlockDefinition, c as CmssyFormDefinition, d as CmssyLayoutGroup, E as EditorToAppMessage, A as AppToEditorMessage, n as FetchLike, o as CmssyClientConfig, p as CmssySiteConfig, R as RawBlock, e as CmssyLocaleContext, q as BlockMap, r as CmssyBlockContext } from './commerce-queries-MXclVwc1.cjs';
2
+ export { a as BlockMeta, s as BlockRect, B as BlockSchema, t as BoundsMessage, u as ClickMessage, v as CmssyBranding, f as CmssyCart, i as CmssyCartDiscount, j as CmssyCartItem, k as CmssyCartItemSnapshot, w as CmssyFormField, x as CmssyFormSettings, y as CmssyFormSubmitResponse, z as CmssyModelDefinition, D as CmssyModelRecord, g as CmssyOrder, G as CmssyPageSummary, h as CmssyProduct, m as CmssyProductVariant, H as CmssyRecordList, I as FORM_QUERY, J as FetchLikeResponse, K as FetchPageOptions, L as FieldType, M as MODEL_DEFINITIONS_QUERY, N as MODEL_RECORDS_QUERY, P as PROTOCOL_VERSION, O as ParentReadyMessage, Q as PatchMessage, S as RawLayoutBlock, T as ReadyMessage, U as SITE_CONFIG_QUERY, V as SUBMIT_FORM_MUTATION, W as SelectMessage, X as SubmitFormInput, Y as blocksToMeta, Z as blocksToSchemas, _ as buildBlockContext, $ as buildBlockMap, a0 as defineBlock, a1 as fetchLayouts, a2 as fetchPage, a3 as fetchPageById, a4 as fetchPages, a5 as isProtocolCompatible, a6 as normalizeSlug } from './commerce-queries-MXclVwc1.cjs';
3
3
  import * as react_jsx_runtime from 'react/jsx-runtime';
4
4
  import 'react';
5
5
 
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { F as FieldDefinition, C as CmssyPageData, b as BlockDefinition, c as CmssyFormDefinition, d as CmssyLayoutGroup, E as EditorToAppMessage, A as AppToEditorMessage, n as FetchLike, o as CmssyClientConfig, p as CmssySiteConfig, R as RawBlock, e as CmssyLocaleContext, q as BlockMap, r as CmssyBlockContext } from './commerce-queries-CNsuz7zE.js';
2
- export { a as BlockMeta, s as BlockRect, B as BlockSchema, t as BoundsMessage, u as ClickMessage, v as CmssyBranding, f as CmssyCart, i as CmssyCartDiscount, j as CmssyCartItem, k as CmssyCartItemSnapshot, w as CmssyFormField, x as CmssyFormSettings, y as CmssyFormSubmitResponse, z as CmssyModelDefinition, D as CmssyModelRecord, g as CmssyOrder, h as CmssyProduct, m as CmssyProductVariant, G as CmssyRecordList, H as FORM_QUERY, I as FetchLikeResponse, J as FetchPageOptions, K as FieldType, M as MODEL_DEFINITIONS_QUERY, L as MODEL_RECORDS_QUERY, P as PROTOCOL_VERSION, N as ParentReadyMessage, O as PatchMessage, Q as RawLayoutBlock, S as ReadyMessage, T as SITE_CONFIG_QUERY, U as SUBMIT_FORM_MUTATION, V as SelectMessage, W as SubmitFormInput, X as blocksToMeta, Y as blocksToSchemas, Z as buildBlockContext, _ as buildBlockMap, $ as defineBlock, a0 as fetchLayouts, a1 as fetchPage, a2 as fetchPageById, a3 as isProtocolCompatible, a4 as normalizeSlug } from './commerce-queries-CNsuz7zE.js';
1
+ import { F as FieldDefinition, C as CmssyPageData, b as BlockDefinition, c as CmssyFormDefinition, d as CmssyLayoutGroup, E as EditorToAppMessage, A as AppToEditorMessage, n as FetchLike, o as CmssyClientConfig, p as CmssySiteConfig, R as RawBlock, e as CmssyLocaleContext, q as BlockMap, r as CmssyBlockContext } from './commerce-queries-MXclVwc1.js';
2
+ export { a as BlockMeta, s as BlockRect, B as BlockSchema, t as BoundsMessage, u as ClickMessage, v as CmssyBranding, f as CmssyCart, i as CmssyCartDiscount, j as CmssyCartItem, k as CmssyCartItemSnapshot, w as CmssyFormField, x as CmssyFormSettings, y as CmssyFormSubmitResponse, z as CmssyModelDefinition, D as CmssyModelRecord, g as CmssyOrder, G as CmssyPageSummary, h as CmssyProduct, m as CmssyProductVariant, H as CmssyRecordList, I as FORM_QUERY, J as FetchLikeResponse, K as FetchPageOptions, L as FieldType, M as MODEL_DEFINITIONS_QUERY, N as MODEL_RECORDS_QUERY, P as PROTOCOL_VERSION, O as ParentReadyMessage, Q as PatchMessage, S as RawLayoutBlock, T as ReadyMessage, U as SITE_CONFIG_QUERY, V as SUBMIT_FORM_MUTATION, W as SelectMessage, X as SubmitFormInput, Y as blocksToMeta, Z as blocksToSchemas, _ as buildBlockContext, $ as buildBlockMap, a0 as defineBlock, a1 as fetchLayouts, a2 as fetchPage, a3 as fetchPageById, a4 as fetchPages, a5 as isProtocolCompatible, a6 as normalizeSlug } from './commerce-queries-MXclVwc1.js';
3
3
  import * as react_jsx_runtime from 'react/jsx-runtime';
4
4
  import 'react';
5
5
 
package/dist/index.js CHANGED
@@ -294,6 +294,13 @@ var PUBLIC_PAGE_BY_ID_QUERY = `query PublicPageById($workspaceSlug: String!, $pa
294
294
  publishedBlocks { id type content }
295
295
  }
296
296
  }`;
297
+ var PUBLIC_PAGES_QUERY = `query PublicPages($workspaceSlug: String!) {
298
+ publicPages(workspaceSlug: $workspaceSlug) {
299
+ slug
300
+ updatedAt
301
+ publishedAt
302
+ }
303
+ }`;
297
304
  var PUBLIC_PAGE_LAYOUTS_QUERY = `query PublicPageLayouts($workspaceSlug: String!, $pageSlug: String!, $previewSecret: String) {
298
305
  publicPageLayouts(workspaceSlug: $workspaceSlug, pageSlug: $pageSlug, previewSecret: $previewSecret) {
299
306
  position
@@ -403,6 +410,37 @@ async function fetchPageById(config, pageId, options = {}) {
403
410
  if (!page) return null;
404
411
  return { id: page.id, blocks: page.publishedBlocks ?? [] };
405
412
  }
413
+ async function fetchPages(config, options = {}) {
414
+ const doFetch = options.fetch ?? globalThis.fetch;
415
+ if (typeof doFetch !== "function") {
416
+ throw new Error(
417
+ "cmssy: no fetch implementation available - pass options.fetch"
418
+ );
419
+ }
420
+ const response = await doFetch(config.apiUrl, {
421
+ method: "POST",
422
+ headers: { "content-type": "application/json" },
423
+ body: JSON.stringify({
424
+ query: PUBLIC_PAGES_QUERY,
425
+ variables: { workspaceSlug: config.workspaceSlug }
426
+ }),
427
+ signal: options.signal
428
+ });
429
+ if (!response.ok) {
430
+ throw new Error(`cmssy: pages fetch failed (${response.status})`);
431
+ }
432
+ let json;
433
+ try {
434
+ json = await response.json();
435
+ } catch {
436
+ throw new Error("cmssy: invalid JSON response from the pages query");
437
+ }
438
+ if (json.errors && json.errors.length > 0) {
439
+ const message = json.errors.map((error) => error.message ?? "GraphQL error").join("; ");
440
+ throw new Error(`cmssy: pages fetch error - ${message}`);
441
+ }
442
+ return json.data?.publicPages ?? [];
443
+ }
406
444
  async function fetchLayouts(config, path, options = {}) {
407
445
  const pageSlug = normalizeSlug(path);
408
446
  const doFetch = options.fetch ?? globalThis.fetch;
@@ -750,4 +788,4 @@ function CmssyBlock({
750
788
  );
751
789
  }
752
790
 
753
- export { CmssyBlock, CmssyServerLayout, CmssyServerPage, FORM_QUERY, MODEL_DEFINITIONS_QUERY, MODEL_RECORDS_QUERY, PROTOCOL_VERSION, SITE_CONFIG_QUERY, SUBMIT_FORM_MUTATION, UnknownBlock, blocksToMeta, blocksToSchemas, buildBlockContext, buildBlockMap, buildLocaleSwitchHref, collectFormIds, createCmssyClient, defineBlock, fetchLayouts, fetchPage, fetchPageById, fetchSiteConfig, fields, getBlockContentForLanguage, graphqlRequest, isProtocolCompatible, localizeHref, localizeHtmlLinks, normalizeOrigin, normalizeSlug, parseEditorMessage, postToEditor, resolveForms, resolveSiteLocales, resolveWorkspaceId, splitLocaleFromPath };
791
+ export { CmssyBlock, CmssyServerLayout, CmssyServerPage, FORM_QUERY, MODEL_DEFINITIONS_QUERY, MODEL_RECORDS_QUERY, PROTOCOL_VERSION, SITE_CONFIG_QUERY, SUBMIT_FORM_MUTATION, UnknownBlock, blocksToMeta, blocksToSchemas, buildBlockContext, buildBlockMap, buildLocaleSwitchHref, collectFormIds, createCmssyClient, defineBlock, fetchLayouts, fetchPage, fetchPageById, fetchPages, fetchSiteConfig, fields, getBlockContentForLanguage, graphqlRequest, isProtocolCompatible, localizeHref, localizeHtmlLinks, normalizeOrigin, normalizeSlug, parseEditorMessage, postToEditor, resolveForms, resolveSiteLocales, resolveWorkspaceId, splitLocaleFromPath };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cmssy/react",
3
- "version": "0.4.0",
3
+ "version": "0.5.1",
4
4
  "description": "React blocks, renderers, data client and editor bridge for cmssy headless sites",
5
5
  "keywords": [
6
6
  "cmssy",