@sazito/client-sdk 1.2.3 → 1.2.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,2301 @@
1
+ /**
2
+ * SDK Configuration
3
+ */
4
+ interface CacheConfig {
5
+ enabled: boolean;
6
+ ttl?: number;
7
+ }
8
+ interface RetryConfig {
9
+ enabled: boolean;
10
+ retries: number;
11
+ retryDelay: number;
12
+ }
13
+ interface SazitoConfig {
14
+ domain: string;
15
+ timeout?: number;
16
+ retry?: RetryConfig;
17
+ cache?: {
18
+ products?: CacheConfig;
19
+ categories?: CacheConfig;
20
+ cart?: CacheConfig;
21
+ orders?: CacheConfig;
22
+ search?: CacheConfig;
23
+ cms?: CacheConfig;
24
+ tags?: CacheConfig;
25
+ entityRoutes?: CacheConfig;
26
+ };
27
+ customFetchApi?: typeof fetch;
28
+ debug?: boolean;
29
+ }
30
+
31
+ /**
32
+ * Common types used throughout the SDK
33
+ */
34
+ type JsonPrimitive = string | number | boolean | null;
35
+ type JsonValue = JsonPrimitive | JsonObject | JsonArray;
36
+ interface JsonObject {
37
+ [key: string]: JsonValue;
38
+ }
39
+ type JsonArray = JsonValue[];
40
+ /**
41
+ * Unified response pattern for all API calls
42
+ * No exceptions are thrown - errors are returned in the error field
43
+ */
44
+ interface SazitoResponse<T> {
45
+ data?: T;
46
+ error?: {
47
+ status?: number;
48
+ message: string;
49
+ type: 'network' | 'api' | 'validation';
50
+ details?: JsonValue;
51
+ };
52
+ }
53
+ /**
54
+ * Paginated response wrapper
55
+ */
56
+ interface PaginatedResponse<T> {
57
+ items: T[];
58
+ total: number;
59
+ page: number;
60
+ pageSize: number;
61
+ }
62
+ /**
63
+ * Request options that can be passed to an API call
64
+ */
65
+ interface RequestOptions {
66
+ retries?: number;
67
+ timeout?: number;
68
+ cache?: boolean;
69
+ headers?: Record<string, string>;
70
+ signal?: AbortSignal;
71
+ skipTransform?: boolean;
72
+ }
73
+ /**
74
+ * Cookie options for token storage
75
+ */
76
+ interface CookieOptions {
77
+ httpOnly?: boolean;
78
+ secure?: boolean;
79
+ sameSite?: 'Strict' | 'Lax' | 'None';
80
+ maxAge?: number;
81
+ path?: string;
82
+ domain?: string;
83
+ }
84
+ /**
85
+ * Image type used in products, categories, etc.
86
+ */
87
+ interface Image {
88
+ id: number;
89
+ name: string;
90
+ url: string;
91
+ alt?: string;
92
+ width?: number;
93
+ height?: number;
94
+ createdAt: string;
95
+ updatedAt: string;
96
+ }
97
+ /**
98
+ * Product attribute (e.g., color, size)
99
+ */
100
+ /**
101
+ * Rich attribute value for typed fields like color swatches.
102
+ * `value` is the human-readable label; `extra` carries the payload
103
+ * (e.g. a hex color when `fieldType` is `'color'`).
104
+ */
105
+ interface ProductAttributeValueObject {
106
+ value: string;
107
+ extra?: string;
108
+ fieldType?: string;
109
+ }
110
+ interface ProductAttribute {
111
+ name: string;
112
+ value: string | ProductAttributeValueObject;
113
+ }
114
+ /**
115
+ * Normalized product snapshot embedded in checkout entities
116
+ * (cart items, invoice items, successful order items).
117
+ */
118
+ interface CheckoutProductSnapshot {
119
+ variantId: number;
120
+ productId?: number;
121
+ name: string;
122
+ url?: string;
123
+ image?: Image;
124
+ attributes: ProductAttribute[];
125
+ productType?: string;
126
+ hasMaxOrder?: boolean;
127
+ maxOrderQuantity?: number;
128
+ minOrderQuantity?: number;
129
+ }
130
+ /**
131
+ * Region (استان)
132
+ */
133
+ interface Region$1 {
134
+ id: number;
135
+ name: string;
136
+ cities?: City$1[];
137
+ }
138
+ /**
139
+ * City (شهر)
140
+ */
141
+ interface City$1 {
142
+ id: number;
143
+ name: string;
144
+ regionId?: number;
145
+ latitude?: number;
146
+ longitude?: number;
147
+ }
148
+
149
+ /**
150
+ * Product-related types
151
+ */
152
+
153
+ interface ProductVariant {
154
+ id: number;
155
+ productId?: number;
156
+ sku?: string;
157
+ enabled: boolean;
158
+ price: number;
159
+ originalPrice?: number;
160
+ stockQuantity: number;
161
+ isStockManaged: boolean;
162
+ isAvailable?: boolean;
163
+ attributes: ProductAttribute[];
164
+ hasMaxOrder: boolean;
165
+ maxOrderQuantity: number;
166
+ minOrderQuantity: number;
167
+ weight?: number;
168
+ dynamicFormId?: number;
169
+ sortIndex: number;
170
+ imageId?: number;
171
+ commercialFiles?: JsonValue[];
172
+ createdAt: string;
173
+ updatedAt: string;
174
+ }
175
+ interface Product {
176
+ id?: number;
177
+ name: string;
178
+ url: string;
179
+ enabled: boolean;
180
+ productType: string;
181
+ themeConfig?: JsonObject;
182
+ dynamicFormId?: number;
183
+ eventEntityId?: number;
184
+ attributes?: ProductAttribute[];
185
+ images: Image[];
186
+ variants: ProductVariant[];
187
+ categories: ProductCategory[];
188
+ createdAt: string;
189
+ updatedAt: string;
190
+ }
191
+ interface ProductCategory {
192
+ id?: number;
193
+ name: string;
194
+ url: string;
195
+ enabled?: boolean;
196
+ description?: string;
197
+ productsCount?: number;
198
+ themeConfig?: JsonObject;
199
+ attributes?: ProductAttribute[];
200
+ createdAt?: string;
201
+ updatedAt?: string;
202
+ }
203
+ interface Tag {
204
+ id: number;
205
+ name: string;
206
+ slug: string;
207
+ }
208
+ type ProductSort = 'newest' | 'best-selling' | 'availability' | 'discount' | '!price' | 'price';
209
+ interface ProductFilters {
210
+ page?: number;
211
+ pageSize?: number;
212
+ sort?: ProductSort;
213
+ categories?: number | number[];
214
+ priceMin?: number;
215
+ priceMax?: number;
216
+ availableOnly?: boolean;
217
+ discountedOnly?: boolean;
218
+ pinnedIds?: number[];
219
+ similarTo?: number;
220
+ }
221
+
222
+ /**
223
+ * Cart-related types
224
+ */
225
+
226
+ interface SchedulerBookingAttributes {
227
+ eventEntityId: string | number;
228
+ eventTitle?: string;
229
+ eventId?: string;
230
+ startDateTimeLocal: string;
231
+ endDateTimeLocal: string;
232
+ timezone: string;
233
+ }
234
+ interface UploadedFormFileAttribute {
235
+ serveKey: string;
236
+ fileName: string;
237
+ }
238
+ type FormAttributeValue = string | number | boolean | null | UploadedFormFileAttribute;
239
+ interface CartProduct {
240
+ id: number | string;
241
+ /** When this line was first added to the cart. */
242
+ createdAt?: string;
243
+ updatedAt?: string;
244
+ productVariantId: number;
245
+ quantity: number;
246
+ unitPrice: number;
247
+ lineTotal: number;
248
+ product: CheckoutProductSnapshot;
249
+ formAttributes?: Record<string, FormAttributeValue>;
250
+ formFields?: JsonObject;
251
+ bookingAttributes?: SchedulerBookingAttributes;
252
+ }
253
+ interface Cart {
254
+ id: number;
255
+ identifier: string;
256
+ items: CartProduct[];
257
+ netTotal: number;
258
+ grossTotal?: number;
259
+ needsShipping: boolean;
260
+ minBasketLimitViolated: boolean;
261
+ deleteCoupon?: boolean;
262
+ }
263
+ interface CartCredentials {
264
+ identifier: string;
265
+ }
266
+ interface AddToCartInput {
267
+ id: number;
268
+ count: number;
269
+ formAttributes?: Record<string, FormAttributeValue>;
270
+ }
271
+ interface CreateCartInput {
272
+ coupon?: string;
273
+ variants: AddToCartInput[];
274
+ formAttributes?: Record<string, FormAttributeValue>;
275
+ schedulerBookingAttributes?: SchedulerBookingAttributes;
276
+ }
277
+
278
+ /**
279
+ * Invoice and checkout-related types
280
+ */
281
+
282
+ interface InvoiceItemFormAttributes {
283
+ formId?: number;
284
+ formData: Record<string, {
285
+ label: string;
286
+ value: JsonValue;
287
+ type: string;
288
+ }>;
289
+ }
290
+ interface InvoiceItem {
291
+ id: number | string;
292
+ productVariantId: number;
293
+ productId?: number;
294
+ name: string;
295
+ url?: string;
296
+ attributes: ProductAttribute[];
297
+ productType?: string;
298
+ hasMaxOrder?: boolean;
299
+ maxOrderQuantity?: number;
300
+ minOrderQuantity?: number;
301
+ image?: Image;
302
+ quantity: number;
303
+ unitPrice: number;
304
+ lineTotal: number;
305
+ rawPrice: number;
306
+ customerProfit: number;
307
+ commercialFiles?: JsonValue;
308
+ formAttributes?: Record<string, FormAttributeValue> | InvoiceItemFormAttributes;
309
+ bookingAttributes?: SchedulerBookingAttributes;
310
+ formFields?: JsonObject;
311
+ }
312
+ interface ShippingItem {
313
+ invoiceItemIds: Array<number | string>;
314
+ rate: {
315
+ id: number;
316
+ name: string;
317
+ price: number;
318
+ icon?: string;
319
+ color?: string;
320
+ type?: string;
321
+ };
322
+ }
323
+ interface ShippingAddressRegion {
324
+ id: number;
325
+ name: string;
326
+ }
327
+ interface ShippingAddressCity {
328
+ id: number;
329
+ name: string;
330
+ regionId?: number;
331
+ latitude?: number;
332
+ longitude?: number;
333
+ }
334
+ interface ShippingAddress {
335
+ id: number;
336
+ identifier: string;
337
+ firstName: string;
338
+ lastName: string;
339
+ mobilePhone?: string;
340
+ phoneNumber?: string;
341
+ email?: string;
342
+ region?: ShippingAddressRegion;
343
+ city: ShippingAddressCity;
344
+ address: string;
345
+ postalCode?: string;
346
+ description?: string;
347
+ latitude?: number;
348
+ longitude?: number;
349
+ userSetCoordinatesBefore?: boolean;
350
+ }
351
+ interface InvoiceShippingAddressRegion extends ShippingAddressRegion {
352
+ city: ShippingAddressCity;
353
+ }
354
+ interface InvoiceShippingAddress {
355
+ identifier: string;
356
+ firstName: string;
357
+ lastName: string;
358
+ mobilePhone?: string;
359
+ phoneNumber?: string;
360
+ email?: string;
361
+ region?: InvoiceShippingAddressRegion;
362
+ address: string;
363
+ postalCode?: string;
364
+ description?: string;
365
+ latitude?: number;
366
+ longitude?: number;
367
+ userSetCoordinatesBefore?: boolean;
368
+ }
369
+ interface User {
370
+ id?: number;
371
+ email?: string;
372
+ mobilePhone?: string;
373
+ phoneNumber?: string;
374
+ firstName?: string;
375
+ lastName?: string;
376
+ birthDate?: string;
377
+ }
378
+ interface Invoice {
379
+ id: number;
380
+ identifier: string;
381
+ items: InvoiceItem[];
382
+ shippingAddress?: InvoiceShippingAddress;
383
+ shippingItems: ShippingItem[];
384
+ needsShipping: boolean;
385
+ userComment?: string;
386
+ netTotal: number;
387
+ finalTotal: number;
388
+ vat: number;
389
+ vatPercent: number;
390
+ itemsDiscount: number;
391
+ discountTotal: number;
392
+ customerProfit: number;
393
+ customerProfitPercentage: number;
394
+ itemsTotalRawPrice: number;
395
+ couponTotal: number;
396
+ shippingTotal: number;
397
+ creditTotal: number;
398
+ discountUsages: Array<{
399
+ discountCode: {
400
+ code: string;
401
+ userSegment?: string;
402
+ };
403
+ }>;
404
+ coupon?: {
405
+ userSegment?: string;
406
+ };
407
+ discountCode?: string;
408
+ }
409
+ interface InvoiceCredentials {
410
+ id: number;
411
+ identifier: string;
412
+ }
413
+ interface CreateInvoiceInput {
414
+ cartIdentifier: string;
415
+ }
416
+ interface RefreshInvoiceInput {
417
+ cartIdentifier: string;
418
+ identifier: string;
419
+ }
420
+
421
+ /**
422
+ * Shipping-related types
423
+ */
424
+ interface ShippingMethod {
425
+ id: number;
426
+ name: string;
427
+ type: string;
428
+ }
429
+ interface ShippingRate {
430
+ id: number;
431
+ name: string;
432
+ price: number;
433
+ description?: string;
434
+ icon?: string;
435
+ color?: string;
436
+ type?: string;
437
+ }
438
+ interface ItemShippingRate {
439
+ invoiceItemId: number | string;
440
+ shippingRate: ShippingRate;
441
+ }
442
+ interface ApplicableShippingMethods {
443
+ shippingMethods: ShippingMethod[];
444
+ groupedShippingRates: Record<string, ShippingRate[]>;
445
+ itemsShippingRate: ItemShippingRate[];
446
+ }
447
+ interface ShippingAddressInput {
448
+ firstName: string;
449
+ lastName: string;
450
+ mobilePhone: string;
451
+ phoneNumber?: string;
452
+ email?: string;
453
+ regionId?: number;
454
+ cityId?: number;
455
+ address: string;
456
+ postalCode?: string;
457
+ description?: string;
458
+ latitude?: number;
459
+ longitude?: number;
460
+ showMap?: boolean;
461
+ userSetCoordinatesBefore?: boolean;
462
+ }
463
+ interface ShippingAddressCredentials {
464
+ id: number;
465
+ identifier: string;
466
+ }
467
+ interface ShippingAssignment {
468
+ rateId: number;
469
+ invoiceItemIds: Array<string | number>;
470
+ }
471
+
472
+ /**
473
+ * Order-related types
474
+ */
475
+
476
+ interface Order {
477
+ id: number;
478
+ orderNumber: string;
479
+ orderIdentifier: string;
480
+ invoice: {
481
+ shippingItems: JsonObject[];
482
+ invoiceItems: InvoiceItem[];
483
+ };
484
+ }
485
+ interface OrdersListResponse {
486
+ orders: Order[];
487
+ pageNumber?: number;
488
+ pageSize?: number;
489
+ totalCount: number;
490
+ totalCountRaw: number;
491
+ totalNotSeen: number;
492
+ totalSeen: number;
493
+ }
494
+ interface OrderFilters {
495
+ pageNumber?: number;
496
+ pageSize?: number;
497
+ filters?: Array<{
498
+ name: string;
499
+ value: JsonValue;
500
+ }>;
501
+ }
502
+
503
+ /**
504
+ * Payment-related types
505
+ */
506
+
507
+ type PaymentGateway = 'mellatpayment' | 'pecpayment' | 'sadadpayment' | 'zarinpalpayment' | 'paypingpayment' | 'podpayment' | 'uppayment' | 'seppayment' | 'vandarpayment' | 'yourgatepayment' | 'bazarpayment' | 'zifypayment' | 'zibalpayment' | 'snapppayment' | 'torobpaypayment' | 'azkipayment' | 'digipaypayment' | 'novapaypayment' | 'zarinpluspayment' | 'tomanpayment' | 'tarapayment' | 'ozonpayment' | 'millipaypayment' | 'ayriapayment' | 'sabinpayment' | 'paymentinplace' | 'cardtocardpayment' | 'freepayment';
508
+ type PaymentStatus = 'PENDING' | 'PROCESSING' | 'PAID' | 'FAILED' | 'CANCELLED' | 'REFUNDED';
509
+ interface PaymentMethod {
510
+ id: number;
511
+ code: PaymentGateway;
512
+ /** Backend display title (English). */
513
+ title: string;
514
+ /** Backend display title (Persian). */
515
+ titleFa: string;
516
+ /** Backend description; often null. */
517
+ description: string | null;
518
+ /** Backend payment sub-type id; null when not provided. */
519
+ paymentSubType: number | null;
520
+ /** Display order from backend. */
521
+ order: number;
522
+ isDefault: boolean;
523
+ }
524
+ interface Payment {
525
+ id: number;
526
+ identifier: string;
527
+ paymentType: {
528
+ id?: number;
529
+ code: PaymentGateway;
530
+ };
531
+ amount: number;
532
+ }
533
+ interface PaymentAction {
534
+ action: 'POST' | 'REDIRECT' | 'UPLOAD' | 'pending' | 'showOrder' | 'StockViolated' | 'FAIL';
535
+ address?: string;
536
+ payload?: JsonObject;
537
+ order?: Order;
538
+ time?: number;
539
+ message?: string;
540
+ }
541
+ interface PaymentCredentials {
542
+ id: number;
543
+ identifier: string;
544
+ }
545
+ interface CreatePaymentInput {
546
+ invoiceId: number;
547
+ invoiceIdentifier: string;
548
+ paymentType: number;
549
+ }
550
+ interface PaymentStepInput {
551
+ id?: number;
552
+ paymentIdentifier?: string;
553
+ payload?: JsonObject;
554
+ tatoken?: string;
555
+ trackingData?: JsonObject;
556
+ isFailed?: string;
557
+ imageUrl?: string;
558
+ code?: string;
559
+ }
560
+ type PaymentStepFormValue = string | number | boolean | null | undefined;
561
+ type PaymentStepFormFields = Record<string, PaymentStepFormValue>;
562
+
563
+ /**
564
+ * Search-related types
565
+ */
566
+
567
+ /**
568
+ * CMS Page types
569
+ */
570
+ type CMSPageType = 'normal' | 'blog';
571
+ /**
572
+ * Blog page entity from search results
573
+ */
574
+ interface BlogPage {
575
+ id?: number;
576
+ name: string;
577
+ url: string;
578
+ enabled?: boolean;
579
+ cmsPageType?: CMSPageType;
580
+ content?: string;
581
+ summary?: string;
582
+ image?: Image;
583
+ themeConfig?: JsonObject;
584
+ attributes?: ProductAttribute[];
585
+ createdAt: string;
586
+ updatedAt: string;
587
+ }
588
+ /**
589
+ * CMS page entity from search results
590
+ */
591
+ interface CmsPage {
592
+ id?: number;
593
+ name: string;
594
+ url: string;
595
+ enabled?: boolean;
596
+ cmsPageType?: CMSPageType;
597
+ content?: string;
598
+ summary?: string;
599
+ image?: Image;
600
+ themeConfig?: JsonObject;
601
+ attributes?: ProductAttribute[];
602
+ createdAt: string;
603
+ updatedAt: string;
604
+ }
605
+ /**
606
+ * Search response containing multiple entity types
607
+ * Each entity type has its own array and pagination info
608
+ */
609
+ interface SearchResponse {
610
+ products: {
611
+ items: Product[];
612
+ total: number;
613
+ page: number;
614
+ pageSize: number;
615
+ };
616
+ blogPages: {
617
+ items: BlogPage[];
618
+ total: number;
619
+ page: number;
620
+ pageSize: number;
621
+ };
622
+ cmsPages: {
623
+ items: CmsPage[];
624
+ total: number;
625
+ page: number;
626
+ pageSize: number;
627
+ };
628
+ productCategories: {
629
+ items: ProductCategory[];
630
+ total: number;
631
+ page: number;
632
+ pageSize: number;
633
+ };
634
+ }
635
+
636
+ /**
637
+ * Entity Route types
638
+ * For resolving URL paths to entities (products, categories, CMS pages)
639
+ */
640
+
641
+ /**
642
+ * Entity type discriminator
643
+ */
644
+ type EntityType = 'product' | 'product_category' | 'cms_page' | 'blog_page' | 'unknown';
645
+ /**
646
+ * Entity route response - polymorphic based on entity type
647
+ */
648
+ interface EntityRoute {
649
+ entityType: EntityType;
650
+ entityId: number;
651
+ url: string;
652
+ }
653
+ /**
654
+ * Product entity route
655
+ */
656
+ interface ProductEntityRoute extends EntityRoute {
657
+ entityType: 'product';
658
+ entity: Product;
659
+ }
660
+ /**
661
+ * Product category entity route
662
+ */
663
+ interface ProductCategoryEntityRoute extends EntityRoute {
664
+ entityType: 'product_category';
665
+ entity: ProductCategory;
666
+ }
667
+ /**
668
+ * CMS page entity route
669
+ */
670
+ interface CMSPageEntityRoute extends EntityRoute {
671
+ entityType: 'cms_page';
672
+ entity: CmsPage;
673
+ }
674
+ /**
675
+ * Blog page entity route
676
+ */
677
+ interface BlogPageEntityRoute extends EntityRoute {
678
+ entityType: 'blog_page';
679
+ entity: BlogPage;
680
+ }
681
+ /**
682
+ * Unknown entity route (404)
683
+ */
684
+ interface UnknownEntityRoute extends EntityRoute {
685
+ entityType: 'unknown';
686
+ entity?: never;
687
+ }
688
+ /**
689
+ * Union type for all possible entity routes
690
+ */
691
+ type EntityRouteResponse = ProductEntityRoute | ProductCategoryEntityRoute | CMSPageEntityRoute | BlogPageEntityRoute | UnknownEntityRoute;
692
+
693
+ /**
694
+ * Menu and Navigation Types
695
+ */
696
+ /**
697
+ * Clean navigation menu item returned by SDK
698
+ */
699
+ interface MenuItem {
700
+ name: string;
701
+ url: string;
702
+ children: MenuItem[];
703
+ }
704
+ /**
705
+ * Raw menu tree structure from API (camelCased by HTTP client)
706
+ */
707
+ interface MenuTree {
708
+ id: number;
709
+ identifier: string;
710
+ treeStructure: {
711
+ nodes: MenuNode[];
712
+ };
713
+ }
714
+ /**
715
+ * Raw menu node from API (camelCased by HTTP client)
716
+ */
717
+ interface MenuNode {
718
+ entityType: 'product_category' | 'product' | 'cms_page' | 'blog_page' | 'url';
719
+ entityId: number | null;
720
+ entity?: {
721
+ id?: number;
722
+ name?: string;
723
+ title?: string;
724
+ url?: string;
725
+ enabled?: boolean;
726
+ };
727
+ details?: {
728
+ title?: string;
729
+ isTitleDefault?: boolean;
730
+ url?: string;
731
+ name?: string;
732
+ entityType?: string;
733
+ includeChildren?: boolean;
734
+ };
735
+ children: MenuNode[];
736
+ }
737
+
738
+ /**
739
+ * Credentials Manager for guest users
740
+ * Manages cart, invoice, shipping, and payment credentials.
741
+ * Accepts an optional StorageAdapter — defaults to localStorage in browsers,
742
+ * in-memory otherwise (SSR / server actions).
743
+ */
744
+
745
+ interface StorageAdapter {
746
+ getItem(key: string): string | null;
747
+ setItem(key: string, value: string): void;
748
+ removeItem(key: string): void;
749
+ }
750
+ declare class MemoryStorage implements StorageAdapter {
751
+ private data;
752
+ getItem(key: string): string | null;
753
+ setItem(key: string, value: string): void;
754
+ removeItem(key: string): void;
755
+ }
756
+ declare class CredentialsManager {
757
+ private readonly CART_KEY;
758
+ private readonly INVOICE_KEY;
759
+ private readonly SHIPPING_KEY;
760
+ private readonly PAYMENT_KEY;
761
+ private readonly DISCOUNT_KEY;
762
+ private storage;
763
+ constructor(storage?: StorageAdapter);
764
+ /**
765
+ * Cart Credentials
766
+ */
767
+ getCartCredentials(): CartCredentials | null;
768
+ setCartCredentials(credentials: CartCredentials & {
769
+ id?: number;
770
+ }): void;
771
+ clearCartCredentials(): void;
772
+ /**
773
+ * Invoice Credentials
774
+ */
775
+ getInvoiceCredentials(): InvoiceCredentials | null;
776
+ setInvoiceCredentials(credentials: InvoiceCredentials): void;
777
+ clearInvoiceCredentials(): void;
778
+ /**
779
+ * Shipping Address Credentials
780
+ */
781
+ getShippingCredentials(): ShippingAddressCredentials | null;
782
+ setShippingCredentials(credentials: ShippingAddressCredentials): void;
783
+ clearShippingCredentials(): void;
784
+ /**
785
+ * Payment Credentials
786
+ */
787
+ getPaymentCredentials(): PaymentCredentials | null;
788
+ setPaymentCredentials(credentials: PaymentCredentials): void;
789
+ clearPaymentCredentials(): void;
790
+ /**
791
+ * Discount Code
792
+ */
793
+ getDiscountCode(): string | null;
794
+ setDiscountCode(code: string): void;
795
+ clearDiscountCode(): void;
796
+ /**
797
+ * Clear all credentials
798
+ */
799
+ clearAll(): void;
800
+ private getItem;
801
+ private setItem;
802
+ private removeItem;
803
+ }
804
+
805
+ /**
806
+ * Token storage for auth token persistence
807
+ * Primary storage: localStorage (user_id_token), with cookie fallback.
808
+ */
809
+
810
+ declare class TokenStorage {
811
+ private readonly tokenKey;
812
+ /**
813
+ * Get token from localStorage (fallback to cookie)
814
+ */
815
+ get(): string | null;
816
+ /**
817
+ * Set token in localStorage and cookie fallback
818
+ */
819
+ set(token: string, options?: CookieOptions): void;
820
+ /**
821
+ * Remove token from both localStorage and cookie
822
+ */
823
+ remove(): void;
824
+ private getFromLocalStorage;
825
+ private setInLocalStorage;
826
+ private removeFromLocalStorage;
827
+ /**
828
+ * Parse document.cookie into key-value pairs
829
+ */
830
+ private parseCookies;
831
+ /**
832
+ * Set a cookie with options
833
+ */
834
+ private setCookie;
835
+ }
836
+
837
+ /**
838
+ * HTTP Client with native fetch
839
+ * Provides unified response pattern, retry logic, caching, and automatic data transformation
840
+ */
841
+
842
+ declare class HttpClient {
843
+ private baseUrl;
844
+ private domain;
845
+ private config;
846
+ private tokenStorage;
847
+ private cache;
848
+ private fetchApi;
849
+ constructor(config: Required<SazitoConfig>);
850
+ /**
851
+ * GET request
852
+ */
853
+ get<T>(endpoint: string, options?: RequestOptions & {
854
+ params?: Record<string, any>;
855
+ }): Promise<SazitoResponse<T>>;
856
+ /**
857
+ * POST request
858
+ */
859
+ post<T>(endpoint: string, body?: any, options?: RequestOptions): Promise<SazitoResponse<T>>;
860
+ /**
861
+ * PUT request
862
+ */
863
+ put<T>(endpoint: string, body?: any, options?: RequestOptions): Promise<SazitoResponse<T>>;
864
+ /**
865
+ * DELETE request
866
+ */
867
+ delete<T>(endpoint: string, options?: RequestOptions): Promise<SazitoResponse<T>>;
868
+ /**
869
+ * Core request method
870
+ */
871
+ private request;
872
+ /**
873
+ * Build full URL with query params
874
+ */
875
+ private buildUrl;
876
+ /**
877
+ * Get request headers
878
+ */
879
+ private getHeaders;
880
+ private isMultipartBody;
881
+ /**
882
+ * Check if status code should trigger a retry
883
+ */
884
+ private shouldRetry;
885
+ /**
886
+ * Delay helper for retries
887
+ */
888
+ private delay;
889
+ /**
890
+ * Extract API name from endpoint for cache management
891
+ */
892
+ private getApiName;
893
+ /**
894
+ * Get token storage instance
895
+ */
896
+ getTokenStorage(): TokenStorage;
897
+ /**
898
+ * Clear all cache
899
+ */
900
+ clearCache(): void;
901
+ }
902
+
903
+ /**
904
+ * Products API
905
+ */
906
+
907
+ declare class ProductsAPI {
908
+ private http;
909
+ constructor(http: HttpClient);
910
+ /**
911
+ * Map SDK sort values to API sort values
912
+ */
913
+ private mapSortToApi;
914
+ /**
915
+ * Transform filters to API request params
916
+ */
917
+ private transformFilters;
918
+ /**
919
+ * Get a single product by slug or URL path
920
+ * Uses the entity route API to resolve the product
921
+ */
922
+ get(slugOrPath: string, options?: RequestOptions): Promise<SazitoResponse<Product>>;
923
+ /**
924
+ * List products with filters
925
+ */
926
+ list(filters?: ProductFilters, options?: RequestOptions): Promise<SazitoResponse<PaginatedResponse<Product>>>;
927
+ /**
928
+ * Search across all entity types (products, blog pages, CMS pages, product categories)
929
+ */
930
+ search(query: string, filters?: ProductFilters, options?: RequestOptions): Promise<SazitoResponse<SearchResponse>>;
931
+ }
932
+
933
+ /**
934
+ * Categories API
935
+ */
936
+
937
+ /**
938
+ * Category tree node structure
939
+ */
940
+ interface CategoryTreeNode {
941
+ id: number;
942
+ entityType: 'product_category';
943
+ entityId: number;
944
+ entity: ProductCategory;
945
+ details: JsonObject;
946
+ children: CategoryTreeNode[];
947
+ createdAt: string;
948
+ updatedAt: string;
949
+ }
950
+ /**
951
+ * Category tree structure
952
+ */
953
+ interface CategoryTree {
954
+ id: number;
955
+ treeType: 'product_categories';
956
+ treeStructure: {
957
+ nodes: CategoryTreeNode[];
958
+ };
959
+ }
960
+ /**
961
+ * Category list response with hierarchical tree
962
+ */
963
+ interface CategoryListResponse {
964
+ categories: ProductCategory[];
965
+ tree: CategoryTree;
966
+ }
967
+ /**
968
+ * Category list filters
969
+ */
970
+ interface CategoryFilters {
971
+ page?: number;
972
+ pageSize?: number;
973
+ }
974
+ declare class CategoriesAPI {
975
+ private http;
976
+ constructor(http: HttpClient);
977
+ /**
978
+ * Get a single category by ID or slug
979
+ */
980
+ get(idOrSlug: string | number, options?: RequestOptions): Promise<SazitoResponse<ProductCategory>>;
981
+ /**
982
+ * List all categories with hierarchical tree structure
983
+ * @param filters Optional pagination filters
984
+ * @param options Additional request options
985
+ */
986
+ list(filters?: CategoryFilters, options?: RequestOptions): Promise<SazitoResponse<CategoryListResponse>>;
987
+ }
988
+
989
+ /**
990
+ * Cart API
991
+ * Supports both authenticated and guest users via credentials
992
+ */
993
+
994
+ interface AddItemAttributesInput {
995
+ formAttributes?: Record<string, FormAttributeValue>;
996
+ schedulerBookingAttributes?: CreateCartInput['schedulerBookingAttributes'];
997
+ coupon?: string;
998
+ }
999
+ interface UpdateItemAttributesInput {
1000
+ formAttributes?: Record<string, FormAttributeValue>;
1001
+ coupon?: string;
1002
+ deleteCoupon?: boolean;
1003
+ }
1004
+ declare class CartAPI {
1005
+ private http;
1006
+ private credentials;
1007
+ constructor(http: HttpClient, credentials: CredentialsManager);
1008
+ private persistCartCredentials;
1009
+ /**
1010
+ * Get current cart
1011
+ */
1012
+ get(options?: RequestOptions): Promise<SazitoResponse<Cart>>;
1013
+ /**
1014
+ * Create a new cart
1015
+ */
1016
+ create(input: CreateCartInput, options?: RequestOptions): Promise<SazitoResponse<Cart>>;
1017
+ /**
1018
+ * Add item to cart
1019
+ */
1020
+ addItem(variantId: number, count: number, formAttributes?: Record<string, FormAttributeValue>, options?: RequestOptions): Promise<SazitoResponse<Cart>>;
1021
+ /**
1022
+ * Add item to cart with standardized attributes payload.
1023
+ */
1024
+ addItemWithAttributes(variantId: number, count: number, attributes?: AddItemAttributesInput, options?: RequestOptions): Promise<SazitoResponse<Cart>>;
1025
+ /**
1026
+ * Update cart item quantity
1027
+ */
1028
+ updateItem(cartProductId: number | string, variantId: number, count: number, formAttributes?: Record<string, FormAttributeValue>, options?: RequestOptions): Promise<SazitoResponse<Cart>>;
1029
+ /**
1030
+ * Update cart item quantity and optional coupon mutations.
1031
+ */
1032
+ updateItemWithAttributes(cartProductId: number | string, variantId: number, count: number, attributes?: UpdateItemAttributesInput, options?: RequestOptions): Promise<SazitoResponse<Cart>>;
1033
+ /**
1034
+ * Remove item from cart
1035
+ */
1036
+ removeItem(cartProductId: number | string, variantId: number, options?: RequestOptions): Promise<SazitoResponse<Cart>>;
1037
+ /**
1038
+ * Clear current cart credentials
1039
+ */
1040
+ clearCart(): void;
1041
+ }
1042
+
1043
+ /**
1044
+ * Orders API
1045
+ * Requires authentication
1046
+ */
1047
+
1048
+ declare class OrdersAPI {
1049
+ private http;
1050
+ constructor(http: HttpClient);
1051
+ /**
1052
+ * List orders (requires authentication)
1053
+ */
1054
+ list(filters?: OrderFilters, options?: RequestOptions): Promise<SazitoResponse<OrdersListResponse>>;
1055
+ /**
1056
+ * Get single order by ID (requires authentication)
1057
+ */
1058
+ get(orderId: number, options?: RequestOptions): Promise<SazitoResponse<Order>>;
1059
+ }
1060
+
1061
+ /**
1062
+ * Invoices API (Checkout)
1063
+ */
1064
+
1065
+ interface AddInvoiceFormInput {
1066
+ formAttributes: JsonObject;
1067
+ invoiceIdentifier?: string;
1068
+ identifier?: string;
1069
+ }
1070
+ declare class InvoicesAPI {
1071
+ private http;
1072
+ private credentials;
1073
+ constructor(http: HttpClient, credentials: CredentialsManager);
1074
+ private normalizeInvoiceResponse;
1075
+ /**
1076
+ * Get current invoice
1077
+ */
1078
+ get(options?: RequestOptions): Promise<SazitoResponse<Invoice>>;
1079
+ /**
1080
+ * Create a new invoice from cart
1081
+ */
1082
+ create(options?: RequestOptions): Promise<SazitoResponse<Invoice>>;
1083
+ /**
1084
+ * Refresh invoice (sync with cart)
1085
+ */
1086
+ refresh(options?: RequestOptions): Promise<SazitoResponse<Invoice>>;
1087
+ /**
1088
+ * Add shipping address to invoice
1089
+ */
1090
+ addShippingAddress(shippingAddressId: number, shippingAddressIdentifier: string, options?: RequestOptions): Promise<SazitoResponse<Invoice>>;
1091
+ /**
1092
+ * Add discount code to invoice
1093
+ */
1094
+ addDiscountCode(code: string, options?: RequestOptions): Promise<SazitoResponse<Invoice>>;
1095
+ /**
1096
+ * Assign shipping method to invoice
1097
+ */
1098
+ assignShippingMethod(shippings: ShippingAssignment[], options?: RequestOptions): Promise<SazitoResponse<Invoice>>;
1099
+ /**
1100
+ * Add invoice details (user comment)
1101
+ */
1102
+ addDetails(comment: string, options?: RequestOptions): Promise<SazitoResponse<Invoice>>;
1103
+ /**
1104
+ * Attach checkout dynamic form data to invoice.
1105
+ */
1106
+ addForm(input: AddInvoiceFormInput, options?: RequestOptions): Promise<SazitoResponse<Invoice>>;
1107
+ /**
1108
+ * Apply wallet credit to invoice.
1109
+ */
1110
+ addCredit(options?: RequestOptions): Promise<SazitoResponse<Invoice>>;
1111
+ /**
1112
+ * Remove wallet credit from invoice.
1113
+ */
1114
+ removeCredit(options?: RequestOptions): Promise<SazitoResponse<Invoice>>;
1115
+ /**
1116
+ * Toggle wallet credit based on current invoice state.
1117
+ */
1118
+ toggleCredit(options?: RequestOptions): Promise<SazitoResponse<Invoice>>;
1119
+ /**
1120
+ * Get applicable shipping methods for invoice
1121
+ */
1122
+ getApplicableShippingMethods(options?: RequestOptions): Promise<SazitoResponse<ApplicableShippingMethods>>;
1123
+ /**
1124
+ * Clear current invoice credentials
1125
+ */
1126
+ clearInvoice(): void;
1127
+ }
1128
+
1129
+ /**
1130
+ * Shipping API (Addresses and Methods)
1131
+ */
1132
+
1133
+ declare class ShippingAPI {
1134
+ private http;
1135
+ private credentials;
1136
+ constructor(http: HttpClient, credentials: CredentialsManager);
1137
+ private sanitizeAddressInput;
1138
+ private unwrapAddressPayload;
1139
+ private extractAddressList;
1140
+ /**
1141
+ * Create shipping address
1142
+ */
1143
+ createAddress(address: ShippingAddressInput, options?: RequestOptions): Promise<SazitoResponse<ShippingAddress>>;
1144
+ /**
1145
+ * Update the address referenced by the currently stored credentials.
1146
+ * @deprecated Do not use during checkout. Existing invoices can reference
1147
+ * this row, so mutation can rewrite address data shown on previous orders.
1148
+ * Create a new address snapshot with createAddress instead.
1149
+ */
1150
+ updateAddress(address: ShippingAddressInput, options?: RequestOptions): Promise<SazitoResponse<ShippingAddress>>;
1151
+ /**
1152
+ * Get the authenticated user's shipping addresses, newest first.
1153
+ * This endpoint is intentionally not cached: checkout must see an address
1154
+ * created by the user's most recent order immediately.
1155
+ */
1156
+ listAddresses(options?: RequestOptions): Promise<SazitoResponse<ShippingAddress[]>>;
1157
+ /**
1158
+ * Get shipping address
1159
+ */
1160
+ getAddress(options?: RequestOptions): Promise<SazitoResponse<ShippingAddress>>;
1161
+ /**
1162
+ * Get list of enabled shipping methods
1163
+ */
1164
+ getMethods(options?: RequestOptions): Promise<SazitoResponse<ShippingMethod[]>>;
1165
+ /**
1166
+ * Clear shipping address credentials
1167
+ */
1168
+ clearAddress(): void;
1169
+ }
1170
+
1171
+ /**
1172
+ * Payments API
1173
+ */
1174
+
1175
+ declare class PaymentsAPI {
1176
+ private http;
1177
+ private credentials;
1178
+ private readonly pinchedPayments;
1179
+ constructor(http: HttpClient, credentials: CredentialsManager);
1180
+ /**
1181
+ * Get list of payment methods for invoice
1182
+ */
1183
+ getMethods(options?: RequestOptions): Promise<SazitoResponse<PaymentMethod[]>>;
1184
+ /**
1185
+ * Create payment
1186
+ */
1187
+ create(paymentTypeId: number, options?: RequestOptions): Promise<SazitoResponse<Payment>>;
1188
+ /**
1189
+ * Initialize payment: start the payment step before redirecting the user to
1190
+ * the gateway. Returns the next {@link PaymentAction} (typically REDIRECT or
1191
+ * POST for hosted gateways, or showOrder for zero-amount/instant payments).
1192
+ */
1193
+ initialize(options?: RequestOptions): Promise<SazitoResponse<PaymentAction>>;
1194
+ /**
1195
+ * Verify payment after the user returns from the gateway. Forwards the
1196
+ * gateway callback parameters (e.g. `tatoken`, `trackingData`, `isFailed`,
1197
+ * `code`) to the same payment-step endpoint and returns the settled
1198
+ * {@link PaymentAction} (showOrder on success, FAIL/StockViolated otherwise,
1199
+ * or pending if the gateway has not reported back yet).
1200
+ */
1201
+ verify(input?: PaymentStepInput, options?: RequestOptions): Promise<SazitoResponse<PaymentAction>>;
1202
+ /**
1203
+ * Process payment step (for card-to-card or multi-step payments).
1204
+ *
1205
+ * @deprecated Prefer {@link verify} for gateway-return verification.
1206
+ */
1207
+ processStep(input: PaymentStepInput, options?: RequestOptions): Promise<SazitoResponse<PaymentAction>>;
1208
+ /**
1209
+ * Shared core for the `process_payment_step` endpoint used by
1210
+ * {@link initialize}, {@link verify} and {@link processStep}.
1211
+ */
1212
+ private submitPaymentStep;
1213
+ /**
1214
+ * Process payment step in form mode (non-JSON content-type).
1215
+ */
1216
+ processStepForm(input: FormData | PaymentStepFormFields, options?: RequestOptions): Promise<SazitoResponse<PaymentAction>>;
1217
+ /**
1218
+ * Poll payment state every 15 seconds until action changes from pending.
1219
+ */
1220
+ pollUntilSettled(options?: RequestOptions, intervalMs?: number): Promise<SazitoResponse<PaymentAction>>;
1221
+ /**
1222
+ * Clear payment credentials
1223
+ */
1224
+ clearPayment(): void;
1225
+ private withExactJsonHeader;
1226
+ private buildProcessStepFormData;
1227
+ private appendFormValue;
1228
+ /**
1229
+ * Post-process a `process_payment_step` response. The exact-JSON endpoint
1230
+ * returns an envelope `{ result: PaymentAction, error, error_code, status }`;
1231
+ * unwrap `result`, surface envelope-level errors, and run the pinch hook.
1232
+ */
1233
+ private finalizeStepResponse;
1234
+ private normalizeAction;
1235
+ private callPinchAfterSuccessfulPayment;
1236
+ }
1237
+
1238
+ /**
1239
+ * Users API (Authentication and user management)
1240
+ */
1241
+
1242
+ /**
1243
+ * Login input (SDK uses camelCase)
1244
+ */
1245
+ interface LoginInput {
1246
+ email: string;
1247
+ password: string;
1248
+ }
1249
+ /**
1250
+ * Register input (SDK uses camelCase)
1251
+ */
1252
+ interface RegisterInput {
1253
+ email: string;
1254
+ password: string;
1255
+ passwordConfirmation: string;
1256
+ firstName?: string;
1257
+ lastName?: string;
1258
+ mobilePhone?: string;
1259
+ }
1260
+ /**
1261
+ * Mobile login input
1262
+ */
1263
+ interface MobileLoginInput {
1264
+ mobilePhone: string;
1265
+ }
1266
+ /**
1267
+ * Verify mobile OTP input (SDK uses camelCase)
1268
+ */
1269
+ interface VerifyMobileInput {
1270
+ mobilePhone: string;
1271
+ token: string;
1272
+ }
1273
+ /**
1274
+ * Passwordless email login input
1275
+ */
1276
+ interface EmailLoginRequestInput {
1277
+ email: string;
1278
+ }
1279
+ /**
1280
+ * Forgot password input
1281
+ */
1282
+ interface ForgotPasswordInput {
1283
+ email: string;
1284
+ }
1285
+ /**
1286
+ * Reset password input (SDK uses camelCase)
1287
+ */
1288
+ interface ResetPasswordInput {
1289
+ forgotPasswordToken: string;
1290
+ password: string;
1291
+ passwordConfirmation: string;
1292
+ }
1293
+ /**
1294
+ * Update user profile input
1295
+ */
1296
+ interface UpdateProfileInput {
1297
+ firstName?: string;
1298
+ lastName?: string;
1299
+ email?: string;
1300
+ password?: string;
1301
+ passwordConfirmation?: string;
1302
+ birthDate?: string;
1303
+ }
1304
+ /**
1305
+ * Update user phone request input
1306
+ */
1307
+ interface UpdateMobilePhoneRequestInput {
1308
+ mobilePhone: string;
1309
+ }
1310
+ /**
1311
+ * Verify user phone update input
1312
+ */
1313
+ interface UpdateMobilePhoneVerificationInput {
1314
+ mobilePhone: string;
1315
+ token: string;
1316
+ }
1317
+ interface LoginResponse {
1318
+ jwt: string;
1319
+ user?: User;
1320
+ }
1321
+ declare class UsersAPI {
1322
+ private http;
1323
+ constructor(http: HttpClient);
1324
+ private normalizeUserResponse;
1325
+ private normalizeLoginResponse;
1326
+ /**
1327
+ * Login with email and password
1328
+ */
1329
+ login(input: LoginInput, options?: RequestOptions): Promise<SazitoResponse<LoginResponse>>;
1330
+ /**
1331
+ * Request mobile OTP
1332
+ */
1333
+ requestMobileOTP(input: MobileLoginInput, options?: RequestOptions): Promise<SazitoResponse<any>>;
1334
+ /**
1335
+ * Verify mobile OTP
1336
+ */
1337
+ verifyMobileOTP(input: VerifyMobileInput, options?: RequestOptions): Promise<SazitoResponse<LoginResponse>>;
1338
+ /**
1339
+ * Passwordless login request via email
1340
+ */
1341
+ requestEmailLogin(input: EmailLoginRequestInput, options?: RequestOptions): Promise<SazitoResponse<any>>;
1342
+ /**
1343
+ * Register new user
1344
+ */
1345
+ register(input: RegisterInput, options?: RequestOptions): Promise<SazitoResponse<User>>;
1346
+ /**
1347
+ * Get current user (requires authentication)
1348
+ */
1349
+ getCurrentUser(options?: RequestOptions): Promise<SazitoResponse<User>>;
1350
+ /**
1351
+ * Update user profile (requires authentication)
1352
+ */
1353
+ updateProfile(userId: number, data: UpdateProfileInput, options?: RequestOptions): Promise<SazitoResponse<User>>;
1354
+ /**
1355
+ * Request mobile phone update (requires authentication)
1356
+ */
1357
+ requestMobilePhoneUpdate(input: UpdateMobilePhoneRequestInput, options?: RequestOptions): Promise<SazitoResponse<any>>;
1358
+ /**
1359
+ * Verify mobile phone update (requires authentication)
1360
+ */
1361
+ verifyMobilePhoneUpdate(input: UpdateMobilePhoneVerificationInput, options?: RequestOptions): Promise<SazitoResponse<User>>;
1362
+ /**
1363
+ * Forgot password - send reset email
1364
+ */
1365
+ forgotPassword(input: ForgotPasswordInput, options?: RequestOptions): Promise<SazitoResponse<any>>;
1366
+ /**
1367
+ * Revive/Reset password with token
1368
+ */
1369
+ revivePassword(input: ResetPasswordInput, options?: RequestOptions): Promise<SazitoResponse<LoginResponse>>;
1370
+ /**
1371
+ * Merge guest and current user accounts after login
1372
+ */
1373
+ mergeUser(options?: RequestOptions): Promise<SazitoResponse<any>>;
1374
+ }
1375
+
1376
+ /**
1377
+ * Search API
1378
+ */
1379
+
1380
+ interface SearchFilters {
1381
+ page?: number;
1382
+ pageSize?: number;
1383
+ categoryId?: number;
1384
+ minPrice?: number;
1385
+ maxPrice?: number;
1386
+ }
1387
+ declare class SearchAPI {
1388
+ private http;
1389
+ constructor(http: HttpClient);
1390
+ private transformFilters;
1391
+ /**
1392
+ * Query across multiple entity types (products, blog pages, CMS pages, categories)
1393
+ */
1394
+ query(term: string, filters?: SearchFilters, options?: RequestOptions): Promise<SazitoResponse<SearchResponse>>;
1395
+ }
1396
+
1397
+ /**
1398
+ * Feedbacks API (Tajrobe reviews + legacy feedback methods)
1399
+ */
1400
+
1401
+ type RecommendationStatus = 'RECOMMENDED' | 'NEUTRAL' | 'NOT-RECOMMENDED' | 'NONE';
1402
+ interface FeedbackProductAttribute {
1403
+ name: string;
1404
+ value: string;
1405
+ }
1406
+ interface FeedbackProductImage {
1407
+ url: string;
1408
+ alt: string;
1409
+ }
1410
+ interface FeedbackSeedItem {
1411
+ productId: string;
1412
+ productVariantId: string;
1413
+ productName: string;
1414
+ productAttributes: FeedbackProductAttribute[];
1415
+ productImage: FeedbackProductImage;
1416
+ }
1417
+ interface FeedbackSeed {
1418
+ orderId: string;
1419
+ orderIdentifier: string;
1420
+ hasCommentAlready: boolean;
1421
+ items: FeedbackSeedItem[];
1422
+ }
1423
+ interface CreateOrderRatingInput {
1424
+ orderId: string;
1425
+ orderIdentifier: string;
1426
+ orderRate: number;
1427
+ }
1428
+ interface CommentResponse {
1429
+ id: string;
1430
+ }
1431
+ interface ProductReviewRequest {
1432
+ commentId: string;
1433
+ productId: string;
1434
+ productVariantId: string;
1435
+ productName: string;
1436
+ productAttributes: FeedbackProductAttribute[];
1437
+ productImage: FeedbackProductImage;
1438
+ productRate: number;
1439
+ text: string;
1440
+ pros: string[];
1441
+ cons: string[];
1442
+ recommendationStatus: RecommendationStatus;
1443
+ attachmentsServeKeys: string[];
1444
+ owner: boolean;
1445
+ isAnonymous: boolean;
1446
+ }
1447
+ interface ProductStatistics {
1448
+ productStatistics: {
1449
+ averageRate: number;
1450
+ totalCount: number;
1451
+ recommendations: {
1452
+ recommendedPercentage: number;
1453
+ recommendedTotalCount: number;
1454
+ };
1455
+ };
1456
+ }
1457
+ interface ProductReview {
1458
+ productRate: number;
1459
+ userFirstName: string;
1460
+ userLastName: string;
1461
+ createdAt: string;
1462
+ owner: boolean;
1463
+ text: string;
1464
+ recommendationStatus: RecommendationStatus;
1465
+ pros: string[];
1466
+ cons: string[];
1467
+ isAnonymous: boolean;
1468
+ metadata: {
1469
+ variantOptions: any[];
1470
+ productName: string;
1471
+ variantId: string;
1472
+ };
1473
+ attachments: Array<{
1474
+ serveUrl: string;
1475
+ }>;
1476
+ }
1477
+ interface ProductReviewsFilters {
1478
+ pageNumber?: number;
1479
+ pageSize?: number;
1480
+ }
1481
+ interface ProductReviewsResponse {
1482
+ entities: ProductReview[];
1483
+ pageNumber: number;
1484
+ pageSize: number;
1485
+ totalCount: number;
1486
+ averageRate: number;
1487
+ recommendations: {
1488
+ recommendedPercentage: number;
1489
+ recommendedTotalCount: number;
1490
+ };
1491
+ }
1492
+ interface ReviewAttachmentInput {
1493
+ file: File | Blob;
1494
+ name?: string;
1495
+ alt?: string;
1496
+ }
1497
+ interface ReviewUploadedImage {
1498
+ id: string;
1499
+ url: string;
1500
+ alt: string;
1501
+ serveUrl: string;
1502
+ serveKey: string;
1503
+ }
1504
+ interface ReviewImageUploadResponse {
1505
+ images: ReviewUploadedImage[];
1506
+ }
1507
+ /**
1508
+ * Legacy feedback model kept for backwards compatibility.
1509
+ */
1510
+ interface Feedback {
1511
+ id: number;
1512
+ user?: {
1513
+ id: number;
1514
+ name: string;
1515
+ };
1516
+ productId?: number;
1517
+ rating?: number;
1518
+ comment: string;
1519
+ status: 'pending' | 'approved' | 'rejected';
1520
+ createdAt: string;
1521
+ updatedAt: string;
1522
+ }
1523
+ /**
1524
+ * Legacy create payload kept for backwards compatibility.
1525
+ */
1526
+ interface CreateFeedbackInput {
1527
+ productId?: number;
1528
+ rating?: number;
1529
+ comment: string;
1530
+ }
1531
+ /**
1532
+ * Legacy filters kept for backwards compatibility.
1533
+ */
1534
+ interface FeedbackFilters {
1535
+ productId?: number;
1536
+ page?: number;
1537
+ pageSize?: number;
1538
+ }
1539
+ declare class FeedbacksAPI {
1540
+ private http;
1541
+ constructor(http: HttpClient);
1542
+ private normalizeSeedItem;
1543
+ private normalizeSeed;
1544
+ private normalizeProductReview;
1545
+ private normalizeProductReviewsResponse;
1546
+ private transformLegacyFilters;
1547
+ /**
1548
+ * Validate order and get products that can be reviewed.
1549
+ */
1550
+ getSeed(orderIdentifier: string, options?: RequestOptions): Promise<SazitoResponse<FeedbackSeed>>;
1551
+ /**
1552
+ * Submit order/shop rating and get a comment identifier for product review steps.
1553
+ */
1554
+ createOrderRating(input: CreateOrderRatingInput, options?: RequestOptions): Promise<SazitoResponse<CommentResponse>>;
1555
+ /**
1556
+ * Submit product-level review details.
1557
+ */
1558
+ submitProductReview(input: ProductReviewRequest, options?: RequestOptions): Promise<SazitoResponse<void>>;
1559
+ /**
1560
+ * Fetch product review statistics (without review list).
1561
+ */
1562
+ getProductStatistics(productId: string, options?: RequestOptions): Promise<SazitoResponse<ProductStatistics>>;
1563
+ /**
1564
+ * Fetch paginated product reviews.
1565
+ */
1566
+ getProductReviews(productId: string, filters?: ProductReviewsFilters, options?: RequestOptions): Promise<SazitoResponse<ProductReviewsResponse>>;
1567
+ /**
1568
+ * Upload review images and get serve keys for attachments.
1569
+ */
1570
+ uploadReviewImages(images: ReviewAttachmentInput[], options?: RequestOptions): Promise<SazitoResponse<ReviewImageUploadResponse>>;
1571
+ /**
1572
+ * Legacy list method kept for backwards compatibility.
1573
+ */
1574
+ list(filters?: FeedbackFilters, options?: RequestOptions): Promise<SazitoResponse<PaginatedResponse<Feedback>>>;
1575
+ /**
1576
+ * Legacy create method kept for backwards compatibility.
1577
+ */
1578
+ create(input: CreateFeedbackInput, options?: RequestOptions): Promise<SazitoResponse<Feedback>>;
1579
+ /**
1580
+ * Legacy get method kept for backwards compatibility.
1581
+ */
1582
+ get(feedbackId: number, options?: RequestOptions): Promise<SazitoResponse<Feedback>>;
1583
+ }
1584
+
1585
+ /**
1586
+ * Wallet API (User wallet and transactions)
1587
+ */
1588
+
1589
+ type WalletTransactionReason = 'redeem' | 'NthPurchase' | 'merge-user' | 'SimpleCashbackRule' | 'BirthdateGift' | 'TajrobehAppreciation' | 'edit_order' | 'cancel_order' | 'edit_shipping_cost' | 'edit_cashback' | 'gift' | 'others' | 'Refund' | 'Charge' | 'Expired' | `${string}:activity`;
1590
+ interface WalletTransaction {
1591
+ id: string | number;
1592
+ reason: WalletTransactionReason;
1593
+ amount: number;
1594
+ createdAt: string;
1595
+ metaData?: Record<string, unknown>;
1596
+ }
1597
+ interface WalletBalance {
1598
+ balance: number;
1599
+ enabled: boolean;
1600
+ }
1601
+ interface Wallet extends WalletBalance {
1602
+ currency?: string;
1603
+ transactions?: WalletTransaction[];
1604
+ }
1605
+ interface TransactionFilters {
1606
+ pageNumber?: number;
1607
+ pageSize?: number;
1608
+ /** @deprecated Use `pageNumber`. */
1609
+ page_number?: number;
1610
+ /** @deprecated Use `pageSize`. */
1611
+ page_size?: number;
1612
+ }
1613
+ interface WalletTransactionsResponse {
1614
+ transactions: WalletTransaction[];
1615
+ pageNumber?: number;
1616
+ pageSize?: number;
1617
+ totalCount?: number;
1618
+ }
1619
+ declare class WalletAPI {
1620
+ private http;
1621
+ constructor(http: HttpClient);
1622
+ private validateInvoiceId;
1623
+ /**
1624
+ * Get wallet balance (requires authentication)
1625
+ */
1626
+ getBalance(options?: RequestOptions): Promise<SazitoResponse<Wallet>>;
1627
+ /**
1628
+ * List wallet transactions (requires authentication)
1629
+ */
1630
+ listTransactions(filters?: TransactionFilters, options?: RequestOptions): Promise<SazitoResponse<WalletTransactionsResponse>>;
1631
+ /**
1632
+ * Apply wallet credit on an invoice (requires authentication)
1633
+ */
1634
+ applyCredit(invoiceId: number, options?: RequestOptions): Promise<SazitoResponse<Invoice>>;
1635
+ /**
1636
+ * Remove wallet credit from an invoice (requires authentication)
1637
+ */
1638
+ removeCredit(invoiceId: number, options?: RequestOptions): Promise<SazitoResponse<Invoice>>;
1639
+ }
1640
+
1641
+ /**
1642
+ * CMS API (Content Management - Pages, Blogs, etc.)
1643
+ */
1644
+
1645
+ /**
1646
+ * CMS Page type (re-exported from search types for convenience)
1647
+ * Both regular pages and blog posts use this structure
1648
+ */
1649
+ type CMSPage = CmsPage;
1650
+
1651
+ /**
1652
+ * Filters for CMS pages list
1653
+ * Backend uses: page_number, page_size, filters[]
1654
+ */
1655
+ interface CMSFilters {
1656
+ page?: number;
1657
+ pageSize?: number;
1658
+ cmsPageTypes?: CMSPageType | CMSPageType[];
1659
+ }
1660
+ declare class CMSAPI {
1661
+ private http;
1662
+ constructor(http: HttpClient);
1663
+ /**
1664
+ * Get CMS page by URL path
1665
+ * Uses entity routes API (recommended approach)
1666
+ * @param urlPath - Page URL path (e.g., '/about-us')
1667
+ * @param options - Request options
1668
+ */
1669
+ getPage(urlPath: string, options?: RequestOptions): Promise<SazitoResponse<CMSPage>>;
1670
+ /**
1671
+ * List CMS pages (excludes blog posts)
1672
+ * @param filters - Filter options (will automatically exclude blog type)
1673
+ * @param options - Request options
1674
+ */
1675
+ listPages(filters?: CMSFilters, options?: RequestOptions): Promise<SazitoResponse<PaginatedResponse<CMSPage>>>;
1676
+ /**
1677
+ * Get blog post by URL path
1678
+ * Uses entity routes API (recommended approach)
1679
+ * @param urlPath - Blog post URL path (e.g., '/blog/my-post')
1680
+ * @param options - Request options
1681
+ */
1682
+ getBlogPost(urlPath: string, options?: RequestOptions): Promise<SazitoResponse<CMSPage>>;
1683
+ /**
1684
+ * List blog posts
1685
+ * @param filters - Filter options (will automatically filter for blog type)
1686
+ * @param options - Request options
1687
+ */
1688
+ listBlogPosts(filters?: CMSFilters, options?: RequestOptions): Promise<SazitoResponse<PaginatedResponse<CMSPage>>>;
1689
+ /**
1690
+ * List all CMS content (both pages and blog posts)
1691
+ * @param filters - Filter options
1692
+ * @param options - Request options
1693
+ */
1694
+ listAll(filters?: CMSFilters, options?: RequestOptions): Promise<SazitoResponse<PaginatedResponse<CMSPage>>>;
1695
+ }
1696
+
1697
+ /**
1698
+ * Images API (File upload)
1699
+ */
1700
+
1701
+ interface UploadImageResponse {
1702
+ id: number;
1703
+ url: string;
1704
+ filename: string;
1705
+ size: number;
1706
+ mime_type: string;
1707
+ }
1708
+ declare class ImagesAPI {
1709
+ private http;
1710
+ constructor(http: HttpClient);
1711
+ /**
1712
+ * Upload image file
1713
+ * @param file - File or Blob to upload
1714
+ */
1715
+ upload(file: File | Blob, options?: RequestOptions): Promise<SazitoResponse<UploadImageResponse>>;
1716
+ /**
1717
+ * Delete image
1718
+ */
1719
+ delete(imageId: number, options?: RequestOptions): Promise<SazitoResponse<void>>;
1720
+ }
1721
+
1722
+ /**
1723
+ * Visits API (Analytics and page views)
1724
+ */
1725
+
1726
+ /**
1727
+ * Visit tracking input (SDK uses camelCase)
1728
+ */
1729
+ interface VisitInput {
1730
+ url: string;
1731
+ referrer?: string;
1732
+ userAgent?: string;
1733
+ entityType?: 'product' | 'category' | 'page';
1734
+ entityId?: number;
1735
+ }
1736
+ /**
1737
+ * Visit tracking response (auto-transformed to camelCase by HTTP client)
1738
+ */
1739
+ interface VisitResponse {
1740
+ id: number;
1741
+ createdAt: string;
1742
+ }
1743
+ declare class VisitsAPI {
1744
+ private http;
1745
+ constructor(http: HttpClient);
1746
+ /**
1747
+ * Track visit analytics event.
1748
+ * Backend endpoint `/api/v1/visits/add` does not accept a payload.
1749
+ */
1750
+ track(inputOrOptions?: VisitInput | RequestOptions, options?: RequestOptions): Promise<SazitoResponse<VisitResponse>>;
1751
+ /**
1752
+ * Track product view
1753
+ */
1754
+ trackProduct(productId: number, url: string, options?: RequestOptions): Promise<SazitoResponse<VisitResponse>>;
1755
+ /**
1756
+ * Track category view
1757
+ */
1758
+ trackCategory(categoryId: number, url: string, options?: RequestOptions): Promise<SazitoResponse<VisitResponse>>;
1759
+ }
1760
+
1761
+ /**
1762
+ * Booking API (Scheduler and appointments)
1763
+ */
1764
+
1765
+ /**
1766
+ * Legacy event shape returned by some scheduler list endpoints.
1767
+ */
1768
+ interface Event {
1769
+ id: number;
1770
+ title: string;
1771
+ description?: string;
1772
+ startTime?: string;
1773
+ endTime?: string;
1774
+ capacity?: number;
1775
+ bookedCount?: number;
1776
+ availableSlots?: number;
1777
+ price?: number;
1778
+ location?: string;
1779
+ createdAt?: string;
1780
+ }
1781
+ /**
1782
+ * Event details used in product booking flow.
1783
+ */
1784
+ interface SchedulerEvent {
1785
+ entityId: number;
1786
+ title: string;
1787
+ description: string;
1788
+ durationsMinute: number[];
1789
+ }
1790
+ interface BookingTimeSlot {
1791
+ startTimeLocal: string;
1792
+ endTimeLocal: string;
1793
+ isAvailable: boolean;
1794
+ remainingCapacity: number;
1795
+ }
1796
+ interface BookingAvailableDay {
1797
+ date: string;
1798
+ timeSlots: BookingTimeSlot[];
1799
+ }
1800
+ interface EventAvailabilitiesResponse {
1801
+ availableDays: BookingAvailableDay[];
1802
+ }
1803
+ interface EventAvailabilityFilters {
1804
+ eventEntityId: number;
1805
+ duration: number;
1806
+ fromDate: string;
1807
+ toDate: string;
1808
+ timezone?: string;
1809
+ }
1810
+ interface CreateBookingInput {
1811
+ eventEntityId?: number;
1812
+ event_entity_id?: number;
1813
+ timezone: string;
1814
+ attendeeName?: string;
1815
+ attendee_name?: string;
1816
+ attendeeEmail?: string;
1817
+ attendee_email?: string;
1818
+ attendeePhone?: string;
1819
+ attendee_phone?: string;
1820
+ }
1821
+ interface Booking {
1822
+ id: number;
1823
+ eventId: number;
1824
+ event: Event;
1825
+ userId?: number;
1826
+ attendeeName: string;
1827
+ attendeeEmail?: string;
1828
+ attendeePhone?: string;
1829
+ status: 'pending' | 'confirmed' | 'cancelled';
1830
+ bookingTime: string;
1831
+ createdAt: string;
1832
+ }
1833
+ interface EventFilters {
1834
+ startDate?: string;
1835
+ start_date?: string;
1836
+ endDate?: string;
1837
+ end_date?: string;
1838
+ availableOnly?: boolean;
1839
+ available_only?: boolean;
1840
+ page?: number;
1841
+ pageSize?: number;
1842
+ page_size?: number;
1843
+ }
1844
+ declare class BookingAPI {
1845
+ private http;
1846
+ constructor(http: HttpClient);
1847
+ private transformEventFilters;
1848
+ /**
1849
+ * List available events (legacy scheduler listing).
1850
+ */
1851
+ listEvents(filters?: EventFilters, options?: RequestOptions): Promise<SazitoResponse<PaginatedResponse<Event>>>;
1852
+ /**
1853
+ * Get event details used for booking (durations, title, description).
1854
+ */
1855
+ getEvent(entityId: number, options?: RequestOptions): Promise<SazitoResponse<SchedulerEvent>>;
1856
+ /**
1857
+ * Get available days and time slots for an event.
1858
+ */
1859
+ getEventAvailabilities(filters: EventAvailabilityFilters, options?: RequestOptions): Promise<SazitoResponse<EventAvailabilitiesResponse>>;
1860
+ /**
1861
+ * Create booking (legacy endpoint kept for backward compatibility).
1862
+ */
1863
+ createBooking(input: CreateBookingInput, options?: RequestOptions): Promise<SazitoResponse<Booking>>;
1864
+ /**
1865
+ * List user bookings (requires authentication).
1866
+ */
1867
+ listBookings(options?: RequestOptions): Promise<SazitoResponse<PaginatedResponse<Booking>>>;
1868
+ /**
1869
+ * Cancel booking.
1870
+ */
1871
+ cancelBooking(bookingId: number, options?: RequestOptions): Promise<SazitoResponse<Booking>>;
1872
+ }
1873
+
1874
+ /**
1875
+ * Entity Routes API
1876
+ * Resolves URLs to entity data (products, categories, CMS pages)
1877
+ */
1878
+
1879
+ declare class EntityRoutesAPI {
1880
+ private http;
1881
+ constructor(http: HttpClient);
1882
+ /**
1883
+ * Resolve URL path to entity data
1884
+ * @param urlPart - URL pathname (e.g., '/product/laptop-abc' or '/category/electronics')
1885
+ * @returns Entity route with cleaned entity data based on type
1886
+ */
1887
+ resolve(urlPart: string, options?: RequestOptions): Promise<SazitoResponse<EntityRouteResponse>>;
1888
+ }
1889
+
1890
+ /**
1891
+ * Menu API (Header Menu, Navigation Trees)
1892
+ */
1893
+
1894
+ declare class MenuAPI {
1895
+ private http;
1896
+ constructor(http: HttpClient);
1897
+ /**
1898
+ * Fetch header menu by identifier
1899
+ * @param identifier - Menu identifier (default: 'headermenu')
1900
+ * @param options - Request options
1901
+ */
1902
+ getHeaderMenu(identifier?: string, options?: RequestOptions): Promise<SazitoResponse<MenuItem[]>>;
1903
+ /**
1904
+ * Convert raw tree structure to clean navigation items
1905
+ * Filters out disabled items and processes nested children recursively
1906
+ */
1907
+ private convertRawTreeToNavigation;
1908
+ /**
1909
+ * Extract the display title for a menu node
1910
+ */
1911
+ private findNodeTitle;
1912
+ private firstNonEmpty;
1913
+ /**
1914
+ * Extract the URL for a menu node
1915
+ */
1916
+ private findNodeUrl;
1917
+ /**
1918
+ * Determine if a node should be filtered out (disabled items)
1919
+ */
1920
+ private shouldDropNode;
1921
+ }
1922
+
1923
+ /**
1924
+ * General API (shop configuration and feature flags)
1925
+ */
1926
+
1927
+ interface Region {
1928
+ id: number;
1929
+ name: string;
1930
+ latitude: number;
1931
+ longitude: number;
1932
+ }
1933
+ interface City {
1934
+ id: number;
1935
+ name: string;
1936
+ latitude: number;
1937
+ longitude: number;
1938
+ region: Region;
1939
+ }
1940
+ interface PremiumInfo {
1941
+ enabled: boolean;
1942
+ nextRenewal: string;
1943
+ subscriptionSubtype: string;
1944
+ }
1945
+ interface GoogleAnalyticsCode {
1946
+ code: string;
1947
+ enabled: boolean;
1948
+ }
1949
+ interface GoogleInfo {
1950
+ analyticsCode: GoogleAnalyticsCode;
1951
+ analyticsId: GoogleAnalyticsCode;
1952
+ tagManager: GoogleAnalyticsCode;
1953
+ }
1954
+ interface LogoInfo {
1955
+ favicon: string;
1956
+ main: string;
1957
+ }
1958
+ interface SocialInfo {
1959
+ facebook: string;
1960
+ instagram: string;
1961
+ phone1: string;
1962
+ phone2: string;
1963
+ telegram: string;
1964
+ twitter: string;
1965
+ whatsapp: string;
1966
+ }
1967
+ interface DomainInfo {
1968
+ url: string;
1969
+ }
1970
+ interface EnamadInfo {
1971
+ code: string;
1972
+ }
1973
+ interface ShopInfo {
1974
+ name: string;
1975
+ description: string;
1976
+ city: City | null;
1977
+ domain: DomainInfo;
1978
+ logo: LogoInfo;
1979
+ social: SocialInfo;
1980
+ }
1981
+ interface CheckoutConfig {
1982
+ addToCartAlert: boolean;
1983
+ dynamicForm: boolean;
1984
+ emailOptional: boolean;
1985
+ preventRedirect: boolean;
1986
+ minBasket: {
1987
+ enabled: boolean;
1988
+ minAmount: number;
1989
+ };
1990
+ miniCart: boolean;
1991
+ postalCodeMandatory: boolean;
1992
+ quickAddToCart: boolean;
1993
+ }
1994
+ interface TajrobeConfig {
1995
+ enabled: boolean;
1996
+ }
1997
+ interface WalletConfig {
1998
+ enabled: boolean;
1999
+ useWithDiscount: boolean;
2000
+ minAmount: number;
2001
+ minAmountRequired: boolean;
2002
+ }
2003
+ /**
2004
+ * Standardized feature shape:
2005
+ * - boolean feature switches as direct keys on the object
2006
+ * - premium details in `premium`
2007
+ */
2008
+ interface ShopFeatures {
2009
+ [featureName: string]: boolean | PremiumInfo | undefined;
2010
+ premium?: PremiumInfo;
2011
+ }
2012
+ interface ScriptsInfo {
2013
+ enamad: EnamadInfo;
2014
+ google: GoogleInfo;
2015
+ }
2016
+ interface SettingsInfo {
2017
+ checkout: CheckoutConfig;
2018
+ features: ShopFeatures;
2019
+ wallet: WalletConfig;
2020
+ tajrobe: TajrobeConfig;
2021
+ registerType: string;
2022
+ showProductStockNumber: boolean;
2023
+ }
2024
+ /**
2025
+ * Standardized General API response
2026
+ */
2027
+ interface GeneralInfo {
2028
+ shop: ShopInfo;
2029
+ settings: SettingsInfo;
2030
+ scripts: ScriptsInfo;
2031
+ }
2032
+ declare class GeneralAPI {
2033
+ private http;
2034
+ constructor(http: HttpClient);
2035
+ /**
2036
+ * Get normalized shop information including config and features.
2037
+ */
2038
+ getInfo(options?: RequestOptions): Promise<SazitoResponse<GeneralInfo>>;
2039
+ /**
2040
+ * Get standardized shop feature flags only.
2041
+ */
2042
+ getFeatures(options?: RequestOptions): Promise<SazitoResponse<ShopFeatures>>;
2043
+ /**
2044
+ * Get standardized checkout config only.
2045
+ */
2046
+ getCheckoutConfig(options?: RequestOptions): Promise<SazitoResponse<CheckoutConfig>>;
2047
+ /**
2048
+ * Get standardized wallet config only.
2049
+ */
2050
+ getWalletConfig(options?: RequestOptions): Promise<SazitoResponse<WalletConfig>>;
2051
+ /**
2052
+ * Get standardized Tajrobe config only.
2053
+ */
2054
+ getTajrobeConfig(options?: RequestOptions): Promise<SazitoResponse<TajrobeConfig>>;
2055
+ }
2056
+
2057
+ /**
2058
+ * Dynamic Forms API
2059
+ */
2060
+
2061
+ type DynamicFormFieldType = 'TextBox' | 'TextArea' | 'Select' | 'Checkbox' | 'StatusBox' | 'Number' | 'Password' | 'NationalId' | 'PhoneNumber' | 'IBAN' | 'Separator' | 'Uploader';
2062
+ interface SelectOption {
2063
+ value: string;
2064
+ label: string;
2065
+ }
2066
+ interface DynamicFormField {
2067
+ key: string;
2068
+ name: string;
2069
+ type: DynamicFormFieldType;
2070
+ label: string;
2071
+ value: any;
2072
+ placeholder: string;
2073
+ required: boolean;
2074
+ inputOptions: SelectOption[];
2075
+ allowedExtensions: string[];
2076
+ }
2077
+ interface DynamicForm {
2078
+ id: number;
2079
+ title: string;
2080
+ description: string;
2081
+ fields: DynamicFormField[];
2082
+ }
2083
+ interface UploadedDynamicFormFile {
2084
+ serveKey: string;
2085
+ }
2086
+ declare class DynamicFormsAPI {
2087
+ private http;
2088
+ constructor(http: HttpClient);
2089
+ private normalizeField;
2090
+ private normalizeForm;
2091
+ /**
2092
+ * Fetch dynamic form definition by ID.
2093
+ */
2094
+ getForm(formId: number, options?: RequestOptions): Promise<SazitoResponse<DynamicForm>>;
2095
+ /**
2096
+ * Upload file for uploader fields in product dynamic forms.
2097
+ */
2098
+ uploadProductFormFile(file: File | Blob, options?: RequestOptions): Promise<SazitoResponse<UploadedDynamicFormFile>>;
2099
+ }
2100
+
2101
+ /**
2102
+ * Regions API
2103
+ */
2104
+
2105
+ interface RegionCity {
2106
+ id: number;
2107
+ name: string;
2108
+ latitude: number;
2109
+ longitude: number;
2110
+ }
2111
+ interface RegionWithCities {
2112
+ id: number;
2113
+ name: string;
2114
+ cities: RegionCity[];
2115
+ }
2116
+ declare class RegionsAPI {
2117
+ private http;
2118
+ constructor(http: HttpClient);
2119
+ private normalizeCity;
2120
+ private normalizeRegion;
2121
+ private extractRegions;
2122
+ private sortAlphabetically;
2123
+ /**
2124
+ * Get all regions with nested cities (sorted by name).
2125
+ */
2126
+ list(options?: RequestOptions): Promise<SazitoResponse<RegionWithCities[]>>;
2127
+ }
2128
+
2129
+ /**
2130
+ * Main Sazito SDK Client
2131
+ */
2132
+
2133
+ declare class SazitoClient {
2134
+ private http;
2135
+ private tokenStorage;
2136
+ private credentialsManager;
2137
+ readonly products: ProductsAPI;
2138
+ readonly categories: CategoriesAPI;
2139
+ readonly cart: CartAPI;
2140
+ readonly orders: OrdersAPI;
2141
+ readonly invoices: InvoicesAPI;
2142
+ readonly shipping: ShippingAPI;
2143
+ readonly payments: PaymentsAPI;
2144
+ readonly users: UsersAPI;
2145
+ readonly search: SearchAPI;
2146
+ readonly feedbacks: FeedbacksAPI;
2147
+ readonly wallet: WalletAPI;
2148
+ readonly cms: CMSAPI;
2149
+ readonly images: ImagesAPI;
2150
+ readonly visits: VisitsAPI;
2151
+ readonly booking: BookingAPI;
2152
+ readonly entityRoutes: EntityRoutesAPI;
2153
+ readonly menu: MenuAPI;
2154
+ readonly general: GeneralAPI;
2155
+ readonly dynamicForms: DynamicFormsAPI;
2156
+ readonly regions: RegionsAPI;
2157
+ constructor(config: SazitoConfig, credentialsManager?: CredentialsManager);
2158
+ /**
2159
+ * Set authentication token (stored in localStorage with cookie fallback)
2160
+ */
2161
+ setAuthToken(token: string): void;
2162
+ /**
2163
+ * Get authentication token from storage
2164
+ */
2165
+ getAuthToken(): string | null;
2166
+ /**
2167
+ * Clear authentication token
2168
+ */
2169
+ clearAuth(): void;
2170
+ /**
2171
+ * Check if user is authenticated
2172
+ */
2173
+ isAuthenticated(): boolean;
2174
+ /**
2175
+ * Clear all cache
2176
+ */
2177
+ clearCache(): void;
2178
+ /**
2179
+ * Clear all guest credentials
2180
+ */
2181
+ clearCredentials(): void;
2182
+ /**
2183
+ * Access the guest credential store used by checkout-related modules.
2184
+ * Useful for integrations that receive an SDK client from the host app and
2185
+ * need to restore cart/invoice/payment credentials on that same instance.
2186
+ */
2187
+ getCredentialsManager(): CredentialsManager;
2188
+ /**
2189
+ * Clear everything (auth + cache + credentials)
2190
+ */
2191
+ clearAll(): void;
2192
+ /**
2193
+ * Search helper for `client.search.query(...)`.
2194
+ */
2195
+ searchQuery(query: string, filters?: SearchFilters, options?: RequestOptions): Promise<SazitoResponse<SearchResponse>>;
2196
+ }
2197
+ /**
2198
+ * Create a new Sazito SDK client instance
2199
+ */
2200
+ declare function createSazitoClient(config: SazitoConfig, credentialsManager?: CredentialsManager): SazitoClient;
2201
+
2202
+ interface ModuleContext {
2203
+ http: HttpClient;
2204
+ credentials: CredentialsManager;
2205
+ }
2206
+
2207
+ declare function createProductsAPI(configOrContext: SazitoConfig | ModuleContext): ProductsAPI;
2208
+
2209
+ declare function createCategoriesAPI(configOrContext: SazitoConfig | ModuleContext): CategoriesAPI;
2210
+
2211
+ declare function createCartAPI(configOrContext: SazitoConfig | ModuleContext): CartAPI;
2212
+
2213
+ declare function createOrdersAPI(configOrContext: SazitoConfig | ModuleContext): OrdersAPI;
2214
+
2215
+ declare function createInvoicesAPI(configOrContext: SazitoConfig | ModuleContext): InvoicesAPI;
2216
+
2217
+ declare function createShippingAPI(configOrContext: SazitoConfig | ModuleContext): ShippingAPI;
2218
+
2219
+ declare function createPaymentsAPI(configOrContext: SazitoConfig | ModuleContext): PaymentsAPI;
2220
+
2221
+ declare function createUsersAPI(configOrContext: SazitoConfig | ModuleContext): UsersAPI;
2222
+
2223
+ declare function createSearchAPI(configOrContext: SazitoConfig | ModuleContext): SearchAPI;
2224
+
2225
+ declare function createFeedbacksAPI(configOrContext: SazitoConfig | ModuleContext): FeedbacksAPI;
2226
+
2227
+ declare function createWalletAPI(configOrContext: SazitoConfig | ModuleContext): WalletAPI;
2228
+
2229
+ declare function createCMSAPI(configOrContext: SazitoConfig | ModuleContext): CMSAPI;
2230
+
2231
+ declare function createImagesAPI(configOrContext: SazitoConfig | ModuleContext): ImagesAPI;
2232
+
2233
+ declare function createVisitsAPI(configOrContext: SazitoConfig | ModuleContext): VisitsAPI;
2234
+
2235
+ declare function createBookingAPI(configOrContext: SazitoConfig | ModuleContext): BookingAPI;
2236
+
2237
+ declare function createEntityRoutesAPI(configOrContext: SazitoConfig | ModuleContext): EntityRoutesAPI;
2238
+
2239
+ declare function createMenuAPI(configOrContext: SazitoConfig | ModuleContext): MenuAPI;
2240
+
2241
+ declare function createGeneralAPI(configOrContext: SazitoConfig | ModuleContext): GeneralAPI;
2242
+
2243
+ declare function createDynamicFormsAPI(configOrContext: SazitoConfig | ModuleContext): DynamicFormsAPI;
2244
+
2245
+ declare function createRegionsAPI(configOrContext: SazitoConfig | ModuleContext): RegionsAPI;
2246
+
2247
+ type TransformScalar = string | number | boolean | null | undefined;
2248
+ type TransformValue = TransformScalar | TransformObject | TransformValue[] | object;
2249
+ interface TransformObject {
2250
+ [key: string]: TransformValue;
2251
+ }
2252
+ interface ApiResponseEnvelope {
2253
+ data?: {
2254
+ result?: TransformObject;
2255
+ };
2256
+ }
2257
+ /** Convert Persian and Arabic-Indic numerals to ASCII digits. */
2258
+ declare function toEnglishDigits(input: string): string;
2259
+ /**
2260
+ * Transform object keys from snake_case to camelCase with field name beautification
2261
+ * @param obj - Object to transform
2262
+ * @returns Transformed object with camelCase keys and beautiful field names
2263
+ */
2264
+ declare function transformResponseKeys(obj: TransformValue | object): TransformValue;
2265
+ /**
2266
+ * Transform object keys from camelCase to snake_case for API requests
2267
+ * @param obj - Object to transform
2268
+ * @returns Transformed object with snake_case keys
2269
+ */
2270
+ declare function transformRequestKeys(obj: TransformValue | object): TransformValue;
2271
+ /**
2272
+ * Transform API response data structure
2273
+ * Unwraps the { data: { result: { ... } } } structure and transforms keys
2274
+ */
2275
+ declare function transformApiResponse<T = TransformObject>(response: TransformValue | ApiResponseEnvelope | object): T;
2276
+ /**
2277
+ * Specific transformer for cart responses
2278
+ * Handles the cart-specific data structure
2279
+ */
2280
+ declare function transformCartResponse<T = TransformObject>(response: TransformValue | ApiResponseEnvelope | object): T;
2281
+ declare function transformInvoiceResponse<T = TransformObject>(response: TransformValue | ApiResponseEnvelope | object): T;
2282
+ /**
2283
+ * Specific transformer for product list responses
2284
+ * Handles paginated product lists
2285
+ */
2286
+ declare function transformProductListResponse<T = TransformObject>(response: TransformValue | ApiResponseEnvelope | object): T;
2287
+ /**
2288
+ * Transform shipping address input for API request
2289
+ */
2290
+ declare function transformShippingAddressInput(input: TransformValue): TransformObject;
2291
+ /**
2292
+ * Transform add to cart input for API request
2293
+ */
2294
+ declare function transformAddToCartInput(variantId: number, quantity: number, formAttributes?: TransformValue): TransformObject;
2295
+ /**
2296
+ * Transform create cart input for API request
2297
+ */
2298
+ declare function transformCreateCartInput(input: TransformValue): TransformObject;
2299
+
2300
+ export { CredentialsManager, HttpClient, MemoryStorage, SazitoClient, TokenStorage, createBookingAPI as booking, createCartAPI as cart, createCategoriesAPI as categories, createCMSAPI as cms, createBookingAPI, createCMSAPI, createCartAPI, createCategoriesAPI, createDynamicFormsAPI, createEntityRoutesAPI, createFeedbacksAPI, createGeneralAPI, createImagesAPI, createInvoicesAPI, createMenuAPI, createOrdersAPI, createPaymentsAPI, createProductsAPI, createRegionsAPI, createSazitoClient, createSearchAPI, createShippingAPI, createUsersAPI, createVisitsAPI, createWalletAPI, createDynamicFormsAPI as dynamicForms, createEntityRoutesAPI as entityRoutes, createFeedbacksAPI as feedbacks, createGeneralAPI as general, createImagesAPI as images, createInvoicesAPI as invoices, createMenuAPI as menu, createOrdersAPI as orders, createPaymentsAPI as payments, createProductsAPI as products, createRegionsAPI as regions, createSearchAPI as search, createShippingAPI as shipping, toEnglishDigits, transformAddToCartInput, transformApiResponse, transformCartResponse, transformCreateCartInput, transformInvoiceResponse, transformProductListResponse, transformRequestKeys, transformResponseKeys, transformShippingAddressInput, createUsersAPI as users, createVisitsAPI as visits, createWalletAPI as wallet };
2301
+ export type { AddToCartInput, ApplicableShippingMethods, BlogPage, BlogPageEntityRoute, CMSPageEntityRoute, CMSPageType, CacheConfig, Cart, CartCredentials, CartProduct, CheckoutProductSnapshot, City$1 as City, CmsPage, CookieOptions, CreateCartInput, CreateInvoiceInput, CreatePaymentInput, EntityRoute, EntityRouteResponse, EntityType, FormAttributeValue, Image, Invoice, InvoiceCredentials, InvoiceItem, InvoiceItemFormAttributes, InvoiceShippingAddress, InvoiceShippingAddressRegion, ItemShippingRate, JsonArray, JsonObject, JsonPrimitive, JsonValue, MenuItem, MenuNode, MenuTree, Order, OrderFilters, OrdersListResponse, PaginatedResponse, Payment, PaymentAction, PaymentCredentials, PaymentGateway, PaymentMethod, PaymentStatus, PaymentStepFormFields, PaymentStepFormValue, PaymentStepInput, Product, ProductAttribute, ProductAttributeValueObject, ProductCategory, ProductCategoryEntityRoute, ProductEntityRoute, ProductFilters, ProductSort, ProductVariant, RefreshInvoiceInput, Region$1 as Region, RequestOptions, RetryConfig, SazitoConfig, SazitoResponse, SchedulerBookingAttributes, SearchFilters, SearchResponse, ShippingAddress, ShippingAddressCity, ShippingAddressCredentials, ShippingAddressInput, ShippingAddressRegion, ShippingAssignment, ShippingItem, ShippingMethod, ShippingRate, StorageAdapter, Tag, UnknownEntityRoute, UploadedFormFileAttribute, User };