@cimplify/sdk 0.6.4 → 0.6.5

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