@cmssy/core 12.14.1 → 13.0.0

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.
@@ -1,10 +1,17 @@
1
- import { CmssyClientConfig, BlockRect, BlockSchema, BlockMeta } from '@cmssy/types';
1
+ import { LayoutRegion, CmssyClientConfig, BlockRect, BlockSchema, BlockMeta } from '@cmssy/types';
2
2
  import { G as GraphqlRequestOptions } from './locale-D9KI4bND.js';
3
3
 
4
+ interface CmssyLayout<R extends readonly LayoutRegion[] = readonly LayoutRegion[]> {
5
+ readonly regions: R;
6
+ }
7
+ type CmssyRegion<L extends CmssyLayout> = L["regions"][number]["id"];
8
+ declare function defineCmssyLayout<const R extends readonly LayoutRegion[]>(layout: CmssyLayout<R>): CmssyLayout<R>;
9
+ declare function layoutRegionIds(layout: CmssyLayout | undefined): string[];
10
+
4
11
  declare const DEFAULT_CMSSY_EDITOR_ORIGINS: string[];
5
12
  declare function isDevelopment(): boolean;
6
13
  declare function resolveEditorOrigin(editorOrigin: string | string[] | undefined): string | string[];
7
- interface CmssyConfig {
14
+ interface CmssyConfig<L extends CmssyLayout = CmssyLayout> {
8
15
  apiUrl?: string;
9
16
  org: string;
10
17
  workspaceSlug: string;
@@ -13,13 +20,15 @@ interface CmssyConfig {
13
20
  editorOrigin?: string | string[];
14
21
  siteUrl?: string;
15
22
  resolveLocale?: () => string | Promise<string>;
23
+ layout?: L;
16
24
  }
17
- type CmssyEnvConfig = Omit<CmssyConfig, "org" | "workspaceSlug" | "draftSecret"> & {
25
+ type CmssyRegionOf<C extends CmssyConfig> = NonNullable<C["layout"]>["regions"][number]["id"];
26
+ type CmssyEnvConfig<L extends CmssyLayout = CmssyLayout> = Omit<CmssyConfig<L>, "org" | "workspaceSlug" | "draftSecret"> & {
18
27
  org?: string;
19
28
  workspaceSlug?: string;
20
29
  draftSecret?: string;
21
30
  };
22
- declare function defineCmssyConfig(config: CmssyEnvConfig): CmssyConfig;
31
+ declare function defineCmssyConfig<L extends CmssyLayout = CmssyLayout>(config: CmssyEnvConfig<L>): CmssyConfig<L>;
23
32
 
24
33
  interface CmssyTypedDocument<Result, Variables> {
25
34
  __apiType?: (variables: Variables) => Result;
@@ -54,6 +63,7 @@ interface ReadyMessage {
54
63
  schemas: Record<string, BlockSchema>;
55
64
  blockMeta?: Record<string, BlockMeta>;
56
65
  capabilities?: string[];
66
+ layoutRegions?: LayoutRegion[];
57
67
  }
58
68
  interface BoundsMessage {
59
69
  type: "cmssy:bounds";
@@ -173,4 +183,4 @@ declare function toCspOrigin(origin: string): string;
173
183
  declare function cmssyCspHeaders(options: CmssyCspOptions): Record<string, string>;
174
184
  declare function applyCmssyCsp<T extends MutableHeaders>(response: T, options: CmssyCspOptions): T;
175
185
 
176
- export { type AppToEditorMessage as A, type BoundsMessage as B, type ClickMessage as C, DEFAULT_CMSSY_EDITOR_ORIGINS as D, type EditorToAppMessage as E, type InvisibleBlock as I, PROTOCOL_VERSION as P, type QueryScopedOptions as Q, type ReadyMessage as R, SHORTCUT_ACTIONS as S, type ViewportMessage as V, type CmssyClient as a, type CmssyConfig as b, type CmssyCspOptions as c, type CmssyEnvConfig as d, type CmssyTypedDocument as e, type InvisibleBlocksMessage as f, type ParentReadyMessage as g, type PatchMessage as h, type PostTarget as i, type SelectMessage as j, type ShortcutAction as k, type ShortcutMessage as l, applyCmssyCsp as m, createCmssyClient as n, defineCmssyConfig as o, isProtocolCompatible as p, normalizeOrigin as q, parseEditorMessage as r, postToEditor as s, resolveEditorOrigin as t, cmssyCspHeaders as u, isDevelopment as v, resolveInitialTarget as w, toCspOrigin as x };
186
+ export { type AppToEditorMessage as A, type BoundsMessage as B, type ClickMessage as C, DEFAULT_CMSSY_EDITOR_ORIGINS as D, type EditorToAppMessage as E, layoutRegionIds as F, resolveInitialTarget as G, toCspOrigin as H, type InvisibleBlock as I, PROTOCOL_VERSION as P, type QueryScopedOptions as Q, type ReadyMessage as R, SHORTCUT_ACTIONS as S, type ViewportMessage as V, type CmssyClient as a, type CmssyConfig as b, type CmssyCspOptions as c, type CmssyEnvConfig as d, type CmssyLayout as e, type CmssyRegion as f, type CmssyRegionOf as g, type CmssyTypedDocument as h, type InvisibleBlocksMessage as i, type ParentReadyMessage as j, type PatchMessage as k, type PostTarget as l, type SelectMessage as m, type ShortcutAction as n, type ShortcutMessage as o, applyCmssyCsp as p, createCmssyClient as q, defineCmssyConfig as r, defineCmssyLayout as s, isProtocolCompatible as t, normalizeOrigin as u, parseEditorMessage as v, postToEditor as w, resolveEditorOrigin as x, cmssyCspHeaders as y, isDevelopment as z };
@@ -1,10 +1,17 @@
1
- import { CmssyClientConfig, BlockRect, BlockSchema, BlockMeta } from '@cmssy/types';
1
+ import { LayoutRegion, CmssyClientConfig, BlockRect, BlockSchema, BlockMeta } from '@cmssy/types';
2
2
  import { G as GraphqlRequestOptions } from './locale-JyBHqpAQ.cjs';
3
3
 
4
+ interface CmssyLayout<R extends readonly LayoutRegion[] = readonly LayoutRegion[]> {
5
+ readonly regions: R;
6
+ }
7
+ type CmssyRegion<L extends CmssyLayout> = L["regions"][number]["id"];
8
+ declare function defineCmssyLayout<const R extends readonly LayoutRegion[]>(layout: CmssyLayout<R>): CmssyLayout<R>;
9
+ declare function layoutRegionIds(layout: CmssyLayout | undefined): string[];
10
+
4
11
  declare const DEFAULT_CMSSY_EDITOR_ORIGINS: string[];
5
12
  declare function isDevelopment(): boolean;
6
13
  declare function resolveEditorOrigin(editorOrigin: string | string[] | undefined): string | string[];
7
- interface CmssyConfig {
14
+ interface CmssyConfig<L extends CmssyLayout = CmssyLayout> {
8
15
  apiUrl?: string;
9
16
  org: string;
10
17
  workspaceSlug: string;
@@ -13,13 +20,15 @@ interface CmssyConfig {
13
20
  editorOrigin?: string | string[];
14
21
  siteUrl?: string;
15
22
  resolveLocale?: () => string | Promise<string>;
23
+ layout?: L;
16
24
  }
17
- type CmssyEnvConfig = Omit<CmssyConfig, "org" | "workspaceSlug" | "draftSecret"> & {
25
+ type CmssyRegionOf<C extends CmssyConfig> = NonNullable<C["layout"]>["regions"][number]["id"];
26
+ type CmssyEnvConfig<L extends CmssyLayout = CmssyLayout> = Omit<CmssyConfig<L>, "org" | "workspaceSlug" | "draftSecret"> & {
18
27
  org?: string;
19
28
  workspaceSlug?: string;
20
29
  draftSecret?: string;
21
30
  };
22
- declare function defineCmssyConfig(config: CmssyEnvConfig): CmssyConfig;
31
+ declare function defineCmssyConfig<L extends CmssyLayout = CmssyLayout>(config: CmssyEnvConfig<L>): CmssyConfig<L>;
23
32
 
24
33
  interface CmssyTypedDocument<Result, Variables> {
25
34
  __apiType?: (variables: Variables) => Result;
@@ -54,6 +63,7 @@ interface ReadyMessage {
54
63
  schemas: Record<string, BlockSchema>;
55
64
  blockMeta?: Record<string, BlockMeta>;
56
65
  capabilities?: string[];
66
+ layoutRegions?: LayoutRegion[];
57
67
  }
58
68
  interface BoundsMessage {
59
69
  type: "cmssy:bounds";
@@ -173,4 +183,4 @@ declare function toCspOrigin(origin: string): string;
173
183
  declare function cmssyCspHeaders(options: CmssyCspOptions): Record<string, string>;
174
184
  declare function applyCmssyCsp<T extends MutableHeaders>(response: T, options: CmssyCspOptions): T;
175
185
 
176
- export { type AppToEditorMessage as A, type BoundsMessage as B, type ClickMessage as C, DEFAULT_CMSSY_EDITOR_ORIGINS as D, type EditorToAppMessage as E, type InvisibleBlock as I, PROTOCOL_VERSION as P, type QueryScopedOptions as Q, type ReadyMessage as R, SHORTCUT_ACTIONS as S, type ViewportMessage as V, type CmssyClient as a, type CmssyConfig as b, type CmssyCspOptions as c, type CmssyEnvConfig as d, type CmssyTypedDocument as e, type InvisibleBlocksMessage as f, type ParentReadyMessage as g, type PatchMessage as h, type PostTarget as i, type SelectMessage as j, type ShortcutAction as k, type ShortcutMessage as l, applyCmssyCsp as m, createCmssyClient as n, defineCmssyConfig as o, isProtocolCompatible as p, normalizeOrigin as q, parseEditorMessage as r, postToEditor as s, resolveEditorOrigin as t, cmssyCspHeaders as u, isDevelopment as v, resolveInitialTarget as w, toCspOrigin as x };
186
+ export { type AppToEditorMessage as A, type BoundsMessage as B, type ClickMessage as C, DEFAULT_CMSSY_EDITOR_ORIGINS as D, type EditorToAppMessage as E, layoutRegionIds as F, resolveInitialTarget as G, toCspOrigin as H, type InvisibleBlock as I, PROTOCOL_VERSION as P, type QueryScopedOptions as Q, type ReadyMessage as R, SHORTCUT_ACTIONS as S, type ViewportMessage as V, type CmssyClient as a, type CmssyConfig as b, type CmssyCspOptions as c, type CmssyEnvConfig as d, type CmssyLayout as e, type CmssyRegion as f, type CmssyRegionOf as g, type CmssyTypedDocument as h, type InvisibleBlocksMessage as i, type ParentReadyMessage as j, type PatchMessage as k, type PostTarget as l, type SelectMessage as m, type ShortcutAction as n, type ShortcutMessage as o, applyCmssyCsp as p, createCmssyClient as q, defineCmssyConfig as r, defineCmssyLayout as s, isProtocolCompatible as t, normalizeOrigin as u, parseEditorMessage as v, postToEditor as w, resolveEditorOrigin as x, cmssyCspHeaders as y, isDevelopment as z };
package/dist/index.cjs CHANGED
@@ -580,6 +580,37 @@ function mediaUrls(value) {
580
580
  function mediaAlt(value) {
581
581
  return typeof value === "string" ? void 0 : value?.alt;
582
582
  }
583
+ function defineCmssyLayout(layout) {
584
+ const regions = layout.regions;
585
+ if (!Array.isArray(regions) || regions.length === 0) {
586
+ throw new Error("cmssy: defineCmssyLayout needs at least one region");
587
+ }
588
+ if (regions.length > types.LAYOUT_REGIONS_MAX) {
589
+ throw new Error(
590
+ `cmssy: a layout declares at most ${types.LAYOUT_REGIONS_MAX} regions, got ${regions.length}`
591
+ );
592
+ }
593
+ const seen = /* @__PURE__ */ new Set();
594
+ for (const region of regions) {
595
+ if (typeof region.id !== "string" || !types.LAYOUT_REGION_ID_PATTERN.test(region.id)) {
596
+ throw new Error(
597
+ `cmssy: layout region id ${JSON.stringify(region.id)} must match ${types.LAYOUT_REGION_ID_PATTERN}`
598
+ );
599
+ }
600
+ if (seen.has(region.id)) {
601
+ throw new Error(`cmssy: layout region "${region.id}" is declared twice`);
602
+ }
603
+ seen.add(region.id);
604
+ if (region.label !== void 0) {
605
+ if (typeof region.label !== "string" || region.label.trim().length === 0 || region.label.length > types.LAYOUT_REGION_LABEL_MAX) {
606
+ throw new Error(
607
+ `cmssy: layout region "${region.id}" label must be 1-${types.LAYOUT_REGION_LABEL_MAX} characters`
608
+ );
609
+ }
610
+ }
611
+ }
612
+ return { regions };
613
+ }
583
614
 
584
615
  // src/data/localize-href.ts
585
616
  var PROTOCOL_OR_RELATIVE = /^([a-z][a-z0-9+.-]*:|\/\/)/i;
@@ -958,10 +989,6 @@ Object.defineProperty(exports, "evaluateFieldConditionGroup", {
958
989
  enumerable: true,
959
990
  get: function () { return types.evaluateFieldConditionGroup; }
960
991
  });
961
- Object.defineProperty(exports, "layoutPositionValues", {
962
- enumerable: true,
963
- get: function () { return types.layoutPositionValues; }
964
- });
965
992
  exports.CMSSY_EDIT_HEADER = CMSSY_EDIT_HEADER;
966
993
  exports.CMSSY_EDIT_QUERY_PARAM = CMSSY_EDIT_QUERY_PARAM;
967
994
  exports.CMSSY_LOCALE_HEADER = CMSSY_LOCALE_HEADER;
@@ -977,6 +1004,7 @@ exports.SHORTCUT_ACTIONS = SHORTCUT_ACTIONS;
977
1004
  exports.applyCmssyCsp = applyCmssyCsp;
978
1005
  exports.createCmssyClient = createCmssyClient;
979
1006
  exports.defineCmssyConfig = defineCmssyConfig;
1007
+ exports.defineCmssyLayout = defineCmssyLayout;
980
1008
  exports.fields = fields;
981
1009
  exports.graphqlRequest = graphqlRequest;
982
1010
  exports.isProtocolCompatible = isProtocolCompatible;
package/dist/index.d.cts CHANGED
@@ -1,9 +1,9 @@
1
- export { A as AppToEditorMessage, B as BoundsMessage, C as ClickMessage, a as CmssyClient, b as CmssyConfig, c as CmssyCspOptions, d as CmssyEnvConfig, e as CmssyTypedDocument, D as DEFAULT_CMSSY_EDITOR_ORIGINS, E as EditorToAppMessage, I as InvisibleBlock, f as InvisibleBlocksMessage, P as PROTOCOL_VERSION, g as ParentReadyMessage, h as PatchMessage, i as PostTarget, Q as QueryScopedOptions, R as ReadyMessage, S as SHORTCUT_ACTIONS, j as SelectMessage, k as ShortcutAction, l as ShortcutMessage, V as ViewportMessage, m as applyCmssyCsp, n as createCmssyClient, o as defineCmssyConfig, p as isProtocolCompatible, q as normalizeOrigin, r as parseEditorMessage, s as postToEditor, t as resolveEditorOrigin } from './csp-RaStdD2i.cjs';
1
+ export { A as AppToEditorMessage, B as BoundsMessage, C as ClickMessage, a as CmssyClient, b as CmssyConfig, c as CmssyCspOptions, d as CmssyEnvConfig, e as CmssyLayout, f as CmssyRegion, g as CmssyRegionOf, h as CmssyTypedDocument, D as DEFAULT_CMSSY_EDITOR_ORIGINS, E as EditorToAppMessage, I as InvisibleBlock, i as InvisibleBlocksMessage, P as PROTOCOL_VERSION, j as ParentReadyMessage, k as PatchMessage, l as PostTarget, Q as QueryScopedOptions, R as ReadyMessage, S as SHORTCUT_ACTIONS, m as SelectMessage, n as ShortcutAction, o as ShortcutMessage, V as ViewportMessage, p as applyCmssyCsp, q as createCmssyClient, r as defineCmssyConfig, s as defineCmssyLayout, t as isProtocolCompatible, u as normalizeOrigin, v as parseEditorMessage, w as postToEditor, x as resolveEditorOrigin } from './csp-hHuxKdMJ.cjs';
2
2
  export { C as CMSSY_LOCALE_HEADER, G as GraphqlRequestOptions, g as graphqlRequest, l as localizeHref, r as resolveCmssyLocale } from './locale-JyBHqpAQ.cjs';
3
3
  export { C as CMSSY_RATE_LIMIT_WINDOW_MS, a as CMSSY_RETRY_MODES, b as CmssyRequestError, c as CmssyRetryMode, D as DEFAULT_CMSSY_API_URL, F as FetchLike, d as FetchLikeResponse, e as FetchPageOptions, R as RetryOption, f as RetryPolicy } from './content-client-65N8ZRq9.cjs';
4
4
  import * as _cmssy_types from '@cmssy/types';
5
5
  import { FieldOptions, TypedField, ResolvedMediaValue, PageRef, BlockPropsSchema, InferBlockContent, RelationMode, CmssyModelRecord, ResolvedMedia, VerifyCmssyWebhookOptions, CmssyWebhookEvent } from '@cmssy/types';
6
- export { BlockMeta, BlockPropsSchema, BlockRect, BlockSchema, BuildBlockContextExtra, CmssyBlockAuthContext, CmssyBlockContext, CmssyBlockMember, CmssyBlockPage, CmssyBlockWorkspace, CmssyBranding, CmssyClientConfig, CmssyFormDefinition, CmssyFormField, CmssyFormSettings, CmssyFormSubmitResponse, CmssyLayoutGroup, CmssyLayoutSettings, CmssyLocaleContext, CmssyLocalizedValue, CmssyModelDefinition, CmssyModelRecord, CmssyPageData, CmssyPageMeta, CmssyPageSummary, CmssyRecordList, CmssySiteConfig, CmssyWebhookEvent, CmssyWebhookOrder, FieldCondition, FieldConditionGroup, FieldConditionLogic, FieldControl, FieldDefinition, FieldOptions, FieldType, InferBlockContent, LayoutPosition, RawBlock, RawLayoutBlock, SubmitFormInput, TypedField, VerifyCmssyWebhookOptions, evaluateFieldConditionGroup, layoutPositionValues } from '@cmssy/types';
6
+ export { BlockMeta, BlockPropsSchema, BlockRect, BlockSchema, BuildBlockContextExtra, CmssyBlockAuthContext, CmssyBlockContext, CmssyBlockMember, CmssyBlockPage, CmssyBlockWorkspace, CmssyBranding, CmssyClientConfig, CmssyFormDefinition, CmssyFormField, CmssyFormSettings, CmssyFormSubmitResponse, CmssyLayoutGroup, CmssyLayoutSettings, CmssyLocaleContext, CmssyLocalizedValue, CmssyModelDefinition, CmssyModelRecord, CmssyPageData, CmssyPageMeta, CmssyPageSummary, CmssyRecordList, CmssySiteConfig, CmssyWebhookEvent, CmssyWebhookOrder, FieldCondition, FieldConditionGroup, FieldConditionLogic, FieldControl, FieldDefinition, FieldOptions, FieldType, InferBlockContent, LayoutPosition, LayoutRegion, RawBlock, RawLayoutBlock, SubmitFormInput, TypedField, VerifyCmssyWebhookOptions, evaluateFieldConditionGroup } from '@cmssy/types';
7
7
 
8
8
  /**
9
9
  * Whether the content is guaranteed to carry the field. Only `required` says
package/dist/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- export { A as AppToEditorMessage, B as BoundsMessage, C as ClickMessage, a as CmssyClient, b as CmssyConfig, c as CmssyCspOptions, d as CmssyEnvConfig, e as CmssyTypedDocument, D as DEFAULT_CMSSY_EDITOR_ORIGINS, E as EditorToAppMessage, I as InvisibleBlock, f as InvisibleBlocksMessage, P as PROTOCOL_VERSION, g as ParentReadyMessage, h as PatchMessage, i as PostTarget, Q as QueryScopedOptions, R as ReadyMessage, S as SHORTCUT_ACTIONS, j as SelectMessage, k as ShortcutAction, l as ShortcutMessage, V as ViewportMessage, m as applyCmssyCsp, n as createCmssyClient, o as defineCmssyConfig, p as isProtocolCompatible, q as normalizeOrigin, r as parseEditorMessage, s as postToEditor, t as resolveEditorOrigin } from './csp-BnOiGUhR.js';
1
+ export { A as AppToEditorMessage, B as BoundsMessage, C as ClickMessage, a as CmssyClient, b as CmssyConfig, c as CmssyCspOptions, d as CmssyEnvConfig, e as CmssyLayout, f as CmssyRegion, g as CmssyRegionOf, h as CmssyTypedDocument, D as DEFAULT_CMSSY_EDITOR_ORIGINS, E as EditorToAppMessage, I as InvisibleBlock, i as InvisibleBlocksMessage, P as PROTOCOL_VERSION, j as ParentReadyMessage, k as PatchMessage, l as PostTarget, Q as QueryScopedOptions, R as ReadyMessage, S as SHORTCUT_ACTIONS, m as SelectMessage, n as ShortcutAction, o as ShortcutMessage, V as ViewportMessage, p as applyCmssyCsp, q as createCmssyClient, r as defineCmssyConfig, s as defineCmssyLayout, t as isProtocolCompatible, u as normalizeOrigin, v as parseEditorMessage, w as postToEditor, x as resolveEditorOrigin } from './csp-9BjyqMRU.js';
2
2
  export { C as CMSSY_LOCALE_HEADER, G as GraphqlRequestOptions, g as graphqlRequest, l as localizeHref, r as resolveCmssyLocale } from './locale-D9KI4bND.js';
3
3
  export { C as CMSSY_RATE_LIMIT_WINDOW_MS, a as CMSSY_RETRY_MODES, b as CmssyRequestError, c as CmssyRetryMode, D as DEFAULT_CMSSY_API_URL, F as FetchLike, d as FetchLikeResponse, e as FetchPageOptions, R as RetryOption, f as RetryPolicy } from './content-client-65N8ZRq9.js';
4
4
  import * as _cmssy_types from '@cmssy/types';
5
5
  import { FieldOptions, TypedField, ResolvedMediaValue, PageRef, BlockPropsSchema, InferBlockContent, RelationMode, CmssyModelRecord, ResolvedMedia, VerifyCmssyWebhookOptions, CmssyWebhookEvent } from '@cmssy/types';
6
- export { BlockMeta, BlockPropsSchema, BlockRect, BlockSchema, BuildBlockContextExtra, CmssyBlockAuthContext, CmssyBlockContext, CmssyBlockMember, CmssyBlockPage, CmssyBlockWorkspace, CmssyBranding, CmssyClientConfig, CmssyFormDefinition, CmssyFormField, CmssyFormSettings, CmssyFormSubmitResponse, CmssyLayoutGroup, CmssyLayoutSettings, CmssyLocaleContext, CmssyLocalizedValue, CmssyModelDefinition, CmssyModelRecord, CmssyPageData, CmssyPageMeta, CmssyPageSummary, CmssyRecordList, CmssySiteConfig, CmssyWebhookEvent, CmssyWebhookOrder, FieldCondition, FieldConditionGroup, FieldConditionLogic, FieldControl, FieldDefinition, FieldOptions, FieldType, InferBlockContent, LayoutPosition, RawBlock, RawLayoutBlock, SubmitFormInput, TypedField, VerifyCmssyWebhookOptions, evaluateFieldConditionGroup, layoutPositionValues } from '@cmssy/types';
6
+ export { BlockMeta, BlockPropsSchema, BlockRect, BlockSchema, BuildBlockContextExtra, CmssyBlockAuthContext, CmssyBlockContext, CmssyBlockMember, CmssyBlockPage, CmssyBlockWorkspace, CmssyBranding, CmssyClientConfig, CmssyFormDefinition, CmssyFormField, CmssyFormSettings, CmssyFormSubmitResponse, CmssyLayoutGroup, CmssyLayoutSettings, CmssyLocaleContext, CmssyLocalizedValue, CmssyModelDefinition, CmssyModelRecord, CmssyPageData, CmssyPageMeta, CmssyPageSummary, CmssyRecordList, CmssySiteConfig, CmssyWebhookEvent, CmssyWebhookOrder, FieldCondition, FieldConditionGroup, FieldConditionLogic, FieldControl, FieldDefinition, FieldOptions, FieldType, InferBlockContent, LayoutPosition, LayoutRegion, RawBlock, RawLayoutBlock, SubmitFormInput, TypedField, VerifyCmssyWebhookOptions, evaluateFieldConditionGroup } from '@cmssy/types';
7
7
 
8
8
  /**
9
9
  * Whether the content is guaranteed to carry the field. Only `required` says
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
- export { evaluateFieldConditionGroup, layoutPositionValues } from '@cmssy/types';
1
+ import { LAYOUT_REGIONS_MAX, LAYOUT_REGION_ID_PATTERN, LAYOUT_REGION_LABEL_MAX } from '@cmssy/types';
2
+ export { evaluateFieldConditionGroup } from '@cmssy/types';
2
3
 
3
4
  // src/config.ts
4
5
  var DEFAULT_CMSSY_EDITOR_ORIGINS = [
@@ -578,6 +579,37 @@ function mediaUrls(value) {
578
579
  function mediaAlt(value) {
579
580
  return typeof value === "string" ? void 0 : value?.alt;
580
581
  }
582
+ function defineCmssyLayout(layout) {
583
+ const regions = layout.regions;
584
+ if (!Array.isArray(regions) || regions.length === 0) {
585
+ throw new Error("cmssy: defineCmssyLayout needs at least one region");
586
+ }
587
+ if (regions.length > LAYOUT_REGIONS_MAX) {
588
+ throw new Error(
589
+ `cmssy: a layout declares at most ${LAYOUT_REGIONS_MAX} regions, got ${regions.length}`
590
+ );
591
+ }
592
+ const seen = /* @__PURE__ */ new Set();
593
+ for (const region of regions) {
594
+ if (typeof region.id !== "string" || !LAYOUT_REGION_ID_PATTERN.test(region.id)) {
595
+ throw new Error(
596
+ `cmssy: layout region id ${JSON.stringify(region.id)} must match ${LAYOUT_REGION_ID_PATTERN}`
597
+ );
598
+ }
599
+ if (seen.has(region.id)) {
600
+ throw new Error(`cmssy: layout region "${region.id}" is declared twice`);
601
+ }
602
+ seen.add(region.id);
603
+ if (region.label !== void 0) {
604
+ if (typeof region.label !== "string" || region.label.trim().length === 0 || region.label.length > LAYOUT_REGION_LABEL_MAX) {
605
+ throw new Error(
606
+ `cmssy: layout region "${region.id}" label must be 1-${LAYOUT_REGION_LABEL_MAX} characters`
607
+ );
608
+ }
609
+ }
610
+ }
611
+ return { regions };
612
+ }
581
613
 
582
614
  // src/data/localize-href.ts
583
615
  var PROTOCOL_OR_RELATIVE = /^([a-z][a-z0-9+.-]*:|\/\/)/i;
@@ -952,4 +984,4 @@ async function verifyCmssyWebhook(options) {
952
984
  return parsed;
953
985
  }
954
986
 
955
- export { CMSSY_EDIT_HEADER, CMSSY_EDIT_QUERY_PARAM, CMSSY_LOCALE_HEADER, CMSSY_RATE_LIMIT_WINDOW_MS, CMSSY_RETRY_MODES, CMSSY_SECRET_QUERY_PARAM, CmssyRequestError, CmssyWebhookError, DEFAULT_CMSSY_API_URL, DEFAULT_CMSSY_EDITOR_ORIGINS, PROTOCOL_VERSION, SHORTCUT_ACTIONS, applyCmssyCsp, createCmssyClient, defineCmssyConfig, fields, graphqlRequest, isProtocolCompatible, isVerifiedEditUrl, localizeHref, mediaAlt, mediaUrl, mediaUrls, normalizeOrigin, parseEditorMessage, postToEditor, resolveCmssyLocale, resolveEditorOrigin, verifyCmssyWebhook };
987
+ export { CMSSY_EDIT_HEADER, CMSSY_EDIT_QUERY_PARAM, CMSSY_LOCALE_HEADER, CMSSY_RATE_LIMIT_WINDOW_MS, CMSSY_RETRY_MODES, CMSSY_SECRET_QUERY_PARAM, CmssyRequestError, CmssyWebhookError, DEFAULT_CMSSY_API_URL, DEFAULT_CMSSY_EDITOR_ORIGINS, PROTOCOL_VERSION, SHORTCUT_ACTIONS, applyCmssyCsp, createCmssyClient, defineCmssyConfig, defineCmssyLayout, fields, graphqlRequest, isProtocolCompatible, isVerifiedEditUrl, localizeHref, mediaAlt, mediaUrl, mediaUrls, normalizeOrigin, parseEditorMessage, postToEditor, resolveCmssyLocale, resolveEditorOrigin, verifyCmssyWebhook };
package/dist/internal.cjs CHANGED
@@ -1,5 +1,7 @@
1
1
  'use strict';
2
2
 
3
+ var types = require('@cmssy/types');
4
+
3
5
  // src/data/http.ts
4
6
  var CmssyRequestError = class extends Error {
5
7
  status;
@@ -1299,6 +1301,9 @@ var CMSSY_DELIVERY_OPERATIONS = [
1299
1301
  document: SUBMIT_FORM_MUTATION
1300
1302
  }
1301
1303
  ];
1304
+ function layoutRegionIds(layout) {
1305
+ return (layout?.regions ?? types.DEFAULT_LAYOUT_REGIONS).map((region) => region.id);
1306
+ }
1302
1307
 
1303
1308
  exports.CMSSY_DELIVERY_OPERATIONS = CMSSY_DELIVERY_OPERATIONS;
1304
1309
  exports.CMSSY_LOCALE_HEADER = CMSSY_LOCALE_HEADER;
@@ -1321,6 +1326,7 @@ exports.fetchPages = fetchPages;
1321
1326
  exports.fetchSiteConfig = fetchSiteConfig;
1322
1327
  exports.getBlockContentForLanguage = getBlockContentForLanguage;
1323
1328
  exports.isDevelopment = isDevelopment;
1329
+ exports.layoutRegionIds = layoutRegionIds;
1324
1330
  exports.localeForPath = localeForPath;
1325
1331
  exports.localeForPathname = localeForPathname;
1326
1332
  exports.localizeHref = localizeHref;
@@ -3,8 +3,8 @@ import { CmssyFormDefinition, BuildBlockContextExtra, CmssyBlockContext, CmssyCl
3
3
  export { CmssySiteLocales } from '@cmssy/types';
4
4
  import { G as GraphqlRequestOptions } from './locale-JyBHqpAQ.cjs';
5
5
  export { C as CMSSY_LOCALE_HEADER, a as localeForPath, b as localeForPathname, l as localizeHref, c as resolveSiteLocales, s as splitCmssyLocale, d as splitLocaleFromPath } from './locale-JyBHqpAQ.cjs';
6
- import { Q as QueryScopedOptions } from './csp-RaStdD2i.cjs';
7
- export { u as cmssyCspHeaders, v as isDevelopment, w as resolveInitialTarget, x as toCspOrigin } from './csp-RaStdD2i.cjs';
6
+ import { Q as QueryScopedOptions } from './csp-hHuxKdMJ.cjs';
7
+ export { y as cmssyCspHeaders, z as isDevelopment, F as layoutRegionIds, G as resolveInitialTarget, H as toCspOrigin } from './csp-hHuxKdMJ.cjs';
8
8
  export { localizedPath } from './internal/locale.cjs';
9
9
 
10
10
  declare const SITE_CONFIG_QUERY = "query PublicSiteConfig($workspaceSlug: String!) {\n public {\n siteConfig(workspaceSlug: $workspaceSlug) {\n id\n workspaceId\n siteName\n defaultLanguage\n enabledLanguages\n enabledFeatures\n notFoundPageId\n previewUrl\n branding {\n brandName\n logoUrl\n logoDarkUrl\n faviconUrl\n ogImageUrl\n }\n }\n }\n}";
@@ -3,8 +3,8 @@ import { CmssyFormDefinition, BuildBlockContextExtra, CmssyBlockContext, CmssyCl
3
3
  export { CmssySiteLocales } from '@cmssy/types';
4
4
  import { G as GraphqlRequestOptions } from './locale-D9KI4bND.js';
5
5
  export { C as CMSSY_LOCALE_HEADER, a as localeForPath, b as localeForPathname, l as localizeHref, c as resolveSiteLocales, s as splitCmssyLocale, d as splitLocaleFromPath } from './locale-D9KI4bND.js';
6
- import { Q as QueryScopedOptions } from './csp-BnOiGUhR.js';
7
- export { u as cmssyCspHeaders, v as isDevelopment, w as resolveInitialTarget, x as toCspOrigin } from './csp-BnOiGUhR.js';
6
+ import { Q as QueryScopedOptions } from './csp-9BjyqMRU.js';
7
+ export { y as cmssyCspHeaders, z as isDevelopment, F as layoutRegionIds, G as resolveInitialTarget, H as toCspOrigin } from './csp-9BjyqMRU.js';
8
8
  export { localizedPath } from './internal/locale.js';
9
9
 
10
10
  declare const SITE_CONFIG_QUERY = "query PublicSiteConfig($workspaceSlug: String!) {\n public {\n siteConfig(workspaceSlug: $workspaceSlug) {\n id\n workspaceId\n siteName\n defaultLanguage\n enabledLanguages\n enabledFeatures\n notFoundPageId\n previewUrl\n branding {\n brandName\n logoUrl\n logoDarkUrl\n faviconUrl\n ogImageUrl\n }\n }\n }\n}";
package/dist/internal.js CHANGED
@@ -1,3 +1,5 @@
1
+ import { DEFAULT_LAYOUT_REGIONS } from '@cmssy/types';
2
+
1
3
  // src/data/http.ts
2
4
  var CmssyRequestError = class extends Error {
3
5
  status;
@@ -1297,5 +1299,8 @@ var CMSSY_DELIVERY_OPERATIONS = [
1297
1299
  document: SUBMIT_FORM_MUTATION
1298
1300
  }
1299
1301
  ];
1302
+ function layoutRegionIds(layout) {
1303
+ return (layout?.regions ?? DEFAULT_LAYOUT_REGIONS).map((region) => region.id);
1304
+ }
1300
1305
 
1301
- export { CMSSY_DELIVERY_OPERATIONS, CMSSY_LOCALE_HEADER, FORM_QUERY, MODEL_DEFINITIONS_QUERY, MODEL_RECORDS_QUERY, SITE_CONFIG_QUERY, SUBMIT_FORM_MUTATION, asBucket, buildBlockContext, clearWorkspaceIdCache, cmssyCspHeaders, cmssySecretsMatch, collectFormIds, fetchLayouts, fetchPage, fetchPageById, fetchPageMeta, fetchPages, fetchSiteConfig, getBlockContentForLanguage, isDevelopment, localeForPath, localeForPathname, localizeHref, localizedPath, normalizeBlockContent, resolveApiUrl, resolveForms, resolveInitialTarget, resolveRelationContent, resolveSiteLocales, resolveWorkspaceId, splitCmssyLocale, splitLocaleFromPath, toCspOrigin };
1306
+ export { CMSSY_DELIVERY_OPERATIONS, CMSSY_LOCALE_HEADER, FORM_QUERY, MODEL_DEFINITIONS_QUERY, MODEL_RECORDS_QUERY, SITE_CONFIG_QUERY, SUBMIT_FORM_MUTATION, asBucket, buildBlockContext, clearWorkspaceIdCache, cmssyCspHeaders, cmssySecretsMatch, collectFormIds, fetchLayouts, fetchPage, fetchPageById, fetchPageMeta, fetchPages, fetchSiteConfig, getBlockContentForLanguage, isDevelopment, layoutRegionIds, localeForPath, localeForPathname, localizeHref, localizedPath, normalizeBlockContent, resolveApiUrl, resolveForms, resolveInitialTarget, resolveRelationContent, resolveSiteLocales, resolveWorkspaceId, splitCmssyLocale, splitLocaleFromPath, toCspOrigin };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cmssy/core",
3
- "version": "12.14.1",
3
+ "version": "13.0.0",
4
4
  "description": "Framework-agnostic cmssy gateway: GraphQL client, block/field system, editor protocol. No React, no Next.",
5
5
  "keywords": [
6
6
  "cmssy",
@@ -87,7 +87,7 @@
87
87
  "vitest": "^2.1.0"
88
88
  },
89
89
  "dependencies": {
90
- "@cmssy/types": "0.35.0",
90
+ "@cmssy/types": "0.37.0",
91
91
  "jose": "^6.2.3"
92
92
  },
93
93
  "scripts": {