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