@sazito/client-sdk 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1812 @@
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
+ /**
35
+ * Unified response pattern for all API calls
36
+ * No exceptions are thrown - errors are returned in the error field
37
+ */
38
+ interface SazitoResponse<T> {
39
+ data?: T;
40
+ error?: {
41
+ status?: number;
42
+ message: string;
43
+ type: 'network' | 'api' | 'validation';
44
+ details?: any;
45
+ };
46
+ }
47
+ /**
48
+ * Paginated response wrapper
49
+ */
50
+ interface PaginatedResponse<T> {
51
+ items: T[];
52
+ total: number;
53
+ page: number;
54
+ pageSize: number;
55
+ }
56
+ /**
57
+ * Request options that can be passed to any API call
58
+ */
59
+ interface RequestOptions {
60
+ retries?: number;
61
+ timeout?: number;
62
+ cache?: boolean;
63
+ headers?: Record<string, string>;
64
+ signal?: AbortSignal;
65
+ }
66
+ /**
67
+ * Cookie options for token storage
68
+ */
69
+ interface CookieOptions {
70
+ httpOnly?: boolean;
71
+ secure?: boolean;
72
+ sameSite?: 'Strict' | 'Lax' | 'None';
73
+ maxAge?: number;
74
+ path?: string;
75
+ domain?: string;
76
+ }
77
+ /**
78
+ * Image type used in products, categories, etc.
79
+ */
80
+ interface Image {
81
+ id: number;
82
+ name: string;
83
+ url: string;
84
+ alt?: string;
85
+ width?: number;
86
+ height?: number;
87
+ order?: number;
88
+ createdAt: string;
89
+ updatedAt: string;
90
+ }
91
+ /**
92
+ * Product attribute (e.g., color, size)
93
+ */
94
+ interface ProductAttribute {
95
+ name: string;
96
+ value: string;
97
+ }
98
+ /**
99
+ * Region (استان)
100
+ */
101
+ interface Region$1 {
102
+ id: number;
103
+ name: string;
104
+ }
105
+ /**
106
+ * City (شهر)
107
+ */
108
+ interface City$1 {
109
+ id: number;
110
+ name: string;
111
+ regionId?: number;
112
+ }
113
+
114
+ /**
115
+ * Product-related types
116
+ */
117
+
118
+ interface ProductVariant {
119
+ id: number;
120
+ productId?: number;
121
+ sku?: string;
122
+ enabled: boolean;
123
+ price: number;
124
+ originalPrice?: number;
125
+ stockQuantity: number;
126
+ isStockManaged: boolean;
127
+ isAvailable?: boolean;
128
+ attributes: ProductAttribute[];
129
+ hasMaxOrder: boolean;
130
+ maxOrderQuantity: number;
131
+ minOrderQuantity: number;
132
+ weight?: number;
133
+ dynamicFormId?: number;
134
+ sortIndex: number;
135
+ imageId?: number;
136
+ commercialFiles?: any[];
137
+ createdAt: string;
138
+ updatedAt: string;
139
+ }
140
+ interface Product {
141
+ id?: number;
142
+ name: string;
143
+ url: string;
144
+ enabled: boolean;
145
+ productType: string;
146
+ themeConfig?: any;
147
+ dynamicFormId?: number;
148
+ eventEntityId?: number;
149
+ attributes?: ProductAttribute[];
150
+ images: Image[];
151
+ variants: ProductVariant[];
152
+ categories: ProductCategory[];
153
+ createdAt: string;
154
+ updatedAt: string;
155
+ }
156
+ interface ProductCategory {
157
+ id?: number;
158
+ name: string;
159
+ url: string;
160
+ enabled?: boolean;
161
+ description?: string;
162
+ productsCount?: number;
163
+ themeConfig?: any;
164
+ attributes?: ProductAttribute[];
165
+ createdAt?: string;
166
+ updatedAt?: string;
167
+ }
168
+ interface Tag {
169
+ id: number;
170
+ name: string;
171
+ slug: string;
172
+ }
173
+ type ProductSort = 'newest' | 'best-selling' | 'availability' | 'discount' | '!price' | 'price';
174
+ interface ProductFilters {
175
+ page?: number;
176
+ pageSize?: number;
177
+ sort?: ProductSort;
178
+ categories?: number | number[];
179
+ priceMin?: number;
180
+ priceMax?: number;
181
+ availableOnly?: boolean;
182
+ discountedOnly?: boolean;
183
+ pinnedIds?: number[];
184
+ similarTo?: number;
185
+ }
186
+
187
+ /**
188
+ * Cart-related types
189
+ */
190
+
191
+ interface CartProduct {
192
+ id: number;
193
+ product: {
194
+ variantId: number;
195
+ name: string;
196
+ url: string;
197
+ image: Image;
198
+ attributes: ProductAttribute[];
199
+ hasMaxOrder: boolean;
200
+ maxOrderQuantity: number;
201
+ minOrderQuantity: number;
202
+ };
203
+ unitPrice: number;
204
+ lineTotal: number;
205
+ quantity: number;
206
+ formAttributes?: Record<string, any>;
207
+ bookingAttributes?: {
208
+ eventEntityId?: number;
209
+ timezone?: string;
210
+ };
211
+ formFields?: Record<string, any>;
212
+ }
213
+ interface Cart {
214
+ id: number;
215
+ identifier: string;
216
+ items: CartProduct[];
217
+ subtotal: number;
218
+ total: number;
219
+ needsShipping: boolean;
220
+ deleteCoupon: boolean;
221
+ }
222
+ interface CartCredentials {
223
+ id: number;
224
+ identifier: string;
225
+ }
226
+ interface AddToCartInput {
227
+ id: number;
228
+ count: number;
229
+ formAttributes?: Record<string, any>;
230
+ schedulerBookingAttributes?: {
231
+ eventEntityId: number;
232
+ timezone: string;
233
+ };
234
+ }
235
+ interface CreateCartInput {
236
+ coupon?: string;
237
+ variants: AddToCartInput[];
238
+ formAttributes?: Record<string, any>;
239
+ schedulerBookingAttributes?: {
240
+ eventEntityId: number;
241
+ timezone: string;
242
+ };
243
+ }
244
+
245
+ /**
246
+ * Invoice and checkout-related types
247
+ */
248
+
249
+ interface InvoiceItem {
250
+ id: number;
251
+ variant: {
252
+ id: number;
253
+ product: any;
254
+ attributes: ProductAttribute[];
255
+ };
256
+ image: Image;
257
+ name: string;
258
+ unitPrice: number;
259
+ lineTotal: number;
260
+ quantity: number;
261
+ formAttributes?: Record<string, any>;
262
+ bookingAttributes?: Record<string, any>;
263
+ formFields?: Record<string, any>;
264
+ }
265
+ interface ShippingItem {
266
+ invoiceItemIds: number[];
267
+ rate: {
268
+ id: number;
269
+ shippingMethodId: number;
270
+ cost: number;
271
+ deliveryTime: string;
272
+ minDays: number;
273
+ maxDays: number;
274
+ };
275
+ }
276
+ interface ShippingAddress {
277
+ id: number;
278
+ identifier: string;
279
+ firstName: string;
280
+ lastName: string;
281
+ mobilePhone: string;
282
+ phoneNumber?: string;
283
+ email?: string;
284
+ region: Region$1;
285
+ city: City$1;
286
+ address: string;
287
+ postalCode?: string;
288
+ latitude?: number;
289
+ longitude?: number;
290
+ userSetCoordinatesBefore?: boolean;
291
+ createdAt: string;
292
+ updatedAt: string;
293
+ }
294
+ interface User {
295
+ id: number;
296
+ email?: string;
297
+ mobilePhone?: string;
298
+ firstName?: string;
299
+ lastName?: string;
300
+ birthDate?: string;
301
+ }
302
+ interface Invoice {
303
+ id: number;
304
+ identifier: string;
305
+ items: InvoiceItem[];
306
+ shippingAddress?: ShippingAddress;
307
+ shippingItems: ShippingItem[];
308
+ shippingMethod?: string;
309
+ needsShipping: boolean;
310
+ user?: User;
311
+ comment?: string;
312
+ subtotal: number;
313
+ total: number;
314
+ finalTotal: number;
315
+ discountTotal: number;
316
+ shippingTotal: number;
317
+ taxTotal: number;
318
+ discountCode?: string;
319
+ createdAt: string;
320
+ updatedAt: string;
321
+ }
322
+ interface InvoiceCredentials {
323
+ id: number;
324
+ identifier: string;
325
+ }
326
+ interface CreateInvoiceInput {
327
+ cartId: number;
328
+ cartIdentifier: string;
329
+ }
330
+ interface RefreshInvoiceInput {
331
+ cartId: number;
332
+ cartIdentifier: string;
333
+ identifier: string;
334
+ }
335
+
336
+ /**
337
+ * Shipping-related types
338
+ */
339
+ interface ShippingMethod {
340
+ id: number;
341
+ code: string;
342
+ name: string;
343
+ description: string;
344
+ enabled: boolean;
345
+ isFree: boolean;
346
+ isCourier: boolean;
347
+ isPost: boolean;
348
+ }
349
+ interface ShippingRate {
350
+ id: number;
351
+ shippingMethodId: number;
352
+ cost: number;
353
+ deliveryTime: string;
354
+ minDays: number;
355
+ maxDays: number;
356
+ }
357
+ interface ShippingAddressInput {
358
+ firstName: string;
359
+ lastName: string;
360
+ mobilePhone: string;
361
+ phoneNumber?: string;
362
+ email?: string;
363
+ regionId: number;
364
+ cityId: number;
365
+ address: string;
366
+ postalCode?: string;
367
+ latitude?: number;
368
+ longitude?: number;
369
+ userSetCoordinatesBefore?: boolean;
370
+ }
371
+ interface ShippingAddressCredentials {
372
+ id: number;
373
+ identifier: string;
374
+ }
375
+ interface ShippingAssignment {
376
+ rateId: number;
377
+ invoiceItemIds: string[];
378
+ }
379
+
380
+ /**
381
+ * Payment-related types
382
+ */
383
+ 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';
384
+ type PaymentStatus = 'PENDING' | 'PROCESSING' | 'PAID' | 'FAILED' | 'CANCELLED' | 'REFUNDED';
385
+ interface PaymentMethod {
386
+ id: number;
387
+ code: PaymentGateway;
388
+ name: string;
389
+ description: {
390
+ description: string;
391
+ cardNumber?: string;
392
+ cardDescription?: string;
393
+ uploadNeeded?: boolean;
394
+ };
395
+ enabled: boolean;
396
+ config?: Record<string, any>;
397
+ }
398
+ interface Payment {
399
+ id: number;
400
+ identifier: string;
401
+ paymentType: PaymentMethod;
402
+ amount: number;
403
+ invoiceId: number;
404
+ status: PaymentStatus;
405
+ createdAt: string;
406
+ updatedAt: string;
407
+ }
408
+ interface PaymentAction {
409
+ action: 'POST' | 'REDIRECT' | 'UPLOAD' | 'FAIL' | 'StockViolated';
410
+ address?: string;
411
+ payload?: Record<string, any>;
412
+ time?: number;
413
+ message?: string;
414
+ }
415
+ interface PaymentCredentials {
416
+ id: number;
417
+ identifier: string;
418
+ }
419
+ interface CreatePaymentInput {
420
+ invoiceId: number;
421
+ invoiceIdentifier: string;
422
+ paymentType: number;
423
+ }
424
+ interface PaymentStepInput {
425
+ identifier: string;
426
+ isFailed?: string;
427
+ imageUrl?: string;
428
+ code?: string;
429
+ }
430
+
431
+ /**
432
+ * Order-related types
433
+ */
434
+
435
+ type OrderStatus = 'PENDING' | 'PROCESSING' | 'SHIPPED' | 'DELIVERED' | 'CANCELLED' | 'REFUNDED';
436
+ interface Order {
437
+ id: number;
438
+ orderNumber: string;
439
+ status: OrderStatus;
440
+ items: InvoiceItem[];
441
+ shippingAddress?: ShippingAddress;
442
+ paymentMethod?: PaymentMethod;
443
+ subtotal: number;
444
+ discountTotal: number;
445
+ shippingTotal: number;
446
+ taxTotal: number;
447
+ total: number;
448
+ trackingNumber?: string;
449
+ notes?: string;
450
+ createdAt: string;
451
+ updatedAt: string;
452
+ }
453
+ interface OrderFilters {
454
+ status?: OrderStatus;
455
+ page?: number;
456
+ pageSize?: number;
457
+ }
458
+
459
+ /**
460
+ * Search-related types
461
+ */
462
+
463
+ /**
464
+ * CMS Page types
465
+ */
466
+ type CMSPageType = 'normal' | 'blog';
467
+ /**
468
+ * Blog page entity from search results
469
+ */
470
+ interface BlogPage {
471
+ id?: number;
472
+ name: string;
473
+ url: string;
474
+ enabled?: boolean;
475
+ cmsPageType?: CMSPageType;
476
+ content?: string;
477
+ summary?: string;
478
+ image?: Image;
479
+ themeConfig?: any;
480
+ attributes?: ProductAttribute[];
481
+ createdAt: string;
482
+ updatedAt: string;
483
+ }
484
+ /**
485
+ * CMS page entity from search results
486
+ */
487
+ interface CmsPage {
488
+ id?: number;
489
+ name: string;
490
+ url: string;
491
+ enabled?: boolean;
492
+ cmsPageType?: CMSPageType;
493
+ content?: string;
494
+ summary?: string;
495
+ image?: Image;
496
+ themeConfig?: any;
497
+ attributes?: ProductAttribute[];
498
+ createdAt: string;
499
+ updatedAt: string;
500
+ }
501
+ /**
502
+ * Search response containing multiple entity types
503
+ * Each entity type has its own array and pagination info
504
+ */
505
+ interface SearchResponse {
506
+ products: {
507
+ items: Product[];
508
+ total: number;
509
+ page: number;
510
+ pageSize: number;
511
+ };
512
+ blogPages: {
513
+ items: BlogPage[];
514
+ total: number;
515
+ page: number;
516
+ pageSize: number;
517
+ };
518
+ cmsPages: {
519
+ items: CmsPage[];
520
+ total: number;
521
+ page: number;
522
+ pageSize: number;
523
+ };
524
+ productCategories: {
525
+ items: ProductCategory[];
526
+ total: number;
527
+ page: number;
528
+ pageSize: number;
529
+ };
530
+ }
531
+
532
+ /**
533
+ * Entity Route types
534
+ * For resolving URL paths to entities (products, categories, CMS pages)
535
+ */
536
+
537
+ /**
538
+ * Entity type discriminator
539
+ */
540
+ type EntityType = 'product' | 'product_category' | 'cms_page' | 'blog_page' | 'unknown';
541
+ /**
542
+ * Entity route response - polymorphic based on entity type
543
+ */
544
+ interface EntityRoute {
545
+ entityType: EntityType;
546
+ entityId: number;
547
+ url: string;
548
+ }
549
+ /**
550
+ * Product entity route
551
+ */
552
+ interface ProductEntityRoute extends EntityRoute {
553
+ entityType: 'product';
554
+ entity: Product;
555
+ }
556
+ /**
557
+ * Product category entity route
558
+ */
559
+ interface ProductCategoryEntityRoute extends EntityRoute {
560
+ entityType: 'product_category';
561
+ entity: ProductCategory;
562
+ }
563
+ /**
564
+ * CMS page entity route
565
+ */
566
+ interface CMSPageEntityRoute extends EntityRoute {
567
+ entityType: 'cms_page';
568
+ entity: CmsPage;
569
+ }
570
+ /**
571
+ * Blog page entity route
572
+ */
573
+ interface BlogPageEntityRoute extends EntityRoute {
574
+ entityType: 'blog_page';
575
+ entity: BlogPage;
576
+ }
577
+ /**
578
+ * Unknown entity route (404)
579
+ */
580
+ interface UnknownEntityRoute extends EntityRoute {
581
+ entityType: 'unknown';
582
+ entity?: never;
583
+ }
584
+ /**
585
+ * Union type for all possible entity routes
586
+ */
587
+ type EntityRouteResponse = ProductEntityRoute | ProductCategoryEntityRoute | CMSPageEntityRoute | BlogPageEntityRoute | UnknownEntityRoute;
588
+
589
+ /**
590
+ * Menu and Navigation Types
591
+ */
592
+ /**
593
+ * Clean navigation menu item returned by SDK
594
+ */
595
+ interface MenuItem {
596
+ name: string;
597
+ url: string;
598
+ children: MenuItem[];
599
+ }
600
+ /**
601
+ * Raw menu tree structure from API (camelCased by HTTP client)
602
+ */
603
+ interface MenuTree {
604
+ id: number;
605
+ identifier: string;
606
+ treeStructure: {
607
+ nodes: MenuNode[];
608
+ };
609
+ }
610
+ /**
611
+ * Raw menu node from API (camelCased by HTTP client)
612
+ */
613
+ interface MenuNode {
614
+ entityType: 'product_category' | 'product' | 'cms_page' | 'blog_page' | 'url';
615
+ entityId: number | null;
616
+ entity?: {
617
+ id?: number;
618
+ name?: string;
619
+ title?: string;
620
+ url?: string;
621
+ enabled?: boolean;
622
+ };
623
+ details?: {
624
+ title?: string;
625
+ isTitleDefault?: boolean;
626
+ url?: string;
627
+ name?: string;
628
+ entityType?: string;
629
+ includeChildren?: boolean;
630
+ };
631
+ children: MenuNode[];
632
+ }
633
+
634
+ /**
635
+ * Token storage for auth token persistence
636
+ * Primary storage: localStorage (user_id_token), with cookie fallback.
637
+ */
638
+
639
+ declare class TokenStorage {
640
+ private readonly tokenKey;
641
+ /**
642
+ * Get token from localStorage (fallback to cookie)
643
+ */
644
+ get(): string | null;
645
+ /**
646
+ * Set token in localStorage and cookie fallback
647
+ */
648
+ set(token: string, options?: CookieOptions): void;
649
+ /**
650
+ * Remove token from both localStorage and cookie
651
+ */
652
+ remove(): void;
653
+ private getFromLocalStorage;
654
+ private setInLocalStorage;
655
+ private removeFromLocalStorage;
656
+ /**
657
+ * Parse document.cookie into key-value pairs
658
+ */
659
+ private parseCookies;
660
+ /**
661
+ * Set a cookie with options
662
+ */
663
+ private setCookie;
664
+ }
665
+
666
+ /**
667
+ * HTTP Client with native fetch
668
+ * Provides unified response pattern, retry logic, caching, and automatic data transformation
669
+ */
670
+
671
+ declare class HttpClient {
672
+ private baseUrl;
673
+ private domain;
674
+ private config;
675
+ private tokenStorage;
676
+ private cache;
677
+ private fetchApi;
678
+ constructor(config: Required<SazitoConfig>);
679
+ /**
680
+ * GET request
681
+ */
682
+ get<T>(endpoint: string, options?: RequestOptions & {
683
+ params?: Record<string, any>;
684
+ }): Promise<SazitoResponse<T>>;
685
+ /**
686
+ * POST request
687
+ */
688
+ post<T>(endpoint: string, body?: any, options?: RequestOptions): Promise<SazitoResponse<T>>;
689
+ /**
690
+ * PUT request
691
+ */
692
+ put<T>(endpoint: string, body?: any, options?: RequestOptions): Promise<SazitoResponse<T>>;
693
+ /**
694
+ * DELETE request
695
+ */
696
+ delete<T>(endpoint: string, options?: RequestOptions): Promise<SazitoResponse<T>>;
697
+ /**
698
+ * Core request method
699
+ */
700
+ private request;
701
+ /**
702
+ * Build full URL with query params
703
+ */
704
+ private buildUrl;
705
+ /**
706
+ * Get request headers
707
+ */
708
+ private getHeaders;
709
+ /**
710
+ * Check if status code should trigger a retry
711
+ */
712
+ private shouldRetry;
713
+ /**
714
+ * Delay helper for retries
715
+ */
716
+ private delay;
717
+ /**
718
+ * Extract API name from endpoint for cache management
719
+ */
720
+ private getApiName;
721
+ /**
722
+ * Get token storage instance
723
+ */
724
+ getTokenStorage(): TokenStorage;
725
+ /**
726
+ * Clear all cache
727
+ */
728
+ clearCache(): void;
729
+ }
730
+
731
+ /**
732
+ * Products API
733
+ */
734
+
735
+ declare class ProductsAPI {
736
+ private http;
737
+ constructor(http: HttpClient);
738
+ /**
739
+ * Map SDK sort values to API sort values
740
+ */
741
+ private mapSortToApi;
742
+ /**
743
+ * Transform filters to API request params
744
+ */
745
+ private transformFilters;
746
+ /**
747
+ * Get a single product by slug or URL path
748
+ * Uses the entity route API to resolve the product
749
+ */
750
+ get(slugOrPath: string, options?: RequestOptions): Promise<SazitoResponse<Product>>;
751
+ /**
752
+ * List products with filters
753
+ */
754
+ list(filters?: ProductFilters, options?: RequestOptions): Promise<SazitoResponse<PaginatedResponse<Product>>>;
755
+ /**
756
+ * Search across all entity types (products, blog pages, CMS pages, product categories)
757
+ */
758
+ search(query: string, filters?: ProductFilters, options?: RequestOptions): Promise<SazitoResponse<SearchResponse>>;
759
+ }
760
+
761
+ /**
762
+ * Categories API
763
+ */
764
+
765
+ /**
766
+ * Category tree node structure
767
+ */
768
+ interface CategoryTreeNode {
769
+ id: number;
770
+ entityType: 'product_category';
771
+ entityId: number;
772
+ entity: ProductCategory;
773
+ details: any;
774
+ children: CategoryTreeNode[];
775
+ createdAt: string;
776
+ updatedAt: string;
777
+ }
778
+ /**
779
+ * Category tree structure
780
+ */
781
+ interface CategoryTree {
782
+ id: number;
783
+ treeType: 'product_categories';
784
+ treeStructure: {
785
+ nodes: CategoryTreeNode[];
786
+ };
787
+ }
788
+ /**
789
+ * Category list response with hierarchical tree
790
+ */
791
+ interface CategoryListResponse {
792
+ categories: ProductCategory[];
793
+ tree: CategoryTree;
794
+ }
795
+ /**
796
+ * Category list filters
797
+ */
798
+ interface CategoryFilters {
799
+ page?: number;
800
+ pageSize?: number;
801
+ }
802
+ declare class CategoriesAPI {
803
+ private http;
804
+ constructor(http: HttpClient);
805
+ /**
806
+ * Get a single category by ID or slug
807
+ */
808
+ get(idOrSlug: string | number, options?: RequestOptions): Promise<SazitoResponse<ProductCategory>>;
809
+ /**
810
+ * List all categories with hierarchical tree structure
811
+ * @param filters Optional pagination filters
812
+ * @param options Additional request options
813
+ */
814
+ list(filters?: CategoryFilters, options?: RequestOptions): Promise<SazitoResponse<CategoryListResponse>>;
815
+ }
816
+
817
+ /**
818
+ * Credentials Manager for guest users
819
+ * Manages cart, invoice, shipping, and payment credentials in localStorage
820
+ */
821
+
822
+ declare class CredentialsManager {
823
+ private readonly CART_KEY;
824
+ private readonly INVOICE_KEY;
825
+ private readonly SHIPPING_KEY;
826
+ private readonly PAYMENT_KEY;
827
+ private readonly DISCOUNT_KEY;
828
+ /**
829
+ * Cart Credentials
830
+ */
831
+ getCartCredentials(): CartCredentials | null;
832
+ setCartCredentials(credentials: CartCredentials): void;
833
+ clearCartCredentials(): void;
834
+ /**
835
+ * Invoice Credentials
836
+ */
837
+ getInvoiceCredentials(): InvoiceCredentials | null;
838
+ setInvoiceCredentials(credentials: InvoiceCredentials): void;
839
+ clearInvoiceCredentials(): void;
840
+ /**
841
+ * Shipping Address Credentials
842
+ */
843
+ getShippingCredentials(): ShippingAddressCredentials | null;
844
+ setShippingCredentials(credentials: ShippingAddressCredentials): void;
845
+ clearShippingCredentials(): void;
846
+ /**
847
+ * Payment Credentials
848
+ */
849
+ getPaymentCredentials(): PaymentCredentials | null;
850
+ setPaymentCredentials(credentials: PaymentCredentials): void;
851
+ clearPaymentCredentials(): void;
852
+ /**
853
+ * Discount Code
854
+ */
855
+ getDiscountCode(): string | null;
856
+ setDiscountCode(code: string): void;
857
+ clearDiscountCode(): void;
858
+ /**
859
+ * Clear all credentials
860
+ */
861
+ clearAll(): void;
862
+ /**
863
+ * Get item from localStorage
864
+ */
865
+ private getItem;
866
+ /**
867
+ * Set item in localStorage
868
+ */
869
+ private setItem;
870
+ /**
871
+ * Remove item from localStorage
872
+ */
873
+ private removeItem;
874
+ }
875
+
876
+ /**
877
+ * Cart API
878
+ * Supports both authenticated and guest users via credentials
879
+ */
880
+
881
+ declare class CartAPI {
882
+ private http;
883
+ private credentials;
884
+ constructor(http: HttpClient, credentials: CredentialsManager);
885
+ /**
886
+ * Get current cart
887
+ */
888
+ get(options?: RequestOptions): Promise<SazitoResponse<Cart>>;
889
+ /**
890
+ * Create a new cart
891
+ */
892
+ create(input: CreateCartInput, options?: RequestOptions): Promise<SazitoResponse<Cart>>;
893
+ /**
894
+ * Add item to cart
895
+ */
896
+ addItem(variantId: number, count: number, formAttributes?: Record<string, any>, options?: RequestOptions): Promise<SazitoResponse<Cart>>;
897
+ /**
898
+ * Update cart item quantity
899
+ */
900
+ updateItem(cartProductId: number, count: number, options?: RequestOptions): Promise<SazitoResponse<Cart>>;
901
+ /**
902
+ * Remove item from cart
903
+ */
904
+ removeItem(cartProductId: number, variantId: number, options?: RequestOptions): Promise<SazitoResponse<Cart>>;
905
+ /**
906
+ * Clear current cart credentials
907
+ */
908
+ clearCart(): void;
909
+ }
910
+
911
+ /**
912
+ * Orders API
913
+ * Requires authentication
914
+ */
915
+
916
+ declare class OrdersAPI {
917
+ private http;
918
+ constructor(http: HttpClient);
919
+ /**
920
+ * List orders (requires authentication)
921
+ */
922
+ list(filters?: OrderFilters, options?: RequestOptions): Promise<SazitoResponse<PaginatedResponse<Order>>>;
923
+ /**
924
+ * Get single order by ID (requires authentication)
925
+ */
926
+ get(orderId: number, options?: RequestOptions): Promise<SazitoResponse<Order>>;
927
+ }
928
+
929
+ /**
930
+ * Invoices API (Checkout)
931
+ */
932
+
933
+ declare class InvoicesAPI {
934
+ private http;
935
+ private credentials;
936
+ constructor(http: HttpClient, credentials: CredentialsManager);
937
+ /**
938
+ * Get current invoice
939
+ */
940
+ get(options?: RequestOptions): Promise<SazitoResponse<Invoice>>;
941
+ /**
942
+ * Create a new invoice from cart
943
+ */
944
+ create(options?: RequestOptions): Promise<SazitoResponse<Invoice>>;
945
+ /**
946
+ * Refresh invoice (sync with cart)
947
+ */
948
+ refresh(options?: RequestOptions): Promise<SazitoResponse<Invoice>>;
949
+ /**
950
+ * Add shipping address to invoice
951
+ */
952
+ addShippingAddress(shippingAddressId: number, shippingAddressIdentifier: string, options?: RequestOptions): Promise<SazitoResponse<Invoice>>;
953
+ /**
954
+ * Add discount code to invoice
955
+ */
956
+ addDiscountCode(code: string, options?: RequestOptions): Promise<SazitoResponse<Invoice>>;
957
+ /**
958
+ * Assign shipping method to invoice
959
+ */
960
+ assignShippingMethod(shippings: ShippingAssignment[], options?: RequestOptions): Promise<SazitoResponse<Invoice>>;
961
+ /**
962
+ * Add invoice details (user comment)
963
+ */
964
+ addDetails(comment: string, options?: RequestOptions): Promise<SazitoResponse<Invoice>>;
965
+ /**
966
+ * Get applicable shipping methods for invoice
967
+ */
968
+ getApplicableShippingMethods(options?: RequestOptions): Promise<SazitoResponse<ShippingMethod[]>>;
969
+ /**
970
+ * Clear current invoice credentials
971
+ */
972
+ clearInvoice(): void;
973
+ }
974
+
975
+ /**
976
+ * Shipping API (Addresses and Methods)
977
+ */
978
+
979
+ declare class ShippingAPI {
980
+ private http;
981
+ private credentials;
982
+ constructor(http: HttpClient, credentials: CredentialsManager);
983
+ /**
984
+ * Create shipping address
985
+ */
986
+ createAddress(address: ShippingAddressInput, options?: RequestOptions): Promise<SazitoResponse<ShippingAddress>>;
987
+ /**
988
+ * Update shipping address
989
+ */
990
+ updateAddress(address: ShippingAddressInput, options?: RequestOptions): Promise<SazitoResponse<ShippingAddress>>;
991
+ /**
992
+ * Get shipping address
993
+ */
994
+ getAddress(options?: RequestOptions): Promise<SazitoResponse<ShippingAddress>>;
995
+ /**
996
+ * Get list of enabled shipping methods
997
+ */
998
+ getMethods(options?: RequestOptions): Promise<SazitoResponse<ShippingMethod[]>>;
999
+ /**
1000
+ * Clear shipping address credentials
1001
+ */
1002
+ clearAddress(): void;
1003
+ }
1004
+
1005
+ /**
1006
+ * Payments API
1007
+ */
1008
+
1009
+ declare class PaymentsAPI {
1010
+ private http;
1011
+ private credentials;
1012
+ constructor(http: HttpClient, credentials: CredentialsManager);
1013
+ /**
1014
+ * Get list of payment methods for invoice
1015
+ */
1016
+ getMethods(options?: RequestOptions): Promise<SazitoResponse<PaymentMethod[]>>;
1017
+ /**
1018
+ * Create payment
1019
+ */
1020
+ create(paymentTypeId: number, options?: RequestOptions): Promise<SazitoResponse<Payment>>;
1021
+ /**
1022
+ * Initialize payment (get payment action)
1023
+ */
1024
+ initialize(options?: RequestOptions): Promise<SazitoResponse<PaymentAction>>;
1025
+ /**
1026
+ * Process payment step (for card-to-card or multi-step payments)
1027
+ */
1028
+ processStep(input: PaymentStepInput, options?: RequestOptions): Promise<SazitoResponse<any>>;
1029
+ /**
1030
+ * Clear payment credentials
1031
+ */
1032
+ clearPayment(): void;
1033
+ }
1034
+
1035
+ /**
1036
+ * Users API (Authentication and user management)
1037
+ */
1038
+
1039
+ /**
1040
+ * Login input (SDK uses camelCase)
1041
+ */
1042
+ interface LoginInput {
1043
+ email: string;
1044
+ password: string;
1045
+ }
1046
+ /**
1047
+ * Register input (SDK uses camelCase)
1048
+ */
1049
+ interface RegisterInput {
1050
+ email: string;
1051
+ password: string;
1052
+ passwordConfirmation: string;
1053
+ firstName?: string;
1054
+ lastName?: string;
1055
+ mobilePhone?: string;
1056
+ }
1057
+ /**
1058
+ * Mobile login input
1059
+ */
1060
+ interface MobileLoginInput {
1061
+ mobilePhone: string;
1062
+ }
1063
+ /**
1064
+ * Verify mobile OTP input (SDK uses camelCase)
1065
+ */
1066
+ interface VerifyMobileInput {
1067
+ mobilePhone: string;
1068
+ token: string;
1069
+ }
1070
+ /**
1071
+ * Passwordless email login input
1072
+ */
1073
+ interface EmailLoginRequestInput {
1074
+ email: string;
1075
+ }
1076
+ /**
1077
+ * Forgot password input
1078
+ */
1079
+ interface ForgotPasswordInput {
1080
+ email: string;
1081
+ }
1082
+ /**
1083
+ * Reset password input (SDK uses camelCase)
1084
+ */
1085
+ interface ResetPasswordInput {
1086
+ forgotPasswordToken: string;
1087
+ password: string;
1088
+ passwordConfirmation: string;
1089
+ }
1090
+ /**
1091
+ * Update user profile input
1092
+ */
1093
+ interface UpdateProfileInput {
1094
+ firstName?: string;
1095
+ lastName?: string;
1096
+ email?: string;
1097
+ password?: string;
1098
+ passwordConfirmation?: string;
1099
+ birthDate?: string;
1100
+ }
1101
+ /**
1102
+ * Update user phone request input
1103
+ */
1104
+ interface UpdateMobilePhoneRequestInput {
1105
+ mobilePhone: string;
1106
+ }
1107
+ /**
1108
+ * Verify user phone update input
1109
+ */
1110
+ interface UpdateMobilePhoneVerificationInput {
1111
+ mobilePhone: string;
1112
+ token: string;
1113
+ }
1114
+ interface LoginResponse {
1115
+ jwt: string;
1116
+ user?: User;
1117
+ }
1118
+ declare class UsersAPI {
1119
+ private http;
1120
+ constructor(http: HttpClient);
1121
+ /**
1122
+ * Login with email and password
1123
+ */
1124
+ login(input: LoginInput, options?: RequestOptions): Promise<SazitoResponse<LoginResponse>>;
1125
+ /**
1126
+ * Request mobile OTP
1127
+ */
1128
+ requestMobileOTP(input: MobileLoginInput, options?: RequestOptions): Promise<SazitoResponse<any>>;
1129
+ /**
1130
+ * Verify mobile OTP
1131
+ */
1132
+ verifyMobileOTP(input: VerifyMobileInput, options?: RequestOptions): Promise<SazitoResponse<LoginResponse>>;
1133
+ /**
1134
+ * Passwordless login request via email
1135
+ */
1136
+ requestEmailLogin(input: EmailLoginRequestInput, options?: RequestOptions): Promise<SazitoResponse<any>>;
1137
+ /**
1138
+ * Register new user
1139
+ */
1140
+ register(input: RegisterInput, options?: RequestOptions): Promise<SazitoResponse<User>>;
1141
+ /**
1142
+ * Get current user (requires authentication)
1143
+ */
1144
+ getCurrentUser(options?: RequestOptions): Promise<SazitoResponse<User>>;
1145
+ /**
1146
+ * Update user profile (requires authentication)
1147
+ */
1148
+ updateProfile(userId: number, data: UpdateProfileInput, options?: RequestOptions): Promise<SazitoResponse<User>>;
1149
+ /**
1150
+ * Request mobile phone update (requires authentication)
1151
+ */
1152
+ requestMobilePhoneUpdate(input: UpdateMobilePhoneRequestInput, options?: RequestOptions): Promise<SazitoResponse<any>>;
1153
+ /**
1154
+ * Verify mobile phone update (requires authentication)
1155
+ */
1156
+ verifyMobilePhoneUpdate(input: UpdateMobilePhoneVerificationInput, options?: RequestOptions): Promise<SazitoResponse<User>>;
1157
+ /**
1158
+ * Forgot password - send reset email
1159
+ */
1160
+ forgotPassword(input: ForgotPasswordInput, options?: RequestOptions): Promise<SazitoResponse<any>>;
1161
+ /**
1162
+ * Revive/Reset password with token
1163
+ */
1164
+ revivePassword(input: ResetPasswordInput, options?: RequestOptions): Promise<SazitoResponse<LoginResponse>>;
1165
+ /**
1166
+ * Merge guest and current user accounts after login
1167
+ */
1168
+ mergeUser(options?: RequestOptions): Promise<SazitoResponse<any>>;
1169
+ }
1170
+
1171
+ /**
1172
+ * Search API
1173
+ */
1174
+
1175
+ interface SearchFilters {
1176
+ page?: number;
1177
+ pageSize?: number;
1178
+ categoryId?: number;
1179
+ minPrice?: number;
1180
+ maxPrice?: number;
1181
+ }
1182
+ declare class SearchAPI {
1183
+ private http;
1184
+ constructor(http: HttpClient);
1185
+ private transformFilters;
1186
+ /**
1187
+ * Query across multiple entity types (products, blog pages, CMS pages, categories)
1188
+ */
1189
+ query(term: string, filters?: SearchFilters, options?: RequestOptions): Promise<SazitoResponse<SearchResponse>>;
1190
+ }
1191
+
1192
+ /**
1193
+ * Feedbacks API (Comments and reviews)
1194
+ */
1195
+
1196
+ interface Feedback {
1197
+ id: number;
1198
+ user?: {
1199
+ id: number;
1200
+ name: string;
1201
+ };
1202
+ productId?: number;
1203
+ rating?: number;
1204
+ comment: string;
1205
+ status: 'pending' | 'approved' | 'rejected';
1206
+ createdAt: string;
1207
+ updatedAt: string;
1208
+ }
1209
+ interface CreateFeedbackInput {
1210
+ productId?: number;
1211
+ rating?: number;
1212
+ comment: string;
1213
+ }
1214
+ interface FeedbackFilters {
1215
+ productId?: number;
1216
+ page?: number;
1217
+ pageSize?: number;
1218
+ }
1219
+ declare class FeedbacksAPI {
1220
+ private http;
1221
+ constructor(http: HttpClient);
1222
+ private transformFilters;
1223
+ /**
1224
+ * List feedbacks
1225
+ */
1226
+ list(filters?: FeedbackFilters, options?: RequestOptions): Promise<SazitoResponse<PaginatedResponse<Feedback>>>;
1227
+ /**
1228
+ * Create feedback/review
1229
+ */
1230
+ create(input: CreateFeedbackInput, options?: RequestOptions): Promise<SazitoResponse<Feedback>>;
1231
+ /**
1232
+ * Get single feedback
1233
+ */
1234
+ get(feedbackId: number, options?: RequestOptions): Promise<SazitoResponse<Feedback>>;
1235
+ }
1236
+
1237
+ /**
1238
+ * Wallet API (User wallet and transactions)
1239
+ */
1240
+
1241
+ 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`;
1242
+ interface WalletTransaction {
1243
+ id: string | number;
1244
+ reason: WalletTransactionReason;
1245
+ amount: number;
1246
+ createdAt: string;
1247
+ metaData?: Record<string, unknown>;
1248
+ }
1249
+ interface WalletBalance {
1250
+ balance: number;
1251
+ enabled: boolean;
1252
+ }
1253
+ interface Wallet extends WalletBalance {
1254
+ currency?: string;
1255
+ transactions?: WalletTransaction[];
1256
+ }
1257
+ interface TransactionFilters {
1258
+ page_number?: number;
1259
+ page_size?: number;
1260
+ }
1261
+ interface WalletTransactionsResponse {
1262
+ transactions: WalletTransaction[];
1263
+ }
1264
+ declare class WalletAPI {
1265
+ private http;
1266
+ constructor(http: HttpClient);
1267
+ private validateInvoiceId;
1268
+ /**
1269
+ * Get wallet balance (requires authentication)
1270
+ */
1271
+ getBalance(options?: RequestOptions): Promise<SazitoResponse<Wallet>>;
1272
+ /**
1273
+ * List wallet transactions (requires authentication)
1274
+ */
1275
+ listTransactions(filters?: TransactionFilters, options?: RequestOptions): Promise<SazitoResponse<WalletTransactionsResponse>>;
1276
+ /**
1277
+ * Apply wallet credit on an invoice (requires authentication)
1278
+ */
1279
+ applyCredit(invoiceId: number, options?: RequestOptions): Promise<SazitoResponse<Invoice>>;
1280
+ /**
1281
+ * Remove wallet credit from an invoice (requires authentication)
1282
+ */
1283
+ removeCredit(invoiceId: number, options?: RequestOptions): Promise<SazitoResponse<Invoice>>;
1284
+ }
1285
+
1286
+ /**
1287
+ * CMS API (Content Management - Pages, Blogs, etc.)
1288
+ */
1289
+
1290
+ /**
1291
+ * CMS Page type (re-exported from search types for convenience)
1292
+ * Both regular pages and blog posts use this structure
1293
+ */
1294
+ type CMSPage = CmsPage;
1295
+
1296
+ /**
1297
+ * Filters for CMS pages list
1298
+ * Backend uses: page_number, page_size, filters[]
1299
+ */
1300
+ interface CMSFilters {
1301
+ page?: number;
1302
+ pageSize?: number;
1303
+ cmsPageTypes?: CMSPageType | CMSPageType[];
1304
+ }
1305
+ declare class CMSAPI {
1306
+ private http;
1307
+ constructor(http: HttpClient);
1308
+ /**
1309
+ * Get CMS page by URL path
1310
+ * Uses entity routes API (recommended approach)
1311
+ * @param urlPath - Page URL path (e.g., '/about-us')
1312
+ * @param options - Request options
1313
+ */
1314
+ getPage(urlPath: string, options?: RequestOptions): Promise<SazitoResponse<CMSPage>>;
1315
+ /**
1316
+ * List CMS pages (excludes blog posts)
1317
+ * @param filters - Filter options (will automatically exclude blog type)
1318
+ * @param options - Request options
1319
+ */
1320
+ listPages(filters?: CMSFilters, options?: RequestOptions): Promise<SazitoResponse<PaginatedResponse<CMSPage>>>;
1321
+ /**
1322
+ * Get blog post by URL path
1323
+ * Uses entity routes API (recommended approach)
1324
+ * @param urlPath - Blog post URL path (e.g., '/blog/my-post')
1325
+ * @param options - Request options
1326
+ */
1327
+ getBlogPost(urlPath: string, options?: RequestOptions): Promise<SazitoResponse<CMSPage>>;
1328
+ /**
1329
+ * List blog posts
1330
+ * @param filters - Filter options (will automatically filter for blog type)
1331
+ * @param options - Request options
1332
+ */
1333
+ listBlogPosts(filters?: CMSFilters, options?: RequestOptions): Promise<SazitoResponse<PaginatedResponse<CMSPage>>>;
1334
+ /**
1335
+ * List all CMS content (both pages and blog posts)
1336
+ * @param filters - Filter options
1337
+ * @param options - Request options
1338
+ */
1339
+ listAll(filters?: CMSFilters, options?: RequestOptions): Promise<SazitoResponse<PaginatedResponse<CMSPage>>>;
1340
+ }
1341
+
1342
+ /**
1343
+ * Images API (File upload)
1344
+ */
1345
+
1346
+ interface UploadImageResponse {
1347
+ id: number;
1348
+ url: string;
1349
+ filename: string;
1350
+ size: number;
1351
+ mime_type: string;
1352
+ }
1353
+ declare class ImagesAPI {
1354
+ private http;
1355
+ constructor(http: HttpClient);
1356
+ /**
1357
+ * Upload image file
1358
+ * @param file - File or Blob to upload
1359
+ */
1360
+ upload(file: File | Blob, options?: RequestOptions): Promise<SazitoResponse<UploadImageResponse>>;
1361
+ /**
1362
+ * Delete image
1363
+ */
1364
+ delete(imageId: number, options?: RequestOptions): Promise<SazitoResponse<void>>;
1365
+ }
1366
+
1367
+ /**
1368
+ * Visits API (Analytics and page views)
1369
+ */
1370
+
1371
+ /**
1372
+ * Visit tracking input (SDK uses camelCase)
1373
+ */
1374
+ interface VisitInput {
1375
+ url: string;
1376
+ referrer?: string;
1377
+ userAgent?: string;
1378
+ entityType?: 'product' | 'category' | 'page';
1379
+ entityId?: number;
1380
+ }
1381
+ /**
1382
+ * Visit tracking response (auto-transformed to camelCase by HTTP client)
1383
+ */
1384
+ interface VisitResponse {
1385
+ id: number;
1386
+ createdAt: string;
1387
+ }
1388
+ declare class VisitsAPI {
1389
+ private http;
1390
+ constructor(http: HttpClient);
1391
+ /**
1392
+ * Track visit analytics event.
1393
+ * Backend endpoint `/api/v1/visits/add` does not accept a payload.
1394
+ */
1395
+ track(inputOrOptions?: VisitInput | RequestOptions, options?: RequestOptions): Promise<SazitoResponse<VisitResponse>>;
1396
+ /**
1397
+ * Track product view
1398
+ */
1399
+ trackProduct(productId: number, url: string, options?: RequestOptions): Promise<SazitoResponse<VisitResponse>>;
1400
+ /**
1401
+ * Track category view
1402
+ */
1403
+ trackCategory(categoryId: number, url: string, options?: RequestOptions): Promise<SazitoResponse<VisitResponse>>;
1404
+ }
1405
+
1406
+ /**
1407
+ * Booking API (Event scheduling and appointments)
1408
+ */
1409
+
1410
+ interface Event {
1411
+ id: number;
1412
+ title: string;
1413
+ description?: string;
1414
+ start_time: string;
1415
+ end_time: string;
1416
+ capacity: number;
1417
+ booked_count: number;
1418
+ available_slots: number;
1419
+ price?: number;
1420
+ location?: string;
1421
+ created_at: string;
1422
+ }
1423
+ interface Booking {
1424
+ id: number;
1425
+ event_id: number;
1426
+ event: Event;
1427
+ user_id?: number;
1428
+ attendee_name: string;
1429
+ attendee_email?: string;
1430
+ attendee_phone?: string;
1431
+ status: 'pending' | 'confirmed' | 'cancelled';
1432
+ booking_time: string;
1433
+ created_at: string;
1434
+ }
1435
+ interface CreateBookingInput {
1436
+ event_entity_id: number;
1437
+ timezone: string;
1438
+ attendee_name: string;
1439
+ attendee_email?: string;
1440
+ attendee_phone?: string;
1441
+ }
1442
+ interface EventFilters {
1443
+ start_date?: string;
1444
+ end_date?: string;
1445
+ available_only?: boolean;
1446
+ page?: number;
1447
+ page_size?: number;
1448
+ }
1449
+ declare class BookingAPI {
1450
+ private http;
1451
+ constructor(http: HttpClient);
1452
+ /**
1453
+ * List available events
1454
+ */
1455
+ listEvents(filters?: EventFilters, options?: RequestOptions): Promise<SazitoResponse<PaginatedResponse<Event>>>;
1456
+ /**
1457
+ * Get single event
1458
+ */
1459
+ getEvent(eventId: number, options?: RequestOptions): Promise<SazitoResponse<Event>>;
1460
+ /**
1461
+ * Create booking
1462
+ */
1463
+ createBooking(input: CreateBookingInput, options?: RequestOptions): Promise<SazitoResponse<Booking>>;
1464
+ /**
1465
+ * List user bookings (requires authentication)
1466
+ */
1467
+ listBookings(options?: RequestOptions): Promise<SazitoResponse<PaginatedResponse<Booking>>>;
1468
+ /**
1469
+ * Cancel booking
1470
+ */
1471
+ cancelBooking(bookingId: number, options?: RequestOptions): Promise<SazitoResponse<Booking>>;
1472
+ }
1473
+
1474
+ /**
1475
+ * Entity Routes API
1476
+ * Resolves URLs to entity data (products, categories, CMS pages)
1477
+ */
1478
+
1479
+ declare class EntityRoutesAPI {
1480
+ private http;
1481
+ constructor(http: HttpClient);
1482
+ /**
1483
+ * Resolve URL path to entity data
1484
+ * @param urlPart - URL pathname (e.g., '/product/laptop-abc' or '/category/electronics')
1485
+ * @returns Entity route with cleaned entity data based on type
1486
+ */
1487
+ resolve(urlPart: string, options?: RequestOptions): Promise<SazitoResponse<EntityRouteResponse>>;
1488
+ }
1489
+
1490
+ /**
1491
+ * Menu API (Header Menu, Navigation Trees)
1492
+ */
1493
+
1494
+ declare class MenuAPI {
1495
+ private http;
1496
+ constructor(http: HttpClient);
1497
+ /**
1498
+ * Fetch header menu by identifier
1499
+ * @param identifier - Menu identifier (default: 'headermenu')
1500
+ * @param options - Request options
1501
+ */
1502
+ getHeaderMenu(identifier?: string, options?: RequestOptions): Promise<SazitoResponse<MenuItem[]>>;
1503
+ /**
1504
+ * Convert raw tree structure to clean navigation items
1505
+ * Filters out disabled items and processes nested children recursively
1506
+ */
1507
+ private convertRawTreeToNavigation;
1508
+ /**
1509
+ * Extract the display title for a menu node
1510
+ */
1511
+ private findNodeTitle;
1512
+ /**
1513
+ * Extract the URL for a menu node
1514
+ */
1515
+ private findNodeUrl;
1516
+ /**
1517
+ * Determine if a node should be filtered out (disabled items)
1518
+ */
1519
+ private shouldDropNode;
1520
+ }
1521
+
1522
+ /**
1523
+ * General API (shop configuration and feature flags)
1524
+ */
1525
+
1526
+ interface Region {
1527
+ id: number;
1528
+ name: string;
1529
+ latitude: number;
1530
+ longitude: number;
1531
+ }
1532
+ interface City {
1533
+ id: number;
1534
+ name: string;
1535
+ latitude: number;
1536
+ longitude: number;
1537
+ region: Region;
1538
+ }
1539
+ interface PremiumInfo {
1540
+ enabled: boolean;
1541
+ nextRenewal: string;
1542
+ subscriptionSubtype: string;
1543
+ }
1544
+ interface GoogleAnalyticsCode {
1545
+ code: string;
1546
+ enabled: boolean;
1547
+ }
1548
+ interface GoogleInfo {
1549
+ analyticsCode: GoogleAnalyticsCode;
1550
+ analyticsId: GoogleAnalyticsCode;
1551
+ tagManager: GoogleAnalyticsCode;
1552
+ }
1553
+ interface LogoInfo {
1554
+ favicon: string;
1555
+ main: string;
1556
+ }
1557
+ interface SocialInfo {
1558
+ facebook: string;
1559
+ instagram: string;
1560
+ phone1: string;
1561
+ phone2: string;
1562
+ telegram: string;
1563
+ twitter: string;
1564
+ whatsapp: string;
1565
+ }
1566
+ interface DomainInfo {
1567
+ url: string;
1568
+ }
1569
+ interface EnamadInfo {
1570
+ code: string;
1571
+ }
1572
+ interface ShopInfo {
1573
+ name: string;
1574
+ description: string;
1575
+ city: City | null;
1576
+ domain: DomainInfo;
1577
+ logo: LogoInfo;
1578
+ social: SocialInfo;
1579
+ }
1580
+ interface CheckoutConfig {
1581
+ addToCartAlert: boolean;
1582
+ dynamicForm: boolean;
1583
+ emailOptional: boolean;
1584
+ preventRedirect: boolean;
1585
+ minBasket: {
1586
+ enabled: boolean;
1587
+ minAmount: number;
1588
+ };
1589
+ miniCart: boolean;
1590
+ postalCodeMandatory: boolean;
1591
+ quickAddToCart: boolean;
1592
+ }
1593
+ interface TajrobeConfig {
1594
+ enabled: boolean;
1595
+ }
1596
+ interface WalletConfig {
1597
+ enabled: boolean;
1598
+ useWithDiscount: boolean;
1599
+ minAmount: number;
1600
+ minAmountRequired: boolean;
1601
+ }
1602
+ /**
1603
+ * Standardized feature shape:
1604
+ * - boolean feature switches as direct keys on the object
1605
+ * - premium details in `premium`
1606
+ */
1607
+ interface ShopFeatures {
1608
+ [featureName: string]: boolean | PremiumInfo | undefined;
1609
+ premium?: PremiumInfo;
1610
+ }
1611
+ interface ScriptsInfo {
1612
+ enamad: EnamadInfo;
1613
+ google: GoogleInfo;
1614
+ }
1615
+ interface SettingsInfo {
1616
+ checkout: CheckoutConfig;
1617
+ features: ShopFeatures;
1618
+ wallet: WalletConfig;
1619
+ tajrobe: TajrobeConfig;
1620
+ registerType: string;
1621
+ showProductStockNumber: boolean;
1622
+ }
1623
+ /**
1624
+ * Standardized General API response
1625
+ */
1626
+ interface GeneralInfo {
1627
+ shop: ShopInfo;
1628
+ settings: SettingsInfo;
1629
+ scripts: ScriptsInfo;
1630
+ }
1631
+ declare class GeneralAPI {
1632
+ private http;
1633
+ constructor(http: HttpClient);
1634
+ /**
1635
+ * Get normalized shop information including config and features.
1636
+ */
1637
+ getInfo(options?: RequestOptions): Promise<SazitoResponse<GeneralInfo>>;
1638
+ /**
1639
+ * Get standardized shop feature flags only.
1640
+ */
1641
+ getFeatures(options?: RequestOptions): Promise<SazitoResponse<ShopFeatures>>;
1642
+ /**
1643
+ * Get standardized checkout config only.
1644
+ */
1645
+ getCheckoutConfig(options?: RequestOptions): Promise<SazitoResponse<CheckoutConfig>>;
1646
+ /**
1647
+ * Get standardized wallet config only.
1648
+ */
1649
+ getWalletConfig(options?: RequestOptions): Promise<SazitoResponse<WalletConfig>>;
1650
+ /**
1651
+ * Get standardized Tajrobe config only.
1652
+ */
1653
+ getTajrobeConfig(options?: RequestOptions): Promise<SazitoResponse<TajrobeConfig>>;
1654
+ }
1655
+
1656
+ /**
1657
+ * Main Sazito SDK Client
1658
+ */
1659
+
1660
+ declare class SazitoClient {
1661
+ private http;
1662
+ private tokenStorage;
1663
+ private credentialsManager;
1664
+ readonly products: ProductsAPI;
1665
+ readonly categories: CategoriesAPI;
1666
+ readonly cart: CartAPI;
1667
+ readonly orders: OrdersAPI;
1668
+ readonly invoices: InvoicesAPI;
1669
+ readonly shipping: ShippingAPI;
1670
+ readonly payments: PaymentsAPI;
1671
+ readonly users: UsersAPI;
1672
+ readonly search: SearchAPI;
1673
+ readonly feedbacks: FeedbacksAPI;
1674
+ readonly wallet: WalletAPI;
1675
+ readonly cms: CMSAPI;
1676
+ readonly images: ImagesAPI;
1677
+ readonly visits: VisitsAPI;
1678
+ readonly booking: BookingAPI;
1679
+ readonly entityRoutes: EntityRoutesAPI;
1680
+ readonly menu: MenuAPI;
1681
+ readonly general: GeneralAPI;
1682
+ constructor(config: SazitoConfig);
1683
+ /**
1684
+ * Set authentication token (stored in localStorage with cookie fallback)
1685
+ */
1686
+ setAuthToken(token: string): void;
1687
+ /**
1688
+ * Get authentication token from storage
1689
+ */
1690
+ getAuthToken(): string | null;
1691
+ /**
1692
+ * Clear authentication token
1693
+ */
1694
+ clearAuth(): void;
1695
+ /**
1696
+ * Check if user is authenticated
1697
+ */
1698
+ isAuthenticated(): boolean;
1699
+ /**
1700
+ * Clear all cache
1701
+ */
1702
+ clearCache(): void;
1703
+ /**
1704
+ * Clear all guest credentials
1705
+ */
1706
+ clearCredentials(): void;
1707
+ /**
1708
+ * Clear everything (auth + cache + credentials)
1709
+ */
1710
+ clearAll(): void;
1711
+ /**
1712
+ * Search helper for `client.search.query(...)`.
1713
+ */
1714
+ searchQuery(query: string, filters?: SearchFilters, options?: RequestOptions): Promise<SazitoResponse<SearchResponse>>;
1715
+ }
1716
+ /**
1717
+ * Create a new Sazito SDK client instance
1718
+ */
1719
+ declare function createSazitoClient(config: SazitoConfig): SazitoClient;
1720
+
1721
+ interface ModuleContext {
1722
+ http: HttpClient;
1723
+ credentials: CredentialsManager;
1724
+ }
1725
+
1726
+ declare function createProductsAPI(configOrContext: SazitoConfig | ModuleContext): ProductsAPI;
1727
+
1728
+ declare function createCategoriesAPI(configOrContext: SazitoConfig | ModuleContext): CategoriesAPI;
1729
+
1730
+ declare function createCartAPI(configOrContext: SazitoConfig | ModuleContext): CartAPI;
1731
+
1732
+ declare function createOrdersAPI(configOrContext: SazitoConfig | ModuleContext): OrdersAPI;
1733
+
1734
+ declare function createInvoicesAPI(configOrContext: SazitoConfig | ModuleContext): InvoicesAPI;
1735
+
1736
+ declare function createShippingAPI(configOrContext: SazitoConfig | ModuleContext): ShippingAPI;
1737
+
1738
+ declare function createPaymentsAPI(configOrContext: SazitoConfig | ModuleContext): PaymentsAPI;
1739
+
1740
+ declare function createUsersAPI(configOrContext: SazitoConfig | ModuleContext): UsersAPI;
1741
+
1742
+ declare function createSearchAPI(configOrContext: SazitoConfig | ModuleContext): SearchAPI;
1743
+
1744
+ declare function createFeedbacksAPI(configOrContext: SazitoConfig | ModuleContext): FeedbacksAPI;
1745
+
1746
+ declare function createWalletAPI(configOrContext: SazitoConfig | ModuleContext): WalletAPI;
1747
+
1748
+ declare function createCMSAPI(configOrContext: SazitoConfig | ModuleContext): CMSAPI;
1749
+
1750
+ declare function createImagesAPI(configOrContext: SazitoConfig | ModuleContext): ImagesAPI;
1751
+
1752
+ declare function createVisitsAPI(configOrContext: SazitoConfig | ModuleContext): VisitsAPI;
1753
+
1754
+ declare function createBookingAPI(configOrContext: SazitoConfig | ModuleContext): BookingAPI;
1755
+
1756
+ declare function createEntityRoutesAPI(configOrContext: SazitoConfig | ModuleContext): EntityRoutesAPI;
1757
+
1758
+ declare function createMenuAPI(configOrContext: SazitoConfig | ModuleContext): MenuAPI;
1759
+
1760
+ declare function createGeneralAPI(configOrContext: SazitoConfig | ModuleContext): GeneralAPI;
1761
+
1762
+ /**
1763
+ * API Data Transformers
1764
+ * Convert between SDK-friendly camelCase and backend snake_case
1765
+ */
1766
+ /**
1767
+ * Transform object keys from snake_case to camelCase with field name beautification
1768
+ * @param obj - Object to transform
1769
+ * @returns Transformed object with camelCase keys and beautiful field names
1770
+ */
1771
+ declare function transformResponseKeys(obj: any): any;
1772
+ /**
1773
+ * Transform object keys from camelCase to snake_case for API requests
1774
+ * @param obj - Object to transform
1775
+ * @returns Transformed object with snake_case keys
1776
+ */
1777
+ declare function transformRequestKeys(obj: any): any;
1778
+ /**
1779
+ * Transform API response data structure
1780
+ * Unwraps the { data: { result: { ... } } } structure and transforms keys
1781
+ */
1782
+ declare function transformApiResponse<T = any>(response: any): T;
1783
+ /**
1784
+ * Specific transformer for cart responses
1785
+ * Handles the cart-specific data structure
1786
+ */
1787
+ declare function transformCartResponse(response: any): any;
1788
+ /**
1789
+ * Specific transformer for invoice responses
1790
+ * Handles the invoice-specific data structure
1791
+ */
1792
+ declare function transformInvoiceResponse(response: any): any;
1793
+ /**
1794
+ * Specific transformer for product list responses
1795
+ * Handles paginated product lists
1796
+ */
1797
+ declare function transformProductListResponse(response: any): any;
1798
+ /**
1799
+ * Transform shipping address input for API request
1800
+ */
1801
+ declare function transformShippingAddressInput(input: any): any;
1802
+ /**
1803
+ * Transform add to cart input for API request
1804
+ */
1805
+ declare function transformAddToCartInput(variantId: number, quantity: number, formAttributes?: any): any;
1806
+ /**
1807
+ * Transform create cart input for API request
1808
+ */
1809
+ declare function transformCreateCartInput(input: any): any;
1810
+
1811
+ export { CredentialsManager, HttpClient, SazitoClient, TokenStorage, createBookingAPI as booking, createCartAPI as cart, createCategoriesAPI as categories, createCMSAPI as cms, createBookingAPI, createCMSAPI, createCartAPI, createCategoriesAPI, createEntityRoutesAPI, createFeedbacksAPI, createGeneralAPI, createImagesAPI, createInvoicesAPI, createMenuAPI, createOrdersAPI, createPaymentsAPI, createProductsAPI, createSazitoClient, createSearchAPI, createShippingAPI, createUsersAPI, createVisitsAPI, createWalletAPI, 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, createSearchAPI as search, createShippingAPI as shipping, transformAddToCartInput, transformApiResponse, transformCartResponse, transformCreateCartInput, transformInvoiceResponse, transformProductListResponse, transformRequestKeys, transformResponseKeys, transformShippingAddressInput, createUsersAPI as users, createVisitsAPI as visits, createWalletAPI as wallet };
1812
+ export type { AddToCartInput, BlogPage, BlogPageEntityRoute, CMSPageEntityRoute, CMSPageType, CacheConfig, Cart, CartCredentials, CartProduct, City$1 as City, CmsPage, CookieOptions, CreateCartInput, CreateInvoiceInput, CreatePaymentInput, EntityRoute, EntityRouteResponse, EntityType, Image, Invoice, InvoiceCredentials, InvoiceItem, MenuItem, MenuNode, MenuTree, Order, OrderFilters, OrderStatus, PaginatedResponse, Payment, PaymentAction, PaymentCredentials, PaymentGateway, PaymentMethod, PaymentStatus, PaymentStepInput, Product, ProductAttribute, ProductCategory, ProductCategoryEntityRoute, ProductEntityRoute, ProductFilters, ProductSort, ProductVariant, RefreshInvoiceInput, Region$1 as Region, RequestOptions, RetryConfig, SazitoConfig, SazitoResponse, SearchFilters, SearchResponse, ShippingAddress, ShippingAddressCredentials, ShippingAddressInput, ShippingAssignment, ShippingItem, ShippingMethod, ShippingRate, Tag, UnknownEntityRoute, User };