@cimplify/sdk 0.35.0 → 0.37.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,915 @@
1
+ import { Hono } from 'hono';
2
+
3
+ interface Clock {
4
+ now(): Date;
5
+ nowMs(): number;
6
+ iso(): string;
7
+ advance(ms: number): void;
8
+ freeze(at?: Date): void;
9
+ unfreeze(): void;
10
+ schedule(at: Date | number, fn: () => void): void;
11
+ }
12
+
13
+ interface IdGen {
14
+ ulid(): string;
15
+ prefixed(prefix: string): string;
16
+ cart(): string;
17
+ cartItem(): string;
18
+ order(): string;
19
+ orderNumber(): string;
20
+ business(): string;
21
+ product(): string;
22
+ variant(): string;
23
+ category(): string;
24
+ collection(): string;
25
+ bundle(): string;
26
+ composite(): string;
27
+ session(): string;
28
+ customer(): string;
29
+ service(): string;
30
+ booking(): string;
31
+ subscription(): string;
32
+ upload(): string;
33
+ conversation(): string;
34
+ message(): string;
35
+ quote(): string;
36
+ fxQuote(): string;
37
+ payment(): string;
38
+ raw(prefix: string): string;
39
+ }
40
+
41
+ type MockEventType = "cart.updated" | "cart.cleared" | "order.created" | "order.payment.captured" | "order.payment.failed" | "order.cancelled" | "order.confirmed" | "subscription.created" | "subscription.cancelled" | "subscription.paused" | "subscription.resumed" | "subscription.renewed" | "booking.created" | "booking.cancelled" | "booking.rescheduled" | "support.message.sent" | "support.message.received" | "auth.session.started" | "auth.session.ended" | "upload.confirmed";
42
+ interface MockEvent<T = unknown> {
43
+ id: string;
44
+ type: MockEventType;
45
+ occurred_at: string;
46
+ business_id?: string;
47
+ payload: T;
48
+ }
49
+ type Handler = (e: MockEvent) => void;
50
+ interface MockBus {
51
+ emit(type: MockEventType, payload: unknown, businessId?: string): MockEvent;
52
+ on(type: MockEventType | "*", handler: Handler): () => void;
53
+ history(limit?: number): MockEvent[];
54
+ clear(): void;
55
+ }
56
+
57
+ interface Store<T> {
58
+ get(id: string): T | undefined;
59
+ put(id: string, value: T): T;
60
+ delete(id: string): boolean;
61
+ list(filter?: (t: T) => boolean): T[];
62
+ values(): IterableIterator<T>;
63
+ size(): number;
64
+ reset(): void;
65
+ toJSON(): Record<string, T>;
66
+ loadJSON(data: Record<string, T>): void;
67
+ }
68
+
69
+ interface Session {
70
+ id: string;
71
+ token: string;
72
+ business_id: string;
73
+ customer_id?: string;
74
+ customer_name?: string;
75
+ customer_email?: string;
76
+ customer_phone?: string;
77
+ is_authenticated: boolean;
78
+ created_at: string;
79
+ expires_at: string;
80
+ }
81
+ interface OtpRequest {
82
+ id: string;
83
+ contact: string;
84
+ code: string;
85
+ expires_at: string;
86
+ attempts: number;
87
+ }
88
+ interface IdempotencyRecord {
89
+ key: string;
90
+ request_hash: string;
91
+ response: unknown;
92
+ status: number;
93
+ created_at: string;
94
+ expires_at: string;
95
+ }
96
+ interface MockBusiness {
97
+ id: string;
98
+ name: string;
99
+ handle: string;
100
+ business_type: string;
101
+ email: string;
102
+ default_currency: string;
103
+ default_phone?: string;
104
+ default_address?: string;
105
+ default_offers_table_service: boolean;
106
+ default_accepts_online_orders: boolean;
107
+ image?: string;
108
+ status: string;
109
+ created_at: string;
110
+ updated_at: string;
111
+ created_by: string;
112
+ preferences: Record<string, unknown>;
113
+ is_online_only: boolean;
114
+ enabled_payment_types: string[];
115
+ default_location_settings: Record<string, unknown>;
116
+ country_code?: string;
117
+ timezone?: string;
118
+ metadata?: Record<string, unknown>;
119
+ }
120
+ interface MockProduct {
121
+ id: string;
122
+ business_id: string;
123
+ name: string;
124
+ slug: string;
125
+ description?: string;
126
+ product_type: string;
127
+ base_price: string;
128
+ currency: string;
129
+ image?: string;
130
+ images: string[];
131
+ is_available: boolean;
132
+ category_ids: string[];
133
+ collection_ids: string[];
134
+ add_on_ids: string[];
135
+ variant_ids: string[];
136
+ metadata?: Record<string, unknown>;
137
+ created_at: string;
138
+ updated_at: string;
139
+ }
140
+ interface MockCategory {
141
+ id: string;
142
+ business_id: string;
143
+ name: string;
144
+ slug: string;
145
+ description?: string;
146
+ image?: string;
147
+ product_ids: string[];
148
+ display_order: number;
149
+ is_active: boolean;
150
+ created_at: string;
151
+ updated_at: string;
152
+ }
153
+ interface MockCollection {
154
+ id: string;
155
+ business_id: string;
156
+ name: string;
157
+ slug: string;
158
+ description?: string;
159
+ product_ids: string[];
160
+ is_active: boolean;
161
+ created_at: string;
162
+ updated_at: string;
163
+ }
164
+ interface MockCart {
165
+ id: string;
166
+ business_id: string;
167
+ session_id?: string;
168
+ customer_id?: string;
169
+ customer_name?: string;
170
+ customer_email?: string;
171
+ customer_phone?: string;
172
+ customer_address?: string;
173
+ items: MockCartItem[];
174
+ subtotal: string;
175
+ tax_amount: string;
176
+ service_charge: string;
177
+ total_discounts: string;
178
+ total_price: string;
179
+ delivery_fee: string;
180
+ total_items: number;
181
+ currency: string;
182
+ applied_discount_ids: string[];
183
+ applied_discount_codes: string[];
184
+ status: string;
185
+ source: string;
186
+ channel: string;
187
+ created_at: string;
188
+ updated_at: string;
189
+ expires_at: string;
190
+ }
191
+ interface MockCartItem {
192
+ id: string;
193
+ cart_id: string;
194
+ item_id: string;
195
+ variant_id?: string;
196
+ line_key: string;
197
+ quantity: number;
198
+ price: string;
199
+ add_ons_price: string;
200
+ configuration: {
201
+ type: string;
202
+ [k: string]: unknown;
203
+ };
204
+ applied_discount_ids: string[];
205
+ item_discount_amount: string;
206
+ created_at: string;
207
+ updated_at: string;
208
+ }
209
+ interface MockOrder {
210
+ id: string;
211
+ business_id: string;
212
+ user_friendly_id: string;
213
+ channel: string;
214
+ status: string;
215
+ payment_state: string;
216
+ order_type: string;
217
+ customer_id?: string;
218
+ customer_name?: string;
219
+ customer_email?: string;
220
+ customer_phone?: string;
221
+ delivery_address?: string;
222
+ delivery_fee: string;
223
+ subtotal: string;
224
+ tax_amount: string;
225
+ service_charge: string;
226
+ total_discounts: string;
227
+ total_price: string;
228
+ currency: string;
229
+ items: unknown[];
230
+ applied_discount_ids: string[];
231
+ applied_discount_codes: string[];
232
+ payment_reference?: string;
233
+ pickup_time?: string;
234
+ metadata?: Record<string, unknown>;
235
+ created_at: string;
236
+ updated_at: string;
237
+ }
238
+ interface MockSubscription {
239
+ id: string;
240
+ business_id: string;
241
+ customer_id: string;
242
+ product_id: string;
243
+ status: "active" | "paused" | "cancelled" | "expired";
244
+ next_renewal_at: string;
245
+ paused_at?: string;
246
+ cancelled_at?: string;
247
+ current_period_start: string;
248
+ current_period_end: string;
249
+ created_at: string;
250
+ updated_at: string;
251
+ }
252
+ interface MockBooking {
253
+ id: string;
254
+ business_id: string;
255
+ customer_id?: string;
256
+ service_id: string;
257
+ service_name: string;
258
+ start_time: string;
259
+ end_time: string;
260
+ status: "confirmed" | "cancelled" | "completed" | "rescheduled";
261
+ participant_count: number;
262
+ confirmation_code: string;
263
+ order_id?: string;
264
+ created_at: string;
265
+ updated_at: string;
266
+ }
267
+ interface MockService {
268
+ id: string;
269
+ business_id: string;
270
+ name: string;
271
+ description?: string;
272
+ duration_minutes: number;
273
+ price: string;
274
+ is_available: boolean;
275
+ }
276
+ interface MockUpload {
277
+ id: string;
278
+ business_id: string;
279
+ filename: string;
280
+ mime_type: string;
281
+ size_bytes: number;
282
+ upload_url: string;
283
+ public_url: string;
284
+ status: "pending" | "confirmed";
285
+ created_at: string;
286
+ }
287
+ interface MockConversation {
288
+ id: string;
289
+ business_id: string;
290
+ customer_id?: string;
291
+ messages: MockChatMessage[];
292
+ created_at: string;
293
+ updated_at: string;
294
+ }
295
+ interface MockChatMessage {
296
+ id: string;
297
+ conversation_id: string;
298
+ sender_type: "customer" | "agent" | "system";
299
+ content_type: "text" | "image" | "file";
300
+ content: string;
301
+ created_at: string;
302
+ }
303
+ interface MockQuote {
304
+ id: string;
305
+ business_id: string;
306
+ product_id: string;
307
+ status: "fresh" | "stale" | "expired";
308
+ total_price: string;
309
+ expires_at: string;
310
+ created_at: string;
311
+ }
312
+ interface MockFxLock {
313
+ id: string;
314
+ base_currency: string;
315
+ pay_currency: string;
316
+ rate: number;
317
+ base_amount: string;
318
+ pay_amount: string;
319
+ expires_at: string;
320
+ created_at: string;
321
+ }
322
+ interface MockActivityEvent {
323
+ id: string;
324
+ business_id: string;
325
+ session_id?: string;
326
+ event_type: string;
327
+ payload: Record<string, unknown>;
328
+ created_at: string;
329
+ }
330
+ interface MockAddOn {
331
+ id: string;
332
+ business_id: string;
333
+ name: string;
334
+ is_multiple_allowed: boolean;
335
+ is_required: boolean;
336
+ is_mutually_exclusive: boolean;
337
+ min_selections?: number;
338
+ max_selections?: number;
339
+ created_at: string;
340
+ updated_at: string;
341
+ options: MockAddOnOption[];
342
+ }
343
+ interface MockAddOnOption {
344
+ id: string;
345
+ add_on_id: string;
346
+ business_id: string;
347
+ name: string;
348
+ default_price?: string;
349
+ description?: string;
350
+ is_required: boolean;
351
+ is_mutually_exclusive: boolean;
352
+ created_at: string;
353
+ updated_at: string;
354
+ }
355
+ interface MockProductAddOnLink {
356
+ product_id: string;
357
+ add_on_id: string;
358
+ }
359
+ interface MockVariantAxis {
360
+ id: string;
361
+ business_id: string;
362
+ product_id: string;
363
+ name: string;
364
+ display_order: number;
365
+ affects_recipe: boolean;
366
+ values: MockVariantAxisValue[];
367
+ created_at: string;
368
+ updated_at: string;
369
+ }
370
+ interface MockVariantAxisValue {
371
+ id: string;
372
+ business_id: string;
373
+ axis_id: string;
374
+ name: string;
375
+ display_order: number;
376
+ color_hex?: string;
377
+ created_at: string;
378
+ updated_at: string;
379
+ }
380
+ interface MockVariant {
381
+ id: string;
382
+ product_id: string;
383
+ business_id: string;
384
+ name: string;
385
+ sku?: string;
386
+ price_adjustment: string;
387
+ component_multiplier: string;
388
+ is_default: boolean;
389
+ is_active: boolean;
390
+ axis_value_ids: string[];
391
+ created_at: string;
392
+ updated_at: string;
393
+ }
394
+ interface MockBundle {
395
+ id: string;
396
+ business_id: string;
397
+ product_id: string;
398
+ name: string;
399
+ slug: string;
400
+ description?: string;
401
+ pricing_type: "fixed" | "percentage_discount" | "fixed_discount";
402
+ bundle_price?: string;
403
+ discount_value?: string;
404
+ product_ids: string[];
405
+ created_at: string;
406
+ updated_at: string;
407
+ }
408
+ interface MockComposite {
409
+ id: string;
410
+ business_id: string;
411
+ product_id: string;
412
+ base_price: string;
413
+ pricing_mode: "additive" | "highest_per_group" | "highest_overall" | "tiered";
414
+ min_order_quantity?: number;
415
+ max_order_quantity?: number;
416
+ groups: {
417
+ id: string;
418
+ name: string;
419
+ min: number;
420
+ max: number;
421
+ component_ids: string[];
422
+ }[];
423
+ created_at: string;
424
+ updated_at: string;
425
+ }
426
+ interface MockTag {
427
+ id: string;
428
+ business_id: string;
429
+ name: string;
430
+ slug: string;
431
+ color?: string;
432
+ icon?: string;
433
+ description?: string;
434
+ tag_group?: string;
435
+ sort_order: number;
436
+ usage_count: number;
437
+ created_at: string;
438
+ updated_at: string;
439
+ }
440
+ interface MockTaxonomy {
441
+ id: string;
442
+ business_id: string;
443
+ name: string;
444
+ slug: string;
445
+ parent_id?: string;
446
+ path: string[];
447
+ attribute_template_ids: string[];
448
+ created_at: string;
449
+ updated_at: string;
450
+ }
451
+ interface MockKnowledgeArticle {
452
+ id: string;
453
+ business_id: string;
454
+ title: string;
455
+ slug: string;
456
+ content: string;
457
+ category?: string;
458
+ tags: string[];
459
+ created_at: string;
460
+ updated_at: string;
461
+ }
462
+ interface MockAttributeDef {
463
+ id: string;
464
+ business_id: string;
465
+ namespace: string;
466
+ name: string;
467
+ slug: string;
468
+ description?: string;
469
+ attribute_type: string;
470
+ options?: string[];
471
+ unit?: string;
472
+ is_required: boolean;
473
+ is_filterable: boolean;
474
+ visibility: "admin_only" | "storefront_read" | "public";
475
+ display_order: number;
476
+ applies_to: "product" | "variant" | "both" | "category" | "collection" | "all";
477
+ created_at: string;
478
+ updated_at: string;
479
+ }
480
+ interface StateRegistry {
481
+ businesses: Store<MockBusiness>;
482
+ products: Store<MockProduct>;
483
+ categories: Store<MockCategory>;
484
+ collections: Store<MockCollection>;
485
+ carts: Store<MockCart>;
486
+ orders: Store<MockOrder>;
487
+ subscriptions: Store<MockSubscription>;
488
+ bookings: Store<MockBooking>;
489
+ services: Store<MockService>;
490
+ sessions: Store<Session>;
491
+ otps: Store<OtpRequest>;
492
+ idempotency: Store<IdempotencyRecord>;
493
+ uploads: Store<MockUpload>;
494
+ conversations: Store<MockConversation>;
495
+ quotes: Store<MockQuote>;
496
+ fxLocks: Store<MockFxLock>;
497
+ activity: Store<MockActivityEvent>;
498
+ addOns: Store<MockAddOn>;
499
+ productAddOns: Store<MockProductAddOnLink>;
500
+ variantAxes: Store<MockVariantAxis>;
501
+ variants: Store<MockVariant>;
502
+ bundles: Store<MockBundle>;
503
+ composites: Store<MockComposite>;
504
+ tags: Store<MockTag>;
505
+ taxonomies: Store<MockTaxonomy>;
506
+ knowledgeArticles: Store<MockKnowledgeArticle>;
507
+ attributeDefs: Store<MockAttributeDef>;
508
+ }
509
+
510
+ interface AuthService {
511
+ resolveSession(token: string | null): Session | null;
512
+ ensureSession(token: string | null): Session;
513
+ requestOtp(contact: string): {
514
+ otp_id: string;
515
+ expires_at: string;
516
+ code_hint?: string;
517
+ };
518
+ verifyOtp(contact: string, code: string): Session;
519
+ logout(token: string): void;
520
+ updateProfile(token: string, profile: {
521
+ name?: string;
522
+ email?: string;
523
+ phone?: string;
524
+ }): Session;
525
+ status(token: string | null): {
526
+ is_authenticated: boolean;
527
+ session?: Session;
528
+ };
529
+ }
530
+
531
+ interface BusinessService {
532
+ primary(): MockBusiness;
533
+ byHandle(handle: string): MockBusiness;
534
+ byDomain(domain: string): MockBusiness;
535
+ settings(businessId: string): unknown;
536
+ locations(businessId: string): unknown[];
537
+ hours(businessId: string): unknown[];
538
+ }
539
+
540
+ interface CatalogueService {
541
+ snapshot(businessId: string): {
542
+ categories: unknown[];
543
+ products: unknown[];
544
+ add_ons: unknown[];
545
+ is_complete: boolean;
546
+ total_available: number;
547
+ };
548
+ listProducts(businessId: string, opts?: {
549
+ page?: number;
550
+ limit?: number;
551
+ category_id?: string;
552
+ collection_id?: string;
553
+ }): unknown;
554
+ getProduct(productId: string): unknown;
555
+ getProductVariants(productId: string): MockVariant[];
556
+ getProductVariantAxes(productId: string): MockVariantAxis[];
557
+ getProductVariantById(productId: string, variantId: string): MockVariant;
558
+ findProductVariant(productId: string, properties: Record<string, string>): MockVariant | null;
559
+ getProductAddOns(productId: string): MockAddOn[];
560
+ getProductAttributes(productId: string): MockAttributeDef[];
561
+ listCategories(businessId: string): MockCategory[];
562
+ getCategory(id: string): MockCategory;
563
+ getCategoryProducts(id: string): unknown[];
564
+ getCategoryAttributes(id: string): MockAttributeDef[];
565
+ listCollections(businessId: string): MockCollection[];
566
+ getCollection(id: string): MockCollection;
567
+ getCollectionProducts(id: string): unknown[];
568
+ getCollectionAttributes(id: string): MockAttributeDef[];
569
+ listBundles(businessId: string): MockBundle[];
570
+ getBundle(id: string): MockBundle;
571
+ listComposites(businessId: string): MockComposite[];
572
+ getComposite(id: string): MockComposite;
573
+ getCompositeByProduct(productId: string): MockComposite | null;
574
+ calculateCompositePrice(id: string, body: unknown): unknown;
575
+ listTaxonomies(businessId: string): MockTaxonomy[];
576
+ searchTaxonomies(businessId: string, q: string): MockTaxonomy[];
577
+ getTaxonomy(id: string): MockTaxonomy;
578
+ getTaxonomyAttributes(id: string): MockAttributeDef[];
579
+ getTaxonomyPath(id: string): string[];
580
+ listAttributes(businessId: string): MockAttributeDef[];
581
+ listTags(businessId: string): MockTag[];
582
+ listKnowledgeArticles(businessId: string): MockKnowledgeArticle[];
583
+ searchKnowledgeBase(businessId: string, q: string): MockKnowledgeArticle[];
584
+ listPropertyFacets(businessId: string): unknown[];
585
+ listDeals(businessId: string): unknown[];
586
+ listOnSale(businessId: string): unknown[];
587
+ validateDiscount(code: string, businessId: string): unknown;
588
+ getProductDeals(productId: string): unknown[];
589
+ getCategoryDeals(id: string): unknown[];
590
+ getCollectionDeals(id: string): unknown[];
591
+ createQuote(businessId: string, body: unknown): unknown;
592
+ getQuote(id: string): unknown;
593
+ refreshQuote(id: string): unknown;
594
+ }
595
+
596
+ interface AddItemInput {
597
+ item_id: string;
598
+ variant_id?: string;
599
+ quantity: number;
600
+ add_on_options?: string[];
601
+ bundle_selections?: BundleSelectionInput[];
602
+ composite_selections?: ComponentSelectionInput[];
603
+ }
604
+ interface BundleSelectionInput {
605
+ component_id: string;
606
+ variant_id?: string;
607
+ quantity: number;
608
+ scheduled_start?: string;
609
+ scheduled_end?: string;
610
+ }
611
+ interface ComponentSelectionInput {
612
+ component_id?: string;
613
+ source_product_id?: string;
614
+ source_stock_id?: string;
615
+ source_type?: "product" | "stock" | "add_on" | "standalone";
616
+ quantity?: number;
617
+ }
618
+
619
+ interface CartService {
620
+ get(session: Session): MockCart;
621
+ getItems(session: Session): MockCartItem[];
622
+ getCount(session: Session): number;
623
+ getTotal(session: Session): string;
624
+ addItem(session: Session, body: AddItemInput): unknown;
625
+ updateQuantity(session: Session, cartItemId: string, quantity: number): unknown;
626
+ removeItem(session: Session, cartItemId: string): unknown;
627
+ clear(session: Session): unknown;
628
+ applyCoupon(session: Session, code: string): unknown;
629
+ removeCoupon(session: Session): unknown;
630
+ toUICart(cart: MockCart): unknown;
631
+ resolveCart(session: Session): MockCart;
632
+ }
633
+
634
+ interface CheckoutService {
635
+ process(session: Session, body: CheckoutBody): CheckoutResult;
636
+ authorize(body: {
637
+ order_id: string;
638
+ otp?: string;
639
+ pin?: string;
640
+ }): {
641
+ status: string;
642
+ order_id: string;
643
+ };
644
+ }
645
+ interface CheckoutBody {
646
+ cart_id: string;
647
+ location_id?: string;
648
+ customer: {
649
+ name: string;
650
+ email: string;
651
+ phone: string;
652
+ notes?: string;
653
+ save_details?: boolean;
654
+ };
655
+ order_type: string;
656
+ address_info?: Record<string, unknown>;
657
+ payment_method: string;
658
+ mobile_money_details?: {
659
+ phone_number: string;
660
+ provider: string;
661
+ };
662
+ special_instructions?: string;
663
+ metadata?: Record<string, unknown>;
664
+ pay_currency?: string;
665
+ fx_quote_id?: string;
666
+ }
667
+ interface CheckoutResult {
668
+ order_id: string;
669
+ order_number: string;
670
+ payment_status: string;
671
+ payment_reference?: string;
672
+ requires_authorization: boolean;
673
+ next_action: {
674
+ type: "none";
675
+ } | {
676
+ type: "redirect";
677
+ authorization_url: string;
678
+ } | {
679
+ type: "authorization";
680
+ authorization_type: string;
681
+ display_text?: string;
682
+ };
683
+ provider?: string;
684
+ authorization_url?: string;
685
+ display_text?: string;
686
+ }
687
+
688
+ interface OrderService {
689
+ list(session: Session, opts?: {
690
+ limit?: number;
691
+ status?: string;
692
+ }): {
693
+ items: MockOrder[];
694
+ pagination: unknown;
695
+ };
696
+ get(orderId: string): MockOrder;
697
+ getPaymentStatus(orderId: string): {
698
+ order_id: string;
699
+ payment_state: string;
700
+ status: string;
701
+ };
702
+ cancel(orderId: string, reason?: string): MockOrder;
703
+ updateCustomer(orderId: string, customer: {
704
+ name?: string;
705
+ email?: string;
706
+ phone?: string;
707
+ }): MockOrder;
708
+ verifyPayment(orderId: string): {
709
+ order_id: string;
710
+ payment_state: string;
711
+ status: string;
712
+ verified: boolean;
713
+ };
714
+ }
715
+
716
+ interface SubscriptionService {
717
+ list(session: Session): MockSubscription[];
718
+ get(id: string): MockSubscription;
719
+ cancel(id: string): MockSubscription;
720
+ pause(id: string): MockSubscription;
721
+ resume(id: string): MockSubscription;
722
+ skipNext(id: string): MockSubscription;
723
+ }
724
+
725
+ interface SchedulingService {
726
+ listServices(businessId: string): MockService[];
727
+ getService(id: string): MockService;
728
+ getSlots(serviceId: string, opts?: {
729
+ date?: string;
730
+ }): unknown[];
731
+ checkSlot(serviceId: string, start: string, end: string): {
732
+ is_available: boolean;
733
+ };
734
+ getServiceAvailability(serviceId: string): unknown;
735
+ getCustomerBookings(session: Session): unknown[];
736
+ getBooking(id: string): MockBooking;
737
+ cancelBooking(id: string, reason?: string): MockBooking;
738
+ rescheduleBooking(body: {
739
+ booking_id: string;
740
+ new_start_time: string;
741
+ new_end_time: string;
742
+ }): MockBooking;
743
+ }
744
+
745
+ interface InventoryService {
746
+ productStock(productId: string): {
747
+ product_id: string;
748
+ quantity: number;
749
+ available: boolean;
750
+ };
751
+ variantStock(variantId: string): {
752
+ variant_id: string;
753
+ quantity: number;
754
+ available: boolean;
755
+ };
756
+ productAvailability(productId: string): {
757
+ product_id: string;
758
+ is_available: boolean;
759
+ };
760
+ variantAvailability(variantId: string): {
761
+ variant_id: string;
762
+ is_available: boolean;
763
+ };
764
+ }
765
+
766
+ interface FxService {
767
+ getRate(from: string, to: string): {
768
+ from: string;
769
+ to: string;
770
+ rate: number;
771
+ updated_at: string;
772
+ };
773
+ lockQuote(body: {
774
+ base_currency: string;
775
+ pay_currency: string;
776
+ base_amount: string;
777
+ }): MockFxLock;
778
+ }
779
+
780
+ interface PlacesService {
781
+ autocomplete(body: {
782
+ query: string;
783
+ country?: string;
784
+ }): {
785
+ predictions: unknown[];
786
+ };
787
+ details(body: {
788
+ place_id: string;
789
+ }): unknown;
790
+ }
791
+
792
+ interface DeliveryService {
793
+ getFee(opts: {
794
+ lat?: number;
795
+ lng?: number;
796
+ address?: string;
797
+ cart_total?: string;
798
+ }): {
799
+ fee: string;
800
+ currency: string;
801
+ estimated_minutes: number;
802
+ provider: string;
803
+ quotes: unknown[];
804
+ };
805
+ }
806
+
807
+ interface ActivityService {
808
+ recordEvents(businessId: string, sessionId: string | undefined, events: {
809
+ event_type: string;
810
+ payload?: Record<string, unknown>;
811
+ }[]): {
812
+ recorded: number;
813
+ };
814
+ getState(businessId: string, sessionId: string | undefined): unknown;
815
+ getRecommendations(businessId: string): unknown;
816
+ dismissMessage(messageId: string): {
817
+ dismissed: boolean;
818
+ message_id: string;
819
+ };
820
+ }
821
+
822
+ interface SupportService {
823
+ openConversation(businessId: string, customerId?: string): MockConversation;
824
+ sendMessage(conversationId: string, body: {
825
+ content: string;
826
+ content_type?: string;
827
+ sender_type?: "customer" | "agent";
828
+ }): MockChatMessage;
829
+ listMessages(conversationId: string, opts?: {
830
+ limit?: number;
831
+ }): MockChatMessage[];
832
+ }
833
+
834
+ interface UploadService {
835
+ init(businessId: string, body: {
836
+ filename: string;
837
+ mime_type: string;
838
+ size_bytes: number;
839
+ }): MockUpload;
840
+ confirm(body: {
841
+ upload_id: string;
842
+ }): MockUpload;
843
+ }
844
+
845
+ interface LiteService {
846
+ bootstrap(businessId: string): unknown;
847
+ getTable(tableId: string): unknown;
848
+ getMenu(businessId: string): unknown;
849
+ getMenuCategory(categoryId: string): unknown;
850
+ }
851
+
852
+ type SeedName = "default" | "empty" | "reesa-storefront" | "restaurant" | "retail" | "services" | "grocery";
853
+ declare function applySeed(registry: StateRegistry, name: SeedName): {
854
+ businessId: string;
855
+ };
856
+
857
+ interface MockOptions {
858
+ seed?: SeedName;
859
+ authMode?: "permissive" | "strict";
860
+ defaultOtp?: string;
861
+ rngSeed?: number;
862
+ frozenAt?: Date;
863
+ }
864
+ interface ChaosState {
865
+ failNext: {
866
+ route: string;
867
+ count: number;
868
+ status: number;
869
+ code?: string;
870
+ }[];
871
+ latencyByRoute: {
872
+ route: string;
873
+ ms: number;
874
+ }[];
875
+ webhookUrl?: string;
876
+ webhookSecret?: string;
877
+ }
878
+ interface Deps {
879
+ clock: Clock;
880
+ ids: IdGen;
881
+ bus: MockBus;
882
+ registry: StateRegistry;
883
+ auth: AuthService;
884
+ business: BusinessService;
885
+ catalogue: CatalogueService;
886
+ cart: CartService;
887
+ checkout: CheckoutService;
888
+ orders: OrderService;
889
+ subscriptions: SubscriptionService;
890
+ scheduling: SchedulingService;
891
+ inventory: InventoryService;
892
+ fx: FxService;
893
+ places: PlacesService;
894
+ delivery: DeliveryService;
895
+ activity: ActivityService;
896
+ support: SupportService;
897
+ uploads: UploadService;
898
+ lite: LiteService;
899
+ defaultBusinessId: string;
900
+ chaos: ChaosState;
901
+ resetAll: (seed?: SeedName) => string;
902
+ }
903
+ declare function createDeps(options?: MockOptions): Deps;
904
+
905
+ interface CreateAppOptions extends MockOptions {
906
+ cors?: string[] | "*";
907
+ }
908
+ interface AppHandle {
909
+ app: Hono;
910
+ deps: Deps;
911
+ request: (path: string, init?: RequestInit) => Promise<Response>;
912
+ }
913
+ declare function createMockApp(options?: CreateAppOptions): AppHandle;
914
+
915
+ export { type AppHandle as A, type CreateAppOptions as C, type Deps as D, type IdGen as I, type MockBus as M, type SeedName as S, type MockEvent as a, createDeps as b, createMockApp as c, type MockOptions as d, applySeed as e, type Session as f, type StateRegistry as g, type MockBusiness as h, type MockProduct as i, type MockCart as j, type MockOrder as k, type MockEventType as l, type Clock as m };