@cmssy/react 2.3.1 → 2.5.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, CmssyFormDefinition, CmssyLayoutGroup, CmssyLocaleContext } from '@cmssy/types';
3
+ import { B as BlockDefinition, C as CmssyAddress, a as CmssyCart, b as CmssyOrder, c as CmssyProduct } from './commerce-queries-CfjwkgfE.cjs';
4
+ export { d as CmssyCartDiscount, e as CmssyCartItem, f as CmssyCartItemSnapshot, g as CmssyOrderItem, h as CmssyProductVariant } from './commerce-queries-CfjwkgfE.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, CmssyFormDefinition, CmssyLayoutGroup, CmssyLocaleContext } from '@cmssy/types';
3
+ import { B as BlockDefinition, C as CmssyAddress, a as CmssyCart, b as CmssyOrder, c as CmssyProduct } from './commerce-queries-CfjwkgfE.js';
4
+ export { d as CmssyCartDiscount, e as CmssyCartItem, f as CmssyCartItemSnapshot, g as CmssyOrderItem, h as CmssyProductVariant } from './commerce-queries-CfjwkgfE.js';
4
5
  import { ReactNode } from 'react';
5
- import '@cmssy/types';
6
6
 
7
7
  interface EditBridgeConfig {
8
8
  editorOrigin: string | string[];
@@ -0,0 +1,223 @@
1
+ import { ComponentType } from 'react';
2
+ import { FieldDefinition, CmssyBlockContext, BlockMeta, BlockSchema } from '@cmssy/types';
3
+
4
+ interface BlockLoaderArgs {
5
+ content: Record<string, unknown>;
6
+ context?: CmssyBlockContext;
7
+ }
8
+ type BlockLoader = (args: BlockLoaderArgs) => Promise<unknown> | unknown;
9
+ interface BlockDefinition {
10
+ type: string;
11
+ label?: string;
12
+ category?: string;
13
+ icon?: string;
14
+ layoutPositions?: string[];
15
+ /**
16
+ * One-line semantic description of what the block is and when it belongs on a
17
+ * page. Surfaced to the AI page composer to guide block selection and order.
18
+ */
19
+ description?: string;
20
+ props: Record<string, FieldDefinition>;
21
+ /**
22
+ * Optional server-side data loader. Run by CmssyServerPage during SSR; its
23
+ * result is passed to the component as the `data` prop. Not run in the
24
+ * editor (the component receives `data: undefined` there).
25
+ *
26
+ * The result crosses the server→client boundary when the block component is a
27
+ * Client Component, so it must be RSC-serializable (plain objects, arrays and
28
+ * primitives - no functions, class instances, etc.).
29
+ */
30
+ loader?: BlockLoader;
31
+ component: ComponentType<{
32
+ content: Record<string, unknown>;
33
+ style?: Record<string, unknown>;
34
+ advanced?: Record<string, unknown>;
35
+ context?: CmssyBlockContext;
36
+ data?: unknown;
37
+ }>;
38
+ }
39
+ declare function defineBlock<C extends Record<string, unknown>, D = unknown, S extends Record<string, unknown> = Record<string, unknown>, A extends Record<string, unknown> = Record<string, unknown>>(def: {
40
+ type: string;
41
+ label?: string;
42
+ category?: string;
43
+ icon?: string;
44
+ layoutPositions?: string[];
45
+ description?: string;
46
+ props: Record<string, FieldDefinition>;
47
+ loader?: (args: {
48
+ content: C;
49
+ context?: CmssyBlockContext;
50
+ }) => Promise<D> | D;
51
+ component: ComponentType<{
52
+ content: C;
53
+ style?: S;
54
+ advanced?: A;
55
+ context?: CmssyBlockContext;
56
+ data?: D;
57
+ }>;
58
+ }): BlockDefinition;
59
+ type BlockMap = Record<string, ComponentType<{
60
+ content: Record<string, unknown>;
61
+ style?: Record<string, unknown>;
62
+ advanced?: Record<string, unknown>;
63
+ context?: CmssyBlockContext;
64
+ data?: unknown;
65
+ }>>;
66
+ declare function buildBlockMap(blocks: BlockDefinition[]): BlockMap;
67
+ declare function blocksToSchemas(blocks: BlockDefinition[]): Record<string, BlockSchema>;
68
+ declare function blocksToMeta(blocks: BlockDefinition[], defaults?: {
69
+ category?: string;
70
+ }): Record<string, BlockMeta>;
71
+
72
+ interface CmssyPriceTier {
73
+ minQty: number;
74
+ price: number;
75
+ }
76
+ interface CmssyCartItemSnapshot {
77
+ name: string;
78
+ price: number;
79
+ currency: string;
80
+ imageUrl: string | null;
81
+ sku: string | null;
82
+ tiers: CmssyPriceTier[];
83
+ }
84
+ interface CmssyCartItem {
85
+ id: string;
86
+ recordId: string;
87
+ quantity: number;
88
+ variantSelections: Record<string, string> | null;
89
+ snapshot: CmssyCartItemSnapshot;
90
+ unitPrice: number;
91
+ currentPrice: number | null;
92
+ priceMismatch: boolean;
93
+ }
94
+ interface CmssyShippingMethod {
95
+ id: string;
96
+ label: string;
97
+ price: number;
98
+ etaLabel: string | null;
99
+ }
100
+ interface CmssyTaxSummaryLine {
101
+ rateId: string | null;
102
+ name: string | null;
103
+ rate: number;
104
+ base: number;
105
+ amount: number;
106
+ }
107
+ interface CmssyAddress {
108
+ name: string;
109
+ company?: string | null;
110
+ line1: string;
111
+ line2?: string | null;
112
+ postalCode: string;
113
+ city: string;
114
+ region?: string | null;
115
+ country: string;
116
+ phone?: string | null;
117
+ vatId?: string | null;
118
+ }
119
+ interface CmssyCartDiscount {
120
+ code: string;
121
+ type: string;
122
+ value: number;
123
+ computedAmount: number;
124
+ }
125
+ interface CmssyCart {
126
+ id: string;
127
+ status: string;
128
+ items: CmssyCartItem[];
129
+ itemCount: number;
130
+ subtotal: number;
131
+ currency: string | null;
132
+ appliedDiscount: CmssyCartDiscount | null;
133
+ discountedTotal: number;
134
+ tax: number;
135
+ taxSummary: CmssyTaxSummaryLine[];
136
+ totalGross: number;
137
+ pricesIncludeTax: boolean;
138
+ shippingMethod: CmssyShippingMethod | null;
139
+ shippingTotal: number;
140
+ availableShippingMethods: CmssyShippingMethod[];
141
+ }
142
+ interface CmssyProductVariant {
143
+ id: string;
144
+ sku: string | null;
145
+ price: number;
146
+ inventory: number | null;
147
+ selectedOptions: Array<{
148
+ name: string;
149
+ value: string;
150
+ }>;
151
+ tiers: CmssyPriceTier[];
152
+ }
153
+ interface CmssyProduct {
154
+ id: string;
155
+ data: Record<string, unknown>;
156
+ variants: CmssyProductVariant[];
157
+ priceTiers: CmssyPriceTier[];
158
+ }
159
+ interface CmssyOrderItem {
160
+ name: string;
161
+ price: number;
162
+ listPrice?: number | null;
163
+ tierMinQty?: number | null;
164
+ currency: string;
165
+ quantity: number;
166
+ sku: string | null;
167
+ }
168
+ interface CmssyOrderPayment {
169
+ amount: number;
170
+ reference: string;
171
+ provider: string | null;
172
+ at: string;
173
+ }
174
+ type CmssyOrderTaxSummaryLine = CmssyTaxSummaryLine;
175
+ interface CmssyOrderDiscount {
176
+ code: string;
177
+ type: string;
178
+ value: number;
179
+ amount: number;
180
+ }
181
+ interface CmssyOrder {
182
+ id: string;
183
+ status: string;
184
+ subtotal: number;
185
+ discount?: number;
186
+ appliedDiscount?: CmssyOrderDiscount | null;
187
+ total: number;
188
+ currency: string;
189
+ customerEmail: string;
190
+ tax?: number;
191
+ pricesIncludeTax?: boolean;
192
+ taxSummary?: CmssyOrderTaxSummaryLine[];
193
+ refundedAmount?: number;
194
+ items?: CmssyOrderItem[];
195
+ paymentProvider?: string | null;
196
+ paymentStatus?: string;
197
+ fulfillmentStatus?: string;
198
+ amountPaid?: number;
199
+ balanceDue?: number;
200
+ paymentReference?: string | null;
201
+ trackingNumber?: string | null;
202
+ trackingCarrier?: string | null;
203
+ invoiceNumber?: string | null;
204
+ invoiceUrl?: string | null;
205
+ invoiceProvider?: string | null;
206
+ payments?: CmssyOrderPayment[];
207
+ paidAt?: string | null;
208
+ fulfilledAt?: string | null;
209
+ createdAt?: string;
210
+ orderNumber?: number | null;
211
+ poNumber?: string | null;
212
+ customerNote?: string | null;
213
+ shippingAddress?: CmssyAddress | null;
214
+ shippingMethod?: {
215
+ id: string;
216
+ label: string;
217
+ price: number;
218
+ } | null;
219
+ shippingTotal?: number;
220
+ accessToken?: string | null;
221
+ }
222
+
223
+ export { type BlockDefinition as B, type CmssyAddress as C, type CmssyCart as a, type CmssyOrder as b, type CmssyProduct as c, type CmssyCartDiscount as d, type CmssyCartItem as e, type CmssyCartItemSnapshot as f, type CmssyOrderItem as g, type CmssyProductVariant as h, type BlockMap as i, type CmssyOrderDiscount as j, type CmssyOrderTaxSummaryLine as k, type CmssyPriceTier as l, type CmssyShippingMethod as m, type CmssyTaxSummaryLine as n, blocksToMeta as o, blocksToSchemas as p, buildBlockMap as q, defineBlock as r };
@@ -0,0 +1,223 @@
1
+ import { ComponentType } from 'react';
2
+ import { FieldDefinition, CmssyBlockContext, BlockMeta, BlockSchema } from '@cmssy/types';
3
+
4
+ interface BlockLoaderArgs {
5
+ content: Record<string, unknown>;
6
+ context?: CmssyBlockContext;
7
+ }
8
+ type BlockLoader = (args: BlockLoaderArgs) => Promise<unknown> | unknown;
9
+ interface BlockDefinition {
10
+ type: string;
11
+ label?: string;
12
+ category?: string;
13
+ icon?: string;
14
+ layoutPositions?: string[];
15
+ /**
16
+ * One-line semantic description of what the block is and when it belongs on a
17
+ * page. Surfaced to the AI page composer to guide block selection and order.
18
+ */
19
+ description?: string;
20
+ props: Record<string, FieldDefinition>;
21
+ /**
22
+ * Optional server-side data loader. Run by CmssyServerPage during SSR; its
23
+ * result is passed to the component as the `data` prop. Not run in the
24
+ * editor (the component receives `data: undefined` there).
25
+ *
26
+ * The result crosses the server→client boundary when the block component is a
27
+ * Client Component, so it must be RSC-serializable (plain objects, arrays and
28
+ * primitives - no functions, class instances, etc.).
29
+ */
30
+ loader?: BlockLoader;
31
+ component: ComponentType<{
32
+ content: Record<string, unknown>;
33
+ style?: Record<string, unknown>;
34
+ advanced?: Record<string, unknown>;
35
+ context?: CmssyBlockContext;
36
+ data?: unknown;
37
+ }>;
38
+ }
39
+ declare function defineBlock<C extends Record<string, unknown>, D = unknown, S extends Record<string, unknown> = Record<string, unknown>, A extends Record<string, unknown> = Record<string, unknown>>(def: {
40
+ type: string;
41
+ label?: string;
42
+ category?: string;
43
+ icon?: string;
44
+ layoutPositions?: string[];
45
+ description?: string;
46
+ props: Record<string, FieldDefinition>;
47
+ loader?: (args: {
48
+ content: C;
49
+ context?: CmssyBlockContext;
50
+ }) => Promise<D> | D;
51
+ component: ComponentType<{
52
+ content: C;
53
+ style?: S;
54
+ advanced?: A;
55
+ context?: CmssyBlockContext;
56
+ data?: D;
57
+ }>;
58
+ }): BlockDefinition;
59
+ type BlockMap = Record<string, ComponentType<{
60
+ content: Record<string, unknown>;
61
+ style?: Record<string, unknown>;
62
+ advanced?: Record<string, unknown>;
63
+ context?: CmssyBlockContext;
64
+ data?: unknown;
65
+ }>>;
66
+ declare function buildBlockMap(blocks: BlockDefinition[]): BlockMap;
67
+ declare function blocksToSchemas(blocks: BlockDefinition[]): Record<string, BlockSchema>;
68
+ declare function blocksToMeta(blocks: BlockDefinition[], defaults?: {
69
+ category?: string;
70
+ }): Record<string, BlockMeta>;
71
+
72
+ interface CmssyPriceTier {
73
+ minQty: number;
74
+ price: number;
75
+ }
76
+ interface CmssyCartItemSnapshot {
77
+ name: string;
78
+ price: number;
79
+ currency: string;
80
+ imageUrl: string | null;
81
+ sku: string | null;
82
+ tiers: CmssyPriceTier[];
83
+ }
84
+ interface CmssyCartItem {
85
+ id: string;
86
+ recordId: string;
87
+ quantity: number;
88
+ variantSelections: Record<string, string> | null;
89
+ snapshot: CmssyCartItemSnapshot;
90
+ unitPrice: number;
91
+ currentPrice: number | null;
92
+ priceMismatch: boolean;
93
+ }
94
+ interface CmssyShippingMethod {
95
+ id: string;
96
+ label: string;
97
+ price: number;
98
+ etaLabel: string | null;
99
+ }
100
+ interface CmssyTaxSummaryLine {
101
+ rateId: string | null;
102
+ name: string | null;
103
+ rate: number;
104
+ base: number;
105
+ amount: number;
106
+ }
107
+ interface CmssyAddress {
108
+ name: string;
109
+ company?: string | null;
110
+ line1: string;
111
+ line2?: string | null;
112
+ postalCode: string;
113
+ city: string;
114
+ region?: string | null;
115
+ country: string;
116
+ phone?: string | null;
117
+ vatId?: string | null;
118
+ }
119
+ interface CmssyCartDiscount {
120
+ code: string;
121
+ type: string;
122
+ value: number;
123
+ computedAmount: number;
124
+ }
125
+ interface CmssyCart {
126
+ id: string;
127
+ status: string;
128
+ items: CmssyCartItem[];
129
+ itemCount: number;
130
+ subtotal: number;
131
+ currency: string | null;
132
+ appliedDiscount: CmssyCartDiscount | null;
133
+ discountedTotal: number;
134
+ tax: number;
135
+ taxSummary: CmssyTaxSummaryLine[];
136
+ totalGross: number;
137
+ pricesIncludeTax: boolean;
138
+ shippingMethod: CmssyShippingMethod | null;
139
+ shippingTotal: number;
140
+ availableShippingMethods: CmssyShippingMethod[];
141
+ }
142
+ interface CmssyProductVariant {
143
+ id: string;
144
+ sku: string | null;
145
+ price: number;
146
+ inventory: number | null;
147
+ selectedOptions: Array<{
148
+ name: string;
149
+ value: string;
150
+ }>;
151
+ tiers: CmssyPriceTier[];
152
+ }
153
+ interface CmssyProduct {
154
+ id: string;
155
+ data: Record<string, unknown>;
156
+ variants: CmssyProductVariant[];
157
+ priceTiers: CmssyPriceTier[];
158
+ }
159
+ interface CmssyOrderItem {
160
+ name: string;
161
+ price: number;
162
+ listPrice?: number | null;
163
+ tierMinQty?: number | null;
164
+ currency: string;
165
+ quantity: number;
166
+ sku: string | null;
167
+ }
168
+ interface CmssyOrderPayment {
169
+ amount: number;
170
+ reference: string;
171
+ provider: string | null;
172
+ at: string;
173
+ }
174
+ type CmssyOrderTaxSummaryLine = CmssyTaxSummaryLine;
175
+ interface CmssyOrderDiscount {
176
+ code: string;
177
+ type: string;
178
+ value: number;
179
+ amount: number;
180
+ }
181
+ interface CmssyOrder {
182
+ id: string;
183
+ status: string;
184
+ subtotal: number;
185
+ discount?: number;
186
+ appliedDiscount?: CmssyOrderDiscount | null;
187
+ total: number;
188
+ currency: string;
189
+ customerEmail: string;
190
+ tax?: number;
191
+ pricesIncludeTax?: boolean;
192
+ taxSummary?: CmssyOrderTaxSummaryLine[];
193
+ refundedAmount?: number;
194
+ items?: CmssyOrderItem[];
195
+ paymentProvider?: string | null;
196
+ paymentStatus?: string;
197
+ fulfillmentStatus?: string;
198
+ amountPaid?: number;
199
+ balanceDue?: number;
200
+ paymentReference?: string | null;
201
+ trackingNumber?: string | null;
202
+ trackingCarrier?: string | null;
203
+ invoiceNumber?: string | null;
204
+ invoiceUrl?: string | null;
205
+ invoiceProvider?: string | null;
206
+ payments?: CmssyOrderPayment[];
207
+ paidAt?: string | null;
208
+ fulfilledAt?: string | null;
209
+ createdAt?: string;
210
+ orderNumber?: number | null;
211
+ poNumber?: string | null;
212
+ customerNote?: string | null;
213
+ shippingAddress?: CmssyAddress | null;
214
+ shippingMethod?: {
215
+ id: string;
216
+ label: string;
217
+ price: number;
218
+ } | null;
219
+ shippingTotal?: number;
220
+ accessToken?: string | null;
221
+ }
222
+
223
+ export { type BlockDefinition as B, type CmssyAddress as C, type CmssyCart as a, type CmssyOrder as b, type CmssyProduct as c, type CmssyCartDiscount as d, type CmssyCartItem as e, type CmssyCartItemSnapshot as f, type CmssyOrderItem as g, type CmssyProductVariant as h, type BlockMap as i, type CmssyOrderDiscount as j, type CmssyOrderTaxSummaryLine as k, type CmssyPriceTier as l, type CmssyShippingMethod as m, type CmssyTaxSummaryLine as n, blocksToMeta as o, blocksToSchemas as p, buildBlockMap as q, defineBlock as r };
package/dist/index.d.cts CHANGED
@@ -1,12 +1,145 @@
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, CmssyFormDefinition, BuildBlockContextExtra, CmssyBlockContext, BlockRect, BlockSchema, BlockMeta, FieldControl, FieldDefinition, CmssyBlockAuthContext, CmssyBlockWorkspace, CmssySiteConfig, RawBlock, CmssySiteLocales, CmssyLocaleContext } from '@cmssy/types';
2
+ export { BlockMeta, BlockRect, BlockSchema, BuildBlockContextExtra, CmssyBlockAuthContext, CmssyBlockContext, CmssyBlockMember, CmssyBlockWorkspace, CmssyBranding, CmssyClientConfig, CmssyFormDefinition, CmssyFormField, CmssyFormSettings, CmssyFormSubmitResponse, CmssyLayoutGroup, CmssyLayoutSettings, CmssyLocaleContext, CmssyLocalizedValue, CmssyModelDefinition, CmssyModelRecord, CmssyPageData, CmssyPageMeta, CmssyPageSummary, CmssyRecordList, CmssySiteConfig, CmssySiteLocales, FieldCondition, FieldConditionGroup, FieldConditionLogic, FieldControl, FieldDefinition, FieldType, RawBlock, RawLayoutBlock, SubmitFormInput, evaluateFieldConditionGroup } from '@cmssy/types';
3
+ import { B as BlockDefinition, i as BlockMap } from './commerce-queries-CfjwkgfE.cjs';
4
+ export { C as CmssyAddress, a as CmssyCart, d as CmssyCartDiscount, e as CmssyCartItem, f as CmssyCartItemSnapshot, b as CmssyOrder, j as CmssyOrderDiscount, g as CmssyOrderItem, k as CmssyOrderTaxSummaryLine, l as CmssyPriceTier, c as CmssyProduct, h as CmssyProductVariant, m as CmssyShippingMethod, n as CmssyTaxSummaryLine, o as blocksToMeta, p as blocksToSchemas, q as buildBlockMap, r as defineBlock } from './commerce-queries-CfjwkgfE.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 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}";
49
+ 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}";
50
+ declare const MODEL_RECORDS_QUERY = "query PublicModelRecords($workspaceId: String!, $modelSlug: String!, $filter: JSON, $sort: String, $limit: Int, $offset: Int, $populate: [String!]) {\n public {\n model {\n records(workspaceId: $workspaceId, modelSlug: $modelSlug, filter: $filter, sort: $sort, limit: $limit, offset: $offset, populate: $populate) {\n items { id modelId data status createdAt updatedAt }\n total\n hasMore\n }\n }\n }\n}";
51
+ 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}";
52
+ 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}";
53
+
54
+ declare function buildBlockContext(locale: string, defaultLocale: string, enabledLocales?: string[], isPreview?: boolean, forms?: Record<string, CmssyFormDefinition>, extra?: BuildBlockContextExtra): CmssyBlockContext;
55
+
56
+ declare const PROTOCOL_VERSION = 2;
57
+
58
+ interface ReadyMessage {
59
+ type: "cmssy:ready";
60
+ protocolVersion: number;
61
+ blocks: Array<{
62
+ id: string;
63
+ type: string;
64
+ bounds: BlockRect;
65
+ layoutPosition?: string;
66
+ }>;
67
+ schemas: Record<string, BlockSchema>;
68
+ blockMeta?: Record<string, BlockMeta>;
69
+ }
70
+ interface BoundsMessage {
71
+ type: "cmssy:bounds";
72
+ blockId: string;
73
+ rect: BlockRect;
74
+ }
75
+ interface ClickMessage {
76
+ type: "cmssy:click";
77
+ blockId: string;
78
+ rect: BlockRect;
79
+ layoutPosition?: string;
80
+ }
81
+ interface MoveMessage {
82
+ type: "cmssy:move";
83
+ protocolVersion: number;
84
+ blockId: string;
85
+ index: number;
86
+ }
87
+ interface DragIndexMessage {
88
+ type: "cmssy:drag-index";
89
+ protocolVersion: number;
90
+ index: number;
91
+ }
92
+ type AppToEditorMessage = ReadyMessage | BoundsMessage | ClickMessage | MoveMessage | DragIndexMessage;
93
+ interface SelectMessage {
94
+ type: "cmssy:select";
95
+ protocolVersion: number;
96
+ blockId: string;
97
+ }
98
+ interface PatchMessage {
99
+ type: "cmssy:patch";
100
+ protocolVersion: number;
101
+ blockId: string;
102
+ content: Record<string, unknown>;
103
+ style?: Record<string, unknown>;
104
+ advanced?: Record<string, unknown>;
105
+ layoutPosition?: string;
106
+ }
107
+ interface ParentReadyMessage {
108
+ type: "cmssy:parent-ready";
109
+ protocolVersion: number;
110
+ }
111
+ interface InsertMessage {
112
+ type: "cmssy:insert";
113
+ protocolVersion: number;
114
+ blockId: string;
115
+ blockType: string;
116
+ content: Record<string, unknown>;
117
+ style?: Record<string, unknown>;
118
+ advanced?: Record<string, unknown>;
119
+ index: number;
120
+ }
121
+ interface ReorderMessage {
122
+ type: "cmssy:reorder";
123
+ protocolVersion: number;
124
+ blockIds: string[];
125
+ }
126
+ interface RemoveMessage {
127
+ type: "cmssy:remove";
128
+ protocolVersion: number;
129
+ blockId: string;
130
+ }
131
+ interface DragOverMessage {
132
+ type: "cmssy:drag-over";
133
+ protocolVersion: number;
134
+ y: number;
135
+ }
136
+ interface DragEndMessage {
137
+ type: "cmssy:drag-end";
138
+ protocolVersion: number;
139
+ }
140
+ type EditorToAppMessage = SelectMessage | PatchMessage | ParentReadyMessage | InsertMessage | ReorderMessage | RemoveMessage | DragOverMessage | DragEndMessage;
141
+ declare function isProtocolCompatible(version: number): boolean;
142
+
10
143
  declare const fields: {
11
144
  text: (opts?: FieldControl) => FieldDefinition;
12
145
  textarea: (opts?: FieldControl) => FieldDefinition;
@@ -107,10 +240,6 @@ declare function createCmssyClient(input: CmssyClientConfig): CmssyClient;
107
240
  declare function collectFormIds(blocks: RawBlock[], locale: string, defaultLocale: string): string[];
108
241
  declare function resolveForms(config: CmssyClientConfig, blocks: RawBlock[], locale: string, defaultLocale: string, options?: QueryScopedOptions): Promise<Record<string, CmssyFormDefinition>>;
109
242
 
110
- interface CmssySiteLocales {
111
- defaultLocale: string;
112
- locales: string[];
113
- }
114
243
  declare function resolveSiteLocales(config: CmssyClientConfig, options?: GraphqlRequestOptions): Promise<CmssySiteLocales>;
115
244
  declare function splitLocaleFromPath(path: string[] | undefined, siteLocales: CmssySiteLocales): {
116
245
  locale: string;
@@ -153,4 +282,4 @@ interface UnknownBlockProps {
153
282
  }
154
283
  declare function UnknownBlock({ type }: UnknownBlockProps): react_jsx_runtime.JSX.Element;
155
284
 
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 };
285
+ export { type AppToEditorMessage, BlockDefinition, BlockMap, type BoundsMessage, type ClickMessage, CmssyBlock, type CmssyBlockProps, type CmssyClient, 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, 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 };