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