@cimplify/sdk 0.6.10 → 0.6.12
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/ads-t3FBTU8p.d.mts +20 -0
- package/dist/ads-t3FBTU8p.d.ts +20 -0
- package/dist/advanced.d.mts +25 -0
- package/dist/advanced.d.ts +25 -0
- package/dist/advanced.js +534 -102
- package/dist/advanced.mjs +534 -102
- package/dist/client-2Rmdqutj.d.ts +2373 -0
- package/dist/client-BIbWQK7v.d.mts +2373 -0
- package/dist/index-DAztg_LQ.d.ts +326 -0
- package/dist/index-Dqaywky7.d.mts +326 -0
- package/dist/index.d.mts +38 -0
- package/dist/index.d.ts +38 -0
- package/dist/index.js +590 -105
- package/dist/index.mjs +587 -106
- package/dist/payment-CLIWNMaP.d.mts +1133 -0
- package/dist/payment-CLIWNMaP.d.ts +1133 -0
- package/dist/react.d.mts +375 -0
- package/dist/react.d.ts +375 -0
- package/dist/react.js +562 -105
- package/dist/react.mjs +562 -105
- package/dist/utils.d.mts +2 -0
- package/dist/utils.d.ts +2 -0
- package/dist/utils.js +27 -0
- package/dist/utils.mjs +24 -1
- package/package.json +1 -1
|
@@ -0,0 +1,2373 @@
|
|
|
1
|
+
import { d as Pagination, q as Product, h as CimplifyError, r as ProductWithDetails, s as ProductVariant, u as VariantAxis, z as VariantAxisSelection, B as AddOn, K as Category, N as Collection, T as Bundle, X as BundleWithDetails, a2 as Composite, a3 as CompositeWithDetails, a7 as ComponentSelectionInput, a8 as CompositePriceResult, an as ChosenPrice, aS as UICart, aD as Cart, aE as CartItem, aW as CartSummary, aU as AddToCartInput, aV as UpdateCartItemInput, ar as DiscountDetails, M as Money, C as CurrencyCode, aC as LineConfiguration, a_ as AuthorizationType, b0 as PaymentMethod, b2 as InitializePaymentResult, b6 as SubmitAuthorizationInput, b4 as PaymentStatusResponse } from './payment-CLIWNMaP.mjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Observability hooks for monitoring SDK behavior.
|
|
5
|
+
*
|
|
6
|
+
* These hooks allow you to plug in your own logging, metrics, and tracing
|
|
7
|
+
* without the SDK depending on any specific observability library.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* const client = createCimplifyClient({
|
|
12
|
+
* hooks: {
|
|
13
|
+
* onRequestStart: ({ method, path }) => {
|
|
14
|
+
* console.log(`[SDK] ${method} ${path}`);
|
|
15
|
+
* },
|
|
16
|
+
* onRequestSuccess: ({ method, path, durationMs }) => {
|
|
17
|
+
* metrics.histogram('sdk.request.duration', durationMs, { method, path });
|
|
18
|
+
* },
|
|
19
|
+
* onRequestError: ({ method, path, error, retryCount }) => {
|
|
20
|
+
* Sentry.captureException(error, { extra: { method, path, retryCount } });
|
|
21
|
+
* },
|
|
22
|
+
* },
|
|
23
|
+
* });
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
/** Context passed to request lifecycle hooks */
|
|
27
|
+
interface RequestContext {
|
|
28
|
+
/** HTTP method */
|
|
29
|
+
method: "GET" | "POST" | "DELETE";
|
|
30
|
+
/** Request path (e.g., "/api/q", "/api/m") */
|
|
31
|
+
path: string;
|
|
32
|
+
/** Full URL */
|
|
33
|
+
url: string;
|
|
34
|
+
/** Request body (for POST requests) */
|
|
35
|
+
body?: unknown;
|
|
36
|
+
/** Timestamp when request started */
|
|
37
|
+
startTime: number;
|
|
38
|
+
}
|
|
39
|
+
/** Passed when a request starts */
|
|
40
|
+
interface RequestStartEvent extends RequestContext {
|
|
41
|
+
}
|
|
42
|
+
/** Passed when a request succeeds */
|
|
43
|
+
interface RequestSuccessEvent extends RequestContext {
|
|
44
|
+
/** HTTP status code */
|
|
45
|
+
status: number;
|
|
46
|
+
/** Duration in milliseconds */
|
|
47
|
+
durationMs: number;
|
|
48
|
+
}
|
|
49
|
+
/** Passed when a request fails */
|
|
50
|
+
interface RequestErrorEvent extends RequestContext {
|
|
51
|
+
/** The error that occurred */
|
|
52
|
+
error: Error;
|
|
53
|
+
/** HTTP status code (when available) */
|
|
54
|
+
status?: number;
|
|
55
|
+
/** Duration in milliseconds */
|
|
56
|
+
durationMs: number;
|
|
57
|
+
/** Number of retries attempted before giving up */
|
|
58
|
+
retryCount: number;
|
|
59
|
+
/** Whether the error is retryable */
|
|
60
|
+
retryable: boolean;
|
|
61
|
+
}
|
|
62
|
+
/** Passed when a retry is about to happen */
|
|
63
|
+
interface RetryEvent extends RequestContext {
|
|
64
|
+
/** Which retry attempt (1, 2, 3...) */
|
|
65
|
+
attempt: number;
|
|
66
|
+
/** Delay before retry in milliseconds */
|
|
67
|
+
delayMs: number;
|
|
68
|
+
/** The error that triggered the retry */
|
|
69
|
+
error: Error;
|
|
70
|
+
}
|
|
71
|
+
/** Passed when session token changes */
|
|
72
|
+
interface SessionChangeEvent {
|
|
73
|
+
/** Previous token (null if none) */
|
|
74
|
+
previousToken: string | null;
|
|
75
|
+
/** New token (null if cleared) */
|
|
76
|
+
newToken: string | null;
|
|
77
|
+
/** Source of the change */
|
|
78
|
+
source: "response" | "manual" | "clear";
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Observability hooks configuration.
|
|
82
|
+
* All hooks are optional - only implement what you need.
|
|
83
|
+
*/
|
|
84
|
+
interface ObservabilityHooks {
|
|
85
|
+
/** Called when a request is about to be sent */
|
|
86
|
+
onRequestStart?: (event: RequestStartEvent) => void;
|
|
87
|
+
/** Called when a request completes successfully */
|
|
88
|
+
onRequestSuccess?: (event: RequestSuccessEvent) => void;
|
|
89
|
+
/** Called when a request fails (4xx/5xx responses or network errors after retries) */
|
|
90
|
+
onRequestError?: (event: RequestErrorEvent) => void;
|
|
91
|
+
/** Called before each retry attempt */
|
|
92
|
+
onRetry?: (event: RetryEvent) => void;
|
|
93
|
+
/** Called when session token changes */
|
|
94
|
+
onSessionChange?: (event: SessionChangeEvent) => void;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** Catalogue listing response with server metadata. */
|
|
98
|
+
interface CatalogueResult<T> {
|
|
99
|
+
items: T[];
|
|
100
|
+
/** true when the full catalogue is returned; false when truncated by server cap. */
|
|
101
|
+
is_complete: boolean;
|
|
102
|
+
/** Total available items before truncation (present when truncated). */
|
|
103
|
+
total_available?: number;
|
|
104
|
+
/** Pagination metadata when listing is paginated. */
|
|
105
|
+
pagination?: Pagination;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* A Result type that makes errors explicit in the type system.
|
|
110
|
+
* Inspired by Rust's Result and fp-ts Either.
|
|
111
|
+
*
|
|
112
|
+
* @example
|
|
113
|
+
* ```typescript
|
|
114
|
+
* const result = await client.cart.addItemSafe({ item_id: "prod_123" });
|
|
115
|
+
*
|
|
116
|
+
* if (result.ok) {
|
|
117
|
+
* console.log(result.value); // Cart
|
|
118
|
+
* } else {
|
|
119
|
+
* console.log(result.error); // CimplifyError
|
|
120
|
+
* }
|
|
121
|
+
* ```
|
|
122
|
+
*/
|
|
123
|
+
type Result<T, E = Error> = Ok<T> | Err<E>;
|
|
124
|
+
interface Ok<T> {
|
|
125
|
+
readonly ok: true;
|
|
126
|
+
readonly value: T;
|
|
127
|
+
}
|
|
128
|
+
interface Err<E> {
|
|
129
|
+
readonly ok: false;
|
|
130
|
+
readonly error: E;
|
|
131
|
+
}
|
|
132
|
+
/** Create a successful Result */
|
|
133
|
+
declare function ok<T>(value: T): Ok<T>;
|
|
134
|
+
/** Create a failed Result */
|
|
135
|
+
declare function err<E>(error: E): Err<E>;
|
|
136
|
+
/** Check if Result is Ok */
|
|
137
|
+
declare function isOk<T, E>(result: Result<T, E>): result is Ok<T>;
|
|
138
|
+
/** Check if Result is Err */
|
|
139
|
+
declare function isErr<T, E>(result: Result<T, E>): result is Err<E>;
|
|
140
|
+
/**
|
|
141
|
+
* Transform the success value of a Result.
|
|
142
|
+
*
|
|
143
|
+
* @example
|
|
144
|
+
* ```typescript
|
|
145
|
+
* const result = ok(5);
|
|
146
|
+
* const doubled = mapResult(result, (n) => n * 2);
|
|
147
|
+
* // doubled = { ok: true, value: 10 }
|
|
148
|
+
* ```
|
|
149
|
+
*/
|
|
150
|
+
declare function mapResult<T, U, E>(result: Result<T, E>, fn: (value: T) => U): Result<U, E>;
|
|
151
|
+
/**
|
|
152
|
+
* Transform the error value of a Result.
|
|
153
|
+
*
|
|
154
|
+
* @example
|
|
155
|
+
* ```typescript
|
|
156
|
+
* const result = err(new Error("oops"));
|
|
157
|
+
* const mapped = mapError(result, (e) => new CustomError(e.message));
|
|
158
|
+
* ```
|
|
159
|
+
*/
|
|
160
|
+
declare function mapError<T, E, F>(result: Result<T, E>, fn: (error: E) => F): Result<T, F>;
|
|
161
|
+
/**
|
|
162
|
+
* Chain Results together. If the first Result is Ok, apply the function.
|
|
163
|
+
* If it's Err, propagate the error.
|
|
164
|
+
*
|
|
165
|
+
* @example
|
|
166
|
+
* ```typescript
|
|
167
|
+
* const getUser = (id: string): Result<User, Error> => { ... }
|
|
168
|
+
* const getOrders = (user: User): Result<Order[], Error> => { ... }
|
|
169
|
+
*
|
|
170
|
+
* const result = flatMap(getUser("123"), (user) => getOrders(user));
|
|
171
|
+
* ```
|
|
172
|
+
*/
|
|
173
|
+
declare function flatMap<T, U, E>(result: Result<T, E>, fn: (value: T) => Result<U, E>): Result<U, E>;
|
|
174
|
+
/**
|
|
175
|
+
* Get the value or a default if the Result is Err.
|
|
176
|
+
*
|
|
177
|
+
* @example
|
|
178
|
+
* ```typescript
|
|
179
|
+
* const result = err(new Error("failed"));
|
|
180
|
+
* const value = getOrElse(result, () => defaultCart);
|
|
181
|
+
* ```
|
|
182
|
+
*/
|
|
183
|
+
declare function getOrElse<T, E>(result: Result<T, E>, defaultFn: () => T): T;
|
|
184
|
+
/**
|
|
185
|
+
* Get the value or throw the error.
|
|
186
|
+
* Use sparingly - defeats the purpose of Result!
|
|
187
|
+
*
|
|
188
|
+
* @example
|
|
189
|
+
* ```typescript
|
|
190
|
+
* const cart = unwrap(result); // throws if Err
|
|
191
|
+
* ```
|
|
192
|
+
*/
|
|
193
|
+
declare function unwrap<T, E>(result: Result<T, E>): T;
|
|
194
|
+
/**
|
|
195
|
+
* Get the value or undefined if Err.
|
|
196
|
+
*
|
|
197
|
+
* @example
|
|
198
|
+
* ```typescript
|
|
199
|
+
* const cart = toNullable(result); // Cart | undefined
|
|
200
|
+
* ```
|
|
201
|
+
*/
|
|
202
|
+
declare function toNullable<T, E>(result: Result<T, E>): T | undefined;
|
|
203
|
+
/**
|
|
204
|
+
* Convert a Promise that might throw into a Result.
|
|
205
|
+
*
|
|
206
|
+
* @example
|
|
207
|
+
* ```typescript
|
|
208
|
+
* const result = await fromPromise(
|
|
209
|
+
* fetch("/api/data"),
|
|
210
|
+
* (error) => new NetworkError(error.message)
|
|
211
|
+
* );
|
|
212
|
+
* ```
|
|
213
|
+
*/
|
|
214
|
+
declare function fromPromise<T, E>(promise: Promise<T>, mapError: (error: unknown) => E): Promise<Result<T, E>>;
|
|
215
|
+
/**
|
|
216
|
+
* Convert a function that might throw into one that returns Result.
|
|
217
|
+
*
|
|
218
|
+
* @example
|
|
219
|
+
* ```typescript
|
|
220
|
+
* const safeParse = tryCatch(
|
|
221
|
+
* () => JSON.parse(input),
|
|
222
|
+
* (e) => new ParseError(e.message)
|
|
223
|
+
* );
|
|
224
|
+
* ```
|
|
225
|
+
*/
|
|
226
|
+
declare function tryCatch<T, E>(fn: () => T, mapError: (error: unknown) => E): Result<T, E>;
|
|
227
|
+
/**
|
|
228
|
+
* Combine multiple Results. Returns Ok with array of values if all succeed,
|
|
229
|
+
* or the first Err encountered.
|
|
230
|
+
*
|
|
231
|
+
* @example
|
|
232
|
+
* ```typescript
|
|
233
|
+
* const results = await Promise.all([
|
|
234
|
+
* client.cart.getSafe(),
|
|
235
|
+
* client.business.getSafe(),
|
|
236
|
+
* ]);
|
|
237
|
+
* const combined = combine(results);
|
|
238
|
+
* // Result<[Cart, Business], CimplifyError>
|
|
239
|
+
* ```
|
|
240
|
+
*/
|
|
241
|
+
declare function combine<T, E>(results: Result<T, E>[]): Result<T[], E>;
|
|
242
|
+
/**
|
|
243
|
+
* Like combine, but for an object of Results.
|
|
244
|
+
*
|
|
245
|
+
* @example
|
|
246
|
+
* ```typescript
|
|
247
|
+
* const data = combineObject({
|
|
248
|
+
* cart: await client.cart.getSafe(),
|
|
249
|
+
* business: await client.business.getSafe(),
|
|
250
|
+
* });
|
|
251
|
+
* // Result<{ cart: Cart, business: Business }, CimplifyError>
|
|
252
|
+
* ```
|
|
253
|
+
*/
|
|
254
|
+
declare function combineObject<T extends Record<string, Result<unknown, unknown>>>(results: T): Result<{
|
|
255
|
+
[K in keyof T]: T[K] extends Result<infer V, unknown> ? V : never;
|
|
256
|
+
}, T[keyof T] extends Result<unknown, infer E> ? E : never>;
|
|
257
|
+
|
|
258
|
+
interface GetProductsOptions {
|
|
259
|
+
category?: string;
|
|
260
|
+
collection?: string;
|
|
261
|
+
search?: string;
|
|
262
|
+
page?: number;
|
|
263
|
+
limit?: number;
|
|
264
|
+
offset?: number;
|
|
265
|
+
cursor?: string;
|
|
266
|
+
tags?: string[];
|
|
267
|
+
featured?: boolean;
|
|
268
|
+
in_stock?: boolean;
|
|
269
|
+
min_price?: number;
|
|
270
|
+
max_price?: number;
|
|
271
|
+
sort_by?: "name" | "price" | "created_at";
|
|
272
|
+
sort_order?: "asc" | "desc";
|
|
273
|
+
}
|
|
274
|
+
interface SearchOptions {
|
|
275
|
+
limit?: number;
|
|
276
|
+
category?: string;
|
|
277
|
+
}
|
|
278
|
+
interface QuoteCompositeSelectionInput {
|
|
279
|
+
component_id: string;
|
|
280
|
+
quantity: number;
|
|
281
|
+
variant_id?: string;
|
|
282
|
+
add_on_option_id?: string;
|
|
283
|
+
}
|
|
284
|
+
interface QuoteBundleSelectionInput {
|
|
285
|
+
component_id: string;
|
|
286
|
+
quantity: number;
|
|
287
|
+
variant_id?: string;
|
|
288
|
+
}
|
|
289
|
+
interface FetchQuoteInput {
|
|
290
|
+
product_id: string;
|
|
291
|
+
variant_id?: string;
|
|
292
|
+
location_id?: string;
|
|
293
|
+
quantity?: number;
|
|
294
|
+
add_on_option_ids?: string[];
|
|
295
|
+
bundle_selections?: QuoteBundleSelectionInput[];
|
|
296
|
+
composite_selections?: QuoteCompositeSelectionInput[];
|
|
297
|
+
}
|
|
298
|
+
interface RefreshQuoteInput {
|
|
299
|
+
quote_id: string;
|
|
300
|
+
product_id?: string;
|
|
301
|
+
variant_id?: string;
|
|
302
|
+
location_id?: string;
|
|
303
|
+
quantity?: number;
|
|
304
|
+
add_on_option_ids?: string[];
|
|
305
|
+
bundle_selections?: QuoteBundleSelectionInput[];
|
|
306
|
+
composite_selections?: QuoteCompositeSelectionInput[];
|
|
307
|
+
}
|
|
308
|
+
type QuoteStatus = "pending" | "used" | "expired";
|
|
309
|
+
interface QuoteDynamicBuckets {
|
|
310
|
+
intent: string;
|
|
311
|
+
demand: string;
|
|
312
|
+
inventory: string;
|
|
313
|
+
competition?: string;
|
|
314
|
+
}
|
|
315
|
+
interface QuoteUiMessage {
|
|
316
|
+
code: string;
|
|
317
|
+
level: "info" | "warn" | "error" | string;
|
|
318
|
+
text: string;
|
|
319
|
+
countdown_seconds?: number;
|
|
320
|
+
}
|
|
321
|
+
interface PriceQuote {
|
|
322
|
+
quote_id: string;
|
|
323
|
+
business_id: string;
|
|
324
|
+
product_id: string;
|
|
325
|
+
variant_id?: string;
|
|
326
|
+
location_id?: string;
|
|
327
|
+
source: string;
|
|
328
|
+
quantity: number;
|
|
329
|
+
currency?: string;
|
|
330
|
+
item_price_info: ChosenPrice;
|
|
331
|
+
variant_price_info?: ChosenPrice;
|
|
332
|
+
final_price_info: ChosenPrice;
|
|
333
|
+
add_on_option_ids: string[];
|
|
334
|
+
bundle_selections?: QuoteBundleSelectionInput[];
|
|
335
|
+
add_ons_price_info?: ChosenPrice;
|
|
336
|
+
quoted_total_price_info?: ChosenPrice;
|
|
337
|
+
composite_selections?: QuoteCompositeSelectionInput[];
|
|
338
|
+
dynamic_buckets: QuoteDynamicBuckets;
|
|
339
|
+
ui_messages: QuoteUiMessage[];
|
|
340
|
+
created_at: string;
|
|
341
|
+
expires_at: string;
|
|
342
|
+
next_change_at?: string;
|
|
343
|
+
status: QuoteStatus;
|
|
344
|
+
}
|
|
345
|
+
interface RefreshQuoteResult {
|
|
346
|
+
previous_quote_id: string;
|
|
347
|
+
quote: PriceQuote;
|
|
348
|
+
}
|
|
349
|
+
declare class CatalogueQueries {
|
|
350
|
+
private client;
|
|
351
|
+
constructor(client: CimplifyClient);
|
|
352
|
+
getProducts(options?: GetProductsOptions): Promise<Result<Product[], CimplifyError>>;
|
|
353
|
+
getProductsWithMeta(options?: GetProductsOptions): Promise<Result<CatalogueResult<Product>, CimplifyError>>;
|
|
354
|
+
getProduct(id: string): Promise<Result<ProductWithDetails, CimplifyError>>;
|
|
355
|
+
getProductBySlug(slug: string): Promise<Result<ProductWithDetails, CimplifyError>>;
|
|
356
|
+
getVariants(productId: string): Promise<Result<ProductVariant[], CimplifyError>>;
|
|
357
|
+
getVariantAxes(productId: string): Promise<Result<VariantAxis[], CimplifyError>>;
|
|
358
|
+
/**
|
|
359
|
+
* Find a variant by axis selections (e.g., { "Size": "Large", "Color": "Red" })
|
|
360
|
+
* Returns the matching variant or null if no match found.
|
|
361
|
+
*/
|
|
362
|
+
getVariantByAxisSelections(productId: string, selections: VariantAxisSelection): Promise<Result<ProductVariant | null, CimplifyError>>;
|
|
363
|
+
/**
|
|
364
|
+
* Get a specific variant by its ID
|
|
365
|
+
*/
|
|
366
|
+
getVariantById(productId: string, variantId: string): Promise<Result<ProductVariant, CimplifyError>>;
|
|
367
|
+
getAddOns(productId: string): Promise<Result<AddOn[], CimplifyError>>;
|
|
368
|
+
getCategories(): Promise<Result<Category[], CimplifyError>>;
|
|
369
|
+
getCategory(id: string): Promise<Result<Category, CimplifyError>>;
|
|
370
|
+
getCategoryBySlug(slug: string): Promise<Result<Category, CimplifyError>>;
|
|
371
|
+
getCategoryProducts(categoryId: string): Promise<Result<Product[], CimplifyError>>;
|
|
372
|
+
getCollections(): Promise<Result<Collection[], CimplifyError>>;
|
|
373
|
+
getCollection(id: string): Promise<Result<Collection, CimplifyError>>;
|
|
374
|
+
getCollectionBySlug(slug: string): Promise<Result<Collection, CimplifyError>>;
|
|
375
|
+
getCollectionProducts(collectionId: string): Promise<Result<Product[], CimplifyError>>;
|
|
376
|
+
searchCollections(query: string, limit?: number): Promise<Result<Collection[], CimplifyError>>;
|
|
377
|
+
getBundles(): Promise<Result<Bundle[], CimplifyError>>;
|
|
378
|
+
getBundle(id: string): Promise<Result<BundleWithDetails, CimplifyError>>;
|
|
379
|
+
getBundleBySlug(slug: string): Promise<Result<BundleWithDetails, CimplifyError>>;
|
|
380
|
+
searchBundles(query: string, limit?: number): Promise<Result<Bundle[], CimplifyError>>;
|
|
381
|
+
getComposites(options?: {
|
|
382
|
+
limit?: number;
|
|
383
|
+
}): Promise<Result<Composite[], CimplifyError>>;
|
|
384
|
+
getComposite(id: string): Promise<Result<CompositeWithDetails, CimplifyError>>;
|
|
385
|
+
getCompositeByProductId(productId: string): Promise<Result<CompositeWithDetails, CimplifyError>>;
|
|
386
|
+
calculateCompositePrice(compositeId: string, selections: ComponentSelectionInput[], locationId?: string): Promise<Result<CompositePriceResult, CimplifyError>>;
|
|
387
|
+
fetchQuote(input: FetchQuoteInput): Promise<Result<PriceQuote, CimplifyError>>;
|
|
388
|
+
getQuote(quoteId: string): Promise<Result<PriceQuote, CimplifyError>>;
|
|
389
|
+
refreshQuote(input: RefreshQuoteInput): Promise<Result<RefreshQuoteResult, CimplifyError>>;
|
|
390
|
+
search(query: string, options?: SearchOptions): Promise<Result<Product[], CimplifyError>>;
|
|
391
|
+
searchProducts(query: string, options?: SearchOptions): Promise<Result<Product[], CimplifyError>>;
|
|
392
|
+
getMenu(options?: {
|
|
393
|
+
category?: string;
|
|
394
|
+
limit?: number;
|
|
395
|
+
}): Promise<Result<Product[], CimplifyError>>;
|
|
396
|
+
getMenuCategory(categoryId: string): Promise<Result<Product[], CimplifyError>>;
|
|
397
|
+
getMenuItem(itemId: string): Promise<Result<ProductWithDetails, CimplifyError>>;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
declare class CartOperations {
|
|
401
|
+
private client;
|
|
402
|
+
constructor(client: CimplifyClient);
|
|
403
|
+
get(): Promise<Result<UICart, CimplifyError>>;
|
|
404
|
+
getRaw(): Promise<Result<Cart, CimplifyError>>;
|
|
405
|
+
getItems(): Promise<Result<CartItem[], CimplifyError>>;
|
|
406
|
+
getCount(): Promise<Result<number, CimplifyError>>;
|
|
407
|
+
getTotal(): Promise<Result<string, CimplifyError>>;
|
|
408
|
+
getSummary(): Promise<Result<CartSummary, CimplifyError>>;
|
|
409
|
+
addItem(input: AddToCartInput): Promise<Result<Cart, CimplifyError>>;
|
|
410
|
+
updateItem(cartItemId: string, updates: UpdateCartItemInput): Promise<Result<Cart, CimplifyError>>;
|
|
411
|
+
updateQuantity(cartItemId: string, quantity: number): Promise<Result<Cart, CimplifyError>>;
|
|
412
|
+
removeItem(cartItemId: string): Promise<Result<Cart, CimplifyError>>;
|
|
413
|
+
clear(): Promise<Result<Cart, CimplifyError>>;
|
|
414
|
+
applyCoupon(code: string): Promise<Result<Cart, CimplifyError>>;
|
|
415
|
+
removeCoupon(): Promise<Result<Cart, CimplifyError>>;
|
|
416
|
+
isEmpty(): Promise<Result<boolean, CimplifyError>>;
|
|
417
|
+
hasItem(productId: string, variantId?: string): Promise<Result<boolean, CimplifyError>>;
|
|
418
|
+
findItem(productId: string, variantId?: string): Promise<Result<CartItem | undefined, CimplifyError>>;
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
type OrderStatus = "pending" | "created" | "confirmed" | "in_preparation" | "ready_to_serve" | "partially_served" | "served" | "delivered" | "picked_up" | "completed" | "cancelled" | "refunded";
|
|
422
|
+
type PaymentState = "not_paid" | "paid" | "partially_refunded" | "refunded";
|
|
423
|
+
type OrderChannel = "qr" | "taker" | "staff" | "web" | "dashboard";
|
|
424
|
+
type LineType = "product" | "service" | "bundle" | "composite" | "digital";
|
|
425
|
+
type OrderLineState = {
|
|
426
|
+
state: "pending";
|
|
427
|
+
} | {
|
|
428
|
+
state: "in_preparation";
|
|
429
|
+
} | {
|
|
430
|
+
state: "ready";
|
|
431
|
+
} | {
|
|
432
|
+
state: "partially_served";
|
|
433
|
+
served_quantity: number;
|
|
434
|
+
} | {
|
|
435
|
+
state: "served";
|
|
436
|
+
} | {
|
|
437
|
+
state: "completed";
|
|
438
|
+
} | {
|
|
439
|
+
state: "cancelled";
|
|
440
|
+
reason?: string;
|
|
441
|
+
};
|
|
442
|
+
interface OrderLineStatus {
|
|
443
|
+
state: OrderLineState;
|
|
444
|
+
quantity_ordered: number;
|
|
445
|
+
quantity_prepared: number;
|
|
446
|
+
quantity_served: number;
|
|
447
|
+
last_modified: string;
|
|
448
|
+
modified_by: string;
|
|
449
|
+
}
|
|
450
|
+
type FulfillmentType = "appointment" | "shipment" | "order" | "digital";
|
|
451
|
+
type FulfillmentStatus = "pending" | "in_progress" | "completed" | "cancelled";
|
|
452
|
+
interface FulfillmentLink {
|
|
453
|
+
fulfillment_type: FulfillmentType;
|
|
454
|
+
fulfillment_id: string;
|
|
455
|
+
}
|
|
456
|
+
interface OrderFulfillmentSummary {
|
|
457
|
+
total_items: number;
|
|
458
|
+
pending_items: number;
|
|
459
|
+
in_progress_items: number;
|
|
460
|
+
completed_items: number;
|
|
461
|
+
cancelled_items: number;
|
|
462
|
+
all_complete: boolean;
|
|
463
|
+
any_in_progress: boolean;
|
|
464
|
+
}
|
|
465
|
+
type FeeBearerType = "customer" | "business" | "split";
|
|
466
|
+
interface AmountToPay {
|
|
467
|
+
customer_pays: Money;
|
|
468
|
+
business_receives: Money;
|
|
469
|
+
cimplify_receives: Money;
|
|
470
|
+
provider_receives: Money;
|
|
471
|
+
fee_bearer: FeeBearerType;
|
|
472
|
+
}
|
|
473
|
+
interface LineItem {
|
|
474
|
+
id: string;
|
|
475
|
+
order_id: string;
|
|
476
|
+
product_id: string;
|
|
477
|
+
line_key: string;
|
|
478
|
+
quantity: number;
|
|
479
|
+
configuration: LineConfiguration;
|
|
480
|
+
price: Money;
|
|
481
|
+
add_ons_price: Money;
|
|
482
|
+
price_info: ChosenPrice;
|
|
483
|
+
item_discount_amount: Money;
|
|
484
|
+
discount_details?: DiscountDetails;
|
|
485
|
+
created_at: string;
|
|
486
|
+
updated_at: string;
|
|
487
|
+
line_state: OrderLineStatus;
|
|
488
|
+
metadata?: Record<string, unknown>;
|
|
489
|
+
fulfillment_type?: FulfillmentType;
|
|
490
|
+
fulfillment_id?: string;
|
|
491
|
+
}
|
|
492
|
+
interface Order {
|
|
493
|
+
id: string;
|
|
494
|
+
business_id: string;
|
|
495
|
+
channel: OrderChannel;
|
|
496
|
+
status: OrderStatus;
|
|
497
|
+
payment_state: PaymentState;
|
|
498
|
+
order_type: string;
|
|
499
|
+
placed_by?: string;
|
|
500
|
+
user_friendly_id: string;
|
|
501
|
+
customer_id?: string;
|
|
502
|
+
customer_name?: string;
|
|
503
|
+
customer_email?: string;
|
|
504
|
+
customer_phone?: string;
|
|
505
|
+
customer_notes?: string[];
|
|
506
|
+
discount_code?: string;
|
|
507
|
+
applied_discount_ids: string[];
|
|
508
|
+
applied_discount_codes: string[];
|
|
509
|
+
discount_details?: DiscountDetails;
|
|
510
|
+
delivery_address?: string;
|
|
511
|
+
tracking_token?: string;
|
|
512
|
+
tracking_link?: string;
|
|
513
|
+
pickup_time?: string;
|
|
514
|
+
created_at: string;
|
|
515
|
+
updated_at: string;
|
|
516
|
+
delivered_at?: string;
|
|
517
|
+
fulfilled_at?: string;
|
|
518
|
+
confirmed_at?: string;
|
|
519
|
+
served_at?: string;
|
|
520
|
+
completed_at?: string;
|
|
521
|
+
cancelled_at?: string;
|
|
522
|
+
table_number?: string;
|
|
523
|
+
room_number?: string;
|
|
524
|
+
location_id?: string;
|
|
525
|
+
was_placed_by_staff: boolean;
|
|
526
|
+
modified_by_staff: boolean;
|
|
527
|
+
delivery_required: boolean;
|
|
528
|
+
customer_will_pick_up: boolean;
|
|
529
|
+
total_price: Money;
|
|
530
|
+
total_excl_tax_discount_and_service_charge: Money;
|
|
531
|
+
total_discount: Money;
|
|
532
|
+
service_charge?: Money;
|
|
533
|
+
tax?: Money;
|
|
534
|
+
price_info: ChosenPrice;
|
|
535
|
+
currency: CurrencyCode;
|
|
536
|
+
bill_token?: string;
|
|
537
|
+
order_group_id?: string;
|
|
538
|
+
paid_via_group: boolean;
|
|
539
|
+
amount_to_pay: AmountToPay;
|
|
540
|
+
served_by?: string;
|
|
541
|
+
metadata?: Record<string, unknown>;
|
|
542
|
+
requires_scheduling: boolean;
|
|
543
|
+
all_items_scheduled: boolean;
|
|
544
|
+
earliest_service_time?: string;
|
|
545
|
+
latest_service_time?: string;
|
|
546
|
+
deposit_required: boolean;
|
|
547
|
+
deposit_amount: Money;
|
|
548
|
+
deposit_paid_amount: Money;
|
|
549
|
+
balance_due: Money;
|
|
550
|
+
deposit_due_date?: string;
|
|
551
|
+
final_payment_due_date?: string;
|
|
552
|
+
version: number;
|
|
553
|
+
total_quantity: number;
|
|
554
|
+
items: LineItem[];
|
|
555
|
+
computed_payment_status?: string;
|
|
556
|
+
is_service_only?: boolean;
|
|
557
|
+
}
|
|
558
|
+
interface OrderHistory {
|
|
559
|
+
id: string;
|
|
560
|
+
order_id: string;
|
|
561
|
+
modified_by: string;
|
|
562
|
+
modification_type: string;
|
|
563
|
+
modification_details: string;
|
|
564
|
+
modified_at: string;
|
|
565
|
+
metadata?: Record<string, unknown>;
|
|
566
|
+
}
|
|
567
|
+
type OrderGroupPaymentState = "not_paid" | "partially_paid" | "fully_paid" | "refunded";
|
|
568
|
+
interface OrderGroup {
|
|
569
|
+
id: string;
|
|
570
|
+
business_id: string;
|
|
571
|
+
location_id: string;
|
|
572
|
+
table_number: string;
|
|
573
|
+
created_at: string;
|
|
574
|
+
updated_at: string;
|
|
575
|
+
status: string;
|
|
576
|
+
is_split: boolean;
|
|
577
|
+
is_closed: boolean;
|
|
578
|
+
total_amount?: Money;
|
|
579
|
+
paid_amount?: Money;
|
|
580
|
+
payment_status: OrderGroupPaymentState;
|
|
581
|
+
split_method?: string;
|
|
582
|
+
max_orders?: number;
|
|
583
|
+
currency?: CurrencyCode;
|
|
584
|
+
amount_to_pay: AmountToPay;
|
|
585
|
+
metadata?: Record<string, unknown>;
|
|
586
|
+
}
|
|
587
|
+
interface OrderGroupPayment {
|
|
588
|
+
id: string;
|
|
589
|
+
order_group_id: string;
|
|
590
|
+
order_id?: string;
|
|
591
|
+
amount: Money;
|
|
592
|
+
payment_method: string;
|
|
593
|
+
status: string;
|
|
594
|
+
created_at: string;
|
|
595
|
+
updated_at: string;
|
|
596
|
+
metadata?: Record<string, unknown>;
|
|
597
|
+
}
|
|
598
|
+
interface OrderSplitDetail {
|
|
599
|
+
order_id: string;
|
|
600
|
+
amount: Money;
|
|
601
|
+
paid_amount?: Money;
|
|
602
|
+
remaining_amount?: Money;
|
|
603
|
+
}
|
|
604
|
+
interface OrderGroupPaymentSummary {
|
|
605
|
+
total_amount: Money;
|
|
606
|
+
paid_amount: Money;
|
|
607
|
+
remaining_amount: Money;
|
|
608
|
+
split_details?: OrderSplitDetail[];
|
|
609
|
+
}
|
|
610
|
+
interface OrderGroupDetails {
|
|
611
|
+
order_group: OrderGroup;
|
|
612
|
+
orders: Order[];
|
|
613
|
+
total: Money;
|
|
614
|
+
payments: OrderGroupPayment[];
|
|
615
|
+
payment_summary: OrderGroupPaymentSummary;
|
|
616
|
+
}
|
|
617
|
+
interface OrderPaymentEvent {
|
|
618
|
+
id: string;
|
|
619
|
+
order_id: string;
|
|
620
|
+
amount: Money;
|
|
621
|
+
reference: string;
|
|
622
|
+
created_at: string;
|
|
623
|
+
event_type: string;
|
|
624
|
+
provider?: string;
|
|
625
|
+
metadata?: Record<string, unknown>;
|
|
626
|
+
}
|
|
627
|
+
interface OrderFilter {
|
|
628
|
+
location_id?: string;
|
|
629
|
+
table_number?: string;
|
|
630
|
+
order_type?: string;
|
|
631
|
+
status?: string;
|
|
632
|
+
from?: string;
|
|
633
|
+
to?: string;
|
|
634
|
+
search?: string;
|
|
635
|
+
limit?: number;
|
|
636
|
+
offset?: number;
|
|
637
|
+
}
|
|
638
|
+
interface CheckoutInput {
|
|
639
|
+
customer_name?: string;
|
|
640
|
+
customer_email?: string;
|
|
641
|
+
customer_phone?: string;
|
|
642
|
+
delivery_address?: string;
|
|
643
|
+
order_type?: string;
|
|
644
|
+
notes?: string;
|
|
645
|
+
table_number?: string;
|
|
646
|
+
room_number?: string;
|
|
647
|
+
}
|
|
648
|
+
interface UpdateOrderStatusInput {
|
|
649
|
+
status: OrderStatus;
|
|
650
|
+
notes?: string;
|
|
651
|
+
}
|
|
652
|
+
interface CancelOrderInput {
|
|
653
|
+
reason?: string;
|
|
654
|
+
}
|
|
655
|
+
interface RefundOrderInput {
|
|
656
|
+
amount?: Money;
|
|
657
|
+
reason?: string;
|
|
658
|
+
}
|
|
659
|
+
type ServiceStatus = "awaiting_scheduling" | "scheduled" | "deposit_paid" | "confirmed" | "in_progress" | "completed" | "rescheduled" | "no_show" | "cancelled";
|
|
660
|
+
type StaffRole = "primary" | "assistant" | "specialist" | "supervisor";
|
|
661
|
+
type ReminderMethod = "sms" | "email" | "push" | "call" | "whatsapp";
|
|
662
|
+
interface CustomerServicePreferences {
|
|
663
|
+
preferred_staff_ids: string[];
|
|
664
|
+
avoid_staff_ids: string[];
|
|
665
|
+
room_type?: string;
|
|
666
|
+
accessibility_needs: string[];
|
|
667
|
+
temperature_preference?: string;
|
|
668
|
+
music_preference?: string;
|
|
669
|
+
special_requests?: string;
|
|
670
|
+
previous_service_history: string[];
|
|
671
|
+
}
|
|
672
|
+
interface BufferTimes {
|
|
673
|
+
before_minutes: number;
|
|
674
|
+
after_minutes: number;
|
|
675
|
+
travel_time_minutes?: number;
|
|
676
|
+
setup_time_minutes?: number;
|
|
677
|
+
cleanup_time_minutes?: number;
|
|
678
|
+
}
|
|
679
|
+
interface ReminderSettings {
|
|
680
|
+
send_24h_reminder: boolean;
|
|
681
|
+
send_2h_reminder: boolean;
|
|
682
|
+
send_30min_reminder: boolean;
|
|
683
|
+
reminder_phone?: string;
|
|
684
|
+
reminder_email?: string;
|
|
685
|
+
reminder_method: ReminderMethod;
|
|
686
|
+
custom_reminder_message?: string;
|
|
687
|
+
}
|
|
688
|
+
interface CancellationPolicy {
|
|
689
|
+
free_cancellation_hours: number;
|
|
690
|
+
partial_refund_hours: number;
|
|
691
|
+
no_refund_hours: number;
|
|
692
|
+
cancellation_fee?: Money;
|
|
693
|
+
reschedule_allowed: boolean;
|
|
694
|
+
reschedule_fee?: Money;
|
|
695
|
+
max_reschedules?: number;
|
|
696
|
+
}
|
|
697
|
+
interface ServiceNotes {
|
|
698
|
+
preparation_notes?: string;
|
|
699
|
+
staff_notes?: string;
|
|
700
|
+
internal_notes?: string;
|
|
701
|
+
customer_history: string[];
|
|
702
|
+
allergies_warnings: string[];
|
|
703
|
+
}
|
|
704
|
+
interface PricingOverrides {
|
|
705
|
+
custom_duration_minutes?: number;
|
|
706
|
+
price_adjustment?: Money;
|
|
707
|
+
discount_reason?: string;
|
|
708
|
+
surge_pricing_multiplier?: Money;
|
|
709
|
+
loyalty_discount?: Money;
|
|
710
|
+
package_deal_reference?: string;
|
|
711
|
+
}
|
|
712
|
+
interface SchedulingMetadata {
|
|
713
|
+
customer_preferences?: CustomerServicePreferences;
|
|
714
|
+
buffer_times?: BufferTimes;
|
|
715
|
+
reminder_settings?: ReminderSettings;
|
|
716
|
+
cancellation_policy?: CancellationPolicy;
|
|
717
|
+
service_notes?: ServiceNotes;
|
|
718
|
+
pricing_overrides?: PricingOverrides;
|
|
719
|
+
}
|
|
720
|
+
interface StaffAssignment {
|
|
721
|
+
staff_id: string;
|
|
722
|
+
role: StaffRole;
|
|
723
|
+
assigned_at: string;
|
|
724
|
+
notes?: string;
|
|
725
|
+
}
|
|
726
|
+
interface ResourceAssignment {
|
|
727
|
+
resource_id: string;
|
|
728
|
+
quantity: number;
|
|
729
|
+
assigned_at: string;
|
|
730
|
+
notes?: string;
|
|
731
|
+
}
|
|
732
|
+
interface SchedulingResult {
|
|
733
|
+
confirmation_code: string;
|
|
734
|
+
assigned_staff: StaffAssignment[];
|
|
735
|
+
assigned_resources: ResourceAssignment[];
|
|
736
|
+
deposit_required: boolean;
|
|
737
|
+
deposit_amount?: Money;
|
|
738
|
+
total_duration_minutes: number;
|
|
739
|
+
}
|
|
740
|
+
interface DepositResult {
|
|
741
|
+
order_confirmed: boolean;
|
|
742
|
+
balance_due: Money;
|
|
743
|
+
final_payment_due?: string;
|
|
744
|
+
confirmation_sent: boolean;
|
|
745
|
+
}
|
|
746
|
+
interface ServiceScheduleRequest {
|
|
747
|
+
line_item_id: string;
|
|
748
|
+
start_time: string;
|
|
749
|
+
end_time: string;
|
|
750
|
+
preferred_staff_ids?: string[];
|
|
751
|
+
resource_requirements?: string[];
|
|
752
|
+
customer_notes?: string;
|
|
753
|
+
}
|
|
754
|
+
interface StaffScheduleItem {
|
|
755
|
+
line_item_id: string;
|
|
756
|
+
order_id: string;
|
|
757
|
+
customer_name: string;
|
|
758
|
+
service_name: string;
|
|
759
|
+
start_time: string;
|
|
760
|
+
end_time: string;
|
|
761
|
+
confirmation_code: string;
|
|
762
|
+
service_status: ServiceStatus;
|
|
763
|
+
notes?: string;
|
|
764
|
+
}
|
|
765
|
+
interface LocationAppointment {
|
|
766
|
+
line_item_id: string;
|
|
767
|
+
order_id: string;
|
|
768
|
+
customer_name: string;
|
|
769
|
+
service_name: string;
|
|
770
|
+
start_time: string;
|
|
771
|
+
end_time: string;
|
|
772
|
+
assigned_staff: string[];
|
|
773
|
+
assigned_resources: string[];
|
|
774
|
+
service_status: ServiceStatus;
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
declare const CHECKOUT_MODE: {
|
|
778
|
+
readonly LINK: "link";
|
|
779
|
+
readonly GUEST: "guest";
|
|
780
|
+
};
|
|
781
|
+
declare const ORDER_TYPE: {
|
|
782
|
+
readonly DELIVERY: "delivery";
|
|
783
|
+
readonly PICKUP: "pickup";
|
|
784
|
+
readonly DINE_IN: "dine-in";
|
|
785
|
+
readonly WALK_IN: "walk-in";
|
|
786
|
+
};
|
|
787
|
+
declare const PAYMENT_METHOD: {
|
|
788
|
+
readonly MOBILE_MONEY: "mobile_money";
|
|
789
|
+
readonly CARD: "card";
|
|
790
|
+
};
|
|
791
|
+
declare const CHECKOUT_STEP: {
|
|
792
|
+
readonly AUTHENTICATION: "authentication";
|
|
793
|
+
readonly ORDER_DETAILS: "order_details";
|
|
794
|
+
readonly PAYMENT_METHOD: "payment_method";
|
|
795
|
+
readonly PAYMENT: "payment";
|
|
796
|
+
readonly CONFIRMATION: "confirmation";
|
|
797
|
+
};
|
|
798
|
+
declare const PAYMENT_STATE: {
|
|
799
|
+
readonly INITIAL: "initial";
|
|
800
|
+
readonly PREPARING: "preparing";
|
|
801
|
+
readonly PROCESSING: "processing";
|
|
802
|
+
readonly VERIFYING: "verifying";
|
|
803
|
+
readonly AWAITING_AUTHORIZATION: "awaiting_authorization";
|
|
804
|
+
readonly SUCCESS: "success";
|
|
805
|
+
readonly ERROR: "error";
|
|
806
|
+
readonly TIMEOUT: "timeout";
|
|
807
|
+
};
|
|
808
|
+
declare const PICKUP_TIME_TYPE: {
|
|
809
|
+
readonly ASAP: "asap";
|
|
810
|
+
readonly SCHEDULED: "scheduled";
|
|
811
|
+
};
|
|
812
|
+
declare const MOBILE_MONEY_PROVIDER: {
|
|
813
|
+
readonly MTN: "mtn";
|
|
814
|
+
readonly VODAFONE: "vodafone";
|
|
815
|
+
readonly AIRTEL: "airtel";
|
|
816
|
+
};
|
|
817
|
+
declare const AUTHORIZATION_TYPE: {
|
|
818
|
+
readonly OTP: "otp";
|
|
819
|
+
readonly PIN: "pin";
|
|
820
|
+
readonly PHONE: "phone";
|
|
821
|
+
readonly BIRTHDAY: "birthday";
|
|
822
|
+
readonly ADDRESS: "address";
|
|
823
|
+
};
|
|
824
|
+
declare const DEVICE_TYPE: {
|
|
825
|
+
readonly MOBILE: "mobile";
|
|
826
|
+
readonly DESKTOP: "desktop";
|
|
827
|
+
readonly TABLET: "tablet";
|
|
828
|
+
};
|
|
829
|
+
declare const CONTACT_TYPE: {
|
|
830
|
+
readonly PHONE: "phone";
|
|
831
|
+
readonly EMAIL: "email";
|
|
832
|
+
};
|
|
833
|
+
declare const LINK_QUERY: {
|
|
834
|
+
readonly DATA: "link.data";
|
|
835
|
+
readonly ADDRESSES: "link.addresses";
|
|
836
|
+
readonly MOBILE_MONEY: "link.mobile_money";
|
|
837
|
+
readonly PREFERENCES: "link.preferences";
|
|
838
|
+
readonly SESSIONS: "link.sessions";
|
|
839
|
+
};
|
|
840
|
+
declare const LINK_MUTATION: {
|
|
841
|
+
readonly CHECK_STATUS: "link.check_status";
|
|
842
|
+
readonly ENROLL: "link.enroll";
|
|
843
|
+
readonly ENROLL_AND_LINK_ORDER: "link.enroll_and_link_order";
|
|
844
|
+
readonly UPDATE_PREFERENCES: "link.update_preferences";
|
|
845
|
+
readonly CREATE_ADDRESS: "link.create_address";
|
|
846
|
+
readonly UPDATE_ADDRESS: "link.update_address";
|
|
847
|
+
readonly DELETE_ADDRESS: "link.delete_address";
|
|
848
|
+
readonly SET_DEFAULT_ADDRESS: "link.set_default_address";
|
|
849
|
+
readonly TRACK_ADDRESS_USAGE: "link.track_address_usage";
|
|
850
|
+
readonly CREATE_MOBILE_MONEY: "link.create_mobile_money";
|
|
851
|
+
readonly DELETE_MOBILE_MONEY: "link.delete_mobile_money";
|
|
852
|
+
readonly SET_DEFAULT_MOBILE_MONEY: "link.set_default_mobile_money";
|
|
853
|
+
readonly TRACK_MOBILE_MONEY_USAGE: "link.track_mobile_money_usage";
|
|
854
|
+
readonly VERIFY_MOBILE_MONEY: "link.verify_mobile_money";
|
|
855
|
+
readonly REVOKE_SESSION: "link.revoke_session";
|
|
856
|
+
readonly REVOKE_ALL_SESSIONS: "link.revoke_all_sessions";
|
|
857
|
+
};
|
|
858
|
+
declare const AUTH_MUTATION: {
|
|
859
|
+
readonly REQUEST_OTP: "auth.request_otp";
|
|
860
|
+
readonly VERIFY_OTP: "auth.verify_otp";
|
|
861
|
+
};
|
|
862
|
+
declare const CHECKOUT_MUTATION: {
|
|
863
|
+
readonly PROCESS: "checkout.process";
|
|
864
|
+
};
|
|
865
|
+
declare const PAYMENT_MUTATION: {
|
|
866
|
+
readonly SUBMIT_AUTHORIZATION: "payment.submit_authorization";
|
|
867
|
+
readonly CHECK_STATUS: "order.poll_payment_status";
|
|
868
|
+
};
|
|
869
|
+
declare const ORDER_MUTATION: {
|
|
870
|
+
readonly UPDATE_CUSTOMER: "order.update_order_customer";
|
|
871
|
+
};
|
|
872
|
+
declare const DEFAULT_CURRENCY = "GHS";
|
|
873
|
+
declare const DEFAULT_COUNTRY = "GHA";
|
|
874
|
+
|
|
875
|
+
type MobileMoneyProvider = (typeof MOBILE_MONEY_PROVIDER)[keyof typeof MOBILE_MONEY_PROVIDER];
|
|
876
|
+
interface Customer {
|
|
877
|
+
id: string;
|
|
878
|
+
email: string | null;
|
|
879
|
+
phone: string | null;
|
|
880
|
+
name: string;
|
|
881
|
+
delivery_address: string | null;
|
|
882
|
+
created_at: string;
|
|
883
|
+
updated_at: string;
|
|
884
|
+
metadata?: Record<string, unknown>;
|
|
885
|
+
}
|
|
886
|
+
interface CustomerAddress {
|
|
887
|
+
id: string;
|
|
888
|
+
customer_id: string;
|
|
889
|
+
label: string;
|
|
890
|
+
street_address: string;
|
|
891
|
+
apartment: string | null;
|
|
892
|
+
city: string;
|
|
893
|
+
region: string;
|
|
894
|
+
postal_code: string | null;
|
|
895
|
+
country: string | null;
|
|
896
|
+
delivery_instructions: string | null;
|
|
897
|
+
phone_for_delivery: string | null;
|
|
898
|
+
latitude: number | null;
|
|
899
|
+
longitude: number | null;
|
|
900
|
+
is_default: boolean | null;
|
|
901
|
+
usage_count: number | null;
|
|
902
|
+
last_used_at: string | null;
|
|
903
|
+
created_at: string;
|
|
904
|
+
updated_at: string;
|
|
905
|
+
}
|
|
906
|
+
interface CustomerMobileMoney {
|
|
907
|
+
id: string;
|
|
908
|
+
customer_id: string;
|
|
909
|
+
phone_number: string;
|
|
910
|
+
provider: MobileMoneyProvider;
|
|
911
|
+
label: string;
|
|
912
|
+
is_verified: boolean | null;
|
|
913
|
+
verification_date: string | null;
|
|
914
|
+
is_default: boolean | null;
|
|
915
|
+
usage_count: number | null;
|
|
916
|
+
last_used_at: string | null;
|
|
917
|
+
success_rate: number | null;
|
|
918
|
+
created_at: string;
|
|
919
|
+
updated_at: string;
|
|
920
|
+
}
|
|
921
|
+
interface CustomerLinkPreferences {
|
|
922
|
+
customer_id: string;
|
|
923
|
+
is_link_enabled: boolean | null;
|
|
924
|
+
enrolled_at: string | null;
|
|
925
|
+
enrollment_business_id: string | null;
|
|
926
|
+
preferred_order_type: string | null;
|
|
927
|
+
default_address_id: string | null;
|
|
928
|
+
default_mobile_money_id: string | null;
|
|
929
|
+
remember_me: boolean | null;
|
|
930
|
+
session_duration_days: number | null;
|
|
931
|
+
two_factor_enabled: boolean | null;
|
|
932
|
+
notify_on_order: boolean | null;
|
|
933
|
+
notify_on_payment: boolean | null;
|
|
934
|
+
created_at: string;
|
|
935
|
+
updated_at: string;
|
|
936
|
+
}
|
|
937
|
+
interface LinkData {
|
|
938
|
+
customer: Customer;
|
|
939
|
+
addresses: CustomerAddress[];
|
|
940
|
+
mobile_money: CustomerMobileMoney[];
|
|
941
|
+
preferences: CustomerLinkPreferences;
|
|
942
|
+
default_address: CustomerAddress | null;
|
|
943
|
+
default_mobile_money: CustomerMobileMoney | null;
|
|
944
|
+
}
|
|
945
|
+
interface CreateAddressInput {
|
|
946
|
+
address_line1: string;
|
|
947
|
+
address_line2?: string;
|
|
948
|
+
city: string;
|
|
949
|
+
state?: string;
|
|
950
|
+
postal_code?: string;
|
|
951
|
+
country: string;
|
|
952
|
+
label?: string;
|
|
953
|
+
}
|
|
954
|
+
interface UpdateAddressInput {
|
|
955
|
+
address_id: string;
|
|
956
|
+
address_line1?: string;
|
|
957
|
+
address_line2?: string;
|
|
958
|
+
city?: string;
|
|
959
|
+
state?: string;
|
|
960
|
+
postal_code?: string;
|
|
961
|
+
country?: string;
|
|
962
|
+
label?: string;
|
|
963
|
+
}
|
|
964
|
+
interface CreateMobileMoneyInput {
|
|
965
|
+
phone_number: string;
|
|
966
|
+
provider: string;
|
|
967
|
+
account_name?: string;
|
|
968
|
+
}
|
|
969
|
+
interface EnrollmentData {
|
|
970
|
+
contact: string;
|
|
971
|
+
name?: string;
|
|
972
|
+
}
|
|
973
|
+
interface AddressData {
|
|
974
|
+
label: string;
|
|
975
|
+
street_address: string;
|
|
976
|
+
apartment?: string;
|
|
977
|
+
city: string;
|
|
978
|
+
region: string;
|
|
979
|
+
delivery_instructions?: string;
|
|
980
|
+
phone_for_delivery?: string;
|
|
981
|
+
}
|
|
982
|
+
interface MobileMoneyData {
|
|
983
|
+
phone_number: string;
|
|
984
|
+
provider: string;
|
|
985
|
+
label: string;
|
|
986
|
+
}
|
|
987
|
+
interface EnrollAndLinkOrderInput {
|
|
988
|
+
order_id: string;
|
|
989
|
+
business_id: string;
|
|
990
|
+
address?: AddressData;
|
|
991
|
+
mobile_money?: MobileMoneyData;
|
|
992
|
+
order_type?: string;
|
|
993
|
+
}
|
|
994
|
+
interface LinkStatusResult {
|
|
995
|
+
is_link_customer: boolean;
|
|
996
|
+
}
|
|
997
|
+
interface LinkEnrollResult {
|
|
998
|
+
success: boolean;
|
|
999
|
+
customer_id: string;
|
|
1000
|
+
contact?: string;
|
|
1001
|
+
enrolled_at?: string;
|
|
1002
|
+
preferences?: CustomerLinkPreferences;
|
|
1003
|
+
}
|
|
1004
|
+
interface EnrollAndLinkOrderResult {
|
|
1005
|
+
success: boolean;
|
|
1006
|
+
customer_id: string;
|
|
1007
|
+
order_id: string;
|
|
1008
|
+
enrollment_result: unknown;
|
|
1009
|
+
linked_at: string;
|
|
1010
|
+
}
|
|
1011
|
+
type DeviceType = (typeof DEVICE_TYPE)[keyof typeof DEVICE_TYPE];
|
|
1012
|
+
interface LinkSession {
|
|
1013
|
+
id: string;
|
|
1014
|
+
device_name: string | null;
|
|
1015
|
+
device_type: DeviceType | null;
|
|
1016
|
+
ip_address: string | null;
|
|
1017
|
+
last_used_at: string | null;
|
|
1018
|
+
created_at: string;
|
|
1019
|
+
is_current: boolean;
|
|
1020
|
+
}
|
|
1021
|
+
interface RevokeSessionResult {
|
|
1022
|
+
success: boolean;
|
|
1023
|
+
session_id: string;
|
|
1024
|
+
message: string;
|
|
1025
|
+
}
|
|
1026
|
+
interface RevokeAllSessionsResult {
|
|
1027
|
+
success: boolean;
|
|
1028
|
+
revoked_count: number;
|
|
1029
|
+
message: string;
|
|
1030
|
+
}
|
|
1031
|
+
type ContactType = (typeof CONTACT_TYPE)[keyof typeof CONTACT_TYPE];
|
|
1032
|
+
interface RequestOtpInput {
|
|
1033
|
+
contact: string;
|
|
1034
|
+
contact_type: ContactType;
|
|
1035
|
+
}
|
|
1036
|
+
interface VerifyOtpInput {
|
|
1037
|
+
contact: string;
|
|
1038
|
+
contact_type: ContactType;
|
|
1039
|
+
otp_code: string;
|
|
1040
|
+
}
|
|
1041
|
+
interface AuthResponse {
|
|
1042
|
+
success: boolean;
|
|
1043
|
+
session_token: string | null;
|
|
1044
|
+
customer_id: string | null;
|
|
1045
|
+
message: string;
|
|
1046
|
+
}
|
|
1047
|
+
|
|
1048
|
+
type CheckoutMode = (typeof CHECKOUT_MODE)[keyof typeof CHECKOUT_MODE];
|
|
1049
|
+
type CheckoutOrderType = (typeof ORDER_TYPE)[keyof typeof ORDER_TYPE];
|
|
1050
|
+
type CheckoutPaymentMethod = (typeof PAYMENT_METHOD)[keyof typeof PAYMENT_METHOD];
|
|
1051
|
+
type CheckoutStep = (typeof CHECKOUT_STEP)[keyof typeof CHECKOUT_STEP];
|
|
1052
|
+
type PickupTimeType = (typeof PICKUP_TIME_TYPE)[keyof typeof PICKUP_TIME_TYPE];
|
|
1053
|
+
interface PickupTime {
|
|
1054
|
+
type: PickupTimeType;
|
|
1055
|
+
scheduled_time?: string;
|
|
1056
|
+
}
|
|
1057
|
+
interface CheckoutAddressInfo {
|
|
1058
|
+
street_address?: string;
|
|
1059
|
+
apartment?: string;
|
|
1060
|
+
city?: string;
|
|
1061
|
+
region?: string;
|
|
1062
|
+
postal_code?: string;
|
|
1063
|
+
country?: string;
|
|
1064
|
+
delivery_instructions?: string;
|
|
1065
|
+
phone_for_delivery?: string;
|
|
1066
|
+
pickup_time?: string;
|
|
1067
|
+
guest_count?: number;
|
|
1068
|
+
seating_time?: string;
|
|
1069
|
+
seating_requests?: string;
|
|
1070
|
+
}
|
|
1071
|
+
interface MobileMoneyDetails {
|
|
1072
|
+
phone_number: string;
|
|
1073
|
+
provider: MobileMoneyProvider;
|
|
1074
|
+
provider_other?: string;
|
|
1075
|
+
}
|
|
1076
|
+
interface CheckoutCustomerInfo {
|
|
1077
|
+
name: string;
|
|
1078
|
+
email: string;
|
|
1079
|
+
phone: string;
|
|
1080
|
+
notes?: string;
|
|
1081
|
+
save_details: boolean;
|
|
1082
|
+
}
|
|
1083
|
+
interface CheckoutFormData {
|
|
1084
|
+
cart_id: string;
|
|
1085
|
+
location_id?: string;
|
|
1086
|
+
customer: CheckoutCustomerInfo;
|
|
1087
|
+
order_type: CheckoutOrderType;
|
|
1088
|
+
address_info: CheckoutAddressInfo;
|
|
1089
|
+
payment_method: string;
|
|
1090
|
+
mobile_money_details?: MobileMoneyDetails;
|
|
1091
|
+
special_instructions?: string;
|
|
1092
|
+
link_address_id?: string;
|
|
1093
|
+
link_payment_method_id?: string;
|
|
1094
|
+
idempotency_key?: string;
|
|
1095
|
+
/** Optional metadata passed through to the payment provider (e.g. success_url, cancel_url) */
|
|
1096
|
+
metadata?: Record<string, unknown>;
|
|
1097
|
+
pay_currency?: CurrencyCode;
|
|
1098
|
+
fx_quote_id?: string;
|
|
1099
|
+
}
|
|
1100
|
+
interface CheckoutResult {
|
|
1101
|
+
order_id: string;
|
|
1102
|
+
order_number: string;
|
|
1103
|
+
payment_reference?: string;
|
|
1104
|
+
payment_status: string;
|
|
1105
|
+
requires_authorization: boolean;
|
|
1106
|
+
authorization_type?: AuthorizationType;
|
|
1107
|
+
authorization_url?: string;
|
|
1108
|
+
display_text?: string;
|
|
1109
|
+
provider?: string;
|
|
1110
|
+
client_secret?: string;
|
|
1111
|
+
public_key?: string;
|
|
1112
|
+
fx?: {
|
|
1113
|
+
base_currency: CurrencyCode;
|
|
1114
|
+
base_amount: Money;
|
|
1115
|
+
pay_currency: CurrencyCode;
|
|
1116
|
+
pay_amount: Money;
|
|
1117
|
+
rate: number;
|
|
1118
|
+
quote_id: string;
|
|
1119
|
+
};
|
|
1120
|
+
}
|
|
1121
|
+
type CheckoutStatus = "preparing" | "recovering" | "processing" | "awaiting_authorization" | "polling" | "finalizing" | "success" | "failed";
|
|
1122
|
+
interface CheckoutStatusContext {
|
|
1123
|
+
display_text?: string;
|
|
1124
|
+
authorization_type?: "otp" | "pin";
|
|
1125
|
+
poll_attempt?: number;
|
|
1126
|
+
max_poll_attempts?: number;
|
|
1127
|
+
order_id?: string;
|
|
1128
|
+
order_number?: string;
|
|
1129
|
+
provider?: string;
|
|
1130
|
+
}
|
|
1131
|
+
interface ProcessCheckoutOptions {
|
|
1132
|
+
cart_id: string;
|
|
1133
|
+
order_type: "delivery" | "pickup" | "dine_in";
|
|
1134
|
+
location_id?: string;
|
|
1135
|
+
notes?: string;
|
|
1136
|
+
scheduled_time?: string;
|
|
1137
|
+
tip_amount?: number;
|
|
1138
|
+
enroll_in_link?: boolean;
|
|
1139
|
+
pay_currency?: CurrencyCode;
|
|
1140
|
+
timeout_ms?: number;
|
|
1141
|
+
on_status_change?: (status: CheckoutStatus, context: CheckoutStatusContext) => void;
|
|
1142
|
+
}
|
|
1143
|
+
interface ProcessCheckoutResult {
|
|
1144
|
+
success: boolean;
|
|
1145
|
+
order?: {
|
|
1146
|
+
id: string;
|
|
1147
|
+
order_number: string;
|
|
1148
|
+
status: string;
|
|
1149
|
+
total: string;
|
|
1150
|
+
currency: CurrencyCode;
|
|
1151
|
+
};
|
|
1152
|
+
error?: {
|
|
1153
|
+
code: string;
|
|
1154
|
+
message: string;
|
|
1155
|
+
recoverable: boolean;
|
|
1156
|
+
docs_url?: string;
|
|
1157
|
+
suggestion?: string;
|
|
1158
|
+
};
|
|
1159
|
+
enrolled_in_link?: boolean;
|
|
1160
|
+
}
|
|
1161
|
+
interface ProcessAndResolveOptions {
|
|
1162
|
+
enroll_in_link?: boolean;
|
|
1163
|
+
/** Disable card payment popups (e.g. server-side execution). Defaults to true in browsers. */
|
|
1164
|
+
allow_popups?: boolean;
|
|
1165
|
+
poll_interval_ms?: number;
|
|
1166
|
+
max_poll_attempts?: number;
|
|
1167
|
+
on_status_change?: (status: CheckoutStatus, context: CheckoutStatusContext) => void;
|
|
1168
|
+
on_authorization_required?: (type: "otp" | "pin", submit: (code: string) => Promise<void>) => void | Promise<void>;
|
|
1169
|
+
return_url?: string;
|
|
1170
|
+
signal?: AbortSignal;
|
|
1171
|
+
}
|
|
1172
|
+
type AbortablePromise<T> = Promise<T> & {
|
|
1173
|
+
abort: () => void;
|
|
1174
|
+
};
|
|
1175
|
+
|
|
1176
|
+
declare function generateIdempotencyKey(): string;
|
|
1177
|
+
declare class CheckoutService {
|
|
1178
|
+
private client;
|
|
1179
|
+
constructor(client: CimplifyClient);
|
|
1180
|
+
process(data: CheckoutFormData): Promise<Result<CheckoutResult, CimplifyError>>;
|
|
1181
|
+
initializePayment(orderId: string, method: PaymentMethod): Promise<Result<InitializePaymentResult, CimplifyError>>;
|
|
1182
|
+
submitAuthorization(input: SubmitAuthorizationInput): Promise<Result<CheckoutResult, CimplifyError>>;
|
|
1183
|
+
pollPaymentStatus(orderId: string): Promise<Result<PaymentStatusResponse, CimplifyError>>;
|
|
1184
|
+
updateOrderCustomer(orderId: string, customer: CheckoutCustomerInfo): Promise<Result<Order, CimplifyError>>;
|
|
1185
|
+
verifyPayment(orderId: string): Promise<Result<Order, CimplifyError>>;
|
|
1186
|
+
processAndResolve(data: CheckoutFormData & ProcessAndResolveOptions): Promise<Result<ProcessCheckoutResult, CimplifyError>>;
|
|
1187
|
+
}
|
|
1188
|
+
|
|
1189
|
+
interface GetOrdersOptions {
|
|
1190
|
+
status?: OrderStatus;
|
|
1191
|
+
limit?: number;
|
|
1192
|
+
offset?: number;
|
|
1193
|
+
}
|
|
1194
|
+
/**
|
|
1195
|
+
* Order queries with explicit error handling via Result type.
|
|
1196
|
+
*
|
|
1197
|
+
* All methods return `Result<T, CimplifyError>` - no exceptions thrown.
|
|
1198
|
+
*
|
|
1199
|
+
* @example
|
|
1200
|
+
* ```typescript
|
|
1201
|
+
* const result = await client.orders.list({ status: "pending" });
|
|
1202
|
+
*
|
|
1203
|
+
* if (result.ok) {
|
|
1204
|
+
* console.log("Orders:", result.value);
|
|
1205
|
+
* } else {
|
|
1206
|
+
* console.error("Failed:", result.error.code);
|
|
1207
|
+
* }
|
|
1208
|
+
* ```
|
|
1209
|
+
*/
|
|
1210
|
+
declare class OrderQueries {
|
|
1211
|
+
private client;
|
|
1212
|
+
constructor(client: CimplifyClient);
|
|
1213
|
+
list(options?: GetOrdersOptions): Promise<Result<Order[], CimplifyError>>;
|
|
1214
|
+
get(orderId: string): Promise<Result<Order, CimplifyError>>;
|
|
1215
|
+
getRecent(limit?: number): Promise<Result<Order[], CimplifyError>>;
|
|
1216
|
+
getByStatus(status: OrderStatus): Promise<Result<Order[], CimplifyError>>;
|
|
1217
|
+
cancel(orderId: string, reason?: string): Promise<Result<Order, CimplifyError>>;
|
|
1218
|
+
}
|
|
1219
|
+
|
|
1220
|
+
interface SuccessResult$2 {
|
|
1221
|
+
success: boolean;
|
|
1222
|
+
message?: string;
|
|
1223
|
+
}
|
|
1224
|
+
/**
|
|
1225
|
+
* Cimplify Link service for express checkout with saved customer data.
|
|
1226
|
+
*
|
|
1227
|
+
* All methods return `Result<T, CimplifyError>` - no exceptions thrown.
|
|
1228
|
+
*/
|
|
1229
|
+
declare class LinkService {
|
|
1230
|
+
private client;
|
|
1231
|
+
constructor(client: CimplifyClient);
|
|
1232
|
+
getProfile(): Promise<Result<LinkData["customer"], CimplifyError>>;
|
|
1233
|
+
requestOtp(input: RequestOtpInput): Promise<Result<SuccessResult$2, CimplifyError>>;
|
|
1234
|
+
verifyOtp(input: VerifyOtpInput): Promise<Result<AuthResponse, CimplifyError>>;
|
|
1235
|
+
logout(): Promise<Result<SuccessResult$2, CimplifyError>>;
|
|
1236
|
+
checkStatus(contact: string): Promise<Result<LinkStatusResult, CimplifyError>>;
|
|
1237
|
+
getLinkData(): Promise<Result<LinkData, CimplifyError>>;
|
|
1238
|
+
getAddresses(): Promise<Result<CustomerAddress[], CimplifyError>>;
|
|
1239
|
+
getMobileMoney(): Promise<Result<CustomerMobileMoney[], CimplifyError>>;
|
|
1240
|
+
getPreferences(): Promise<Result<CustomerLinkPreferences, CimplifyError>>;
|
|
1241
|
+
enroll(data: EnrollmentData): Promise<Result<LinkEnrollResult, CimplifyError>>;
|
|
1242
|
+
enrollAndLinkOrder(data: EnrollAndLinkOrderInput): Promise<Result<EnrollAndLinkOrderResult, CimplifyError>>;
|
|
1243
|
+
updatePreferences(preferences: Partial<CustomerLinkPreferences>): Promise<Result<SuccessResult$2, CimplifyError>>;
|
|
1244
|
+
createAddress(input: CreateAddressInput): Promise<Result<CustomerAddress, CimplifyError>>;
|
|
1245
|
+
updateAddress(input: UpdateAddressInput): Promise<Result<SuccessResult$2, CimplifyError>>;
|
|
1246
|
+
deleteAddress(addressId: string): Promise<Result<SuccessResult$2, CimplifyError>>;
|
|
1247
|
+
setDefaultAddress(addressId: string): Promise<Result<SuccessResult$2, CimplifyError>>;
|
|
1248
|
+
trackAddressUsage(addressId: string): Promise<Result<SuccessResult$2, CimplifyError>>;
|
|
1249
|
+
createMobileMoney(input: CreateMobileMoneyInput): Promise<Result<CustomerMobileMoney, CimplifyError>>;
|
|
1250
|
+
deleteMobileMoney(mobileMoneyId: string): Promise<Result<SuccessResult$2, CimplifyError>>;
|
|
1251
|
+
setDefaultMobileMoney(mobileMoneyId: string): Promise<Result<SuccessResult$2, CimplifyError>>;
|
|
1252
|
+
trackMobileMoneyUsage(mobileMoneyId: string): Promise<Result<SuccessResult$2, CimplifyError>>;
|
|
1253
|
+
verifyMobileMoney(mobileMoneyId: string): Promise<Result<SuccessResult$2, CimplifyError>>;
|
|
1254
|
+
getSessions(): Promise<Result<LinkSession[], CimplifyError>>;
|
|
1255
|
+
revokeSession(sessionId: string): Promise<Result<RevokeSessionResult, CimplifyError>>;
|
|
1256
|
+
revokeAllSessions(): Promise<Result<RevokeAllSessionsResult, CimplifyError>>;
|
|
1257
|
+
getAddressesRest(): Promise<Result<CustomerAddress[], CimplifyError>>;
|
|
1258
|
+
createAddressRest(input: CreateAddressInput): Promise<Result<CustomerAddress, CimplifyError>>;
|
|
1259
|
+
deleteAddressRest(addressId: string): Promise<Result<SuccessResult$2, CimplifyError>>;
|
|
1260
|
+
setDefaultAddressRest(addressId: string): Promise<Result<SuccessResult$2, CimplifyError>>;
|
|
1261
|
+
getMobileMoneyRest(): Promise<Result<CustomerMobileMoney[], CimplifyError>>;
|
|
1262
|
+
createMobileMoneyRest(input: CreateMobileMoneyInput): Promise<Result<CustomerMobileMoney, CimplifyError>>;
|
|
1263
|
+
deleteMobileMoneyRest(mobileMoneyId: string): Promise<Result<SuccessResult$2, CimplifyError>>;
|
|
1264
|
+
setDefaultMobileMoneyRest(mobileMoneyId: string): Promise<Result<SuccessResult$2, CimplifyError>>;
|
|
1265
|
+
}
|
|
1266
|
+
|
|
1267
|
+
interface AuthStatus {
|
|
1268
|
+
is_authenticated: boolean;
|
|
1269
|
+
customer?: Customer;
|
|
1270
|
+
session_expires_at?: string;
|
|
1271
|
+
}
|
|
1272
|
+
interface OtpResult {
|
|
1273
|
+
customer: Customer;
|
|
1274
|
+
session_token?: string;
|
|
1275
|
+
}
|
|
1276
|
+
interface UpdateProfileInput {
|
|
1277
|
+
name?: string;
|
|
1278
|
+
email?: string;
|
|
1279
|
+
phone?: string;
|
|
1280
|
+
}
|
|
1281
|
+
interface ChangePasswordInput {
|
|
1282
|
+
current_password: string;
|
|
1283
|
+
new_password: string;
|
|
1284
|
+
}
|
|
1285
|
+
interface SuccessResult$1 {
|
|
1286
|
+
success: boolean;
|
|
1287
|
+
}
|
|
1288
|
+
declare class AuthService {
|
|
1289
|
+
private client;
|
|
1290
|
+
constructor(client: CimplifyClient);
|
|
1291
|
+
getStatus(): Promise<Result<AuthStatus, CimplifyError>>;
|
|
1292
|
+
getCurrentUser(): Promise<Result<Customer | null, CimplifyError>>;
|
|
1293
|
+
isAuthenticated(): Promise<Result<boolean, CimplifyError>>;
|
|
1294
|
+
requestOtp(contact: string, contactType?: "phone" | "email"): Promise<Result<void, CimplifyError>>;
|
|
1295
|
+
verifyOtp(code: string, contact?: string): Promise<Result<OtpResult, CimplifyError>>;
|
|
1296
|
+
logout(): Promise<Result<SuccessResult$1, CimplifyError>>;
|
|
1297
|
+
updateProfile(input: UpdateProfileInput): Promise<Result<Customer, CimplifyError>>;
|
|
1298
|
+
changePassword(input: ChangePasswordInput): Promise<Result<SuccessResult$1, CimplifyError>>;
|
|
1299
|
+
resetPassword(email: string): Promise<Result<SuccessResult$1, CimplifyError>>;
|
|
1300
|
+
}
|
|
1301
|
+
|
|
1302
|
+
type BusinessType = "eatery" | "retail" | "service" | "other" | "system" | "unset";
|
|
1303
|
+
interface BusinessPreferences {
|
|
1304
|
+
[key: string]: unknown;
|
|
1305
|
+
}
|
|
1306
|
+
interface Business {
|
|
1307
|
+
id: string;
|
|
1308
|
+
name: string;
|
|
1309
|
+
handle: string;
|
|
1310
|
+
business_type: BusinessType;
|
|
1311
|
+
email: string;
|
|
1312
|
+
default_currency: CurrencyCode;
|
|
1313
|
+
default_phone?: string;
|
|
1314
|
+
default_address?: string;
|
|
1315
|
+
default_offers_table_service: boolean;
|
|
1316
|
+
default_accepts_online_orders: boolean;
|
|
1317
|
+
image?: string;
|
|
1318
|
+
status: string;
|
|
1319
|
+
created_at: string;
|
|
1320
|
+
updated_at: string;
|
|
1321
|
+
subscription_id?: string;
|
|
1322
|
+
owner_id?: string;
|
|
1323
|
+
created_by: string;
|
|
1324
|
+
preferences: BusinessPreferences;
|
|
1325
|
+
is_online_only: boolean;
|
|
1326
|
+
enabled_payment_types: string[];
|
|
1327
|
+
default_location_settings: Record<string, unknown>;
|
|
1328
|
+
country_code?: string;
|
|
1329
|
+
timezone?: string;
|
|
1330
|
+
metadata?: Record<string, unknown>;
|
|
1331
|
+
}
|
|
1332
|
+
interface LocationTaxBehavior {
|
|
1333
|
+
is_tax_inclusive: boolean;
|
|
1334
|
+
tax_rate: Money;
|
|
1335
|
+
}
|
|
1336
|
+
interface LocationTaxOverrides {
|
|
1337
|
+
[productId: string]: {
|
|
1338
|
+
tax_rate: Money;
|
|
1339
|
+
is_exempt: boolean;
|
|
1340
|
+
};
|
|
1341
|
+
}
|
|
1342
|
+
interface Location {
|
|
1343
|
+
id: string;
|
|
1344
|
+
business_id: string;
|
|
1345
|
+
name: string;
|
|
1346
|
+
location?: string;
|
|
1347
|
+
phone?: string;
|
|
1348
|
+
address?: string;
|
|
1349
|
+
service_charge_rate?: number;
|
|
1350
|
+
currency: CurrencyCode;
|
|
1351
|
+
capacity: number;
|
|
1352
|
+
status: string;
|
|
1353
|
+
enabled_payment_types?: string[];
|
|
1354
|
+
offers_table_service: boolean;
|
|
1355
|
+
accepts_online_orders: boolean;
|
|
1356
|
+
created_at: string;
|
|
1357
|
+
updated_at: string;
|
|
1358
|
+
preferences?: Record<string, unknown>;
|
|
1359
|
+
metadata?: Record<string, unknown>;
|
|
1360
|
+
country_code: string;
|
|
1361
|
+
timezone: string;
|
|
1362
|
+
tax_behavior?: LocationTaxBehavior;
|
|
1363
|
+
tax_overrides?: LocationTaxOverrides;
|
|
1364
|
+
}
|
|
1365
|
+
interface TimeRange {
|
|
1366
|
+
start: string;
|
|
1367
|
+
end: string;
|
|
1368
|
+
}
|
|
1369
|
+
type TimeRanges = TimeRange[];
|
|
1370
|
+
interface LocationTimeProfile {
|
|
1371
|
+
id: string;
|
|
1372
|
+
business_id: string;
|
|
1373
|
+
location_id: string;
|
|
1374
|
+
day: string;
|
|
1375
|
+
is_open: boolean;
|
|
1376
|
+
hours: TimeRanges;
|
|
1377
|
+
created_at: string;
|
|
1378
|
+
updated_at: string;
|
|
1379
|
+
metadata?: Record<string, unknown>;
|
|
1380
|
+
}
|
|
1381
|
+
interface Table {
|
|
1382
|
+
id: string;
|
|
1383
|
+
business_id: string;
|
|
1384
|
+
location_id: string;
|
|
1385
|
+
table_number: string;
|
|
1386
|
+
capacity: number;
|
|
1387
|
+
occupied: boolean;
|
|
1388
|
+
created_at: string;
|
|
1389
|
+
updated_at: string;
|
|
1390
|
+
metadata?: Record<string, unknown>;
|
|
1391
|
+
}
|
|
1392
|
+
interface Room {
|
|
1393
|
+
id: string;
|
|
1394
|
+
business_id: string;
|
|
1395
|
+
location_id: string;
|
|
1396
|
+
name: string;
|
|
1397
|
+
capacity: number;
|
|
1398
|
+
status: string;
|
|
1399
|
+
floor?: string;
|
|
1400
|
+
created_at: string;
|
|
1401
|
+
updated_at: string;
|
|
1402
|
+
metadata?: Record<string, unknown>;
|
|
1403
|
+
}
|
|
1404
|
+
interface ServiceCharge {
|
|
1405
|
+
percentage?: Money;
|
|
1406
|
+
is_mandatory?: boolean;
|
|
1407
|
+
description?: string;
|
|
1408
|
+
applies_to_parties_of?: number;
|
|
1409
|
+
minimum_amount?: Money;
|
|
1410
|
+
maximum_amount?: Money;
|
|
1411
|
+
}
|
|
1412
|
+
interface StorefrontBootstrap {
|
|
1413
|
+
business: Business;
|
|
1414
|
+
location?: Location;
|
|
1415
|
+
locations: Location[];
|
|
1416
|
+
categories: CategoryInfo[];
|
|
1417
|
+
currency: CurrencyCode;
|
|
1418
|
+
is_open: boolean;
|
|
1419
|
+
accepts_orders: boolean;
|
|
1420
|
+
time_profiles?: LocationTimeProfile[];
|
|
1421
|
+
}
|
|
1422
|
+
interface BusinessWithLocations extends Business {
|
|
1423
|
+
locations: Location[];
|
|
1424
|
+
default_location?: Location;
|
|
1425
|
+
}
|
|
1426
|
+
interface LocationWithDetails extends Location {
|
|
1427
|
+
time_profiles: LocationTimeProfile[];
|
|
1428
|
+
tables: Table[];
|
|
1429
|
+
rooms: Room[];
|
|
1430
|
+
is_open_now: boolean;
|
|
1431
|
+
next_open_time?: string;
|
|
1432
|
+
}
|
|
1433
|
+
/** Settings for frontend display (derived from Business/Location) */
|
|
1434
|
+
interface BusinessSettings {
|
|
1435
|
+
accept_online_orders: boolean;
|
|
1436
|
+
accept_reservations: boolean;
|
|
1437
|
+
require_customer_account: boolean;
|
|
1438
|
+
enable_tips: boolean;
|
|
1439
|
+
enable_loyalty: boolean;
|
|
1440
|
+
minimum_order_amount?: string;
|
|
1441
|
+
delivery_fee?: string;
|
|
1442
|
+
free_delivery_threshold?: string;
|
|
1443
|
+
tax_rate?: number;
|
|
1444
|
+
tax_inclusive: boolean;
|
|
1445
|
+
}
|
|
1446
|
+
/** Business hours (simplified for frontend) */
|
|
1447
|
+
interface BusinessHours {
|
|
1448
|
+
business_id: string;
|
|
1449
|
+
location_id?: string;
|
|
1450
|
+
day_of_week: number;
|
|
1451
|
+
open_time: string;
|
|
1452
|
+
close_time: string;
|
|
1453
|
+
is_closed: boolean;
|
|
1454
|
+
}
|
|
1455
|
+
/** Category summary for bootstrap (minimal fields) */
|
|
1456
|
+
interface CategoryInfo {
|
|
1457
|
+
id: string;
|
|
1458
|
+
name: string;
|
|
1459
|
+
slug: string;
|
|
1460
|
+
}
|
|
1461
|
+
|
|
1462
|
+
/**
|
|
1463
|
+
* Business service with explicit error handling via Result type.
|
|
1464
|
+
*
|
|
1465
|
+
* All methods return `Result<T, CimplifyError>` - no exceptions thrown.
|
|
1466
|
+
*
|
|
1467
|
+
* @example
|
|
1468
|
+
* ```typescript
|
|
1469
|
+
* const result = await client.business.getInfo();
|
|
1470
|
+
*
|
|
1471
|
+
* if (result.ok) {
|
|
1472
|
+
* console.log("Business:", result.value.name);
|
|
1473
|
+
* } else {
|
|
1474
|
+
* console.error("Failed:", result.error.code);
|
|
1475
|
+
* }
|
|
1476
|
+
* ```
|
|
1477
|
+
*/
|
|
1478
|
+
declare class BusinessService {
|
|
1479
|
+
private client;
|
|
1480
|
+
constructor(client: CimplifyClient);
|
|
1481
|
+
getInfo(): Promise<Result<Business, CimplifyError>>;
|
|
1482
|
+
getByHandle(handle: string): Promise<Result<Business, CimplifyError>>;
|
|
1483
|
+
getByDomain(domain: string): Promise<Result<Business, CimplifyError>>;
|
|
1484
|
+
getSettings(): Promise<Result<BusinessSettings, CimplifyError>>;
|
|
1485
|
+
getTheme(): Promise<Result<Record<string, unknown>, CimplifyError>>;
|
|
1486
|
+
getLocations(): Promise<Result<Location[], CimplifyError>>;
|
|
1487
|
+
getLocation(locationId: string): Promise<Result<Location, CimplifyError>>;
|
|
1488
|
+
getHours(): Promise<Result<BusinessHours[], CimplifyError>>;
|
|
1489
|
+
getLocationHours(locationId: string): Promise<Result<BusinessHours[], CimplifyError>>;
|
|
1490
|
+
getBootstrap(): Promise<Result<StorefrontBootstrap, CimplifyError>>;
|
|
1491
|
+
}
|
|
1492
|
+
|
|
1493
|
+
type StockOwnershipType = "owned" | "consignment" | "dropship";
|
|
1494
|
+
type StockStatus = "in_stock" | "low_stock" | "out_of_stock";
|
|
1495
|
+
interface Stock {
|
|
1496
|
+
id: string;
|
|
1497
|
+
business_id: string;
|
|
1498
|
+
name: string;
|
|
1499
|
+
sku?: string;
|
|
1500
|
+
barcode?: string;
|
|
1501
|
+
unit_type: string;
|
|
1502
|
+
unit_cost?: Money;
|
|
1503
|
+
description?: string;
|
|
1504
|
+
image_url?: string;
|
|
1505
|
+
tags?: string[];
|
|
1506
|
+
categories?: string[];
|
|
1507
|
+
is_taxable: boolean;
|
|
1508
|
+
tax_rate?: Money;
|
|
1509
|
+
is_expirable: boolean;
|
|
1510
|
+
ownership_type: StockOwnershipType;
|
|
1511
|
+
quantity_on_hand: Money;
|
|
1512
|
+
quantity_allocated: Money;
|
|
1513
|
+
quantity_reserved: Money;
|
|
1514
|
+
min_order_quantity: Money;
|
|
1515
|
+
reorder_point?: Money;
|
|
1516
|
+
reorder_quantity?: Money;
|
|
1517
|
+
last_counted_at?: string;
|
|
1518
|
+
status: string;
|
|
1519
|
+
created_at: string;
|
|
1520
|
+
updated_at: string;
|
|
1521
|
+
metadata?: Record<string, unknown>;
|
|
1522
|
+
}
|
|
1523
|
+
interface StockLevel {
|
|
1524
|
+
product_id: string;
|
|
1525
|
+
variant_id?: string;
|
|
1526
|
+
location_id?: string;
|
|
1527
|
+
quantity: number;
|
|
1528
|
+
reserved_quantity: number;
|
|
1529
|
+
available_quantity: number;
|
|
1530
|
+
low_stock_threshold?: number;
|
|
1531
|
+
status: StockStatus;
|
|
1532
|
+
last_updated: string;
|
|
1533
|
+
}
|
|
1534
|
+
interface ProductStock {
|
|
1535
|
+
product_id: string;
|
|
1536
|
+
product_name: string;
|
|
1537
|
+
total_quantity: number;
|
|
1538
|
+
available_quantity: number;
|
|
1539
|
+
reserved_quantity: number;
|
|
1540
|
+
status: StockStatus;
|
|
1541
|
+
variants?: VariantStock[];
|
|
1542
|
+
locations?: LocationStock[];
|
|
1543
|
+
}
|
|
1544
|
+
interface VariantStock {
|
|
1545
|
+
variant_id: string;
|
|
1546
|
+
variant_name: string;
|
|
1547
|
+
sku?: string;
|
|
1548
|
+
quantity: number;
|
|
1549
|
+
available_quantity: number;
|
|
1550
|
+
status: StockStatus;
|
|
1551
|
+
}
|
|
1552
|
+
interface LocationStock {
|
|
1553
|
+
location_id: string;
|
|
1554
|
+
location_name: string;
|
|
1555
|
+
quantity: number;
|
|
1556
|
+
available_quantity: number;
|
|
1557
|
+
status: StockStatus;
|
|
1558
|
+
}
|
|
1559
|
+
interface AvailabilityCheck {
|
|
1560
|
+
product_id: string;
|
|
1561
|
+
variant_id?: string;
|
|
1562
|
+
location_id?: string;
|
|
1563
|
+
requested_quantity: number;
|
|
1564
|
+
}
|
|
1565
|
+
interface AvailabilityResult {
|
|
1566
|
+
product_id: string;
|
|
1567
|
+
variant_id?: string;
|
|
1568
|
+
is_available: boolean;
|
|
1569
|
+
available_quantity: number;
|
|
1570
|
+
requested_quantity: number;
|
|
1571
|
+
shortfall?: number;
|
|
1572
|
+
}
|
|
1573
|
+
interface InventorySummary {
|
|
1574
|
+
total_products: number;
|
|
1575
|
+
in_stock_count: number;
|
|
1576
|
+
low_stock_count: number;
|
|
1577
|
+
out_of_stock_count: number;
|
|
1578
|
+
total_value?: Money;
|
|
1579
|
+
}
|
|
1580
|
+
|
|
1581
|
+
/**
|
|
1582
|
+
* Inventory service with explicit error handling via Result type.
|
|
1583
|
+
*
|
|
1584
|
+
* All methods return `Result<T, CimplifyError>` - no exceptions thrown.
|
|
1585
|
+
*
|
|
1586
|
+
* @example
|
|
1587
|
+
* ```typescript
|
|
1588
|
+
* const result = await client.inventory.isInStock("prod_123");
|
|
1589
|
+
*
|
|
1590
|
+
* if (result.ok) {
|
|
1591
|
+
* console.log("In stock:", result.value);
|
|
1592
|
+
* } else {
|
|
1593
|
+
* console.error("Failed:", result.error.code);
|
|
1594
|
+
* }
|
|
1595
|
+
* ```
|
|
1596
|
+
*/
|
|
1597
|
+
declare class InventoryService {
|
|
1598
|
+
private client;
|
|
1599
|
+
constructor(client: CimplifyClient);
|
|
1600
|
+
getStockLevels(): Promise<Result<StockLevel[], CimplifyError>>;
|
|
1601
|
+
getProductStock(productId: string, locationId?: string): Promise<Result<ProductStock, CimplifyError>>;
|
|
1602
|
+
getVariantStock(variantId: string, locationId?: string): Promise<Result<StockLevel, CimplifyError>>;
|
|
1603
|
+
checkProductAvailability(productId: string, quantity: number, locationId?: string): Promise<Result<AvailabilityResult, CimplifyError>>;
|
|
1604
|
+
checkVariantAvailability(variantId: string, quantity: number, locationId?: string): Promise<Result<AvailabilityResult, CimplifyError>>;
|
|
1605
|
+
checkMultipleAvailability(items: {
|
|
1606
|
+
product_id: string;
|
|
1607
|
+
variant_id?: string;
|
|
1608
|
+
quantity: number;
|
|
1609
|
+
}[], locationId?: string): Promise<Result<AvailabilityResult[], CimplifyError>>;
|
|
1610
|
+
getSummary(): Promise<Result<InventorySummary, CimplifyError>>;
|
|
1611
|
+
isInStock(productId: string, locationId?: string): Promise<Result<boolean, CimplifyError>>;
|
|
1612
|
+
getAvailableQuantity(productId: string, locationId?: string): Promise<Result<number, CimplifyError>>;
|
|
1613
|
+
}
|
|
1614
|
+
|
|
1615
|
+
interface ServiceAvailabilityRule {
|
|
1616
|
+
id: string;
|
|
1617
|
+
business_id: string;
|
|
1618
|
+
location_id: string;
|
|
1619
|
+
item_id: string;
|
|
1620
|
+
day_of_week: number;
|
|
1621
|
+
start_time: string;
|
|
1622
|
+
end_time: string;
|
|
1623
|
+
capacity?: number;
|
|
1624
|
+
created_at: string;
|
|
1625
|
+
updated_at: string;
|
|
1626
|
+
metadata?: Record<string, unknown>;
|
|
1627
|
+
}
|
|
1628
|
+
interface ServiceAvailabilityException {
|
|
1629
|
+
id: string;
|
|
1630
|
+
business_id: string;
|
|
1631
|
+
location_id: string;
|
|
1632
|
+
item_id: string;
|
|
1633
|
+
exception_date: string;
|
|
1634
|
+
is_closed: boolean;
|
|
1635
|
+
start_time?: string;
|
|
1636
|
+
end_time?: string;
|
|
1637
|
+
capacity?: number;
|
|
1638
|
+
reason?: string;
|
|
1639
|
+
created_at: string;
|
|
1640
|
+
updated_at: string;
|
|
1641
|
+
metadata?: Record<string, unknown>;
|
|
1642
|
+
}
|
|
1643
|
+
interface StaffAvailabilityRule {
|
|
1644
|
+
id: string;
|
|
1645
|
+
staff_id: string;
|
|
1646
|
+
location_id?: string;
|
|
1647
|
+
day_of_week: number;
|
|
1648
|
+
start_time: string;
|
|
1649
|
+
end_time: string;
|
|
1650
|
+
is_available: boolean;
|
|
1651
|
+
created_at: string;
|
|
1652
|
+
updated_at: string;
|
|
1653
|
+
metadata?: Record<string, unknown>;
|
|
1654
|
+
}
|
|
1655
|
+
interface StaffAvailabilityException {
|
|
1656
|
+
id: string;
|
|
1657
|
+
staff_id: string;
|
|
1658
|
+
location_id?: string;
|
|
1659
|
+
exception_date: string;
|
|
1660
|
+
is_unavailable_all_day: boolean;
|
|
1661
|
+
start_time?: string;
|
|
1662
|
+
end_time?: string;
|
|
1663
|
+
reason?: string;
|
|
1664
|
+
created_at: string;
|
|
1665
|
+
updated_at: string;
|
|
1666
|
+
metadata?: Record<string, unknown>;
|
|
1667
|
+
}
|
|
1668
|
+
interface ResourceAvailabilityRule {
|
|
1669
|
+
id: string;
|
|
1670
|
+
business_id: string;
|
|
1671
|
+
location_id: string;
|
|
1672
|
+
resource_id: string;
|
|
1673
|
+
day_of_week: number;
|
|
1674
|
+
start_time: string;
|
|
1675
|
+
end_time: string;
|
|
1676
|
+
is_available: boolean;
|
|
1677
|
+
created_at: string;
|
|
1678
|
+
updated_at: string;
|
|
1679
|
+
metadata?: Record<string, unknown>;
|
|
1680
|
+
}
|
|
1681
|
+
interface ResourceAvailabilityException {
|
|
1682
|
+
id: string;
|
|
1683
|
+
business_id: string;
|
|
1684
|
+
location_id: string;
|
|
1685
|
+
resource_id: string;
|
|
1686
|
+
exception_date: string;
|
|
1687
|
+
is_unavailable_all_day: boolean;
|
|
1688
|
+
start_time?: string;
|
|
1689
|
+
end_time?: string;
|
|
1690
|
+
reason?: string;
|
|
1691
|
+
created_at: string;
|
|
1692
|
+
updated_at: string;
|
|
1693
|
+
metadata?: Record<string, unknown>;
|
|
1694
|
+
}
|
|
1695
|
+
interface StaffBookingProfile {
|
|
1696
|
+
id: string;
|
|
1697
|
+
staff_id: string;
|
|
1698
|
+
skills?: string[];
|
|
1699
|
+
can_be_booked: boolean;
|
|
1700
|
+
default_service_duration_override?: number;
|
|
1701
|
+
booking_buffer_minutes?: number;
|
|
1702
|
+
max_daily_bookings?: number;
|
|
1703
|
+
preferred_working_hours?: Record<string, unknown>;
|
|
1704
|
+
created_at: string;
|
|
1705
|
+
updated_at: string;
|
|
1706
|
+
metadata?: Record<string, unknown>;
|
|
1707
|
+
}
|
|
1708
|
+
interface ServiceStaffRequirement {
|
|
1709
|
+
id: string;
|
|
1710
|
+
service_item_id: string;
|
|
1711
|
+
role_id?: string;
|
|
1712
|
+
required_skill?: string;
|
|
1713
|
+
number_of_staff: number;
|
|
1714
|
+
specific_staff_assignment_required: boolean;
|
|
1715
|
+
created_at: string;
|
|
1716
|
+
updated_at: string;
|
|
1717
|
+
metadata?: Record<string, unknown>;
|
|
1718
|
+
}
|
|
1719
|
+
interface BookingRequirementOverride {
|
|
1720
|
+
id: string;
|
|
1721
|
+
appointment_id: string;
|
|
1722
|
+
overridden_by: string;
|
|
1723
|
+
reason: string;
|
|
1724
|
+
missing_staff_requirements?: Record<string, unknown>;
|
|
1725
|
+
missing_resource_requirements?: Record<string, unknown>;
|
|
1726
|
+
created_at: string;
|
|
1727
|
+
}
|
|
1728
|
+
interface ResourceType {
|
|
1729
|
+
id: string;
|
|
1730
|
+
business_id: string;
|
|
1731
|
+
name: string;
|
|
1732
|
+
description?: string;
|
|
1733
|
+
created_at: string;
|
|
1734
|
+
updated_at: string;
|
|
1735
|
+
}
|
|
1736
|
+
interface Service {
|
|
1737
|
+
id: string;
|
|
1738
|
+
business_id: string;
|
|
1739
|
+
product_id: string;
|
|
1740
|
+
name: string;
|
|
1741
|
+
description?: string;
|
|
1742
|
+
duration_minutes: number;
|
|
1743
|
+
buffer_before_minutes: number;
|
|
1744
|
+
buffer_after_minutes: number;
|
|
1745
|
+
max_participants: number;
|
|
1746
|
+
price: Money;
|
|
1747
|
+
currency: CurrencyCode;
|
|
1748
|
+
requires_staff: boolean;
|
|
1749
|
+
is_active: boolean;
|
|
1750
|
+
image_url?: string;
|
|
1751
|
+
category_id?: string;
|
|
1752
|
+
metadata?: Record<string, unknown>;
|
|
1753
|
+
}
|
|
1754
|
+
interface ServiceWithStaff extends Service {
|
|
1755
|
+
available_staff: Staff[];
|
|
1756
|
+
}
|
|
1757
|
+
interface Staff {
|
|
1758
|
+
id: string;
|
|
1759
|
+
business_id: string;
|
|
1760
|
+
name: string;
|
|
1761
|
+
email?: string;
|
|
1762
|
+
phone?: string;
|
|
1763
|
+
avatar_url?: string;
|
|
1764
|
+
bio?: string;
|
|
1765
|
+
is_active: boolean;
|
|
1766
|
+
services?: string[];
|
|
1767
|
+
}
|
|
1768
|
+
interface TimeSlot {
|
|
1769
|
+
start_time: string;
|
|
1770
|
+
end_time: string;
|
|
1771
|
+
is_available: boolean;
|
|
1772
|
+
staff_id?: string;
|
|
1773
|
+
staff_name?: string;
|
|
1774
|
+
remaining_capacity?: number;
|
|
1775
|
+
}
|
|
1776
|
+
interface AvailableSlot extends TimeSlot {
|
|
1777
|
+
price?: Money;
|
|
1778
|
+
duration_minutes: number;
|
|
1779
|
+
}
|
|
1780
|
+
interface DayAvailability {
|
|
1781
|
+
date: string;
|
|
1782
|
+
slots: TimeSlot[];
|
|
1783
|
+
is_fully_booked: boolean;
|
|
1784
|
+
}
|
|
1785
|
+
type BookingStatus = "pending" | "confirmed" | "in_progress" | "completed" | "cancelled" | "no_show";
|
|
1786
|
+
interface Booking {
|
|
1787
|
+
id: string;
|
|
1788
|
+
business_id: string;
|
|
1789
|
+
order_id: string;
|
|
1790
|
+
line_item_id: string;
|
|
1791
|
+
service_id: string;
|
|
1792
|
+
service_name: string;
|
|
1793
|
+
customer_id?: string;
|
|
1794
|
+
customer_name?: string;
|
|
1795
|
+
customer_phone?: string;
|
|
1796
|
+
staff_id?: string;
|
|
1797
|
+
staff_name?: string;
|
|
1798
|
+
location_id?: string;
|
|
1799
|
+
location_name?: string;
|
|
1800
|
+
start_time: string;
|
|
1801
|
+
end_time: string;
|
|
1802
|
+
duration_minutes: number;
|
|
1803
|
+
participant_count: number;
|
|
1804
|
+
status: BookingStatus;
|
|
1805
|
+
notes?: string;
|
|
1806
|
+
cancellation_reason?: string;
|
|
1807
|
+
cancelled_at?: string;
|
|
1808
|
+
created_at: string;
|
|
1809
|
+
updated_at: string;
|
|
1810
|
+
}
|
|
1811
|
+
interface BookingWithDetails extends Booking {
|
|
1812
|
+
service: Service;
|
|
1813
|
+
staff?: Staff;
|
|
1814
|
+
}
|
|
1815
|
+
interface GetAvailableSlotsInput {
|
|
1816
|
+
service_id: string;
|
|
1817
|
+
date: string;
|
|
1818
|
+
participant_count?: number;
|
|
1819
|
+
duration_minutes?: number;
|
|
1820
|
+
staff_id?: string;
|
|
1821
|
+
location_id?: string;
|
|
1822
|
+
}
|
|
1823
|
+
interface CheckSlotAvailabilityInput {
|
|
1824
|
+
service_id: string;
|
|
1825
|
+
slot_time: string;
|
|
1826
|
+
duration_minutes?: number;
|
|
1827
|
+
participant_count?: number;
|
|
1828
|
+
staff_id?: string;
|
|
1829
|
+
}
|
|
1830
|
+
interface RescheduleBookingInput {
|
|
1831
|
+
order_id: string;
|
|
1832
|
+
line_item_id: string;
|
|
1833
|
+
new_start_time: string;
|
|
1834
|
+
new_end_time: string;
|
|
1835
|
+
new_staff_id?: string;
|
|
1836
|
+
reason?: string;
|
|
1837
|
+
}
|
|
1838
|
+
interface CancelBookingInput {
|
|
1839
|
+
booking_id: string;
|
|
1840
|
+
reason?: string;
|
|
1841
|
+
}
|
|
1842
|
+
interface ServiceAvailabilityParams {
|
|
1843
|
+
service_id: string;
|
|
1844
|
+
start_date: string;
|
|
1845
|
+
end_date: string;
|
|
1846
|
+
location_id?: string;
|
|
1847
|
+
staff_id?: string;
|
|
1848
|
+
participant_count?: number;
|
|
1849
|
+
}
|
|
1850
|
+
interface ServiceAvailabilityResult {
|
|
1851
|
+
service_id: string;
|
|
1852
|
+
days: DayAvailability[];
|
|
1853
|
+
}
|
|
1854
|
+
|
|
1855
|
+
/**
|
|
1856
|
+
* Scheduling service with explicit error handling via Result type.
|
|
1857
|
+
*
|
|
1858
|
+
* All methods return `Result<T, CimplifyError>` - no exceptions thrown.
|
|
1859
|
+
*
|
|
1860
|
+
* @example
|
|
1861
|
+
* ```typescript
|
|
1862
|
+
* const result = await client.scheduling.getAvailableSlots({
|
|
1863
|
+
* service_id: "svc_haircut",
|
|
1864
|
+
* date: "2024-01-15"
|
|
1865
|
+
* });
|
|
1866
|
+
*
|
|
1867
|
+
* if (result.ok) {
|
|
1868
|
+
* console.log("Available slots:", result.value);
|
|
1869
|
+
* } else {
|
|
1870
|
+
* console.error("Failed:", result.error.code);
|
|
1871
|
+
* }
|
|
1872
|
+
* ```
|
|
1873
|
+
*/
|
|
1874
|
+
declare class SchedulingService {
|
|
1875
|
+
private client;
|
|
1876
|
+
constructor(client: CimplifyClient);
|
|
1877
|
+
getServices(): Promise<Result<Service[], CimplifyError>>;
|
|
1878
|
+
/**
|
|
1879
|
+
* Get a specific service by ID
|
|
1880
|
+
* Note: Filters from all services client-side (no single-service endpoint)
|
|
1881
|
+
*/
|
|
1882
|
+
getService(serviceId: string): Promise<Result<Service | null, CimplifyError>>;
|
|
1883
|
+
getAvailableSlots(input: GetAvailableSlotsInput): Promise<Result<AvailableSlot[], CimplifyError>>;
|
|
1884
|
+
checkSlotAvailability(input: CheckSlotAvailabilityInput): Promise<Result<{
|
|
1885
|
+
available: boolean;
|
|
1886
|
+
reason?: string;
|
|
1887
|
+
}, CimplifyError>>;
|
|
1888
|
+
getServiceAvailability(params: ServiceAvailabilityParams): Promise<Result<ServiceAvailabilityResult, CimplifyError>>;
|
|
1889
|
+
getBooking(bookingId: string): Promise<Result<BookingWithDetails, CimplifyError>>;
|
|
1890
|
+
getCustomerBookings(): Promise<Result<Booking[], CimplifyError>>;
|
|
1891
|
+
getUpcomingBookings(): Promise<Result<Booking[], CimplifyError>>;
|
|
1892
|
+
getPastBookings(limit?: number): Promise<Result<Booking[], CimplifyError>>;
|
|
1893
|
+
cancelBooking(input: CancelBookingInput): Promise<Result<Booking, CimplifyError>>;
|
|
1894
|
+
rescheduleBooking(input: RescheduleBookingInput): Promise<Result<Booking, CimplifyError>>;
|
|
1895
|
+
getNextAvailableSlot(serviceId: string, fromDate?: string): Promise<Result<AvailableSlot | null, CimplifyError>>;
|
|
1896
|
+
hasAvailabilityOn(serviceId: string, date: string): Promise<Result<boolean, CimplifyError>>;
|
|
1897
|
+
}
|
|
1898
|
+
|
|
1899
|
+
interface LiteBootstrap {
|
|
1900
|
+
business: Business;
|
|
1901
|
+
location: Location;
|
|
1902
|
+
categories: Category[];
|
|
1903
|
+
table?: TableInfo;
|
|
1904
|
+
cart: Cart | null;
|
|
1905
|
+
currency: string;
|
|
1906
|
+
is_open: boolean;
|
|
1907
|
+
}
|
|
1908
|
+
interface TableInfo {
|
|
1909
|
+
id: string;
|
|
1910
|
+
number: string;
|
|
1911
|
+
location_id: string;
|
|
1912
|
+
capacity?: number;
|
|
1913
|
+
status: "available" | "occupied" | "reserved";
|
|
1914
|
+
current_order_id?: string;
|
|
1915
|
+
}
|
|
1916
|
+
interface KitchenOrderItem {
|
|
1917
|
+
product_id: string;
|
|
1918
|
+
quantity: number;
|
|
1919
|
+
variant_id?: string;
|
|
1920
|
+
modifiers?: string[];
|
|
1921
|
+
notes?: string;
|
|
1922
|
+
}
|
|
1923
|
+
interface KitchenOrderResult {
|
|
1924
|
+
success: boolean;
|
|
1925
|
+
order_id: string;
|
|
1926
|
+
order_number: string;
|
|
1927
|
+
estimated_time_minutes?: number;
|
|
1928
|
+
}
|
|
1929
|
+
interface SuccessResult {
|
|
1930
|
+
success: boolean;
|
|
1931
|
+
}
|
|
1932
|
+
interface RequestBillResult {
|
|
1933
|
+
success: boolean;
|
|
1934
|
+
order_id: string;
|
|
1935
|
+
}
|
|
1936
|
+
/**
|
|
1937
|
+
* Lite service for QR code ordering with explicit error handling via Result type.
|
|
1938
|
+
*
|
|
1939
|
+
* All methods return `Result<T, CimplifyError>` - no exceptions thrown.
|
|
1940
|
+
*
|
|
1941
|
+
* @example
|
|
1942
|
+
* ```typescript
|
|
1943
|
+
* const result = await client.lite.getBootstrap();
|
|
1944
|
+
*
|
|
1945
|
+
* if (result.ok) {
|
|
1946
|
+
* console.log("Business:", result.value.business.name);
|
|
1947
|
+
* console.log("Table:", result.value.table?.number);
|
|
1948
|
+
* } else {
|
|
1949
|
+
* console.error("Failed:", result.error.code);
|
|
1950
|
+
* }
|
|
1951
|
+
* ```
|
|
1952
|
+
*/
|
|
1953
|
+
declare class LiteService {
|
|
1954
|
+
private client;
|
|
1955
|
+
constructor(client: CimplifyClient);
|
|
1956
|
+
getBootstrap(): Promise<Result<LiteBootstrap, CimplifyError>>;
|
|
1957
|
+
getTable(tableId: string): Promise<Result<TableInfo, CimplifyError>>;
|
|
1958
|
+
getTableByNumber(tableNumber: string, locationId?: string): Promise<Result<TableInfo, CimplifyError>>;
|
|
1959
|
+
sendToKitchen(tableId: string, items: KitchenOrderItem[]): Promise<Result<KitchenOrderResult, CimplifyError>>;
|
|
1960
|
+
callWaiter(tableId: string, reason?: string): Promise<Result<SuccessResult, CimplifyError>>;
|
|
1961
|
+
requestBill(tableId: string): Promise<Result<RequestBillResult, CimplifyError>>;
|
|
1962
|
+
getMenu(): Promise<Result<Product[], CimplifyError>>;
|
|
1963
|
+
getMenuByCategory(categoryId: string): Promise<Result<Product[], CimplifyError>>;
|
|
1964
|
+
}
|
|
1965
|
+
|
|
1966
|
+
interface FxQuoteRequest {
|
|
1967
|
+
from: CurrencyCode;
|
|
1968
|
+
to: CurrencyCode;
|
|
1969
|
+
amount: Money;
|
|
1970
|
+
}
|
|
1971
|
+
interface FxQuote {
|
|
1972
|
+
id: string;
|
|
1973
|
+
base_currency: CurrencyCode;
|
|
1974
|
+
pay_currency: CurrencyCode;
|
|
1975
|
+
rate: number;
|
|
1976
|
+
inverse_rate: number;
|
|
1977
|
+
base_amount: Money;
|
|
1978
|
+
converted_amount: Money;
|
|
1979
|
+
quoted_at: string;
|
|
1980
|
+
valid_until: string;
|
|
1981
|
+
}
|
|
1982
|
+
interface FxRateResponse {
|
|
1983
|
+
from: CurrencyCode;
|
|
1984
|
+
to: CurrencyCode;
|
|
1985
|
+
rate: number;
|
|
1986
|
+
inverse_rate: number;
|
|
1987
|
+
quoted_at: string;
|
|
1988
|
+
valid_until: string;
|
|
1989
|
+
}
|
|
1990
|
+
|
|
1991
|
+
declare class FxService {
|
|
1992
|
+
private client;
|
|
1993
|
+
constructor(client: CimplifyClient);
|
|
1994
|
+
getRate(from: CurrencyCode, to: CurrencyCode): Promise<Result<FxRateResponse, CimplifyError>>;
|
|
1995
|
+
lockQuote(request: FxQuoteRequest): Promise<Result<FxQuote, CimplifyError>>;
|
|
1996
|
+
}
|
|
1997
|
+
|
|
1998
|
+
declare const ELEMENT_TYPES: {
|
|
1999
|
+
readonly AUTH: "auth";
|
|
2000
|
+
readonly ADDRESS: "address";
|
|
2001
|
+
readonly PAYMENT: "payment";
|
|
2002
|
+
};
|
|
2003
|
+
type ElementType = (typeof ELEMENT_TYPES)[keyof typeof ELEMENT_TYPES];
|
|
2004
|
+
declare const MESSAGE_TYPES: {
|
|
2005
|
+
readonly INIT: "init";
|
|
2006
|
+
readonly SET_TOKEN: "set_token";
|
|
2007
|
+
readonly GET_DATA: "get_data";
|
|
2008
|
+
readonly REFRESH_TOKEN: "refresh_token";
|
|
2009
|
+
readonly LOGOUT: "logout";
|
|
2010
|
+
readonly PROCESS_CHECKOUT: "process_checkout";
|
|
2011
|
+
readonly ABORT_CHECKOUT: "abort_checkout";
|
|
2012
|
+
readonly READY: "ready";
|
|
2013
|
+
readonly HEIGHT_CHANGE: "height_change";
|
|
2014
|
+
readonly AUTHENTICATED: "authenticated";
|
|
2015
|
+
readonly REQUIRES_OTP: "requires_otp";
|
|
2016
|
+
readonly ERROR: "error";
|
|
2017
|
+
readonly ADDRESS_CHANGED: "address_changed";
|
|
2018
|
+
readonly ADDRESS_SELECTED: "address_selected";
|
|
2019
|
+
readonly PAYMENT_METHOD_SELECTED: "payment_method_selected";
|
|
2020
|
+
readonly TOKEN_REFRESHED: "token_refreshed";
|
|
2021
|
+
readonly LOGOUT_COMPLETE: "logout_complete";
|
|
2022
|
+
readonly CHECKOUT_STATUS: "checkout_status";
|
|
2023
|
+
readonly CHECKOUT_COMPLETE: "checkout_complete";
|
|
2024
|
+
};
|
|
2025
|
+
interface ElementsOptions {
|
|
2026
|
+
linkUrl?: string;
|
|
2027
|
+
appearance?: ElementAppearance;
|
|
2028
|
+
}
|
|
2029
|
+
interface ElementAppearance {
|
|
2030
|
+
theme?: "light" | "dark";
|
|
2031
|
+
variables?: {
|
|
2032
|
+
primaryColor?: string;
|
|
2033
|
+
fontFamily?: string;
|
|
2034
|
+
borderRadius?: string;
|
|
2035
|
+
};
|
|
2036
|
+
}
|
|
2037
|
+
interface ElementOptions {
|
|
2038
|
+
mode?: "shipping" | "billing";
|
|
2039
|
+
prefillEmail?: string;
|
|
2040
|
+
amount?: number;
|
|
2041
|
+
currency?: CurrencyCode;
|
|
2042
|
+
}
|
|
2043
|
+
interface AddressInfo {
|
|
2044
|
+
id?: string;
|
|
2045
|
+
street_address: string;
|
|
2046
|
+
apartment?: string;
|
|
2047
|
+
city: string;
|
|
2048
|
+
region: string;
|
|
2049
|
+
postal_code?: string;
|
|
2050
|
+
country?: string;
|
|
2051
|
+
delivery_instructions?: string;
|
|
2052
|
+
phone_for_delivery?: string;
|
|
2053
|
+
}
|
|
2054
|
+
interface PaymentMethodInfo {
|
|
2055
|
+
id?: string;
|
|
2056
|
+
type: "mobile_money" | "card" | "cash";
|
|
2057
|
+
provider?: string;
|
|
2058
|
+
last_four?: string;
|
|
2059
|
+
phone_number?: string;
|
|
2060
|
+
label?: string;
|
|
2061
|
+
}
|
|
2062
|
+
interface AuthenticatedCustomer {
|
|
2063
|
+
name: string;
|
|
2064
|
+
email: string | null;
|
|
2065
|
+
phone: string | null;
|
|
2066
|
+
}
|
|
2067
|
+
type ElementsCustomerInfo = {
|
|
2068
|
+
name: string;
|
|
2069
|
+
email: string | null;
|
|
2070
|
+
phone: string | null;
|
|
2071
|
+
} | null;
|
|
2072
|
+
interface AuthenticatedData {
|
|
2073
|
+
accountId: string;
|
|
2074
|
+
customerId: string;
|
|
2075
|
+
token: string;
|
|
2076
|
+
customer: AuthenticatedCustomer;
|
|
2077
|
+
}
|
|
2078
|
+
interface ElementsCheckoutData {
|
|
2079
|
+
cart_id: string;
|
|
2080
|
+
order_type?: "delivery" | "pickup" | "dine_in";
|
|
2081
|
+
location_id?: string;
|
|
2082
|
+
scheduled_time?: string;
|
|
2083
|
+
tip_amount?: number;
|
|
2084
|
+
notes?: string;
|
|
2085
|
+
}
|
|
2086
|
+
interface ElementsCheckoutResult {
|
|
2087
|
+
success: boolean;
|
|
2088
|
+
order?: {
|
|
2089
|
+
id: string;
|
|
2090
|
+
status: string;
|
|
2091
|
+
total: string;
|
|
2092
|
+
};
|
|
2093
|
+
error?: {
|
|
2094
|
+
code: string;
|
|
2095
|
+
message: string;
|
|
2096
|
+
};
|
|
2097
|
+
}
|
|
2098
|
+
type ParentToIframeMessage = {
|
|
2099
|
+
type: typeof MESSAGE_TYPES.INIT;
|
|
2100
|
+
businessId: string;
|
|
2101
|
+
publicKey: string;
|
|
2102
|
+
demoMode?: boolean;
|
|
2103
|
+
prefillEmail?: string;
|
|
2104
|
+
appearance?: ElementAppearance;
|
|
2105
|
+
} | {
|
|
2106
|
+
type: typeof MESSAGE_TYPES.SET_TOKEN;
|
|
2107
|
+
token: string;
|
|
2108
|
+
} | {
|
|
2109
|
+
type: typeof MESSAGE_TYPES.GET_DATA;
|
|
2110
|
+
} | {
|
|
2111
|
+
type: typeof MESSAGE_TYPES.REFRESH_TOKEN;
|
|
2112
|
+
} | {
|
|
2113
|
+
type: typeof MESSAGE_TYPES.LOGOUT;
|
|
2114
|
+
} | {
|
|
2115
|
+
type: typeof MESSAGE_TYPES.PROCESS_CHECKOUT;
|
|
2116
|
+
cart_id: string;
|
|
2117
|
+
order_type: "delivery" | "pickup" | "dine_in";
|
|
2118
|
+
location_id?: string;
|
|
2119
|
+
notes?: string;
|
|
2120
|
+
scheduled_time?: string;
|
|
2121
|
+
tip_amount?: number;
|
|
2122
|
+
pay_currency?: CurrencyCode;
|
|
2123
|
+
enroll_in_link?: boolean;
|
|
2124
|
+
address?: AddressInfo;
|
|
2125
|
+
customer: ElementsCustomerInfo;
|
|
2126
|
+
account_id?: string;
|
|
2127
|
+
customer_id?: string;
|
|
2128
|
+
} | {
|
|
2129
|
+
type: typeof MESSAGE_TYPES.ABORT_CHECKOUT;
|
|
2130
|
+
};
|
|
2131
|
+
type IframeToParentMessage = {
|
|
2132
|
+
type: typeof MESSAGE_TYPES.READY;
|
|
2133
|
+
height: number;
|
|
2134
|
+
} | {
|
|
2135
|
+
type: typeof MESSAGE_TYPES.HEIGHT_CHANGE;
|
|
2136
|
+
height: number;
|
|
2137
|
+
} | {
|
|
2138
|
+
type: typeof MESSAGE_TYPES.AUTHENTICATED;
|
|
2139
|
+
accountId: string;
|
|
2140
|
+
customerId: string;
|
|
2141
|
+
token: string;
|
|
2142
|
+
customer: AuthenticatedCustomer;
|
|
2143
|
+
} | {
|
|
2144
|
+
type: typeof MESSAGE_TYPES.REQUIRES_OTP;
|
|
2145
|
+
contactMasked: string;
|
|
2146
|
+
} | {
|
|
2147
|
+
type: typeof MESSAGE_TYPES.ERROR;
|
|
2148
|
+
code: string;
|
|
2149
|
+
message: string;
|
|
2150
|
+
} | {
|
|
2151
|
+
type: typeof MESSAGE_TYPES.ADDRESS_CHANGED;
|
|
2152
|
+
address: AddressInfo;
|
|
2153
|
+
saveToLink: boolean;
|
|
2154
|
+
} | {
|
|
2155
|
+
type: typeof MESSAGE_TYPES.ADDRESS_SELECTED;
|
|
2156
|
+
address: AddressInfo;
|
|
2157
|
+
} | {
|
|
2158
|
+
type: typeof MESSAGE_TYPES.PAYMENT_METHOD_SELECTED;
|
|
2159
|
+
method: PaymentMethodInfo;
|
|
2160
|
+
saveToLink: boolean;
|
|
2161
|
+
} | {
|
|
2162
|
+
type: typeof MESSAGE_TYPES.TOKEN_REFRESHED;
|
|
2163
|
+
token: string;
|
|
2164
|
+
} | {
|
|
2165
|
+
type: typeof MESSAGE_TYPES.LOGOUT_COMPLETE;
|
|
2166
|
+
} | {
|
|
2167
|
+
type: typeof MESSAGE_TYPES.CHECKOUT_STATUS;
|
|
2168
|
+
status: CheckoutStatus;
|
|
2169
|
+
context: CheckoutStatusContext;
|
|
2170
|
+
} | {
|
|
2171
|
+
type: typeof MESSAGE_TYPES.CHECKOUT_COMPLETE;
|
|
2172
|
+
success: boolean;
|
|
2173
|
+
order?: {
|
|
2174
|
+
id: string;
|
|
2175
|
+
order_number: string;
|
|
2176
|
+
status: string;
|
|
2177
|
+
total: string;
|
|
2178
|
+
currency: CurrencyCode;
|
|
2179
|
+
};
|
|
2180
|
+
error?: {
|
|
2181
|
+
code: string;
|
|
2182
|
+
message: string;
|
|
2183
|
+
recoverable: boolean;
|
|
2184
|
+
};
|
|
2185
|
+
enrolled_in_link?: boolean;
|
|
2186
|
+
};
|
|
2187
|
+
declare const EVENT_TYPES: {
|
|
2188
|
+
readonly READY: "ready";
|
|
2189
|
+
readonly AUTHENTICATED: "authenticated";
|
|
2190
|
+
readonly REQUIRES_OTP: "requires_otp";
|
|
2191
|
+
readonly ERROR: "error";
|
|
2192
|
+
readonly CHANGE: "change";
|
|
2193
|
+
readonly BLUR: "blur";
|
|
2194
|
+
readonly FOCUS: "focus";
|
|
2195
|
+
};
|
|
2196
|
+
type ElementEventType = (typeof EVENT_TYPES)[keyof typeof EVENT_TYPES];
|
|
2197
|
+
type ElementEventHandler<T = unknown> = (data: T) => void;
|
|
2198
|
+
|
|
2199
|
+
declare class CimplifyElements {
|
|
2200
|
+
private client;
|
|
2201
|
+
private businessId;
|
|
2202
|
+
private linkUrl;
|
|
2203
|
+
private options;
|
|
2204
|
+
private elements;
|
|
2205
|
+
private accessToken;
|
|
2206
|
+
private accountId;
|
|
2207
|
+
private customerId;
|
|
2208
|
+
private customerData;
|
|
2209
|
+
private addressData;
|
|
2210
|
+
private paymentData;
|
|
2211
|
+
private checkoutInProgress;
|
|
2212
|
+
private activeCheckoutAbort;
|
|
2213
|
+
private hasWarnedMissingAuthElement;
|
|
2214
|
+
private boundHandleMessage;
|
|
2215
|
+
private businessIdResolvePromise;
|
|
2216
|
+
constructor(client: CimplifyClient, businessId?: string, options?: ElementsOptions);
|
|
2217
|
+
create(type: ElementType, options?: ElementOptions): CimplifyElement;
|
|
2218
|
+
getElement(type: ElementType): CimplifyElement | undefined;
|
|
2219
|
+
destroy(): void;
|
|
2220
|
+
submitCheckout(data: ElementsCheckoutData): Promise<ElementsCheckoutResult>;
|
|
2221
|
+
processCheckout(options: ProcessCheckoutOptions): AbortablePromise<ProcessCheckoutResult>;
|
|
2222
|
+
isAuthenticated(): boolean;
|
|
2223
|
+
getAccessToken(): string | null;
|
|
2224
|
+
getPublicKey(): string;
|
|
2225
|
+
getBusinessId(): string | null;
|
|
2226
|
+
resolveBusinessId(): Promise<string | null>;
|
|
2227
|
+
getAppearance(): ElementsOptions["appearance"];
|
|
2228
|
+
private hydrateCustomerData;
|
|
2229
|
+
private handleMessage;
|
|
2230
|
+
_setAddressData(data: AddressInfo): void;
|
|
2231
|
+
_setPaymentData(data: PaymentMethodInfo): void;
|
|
2232
|
+
}
|
|
2233
|
+
declare class CimplifyElement {
|
|
2234
|
+
private type;
|
|
2235
|
+
private businessId;
|
|
2236
|
+
private linkUrl;
|
|
2237
|
+
private options;
|
|
2238
|
+
private parent;
|
|
2239
|
+
private iframe;
|
|
2240
|
+
private container;
|
|
2241
|
+
private mounted;
|
|
2242
|
+
private eventHandlers;
|
|
2243
|
+
private resolvers;
|
|
2244
|
+
private boundHandleMessage;
|
|
2245
|
+
constructor(type: ElementType, businessId: string | null, linkUrl: string, options: ElementOptions, parent: CimplifyElements);
|
|
2246
|
+
mount(container: string | HTMLElement): void;
|
|
2247
|
+
destroy(): void;
|
|
2248
|
+
on(event: ElementEventType, handler: ElementEventHandler): void;
|
|
2249
|
+
off(event: ElementEventType, handler: ElementEventHandler): void;
|
|
2250
|
+
getData(): Promise<unknown>;
|
|
2251
|
+
sendMessage(message: ParentToIframeMessage): void;
|
|
2252
|
+
getContentWindow(): Window | null;
|
|
2253
|
+
isMounted(): boolean;
|
|
2254
|
+
private createIframe;
|
|
2255
|
+
private handleMessage;
|
|
2256
|
+
private emit;
|
|
2257
|
+
private resolveData;
|
|
2258
|
+
}
|
|
2259
|
+
declare function createElements(client: CimplifyClient, businessId?: string, options?: ElementsOptions): CimplifyElements;
|
|
2260
|
+
|
|
2261
|
+
interface CimplifyConfig {
|
|
2262
|
+
publicKey?: string;
|
|
2263
|
+
credentials?: RequestCredentials;
|
|
2264
|
+
/** Override storefront base URL (default auto-derives by hostname). */
|
|
2265
|
+
baseUrl?: string;
|
|
2266
|
+
/** Override Link/API base URL (default auto-derives by hostname). */
|
|
2267
|
+
linkApiUrl?: string;
|
|
2268
|
+
/** Disable console warning when no public key is provided (for Link REST-only portal usage). */
|
|
2269
|
+
suppressPublicKeyWarning?: boolean;
|
|
2270
|
+
/** Request timeout in milliseconds (default: 30000) */
|
|
2271
|
+
timeout?: number;
|
|
2272
|
+
/** Maximum retry attempts for retryable errors (default: 3) */
|
|
2273
|
+
maxRetries?: number;
|
|
2274
|
+
/** Base delay between retries in milliseconds (default: 1000) */
|
|
2275
|
+
retryDelay?: number;
|
|
2276
|
+
/** Observability hooks for logging, metrics, and tracing */
|
|
2277
|
+
hooks?: ObservabilityHooks;
|
|
2278
|
+
}
|
|
2279
|
+
declare class CimplifyClient {
|
|
2280
|
+
private baseUrl;
|
|
2281
|
+
private linkApiUrl;
|
|
2282
|
+
private publicKey;
|
|
2283
|
+
private credentials;
|
|
2284
|
+
private accessToken;
|
|
2285
|
+
private timeout;
|
|
2286
|
+
private maxRetries;
|
|
2287
|
+
private retryDelay;
|
|
2288
|
+
private hooks;
|
|
2289
|
+
private context;
|
|
2290
|
+
private businessId;
|
|
2291
|
+
private businessIdResolvePromise;
|
|
2292
|
+
private inflightRequests;
|
|
2293
|
+
private _catalogue?;
|
|
2294
|
+
private _cart?;
|
|
2295
|
+
private _checkout?;
|
|
2296
|
+
private _orders?;
|
|
2297
|
+
private _link?;
|
|
2298
|
+
private _auth?;
|
|
2299
|
+
private _business?;
|
|
2300
|
+
private _inventory?;
|
|
2301
|
+
private _scheduling?;
|
|
2302
|
+
private _lite?;
|
|
2303
|
+
private _fx?;
|
|
2304
|
+
constructor(config?: CimplifyConfig);
|
|
2305
|
+
/** @deprecated Use getAccessToken() instead */
|
|
2306
|
+
getSessionToken(): string | null;
|
|
2307
|
+
/** @deprecated Use setAccessToken() instead */
|
|
2308
|
+
setSessionToken(token: string | null): void;
|
|
2309
|
+
getAccessToken(): string | null;
|
|
2310
|
+
getPublicKey(): string;
|
|
2311
|
+
isTestMode(): boolean;
|
|
2312
|
+
setAccessToken(token: string | null): void;
|
|
2313
|
+
clearSession(): void;
|
|
2314
|
+
/** Set the active location/branch for all subsequent requests */
|
|
2315
|
+
setLocationId(locationId: string | null): void;
|
|
2316
|
+
/** Get the currently active location ID */
|
|
2317
|
+
getLocationId(): string | null;
|
|
2318
|
+
/** Cache a resolved business ID for future element/checkouts initialization. */
|
|
2319
|
+
setBusinessId(businessId: string): void;
|
|
2320
|
+
/** Get cached business ID if available. */
|
|
2321
|
+
getBusinessId(): string | null;
|
|
2322
|
+
/**
|
|
2323
|
+
* Resolve business ID from public key once and cache it.
|
|
2324
|
+
* Subsequent calls return the cached value (or shared in-flight promise).
|
|
2325
|
+
*/
|
|
2326
|
+
resolveBusinessId(): Promise<string>;
|
|
2327
|
+
private loadAccessToken;
|
|
2328
|
+
private saveAccessToken;
|
|
2329
|
+
private getHeaders;
|
|
2330
|
+
private resilientFetch;
|
|
2331
|
+
private getDedupeKey;
|
|
2332
|
+
private deduplicatedRequest;
|
|
2333
|
+
query<T = unknown>(query: string, variables?: Record<string, unknown>): Promise<T>;
|
|
2334
|
+
call<T = unknown>(method: string, args?: unknown): Promise<T>;
|
|
2335
|
+
get<T = unknown>(path: string): Promise<T>;
|
|
2336
|
+
post<T = unknown>(path: string, body?: unknown): Promise<T>;
|
|
2337
|
+
patch<T = unknown>(path: string, body?: unknown): Promise<T>;
|
|
2338
|
+
delete<T = unknown>(path: string): Promise<T>;
|
|
2339
|
+
linkGet<T = unknown>(path: string): Promise<T>;
|
|
2340
|
+
linkPost<T = unknown>(path: string, body?: unknown): Promise<T>;
|
|
2341
|
+
linkDelete<T = unknown>(path: string): Promise<T>;
|
|
2342
|
+
private handleRestResponse;
|
|
2343
|
+
private handleResponse;
|
|
2344
|
+
get catalogue(): CatalogueQueries;
|
|
2345
|
+
get cart(): CartOperations;
|
|
2346
|
+
get checkout(): CheckoutService;
|
|
2347
|
+
get orders(): OrderQueries;
|
|
2348
|
+
get link(): LinkService;
|
|
2349
|
+
get auth(): AuthService;
|
|
2350
|
+
get business(): BusinessService;
|
|
2351
|
+
get inventory(): InventoryService;
|
|
2352
|
+
get scheduling(): SchedulingService;
|
|
2353
|
+
get lite(): LiteService;
|
|
2354
|
+
get fx(): FxService;
|
|
2355
|
+
/**
|
|
2356
|
+
* Create a CimplifyElements instance for embedding checkout components.
|
|
2357
|
+
* Like Stripe's stripe.elements().
|
|
2358
|
+
*
|
|
2359
|
+
* @param businessId - The business ID for checkout context
|
|
2360
|
+
* @param options - Optional configuration for elements
|
|
2361
|
+
*
|
|
2362
|
+
* @example
|
|
2363
|
+
* ```ts
|
|
2364
|
+
* const elements = client.elements('bus_xxx');
|
|
2365
|
+
* const authElement = elements.create('auth');
|
|
2366
|
+
* authElement.mount('#auth-container');
|
|
2367
|
+
* ```
|
|
2368
|
+
*/
|
|
2369
|
+
elements(businessId?: string, options?: ElementsOptions): CimplifyElements;
|
|
2370
|
+
}
|
|
2371
|
+
declare function createCimplifyClient(config?: CimplifyConfig): CimplifyClient;
|
|
2372
|
+
|
|
2373
|
+
export { type ProcessAndResolveOptions as $, AuthService as A, BusinessService as B, CimplifyClient as C, type ElementType as D, EVENT_TYPES as E, type FetchQuoteInput as F, type GetProductsOptions as G, type ElementEventType as H, InventoryService as I, type CheckoutMode as J, type KitchenOrderItem as K, LinkService as L, MESSAGE_TYPES as M, type CheckoutOrderType as N, OrderQueries as O, type PriceQuote as P, type QuoteCompositeSelectionInput as Q, type RefreshQuoteInput as R, type SearchOptions as S, type TableInfo as T, type UpdateProfileInput as U, type CheckoutPaymentMethod as V, type CheckoutStep as W, type CheckoutFormData as X, type CheckoutResult as Y, type ProcessCheckoutOptions as Z, type ProcessCheckoutResult as _, type CimplifyConfig as a, type OrderPaymentEvent as a$, type CheckoutStatus as a0, type CheckoutStatusContext as a1, type AbortablePromise as a2, type MobileMoneyProvider as a3, type DeviceType as a4, type ContactType as a5, CHECKOUT_MODE as a6, ORDER_TYPE as a7, PAYMENT_METHOD as a8, CHECKOUT_STEP as a9, toNullable as aA, fromPromise as aB, tryCatch as aC, combine as aD, combineObject as aE, type CatalogueResult as aF, type OrderStatus as aG, type PaymentState as aH, type OrderChannel as aI, type LineType as aJ, type OrderLineState as aK, type OrderLineStatus as aL, type FulfillmentType as aM, type FulfillmentStatus as aN, type FulfillmentLink as aO, type OrderFulfillmentSummary as aP, type FeeBearerType as aQ, type AmountToPay as aR, type LineItem as aS, type Order as aT, type OrderHistory as aU, type OrderGroupPaymentState as aV, type OrderGroup as aW, type OrderGroupPayment as aX, type OrderSplitDetail as aY, type OrderGroupPaymentSummary as aZ, type OrderGroupDetails as a_, PAYMENT_STATE as aa, PICKUP_TIME_TYPE as ab, MOBILE_MONEY_PROVIDER as ac, AUTHORIZATION_TYPE as ad, DEVICE_TYPE as ae, CONTACT_TYPE as af, LINK_QUERY as ag, LINK_MUTATION as ah, AUTH_MUTATION as ai, CHECKOUT_MUTATION as aj, PAYMENT_MUTATION as ak, ORDER_MUTATION as al, DEFAULT_CURRENCY as am, DEFAULT_COUNTRY as an, type Result as ao, type Ok as ap, type Err as aq, ok as ar, err as as, isOk as at, isErr as au, mapResult as av, mapError as aw, flatMap as ax, getOrElse as ay, unwrap as az, CatalogueQueries as b, type ServiceAvailabilityParams as b$, type OrderFilter as b0, type CheckoutInput as b1, type UpdateOrderStatusInput as b2, type CancelOrderInput as b3, type RefundOrderInput as b4, type ServiceStatus as b5, type StaffRole as b6, type ReminderMethod as b7, type CustomerServicePreferences as b8, type BufferTimes as b9, type LocationWithDetails as bA, type BusinessSettings as bB, type BusinessHours as bC, type CategoryInfo as bD, type ServiceAvailabilityRule as bE, type ServiceAvailabilityException as bF, type StaffAvailabilityRule as bG, type StaffAvailabilityException as bH, type ResourceAvailabilityRule as bI, type ResourceAvailabilityException as bJ, type StaffBookingProfile as bK, type ServiceStaffRequirement as bL, type BookingRequirementOverride as bM, type ResourceType as bN, type Service as bO, type ServiceWithStaff as bP, type Staff as bQ, type TimeSlot as bR, type AvailableSlot as bS, type DayAvailability as bT, type BookingStatus as bU, type Booking as bV, type BookingWithDetails as bW, type GetAvailableSlotsInput as bX, type CheckSlotAvailabilityInput as bY, type RescheduleBookingInput as bZ, type CancelBookingInput as b_, type ReminderSettings as ba, type CancellationPolicy as bb, type ServiceNotes as bc, type PricingOverrides as bd, type SchedulingMetadata as be, type StaffAssignment as bf, type ResourceAssignment as bg, type SchedulingResult as bh, type DepositResult as bi, type ServiceScheduleRequest as bj, type StaffScheduleItem as bk, type LocationAppointment as bl, type BusinessType as bm, type BusinessPreferences as bn, type Business as bo, type LocationTaxBehavior as bp, type LocationTaxOverrides as bq, type Location as br, type TimeRange as bs, type TimeRanges as bt, type LocationTimeProfile as bu, type Table as bv, type Room as bw, type ServiceCharge as bx, type StorefrontBootstrap as by, type BusinessWithLocations as bz, createCimplifyClient as c, type ServiceAvailabilityResult as c0, type StockOwnershipType as c1, type StockStatus as c2, type Stock as c3, type StockLevel as c4, type ProductStock as c5, type VariantStock as c6, type LocationStock as c7, type AvailabilityCheck as c8, type AvailabilityResult as c9, type CheckoutCustomerInfo as cA, type FxQuoteRequest as cB, type FxQuote as cC, type FxRateResponse as cD, type RequestContext as cE, type RequestStartEvent as cF, type RequestSuccessEvent as cG, type RequestErrorEvent as cH, type RetryEvent as cI, type SessionChangeEvent as cJ, type ObservabilityHooks as cK, type ElementAppearance as cL, type AddressInfo as cM, type PaymentMethodInfo as cN, type AuthenticatedCustomer as cO, type ElementsCustomerInfo as cP, type AuthenticatedData as cQ, type ElementsCheckoutData as cR, type ElementsCheckoutResult as cS, type ParentToIframeMessage as cT, type IframeToParentMessage as cU, type ElementEventHandler as cV, type InventorySummary as ca, type Customer as cb, type CustomerAddress as cc, type CustomerMobileMoney as cd, type CustomerLinkPreferences as ce, type LinkData as cf, type CreateAddressInput as cg, type UpdateAddressInput as ch, type CreateMobileMoneyInput as ci, type EnrollmentData as cj, type AddressData as ck, type MobileMoneyData as cl, type EnrollAndLinkOrderInput as cm, type LinkStatusResult as cn, type LinkEnrollResult as co, type EnrollAndLinkOrderResult as cp, type LinkSession as cq, type RevokeSessionResult as cr, type RevokeAllSessionsResult as cs, type RequestOtpInput as ct, type VerifyOtpInput as cu, type AuthResponse as cv, type PickupTimeType as cw, type PickupTime as cx, type CheckoutAddressInfo as cy, type MobileMoneyDetails as cz, type QuoteBundleSelectionInput as d, type QuoteStatus as e, type QuoteDynamicBuckets as f, type QuoteUiMessage as g, type RefreshQuoteResult as h, CartOperations as i, CheckoutService as j, generateIdempotencyKey as k, type GetOrdersOptions as l, type AuthStatus as m, type OtpResult as n, type ChangePasswordInput as o, SchedulingService as p, LiteService as q, FxService as r, type LiteBootstrap as s, type KitchenOrderResult as t, CimplifyElements as u, CimplifyElement as v, createElements as w, ELEMENT_TYPES as x, type ElementsOptions as y, type ElementOptions as z };
|