@cimplify/sdk 0.6.2 → 0.6.4
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/index.js +2592 -1709
- package/dist/index.mjs +2592 -1709
- package/dist/react.js +215 -1
- package/dist/react.mjs +217 -4
- package/package.json +5 -1
- package/dist/ads-CXOn6J7P.d.mts +0 -3325
- package/dist/ads-CXOn6J7P.d.ts +0 -3325
- package/dist/index.d.mts +0 -377
- package/dist/index.d.ts +0 -377
- package/dist/react.d.mts +0 -105
- package/dist/react.d.ts +0 -105
package/dist/ads-CXOn6J7P.d.ts
DELETED
|
@@ -1,3325 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Observability hooks for monitoring SDK behavior.
|
|
3
|
-
*
|
|
4
|
-
* These hooks allow you to plug in your own logging, metrics, and tracing
|
|
5
|
-
* without the SDK depending on any specific observability library.
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* ```typescript
|
|
9
|
-
* const client = createCimplifyClient({
|
|
10
|
-
* hooks: {
|
|
11
|
-
* onRequestStart: ({ method, path }) => {
|
|
12
|
-
* console.log(`[SDK] ${method} ${path}`);
|
|
13
|
-
* },
|
|
14
|
-
* onRequestSuccess: ({ method, path, durationMs }) => {
|
|
15
|
-
* metrics.histogram('sdk.request.duration', durationMs, { method, path });
|
|
16
|
-
* },
|
|
17
|
-
* onRequestError: ({ method, path, error, retryCount }) => {
|
|
18
|
-
* Sentry.captureException(error, { extra: { method, path, retryCount } });
|
|
19
|
-
* },
|
|
20
|
-
* },
|
|
21
|
-
* });
|
|
22
|
-
* ```
|
|
23
|
-
*/
|
|
24
|
-
/** Context passed to request lifecycle hooks */
|
|
25
|
-
interface RequestContext {
|
|
26
|
-
/** HTTP method */
|
|
27
|
-
method: "GET" | "POST" | "DELETE";
|
|
28
|
-
/** Request path (e.g., "/api/q", "/api/m") */
|
|
29
|
-
path: string;
|
|
30
|
-
/** Full URL */
|
|
31
|
-
url: string;
|
|
32
|
-
/** Request body (for POST requests) */
|
|
33
|
-
body?: unknown;
|
|
34
|
-
/** Timestamp when request started */
|
|
35
|
-
startTime: number;
|
|
36
|
-
}
|
|
37
|
-
/** Passed when a request starts */
|
|
38
|
-
interface RequestStartEvent extends RequestContext {
|
|
39
|
-
}
|
|
40
|
-
/** Passed when a request succeeds */
|
|
41
|
-
interface RequestSuccessEvent extends RequestContext {
|
|
42
|
-
/** HTTP status code */
|
|
43
|
-
status: number;
|
|
44
|
-
/** Duration in milliseconds */
|
|
45
|
-
durationMs: number;
|
|
46
|
-
}
|
|
47
|
-
/** Passed when a request fails */
|
|
48
|
-
interface RequestErrorEvent extends RequestContext {
|
|
49
|
-
/** The error that occurred */
|
|
50
|
-
error: Error;
|
|
51
|
-
/** Duration in milliseconds */
|
|
52
|
-
durationMs: number;
|
|
53
|
-
/** Number of retries attempted before giving up */
|
|
54
|
-
retryCount: number;
|
|
55
|
-
/** Whether the error is retryable */
|
|
56
|
-
retryable: boolean;
|
|
57
|
-
}
|
|
58
|
-
/** Passed when a retry is about to happen */
|
|
59
|
-
interface RetryEvent extends RequestContext {
|
|
60
|
-
/** Which retry attempt (1, 2, 3...) */
|
|
61
|
-
attempt: number;
|
|
62
|
-
/** Delay before retry in milliseconds */
|
|
63
|
-
delayMs: number;
|
|
64
|
-
/** The error that triggered the retry */
|
|
65
|
-
error: Error;
|
|
66
|
-
}
|
|
67
|
-
/** Passed when session token changes */
|
|
68
|
-
interface SessionChangeEvent {
|
|
69
|
-
/** Previous token (null if none) */
|
|
70
|
-
previousToken: string | null;
|
|
71
|
-
/** New token (null if cleared) */
|
|
72
|
-
newToken: string | null;
|
|
73
|
-
/** Source of the change */
|
|
74
|
-
source: "response" | "manual" | "clear";
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Observability hooks configuration.
|
|
78
|
-
* All hooks are optional - only implement what you need.
|
|
79
|
-
*/
|
|
80
|
-
interface ObservabilityHooks {
|
|
81
|
-
/** Called when a request is about to be sent */
|
|
82
|
-
onRequestStart?: (event: RequestStartEvent) => void;
|
|
83
|
-
/** Called when a request completes successfully */
|
|
84
|
-
onRequestSuccess?: (event: RequestSuccessEvent) => void;
|
|
85
|
-
/** Called when a request fails (after all retries exhausted) */
|
|
86
|
-
onRequestError?: (event: RequestErrorEvent) => void;
|
|
87
|
-
/** Called before each retry attempt */
|
|
88
|
-
onRetry?: (event: RetryEvent) => void;
|
|
89
|
-
/** Called when session token changes */
|
|
90
|
-
onSessionChange?: (event: SessionChangeEvent) => void;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/** Decimal value represented as string for precision */
|
|
94
|
-
type Money = string;
|
|
95
|
-
/** Supported currencies */
|
|
96
|
-
type Currency = "GHS" | "USD" | "NGN" | "KES" | "ZAR" | string;
|
|
97
|
-
/** Pagination parameters */
|
|
98
|
-
interface PaginationParams {
|
|
99
|
-
page?: number;
|
|
100
|
-
limit?: number;
|
|
101
|
-
offset?: number;
|
|
102
|
-
}
|
|
103
|
-
/** Pagination metadata in response */
|
|
104
|
-
interface Pagination {
|
|
105
|
-
total_count: number;
|
|
106
|
-
current_page: number;
|
|
107
|
-
page_size: number;
|
|
108
|
-
total_pages: number;
|
|
109
|
-
}
|
|
110
|
-
/** Strongly-typed error codes for better DX */
|
|
111
|
-
declare const ErrorCode: {
|
|
112
|
-
readonly UNKNOWN_ERROR: "UNKNOWN_ERROR";
|
|
113
|
-
readonly NETWORK_ERROR: "NETWORK_ERROR";
|
|
114
|
-
readonly TIMEOUT: "TIMEOUT";
|
|
115
|
-
readonly UNAUTHORIZED: "UNAUTHORIZED";
|
|
116
|
-
readonly FORBIDDEN: "FORBIDDEN";
|
|
117
|
-
readonly NOT_FOUND: "NOT_FOUND";
|
|
118
|
-
readonly VALIDATION_ERROR: "VALIDATION_ERROR";
|
|
119
|
-
readonly CART_EMPTY: "CART_EMPTY";
|
|
120
|
-
readonly CART_EXPIRED: "CART_EXPIRED";
|
|
121
|
-
readonly CART_NOT_FOUND: "CART_NOT_FOUND";
|
|
122
|
-
readonly ITEM_UNAVAILABLE: "ITEM_UNAVAILABLE";
|
|
123
|
-
readonly VARIANT_NOT_FOUND: "VARIANT_NOT_FOUND";
|
|
124
|
-
readonly VARIANT_OUT_OF_STOCK: "VARIANT_OUT_OF_STOCK";
|
|
125
|
-
readonly ADDON_REQUIRED: "ADDON_REQUIRED";
|
|
126
|
-
readonly ADDON_MAX_EXCEEDED: "ADDON_MAX_EXCEEDED";
|
|
127
|
-
readonly CHECKOUT_VALIDATION_FAILED: "CHECKOUT_VALIDATION_FAILED";
|
|
128
|
-
readonly DELIVERY_ADDRESS_REQUIRED: "DELIVERY_ADDRESS_REQUIRED";
|
|
129
|
-
readonly CUSTOMER_INFO_REQUIRED: "CUSTOMER_INFO_REQUIRED";
|
|
130
|
-
readonly PAYMENT_FAILED: "PAYMENT_FAILED";
|
|
131
|
-
readonly PAYMENT_CANCELLED: "PAYMENT_CANCELLED";
|
|
132
|
-
readonly INSUFFICIENT_FUNDS: "INSUFFICIENT_FUNDS";
|
|
133
|
-
readonly CARD_DECLINED: "CARD_DECLINED";
|
|
134
|
-
readonly INVALID_OTP: "INVALID_OTP";
|
|
135
|
-
readonly OTP_EXPIRED: "OTP_EXPIRED";
|
|
136
|
-
readonly AUTHORIZATION_FAILED: "AUTHORIZATION_FAILED";
|
|
137
|
-
readonly PAYMENT_ACTION_NOT_COMPLETED: "PAYMENT_ACTION_NOT_COMPLETED";
|
|
138
|
-
readonly SLOT_UNAVAILABLE: "SLOT_UNAVAILABLE";
|
|
139
|
-
readonly BOOKING_CONFLICT: "BOOKING_CONFLICT";
|
|
140
|
-
readonly SERVICE_NOT_FOUND: "SERVICE_NOT_FOUND";
|
|
141
|
-
readonly OUT_OF_STOCK: "OUT_OF_STOCK";
|
|
142
|
-
readonly INSUFFICIENT_QUANTITY: "INSUFFICIENT_QUANTITY";
|
|
143
|
-
};
|
|
144
|
-
type ErrorCodeType = (typeof ErrorCode)[keyof typeof ErrorCode];
|
|
145
|
-
/** API error structure */
|
|
146
|
-
interface ApiError {
|
|
147
|
-
code: string;
|
|
148
|
-
message: string;
|
|
149
|
-
retryable: boolean;
|
|
150
|
-
}
|
|
151
|
-
/**
|
|
152
|
-
* Custom error class for SDK errors with typed error codes.
|
|
153
|
-
*
|
|
154
|
-
* @example
|
|
155
|
-
* ```typescript
|
|
156
|
-
* try {
|
|
157
|
-
* await client.cart.addItem({ item_id: "prod_123" });
|
|
158
|
-
* } catch (error) {
|
|
159
|
-
* if (isCimplifyError(error)) {
|
|
160
|
-
* switch (error.code) {
|
|
161
|
-
* case ErrorCode.ITEM_UNAVAILABLE:
|
|
162
|
-
* toast.error("This item is no longer available");
|
|
163
|
-
* break;
|
|
164
|
-
* case ErrorCode.VARIANT_OUT_OF_STOCK:
|
|
165
|
-
* toast.error("Selected option is out of stock");
|
|
166
|
-
* break;
|
|
167
|
-
* default:
|
|
168
|
-
* toast.error(error.message);
|
|
169
|
-
* }
|
|
170
|
-
* }
|
|
171
|
-
* }
|
|
172
|
-
* ```
|
|
173
|
-
*/
|
|
174
|
-
declare class CimplifyError extends Error {
|
|
175
|
-
code: string;
|
|
176
|
-
retryable: boolean;
|
|
177
|
-
constructor(code: string, message: string, retryable?: boolean);
|
|
178
|
-
/** User-friendly message safe to display */
|
|
179
|
-
get userMessage(): string;
|
|
180
|
-
}
|
|
181
|
-
/** Type guard for CimplifyError */
|
|
182
|
-
declare function isCimplifyError(error: unknown): error is CimplifyError;
|
|
183
|
-
/** Check if error is retryable */
|
|
184
|
-
declare function isRetryableError(error: unknown): boolean;
|
|
185
|
-
|
|
186
|
-
type ProductType = "product" | "service" | "digital" | "bundle" | "composite";
|
|
187
|
-
type InventoryType = "one_to_one" | "composition" | "none";
|
|
188
|
-
type VariantStrategy = "fetch_all" | "use_axes";
|
|
189
|
-
type DigitalProductType = "download" | "license_key" | "ticket" | "access_grant" | "redemption_code";
|
|
190
|
-
type DepositType = "none" | "fixed" | "percentage";
|
|
191
|
-
type SalesChannel = "pos" | "online" | "marketplace" | "partners";
|
|
192
|
-
interface Product {
|
|
193
|
-
id: string;
|
|
194
|
-
business_id: string;
|
|
195
|
-
category_id?: string;
|
|
196
|
-
name: string;
|
|
197
|
-
slug: string;
|
|
198
|
-
description?: string;
|
|
199
|
-
image_url?: string;
|
|
200
|
-
default_price: Money;
|
|
201
|
-
product_type: ProductType;
|
|
202
|
-
inventory_type: InventoryType;
|
|
203
|
-
variant_strategy: VariantStrategy;
|
|
204
|
-
is_active: boolean;
|
|
205
|
-
created_at: string;
|
|
206
|
-
updated_at: string;
|
|
207
|
-
metadata?: Record<string, unknown>;
|
|
208
|
-
tags?: string[];
|
|
209
|
-
images?: string[];
|
|
210
|
-
calories?: number;
|
|
211
|
-
allergies?: string[];
|
|
212
|
-
recipe?: Record<string, unknown>;
|
|
213
|
-
sku?: string;
|
|
214
|
-
barcode?: string;
|
|
215
|
-
ean?: string;
|
|
216
|
-
upc?: string;
|
|
217
|
-
is_trackable?: boolean;
|
|
218
|
-
is_tracked?: boolean;
|
|
219
|
-
is_tracked_in_store?: boolean;
|
|
220
|
-
is_tracked_in_warehouse?: boolean;
|
|
221
|
-
inventory_threshold?: number;
|
|
222
|
-
external_id?: string;
|
|
223
|
-
external_source?: string;
|
|
224
|
-
download_url?: string;
|
|
225
|
-
digital_type?: DigitalProductType;
|
|
226
|
-
max_downloads?: number;
|
|
227
|
-
license_key_required?: boolean;
|
|
228
|
-
file_size_mb?: number;
|
|
229
|
-
file_hash?: string;
|
|
230
|
-
file_type?: string;
|
|
231
|
-
version?: string;
|
|
232
|
-
download_expires_days?: number;
|
|
233
|
-
license_key_format?: string;
|
|
234
|
-
max_activations?: number;
|
|
235
|
-
validity_days?: number;
|
|
236
|
-
event_id?: string;
|
|
237
|
-
event_date?: string;
|
|
238
|
-
venue?: string;
|
|
239
|
-
ticket_type?: string;
|
|
240
|
-
seat_info?: Record<string, unknown>;
|
|
241
|
-
access_type?: string;
|
|
242
|
-
access_level?: string;
|
|
243
|
-
access_duration_days?: number;
|
|
244
|
-
code_type?: string;
|
|
245
|
-
code_value?: Money;
|
|
246
|
-
code_currency?: string;
|
|
247
|
-
duration_minutes?: number;
|
|
248
|
-
preparation_time_minutes?: number;
|
|
249
|
-
staff_required_count?: number;
|
|
250
|
-
buffer_before_minutes?: number;
|
|
251
|
-
buffer_after_minutes?: number;
|
|
252
|
-
general_service_capacity?: number;
|
|
253
|
-
deposit_type?: DepositType;
|
|
254
|
-
deposit_amount?: Money;
|
|
255
|
-
cancellation_window_minutes?: number;
|
|
256
|
-
no_show_fee?: Money;
|
|
257
|
-
requires_specific_staff?: boolean;
|
|
258
|
-
requires_specific_resource?: boolean;
|
|
259
|
-
hs_code?: string;
|
|
260
|
-
mid_code?: string;
|
|
261
|
-
material?: string;
|
|
262
|
-
allow_backorder?: boolean;
|
|
263
|
-
item_condition?: string;
|
|
264
|
-
vendor?: string;
|
|
265
|
-
length_mm?: number;
|
|
266
|
-
width_mm?: number;
|
|
267
|
-
height_mm?: number;
|
|
268
|
-
channels?: SalesChannel[];
|
|
269
|
-
meta_title?: string;
|
|
270
|
-
meta_description?: string;
|
|
271
|
-
is_discountable?: boolean;
|
|
272
|
-
taxonomy_id?: string;
|
|
273
|
-
}
|
|
274
|
-
interface ProductWithDetails extends Product {
|
|
275
|
-
category?: Category;
|
|
276
|
-
variants?: ProductVariant[];
|
|
277
|
-
add_ons?: AddOnWithOptions[];
|
|
278
|
-
variant_axes?: VariantAxisWithValues[];
|
|
279
|
-
location_prices?: LocationProductPrice[];
|
|
280
|
-
location_availability?: ProductAvailability[];
|
|
281
|
-
time_profiles?: ProductTimeProfile[];
|
|
282
|
-
}
|
|
283
|
-
interface ProductVariant {
|
|
284
|
-
id: string;
|
|
285
|
-
name: string;
|
|
286
|
-
business_id: string;
|
|
287
|
-
product_id: string;
|
|
288
|
-
component_multiplier: Money;
|
|
289
|
-
price_adjustment: Money;
|
|
290
|
-
is_default: boolean;
|
|
291
|
-
created_at: string;
|
|
292
|
-
updated_at: string;
|
|
293
|
-
is_active?: boolean;
|
|
294
|
-
is_archived?: boolean;
|
|
295
|
-
is_deleted?: boolean;
|
|
296
|
-
inventory_threshold?: number;
|
|
297
|
-
images?: string[];
|
|
298
|
-
external_id?: string;
|
|
299
|
-
external_source?: string;
|
|
300
|
-
ean?: string;
|
|
301
|
-
upc?: string;
|
|
302
|
-
is_trackable?: boolean;
|
|
303
|
-
is_tracked?: boolean;
|
|
304
|
-
is_tracked_in_store?: boolean;
|
|
305
|
-
is_tracked_in_warehouse?: boolean;
|
|
306
|
-
sku?: string;
|
|
307
|
-
barcode?: string;
|
|
308
|
-
download_url?: string;
|
|
309
|
-
metadata?: Record<string, unknown>;
|
|
310
|
-
duration_minutes?: number;
|
|
311
|
-
max_downloads?: number;
|
|
312
|
-
license_key?: string;
|
|
313
|
-
display_attributes?: VariantDisplayAttribute[];
|
|
314
|
-
}
|
|
315
|
-
interface VariantDisplayAttribute {
|
|
316
|
-
axis_id: string;
|
|
317
|
-
axis_name: string;
|
|
318
|
-
value_id: string;
|
|
319
|
-
value_name: string;
|
|
320
|
-
}
|
|
321
|
-
interface VariantAxis {
|
|
322
|
-
id: string;
|
|
323
|
-
business_id: string;
|
|
324
|
-
product_id: string;
|
|
325
|
-
name: string;
|
|
326
|
-
display_order: number;
|
|
327
|
-
affects_recipe: boolean;
|
|
328
|
-
created_at: string;
|
|
329
|
-
updated_at: string;
|
|
330
|
-
metadata?: Record<string, unknown>;
|
|
331
|
-
}
|
|
332
|
-
interface VariantAxisWithValues extends VariantAxis {
|
|
333
|
-
values: VariantAxisValue[];
|
|
334
|
-
}
|
|
335
|
-
interface VariantAxisValue {
|
|
336
|
-
id: string;
|
|
337
|
-
business_id: string;
|
|
338
|
-
axis_id: string;
|
|
339
|
-
name: string;
|
|
340
|
-
display_order: number;
|
|
341
|
-
created_at: string;
|
|
342
|
-
updated_at: string;
|
|
343
|
-
metadata?: Record<string, unknown>;
|
|
344
|
-
}
|
|
345
|
-
interface ProductVariantValue {
|
|
346
|
-
variant_id: string;
|
|
347
|
-
axis_value_id: string;
|
|
348
|
-
business_id: string;
|
|
349
|
-
created_at: string;
|
|
350
|
-
updated_at: string;
|
|
351
|
-
metadata?: Record<string, unknown>;
|
|
352
|
-
}
|
|
353
|
-
interface VariantLocationAvailability {
|
|
354
|
-
id: string;
|
|
355
|
-
variant_id: string;
|
|
356
|
-
location_id: string;
|
|
357
|
-
business_id: string;
|
|
358
|
-
is_available: boolean;
|
|
359
|
-
is_in_stock: boolean;
|
|
360
|
-
created_at: string;
|
|
361
|
-
updated_at: string;
|
|
362
|
-
metadata?: Record<string, unknown>;
|
|
363
|
-
}
|
|
364
|
-
/** Input for selecting a variant by axis values */
|
|
365
|
-
interface VariantAxisSelection {
|
|
366
|
-
[axisName: string]: string;
|
|
367
|
-
}
|
|
368
|
-
interface AddOn {
|
|
369
|
-
id: string;
|
|
370
|
-
business_id: string;
|
|
371
|
-
name: string;
|
|
372
|
-
is_multiple_allowed: boolean;
|
|
373
|
-
is_required: boolean;
|
|
374
|
-
is_mutually_exclusive: boolean;
|
|
375
|
-
min_selections?: number;
|
|
376
|
-
max_selections?: number;
|
|
377
|
-
created_at: string;
|
|
378
|
-
updated_at: string;
|
|
379
|
-
metadata?: Record<string, unknown>;
|
|
380
|
-
}
|
|
381
|
-
interface AddOnWithOptions extends AddOn {
|
|
382
|
-
options: AddOnOption[];
|
|
383
|
-
}
|
|
384
|
-
interface AddOnOption {
|
|
385
|
-
id: string;
|
|
386
|
-
add_on_id: string;
|
|
387
|
-
business_id: string;
|
|
388
|
-
name: string;
|
|
389
|
-
option_sku?: string;
|
|
390
|
-
default_price?: Money;
|
|
391
|
-
description?: string;
|
|
392
|
-
is_required: boolean;
|
|
393
|
-
is_mutually_exclusive: boolean;
|
|
394
|
-
created_at: string;
|
|
395
|
-
updated_at: string;
|
|
396
|
-
metadata?: Record<string, unknown>;
|
|
397
|
-
}
|
|
398
|
-
interface AddOnOptionPrice {
|
|
399
|
-
id: string;
|
|
400
|
-
add_on_option_id: string;
|
|
401
|
-
location_id: string;
|
|
402
|
-
business_id: string;
|
|
403
|
-
price: Money;
|
|
404
|
-
created_at: string;
|
|
405
|
-
updated_at: string;
|
|
406
|
-
metadata?: Record<string, unknown>;
|
|
407
|
-
}
|
|
408
|
-
interface ProductAddOn {
|
|
409
|
-
id: string;
|
|
410
|
-
business_id: string;
|
|
411
|
-
product_id: string;
|
|
412
|
-
add_on_id: string;
|
|
413
|
-
created_at: string;
|
|
414
|
-
updated_at: string;
|
|
415
|
-
metadata?: Record<string, unknown>;
|
|
416
|
-
}
|
|
417
|
-
interface Category {
|
|
418
|
-
id: string;
|
|
419
|
-
business_id: string;
|
|
420
|
-
name: string;
|
|
421
|
-
slug: string;
|
|
422
|
-
description?: string;
|
|
423
|
-
created_at: string;
|
|
424
|
-
updated_at: string;
|
|
425
|
-
metadata?: Record<string, unknown>;
|
|
426
|
-
}
|
|
427
|
-
interface CategorySummary extends Category {
|
|
428
|
-
product_count: number;
|
|
429
|
-
}
|
|
430
|
-
interface Collection {
|
|
431
|
-
id: string;
|
|
432
|
-
business_id: string;
|
|
433
|
-
name: string;
|
|
434
|
-
slug: string;
|
|
435
|
-
description?: string;
|
|
436
|
-
tags?: string[];
|
|
437
|
-
image_url?: string;
|
|
438
|
-
channels?: SalesChannel[];
|
|
439
|
-
created_at: string;
|
|
440
|
-
updated_at: string;
|
|
441
|
-
metadata?: Record<string, unknown>;
|
|
442
|
-
}
|
|
443
|
-
interface CollectionSummary extends Collection {
|
|
444
|
-
product_count: number;
|
|
445
|
-
}
|
|
446
|
-
interface CollectionProduct {
|
|
447
|
-
id: string;
|
|
448
|
-
collection_id: string;
|
|
449
|
-
product_id: string;
|
|
450
|
-
display_order?: number;
|
|
451
|
-
created_at: string;
|
|
452
|
-
updated_at: string;
|
|
453
|
-
metadata?: Record<string, unknown>;
|
|
454
|
-
}
|
|
455
|
-
type BundlePriceType = "fixed" | "percentage_discount" | "fixed_discount";
|
|
456
|
-
interface Bundle {
|
|
457
|
-
id: string;
|
|
458
|
-
business_id: string;
|
|
459
|
-
product_id: string;
|
|
460
|
-
name: string;
|
|
461
|
-
slug: string;
|
|
462
|
-
description?: string;
|
|
463
|
-
image_url?: string;
|
|
464
|
-
pricing_type: BundlePriceType;
|
|
465
|
-
bundle_price?: Money;
|
|
466
|
-
discount_value?: Money;
|
|
467
|
-
created_at: string;
|
|
468
|
-
updated_at: string;
|
|
469
|
-
metadata?: Record<string, unknown>;
|
|
470
|
-
}
|
|
471
|
-
interface BundleSummary extends Bundle {
|
|
472
|
-
product_count: number;
|
|
473
|
-
}
|
|
474
|
-
interface BundleProduct {
|
|
475
|
-
id: string;
|
|
476
|
-
bundle_id: string;
|
|
477
|
-
product_id: string;
|
|
478
|
-
variant_id?: string;
|
|
479
|
-
allow_variant_choice: boolean;
|
|
480
|
-
quantity: number;
|
|
481
|
-
created_at: string;
|
|
482
|
-
updated_at: string;
|
|
483
|
-
metadata?: Record<string, unknown>;
|
|
484
|
-
}
|
|
485
|
-
interface BundleWithDetails extends Bundle {
|
|
486
|
-
product: Product;
|
|
487
|
-
components: BundleComponentData[];
|
|
488
|
-
schedules?: ProductTimeProfile[];
|
|
489
|
-
availability?: Record<string, ProductAvailability>;
|
|
490
|
-
}
|
|
491
|
-
interface BundleComponentData {
|
|
492
|
-
component: BundleProduct;
|
|
493
|
-
product: Product;
|
|
494
|
-
variants: ProductVariant[];
|
|
495
|
-
variant_axes: VariantAxis[];
|
|
496
|
-
variant_axis_values: VariantAxisValue[];
|
|
497
|
-
product_variant_values: ProductVariantValue[];
|
|
498
|
-
}
|
|
499
|
-
interface BundleComponentInfo {
|
|
500
|
-
id: string;
|
|
501
|
-
product_id: string;
|
|
502
|
-
variant_id?: string;
|
|
503
|
-
quantity: number;
|
|
504
|
-
}
|
|
505
|
-
type CompositePricingMode = "additive" | "highest_per_group" | "highest_overall" | "tiered";
|
|
506
|
-
type GroupPricingBehavior = "additive" | "first_n_free" | "flat_fee" | "highest_only";
|
|
507
|
-
type ComponentSourceType = "product" | "stock" | "add_on" | "standalone";
|
|
508
|
-
interface Composite {
|
|
509
|
-
id: string;
|
|
510
|
-
business_id: string;
|
|
511
|
-
product_id: string;
|
|
512
|
-
base_price: Money;
|
|
513
|
-
pricing_mode: CompositePricingMode;
|
|
514
|
-
min_order_quantity?: number;
|
|
515
|
-
max_order_quantity?: number;
|
|
516
|
-
created_at: string;
|
|
517
|
-
updated_at: string;
|
|
518
|
-
metadata?: Record<string, unknown>;
|
|
519
|
-
}
|
|
520
|
-
interface CompositeWithDetails extends Composite {
|
|
521
|
-
product: Product;
|
|
522
|
-
groups: ComponentGroupWithComponents[];
|
|
523
|
-
}
|
|
524
|
-
interface ComponentGroup {
|
|
525
|
-
id: string;
|
|
526
|
-
composite_id: string;
|
|
527
|
-
name: string;
|
|
528
|
-
description?: string;
|
|
529
|
-
display_order: number;
|
|
530
|
-
min_selections: number;
|
|
531
|
-
max_selections?: number;
|
|
532
|
-
allow_quantity: boolean;
|
|
533
|
-
max_quantity_per_component?: number;
|
|
534
|
-
pricing_behavior: GroupPricingBehavior;
|
|
535
|
-
pricing_behavior_config?: Record<string, unknown>;
|
|
536
|
-
icon?: string;
|
|
537
|
-
color?: string;
|
|
538
|
-
created_at: string;
|
|
539
|
-
updated_at: string;
|
|
540
|
-
}
|
|
541
|
-
interface ComponentGroupWithComponents extends ComponentGroup {
|
|
542
|
-
components: CompositeComponent[];
|
|
543
|
-
}
|
|
544
|
-
interface CompositeComponent {
|
|
545
|
-
id: string;
|
|
546
|
-
group_id: string;
|
|
547
|
-
product_id?: string;
|
|
548
|
-
variant_id?: string;
|
|
549
|
-
stock_id?: string;
|
|
550
|
-
add_on_id?: string;
|
|
551
|
-
add_on_option_id?: string;
|
|
552
|
-
display_name?: string;
|
|
553
|
-
display_description?: string;
|
|
554
|
-
display_image_url?: string;
|
|
555
|
-
price: Money;
|
|
556
|
-
price_per_additional?: Money;
|
|
557
|
-
quantity_per_selection?: Money;
|
|
558
|
-
waste_percentage?: Money;
|
|
559
|
-
calories?: number;
|
|
560
|
-
allergens?: string[];
|
|
561
|
-
display_order: number;
|
|
562
|
-
is_popular: boolean;
|
|
563
|
-
is_premium: boolean;
|
|
564
|
-
is_available: boolean;
|
|
565
|
-
is_archived: boolean;
|
|
566
|
-
created_at: string;
|
|
567
|
-
updated_at: string;
|
|
568
|
-
}
|
|
569
|
-
/** Input for calculating composite price or adding to cart */
|
|
570
|
-
interface ComponentSelectionInput {
|
|
571
|
-
component_id: string;
|
|
572
|
-
quantity: number;
|
|
573
|
-
variant_id?: string;
|
|
574
|
-
add_on_option_id?: string;
|
|
575
|
-
}
|
|
576
|
-
/** Result of composite price calculation */
|
|
577
|
-
interface CompositePriceResult {
|
|
578
|
-
base_price: Money;
|
|
579
|
-
components_total: Money;
|
|
580
|
-
tier_applied?: string;
|
|
581
|
-
final_price: Money;
|
|
582
|
-
breakdown: ComponentPriceBreakdown[];
|
|
583
|
-
}
|
|
584
|
-
interface ComponentPriceBreakdown {
|
|
585
|
-
component_id: string;
|
|
586
|
-
component_name: string;
|
|
587
|
-
quantity: number;
|
|
588
|
-
unit_price: Money;
|
|
589
|
-
total_price: Money;
|
|
590
|
-
group_id: string;
|
|
591
|
-
source_type: ComponentSourceType;
|
|
592
|
-
source_product_id?: string;
|
|
593
|
-
source_stock_id?: string;
|
|
594
|
-
}
|
|
595
|
-
type PriceEntryType = "base" | "location" | "time" | "channel";
|
|
596
|
-
interface Price {
|
|
597
|
-
id: string;
|
|
598
|
-
product_id: string;
|
|
599
|
-
location_id: string;
|
|
600
|
-
business_id: string;
|
|
601
|
-
price: Money;
|
|
602
|
-
entry_type: PriceEntryType;
|
|
603
|
-
created_at: string;
|
|
604
|
-
updated_at: string;
|
|
605
|
-
metadata?: Record<string, unknown>;
|
|
606
|
-
}
|
|
607
|
-
type LocationProductPrice = Price;
|
|
608
|
-
interface ProductAvailability {
|
|
609
|
-
id: string;
|
|
610
|
-
business_id: string;
|
|
611
|
-
location_id: string;
|
|
612
|
-
product_id: string;
|
|
613
|
-
is_available: boolean;
|
|
614
|
-
is_in_stock: boolean;
|
|
615
|
-
created_at: string;
|
|
616
|
-
updated_at: string;
|
|
617
|
-
metadata?: Record<string, unknown>;
|
|
618
|
-
}
|
|
619
|
-
interface ProductTimeProfile {
|
|
620
|
-
id: string;
|
|
621
|
-
business_id: string;
|
|
622
|
-
product_id: string;
|
|
623
|
-
day_of_week: number;
|
|
624
|
-
start_time: string;
|
|
625
|
-
end_time: string;
|
|
626
|
-
created_at: string;
|
|
627
|
-
updated_at: string;
|
|
628
|
-
metadata?: Record<string, unknown>;
|
|
629
|
-
}
|
|
630
|
-
|
|
631
|
-
type CartStatus = "active" | "converting" | "converted" | "expired" | "abandoned";
|
|
632
|
-
type CartChannel = "qr" | "taker" | "staff" | "web" | "dashboard";
|
|
633
|
-
type PriceSource = {
|
|
634
|
-
type: "default_item";
|
|
635
|
-
} | {
|
|
636
|
-
type: "location_specific";
|
|
637
|
-
location_id: string;
|
|
638
|
-
} | {
|
|
639
|
-
type: "variant";
|
|
640
|
-
variant_id: string;
|
|
641
|
-
} | {
|
|
642
|
-
type: "composite";
|
|
643
|
-
composite_id: string;
|
|
644
|
-
} | {
|
|
645
|
-
type: "custom";
|
|
646
|
-
};
|
|
647
|
-
type AdjustmentType = {
|
|
648
|
-
type: "location_based";
|
|
649
|
-
location_id: string;
|
|
650
|
-
} | {
|
|
651
|
-
type: "variant_based";
|
|
652
|
-
variant_id: string;
|
|
653
|
-
} | {
|
|
654
|
-
type: "time_based";
|
|
655
|
-
} | {
|
|
656
|
-
type: "customer_segment";
|
|
657
|
-
segment_id: string;
|
|
658
|
-
} | {
|
|
659
|
-
type: "customer_loyalty";
|
|
660
|
-
tier: string;
|
|
661
|
-
} | {
|
|
662
|
-
type: "channel_markup";
|
|
663
|
-
channel: string;
|
|
664
|
-
} | {
|
|
665
|
-
type: "discount";
|
|
666
|
-
discount_id: string;
|
|
667
|
-
} | {
|
|
668
|
-
type: "bundle";
|
|
669
|
-
bundle_id: string;
|
|
670
|
-
} | {
|
|
671
|
-
type: "manual";
|
|
672
|
-
reason: string;
|
|
673
|
-
} | {
|
|
674
|
-
type: "time_limited_promotion";
|
|
675
|
-
promotion_id: string;
|
|
676
|
-
valid_until: string;
|
|
677
|
-
};
|
|
678
|
-
interface PriceAdjustment {
|
|
679
|
-
adjustment_type: AdjustmentType;
|
|
680
|
-
amount: Money;
|
|
681
|
-
percentage?: Money;
|
|
682
|
-
reason: string;
|
|
683
|
-
applied_at: string;
|
|
684
|
-
}
|
|
685
|
-
interface TaxPathComponent {
|
|
686
|
-
name: string;
|
|
687
|
-
rate: Money;
|
|
688
|
-
}
|
|
689
|
-
interface PricePathTaxInfo {
|
|
690
|
-
tax_rate: Money;
|
|
691
|
-
tax_amount: Money;
|
|
692
|
-
is_inclusive: boolean;
|
|
693
|
-
components: TaxPathComponent[];
|
|
694
|
-
}
|
|
695
|
-
interface PriceDecisionPath {
|
|
696
|
-
base_price_source: PriceSource;
|
|
697
|
-
adjustments: PriceAdjustment[];
|
|
698
|
-
context?: Record<string, unknown>;
|
|
699
|
-
}
|
|
700
|
-
interface ChosenPrice {
|
|
701
|
-
base_price: Money;
|
|
702
|
-
final_price: Money;
|
|
703
|
-
markup_percentage: Money;
|
|
704
|
-
markup_amount: Money;
|
|
705
|
-
markup_discount_percentage: Money;
|
|
706
|
-
markup_discount_amount: Money;
|
|
707
|
-
currency?: string;
|
|
708
|
-
custom_fields?: Record<string, unknown>;
|
|
709
|
-
decision_path?: PriceDecisionPath;
|
|
710
|
-
tax_info?: PricePathTaxInfo;
|
|
711
|
-
}
|
|
712
|
-
type BenefitType = "percentage" | "fixed_amount" | "free_item" | "buy_x_get_y";
|
|
713
|
-
interface AppliedDiscount {
|
|
714
|
-
discount_id: string;
|
|
715
|
-
discount_code?: string;
|
|
716
|
-
discount_type: BenefitType;
|
|
717
|
-
discount_value: Money;
|
|
718
|
-
discount_amount: Money;
|
|
719
|
-
applied_at: string;
|
|
720
|
-
}
|
|
721
|
-
interface DiscountBreakdown {
|
|
722
|
-
item_discounts: Record<string, AppliedDiscount[]>;
|
|
723
|
-
order_discounts: AppliedDiscount[];
|
|
724
|
-
}
|
|
725
|
-
interface DiscountDetails {
|
|
726
|
-
discounts: AppliedDiscount[];
|
|
727
|
-
total_discount_amount: Money;
|
|
728
|
-
breakdown: DiscountBreakdown;
|
|
729
|
-
}
|
|
730
|
-
interface SelectedAddOnOption {
|
|
731
|
-
option_id: string;
|
|
732
|
-
add_on_id: string;
|
|
733
|
-
name: string;
|
|
734
|
-
price: Money;
|
|
735
|
-
quantity: number;
|
|
736
|
-
is_required: boolean;
|
|
737
|
-
selected_at: string;
|
|
738
|
-
price_info?: ChosenPrice;
|
|
739
|
-
}
|
|
740
|
-
interface AddOnDetails {
|
|
741
|
-
selected_options: SelectedAddOnOption[];
|
|
742
|
-
total_add_on_price: Money;
|
|
743
|
-
add_ons: CartAddOn[];
|
|
744
|
-
}
|
|
745
|
-
interface CartAddOn {
|
|
746
|
-
add_on_id: string;
|
|
747
|
-
name: string;
|
|
748
|
-
min_selections: number;
|
|
749
|
-
max_selections: number;
|
|
750
|
-
selected_options: string[];
|
|
751
|
-
is_required: boolean;
|
|
752
|
-
}
|
|
753
|
-
interface VariantDetails {
|
|
754
|
-
variant_id: string;
|
|
755
|
-
sku?: string;
|
|
756
|
-
properties: Record<string, string>;
|
|
757
|
-
}
|
|
758
|
-
interface BundleSelectionInput {
|
|
759
|
-
component_id: string;
|
|
760
|
-
variant_id?: string;
|
|
761
|
-
quantity: number;
|
|
762
|
-
}
|
|
763
|
-
interface BundleStoredSelection {
|
|
764
|
-
component_id: string;
|
|
765
|
-
product_id: string;
|
|
766
|
-
product_name: string;
|
|
767
|
-
variant_id?: string;
|
|
768
|
-
variant_name?: string;
|
|
769
|
-
quantity: number;
|
|
770
|
-
unit_price: Money;
|
|
771
|
-
}
|
|
772
|
-
interface BundleSelectionData {
|
|
773
|
-
bundle_id: string;
|
|
774
|
-
selections: BundleStoredSelection[];
|
|
775
|
-
}
|
|
776
|
-
interface CompositeStoredSelection {
|
|
777
|
-
component_id: string;
|
|
778
|
-
component_name: string;
|
|
779
|
-
quantity: number;
|
|
780
|
-
group_id: string;
|
|
781
|
-
source_type: "product" | "stock" | "add_on" | "standalone";
|
|
782
|
-
source_product_id?: string;
|
|
783
|
-
source_stock_id?: string;
|
|
784
|
-
unit_price: Money;
|
|
785
|
-
}
|
|
786
|
-
interface CompositePriceBreakdown {
|
|
787
|
-
base_price: Money;
|
|
788
|
-
components_total: Money;
|
|
789
|
-
tier_applied?: string;
|
|
790
|
-
final_price: Money;
|
|
791
|
-
}
|
|
792
|
-
interface CompositeSelectionData {
|
|
793
|
-
composite_id: string;
|
|
794
|
-
selections: CompositeStoredSelection[];
|
|
795
|
-
breakdown: CompositePriceBreakdown;
|
|
796
|
-
}
|
|
797
|
-
|
|
798
|
-
type LineConfiguration = {
|
|
799
|
-
type: "simple";
|
|
800
|
-
variant?: VariantDetails;
|
|
801
|
-
add_ons?: AddOnDetails;
|
|
802
|
-
} | {
|
|
803
|
-
type: "service";
|
|
804
|
-
variant?: VariantDetails;
|
|
805
|
-
add_ons?: AddOnDetails;
|
|
806
|
-
scheduled_start?: string;
|
|
807
|
-
scheduled_end?: string;
|
|
808
|
-
confirmation_code?: string;
|
|
809
|
-
service_status?: string;
|
|
810
|
-
primary_staff_id?: string;
|
|
811
|
-
scheduling_metadata?: Record<string, unknown>;
|
|
812
|
-
} | {
|
|
813
|
-
type: "bundle";
|
|
814
|
-
variant?: VariantDetails;
|
|
815
|
-
input: BundleSelectionInput[];
|
|
816
|
-
resolved?: BundleSelectionData;
|
|
817
|
-
add_ons?: AddOnDetails;
|
|
818
|
-
} | {
|
|
819
|
-
type: "composite";
|
|
820
|
-
variant?: VariantDetails;
|
|
821
|
-
input: ComponentSelectionInput[];
|
|
822
|
-
resolved?: CompositeSelectionData;
|
|
823
|
-
add_ons?: AddOnDetails;
|
|
824
|
-
} | {
|
|
825
|
-
type: "digital";
|
|
826
|
-
variant?: VariantDetails;
|
|
827
|
-
add_ons?: AddOnDetails;
|
|
828
|
-
digital_type?: string;
|
|
829
|
-
fulfillment_id?: string;
|
|
830
|
-
};
|
|
831
|
-
interface Cart {
|
|
832
|
-
id: string;
|
|
833
|
-
business_id: string;
|
|
834
|
-
customer_id?: string;
|
|
835
|
-
session_id?: string;
|
|
836
|
-
location_id?: string;
|
|
837
|
-
created_at: string;
|
|
838
|
-
updated_at: string;
|
|
839
|
-
expires_at: string;
|
|
840
|
-
subtotal: Money;
|
|
841
|
-
tax_amount: Money;
|
|
842
|
-
service_charge: Money;
|
|
843
|
-
total_discounts: Money;
|
|
844
|
-
total_price: Money;
|
|
845
|
-
total_items: number;
|
|
846
|
-
tax_rate?: Money;
|
|
847
|
-
service_charge_rate?: Money;
|
|
848
|
-
price_info: ChosenPrice;
|
|
849
|
-
applied_discount_ids: string[];
|
|
850
|
-
applied_discount_codes: string[];
|
|
851
|
-
discount_details?: DiscountDetails;
|
|
852
|
-
currency: string;
|
|
853
|
-
customer_name?: string;
|
|
854
|
-
customer_email?: string;
|
|
855
|
-
customer_phone?: string;
|
|
856
|
-
customer_address?: string;
|
|
857
|
-
source: string;
|
|
858
|
-
status: CartStatus;
|
|
859
|
-
channel: string;
|
|
860
|
-
order_id?: string;
|
|
861
|
-
metadata?: Record<string, unknown>;
|
|
862
|
-
items: CartItem[];
|
|
863
|
-
}
|
|
864
|
-
interface CartItem {
|
|
865
|
-
id: string;
|
|
866
|
-
cart_id: string;
|
|
867
|
-
item_id: string;
|
|
868
|
-
quantity: number;
|
|
869
|
-
line_key: string;
|
|
870
|
-
configuration: LineConfiguration;
|
|
871
|
-
price: Money;
|
|
872
|
-
add_ons_price: Money;
|
|
873
|
-
price_info: ChosenPrice;
|
|
874
|
-
applied_discount_ids: string[];
|
|
875
|
-
item_discount_amount: Money;
|
|
876
|
-
discount_details?: DiscountDetails;
|
|
877
|
-
created_at: string;
|
|
878
|
-
updated_at: string;
|
|
879
|
-
metadata?: Record<string, unknown>;
|
|
880
|
-
}
|
|
881
|
-
interface CartTotals {
|
|
882
|
-
subtotal: Money;
|
|
883
|
-
tax_amount: Money;
|
|
884
|
-
service_charge: Money;
|
|
885
|
-
total_discounts: Money;
|
|
886
|
-
total_price: Money;
|
|
887
|
-
tax_rate?: Money;
|
|
888
|
-
service_charge_rate?: Money;
|
|
889
|
-
applied_discount_ids: string[];
|
|
890
|
-
applied_discount_codes: string[];
|
|
891
|
-
discount_details?: DiscountDetails;
|
|
892
|
-
}
|
|
893
|
-
interface DisplayCart {
|
|
894
|
-
id: string;
|
|
895
|
-
business_id: string;
|
|
896
|
-
customer_id?: string;
|
|
897
|
-
session_id?: string;
|
|
898
|
-
location_id?: string;
|
|
899
|
-
subtotal: Money;
|
|
900
|
-
tax_amount: Money;
|
|
901
|
-
service_charge: Money;
|
|
902
|
-
total_discounts: Money;
|
|
903
|
-
total_price: Money;
|
|
904
|
-
total_items: number;
|
|
905
|
-
tax_rate?: Money;
|
|
906
|
-
service_charge_rate?: Money;
|
|
907
|
-
currency: string;
|
|
908
|
-
channel: string;
|
|
909
|
-
status: string;
|
|
910
|
-
business_name: string;
|
|
911
|
-
business_logo?: string;
|
|
912
|
-
location_name?: string;
|
|
913
|
-
customer_name?: string;
|
|
914
|
-
customer_email?: string;
|
|
915
|
-
customer_phone?: string;
|
|
916
|
-
customer_address?: string;
|
|
917
|
-
items: DisplayCartItem[];
|
|
918
|
-
applied_discount_codes: string[];
|
|
919
|
-
discount_details?: DiscountDetails;
|
|
920
|
-
}
|
|
921
|
-
interface DisplayCartItem {
|
|
922
|
-
id: string;
|
|
923
|
-
cart_id: string;
|
|
924
|
-
item_id: string;
|
|
925
|
-
quantity: number;
|
|
926
|
-
name: string;
|
|
927
|
-
description?: string;
|
|
928
|
-
image_url?: string;
|
|
929
|
-
category_name?: string;
|
|
930
|
-
is_available: boolean;
|
|
931
|
-
preparation_time?: number;
|
|
932
|
-
unit_price: Money;
|
|
933
|
-
total_price: Money;
|
|
934
|
-
add_ons_price: Money;
|
|
935
|
-
price_info: ChosenPrice;
|
|
936
|
-
item_discount_amount: Money;
|
|
937
|
-
discount_details?: DiscountDetails;
|
|
938
|
-
add_ons: DisplayAddOn[];
|
|
939
|
-
special_instructions?: string;
|
|
940
|
-
}
|
|
941
|
-
interface DisplayAddOn {
|
|
942
|
-
id: string;
|
|
943
|
-
name: string;
|
|
944
|
-
min_selections: number;
|
|
945
|
-
max_selections: number;
|
|
946
|
-
is_required: boolean;
|
|
947
|
-
selected_options: DisplayAddOnOption[];
|
|
948
|
-
}
|
|
949
|
-
interface DisplayAddOnOption {
|
|
950
|
-
id: string;
|
|
951
|
-
name: string;
|
|
952
|
-
price: Money;
|
|
953
|
-
quantity: number;
|
|
954
|
-
image_url?: string;
|
|
955
|
-
description?: string;
|
|
956
|
-
}
|
|
957
|
-
interface UICartBusiness {
|
|
958
|
-
name: string;
|
|
959
|
-
logo_url?: string;
|
|
960
|
-
contact_email?: string;
|
|
961
|
-
contact_phone?: string;
|
|
962
|
-
}
|
|
963
|
-
interface UICartLocation {
|
|
964
|
-
id?: string;
|
|
965
|
-
name?: string;
|
|
966
|
-
}
|
|
967
|
-
interface UICartCustomer {
|
|
968
|
-
id?: string;
|
|
969
|
-
name?: string;
|
|
970
|
-
email?: string;
|
|
971
|
-
phone?: string;
|
|
972
|
-
address?: string;
|
|
973
|
-
}
|
|
974
|
-
interface UICartPricing {
|
|
975
|
-
subtotal: Money;
|
|
976
|
-
tax_amount: Money;
|
|
977
|
-
service_charge: Money;
|
|
978
|
-
total_discounts: Money;
|
|
979
|
-
total_price: Money;
|
|
980
|
-
tax_rate?: Money;
|
|
981
|
-
service_charge_rate?: Money;
|
|
982
|
-
currency: string;
|
|
983
|
-
}
|
|
984
|
-
interface AddOnOptionDetails {
|
|
985
|
-
id: string;
|
|
986
|
-
name: string;
|
|
987
|
-
price?: Money;
|
|
988
|
-
is_required: boolean;
|
|
989
|
-
description?: string;
|
|
990
|
-
image_url?: string;
|
|
991
|
-
}
|
|
992
|
-
interface AddOnGroupDetails {
|
|
993
|
-
id: string;
|
|
994
|
-
name: string;
|
|
995
|
-
is_multiple_allowed: boolean;
|
|
996
|
-
min_selections: number;
|
|
997
|
-
max_selections: number;
|
|
998
|
-
required: boolean;
|
|
999
|
-
options: AddOnOptionDetails[];
|
|
1000
|
-
}
|
|
1001
|
-
interface VariantDetailsDTO {
|
|
1002
|
-
id: string;
|
|
1003
|
-
name: string;
|
|
1004
|
-
price: Money;
|
|
1005
|
-
price_adjustment: Money;
|
|
1006
|
-
is_default: boolean;
|
|
1007
|
-
}
|
|
1008
|
-
interface CartItemDetails {
|
|
1009
|
-
id: string;
|
|
1010
|
-
cart_id: string;
|
|
1011
|
-
item_id: string;
|
|
1012
|
-
quantity: number;
|
|
1013
|
-
line_key: string;
|
|
1014
|
-
line_type: "simple" | "service" | "bundle" | "composite" | "digital";
|
|
1015
|
-
name: string;
|
|
1016
|
-
description?: string;
|
|
1017
|
-
image_url?: string;
|
|
1018
|
-
category_id?: string;
|
|
1019
|
-
category_name?: string;
|
|
1020
|
-
is_available: boolean;
|
|
1021
|
-
variant_id?: string;
|
|
1022
|
-
variant_details?: VariantDetails;
|
|
1023
|
-
variant_name?: string;
|
|
1024
|
-
variant_info?: VariantDetailsDTO;
|
|
1025
|
-
base_price: Money;
|
|
1026
|
-
add_ons_price: Money;
|
|
1027
|
-
total_price: Money;
|
|
1028
|
-
item_discount_amount: Money;
|
|
1029
|
-
price_info: ChosenPrice;
|
|
1030
|
-
add_on_option_ids: string[];
|
|
1031
|
-
add_on_ids: string[];
|
|
1032
|
-
add_on_details: AddOnDetails;
|
|
1033
|
-
add_on_options: AddOnOptionDetails[];
|
|
1034
|
-
add_ons: AddOnGroupDetails[];
|
|
1035
|
-
special_instructions?: string;
|
|
1036
|
-
scheduled_start?: string;
|
|
1037
|
-
scheduled_end?: string;
|
|
1038
|
-
confirmation_code?: string;
|
|
1039
|
-
service_status?: string;
|
|
1040
|
-
staff_id?: string;
|
|
1041
|
-
scheduling_metadata?: Record<string, unknown>;
|
|
1042
|
-
bundle_selections?: BundleSelectionInput[];
|
|
1043
|
-
bundle_resolved?: BundleSelectionData;
|
|
1044
|
-
composite_selections?: ComponentSelectionInput[];
|
|
1045
|
-
composite_resolved?: CompositeSelectionData;
|
|
1046
|
-
applied_discount_ids: string[];
|
|
1047
|
-
discount_details?: DiscountDetails;
|
|
1048
|
-
created_at: string;
|
|
1049
|
-
updated_at: string;
|
|
1050
|
-
metadata?: Record<string, unknown>;
|
|
1051
|
-
}
|
|
1052
|
-
/** Enriched cart returned by cart#enriched - matches cart_dto.rs UICart */
|
|
1053
|
-
interface UICart {
|
|
1054
|
-
id: string;
|
|
1055
|
-
business_id: string;
|
|
1056
|
-
session_id?: string;
|
|
1057
|
-
customer_id?: string;
|
|
1058
|
-
location_id?: string;
|
|
1059
|
-
created_at: string;
|
|
1060
|
-
updated_at: string;
|
|
1061
|
-
expires_at: string;
|
|
1062
|
-
status: string;
|
|
1063
|
-
source: string;
|
|
1064
|
-
channel: string;
|
|
1065
|
-
business_details?: UICartBusiness;
|
|
1066
|
-
location_details?: UICartLocation;
|
|
1067
|
-
customer_info: UICartCustomer;
|
|
1068
|
-
items: CartItemDetails[];
|
|
1069
|
-
pricing: UICartPricing;
|
|
1070
|
-
metadata?: Record<string, unknown>;
|
|
1071
|
-
}
|
|
1072
|
-
/** Envelope returned by cart#enriched query */
|
|
1073
|
-
interface UICartResponse {
|
|
1074
|
-
cart: UICart;
|
|
1075
|
-
cart_count: number;
|
|
1076
|
-
message?: string | null;
|
|
1077
|
-
}
|
|
1078
|
-
interface AddToCartInput {
|
|
1079
|
-
item_id: string;
|
|
1080
|
-
quantity?: number;
|
|
1081
|
-
variant_id?: string;
|
|
1082
|
-
quote_id?: string;
|
|
1083
|
-
add_on_options?: string[];
|
|
1084
|
-
special_instructions?: string;
|
|
1085
|
-
bundle_selections?: BundleSelectionInput[];
|
|
1086
|
-
composite_selections?: ComponentSelectionInput[];
|
|
1087
|
-
scheduled_start?: string;
|
|
1088
|
-
scheduled_end?: string;
|
|
1089
|
-
staff_id?: string;
|
|
1090
|
-
}
|
|
1091
|
-
interface UpdateCartItemInput {
|
|
1092
|
-
quantity?: number;
|
|
1093
|
-
variant_id?: string;
|
|
1094
|
-
add_on_options?: string[];
|
|
1095
|
-
notes?: string;
|
|
1096
|
-
bundle_selections?: BundleSelectionInput[];
|
|
1097
|
-
composite_selections?: ComponentSelectionInput[];
|
|
1098
|
-
scheduled_start?: string;
|
|
1099
|
-
scheduled_end?: string;
|
|
1100
|
-
staff_id?: string;
|
|
1101
|
-
}
|
|
1102
|
-
interface CartSummary {
|
|
1103
|
-
item_count: number;
|
|
1104
|
-
total_items: number;
|
|
1105
|
-
subtotal: Money;
|
|
1106
|
-
discount_amount: Money;
|
|
1107
|
-
tax_amount: Money;
|
|
1108
|
-
total: Money;
|
|
1109
|
-
currency: string;
|
|
1110
|
-
}
|
|
1111
|
-
|
|
1112
|
-
/**
|
|
1113
|
-
* A Result type that makes errors explicit in the type system.
|
|
1114
|
-
* Inspired by Rust's Result and fp-ts Either.
|
|
1115
|
-
*
|
|
1116
|
-
* @example
|
|
1117
|
-
* ```typescript
|
|
1118
|
-
* const result = await client.cart.addItemSafe({ item_id: "prod_123" });
|
|
1119
|
-
*
|
|
1120
|
-
* if (result.ok) {
|
|
1121
|
-
* console.log(result.value); // Cart
|
|
1122
|
-
* } else {
|
|
1123
|
-
* console.log(result.error); // CimplifyError
|
|
1124
|
-
* }
|
|
1125
|
-
* ```
|
|
1126
|
-
*/
|
|
1127
|
-
type Result<T, E = Error> = Ok<T> | Err<E>;
|
|
1128
|
-
interface Ok<T> {
|
|
1129
|
-
readonly ok: true;
|
|
1130
|
-
readonly value: T;
|
|
1131
|
-
}
|
|
1132
|
-
interface Err<E> {
|
|
1133
|
-
readonly ok: false;
|
|
1134
|
-
readonly error: E;
|
|
1135
|
-
}
|
|
1136
|
-
/** Create a successful Result */
|
|
1137
|
-
declare function ok<T>(value: T): Ok<T>;
|
|
1138
|
-
/** Create a failed Result */
|
|
1139
|
-
declare function err<E>(error: E): Err<E>;
|
|
1140
|
-
/** Check if Result is Ok */
|
|
1141
|
-
declare function isOk<T, E>(result: Result<T, E>): result is Ok<T>;
|
|
1142
|
-
/** Check if Result is Err */
|
|
1143
|
-
declare function isErr<T, E>(result: Result<T, E>): result is Err<E>;
|
|
1144
|
-
/**
|
|
1145
|
-
* Transform the success value of a Result.
|
|
1146
|
-
*
|
|
1147
|
-
* @example
|
|
1148
|
-
* ```typescript
|
|
1149
|
-
* const result = ok(5);
|
|
1150
|
-
* const doubled = mapResult(result, (n) => n * 2);
|
|
1151
|
-
* // doubled = { ok: true, value: 10 }
|
|
1152
|
-
* ```
|
|
1153
|
-
*/
|
|
1154
|
-
declare function mapResult<T, U, E>(result: Result<T, E>, fn: (value: T) => U): Result<U, E>;
|
|
1155
|
-
/**
|
|
1156
|
-
* Transform the error value of a Result.
|
|
1157
|
-
*
|
|
1158
|
-
* @example
|
|
1159
|
-
* ```typescript
|
|
1160
|
-
* const result = err(new Error("oops"));
|
|
1161
|
-
* const mapped = mapError(result, (e) => new CustomError(e.message));
|
|
1162
|
-
* ```
|
|
1163
|
-
*/
|
|
1164
|
-
declare function mapError<T, E, F>(result: Result<T, E>, fn: (error: E) => F): Result<T, F>;
|
|
1165
|
-
/**
|
|
1166
|
-
* Chain Results together. If the first Result is Ok, apply the function.
|
|
1167
|
-
* If it's Err, propagate the error.
|
|
1168
|
-
*
|
|
1169
|
-
* @example
|
|
1170
|
-
* ```typescript
|
|
1171
|
-
* const getUser = (id: string): Result<User, Error> => { ... }
|
|
1172
|
-
* const getOrders = (user: User): Result<Order[], Error> => { ... }
|
|
1173
|
-
*
|
|
1174
|
-
* const result = flatMap(getUser("123"), (user) => getOrders(user));
|
|
1175
|
-
* ```
|
|
1176
|
-
*/
|
|
1177
|
-
declare function flatMap<T, U, E>(result: Result<T, E>, fn: (value: T) => Result<U, E>): Result<U, E>;
|
|
1178
|
-
/**
|
|
1179
|
-
* Get the value or a default if the Result is Err.
|
|
1180
|
-
*
|
|
1181
|
-
* @example
|
|
1182
|
-
* ```typescript
|
|
1183
|
-
* const result = err(new Error("failed"));
|
|
1184
|
-
* const value = getOrElse(result, () => defaultCart);
|
|
1185
|
-
* ```
|
|
1186
|
-
*/
|
|
1187
|
-
declare function getOrElse<T, E>(result: Result<T, E>, defaultFn: () => T): T;
|
|
1188
|
-
/**
|
|
1189
|
-
* Get the value or throw the error.
|
|
1190
|
-
* Use sparingly - defeats the purpose of Result!
|
|
1191
|
-
*
|
|
1192
|
-
* @example
|
|
1193
|
-
* ```typescript
|
|
1194
|
-
* const cart = unwrap(result); // throws if Err
|
|
1195
|
-
* ```
|
|
1196
|
-
*/
|
|
1197
|
-
declare function unwrap<T, E>(result: Result<T, E>): T;
|
|
1198
|
-
/**
|
|
1199
|
-
* Get the value or undefined if Err.
|
|
1200
|
-
*
|
|
1201
|
-
* @example
|
|
1202
|
-
* ```typescript
|
|
1203
|
-
* const cart = toNullable(result); // Cart | undefined
|
|
1204
|
-
* ```
|
|
1205
|
-
*/
|
|
1206
|
-
declare function toNullable<T, E>(result: Result<T, E>): T | undefined;
|
|
1207
|
-
/**
|
|
1208
|
-
* Convert a Promise that might throw into a Result.
|
|
1209
|
-
*
|
|
1210
|
-
* @example
|
|
1211
|
-
* ```typescript
|
|
1212
|
-
* const result = await fromPromise(
|
|
1213
|
-
* fetch("/api/data"),
|
|
1214
|
-
* (error) => new NetworkError(error.message)
|
|
1215
|
-
* );
|
|
1216
|
-
* ```
|
|
1217
|
-
*/
|
|
1218
|
-
declare function fromPromise<T, E>(promise: Promise<T>, mapError: (error: unknown) => E): Promise<Result<T, E>>;
|
|
1219
|
-
/**
|
|
1220
|
-
* Convert a function that might throw into one that returns Result.
|
|
1221
|
-
*
|
|
1222
|
-
* @example
|
|
1223
|
-
* ```typescript
|
|
1224
|
-
* const safeParse = tryCatch(
|
|
1225
|
-
* () => JSON.parse(input),
|
|
1226
|
-
* (e) => new ParseError(e.message)
|
|
1227
|
-
* );
|
|
1228
|
-
* ```
|
|
1229
|
-
*/
|
|
1230
|
-
declare function tryCatch<T, E>(fn: () => T, mapError: (error: unknown) => E): Result<T, E>;
|
|
1231
|
-
/**
|
|
1232
|
-
* Combine multiple Results. Returns Ok with array of values if all succeed,
|
|
1233
|
-
* or the first Err encountered.
|
|
1234
|
-
*
|
|
1235
|
-
* @example
|
|
1236
|
-
* ```typescript
|
|
1237
|
-
* const results = await Promise.all([
|
|
1238
|
-
* client.cart.getSafe(),
|
|
1239
|
-
* client.business.getSafe(),
|
|
1240
|
-
* ]);
|
|
1241
|
-
* const combined = combine(results);
|
|
1242
|
-
* // Result<[Cart, Business], CimplifyError>
|
|
1243
|
-
* ```
|
|
1244
|
-
*/
|
|
1245
|
-
declare function combine<T, E>(results: Result<T, E>[]): Result<T[], E>;
|
|
1246
|
-
/**
|
|
1247
|
-
* Like combine, but for an object of Results.
|
|
1248
|
-
*
|
|
1249
|
-
* @example
|
|
1250
|
-
* ```typescript
|
|
1251
|
-
* const data = combineObject({
|
|
1252
|
-
* cart: await client.cart.getSafe(),
|
|
1253
|
-
* business: await client.business.getSafe(),
|
|
1254
|
-
* });
|
|
1255
|
-
* // Result<{ cart: Cart, business: Business }, CimplifyError>
|
|
1256
|
-
* ```
|
|
1257
|
-
*/
|
|
1258
|
-
declare function combineObject<T extends Record<string, Result<unknown, unknown>>>(results: T): Result<{
|
|
1259
|
-
[K in keyof T]: T[K] extends Result<infer V, unknown> ? V : never;
|
|
1260
|
-
}, T[keyof T] extends Result<unknown, infer E> ? E : never>;
|
|
1261
|
-
|
|
1262
|
-
interface GetProductsOptions {
|
|
1263
|
-
category?: string;
|
|
1264
|
-
collection?: string;
|
|
1265
|
-
search?: string;
|
|
1266
|
-
limit?: number;
|
|
1267
|
-
offset?: number;
|
|
1268
|
-
tags?: string[];
|
|
1269
|
-
featured?: boolean;
|
|
1270
|
-
in_stock?: boolean;
|
|
1271
|
-
min_price?: number;
|
|
1272
|
-
max_price?: number;
|
|
1273
|
-
sort_by?: "name" | "price" | "created_at";
|
|
1274
|
-
sort_order?: "asc" | "desc";
|
|
1275
|
-
}
|
|
1276
|
-
interface SearchOptions {
|
|
1277
|
-
limit?: number;
|
|
1278
|
-
category?: string;
|
|
1279
|
-
}
|
|
1280
|
-
interface QuoteCompositeSelectionInput {
|
|
1281
|
-
component_id: string;
|
|
1282
|
-
quantity: number;
|
|
1283
|
-
variant_id?: string;
|
|
1284
|
-
add_on_option_id?: string;
|
|
1285
|
-
}
|
|
1286
|
-
interface QuoteBundleSelectionInput {
|
|
1287
|
-
component_id: string;
|
|
1288
|
-
quantity: number;
|
|
1289
|
-
variant_id?: string;
|
|
1290
|
-
}
|
|
1291
|
-
interface FetchQuoteInput {
|
|
1292
|
-
product_id: string;
|
|
1293
|
-
variant_id?: string;
|
|
1294
|
-
location_id?: string;
|
|
1295
|
-
quantity?: number;
|
|
1296
|
-
add_on_option_ids?: string[];
|
|
1297
|
-
bundle_selections?: QuoteBundleSelectionInput[];
|
|
1298
|
-
composite_selections?: QuoteCompositeSelectionInput[];
|
|
1299
|
-
}
|
|
1300
|
-
interface RefreshQuoteInput {
|
|
1301
|
-
quote_id: string;
|
|
1302
|
-
product_id?: string;
|
|
1303
|
-
variant_id?: string;
|
|
1304
|
-
location_id?: string;
|
|
1305
|
-
quantity?: number;
|
|
1306
|
-
add_on_option_ids?: string[];
|
|
1307
|
-
bundle_selections?: QuoteBundleSelectionInput[];
|
|
1308
|
-
composite_selections?: QuoteCompositeSelectionInput[];
|
|
1309
|
-
}
|
|
1310
|
-
type QuoteStatus = "pending" | "used" | "expired";
|
|
1311
|
-
interface QuoteDynamicBuckets {
|
|
1312
|
-
intent: string;
|
|
1313
|
-
demand: string;
|
|
1314
|
-
inventory: string;
|
|
1315
|
-
competition?: string;
|
|
1316
|
-
}
|
|
1317
|
-
interface QuoteUiMessage {
|
|
1318
|
-
code: string;
|
|
1319
|
-
level: "info" | "warn" | "error" | string;
|
|
1320
|
-
text: string;
|
|
1321
|
-
countdown_seconds?: number;
|
|
1322
|
-
}
|
|
1323
|
-
interface PriceQuote {
|
|
1324
|
-
quote_id: string;
|
|
1325
|
-
business_id: string;
|
|
1326
|
-
product_id: string;
|
|
1327
|
-
variant_id?: string;
|
|
1328
|
-
location_id?: string;
|
|
1329
|
-
source: string;
|
|
1330
|
-
quantity: number;
|
|
1331
|
-
currency?: string;
|
|
1332
|
-
item_price_info: ChosenPrice;
|
|
1333
|
-
variant_price_info?: ChosenPrice;
|
|
1334
|
-
final_price_info: ChosenPrice;
|
|
1335
|
-
add_on_option_ids: string[];
|
|
1336
|
-
bundle_selections?: QuoteBundleSelectionInput[];
|
|
1337
|
-
add_ons_price_info?: ChosenPrice;
|
|
1338
|
-
quoted_total_price_info?: ChosenPrice;
|
|
1339
|
-
composite_selections?: QuoteCompositeSelectionInput[];
|
|
1340
|
-
dynamic_buckets: QuoteDynamicBuckets;
|
|
1341
|
-
ui_messages: QuoteUiMessage[];
|
|
1342
|
-
created_at: string;
|
|
1343
|
-
expires_at: string;
|
|
1344
|
-
next_change_at?: string;
|
|
1345
|
-
status: QuoteStatus;
|
|
1346
|
-
}
|
|
1347
|
-
interface RefreshQuoteResult {
|
|
1348
|
-
previous_quote_id: string;
|
|
1349
|
-
quote: PriceQuote;
|
|
1350
|
-
}
|
|
1351
|
-
declare class CatalogueQueries {
|
|
1352
|
-
private client;
|
|
1353
|
-
constructor(client: CimplifyClient);
|
|
1354
|
-
getProducts(options?: GetProductsOptions): Promise<Result<Product[], CimplifyError>>;
|
|
1355
|
-
getProduct(id: string): Promise<Result<ProductWithDetails, CimplifyError>>;
|
|
1356
|
-
getProductBySlug(slug: string): Promise<Result<ProductWithDetails, CimplifyError>>;
|
|
1357
|
-
getVariants(productId: string): Promise<Result<ProductVariant[], CimplifyError>>;
|
|
1358
|
-
getVariantAxes(productId: string): Promise<Result<VariantAxis[], CimplifyError>>;
|
|
1359
|
-
/**
|
|
1360
|
-
* Find a variant by axis selections (e.g., { "Size": "Large", "Color": "Red" })
|
|
1361
|
-
* Returns the matching variant or null if no match found.
|
|
1362
|
-
*/
|
|
1363
|
-
getVariantByAxisSelections(productId: string, selections: VariantAxisSelection): Promise<Result<ProductVariant | null, CimplifyError>>;
|
|
1364
|
-
/**
|
|
1365
|
-
* Get a specific variant by its ID
|
|
1366
|
-
*/
|
|
1367
|
-
getVariantById(productId: string, variantId: string): Promise<Result<ProductVariant, CimplifyError>>;
|
|
1368
|
-
getAddOns(productId: string): Promise<Result<AddOn[], CimplifyError>>;
|
|
1369
|
-
getCategories(): Promise<Result<Category[], CimplifyError>>;
|
|
1370
|
-
getCategory(id: string): Promise<Result<Category, CimplifyError>>;
|
|
1371
|
-
getCategoryBySlug(slug: string): Promise<Result<Category, CimplifyError>>;
|
|
1372
|
-
getCategoryProducts(categoryId: string): Promise<Result<Product[], CimplifyError>>;
|
|
1373
|
-
getCollections(): Promise<Result<Collection[], CimplifyError>>;
|
|
1374
|
-
getCollection(id: string): Promise<Result<Collection, CimplifyError>>;
|
|
1375
|
-
getCollectionBySlug(slug: string): Promise<Result<Collection, CimplifyError>>;
|
|
1376
|
-
getCollectionProducts(collectionId: string): Promise<Result<Product[], CimplifyError>>;
|
|
1377
|
-
searchCollections(query: string, limit?: number): Promise<Result<Collection[], CimplifyError>>;
|
|
1378
|
-
getBundles(): Promise<Result<Bundle[], CimplifyError>>;
|
|
1379
|
-
getBundle(id: string): Promise<Result<BundleWithDetails, CimplifyError>>;
|
|
1380
|
-
getBundleBySlug(slug: string): Promise<Result<BundleWithDetails, CimplifyError>>;
|
|
1381
|
-
searchBundles(query: string, limit?: number): Promise<Result<Bundle[], CimplifyError>>;
|
|
1382
|
-
getComposites(options?: {
|
|
1383
|
-
limit?: number;
|
|
1384
|
-
}): Promise<Result<Composite[], CimplifyError>>;
|
|
1385
|
-
getComposite(id: string): Promise<Result<CompositeWithDetails, CimplifyError>>;
|
|
1386
|
-
getCompositeByProductId(productId: string): Promise<Result<CompositeWithDetails, CimplifyError>>;
|
|
1387
|
-
calculateCompositePrice(compositeId: string, selections: ComponentSelectionInput[], locationId?: string): Promise<Result<CompositePriceResult, CimplifyError>>;
|
|
1388
|
-
fetchQuote(input: FetchQuoteInput): Promise<Result<PriceQuote, CimplifyError>>;
|
|
1389
|
-
getQuote(quoteId: string): Promise<Result<PriceQuote, CimplifyError>>;
|
|
1390
|
-
refreshQuote(input: RefreshQuoteInput): Promise<Result<RefreshQuoteResult, CimplifyError>>;
|
|
1391
|
-
search(query: string, options?: SearchOptions): Promise<Result<Product[], CimplifyError>>;
|
|
1392
|
-
searchProducts(query: string, options?: SearchOptions): Promise<Result<Product[], CimplifyError>>;
|
|
1393
|
-
getMenu(options?: {
|
|
1394
|
-
category?: string;
|
|
1395
|
-
limit?: number;
|
|
1396
|
-
}): Promise<Result<Product[], CimplifyError>>;
|
|
1397
|
-
getMenuCategory(categoryId: string): Promise<Result<Product[], CimplifyError>>;
|
|
1398
|
-
getMenuItem(itemId: string): Promise<Result<ProductWithDetails, CimplifyError>>;
|
|
1399
|
-
}
|
|
1400
|
-
|
|
1401
|
-
declare class CartOperations {
|
|
1402
|
-
private client;
|
|
1403
|
-
constructor(client: CimplifyClient);
|
|
1404
|
-
get(): Promise<Result<UICart, CimplifyError>>;
|
|
1405
|
-
getRaw(): Promise<Result<Cart, CimplifyError>>;
|
|
1406
|
-
getItems(): Promise<Result<CartItem[], CimplifyError>>;
|
|
1407
|
-
getCount(): Promise<Result<number, CimplifyError>>;
|
|
1408
|
-
getTotal(): Promise<Result<string, CimplifyError>>;
|
|
1409
|
-
getSummary(): Promise<Result<CartSummary, CimplifyError>>;
|
|
1410
|
-
addItem(input: AddToCartInput): Promise<Result<Cart, CimplifyError>>;
|
|
1411
|
-
updateItem(cartItemId: string, updates: UpdateCartItemInput): Promise<Result<Cart, CimplifyError>>;
|
|
1412
|
-
updateQuantity(cartItemId: string, quantity: number): Promise<Result<Cart, CimplifyError>>;
|
|
1413
|
-
removeItem(cartItemId: string): Promise<Result<Cart, CimplifyError>>;
|
|
1414
|
-
clear(): Promise<Result<Cart, CimplifyError>>;
|
|
1415
|
-
applyCoupon(code: string): Promise<Result<Cart, CimplifyError>>;
|
|
1416
|
-
removeCoupon(): Promise<Result<Cart, CimplifyError>>;
|
|
1417
|
-
isEmpty(): Promise<Result<boolean, CimplifyError>>;
|
|
1418
|
-
hasItem(productId: string, variantId?: string): Promise<Result<boolean, CimplifyError>>;
|
|
1419
|
-
findItem(productId: string, variantId?: string): Promise<Result<CartItem | undefined, CimplifyError>>;
|
|
1420
|
-
}
|
|
1421
|
-
|
|
1422
|
-
type OrderStatus = "pending" | "created" | "confirmed" | "in_preparation" | "ready_to_serve" | "partially_served" | "served" | "delivered" | "picked_up" | "completed" | "cancelled" | "refunded";
|
|
1423
|
-
type PaymentState = "not_paid" | "paid" | "partially_refunded" | "refunded";
|
|
1424
|
-
type OrderChannel = "qr" | "taker" | "staff" | "web" | "dashboard";
|
|
1425
|
-
type LineType = "product" | "service" | "bundle" | "composite" | "digital";
|
|
1426
|
-
type OrderLineState = {
|
|
1427
|
-
state: "pending";
|
|
1428
|
-
} | {
|
|
1429
|
-
state: "in_preparation";
|
|
1430
|
-
} | {
|
|
1431
|
-
state: "ready";
|
|
1432
|
-
} | {
|
|
1433
|
-
state: "partially_served";
|
|
1434
|
-
served_quantity: number;
|
|
1435
|
-
} | {
|
|
1436
|
-
state: "served";
|
|
1437
|
-
} | {
|
|
1438
|
-
state: "completed";
|
|
1439
|
-
} | {
|
|
1440
|
-
state: "cancelled";
|
|
1441
|
-
reason?: string;
|
|
1442
|
-
};
|
|
1443
|
-
interface OrderLineStatus {
|
|
1444
|
-
state: OrderLineState;
|
|
1445
|
-
quantity_ordered: number;
|
|
1446
|
-
quantity_prepared: number;
|
|
1447
|
-
quantity_served: number;
|
|
1448
|
-
last_modified: string;
|
|
1449
|
-
modified_by: string;
|
|
1450
|
-
}
|
|
1451
|
-
type FulfillmentType = "appointment" | "shipment" | "order" | "digital";
|
|
1452
|
-
type FulfillmentStatus = "pending" | "in_progress" | "completed" | "cancelled";
|
|
1453
|
-
interface FulfillmentLink {
|
|
1454
|
-
fulfillment_type: FulfillmentType;
|
|
1455
|
-
fulfillment_id: string;
|
|
1456
|
-
}
|
|
1457
|
-
interface OrderFulfillmentSummary {
|
|
1458
|
-
total_items: number;
|
|
1459
|
-
pending_items: number;
|
|
1460
|
-
in_progress_items: number;
|
|
1461
|
-
completed_items: number;
|
|
1462
|
-
cancelled_items: number;
|
|
1463
|
-
all_complete: boolean;
|
|
1464
|
-
any_in_progress: boolean;
|
|
1465
|
-
}
|
|
1466
|
-
type FeeBearerType = "customer" | "business" | "split";
|
|
1467
|
-
interface AmountToPay {
|
|
1468
|
-
customer_pays: Money;
|
|
1469
|
-
business_receives: Money;
|
|
1470
|
-
cimplify_receives: Money;
|
|
1471
|
-
provider_receives: Money;
|
|
1472
|
-
fee_bearer: FeeBearerType;
|
|
1473
|
-
}
|
|
1474
|
-
interface LineItem {
|
|
1475
|
-
id: string;
|
|
1476
|
-
order_id: string;
|
|
1477
|
-
product_id: string;
|
|
1478
|
-
line_key: string;
|
|
1479
|
-
quantity: number;
|
|
1480
|
-
configuration: LineConfiguration;
|
|
1481
|
-
price: Money;
|
|
1482
|
-
add_ons_price: Money;
|
|
1483
|
-
price_info: ChosenPrice;
|
|
1484
|
-
item_discount_amount: Money;
|
|
1485
|
-
discount_details?: DiscountDetails;
|
|
1486
|
-
created_at: string;
|
|
1487
|
-
updated_at: string;
|
|
1488
|
-
line_state: OrderLineStatus;
|
|
1489
|
-
metadata?: Record<string, unknown>;
|
|
1490
|
-
fulfillment_type?: FulfillmentType;
|
|
1491
|
-
fulfillment_id?: string;
|
|
1492
|
-
}
|
|
1493
|
-
interface Order {
|
|
1494
|
-
id: string;
|
|
1495
|
-
business_id: string;
|
|
1496
|
-
channel: OrderChannel;
|
|
1497
|
-
status: OrderStatus;
|
|
1498
|
-
payment_state: PaymentState;
|
|
1499
|
-
order_type: string;
|
|
1500
|
-
placed_by?: string;
|
|
1501
|
-
user_friendly_id: string;
|
|
1502
|
-
customer_id?: string;
|
|
1503
|
-
customer_name?: string;
|
|
1504
|
-
customer_email?: string;
|
|
1505
|
-
customer_phone?: string;
|
|
1506
|
-
customer_notes?: string[];
|
|
1507
|
-
discount_code?: string;
|
|
1508
|
-
applied_discount_ids: string[];
|
|
1509
|
-
applied_discount_codes: string[];
|
|
1510
|
-
discount_details?: DiscountDetails;
|
|
1511
|
-
delivery_address?: string;
|
|
1512
|
-
tracking_token?: string;
|
|
1513
|
-
tracking_link?: string;
|
|
1514
|
-
pickup_time?: string;
|
|
1515
|
-
created_at: string;
|
|
1516
|
-
updated_at: string;
|
|
1517
|
-
delivered_at?: string;
|
|
1518
|
-
fulfilled_at?: string;
|
|
1519
|
-
confirmed_at?: string;
|
|
1520
|
-
served_at?: string;
|
|
1521
|
-
completed_at?: string;
|
|
1522
|
-
cancelled_at?: string;
|
|
1523
|
-
table_number?: string;
|
|
1524
|
-
room_number?: string;
|
|
1525
|
-
location_id?: string;
|
|
1526
|
-
was_placed_by_staff: boolean;
|
|
1527
|
-
modified_by_staff: boolean;
|
|
1528
|
-
delivery_required: boolean;
|
|
1529
|
-
customer_will_pick_up: boolean;
|
|
1530
|
-
total_price: Money;
|
|
1531
|
-
total_excl_tax_discount_and_service_charge: Money;
|
|
1532
|
-
total_discount: Money;
|
|
1533
|
-
service_charge?: Money;
|
|
1534
|
-
tax?: Money;
|
|
1535
|
-
price_info: ChosenPrice;
|
|
1536
|
-
currency: string;
|
|
1537
|
-
bill_token?: string;
|
|
1538
|
-
order_group_id?: string;
|
|
1539
|
-
paid_via_group: boolean;
|
|
1540
|
-
amount_to_pay: AmountToPay;
|
|
1541
|
-
served_by?: string;
|
|
1542
|
-
metadata?: Record<string, unknown>;
|
|
1543
|
-
requires_scheduling: boolean;
|
|
1544
|
-
all_items_scheduled: boolean;
|
|
1545
|
-
earliest_service_time?: string;
|
|
1546
|
-
latest_service_time?: string;
|
|
1547
|
-
deposit_required: boolean;
|
|
1548
|
-
deposit_amount: Money;
|
|
1549
|
-
deposit_paid_amount: Money;
|
|
1550
|
-
balance_due: Money;
|
|
1551
|
-
deposit_due_date?: string;
|
|
1552
|
-
final_payment_due_date?: string;
|
|
1553
|
-
version: number;
|
|
1554
|
-
total_quantity: number;
|
|
1555
|
-
items: LineItem[];
|
|
1556
|
-
computed_payment_status?: string;
|
|
1557
|
-
is_service_only?: boolean;
|
|
1558
|
-
}
|
|
1559
|
-
interface OrderHistory {
|
|
1560
|
-
id: string;
|
|
1561
|
-
order_id: string;
|
|
1562
|
-
modified_by: string;
|
|
1563
|
-
modification_type: string;
|
|
1564
|
-
modification_details: string;
|
|
1565
|
-
modified_at: string;
|
|
1566
|
-
metadata?: Record<string, unknown>;
|
|
1567
|
-
}
|
|
1568
|
-
type OrderGroupPaymentState = "not_paid" | "partially_paid" | "fully_paid" | "refunded";
|
|
1569
|
-
interface OrderGroup {
|
|
1570
|
-
id: string;
|
|
1571
|
-
business_id: string;
|
|
1572
|
-
location_id: string;
|
|
1573
|
-
table_number: string;
|
|
1574
|
-
created_at: string;
|
|
1575
|
-
updated_at: string;
|
|
1576
|
-
status: string;
|
|
1577
|
-
is_split: boolean;
|
|
1578
|
-
is_closed: boolean;
|
|
1579
|
-
total_amount?: Money;
|
|
1580
|
-
paid_amount?: Money;
|
|
1581
|
-
payment_status: OrderGroupPaymentState;
|
|
1582
|
-
split_method?: string;
|
|
1583
|
-
max_orders?: number;
|
|
1584
|
-
currency?: string;
|
|
1585
|
-
amount_to_pay: AmountToPay;
|
|
1586
|
-
metadata?: Record<string, unknown>;
|
|
1587
|
-
}
|
|
1588
|
-
interface OrderGroupPayment {
|
|
1589
|
-
id: string;
|
|
1590
|
-
order_group_id: string;
|
|
1591
|
-
order_id?: string;
|
|
1592
|
-
amount: Money;
|
|
1593
|
-
payment_method: string;
|
|
1594
|
-
status: string;
|
|
1595
|
-
created_at: string;
|
|
1596
|
-
updated_at: string;
|
|
1597
|
-
metadata?: Record<string, unknown>;
|
|
1598
|
-
}
|
|
1599
|
-
interface OrderSplitDetail {
|
|
1600
|
-
order_id: string;
|
|
1601
|
-
amount: Money;
|
|
1602
|
-
paid_amount?: Money;
|
|
1603
|
-
remaining_amount?: Money;
|
|
1604
|
-
}
|
|
1605
|
-
interface OrderGroupPaymentSummary {
|
|
1606
|
-
total_amount: Money;
|
|
1607
|
-
paid_amount: Money;
|
|
1608
|
-
remaining_amount: Money;
|
|
1609
|
-
split_details?: OrderSplitDetail[];
|
|
1610
|
-
}
|
|
1611
|
-
interface OrderGroupDetails {
|
|
1612
|
-
order_group: OrderGroup;
|
|
1613
|
-
orders: Order[];
|
|
1614
|
-
total: Money;
|
|
1615
|
-
payments: OrderGroupPayment[];
|
|
1616
|
-
payment_summary: OrderGroupPaymentSummary;
|
|
1617
|
-
}
|
|
1618
|
-
interface OrderPaymentEvent {
|
|
1619
|
-
id: string;
|
|
1620
|
-
order_id: string;
|
|
1621
|
-
amount: Money;
|
|
1622
|
-
reference: string;
|
|
1623
|
-
created_at: string;
|
|
1624
|
-
event_type: string;
|
|
1625
|
-
provider?: string;
|
|
1626
|
-
metadata?: Record<string, unknown>;
|
|
1627
|
-
}
|
|
1628
|
-
interface OrderFilter {
|
|
1629
|
-
location_id?: string;
|
|
1630
|
-
table_number?: string;
|
|
1631
|
-
order_type?: string;
|
|
1632
|
-
status?: string;
|
|
1633
|
-
from?: string;
|
|
1634
|
-
to?: string;
|
|
1635
|
-
search?: string;
|
|
1636
|
-
limit?: number;
|
|
1637
|
-
offset?: number;
|
|
1638
|
-
}
|
|
1639
|
-
interface CheckoutInput {
|
|
1640
|
-
customer_name?: string;
|
|
1641
|
-
customer_email?: string;
|
|
1642
|
-
customer_phone?: string;
|
|
1643
|
-
delivery_address?: string;
|
|
1644
|
-
order_type?: string;
|
|
1645
|
-
notes?: string;
|
|
1646
|
-
table_number?: string;
|
|
1647
|
-
room_number?: string;
|
|
1648
|
-
}
|
|
1649
|
-
interface UpdateOrderStatusInput {
|
|
1650
|
-
status: OrderStatus;
|
|
1651
|
-
notes?: string;
|
|
1652
|
-
}
|
|
1653
|
-
interface CancelOrderInput {
|
|
1654
|
-
reason?: string;
|
|
1655
|
-
}
|
|
1656
|
-
interface RefundOrderInput {
|
|
1657
|
-
amount?: Money;
|
|
1658
|
-
reason?: string;
|
|
1659
|
-
}
|
|
1660
|
-
type ServiceStatus = "awaiting_scheduling" | "scheduled" | "deposit_paid" | "confirmed" | "in_progress" | "completed" | "rescheduled" | "no_show" | "cancelled";
|
|
1661
|
-
type StaffRole = "primary" | "assistant" | "specialist" | "supervisor";
|
|
1662
|
-
type ReminderMethod = "sms" | "email" | "push" | "call" | "whatsapp";
|
|
1663
|
-
interface CustomerServicePreferences {
|
|
1664
|
-
preferred_staff_ids: string[];
|
|
1665
|
-
avoid_staff_ids: string[];
|
|
1666
|
-
room_type?: string;
|
|
1667
|
-
accessibility_needs: string[];
|
|
1668
|
-
temperature_preference?: string;
|
|
1669
|
-
music_preference?: string;
|
|
1670
|
-
special_requests?: string;
|
|
1671
|
-
previous_service_history: string[];
|
|
1672
|
-
}
|
|
1673
|
-
interface BufferTimes {
|
|
1674
|
-
before_minutes: number;
|
|
1675
|
-
after_minutes: number;
|
|
1676
|
-
travel_time_minutes?: number;
|
|
1677
|
-
setup_time_minutes?: number;
|
|
1678
|
-
cleanup_time_minutes?: number;
|
|
1679
|
-
}
|
|
1680
|
-
interface ReminderSettings {
|
|
1681
|
-
send_24h_reminder: boolean;
|
|
1682
|
-
send_2h_reminder: boolean;
|
|
1683
|
-
send_30min_reminder: boolean;
|
|
1684
|
-
reminder_phone?: string;
|
|
1685
|
-
reminder_email?: string;
|
|
1686
|
-
reminder_method: ReminderMethod;
|
|
1687
|
-
custom_reminder_message?: string;
|
|
1688
|
-
}
|
|
1689
|
-
interface CancellationPolicy {
|
|
1690
|
-
free_cancellation_hours: number;
|
|
1691
|
-
partial_refund_hours: number;
|
|
1692
|
-
no_refund_hours: number;
|
|
1693
|
-
cancellation_fee?: Money;
|
|
1694
|
-
reschedule_allowed: boolean;
|
|
1695
|
-
reschedule_fee?: Money;
|
|
1696
|
-
max_reschedules?: number;
|
|
1697
|
-
}
|
|
1698
|
-
interface ServiceNotes {
|
|
1699
|
-
preparation_notes?: string;
|
|
1700
|
-
staff_notes?: string;
|
|
1701
|
-
internal_notes?: string;
|
|
1702
|
-
customer_history: string[];
|
|
1703
|
-
allergies_warnings: string[];
|
|
1704
|
-
}
|
|
1705
|
-
interface PricingOverrides {
|
|
1706
|
-
custom_duration_minutes?: number;
|
|
1707
|
-
price_adjustment?: Money;
|
|
1708
|
-
discount_reason?: string;
|
|
1709
|
-
surge_pricing_multiplier?: Money;
|
|
1710
|
-
loyalty_discount?: Money;
|
|
1711
|
-
package_deal_reference?: string;
|
|
1712
|
-
}
|
|
1713
|
-
interface SchedulingMetadata {
|
|
1714
|
-
customer_preferences?: CustomerServicePreferences;
|
|
1715
|
-
buffer_times?: BufferTimes;
|
|
1716
|
-
reminder_settings?: ReminderSettings;
|
|
1717
|
-
cancellation_policy?: CancellationPolicy;
|
|
1718
|
-
service_notes?: ServiceNotes;
|
|
1719
|
-
pricing_overrides?: PricingOverrides;
|
|
1720
|
-
}
|
|
1721
|
-
interface StaffAssignment {
|
|
1722
|
-
staff_id: string;
|
|
1723
|
-
role: StaffRole;
|
|
1724
|
-
assigned_at: string;
|
|
1725
|
-
notes?: string;
|
|
1726
|
-
}
|
|
1727
|
-
interface ResourceAssignment {
|
|
1728
|
-
resource_id: string;
|
|
1729
|
-
quantity: number;
|
|
1730
|
-
assigned_at: string;
|
|
1731
|
-
notes?: string;
|
|
1732
|
-
}
|
|
1733
|
-
interface SchedulingResult {
|
|
1734
|
-
confirmation_code: string;
|
|
1735
|
-
assigned_staff: StaffAssignment[];
|
|
1736
|
-
assigned_resources: ResourceAssignment[];
|
|
1737
|
-
deposit_required: boolean;
|
|
1738
|
-
deposit_amount?: Money;
|
|
1739
|
-
total_duration_minutes: number;
|
|
1740
|
-
}
|
|
1741
|
-
interface DepositResult {
|
|
1742
|
-
order_confirmed: boolean;
|
|
1743
|
-
balance_due: Money;
|
|
1744
|
-
final_payment_due?: string;
|
|
1745
|
-
confirmation_sent: boolean;
|
|
1746
|
-
}
|
|
1747
|
-
interface ServiceScheduleRequest {
|
|
1748
|
-
line_item_id: string;
|
|
1749
|
-
start_time: string;
|
|
1750
|
-
end_time: string;
|
|
1751
|
-
preferred_staff_ids?: string[];
|
|
1752
|
-
resource_requirements?: string[];
|
|
1753
|
-
customer_notes?: string;
|
|
1754
|
-
}
|
|
1755
|
-
interface StaffScheduleItem {
|
|
1756
|
-
line_item_id: string;
|
|
1757
|
-
order_id: string;
|
|
1758
|
-
customer_name: string;
|
|
1759
|
-
service_name: string;
|
|
1760
|
-
start_time: string;
|
|
1761
|
-
end_time: string;
|
|
1762
|
-
confirmation_code: string;
|
|
1763
|
-
service_status: ServiceStatus;
|
|
1764
|
-
notes?: string;
|
|
1765
|
-
}
|
|
1766
|
-
interface LocationAppointment {
|
|
1767
|
-
line_item_id: string;
|
|
1768
|
-
order_id: string;
|
|
1769
|
-
customer_name: string;
|
|
1770
|
-
service_name: string;
|
|
1771
|
-
start_time: string;
|
|
1772
|
-
end_time: string;
|
|
1773
|
-
assigned_staff: string[];
|
|
1774
|
-
assigned_resources: string[];
|
|
1775
|
-
service_status: ServiceStatus;
|
|
1776
|
-
}
|
|
1777
|
-
|
|
1778
|
-
type PaymentStatus = "pending" | "processing" | "created" | "pending_confirmation" | "success" | "succeeded" | "failed" | "declined" | "authorized" | "refunded" | "partially_refunded" | "partially_paid" | "paid" | "unpaid" | "requires_action" | "requires_payment_method" | "requires_capture" | "captured" | "cancelled" | "completed" | "voided" | "error" | "unknown";
|
|
1779
|
-
type PaymentProvider = "stripe" | "paystack" | "mtn" | "vodafone" | "airtel" | "cellulant" | "offline" | "cash" | "manual";
|
|
1780
|
-
type PaymentMethodType = "card" | "mobile_money" | "bank_transfer" | "cash" | "custom";
|
|
1781
|
-
/** Authorization types for payment verification (OTP, PIN, etc.) */
|
|
1782
|
-
type AuthorizationType = "otp" | "pin" | "phone" | "birthday" | "address";
|
|
1783
|
-
/** Payment processing state machine states (for UI) */
|
|
1784
|
-
type PaymentProcessingState = "initial" | "preparing" | "processing" | "verifying" | "awaiting_authorization" | "success" | "error" | "timeout";
|
|
1785
|
-
interface PaymentMethod {
|
|
1786
|
-
type: PaymentMethodType;
|
|
1787
|
-
provider?: string;
|
|
1788
|
-
phone_number?: string;
|
|
1789
|
-
card_last_four?: string;
|
|
1790
|
-
custom_value?: string;
|
|
1791
|
-
}
|
|
1792
|
-
interface Payment {
|
|
1793
|
-
id: string;
|
|
1794
|
-
order_id: string;
|
|
1795
|
-
business_id: string;
|
|
1796
|
-
amount: Money;
|
|
1797
|
-
currency: Currency;
|
|
1798
|
-
payment_method: PaymentMethod;
|
|
1799
|
-
status: PaymentStatus;
|
|
1800
|
-
provider: PaymentProvider;
|
|
1801
|
-
provider_reference?: string;
|
|
1802
|
-
failure_reason?: string;
|
|
1803
|
-
created_at: string;
|
|
1804
|
-
updated_at: string;
|
|
1805
|
-
}
|
|
1806
|
-
interface InitializePaymentResult {
|
|
1807
|
-
payment_id: string;
|
|
1808
|
-
status: PaymentStatus;
|
|
1809
|
-
redirect_url?: string;
|
|
1810
|
-
authorization_url?: string;
|
|
1811
|
-
reference: string;
|
|
1812
|
-
provider: PaymentProvider;
|
|
1813
|
-
}
|
|
1814
|
-
/** Normalized payment response from checkout or payment initialization */
|
|
1815
|
-
interface PaymentResponse {
|
|
1816
|
-
method: string;
|
|
1817
|
-
provider: string;
|
|
1818
|
-
requires_action: boolean;
|
|
1819
|
-
public_key?: string;
|
|
1820
|
-
client_secret?: string;
|
|
1821
|
-
access_code?: string;
|
|
1822
|
-
redirect_url?: string;
|
|
1823
|
-
transaction_id?: string;
|
|
1824
|
-
order_id?: string;
|
|
1825
|
-
reference?: string;
|
|
1826
|
-
metadata?: Record<string, unknown>;
|
|
1827
|
-
instructions?: string;
|
|
1828
|
-
display_text?: string;
|
|
1829
|
-
requires_authorization?: boolean;
|
|
1830
|
-
authorization_type?: AuthorizationType;
|
|
1831
|
-
provider_payment_id?: string;
|
|
1832
|
-
}
|
|
1833
|
-
/** Payment status polling response */
|
|
1834
|
-
interface PaymentStatusResponse {
|
|
1835
|
-
status: PaymentStatus;
|
|
1836
|
-
paid: boolean;
|
|
1837
|
-
amount?: Money;
|
|
1838
|
-
currency?: string;
|
|
1839
|
-
reference?: string;
|
|
1840
|
-
message?: string;
|
|
1841
|
-
}
|
|
1842
|
-
interface PaymentErrorDetails {
|
|
1843
|
-
code: string;
|
|
1844
|
-
message: string;
|
|
1845
|
-
recoverable: boolean;
|
|
1846
|
-
technical?: string;
|
|
1847
|
-
}
|
|
1848
|
-
interface SubmitAuthorizationInput {
|
|
1849
|
-
reference: string;
|
|
1850
|
-
auth_type: AuthorizationType;
|
|
1851
|
-
value: string;
|
|
1852
|
-
}
|
|
1853
|
-
|
|
1854
|
-
declare const CHECKOUT_MODE: {
|
|
1855
|
-
readonly LINK: "link";
|
|
1856
|
-
readonly GUEST: "guest";
|
|
1857
|
-
};
|
|
1858
|
-
declare const ORDER_TYPE: {
|
|
1859
|
-
readonly DELIVERY: "delivery";
|
|
1860
|
-
readonly PICKUP: "pickup";
|
|
1861
|
-
readonly DINE_IN: "dine-in";
|
|
1862
|
-
readonly WALK_IN: "walk-in";
|
|
1863
|
-
};
|
|
1864
|
-
declare const PAYMENT_METHOD: {
|
|
1865
|
-
readonly MOBILE_MONEY: "mobile_money";
|
|
1866
|
-
readonly CARD: "card";
|
|
1867
|
-
};
|
|
1868
|
-
declare const CHECKOUT_STEP: {
|
|
1869
|
-
readonly AUTHENTICATION: "authentication";
|
|
1870
|
-
readonly ORDER_DETAILS: "order_details";
|
|
1871
|
-
readonly PAYMENT_METHOD: "payment_method";
|
|
1872
|
-
readonly PAYMENT: "payment";
|
|
1873
|
-
readonly CONFIRMATION: "confirmation";
|
|
1874
|
-
};
|
|
1875
|
-
declare const PAYMENT_STATE: {
|
|
1876
|
-
readonly INITIAL: "initial";
|
|
1877
|
-
readonly PREPARING: "preparing";
|
|
1878
|
-
readonly PROCESSING: "processing";
|
|
1879
|
-
readonly VERIFYING: "verifying";
|
|
1880
|
-
readonly AWAITING_AUTHORIZATION: "awaiting_authorization";
|
|
1881
|
-
readonly SUCCESS: "success";
|
|
1882
|
-
readonly ERROR: "error";
|
|
1883
|
-
readonly TIMEOUT: "timeout";
|
|
1884
|
-
};
|
|
1885
|
-
declare const PICKUP_TIME_TYPE: {
|
|
1886
|
-
readonly ASAP: "asap";
|
|
1887
|
-
readonly SCHEDULED: "scheduled";
|
|
1888
|
-
};
|
|
1889
|
-
declare const MOBILE_MONEY_PROVIDER: {
|
|
1890
|
-
readonly MTN: "mtn";
|
|
1891
|
-
readonly VODAFONE: "vodafone";
|
|
1892
|
-
readonly AIRTEL: "airtel";
|
|
1893
|
-
};
|
|
1894
|
-
declare const AUTHORIZATION_TYPE: {
|
|
1895
|
-
readonly OTP: "otp";
|
|
1896
|
-
readonly PIN: "pin";
|
|
1897
|
-
readonly PHONE: "phone";
|
|
1898
|
-
readonly BIRTHDAY: "birthday";
|
|
1899
|
-
readonly ADDRESS: "address";
|
|
1900
|
-
};
|
|
1901
|
-
declare const DEVICE_TYPE: {
|
|
1902
|
-
readonly MOBILE: "mobile";
|
|
1903
|
-
readonly DESKTOP: "desktop";
|
|
1904
|
-
readonly TABLET: "tablet";
|
|
1905
|
-
};
|
|
1906
|
-
declare const CONTACT_TYPE: {
|
|
1907
|
-
readonly PHONE: "phone";
|
|
1908
|
-
readonly EMAIL: "email";
|
|
1909
|
-
};
|
|
1910
|
-
declare const LINK_QUERY: {
|
|
1911
|
-
readonly DATA: "link.data";
|
|
1912
|
-
readonly ADDRESSES: "link.addresses";
|
|
1913
|
-
readonly MOBILE_MONEY: "link.mobile_money";
|
|
1914
|
-
readonly PREFERENCES: "link.preferences";
|
|
1915
|
-
readonly SESSIONS: "link.sessions";
|
|
1916
|
-
};
|
|
1917
|
-
declare const LINK_MUTATION: {
|
|
1918
|
-
readonly CHECK_STATUS: "link.check_status";
|
|
1919
|
-
readonly ENROLL: "link.enroll";
|
|
1920
|
-
readonly ENROLL_AND_LINK_ORDER: "link.enroll_and_link_order";
|
|
1921
|
-
readonly UPDATE_PREFERENCES: "link.update_preferences";
|
|
1922
|
-
readonly CREATE_ADDRESS: "link.create_address";
|
|
1923
|
-
readonly UPDATE_ADDRESS: "link.update_address";
|
|
1924
|
-
readonly DELETE_ADDRESS: "link.delete_address";
|
|
1925
|
-
readonly SET_DEFAULT_ADDRESS: "link.set_default_address";
|
|
1926
|
-
readonly TRACK_ADDRESS_USAGE: "link.track_address_usage";
|
|
1927
|
-
readonly CREATE_MOBILE_MONEY: "link.create_mobile_money";
|
|
1928
|
-
readonly DELETE_MOBILE_MONEY: "link.delete_mobile_money";
|
|
1929
|
-
readonly SET_DEFAULT_MOBILE_MONEY: "link.set_default_mobile_money";
|
|
1930
|
-
readonly TRACK_MOBILE_MONEY_USAGE: "link.track_mobile_money_usage";
|
|
1931
|
-
readonly VERIFY_MOBILE_MONEY: "link.verify_mobile_money";
|
|
1932
|
-
readonly REVOKE_SESSION: "link.revoke_session";
|
|
1933
|
-
readonly REVOKE_ALL_SESSIONS: "link.revoke_all_sessions";
|
|
1934
|
-
};
|
|
1935
|
-
declare const AUTH_MUTATION: {
|
|
1936
|
-
readonly REQUEST_OTP: "auth.request_otp";
|
|
1937
|
-
readonly VERIFY_OTP: "auth.verify_otp";
|
|
1938
|
-
};
|
|
1939
|
-
declare const CHECKOUT_MUTATION: {
|
|
1940
|
-
readonly PROCESS: "checkout.process";
|
|
1941
|
-
};
|
|
1942
|
-
declare const PAYMENT_MUTATION: {
|
|
1943
|
-
readonly SUBMIT_AUTHORIZATION: "payment.submit_authorization";
|
|
1944
|
-
readonly CHECK_STATUS: "order.poll_payment_status";
|
|
1945
|
-
};
|
|
1946
|
-
declare const ORDER_MUTATION: {
|
|
1947
|
-
readonly UPDATE_CUSTOMER: "order.update_order_customer";
|
|
1948
|
-
};
|
|
1949
|
-
declare const DEFAULT_CURRENCY = "GHS";
|
|
1950
|
-
declare const DEFAULT_COUNTRY = "GHA";
|
|
1951
|
-
|
|
1952
|
-
type MobileMoneyProvider = (typeof MOBILE_MONEY_PROVIDER)[keyof typeof MOBILE_MONEY_PROVIDER];
|
|
1953
|
-
interface Customer {
|
|
1954
|
-
id: string;
|
|
1955
|
-
email: string | null;
|
|
1956
|
-
phone: string | null;
|
|
1957
|
-
name: string;
|
|
1958
|
-
delivery_address: string | null;
|
|
1959
|
-
created_at: string;
|
|
1960
|
-
updated_at: string;
|
|
1961
|
-
metadata?: Record<string, unknown>;
|
|
1962
|
-
}
|
|
1963
|
-
interface CustomerAddress {
|
|
1964
|
-
id: string;
|
|
1965
|
-
customer_id: string;
|
|
1966
|
-
label: string;
|
|
1967
|
-
street_address: string;
|
|
1968
|
-
apartment: string | null;
|
|
1969
|
-
city: string;
|
|
1970
|
-
region: string;
|
|
1971
|
-
postal_code: string | null;
|
|
1972
|
-
country: string | null;
|
|
1973
|
-
delivery_instructions: string | null;
|
|
1974
|
-
phone_for_delivery: string | null;
|
|
1975
|
-
latitude: number | null;
|
|
1976
|
-
longitude: number | null;
|
|
1977
|
-
is_default: boolean | null;
|
|
1978
|
-
usage_count: number | null;
|
|
1979
|
-
last_used_at: string | null;
|
|
1980
|
-
created_at: string;
|
|
1981
|
-
updated_at: string;
|
|
1982
|
-
}
|
|
1983
|
-
interface CustomerMobileMoney {
|
|
1984
|
-
id: string;
|
|
1985
|
-
customer_id: string;
|
|
1986
|
-
phone_number: string;
|
|
1987
|
-
provider: MobileMoneyProvider;
|
|
1988
|
-
label: string;
|
|
1989
|
-
is_verified: boolean | null;
|
|
1990
|
-
verification_date: string | null;
|
|
1991
|
-
is_default: boolean | null;
|
|
1992
|
-
usage_count: number | null;
|
|
1993
|
-
last_used_at: string | null;
|
|
1994
|
-
success_rate: number | null;
|
|
1995
|
-
created_at: string;
|
|
1996
|
-
updated_at: string;
|
|
1997
|
-
}
|
|
1998
|
-
interface CustomerLinkPreferences {
|
|
1999
|
-
customer_id: string;
|
|
2000
|
-
is_link_enabled: boolean | null;
|
|
2001
|
-
enrolled_at: string | null;
|
|
2002
|
-
enrollment_business_id: string | null;
|
|
2003
|
-
preferred_order_type: string | null;
|
|
2004
|
-
default_address_id: string | null;
|
|
2005
|
-
default_mobile_money_id: string | null;
|
|
2006
|
-
remember_me: boolean | null;
|
|
2007
|
-
session_duration_days: number | null;
|
|
2008
|
-
two_factor_enabled: boolean | null;
|
|
2009
|
-
notify_on_order: boolean | null;
|
|
2010
|
-
notify_on_payment: boolean | null;
|
|
2011
|
-
created_at: string;
|
|
2012
|
-
updated_at: string;
|
|
2013
|
-
}
|
|
2014
|
-
interface LinkData {
|
|
2015
|
-
customer: Customer;
|
|
2016
|
-
addresses: CustomerAddress[];
|
|
2017
|
-
mobile_money: CustomerMobileMoney[];
|
|
2018
|
-
preferences: CustomerLinkPreferences;
|
|
2019
|
-
default_address: CustomerAddress | null;
|
|
2020
|
-
default_mobile_money: CustomerMobileMoney | null;
|
|
2021
|
-
}
|
|
2022
|
-
interface CreateAddressInput {
|
|
2023
|
-
address_line1: string;
|
|
2024
|
-
address_line2?: string;
|
|
2025
|
-
city: string;
|
|
2026
|
-
state?: string;
|
|
2027
|
-
postal_code?: string;
|
|
2028
|
-
country: string;
|
|
2029
|
-
label?: string;
|
|
2030
|
-
}
|
|
2031
|
-
interface UpdateAddressInput {
|
|
2032
|
-
address_id: string;
|
|
2033
|
-
address_line1?: string;
|
|
2034
|
-
address_line2?: string;
|
|
2035
|
-
city?: string;
|
|
2036
|
-
state?: string;
|
|
2037
|
-
postal_code?: string;
|
|
2038
|
-
country?: string;
|
|
2039
|
-
label?: string;
|
|
2040
|
-
}
|
|
2041
|
-
interface CreateMobileMoneyInput {
|
|
2042
|
-
phone_number: string;
|
|
2043
|
-
provider: string;
|
|
2044
|
-
account_name?: string;
|
|
2045
|
-
}
|
|
2046
|
-
interface EnrollmentData {
|
|
2047
|
-
contact: string;
|
|
2048
|
-
name?: string;
|
|
2049
|
-
}
|
|
2050
|
-
interface AddressData {
|
|
2051
|
-
label: string;
|
|
2052
|
-
street_address: string;
|
|
2053
|
-
apartment?: string;
|
|
2054
|
-
city: string;
|
|
2055
|
-
region: string;
|
|
2056
|
-
delivery_instructions?: string;
|
|
2057
|
-
phone_for_delivery?: string;
|
|
2058
|
-
}
|
|
2059
|
-
interface MobileMoneyData {
|
|
2060
|
-
phone_number: string;
|
|
2061
|
-
provider: string;
|
|
2062
|
-
label: string;
|
|
2063
|
-
}
|
|
2064
|
-
interface EnrollAndLinkOrderInput {
|
|
2065
|
-
order_id: string;
|
|
2066
|
-
business_id: string;
|
|
2067
|
-
address?: AddressData;
|
|
2068
|
-
mobile_money?: MobileMoneyData;
|
|
2069
|
-
order_type?: string;
|
|
2070
|
-
}
|
|
2071
|
-
interface LinkStatusResult {
|
|
2072
|
-
is_link_customer: boolean;
|
|
2073
|
-
}
|
|
2074
|
-
interface LinkEnrollResult {
|
|
2075
|
-
success: boolean;
|
|
2076
|
-
customer_id: string;
|
|
2077
|
-
contact?: string;
|
|
2078
|
-
enrolled_at?: string;
|
|
2079
|
-
preferences?: CustomerLinkPreferences;
|
|
2080
|
-
}
|
|
2081
|
-
interface EnrollAndLinkOrderResult {
|
|
2082
|
-
success: boolean;
|
|
2083
|
-
customer_id: string;
|
|
2084
|
-
order_id: string;
|
|
2085
|
-
enrollment_result: unknown;
|
|
2086
|
-
linked_at: string;
|
|
2087
|
-
}
|
|
2088
|
-
type DeviceType = (typeof DEVICE_TYPE)[keyof typeof DEVICE_TYPE];
|
|
2089
|
-
interface LinkSession {
|
|
2090
|
-
id: string;
|
|
2091
|
-
device_name: string | null;
|
|
2092
|
-
device_type: DeviceType | null;
|
|
2093
|
-
ip_address: string | null;
|
|
2094
|
-
last_used_at: string | null;
|
|
2095
|
-
created_at: string;
|
|
2096
|
-
is_current: boolean;
|
|
2097
|
-
}
|
|
2098
|
-
interface RevokeSessionResult {
|
|
2099
|
-
success: boolean;
|
|
2100
|
-
session_id: string;
|
|
2101
|
-
message: string;
|
|
2102
|
-
}
|
|
2103
|
-
interface RevokeAllSessionsResult {
|
|
2104
|
-
success: boolean;
|
|
2105
|
-
revoked_count: number;
|
|
2106
|
-
message: string;
|
|
2107
|
-
}
|
|
2108
|
-
type ContactType = (typeof CONTACT_TYPE)[keyof typeof CONTACT_TYPE];
|
|
2109
|
-
interface RequestOtpInput {
|
|
2110
|
-
contact: string;
|
|
2111
|
-
contact_type: ContactType;
|
|
2112
|
-
}
|
|
2113
|
-
interface VerifyOtpInput {
|
|
2114
|
-
contact: string;
|
|
2115
|
-
contact_type: ContactType;
|
|
2116
|
-
otp_code: string;
|
|
2117
|
-
}
|
|
2118
|
-
interface AuthResponse {
|
|
2119
|
-
success: boolean;
|
|
2120
|
-
session_token: string | null;
|
|
2121
|
-
customer_id: string | null;
|
|
2122
|
-
message: string;
|
|
2123
|
-
}
|
|
2124
|
-
|
|
2125
|
-
type CheckoutMode = (typeof CHECKOUT_MODE)[keyof typeof CHECKOUT_MODE];
|
|
2126
|
-
type CheckoutOrderType = (typeof ORDER_TYPE)[keyof typeof ORDER_TYPE];
|
|
2127
|
-
type CheckoutPaymentMethod = (typeof PAYMENT_METHOD)[keyof typeof PAYMENT_METHOD];
|
|
2128
|
-
type CheckoutStep = (typeof CHECKOUT_STEP)[keyof typeof CHECKOUT_STEP];
|
|
2129
|
-
type PickupTimeType = (typeof PICKUP_TIME_TYPE)[keyof typeof PICKUP_TIME_TYPE];
|
|
2130
|
-
interface PickupTime {
|
|
2131
|
-
type: PickupTimeType;
|
|
2132
|
-
scheduled_time?: string;
|
|
2133
|
-
}
|
|
2134
|
-
interface CheckoutAddressInfo {
|
|
2135
|
-
street_address?: string;
|
|
2136
|
-
apartment?: string;
|
|
2137
|
-
city?: string;
|
|
2138
|
-
region?: string;
|
|
2139
|
-
postal_code?: string;
|
|
2140
|
-
country?: string;
|
|
2141
|
-
delivery_instructions?: string;
|
|
2142
|
-
phone_for_delivery?: string;
|
|
2143
|
-
pickup_time?: string;
|
|
2144
|
-
guest_count?: number;
|
|
2145
|
-
seating_time?: string;
|
|
2146
|
-
seating_requests?: string;
|
|
2147
|
-
}
|
|
2148
|
-
interface MobileMoneyDetails {
|
|
2149
|
-
phone_number: string;
|
|
2150
|
-
provider: MobileMoneyProvider;
|
|
2151
|
-
provider_other?: string;
|
|
2152
|
-
}
|
|
2153
|
-
interface CheckoutCustomerInfo {
|
|
2154
|
-
name: string;
|
|
2155
|
-
email: string;
|
|
2156
|
-
phone: string;
|
|
2157
|
-
notes?: string;
|
|
2158
|
-
save_details: boolean;
|
|
2159
|
-
}
|
|
2160
|
-
interface CheckoutFormData {
|
|
2161
|
-
cart_id: string;
|
|
2162
|
-
location_id?: string;
|
|
2163
|
-
customer: CheckoutCustomerInfo;
|
|
2164
|
-
order_type: CheckoutOrderType;
|
|
2165
|
-
address_info: CheckoutAddressInfo;
|
|
2166
|
-
payment_method: string;
|
|
2167
|
-
mobile_money_details?: MobileMoneyDetails;
|
|
2168
|
-
special_instructions?: string;
|
|
2169
|
-
link_address_id?: string;
|
|
2170
|
-
link_payment_method_id?: string;
|
|
2171
|
-
idempotency_key?: string;
|
|
2172
|
-
/** Optional metadata passed through to the payment provider (e.g. success_url, cancel_url) */
|
|
2173
|
-
metadata?: Record<string, unknown>;
|
|
2174
|
-
pay_currency?: string;
|
|
2175
|
-
fx_quote_id?: string;
|
|
2176
|
-
}
|
|
2177
|
-
interface CheckoutResult {
|
|
2178
|
-
order_id: string;
|
|
2179
|
-
order_number: string;
|
|
2180
|
-
payment_reference?: string;
|
|
2181
|
-
payment_status: string;
|
|
2182
|
-
requires_authorization: boolean;
|
|
2183
|
-
authorization_type?: AuthorizationType;
|
|
2184
|
-
authorization_url?: string;
|
|
2185
|
-
display_text?: string;
|
|
2186
|
-
provider?: string;
|
|
2187
|
-
client_secret?: string;
|
|
2188
|
-
public_key?: string;
|
|
2189
|
-
fx?: {
|
|
2190
|
-
base_currency: string;
|
|
2191
|
-
base_amount: number;
|
|
2192
|
-
pay_currency: string;
|
|
2193
|
-
pay_amount: number;
|
|
2194
|
-
rate: number;
|
|
2195
|
-
quote_id: string;
|
|
2196
|
-
};
|
|
2197
|
-
}
|
|
2198
|
-
|
|
2199
|
-
declare function generateIdempotencyKey(): string;
|
|
2200
|
-
declare class CheckoutService {
|
|
2201
|
-
private client;
|
|
2202
|
-
constructor(client: CimplifyClient);
|
|
2203
|
-
process(data: CheckoutFormData): Promise<Result<CheckoutResult, CimplifyError>>;
|
|
2204
|
-
initializePayment(orderId: string, method: PaymentMethod): Promise<Result<InitializePaymentResult, CimplifyError>>;
|
|
2205
|
-
submitAuthorization(input: SubmitAuthorizationInput): Promise<Result<CheckoutResult, CimplifyError>>;
|
|
2206
|
-
pollPaymentStatus(orderId: string): Promise<Result<PaymentStatusResponse, CimplifyError>>;
|
|
2207
|
-
updateOrderCustomer(orderId: string, customer: CheckoutCustomerInfo): Promise<Result<Order, CimplifyError>>;
|
|
2208
|
-
verifyPayment(orderId: string): Promise<Result<Order, CimplifyError>>;
|
|
2209
|
-
}
|
|
2210
|
-
|
|
2211
|
-
interface GetOrdersOptions {
|
|
2212
|
-
status?: OrderStatus;
|
|
2213
|
-
limit?: number;
|
|
2214
|
-
offset?: number;
|
|
2215
|
-
}
|
|
2216
|
-
/**
|
|
2217
|
-
* Order queries with explicit error handling via Result type.
|
|
2218
|
-
*
|
|
2219
|
-
* All methods return `Result<T, CimplifyError>` - no exceptions thrown.
|
|
2220
|
-
*
|
|
2221
|
-
* @example
|
|
2222
|
-
* ```typescript
|
|
2223
|
-
* const result = await client.orders.list({ status: "pending" });
|
|
2224
|
-
*
|
|
2225
|
-
* if (result.ok) {
|
|
2226
|
-
* console.log("Orders:", result.value);
|
|
2227
|
-
* } else {
|
|
2228
|
-
* console.error("Failed:", result.error.code);
|
|
2229
|
-
* }
|
|
2230
|
-
* ```
|
|
2231
|
-
*/
|
|
2232
|
-
declare class OrderQueries {
|
|
2233
|
-
private client;
|
|
2234
|
-
constructor(client: CimplifyClient);
|
|
2235
|
-
list(options?: GetOrdersOptions): Promise<Result<Order[], CimplifyError>>;
|
|
2236
|
-
get(orderId: string): Promise<Result<Order, CimplifyError>>;
|
|
2237
|
-
getRecent(limit?: number): Promise<Result<Order[], CimplifyError>>;
|
|
2238
|
-
getByStatus(status: OrderStatus): Promise<Result<Order[], CimplifyError>>;
|
|
2239
|
-
cancel(orderId: string, reason?: string): Promise<Result<Order, CimplifyError>>;
|
|
2240
|
-
}
|
|
2241
|
-
|
|
2242
|
-
interface SuccessResult$2 {
|
|
2243
|
-
success: boolean;
|
|
2244
|
-
message?: string;
|
|
2245
|
-
}
|
|
2246
|
-
/**
|
|
2247
|
-
* Cimplify Link service for express checkout with saved customer data.
|
|
2248
|
-
*
|
|
2249
|
-
* All methods return `Result<T, CimplifyError>` - no exceptions thrown.
|
|
2250
|
-
*/
|
|
2251
|
-
declare class LinkService {
|
|
2252
|
-
private client;
|
|
2253
|
-
constructor(client: CimplifyClient);
|
|
2254
|
-
requestOtp(input: RequestOtpInput): Promise<Result<SuccessResult$2, CimplifyError>>;
|
|
2255
|
-
verifyOtp(input: VerifyOtpInput): Promise<Result<AuthResponse, CimplifyError>>;
|
|
2256
|
-
logout(): Promise<Result<SuccessResult$2, CimplifyError>>;
|
|
2257
|
-
checkStatus(contact: string): Promise<Result<LinkStatusResult, CimplifyError>>;
|
|
2258
|
-
getLinkData(): Promise<Result<LinkData, CimplifyError>>;
|
|
2259
|
-
getAddresses(): Promise<Result<CustomerAddress[], CimplifyError>>;
|
|
2260
|
-
getMobileMoney(): Promise<Result<CustomerMobileMoney[], CimplifyError>>;
|
|
2261
|
-
getPreferences(): Promise<Result<CustomerLinkPreferences, CimplifyError>>;
|
|
2262
|
-
enroll(data: EnrollmentData): Promise<Result<LinkEnrollResult, CimplifyError>>;
|
|
2263
|
-
enrollAndLinkOrder(data: EnrollAndLinkOrderInput): Promise<Result<EnrollAndLinkOrderResult, CimplifyError>>;
|
|
2264
|
-
updatePreferences(preferences: Partial<CustomerLinkPreferences>): Promise<Result<SuccessResult$2, CimplifyError>>;
|
|
2265
|
-
createAddress(input: CreateAddressInput): Promise<Result<CustomerAddress, CimplifyError>>;
|
|
2266
|
-
updateAddress(input: UpdateAddressInput): Promise<Result<SuccessResult$2, CimplifyError>>;
|
|
2267
|
-
deleteAddress(addressId: string): Promise<Result<SuccessResult$2, CimplifyError>>;
|
|
2268
|
-
setDefaultAddress(addressId: string): Promise<Result<SuccessResult$2, CimplifyError>>;
|
|
2269
|
-
trackAddressUsage(addressId: string): Promise<Result<SuccessResult$2, CimplifyError>>;
|
|
2270
|
-
createMobileMoney(input: CreateMobileMoneyInput): Promise<Result<CustomerMobileMoney, CimplifyError>>;
|
|
2271
|
-
deleteMobileMoney(mobileMoneyId: string): Promise<Result<SuccessResult$2, CimplifyError>>;
|
|
2272
|
-
setDefaultMobileMoney(mobileMoneyId: string): Promise<Result<SuccessResult$2, CimplifyError>>;
|
|
2273
|
-
trackMobileMoneyUsage(mobileMoneyId: string): Promise<Result<SuccessResult$2, CimplifyError>>;
|
|
2274
|
-
verifyMobileMoney(mobileMoneyId: string): Promise<Result<SuccessResult$2, CimplifyError>>;
|
|
2275
|
-
getSessions(): Promise<Result<LinkSession[], CimplifyError>>;
|
|
2276
|
-
revokeSession(sessionId: string): Promise<Result<RevokeSessionResult, CimplifyError>>;
|
|
2277
|
-
revokeAllSessions(): Promise<Result<RevokeAllSessionsResult, CimplifyError>>;
|
|
2278
|
-
getAddressesRest(): Promise<Result<CustomerAddress[], CimplifyError>>;
|
|
2279
|
-
createAddressRest(input: CreateAddressInput): Promise<Result<CustomerAddress, CimplifyError>>;
|
|
2280
|
-
deleteAddressRest(addressId: string): Promise<Result<SuccessResult$2, CimplifyError>>;
|
|
2281
|
-
setDefaultAddressRest(addressId: string): Promise<Result<SuccessResult$2, CimplifyError>>;
|
|
2282
|
-
getMobileMoneyRest(): Promise<Result<CustomerMobileMoney[], CimplifyError>>;
|
|
2283
|
-
createMobileMoneyRest(input: CreateMobileMoneyInput): Promise<Result<CustomerMobileMoney, CimplifyError>>;
|
|
2284
|
-
deleteMobileMoneyRest(mobileMoneyId: string): Promise<Result<SuccessResult$2, CimplifyError>>;
|
|
2285
|
-
setDefaultMobileMoneyRest(mobileMoneyId: string): Promise<Result<SuccessResult$2, CimplifyError>>;
|
|
2286
|
-
}
|
|
2287
|
-
|
|
2288
|
-
interface AuthStatus {
|
|
2289
|
-
is_authenticated: boolean;
|
|
2290
|
-
customer?: Customer;
|
|
2291
|
-
session_expires_at?: string;
|
|
2292
|
-
}
|
|
2293
|
-
interface OtpResult {
|
|
2294
|
-
customer: Customer;
|
|
2295
|
-
session_token?: string;
|
|
2296
|
-
}
|
|
2297
|
-
interface UpdateProfileInput {
|
|
2298
|
-
name?: string;
|
|
2299
|
-
email?: string;
|
|
2300
|
-
phone?: string;
|
|
2301
|
-
}
|
|
2302
|
-
interface ChangePasswordInput {
|
|
2303
|
-
current_password: string;
|
|
2304
|
-
new_password: string;
|
|
2305
|
-
}
|
|
2306
|
-
interface SuccessResult$1 {
|
|
2307
|
-
success: boolean;
|
|
2308
|
-
}
|
|
2309
|
-
declare class AuthService {
|
|
2310
|
-
private client;
|
|
2311
|
-
constructor(client: CimplifyClient);
|
|
2312
|
-
getStatus(): Promise<Result<AuthStatus, CimplifyError>>;
|
|
2313
|
-
getCurrentUser(): Promise<Result<Customer | null, CimplifyError>>;
|
|
2314
|
-
isAuthenticated(): Promise<Result<boolean, CimplifyError>>;
|
|
2315
|
-
requestOtp(contact: string, contactType?: "phone" | "email"): Promise<Result<void, CimplifyError>>;
|
|
2316
|
-
verifyOtp(code: string, contact?: string): Promise<Result<OtpResult, CimplifyError>>;
|
|
2317
|
-
logout(): Promise<Result<SuccessResult$1, CimplifyError>>;
|
|
2318
|
-
updateProfile(input: UpdateProfileInput): Promise<Result<Customer, CimplifyError>>;
|
|
2319
|
-
changePassword(input: ChangePasswordInput): Promise<Result<SuccessResult$1, CimplifyError>>;
|
|
2320
|
-
resetPassword(email: string): Promise<Result<SuccessResult$1, CimplifyError>>;
|
|
2321
|
-
}
|
|
2322
|
-
|
|
2323
|
-
type BusinessType = "eatery" | "retail" | "service" | "other" | "system" | "unset";
|
|
2324
|
-
interface BusinessPreferences {
|
|
2325
|
-
[key: string]: unknown;
|
|
2326
|
-
}
|
|
2327
|
-
interface Business {
|
|
2328
|
-
id: string;
|
|
2329
|
-
name: string;
|
|
2330
|
-
handle: string;
|
|
2331
|
-
business_type: BusinessType;
|
|
2332
|
-
email: string;
|
|
2333
|
-
default_currency: string;
|
|
2334
|
-
default_phone?: string;
|
|
2335
|
-
default_address?: string;
|
|
2336
|
-
default_offers_table_service: boolean;
|
|
2337
|
-
default_accepts_online_orders: boolean;
|
|
2338
|
-
image?: string;
|
|
2339
|
-
status: string;
|
|
2340
|
-
created_at: string;
|
|
2341
|
-
updated_at: string;
|
|
2342
|
-
subscription_id?: string;
|
|
2343
|
-
owner_id?: string;
|
|
2344
|
-
created_by: string;
|
|
2345
|
-
preferences: BusinessPreferences;
|
|
2346
|
-
is_online_only: boolean;
|
|
2347
|
-
enabled_payment_types: string[];
|
|
2348
|
-
default_location_settings: Record<string, unknown>;
|
|
2349
|
-
country_code?: string;
|
|
2350
|
-
timezone?: string;
|
|
2351
|
-
metadata?: Record<string, unknown>;
|
|
2352
|
-
}
|
|
2353
|
-
interface LocationTaxBehavior {
|
|
2354
|
-
is_tax_inclusive: boolean;
|
|
2355
|
-
tax_rate: Money;
|
|
2356
|
-
}
|
|
2357
|
-
interface LocationTaxOverrides {
|
|
2358
|
-
[productId: string]: {
|
|
2359
|
-
tax_rate: Money;
|
|
2360
|
-
is_exempt: boolean;
|
|
2361
|
-
};
|
|
2362
|
-
}
|
|
2363
|
-
interface Location {
|
|
2364
|
-
id: string;
|
|
2365
|
-
business_id: string;
|
|
2366
|
-
name: string;
|
|
2367
|
-
location?: string;
|
|
2368
|
-
phone?: string;
|
|
2369
|
-
address?: string;
|
|
2370
|
-
service_charge_rate?: number;
|
|
2371
|
-
currency: string;
|
|
2372
|
-
capacity: number;
|
|
2373
|
-
status: string;
|
|
2374
|
-
enabled_payment_types?: string[];
|
|
2375
|
-
offers_table_service: boolean;
|
|
2376
|
-
accepts_online_orders: boolean;
|
|
2377
|
-
created_at: string;
|
|
2378
|
-
updated_at: string;
|
|
2379
|
-
preferences?: Record<string, unknown>;
|
|
2380
|
-
metadata?: Record<string, unknown>;
|
|
2381
|
-
country_code: string;
|
|
2382
|
-
timezone: string;
|
|
2383
|
-
tax_behavior?: LocationTaxBehavior;
|
|
2384
|
-
tax_overrides?: LocationTaxOverrides;
|
|
2385
|
-
}
|
|
2386
|
-
interface TimeRange {
|
|
2387
|
-
start: string;
|
|
2388
|
-
end: string;
|
|
2389
|
-
}
|
|
2390
|
-
type TimeRanges = TimeRange[];
|
|
2391
|
-
interface LocationTimeProfile {
|
|
2392
|
-
id: string;
|
|
2393
|
-
business_id: string;
|
|
2394
|
-
location_id: string;
|
|
2395
|
-
day: string;
|
|
2396
|
-
is_open: boolean;
|
|
2397
|
-
hours: TimeRanges;
|
|
2398
|
-
created_at: string;
|
|
2399
|
-
updated_at: string;
|
|
2400
|
-
metadata?: Record<string, unknown>;
|
|
2401
|
-
}
|
|
2402
|
-
interface Table {
|
|
2403
|
-
id: string;
|
|
2404
|
-
business_id: string;
|
|
2405
|
-
location_id: string;
|
|
2406
|
-
table_number: string;
|
|
2407
|
-
capacity: number;
|
|
2408
|
-
occupied: boolean;
|
|
2409
|
-
created_at: string;
|
|
2410
|
-
updated_at: string;
|
|
2411
|
-
metadata?: Record<string, unknown>;
|
|
2412
|
-
}
|
|
2413
|
-
interface Room {
|
|
2414
|
-
id: string;
|
|
2415
|
-
business_id: string;
|
|
2416
|
-
location_id: string;
|
|
2417
|
-
name: string;
|
|
2418
|
-
capacity: number;
|
|
2419
|
-
status: string;
|
|
2420
|
-
floor?: string;
|
|
2421
|
-
created_at: string;
|
|
2422
|
-
updated_at: string;
|
|
2423
|
-
metadata?: Record<string, unknown>;
|
|
2424
|
-
}
|
|
2425
|
-
interface ServiceCharge {
|
|
2426
|
-
percentage?: Money;
|
|
2427
|
-
is_mandatory?: boolean;
|
|
2428
|
-
description?: string;
|
|
2429
|
-
applies_to_parties_of?: number;
|
|
2430
|
-
minimum_amount?: Money;
|
|
2431
|
-
maximum_amount?: Money;
|
|
2432
|
-
}
|
|
2433
|
-
interface StorefrontBootstrap {
|
|
2434
|
-
business: Business;
|
|
2435
|
-
location?: Location;
|
|
2436
|
-
locations: Location[];
|
|
2437
|
-
categories: CategoryInfo[];
|
|
2438
|
-
currency: string;
|
|
2439
|
-
is_open: boolean;
|
|
2440
|
-
accepts_orders: boolean;
|
|
2441
|
-
time_profiles?: LocationTimeProfile[];
|
|
2442
|
-
}
|
|
2443
|
-
interface BusinessWithLocations extends Business {
|
|
2444
|
-
locations: Location[];
|
|
2445
|
-
default_location?: Location;
|
|
2446
|
-
}
|
|
2447
|
-
interface LocationWithDetails extends Location {
|
|
2448
|
-
time_profiles: LocationTimeProfile[];
|
|
2449
|
-
tables: Table[];
|
|
2450
|
-
rooms: Room[];
|
|
2451
|
-
is_open_now: boolean;
|
|
2452
|
-
next_open_time?: string;
|
|
2453
|
-
}
|
|
2454
|
-
/** Settings for frontend display (derived from Business/Location) */
|
|
2455
|
-
interface BusinessSettings {
|
|
2456
|
-
accept_online_orders: boolean;
|
|
2457
|
-
accept_reservations: boolean;
|
|
2458
|
-
require_customer_account: boolean;
|
|
2459
|
-
enable_tips: boolean;
|
|
2460
|
-
enable_loyalty: boolean;
|
|
2461
|
-
minimum_order_amount?: string;
|
|
2462
|
-
delivery_fee?: string;
|
|
2463
|
-
free_delivery_threshold?: string;
|
|
2464
|
-
tax_rate?: number;
|
|
2465
|
-
tax_inclusive: boolean;
|
|
2466
|
-
}
|
|
2467
|
-
/** Business hours (simplified for frontend) */
|
|
2468
|
-
interface BusinessHours {
|
|
2469
|
-
business_id: string;
|
|
2470
|
-
location_id?: string;
|
|
2471
|
-
day_of_week: number;
|
|
2472
|
-
open_time: string;
|
|
2473
|
-
close_time: string;
|
|
2474
|
-
is_closed: boolean;
|
|
2475
|
-
}
|
|
2476
|
-
/** Category summary for bootstrap (minimal fields) */
|
|
2477
|
-
interface CategoryInfo {
|
|
2478
|
-
id: string;
|
|
2479
|
-
name: string;
|
|
2480
|
-
slug: string;
|
|
2481
|
-
}
|
|
2482
|
-
|
|
2483
|
-
/**
|
|
2484
|
-
* Business service with explicit error handling via Result type.
|
|
2485
|
-
*
|
|
2486
|
-
* All methods return `Result<T, CimplifyError>` - no exceptions thrown.
|
|
2487
|
-
*
|
|
2488
|
-
* @example
|
|
2489
|
-
* ```typescript
|
|
2490
|
-
* const result = await client.business.getInfo();
|
|
2491
|
-
*
|
|
2492
|
-
* if (result.ok) {
|
|
2493
|
-
* console.log("Business:", result.value.name);
|
|
2494
|
-
* } else {
|
|
2495
|
-
* console.error("Failed:", result.error.code);
|
|
2496
|
-
* }
|
|
2497
|
-
* ```
|
|
2498
|
-
*/
|
|
2499
|
-
declare class BusinessService {
|
|
2500
|
-
private client;
|
|
2501
|
-
constructor(client: CimplifyClient);
|
|
2502
|
-
getInfo(): Promise<Result<Business, CimplifyError>>;
|
|
2503
|
-
getByHandle(handle: string): Promise<Result<Business, CimplifyError>>;
|
|
2504
|
-
getByDomain(domain: string): Promise<Result<Business, CimplifyError>>;
|
|
2505
|
-
getSettings(): Promise<Result<BusinessSettings, CimplifyError>>;
|
|
2506
|
-
getTheme(): Promise<Result<Record<string, unknown>, CimplifyError>>;
|
|
2507
|
-
getLocations(): Promise<Result<Location[], CimplifyError>>;
|
|
2508
|
-
getLocation(locationId: string): Promise<Result<Location, CimplifyError>>;
|
|
2509
|
-
getHours(): Promise<Result<BusinessHours[], CimplifyError>>;
|
|
2510
|
-
getLocationHours(locationId: string): Promise<Result<BusinessHours[], CimplifyError>>;
|
|
2511
|
-
getBootstrap(): Promise<Result<StorefrontBootstrap, CimplifyError>>;
|
|
2512
|
-
}
|
|
2513
|
-
|
|
2514
|
-
type StockOwnershipType = "owned" | "consignment" | "dropship";
|
|
2515
|
-
type StockStatus = "in_stock" | "low_stock" | "out_of_stock";
|
|
2516
|
-
interface Stock {
|
|
2517
|
-
id: string;
|
|
2518
|
-
business_id: string;
|
|
2519
|
-
name: string;
|
|
2520
|
-
sku?: string;
|
|
2521
|
-
barcode?: string;
|
|
2522
|
-
unit_type: string;
|
|
2523
|
-
unit_cost?: Money;
|
|
2524
|
-
description?: string;
|
|
2525
|
-
image_url?: string;
|
|
2526
|
-
tags?: string[];
|
|
2527
|
-
categories?: string[];
|
|
2528
|
-
is_taxable: boolean;
|
|
2529
|
-
tax_rate?: Money;
|
|
2530
|
-
is_expirable: boolean;
|
|
2531
|
-
ownership_type: StockOwnershipType;
|
|
2532
|
-
quantity_on_hand: Money;
|
|
2533
|
-
quantity_allocated: Money;
|
|
2534
|
-
quantity_reserved: Money;
|
|
2535
|
-
min_order_quantity: Money;
|
|
2536
|
-
reorder_point?: Money;
|
|
2537
|
-
reorder_quantity?: Money;
|
|
2538
|
-
last_counted_at?: string;
|
|
2539
|
-
status: string;
|
|
2540
|
-
created_at: string;
|
|
2541
|
-
updated_at: string;
|
|
2542
|
-
metadata?: Record<string, unknown>;
|
|
2543
|
-
}
|
|
2544
|
-
interface StockLevel {
|
|
2545
|
-
product_id: string;
|
|
2546
|
-
variant_id?: string;
|
|
2547
|
-
location_id?: string;
|
|
2548
|
-
quantity: number;
|
|
2549
|
-
reserved_quantity: number;
|
|
2550
|
-
available_quantity: number;
|
|
2551
|
-
low_stock_threshold?: number;
|
|
2552
|
-
status: StockStatus;
|
|
2553
|
-
last_updated: string;
|
|
2554
|
-
}
|
|
2555
|
-
interface ProductStock {
|
|
2556
|
-
product_id: string;
|
|
2557
|
-
product_name: string;
|
|
2558
|
-
total_quantity: number;
|
|
2559
|
-
available_quantity: number;
|
|
2560
|
-
reserved_quantity: number;
|
|
2561
|
-
status: StockStatus;
|
|
2562
|
-
variants?: VariantStock[];
|
|
2563
|
-
locations?: LocationStock[];
|
|
2564
|
-
}
|
|
2565
|
-
interface VariantStock {
|
|
2566
|
-
variant_id: string;
|
|
2567
|
-
variant_name: string;
|
|
2568
|
-
sku?: string;
|
|
2569
|
-
quantity: number;
|
|
2570
|
-
available_quantity: number;
|
|
2571
|
-
status: StockStatus;
|
|
2572
|
-
}
|
|
2573
|
-
interface LocationStock {
|
|
2574
|
-
location_id: string;
|
|
2575
|
-
location_name: string;
|
|
2576
|
-
quantity: number;
|
|
2577
|
-
available_quantity: number;
|
|
2578
|
-
status: StockStatus;
|
|
2579
|
-
}
|
|
2580
|
-
interface AvailabilityCheck {
|
|
2581
|
-
product_id: string;
|
|
2582
|
-
variant_id?: string;
|
|
2583
|
-
location_id?: string;
|
|
2584
|
-
requested_quantity: number;
|
|
2585
|
-
}
|
|
2586
|
-
interface AvailabilityResult {
|
|
2587
|
-
product_id: string;
|
|
2588
|
-
variant_id?: string;
|
|
2589
|
-
is_available: boolean;
|
|
2590
|
-
available_quantity: number;
|
|
2591
|
-
requested_quantity: number;
|
|
2592
|
-
shortfall?: number;
|
|
2593
|
-
}
|
|
2594
|
-
interface InventorySummary {
|
|
2595
|
-
total_products: number;
|
|
2596
|
-
in_stock_count: number;
|
|
2597
|
-
low_stock_count: number;
|
|
2598
|
-
out_of_stock_count: number;
|
|
2599
|
-
total_value?: Money;
|
|
2600
|
-
}
|
|
2601
|
-
|
|
2602
|
-
/**
|
|
2603
|
-
* Inventory service with explicit error handling via Result type.
|
|
2604
|
-
*
|
|
2605
|
-
* All methods return `Result<T, CimplifyError>` - no exceptions thrown.
|
|
2606
|
-
*
|
|
2607
|
-
* @example
|
|
2608
|
-
* ```typescript
|
|
2609
|
-
* const result = await client.inventory.isInStock("prod_123");
|
|
2610
|
-
*
|
|
2611
|
-
* if (result.ok) {
|
|
2612
|
-
* console.log("In stock:", result.value);
|
|
2613
|
-
* } else {
|
|
2614
|
-
* console.error("Failed:", result.error.code);
|
|
2615
|
-
* }
|
|
2616
|
-
* ```
|
|
2617
|
-
*/
|
|
2618
|
-
declare class InventoryService {
|
|
2619
|
-
private client;
|
|
2620
|
-
constructor(client: CimplifyClient);
|
|
2621
|
-
getStockLevels(): Promise<Result<StockLevel[], CimplifyError>>;
|
|
2622
|
-
getProductStock(productId: string, locationId?: string): Promise<Result<ProductStock, CimplifyError>>;
|
|
2623
|
-
getVariantStock(variantId: string, locationId?: string): Promise<Result<StockLevel, CimplifyError>>;
|
|
2624
|
-
checkProductAvailability(productId: string, quantity: number, locationId?: string): Promise<Result<AvailabilityResult, CimplifyError>>;
|
|
2625
|
-
checkVariantAvailability(variantId: string, quantity: number, locationId?: string): Promise<Result<AvailabilityResult, CimplifyError>>;
|
|
2626
|
-
checkMultipleAvailability(items: {
|
|
2627
|
-
product_id: string;
|
|
2628
|
-
variant_id?: string;
|
|
2629
|
-
quantity: number;
|
|
2630
|
-
}[], locationId?: string): Promise<Result<AvailabilityResult[], CimplifyError>>;
|
|
2631
|
-
getSummary(): Promise<Result<InventorySummary, CimplifyError>>;
|
|
2632
|
-
isInStock(productId: string, locationId?: string): Promise<Result<boolean, CimplifyError>>;
|
|
2633
|
-
getAvailableQuantity(productId: string, locationId?: string): Promise<Result<number, CimplifyError>>;
|
|
2634
|
-
}
|
|
2635
|
-
|
|
2636
|
-
interface ServiceAvailabilityRule {
|
|
2637
|
-
id: string;
|
|
2638
|
-
business_id: string;
|
|
2639
|
-
location_id: string;
|
|
2640
|
-
item_id: string;
|
|
2641
|
-
day_of_week: number;
|
|
2642
|
-
start_time: string;
|
|
2643
|
-
end_time: string;
|
|
2644
|
-
capacity?: number;
|
|
2645
|
-
created_at: string;
|
|
2646
|
-
updated_at: string;
|
|
2647
|
-
metadata?: Record<string, unknown>;
|
|
2648
|
-
}
|
|
2649
|
-
interface ServiceAvailabilityException {
|
|
2650
|
-
id: string;
|
|
2651
|
-
business_id: string;
|
|
2652
|
-
location_id: string;
|
|
2653
|
-
item_id: string;
|
|
2654
|
-
exception_date: string;
|
|
2655
|
-
is_closed: boolean;
|
|
2656
|
-
start_time?: string;
|
|
2657
|
-
end_time?: string;
|
|
2658
|
-
capacity?: number;
|
|
2659
|
-
reason?: string;
|
|
2660
|
-
created_at: string;
|
|
2661
|
-
updated_at: string;
|
|
2662
|
-
metadata?: Record<string, unknown>;
|
|
2663
|
-
}
|
|
2664
|
-
interface StaffAvailabilityRule {
|
|
2665
|
-
id: string;
|
|
2666
|
-
staff_id: string;
|
|
2667
|
-
location_id?: string;
|
|
2668
|
-
day_of_week: number;
|
|
2669
|
-
start_time: string;
|
|
2670
|
-
end_time: string;
|
|
2671
|
-
is_available: boolean;
|
|
2672
|
-
created_at: string;
|
|
2673
|
-
updated_at: string;
|
|
2674
|
-
metadata?: Record<string, unknown>;
|
|
2675
|
-
}
|
|
2676
|
-
interface StaffAvailabilityException {
|
|
2677
|
-
id: string;
|
|
2678
|
-
staff_id: string;
|
|
2679
|
-
location_id?: string;
|
|
2680
|
-
exception_date: string;
|
|
2681
|
-
is_unavailable_all_day: boolean;
|
|
2682
|
-
start_time?: string;
|
|
2683
|
-
end_time?: string;
|
|
2684
|
-
reason?: string;
|
|
2685
|
-
created_at: string;
|
|
2686
|
-
updated_at: string;
|
|
2687
|
-
metadata?: Record<string, unknown>;
|
|
2688
|
-
}
|
|
2689
|
-
interface ResourceAvailabilityRule {
|
|
2690
|
-
id: string;
|
|
2691
|
-
business_id: string;
|
|
2692
|
-
location_id: string;
|
|
2693
|
-
resource_id: string;
|
|
2694
|
-
day_of_week: number;
|
|
2695
|
-
start_time: string;
|
|
2696
|
-
end_time: string;
|
|
2697
|
-
is_available: boolean;
|
|
2698
|
-
created_at: string;
|
|
2699
|
-
updated_at: string;
|
|
2700
|
-
metadata?: Record<string, unknown>;
|
|
2701
|
-
}
|
|
2702
|
-
interface ResourceAvailabilityException {
|
|
2703
|
-
id: string;
|
|
2704
|
-
business_id: string;
|
|
2705
|
-
location_id: string;
|
|
2706
|
-
resource_id: string;
|
|
2707
|
-
exception_date: string;
|
|
2708
|
-
is_unavailable_all_day: boolean;
|
|
2709
|
-
start_time?: string;
|
|
2710
|
-
end_time?: string;
|
|
2711
|
-
reason?: string;
|
|
2712
|
-
created_at: string;
|
|
2713
|
-
updated_at: string;
|
|
2714
|
-
metadata?: Record<string, unknown>;
|
|
2715
|
-
}
|
|
2716
|
-
interface StaffBookingProfile {
|
|
2717
|
-
id: string;
|
|
2718
|
-
staff_id: string;
|
|
2719
|
-
skills?: string[];
|
|
2720
|
-
can_be_booked: boolean;
|
|
2721
|
-
default_service_duration_override?: number;
|
|
2722
|
-
booking_buffer_minutes?: number;
|
|
2723
|
-
max_daily_bookings?: number;
|
|
2724
|
-
preferred_working_hours?: Record<string, unknown>;
|
|
2725
|
-
created_at: string;
|
|
2726
|
-
updated_at: string;
|
|
2727
|
-
metadata?: Record<string, unknown>;
|
|
2728
|
-
}
|
|
2729
|
-
interface ServiceStaffRequirement {
|
|
2730
|
-
id: string;
|
|
2731
|
-
service_item_id: string;
|
|
2732
|
-
role_id?: string;
|
|
2733
|
-
required_skill?: string;
|
|
2734
|
-
number_of_staff: number;
|
|
2735
|
-
specific_staff_assignment_required: boolean;
|
|
2736
|
-
created_at: string;
|
|
2737
|
-
updated_at: string;
|
|
2738
|
-
metadata?: Record<string, unknown>;
|
|
2739
|
-
}
|
|
2740
|
-
interface BookingRequirementOverride {
|
|
2741
|
-
id: string;
|
|
2742
|
-
appointment_id: string;
|
|
2743
|
-
overridden_by: string;
|
|
2744
|
-
reason: string;
|
|
2745
|
-
missing_staff_requirements?: Record<string, unknown>;
|
|
2746
|
-
missing_resource_requirements?: Record<string, unknown>;
|
|
2747
|
-
created_at: string;
|
|
2748
|
-
}
|
|
2749
|
-
interface ResourceType {
|
|
2750
|
-
id: string;
|
|
2751
|
-
business_id: string;
|
|
2752
|
-
name: string;
|
|
2753
|
-
description?: string;
|
|
2754
|
-
created_at: string;
|
|
2755
|
-
updated_at: string;
|
|
2756
|
-
}
|
|
2757
|
-
interface Service {
|
|
2758
|
-
id: string;
|
|
2759
|
-
business_id: string;
|
|
2760
|
-
product_id: string;
|
|
2761
|
-
name: string;
|
|
2762
|
-
description?: string;
|
|
2763
|
-
duration_minutes: number;
|
|
2764
|
-
buffer_before_minutes: number;
|
|
2765
|
-
buffer_after_minutes: number;
|
|
2766
|
-
max_participants: number;
|
|
2767
|
-
price: Money;
|
|
2768
|
-
currency: string;
|
|
2769
|
-
requires_staff: boolean;
|
|
2770
|
-
is_active: boolean;
|
|
2771
|
-
image_url?: string;
|
|
2772
|
-
category_id?: string;
|
|
2773
|
-
metadata?: Record<string, unknown>;
|
|
2774
|
-
}
|
|
2775
|
-
interface ServiceWithStaff extends Service {
|
|
2776
|
-
available_staff: Staff[];
|
|
2777
|
-
}
|
|
2778
|
-
interface Staff {
|
|
2779
|
-
id: string;
|
|
2780
|
-
business_id: string;
|
|
2781
|
-
name: string;
|
|
2782
|
-
email?: string;
|
|
2783
|
-
phone?: string;
|
|
2784
|
-
avatar_url?: string;
|
|
2785
|
-
bio?: string;
|
|
2786
|
-
is_active: boolean;
|
|
2787
|
-
services?: string[];
|
|
2788
|
-
}
|
|
2789
|
-
interface TimeSlot {
|
|
2790
|
-
start_time: string;
|
|
2791
|
-
end_time: string;
|
|
2792
|
-
is_available: boolean;
|
|
2793
|
-
staff_id?: string;
|
|
2794
|
-
staff_name?: string;
|
|
2795
|
-
remaining_capacity?: number;
|
|
2796
|
-
}
|
|
2797
|
-
interface AvailableSlot extends TimeSlot {
|
|
2798
|
-
price?: Money;
|
|
2799
|
-
duration_minutes: number;
|
|
2800
|
-
}
|
|
2801
|
-
interface DayAvailability {
|
|
2802
|
-
date: string;
|
|
2803
|
-
slots: TimeSlot[];
|
|
2804
|
-
is_fully_booked: boolean;
|
|
2805
|
-
}
|
|
2806
|
-
type BookingStatus = "pending" | "confirmed" | "in_progress" | "completed" | "cancelled" | "no_show";
|
|
2807
|
-
interface Booking {
|
|
2808
|
-
id: string;
|
|
2809
|
-
business_id: string;
|
|
2810
|
-
order_id: string;
|
|
2811
|
-
line_item_id: string;
|
|
2812
|
-
service_id: string;
|
|
2813
|
-
service_name: string;
|
|
2814
|
-
customer_id?: string;
|
|
2815
|
-
customer_name?: string;
|
|
2816
|
-
customer_phone?: string;
|
|
2817
|
-
staff_id?: string;
|
|
2818
|
-
staff_name?: string;
|
|
2819
|
-
location_id?: string;
|
|
2820
|
-
location_name?: string;
|
|
2821
|
-
start_time: string;
|
|
2822
|
-
end_time: string;
|
|
2823
|
-
duration_minutes: number;
|
|
2824
|
-
participant_count: number;
|
|
2825
|
-
status: BookingStatus;
|
|
2826
|
-
notes?: string;
|
|
2827
|
-
cancellation_reason?: string;
|
|
2828
|
-
cancelled_at?: string;
|
|
2829
|
-
created_at: string;
|
|
2830
|
-
updated_at: string;
|
|
2831
|
-
}
|
|
2832
|
-
interface BookingWithDetails extends Booking {
|
|
2833
|
-
service: Service;
|
|
2834
|
-
staff?: Staff;
|
|
2835
|
-
}
|
|
2836
|
-
interface GetAvailableSlotsInput {
|
|
2837
|
-
service_id: string;
|
|
2838
|
-
date: string;
|
|
2839
|
-
participant_count?: number;
|
|
2840
|
-
duration_minutes?: number;
|
|
2841
|
-
staff_id?: string;
|
|
2842
|
-
location_id?: string;
|
|
2843
|
-
}
|
|
2844
|
-
interface CheckSlotAvailabilityInput {
|
|
2845
|
-
service_id: string;
|
|
2846
|
-
slot_time: string;
|
|
2847
|
-
duration_minutes?: number;
|
|
2848
|
-
participant_count?: number;
|
|
2849
|
-
staff_id?: string;
|
|
2850
|
-
}
|
|
2851
|
-
interface RescheduleBookingInput {
|
|
2852
|
-
order_id: string;
|
|
2853
|
-
line_item_id: string;
|
|
2854
|
-
new_start_time: string;
|
|
2855
|
-
new_end_time: string;
|
|
2856
|
-
new_staff_id?: string;
|
|
2857
|
-
reason?: string;
|
|
2858
|
-
}
|
|
2859
|
-
interface CancelBookingInput {
|
|
2860
|
-
booking_id: string;
|
|
2861
|
-
reason?: string;
|
|
2862
|
-
}
|
|
2863
|
-
interface ServiceAvailabilityParams {
|
|
2864
|
-
service_id: string;
|
|
2865
|
-
start_date: string;
|
|
2866
|
-
end_date: string;
|
|
2867
|
-
location_id?: string;
|
|
2868
|
-
staff_id?: string;
|
|
2869
|
-
participant_count?: number;
|
|
2870
|
-
}
|
|
2871
|
-
interface ServiceAvailabilityResult {
|
|
2872
|
-
service_id: string;
|
|
2873
|
-
days: DayAvailability[];
|
|
2874
|
-
}
|
|
2875
|
-
|
|
2876
|
-
/**
|
|
2877
|
-
* Scheduling service with explicit error handling via Result type.
|
|
2878
|
-
*
|
|
2879
|
-
* All methods return `Result<T, CimplifyError>` - no exceptions thrown.
|
|
2880
|
-
*
|
|
2881
|
-
* @example
|
|
2882
|
-
* ```typescript
|
|
2883
|
-
* const result = await client.scheduling.getAvailableSlots({
|
|
2884
|
-
* service_id: "svc_haircut",
|
|
2885
|
-
* date: "2024-01-15"
|
|
2886
|
-
* });
|
|
2887
|
-
*
|
|
2888
|
-
* if (result.ok) {
|
|
2889
|
-
* console.log("Available slots:", result.value);
|
|
2890
|
-
* } else {
|
|
2891
|
-
* console.error("Failed:", result.error.code);
|
|
2892
|
-
* }
|
|
2893
|
-
* ```
|
|
2894
|
-
*/
|
|
2895
|
-
declare class SchedulingService {
|
|
2896
|
-
private client;
|
|
2897
|
-
constructor(client: CimplifyClient);
|
|
2898
|
-
getServices(): Promise<Result<Service[], CimplifyError>>;
|
|
2899
|
-
/**
|
|
2900
|
-
* Get a specific service by ID
|
|
2901
|
-
* Note: Filters from all services client-side (no single-service endpoint)
|
|
2902
|
-
*/
|
|
2903
|
-
getService(serviceId: string): Promise<Result<Service | null, CimplifyError>>;
|
|
2904
|
-
getAvailableSlots(input: GetAvailableSlotsInput): Promise<Result<AvailableSlot[], CimplifyError>>;
|
|
2905
|
-
checkSlotAvailability(input: CheckSlotAvailabilityInput): Promise<Result<{
|
|
2906
|
-
available: boolean;
|
|
2907
|
-
reason?: string;
|
|
2908
|
-
}, CimplifyError>>;
|
|
2909
|
-
getServiceAvailability(params: ServiceAvailabilityParams): Promise<Result<ServiceAvailabilityResult, CimplifyError>>;
|
|
2910
|
-
getBooking(bookingId: string): Promise<Result<BookingWithDetails, CimplifyError>>;
|
|
2911
|
-
getCustomerBookings(): Promise<Result<Booking[], CimplifyError>>;
|
|
2912
|
-
getUpcomingBookings(): Promise<Result<Booking[], CimplifyError>>;
|
|
2913
|
-
getPastBookings(limit?: number): Promise<Result<Booking[], CimplifyError>>;
|
|
2914
|
-
cancelBooking(input: CancelBookingInput): Promise<Result<Booking, CimplifyError>>;
|
|
2915
|
-
rescheduleBooking(input: RescheduleBookingInput): Promise<Result<Booking, CimplifyError>>;
|
|
2916
|
-
getNextAvailableSlot(serviceId: string, fromDate?: string): Promise<Result<AvailableSlot | null, CimplifyError>>;
|
|
2917
|
-
hasAvailabilityOn(serviceId: string, date: string): Promise<Result<boolean, CimplifyError>>;
|
|
2918
|
-
}
|
|
2919
|
-
|
|
2920
|
-
interface LiteBootstrap {
|
|
2921
|
-
business: Business;
|
|
2922
|
-
location: Location;
|
|
2923
|
-
categories: Category[];
|
|
2924
|
-
table?: TableInfo;
|
|
2925
|
-
cart: Cart | null;
|
|
2926
|
-
currency: string;
|
|
2927
|
-
is_open: boolean;
|
|
2928
|
-
}
|
|
2929
|
-
interface TableInfo {
|
|
2930
|
-
id: string;
|
|
2931
|
-
number: string;
|
|
2932
|
-
location_id: string;
|
|
2933
|
-
capacity?: number;
|
|
2934
|
-
status: "available" | "occupied" | "reserved";
|
|
2935
|
-
current_order_id?: string;
|
|
2936
|
-
}
|
|
2937
|
-
interface KitchenOrderItem {
|
|
2938
|
-
product_id: string;
|
|
2939
|
-
quantity: number;
|
|
2940
|
-
variant_id?: string;
|
|
2941
|
-
modifiers?: string[];
|
|
2942
|
-
notes?: string;
|
|
2943
|
-
}
|
|
2944
|
-
interface KitchenOrderResult {
|
|
2945
|
-
success: boolean;
|
|
2946
|
-
order_id: string;
|
|
2947
|
-
order_number: string;
|
|
2948
|
-
estimated_time_minutes?: number;
|
|
2949
|
-
}
|
|
2950
|
-
interface SuccessResult {
|
|
2951
|
-
success: boolean;
|
|
2952
|
-
}
|
|
2953
|
-
interface RequestBillResult {
|
|
2954
|
-
success: boolean;
|
|
2955
|
-
order_id: string;
|
|
2956
|
-
}
|
|
2957
|
-
/**
|
|
2958
|
-
* Lite service for QR code ordering with explicit error handling via Result type.
|
|
2959
|
-
*
|
|
2960
|
-
* All methods return `Result<T, CimplifyError>` - no exceptions thrown.
|
|
2961
|
-
*
|
|
2962
|
-
* @example
|
|
2963
|
-
* ```typescript
|
|
2964
|
-
* const result = await client.lite.getBootstrap();
|
|
2965
|
-
*
|
|
2966
|
-
* if (result.ok) {
|
|
2967
|
-
* console.log("Business:", result.value.business.name);
|
|
2968
|
-
* console.log("Table:", result.value.table?.number);
|
|
2969
|
-
* } else {
|
|
2970
|
-
* console.error("Failed:", result.error.code);
|
|
2971
|
-
* }
|
|
2972
|
-
* ```
|
|
2973
|
-
*/
|
|
2974
|
-
declare class LiteService {
|
|
2975
|
-
private client;
|
|
2976
|
-
constructor(client: CimplifyClient);
|
|
2977
|
-
getBootstrap(): Promise<Result<LiteBootstrap, CimplifyError>>;
|
|
2978
|
-
getTable(tableId: string): Promise<Result<TableInfo, CimplifyError>>;
|
|
2979
|
-
getTableByNumber(tableNumber: string, locationId?: string): Promise<Result<TableInfo, CimplifyError>>;
|
|
2980
|
-
sendToKitchen(tableId: string, items: KitchenOrderItem[]): Promise<Result<KitchenOrderResult, CimplifyError>>;
|
|
2981
|
-
callWaiter(tableId: string, reason?: string): Promise<Result<SuccessResult, CimplifyError>>;
|
|
2982
|
-
requestBill(tableId: string): Promise<Result<RequestBillResult, CimplifyError>>;
|
|
2983
|
-
getMenu(): Promise<Result<Product[], CimplifyError>>;
|
|
2984
|
-
getMenuByCategory(categoryId: string): Promise<Result<Product[], CimplifyError>>;
|
|
2985
|
-
}
|
|
2986
|
-
|
|
2987
|
-
interface FxQuoteRequest {
|
|
2988
|
-
from: string;
|
|
2989
|
-
to: string;
|
|
2990
|
-
amount: number;
|
|
2991
|
-
}
|
|
2992
|
-
interface FxQuote {
|
|
2993
|
-
id: string;
|
|
2994
|
-
base_currency: string;
|
|
2995
|
-
pay_currency: string;
|
|
2996
|
-
rate: number;
|
|
2997
|
-
inverse_rate: number;
|
|
2998
|
-
base_amount: number;
|
|
2999
|
-
converted_amount: number;
|
|
3000
|
-
quoted_at: string;
|
|
3001
|
-
valid_until: string;
|
|
3002
|
-
}
|
|
3003
|
-
interface FxRateResponse {
|
|
3004
|
-
from: string;
|
|
3005
|
-
to: string;
|
|
3006
|
-
rate: number;
|
|
3007
|
-
inverse_rate: number;
|
|
3008
|
-
quoted_at: string;
|
|
3009
|
-
valid_until: string;
|
|
3010
|
-
}
|
|
3011
|
-
|
|
3012
|
-
declare class FxService {
|
|
3013
|
-
private client;
|
|
3014
|
-
constructor(client: CimplifyClient);
|
|
3015
|
-
getRate(from: string, to: string): Promise<Result<FxRateResponse, CimplifyError>>;
|
|
3016
|
-
lockQuote(request: FxQuoteRequest): Promise<Result<FxQuote, CimplifyError>>;
|
|
3017
|
-
}
|
|
3018
|
-
|
|
3019
|
-
declare const ELEMENT_TYPES: {
|
|
3020
|
-
readonly AUTH: "auth";
|
|
3021
|
-
readonly ADDRESS: "address";
|
|
3022
|
-
readonly PAYMENT: "payment";
|
|
3023
|
-
};
|
|
3024
|
-
type ElementType = (typeof ELEMENT_TYPES)[keyof typeof ELEMENT_TYPES];
|
|
3025
|
-
declare const MESSAGE_TYPES: {
|
|
3026
|
-
readonly INIT: "init";
|
|
3027
|
-
readonly SET_TOKEN: "set_token";
|
|
3028
|
-
readonly GET_DATA: "get_data";
|
|
3029
|
-
readonly REFRESH_TOKEN: "refresh_token";
|
|
3030
|
-
readonly LOGOUT: "logout";
|
|
3031
|
-
readonly READY: "ready";
|
|
3032
|
-
readonly HEIGHT_CHANGE: "height_change";
|
|
3033
|
-
readonly AUTHENTICATED: "authenticated";
|
|
3034
|
-
readonly REQUIRES_OTP: "requires_otp";
|
|
3035
|
-
readonly ERROR: "error";
|
|
3036
|
-
readonly ADDRESS_CHANGED: "address_changed";
|
|
3037
|
-
readonly ADDRESS_SELECTED: "address_selected";
|
|
3038
|
-
readonly PAYMENT_METHOD_SELECTED: "payment_method_selected";
|
|
3039
|
-
readonly TOKEN_REFRESHED: "token_refreshed";
|
|
3040
|
-
readonly LOGOUT_COMPLETE: "logout_complete";
|
|
3041
|
-
};
|
|
3042
|
-
interface ElementsOptions {
|
|
3043
|
-
linkUrl?: string;
|
|
3044
|
-
appearance?: ElementAppearance;
|
|
3045
|
-
}
|
|
3046
|
-
interface ElementAppearance {
|
|
3047
|
-
theme?: "light" | "dark";
|
|
3048
|
-
variables?: {
|
|
3049
|
-
primaryColor?: string;
|
|
3050
|
-
fontFamily?: string;
|
|
3051
|
-
borderRadius?: string;
|
|
3052
|
-
};
|
|
3053
|
-
}
|
|
3054
|
-
interface ElementOptions {
|
|
3055
|
-
mode?: "shipping" | "billing";
|
|
3056
|
-
prefillEmail?: string;
|
|
3057
|
-
amount?: number;
|
|
3058
|
-
currency?: string;
|
|
3059
|
-
}
|
|
3060
|
-
interface AddressInfo {
|
|
3061
|
-
id?: string;
|
|
3062
|
-
street_address: string;
|
|
3063
|
-
apartment?: string;
|
|
3064
|
-
city: string;
|
|
3065
|
-
region: string;
|
|
3066
|
-
postal_code?: string;
|
|
3067
|
-
country?: string;
|
|
3068
|
-
delivery_instructions?: string;
|
|
3069
|
-
phone_for_delivery?: string;
|
|
3070
|
-
}
|
|
3071
|
-
interface PaymentMethodInfo {
|
|
3072
|
-
id?: string;
|
|
3073
|
-
type: "mobile_money" | "card" | "cash";
|
|
3074
|
-
provider?: string;
|
|
3075
|
-
last_four?: string;
|
|
3076
|
-
phone_number?: string;
|
|
3077
|
-
label?: string;
|
|
3078
|
-
}
|
|
3079
|
-
interface AuthenticatedData {
|
|
3080
|
-
accountId: string;
|
|
3081
|
-
customerId: string;
|
|
3082
|
-
token: string;
|
|
3083
|
-
}
|
|
3084
|
-
interface ElementsCheckoutData {
|
|
3085
|
-
cart_id: string;
|
|
3086
|
-
order_type?: "delivery" | "pickup" | "dine_in";
|
|
3087
|
-
location_id?: string;
|
|
3088
|
-
scheduled_time?: string;
|
|
3089
|
-
tip_amount?: number;
|
|
3090
|
-
notes?: string;
|
|
3091
|
-
}
|
|
3092
|
-
interface ElementsCheckoutResult {
|
|
3093
|
-
success: boolean;
|
|
3094
|
-
order?: {
|
|
3095
|
-
id: string;
|
|
3096
|
-
status: string;
|
|
3097
|
-
total: string;
|
|
3098
|
-
};
|
|
3099
|
-
error?: {
|
|
3100
|
-
code: string;
|
|
3101
|
-
message: string;
|
|
3102
|
-
};
|
|
3103
|
-
}
|
|
3104
|
-
type ParentToIframeMessage = {
|
|
3105
|
-
type: typeof MESSAGE_TYPES.INIT;
|
|
3106
|
-
businessId: string;
|
|
3107
|
-
prefillEmail?: string;
|
|
3108
|
-
} | {
|
|
3109
|
-
type: typeof MESSAGE_TYPES.SET_TOKEN;
|
|
3110
|
-
token: string;
|
|
3111
|
-
} | {
|
|
3112
|
-
type: typeof MESSAGE_TYPES.GET_DATA;
|
|
3113
|
-
} | {
|
|
3114
|
-
type: typeof MESSAGE_TYPES.REFRESH_TOKEN;
|
|
3115
|
-
} | {
|
|
3116
|
-
type: typeof MESSAGE_TYPES.LOGOUT;
|
|
3117
|
-
};
|
|
3118
|
-
type IframeToParentMessage = {
|
|
3119
|
-
type: typeof MESSAGE_TYPES.READY;
|
|
3120
|
-
height: number;
|
|
3121
|
-
} | {
|
|
3122
|
-
type: typeof MESSAGE_TYPES.HEIGHT_CHANGE;
|
|
3123
|
-
height: number;
|
|
3124
|
-
} | {
|
|
3125
|
-
type: typeof MESSAGE_TYPES.AUTHENTICATED;
|
|
3126
|
-
accountId: string;
|
|
3127
|
-
customerId: string;
|
|
3128
|
-
token: string;
|
|
3129
|
-
} | {
|
|
3130
|
-
type: typeof MESSAGE_TYPES.REQUIRES_OTP;
|
|
3131
|
-
contactMasked: string;
|
|
3132
|
-
} | {
|
|
3133
|
-
type: typeof MESSAGE_TYPES.ERROR;
|
|
3134
|
-
code: string;
|
|
3135
|
-
message: string;
|
|
3136
|
-
} | {
|
|
3137
|
-
type: typeof MESSAGE_TYPES.ADDRESS_CHANGED;
|
|
3138
|
-
address: AddressInfo;
|
|
3139
|
-
saveToLink: boolean;
|
|
3140
|
-
} | {
|
|
3141
|
-
type: typeof MESSAGE_TYPES.ADDRESS_SELECTED;
|
|
3142
|
-
address: AddressInfo;
|
|
3143
|
-
} | {
|
|
3144
|
-
type: typeof MESSAGE_TYPES.PAYMENT_METHOD_SELECTED;
|
|
3145
|
-
method: PaymentMethodInfo;
|
|
3146
|
-
saveToLink: boolean;
|
|
3147
|
-
} | {
|
|
3148
|
-
type: typeof MESSAGE_TYPES.TOKEN_REFRESHED;
|
|
3149
|
-
token: string;
|
|
3150
|
-
} | {
|
|
3151
|
-
type: typeof MESSAGE_TYPES.LOGOUT_COMPLETE;
|
|
3152
|
-
};
|
|
3153
|
-
declare const EVENT_TYPES: {
|
|
3154
|
-
readonly READY: "ready";
|
|
3155
|
-
readonly AUTHENTICATED: "authenticated";
|
|
3156
|
-
readonly REQUIRES_OTP: "requires_otp";
|
|
3157
|
-
readonly ERROR: "error";
|
|
3158
|
-
readonly CHANGE: "change";
|
|
3159
|
-
readonly BLUR: "blur";
|
|
3160
|
-
readonly FOCUS: "focus";
|
|
3161
|
-
};
|
|
3162
|
-
type ElementEventType = (typeof EVENT_TYPES)[keyof typeof EVENT_TYPES];
|
|
3163
|
-
type ElementEventHandler<T = unknown> = (data: T) => void;
|
|
3164
|
-
|
|
3165
|
-
declare class CimplifyElements {
|
|
3166
|
-
private client;
|
|
3167
|
-
private businessId;
|
|
3168
|
-
private linkUrl;
|
|
3169
|
-
private options;
|
|
3170
|
-
private elements;
|
|
3171
|
-
private accessToken;
|
|
3172
|
-
private accountId;
|
|
3173
|
-
private customerId;
|
|
3174
|
-
private addressData;
|
|
3175
|
-
private paymentData;
|
|
3176
|
-
private boundHandleMessage;
|
|
3177
|
-
constructor(client: CimplifyClient, businessId: string, options?: ElementsOptions);
|
|
3178
|
-
create(type: ElementType, options?: ElementOptions): CimplifyElement;
|
|
3179
|
-
getElement(type: ElementType): CimplifyElement | undefined;
|
|
3180
|
-
destroy(): void;
|
|
3181
|
-
submitCheckout(data: ElementsCheckoutData): Promise<ElementsCheckoutResult>;
|
|
3182
|
-
isAuthenticated(): boolean;
|
|
3183
|
-
getAccessToken(): string | null;
|
|
3184
|
-
private handleMessage;
|
|
3185
|
-
_setAddressData(data: AddressInfo): void;
|
|
3186
|
-
_setPaymentData(data: PaymentMethodInfo): void;
|
|
3187
|
-
}
|
|
3188
|
-
declare class CimplifyElement {
|
|
3189
|
-
private type;
|
|
3190
|
-
private businessId;
|
|
3191
|
-
private linkUrl;
|
|
3192
|
-
private options;
|
|
3193
|
-
private parent;
|
|
3194
|
-
private iframe;
|
|
3195
|
-
private container;
|
|
3196
|
-
private mounted;
|
|
3197
|
-
private eventHandlers;
|
|
3198
|
-
private resolvers;
|
|
3199
|
-
private boundHandleMessage;
|
|
3200
|
-
constructor(type: ElementType, businessId: string, linkUrl: string, options: ElementOptions, parent: CimplifyElements);
|
|
3201
|
-
mount(container: string | HTMLElement): void;
|
|
3202
|
-
destroy(): void;
|
|
3203
|
-
on(event: ElementEventType, handler: ElementEventHandler): void;
|
|
3204
|
-
off(event: ElementEventType, handler: ElementEventHandler): void;
|
|
3205
|
-
getData(): Promise<unknown>;
|
|
3206
|
-
sendMessage(message: ParentToIframeMessage): void;
|
|
3207
|
-
private createIframe;
|
|
3208
|
-
private handleMessage;
|
|
3209
|
-
private emit;
|
|
3210
|
-
private resolveData;
|
|
3211
|
-
}
|
|
3212
|
-
declare function createElements(client: CimplifyClient, businessId: string, options?: ElementsOptions): CimplifyElements;
|
|
3213
|
-
|
|
3214
|
-
interface CimplifyConfig {
|
|
3215
|
-
publicKey?: string;
|
|
3216
|
-
credentials?: RequestCredentials;
|
|
3217
|
-
/** Request timeout in milliseconds (default: 30000) */
|
|
3218
|
-
timeout?: number;
|
|
3219
|
-
/** Maximum retry attempts for retryable errors (default: 3) */
|
|
3220
|
-
maxRetries?: number;
|
|
3221
|
-
/** Base delay between retries in milliseconds (default: 1000) */
|
|
3222
|
-
retryDelay?: number;
|
|
3223
|
-
/** Observability hooks for logging, metrics, and tracing */
|
|
3224
|
-
hooks?: ObservabilityHooks;
|
|
3225
|
-
}
|
|
3226
|
-
declare class CimplifyClient {
|
|
3227
|
-
private baseUrl;
|
|
3228
|
-
private linkApiUrl;
|
|
3229
|
-
private publicKey;
|
|
3230
|
-
private credentials;
|
|
3231
|
-
private accessToken;
|
|
3232
|
-
private timeout;
|
|
3233
|
-
private maxRetries;
|
|
3234
|
-
private retryDelay;
|
|
3235
|
-
private hooks;
|
|
3236
|
-
private context;
|
|
3237
|
-
private inflightRequests;
|
|
3238
|
-
private _catalogue?;
|
|
3239
|
-
private _cart?;
|
|
3240
|
-
private _checkout?;
|
|
3241
|
-
private _orders?;
|
|
3242
|
-
private _link?;
|
|
3243
|
-
private _auth?;
|
|
3244
|
-
private _business?;
|
|
3245
|
-
private _inventory?;
|
|
3246
|
-
private _scheduling?;
|
|
3247
|
-
private _lite?;
|
|
3248
|
-
private _fx?;
|
|
3249
|
-
constructor(config?: CimplifyConfig);
|
|
3250
|
-
/** @deprecated Use getAccessToken() instead */
|
|
3251
|
-
getSessionToken(): string | null;
|
|
3252
|
-
/** @deprecated Use setAccessToken() instead */
|
|
3253
|
-
setSessionToken(token: string | null): void;
|
|
3254
|
-
getAccessToken(): string | null;
|
|
3255
|
-
setAccessToken(token: string | null): void;
|
|
3256
|
-
clearSession(): void;
|
|
3257
|
-
/** Set the active location/branch for all subsequent requests */
|
|
3258
|
-
setLocationId(locationId: string | null): void;
|
|
3259
|
-
/** Get the currently active location ID */
|
|
3260
|
-
getLocationId(): string | null;
|
|
3261
|
-
private loadAccessToken;
|
|
3262
|
-
private saveAccessToken;
|
|
3263
|
-
private getHeaders;
|
|
3264
|
-
private resilientFetch;
|
|
3265
|
-
private getDedupeKey;
|
|
3266
|
-
private deduplicatedRequest;
|
|
3267
|
-
query<T = unknown>(query: string, variables?: Record<string, unknown>): Promise<T>;
|
|
3268
|
-
call<T = unknown>(method: string, args?: unknown): Promise<T>;
|
|
3269
|
-
get<T = unknown>(path: string): Promise<T>;
|
|
3270
|
-
post<T = unknown>(path: string, body?: unknown): Promise<T>;
|
|
3271
|
-
delete<T = unknown>(path: string): Promise<T>;
|
|
3272
|
-
linkGet<T = unknown>(path: string): Promise<T>;
|
|
3273
|
-
linkPost<T = unknown>(path: string, body?: unknown): Promise<T>;
|
|
3274
|
-
linkDelete<T = unknown>(path: string): Promise<T>;
|
|
3275
|
-
private handleRestResponse;
|
|
3276
|
-
private handleResponse;
|
|
3277
|
-
get catalogue(): CatalogueQueries;
|
|
3278
|
-
get cart(): CartOperations;
|
|
3279
|
-
get checkout(): CheckoutService;
|
|
3280
|
-
get orders(): OrderQueries;
|
|
3281
|
-
get link(): LinkService;
|
|
3282
|
-
get auth(): AuthService;
|
|
3283
|
-
get business(): BusinessService;
|
|
3284
|
-
get inventory(): InventoryService;
|
|
3285
|
-
get scheduling(): SchedulingService;
|
|
3286
|
-
get lite(): LiteService;
|
|
3287
|
-
get fx(): FxService;
|
|
3288
|
-
/**
|
|
3289
|
-
* Create a CimplifyElements instance for embedding checkout components.
|
|
3290
|
-
* Like Stripe's stripe.elements().
|
|
3291
|
-
*
|
|
3292
|
-
* @param businessId - The business ID for checkout context
|
|
3293
|
-
* @param options - Optional configuration for elements
|
|
3294
|
-
*
|
|
3295
|
-
* @example
|
|
3296
|
-
* ```ts
|
|
3297
|
-
* const elements = client.elements('bus_xxx');
|
|
3298
|
-
* const authElement = elements.create('auth');
|
|
3299
|
-
* authElement.mount('#auth-container');
|
|
3300
|
-
* ```
|
|
3301
|
-
*/
|
|
3302
|
-
elements(businessId: string, options?: ElementsOptions): CimplifyElements;
|
|
3303
|
-
}
|
|
3304
|
-
declare function createCimplifyClient(config?: CimplifyConfig): CimplifyClient;
|
|
3305
|
-
|
|
3306
|
-
type AdSlot = "banner" | "sidebar" | "in-content" | "native" | "footer";
|
|
3307
|
-
type AdPosition = "static" | "sticky" | "fixed";
|
|
3308
|
-
type AdTheme = "light" | "dark" | "auto";
|
|
3309
|
-
interface AdConfig {
|
|
3310
|
-
enabled: boolean;
|
|
3311
|
-
theme: AdTheme;
|
|
3312
|
-
excludePaths?: string[];
|
|
3313
|
-
}
|
|
3314
|
-
interface AdCreative {
|
|
3315
|
-
id: string;
|
|
3316
|
-
html: string;
|
|
3317
|
-
clickUrl: string;
|
|
3318
|
-
}
|
|
3319
|
-
interface AdContextValue {
|
|
3320
|
-
siteId: string | null;
|
|
3321
|
-
config: AdConfig | null;
|
|
3322
|
-
isLoading: boolean;
|
|
3323
|
-
}
|
|
3324
|
-
|
|
3325
|
-
export { type CheckoutFormData as $, type ApiError as A, BusinessService as B, CimplifyClient as C, createElements as D, EVENT_TYPES as E, type FetchQuoteInput as F, type GetProductsOptions as G, ELEMENT_TYPES as H, InventoryService as I, type ElementsOptions as J, type KitchenOrderItem as K, LinkService as L, MESSAGE_TYPES as M, type ElementOptions as N, OrderQueries as O, type PaymentErrorDetails as P, type QuoteCompositeSelectionInput as Q, type RefreshQuoteInput as R, type SearchOptions as S, type TableInfo as T, type UpdateProfileInput as U, type ElementType as V, type ElementEventType as W, type CheckoutMode as X, type CheckoutOrderType as Y, type CheckoutPaymentMethod as Z, type CheckoutStep as _, type PaymentResponse as a, type VariantAxisSelection as a$, type CheckoutResult as a0, type MobileMoneyProvider as a1, type DeviceType as a2, type ContactType as a3, CHECKOUT_MODE as a4, ORDER_TYPE as a5, PAYMENT_METHOD as a6, CHECKOUT_STEP as a7, PAYMENT_STATE as a8, PICKUP_TIME_TYPE as a9, isOk as aA, isErr as aB, mapResult as aC, mapError as aD, flatMap as aE, getOrElse as aF, unwrap as aG, toNullable as aH, fromPromise as aI, tryCatch as aJ, combine as aK, combineObject as aL, type ProductType as aM, type InventoryType as aN, type VariantStrategy as aO, type DigitalProductType as aP, type DepositType as aQ, type SalesChannel as aR, type Product as aS, type ProductWithDetails as aT, type ProductVariant as aU, type VariantDisplayAttribute as aV, type VariantAxis as aW, type VariantAxisWithValues as aX, type VariantAxisValue as aY, type ProductVariantValue as aZ, type VariantLocationAvailability as a_, MOBILE_MONEY_PROVIDER as aa, AUTHORIZATION_TYPE as ab, DEVICE_TYPE as ac, CONTACT_TYPE as ad, LINK_QUERY as ae, LINK_MUTATION as af, AUTH_MUTATION as ag, CHECKOUT_MUTATION as ah, PAYMENT_MUTATION as ai, ORDER_MUTATION as aj, DEFAULT_CURRENCY as ak, DEFAULT_COUNTRY as al, type Money as am, type Currency as an, type PaginationParams as ao, type Pagination as ap, ErrorCode as aq, type ErrorCodeType as ar, CimplifyError as as, isCimplifyError as at, isRetryableError as au, type Result as av, type Ok as aw, type Err as ax, ok as ay, err as az, type PaymentStatusResponse as b, type DisplayAddOnOption as b$, type AddOn as b0, type AddOnWithOptions as b1, type AddOnOption as b2, type AddOnOptionPrice as b3, type ProductAddOn as b4, type Category as b5, type CategorySummary as b6, type Collection as b7, type CollectionSummary as b8, type CollectionProduct as b9, type AdjustmentType as bA, type PriceAdjustment as bB, type TaxPathComponent as bC, type PricePathTaxInfo as bD, type PriceDecisionPath as bE, type ChosenPrice as bF, type BenefitType as bG, type AppliedDiscount as bH, type DiscountBreakdown as bI, type DiscountDetails as bJ, type SelectedAddOnOption as bK, type AddOnDetails as bL, type CartAddOn as bM, type VariantDetails as bN, type BundleSelectionInput as bO, type BundleStoredSelection as bP, type BundleSelectionData as bQ, type CompositeStoredSelection as bR, type CompositePriceBreakdown as bS, type CompositeSelectionData as bT, type LineConfiguration as bU, type Cart as bV, type CartItem as bW, type CartTotals as bX, type DisplayCart as bY, type DisplayCartItem as bZ, type DisplayAddOn as b_, type BundlePriceType as ba, type Bundle as bb, type BundleSummary as bc, type BundleProduct as bd, type BundleWithDetails as be, type BundleComponentData as bf, type BundleComponentInfo as bg, type CompositePricingMode as bh, type GroupPricingBehavior as bi, type ComponentSourceType as bj, type Composite as bk, type CompositeWithDetails as bl, type ComponentGroup as bm, type ComponentGroupWithComponents as bn, type CompositeComponent as bo, type ComponentSelectionInput as bp, type CompositePriceResult as bq, type ComponentPriceBreakdown as br, type PriceEntryType as bs, type Price as bt, type LocationProductPrice as bu, type ProductAvailability as bv, type ProductTimeProfile as bw, type CartStatus as bx, type CartChannel as by, type PriceSource as bz, createCimplifyClient as c, type Payment as c$, type UICartBusiness as c0, type UICartLocation as c1, type UICartCustomer as c2, type UICartPricing as c3, type AddOnOptionDetails as c4, type AddOnGroupDetails as c5, type VariantDetailsDTO as c6, type CartItemDetails as c7, type UICart as c8, type UICartResponse as c9, type CheckoutInput as cA, type UpdateOrderStatusInput as cB, type CancelOrderInput as cC, type RefundOrderInput as cD, type ServiceStatus as cE, type StaffRole as cF, type ReminderMethod as cG, type CustomerServicePreferences as cH, type BufferTimes as cI, type ReminderSettings as cJ, type CancellationPolicy as cK, type ServiceNotes as cL, type PricingOverrides as cM, type SchedulingMetadata as cN, type StaffAssignment as cO, type ResourceAssignment as cP, type SchedulingResult as cQ, type DepositResult as cR, type ServiceScheduleRequest as cS, type StaffScheduleItem as cT, type LocationAppointment as cU, type PaymentStatus as cV, type PaymentProvider as cW, type PaymentMethodType as cX, type AuthorizationType as cY, type PaymentProcessingState as cZ, type PaymentMethod as c_, type AddToCartInput as ca, type UpdateCartItemInput as cb, type CartSummary as cc, type OrderStatus as cd, type PaymentState as ce, type OrderChannel as cf, type LineType as cg, type OrderLineState as ch, type OrderLineStatus as ci, type FulfillmentType as cj, type FulfillmentStatus as ck, type FulfillmentLink as cl, type OrderFulfillmentSummary as cm, type FeeBearerType as cn, type AmountToPay as co, type LineItem as cp, type Order as cq, type OrderHistory as cr, type OrderGroupPaymentState as cs, type OrderGroup as ct, type OrderGroupPayment as cu, type OrderSplitDetail as cv, type OrderGroupPaymentSummary as cw, type OrderGroupDetails as cx, type OrderPaymentEvent as cy, type OrderFilter as cz, type CimplifyConfig as d, type CreateMobileMoneyInput as d$, type InitializePaymentResult as d0, type SubmitAuthorizationInput as d1, type BusinessType as d2, type BusinessPreferences as d3, type Business as d4, type LocationTaxBehavior as d5, type LocationTaxOverrides as d6, type Location as d7, type TimeRange as d8, type TimeRanges as d9, type DayAvailability as dA, type BookingStatus as dB, type Booking as dC, type BookingWithDetails as dD, type GetAvailableSlotsInput as dE, type CheckSlotAvailabilityInput as dF, type RescheduleBookingInput as dG, type CancelBookingInput as dH, type ServiceAvailabilityParams as dI, type ServiceAvailabilityResult as dJ, type StockOwnershipType as dK, type StockStatus as dL, type Stock as dM, type StockLevel as dN, type ProductStock as dO, type VariantStock as dP, type LocationStock as dQ, type AvailabilityCheck as dR, type AvailabilityResult as dS, type InventorySummary as dT, type Customer as dU, type CustomerAddress as dV, type CustomerMobileMoney as dW, type CustomerLinkPreferences as dX, type LinkData as dY, type CreateAddressInput as dZ, type UpdateAddressInput as d_, type LocationTimeProfile as da, type Table as db, type Room as dc, type ServiceCharge as dd, type StorefrontBootstrap as de, type BusinessWithLocations as df, type LocationWithDetails as dg, type BusinessSettings as dh, type BusinessHours as di, type CategoryInfo as dj, type ServiceAvailabilityRule as dk, type ServiceAvailabilityException as dl, type StaffAvailabilityRule as dm, type StaffAvailabilityException as dn, type ResourceAvailabilityRule as dp, type ResourceAvailabilityException as dq, type StaffBookingProfile as dr, type ServiceStaffRequirement as ds, type BookingRequirementOverride as dt, type ResourceType as du, type Service as dv, type ServiceWithStaff as dw, type Staff as dx, type TimeSlot as dy, type AvailableSlot as dz, CatalogueQueries as e, type EnrollmentData as e0, type AddressData as e1, type MobileMoneyData as e2, type EnrollAndLinkOrderInput as e3, type LinkStatusResult as e4, type LinkEnrollResult as e5, type EnrollAndLinkOrderResult as e6, type LinkSession as e7, type RevokeSessionResult as e8, type RevokeAllSessionsResult as e9, type ElementEventHandler as eA, type AdSlot as eB, type AdPosition as eC, type AdTheme as eD, type AdConfig as eE, type AdCreative as eF, type AdContextValue as eG, type RequestOtpInput as ea, type VerifyOtpInput as eb, type AuthResponse as ec, type PickupTimeType as ed, type PickupTime as ee, type CheckoutAddressInfo as ef, type MobileMoneyDetails as eg, type CheckoutCustomerInfo as eh, type FxQuoteRequest as ei, type FxQuote as ej, type FxRateResponse as ek, type RequestContext as el, type RequestStartEvent as em, type RequestSuccessEvent as en, type RequestErrorEvent as eo, type RetryEvent as ep, type SessionChangeEvent as eq, type ObservabilityHooks as er, type ElementAppearance as es, type AddressInfo as et, type PaymentMethodInfo as eu, type AuthenticatedData as ev, type ElementsCheckoutData as ew, type ElementsCheckoutResult as ex, type ParentToIframeMessage as ey, type IframeToParentMessage as ez, type QuoteBundleSelectionInput as f, type QuoteStatus as g, type QuoteDynamicBuckets as h, type QuoteUiMessage as i, type PriceQuote as j, type RefreshQuoteResult as k, CartOperations as l, CheckoutService as m, generateIdempotencyKey as n, type GetOrdersOptions as o, AuthService as p, type AuthStatus as q, type OtpResult as r, type ChangePasswordInput as s, SchedulingService as t, LiteService as u, FxService as v, type LiteBootstrap as w, type KitchenOrderResult as x, CimplifyElements as y, CimplifyElement as z };
|