@cmssy/react 0.18.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -39,7 +39,10 @@ the CMS at runtime.
39
39
  ```tsx
40
40
  import { fetchPage, CmssyServerPage } from "@cmssy/react";
41
41
 
42
- const page = await fetchPage({ org: "acme-org", workspaceSlug: "acme" }, pathSegments);
42
+ const page = await fetchPage(
43
+ { org: "acme-org", workspaceSlug: "acme" },
44
+ pathSegments,
45
+ );
43
46
 
44
47
  return <CmssyServerPage page={page} blocks={blocks} locale="en" />;
45
48
  ```
@@ -62,7 +65,11 @@ const cmssy = createCmssyClient({ org: "acme-org", workspaceSlug: "acme" });
62
65
  await cmssy.query(MY_QUERY, vars);
63
66
 
64
67
  // workspace-scoped (auto x-workspace-id header + $workspaceId var)
65
- const { publicModelRecords } = await cmssy.queryScoped(MODEL_RECORDS_QUERY, {
68
+ const {
69
+ public: {
70
+ model: { records },
71
+ },
72
+ } = await cmssy.queryScoped(MODEL_RECORDS_QUERY, {
66
73
  modelSlug: "posts",
67
74
  });
68
75
  ```
package/dist/client.cjs CHANGED
@@ -1023,13 +1023,18 @@ function CmssyCommerceProvider({
1023
1023
  () => runCart("remove-discount", {}),
1024
1024
  [runCart]
1025
1025
  );
1026
+ const setShippingMethod = react.useCallback(
1027
+ (shippingMethodId) => runCart("set-shipping", { shippingMethodId }),
1028
+ [runCart]
1029
+ );
1030
+ const merge = react.useCallback(() => runCart("merge", {}), [runCart]);
1026
1031
  const checkout = react.useCallback(
1027
- async (customerEmail) => {
1032
+ async (input) => {
1028
1033
  const gen = ++generation.current;
1029
1034
  setError(null);
1030
1035
  try {
1031
1036
  const data = await post("checkout", {
1032
- customerEmail
1037
+ ...input
1033
1038
  });
1034
1039
  if (gen === generation.current) setCart(null);
1035
1040
  return data.order;
@@ -1063,6 +1068,8 @@ function CmssyCommerceProvider({
1063
1068
  clearCart,
1064
1069
  applyDiscount,
1065
1070
  removeDiscount,
1071
+ setShippingMethod,
1072
+ merge,
1066
1073
  checkout,
1067
1074
  refresh,
1068
1075
  fetchProduct
@@ -1077,6 +1084,8 @@ function CmssyCommerceProvider({
1077
1084
  clearCart,
1078
1085
  applyDiscount,
1079
1086
  removeDiscount,
1087
+ setShippingMethod,
1088
+ merge,
1080
1089
  checkout,
1081
1090
  refresh,
1082
1091
  fetchProduct
@@ -1457,7 +1466,7 @@ function CheckoutComponent({ content }) {
1457
1466
  setBusy(true);
1458
1467
  setError(null);
1459
1468
  try {
1460
- setOrder(await checkout(email.trim()));
1469
+ setOrder(await checkout({ customerEmail: email.trim() }));
1461
1470
  } catch (err) {
1462
1471
  setError(err instanceof Error ? err.message : "Checkout failed");
1463
1472
  } finally {
@@ -1558,6 +1567,46 @@ function useCmssyOrders(options = {}) {
1558
1567
  }, [load]);
1559
1568
  return { orders, total, hasMore, loading, error, refresh: load };
1560
1569
  }
1570
+ function useCmssyOrder(id, options = {}) {
1571
+ const base = (options.basePath ?? "/api/cmssy/orders").replace(/\/+$/, "");
1572
+ const [order, setOrder] = react.useState(null);
1573
+ const [loading, setLoading] = react.useState(Boolean(id));
1574
+ const [error, setError] = react.useState(null);
1575
+ const load = react.useCallback(async () => {
1576
+ if (!id) {
1577
+ setOrder(null);
1578
+ setLoading(false);
1579
+ return;
1580
+ }
1581
+ setLoading(true);
1582
+ setError(null);
1583
+ try {
1584
+ const qs = new URLSearchParams({ id });
1585
+ const res = await fetch(`${base}?${qs.toString()}`, {
1586
+ credentials: "same-origin",
1587
+ cache: "no-store"
1588
+ });
1589
+ if (res.status === 401) {
1590
+ setOrder(null);
1591
+ return;
1592
+ }
1593
+ if (!res.ok) {
1594
+ const body = await res.json().catch(() => ({}));
1595
+ throw new Error(body.message ?? `Order request failed (${res.status})`);
1596
+ }
1597
+ const data = await res.json();
1598
+ setOrder(data.order ?? null);
1599
+ } catch (e) {
1600
+ setError(e instanceof Error ? e.message : "Could not load the order");
1601
+ } finally {
1602
+ setLoading(false);
1603
+ }
1604
+ }, [base, id]);
1605
+ react.useEffect(() => {
1606
+ void load();
1607
+ }, [load]);
1608
+ return { order, loading, error, refresh: load };
1609
+ }
1561
1610
 
1562
1611
  exports.CmssyAuthProvider = CmssyAuthProvider;
1563
1612
  exports.CmssyCommerceProvider = CmssyCommerceProvider;
@@ -1575,6 +1624,7 @@ exports.productBlock = productBlock;
1575
1624
  exports.toMinorUnits = toMinorUnits;
1576
1625
  exports.useCart = useCart;
1577
1626
  exports.useCmssyLocale = useCmssyLocale;
1627
+ exports.useCmssyOrder = useCmssyOrder;
1578
1628
  exports.useCmssyOrders = useCmssyOrders;
1579
1629
  exports.useCmssyUser = useCmssyUser;
1580
1630
  exports.useEditBridge = useEditBridge;
package/dist/client.d.cts CHANGED
@@ -1,6 +1,6 @@
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 CmssyCart, g as CmssyOrder, h as CmssyProduct } from './commerce-queries-CxUeiT52.cjs';
3
- export { i as CmssyCartDiscount, j as CmssyCartItem, k as CmssyCartItemSnapshot, l as CmssyOrderItem, m as CmssyProductVariant } from './commerce-queries-CxUeiT52.cjs';
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-fR6ZKQ3r.cjs';
3
+ export { j as CmssyCartDiscount, k as CmssyCartItem, l as CmssyCartItemSnapshot, m as CmssyOrderItem, n as CmssyProductVariant } from './commerce-queries-fR6ZKQ3r.cjs';
4
4
  import { ReactNode } from 'react';
5
5
  import '@cmssy/types';
6
6
 
@@ -127,6 +127,12 @@ interface CmssyAddToCartOptions {
127
127
  variantSelections?: Record<string, string>;
128
128
  notes?: string;
129
129
  }
130
+ interface CmssyCheckoutInput {
131
+ customerEmail: string;
132
+ poNumber?: string | null;
133
+ customerNote?: string | null;
134
+ shippingAddress?: CmssyAddress | null;
135
+ }
130
136
  interface CmssyCommerceState {
131
137
  cart: CmssyCart | null;
132
138
  loading: boolean;
@@ -137,7 +143,9 @@ interface CmssyCommerceState {
137
143
  clearCart(): Promise<void>;
138
144
  applyDiscount(code: string): Promise<void>;
139
145
  removeDiscount(): Promise<void>;
140
- checkout(customerEmail: string): Promise<CmssyOrder>;
146
+ setShippingMethod(shippingMethodId: string | null): Promise<void>;
147
+ merge(): Promise<void>;
148
+ checkout(input: CmssyCheckoutInput): Promise<CmssyOrder>;
141
149
  refresh(): Promise<void>;
142
150
  fetchProduct(modelSlug: string, filter: Record<string, unknown>): Promise<CmssyProduct | null>;
143
151
  }
@@ -168,10 +176,20 @@ interface UseCmssyOrdersOptions {
168
176
  limit?: number;
169
177
  }
170
178
  declare function useCmssyOrders(options?: UseCmssyOrdersOptions): CmssyOrdersState;
179
+ interface CmssyOrderState {
180
+ order: CmssyOrder | null;
181
+ loading: boolean;
182
+ error: string | null;
183
+ refresh(): Promise<void>;
184
+ }
185
+ interface UseCmssyOrderOptions {
186
+ basePath?: string;
187
+ }
188
+ declare function useCmssyOrder(id: string | null | undefined, options?: UseCmssyOrderOptions): CmssyOrderState;
171
189
 
172
190
  declare function fractionDigits(currency: string): number;
173
191
  declare function fromMinorUnits(minor: number, currency: string): number;
174
192
  declare function toMinorUnits(amount: number, currency: string): number;
175
193
  declare function formatPrice(minor: number, currency: string | null | undefined): string;
176
194
 
177
- export { type CmssyAddToCartOptions, type CmssyAuthActionResult, CmssyAuthProvider, type CmssyAuthProviderProps, type CmssyAuthState, type CmssyAuthUser, CmssyCart, CmssyCommerceProvider, type CmssyCommerceProviderProps, type CmssyCommerceState, CmssyEditableLayout, type CmssyEditableLayoutProps, CmssyEditablePage, type CmssyEditablePageProps, CmssyLazyEditor, type CmssyLazyEditorProps, CmssyLazyLayout, type CmssyLazyLayoutProps, CmssyLocaleProvider, type CmssyLocaleProviderProps, CmssyOrder, type CmssyOrdersState, CmssyProduct, type EditBridgeConfig, type EditBridgeState, type PatchMap, type UseCmssyOrdersOptions, cartBlock, checkoutBlock, formatPrice, fractionDigits, fromMinorUnits, productBlock, toMinorUnits, useCart, useCmssyLocale, useCmssyOrders, useCmssyUser, useEditBridge };
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 };
package/dist/client.d.ts CHANGED
@@ -1,6 +1,6 @@
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 CmssyCart, g as CmssyOrder, h as CmssyProduct } from './commerce-queries-CxUeiT52.js';
3
- export { i as CmssyCartDiscount, j as CmssyCartItem, k as CmssyCartItemSnapshot, l as CmssyOrderItem, m as CmssyProductVariant } from './commerce-queries-CxUeiT52.js';
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-fR6ZKQ3r.js';
3
+ export { j as CmssyCartDiscount, k as CmssyCartItem, l as CmssyCartItemSnapshot, m as CmssyOrderItem, n as CmssyProductVariant } from './commerce-queries-fR6ZKQ3r.js';
4
4
  import { ReactNode } from 'react';
5
5
  import '@cmssy/types';
6
6
 
@@ -127,6 +127,12 @@ interface CmssyAddToCartOptions {
127
127
  variantSelections?: Record<string, string>;
128
128
  notes?: string;
129
129
  }
130
+ interface CmssyCheckoutInput {
131
+ customerEmail: string;
132
+ poNumber?: string | null;
133
+ customerNote?: string | null;
134
+ shippingAddress?: CmssyAddress | null;
135
+ }
130
136
  interface CmssyCommerceState {
131
137
  cart: CmssyCart | null;
132
138
  loading: boolean;
@@ -137,7 +143,9 @@ interface CmssyCommerceState {
137
143
  clearCart(): Promise<void>;
138
144
  applyDiscount(code: string): Promise<void>;
139
145
  removeDiscount(): Promise<void>;
140
- checkout(customerEmail: string): Promise<CmssyOrder>;
146
+ setShippingMethod(shippingMethodId: string | null): Promise<void>;
147
+ merge(): Promise<void>;
148
+ checkout(input: CmssyCheckoutInput): Promise<CmssyOrder>;
141
149
  refresh(): Promise<void>;
142
150
  fetchProduct(modelSlug: string, filter: Record<string, unknown>): Promise<CmssyProduct | null>;
143
151
  }
@@ -168,10 +176,20 @@ interface UseCmssyOrdersOptions {
168
176
  limit?: number;
169
177
  }
170
178
  declare function useCmssyOrders(options?: UseCmssyOrdersOptions): CmssyOrdersState;
179
+ interface CmssyOrderState {
180
+ order: CmssyOrder | null;
181
+ loading: boolean;
182
+ error: string | null;
183
+ refresh(): Promise<void>;
184
+ }
185
+ interface UseCmssyOrderOptions {
186
+ basePath?: string;
187
+ }
188
+ declare function useCmssyOrder(id: string | null | undefined, options?: UseCmssyOrderOptions): CmssyOrderState;
171
189
 
172
190
  declare function fractionDigits(currency: string): number;
173
191
  declare function fromMinorUnits(minor: number, currency: string): number;
174
192
  declare function toMinorUnits(amount: number, currency: string): number;
175
193
  declare function formatPrice(minor: number, currency: string | null | undefined): string;
176
194
 
177
- export { type CmssyAddToCartOptions, type CmssyAuthActionResult, CmssyAuthProvider, type CmssyAuthProviderProps, type CmssyAuthState, type CmssyAuthUser, CmssyCart, CmssyCommerceProvider, type CmssyCommerceProviderProps, type CmssyCommerceState, CmssyEditableLayout, type CmssyEditableLayoutProps, CmssyEditablePage, type CmssyEditablePageProps, CmssyLazyEditor, type CmssyLazyEditorProps, CmssyLazyLayout, type CmssyLazyLayoutProps, CmssyLocaleProvider, type CmssyLocaleProviderProps, CmssyOrder, type CmssyOrdersState, CmssyProduct, type EditBridgeConfig, type EditBridgeState, type PatchMap, type UseCmssyOrdersOptions, cartBlock, checkoutBlock, formatPrice, fractionDigits, fromMinorUnits, productBlock, toMinorUnits, useCart, useCmssyLocale, useCmssyOrders, useCmssyUser, useEditBridge };
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 };
package/dist/client.js CHANGED
@@ -1021,13 +1021,18 @@ function CmssyCommerceProvider({
1021
1021
  () => runCart("remove-discount", {}),
1022
1022
  [runCart]
1023
1023
  );
1024
+ const setShippingMethod = useCallback(
1025
+ (shippingMethodId) => runCart("set-shipping", { shippingMethodId }),
1026
+ [runCart]
1027
+ );
1028
+ const merge = useCallback(() => runCart("merge", {}), [runCart]);
1024
1029
  const checkout = useCallback(
1025
- async (customerEmail) => {
1030
+ async (input) => {
1026
1031
  const gen = ++generation.current;
1027
1032
  setError(null);
1028
1033
  try {
1029
1034
  const data = await post("checkout", {
1030
- customerEmail
1035
+ ...input
1031
1036
  });
1032
1037
  if (gen === generation.current) setCart(null);
1033
1038
  return data.order;
@@ -1061,6 +1066,8 @@ function CmssyCommerceProvider({
1061
1066
  clearCart,
1062
1067
  applyDiscount,
1063
1068
  removeDiscount,
1069
+ setShippingMethod,
1070
+ merge,
1064
1071
  checkout,
1065
1072
  refresh,
1066
1073
  fetchProduct
@@ -1075,6 +1082,8 @@ function CmssyCommerceProvider({
1075
1082
  clearCart,
1076
1083
  applyDiscount,
1077
1084
  removeDiscount,
1085
+ setShippingMethod,
1086
+ merge,
1078
1087
  checkout,
1079
1088
  refresh,
1080
1089
  fetchProduct
@@ -1455,7 +1464,7 @@ function CheckoutComponent({ content }) {
1455
1464
  setBusy(true);
1456
1465
  setError(null);
1457
1466
  try {
1458
- setOrder(await checkout(email.trim()));
1467
+ setOrder(await checkout({ customerEmail: email.trim() }));
1459
1468
  } catch (err) {
1460
1469
  setError(err instanceof Error ? err.message : "Checkout failed");
1461
1470
  } finally {
@@ -1556,5 +1565,45 @@ function useCmssyOrders(options = {}) {
1556
1565
  }, [load]);
1557
1566
  return { orders, total, hasMore, loading, error, refresh: load };
1558
1567
  }
1568
+ function useCmssyOrder(id, options = {}) {
1569
+ const base = (options.basePath ?? "/api/cmssy/orders").replace(/\/+$/, "");
1570
+ const [order, setOrder] = useState(null);
1571
+ const [loading, setLoading] = useState(Boolean(id));
1572
+ const [error, setError] = useState(null);
1573
+ const load = useCallback(async () => {
1574
+ if (!id) {
1575
+ setOrder(null);
1576
+ setLoading(false);
1577
+ return;
1578
+ }
1579
+ setLoading(true);
1580
+ setError(null);
1581
+ try {
1582
+ const qs = new URLSearchParams({ id });
1583
+ const res = await fetch(`${base}?${qs.toString()}`, {
1584
+ credentials: "same-origin",
1585
+ cache: "no-store"
1586
+ });
1587
+ if (res.status === 401) {
1588
+ setOrder(null);
1589
+ return;
1590
+ }
1591
+ if (!res.ok) {
1592
+ const body = await res.json().catch(() => ({}));
1593
+ throw new Error(body.message ?? `Order request failed (${res.status})`);
1594
+ }
1595
+ const data = await res.json();
1596
+ setOrder(data.order ?? null);
1597
+ } catch (e) {
1598
+ setError(e instanceof Error ? e.message : "Could not load the order");
1599
+ } finally {
1600
+ setLoading(false);
1601
+ }
1602
+ }, [base, id]);
1603
+ useEffect(() => {
1604
+ void load();
1605
+ }, [load]);
1606
+ return { order, loading, error, refresh: load };
1607
+ }
1559
1608
 
1560
- export { CmssyAuthProvider, CmssyCommerceProvider, CmssyEditableLayout, CmssyEditablePage, CmssyLazyEditor, CmssyLazyLayout, CmssyLocaleProvider, cartBlock, checkoutBlock, formatPrice, fractionDigits, fromMinorUnits, productBlock, toMinorUnits, useCart, useCmssyLocale, useCmssyOrders, useCmssyUser, useEditBridge };
1609
+ export { CmssyAuthProvider, CmssyCommerceProvider, CmssyEditableLayout, CmssyEditablePage, CmssyLazyEditor, CmssyLazyLayout, CmssyLocaleProvider, cartBlock, checkoutBlock, formatPrice, fractionDigits, fromMinorUnits, productBlock, toMinorUnits, useCart, useCmssyLocale, useCmssyOrder, useCmssyOrders, useCmssyUser, useEditBridge };
@@ -131,8 +131,8 @@ interface CmssyRecordList {
131
131
  total: number;
132
132
  hasMore: boolean;
133
133
  }
134
- declare const MODEL_DEFINITIONS_QUERY = "query PublicModelDefinitions($workspaceId: String!) {\n publicModelDefinitions(workspaceId: $workspaceId) {\n id name slug description icon color displayField recordCount\n }\n}";
135
- declare const MODEL_RECORDS_QUERY = "query PublicModelRecords($workspaceId: String!, $modelSlug: String!, $filter: JSON, $sort: String, $limit: Int, $offset: Int, $populate: [String!]) {\n publicModelRecords(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}";
134
+ 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}";
135
+ 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}";
136
136
  interface CmssyFormField {
137
137
  id: string;
138
138
  name: string;
@@ -177,8 +177,8 @@ interface SubmitFormInput {
177
177
  data: Record<string, unknown>;
178
178
  website?: string;
179
179
  }
180
- declare const FORM_QUERY = "query PublicForm($formId: ID!) {\n publicForm(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}";
181
- declare const SUBMIT_FORM_MUTATION = "mutation SubmitForm($formId: ID!, $input: SubmitFormInput!) {\n submitForm(formId: $formId, input: $input) {\n success message submissionId redirectUrl accessToken customer\n }\n}";
180
+ 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}";
181
+ 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}";
182
182
 
183
183
  interface CmssyLocaleContext {
184
184
  current: string;
@@ -396,12 +396,17 @@ declare function blocksToMeta(blocks: BlockDefinition[], defaults?: {
396
396
  category?: string;
397
397
  }): Record<string, BlockMeta>;
398
398
 
399
+ interface CmssyPriceTier {
400
+ minQty: number;
401
+ price: number;
402
+ }
399
403
  interface CmssyCartItemSnapshot {
400
404
  name: string;
401
405
  price: number;
402
406
  currency: string;
403
407
  imageUrl: string | null;
404
408
  sku: string | null;
409
+ tiers: CmssyPriceTier[];
405
410
  }
406
411
  interface CmssyCartItem {
407
412
  id: string;
@@ -409,9 +414,35 @@ interface CmssyCartItem {
409
414
  quantity: number;
410
415
  variantSelections: Record<string, string> | null;
411
416
  snapshot: CmssyCartItemSnapshot;
417
+ unitPrice: number;
412
418
  currentPrice: number | null;
413
419
  priceMismatch: boolean;
414
420
  }
421
+ interface CmssyShippingMethod {
422
+ id: string;
423
+ label: string;
424
+ price: number;
425
+ etaLabel: string | null;
426
+ }
427
+ interface CmssyTaxSummaryLine {
428
+ rateId: string | null;
429
+ name: string | null;
430
+ rate: number;
431
+ base: number;
432
+ amount: number;
433
+ }
434
+ interface CmssyAddress {
435
+ name: string;
436
+ company?: string | null;
437
+ line1: string;
438
+ line2?: string | null;
439
+ postalCode: string;
440
+ city: string;
441
+ region?: string | null;
442
+ country: string;
443
+ phone?: string | null;
444
+ vatId?: string | null;
445
+ }
415
446
  interface CmssyCartDiscount {
416
447
  code: string;
417
448
  type: string;
@@ -427,6 +458,13 @@ interface CmssyCart {
427
458
  currency: string | null;
428
459
  appliedDiscount: CmssyCartDiscount | null;
429
460
  discountedTotal: number;
461
+ tax: number;
462
+ taxSummary: CmssyTaxSummaryLine[];
463
+ totalGross: number;
464
+ pricesIncludeTax: boolean;
465
+ shippingMethod: CmssyShippingMethod | null;
466
+ shippingTotal: number;
467
+ availableShippingMethods: CmssyShippingMethod[];
430
468
  }
431
469
  interface CmssyProductVariant {
432
470
  id: string;
@@ -437,15 +475,19 @@ interface CmssyProductVariant {
437
475
  name: string;
438
476
  value: string;
439
477
  }>;
478
+ tiers: CmssyPriceTier[];
440
479
  }
441
480
  interface CmssyProduct {
442
481
  id: string;
443
482
  data: Record<string, unknown>;
444
483
  variants: CmssyProductVariant[];
484
+ priceTiers: CmssyPriceTier[];
445
485
  }
446
486
  interface CmssyOrderItem {
447
487
  name: string;
448
488
  price: number;
489
+ listPrice?: number | null;
490
+ tierMinQty?: number | null;
449
491
  currency: string;
450
492
  quantity: number;
451
493
  sku: string | null;
@@ -456,13 +498,7 @@ interface CmssyOrderPayment {
456
498
  provider: string | null;
457
499
  at: string;
458
500
  }
459
- interface CmssyOrderTaxSummaryLine {
460
- rateId: string | null;
461
- name: string | null;
462
- rate: number;
463
- base: number;
464
- amount: number;
465
- }
501
+ type CmssyOrderTaxSummaryLine = CmssyTaxSummaryLine;
466
502
  interface CmssyOrder {
467
503
  id: string;
468
504
  status: string;
@@ -490,6 +526,17 @@ interface CmssyOrder {
490
526
  paidAt?: string | null;
491
527
  fulfilledAt?: string | null;
492
528
  createdAt?: string;
529
+ orderNumber?: number | null;
530
+ poNumber?: string | null;
531
+ customerNote?: string | null;
532
+ shippingAddress?: CmssyAddress | null;
533
+ shippingMethod?: {
534
+ id: string;
535
+ label: string;
536
+ price: number;
537
+ } | null;
538
+ shippingTotal?: number;
539
+ accessToken?: string | null;
493
540
  }
494
541
 
495
- export { SUBMIT_FORM_MUTATION as $, type AppToEditorMessage as A, type BlockSchema as B, type CmssyPageData as C, type CmssyFormField as D, type EditorToAppMessage as E, type FieldDefinition as F, type CmssyFormSettings as G, type CmssyFormSubmitResponse as H, type CmssyLocalizedValue as I, type CmssyModelDefinition as J, type CmssyModelRecord as K, type CmssyPageMeta as L, type CmssyPageSummary as M, type CmssyRecordList as N, DEFAULT_CMSSY_API_URL as O, FORM_QUERY as P, type FetchLikeResponse as Q, type RawBlock as R, type FetchPageOptions as S, MODEL_DEFINITIONS_QUERY as T, MODEL_RECORDS_QUERY as U, PROTOCOL_VERSION as V, type ParentReadyMessage as W, type PatchMessage as X, type RawLayoutBlock as Y, type ReadyMessage as Z, SITE_CONFIG_QUERY as _, type BlockMeta as a, type SelectMessage as a0, type SubmitFormInput as a1, blocksToMeta as a2, blocksToSchemas as a3, buildBlockContext as a4, buildBlockMap as a5, defineBlock as a6, fetchLayouts as a7, fetchPage as a8, fetchPageById as a9, fetchPageMeta as aa, fetchPages as ab, isProtocolCompatible as ac, normalizeSlug as ad, resolveApiUrl as ae, resolvePublicUrl as af, type BlockDefinition as b, type CmssyFormDefinition as c, type CmssyLayoutGroup as d, type CmssyLocaleContext as e, type CmssyCart as f, type CmssyOrder as g, type CmssyProduct as h, type CmssyCartDiscount as i, type CmssyCartItem as j, type CmssyCartItemSnapshot as k, type CmssyOrderItem as l, type CmssyProductVariant as m, type CmssyBlockAuthContext as n, type CmssyBlockWorkspace as o, type FetchLike as p, type CmssyClientConfig as q, type CmssySiteConfig as r, type BlockMap as s, type CmssyBlockContext as t, type BlockRect as u, type BoundsMessage as v, type BuildBlockContextExtra as w, type ClickMessage as x, type CmssyBlockMember as y, type CmssyBranding as z };
542
+ export { type ParentReadyMessage as $, type AppToEditorMessage as A, type BlockSchema as B, type CmssyPageData as C, type CmssyBranding as D, type EditorToAppMessage as E, type FieldDefinition as F, type CmssyFormField as G, type CmssyFormSettings as H, type CmssyFormSubmitResponse as I, type CmssyLocalizedValue as J, type CmssyModelDefinition as K, type CmssyModelRecord as L, type CmssyOrderTaxSummaryLine as M, type CmssyPageMeta as N, type CmssyPageSummary as O, type CmssyPriceTier as P, type CmssyRecordList as Q, type RawBlock as R, type CmssyShippingMethod as S, type CmssyTaxSummaryLine as T, DEFAULT_CMSSY_API_URL as U, FORM_QUERY as V, type FetchLikeResponse as W, type FetchPageOptions as X, MODEL_DEFINITIONS_QUERY as Y, MODEL_RECORDS_QUERY as Z, PROTOCOL_VERSION as _, type BlockMeta as a, type PatchMessage as a0, type RawLayoutBlock as a1, type ReadyMessage as a2, SITE_CONFIG_QUERY as a3, SUBMIT_FORM_MUTATION as a4, type SelectMessage as a5, type SubmitFormInput as a6, blocksToMeta as a7, blocksToSchemas as a8, buildBlockContext as a9, buildBlockMap as aa, defineBlock as ab, fetchLayouts as ac, fetchPage as ad, fetchPageById as ae, fetchPageMeta as af, fetchPages as ag, isProtocolCompatible as ah, normalizeSlug as ai, resolveApiUrl as aj, resolvePublicUrl as ak, type BlockDefinition as b, type CmssyFormDefinition as c, type CmssyLayoutGroup as d, type CmssyLocaleContext as e, type CmssyAddress as f, type CmssyCart as g, type CmssyOrder as h, type CmssyProduct as i, type CmssyCartDiscount as j, type CmssyCartItem as k, type CmssyCartItemSnapshot as l, type CmssyOrderItem as m, type CmssyProductVariant as n, type CmssyBlockAuthContext as o, type CmssyBlockWorkspace as p, type FetchLike as q, type CmssyClientConfig as r, type CmssySiteConfig as s, type BlockMap as t, type CmssyBlockContext as u, type BlockRect as v, type BoundsMessage as w, type BuildBlockContextExtra as x, type ClickMessage as y, type CmssyBlockMember as z };
@@ -131,8 +131,8 @@ interface CmssyRecordList {
131
131
  total: number;
132
132
  hasMore: boolean;
133
133
  }
134
- declare const MODEL_DEFINITIONS_QUERY = "query PublicModelDefinitions($workspaceId: String!) {\n publicModelDefinitions(workspaceId: $workspaceId) {\n id name slug description icon color displayField recordCount\n }\n}";
135
- declare const MODEL_RECORDS_QUERY = "query PublicModelRecords($workspaceId: String!, $modelSlug: String!, $filter: JSON, $sort: String, $limit: Int, $offset: Int, $populate: [String!]) {\n publicModelRecords(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}";
134
+ 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}";
135
+ 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}";
136
136
  interface CmssyFormField {
137
137
  id: string;
138
138
  name: string;
@@ -177,8 +177,8 @@ interface SubmitFormInput {
177
177
  data: Record<string, unknown>;
178
178
  website?: string;
179
179
  }
180
- declare const FORM_QUERY = "query PublicForm($formId: ID!) {\n publicForm(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}";
181
- declare const SUBMIT_FORM_MUTATION = "mutation SubmitForm($formId: ID!, $input: SubmitFormInput!) {\n submitForm(formId: $formId, input: $input) {\n success message submissionId redirectUrl accessToken customer\n }\n}";
180
+ 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}";
181
+ 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}";
182
182
 
183
183
  interface CmssyLocaleContext {
184
184
  current: string;
@@ -396,12 +396,17 @@ declare function blocksToMeta(blocks: BlockDefinition[], defaults?: {
396
396
  category?: string;
397
397
  }): Record<string, BlockMeta>;
398
398
 
399
+ interface CmssyPriceTier {
400
+ minQty: number;
401
+ price: number;
402
+ }
399
403
  interface CmssyCartItemSnapshot {
400
404
  name: string;
401
405
  price: number;
402
406
  currency: string;
403
407
  imageUrl: string | null;
404
408
  sku: string | null;
409
+ tiers: CmssyPriceTier[];
405
410
  }
406
411
  interface CmssyCartItem {
407
412
  id: string;
@@ -409,9 +414,35 @@ interface CmssyCartItem {
409
414
  quantity: number;
410
415
  variantSelections: Record<string, string> | null;
411
416
  snapshot: CmssyCartItemSnapshot;
417
+ unitPrice: number;
412
418
  currentPrice: number | null;
413
419
  priceMismatch: boolean;
414
420
  }
421
+ interface CmssyShippingMethod {
422
+ id: string;
423
+ label: string;
424
+ price: number;
425
+ etaLabel: string | null;
426
+ }
427
+ interface CmssyTaxSummaryLine {
428
+ rateId: string | null;
429
+ name: string | null;
430
+ rate: number;
431
+ base: number;
432
+ amount: number;
433
+ }
434
+ interface CmssyAddress {
435
+ name: string;
436
+ company?: string | null;
437
+ line1: string;
438
+ line2?: string | null;
439
+ postalCode: string;
440
+ city: string;
441
+ region?: string | null;
442
+ country: string;
443
+ phone?: string | null;
444
+ vatId?: string | null;
445
+ }
415
446
  interface CmssyCartDiscount {
416
447
  code: string;
417
448
  type: string;
@@ -427,6 +458,13 @@ interface CmssyCart {
427
458
  currency: string | null;
428
459
  appliedDiscount: CmssyCartDiscount | null;
429
460
  discountedTotal: number;
461
+ tax: number;
462
+ taxSummary: CmssyTaxSummaryLine[];
463
+ totalGross: number;
464
+ pricesIncludeTax: boolean;
465
+ shippingMethod: CmssyShippingMethod | null;
466
+ shippingTotal: number;
467
+ availableShippingMethods: CmssyShippingMethod[];
430
468
  }
431
469
  interface CmssyProductVariant {
432
470
  id: string;
@@ -437,15 +475,19 @@ interface CmssyProductVariant {
437
475
  name: string;
438
476
  value: string;
439
477
  }>;
478
+ tiers: CmssyPriceTier[];
440
479
  }
441
480
  interface CmssyProduct {
442
481
  id: string;
443
482
  data: Record<string, unknown>;
444
483
  variants: CmssyProductVariant[];
484
+ priceTiers: CmssyPriceTier[];
445
485
  }
446
486
  interface CmssyOrderItem {
447
487
  name: string;
448
488
  price: number;
489
+ listPrice?: number | null;
490
+ tierMinQty?: number | null;
449
491
  currency: string;
450
492
  quantity: number;
451
493
  sku: string | null;
@@ -456,13 +498,7 @@ interface CmssyOrderPayment {
456
498
  provider: string | null;
457
499
  at: string;
458
500
  }
459
- interface CmssyOrderTaxSummaryLine {
460
- rateId: string | null;
461
- name: string | null;
462
- rate: number;
463
- base: number;
464
- amount: number;
465
- }
501
+ type CmssyOrderTaxSummaryLine = CmssyTaxSummaryLine;
466
502
  interface CmssyOrder {
467
503
  id: string;
468
504
  status: string;
@@ -490,6 +526,17 @@ interface CmssyOrder {
490
526
  paidAt?: string | null;
491
527
  fulfilledAt?: string | null;
492
528
  createdAt?: string;
529
+ orderNumber?: number | null;
530
+ poNumber?: string | null;
531
+ customerNote?: string | null;
532
+ shippingAddress?: CmssyAddress | null;
533
+ shippingMethod?: {
534
+ id: string;
535
+ label: string;
536
+ price: number;
537
+ } | null;
538
+ shippingTotal?: number;
539
+ accessToken?: string | null;
493
540
  }
494
541
 
495
- export { SUBMIT_FORM_MUTATION as $, type AppToEditorMessage as A, type BlockSchema as B, type CmssyPageData as C, type CmssyFormField as D, type EditorToAppMessage as E, type FieldDefinition as F, type CmssyFormSettings as G, type CmssyFormSubmitResponse as H, type CmssyLocalizedValue as I, type CmssyModelDefinition as J, type CmssyModelRecord as K, type CmssyPageMeta as L, type CmssyPageSummary as M, type CmssyRecordList as N, DEFAULT_CMSSY_API_URL as O, FORM_QUERY as P, type FetchLikeResponse as Q, type RawBlock as R, type FetchPageOptions as S, MODEL_DEFINITIONS_QUERY as T, MODEL_RECORDS_QUERY as U, PROTOCOL_VERSION as V, type ParentReadyMessage as W, type PatchMessage as X, type RawLayoutBlock as Y, type ReadyMessage as Z, SITE_CONFIG_QUERY as _, type BlockMeta as a, type SelectMessage as a0, type SubmitFormInput as a1, blocksToMeta as a2, blocksToSchemas as a3, buildBlockContext as a4, buildBlockMap as a5, defineBlock as a6, fetchLayouts as a7, fetchPage as a8, fetchPageById as a9, fetchPageMeta as aa, fetchPages as ab, isProtocolCompatible as ac, normalizeSlug as ad, resolveApiUrl as ae, resolvePublicUrl as af, type BlockDefinition as b, type CmssyFormDefinition as c, type CmssyLayoutGroup as d, type CmssyLocaleContext as e, type CmssyCart as f, type CmssyOrder as g, type CmssyProduct as h, type CmssyCartDiscount as i, type CmssyCartItem as j, type CmssyCartItemSnapshot as k, type CmssyOrderItem as l, type CmssyProductVariant as m, type CmssyBlockAuthContext as n, type CmssyBlockWorkspace as o, type FetchLike as p, type CmssyClientConfig as q, type CmssySiteConfig as r, type BlockMap as s, type CmssyBlockContext as t, type BlockRect as u, type BoundsMessage as v, type BuildBlockContextExtra as w, type ClickMessage as x, type CmssyBlockMember as y, type CmssyBranding as z };
542
+ export { type ParentReadyMessage as $, type AppToEditorMessage as A, type BlockSchema as B, type CmssyPageData as C, type CmssyBranding as D, type EditorToAppMessage as E, type FieldDefinition as F, type CmssyFormField as G, type CmssyFormSettings as H, type CmssyFormSubmitResponse as I, type CmssyLocalizedValue as J, type CmssyModelDefinition as K, type CmssyModelRecord as L, type CmssyOrderTaxSummaryLine as M, type CmssyPageMeta as N, type CmssyPageSummary as O, type CmssyPriceTier as P, type CmssyRecordList as Q, type RawBlock as R, type CmssyShippingMethod as S, type CmssyTaxSummaryLine as T, DEFAULT_CMSSY_API_URL as U, FORM_QUERY as V, type FetchLikeResponse as W, type FetchPageOptions as X, MODEL_DEFINITIONS_QUERY as Y, MODEL_RECORDS_QUERY as Z, PROTOCOL_VERSION as _, type BlockMeta as a, type PatchMessage as a0, type RawLayoutBlock as a1, type ReadyMessage as a2, SITE_CONFIG_QUERY as a3, SUBMIT_FORM_MUTATION as a4, type SelectMessage as a5, type SubmitFormInput as a6, blocksToMeta as a7, blocksToSchemas as a8, buildBlockContext as a9, buildBlockMap as aa, defineBlock as ab, fetchLayouts as ac, fetchPage as ad, fetchPageById as ae, fetchPageMeta as af, fetchPages as ag, isProtocolCompatible as ah, normalizeSlug as ai, resolveApiUrl as aj, resolvePublicUrl as ak, type BlockDefinition as b, type CmssyFormDefinition as c, type CmssyLayoutGroup as d, type CmssyLocaleContext as e, type CmssyAddress as f, type CmssyCart as g, type CmssyOrder as h, type CmssyProduct as i, type CmssyCartDiscount as j, type CmssyCartItem as k, type CmssyCartItemSnapshot as l, type CmssyOrderItem as m, type CmssyProductVariant as n, type CmssyBlockAuthContext as o, type CmssyBlockWorkspace as p, type FetchLike as q, type CmssyClientConfig as r, type CmssySiteConfig as s, type BlockMap as t, type CmssyBlockContext as u, type BlockRect as v, type BoundsMessage as w, type BuildBlockContextExtra as x, type ClickMessage as y, type CmssyBlockMember as z };
package/dist/index.cjs CHANGED
@@ -678,38 +678,54 @@ var SITE_CONFIG_QUERY = `query PublicSiteConfig($workspaceSlug: String!) {
678
678
  }
679
679
  }`;
680
680
  var MODEL_DEFINITIONS_QUERY = `query PublicModelDefinitions($workspaceId: String!) {
681
- publicModelDefinitions(workspaceId: $workspaceId) {
682
- id name slug description icon color displayField recordCount
681
+ public {
682
+ model {
683
+ definitions(workspaceId: $workspaceId) {
684
+ id name slug description icon color displayField recordCount
685
+ }
686
+ }
683
687
  }
684
688
  }`;
685
689
  var MODEL_RECORDS_QUERY = `query PublicModelRecords($workspaceId: String!, $modelSlug: String!, $filter: JSON, $sort: String, $limit: Int, $offset: Int, $populate: [String!]) {
686
- publicModelRecords(workspaceId: $workspaceId, modelSlug: $modelSlug, filter: $filter, sort: $sort, limit: $limit, offset: $offset, populate: $populate) {
687
- items { id modelId data status createdAt updatedAt }
688
- total
689
- hasMore
690
+ public {
691
+ model {
692
+ records(workspaceId: $workspaceId, modelSlug: $modelSlug, filter: $filter, sort: $sort, limit: $limit, offset: $offset, populate: $populate) {
693
+ items { id modelId data status createdAt updatedAt }
694
+ total
695
+ hasMore
696
+ }
697
+ }
690
698
  }
691
699
  }`;
692
700
  var FORM_QUERY = `query PublicForm($formId: ID!) {
693
- publicForm(formId: $formId) {
694
- id
695
- name
696
- slug
697
- description
698
- fields {
699
- id name fieldType label placeholder helpText
700
- defaultValue width order showWhen requiredWhen
701
- options { value label disabled }
702
- validation { required minLength maxLength minValue maxValue pattern customMessage }
703
- }
704
- settings {
705
- actionType submitButtonLabel successMessage errorMessage
706
- redirectUrl requireLogin enableCaptcha
701
+ public {
702
+ form {
703
+ get(formId: $formId) {
704
+ id
705
+ name
706
+ slug
707
+ description
708
+ fields {
709
+ id name fieldType label placeholder helpText
710
+ defaultValue width order showWhen requiredWhen
711
+ options { value label disabled }
712
+ validation { required minLength maxLength minValue maxValue pattern customMessage }
713
+ }
714
+ settings {
715
+ actionType submitButtonLabel successMessage errorMessage
716
+ redirectUrl requireLogin enableCaptcha
717
+ }
718
+ }
707
719
  }
708
720
  }
709
721
  }`;
710
722
  var SUBMIT_FORM_MUTATION = `mutation SubmitForm($formId: ID!, $input: SubmitFormInput!) {
711
- submitForm(formId: $formId, input: $input) {
712
- success message submissionId redirectUrl accessToken customer
723
+ public {
724
+ form {
725
+ submit(formId: $formId, input: $input) {
726
+ success message submissionId redirectUrl accessToken customer
727
+ }
728
+ }
713
729
  }
714
730
  }`;
715
731
 
@@ -804,7 +820,7 @@ async function resolveForms(config, blocks, locale, defaultLocale, options) {
804
820
  ids.map(async (id) => {
805
821
  try {
806
822
  const data = await client.queryScoped(FORM_QUERY, { formId: id }, options);
807
- return [id, data.publicForm];
823
+ return [id, data.public.form.get];
808
824
  } catch (err) {
809
825
  if (typeof console !== "undefined") {
810
826
  console.warn(`[cmssy] failed to resolve form ${id}`, err);
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { F as FieldDefinition, C as CmssyPageData, b as BlockDefinition, c as CmssyFormDefinition, n as CmssyBlockAuthContext, o as CmssyBlockWorkspace, d as CmssyLayoutGroup, E as EditorToAppMessage, A as AppToEditorMessage, p as FetchLike, q as CmssyClientConfig, r as CmssySiteConfig, R as RawBlock, e as CmssyLocaleContext, s as BlockMap, t as CmssyBlockContext } from './commerce-queries-CxUeiT52.cjs';
2
- export { a as BlockMeta, u as BlockRect, B as BlockSchema, v as BoundsMessage, w as BuildBlockContextExtra, x as ClickMessage, y as CmssyBlockMember, z as CmssyBranding, f as CmssyCart, i as CmssyCartDiscount, j as CmssyCartItem, k as CmssyCartItemSnapshot, D as CmssyFormField, G as CmssyFormSettings, H as CmssyFormSubmitResponse, I as CmssyLocalizedValue, J as CmssyModelDefinition, K as CmssyModelRecord, g as CmssyOrder, L as CmssyPageMeta, M as CmssyPageSummary, h as CmssyProduct, m as CmssyProductVariant, N as CmssyRecordList, O as DEFAULT_CMSSY_API_URL, P as FORM_QUERY, Q as FetchLikeResponse, S as FetchPageOptions, T as MODEL_DEFINITIONS_QUERY, U as MODEL_RECORDS_QUERY, V as PROTOCOL_VERSION, W as ParentReadyMessage, X as PatchMessage, Y as RawLayoutBlock, Z as ReadyMessage, _ as SITE_CONFIG_QUERY, $ as SUBMIT_FORM_MUTATION, a0 as SelectMessage, a1 as SubmitFormInput, a2 as blocksToMeta, a3 as blocksToSchemas, a4 as buildBlockContext, a5 as buildBlockMap, a6 as defineBlock, a7 as fetchLayouts, a8 as fetchPage, a9 as fetchPageById, aa as fetchPageMeta, ab as fetchPages, ac as isProtocolCompatible, ad as normalizeSlug, ae as resolveApiUrl, af as resolvePublicUrl } from './commerce-queries-CxUeiT52.cjs';
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-fR6ZKQ3r.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 CmssyLocalizedValue, K as CmssyModelDefinition, L as CmssyModelRecord, h as CmssyOrder, m as CmssyOrderItem, M as CmssyOrderTaxSummaryLine, N as CmssyPageMeta, O as CmssyPageSummary, P as CmssyPriceTier, i as CmssyProduct, n as CmssyProductVariant, Q as CmssyRecordList, S as CmssyShippingMethod, T as CmssyTaxSummaryLine, U as DEFAULT_CMSSY_API_URL, V as FORM_QUERY, W as FetchLikeResponse, X as FetchPageOptions, Y as MODEL_DEFINITIONS_QUERY, Z as MODEL_RECORDS_QUERY, _ as PROTOCOL_VERSION, $ as ParentReadyMessage, a0 as PatchMessage, a1 as RawLayoutBlock, a2 as ReadyMessage, a3 as SITE_CONFIG_QUERY, a4 as SUBMIT_FORM_MUTATION, a5 as SelectMessage, a6 as SubmitFormInput, a7 as blocksToMeta, a8 as blocksToSchemas, a9 as buildBlockContext, aa as buildBlockMap, ab as defineBlock, ac as fetchLayouts, ad as fetchPage, ae as fetchPageById, af as fetchPageMeta, ag as fetchPages, ah as isProtocolCompatible, ai as normalizeSlug, aj as resolveApiUrl, ak as resolvePublicUrl } from './commerce-queries-fR6ZKQ3r.cjs';
3
3
  import * as react_jsx_runtime from 'react/jsx-runtime';
4
4
  export { FieldCondition, FieldConditionGroup, FieldConditionLogic, FieldType, evaluateFieldConditionGroup } from '@cmssy/types';
5
5
  import 'react';
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { F as FieldDefinition, C as CmssyPageData, b as BlockDefinition, c as CmssyFormDefinition, n as CmssyBlockAuthContext, o as CmssyBlockWorkspace, d as CmssyLayoutGroup, E as EditorToAppMessage, A as AppToEditorMessage, p as FetchLike, q as CmssyClientConfig, r as CmssySiteConfig, R as RawBlock, e as CmssyLocaleContext, s as BlockMap, t as CmssyBlockContext } from './commerce-queries-CxUeiT52.js';
2
- export { a as BlockMeta, u as BlockRect, B as BlockSchema, v as BoundsMessage, w as BuildBlockContextExtra, x as ClickMessage, y as CmssyBlockMember, z as CmssyBranding, f as CmssyCart, i as CmssyCartDiscount, j as CmssyCartItem, k as CmssyCartItemSnapshot, D as CmssyFormField, G as CmssyFormSettings, H as CmssyFormSubmitResponse, I as CmssyLocalizedValue, J as CmssyModelDefinition, K as CmssyModelRecord, g as CmssyOrder, L as CmssyPageMeta, M as CmssyPageSummary, h as CmssyProduct, m as CmssyProductVariant, N as CmssyRecordList, O as DEFAULT_CMSSY_API_URL, P as FORM_QUERY, Q as FetchLikeResponse, S as FetchPageOptions, T as MODEL_DEFINITIONS_QUERY, U as MODEL_RECORDS_QUERY, V as PROTOCOL_VERSION, W as ParentReadyMessage, X as PatchMessage, Y as RawLayoutBlock, Z as ReadyMessage, _ as SITE_CONFIG_QUERY, $ as SUBMIT_FORM_MUTATION, a0 as SelectMessage, a1 as SubmitFormInput, a2 as blocksToMeta, a3 as blocksToSchemas, a4 as buildBlockContext, a5 as buildBlockMap, a6 as defineBlock, a7 as fetchLayouts, a8 as fetchPage, a9 as fetchPageById, aa as fetchPageMeta, ab as fetchPages, ac as isProtocolCompatible, ad as normalizeSlug, ae as resolveApiUrl, af as resolvePublicUrl } from './commerce-queries-CxUeiT52.js';
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-fR6ZKQ3r.js';
2
+ export { a as BlockMeta, v as BlockRect, B as BlockSchema, w as BoundsMessage, x as BuildBlockContextExtra, y as ClickMessage, f as CmssyAddress, z as CmssyBlockMember, D as CmssyBranding, g as CmssyCart, j as CmssyCartDiscount, k as CmssyCartItem, l as CmssyCartItemSnapshot, G as CmssyFormField, H as CmssyFormSettings, I as CmssyFormSubmitResponse, J as CmssyLocalizedValue, K as CmssyModelDefinition, L as CmssyModelRecord, h as CmssyOrder, m as CmssyOrderItem, M as CmssyOrderTaxSummaryLine, N as CmssyPageMeta, O as CmssyPageSummary, P as CmssyPriceTier, i as CmssyProduct, n as CmssyProductVariant, Q as CmssyRecordList, S as CmssyShippingMethod, T as CmssyTaxSummaryLine, U as DEFAULT_CMSSY_API_URL, V as FORM_QUERY, W as FetchLikeResponse, X as FetchPageOptions, Y as MODEL_DEFINITIONS_QUERY, Z as MODEL_RECORDS_QUERY, _ as PROTOCOL_VERSION, $ as ParentReadyMessage, a0 as PatchMessage, a1 as RawLayoutBlock, a2 as ReadyMessage, a3 as SITE_CONFIG_QUERY, a4 as SUBMIT_FORM_MUTATION, a5 as SelectMessage, a6 as SubmitFormInput, a7 as blocksToMeta, a8 as blocksToSchemas, a9 as buildBlockContext, aa as buildBlockMap, ab as defineBlock, ac as fetchLayouts, ad as fetchPage, ae as fetchPageById, af as fetchPageMeta, ag as fetchPages, ah as isProtocolCompatible, ai as normalizeSlug, aj as resolveApiUrl, ak as resolvePublicUrl } from './commerce-queries-fR6ZKQ3r.js';
3
3
  import * as react_jsx_runtime from 'react/jsx-runtime';
4
4
  export { FieldCondition, FieldConditionGroup, FieldConditionLogic, FieldType, evaluateFieldConditionGroup } from '@cmssy/types';
5
5
  import 'react';
package/dist/index.js CHANGED
@@ -676,38 +676,54 @@ var SITE_CONFIG_QUERY = `query PublicSiteConfig($workspaceSlug: String!) {
676
676
  }
677
677
  }`;
678
678
  var MODEL_DEFINITIONS_QUERY = `query PublicModelDefinitions($workspaceId: String!) {
679
- publicModelDefinitions(workspaceId: $workspaceId) {
680
- id name slug description icon color displayField recordCount
679
+ public {
680
+ model {
681
+ definitions(workspaceId: $workspaceId) {
682
+ id name slug description icon color displayField recordCount
683
+ }
684
+ }
681
685
  }
682
686
  }`;
683
687
  var MODEL_RECORDS_QUERY = `query PublicModelRecords($workspaceId: String!, $modelSlug: String!, $filter: JSON, $sort: String, $limit: Int, $offset: Int, $populate: [String!]) {
684
- publicModelRecords(workspaceId: $workspaceId, modelSlug: $modelSlug, filter: $filter, sort: $sort, limit: $limit, offset: $offset, populate: $populate) {
685
- items { id modelId data status createdAt updatedAt }
686
- total
687
- hasMore
688
+ public {
689
+ model {
690
+ records(workspaceId: $workspaceId, modelSlug: $modelSlug, filter: $filter, sort: $sort, limit: $limit, offset: $offset, populate: $populate) {
691
+ items { id modelId data status createdAt updatedAt }
692
+ total
693
+ hasMore
694
+ }
695
+ }
688
696
  }
689
697
  }`;
690
698
  var FORM_QUERY = `query PublicForm($formId: ID!) {
691
- publicForm(formId: $formId) {
692
- id
693
- name
694
- slug
695
- description
696
- fields {
697
- id name fieldType label placeholder helpText
698
- defaultValue width order showWhen requiredWhen
699
- options { value label disabled }
700
- validation { required minLength maxLength minValue maxValue pattern customMessage }
701
- }
702
- settings {
703
- actionType submitButtonLabel successMessage errorMessage
704
- redirectUrl requireLogin enableCaptcha
699
+ public {
700
+ form {
701
+ get(formId: $formId) {
702
+ id
703
+ name
704
+ slug
705
+ description
706
+ fields {
707
+ id name fieldType label placeholder helpText
708
+ defaultValue width order showWhen requiredWhen
709
+ options { value label disabled }
710
+ validation { required minLength maxLength minValue maxValue pattern customMessage }
711
+ }
712
+ settings {
713
+ actionType submitButtonLabel successMessage errorMessage
714
+ redirectUrl requireLogin enableCaptcha
715
+ }
716
+ }
705
717
  }
706
718
  }
707
719
  }`;
708
720
  var SUBMIT_FORM_MUTATION = `mutation SubmitForm($formId: ID!, $input: SubmitFormInput!) {
709
- submitForm(formId: $formId, input: $input) {
710
- success message submissionId redirectUrl accessToken customer
721
+ public {
722
+ form {
723
+ submit(formId: $formId, input: $input) {
724
+ success message submissionId redirectUrl accessToken customer
725
+ }
726
+ }
711
727
  }
712
728
  }`;
713
729
 
@@ -802,7 +818,7 @@ async function resolveForms(config, blocks, locale, defaultLocale, options) {
802
818
  ids.map(async (id) => {
803
819
  try {
804
820
  const data = await client.queryScoped(FORM_QUERY, { formId: id }, options);
805
- return [id, data.publicForm];
821
+ return [id, data.public.form.get];
806
822
  } catch (err) {
807
823
  if (typeof console !== "undefined") {
808
824
  console.warn(`[cmssy] failed to resolve form ${id}`, err);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cmssy/react",
3
- "version": "0.18.0",
3
+ "version": "2.0.0",
4
4
  "description": "React blocks, renderers, data client and editor bridge for cmssy headless sites",
5
5
  "keywords": [
6
6
  "cmssy",