@cmssy/react 2.5.0 → 2.6.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,7 +1,7 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
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';
2
+ import { BlockSchema, BlockMeta, CmssyPageData, CmssyFormDefinition, CmssyLayoutGroup, CmssyLocaleContext, CmssyAuthUser, CmssyAuthActionResult, CmssyCart, CmssyAddToCartOptions, CmssyCheckoutInput, CmssyOrder, CmssyProduct, UseCmssyOrderOptions, UseCmssyOrdersOptions } from '@cmssy/types';
3
+ export { CmssyAddToCartOptions, CmssyAuthActionResult, CmssyAuthUser, CmssyCart, CmssyCartDiscount, CmssyCartItem, CmssyCartItemSnapshot, CmssyCheckoutInput, CmssyOrder, CmssyOrderItem, CmssyProduct, CmssyProductVariant, UseCmssyOrderOptions, UseCmssyOrdersOptions } from '@cmssy/types';
4
+ import { B as BlockDefinition } from './registry-DBPEDxug.cjs';
5
5
  import { ReactNode } from 'react';
6
6
 
7
7
  interface EditBridgeConfig {
@@ -99,14 +99,6 @@ declare function CmssyLocaleProvider({ value, children, }: CmssyLocaleProviderPr
99
99
  /** Reads the active locale; returns null when no provider is mounted. */
100
100
  declare function useCmssyLocale(): CmssyLocaleContext | null;
101
101
 
102
- interface CmssyAuthUser {
103
- recordId: string;
104
- email: string;
105
- }
106
- interface CmssyAuthActionResult {
107
- ok: boolean;
108
- message?: string;
109
- }
110
102
  interface CmssyAuthState {
111
103
  user: CmssyAuthUser | null;
112
104
  loading: boolean;
@@ -123,16 +115,6 @@ interface CmssyAuthProviderProps {
123
115
  declare function CmssyAuthProvider({ children, basePath, initialUser, }: CmssyAuthProviderProps): react_jsx_runtime.JSX.Element;
124
116
  declare function useCmssyUser(): CmssyAuthState;
125
117
 
126
- interface CmssyAddToCartOptions {
127
- variantSelections?: Record<string, string>;
128
- notes?: string;
129
- }
130
- interface CmssyCheckoutInput {
131
- customerEmail: string;
132
- poNumber?: string | null;
133
- customerNote?: string | null;
134
- shippingAddress?: CmssyAddress | null;
135
- }
136
118
  interface CmssyCommerceState {
137
119
  cart: CmssyCart | null;
138
120
  loading: boolean;
@@ -170,11 +152,6 @@ interface CmssyOrdersState {
170
152
  error: string | null;
171
153
  refresh(): Promise<void>;
172
154
  }
173
- interface UseCmssyOrdersOptions {
174
- basePath?: string;
175
- skip?: number;
176
- limit?: number;
177
- }
178
155
  declare function useCmssyOrders(options?: UseCmssyOrdersOptions): CmssyOrdersState;
179
156
  interface CmssyOrderState {
180
157
  order: CmssyOrder | null;
@@ -182,9 +159,6 @@ interface CmssyOrderState {
182
159
  error: string | null;
183
160
  refresh(): Promise<void>;
184
161
  }
185
- interface UseCmssyOrderOptions {
186
- basePath?: string;
187
- }
188
162
  declare function useCmssyOrder(id: string | null | undefined, options?: UseCmssyOrderOptions): CmssyOrderState;
189
163
 
190
164
  declare function fractionDigits(currency: string): number;
@@ -192,4 +166,4 @@ declare function fromMinorUnits(minor: number, currency: string): number;
192
166
  declare function toMinorUnits(amount: number, currency: string): number;
193
167
  declare function formatPrice(minor: number, currency: string | null | undefined): string;
194
168
 
195
- export { type CmssyAddToCartOptions, type CmssyAuthActionResult, CmssyAuthProvider, type CmssyAuthProviderProps, type CmssyAuthState, type CmssyAuthUser, CmssyCart, type CmssyCheckoutInput, CmssyCommerceProvider, type CmssyCommerceProviderProps, type CmssyCommerceState, CmssyEditableLayout, type CmssyEditableLayoutProps, CmssyEditablePage, type CmssyEditablePageProps, CmssyLazyEditor, type CmssyLazyEditorProps, CmssyLazyLayout, type CmssyLazyLayoutProps, CmssyLocaleProvider, type CmssyLocaleProviderProps, CmssyOrder, type CmssyOrderState, type CmssyOrdersState, CmssyProduct, type EditBridgeConfig, type EditBridgeState, type PatchMap, type UseCmssyOrderOptions, type UseCmssyOrdersOptions, cartBlock, checkoutBlock, formatPrice, fractionDigits, fromMinorUnits, productBlock, toMinorUnits, useCart, useCmssyLocale, useCmssyOrder, useCmssyOrders, useCmssyUser, useEditBridge };
169
+ export { CmssyAuthProvider, type CmssyAuthProviderProps, type CmssyAuthState, CmssyCommerceProvider, type CmssyCommerceProviderProps, type CmssyCommerceState, CmssyEditableLayout, type CmssyEditableLayoutProps, CmssyEditablePage, type CmssyEditablePageProps, CmssyLazyEditor, type CmssyLazyEditorProps, CmssyLazyLayout, type CmssyLazyLayoutProps, CmssyLocaleProvider, type CmssyLocaleProviderProps, type CmssyOrderState, type CmssyOrdersState, type EditBridgeConfig, type EditBridgeState, type PatchMap, cartBlock, checkoutBlock, formatPrice, fractionDigits, fromMinorUnits, productBlock, toMinorUnits, useCart, useCmssyLocale, useCmssyOrder, useCmssyOrders, useCmssyUser, useEditBridge };
package/dist/client.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
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';
2
+ import { BlockSchema, BlockMeta, CmssyPageData, CmssyFormDefinition, CmssyLayoutGroup, CmssyLocaleContext, CmssyAuthUser, CmssyAuthActionResult, CmssyCart, CmssyAddToCartOptions, CmssyCheckoutInput, CmssyOrder, CmssyProduct, UseCmssyOrderOptions, UseCmssyOrdersOptions } from '@cmssy/types';
3
+ export { CmssyAddToCartOptions, CmssyAuthActionResult, CmssyAuthUser, CmssyCart, CmssyCartDiscount, CmssyCartItem, CmssyCartItemSnapshot, CmssyCheckoutInput, CmssyOrder, CmssyOrderItem, CmssyProduct, CmssyProductVariant, UseCmssyOrderOptions, UseCmssyOrdersOptions } from '@cmssy/types';
4
+ import { B as BlockDefinition } from './registry-DBPEDxug.js';
5
5
  import { ReactNode } from 'react';
6
6
 
7
7
  interface EditBridgeConfig {
@@ -99,14 +99,6 @@ declare function CmssyLocaleProvider({ value, children, }: CmssyLocaleProviderPr
99
99
  /** Reads the active locale; returns null when no provider is mounted. */
100
100
  declare function useCmssyLocale(): CmssyLocaleContext | null;
101
101
 
102
- interface CmssyAuthUser {
103
- recordId: string;
104
- email: string;
105
- }
106
- interface CmssyAuthActionResult {
107
- ok: boolean;
108
- message?: string;
109
- }
110
102
  interface CmssyAuthState {
111
103
  user: CmssyAuthUser | null;
112
104
  loading: boolean;
@@ -123,16 +115,6 @@ interface CmssyAuthProviderProps {
123
115
  declare function CmssyAuthProvider({ children, basePath, initialUser, }: CmssyAuthProviderProps): react_jsx_runtime.JSX.Element;
124
116
  declare function useCmssyUser(): CmssyAuthState;
125
117
 
126
- interface CmssyAddToCartOptions {
127
- variantSelections?: Record<string, string>;
128
- notes?: string;
129
- }
130
- interface CmssyCheckoutInput {
131
- customerEmail: string;
132
- poNumber?: string | null;
133
- customerNote?: string | null;
134
- shippingAddress?: CmssyAddress | null;
135
- }
136
118
  interface CmssyCommerceState {
137
119
  cart: CmssyCart | null;
138
120
  loading: boolean;
@@ -170,11 +152,6 @@ interface CmssyOrdersState {
170
152
  error: string | null;
171
153
  refresh(): Promise<void>;
172
154
  }
173
- interface UseCmssyOrdersOptions {
174
- basePath?: string;
175
- skip?: number;
176
- limit?: number;
177
- }
178
155
  declare function useCmssyOrders(options?: UseCmssyOrdersOptions): CmssyOrdersState;
179
156
  interface CmssyOrderState {
180
157
  order: CmssyOrder | null;
@@ -182,9 +159,6 @@ interface CmssyOrderState {
182
159
  error: string | null;
183
160
  refresh(): Promise<void>;
184
161
  }
185
- interface UseCmssyOrderOptions {
186
- basePath?: string;
187
- }
188
162
  declare function useCmssyOrder(id: string | null | undefined, options?: UseCmssyOrderOptions): CmssyOrderState;
189
163
 
190
164
  declare function fractionDigits(currency: string): number;
@@ -192,4 +166,4 @@ declare function fromMinorUnits(minor: number, currency: string): number;
192
166
  declare function toMinorUnits(amount: number, currency: string): number;
193
167
  declare function formatPrice(minor: number, currency: string | null | undefined): string;
194
168
 
195
- export { type CmssyAddToCartOptions, type CmssyAuthActionResult, CmssyAuthProvider, type CmssyAuthProviderProps, type CmssyAuthState, type CmssyAuthUser, CmssyCart, type CmssyCheckoutInput, CmssyCommerceProvider, type CmssyCommerceProviderProps, type CmssyCommerceState, CmssyEditableLayout, type CmssyEditableLayoutProps, CmssyEditablePage, type CmssyEditablePageProps, CmssyLazyEditor, type CmssyLazyEditorProps, CmssyLazyLayout, type CmssyLazyLayoutProps, CmssyLocaleProvider, type CmssyLocaleProviderProps, CmssyOrder, type CmssyOrderState, type CmssyOrdersState, CmssyProduct, type EditBridgeConfig, type EditBridgeState, type PatchMap, type UseCmssyOrderOptions, type UseCmssyOrdersOptions, cartBlock, checkoutBlock, formatPrice, fractionDigits, fromMinorUnits, productBlock, toMinorUnits, useCart, useCmssyLocale, useCmssyOrder, useCmssyOrders, useCmssyUser, useEditBridge };
169
+ export { CmssyAuthProvider, type CmssyAuthProviderProps, type CmssyAuthState, CmssyCommerceProvider, type CmssyCommerceProviderProps, type CmssyCommerceState, CmssyEditableLayout, type CmssyEditableLayoutProps, CmssyEditablePage, type CmssyEditablePageProps, CmssyLazyEditor, type CmssyLazyEditorProps, CmssyLazyLayout, type CmssyLazyLayoutProps, CmssyLocaleProvider, type CmssyLocaleProviderProps, type CmssyOrderState, type CmssyOrdersState, type EditBridgeConfig, type EditBridgeState, type PatchMap, cartBlock, checkoutBlock, formatPrice, fractionDigits, fromMinorUnits, productBlock, toMinorUnits, useCart, useCmssyLocale, useCmssyOrder, useCmssyOrders, useCmssyUser, useEditBridge };
package/dist/index.d.cts CHANGED
@@ -1,7 +1,7 @@
1
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';
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';
5
5
  import * as react_jsx_runtime from 'react/jsx-runtime';
6
6
  import 'react';
7
7
 
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
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.js';
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.js';
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';
5
5
  import * as react_jsx_runtime from 'react/jsx-runtime';
6
6
  import 'react';
7
7
 
@@ -0,0 +1,72 @@
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
+ export { type BlockDefinition as B, type BlockMap as a, blocksToMeta as b, blocksToSchemas as c, buildBlockMap as d, defineBlock as e };
@@ -0,0 +1,72 @@
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
+ export { type BlockDefinition as B, type BlockMap as a, blocksToMeta as b, blocksToSchemas as c, buildBlockMap as d, defineBlock as e };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cmssy/react",
3
- "version": "2.5.0",
3
+ "version": "2.6.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.25.0"
59
+ "@cmssy/types": "0.26.0"
60
60
  },
61
61
  "scripts": {
62
62
  "build": "tsup",
@@ -1,223 +0,0 @@
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 };
@@ -1,223 +0,0 @@
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 };