@sazito/client-sdk 1.2.2 → 1.2.3
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/README.md +60 -6
- package/dist/index.d.ts +142 -71
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1 -1
- package/dist/index.umd.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Official JavaScript/TypeScript SDK for Sazito storefronts.
|
|
4
4
|
|
|
5
|
+
Read the full developer documentation at [developers.sazito.com](https://developers.sazito.com).
|
|
6
|
+
|
|
5
7
|
This SDK is built for application developers who want a typed, framework-agnostic client with:
|
|
6
8
|
- automatic request/response key transformation
|
|
7
9
|
- unified response objects (`{ data, error }`)
|
|
@@ -56,6 +58,54 @@ if (res.error) {
|
|
|
56
58
|
}
|
|
57
59
|
```
|
|
58
60
|
|
|
61
|
+
## Checkout component
|
|
62
|
+
|
|
63
|
+
For a ready-made React/Next.js checkout UI, install the companion package:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
pnpm add @sazito/client-sdk @sazito/checkout
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Create one SDK client, provide it to the checkout, and import the checkout
|
|
70
|
+
stylesheet once:
|
|
71
|
+
|
|
72
|
+
```tsx
|
|
73
|
+
'use client';
|
|
74
|
+
|
|
75
|
+
import '@sazito/checkout/styles.css';
|
|
76
|
+
import { createSazitoClient } from '@sazito/client-sdk';
|
|
77
|
+
import { SazitoCheckoutPage, SazitoProvider } from '@sazito/checkout/next';
|
|
78
|
+
|
|
79
|
+
const sazito = createSazitoClient({ domain: 'mystore.sazito.com' });
|
|
80
|
+
|
|
81
|
+
export default function CheckoutPage() {
|
|
82
|
+
return (
|
|
83
|
+
<SazitoProvider client={sazito}>
|
|
84
|
+
<SazitoCheckoutPage
|
|
85
|
+
credentials={{ cart: { identifier: 'cart-identifier' } }}
|
|
86
|
+
config={{
|
|
87
|
+
locale: 'fa',
|
|
88
|
+
continueShoppingUrl: '/',
|
|
89
|
+
theme: {
|
|
90
|
+
accent: '#4f46e5',
|
|
91
|
+
accentForeground: '#ffffff',
|
|
92
|
+
radius: 16
|
|
93
|
+
}
|
|
94
|
+
}}
|
|
95
|
+
/>
|
|
96
|
+
</SazitoProvider>
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
The component provides a typed, RTL-first flow for `cart → shipping → payment → result`,
|
|
102
|
+
including cart editing, address and shipping-rate selection, discounts, payment
|
|
103
|
+
gateway redirects, and pending-payment polling. It reuses the credentials stored
|
|
104
|
+
by the SDK client, so credentials created through `sazito.cart` and
|
|
105
|
+
`sazito.invoices` can be used by the component. For theming, custom buttons,
|
|
106
|
+
analytics, payment returns, and a fully custom layout, see the
|
|
107
|
+
[checkout guide](https://developers.sazito.com/docs/guides/checkout).
|
|
108
|
+
|
|
59
109
|
## Core Response Model
|
|
60
110
|
|
|
61
111
|
All SDK methods return a `SazitoResponse<T>`:
|
|
@@ -198,6 +248,8 @@ The client instance exposes:
|
|
|
198
248
|
- `entityRoutes`
|
|
199
249
|
- `menu`
|
|
200
250
|
- `general`
|
|
251
|
+
- `dynamicForms`
|
|
252
|
+
- `regions`
|
|
201
253
|
|
|
202
254
|
### Methods by Module
|
|
203
255
|
|
|
@@ -205,14 +257,14 @@ The client instance exposes:
|
|
|
205
257
|
|---|---|
|
|
206
258
|
| `products` | `get`, `list`, `search` |
|
|
207
259
|
| `categories` | `get`, `list` |
|
|
208
|
-
| `cart` | `get`, `create`, `addItem`, `updateItem`, `removeItem`, `clearCart` |
|
|
260
|
+
| `cart` | `get`, `create`, `addItem`, `addItemWithAttributes`, `updateItem`, `updateItemWithAttributes`, `removeItem`, `clearCart` |
|
|
209
261
|
| `orders` | `list`, `get` |
|
|
210
|
-
| `invoices` | `get`, `create`, `refresh`, `addShippingAddress`, `addDiscountCode`, `assignShippingMethod`, `addDetails`, `getApplicableShippingMethods`, `clearInvoice` |
|
|
211
|
-
| `shipping` | `createAddress`, `updateAddress`, `getAddress`, `getMethods`, `clearAddress` |
|
|
212
|
-
| `payments` | `getMethods`, `create`, `initialize`, `processStep`, `clearPayment` |
|
|
262
|
+
| `invoices` | `get`, `create`, `refresh`, `addShippingAddress`, `addDiscountCode`, `assignShippingMethod`, `addDetails`, `addForm`, `addCredit`, `removeCredit`, `toggleCredit`, `getApplicableShippingMethods`, `clearInvoice` |
|
|
263
|
+
| `shipping` | `createAddress`, `updateAddress` (legacy), `listAddresses`, `getAddress`, `getMethods`, `clearAddress` |
|
|
264
|
+
| `payments` | `getMethods`, `create`, `initialize`, `verify`, `processStep`, `processStepForm`, `pollUntilSettled`, `clearPayment` |
|
|
213
265
|
| `users` | `login`, `requestMobileOTP`, `verifyMobileOTP`, `requestEmailLogin`, `register`, `getCurrentUser`, `updateProfile`, `requestMobilePhoneUpdate`, `verifyMobilePhoneUpdate`, `forgotPassword`, `revivePassword`, `mergeUser` |
|
|
214
|
-
| `search` | `
|
|
215
|
-
| `feedbacks` | `list`, `create`, `get` |
|
|
266
|
+
| `search` | `query` |
|
|
267
|
+
| `feedbacks` | `getSeed`, `createOrderRating`, `submitProductReview`, `getProductStatistics`, `getProductReviews`, `uploadReviewImages`, `list`, `create`, `get` |
|
|
216
268
|
| `wallet` | `getBalance`, `applyCredit`, `removeCredit`, `listTransactions` |
|
|
217
269
|
| `cms` | `getPage`, `listPages`, `getBlogPost`, `listBlogPosts`, `listAll` |
|
|
218
270
|
| `images` | `upload`, `delete` |
|
|
@@ -221,6 +273,8 @@ The client instance exposes:
|
|
|
221
273
|
| `entityRoutes` | `resolve` |
|
|
222
274
|
| `menu` | `getHeaderMenu` |
|
|
223
275
|
| `general` | `getInfo`, `getFeatures`, `getCheckoutConfig`, `getWalletConfig`, `getTajrobeConfig` |
|
|
276
|
+
| `dynamicForms` | `getForm`, `uploadProductFormFile` |
|
|
277
|
+
| `regions` | `list` |
|
|
224
278
|
|
|
225
279
|
## Usage Examples
|
|
226
280
|
|
package/dist/index.d.ts
CHANGED
|
@@ -68,6 +68,7 @@ interface RequestOptions {
|
|
|
68
68
|
cache?: boolean;
|
|
69
69
|
headers?: Record<string, string>;
|
|
70
70
|
signal?: AbortSignal;
|
|
71
|
+
skipTransform?: boolean;
|
|
71
72
|
}
|
|
72
73
|
/**
|
|
73
74
|
* Cookie options for token storage
|
|
@@ -96,9 +97,19 @@ interface Image {
|
|
|
96
97
|
/**
|
|
97
98
|
* Product attribute (e.g., color, size)
|
|
98
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
|
+
}
|
|
99
110
|
interface ProductAttribute {
|
|
100
111
|
name: string;
|
|
101
|
-
value: string;
|
|
112
|
+
value: string | ProductAttributeValueObject;
|
|
102
113
|
}
|
|
103
114
|
/**
|
|
104
115
|
* Normalized product snapshot embedded in checkout entities
|
|
@@ -247,7 +258,6 @@ interface Cart {
|
|
|
247
258
|
deleteCoupon?: boolean;
|
|
248
259
|
}
|
|
249
260
|
interface CartCredentials {
|
|
250
|
-
id: number;
|
|
251
261
|
identifier: string;
|
|
252
262
|
}
|
|
253
263
|
interface AddToCartInput {
|
|
@@ -330,6 +340,7 @@ interface ShippingAddress {
|
|
|
330
340
|
city: ShippingAddressCity;
|
|
331
341
|
address: string;
|
|
332
342
|
postalCode?: string;
|
|
343
|
+
description?: string;
|
|
333
344
|
latitude?: number;
|
|
334
345
|
longitude?: number;
|
|
335
346
|
userSetCoordinatesBefore?: boolean;
|
|
@@ -347,6 +358,7 @@ interface InvoiceShippingAddress {
|
|
|
347
358
|
region?: InvoiceShippingAddressRegion;
|
|
348
359
|
address: string;
|
|
349
360
|
postalCode?: string;
|
|
361
|
+
description?: string;
|
|
350
362
|
latitude?: number;
|
|
351
363
|
longitude?: number;
|
|
352
364
|
userSetCoordinatesBefore?: boolean;
|
|
@@ -396,11 +408,9 @@ interface InvoiceCredentials {
|
|
|
396
408
|
identifier: string;
|
|
397
409
|
}
|
|
398
410
|
interface CreateInvoiceInput {
|
|
399
|
-
cartId: number;
|
|
400
411
|
cartIdentifier: string;
|
|
401
412
|
}
|
|
402
413
|
interface RefreshInvoiceInput {
|
|
403
|
-
cartId: number;
|
|
404
414
|
cartIdentifier: string;
|
|
405
415
|
identifier: string;
|
|
406
416
|
}
|
|
@@ -417,6 +427,7 @@ interface ShippingRate {
|
|
|
417
427
|
id: number;
|
|
418
428
|
name: string;
|
|
419
429
|
price: number;
|
|
430
|
+
description?: string;
|
|
420
431
|
icon?: string;
|
|
421
432
|
color?: string;
|
|
422
433
|
type?: string;
|
|
@@ -440,6 +451,7 @@ interface ShippingAddressInput {
|
|
|
440
451
|
cityId?: number;
|
|
441
452
|
address: string;
|
|
442
453
|
postalCode?: string;
|
|
454
|
+
description?: string;
|
|
443
455
|
latitude?: number;
|
|
444
456
|
longitude?: number;
|
|
445
457
|
showMap?: boolean;
|
|
@@ -492,6 +504,16 @@ type PaymentStatus = 'PENDING' | 'PROCESSING' | 'PAID' | 'FAILED' | 'CANCELLED'
|
|
|
492
504
|
interface PaymentMethod {
|
|
493
505
|
id: number;
|
|
494
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;
|
|
495
517
|
isDefault: boolean;
|
|
496
518
|
}
|
|
497
519
|
interface Payment {
|
|
@@ -708,6 +730,73 @@ interface MenuNode {
|
|
|
708
730
|
children: MenuNode[];
|
|
709
731
|
}
|
|
710
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
|
+
|
|
711
800
|
/**
|
|
712
801
|
* Token storage for auth token persistence
|
|
713
802
|
* Primary storage: localStorage (user_id_token), with cookie fallback.
|
|
@@ -892,65 +981,6 @@ declare class CategoriesAPI {
|
|
|
892
981
|
list(filters?: CategoryFilters, options?: RequestOptions): Promise<SazitoResponse<CategoryListResponse>>;
|
|
893
982
|
}
|
|
894
983
|
|
|
895
|
-
/**
|
|
896
|
-
* Credentials Manager for guest users
|
|
897
|
-
* Manages cart, invoice, shipping, and payment credentials in localStorage
|
|
898
|
-
*/
|
|
899
|
-
|
|
900
|
-
declare class CredentialsManager {
|
|
901
|
-
private readonly CART_KEY;
|
|
902
|
-
private readonly INVOICE_KEY;
|
|
903
|
-
private readonly SHIPPING_KEY;
|
|
904
|
-
private readonly PAYMENT_KEY;
|
|
905
|
-
private readonly DISCOUNT_KEY;
|
|
906
|
-
/**
|
|
907
|
-
* Cart Credentials
|
|
908
|
-
*/
|
|
909
|
-
getCartCredentials(): CartCredentials | null;
|
|
910
|
-
setCartCredentials(credentials: CartCredentials): void;
|
|
911
|
-
clearCartCredentials(): void;
|
|
912
|
-
/**
|
|
913
|
-
* Invoice Credentials
|
|
914
|
-
*/
|
|
915
|
-
getInvoiceCredentials(): InvoiceCredentials | null;
|
|
916
|
-
setInvoiceCredentials(credentials: InvoiceCredentials): void;
|
|
917
|
-
clearInvoiceCredentials(): void;
|
|
918
|
-
/**
|
|
919
|
-
* Shipping Address Credentials
|
|
920
|
-
*/
|
|
921
|
-
getShippingCredentials(): ShippingAddressCredentials | null;
|
|
922
|
-
setShippingCredentials(credentials: ShippingAddressCredentials): void;
|
|
923
|
-
clearShippingCredentials(): void;
|
|
924
|
-
/**
|
|
925
|
-
* Payment Credentials
|
|
926
|
-
*/
|
|
927
|
-
getPaymentCredentials(): PaymentCredentials | null;
|
|
928
|
-
setPaymentCredentials(credentials: PaymentCredentials): void;
|
|
929
|
-
clearPaymentCredentials(): void;
|
|
930
|
-
/**
|
|
931
|
-
* Discount Code
|
|
932
|
-
*/
|
|
933
|
-
getDiscountCode(): string | null;
|
|
934
|
-
setDiscountCode(code: string): void;
|
|
935
|
-
clearDiscountCode(): void;
|
|
936
|
-
/**
|
|
937
|
-
* Clear all credentials
|
|
938
|
-
*/
|
|
939
|
-
clearAll(): void;
|
|
940
|
-
/**
|
|
941
|
-
* Get item from localStorage
|
|
942
|
-
*/
|
|
943
|
-
private getItem;
|
|
944
|
-
/**
|
|
945
|
-
* Set item in localStorage
|
|
946
|
-
*/
|
|
947
|
-
private setItem;
|
|
948
|
-
/**
|
|
949
|
-
* Remove item from localStorage
|
|
950
|
-
*/
|
|
951
|
-
private removeItem;
|
|
952
|
-
}
|
|
953
|
-
|
|
954
984
|
/**
|
|
955
985
|
* Cart API
|
|
956
986
|
* Supports both authenticated and guest users via credentials
|
|
@@ -1100,14 +1130,25 @@ declare class ShippingAPI {
|
|
|
1100
1130
|
private credentials;
|
|
1101
1131
|
constructor(http: HttpClient, credentials: CredentialsManager);
|
|
1102
1132
|
private sanitizeAddressInput;
|
|
1133
|
+
private unwrapAddressPayload;
|
|
1134
|
+
private extractAddressList;
|
|
1103
1135
|
/**
|
|
1104
1136
|
* Create shipping address
|
|
1105
1137
|
*/
|
|
1106
1138
|
createAddress(address: ShippingAddressInput, options?: RequestOptions): Promise<SazitoResponse<ShippingAddress>>;
|
|
1107
1139
|
/**
|
|
1108
|
-
* Update
|
|
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.
|
|
1109
1144
|
*/
|
|
1110
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[]>>;
|
|
1111
1152
|
/**
|
|
1112
1153
|
* Get shipping address
|
|
1113
1154
|
*/
|
|
@@ -1140,13 +1181,30 @@ declare class PaymentsAPI {
|
|
|
1140
1181
|
*/
|
|
1141
1182
|
create(paymentTypeId: number, options?: RequestOptions): Promise<SazitoResponse<Payment>>;
|
|
1142
1183
|
/**
|
|
1143
|
-
* Initialize payment
|
|
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).
|
|
1144
1187
|
*/
|
|
1145
1188
|
initialize(options?: RequestOptions): Promise<SazitoResponse<PaymentAction>>;
|
|
1146
1189
|
/**
|
|
1147
|
-
*
|
|
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.
|
|
1148
1201
|
*/
|
|
1149
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;
|
|
1150
1208
|
/**
|
|
1151
1209
|
* Process payment step in form mode (non-JSON content-type).
|
|
1152
1210
|
*/
|
|
@@ -1162,7 +1220,12 @@ declare class PaymentsAPI {
|
|
|
1162
1220
|
private withExactJsonHeader;
|
|
1163
1221
|
private buildProcessStepFormData;
|
|
1164
1222
|
private appendFormValue;
|
|
1165
|
-
|
|
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;
|
|
1166
1229
|
private normalizeAction;
|
|
1167
1230
|
private callPinchAfterSuccessfulPayment;
|
|
1168
1231
|
}
|
|
@@ -2078,7 +2141,7 @@ declare class SazitoClient {
|
|
|
2078
2141
|
readonly general: GeneralAPI;
|
|
2079
2142
|
readonly dynamicForms: DynamicFormsAPI;
|
|
2080
2143
|
readonly regions: RegionsAPI;
|
|
2081
|
-
constructor(config: SazitoConfig);
|
|
2144
|
+
constructor(config: SazitoConfig, credentialsManager?: CredentialsManager);
|
|
2082
2145
|
/**
|
|
2083
2146
|
* Set authentication token (stored in localStorage with cookie fallback)
|
|
2084
2147
|
*/
|
|
@@ -2103,6 +2166,12 @@ declare class SazitoClient {
|
|
|
2103
2166
|
* Clear all guest credentials
|
|
2104
2167
|
*/
|
|
2105
2168
|
clearCredentials(): void;
|
|
2169
|
+
/**
|
|
2170
|
+
* Access the guest credential store used by checkout-related modules.
|
|
2171
|
+
* Useful for integrations that receive an SDK client from the host app and
|
|
2172
|
+
* need to restore cart/invoice/payment credentials on that same instance.
|
|
2173
|
+
*/
|
|
2174
|
+
getCredentialsManager(): CredentialsManager;
|
|
2106
2175
|
/**
|
|
2107
2176
|
* Clear everything (auth + cache + credentials)
|
|
2108
2177
|
*/
|
|
@@ -2115,7 +2184,7 @@ declare class SazitoClient {
|
|
|
2115
2184
|
/**
|
|
2116
2185
|
* Create a new Sazito SDK client instance
|
|
2117
2186
|
*/
|
|
2118
|
-
declare function createSazitoClient(config: SazitoConfig): SazitoClient;
|
|
2187
|
+
declare function createSazitoClient(config: SazitoConfig, credentialsManager?: CredentialsManager): SazitoClient;
|
|
2119
2188
|
|
|
2120
2189
|
interface ModuleContext {
|
|
2121
2190
|
http: HttpClient;
|
|
@@ -2172,6 +2241,8 @@ interface ApiResponseEnvelope {
|
|
|
2172
2241
|
result?: TransformObject;
|
|
2173
2242
|
};
|
|
2174
2243
|
}
|
|
2244
|
+
/** Convert Persian and Arabic-Indic numerals to ASCII digits. */
|
|
2245
|
+
declare function toEnglishDigits(input: string): string;
|
|
2175
2246
|
/**
|
|
2176
2247
|
* Transform object keys from snake_case to camelCase with field name beautification
|
|
2177
2248
|
* @param obj - Object to transform
|
|
@@ -2213,5 +2284,5 @@ declare function transformAddToCartInput(variantId: number, quantity: number, fo
|
|
|
2213
2284
|
*/
|
|
2214
2285
|
declare function transformCreateCartInput(input: TransformValue): TransformObject;
|
|
2215
2286
|
|
|
2216
|
-
export { CredentialsManager, HttpClient, 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, transformAddToCartInput, transformApiResponse, transformCartResponse, transformCreateCartInput, transformInvoiceResponse, transformProductListResponse, transformRequestKeys, transformResponseKeys, transformShippingAddressInput, createUsersAPI as users, createVisitsAPI as visits, createWalletAPI as wallet };
|
|
2217
|
-
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, 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, Tag, UnknownEntityRoute, UploadedFormFileAttribute, User };
|
|
2287
|
+
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 };
|
|
2288
|
+
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 };
|