@cmssy/react 2.3.1 → 2.4.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.
package/dist/client.d.cts CHANGED
@@ -1,8 +1,8 @@
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 CmssyAddress, g as CmssyCart, h as CmssyOrder, i as CmssyProduct } from './commerce-queries-CQgJBHMK.cjs';
3
- export { j as CmssyCartDiscount, k as CmssyCartItem, l as CmssyCartItemSnapshot, m as CmssyOrderItem, n as CmssyProductVariant } from './commerce-queries-CQgJBHMK.cjs';
2
+ import { BlockSchema, BlockMeta, CmssyPageData, CmssyLayoutGroup } from '@cmssy/types';
3
+ import { B as BlockDefinition, C as CmssyFormDefinition, a as CmssyLocaleContext, b as CmssyAddress, c as CmssyCart, d as CmssyOrder, e as CmssyProduct } from './commerce-queries-BJCoqTJW.cjs';
4
+ export { f as CmssyCartDiscount, g as CmssyCartItem, h as CmssyCartItemSnapshot, i as CmssyOrderItem, j as CmssyProductVariant } from './commerce-queries-BJCoqTJW.cjs';
4
5
  import { ReactNode } from 'react';
5
- import '@cmssy/types';
6
6
 
7
7
  interface EditBridgeConfig {
8
8
  editorOrigin: string | string[];
package/dist/client.d.ts CHANGED
@@ -1,8 +1,8 @@
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 CmssyAddress, g as CmssyCart, h as CmssyOrder, i as CmssyProduct } from './commerce-queries-CQgJBHMK.js';
3
- export { j as CmssyCartDiscount, k as CmssyCartItem, l as CmssyCartItemSnapshot, m as CmssyOrderItem, n as CmssyProductVariant } from './commerce-queries-CQgJBHMK.js';
2
+ import { BlockSchema, BlockMeta, CmssyPageData, CmssyLayoutGroup } from '@cmssy/types';
3
+ import { B as BlockDefinition, C as CmssyFormDefinition, a as CmssyLocaleContext, b as CmssyAddress, c as CmssyCart, d as CmssyOrder, e as CmssyProduct } from './commerce-queries-BJCoqTJW.js';
4
+ export { f as CmssyCartDiscount, g as CmssyCartItem, h as CmssyCartItemSnapshot, i as CmssyOrderItem, j as CmssyProductVariant } from './commerce-queries-BJCoqTJW.js';
4
5
  import { ReactNode } from 'react';
5
- import '@cmssy/types';
6
6
 
7
7
  interface EditBridgeConfig {
8
8
  editorOrigin: string | string[];
@@ -1,117 +1,6 @@
1
1
  import { ComponentType } from 'react';
2
- import { FieldConditionGroup, FieldType } from '@cmssy/types';
2
+ import { FieldConditionGroup, FieldDefinition, BlockMeta, BlockSchema } from '@cmssy/types';
3
3
 
4
- /**
5
- * The cmssy cloud GraphQL delivery endpoint. It is the same for every workspace,
6
- * so consumers never need to set it - `apiUrl` defaults to this. Self-hosted /
7
- * staging deployments override it via config.
8
- */
9
- declare const DEFAULT_CMSSY_API_URL = "https://api.cmssy.io/graphql";
10
- declare function resolveApiUrl(apiUrl: string | undefined): string;
11
- /**
12
- * Public delivery endpoint for a workspace: the org-scoped path
13
- * `{base}/public/{orgSlug}/{workspaceSlug}/graphql`. `apiUrl` is the GraphQL
14
- * base (its trailing `/graphql` is stripped); the org path is what tells the
15
- * backend which workspace to serve, so slugs only need to be unique per org.
16
- */
17
- declare function resolvePublicUrl(config: CmssyClientConfig): string;
18
- interface CmssyClientConfig {
19
- /**
20
- * Full GraphQL endpoint (used as-is for authenticated requests). Defaults to
21
- * {@link DEFAULT_CMSSY_API_URL}. Public reads strip its trailing `/graphql`
22
- * and append the org-scoped path (see {@link resolvePublicUrl}).
23
- */
24
- apiUrl?: string;
25
- /** Organization slug - part of the org-scoped delivery path. */
26
- org: string;
27
- workspaceSlug: string;
28
- }
29
- interface FetchLikeResponse {
30
- ok: boolean;
31
- status: number;
32
- json: () => Promise<unknown>;
33
- }
34
- type FetchLike = (url: string, init: {
35
- method: string;
36
- headers: Record<string, string>;
37
- body: string;
38
- signal?: AbortSignal;
39
- }) => Promise<FetchLikeResponse>;
40
- interface FetchPageOptions {
41
- previewSecret?: string;
42
- devPreview?: boolean;
43
- devToken?: string;
44
- workspaceId?: string;
45
- fetch?: FetchLike;
46
- signal?: AbortSignal;
47
- }
48
- interface RawBlock {
49
- id: string;
50
- type: string;
51
- content: unknown;
52
- style?: unknown;
53
- advanced?: unknown;
54
- }
55
- interface CmssyPageData {
56
- id: string;
57
- blocks: RawBlock[];
58
- }
59
- interface RawLayoutBlock {
60
- id: string;
61
- type: string;
62
- content: unknown;
63
- style?: unknown;
64
- advanced?: unknown;
65
- order: number;
66
- isActive: boolean;
67
- }
68
- interface CmssyLayoutSettings {
69
- desktopWidth: number | null;
70
- mobileBehavior: string;
71
- }
72
- interface CmssyLayoutGroup {
73
- position: string;
74
- blocks: RawLayoutBlock[];
75
- settings?: CmssyLayoutSettings | null;
76
- }
77
- declare function normalizeSlug(path: string | string[] | undefined): string;
78
- declare function fetchPage(config: CmssyClientConfig, path: string | string[] | undefined, options?: FetchPageOptions): Promise<CmssyPageData | null>;
79
- declare function fetchPageById(config: CmssyClientConfig, pageId: string, options?: Pick<FetchPageOptions, "fetch" | "signal">): Promise<CmssyPageData | null>;
80
- interface CmssyPageSummary {
81
- id: string;
82
- slug: string;
83
- updatedAt: string | null;
84
- publishedAt: string | null;
85
- }
86
- declare function fetchPages(config: CmssyClientConfig, options?: Pick<FetchPageOptions, "fetch" | "signal">): Promise<CmssyPageSummary[]>;
87
- type CmssyLocalizedValue = Record<string, string> | string | null;
88
- interface CmssyPageMeta {
89
- id: string;
90
- seoTitle: CmssyLocalizedValue;
91
- seoDescription: CmssyLocalizedValue;
92
- seoKeywords: string[] | null;
93
- displayName: CmssyLocalizedValue;
94
- }
95
- declare function fetchPageMeta(config: CmssyClientConfig, path: string | string[] | undefined, options?: Pick<FetchPageOptions, "fetch" | "signal">): Promise<CmssyPageMeta | null>;
96
- declare function fetchLayouts(config: CmssyClientConfig, path: string | string[] | undefined, options?: FetchPageOptions): Promise<CmssyLayoutGroup[]>;
97
-
98
- interface CmssyBranding {
99
- brandName: string | null;
100
- logoUrl: string | null;
101
- faviconUrl: string | null;
102
- ogImageUrl: string | null;
103
- }
104
- interface CmssySiteConfig {
105
- id: string;
106
- workspaceId: string;
107
- siteName: unknown;
108
- defaultLanguage: string | null;
109
- enabledLanguages: string[];
110
- enabledFeatures: string[];
111
- notFoundPageId: string | null;
112
- previewUrl: string | null;
113
- branding: CmssyBranding | null;
114
- }
115
4
  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 faviconUrl\n ogImageUrl\n }\n }\n }\n}";
116
5
  interface CmssyModelDefinition {
117
6
  id: string;
@@ -215,126 +104,6 @@ interface BuildBlockContextExtra {
215
104
  }
216
105
  declare function buildBlockContext(locale: string, defaultLocale: string, enabledLocales?: string[], isPreview?: boolean, forms?: Record<string, CmssyFormDefinition>, extra?: BuildBlockContextExtra): CmssyBlockContext;
217
106
 
218
- declare const PROTOCOL_VERSION = 2;
219
-
220
- interface FieldDefinition {
221
- type: FieldType;
222
- label: string;
223
- defaultValue?: unknown;
224
- helperText?: string;
225
- required?: boolean;
226
- placeholder?: string;
227
- tab?: string;
228
- options?: string[];
229
- itemSchema?: Record<string, FieldDefinition>;
230
- itemLabel?: string;
231
- addButtonLabel?: string;
232
- minItems?: number;
233
- maxItems?: number;
234
- collapsible?: boolean;
235
- multiple?: boolean;
236
- pageType?: string;
237
- }
238
- type BlockSchema = Record<string, FieldDefinition>;
239
- interface BlockMeta {
240
- label: string;
241
- category?: string;
242
- icon?: string;
243
- layoutPositions?: string[];
244
- /** One-line block description; surfaced to the AI page composer. */
245
- description?: string;
246
- }
247
- interface BlockRect {
248
- x: number;
249
- y: number;
250
- width: number;
251
- height: number;
252
- }
253
- interface ReadyMessage {
254
- type: "cmssy:ready";
255
- protocolVersion: number;
256
- blocks: Array<{
257
- id: string;
258
- type: string;
259
- bounds: BlockRect;
260
- layoutPosition?: string;
261
- }>;
262
- schemas: Record<string, BlockSchema>;
263
- blockMeta?: Record<string, BlockMeta>;
264
- }
265
- interface BoundsMessage {
266
- type: "cmssy:bounds";
267
- blockId: string;
268
- rect: BlockRect;
269
- }
270
- interface ClickMessage {
271
- type: "cmssy:click";
272
- blockId: string;
273
- rect: BlockRect;
274
- layoutPosition?: string;
275
- }
276
- interface MoveMessage {
277
- type: "cmssy:move";
278
- protocolVersion: number;
279
- blockId: string;
280
- index: number;
281
- }
282
- interface DragIndexMessage {
283
- type: "cmssy:drag-index";
284
- protocolVersion: number;
285
- index: number;
286
- }
287
- type AppToEditorMessage = ReadyMessage | BoundsMessage | ClickMessage | MoveMessage | DragIndexMessage;
288
- interface SelectMessage {
289
- type: "cmssy:select";
290
- protocolVersion: number;
291
- blockId: string;
292
- }
293
- interface PatchMessage {
294
- type: "cmssy:patch";
295
- protocolVersion: number;
296
- blockId: string;
297
- content: Record<string, unknown>;
298
- style?: Record<string, unknown>;
299
- advanced?: Record<string, unknown>;
300
- layoutPosition?: string;
301
- }
302
- interface ParentReadyMessage {
303
- type: "cmssy:parent-ready";
304
- protocolVersion: number;
305
- }
306
- interface InsertMessage {
307
- type: "cmssy:insert";
308
- protocolVersion: number;
309
- blockId: string;
310
- blockType: string;
311
- content: Record<string, unknown>;
312
- style?: Record<string, unknown>;
313
- advanced?: Record<string, unknown>;
314
- index: number;
315
- }
316
- interface ReorderMessage {
317
- type: "cmssy:reorder";
318
- protocolVersion: number;
319
- blockIds: string[];
320
- }
321
- interface RemoveMessage {
322
- type: "cmssy:remove";
323
- protocolVersion: number;
324
- blockId: string;
325
- }
326
- interface DragOverMessage {
327
- type: "cmssy:drag-over";
328
- protocolVersion: number;
329
- y: number;
330
- }
331
- interface DragEndMessage {
332
- type: "cmssy:drag-end";
333
- protocolVersion: number;
334
- }
335
- type EditorToAppMessage = SelectMessage | PatchMessage | ParentReadyMessage | InsertMessage | ReorderMessage | RemoveMessage | DragOverMessage | DragEndMessage;
336
- declare function isProtocolCompatible(version: number): boolean;
337
-
338
107
  interface BlockLoaderArgs {
339
108
  content: Record<string, unknown>;
340
109
  context?: CmssyBlockContext;
@@ -554,4 +323,4 @@ interface CmssyOrder {
554
323
  accessToken?: string | null;
555
324
  }
556
325
 
557
- export { MODEL_RECORDS_QUERY as $, type AppToEditorMessage as A, type BlockSchema as B, type CmssyPageData as C, type CmssyBranding as D, type EditorToAppMessage as E, type FieldDefinition as F, type CmssyFormField as G, type CmssyFormSettings as H, type CmssyFormSubmitResponse as I, type CmssyLayoutSettings as J, type CmssyLocalizedValue as K, type CmssyModelDefinition as L, type CmssyModelRecord as M, type CmssyOrderDiscount as N, type CmssyOrderTaxSummaryLine as O, type CmssyPageMeta as P, type CmssyPageSummary as Q, type RawBlock as R, type CmssyPriceTier as S, type CmssyRecordList as T, type CmssyShippingMethod as U, type CmssyTaxSummaryLine as V, DEFAULT_CMSSY_API_URL as W, FORM_QUERY as X, type FetchLikeResponse as Y, type FetchPageOptions as Z, MODEL_DEFINITIONS_QUERY as _, type BlockMeta as a, PROTOCOL_VERSION as a0, type ParentReadyMessage as a1, type PatchMessage as a2, type RawLayoutBlock as a3, type ReadyMessage as a4, SITE_CONFIG_QUERY as a5, SUBMIT_FORM_MUTATION as a6, type SelectMessage as a7, type SubmitFormInput as a8, blocksToMeta as a9, blocksToSchemas as aa, buildBlockContext as ab, buildBlockMap as ac, defineBlock as ad, fetchLayouts as ae, fetchPage as af, fetchPageById as ag, fetchPageMeta as ah, fetchPages as ai, isProtocolCompatible as aj, normalizeSlug as ak, resolveApiUrl as al, resolvePublicUrl as am, type BlockDefinition as b, type CmssyFormDefinition as c, type CmssyLayoutGroup as d, type CmssyLocaleContext as e, type CmssyAddress as f, type CmssyCart as g, type CmssyOrder as h, type CmssyProduct as i, type CmssyCartDiscount as j, type CmssyCartItem as k, type CmssyCartItemSnapshot as l, type CmssyOrderItem as m, type CmssyProductVariant as n, type CmssyBlockAuthContext as o, type CmssyBlockWorkspace as p, type FetchLike as q, type CmssyClientConfig as r, type CmssySiteConfig as s, type BlockMap as t, type CmssyBlockContext as u, type BlockRect as v, type BoundsMessage as w, type BuildBlockContextExtra as x, type ClickMessage as y, type CmssyBlockMember as z };
326
+ export { type CmssyTaxSummaryLine as A, type BlockDefinition as B, type CmssyFormDefinition as C, MODEL_RECORDS_QUERY as D, SUBMIT_FORM_MUTATION as E, FORM_QUERY as F, type SubmitFormInput as G, blocksToMeta as H, blocksToSchemas as I, buildBlockContext as J, buildBlockMap as K, defineBlock as L, MODEL_DEFINITIONS_QUERY as M, SITE_CONFIG_QUERY as S, type CmssyLocaleContext as a, type CmssyAddress as b, type CmssyCart as c, type CmssyOrder as d, type CmssyProduct as e, type CmssyCartDiscount as f, type CmssyCartItem as g, type CmssyCartItemSnapshot as h, type CmssyOrderItem as i, type CmssyProductVariant as j, type CmssyBlockAuthContext as k, type CmssyBlockWorkspace as l, type BlockMap as m, type CmssyBlockContext as n, type BuildBlockContextExtra as o, type CmssyBlockMember as p, type CmssyFormField as q, type CmssyFormSettings as r, type CmssyFormSubmitResponse as s, type CmssyModelDefinition as t, type CmssyModelRecord as u, type CmssyOrderDiscount as v, type CmssyOrderTaxSummaryLine as w, type CmssyPriceTier as x, type CmssyRecordList as y, type CmssyShippingMethod as z };
@@ -1,117 +1,6 @@
1
1
  import { ComponentType } from 'react';
2
- import { FieldConditionGroup, FieldType } from '@cmssy/types';
2
+ import { FieldConditionGroup, FieldDefinition, BlockMeta, BlockSchema } from '@cmssy/types';
3
3
 
4
- /**
5
- * The cmssy cloud GraphQL delivery endpoint. It is the same for every workspace,
6
- * so consumers never need to set it - `apiUrl` defaults to this. Self-hosted /
7
- * staging deployments override it via config.
8
- */
9
- declare const DEFAULT_CMSSY_API_URL = "https://api.cmssy.io/graphql";
10
- declare function resolveApiUrl(apiUrl: string | undefined): string;
11
- /**
12
- * Public delivery endpoint for a workspace: the org-scoped path
13
- * `{base}/public/{orgSlug}/{workspaceSlug}/graphql`. `apiUrl` is the GraphQL
14
- * base (its trailing `/graphql` is stripped); the org path is what tells the
15
- * backend which workspace to serve, so slugs only need to be unique per org.
16
- */
17
- declare function resolvePublicUrl(config: CmssyClientConfig): string;
18
- interface CmssyClientConfig {
19
- /**
20
- * Full GraphQL endpoint (used as-is for authenticated requests). Defaults to
21
- * {@link DEFAULT_CMSSY_API_URL}. Public reads strip its trailing `/graphql`
22
- * and append the org-scoped path (see {@link resolvePublicUrl}).
23
- */
24
- apiUrl?: string;
25
- /** Organization slug - part of the org-scoped delivery path. */
26
- org: string;
27
- workspaceSlug: string;
28
- }
29
- interface FetchLikeResponse {
30
- ok: boolean;
31
- status: number;
32
- json: () => Promise<unknown>;
33
- }
34
- type FetchLike = (url: string, init: {
35
- method: string;
36
- headers: Record<string, string>;
37
- body: string;
38
- signal?: AbortSignal;
39
- }) => Promise<FetchLikeResponse>;
40
- interface FetchPageOptions {
41
- previewSecret?: string;
42
- devPreview?: boolean;
43
- devToken?: string;
44
- workspaceId?: string;
45
- fetch?: FetchLike;
46
- signal?: AbortSignal;
47
- }
48
- interface RawBlock {
49
- id: string;
50
- type: string;
51
- content: unknown;
52
- style?: unknown;
53
- advanced?: unknown;
54
- }
55
- interface CmssyPageData {
56
- id: string;
57
- blocks: RawBlock[];
58
- }
59
- interface RawLayoutBlock {
60
- id: string;
61
- type: string;
62
- content: unknown;
63
- style?: unknown;
64
- advanced?: unknown;
65
- order: number;
66
- isActive: boolean;
67
- }
68
- interface CmssyLayoutSettings {
69
- desktopWidth: number | null;
70
- mobileBehavior: string;
71
- }
72
- interface CmssyLayoutGroup {
73
- position: string;
74
- blocks: RawLayoutBlock[];
75
- settings?: CmssyLayoutSettings | null;
76
- }
77
- declare function normalizeSlug(path: string | string[] | undefined): string;
78
- declare function fetchPage(config: CmssyClientConfig, path: string | string[] | undefined, options?: FetchPageOptions): Promise<CmssyPageData | null>;
79
- declare function fetchPageById(config: CmssyClientConfig, pageId: string, options?: Pick<FetchPageOptions, "fetch" | "signal">): Promise<CmssyPageData | null>;
80
- interface CmssyPageSummary {
81
- id: string;
82
- slug: string;
83
- updatedAt: string | null;
84
- publishedAt: string | null;
85
- }
86
- declare function fetchPages(config: CmssyClientConfig, options?: Pick<FetchPageOptions, "fetch" | "signal">): Promise<CmssyPageSummary[]>;
87
- type CmssyLocalizedValue = Record<string, string> | string | null;
88
- interface CmssyPageMeta {
89
- id: string;
90
- seoTitle: CmssyLocalizedValue;
91
- seoDescription: CmssyLocalizedValue;
92
- seoKeywords: string[] | null;
93
- displayName: CmssyLocalizedValue;
94
- }
95
- declare function fetchPageMeta(config: CmssyClientConfig, path: string | string[] | undefined, options?: Pick<FetchPageOptions, "fetch" | "signal">): Promise<CmssyPageMeta | null>;
96
- declare function fetchLayouts(config: CmssyClientConfig, path: string | string[] | undefined, options?: FetchPageOptions): Promise<CmssyLayoutGroup[]>;
97
-
98
- interface CmssyBranding {
99
- brandName: string | null;
100
- logoUrl: string | null;
101
- faviconUrl: string | null;
102
- ogImageUrl: string | null;
103
- }
104
- interface CmssySiteConfig {
105
- id: string;
106
- workspaceId: string;
107
- siteName: unknown;
108
- defaultLanguage: string | null;
109
- enabledLanguages: string[];
110
- enabledFeatures: string[];
111
- notFoundPageId: string | null;
112
- previewUrl: string | null;
113
- branding: CmssyBranding | null;
114
- }
115
4
  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 faviconUrl\n ogImageUrl\n }\n }\n }\n}";
116
5
  interface CmssyModelDefinition {
117
6
  id: string;
@@ -215,126 +104,6 @@ interface BuildBlockContextExtra {
215
104
  }
216
105
  declare function buildBlockContext(locale: string, defaultLocale: string, enabledLocales?: string[], isPreview?: boolean, forms?: Record<string, CmssyFormDefinition>, extra?: BuildBlockContextExtra): CmssyBlockContext;
217
106
 
218
- declare const PROTOCOL_VERSION = 2;
219
-
220
- interface FieldDefinition {
221
- type: FieldType;
222
- label: string;
223
- defaultValue?: unknown;
224
- helperText?: string;
225
- required?: boolean;
226
- placeholder?: string;
227
- tab?: string;
228
- options?: string[];
229
- itemSchema?: Record<string, FieldDefinition>;
230
- itemLabel?: string;
231
- addButtonLabel?: string;
232
- minItems?: number;
233
- maxItems?: number;
234
- collapsible?: boolean;
235
- multiple?: boolean;
236
- pageType?: string;
237
- }
238
- type BlockSchema = Record<string, FieldDefinition>;
239
- interface BlockMeta {
240
- label: string;
241
- category?: string;
242
- icon?: string;
243
- layoutPositions?: string[];
244
- /** One-line block description; surfaced to the AI page composer. */
245
- description?: string;
246
- }
247
- interface BlockRect {
248
- x: number;
249
- y: number;
250
- width: number;
251
- height: number;
252
- }
253
- interface ReadyMessage {
254
- type: "cmssy:ready";
255
- protocolVersion: number;
256
- blocks: Array<{
257
- id: string;
258
- type: string;
259
- bounds: BlockRect;
260
- layoutPosition?: string;
261
- }>;
262
- schemas: Record<string, BlockSchema>;
263
- blockMeta?: Record<string, BlockMeta>;
264
- }
265
- interface BoundsMessage {
266
- type: "cmssy:bounds";
267
- blockId: string;
268
- rect: BlockRect;
269
- }
270
- interface ClickMessage {
271
- type: "cmssy:click";
272
- blockId: string;
273
- rect: BlockRect;
274
- layoutPosition?: string;
275
- }
276
- interface MoveMessage {
277
- type: "cmssy:move";
278
- protocolVersion: number;
279
- blockId: string;
280
- index: number;
281
- }
282
- interface DragIndexMessage {
283
- type: "cmssy:drag-index";
284
- protocolVersion: number;
285
- index: number;
286
- }
287
- type AppToEditorMessage = ReadyMessage | BoundsMessage | ClickMessage | MoveMessage | DragIndexMessage;
288
- interface SelectMessage {
289
- type: "cmssy:select";
290
- protocolVersion: number;
291
- blockId: string;
292
- }
293
- interface PatchMessage {
294
- type: "cmssy:patch";
295
- protocolVersion: number;
296
- blockId: string;
297
- content: Record<string, unknown>;
298
- style?: Record<string, unknown>;
299
- advanced?: Record<string, unknown>;
300
- layoutPosition?: string;
301
- }
302
- interface ParentReadyMessage {
303
- type: "cmssy:parent-ready";
304
- protocolVersion: number;
305
- }
306
- interface InsertMessage {
307
- type: "cmssy:insert";
308
- protocolVersion: number;
309
- blockId: string;
310
- blockType: string;
311
- content: Record<string, unknown>;
312
- style?: Record<string, unknown>;
313
- advanced?: Record<string, unknown>;
314
- index: number;
315
- }
316
- interface ReorderMessage {
317
- type: "cmssy:reorder";
318
- protocolVersion: number;
319
- blockIds: string[];
320
- }
321
- interface RemoveMessage {
322
- type: "cmssy:remove";
323
- protocolVersion: number;
324
- blockId: string;
325
- }
326
- interface DragOverMessage {
327
- type: "cmssy:drag-over";
328
- protocolVersion: number;
329
- y: number;
330
- }
331
- interface DragEndMessage {
332
- type: "cmssy:drag-end";
333
- protocolVersion: number;
334
- }
335
- type EditorToAppMessage = SelectMessage | PatchMessage | ParentReadyMessage | InsertMessage | ReorderMessage | RemoveMessage | DragOverMessage | DragEndMessage;
336
- declare function isProtocolCompatible(version: number): boolean;
337
-
338
107
  interface BlockLoaderArgs {
339
108
  content: Record<string, unknown>;
340
109
  context?: CmssyBlockContext;
@@ -554,4 +323,4 @@ interface CmssyOrder {
554
323
  accessToken?: string | null;
555
324
  }
556
325
 
557
- export { MODEL_RECORDS_QUERY as $, type AppToEditorMessage as A, type BlockSchema as B, type CmssyPageData as C, type CmssyBranding as D, type EditorToAppMessage as E, type FieldDefinition as F, type CmssyFormField as G, type CmssyFormSettings as H, type CmssyFormSubmitResponse as I, type CmssyLayoutSettings as J, type CmssyLocalizedValue as K, type CmssyModelDefinition as L, type CmssyModelRecord as M, type CmssyOrderDiscount as N, type CmssyOrderTaxSummaryLine as O, type CmssyPageMeta as P, type CmssyPageSummary as Q, type RawBlock as R, type CmssyPriceTier as S, type CmssyRecordList as T, type CmssyShippingMethod as U, type CmssyTaxSummaryLine as V, DEFAULT_CMSSY_API_URL as W, FORM_QUERY as X, type FetchLikeResponse as Y, type FetchPageOptions as Z, MODEL_DEFINITIONS_QUERY as _, type BlockMeta as a, PROTOCOL_VERSION as a0, type ParentReadyMessage as a1, type PatchMessage as a2, type RawLayoutBlock as a3, type ReadyMessage as a4, SITE_CONFIG_QUERY as a5, SUBMIT_FORM_MUTATION as a6, type SelectMessage as a7, type SubmitFormInput as a8, blocksToMeta as a9, blocksToSchemas as aa, buildBlockContext as ab, buildBlockMap as ac, defineBlock as ad, fetchLayouts as ae, fetchPage as af, fetchPageById as ag, fetchPageMeta as ah, fetchPages as ai, isProtocolCompatible as aj, normalizeSlug as ak, resolveApiUrl as al, resolvePublicUrl as am, type BlockDefinition as b, type CmssyFormDefinition as c, type CmssyLayoutGroup as d, type CmssyLocaleContext as e, type CmssyAddress as f, type CmssyCart as g, type CmssyOrder as h, type CmssyProduct as i, type CmssyCartDiscount as j, type CmssyCartItem as k, type CmssyCartItemSnapshot as l, type CmssyOrderItem as m, type CmssyProductVariant as n, type CmssyBlockAuthContext as o, type CmssyBlockWorkspace as p, type FetchLike as q, type CmssyClientConfig as r, type CmssySiteConfig as s, type BlockMap as t, type CmssyBlockContext as u, type BlockRect as v, type BoundsMessage as w, type BuildBlockContextExtra as x, type ClickMessage as y, type CmssyBlockMember as z };
326
+ export { type CmssyTaxSummaryLine as A, type BlockDefinition as B, type CmssyFormDefinition as C, MODEL_RECORDS_QUERY as D, SUBMIT_FORM_MUTATION as E, FORM_QUERY as F, type SubmitFormInput as G, blocksToMeta as H, blocksToSchemas as I, buildBlockContext as J, buildBlockMap as K, defineBlock as L, MODEL_DEFINITIONS_QUERY as M, SITE_CONFIG_QUERY as S, type CmssyLocaleContext as a, type CmssyAddress as b, type CmssyCart as c, type CmssyOrder as d, type CmssyProduct as e, type CmssyCartDiscount as f, type CmssyCartItem as g, type CmssyCartItemSnapshot as h, type CmssyOrderItem as i, type CmssyProductVariant as j, type CmssyBlockAuthContext as k, type CmssyBlockWorkspace as l, type BlockMap as m, type CmssyBlockContext as n, type BuildBlockContextExtra as o, type CmssyBlockMember as p, type CmssyFormField as q, type CmssyFormSettings as r, type CmssyFormSubmitResponse as s, type CmssyModelDefinition as t, type CmssyModelRecord as u, type CmssyOrderDiscount as v, type CmssyOrderTaxSummaryLine as w, type CmssyPriceTier as x, type CmssyRecordList as y, type CmssyShippingMethod as z };
package/dist/index.d.cts CHANGED
@@ -1,12 +1,137 @@
1
- import { F as FieldDefinition, C as CmssyPageData, b as BlockDefinition, c as CmssyFormDefinition, o as CmssyBlockAuthContext, p as CmssyBlockWorkspace, d as CmssyLayoutGroup, E as EditorToAppMessage, A as AppToEditorMessage, q as FetchLike, r as CmssyClientConfig, s as CmssySiteConfig, R as RawBlock, e as CmssyLocaleContext, t as BlockMap, u as CmssyBlockContext } from './commerce-queries-CQgJBHMK.cjs';
2
- export { a as BlockMeta, v as BlockRect, B as BlockSchema, w as BoundsMessage, x as BuildBlockContextExtra, y as ClickMessage, f as CmssyAddress, z as CmssyBlockMember, D as CmssyBranding, g as CmssyCart, j as CmssyCartDiscount, k as CmssyCartItem, l as CmssyCartItemSnapshot, G as CmssyFormField, H as CmssyFormSettings, I as CmssyFormSubmitResponse, J as CmssyLayoutSettings, K as CmssyLocalizedValue, L as CmssyModelDefinition, M as CmssyModelRecord, h as CmssyOrder, N as CmssyOrderDiscount, m as CmssyOrderItem, O as CmssyOrderTaxSummaryLine, P as CmssyPageMeta, Q as CmssyPageSummary, S as CmssyPriceTier, i as CmssyProduct, n as CmssyProductVariant, T as CmssyRecordList, U as CmssyShippingMethod, V as CmssyTaxSummaryLine, W as DEFAULT_CMSSY_API_URL, X as FORM_QUERY, Y as FetchLikeResponse, Z as FetchPageOptions, _ as MODEL_DEFINITIONS_QUERY, $ as MODEL_RECORDS_QUERY, a0 as PROTOCOL_VERSION, a1 as ParentReadyMessage, a2 as PatchMessage, a3 as RawLayoutBlock, a4 as ReadyMessage, a5 as SITE_CONFIG_QUERY, a6 as SUBMIT_FORM_MUTATION, a7 as SelectMessage, a8 as SubmitFormInput, a9 as blocksToMeta, aa as blocksToSchemas, ab as buildBlockContext, ac as buildBlockMap, ad as defineBlock, ae as fetchLayouts, af as fetchPage, ag as fetchPageById, ah as fetchPageMeta, ai as fetchPages, aj as isProtocolCompatible, ak as normalizeSlug, al as resolveApiUrl, am as resolvePublicUrl } from './commerce-queries-CQgJBHMK.cjs';
1
+ import { CmssyClientConfig, CmssyLayoutGroup, CmssyPageData, CmssyPageMeta, CmssyPageSummary, BlockRect, BlockSchema, BlockMeta, FieldControl, FieldDefinition, CmssySiteConfig, RawBlock, CmssySiteLocales } from '@cmssy/types';
2
+ export { BlockMeta, BlockRect, BlockSchema, CmssyBranding, CmssyClientConfig, CmssyLayoutGroup, CmssyLayoutSettings, CmssyLocalizedValue, CmssyPageData, CmssyPageMeta, CmssyPageSummary, CmssySiteConfig, CmssySiteLocales, FieldCondition, FieldConditionGroup, FieldConditionLogic, FieldControl, FieldDefinition, FieldType, RawBlock, RawLayoutBlock, evaluateFieldConditionGroup } from '@cmssy/types';
3
+ import { B as BlockDefinition, C as CmssyFormDefinition, k as CmssyBlockAuthContext, l as CmssyBlockWorkspace, a as CmssyLocaleContext, m as BlockMap, n as CmssyBlockContext } from './commerce-queries-BJCoqTJW.cjs';
4
+ export { o as BuildBlockContextExtra, b as CmssyAddress, p as CmssyBlockMember, c as CmssyCart, f as CmssyCartDiscount, g as CmssyCartItem, h as CmssyCartItemSnapshot, q as CmssyFormField, r as CmssyFormSettings, s as CmssyFormSubmitResponse, t as CmssyModelDefinition, u as CmssyModelRecord, d as CmssyOrder, v as CmssyOrderDiscount, i as CmssyOrderItem, w as CmssyOrderTaxSummaryLine, x as CmssyPriceTier, e as CmssyProduct, j as CmssyProductVariant, y as CmssyRecordList, z as CmssyShippingMethod, A as CmssyTaxSummaryLine, F as FORM_QUERY, M as MODEL_DEFINITIONS_QUERY, D as MODEL_RECORDS_QUERY, S as SITE_CONFIG_QUERY, E as SUBMIT_FORM_MUTATION, G as SubmitFormInput, H as blocksToMeta, I as blocksToSchemas, J as buildBlockContext, K as buildBlockMap, L as defineBlock } from './commerce-queries-BJCoqTJW.cjs';
3
5
  import * as react_jsx_runtime from 'react/jsx-runtime';
4
- export { FieldCondition, FieldConditionGroup, FieldConditionLogic, FieldType, evaluateFieldConditionGroup } from '@cmssy/types';
5
6
  import 'react';
6
7
 
7
- type FieldControl = Omit<FieldDefinition, "type" | "label"> & {
8
- label?: string;
9
- };
8
+ /**
9
+ * The cmssy cloud GraphQL delivery endpoint. It is the same for every workspace,
10
+ * so consumers never need to set it - `apiUrl` defaults to this. Self-hosted /
11
+ * staging deployments override it via config.
12
+ */
13
+ declare const DEFAULT_CMSSY_API_URL = "https://api.cmssy.io/graphql";
14
+ declare function resolveApiUrl(apiUrl: string | undefined): string;
15
+ /**
16
+ * Public delivery endpoint for a workspace: the org-scoped path
17
+ * `{base}/public/{orgSlug}/{workspaceSlug}/graphql`. `apiUrl` is the GraphQL
18
+ * base (its trailing `/graphql` is stripped); the org path is what tells the
19
+ * backend which workspace to serve, so slugs only need to be unique per org.
20
+ */
21
+ declare function resolvePublicUrl(config: CmssyClientConfig): string;
22
+ interface FetchLikeResponse {
23
+ ok: boolean;
24
+ status: number;
25
+ json: () => Promise<unknown>;
26
+ }
27
+ type FetchLike = (url: string, init: {
28
+ method: string;
29
+ headers: Record<string, string>;
30
+ body: string;
31
+ signal?: AbortSignal;
32
+ }) => Promise<FetchLikeResponse>;
33
+ interface FetchPageOptions {
34
+ previewSecret?: string;
35
+ devPreview?: boolean;
36
+ devToken?: string;
37
+ workspaceId?: string;
38
+ fetch?: FetchLike;
39
+ signal?: AbortSignal;
40
+ }
41
+ declare function normalizeSlug(path: string | string[] | undefined): string;
42
+ declare function fetchPage(config: CmssyClientConfig, path: string | string[] | undefined, options?: FetchPageOptions): Promise<CmssyPageData | null>;
43
+ declare function fetchPageById(config: CmssyClientConfig, pageId: string, options?: Pick<FetchPageOptions, "fetch" | "signal">): Promise<CmssyPageData | null>;
44
+ declare function fetchPages(config: CmssyClientConfig, options?: Pick<FetchPageOptions, "fetch" | "signal">): Promise<CmssyPageSummary[]>;
45
+ declare function fetchPageMeta(config: CmssyClientConfig, path: string | string[] | undefined, options?: Pick<FetchPageOptions, "fetch" | "signal">): Promise<CmssyPageMeta | null>;
46
+ declare function fetchLayouts(config: CmssyClientConfig, path: string | string[] | undefined, options?: FetchPageOptions): Promise<CmssyLayoutGroup[]>;
47
+
48
+ declare const PROTOCOL_VERSION = 2;
49
+
50
+ interface ReadyMessage {
51
+ type: "cmssy:ready";
52
+ protocolVersion: number;
53
+ blocks: Array<{
54
+ id: string;
55
+ type: string;
56
+ bounds: BlockRect;
57
+ layoutPosition?: string;
58
+ }>;
59
+ schemas: Record<string, BlockSchema>;
60
+ blockMeta?: Record<string, BlockMeta>;
61
+ }
62
+ interface BoundsMessage {
63
+ type: "cmssy:bounds";
64
+ blockId: string;
65
+ rect: BlockRect;
66
+ }
67
+ interface ClickMessage {
68
+ type: "cmssy:click";
69
+ blockId: string;
70
+ rect: BlockRect;
71
+ layoutPosition?: string;
72
+ }
73
+ interface MoveMessage {
74
+ type: "cmssy:move";
75
+ protocolVersion: number;
76
+ blockId: string;
77
+ index: number;
78
+ }
79
+ interface DragIndexMessage {
80
+ type: "cmssy:drag-index";
81
+ protocolVersion: number;
82
+ index: number;
83
+ }
84
+ type AppToEditorMessage = ReadyMessage | BoundsMessage | ClickMessage | MoveMessage | DragIndexMessage;
85
+ interface SelectMessage {
86
+ type: "cmssy:select";
87
+ protocolVersion: number;
88
+ blockId: string;
89
+ }
90
+ interface PatchMessage {
91
+ type: "cmssy:patch";
92
+ protocolVersion: number;
93
+ blockId: string;
94
+ content: Record<string, unknown>;
95
+ style?: Record<string, unknown>;
96
+ advanced?: Record<string, unknown>;
97
+ layoutPosition?: string;
98
+ }
99
+ interface ParentReadyMessage {
100
+ type: "cmssy:parent-ready";
101
+ protocolVersion: number;
102
+ }
103
+ interface InsertMessage {
104
+ type: "cmssy:insert";
105
+ protocolVersion: number;
106
+ blockId: string;
107
+ blockType: string;
108
+ content: Record<string, unknown>;
109
+ style?: Record<string, unknown>;
110
+ advanced?: Record<string, unknown>;
111
+ index: number;
112
+ }
113
+ interface ReorderMessage {
114
+ type: "cmssy:reorder";
115
+ protocolVersion: number;
116
+ blockIds: string[];
117
+ }
118
+ interface RemoveMessage {
119
+ type: "cmssy:remove";
120
+ protocolVersion: number;
121
+ blockId: string;
122
+ }
123
+ interface DragOverMessage {
124
+ type: "cmssy:drag-over";
125
+ protocolVersion: number;
126
+ y: number;
127
+ }
128
+ interface DragEndMessage {
129
+ type: "cmssy:drag-end";
130
+ protocolVersion: number;
131
+ }
132
+ type EditorToAppMessage = SelectMessage | PatchMessage | ParentReadyMessage | InsertMessage | ReorderMessage | RemoveMessage | DragOverMessage | DragEndMessage;
133
+ declare function isProtocolCompatible(version: number): boolean;
134
+
10
135
  declare const fields: {
11
136
  text: (opts?: FieldControl) => FieldDefinition;
12
137
  textarea: (opts?: FieldControl) => FieldDefinition;
@@ -107,10 +232,6 @@ declare function createCmssyClient(input: CmssyClientConfig): CmssyClient;
107
232
  declare function collectFormIds(blocks: RawBlock[], locale: string, defaultLocale: string): string[];
108
233
  declare function resolveForms(config: CmssyClientConfig, blocks: RawBlock[], locale: string, defaultLocale: string, options?: QueryScopedOptions): Promise<Record<string, CmssyFormDefinition>>;
109
234
 
110
- interface CmssySiteLocales {
111
- defaultLocale: string;
112
- locales: string[];
113
- }
114
235
  declare function resolveSiteLocales(config: CmssyClientConfig, options?: GraphqlRequestOptions): Promise<CmssySiteLocales>;
115
236
  declare function splitLocaleFromPath(path: string[] | undefined, siteLocales: CmssySiteLocales): {
116
237
  locale: string;
@@ -153,4 +274,4 @@ interface UnknownBlockProps {
153
274
  }
154
275
  declare function UnknownBlock({ type }: UnknownBlockProps): react_jsx_runtime.JSX.Element;
155
276
 
156
- export { AppToEditorMessage, BlockDefinition, BlockMap, CmssyBlock, CmssyBlockAuthContext, CmssyBlockContext, type CmssyBlockProps, CmssyBlockWorkspace, type CmssyClient, CmssyClientConfig, CmssyFormDefinition, CmssyLayoutGroup, CmssyLocaleContext, CmssyPageData, CmssyServerLayout, type CmssyServerLayoutProps, CmssyServerPage, type CmssyServerPageProps, CmssySiteConfig, type CmssySiteLocales, EditorToAppMessage, FetchLike, type FieldControl, FieldDefinition, type GraphqlRequestOptions, type PostTarget, type QueryScopedOptions, RawBlock, UnknownBlock, type UnknownBlockProps, buildLocaleSwitchHref, collectFormIds, createCmssyClient, fetchSiteConfig, fields, getBlockContentForLanguage, graphqlRequest, localizeHref, localizeHtmlLinks, normalizeOrigin, parseEditorMessage, postToEditor, resolveForms, resolveSiteLocales, resolveWorkspaceId, splitLocaleFromPath };
277
+ export { type AppToEditorMessage, BlockDefinition, BlockMap, type BoundsMessage, type ClickMessage, CmssyBlock, CmssyBlockAuthContext, CmssyBlockContext, type CmssyBlockProps, CmssyBlockWorkspace, type CmssyClient, CmssyFormDefinition, CmssyLocaleContext, CmssyServerLayout, type CmssyServerLayoutProps, CmssyServerPage, type CmssyServerPageProps, DEFAULT_CMSSY_API_URL, type EditorToAppMessage, type FetchLike, type FetchLikeResponse, type FetchPageOptions, type GraphqlRequestOptions, PROTOCOL_VERSION, type ParentReadyMessage, type PatchMessage, type PostTarget, type QueryScopedOptions, type ReadyMessage, type SelectMessage, UnknownBlock, type UnknownBlockProps, buildLocaleSwitchHref, collectFormIds, createCmssyClient, fetchLayouts, fetchPage, fetchPageById, fetchPageMeta, fetchPages, fetchSiteConfig, fields, getBlockContentForLanguage, graphqlRequest, isProtocolCompatible, localizeHref, localizeHtmlLinks, normalizeOrigin, normalizeSlug, parseEditorMessage, postToEditor, resolveApiUrl, resolveForms, resolvePublicUrl, resolveSiteLocales, resolveWorkspaceId, splitLocaleFromPath };
package/dist/index.d.ts CHANGED
@@ -1,12 +1,137 @@
1
- import { F as FieldDefinition, C as CmssyPageData, b as BlockDefinition, c as CmssyFormDefinition, o as CmssyBlockAuthContext, p as CmssyBlockWorkspace, d as CmssyLayoutGroup, E as EditorToAppMessage, A as AppToEditorMessage, q as FetchLike, r as CmssyClientConfig, s as CmssySiteConfig, R as RawBlock, e as CmssyLocaleContext, t as BlockMap, u as CmssyBlockContext } from './commerce-queries-CQgJBHMK.js';
2
- export { a as BlockMeta, v as BlockRect, B as BlockSchema, w as BoundsMessage, x as BuildBlockContextExtra, y as ClickMessage, f as CmssyAddress, z as CmssyBlockMember, D as CmssyBranding, g as CmssyCart, j as CmssyCartDiscount, k as CmssyCartItem, l as CmssyCartItemSnapshot, G as CmssyFormField, H as CmssyFormSettings, I as CmssyFormSubmitResponse, J as CmssyLayoutSettings, K as CmssyLocalizedValue, L as CmssyModelDefinition, M as CmssyModelRecord, h as CmssyOrder, N as CmssyOrderDiscount, m as CmssyOrderItem, O as CmssyOrderTaxSummaryLine, P as CmssyPageMeta, Q as CmssyPageSummary, S as CmssyPriceTier, i as CmssyProduct, n as CmssyProductVariant, T as CmssyRecordList, U as CmssyShippingMethod, V as CmssyTaxSummaryLine, W as DEFAULT_CMSSY_API_URL, X as FORM_QUERY, Y as FetchLikeResponse, Z as FetchPageOptions, _ as MODEL_DEFINITIONS_QUERY, $ as MODEL_RECORDS_QUERY, a0 as PROTOCOL_VERSION, a1 as ParentReadyMessage, a2 as PatchMessage, a3 as RawLayoutBlock, a4 as ReadyMessage, a5 as SITE_CONFIG_QUERY, a6 as SUBMIT_FORM_MUTATION, a7 as SelectMessage, a8 as SubmitFormInput, a9 as blocksToMeta, aa as blocksToSchemas, ab as buildBlockContext, ac as buildBlockMap, ad as defineBlock, ae as fetchLayouts, af as fetchPage, ag as fetchPageById, ah as fetchPageMeta, ai as fetchPages, aj as isProtocolCompatible, ak as normalizeSlug, al as resolveApiUrl, am as resolvePublicUrl } from './commerce-queries-CQgJBHMK.js';
1
+ import { CmssyClientConfig, CmssyLayoutGroup, CmssyPageData, CmssyPageMeta, CmssyPageSummary, BlockRect, BlockSchema, BlockMeta, FieldControl, FieldDefinition, CmssySiteConfig, RawBlock, CmssySiteLocales } from '@cmssy/types';
2
+ export { BlockMeta, BlockRect, BlockSchema, CmssyBranding, CmssyClientConfig, CmssyLayoutGroup, CmssyLayoutSettings, CmssyLocalizedValue, CmssyPageData, CmssyPageMeta, CmssyPageSummary, CmssySiteConfig, CmssySiteLocales, FieldCondition, FieldConditionGroup, FieldConditionLogic, FieldControl, FieldDefinition, FieldType, RawBlock, RawLayoutBlock, evaluateFieldConditionGroup } from '@cmssy/types';
3
+ import { B as BlockDefinition, C as CmssyFormDefinition, k as CmssyBlockAuthContext, l as CmssyBlockWorkspace, a as CmssyLocaleContext, m as BlockMap, n as CmssyBlockContext } from './commerce-queries-BJCoqTJW.js';
4
+ export { o as BuildBlockContextExtra, b as CmssyAddress, p as CmssyBlockMember, c as CmssyCart, f as CmssyCartDiscount, g as CmssyCartItem, h as CmssyCartItemSnapshot, q as CmssyFormField, r as CmssyFormSettings, s as CmssyFormSubmitResponse, t as CmssyModelDefinition, u as CmssyModelRecord, d as CmssyOrder, v as CmssyOrderDiscount, i as CmssyOrderItem, w as CmssyOrderTaxSummaryLine, x as CmssyPriceTier, e as CmssyProduct, j as CmssyProductVariant, y as CmssyRecordList, z as CmssyShippingMethod, A as CmssyTaxSummaryLine, F as FORM_QUERY, M as MODEL_DEFINITIONS_QUERY, D as MODEL_RECORDS_QUERY, S as SITE_CONFIG_QUERY, E as SUBMIT_FORM_MUTATION, G as SubmitFormInput, H as blocksToMeta, I as blocksToSchemas, J as buildBlockContext, K as buildBlockMap, L as defineBlock } from './commerce-queries-BJCoqTJW.js';
3
5
  import * as react_jsx_runtime from 'react/jsx-runtime';
4
- export { FieldCondition, FieldConditionGroup, FieldConditionLogic, FieldType, evaluateFieldConditionGroup } from '@cmssy/types';
5
6
  import 'react';
6
7
 
7
- type FieldControl = Omit<FieldDefinition, "type" | "label"> & {
8
- label?: string;
9
- };
8
+ /**
9
+ * The cmssy cloud GraphQL delivery endpoint. It is the same for every workspace,
10
+ * so consumers never need to set it - `apiUrl` defaults to this. Self-hosted /
11
+ * staging deployments override it via config.
12
+ */
13
+ declare const DEFAULT_CMSSY_API_URL = "https://api.cmssy.io/graphql";
14
+ declare function resolveApiUrl(apiUrl: string | undefined): string;
15
+ /**
16
+ * Public delivery endpoint for a workspace: the org-scoped path
17
+ * `{base}/public/{orgSlug}/{workspaceSlug}/graphql`. `apiUrl` is the GraphQL
18
+ * base (its trailing `/graphql` is stripped); the org path is what tells the
19
+ * backend which workspace to serve, so slugs only need to be unique per org.
20
+ */
21
+ declare function resolvePublicUrl(config: CmssyClientConfig): string;
22
+ interface FetchLikeResponse {
23
+ ok: boolean;
24
+ status: number;
25
+ json: () => Promise<unknown>;
26
+ }
27
+ type FetchLike = (url: string, init: {
28
+ method: string;
29
+ headers: Record<string, string>;
30
+ body: string;
31
+ signal?: AbortSignal;
32
+ }) => Promise<FetchLikeResponse>;
33
+ interface FetchPageOptions {
34
+ previewSecret?: string;
35
+ devPreview?: boolean;
36
+ devToken?: string;
37
+ workspaceId?: string;
38
+ fetch?: FetchLike;
39
+ signal?: AbortSignal;
40
+ }
41
+ declare function normalizeSlug(path: string | string[] | undefined): string;
42
+ declare function fetchPage(config: CmssyClientConfig, path: string | string[] | undefined, options?: FetchPageOptions): Promise<CmssyPageData | null>;
43
+ declare function fetchPageById(config: CmssyClientConfig, pageId: string, options?: Pick<FetchPageOptions, "fetch" | "signal">): Promise<CmssyPageData | null>;
44
+ declare function fetchPages(config: CmssyClientConfig, options?: Pick<FetchPageOptions, "fetch" | "signal">): Promise<CmssyPageSummary[]>;
45
+ declare function fetchPageMeta(config: CmssyClientConfig, path: string | string[] | undefined, options?: Pick<FetchPageOptions, "fetch" | "signal">): Promise<CmssyPageMeta | null>;
46
+ declare function fetchLayouts(config: CmssyClientConfig, path: string | string[] | undefined, options?: FetchPageOptions): Promise<CmssyLayoutGroup[]>;
47
+
48
+ declare const PROTOCOL_VERSION = 2;
49
+
50
+ interface ReadyMessage {
51
+ type: "cmssy:ready";
52
+ protocolVersion: number;
53
+ blocks: Array<{
54
+ id: string;
55
+ type: string;
56
+ bounds: BlockRect;
57
+ layoutPosition?: string;
58
+ }>;
59
+ schemas: Record<string, BlockSchema>;
60
+ blockMeta?: Record<string, BlockMeta>;
61
+ }
62
+ interface BoundsMessage {
63
+ type: "cmssy:bounds";
64
+ blockId: string;
65
+ rect: BlockRect;
66
+ }
67
+ interface ClickMessage {
68
+ type: "cmssy:click";
69
+ blockId: string;
70
+ rect: BlockRect;
71
+ layoutPosition?: string;
72
+ }
73
+ interface MoveMessage {
74
+ type: "cmssy:move";
75
+ protocolVersion: number;
76
+ blockId: string;
77
+ index: number;
78
+ }
79
+ interface DragIndexMessage {
80
+ type: "cmssy:drag-index";
81
+ protocolVersion: number;
82
+ index: number;
83
+ }
84
+ type AppToEditorMessage = ReadyMessage | BoundsMessage | ClickMessage | MoveMessage | DragIndexMessage;
85
+ interface SelectMessage {
86
+ type: "cmssy:select";
87
+ protocolVersion: number;
88
+ blockId: string;
89
+ }
90
+ interface PatchMessage {
91
+ type: "cmssy:patch";
92
+ protocolVersion: number;
93
+ blockId: string;
94
+ content: Record<string, unknown>;
95
+ style?: Record<string, unknown>;
96
+ advanced?: Record<string, unknown>;
97
+ layoutPosition?: string;
98
+ }
99
+ interface ParentReadyMessage {
100
+ type: "cmssy:parent-ready";
101
+ protocolVersion: number;
102
+ }
103
+ interface InsertMessage {
104
+ type: "cmssy:insert";
105
+ protocolVersion: number;
106
+ blockId: string;
107
+ blockType: string;
108
+ content: Record<string, unknown>;
109
+ style?: Record<string, unknown>;
110
+ advanced?: Record<string, unknown>;
111
+ index: number;
112
+ }
113
+ interface ReorderMessage {
114
+ type: "cmssy:reorder";
115
+ protocolVersion: number;
116
+ blockIds: string[];
117
+ }
118
+ interface RemoveMessage {
119
+ type: "cmssy:remove";
120
+ protocolVersion: number;
121
+ blockId: string;
122
+ }
123
+ interface DragOverMessage {
124
+ type: "cmssy:drag-over";
125
+ protocolVersion: number;
126
+ y: number;
127
+ }
128
+ interface DragEndMessage {
129
+ type: "cmssy:drag-end";
130
+ protocolVersion: number;
131
+ }
132
+ type EditorToAppMessage = SelectMessage | PatchMessage | ParentReadyMessage | InsertMessage | ReorderMessage | RemoveMessage | DragOverMessage | DragEndMessage;
133
+ declare function isProtocolCompatible(version: number): boolean;
134
+
10
135
  declare const fields: {
11
136
  text: (opts?: FieldControl) => FieldDefinition;
12
137
  textarea: (opts?: FieldControl) => FieldDefinition;
@@ -107,10 +232,6 @@ declare function createCmssyClient(input: CmssyClientConfig): CmssyClient;
107
232
  declare function collectFormIds(blocks: RawBlock[], locale: string, defaultLocale: string): string[];
108
233
  declare function resolveForms(config: CmssyClientConfig, blocks: RawBlock[], locale: string, defaultLocale: string, options?: QueryScopedOptions): Promise<Record<string, CmssyFormDefinition>>;
109
234
 
110
- interface CmssySiteLocales {
111
- defaultLocale: string;
112
- locales: string[];
113
- }
114
235
  declare function resolveSiteLocales(config: CmssyClientConfig, options?: GraphqlRequestOptions): Promise<CmssySiteLocales>;
115
236
  declare function splitLocaleFromPath(path: string[] | undefined, siteLocales: CmssySiteLocales): {
116
237
  locale: string;
@@ -153,4 +274,4 @@ interface UnknownBlockProps {
153
274
  }
154
275
  declare function UnknownBlock({ type }: UnknownBlockProps): react_jsx_runtime.JSX.Element;
155
276
 
156
- export { AppToEditorMessage, BlockDefinition, BlockMap, CmssyBlock, CmssyBlockAuthContext, CmssyBlockContext, type CmssyBlockProps, CmssyBlockWorkspace, type CmssyClient, CmssyClientConfig, CmssyFormDefinition, CmssyLayoutGroup, CmssyLocaleContext, CmssyPageData, CmssyServerLayout, type CmssyServerLayoutProps, CmssyServerPage, type CmssyServerPageProps, CmssySiteConfig, type CmssySiteLocales, EditorToAppMessage, FetchLike, type FieldControl, FieldDefinition, type GraphqlRequestOptions, type PostTarget, type QueryScopedOptions, RawBlock, UnknownBlock, type UnknownBlockProps, buildLocaleSwitchHref, collectFormIds, createCmssyClient, fetchSiteConfig, fields, getBlockContentForLanguage, graphqlRequest, localizeHref, localizeHtmlLinks, normalizeOrigin, parseEditorMessage, postToEditor, resolveForms, resolveSiteLocales, resolveWorkspaceId, splitLocaleFromPath };
277
+ export { type AppToEditorMessage, BlockDefinition, BlockMap, type BoundsMessage, type ClickMessage, CmssyBlock, CmssyBlockAuthContext, CmssyBlockContext, type CmssyBlockProps, CmssyBlockWorkspace, type CmssyClient, CmssyFormDefinition, CmssyLocaleContext, CmssyServerLayout, type CmssyServerLayoutProps, CmssyServerPage, type CmssyServerPageProps, DEFAULT_CMSSY_API_URL, type EditorToAppMessage, type FetchLike, type FetchLikeResponse, type FetchPageOptions, type GraphqlRequestOptions, PROTOCOL_VERSION, type ParentReadyMessage, type PatchMessage, type PostTarget, type QueryScopedOptions, type ReadyMessage, type SelectMessage, UnknownBlock, type UnknownBlockProps, buildLocaleSwitchHref, collectFormIds, createCmssyClient, fetchLayouts, fetchPage, fetchPageById, fetchPageMeta, fetchPages, fetchSiteConfig, fields, getBlockContentForLanguage, graphqlRequest, isProtocolCompatible, localizeHref, localizeHtmlLinks, normalizeOrigin, normalizeSlug, parseEditorMessage, postToEditor, resolveApiUrl, resolveForms, resolvePublicUrl, resolveSiteLocales, resolveWorkspaceId, splitLocaleFromPath };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cmssy/react",
3
- "version": "2.3.1",
3
+ "version": "2.4.0",
4
4
  "description": "React blocks, renderers, data client and editor bridge for cmssy headless sites",
5
5
  "keywords": [
6
6
  "cmssy",
@@ -56,7 +56,7 @@
56
56
  "vitest": "^2.1.0"
57
57
  },
58
58
  "dependencies": {
59
- "@cmssy/types": "0.22.0"
59
+ "@cmssy/types": "0.24.0"
60
60
  },
61
61
  "scripts": {
62
62
  "build": "tsup",