@cmssy/react 4.7.2 → 5.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -1,189 +1,11 @@
1
- import { CmssyClientConfig, CmssyLayoutGroup, CmssyPageData, CmssyPageMeta, CmssyPageSummary, CmssyFormDefinition, BuildBlockContextExtra, CmssyBlockContext, BlockRect, BlockSchema, BlockMeta, FieldControl, FieldDefinition, CmssyBlockAuthContext, CmssyBlockWorkspace, CmssySiteConfig, RawBlock, CmssySiteLocales, CmssyLocaleContext } from '@cmssy/types';
2
- export { BlockMeta, BlockRect, BlockSchema, BuildBlockContextExtra, CmssyAddress, CmssyBlockAuthContext, CmssyBlockContext, CmssyBlockMember, CmssyBlockWorkspace, CmssyBranding, CmssyCart, CmssyCartDiscount, CmssyCartItem, CmssyCartItemSnapshot, CmssyClientConfig, CmssyFormDefinition, CmssyFormField, CmssyFormSettings, CmssyFormSubmitResponse, CmssyLayoutGroup, CmssyLayoutSettings, CmssyLocaleContext, CmssyLocalizedValue, CmssyModelDefinition, CmssyModelRecord, CmssyOrder, CmssyOrderDiscount, CmssyOrderItem, CmssyOrderTaxSummaryLine, CmssyPageData, CmssyPageMeta, CmssyPageSummary, CmssyPriceTier, CmssyProduct, CmssyProductVariant, CmssyRecordList, CmssyShippingMethod, CmssySiteConfig, CmssySiteLocales, CmssyTaxSummaryLine, FieldCondition, FieldConditionGroup, FieldConditionLogic, FieldControl, FieldDefinition, FieldType, RawBlock, RawLayoutBlock, SubmitFormInput, evaluateFieldConditionGroup } from '@cmssy/types';
3
- import { B as BlockDefinition, a as BlockMap } from './registry-DBPEDxug.cjs';
4
- export { b as blocksToMeta, c as blocksToSchemas, d as buildBlockMap, e as defineBlock } from './registry-DBPEDxug.cjs';
1
+ import { CmssyPageData, CmssyClientConfig, CmssyFormDefinition, CmssyBlockAuthContext, CmssyBlockWorkspace, CmssyLayoutGroup, RawBlock, CmssyBlockContext } from '@cmssy/core';
2
+ export { AppToEditorMessage, BlockMeta, BlockRect, BlockSchema, BoundsMessage, BuildBlockContextExtra, ClickMessage, CmssyAddress, CmssyBlockAuthContext, CmssyBlockContext, CmssyBlockMember, CmssyBlockWorkspace, CmssyBranding, CmssyCart, CmssyCartDiscount, CmssyCartItem, CmssyCartItemSnapshot, CmssyClient, CmssyClientConfig, CmssyFormDefinition, CmssyFormField, CmssyFormSettings, CmssyFormSubmitResponse, CmssyLayoutGroup, CmssyLayoutSettings, CmssyLocaleContext, CmssyLocalizedValue, CmssyModelDefinition, CmssyModelRecord, CmssyOrder, CmssyOrderDiscount, CmssyOrderItem, CmssyOrderTaxSummaryLine, CmssyPageData, CmssyPageMeta, CmssyPageSummary, CmssyPriceTier, CmssyProduct, CmssyProductVariant, CmssyRecordList, CmssyRequestError, CmssyShippingMethod, CmssySiteConfig, CmssySiteLocales, CmssyTaxSummaryLine, DEFAULT_CMSSY_API_URL, EditorToAppMessage, FORM_QUERY, FetchLike, FetchLikeResponse, FetchPageOptions, FieldControl, FieldDefinition, FieldType, GraphqlRequestOptions, MODEL_DEFINITIONS_QUERY, MODEL_RECORDS_QUERY, PROTOCOL_VERSION, ParentReadyMessage, PatchMessage, PostTarget, QueryScopedOptions, RawBlock, RawLayoutBlock, ReadyMessage, RetryPolicy, SITE_CONFIG_QUERY, SUBMIT_FORM_MUTATION, SelectMessage, SubmitFormInput, buildBlockContext, 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 } from '@cmssy/core';
3
+ import { B as BlockDefinition, a as BlockMap } from './registry-DnhIHuzF.cjs';
4
+ export { b as blocksToMeta, c as blocksToSchemas, d as buildBlockMap, e as defineBlock } from './registry-DnhIHuzF.cjs';
5
5
  import * as react_jsx_runtime from 'react/jsx-runtime';
6
+ export { FieldCondition, FieldConditionGroup, FieldConditionLogic, evaluateFieldConditionGroup } from '@cmssy/types';
6
7
  import 'react';
7
8
 
8
- /** HTTP-level failure from the cmssy API, with a machine-readable status. */
9
- declare class CmssyRequestError extends Error {
10
- readonly status: number;
11
- constructor(message: string, status: number);
12
- }
13
- interface RetryPolicy {
14
- /** Additional attempts after the first request (default 3). */
15
- maxRetries?: number;
16
- /** Exponential backoff base in ms: base * 2^attempt (default 300). */
17
- baseDelayMs?: number;
18
- /** Upper bound for any single wait, including Retry-After (default 3000). */
19
- maxDelayMs?: number;
20
- /** HTTP statuses that trigger a retry (default [429, 503]). */
21
- retryStatuses?: number[];
22
- }
23
-
24
- /**
25
- * The cmssy cloud GraphQL delivery endpoint. It is the same for every workspace,
26
- * so consumers never need to set it - `apiUrl` defaults to this. Self-hosted /
27
- * staging deployments override it via config.
28
- */
29
- declare const DEFAULT_CMSSY_API_URL = "https://api.cmssy.io/graphql";
30
- declare function resolveApiUrl(apiUrl: string | undefined): string;
31
- /**
32
- * Public delivery endpoint for a workspace: the org-scoped path
33
- * `{base}/public/{orgSlug}/{workspaceSlug}/graphql`. `apiUrl` is the GraphQL
34
- * base (its trailing `/graphql` is stripped); the org path is what tells the
35
- * backend which workspace to serve, so slugs only need to be unique per org.
36
- */
37
- declare function resolvePublicUrl(config: CmssyClientConfig): string;
38
- interface FetchLikeResponse {
39
- ok: boolean;
40
- status: number;
41
- json: () => Promise<unknown>;
42
- headers?: {
43
- get: (name: string) => string | null;
44
- };
45
- }
46
- type FetchLike = (url: string, init: {
47
- method: string;
48
- headers: Record<string, string>;
49
- body: string;
50
- signal?: AbortSignal;
51
- }) => Promise<FetchLikeResponse>;
52
- interface FetchPageOptions {
53
- previewSecret?: string;
54
- devPreview?: boolean;
55
- devToken?: string;
56
- workspaceId?: string;
57
- fetch?: FetchLike;
58
- signal?: AbortSignal;
59
- retry?: RetryPolicy | false;
60
- }
61
- declare function normalizeSlug(path: string | string[] | undefined): string;
62
- declare function fetchPage(config: CmssyClientConfig, path: string | string[] | undefined, options?: FetchPageOptions): Promise<CmssyPageData | null>;
63
- declare function fetchPageById(config: CmssyClientConfig, pageId: string, options?: Pick<FetchPageOptions, "fetch" | "signal" | "retry">): Promise<CmssyPageData | null>;
64
- declare function fetchPages(config: CmssyClientConfig, options?: Pick<FetchPageOptions, "fetch" | "signal" | "retry">): Promise<CmssyPageSummary[]>;
65
- declare function fetchPageMeta(config: CmssyClientConfig, path: string | string[] | undefined, options?: Pick<FetchPageOptions, "fetch" | "signal" | "retry">): Promise<CmssyPageMeta | null>;
66
- declare function fetchLayouts(config: CmssyClientConfig, path: string | string[] | undefined, options?: FetchPageOptions): Promise<CmssyLayoutGroup[]>;
67
-
68
- 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}";
69
- declare const MODEL_DEFINITIONS_QUERY = "query PublicModelDefinitions($workspaceId: String!) {\n public {\n model {\n definitions(workspaceId: $workspaceId) {\n id name slug description icon color displayField recordCount\n }\n }\n }\n}";
70
- declare const MODEL_RECORDS_QUERY = "query PublicModelRecords($workspaceId: String!, $modelSlug: String!, $filter: JSON, $sort: String, $locale: String, $limit: Int, $offset: Int, $populate: [String!]) {\n public {\n model {\n records(workspaceId: $workspaceId, modelSlug: $modelSlug, filter: $filter, sort: $sort, locale: $locale, limit: $limit, offset: $offset, populate: $populate) {\n items { id modelId data status createdAt updatedAt }\n total\n hasMore\n }\n }\n }\n}";
71
- declare const FORM_QUERY = "query PublicForm($formId: ID!) {\n public {\n form {\n get(formId: $formId) {\n id\n name\n slug\n description\n fields {\n id name fieldType label placeholder helpText\n defaultValue width order showWhen requiredWhen\n options { value label disabled }\n validation { required minLength maxLength minValue maxValue pattern customMessage }\n }\n settings {\n actionType submitButtonLabel successMessage errorMessage\n redirectUrl requireLogin enableCaptcha\n }\n }\n }\n }\n}";
72
- declare const SUBMIT_FORM_MUTATION = "mutation SubmitForm($formId: ID!, $input: SubmitFormInput!) {\n public {\n form {\n submit(formId: $formId, input: $input) {\n success message submissionId redirectUrl accessToken customer\n }\n }\n }\n}";
73
-
74
- declare function buildBlockContext(locale: string, defaultLocale: string, enabledLocales?: string[], isPreview?: boolean, forms?: Record<string, CmssyFormDefinition>, extra?: BuildBlockContextExtra): CmssyBlockContext;
75
-
76
- declare const PROTOCOL_VERSION = 2;
77
-
78
- interface ReadyMessage {
79
- type: "cmssy:ready";
80
- protocolVersion: number;
81
- blocks: Array<{
82
- id: string;
83
- type: string;
84
- bounds: BlockRect;
85
- layoutPosition?: string;
86
- }>;
87
- schemas: Record<string, BlockSchema>;
88
- blockMeta?: Record<string, BlockMeta>;
89
- }
90
- interface BoundsMessage {
91
- type: "cmssy:bounds";
92
- blockId: string;
93
- rect: BlockRect;
94
- }
95
- interface ClickMessage {
96
- type: "cmssy:click";
97
- blockId: string;
98
- rect: BlockRect;
99
- layoutPosition?: string;
100
- }
101
- interface MoveMessage {
102
- type: "cmssy:move";
103
- protocolVersion: number;
104
- blockId: string;
105
- index: number;
106
- }
107
- interface DragIndexMessage {
108
- type: "cmssy:drag-index";
109
- protocolVersion: number;
110
- index: number;
111
- }
112
- type AppToEditorMessage = ReadyMessage | BoundsMessage | ClickMessage | MoveMessage | DragIndexMessage;
113
- interface SelectMessage {
114
- type: "cmssy:select";
115
- protocolVersion: number;
116
- blockId: string;
117
- }
118
- interface PatchMessage {
119
- type: "cmssy:patch";
120
- protocolVersion: number;
121
- blockId: string;
122
- content: Record<string, unknown>;
123
- style?: Record<string, unknown>;
124
- advanced?: Record<string, unknown>;
125
- layoutPosition?: string;
126
- }
127
- interface ParentReadyMessage {
128
- type: "cmssy:parent-ready";
129
- protocolVersion: number;
130
- }
131
- interface InsertMessage {
132
- type: "cmssy:insert";
133
- protocolVersion: number;
134
- blockId: string;
135
- blockType: string;
136
- content: Record<string, unknown>;
137
- style?: Record<string, unknown>;
138
- advanced?: Record<string, unknown>;
139
- index: number;
140
- }
141
- interface ReorderMessage {
142
- type: "cmssy:reorder";
143
- protocolVersion: number;
144
- blockIds: string[];
145
- }
146
- interface RemoveMessage {
147
- type: "cmssy:remove";
148
- protocolVersion: number;
149
- blockId: string;
150
- }
151
- interface DragOverMessage {
152
- type: "cmssy:drag-over";
153
- protocolVersion: number;
154
- y: number;
155
- }
156
- interface DragEndMessage {
157
- type: "cmssy:drag-end";
158
- protocolVersion: number;
159
- }
160
- type EditorToAppMessage = SelectMessage | PatchMessage | ParentReadyMessage | InsertMessage | ReorderMessage | RemoveMessage | DragOverMessage | DragEndMessage;
161
- declare function isProtocolCompatible(version: number): boolean;
162
-
163
- declare const fields: {
164
- text: (opts?: FieldControl) => FieldDefinition;
165
- textarea: (opts?: FieldControl) => FieldDefinition;
166
- richText: (opts?: FieldControl) => FieldDefinition;
167
- markdown: (opts?: FieldControl) => FieldDefinition;
168
- number: (opts?: FieldControl) => FieldDefinition;
169
- date: (opts?: FieldControl) => FieldDefinition;
170
- datetime: (opts?: FieldControl) => FieldDefinition;
171
- boolean: (opts?: FieldControl) => FieldDefinition;
172
- color: (opts?: FieldControl) => FieldDefinition;
173
- media: (opts?: FieldControl) => FieldDefinition;
174
- link: (opts?: FieldControl) => FieldDefinition;
175
- url: (opts?: FieldControl) => FieldDefinition;
176
- email: (opts?: FieldControl) => FieldDefinition;
177
- select: (opts?: FieldControl) => FieldDefinition;
178
- multiselect: (opts?: FieldControl) => FieldDefinition;
179
- radio: (opts?: FieldControl) => FieldDefinition;
180
- repeater: (opts?: FieldControl) => FieldDefinition;
181
- table: (opts?: FieldControl) => FieldDefinition;
182
- json: (opts?: FieldControl) => FieldDefinition;
183
- form: (opts?: FieldControl) => FieldDefinition;
184
- pageSelector: (opts?: FieldControl) => FieldDefinition;
185
- };
186
-
187
9
  interface CmssyServerPageProps {
188
10
  page: CmssyPageData | null;
189
11
  blocks: BlockDefinition[];
@@ -232,74 +54,6 @@ interface CmssyServerLayoutProps {
232
54
  */
233
55
  declare function CmssyServerLayout({ groups, blocks, position, locale: localeProp, defaultLocale: defaultLocaleProp, enabledLocales: enabledLocalesProp, config, }: CmssyServerLayoutProps): Promise<react_jsx_runtime.JSX.Element | null>;
234
56
 
235
- interface PostTarget {
236
- postMessage: (message: unknown, targetOrigin: string) => void;
237
- }
238
- declare function normalizeOrigin(origin: string): string;
239
- declare function postToEditor(target: PostTarget, editorOrigin: string, message: AppToEditorMessage): void;
240
- declare function parseEditorMessage(data: unknown, origin: string, expectedOrigin: string | string[]): EditorToAppMessage | null;
241
-
242
- declare function getBlockContentForLanguage(content: unknown, locale: string, defaultLocale?: string, availableLocales?: string[]): Record<string, unknown>;
243
-
244
- interface GraphqlRequestOptions {
245
- fetch?: FetchLike;
246
- signal?: AbortSignal;
247
- headers?: Record<string, string>;
248
- /**
249
- * Route through the org-scoped public delivery path instead of the base
250
- * `/graphql` endpoint. Set for unauthenticated public queries so the backend
251
- * resolves the workspace from the URL rather than a global slug lookup.
252
- */
253
- public?: boolean;
254
- /**
255
- * Retry transient HTTP failures (429/503, honoring Retry-After). Off by
256
- * default: this function also carries mutations (auth, cart, checkout),
257
- * which must never be blind-retried. Read-only callers opt in with `{}`.
258
- */
259
- retry?: RetryPolicy | false;
260
- }
261
- declare function graphqlRequest<T>(config: CmssyClientConfig, query: string, variables: Record<string, unknown>, options?: GraphqlRequestOptions, label?: string): Promise<T>;
262
-
263
- declare function fetchSiteConfig(config: CmssyClientConfig, options?: GraphqlRequestOptions): Promise<CmssySiteConfig | null>;
264
- declare function resolveWorkspaceId(config: CmssyClientConfig, options?: GraphqlRequestOptions): Promise<string>;
265
-
266
- interface QueryScopedOptions extends GraphqlRequestOptions {
267
- workspaceId?: string;
268
- }
269
- interface CmssyClient {
270
- readonly config: CmssyClientConfig;
271
- query<T = unknown>(document: string, variables?: Record<string, unknown>, options?: GraphqlRequestOptions): Promise<T>;
272
- queryScoped<T = unknown>(document: string, variables?: Record<string, unknown>, options?: QueryScopedOptions): Promise<T>;
273
- resolveWorkspaceId(options?: GraphqlRequestOptions): Promise<string>;
274
- }
275
- declare function createCmssyClient(input: CmssyClientConfig): CmssyClient;
276
-
277
- declare function collectFormIds(blocks: RawBlock[], locale: string, defaultLocale: string): string[];
278
- declare function resolveForms(config: CmssyClientConfig, blocks: RawBlock[], locale: string, defaultLocale: string, options?: QueryScopedOptions): Promise<Record<string, CmssyFormDefinition>>;
279
-
280
- declare function resolveSiteLocales(config: CmssyClientConfig, options?: GraphqlRequestOptions): Promise<CmssySiteLocales>;
281
- declare function splitLocaleFromPath(path: string[] | undefined, siteLocales: CmssySiteLocales): {
282
- locale: string;
283
- path: string[] | undefined;
284
- };
285
-
286
- /**
287
- * Rewrites an internal href to carry the active locale as a path prefix.
288
- * External hrefs, fragments and relative paths are returned untouched. Already
289
- * prefixed hrefs are normalized so the prefix never doubles.
290
- */
291
- declare function localizeHref(href: string, locale: CmssyLocaleContext): string;
292
- /**
293
- * Builds the href that switches the current `pathname` to `target` locale,
294
- * preserving the rest of the path. Used by a language switcher.
295
- */
296
- declare function buildLocaleSwitchHref(target: string, pathname: string, locale: CmssyLocaleContext): string;
297
- /**
298
- * Rewrites every `<a href>` inside an HTML string with {@link localizeHref}.
299
- * For rich-text content stored in CMS blocks where links are raw markup.
300
- */
301
- declare function localizeHtmlLinks(html: string, locale: CmssyLocaleContext): string;
302
-
303
57
  interface CmssyBlockProps {
304
58
  block: RawBlock;
305
59
  locale: string;
@@ -319,4 +73,4 @@ interface UnknownBlockProps {
319
73
  }
320
74
  declare function UnknownBlock({ type }: UnknownBlockProps): react_jsx_runtime.JSX.Element;
321
75
 
322
- export { type AppToEditorMessage, BlockDefinition, BlockMap, type BoundsMessage, type ClickMessage, CmssyBlock, type CmssyBlockProps, type CmssyClient, CmssyRequestError, CmssyServerLayout, type CmssyServerLayoutProps, CmssyServerPage, type CmssyServerPageProps, DEFAULT_CMSSY_API_URL, type EditorToAppMessage, FORM_QUERY, type FetchLike, type FetchLikeResponse, type FetchPageOptions, type GraphqlRequestOptions, MODEL_DEFINITIONS_QUERY, MODEL_RECORDS_QUERY, PROTOCOL_VERSION, type ParentReadyMessage, type PatchMessage, type PostTarget, type QueryScopedOptions, type ReadyMessage, type RetryPolicy, SITE_CONFIG_QUERY, SUBMIT_FORM_MUTATION, type SelectMessage, UnknownBlock, type UnknownBlockProps, buildBlockContext, 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 };
76
+ export { BlockDefinition, BlockMap, CmssyBlock, type CmssyBlockProps, CmssyServerLayout, type CmssyServerLayoutProps, CmssyServerPage, type CmssyServerPageProps, UnknownBlock, type UnknownBlockProps };
package/dist/index.d.ts CHANGED
@@ -1,189 +1,11 @@
1
- import { CmssyClientConfig, CmssyLayoutGroup, CmssyPageData, CmssyPageMeta, CmssyPageSummary, CmssyFormDefinition, BuildBlockContextExtra, CmssyBlockContext, BlockRect, BlockSchema, BlockMeta, FieldControl, FieldDefinition, CmssyBlockAuthContext, CmssyBlockWorkspace, CmssySiteConfig, RawBlock, CmssySiteLocales, CmssyLocaleContext } from '@cmssy/types';
2
- export { BlockMeta, BlockRect, BlockSchema, BuildBlockContextExtra, CmssyAddress, CmssyBlockAuthContext, CmssyBlockContext, CmssyBlockMember, CmssyBlockWorkspace, CmssyBranding, CmssyCart, CmssyCartDiscount, CmssyCartItem, CmssyCartItemSnapshot, CmssyClientConfig, CmssyFormDefinition, CmssyFormField, CmssyFormSettings, CmssyFormSubmitResponse, CmssyLayoutGroup, CmssyLayoutSettings, CmssyLocaleContext, CmssyLocalizedValue, CmssyModelDefinition, CmssyModelRecord, CmssyOrder, CmssyOrderDiscount, CmssyOrderItem, CmssyOrderTaxSummaryLine, CmssyPageData, CmssyPageMeta, CmssyPageSummary, CmssyPriceTier, CmssyProduct, CmssyProductVariant, CmssyRecordList, CmssyShippingMethod, CmssySiteConfig, CmssySiteLocales, CmssyTaxSummaryLine, FieldCondition, FieldConditionGroup, FieldConditionLogic, FieldControl, FieldDefinition, FieldType, RawBlock, RawLayoutBlock, SubmitFormInput, evaluateFieldConditionGroup } from '@cmssy/types';
3
- import { B as BlockDefinition, a as BlockMap } from './registry-DBPEDxug.js';
4
- export { b as blocksToMeta, c as blocksToSchemas, d as buildBlockMap, e as defineBlock } from './registry-DBPEDxug.js';
1
+ import { CmssyPageData, CmssyClientConfig, CmssyFormDefinition, CmssyBlockAuthContext, CmssyBlockWorkspace, CmssyLayoutGroup, RawBlock, CmssyBlockContext } from '@cmssy/core';
2
+ export { AppToEditorMessage, BlockMeta, BlockRect, BlockSchema, BoundsMessage, BuildBlockContextExtra, ClickMessage, CmssyAddress, CmssyBlockAuthContext, CmssyBlockContext, CmssyBlockMember, CmssyBlockWorkspace, CmssyBranding, CmssyCart, CmssyCartDiscount, CmssyCartItem, CmssyCartItemSnapshot, CmssyClient, CmssyClientConfig, CmssyFormDefinition, CmssyFormField, CmssyFormSettings, CmssyFormSubmitResponse, CmssyLayoutGroup, CmssyLayoutSettings, CmssyLocaleContext, CmssyLocalizedValue, CmssyModelDefinition, CmssyModelRecord, CmssyOrder, CmssyOrderDiscount, CmssyOrderItem, CmssyOrderTaxSummaryLine, CmssyPageData, CmssyPageMeta, CmssyPageSummary, CmssyPriceTier, CmssyProduct, CmssyProductVariant, CmssyRecordList, CmssyRequestError, CmssyShippingMethod, CmssySiteConfig, CmssySiteLocales, CmssyTaxSummaryLine, DEFAULT_CMSSY_API_URL, EditorToAppMessage, FORM_QUERY, FetchLike, FetchLikeResponse, FetchPageOptions, FieldControl, FieldDefinition, FieldType, GraphqlRequestOptions, MODEL_DEFINITIONS_QUERY, MODEL_RECORDS_QUERY, PROTOCOL_VERSION, ParentReadyMessage, PatchMessage, PostTarget, QueryScopedOptions, RawBlock, RawLayoutBlock, ReadyMessage, RetryPolicy, SITE_CONFIG_QUERY, SUBMIT_FORM_MUTATION, SelectMessage, SubmitFormInput, buildBlockContext, 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 } from '@cmssy/core';
3
+ import { B as BlockDefinition, a as BlockMap } from './registry-DnhIHuzF.js';
4
+ export { b as blocksToMeta, c as blocksToSchemas, d as buildBlockMap, e as defineBlock } from './registry-DnhIHuzF.js';
5
5
  import * as react_jsx_runtime from 'react/jsx-runtime';
6
+ export { FieldCondition, FieldConditionGroup, FieldConditionLogic, evaluateFieldConditionGroup } from '@cmssy/types';
6
7
  import 'react';
7
8
 
8
- /** HTTP-level failure from the cmssy API, with a machine-readable status. */
9
- declare class CmssyRequestError extends Error {
10
- readonly status: number;
11
- constructor(message: string, status: number);
12
- }
13
- interface RetryPolicy {
14
- /** Additional attempts after the first request (default 3). */
15
- maxRetries?: number;
16
- /** Exponential backoff base in ms: base * 2^attempt (default 300). */
17
- baseDelayMs?: number;
18
- /** Upper bound for any single wait, including Retry-After (default 3000). */
19
- maxDelayMs?: number;
20
- /** HTTP statuses that trigger a retry (default [429, 503]). */
21
- retryStatuses?: number[];
22
- }
23
-
24
- /**
25
- * The cmssy cloud GraphQL delivery endpoint. It is the same for every workspace,
26
- * so consumers never need to set it - `apiUrl` defaults to this. Self-hosted /
27
- * staging deployments override it via config.
28
- */
29
- declare const DEFAULT_CMSSY_API_URL = "https://api.cmssy.io/graphql";
30
- declare function resolveApiUrl(apiUrl: string | undefined): string;
31
- /**
32
- * Public delivery endpoint for a workspace: the org-scoped path
33
- * `{base}/public/{orgSlug}/{workspaceSlug}/graphql`. `apiUrl` is the GraphQL
34
- * base (its trailing `/graphql` is stripped); the org path is what tells the
35
- * backend which workspace to serve, so slugs only need to be unique per org.
36
- */
37
- declare function resolvePublicUrl(config: CmssyClientConfig): string;
38
- interface FetchLikeResponse {
39
- ok: boolean;
40
- status: number;
41
- json: () => Promise<unknown>;
42
- headers?: {
43
- get: (name: string) => string | null;
44
- };
45
- }
46
- type FetchLike = (url: string, init: {
47
- method: string;
48
- headers: Record<string, string>;
49
- body: string;
50
- signal?: AbortSignal;
51
- }) => Promise<FetchLikeResponse>;
52
- interface FetchPageOptions {
53
- previewSecret?: string;
54
- devPreview?: boolean;
55
- devToken?: string;
56
- workspaceId?: string;
57
- fetch?: FetchLike;
58
- signal?: AbortSignal;
59
- retry?: RetryPolicy | false;
60
- }
61
- declare function normalizeSlug(path: string | string[] | undefined): string;
62
- declare function fetchPage(config: CmssyClientConfig, path: string | string[] | undefined, options?: FetchPageOptions): Promise<CmssyPageData | null>;
63
- declare function fetchPageById(config: CmssyClientConfig, pageId: string, options?: Pick<FetchPageOptions, "fetch" | "signal" | "retry">): Promise<CmssyPageData | null>;
64
- declare function fetchPages(config: CmssyClientConfig, options?: Pick<FetchPageOptions, "fetch" | "signal" | "retry">): Promise<CmssyPageSummary[]>;
65
- declare function fetchPageMeta(config: CmssyClientConfig, path: string | string[] | undefined, options?: Pick<FetchPageOptions, "fetch" | "signal" | "retry">): Promise<CmssyPageMeta | null>;
66
- declare function fetchLayouts(config: CmssyClientConfig, path: string | string[] | undefined, options?: FetchPageOptions): Promise<CmssyLayoutGroup[]>;
67
-
68
- 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}";
69
- declare const MODEL_DEFINITIONS_QUERY = "query PublicModelDefinitions($workspaceId: String!) {\n public {\n model {\n definitions(workspaceId: $workspaceId) {\n id name slug description icon color displayField recordCount\n }\n }\n }\n}";
70
- declare const MODEL_RECORDS_QUERY = "query PublicModelRecords($workspaceId: String!, $modelSlug: String!, $filter: JSON, $sort: String, $locale: String, $limit: Int, $offset: Int, $populate: [String!]) {\n public {\n model {\n records(workspaceId: $workspaceId, modelSlug: $modelSlug, filter: $filter, sort: $sort, locale: $locale, limit: $limit, offset: $offset, populate: $populate) {\n items { id modelId data status createdAt updatedAt }\n total\n hasMore\n }\n }\n }\n}";
71
- declare const FORM_QUERY = "query PublicForm($formId: ID!) {\n public {\n form {\n get(formId: $formId) {\n id\n name\n slug\n description\n fields {\n id name fieldType label placeholder helpText\n defaultValue width order showWhen requiredWhen\n options { value label disabled }\n validation { required minLength maxLength minValue maxValue pattern customMessage }\n }\n settings {\n actionType submitButtonLabel successMessage errorMessage\n redirectUrl requireLogin enableCaptcha\n }\n }\n }\n }\n}";
72
- declare const SUBMIT_FORM_MUTATION = "mutation SubmitForm($formId: ID!, $input: SubmitFormInput!) {\n public {\n form {\n submit(formId: $formId, input: $input) {\n success message submissionId redirectUrl accessToken customer\n }\n }\n }\n}";
73
-
74
- declare function buildBlockContext(locale: string, defaultLocale: string, enabledLocales?: string[], isPreview?: boolean, forms?: Record<string, CmssyFormDefinition>, extra?: BuildBlockContextExtra): CmssyBlockContext;
75
-
76
- declare const PROTOCOL_VERSION = 2;
77
-
78
- interface ReadyMessage {
79
- type: "cmssy:ready";
80
- protocolVersion: number;
81
- blocks: Array<{
82
- id: string;
83
- type: string;
84
- bounds: BlockRect;
85
- layoutPosition?: string;
86
- }>;
87
- schemas: Record<string, BlockSchema>;
88
- blockMeta?: Record<string, BlockMeta>;
89
- }
90
- interface BoundsMessage {
91
- type: "cmssy:bounds";
92
- blockId: string;
93
- rect: BlockRect;
94
- }
95
- interface ClickMessage {
96
- type: "cmssy:click";
97
- blockId: string;
98
- rect: BlockRect;
99
- layoutPosition?: string;
100
- }
101
- interface MoveMessage {
102
- type: "cmssy:move";
103
- protocolVersion: number;
104
- blockId: string;
105
- index: number;
106
- }
107
- interface DragIndexMessage {
108
- type: "cmssy:drag-index";
109
- protocolVersion: number;
110
- index: number;
111
- }
112
- type AppToEditorMessage = ReadyMessage | BoundsMessage | ClickMessage | MoveMessage | DragIndexMessage;
113
- interface SelectMessage {
114
- type: "cmssy:select";
115
- protocolVersion: number;
116
- blockId: string;
117
- }
118
- interface PatchMessage {
119
- type: "cmssy:patch";
120
- protocolVersion: number;
121
- blockId: string;
122
- content: Record<string, unknown>;
123
- style?: Record<string, unknown>;
124
- advanced?: Record<string, unknown>;
125
- layoutPosition?: string;
126
- }
127
- interface ParentReadyMessage {
128
- type: "cmssy:parent-ready";
129
- protocolVersion: number;
130
- }
131
- interface InsertMessage {
132
- type: "cmssy:insert";
133
- protocolVersion: number;
134
- blockId: string;
135
- blockType: string;
136
- content: Record<string, unknown>;
137
- style?: Record<string, unknown>;
138
- advanced?: Record<string, unknown>;
139
- index: number;
140
- }
141
- interface ReorderMessage {
142
- type: "cmssy:reorder";
143
- protocolVersion: number;
144
- blockIds: string[];
145
- }
146
- interface RemoveMessage {
147
- type: "cmssy:remove";
148
- protocolVersion: number;
149
- blockId: string;
150
- }
151
- interface DragOverMessage {
152
- type: "cmssy:drag-over";
153
- protocolVersion: number;
154
- y: number;
155
- }
156
- interface DragEndMessage {
157
- type: "cmssy:drag-end";
158
- protocolVersion: number;
159
- }
160
- type EditorToAppMessage = SelectMessage | PatchMessage | ParentReadyMessage | InsertMessage | ReorderMessage | RemoveMessage | DragOverMessage | DragEndMessage;
161
- declare function isProtocolCompatible(version: number): boolean;
162
-
163
- declare const fields: {
164
- text: (opts?: FieldControl) => FieldDefinition;
165
- textarea: (opts?: FieldControl) => FieldDefinition;
166
- richText: (opts?: FieldControl) => FieldDefinition;
167
- markdown: (opts?: FieldControl) => FieldDefinition;
168
- number: (opts?: FieldControl) => FieldDefinition;
169
- date: (opts?: FieldControl) => FieldDefinition;
170
- datetime: (opts?: FieldControl) => FieldDefinition;
171
- boolean: (opts?: FieldControl) => FieldDefinition;
172
- color: (opts?: FieldControl) => FieldDefinition;
173
- media: (opts?: FieldControl) => FieldDefinition;
174
- link: (opts?: FieldControl) => FieldDefinition;
175
- url: (opts?: FieldControl) => FieldDefinition;
176
- email: (opts?: FieldControl) => FieldDefinition;
177
- select: (opts?: FieldControl) => FieldDefinition;
178
- multiselect: (opts?: FieldControl) => FieldDefinition;
179
- radio: (opts?: FieldControl) => FieldDefinition;
180
- repeater: (opts?: FieldControl) => FieldDefinition;
181
- table: (opts?: FieldControl) => FieldDefinition;
182
- json: (opts?: FieldControl) => FieldDefinition;
183
- form: (opts?: FieldControl) => FieldDefinition;
184
- pageSelector: (opts?: FieldControl) => FieldDefinition;
185
- };
186
-
187
9
  interface CmssyServerPageProps {
188
10
  page: CmssyPageData | null;
189
11
  blocks: BlockDefinition[];
@@ -232,74 +54,6 @@ interface CmssyServerLayoutProps {
232
54
  */
233
55
  declare function CmssyServerLayout({ groups, blocks, position, locale: localeProp, defaultLocale: defaultLocaleProp, enabledLocales: enabledLocalesProp, config, }: CmssyServerLayoutProps): Promise<react_jsx_runtime.JSX.Element | null>;
234
56
 
235
- interface PostTarget {
236
- postMessage: (message: unknown, targetOrigin: string) => void;
237
- }
238
- declare function normalizeOrigin(origin: string): string;
239
- declare function postToEditor(target: PostTarget, editorOrigin: string, message: AppToEditorMessage): void;
240
- declare function parseEditorMessage(data: unknown, origin: string, expectedOrigin: string | string[]): EditorToAppMessage | null;
241
-
242
- declare function getBlockContentForLanguage(content: unknown, locale: string, defaultLocale?: string, availableLocales?: string[]): Record<string, unknown>;
243
-
244
- interface GraphqlRequestOptions {
245
- fetch?: FetchLike;
246
- signal?: AbortSignal;
247
- headers?: Record<string, string>;
248
- /**
249
- * Route through the org-scoped public delivery path instead of the base
250
- * `/graphql` endpoint. Set for unauthenticated public queries so the backend
251
- * resolves the workspace from the URL rather than a global slug lookup.
252
- */
253
- public?: boolean;
254
- /**
255
- * Retry transient HTTP failures (429/503, honoring Retry-After). Off by
256
- * default: this function also carries mutations (auth, cart, checkout),
257
- * which must never be blind-retried. Read-only callers opt in with `{}`.
258
- */
259
- retry?: RetryPolicy | false;
260
- }
261
- declare function graphqlRequest<T>(config: CmssyClientConfig, query: string, variables: Record<string, unknown>, options?: GraphqlRequestOptions, label?: string): Promise<T>;
262
-
263
- declare function fetchSiteConfig(config: CmssyClientConfig, options?: GraphqlRequestOptions): Promise<CmssySiteConfig | null>;
264
- declare function resolveWorkspaceId(config: CmssyClientConfig, options?: GraphqlRequestOptions): Promise<string>;
265
-
266
- interface QueryScopedOptions extends GraphqlRequestOptions {
267
- workspaceId?: string;
268
- }
269
- interface CmssyClient {
270
- readonly config: CmssyClientConfig;
271
- query<T = unknown>(document: string, variables?: Record<string, unknown>, options?: GraphqlRequestOptions): Promise<T>;
272
- queryScoped<T = unknown>(document: string, variables?: Record<string, unknown>, options?: QueryScopedOptions): Promise<T>;
273
- resolveWorkspaceId(options?: GraphqlRequestOptions): Promise<string>;
274
- }
275
- declare function createCmssyClient(input: CmssyClientConfig): CmssyClient;
276
-
277
- declare function collectFormIds(blocks: RawBlock[], locale: string, defaultLocale: string): string[];
278
- declare function resolveForms(config: CmssyClientConfig, blocks: RawBlock[], locale: string, defaultLocale: string, options?: QueryScopedOptions): Promise<Record<string, CmssyFormDefinition>>;
279
-
280
- declare function resolveSiteLocales(config: CmssyClientConfig, options?: GraphqlRequestOptions): Promise<CmssySiteLocales>;
281
- declare function splitLocaleFromPath(path: string[] | undefined, siteLocales: CmssySiteLocales): {
282
- locale: string;
283
- path: string[] | undefined;
284
- };
285
-
286
- /**
287
- * Rewrites an internal href to carry the active locale as a path prefix.
288
- * External hrefs, fragments and relative paths are returned untouched. Already
289
- * prefixed hrefs are normalized so the prefix never doubles.
290
- */
291
- declare function localizeHref(href: string, locale: CmssyLocaleContext): string;
292
- /**
293
- * Builds the href that switches the current `pathname` to `target` locale,
294
- * preserving the rest of the path. Used by a language switcher.
295
- */
296
- declare function buildLocaleSwitchHref(target: string, pathname: string, locale: CmssyLocaleContext): string;
297
- /**
298
- * Rewrites every `<a href>` inside an HTML string with {@link localizeHref}.
299
- * For rich-text content stored in CMS blocks where links are raw markup.
300
- */
301
- declare function localizeHtmlLinks(html: string, locale: CmssyLocaleContext): string;
302
-
303
57
  interface CmssyBlockProps {
304
58
  block: RawBlock;
305
59
  locale: string;
@@ -319,4 +73,4 @@ interface UnknownBlockProps {
319
73
  }
320
74
  declare function UnknownBlock({ type }: UnknownBlockProps): react_jsx_runtime.JSX.Element;
321
75
 
322
- export { type AppToEditorMessage, BlockDefinition, BlockMap, type BoundsMessage, type ClickMessage, CmssyBlock, type CmssyBlockProps, type CmssyClient, CmssyRequestError, CmssyServerLayout, type CmssyServerLayoutProps, CmssyServerPage, type CmssyServerPageProps, DEFAULT_CMSSY_API_URL, type EditorToAppMessage, FORM_QUERY, type FetchLike, type FetchLikeResponse, type FetchPageOptions, type GraphqlRequestOptions, MODEL_DEFINITIONS_QUERY, MODEL_RECORDS_QUERY, PROTOCOL_VERSION, type ParentReadyMessage, type PatchMessage, type PostTarget, type QueryScopedOptions, type ReadyMessage, type RetryPolicy, SITE_CONFIG_QUERY, SUBMIT_FORM_MUTATION, type SelectMessage, UnknownBlock, type UnknownBlockProps, buildBlockContext, 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 };
76
+ export { BlockDefinition, BlockMap, CmssyBlock, type CmssyBlockProps, CmssyServerLayout, type CmssyServerLayoutProps, CmssyServerPage, type CmssyServerPageProps, UnknownBlock, type UnknownBlockProps };