@cimplify/sdk 0.3.5 → 0.4.0

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