@cimplify/sdk 0.49.2 → 0.50.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.
@@ -1,1183 +0,0 @@
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
- declare const __money: unique symbol;
70
- type Money = number & {
71
- readonly [__money]: true;
72
- };
73
-
74
- type InputFieldType = "text" | "textarea" | "number" | "select" | "radio" | "checkbox" | "color" | "date" | "file" | "image" | "url" | "address" | "phone" | "email" | "date_time" | "time" | "signature" | "multi_select" | "date_range" | "location";
75
- interface InputFieldValidation {
76
- max_length?: number;
77
- min_length?: number;
78
- min_value?: number;
79
- max_value?: number;
80
- accepted_formats?: string[];
81
- max_size_mb?: number;
82
- pattern?: string;
83
- allowed_countries?: string[];
84
- max_selections?: number;
85
- }
86
- type SemanticKind = "allergen" | "dietary_preference" | "sensitivity" | "consent";
87
- interface ProductInputField {
88
- id: string;
89
- product_id: string;
90
- name: string;
91
- slug: string;
92
- field_type: InputFieldType;
93
- is_required: boolean;
94
- display_order: number;
95
- placeholder?: string;
96
- help_text?: string;
97
- validation?: InputFieldValidation;
98
- options?: string[];
99
- price_adjustment?: Money;
100
- semantic_kind?: SemanticKind;
101
- }
102
-
103
- interface Session {
104
- id: string;
105
- token: string;
106
- business_id: string;
107
- customer_id?: string;
108
- customer_name?: string;
109
- customer_email?: string;
110
- customer_phone?: string;
111
- is_authenticated: boolean;
112
- created_at: string;
113
- expires_at: string;
114
- }
115
- interface OtpRequest {
116
- id: string;
117
- contact: string;
118
- code: string;
119
- expires_at: string;
120
- attempts: number;
121
- }
122
- interface IdempotencyRecord {
123
- key: string;
124
- request_hash: string;
125
- response: unknown;
126
- status: number;
127
- created_at: string;
128
- expires_at: string;
129
- }
130
- interface MockBusiness {
131
- id: string;
132
- name: string;
133
- handle: string;
134
- business_type: string;
135
- email: string;
136
- default_currency: string;
137
- default_phone?: string;
138
- default_address?: string;
139
- default_offers_table_service: boolean;
140
- default_accepts_online_orders: boolean;
141
- image?: string;
142
- status: string;
143
- created_at: string;
144
- updated_at: string;
145
- created_by: string;
146
- preferences: Record<string, unknown>;
147
- is_online_only: boolean;
148
- enabled_payment_types: string[];
149
- default_location_settings: Record<string, unknown>;
150
- country_code?: string;
151
- timezone?: string;
152
- metadata?: Record<string, unknown>;
153
- }
154
- interface MockQuantityPricingTier {
155
- min_quantity: number;
156
- unit_price: string;
157
- }
158
- interface MockBillingPlan {
159
- id: string;
160
- name: string;
161
- interval: "day" | "week" | "month" | "year";
162
- interval_count: number;
163
- price: string;
164
- currency: string;
165
- trial_period_days?: number;
166
- }
167
- interface MockProduct {
168
- id: string;
169
- business_id: string;
170
- name: string;
171
- slug: string;
172
- description?: string;
173
- product_type: string;
174
- base_price: string;
175
- currency: string;
176
- image?: string;
177
- images: string[];
178
- is_available: boolean;
179
- category_ids: string[];
180
- collection_ids: string[];
181
- add_on_ids: string[];
182
- variant_ids: string[];
183
- tags?: string[];
184
- calories?: number;
185
- allergies?: string[];
186
- ingredients?: string[];
187
- pairings?: string[];
188
- is_signature?: boolean;
189
- is_new?: boolean;
190
- /** Override for the auto-derived render hint. */
191
- render_hint?: "food" | "physical" | "general";
192
- /** Display mode hint (card opens modal, page is a link). Storefronts can override. */
193
- display_mode?: "card" | "page";
194
- /** For digital products — how the SDK renders fulfilment UI. */
195
- digital_product_type?: "download" | "license" | "event_ticket" | "access_pass" | "gift_code";
196
- /** For wholesale products — quantity-pricing tiers. */
197
- quantity_pricing?: MockQuantityPricingTier[];
198
- /** For services — duration unit (drives Rental/Accommodation/Lease cards). */
199
- duration_unit?: "minutes" | "hours" | "days" | "nights" | "weeks" | "months" | "years";
200
- /** For schedule services — duration in minutes (presence implies non-subscription service). */
201
- duration_minutes?: number;
202
- /** For subscription services — billing plans. */
203
- billing_plans?: MockBillingPlan[];
204
- /**
205
- * Per-product customer input fields. Surfaced as ProductView.input_fields
206
- * on the wire so the SDK's product UIs can render the right input
207
- * controls (file upload for prescriptions, date for DOB, signature for
208
- * consent, etc.). Same shape the Rust backend already emits
209
- * (`src/salesman/models/view.rs::ProductView.input_fields`).
210
- */
211
- input_fields?: ProductInputField[];
212
- metadata?: Record<string, unknown>;
213
- created_at: string;
214
- updated_at: string;
215
- }
216
- interface MockCategory {
217
- id: string;
218
- business_id: string;
219
- name: string;
220
- slug: string;
221
- description?: string;
222
- image?: string;
223
- product_ids: string[];
224
- display_order: number;
225
- is_active: boolean;
226
- created_at: string;
227
- updated_at: string;
228
- }
229
- interface MockCollection {
230
- id: string;
231
- business_id: string;
232
- name: string;
233
- slug: string;
234
- description?: string;
235
- product_ids: string[];
236
- is_active: boolean;
237
- created_at: string;
238
- updated_at: string;
239
- }
240
- interface MockCart {
241
- id: string;
242
- business_id: string;
243
- session_id?: string;
244
- customer_id?: string;
245
- customer_name?: string;
246
- customer_email?: string;
247
- customer_phone?: string;
248
- customer_address?: string;
249
- items: MockCartItem[];
250
- subtotal: string;
251
- tax_amount: string;
252
- tax_rate?: string;
253
- service_charge: string;
254
- service_charge_rate?: string;
255
- total_discounts: string;
256
- total_price: string;
257
- delivery_fee: string;
258
- total_items: number;
259
- currency: string;
260
- applied_discount_ids: string[];
261
- applied_discount_codes: string[];
262
- status: string;
263
- source: string;
264
- channel: string;
265
- created_at: string;
266
- updated_at: string;
267
- expires_at: string;
268
- }
269
- interface MockCartItem {
270
- id: string;
271
- cart_id: string;
272
- item_id: string;
273
- variant_id?: string;
274
- line_key: string;
275
- quantity: number;
276
- price: string;
277
- add_ons_price: string;
278
- configuration: {
279
- type: string;
280
- [k: string]: unknown;
281
- };
282
- applied_discount_ids: string[];
283
- item_discount_amount: string;
284
- scheduled_start?: string;
285
- scheduled_end?: string;
286
- staff_id?: string;
287
- resource_id?: string;
288
- service_status?: "pending" | "confirmed" | "completed" | "cancelled";
289
- confirmation_code?: string;
290
- special_instructions?: string;
291
- customer_inputs?: {
292
- field_id: string;
293
- field_name?: string;
294
- field_type?: string;
295
- value: unknown;
296
- }[];
297
- billing_plan_id?: string;
298
- metadata?: Record<string, unknown>;
299
- created_at: string;
300
- updated_at: string;
301
- }
302
- interface MockOrder {
303
- id: string;
304
- business_id: string;
305
- user_friendly_id: string;
306
- channel: string;
307
- status: string;
308
- payment_state: string;
309
- order_type: string;
310
- customer_id?: string;
311
- customer_name?: string;
312
- customer_email?: string;
313
- customer_phone?: string;
314
- delivery_address?: string;
315
- delivery_fee: string;
316
- subtotal: string;
317
- tax_amount: string;
318
- service_charge: string;
319
- total_discounts: string;
320
- total_price: string;
321
- currency: string;
322
- items: unknown[];
323
- applied_discount_ids: string[];
324
- applied_discount_codes: string[];
325
- payment_reference?: string;
326
- pickup_time?: string;
327
- metadata?: Record<string, unknown>;
328
- created_at: string;
329
- updated_at: string;
330
- }
331
- interface MockSubscription {
332
- id: string;
333
- business_id: string;
334
- customer_id: string;
335
- product_id: string;
336
- status: "active" | "paused" | "cancelled" | "expired";
337
- next_renewal_at: string;
338
- paused_at?: string;
339
- cancelled_at?: string;
340
- current_period_start: string;
341
- current_period_end: string;
342
- created_at: string;
343
- updated_at: string;
344
- }
345
- interface MockBooking {
346
- id: string;
347
- business_id: string;
348
- customer_id?: string;
349
- service_id: string;
350
- service_name: string;
351
- start_time: string;
352
- end_time: string;
353
- status: "confirmed" | "cancelled" | "completed" | "rescheduled";
354
- participant_count: number;
355
- confirmation_code: string;
356
- order_id?: string;
357
- created_at: string;
358
- updated_at: string;
359
- }
360
- interface MockService {
361
- id: string;
362
- business_id: string;
363
- name: string;
364
- description?: string;
365
- duration_minutes: number;
366
- price: string;
367
- is_available: boolean;
368
- }
369
- interface MockUpload {
370
- id: string;
371
- business_id: string;
372
- filename: string;
373
- mime_type: string;
374
- size_bytes: number;
375
- upload_url: string;
376
- public_url: string;
377
- status: "pending" | "confirmed";
378
- created_at: string;
379
- }
380
- interface MockConversation {
381
- id: string;
382
- business_id: string;
383
- customer_id?: string;
384
- messages: MockChatMessage[];
385
- created_at: string;
386
- updated_at: string;
387
- }
388
- interface MockChatMessage {
389
- id: string;
390
- conversation_id: string;
391
- sender_type: "customer" | "agent" | "system";
392
- content_type: "text" | "image" | "file";
393
- content: string;
394
- created_at: string;
395
- }
396
- interface MockQuote {
397
- id: string;
398
- business_id: string;
399
- product_id: string;
400
- status: "fresh" | "stale" | "expired";
401
- total_price: string;
402
- expires_at: string;
403
- created_at: string;
404
- }
405
- interface MockFxLock {
406
- id: string;
407
- base_currency: string;
408
- pay_currency: string;
409
- rate: number;
410
- base_amount: string;
411
- pay_amount: string;
412
- expires_at: string;
413
- created_at: string;
414
- }
415
- interface MockActivityEvent {
416
- id: string;
417
- business_id: string;
418
- session_id?: string;
419
- event_type: string;
420
- payload: Record<string, unknown>;
421
- created_at: string;
422
- }
423
- interface MockAddOn {
424
- id: string;
425
- business_id: string;
426
- name: string;
427
- is_multiple_allowed: boolean;
428
- is_required: boolean;
429
- is_mutually_exclusive: boolean;
430
- min_selections?: number;
431
- max_selections?: number;
432
- created_at: string;
433
- updated_at: string;
434
- options: MockAddOnOption[];
435
- }
436
- interface MockAddOnOption {
437
- id: string;
438
- add_on_id: string;
439
- business_id: string;
440
- name: string;
441
- default_price?: string;
442
- description?: string;
443
- is_required: boolean;
444
- is_mutually_exclusive: boolean;
445
- created_at: string;
446
- updated_at: string;
447
- }
448
- interface MockProductAddOnLink {
449
- product_id: string;
450
- add_on_id: string;
451
- }
452
- interface MockVariantAxis {
453
- id: string;
454
- business_id: string;
455
- product_id: string;
456
- name: string;
457
- display_order: number;
458
- affects_recipe: boolean;
459
- values: MockVariantAxisValue[];
460
- created_at: string;
461
- updated_at: string;
462
- }
463
- interface MockVariantAxisValue {
464
- id: string;
465
- business_id: string;
466
- axis_id: string;
467
- name: string;
468
- display_order: number;
469
- color_hex?: string;
470
- created_at: string;
471
- updated_at: string;
472
- }
473
- interface MockVariant {
474
- id: string;
475
- product_id: string;
476
- business_id: string;
477
- name: string;
478
- sku?: string;
479
- price_adjustment: string;
480
- component_multiplier: string;
481
- is_default: boolean;
482
- is_active: boolean;
483
- axis_value_ids: string[];
484
- /** Per-variant images, when authored. Optional — most fixtures omit it. */
485
- images?: string[];
486
- created_at: string;
487
- updated_at: string;
488
- }
489
- interface MockBundle {
490
- id: string;
491
- business_id: string;
492
- product_id: string;
493
- name: string;
494
- slug: string;
495
- description?: string;
496
- pricing_type: "fixed" | "percentage_discount" | "fixed_discount";
497
- bundle_price?: string;
498
- discount_value?: string;
499
- product_ids: string[];
500
- created_at: string;
501
- updated_at: string;
502
- }
503
- interface MockComposite {
504
- id: string;
505
- business_id: string;
506
- product_id: string;
507
- base_price: string;
508
- pricing_mode: "additive" | "highest_per_group" | "highest_overall" | "tiered";
509
- min_order_quantity?: number;
510
- max_order_quantity?: number;
511
- groups: {
512
- id: string;
513
- name: string;
514
- min: number;
515
- max: number;
516
- component_ids: string[];
517
- }[];
518
- created_at: string;
519
- updated_at: string;
520
- }
521
- interface MockTag {
522
- id: string;
523
- business_id: string;
524
- name: string;
525
- slug: string;
526
- color?: string;
527
- icon?: string;
528
- description?: string;
529
- tag_group?: string;
530
- sort_order: number;
531
- usage_count: number;
532
- created_at: string;
533
- updated_at: string;
534
- }
535
- interface MockTaxonomy {
536
- id: string;
537
- business_id: string;
538
- name: string;
539
- slug: string;
540
- parent_id?: string;
541
- path: string[];
542
- attribute_template_ids: string[];
543
- created_at: string;
544
- updated_at: string;
545
- }
546
- interface MockKnowledgeArticle {
547
- id: string;
548
- business_id: string;
549
- title: string;
550
- slug: string;
551
- content: string;
552
- category?: string;
553
- tags: string[];
554
- created_at: string;
555
- updated_at: string;
556
- }
557
- interface MockAttributeDef {
558
- id: string;
559
- business_id: string;
560
- namespace: string;
561
- name: string;
562
- slug: string;
563
- description?: string;
564
- attribute_type: string;
565
- options?: string[];
566
- unit?: string;
567
- is_required: boolean;
568
- is_filterable: boolean;
569
- visibility: "admin_only" | "storefront_read" | "public";
570
- display_order: number;
571
- applies_to: "product" | "variant" | "both" | "category" | "collection" | "all";
572
- created_at: string;
573
- updated_at: string;
574
- }
575
- interface StateRegistry {
576
- businesses: Store<MockBusiness>;
577
- products: Store<MockProduct>;
578
- categories: Store<MockCategory>;
579
- collections: Store<MockCollection>;
580
- carts: Store<MockCart>;
581
- orders: Store<MockOrder>;
582
- subscriptions: Store<MockSubscription>;
583
- bookings: Store<MockBooking>;
584
- services: Store<MockService>;
585
- sessions: Store<Session>;
586
- otps: Store<OtpRequest>;
587
- idempotency: Store<IdempotencyRecord>;
588
- uploads: Store<MockUpload>;
589
- conversations: Store<MockConversation>;
590
- quotes: Store<MockQuote>;
591
- fxLocks: Store<MockFxLock>;
592
- activity: Store<MockActivityEvent>;
593
- addOns: Store<MockAddOn>;
594
- productAddOns: Store<MockProductAddOnLink>;
595
- variantAxes: Store<MockVariantAxis>;
596
- variants: Store<MockVariant>;
597
- bundles: Store<MockBundle>;
598
- composites: Store<MockComposite>;
599
- tags: Store<MockTag>;
600
- taxonomies: Store<MockTaxonomy>;
601
- knowledgeArticles: Store<MockKnowledgeArticle>;
602
- attributeDefs: Store<MockAttributeDef>;
603
- }
604
-
605
- interface AuthService {
606
- resolveSession(token: string | null): Session | null;
607
- ensureSession(token: string | null): Session;
608
- requestOtp(contact: string): {
609
- otp_id: string;
610
- expires_at: string;
611
- code_hint?: string;
612
- };
613
- verifyOtp(contact: string, code: string): Session;
614
- logout(token: string): void;
615
- updateProfile(token: string, profile: {
616
- name?: string;
617
- email?: string;
618
- phone?: string;
619
- }): Session;
620
- status(token: string | null): {
621
- is_authenticated: boolean;
622
- account_id?: string;
623
- user_type: "customer" | "guest";
624
- session_expires_at?: number;
625
- /** @deprecated Kept for SDK back-compat; production lens does not return this. */
626
- session?: Session;
627
- };
628
- }
629
-
630
- interface BusinessService {
631
- primary(): MockBusiness;
632
- byHandle(handle: string): MockBusiness;
633
- byDomain(domain: string): MockBusiness;
634
- settings(businessId: string): unknown;
635
- locations(businessId: string): unknown[];
636
- hours(businessId: string): unknown[];
637
- }
638
-
639
- interface CatalogueService {
640
- snapshot(businessId: string): {
641
- categories: unknown[];
642
- products: unknown[];
643
- add_ons: unknown[];
644
- is_complete: boolean;
645
- total_available: number;
646
- };
647
- listProducts(businessId: string, opts?: {
648
- page?: number;
649
- limit?: number;
650
- category_id?: string;
651
- collection_id?: string;
652
- }): unknown;
653
- getProduct(productId: string): unknown;
654
- getProductVariants(productId: string): MockVariant[];
655
- getProductVariantAxes(productId: string): MockVariantAxis[];
656
- getProductVariantById(productId: string, variantId: string): MockVariant;
657
- findProductVariant(productId: string, properties: Record<string, string>): MockVariant | null;
658
- getProductAddOns(productId: string): MockAddOn[];
659
- getProductAttributes(productId: string): MockAttributeDef[];
660
- listCategories(businessId: string): MockCategory[];
661
- getCategory(id: string): MockCategory;
662
- getCategoryProducts(id: string): unknown[];
663
- getCategoryAttributes(id: string): MockAttributeDef[];
664
- listCollections(businessId: string): MockCollection[];
665
- getCollection(id: string): MockCollection;
666
- getCollectionProducts(id: string): unknown[];
667
- getCollectionAttributes(id: string): MockAttributeDef[];
668
- listBundles(businessId: string): MockBundle[];
669
- getBundle(id: string): MockBundle;
670
- listComposites(businessId: string): MockComposite[];
671
- getComposite(id: string): MockComposite;
672
- getCompositeByProduct(productId: string): MockComposite | null;
673
- calculateCompositePrice(id: string, body: unknown): unknown;
674
- listTaxonomies(businessId: string): MockTaxonomy[];
675
- searchTaxonomies(businessId: string, q: string): MockTaxonomy[];
676
- getTaxonomy(id: string): MockTaxonomy;
677
- getTaxonomyAttributes(id: string): MockAttributeDef[];
678
- getTaxonomyPath(id: string): string[];
679
- listAttributes(businessId: string): MockAttributeDef[];
680
- listTags(businessId: string): MockTag[];
681
- listKnowledgeArticles(businessId: string): MockKnowledgeArticle[];
682
- searchKnowledgeBase(businessId: string, q: string): MockKnowledgeArticle[];
683
- listPropertyFacets(businessId: string): unknown[];
684
- listDeals(businessId: string): unknown[];
685
- listOnSale(businessId: string): unknown[];
686
- validateDiscount(code: string, businessId: string): unknown;
687
- getProductDeals(productId: string): unknown[];
688
- getCategoryDeals(id: string): unknown[];
689
- getCollectionDeals(id: string): unknown[];
690
- createQuote(businessId: string, body: unknown): unknown;
691
- getQuote(id: string): unknown;
692
- refreshQuote(id: string): unknown;
693
- }
694
-
695
- interface CustomerInputValue {
696
- field_id: string;
697
- field_name?: string;
698
- field_type?: string;
699
- value: unknown;
700
- }
701
- interface AddItemInput {
702
- item_id: string;
703
- variant_id?: string;
704
- quantity: number;
705
- add_on_options?: string[];
706
- bundle_selections?: BundleSelectionInput[];
707
- composite_selections?: ComponentSelectionInput[];
708
- scheduled_start?: string;
709
- scheduled_end?: string;
710
- staff_id?: string;
711
- resource_id?: string;
712
- special_instructions?: string;
713
- customer_inputs?: CustomerInputValue[];
714
- billing_plan_id?: string;
715
- quote_id?: string;
716
- metadata?: Record<string, unknown>;
717
- }
718
- interface BundleSelectionInput {
719
- component_id: string;
720
- variant_id?: string;
721
- quantity: number;
722
- scheduled_start?: string;
723
- scheduled_end?: string;
724
- }
725
- interface ComponentSelectionInput {
726
- component_id?: string;
727
- source_product_id?: string;
728
- source_stock_id?: string;
729
- source_type?: "product" | "stock" | "add_on" | "standalone";
730
- quantity?: number;
731
- }
732
-
733
- interface CartService {
734
- get(session: Session): MockCart;
735
- getItems(session: Session): MockCartItem[];
736
- getCount(session: Session): number;
737
- getTotal(session: Session): string;
738
- addItem(session: Session, body: AddItemInput): unknown;
739
- updateQuantity(session: Session, cartItemId: string, quantity: number): unknown;
740
- removeItem(session: Session, cartItemId: string): unknown;
741
- clear(session: Session): unknown;
742
- applyCoupon(session: Session, code: string): unknown;
743
- removeCoupon(session: Session): unknown;
744
- toUICart(cart: MockCart): unknown;
745
- resolveCart(session: Session): MockCart;
746
- }
747
-
748
- interface CheckoutService {
749
- process(session: Session, body: CheckoutBody): CheckoutResult;
750
- authorize(body: {
751
- order_id: string;
752
- otp?: string;
753
- pin?: string;
754
- }): {
755
- status: string;
756
- order_id: string;
757
- };
758
- }
759
- interface CheckoutBody {
760
- cart_id: string;
761
- location_id?: string;
762
- customer: {
763
- name: string;
764
- email: string;
765
- phone: string;
766
- notes?: string;
767
- save_details?: boolean;
768
- };
769
- order_type: string;
770
- address_info?: Record<string, unknown>;
771
- payment_method: string;
772
- mobile_money_details?: {
773
- phone_number: string;
774
- provider: string;
775
- };
776
- special_instructions?: string;
777
- metadata?: Record<string, unknown>;
778
- pay_currency?: string;
779
- fx_quote_id?: string;
780
- }
781
- interface CheckoutResult {
782
- order_id: string;
783
- order_number: string;
784
- payment_status: string;
785
- payment_reference?: string;
786
- requires_authorization: boolean;
787
- authorization_type?: "otp" | "pin" | "phone" | "birthday" | "address";
788
- next_action: {
789
- type: "none";
790
- } | {
791
- type: "redirect";
792
- authorization_url: string;
793
- } | {
794
- type: "authorization";
795
- authorization_type: string;
796
- display_text?: string;
797
- };
798
- provider?: string;
799
- authorization_url?: string;
800
- display_text?: string;
801
- /** Bearer token used for guest order access (lookup `/orders/{id}?token=...`). */
802
- bill_token?: string;
803
- /** Stripe-style client secret for direct PaymentIntent confirmation. */
804
- client_secret?: string;
805
- /** Stripe publishable key (mock value in dev). */
806
- public_key?: string;
807
- }
808
-
809
- interface OrderService {
810
- list(session: Session, opts?: {
811
- limit?: number;
812
- status?: string;
813
- }): {
814
- items: MockOrder[];
815
- pagination: unknown;
816
- };
817
- /** Cross-business listing for the Cimplify Link surface. */
818
- listByCustomer(customerId: string, opts?: {
819
- limit?: number;
820
- offset?: number;
821
- status?: string;
822
- }): MockOrder[];
823
- get(orderId: string): MockOrder;
824
- getPaymentStatus(orderId: string): {
825
- order_id: string;
826
- payment_state: string;
827
- status: string;
828
- };
829
- cancel(orderId: string, reason?: string): MockOrder;
830
- updateCustomer(orderId: string, customer: {
831
- name?: string;
832
- email?: string;
833
- phone?: string;
834
- }): MockOrder;
835
- verifyPayment(orderId: string): {
836
- order_id: string;
837
- payment_state: string;
838
- status: string;
839
- verified: boolean;
840
- };
841
- }
842
-
843
- interface SubscriptionService {
844
- list(session: Session): MockSubscription[];
845
- get(id: string): MockSubscription;
846
- cancel(id: string): MockSubscription;
847
- pause(id: string): MockSubscription;
848
- resume(id: string): MockSubscription;
849
- skipNext(id: string): MockSubscription;
850
- }
851
-
852
- interface SchedulingService {
853
- listServices(businessId: string): MockService[];
854
- getService(id: string): MockService;
855
- getSlots(serviceId: string, opts?: {
856
- date?: string;
857
- }): unknown[];
858
- checkSlot(serviceId: string, start: string, end: string): {
859
- is_available: boolean;
860
- };
861
- getServiceAvailability(serviceId: string): unknown;
862
- getCustomerBookings(session: Session): unknown[];
863
- getBooking(id: string): MockBooking;
864
- cancelBooking(id: string, reason?: string): MockBooking;
865
- rescheduleBooking(body: {
866
- booking_id: string;
867
- new_start_time: string;
868
- new_end_time: string;
869
- }): MockBooking;
870
- }
871
-
872
- interface InventoryService {
873
- productStock(productId: string): {
874
- product_id: string;
875
- location_id?: string;
876
- stock_level: number;
877
- in_stock: boolean;
878
- };
879
- variantStock(variantId: string): {
880
- variant_id: string;
881
- location_id?: string;
882
- stock_level: number;
883
- in_stock: boolean;
884
- };
885
- productAvailability(productId: string, quantity?: number): {
886
- product_id: string;
887
- quantity: number;
888
- is_available: boolean;
889
- };
890
- variantAvailability(variantId: string, quantity?: number): {
891
- variant_id: string;
892
- quantity: number;
893
- is_available: boolean;
894
- };
895
- /**
896
- * Reserve stock for a cart item. No-op for product types that don't track
897
- * inventory (services, digital). Throws on insufficient stock.
898
- */
899
- reserve(productId: string, variantId: string | undefined, quantity: number): void;
900
- /** Release a previously-reserved quantity (e.g. when a line is removed). */
901
- release(productId: string, variantId: string | undefined, quantity: number): void;
902
- }
903
-
904
- interface FxService {
905
- getRate(from: string, to: string): {
906
- from: string;
907
- to: string;
908
- rate: number;
909
- updated_at: string;
910
- };
911
- lockQuote(body: {
912
- base_currency: string;
913
- pay_currency: string;
914
- base_amount: string;
915
- }): MockFxLock;
916
- }
917
-
918
- interface PlacesService {
919
- autocomplete(body: {
920
- query: string;
921
- country?: string;
922
- }): {
923
- predictions: unknown[];
924
- };
925
- details(body: {
926
- place_id: string;
927
- }): unknown;
928
- }
929
-
930
- interface DeliveryService {
931
- getFee(opts: {
932
- lat?: number;
933
- lng?: number;
934
- address?: string;
935
- cart_total?: string;
936
- }): {
937
- fee: string;
938
- currency: string;
939
- estimated_minutes: number;
940
- provider: string;
941
- quotes: unknown[];
942
- };
943
- }
944
-
945
- interface ActivityService {
946
- recordEvents(businessId: string, sessionId: string | undefined, events: {
947
- event_type: string;
948
- payload?: Record<string, unknown>;
949
- }[]): {
950
- recorded: number;
951
- };
952
- getState(businessId: string, sessionId: string | undefined): unknown;
953
- getRecommendations(businessId: string): unknown;
954
- dismissMessage(messageId: string): {
955
- dismissed: boolean;
956
- message_id: string;
957
- };
958
- }
959
-
960
- interface SupportService {
961
- openConversation(businessId: string, customerId?: string): MockConversation;
962
- sendMessage(conversationId: string, body: {
963
- content: string;
964
- content_type?: string;
965
- sender_type?: "customer" | "agent";
966
- }): MockChatMessage;
967
- listMessages(conversationId: string, opts?: {
968
- limit?: number;
969
- }): MockChatMessage[];
970
- }
971
-
972
- interface UploadService {
973
- init(businessId: string, body: {
974
- filename: string;
975
- mime_type: string;
976
- size_bytes: number;
977
- }): MockUpload;
978
- confirm(body: {
979
- upload_id: string;
980
- }): MockUpload;
981
- }
982
-
983
- interface LiteService {
984
- bootstrap(businessId: string): unknown;
985
- getTable(tableId: string): unknown;
986
- getMenu(businessId: string): unknown;
987
- getMenuCategory(categoryId: string): unknown;
988
- }
989
-
990
- interface MockAddress {
991
- id: string;
992
- customer_id: string;
993
- label: string;
994
- street_address: string;
995
- apartment: string | null;
996
- city: string;
997
- region: string;
998
- postal_code: string | null;
999
- country: string | null;
1000
- delivery_instructions: string | null;
1001
- phone_for_delivery: string | null;
1002
- latitude: number | null;
1003
- longitude: number | null;
1004
- is_default: boolean;
1005
- usage_count: number;
1006
- last_used_at: string | null;
1007
- created_at: string;
1008
- updated_at: string;
1009
- }
1010
- interface MockMobileMoney {
1011
- id: string;
1012
- customer_id: string;
1013
- phone_number: string;
1014
- provider: string;
1015
- label: string;
1016
- is_verified: boolean;
1017
- verification_date: string | null;
1018
- is_default: boolean;
1019
- usage_count: number;
1020
- last_used_at: string | null;
1021
- success_rate: number;
1022
- created_at: string;
1023
- updated_at: string;
1024
- }
1025
- interface MockLinkPreferences {
1026
- customer_id: string;
1027
- is_link_enabled: boolean;
1028
- enrolled_at: string | null;
1029
- enrollment_business_id: string | null;
1030
- preferred_order_type: string | null;
1031
- default_address_id: string | null;
1032
- default_mobile_money_id: string | null;
1033
- remember_me: boolean;
1034
- session_duration_days: number;
1035
- two_factor_enabled: boolean;
1036
- notify_on_order: boolean;
1037
- notify_on_payment: boolean;
1038
- created_at: string;
1039
- updated_at: string;
1040
- }
1041
- interface MockLinkCustomer {
1042
- id: string;
1043
- email: string | null;
1044
- phone: string | null;
1045
- name: string;
1046
- created_at: string;
1047
- updated_at: string;
1048
- }
1049
- interface MockLinkSession {
1050
- id: string;
1051
- customer_id: string;
1052
- created_at: string;
1053
- last_used_at: string;
1054
- device_type: "mobile" | "desktop" | "tablet" | "unknown";
1055
- ip: string | null;
1056
- user_agent: string | null;
1057
- is_current: boolean;
1058
- }
1059
- interface CustomerState {
1060
- customer: MockLinkCustomer;
1061
- addresses: Map<string, MockAddress>;
1062
- mobileMoney: Map<string, MockMobileMoney>;
1063
- preferences: MockLinkPreferences;
1064
- sessions: Map<string, MockLinkSession>;
1065
- }
1066
- interface LinkService {
1067
- /** Get-or-create a customer state record. The mock auth seeds a customer
1068
- * on first OTP verify; this lazily ensures one exists for tests that
1069
- * bypass the auth flow. */
1070
- ensureCustomer(customerId: string, seed?: {
1071
- email?: string;
1072
- phone?: string;
1073
- name?: string;
1074
- }): CustomerState;
1075
- getCustomer(customerId: string): MockLinkCustomer;
1076
- getProfile(customerId: string): MockLinkCustomer;
1077
- getLinkData(customerId: string): {
1078
- customer: MockLinkCustomer;
1079
- addresses: MockAddress[];
1080
- mobile_money: MockMobileMoney[];
1081
- preferences: MockLinkPreferences;
1082
- default_address: MockAddress | null;
1083
- default_mobile_money: MockMobileMoney | null;
1084
- };
1085
- isEnrolled(customerId: string): boolean;
1086
- checkStatus(contact: string): boolean;
1087
- enroll(customerId: string, businessId: string, name?: string): MockLinkPreferences;
1088
- getPreferences(customerId: string): MockLinkPreferences;
1089
- updatePreferences(customerId: string, patch: Partial<MockLinkPreferences>): MockLinkPreferences;
1090
- getAddresses(customerId: string): MockAddress[];
1091
- getAddressById(customerId: string, id: string): MockAddress;
1092
- createAddress(customerId: string, input: Partial<MockAddress>): MockAddress;
1093
- updateAddress(customerId: string, id: string, patch: Partial<MockAddress>): MockAddress;
1094
- deleteAddress(customerId: string, id: string): void;
1095
- setDefaultAddress(customerId: string, id: string): void;
1096
- trackAddressUsage(customerId: string, id: string): void;
1097
- getMobileMoney(customerId: string): MockMobileMoney[];
1098
- createMobileMoney(customerId: string, input: Partial<MockMobileMoney>): MockMobileMoney;
1099
- deleteMobileMoney(customerId: string, id: string): void;
1100
- setDefaultMobileMoney(customerId: string, id: string): void;
1101
- trackMobileMoneyUsage(customerId: string, id: string): void;
1102
- verifyMobileMoney(customerId: string, id: string): void;
1103
- getSessions(customerId: string): MockLinkSession[];
1104
- revokeSession(customerId: string, id: string): void;
1105
- revokeAllSessions(customerId: string): number;
1106
- }
1107
-
1108
- type SeedName = "default" | "empty" | "reesa-storefront" | "restaurant" | "retail" | "services" | "grocery" | "fashion" | "pharmacy" | "auto";
1109
- declare function applySeed(registry: StateRegistry, name: SeedName): {
1110
- businessId: string;
1111
- };
1112
-
1113
- interface MockOptions {
1114
- seed?: SeedName;
1115
- authMode?: "permissive" | "strict";
1116
- defaultOtp?: string;
1117
- rngSeed?: number;
1118
- frozenAt?: Date;
1119
- }
1120
- interface ChaosState {
1121
- failNext: {
1122
- route: string;
1123
- count: number;
1124
- status: number;
1125
- code?: string;
1126
- }[];
1127
- latencyByRoute: {
1128
- route: string;
1129
- ms: number;
1130
- }[];
1131
- webhookUrl?: string;
1132
- webhookSecret?: string;
1133
- }
1134
- interface Deps {
1135
- clock: Clock;
1136
- ids: IdGen;
1137
- bus: MockBus;
1138
- registry: StateRegistry;
1139
- auth: AuthService;
1140
- business: BusinessService;
1141
- catalogue: CatalogueService;
1142
- cart: CartService;
1143
- checkout: CheckoutService;
1144
- orders: OrderService;
1145
- subscriptions: SubscriptionService;
1146
- scheduling: SchedulingService;
1147
- inventory: InventoryService;
1148
- fx: FxService;
1149
- places: PlacesService;
1150
- delivery: DeliveryService;
1151
- activity: ActivityService;
1152
- support: SupportService;
1153
- uploads: UploadService;
1154
- lite: LiteService;
1155
- link: LinkService;
1156
- defaultBusinessId: string;
1157
- chaos: ChaosState;
1158
- resetAll: (seed?: SeedName) => string;
1159
- }
1160
- declare function createDeps(options?: MockOptions): Deps;
1161
-
1162
- interface CreateAppOptions extends MockOptions {
1163
- /**
1164
- * CORS origins to allow. `"*"` (default) allows any origin and is
1165
- * appropriate for local dev. Pass an explicit allow-list for production
1166
- * mock deployments.
1167
- */
1168
- cors?: string[] | "*";
1169
- }
1170
- interface AppHandle {
1171
- app: Hono;
1172
- deps: Deps;
1173
- request: (path: string, init?: RequestInit) => Promise<Response>;
1174
- }
1175
- /**
1176
- * Construct the full mock app — wires CORS, all route groups, and the
1177
- * 501 catch-all. Returns a handle that exposes the underlying Hono app,
1178
- * the dependency container, and an in-process `request()` shortcut for
1179
- * tests / MSW handlers.
1180
- */
1181
- declare function createMockApp(options?: CreateAppOptions): AppHandle;
1182
-
1183
- 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 };