@cimplify/sdk 0.6.6 → 0.6.8
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 +19 -0
- package/dist/advanced.d.mts +2 -2
- package/dist/advanced.d.ts +2 -2
- package/dist/advanced.js +228 -101
- package/dist/advanced.mjs +228 -101
- package/dist/{client-CUFdFugo.d.mts → client-D4vA6FY_.d.ts} +40 -34
- package/dist/{client-CjqNbEM6.d.ts → client-FQUyv41r.d.mts} +40 -34
- package/dist/{index-CJ9GkIXf.d.mts → index-DaKJxoEh.d.mts} +13 -12
- package/dist/{index-B5Bj-Ikg.d.ts → index-pztT_bcJ.d.ts} +13 -12
- package/dist/index.d.mts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +315 -131
- package/dist/index.mjs +309 -132
- package/dist/{payment-D-u3asA8.d.mts → payment-Cu75tmUc.d.mts} +34 -8
- package/dist/{payment-D-u3asA8.d.ts → payment-Cu75tmUc.d.ts} +34 -8
- package/dist/react.d.mts +225 -4
- package/dist/react.d.ts +225 -4
- package/dist/react.js +2097 -63
- package/dist/react.mjs +2086 -65
- package/dist/utils.d.mts +2 -2
- package/dist/utils.d.ts +2 -2
- package/dist/utils.js +76 -4
- package/dist/utils.mjs +76 -4
- package/package.json +1 -1
|
@@ -1,7 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
declare const __money: unique symbol;
|
|
2
|
+
/** Decimal monetary amount as a string (e.g. "29.99"). Branded to prevent mixing with plain strings. */
|
|
3
|
+
type Money = string & {
|
|
4
|
+
readonly [__money]: true;
|
|
5
|
+
};
|
|
6
|
+
/** Create a Money value from a string decimal. */
|
|
7
|
+
declare function money(value: string): Money;
|
|
8
|
+
/** Create a Money value from a number. Converts to a 2-decimal string. */
|
|
9
|
+
declare function moneyFromNumber(value: number): Money;
|
|
10
|
+
/** Zero money constant. */
|
|
11
|
+
declare const ZERO: Money;
|
|
12
|
+
/** ISO 4217 currency codes supported by the platform */
|
|
13
|
+
type CurrencyCode = "USD" | "EUR" | "GBP" | "JPY" | "CNY" | "CHF" | "CAD" | "AUD" | "GHS" | "NGN" | "KES" | "ZAR" | "XOF" | "XAF" | "EGP" | "TZS" | "UGX" | "RWF" | "ETB" | "ZMW" | "BWP" | "MUR" | "NAD" | "MWK" | "AOA" | "CDF" | "GMD" | "GNF" | "LRD" | "SLL" | "MZN" | "BIF" | "INR" | "BRL" | "MXN" | "KRW" | "TRY" | "THB" | "MYR" | "PHP" | "IDR" | "VND" | "SGD" | "HKD" | "TWD" | "AED" | "SAR" | "ILS";
|
|
14
|
+
/** Assert a string as CurrencyCode at API boundaries. */
|
|
15
|
+
declare function currencyCode(value: string): CurrencyCode;
|
|
16
|
+
/**
|
|
17
|
+
* @deprecated Use `CurrencyCode` instead. Kept for backward compatibility.
|
|
18
|
+
*/
|
|
19
|
+
type Currency = CurrencyCode;
|
|
5
20
|
/** Pagination parameters */
|
|
6
21
|
interface PaginationParams {
|
|
7
22
|
page?: number;
|
|
@@ -56,6 +71,11 @@ interface ApiError {
|
|
|
56
71
|
message: string;
|
|
57
72
|
retryable: boolean;
|
|
58
73
|
}
|
|
74
|
+
interface ErrorHint {
|
|
75
|
+
docs_url: string;
|
|
76
|
+
suggestion: string;
|
|
77
|
+
}
|
|
78
|
+
declare const ERROR_HINTS: Record<string, ErrorHint>;
|
|
59
79
|
/**
|
|
60
80
|
* Custom error class for SDK errors with typed error codes.
|
|
61
81
|
*
|
|
@@ -82,12 +102,18 @@ interface ApiError {
|
|
|
82
102
|
declare class CimplifyError extends Error {
|
|
83
103
|
code: string;
|
|
84
104
|
retryable: boolean;
|
|
85
|
-
|
|
105
|
+
docs_url?: string | undefined;
|
|
106
|
+
suggestion?: string | undefined;
|
|
107
|
+
constructor(code: string, message: string, retryable?: boolean, docs_url?: string | undefined, suggestion?: string | undefined);
|
|
86
108
|
/** User-friendly message safe to display */
|
|
87
109
|
get userMessage(): string;
|
|
88
110
|
}
|
|
89
111
|
/** Type guard for CimplifyError */
|
|
90
112
|
declare function isCimplifyError(error: unknown): error is CimplifyError;
|
|
113
|
+
declare function getErrorHint(code: string): ErrorHint | undefined;
|
|
114
|
+
declare function enrichError(error: CimplifyError, options?: {
|
|
115
|
+
isTestMode?: boolean;
|
|
116
|
+
}): CimplifyError;
|
|
91
117
|
/** Check if error is retryable */
|
|
92
118
|
declare function isRetryableError(error: unknown): boolean;
|
|
93
119
|
|
|
@@ -110,7 +136,7 @@ interface Payment {
|
|
|
110
136
|
order_id: string;
|
|
111
137
|
business_id: string;
|
|
112
138
|
amount: Money;
|
|
113
|
-
currency:
|
|
139
|
+
currency: CurrencyCode;
|
|
114
140
|
payment_method: PaymentMethod;
|
|
115
141
|
status: PaymentStatus;
|
|
116
142
|
provider: PaymentProvider;
|
|
@@ -151,7 +177,7 @@ interface PaymentStatusResponse {
|
|
|
151
177
|
status: PaymentStatus;
|
|
152
178
|
paid: boolean;
|
|
153
179
|
amount?: Money;
|
|
154
|
-
currency?:
|
|
180
|
+
currency?: CurrencyCode;
|
|
155
181
|
reference?: string;
|
|
156
182
|
message?: string;
|
|
157
183
|
}
|
|
@@ -167,4 +193,4 @@ interface SubmitAuthorizationInput {
|
|
|
167
193
|
value: string;
|
|
168
194
|
}
|
|
169
195
|
|
|
170
|
-
export { type ApiError as A, type
|
|
196
|
+
export { type ApiError as A, type CurrencyCode as C, ErrorCode as E, type InitializePaymentResult as I, type Money as M, type PaginationParams as P, type SubmitAuthorizationInput as S, ZERO as Z, moneyFromNumber as a, type Currency as b, currencyCode as c, type Pagination as d, type ErrorCodeType as e, type ErrorHint as f, ERROR_HINTS as g, CimplifyError as h, isCimplifyError as i, getErrorHint as j, enrichError as k, isRetryableError as l, money as m, type PaymentStatus as n, type PaymentProvider as o, type PaymentMethodType as p, type AuthorizationType as q, type PaymentProcessingState as r, type PaymentMethod as s, type Payment as t, type PaymentResponse as u, type PaymentStatusResponse as v, type PaymentErrorDetails as w };
|
|
@@ -1,7 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
declare const __money: unique symbol;
|
|
2
|
+
/** Decimal monetary amount as a string (e.g. "29.99"). Branded to prevent mixing with plain strings. */
|
|
3
|
+
type Money = string & {
|
|
4
|
+
readonly [__money]: true;
|
|
5
|
+
};
|
|
6
|
+
/** Create a Money value from a string decimal. */
|
|
7
|
+
declare function money(value: string): Money;
|
|
8
|
+
/** Create a Money value from a number. Converts to a 2-decimal string. */
|
|
9
|
+
declare function moneyFromNumber(value: number): Money;
|
|
10
|
+
/** Zero money constant. */
|
|
11
|
+
declare const ZERO: Money;
|
|
12
|
+
/** ISO 4217 currency codes supported by the platform */
|
|
13
|
+
type CurrencyCode = "USD" | "EUR" | "GBP" | "JPY" | "CNY" | "CHF" | "CAD" | "AUD" | "GHS" | "NGN" | "KES" | "ZAR" | "XOF" | "XAF" | "EGP" | "TZS" | "UGX" | "RWF" | "ETB" | "ZMW" | "BWP" | "MUR" | "NAD" | "MWK" | "AOA" | "CDF" | "GMD" | "GNF" | "LRD" | "SLL" | "MZN" | "BIF" | "INR" | "BRL" | "MXN" | "KRW" | "TRY" | "THB" | "MYR" | "PHP" | "IDR" | "VND" | "SGD" | "HKD" | "TWD" | "AED" | "SAR" | "ILS";
|
|
14
|
+
/** Assert a string as CurrencyCode at API boundaries. */
|
|
15
|
+
declare function currencyCode(value: string): CurrencyCode;
|
|
16
|
+
/**
|
|
17
|
+
* @deprecated Use `CurrencyCode` instead. Kept for backward compatibility.
|
|
18
|
+
*/
|
|
19
|
+
type Currency = CurrencyCode;
|
|
5
20
|
/** Pagination parameters */
|
|
6
21
|
interface PaginationParams {
|
|
7
22
|
page?: number;
|
|
@@ -56,6 +71,11 @@ interface ApiError {
|
|
|
56
71
|
message: string;
|
|
57
72
|
retryable: boolean;
|
|
58
73
|
}
|
|
74
|
+
interface ErrorHint {
|
|
75
|
+
docs_url: string;
|
|
76
|
+
suggestion: string;
|
|
77
|
+
}
|
|
78
|
+
declare const ERROR_HINTS: Record<string, ErrorHint>;
|
|
59
79
|
/**
|
|
60
80
|
* Custom error class for SDK errors with typed error codes.
|
|
61
81
|
*
|
|
@@ -82,12 +102,18 @@ interface ApiError {
|
|
|
82
102
|
declare class CimplifyError extends Error {
|
|
83
103
|
code: string;
|
|
84
104
|
retryable: boolean;
|
|
85
|
-
|
|
105
|
+
docs_url?: string | undefined;
|
|
106
|
+
suggestion?: string | undefined;
|
|
107
|
+
constructor(code: string, message: string, retryable?: boolean, docs_url?: string | undefined, suggestion?: string | undefined);
|
|
86
108
|
/** User-friendly message safe to display */
|
|
87
109
|
get userMessage(): string;
|
|
88
110
|
}
|
|
89
111
|
/** Type guard for CimplifyError */
|
|
90
112
|
declare function isCimplifyError(error: unknown): error is CimplifyError;
|
|
113
|
+
declare function getErrorHint(code: string): ErrorHint | undefined;
|
|
114
|
+
declare function enrichError(error: CimplifyError, options?: {
|
|
115
|
+
isTestMode?: boolean;
|
|
116
|
+
}): CimplifyError;
|
|
91
117
|
/** Check if error is retryable */
|
|
92
118
|
declare function isRetryableError(error: unknown): boolean;
|
|
93
119
|
|
|
@@ -110,7 +136,7 @@ interface Payment {
|
|
|
110
136
|
order_id: string;
|
|
111
137
|
business_id: string;
|
|
112
138
|
amount: Money;
|
|
113
|
-
currency:
|
|
139
|
+
currency: CurrencyCode;
|
|
114
140
|
payment_method: PaymentMethod;
|
|
115
141
|
status: PaymentStatus;
|
|
116
142
|
provider: PaymentProvider;
|
|
@@ -151,7 +177,7 @@ interface PaymentStatusResponse {
|
|
|
151
177
|
status: PaymentStatus;
|
|
152
178
|
paid: boolean;
|
|
153
179
|
amount?: Money;
|
|
154
|
-
currency?:
|
|
180
|
+
currency?: CurrencyCode;
|
|
155
181
|
reference?: string;
|
|
156
182
|
message?: string;
|
|
157
183
|
}
|
|
@@ -167,4 +193,4 @@ interface SubmitAuthorizationInput {
|
|
|
167
193
|
value: string;
|
|
168
194
|
}
|
|
169
195
|
|
|
170
|
-
export { type ApiError as A, type
|
|
196
|
+
export { type ApiError as A, type CurrencyCode as C, ErrorCode as E, type InitializePaymentResult as I, type Money as M, type PaginationParams as P, type SubmitAuthorizationInput as S, ZERO as Z, moneyFromNumber as a, type Currency as b, currencyCode as c, type Pagination as d, type ErrorCodeType as e, type ErrorHint as f, ERROR_HINTS as g, CimplifyError as h, isCimplifyError as i, getErrorHint as j, enrichError as k, isRetryableError as l, money as m, type PaymentStatus as n, type PaymentProvider as o, type PaymentMethodType as p, type AuthorizationType as q, type PaymentProcessingState as r, type PaymentMethod as s, type Payment as t, type PaymentResponse as u, type PaymentStatusResponse as v, type PaymentErrorDetails as w };
|
package/dist/react.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { C as CimplifyClient, _ as ProcessCheckoutResult, a0 as CheckoutStatus, a1 as CheckoutStatusContext, cT as Location, cQ as Business, u as CimplifyElements, y as ElementsOptions, eh as AuthenticatedData, ed as AddressInfo, ee as PaymentMethodInfo, ej as ElementsCheckoutResult, Z as ProcessCheckoutOptions } from './client-
|
|
1
|
+
import { C as CimplifyClient, _ as ProcessCheckoutResult, a0 as CheckoutStatus, a1 as CheckoutStatusContext, cT as Location, cQ as Business, aL as Product, aM as ProductWithDetails, a_ as Category, bH as BundleSelectionInput, bi as ComponentSelectionInput, cj as Order, b0 as Collection, b7 as BundleWithDetails, be as CompositeWithDetails, bj as CompositePriceResult, d as QuoteBundleSelectionInput, Q as QuoteCompositeSelectionInput, P as PriceQuote, g as QuoteUiMessage, u as CimplifyElements, y as ElementsOptions, eh as AuthenticatedData, ed as AddressInfo, ee as PaymentMethodInfo, ej as ElementsCheckoutResult, Z as ProcessCheckoutOptions } from './client-FQUyv41r.mjs';
|
|
2
2
|
import React, { ReactNode } from 'react';
|
|
3
|
+
import { h as CimplifyError, C as CurrencyCode } from './payment-Cu75tmUc.mjs';
|
|
3
4
|
import { A as AdSlot, a as AdPosition, e as AdContextValue } from './ads-t3FBTU8p.mjs';
|
|
4
5
|
export { c as AdConfig } from './ads-t3FBTU8p.mjs';
|
|
5
|
-
import './payment-D-u3asA8.mjs';
|
|
6
6
|
|
|
7
7
|
interface UserIdentity {
|
|
8
8
|
uid: string;
|
|
@@ -94,6 +94,227 @@ interface CimplifyProviderProps {
|
|
|
94
94
|
}
|
|
95
95
|
declare function CimplifyProvider({ client, children, onLocationChange, }: CimplifyProviderProps): React.ReactElement;
|
|
96
96
|
declare function useCimplify(): CimplifyContextValue;
|
|
97
|
+
declare function useOptionalCimplify(): CimplifyContextValue | null;
|
|
98
|
+
|
|
99
|
+
interface UseProductsOptions {
|
|
100
|
+
category?: string;
|
|
101
|
+
collection?: string;
|
|
102
|
+
search?: string;
|
|
103
|
+
featured?: boolean;
|
|
104
|
+
limit?: number;
|
|
105
|
+
enabled?: boolean;
|
|
106
|
+
client?: CimplifyClient;
|
|
107
|
+
}
|
|
108
|
+
interface UseProductsResult {
|
|
109
|
+
products: Product[];
|
|
110
|
+
isLoading: boolean;
|
|
111
|
+
error: CimplifyError | null;
|
|
112
|
+
refetch: () => Promise<void>;
|
|
113
|
+
}
|
|
114
|
+
declare function useProducts(options?: UseProductsOptions): UseProductsResult;
|
|
115
|
+
|
|
116
|
+
interface UseProductOptions {
|
|
117
|
+
enabled?: boolean;
|
|
118
|
+
client?: CimplifyClient;
|
|
119
|
+
}
|
|
120
|
+
interface UseProductResult {
|
|
121
|
+
product: ProductWithDetails | null;
|
|
122
|
+
isLoading: boolean;
|
|
123
|
+
error: CimplifyError | null;
|
|
124
|
+
refetch: () => Promise<void>;
|
|
125
|
+
}
|
|
126
|
+
declare function useProduct(slugOrId: string | null | undefined, options?: UseProductOptions): UseProductResult;
|
|
127
|
+
|
|
128
|
+
interface UseCategoriesOptions {
|
|
129
|
+
enabled?: boolean;
|
|
130
|
+
client?: CimplifyClient;
|
|
131
|
+
}
|
|
132
|
+
interface UseCategoriesResult {
|
|
133
|
+
categories: Category[];
|
|
134
|
+
isLoading: boolean;
|
|
135
|
+
error: CimplifyError | null;
|
|
136
|
+
refetch: () => Promise<void>;
|
|
137
|
+
}
|
|
138
|
+
declare function useCategories(options?: UseCategoriesOptions): UseCategoriesResult;
|
|
139
|
+
|
|
140
|
+
interface CartVariantSelection {
|
|
141
|
+
id: string;
|
|
142
|
+
name: string;
|
|
143
|
+
price_adjustment?: string;
|
|
144
|
+
}
|
|
145
|
+
interface CartAddOnOptionSelection {
|
|
146
|
+
id: string;
|
|
147
|
+
name: string;
|
|
148
|
+
add_on_id?: string;
|
|
149
|
+
default_price?: string;
|
|
150
|
+
}
|
|
151
|
+
interface UseCartItem {
|
|
152
|
+
id: string;
|
|
153
|
+
product: Product;
|
|
154
|
+
quantity: number;
|
|
155
|
+
locationId?: string;
|
|
156
|
+
variantId?: string;
|
|
157
|
+
variant?: CartVariantSelection;
|
|
158
|
+
quoteId?: string;
|
|
159
|
+
addOnOptionIds?: string[];
|
|
160
|
+
addOnOptions?: CartAddOnOptionSelection[];
|
|
161
|
+
bundleSelections?: BundleSelectionInput[];
|
|
162
|
+
compositeSelections?: ComponentSelectionInput[];
|
|
163
|
+
specialInstructions?: string;
|
|
164
|
+
}
|
|
165
|
+
interface AddToCartOptions {
|
|
166
|
+
locationId?: string;
|
|
167
|
+
variantId?: string;
|
|
168
|
+
variant?: CartVariantSelection;
|
|
169
|
+
quoteId?: string;
|
|
170
|
+
addOnOptionIds?: string[];
|
|
171
|
+
addOnOptions?: CartAddOnOptionSelection[];
|
|
172
|
+
bundleSelections?: BundleSelectionInput[];
|
|
173
|
+
compositeSelections?: ComponentSelectionInput[];
|
|
174
|
+
specialInstructions?: string;
|
|
175
|
+
}
|
|
176
|
+
interface UseCartOptions {
|
|
177
|
+
client?: CimplifyClient;
|
|
178
|
+
demoMode?: boolean;
|
|
179
|
+
locationId?: string;
|
|
180
|
+
currency?: string;
|
|
181
|
+
}
|
|
182
|
+
interface UseCartResult {
|
|
183
|
+
items: UseCartItem[];
|
|
184
|
+
itemCount: number;
|
|
185
|
+
subtotal: number;
|
|
186
|
+
tax: number;
|
|
187
|
+
total: number;
|
|
188
|
+
currency: string;
|
|
189
|
+
isEmpty: boolean;
|
|
190
|
+
isLoading: boolean;
|
|
191
|
+
addItem: (product: Product, quantity?: number, options?: AddToCartOptions) => Promise<void>;
|
|
192
|
+
removeItem: (itemId: string) => Promise<void>;
|
|
193
|
+
updateQuantity: (itemId: string, quantity: number) => Promise<void>;
|
|
194
|
+
clearCart: () => Promise<void>;
|
|
195
|
+
sync: () => Promise<void>;
|
|
196
|
+
}
|
|
197
|
+
declare function useCart(options?: UseCartOptions): UseCartResult;
|
|
198
|
+
|
|
199
|
+
interface UseOrderOptions {
|
|
200
|
+
poll?: boolean;
|
|
201
|
+
pollInterval?: number;
|
|
202
|
+
enabled?: boolean;
|
|
203
|
+
client?: CimplifyClient;
|
|
204
|
+
}
|
|
205
|
+
interface UseOrderResult {
|
|
206
|
+
order: Order | null;
|
|
207
|
+
isLoading: boolean;
|
|
208
|
+
error: CimplifyError | null;
|
|
209
|
+
refetch: () => Promise<void>;
|
|
210
|
+
}
|
|
211
|
+
declare function useOrder(orderId: string | null | undefined, options?: UseOrderOptions): UseOrderResult;
|
|
212
|
+
|
|
213
|
+
interface UseLocationsOptions {
|
|
214
|
+
client?: CimplifyClient;
|
|
215
|
+
}
|
|
216
|
+
interface UseLocationsResult {
|
|
217
|
+
locations: Location[];
|
|
218
|
+
currentLocation: Location | null;
|
|
219
|
+
setCurrentLocation: (location: Location) => void;
|
|
220
|
+
isLoading: boolean;
|
|
221
|
+
}
|
|
222
|
+
declare function useLocations(options?: UseLocationsOptions): UseLocationsResult;
|
|
223
|
+
|
|
224
|
+
interface UseCollectionsOptions {
|
|
225
|
+
client?: CimplifyClient;
|
|
226
|
+
enabled?: boolean;
|
|
227
|
+
}
|
|
228
|
+
interface UseCollectionsResult {
|
|
229
|
+
collections: Collection[];
|
|
230
|
+
isLoading: boolean;
|
|
231
|
+
error: CimplifyError | null;
|
|
232
|
+
refetch: () => Promise<void>;
|
|
233
|
+
}
|
|
234
|
+
declare function useCollections(options?: UseCollectionsOptions): UseCollectionsResult;
|
|
235
|
+
|
|
236
|
+
interface UseCollectionOptions {
|
|
237
|
+
client?: CimplifyClient;
|
|
238
|
+
enabled?: boolean;
|
|
239
|
+
}
|
|
240
|
+
interface UseCollectionResult {
|
|
241
|
+
collection: Collection | null;
|
|
242
|
+
products: Product[];
|
|
243
|
+
isLoading: boolean;
|
|
244
|
+
error: CimplifyError | null;
|
|
245
|
+
refetch: () => Promise<void>;
|
|
246
|
+
}
|
|
247
|
+
declare function useCollection(idOrSlug: string | null | undefined, options?: UseCollectionOptions): UseCollectionResult;
|
|
248
|
+
|
|
249
|
+
interface UseBundleOptions {
|
|
250
|
+
client?: CimplifyClient;
|
|
251
|
+
enabled?: boolean;
|
|
252
|
+
}
|
|
253
|
+
interface UseBundleResult {
|
|
254
|
+
bundle: BundleWithDetails | null;
|
|
255
|
+
isLoading: boolean;
|
|
256
|
+
error: CimplifyError | null;
|
|
257
|
+
refetch: () => Promise<void>;
|
|
258
|
+
}
|
|
259
|
+
declare function useBundle(idOrSlug: string | null | undefined, options?: UseBundleOptions): UseBundleResult;
|
|
260
|
+
|
|
261
|
+
interface UseCompositeOptions {
|
|
262
|
+
client?: CimplifyClient;
|
|
263
|
+
enabled?: boolean;
|
|
264
|
+
byProductId?: boolean;
|
|
265
|
+
}
|
|
266
|
+
interface UseCompositeResult {
|
|
267
|
+
composite: CompositeWithDetails | null;
|
|
268
|
+
isLoading: boolean;
|
|
269
|
+
error: CimplifyError | null;
|
|
270
|
+
refetch: () => Promise<void>;
|
|
271
|
+
calculatePrice: (selections: ComponentSelectionInput[], locationId?: string) => Promise<CompositePriceResult | null>;
|
|
272
|
+
priceResult: CompositePriceResult | null;
|
|
273
|
+
isPriceLoading: boolean;
|
|
274
|
+
}
|
|
275
|
+
declare function useComposite(idOrProductId: string | null | undefined, options?: UseCompositeOptions): UseCompositeResult;
|
|
276
|
+
|
|
277
|
+
interface UseSearchOptions {
|
|
278
|
+
client?: CimplifyClient;
|
|
279
|
+
minLength?: number;
|
|
280
|
+
debounceMs?: number;
|
|
281
|
+
limit?: number;
|
|
282
|
+
category?: string;
|
|
283
|
+
}
|
|
284
|
+
interface UseSearchResult {
|
|
285
|
+
results: Product[];
|
|
286
|
+
isLoading: boolean;
|
|
287
|
+
error: CimplifyError | null;
|
|
288
|
+
query: string;
|
|
289
|
+
setQuery: (query: string) => void;
|
|
290
|
+
clear: () => void;
|
|
291
|
+
}
|
|
292
|
+
declare function useSearch(options?: UseSearchOptions): UseSearchResult;
|
|
293
|
+
|
|
294
|
+
interface UseQuoteOptions {
|
|
295
|
+
client?: CimplifyClient;
|
|
296
|
+
enabled?: boolean;
|
|
297
|
+
autoRefresh?: boolean;
|
|
298
|
+
refreshBeforeExpiryMs?: number;
|
|
299
|
+
}
|
|
300
|
+
interface UseQuoteInput {
|
|
301
|
+
productId: string;
|
|
302
|
+
variantId?: string;
|
|
303
|
+
locationId?: string;
|
|
304
|
+
quantity?: number;
|
|
305
|
+
addOnOptionIds?: string[];
|
|
306
|
+
bundleSelections?: QuoteBundleSelectionInput[];
|
|
307
|
+
compositeSelections?: QuoteCompositeSelectionInput[];
|
|
308
|
+
}
|
|
309
|
+
interface UseQuoteResult {
|
|
310
|
+
quote: PriceQuote | null;
|
|
311
|
+
isLoading: boolean;
|
|
312
|
+
error: CimplifyError | null;
|
|
313
|
+
refresh: () => Promise<void>;
|
|
314
|
+
isExpired: boolean;
|
|
315
|
+
messages: QuoteUiMessage[];
|
|
316
|
+
}
|
|
317
|
+
declare function useQuote(input: UseQuoteInput | null | undefined, options?: UseQuoteOptions): UseQuoteResult;
|
|
97
318
|
|
|
98
319
|
declare function useElements(): CimplifyElements | null;
|
|
99
320
|
declare function useElementsReady(): boolean;
|
|
@@ -131,7 +352,7 @@ interface AddressElementProps extends BaseElementProps {
|
|
|
131
352
|
declare function AddressElement({ className, style, mode, onReady, onChange, onError, }: AddressElementProps): React.ReactElement | null;
|
|
132
353
|
interface PaymentElementProps extends BaseElementProps {
|
|
133
354
|
amount?: number;
|
|
134
|
-
currency?:
|
|
355
|
+
currency?: CurrencyCode;
|
|
135
356
|
onChange?: (data: {
|
|
136
357
|
paymentMethod: PaymentMethodInfo;
|
|
137
358
|
saveToLink: boolean;
|
|
@@ -151,4 +372,4 @@ declare function useCheckout(): {
|
|
|
151
372
|
isLoading: boolean;
|
|
152
373
|
};
|
|
153
374
|
|
|
154
|
-
export { Ad, AdPosition, type AdProps, AdProvider, AdSlot, AddressElement, AuthElement, CimplifyCheckout, type CimplifyCheckoutProps, type CimplifyContextValue, CimplifyProvider, type CimplifyProviderProps, ElementsProvider, PaymentElement, useAds, useCheckout, useCimplify, useElements, useElementsReady };
|
|
375
|
+
export { Ad, AdPosition, type AdProps, AdProvider, AdSlot, type AddToCartOptions, AddressElement, AuthElement, CimplifyCheckout, type CimplifyCheckoutProps, type CimplifyContextValue, CimplifyProvider, type CimplifyProviderProps, ElementsProvider, PaymentElement, type UseBundleOptions, type UseBundleResult, type UseCartItem, type UseCartOptions, type UseCartResult, type UseCategoriesOptions, type UseCategoriesResult, type UseCollectionOptions, type UseCollectionResult, type UseCollectionsOptions, type UseCollectionsResult, type UseCompositeOptions, type UseCompositeResult, type UseLocationsOptions, type UseLocationsResult, type UseOrderOptions, type UseOrderResult, type UseProductOptions, type UseProductResult, type UseProductsOptions, type UseProductsResult, type UseQuoteInput, type UseQuoteOptions, type UseQuoteResult, type UseSearchOptions, type UseSearchResult, useAds, useBundle, useCart, useCategories, useCheckout, useCimplify, useCollection, useCollections, useComposite, useElements, useElementsReady, useLocations, useOptionalCimplify, useOrder, useProduct, useProducts, useQuote, useSearch };
|
package/dist/react.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { C as CimplifyClient, _ as ProcessCheckoutResult, a0 as CheckoutStatus, a1 as CheckoutStatusContext, cT as Location, cQ as Business, u as CimplifyElements, y as ElementsOptions, eh as AuthenticatedData, ed as AddressInfo, ee as PaymentMethodInfo, ej as ElementsCheckoutResult, Z as ProcessCheckoutOptions } from './client-
|
|
1
|
+
import { C as CimplifyClient, _ as ProcessCheckoutResult, a0 as CheckoutStatus, a1 as CheckoutStatusContext, cT as Location, cQ as Business, aL as Product, aM as ProductWithDetails, a_ as Category, bH as BundleSelectionInput, bi as ComponentSelectionInput, cj as Order, b0 as Collection, b7 as BundleWithDetails, be as CompositeWithDetails, bj as CompositePriceResult, d as QuoteBundleSelectionInput, Q as QuoteCompositeSelectionInput, P as PriceQuote, g as QuoteUiMessage, u as CimplifyElements, y as ElementsOptions, eh as AuthenticatedData, ed as AddressInfo, ee as PaymentMethodInfo, ej as ElementsCheckoutResult, Z as ProcessCheckoutOptions } from './client-D4vA6FY_.js';
|
|
2
2
|
import React, { ReactNode } from 'react';
|
|
3
|
+
import { h as CimplifyError, C as CurrencyCode } from './payment-Cu75tmUc.js';
|
|
3
4
|
import { A as AdSlot, a as AdPosition, e as AdContextValue } from './ads-t3FBTU8p.js';
|
|
4
5
|
export { c as AdConfig } from './ads-t3FBTU8p.js';
|
|
5
|
-
import './payment-D-u3asA8.js';
|
|
6
6
|
|
|
7
7
|
interface UserIdentity {
|
|
8
8
|
uid: string;
|
|
@@ -94,6 +94,227 @@ interface CimplifyProviderProps {
|
|
|
94
94
|
}
|
|
95
95
|
declare function CimplifyProvider({ client, children, onLocationChange, }: CimplifyProviderProps): React.ReactElement;
|
|
96
96
|
declare function useCimplify(): CimplifyContextValue;
|
|
97
|
+
declare function useOptionalCimplify(): CimplifyContextValue | null;
|
|
98
|
+
|
|
99
|
+
interface UseProductsOptions {
|
|
100
|
+
category?: string;
|
|
101
|
+
collection?: string;
|
|
102
|
+
search?: string;
|
|
103
|
+
featured?: boolean;
|
|
104
|
+
limit?: number;
|
|
105
|
+
enabled?: boolean;
|
|
106
|
+
client?: CimplifyClient;
|
|
107
|
+
}
|
|
108
|
+
interface UseProductsResult {
|
|
109
|
+
products: Product[];
|
|
110
|
+
isLoading: boolean;
|
|
111
|
+
error: CimplifyError | null;
|
|
112
|
+
refetch: () => Promise<void>;
|
|
113
|
+
}
|
|
114
|
+
declare function useProducts(options?: UseProductsOptions): UseProductsResult;
|
|
115
|
+
|
|
116
|
+
interface UseProductOptions {
|
|
117
|
+
enabled?: boolean;
|
|
118
|
+
client?: CimplifyClient;
|
|
119
|
+
}
|
|
120
|
+
interface UseProductResult {
|
|
121
|
+
product: ProductWithDetails | null;
|
|
122
|
+
isLoading: boolean;
|
|
123
|
+
error: CimplifyError | null;
|
|
124
|
+
refetch: () => Promise<void>;
|
|
125
|
+
}
|
|
126
|
+
declare function useProduct(slugOrId: string | null | undefined, options?: UseProductOptions): UseProductResult;
|
|
127
|
+
|
|
128
|
+
interface UseCategoriesOptions {
|
|
129
|
+
enabled?: boolean;
|
|
130
|
+
client?: CimplifyClient;
|
|
131
|
+
}
|
|
132
|
+
interface UseCategoriesResult {
|
|
133
|
+
categories: Category[];
|
|
134
|
+
isLoading: boolean;
|
|
135
|
+
error: CimplifyError | null;
|
|
136
|
+
refetch: () => Promise<void>;
|
|
137
|
+
}
|
|
138
|
+
declare function useCategories(options?: UseCategoriesOptions): UseCategoriesResult;
|
|
139
|
+
|
|
140
|
+
interface CartVariantSelection {
|
|
141
|
+
id: string;
|
|
142
|
+
name: string;
|
|
143
|
+
price_adjustment?: string;
|
|
144
|
+
}
|
|
145
|
+
interface CartAddOnOptionSelection {
|
|
146
|
+
id: string;
|
|
147
|
+
name: string;
|
|
148
|
+
add_on_id?: string;
|
|
149
|
+
default_price?: string;
|
|
150
|
+
}
|
|
151
|
+
interface UseCartItem {
|
|
152
|
+
id: string;
|
|
153
|
+
product: Product;
|
|
154
|
+
quantity: number;
|
|
155
|
+
locationId?: string;
|
|
156
|
+
variantId?: string;
|
|
157
|
+
variant?: CartVariantSelection;
|
|
158
|
+
quoteId?: string;
|
|
159
|
+
addOnOptionIds?: string[];
|
|
160
|
+
addOnOptions?: CartAddOnOptionSelection[];
|
|
161
|
+
bundleSelections?: BundleSelectionInput[];
|
|
162
|
+
compositeSelections?: ComponentSelectionInput[];
|
|
163
|
+
specialInstructions?: string;
|
|
164
|
+
}
|
|
165
|
+
interface AddToCartOptions {
|
|
166
|
+
locationId?: string;
|
|
167
|
+
variantId?: string;
|
|
168
|
+
variant?: CartVariantSelection;
|
|
169
|
+
quoteId?: string;
|
|
170
|
+
addOnOptionIds?: string[];
|
|
171
|
+
addOnOptions?: CartAddOnOptionSelection[];
|
|
172
|
+
bundleSelections?: BundleSelectionInput[];
|
|
173
|
+
compositeSelections?: ComponentSelectionInput[];
|
|
174
|
+
specialInstructions?: string;
|
|
175
|
+
}
|
|
176
|
+
interface UseCartOptions {
|
|
177
|
+
client?: CimplifyClient;
|
|
178
|
+
demoMode?: boolean;
|
|
179
|
+
locationId?: string;
|
|
180
|
+
currency?: string;
|
|
181
|
+
}
|
|
182
|
+
interface UseCartResult {
|
|
183
|
+
items: UseCartItem[];
|
|
184
|
+
itemCount: number;
|
|
185
|
+
subtotal: number;
|
|
186
|
+
tax: number;
|
|
187
|
+
total: number;
|
|
188
|
+
currency: string;
|
|
189
|
+
isEmpty: boolean;
|
|
190
|
+
isLoading: boolean;
|
|
191
|
+
addItem: (product: Product, quantity?: number, options?: AddToCartOptions) => Promise<void>;
|
|
192
|
+
removeItem: (itemId: string) => Promise<void>;
|
|
193
|
+
updateQuantity: (itemId: string, quantity: number) => Promise<void>;
|
|
194
|
+
clearCart: () => Promise<void>;
|
|
195
|
+
sync: () => Promise<void>;
|
|
196
|
+
}
|
|
197
|
+
declare function useCart(options?: UseCartOptions): UseCartResult;
|
|
198
|
+
|
|
199
|
+
interface UseOrderOptions {
|
|
200
|
+
poll?: boolean;
|
|
201
|
+
pollInterval?: number;
|
|
202
|
+
enabled?: boolean;
|
|
203
|
+
client?: CimplifyClient;
|
|
204
|
+
}
|
|
205
|
+
interface UseOrderResult {
|
|
206
|
+
order: Order | null;
|
|
207
|
+
isLoading: boolean;
|
|
208
|
+
error: CimplifyError | null;
|
|
209
|
+
refetch: () => Promise<void>;
|
|
210
|
+
}
|
|
211
|
+
declare function useOrder(orderId: string | null | undefined, options?: UseOrderOptions): UseOrderResult;
|
|
212
|
+
|
|
213
|
+
interface UseLocationsOptions {
|
|
214
|
+
client?: CimplifyClient;
|
|
215
|
+
}
|
|
216
|
+
interface UseLocationsResult {
|
|
217
|
+
locations: Location[];
|
|
218
|
+
currentLocation: Location | null;
|
|
219
|
+
setCurrentLocation: (location: Location) => void;
|
|
220
|
+
isLoading: boolean;
|
|
221
|
+
}
|
|
222
|
+
declare function useLocations(options?: UseLocationsOptions): UseLocationsResult;
|
|
223
|
+
|
|
224
|
+
interface UseCollectionsOptions {
|
|
225
|
+
client?: CimplifyClient;
|
|
226
|
+
enabled?: boolean;
|
|
227
|
+
}
|
|
228
|
+
interface UseCollectionsResult {
|
|
229
|
+
collections: Collection[];
|
|
230
|
+
isLoading: boolean;
|
|
231
|
+
error: CimplifyError | null;
|
|
232
|
+
refetch: () => Promise<void>;
|
|
233
|
+
}
|
|
234
|
+
declare function useCollections(options?: UseCollectionsOptions): UseCollectionsResult;
|
|
235
|
+
|
|
236
|
+
interface UseCollectionOptions {
|
|
237
|
+
client?: CimplifyClient;
|
|
238
|
+
enabled?: boolean;
|
|
239
|
+
}
|
|
240
|
+
interface UseCollectionResult {
|
|
241
|
+
collection: Collection | null;
|
|
242
|
+
products: Product[];
|
|
243
|
+
isLoading: boolean;
|
|
244
|
+
error: CimplifyError | null;
|
|
245
|
+
refetch: () => Promise<void>;
|
|
246
|
+
}
|
|
247
|
+
declare function useCollection(idOrSlug: string | null | undefined, options?: UseCollectionOptions): UseCollectionResult;
|
|
248
|
+
|
|
249
|
+
interface UseBundleOptions {
|
|
250
|
+
client?: CimplifyClient;
|
|
251
|
+
enabled?: boolean;
|
|
252
|
+
}
|
|
253
|
+
interface UseBundleResult {
|
|
254
|
+
bundle: BundleWithDetails | null;
|
|
255
|
+
isLoading: boolean;
|
|
256
|
+
error: CimplifyError | null;
|
|
257
|
+
refetch: () => Promise<void>;
|
|
258
|
+
}
|
|
259
|
+
declare function useBundle(idOrSlug: string | null | undefined, options?: UseBundleOptions): UseBundleResult;
|
|
260
|
+
|
|
261
|
+
interface UseCompositeOptions {
|
|
262
|
+
client?: CimplifyClient;
|
|
263
|
+
enabled?: boolean;
|
|
264
|
+
byProductId?: boolean;
|
|
265
|
+
}
|
|
266
|
+
interface UseCompositeResult {
|
|
267
|
+
composite: CompositeWithDetails | null;
|
|
268
|
+
isLoading: boolean;
|
|
269
|
+
error: CimplifyError | null;
|
|
270
|
+
refetch: () => Promise<void>;
|
|
271
|
+
calculatePrice: (selections: ComponentSelectionInput[], locationId?: string) => Promise<CompositePriceResult | null>;
|
|
272
|
+
priceResult: CompositePriceResult | null;
|
|
273
|
+
isPriceLoading: boolean;
|
|
274
|
+
}
|
|
275
|
+
declare function useComposite(idOrProductId: string | null | undefined, options?: UseCompositeOptions): UseCompositeResult;
|
|
276
|
+
|
|
277
|
+
interface UseSearchOptions {
|
|
278
|
+
client?: CimplifyClient;
|
|
279
|
+
minLength?: number;
|
|
280
|
+
debounceMs?: number;
|
|
281
|
+
limit?: number;
|
|
282
|
+
category?: string;
|
|
283
|
+
}
|
|
284
|
+
interface UseSearchResult {
|
|
285
|
+
results: Product[];
|
|
286
|
+
isLoading: boolean;
|
|
287
|
+
error: CimplifyError | null;
|
|
288
|
+
query: string;
|
|
289
|
+
setQuery: (query: string) => void;
|
|
290
|
+
clear: () => void;
|
|
291
|
+
}
|
|
292
|
+
declare function useSearch(options?: UseSearchOptions): UseSearchResult;
|
|
293
|
+
|
|
294
|
+
interface UseQuoteOptions {
|
|
295
|
+
client?: CimplifyClient;
|
|
296
|
+
enabled?: boolean;
|
|
297
|
+
autoRefresh?: boolean;
|
|
298
|
+
refreshBeforeExpiryMs?: number;
|
|
299
|
+
}
|
|
300
|
+
interface UseQuoteInput {
|
|
301
|
+
productId: string;
|
|
302
|
+
variantId?: string;
|
|
303
|
+
locationId?: string;
|
|
304
|
+
quantity?: number;
|
|
305
|
+
addOnOptionIds?: string[];
|
|
306
|
+
bundleSelections?: QuoteBundleSelectionInput[];
|
|
307
|
+
compositeSelections?: QuoteCompositeSelectionInput[];
|
|
308
|
+
}
|
|
309
|
+
interface UseQuoteResult {
|
|
310
|
+
quote: PriceQuote | null;
|
|
311
|
+
isLoading: boolean;
|
|
312
|
+
error: CimplifyError | null;
|
|
313
|
+
refresh: () => Promise<void>;
|
|
314
|
+
isExpired: boolean;
|
|
315
|
+
messages: QuoteUiMessage[];
|
|
316
|
+
}
|
|
317
|
+
declare function useQuote(input: UseQuoteInput | null | undefined, options?: UseQuoteOptions): UseQuoteResult;
|
|
97
318
|
|
|
98
319
|
declare function useElements(): CimplifyElements | null;
|
|
99
320
|
declare function useElementsReady(): boolean;
|
|
@@ -131,7 +352,7 @@ interface AddressElementProps extends BaseElementProps {
|
|
|
131
352
|
declare function AddressElement({ className, style, mode, onReady, onChange, onError, }: AddressElementProps): React.ReactElement | null;
|
|
132
353
|
interface PaymentElementProps extends BaseElementProps {
|
|
133
354
|
amount?: number;
|
|
134
|
-
currency?:
|
|
355
|
+
currency?: CurrencyCode;
|
|
135
356
|
onChange?: (data: {
|
|
136
357
|
paymentMethod: PaymentMethodInfo;
|
|
137
358
|
saveToLink: boolean;
|
|
@@ -151,4 +372,4 @@ declare function useCheckout(): {
|
|
|
151
372
|
isLoading: boolean;
|
|
152
373
|
};
|
|
153
374
|
|
|
154
|
-
export { Ad, AdPosition, type AdProps, AdProvider, AdSlot, AddressElement, AuthElement, CimplifyCheckout, type CimplifyCheckoutProps, type CimplifyContextValue, CimplifyProvider, type CimplifyProviderProps, ElementsProvider, PaymentElement, useAds, useCheckout, useCimplify, useElements, useElementsReady };
|
|
375
|
+
export { Ad, AdPosition, type AdProps, AdProvider, AdSlot, type AddToCartOptions, AddressElement, AuthElement, CimplifyCheckout, type CimplifyCheckoutProps, type CimplifyContextValue, CimplifyProvider, type CimplifyProviderProps, ElementsProvider, PaymentElement, type UseBundleOptions, type UseBundleResult, type UseCartItem, type UseCartOptions, type UseCartResult, type UseCategoriesOptions, type UseCategoriesResult, type UseCollectionOptions, type UseCollectionResult, type UseCollectionsOptions, type UseCollectionsResult, type UseCompositeOptions, type UseCompositeResult, type UseLocationsOptions, type UseLocationsResult, type UseOrderOptions, type UseOrderResult, type UseProductOptions, type UseProductResult, type UseProductsOptions, type UseProductsResult, type UseQuoteInput, type UseQuoteOptions, type UseQuoteResult, type UseSearchOptions, type UseSearchResult, useAds, useBundle, useCart, useCategories, useCheckout, useCimplify, useCollection, useCollections, useComposite, useElements, useElementsReady, useLocations, useOptionalCimplify, useOrder, useProduct, useProducts, useQuote, useSearch };
|