@djust-b2b/djust-front-sdk 1.15.0 → 1.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.d.ts +7 -7
- package/lib/services/auth/definitions.requests.d.ts +21 -0
- package/lib/services/auth/definitions.requests.js +2 -0
- package/lib/services/auth/index.d.ts +146 -120
- package/lib/services/auth/index.js +144 -119
- package/lib/services/cart/index.d.ts +185 -254
- package/lib/services/cart/index.js +198 -257
- package/lib/services/custom-field/index.d.ts +55 -100
- package/lib/services/custom-field/index.js +55 -105
- package/lib/services/customer-user/index.d.ts +107 -125
- package/lib/services/customer-user/index.js +107 -125
- package/lib/services/navigation-category/index.d.ts +68 -119
- package/lib/services/navigation-category/index.js +68 -119
- package/lib/services/product/index.d.ts +296 -1687
- package/lib/services/product/index.js +312 -1706
- package/lib/services/product-variant/index.d.ts +53 -160
- package/lib/services/product-variant/index.js +53 -160
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -88,13 +88,13 @@ export declare const DjustSDK: {
|
|
|
88
88
|
getProductVariantSuppliers({ productVariantId, }: import("./interfaces").GetProductVariantSuppliersParameters): Promise<import("./interfaces").GetProductVariantSuppliersResponse>;
|
|
89
89
|
getProduct({ productIdentifier, productIdType, locale, }: import("./interfaces").GetProductParameters): Promise<import("./interfaces").GetProductsListResponse>;
|
|
90
90
|
getProductOffers({ productIdentifier, productIdType, locale, currency, }: import("./interfaces").GetProductOffersParameters): Promise<import("./interfaces").GetProductOffersResponse>;
|
|
91
|
-
|
|
92
|
-
getRelatedProducts({ productIdentifier, productIdType, locale, currency, pageable, }: import("./interfaces").GetRelatedProductsParameters): Promise<import("./interfaces").GetRelatedProductsResponse>;
|
|
91
|
+
getRelatedProducts({ productIdentifier, productIdType, locale, currency, pageable, }: import("./interfaces").GetRelatedProductsParameters): Promise<import("./interfaces").GetRelatedProductsParameters>;
|
|
93
92
|
getProductReviews({ productIdentifier, productIdType, }: import("./interfaces").GetProductReviewsParameters): Promise<import("./interfaces").GetProductReviewsResponse>;
|
|
94
93
|
getProductStatReviews({ productIdentifier, productIdType, }: import("./interfaces").GetProductStatReviewsParameters): Promise<import("./interfaces").GetProductStatReviewsResponse>;
|
|
95
94
|
getProductVariantAttributes({ productIdentifier, productIdType, locale, }: import("./interfaces").GetProductVariantAttributesParameters): Promise<import("./interfaces").GetProductVariantAttributesResponse>;
|
|
96
95
|
createProductReview({ message, productSku, rating, }: import("./interfaces").CreateProductReviewParameters): Promise<import("./interfaces").CreateProductReviewResponse>;
|
|
97
96
|
updateProductReview({ productReviewId, message, rating, }: import("./interfaces").UpdateProductReviewParameters): Promise<import("./interfaces").UpdateProductReviewResponse>;
|
|
97
|
+
getProductPaginatedOffers({ productIdentifier, productIdType, currency, locale, withoutPrices, pageable, }: import("./interfaces").GetProductPaginatedOffersParameters): Promise<import("./interfaces").GetProductPaginatedOffersResponse>;
|
|
98
98
|
getNavigationCategories({ locale, }: import("./interfaces").GetNavigationCategoriesParameters): Promise<import("./interfaces").GetNavigationCategoriesResponse>;
|
|
99
99
|
getNavigationCategory({ locale, idType, navigationCategoryId, }: import("./interfaces").GetNavigationCategoryParameters): Promise<import("./interfaces").GetNavigationCategoryResponse>;
|
|
100
100
|
getNavigationCategoryBreadcrumbs({ locale, idType, navigationCategoryId, }: import("./interfaces").GetNavigationCategoryBreadcrumbsParameters): Promise<import("./interfaces").GetNavigationCategoryBreadcrumbsResponse>;
|
|
@@ -142,11 +142,11 @@ export declare const DjustSDK: {
|
|
|
142
142
|
deleteBuyingList({ buyingListId, }: import("./interfaces").DeleteBuyingListParameters): Promise<void>;
|
|
143
143
|
deleteBuyingListItems({ buyingListId, itemIds, }: import("./interfaces").DeleteBuyingListItemsParameters): Promise<void>;
|
|
144
144
|
updateBuyingListOwner({ buyingListId, newOwnerEmail, }: import("./interfaces").UpdateBuyingListOwnerParameters): Promise<void>;
|
|
145
|
-
isTokenValid({ token, }: import("./
|
|
146
|
-
refreshToken({ refreshToken, }: import("./
|
|
147
|
-
resetPassword({ newPassword, resetPasswordToken, }: import("./
|
|
148
|
-
sendResetPasswordEmail({ email, }: import("./
|
|
149
|
-
login({ username, password, }: import("./
|
|
145
|
+
isTokenValid({ token, }: import("./services/auth/definitions.requests").IsTokenValidParameters): Promise<boolean>;
|
|
146
|
+
refreshToken({ refreshToken, }: import("./services/auth/definitions.requests").RefreshTokenParameters): Promise<import("./interfaces").RefreshTokenResponse>;
|
|
147
|
+
resetPassword({ newPassword, resetPasswordToken, }: import("./services/auth/definitions.requests").ResetPasswordParameters): Promise<void>;
|
|
148
|
+
sendResetPasswordEmail({ email, }: import("./services/auth/definitions.requests").SendResetPasswordEmailParameters): Promise<void>;
|
|
149
|
+
login({ username, password, }: import("./services/auth/definitions.requests").LoginParameters): Promise<import("./interfaces").LoginResponse>;
|
|
150
150
|
logout(): Promise<void>;
|
|
151
151
|
};
|
|
152
152
|
export * from "./interfaces";
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Request parameters type definitions
|
|
3
|
+
*/
|
|
4
|
+
export interface IsTokenValidParameters {
|
|
5
|
+
token: string;
|
|
6
|
+
}
|
|
7
|
+
export interface RefreshTokenParameters {
|
|
8
|
+
refreshToken: string;
|
|
9
|
+
}
|
|
10
|
+
export interface ResetPasswordParameters {
|
|
11
|
+
newPassword: string;
|
|
12
|
+
resetPasswordToken: string;
|
|
13
|
+
}
|
|
14
|
+
export interface SendResetPasswordEmailParameters {
|
|
15
|
+
email: string;
|
|
16
|
+
redirectUrl: string;
|
|
17
|
+
}
|
|
18
|
+
export interface LoginParameters {
|
|
19
|
+
username: string;
|
|
20
|
+
password: string;
|
|
21
|
+
}
|
|
@@ -1,150 +1,176 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* # Auth Service
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
*
|
|
4
|
+
* This module provides all functionalities related to user authentication and authorization.
|
|
5
|
+
*
|
|
6
|
+
* ## Features:
|
|
7
|
+
* - Validate tokens
|
|
8
|
+
* - Refresh tokens
|
|
9
|
+
* - Reset user passwords
|
|
10
|
+
* - Manage user login and logout
|
|
11
|
+
* - Send password reset emails
|
|
12
|
+
*
|
|
13
|
+
* Each function is described with its input parameters, output responses, and example usages.
|
|
9
14
|
*/
|
|
15
|
+
import { LoginResponse, RefreshTokenResponse } from "./definitions";
|
|
16
|
+
import { IsTokenValidParameters, LoginParameters, RefreshTokenParameters, ResetPasswordParameters, SendResetPasswordEmailParameters } from "./definitions.requests";
|
|
10
17
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
18
|
+
* 🔐 Validates if a token is still active and unexpired.
|
|
19
|
+
*
|
|
20
|
+
* This function checks whether the provided token is valid, ensuring it has not expired or been invalidated.
|
|
21
|
+
*
|
|
22
|
+
* 🛠 **Endpoint**: `GET /auth/is-token-valid [TOK-200]`
|
|
23
|
+
*
|
|
24
|
+
* | Parameter | Type | Required | Description |
|
|
25
|
+
* |-----------|----------|----------|-------------------------------------|
|
|
26
|
+
* | `token` | `string` | ✅ | The token to validate. |
|
|
27
|
+
*
|
|
28
|
+
* 📤 **Returns**:
|
|
29
|
+
* A `Promise<boolean>` resolving to `true` if the token is valid and active, or `false` otherwise.
|
|
30
|
+
*
|
|
31
|
+
* 🛠 **Example usage**:
|
|
32
|
+
* ```ts
|
|
33
|
+
* const isValid = await isTokenValid({
|
|
34
|
+
* token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c",
|
|
24
35
|
* });
|
|
36
|
+
* console.log(isValid); // true
|
|
25
37
|
* ```
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
38
|
+
*
|
|
39
|
+
* @param {IsTokenValidParameters} params - The parameters for validating the token.
|
|
40
|
+
* @throws {Error} If the required `token` parameter is missing.
|
|
41
|
+
* @returns {Promise<boolean>} A promise that resolves to a boolean indicating whether the token is valid.
|
|
30
42
|
*/
|
|
31
43
|
export declare function isTokenValid({ token, }: IsTokenValidParameters): Promise<boolean>;
|
|
32
44
|
/**
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
* ```
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
* "expireAt": 0,
|
|
52
|
-
* "refreshToken": "string"
|
|
53
|
-
* },
|
|
54
|
-
* "user": {
|
|
55
|
-
* "id": "userID"
|
|
56
|
-
* }
|
|
57
|
-
* }
|
|
45
|
+
* 🔄 Requests a new access token using a refresh token.
|
|
46
|
+
*
|
|
47
|
+
* This function allows you to obtain a new access token by providing a valid refresh token.
|
|
48
|
+
*
|
|
49
|
+
* 🛠 **Endpoint**: `POST /auth/refresh-token [AUTH-102]`
|
|
50
|
+
*
|
|
51
|
+
* | Parameter | Type | Required | Description |
|
|
52
|
+
* |-----------------|----------|----------|--------------------------------------------------|
|
|
53
|
+
* | `refreshToken` | `string` | ✅ | The refresh token used to request a new access token. |
|
|
54
|
+
*
|
|
55
|
+
* 📤 **Returns**:
|
|
56
|
+
* A `Promise<RefreshTokenResponse>` containing the new access token, its expiry time, and a refreshed token.
|
|
57
|
+
*
|
|
58
|
+
* 🛠 **Example usage**:
|
|
59
|
+
* ```ts
|
|
60
|
+
* const response = await refreshToken({
|
|
61
|
+
* refreshToken: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
|
|
62
|
+
* });
|
|
58
63
|
* ```
|
|
64
|
+
*
|
|
65
|
+
* @param {RefreshTokenParameters} params - The parameters for requesting a new token.
|
|
66
|
+
* @throws {Error} If the required `refreshToken` parameter is missing.
|
|
67
|
+
* @returns {Promise<RefreshTokenResponse>} A promise that resolves to the response containing the new token and user details.
|
|
59
68
|
*/
|
|
60
69
|
export declare function refreshToken({ refreshToken, }: RefreshTokenParameters): Promise<RefreshTokenResponse>;
|
|
61
70
|
/**
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
71
|
+
* 🔑 Resets the password of a user.
|
|
72
|
+
*
|
|
73
|
+
* This function allows a user to reset their password by providing a new password along with a valid reset token.
|
|
74
|
+
*
|
|
75
|
+
* 🛠 **Endpoint**: `POST /auth/reset-password [PWD-102]`
|
|
76
|
+
*
|
|
77
|
+
* | Parameter | Type | Required | Description |
|
|
78
|
+
* |-----------------------|----------|----------|--------------------------------------------------------------|
|
|
79
|
+
* | `newPassword` | `string` | ✅ | The new password to set for the user. |
|
|
80
|
+
* | `resetPasswordToken` | `string` | ✅ | The token required to authenticate the password reset process. |
|
|
81
|
+
*
|
|
82
|
+
* 📤 **Returns**:
|
|
83
|
+
* A `Promise<void>` that resolves with a success message `"OK"` if the password is successfully reset.
|
|
84
|
+
*
|
|
85
|
+
* 🛠 **Example usage**:
|
|
86
|
+
* ```ts
|
|
87
|
+
* await resetPassword({
|
|
88
|
+
* newPassword: "mySecurePassword2025!",
|
|
89
|
+
* resetPasswordToken: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
|
|
90
|
+
* });
|
|
80
91
|
* ```
|
|
92
|
+
*
|
|
93
|
+
* @param {ResetPasswordParameters} params - The parameters required for resetting the password.
|
|
94
|
+
* @throws {Error} If the required parameters `newPassword` or `resetPasswordToken` are missing.
|
|
95
|
+
* @returns {Promise<void>} Resolves to `"OK"` if the password reset is successful.
|
|
81
96
|
*/
|
|
82
97
|
export declare function resetPassword({ newPassword, resetPasswordToken, }: ResetPasswordParameters): Promise<void>;
|
|
83
98
|
/**
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
* ```
|
|
99
|
-
*
|
|
99
|
+
* 📧 Sends a reset password email to a user.
|
|
100
|
+
*
|
|
101
|
+
* This function sends an email containing a reset password link to the specified email address.
|
|
102
|
+
*
|
|
103
|
+
* 🛠 **Endpoint**: `POST /auth/send-reset-password-email [PWD-101]`
|
|
104
|
+
*
|
|
105
|
+
* | Parameter | Type | Required | Description |
|
|
106
|
+
* |------------|----------|----------|----------------------------------------------------|
|
|
107
|
+
* | `email` | `string` | ✅ | The email address to which the reset link will be sent. |
|
|
108
|
+
*
|
|
109
|
+
* 📤 **Returns**:
|
|
110
|
+
* A `Promise<void>` that resolves when the reset password email is successfully sent.
|
|
111
|
+
*
|
|
112
|
+
* 🛠 **Example usage**:
|
|
113
|
+
* ```ts
|
|
114
|
+
* await sendResetPasswordEmail({
|
|
115
|
+
* email: "user@example.com",
|
|
116
|
+
* });
|
|
100
117
|
* ```
|
|
118
|
+
*
|
|
119
|
+
* @param {SendResetPasswordEmailParameters} params - The parameters required to send the reset password email.
|
|
120
|
+
* @throws {Error} If the required parameter `email` is missing.
|
|
121
|
+
* @returns {Promise<void>} Resolves when the reset email is successfully sent.
|
|
101
122
|
*/
|
|
102
123
|
export declare function sendResetPasswordEmail({ email, }: SendResetPasswordEmailParameters): Promise<void>;
|
|
103
124
|
/**
|
|
104
|
-
*
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
*
|
|
115
|
-
*
|
|
116
|
-
*
|
|
117
|
-
*
|
|
118
|
-
*
|
|
119
|
-
*
|
|
120
|
-
*
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
*
|
|
126
|
-
* },
|
|
127
|
-
* "user": {
|
|
128
|
-
* "id": "userID"
|
|
129
|
-
* }
|
|
130
|
-
* }
|
|
125
|
+
* 🔐 Logs in a user.
|
|
126
|
+
*
|
|
127
|
+
* This function allows a user to log in by providing their username and password, and returns their login information, including an access token and user details.
|
|
128
|
+
*
|
|
129
|
+
* 🛠 **Endpoint**: `POST /auth/token?withUser=true [AUTH-101]`
|
|
130
|
+
*
|
|
131
|
+
* | Parameter | Type | Required | Description |
|
|
132
|
+
* |-------------|----------|----------|--------------------------------------|
|
|
133
|
+
* | `username` | `string` | ✅ | The username of the user to log in. |
|
|
134
|
+
* | `password` | `string` | ✅ | The password of the user to log in. |
|
|
135
|
+
*
|
|
136
|
+
* 📤 **Returns**:
|
|
137
|
+
* A `Promise<LoginResponse>` that resolves to the user's login information, including:
|
|
138
|
+
* - `token` (object): Contains the `accessToken`, `refreshToken`, and `expireAt` timestamp.
|
|
139
|
+
* - `user` (object): Contains the user's `id`.
|
|
140
|
+
*
|
|
141
|
+
* 🛠 **Example usage**:
|
|
142
|
+
* ```ts
|
|
143
|
+
* const loginResponse = await login({
|
|
144
|
+
* username: "user@example.com",
|
|
145
|
+
* password: "password123",
|
|
146
|
+
* });
|
|
131
147
|
* ```
|
|
148
|
+
*
|
|
149
|
+
* @param {LoginParameters} params - The parameters required for logging in the user.
|
|
150
|
+
* @throws {Error} If the required parameters `username` or `password` are missing.
|
|
151
|
+
* @returns {Promise<LoginResponse>} Resolves to an object containing the user's login information.
|
|
132
152
|
*/
|
|
133
153
|
export declare function login({ username, password, }: LoginParameters): Promise<LoginResponse>;
|
|
134
154
|
/**
|
|
135
|
-
*
|
|
136
|
-
* ### APICODE(AUTH-103)
|
|
155
|
+
* 🚪 Logs out the user.
|
|
137
156
|
*
|
|
138
|
-
*
|
|
157
|
+
* This function logs out the user by revoking their authentication token.
|
|
139
158
|
*
|
|
140
|
-
*
|
|
141
|
-
*
|
|
142
|
-
*
|
|
143
|
-
*
|
|
144
|
-
*
|
|
145
|
-
*
|
|
146
|
-
*
|
|
147
|
-
*
|
|
159
|
+
* 🛠 **Endpoint**: `POST /auth/revoke-token [AUTH-103]`
|
|
160
|
+
*
|
|
161
|
+
* | Parameter | Type | Required | Description |
|
|
162
|
+
* |-----------|------|----------|-------------|
|
|
163
|
+
* | *(none)* | - | - | This function does not require any parameters. |
|
|
164
|
+
*
|
|
165
|
+
* 📤 **Returns**:
|
|
166
|
+
* A `Promise<void>` that resolves when the user is successfully logged out. No additional data is returned.
|
|
167
|
+
*
|
|
168
|
+
* 🛠 **Example usage**:
|
|
169
|
+
* ```ts
|
|
170
|
+
* await logout();
|
|
148
171
|
* ```
|
|
172
|
+
*
|
|
173
|
+
* @throws {Error} If there is an issue with the logout process (e.g., network error).
|
|
174
|
+
* @returns {Promise<void>} Resolves when the logout is successful.
|
|
149
175
|
*/
|
|
150
176
|
export declare function logout(): Promise<void>;
|