@cmssy/react 0.5.2 → 0.5.4

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-BIiXoA6A.cjs';
3
- export { i as CmssyCartDiscount, j as CmssyCartItem, k as CmssyCartItemSnapshot, l as CmssyOrderItem, m as CmssyProductVariant } from './commerce-queries-BIiXoA6A.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-DLiN9uHz.cjs';
3
+ export { i as CmssyCartDiscount, j as CmssyCartItem, k as CmssyCartItemSnapshot, l as CmssyOrderItem, m as CmssyProductVariant } from './commerce-queries-DLiN9uHz.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-BIiXoA6A.js';
3
- export { i as CmssyCartDiscount, j as CmssyCartItem, k as CmssyCartItemSnapshot, l as CmssyOrderItem, m as CmssyProductVariant } from './commerce-queries-BIiXoA6A.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-DLiN9uHz.js';
3
+ export { i as CmssyCartDiscount, j as CmssyCartItem, k as CmssyCartItemSnapshot, l as CmssyOrderItem, m as CmssyProductVariant } from './commerce-queries-DLiN9uHz.js';
4
4
  import { ReactNode } from 'react';
5
5
 
6
6
  interface EditBridgeConfig {
@@ -50,6 +50,15 @@ interface CmssyPageSummary {
50
50
  publishedAt: string | null;
51
51
  }
52
52
  declare function fetchPages(config: CmssyClientConfig, options?: Pick<FetchPageOptions, "fetch" | "signal">): Promise<CmssyPageSummary[]>;
53
+ type CmssyLocalizedValue = Record<string, string> | string | null;
54
+ interface CmssyPageMeta {
55
+ id: string;
56
+ seoTitle: CmssyLocalizedValue;
57
+ seoDescription: CmssyLocalizedValue;
58
+ seoKeywords: string[] | null;
59
+ displayName: CmssyLocalizedValue;
60
+ }
61
+ declare function fetchPageMeta(config: CmssyClientConfig, path: string | string[] | undefined, options?: Pick<FetchPageOptions, "fetch" | "signal">): Promise<CmssyPageMeta | null>;
53
62
  declare function fetchLayouts(config: CmssyClientConfig, path: string | string[] | undefined, options?: FetchPageOptions): Promise<CmssyLayoutGroup[]>;
54
63
 
55
64
  interface CmssyBranding {
@@ -416,4 +425,4 @@ interface CmssyOrder {
416
425
  createdAt?: string;
417
426
  }
418
427
 
419
- 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 };
428
+ export { blocksToSchemas as $, type AppToEditorMessage as A, type BlockSchema as B, type CmssyPageData as C, type CmssyModelDefinition as D, type EditorToAppMessage as E, type FieldDefinition as F, type CmssyModelRecord as G, type CmssyPageMeta as H, type CmssyPageSummary as I, type CmssyRecordList as J, FORM_QUERY as K, type FetchLikeResponse as L, type FetchPageOptions as M, type FieldType as N, MODEL_DEFINITIONS_QUERY as O, MODEL_RECORDS_QUERY as P, PROTOCOL_VERSION as Q, type RawBlock as R, type ParentReadyMessage as S, type PatchMessage as T, type RawLayoutBlock as U, type ReadyMessage as V, SITE_CONFIG_QUERY as W, SUBMIT_FORM_MUTATION as X, type SelectMessage as Y, type SubmitFormInput as Z, blocksToMeta as _, type BlockMeta as a, buildBlockContext as a0, buildBlockMap as a1, defineBlock as a2, fetchLayouts as a3, fetchPage as a4, fetchPageById as a5, fetchPageMeta as a6, fetchPages as a7, isProtocolCompatible as a8, normalizeSlug as a9, 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 CmssyLocalizedValue as z };
@@ -50,6 +50,15 @@ interface CmssyPageSummary {
50
50
  publishedAt: string | null;
51
51
  }
52
52
  declare function fetchPages(config: CmssyClientConfig, options?: Pick<FetchPageOptions, "fetch" | "signal">): Promise<CmssyPageSummary[]>;
53
+ type CmssyLocalizedValue = Record<string, string> | string | null;
54
+ interface CmssyPageMeta {
55
+ id: string;
56
+ seoTitle: CmssyLocalizedValue;
57
+ seoDescription: CmssyLocalizedValue;
58
+ seoKeywords: string[] | null;
59
+ displayName: CmssyLocalizedValue;
60
+ }
61
+ declare function fetchPageMeta(config: CmssyClientConfig, path: string | string[] | undefined, options?: Pick<FetchPageOptions, "fetch" | "signal">): Promise<CmssyPageMeta | null>;
53
62
  declare function fetchLayouts(config: CmssyClientConfig, path: string | string[] | undefined, options?: FetchPageOptions): Promise<CmssyLayoutGroup[]>;
54
63
 
55
64
  interface CmssyBranding {
@@ -416,4 +425,4 @@ interface CmssyOrder {
416
425
  createdAt?: string;
417
426
  }
418
427
 
419
- 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 };
428
+ export { blocksToSchemas as $, type AppToEditorMessage as A, type BlockSchema as B, type CmssyPageData as C, type CmssyModelDefinition as D, type EditorToAppMessage as E, type FieldDefinition as F, type CmssyModelRecord as G, type CmssyPageMeta as H, type CmssyPageSummary as I, type CmssyRecordList as J, FORM_QUERY as K, type FetchLikeResponse as L, type FetchPageOptions as M, type FieldType as N, MODEL_DEFINITIONS_QUERY as O, MODEL_RECORDS_QUERY as P, PROTOCOL_VERSION as Q, type RawBlock as R, type ParentReadyMessage as S, type PatchMessage as T, type RawLayoutBlock as U, type ReadyMessage as V, SITE_CONFIG_QUERY as W, SUBMIT_FORM_MUTATION as X, type SelectMessage as Y, type SubmitFormInput as Z, blocksToMeta as _, type BlockMeta as a, buildBlockContext as a0, buildBlockMap as a1, defineBlock as a2, fetchLayouts as a3, fetchPage as a4, fetchPageById as a5, fetchPageMeta as a6, fetchPages as a7, isProtocolCompatible as a8, normalizeSlug as a9, 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 CmssyLocalizedValue as z };
package/dist/index.cjs CHANGED
@@ -304,6 +304,15 @@ var PUBLIC_PAGES_QUERY = `query PublicPages($workspaceSlug: String!) {
304
304
  publishedAt
305
305
  }
306
306
  }`;
307
+ var PUBLIC_PAGE_META_QUERY = `query PublicPageMeta($workspaceSlug: String!, $slug: String!) {
308
+ publicPage(workspaceSlug: $workspaceSlug, slug: $slug) {
309
+ id
310
+ seoTitle
311
+ seoDescription
312
+ seoKeywords
313
+ displayName
314
+ }
315
+ }`;
307
316
  var PUBLIC_PAGE_LAYOUTS_QUERY = `query PublicPageLayouts($workspaceSlug: String!, $pageSlug: String!, $previewSecret: String) {
308
317
  publicPageLayouts(workspaceSlug: $workspaceSlug, pageSlug: $pageSlug, previewSecret: $previewSecret) {
309
318
  position
@@ -444,6 +453,38 @@ async function fetchPages(config, options = {}) {
444
453
  }
445
454
  return json.data?.publicPages ?? [];
446
455
  }
456
+ async function fetchPageMeta(config, path, options = {}) {
457
+ const slug = normalizeSlug(path);
458
+ const doFetch = options.fetch ?? globalThis.fetch;
459
+ if (typeof doFetch !== "function") {
460
+ throw new Error(
461
+ "cmssy: no fetch implementation available - pass options.fetch"
462
+ );
463
+ }
464
+ const response = await doFetch(config.apiUrl, {
465
+ method: "POST",
466
+ headers: { "content-type": "application/json" },
467
+ body: JSON.stringify({
468
+ query: PUBLIC_PAGE_META_QUERY,
469
+ variables: { workspaceSlug: config.workspaceSlug, slug }
470
+ }),
471
+ signal: options.signal
472
+ });
473
+ if (!response.ok) {
474
+ throw new Error(`cmssy: page meta fetch failed (${response.status})`);
475
+ }
476
+ let json;
477
+ try {
478
+ json = await response.json();
479
+ } catch {
480
+ throw new Error("cmssy: invalid JSON response from the page meta query");
481
+ }
482
+ if (json.errors && json.errors.length > 0) {
483
+ const message = json.errors.map((error) => error.message ?? "GraphQL error").join("; ");
484
+ throw new Error(`cmssy: page meta fetch error - ${message}`);
485
+ }
486
+ return json.data?.publicPage ?? null;
487
+ }
447
488
  async function fetchLayouts(config, path, options = {}) {
448
489
  const pageSlug = normalizeSlug(path);
449
490
  const doFetch = options.fetch ?? globalThis.fetch;
@@ -812,6 +853,7 @@ exports.defineBlock = defineBlock;
812
853
  exports.fetchLayouts = fetchLayouts;
813
854
  exports.fetchPage = fetchPage;
814
855
  exports.fetchPageById = fetchPageById;
856
+ exports.fetchPageMeta = fetchPageMeta;
815
857
  exports.fetchPages = fetchPages;
816
858
  exports.fetchSiteConfig = fetchSiteConfig;
817
859
  exports.fields = fields;
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-BIiXoA6A.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-BIiXoA6A.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-DLiN9uHz.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 CmssyLocalizedValue, D as CmssyModelDefinition, G as CmssyModelRecord, g as CmssyOrder, H as CmssyPageMeta, I as CmssyPageSummary, h as CmssyProduct, m as CmssyProductVariant, J as CmssyRecordList, K as FORM_QUERY, L as FetchLikeResponse, M as FetchPageOptions, N as FieldType, O as MODEL_DEFINITIONS_QUERY, P as MODEL_RECORDS_QUERY, Q as PROTOCOL_VERSION, S as ParentReadyMessage, T as PatchMessage, U as RawLayoutBlock, V as ReadyMessage, W as SITE_CONFIG_QUERY, X as SUBMIT_FORM_MUTATION, Y as SelectMessage, Z as SubmitFormInput, _ as blocksToMeta, $ as blocksToSchemas, a0 as buildBlockContext, a1 as buildBlockMap, a2 as defineBlock, a3 as fetchLayouts, a4 as fetchPage, a5 as fetchPageById, a6 as fetchPageMeta, a7 as fetchPages, a8 as isProtocolCompatible, a9 as normalizeSlug } from './commerce-queries-DLiN9uHz.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-BIiXoA6A.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-BIiXoA6A.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-DLiN9uHz.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 CmssyLocalizedValue, D as CmssyModelDefinition, G as CmssyModelRecord, g as CmssyOrder, H as CmssyPageMeta, I as CmssyPageSummary, h as CmssyProduct, m as CmssyProductVariant, J as CmssyRecordList, K as FORM_QUERY, L as FetchLikeResponse, M as FetchPageOptions, N as FieldType, O as MODEL_DEFINITIONS_QUERY, P as MODEL_RECORDS_QUERY, Q as PROTOCOL_VERSION, S as ParentReadyMessage, T as PatchMessage, U as RawLayoutBlock, V as ReadyMessage, W as SITE_CONFIG_QUERY, X as SUBMIT_FORM_MUTATION, Y as SelectMessage, Z as SubmitFormInput, _ as blocksToMeta, $ as blocksToSchemas, a0 as buildBlockContext, a1 as buildBlockMap, a2 as defineBlock, a3 as fetchLayouts, a4 as fetchPage, a5 as fetchPageById, a6 as fetchPageMeta, a7 as fetchPages, a8 as isProtocolCompatible, a9 as normalizeSlug } from './commerce-queries-DLiN9uHz.js';
3
3
  import * as react_jsx_runtime from 'react/jsx-runtime';
4
4
  import 'react';
5
5
 
package/dist/index.js CHANGED
@@ -302,6 +302,15 @@ var PUBLIC_PAGES_QUERY = `query PublicPages($workspaceSlug: String!) {
302
302
  publishedAt
303
303
  }
304
304
  }`;
305
+ var PUBLIC_PAGE_META_QUERY = `query PublicPageMeta($workspaceSlug: String!, $slug: String!) {
306
+ publicPage(workspaceSlug: $workspaceSlug, slug: $slug) {
307
+ id
308
+ seoTitle
309
+ seoDescription
310
+ seoKeywords
311
+ displayName
312
+ }
313
+ }`;
305
314
  var PUBLIC_PAGE_LAYOUTS_QUERY = `query PublicPageLayouts($workspaceSlug: String!, $pageSlug: String!, $previewSecret: String) {
306
315
  publicPageLayouts(workspaceSlug: $workspaceSlug, pageSlug: $pageSlug, previewSecret: $previewSecret) {
307
316
  position
@@ -442,6 +451,38 @@ async function fetchPages(config, options = {}) {
442
451
  }
443
452
  return json.data?.publicPages ?? [];
444
453
  }
454
+ async function fetchPageMeta(config, path, options = {}) {
455
+ const slug = normalizeSlug(path);
456
+ const doFetch = options.fetch ?? globalThis.fetch;
457
+ if (typeof doFetch !== "function") {
458
+ throw new Error(
459
+ "cmssy: no fetch implementation available - pass options.fetch"
460
+ );
461
+ }
462
+ const response = await doFetch(config.apiUrl, {
463
+ method: "POST",
464
+ headers: { "content-type": "application/json" },
465
+ body: JSON.stringify({
466
+ query: PUBLIC_PAGE_META_QUERY,
467
+ variables: { workspaceSlug: config.workspaceSlug, slug }
468
+ }),
469
+ signal: options.signal
470
+ });
471
+ if (!response.ok) {
472
+ throw new Error(`cmssy: page meta fetch failed (${response.status})`);
473
+ }
474
+ let json;
475
+ try {
476
+ json = await response.json();
477
+ } catch {
478
+ throw new Error("cmssy: invalid JSON response from the page meta query");
479
+ }
480
+ if (json.errors && json.errors.length > 0) {
481
+ const message = json.errors.map((error) => error.message ?? "GraphQL error").join("; ");
482
+ throw new Error(`cmssy: page meta fetch error - ${message}`);
483
+ }
484
+ return json.data?.publicPage ?? null;
485
+ }
445
486
  async function fetchLayouts(config, path, options = {}) {
446
487
  const pageSlug = normalizeSlug(path);
447
488
  const doFetch = options.fetch ?? globalThis.fetch;
@@ -789,4 +830,4 @@ function CmssyBlock({
789
830
  );
790
831
  }
791
832
 
792
- 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 };
833
+ 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, fetchPageMeta, 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.5.2",
3
+ "version": "0.5.4",
4
4
  "description": "React blocks, renderers, data client and editor bridge for cmssy headless sites",
5
5
  "keywords": [
6
6
  "cmssy",