@djust-b2b/djust-front-sdk 1.12.0 → 1.13.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 +6 -4
- package/lib/interfaces/models/offer.d.ts +1 -1
- package/lib/interfaces/models/quote.d.ts +13 -1
- package/lib/services/auth/index.d.ts +119 -4
- package/lib/services/auth/index.js +119 -4
- package/lib/services/customer-user/definitions.d.ts +0 -3
- package/lib/services/customer-user/index.d.ts +263 -14
- package/lib/services/customer-user/index.js +264 -20
- package/lib/services/quote/definitions.d.ts +25 -1
- package/lib/services/quote/index.d.ts +349 -10
- package/lib/services/quote/index.js +382 -11
- package/lib/services/supplier/definitions.d.ts +3 -0
- package/lib/services/supplier/index.d.ts +92 -4
- package/lib/services/supplier/index.js +96 -5
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -64,7 +64,7 @@ export declare const DjustSDK: {
|
|
|
64
64
|
addLogisitcOrderReview({ orderId, comment, grade, }: import("./interfaces").AddLogisticOrderReviewParameters): Promise<import("./interfaces").AddLogisticOrderReviewResponse>;
|
|
65
65
|
getThreadReasonTypes(): Promise<import("./interfaces").GetThreadReasonTypesResponse>;
|
|
66
66
|
getThreadSubReasons({ reasonType, }: import("./interfaces").GetThreadSubReasonsParameters): Promise<import("./interfaces").GetThreadSubReasonsResponse>;
|
|
67
|
-
getSuppliers({ pageable, }: import("./interfaces").GetSuppliersParameters): Promise<import("./interfaces").GetSuppliersResponse>;
|
|
67
|
+
getSuppliers({ pageable, supplierStatus, supplierIds, idType, }: import("./interfaces").GetSuppliersParameters): Promise<import("./interfaces").GetSuppliersResponse>;
|
|
68
68
|
getSupplier({ supplierId, idType, }: import("./interfaces").GetSupplierParameters): Promise<import("./interfaces").GetSupplierResponse>;
|
|
69
69
|
getSupplierEvaluations({ supplierId, idType, pageable, }: import("./interfaces").GetSupplierEvaluationsParameters): Promise<import("./interfaces").GetSupplierEvaluationsResponse>;
|
|
70
70
|
getMasterQuotes({ fromCustomerAccount, pageable, }?: import("./interfaces").GetMasterQuotesParameters): Promise<import("./interfaces").GetMasterQuotesResponse>;
|
|
@@ -74,8 +74,11 @@ export declare const DjustSDK: {
|
|
|
74
74
|
updateMasterQuote({ masterQuoteId, customFieldValues, masterQuoteDetailsToAdd, masterQuoteDetailsToRemove, }: import("./interfaces").UpdateMasterQuoteParameters): Promise<import("./interfaces").UpdateMasterQuoteResponse>;
|
|
75
75
|
createSupplierQuotes({ billingAddressId, createSupplierQuoteRequests, masterQuoteId, supplierQuoteUrl, }: import("./interfaces").CreateSupplierQuotesParameters): Promise<import("./interfaces").CreateSupplierQuotesResponse>;
|
|
76
76
|
getSupplierQuote({ supplierQuoteId, }: import("./interfaces").GetSupplierQuoteParameters): Promise<import("./interfaces").GetSupplierQuoteResponse>;
|
|
77
|
+
acceptSupplierQuote({ supplierQuoteId, }: import("./interfaces").AcceptSupplierQuoteParameters): Promise<import("./interfaces").AcceptSupplierQuoteResponse>;
|
|
78
|
+
updateSupplierQuoteCustomFields({ supplierQuoteId, customFieldValues, idType, }: import("./interfaces").UpdateSupplierQuoteCustomFieldsParameters): Promise<import("./interfaces").UpdateSupplierQuoteCustomFieldsResponse>;
|
|
77
79
|
declineSupplierQuote({ supplierQuoteId, }: import("./interfaces").DeclineSupplierQuoteParameters): Promise<import("./interfaces").DeclineSupplierQuoteResponse>;
|
|
78
80
|
postMessageToSupplierQuote({ supplierQuoteId, message, username, }: import("./interfaces").PostMessageToSupplierQuoteParameters): Promise<import("./interfaces").PostMessageToSupplierQuoteResponse>;
|
|
81
|
+
initializeOrderFromSupplierQuote({ supplierQuoteId, nbPreviewLines, quoteLineIdsAndQuantities, }: import("./interfaces").InitializeOrderFromSupplierQuoteParameters): Promise<import("./interfaces").InitializeOrderFromSupplierQuoteResponse>;
|
|
79
82
|
autoCompleteSearchProducts({ input, locale, currency, pageable, aggregation, productTags, }: import("./interfaces").AutoCompleteSearchProductsParameters): Promise<import("./interfaces").SearchProductsResponse>;
|
|
80
83
|
getProductsList({ locale, filters, pageable, }: import("./interfaces").GetProductsListParameters): Promise<import("./interfaces").GetProductsListResponse>;
|
|
81
84
|
getProductVariantsList({ productSku, locale, pageable, }: import("./interfaces").GetProductVariantsListParameters): Promise<import("./interfaces").GetProductVariantsListResponse>;
|
|
@@ -94,10 +97,9 @@ export declare const DjustSDK: {
|
|
|
94
97
|
getNavigationCategory({ locale, idType, navigationCategoryId, }: import("./interfaces").GetNavigationCategoryParameters): Promise<import("./interfaces").GetNavigationCategoryResponse>;
|
|
95
98
|
getNavigationCategoryBreadcrumbs({ locale, idType, navigationCategoryId, }: import("./interfaces").GetNavigationCategoryBreadcrumbsParameters): Promise<import("./interfaces").GetNavigationCategoryBreadcrumbsResponse>;
|
|
96
99
|
getAuthenticatedUser(): Promise<any>;
|
|
97
|
-
createCustomerUser(
|
|
100
|
+
createCustomerUser(params: import("./interfaces").CreateCustomerUserParameters): Promise<import("./interfaces").CreateCustomerUserResponse>;
|
|
98
101
|
updateCustomerUser({ civility, firstName, lastName, phone, customFieldValues, }: import("./interfaces").UpdateCustomerUserParameters): Promise<import("./interfaces").UpdateCustomerUserResponse>;
|
|
99
|
-
|
|
100
|
-
activateCustomerUser({ token, }: import("./interfaces").ActivateCustomerUserParameters): Promise<void>;
|
|
102
|
+
activateCustomerUser(params: import("./interfaces").ActivateCustomerUserParameters): Promise<void>;
|
|
101
103
|
getCustomerUserAddresses({ shipping, billing, account, organisationIds, }: import("./interfaces").GetCustomerUserAddressesParameters): Promise<void>;
|
|
102
104
|
getCustomerUserOrganisations(): Promise<import("./interfaces").GetCustomerUserOrganisationsResponse>;
|
|
103
105
|
sendCustomerUserActivationRequest({ redirectUrl, token, }: import("./interfaces").SendCustomerUserActivationRequestParameters): Promise<void>;
|
|
@@ -62,7 +62,7 @@ export interface OfferInventory {
|
|
|
62
62
|
minShippingPrice: number;
|
|
63
63
|
minShippingPriceAdditional: number;
|
|
64
64
|
minShippingType: number;
|
|
65
|
-
minShippingZone:
|
|
65
|
+
minShippingZone: string;
|
|
66
66
|
leadTimeToShip: number;
|
|
67
67
|
customFieldValues: CustomFieldValueDto[];
|
|
68
68
|
}
|
|
@@ -2,7 +2,10 @@ import { SupplierSimpleView } from "./supplier";
|
|
|
2
2
|
import { AddressDto } from "./address";
|
|
3
3
|
import { Order, PageableObject } from "./common";
|
|
4
4
|
import { ProductVariantResponse } from "./product";
|
|
5
|
-
|
|
5
|
+
import { CustomFieldValueObject } from "./custom-field";
|
|
6
|
+
export type SupplierQuoteStatus = "STAGING" | "NEW" | "WAITING_FOR_CUSTOMER" | "WAITING_FOR_SUPPLIER_INFOS" | "WAITING_FOR_OPERATOR" | "DECLINED_BY_OPERATOR" | "DECLINED_BY_SUPPLIER" | "DECLINED_BY_CUSTOMER" | "VALIDATED" | "CLOSED" | "EXPIRED";
|
|
7
|
+
export type SupplierQuoteOrderingState = "TO_ORDER" | "PARTIALLY_ORDERED" | "FULLY_ORDERED";
|
|
8
|
+
export type SupplierQuoteIdType = "DJUST_ID" | "EXTERNAL_ID";
|
|
6
9
|
export interface PageMasterQuote {
|
|
7
10
|
content: MasterQuote[];
|
|
8
11
|
empty: boolean;
|
|
@@ -17,6 +20,7 @@ export interface PageMasterQuote {
|
|
|
17
20
|
totalPages: number;
|
|
18
21
|
}
|
|
19
22
|
export interface MasterQuote {
|
|
23
|
+
customFieldValues: CustomFieldValueObject[];
|
|
20
24
|
description: string;
|
|
21
25
|
id: string;
|
|
22
26
|
masterQuoteDetails: MasterQuoteDetail[];
|
|
@@ -31,17 +35,24 @@ export interface MasterQuoteDetail {
|
|
|
31
35
|
export interface SupplierQuoteDto {
|
|
32
36
|
billingAddress: AddressDto;
|
|
33
37
|
createdAt: string;
|
|
38
|
+
customFieldValue: CustomFieldValueObject[];
|
|
34
39
|
customerName: string;
|
|
35
40
|
customerThread: ThreadMessage[];
|
|
36
41
|
customerUserId: string;
|
|
42
|
+
externalId: string;
|
|
43
|
+
globalDiscount: number;
|
|
37
44
|
id: string;
|
|
45
|
+
orderingState: SupplierQuoteOrderingState;
|
|
38
46
|
quoteLines: QuoteLine[];
|
|
47
|
+
quoteWithMultipleOrders: boolean;
|
|
39
48
|
status: SupplierQuoteStatus;
|
|
40
49
|
supplier: SupplierSimpleView;
|
|
41
50
|
updatedAt: string;
|
|
42
51
|
validityDate: string;
|
|
43
52
|
}
|
|
44
53
|
interface QuoteLine {
|
|
54
|
+
customFieldValues: CustomFieldValueObject[];
|
|
55
|
+
externalId: string;
|
|
45
56
|
id: string;
|
|
46
57
|
offerInventoryId: string;
|
|
47
58
|
price: number;
|
|
@@ -53,6 +64,7 @@ interface QuoteLine {
|
|
|
53
64
|
quantity: number;
|
|
54
65
|
shippingAddress: AddressDto;
|
|
55
66
|
}[];
|
|
67
|
+
remainingQuantity: number;
|
|
56
68
|
shippingPrice: number;
|
|
57
69
|
shippingTaxAmount: number;
|
|
58
70
|
shippingTaxRate: number;
|
|
@@ -1,36 +1,151 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
*
|
|
4
|
+
* @document documents/auth.md
|
|
5
|
+
*/
|
|
1
6
|
import { IsTokenValidParameters, LoginParameters, LoginResponse, RefreshTokenParameters, RefreshTokenResponse, ResetPasswordParameters, SendResetPasswordEmailParameters } from "./definitions";
|
|
2
7
|
/**
|
|
8
|
+
* CART ENDPOINT
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* APICODE(TOK-200)
|
|
3
12
|
* Returns true if the token is valid and not expired, false otherwise
|
|
4
13
|
* @param {IsTokenValidParameters} params - The parameters for the function
|
|
14
|
+
* #### token - `string` | <strong style={{ color: 'red' }}>required</strong>
|
|
15
|
+
* The token to validate.
|
|
16
|
+
*
|
|
5
17
|
* @returns {Promise<boolean>} - A promise that resolves to a boolean indicating whether the token is valid or not
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* #### input
|
|
21
|
+
* ```typescript
|
|
22
|
+
* const isValidToken = await isTokenValid({
|
|
23
|
+
* token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c",
|
|
24
|
+
* });
|
|
25
|
+
* ```
|
|
26
|
+
* #### output
|
|
27
|
+
* ```json
|
|
28
|
+
* true
|
|
29
|
+
* ```
|
|
6
30
|
*/
|
|
7
31
|
export declare function isTokenValid({ token, }: IsTokenValidParameters): Promise<boolean>;
|
|
8
32
|
/**
|
|
33
|
+
* APICODE(AUTH-102)
|
|
9
34
|
* Ask for a new token from a refresh token
|
|
10
|
-
* @param {RefreshTokenParameters} params - The parameters for the function
|
|
35
|
+
* @param {RefreshTokenParameters} params - The parameters for the function, including:
|
|
36
|
+
* #### refreshToken - `string` | <strong style={{ color: 'red' }}>required</strong>
|
|
37
|
+
* The refresh token to request a new access token (required)
|
|
38
|
+
*
|
|
11
39
|
* @returns {Promise<RefreshTokenResponse>} - A promise that resolves to the response containing the new token
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* #### input
|
|
43
|
+
* ```typescript
|
|
44
|
+
* const response = await refreshToken({ refreshToken: 'string' });
|
|
45
|
+
* ```
|
|
46
|
+
* #### output
|
|
47
|
+
* ```json
|
|
48
|
+
* {
|
|
49
|
+
* "token": {
|
|
50
|
+
* "accessToken": "string",
|
|
51
|
+
* "expireAt": 0,
|
|
52
|
+
* "refreshToken": "string"
|
|
53
|
+
* },
|
|
54
|
+
* "user": {
|
|
55
|
+
* "id": "userID"
|
|
56
|
+
* }
|
|
57
|
+
* }
|
|
58
|
+
* ```
|
|
12
59
|
*/
|
|
13
60
|
export declare function refreshToken({ refreshToken, }: RefreshTokenParameters): Promise<RefreshTokenResponse>;
|
|
14
61
|
/**
|
|
62
|
+
* APICODE(PWD-102)
|
|
15
63
|
* Reset the password of a user
|
|
16
64
|
* @param {ResetPasswordParameters} params - The parameters for the function
|
|
17
|
-
*
|
|
65
|
+
* #### newPassword - `string` | <strong style={{ color: 'red' }}>required</strong>
|
|
66
|
+
* The new password to set for the user.
|
|
67
|
+
* #### resetPasswordToken - `string` | <strong style={{ color: 'red' }}>required</strong>
|
|
68
|
+
* The token required to authenticate the password reset process.
|
|
69
|
+
*
|
|
70
|
+
* @returns {Promise<void>} - Resolves to a success message `"OK"` when the password is successfully reset
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* #### input
|
|
74
|
+
* ```typescript
|
|
75
|
+
* await resetPassword({ newPassword: 'string', resetPasswordToken: 'string' });
|
|
76
|
+
* ```
|
|
77
|
+
* #### output
|
|
78
|
+
* ```json
|
|
79
|
+
* "OK" (No output, resolves on success)
|
|
80
|
+
* ```
|
|
18
81
|
*/
|
|
19
82
|
export declare function resetPassword({ newPassword, resetPasswordToken, }: ResetPasswordParameters): Promise<void>;
|
|
20
83
|
/**
|
|
84
|
+
* APICODE(PWD-101)
|
|
21
85
|
* Send an email to the user with a reset password link
|
|
22
|
-
* @param {SendResetPasswordEmailParameters} params - The parameters for the function
|
|
86
|
+
* @param {SendResetPasswordEmailParameters} params - The parameters for the function, including:
|
|
87
|
+
* #### email - `string` | <strong style={{ color: 'red' }}>required</strong>
|
|
88
|
+
* The email address to send the reset link to.
|
|
89
|
+
*
|
|
23
90
|
* @returns {Promise<void>} - A promise that resolves when the email is sent
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* #### input
|
|
94
|
+
* ```typescript
|
|
95
|
+
* await sendResetPasswordEmail({ email: 'user@example.com' });
|
|
96
|
+
* ```
|
|
97
|
+
* #### output
|
|
98
|
+
* ```json
|
|
99
|
+
* "OK" (No output, resolves on success)
|
|
100
|
+
* ```
|
|
24
101
|
*/
|
|
25
102
|
export declare function sendResetPasswordEmail({ email, }: SendResetPasswordEmailParameters): Promise<void>;
|
|
26
103
|
/**
|
|
104
|
+
* APICODE(AUTH-101)
|
|
27
105
|
* Login a user
|
|
28
|
-
* @param {LoginParameters} params - The parameters for the function
|
|
106
|
+
* @param {LoginParameters} params - The parameters for the function, including:
|
|
107
|
+
* #### username - `string` | <strong style={{ color: 'red' }}>required</strong>
|
|
108
|
+
* The username of the user to log in.
|
|
109
|
+
* #### password - `string` | <strong style={{ color: 'red' }}>required</strong>
|
|
110
|
+
* The password of the user to log in.
|
|
111
|
+
*
|
|
29
112
|
* @returns {Promise<LoginResponse>} - A promise that resolves to the response containing the user's login information
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* #### input
|
|
116
|
+
* ```typescript
|
|
117
|
+
* const loginResponse = await login({ username: 'user@example.com', password: 'password123' });
|
|
118
|
+
* ```
|
|
119
|
+
* #### output
|
|
120
|
+
* ```json
|
|
121
|
+
* {
|
|
122
|
+
* "token": {
|
|
123
|
+
* "accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c",
|
|
124
|
+
* "expireAt": 1679022000,
|
|
125
|
+
* "refreshToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c"
|
|
126
|
+
* },
|
|
127
|
+
* "user": {
|
|
128
|
+
* "id": "userID"
|
|
129
|
+
* }
|
|
130
|
+
* }
|
|
131
|
+
* ```
|
|
30
132
|
*/
|
|
31
133
|
export declare function login({ username, password, }: LoginParameters): Promise<LoginResponse>;
|
|
32
134
|
/**
|
|
135
|
+
* APICODE(AUTH-103)
|
|
136
|
+
*
|
|
33
137
|
* Logout the user
|
|
138
|
+
*
|
|
34
139
|
* @returns {Promise<void>} - A promise that resolves when the user is logged out
|
|
140
|
+
*
|
|
141
|
+
* @example
|
|
142
|
+
* #### input
|
|
143
|
+
* ```typescript
|
|
144
|
+
* await logout();
|
|
145
|
+
* ```
|
|
146
|
+
* #### output
|
|
147
|
+
* ```json
|
|
148
|
+
* "OK" (No output, resolves on success)
|
|
149
|
+
* ```
|
|
35
150
|
*/
|
|
36
151
|
export declare function logout(): Promise<void>;
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @packageDocumentation
|
|
4
|
+
*
|
|
5
|
+
* @document documents/auth.md
|
|
6
|
+
*/
|
|
2
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
8
|
exports.isTokenValid = isTokenValid;
|
|
4
9
|
exports.refreshToken = refreshToken;
|
|
@@ -9,9 +14,28 @@ exports.logout = logout;
|
|
|
9
14
|
const parameters_validation_1 = require("../../helpers/parameters-validation");
|
|
10
15
|
const fetch_instance_1 = require("../../settings/fetch-instance");
|
|
11
16
|
/**
|
|
17
|
+
* CART ENDPOINT
|
|
18
|
+
*/
|
|
19
|
+
/**
|
|
20
|
+
* APICODE(TOK-200)
|
|
12
21
|
* Returns true if the token is valid and not expired, false otherwise
|
|
13
22
|
* @param {IsTokenValidParameters} params - The parameters for the function
|
|
23
|
+
* #### token - `string` | <strong style={{ color: 'red' }}>required</strong>
|
|
24
|
+
* The token to validate.
|
|
25
|
+
*
|
|
14
26
|
* @returns {Promise<boolean>} - A promise that resolves to a boolean indicating whether the token is valid or not
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* #### input
|
|
30
|
+
* ```typescript
|
|
31
|
+
* const isValidToken = await isTokenValid({
|
|
32
|
+
* token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c",
|
|
33
|
+
* });
|
|
34
|
+
* ```
|
|
35
|
+
* #### output
|
|
36
|
+
* ```json
|
|
37
|
+
* true
|
|
38
|
+
* ```
|
|
15
39
|
*/
|
|
16
40
|
async function isTokenValid({ token, }) {
|
|
17
41
|
(0, parameters_validation_1.required)({ token });
|
|
@@ -25,9 +49,32 @@ async function isTokenValid({ token, }) {
|
|
|
25
49
|
return response === null || response === void 0 ? void 0 : response.data;
|
|
26
50
|
}
|
|
27
51
|
/**
|
|
52
|
+
* APICODE(AUTH-102)
|
|
28
53
|
* Ask for a new token from a refresh token
|
|
29
|
-
* @param {RefreshTokenParameters} params - The parameters for the function
|
|
54
|
+
* @param {RefreshTokenParameters} params - The parameters for the function, including:
|
|
55
|
+
* #### refreshToken - `string` | <strong style={{ color: 'red' }}>required</strong>
|
|
56
|
+
* The refresh token to request a new access token (required)
|
|
57
|
+
*
|
|
30
58
|
* @returns {Promise<RefreshTokenResponse>} - A promise that resolves to the response containing the new token
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* #### input
|
|
62
|
+
* ```typescript
|
|
63
|
+
* const response = await refreshToken({ refreshToken: 'string' });
|
|
64
|
+
* ```
|
|
65
|
+
* #### output
|
|
66
|
+
* ```json
|
|
67
|
+
* {
|
|
68
|
+
* "token": {
|
|
69
|
+
* "accessToken": "string",
|
|
70
|
+
* "expireAt": 0,
|
|
71
|
+
* "refreshToken": "string"
|
|
72
|
+
* },
|
|
73
|
+
* "user": {
|
|
74
|
+
* "id": "userID"
|
|
75
|
+
* }
|
|
76
|
+
* }
|
|
77
|
+
* ```
|
|
31
78
|
*/
|
|
32
79
|
async function refreshToken({ refreshToken, }) {
|
|
33
80
|
(0, parameters_validation_1.required)({ refreshToken });
|
|
@@ -41,9 +88,25 @@ async function refreshToken({ refreshToken, }) {
|
|
|
41
88
|
return data;
|
|
42
89
|
}
|
|
43
90
|
/**
|
|
91
|
+
* APICODE(PWD-102)
|
|
44
92
|
* Reset the password of a user
|
|
45
93
|
* @param {ResetPasswordParameters} params - The parameters for the function
|
|
46
|
-
*
|
|
94
|
+
* #### newPassword - `string` | <strong style={{ color: 'red' }}>required</strong>
|
|
95
|
+
* The new password to set for the user.
|
|
96
|
+
* #### resetPasswordToken - `string` | <strong style={{ color: 'red' }}>required</strong>
|
|
97
|
+
* The token required to authenticate the password reset process.
|
|
98
|
+
*
|
|
99
|
+
* @returns {Promise<void>} - Resolves to a success message `"OK"` when the password is successfully reset
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
* #### input
|
|
103
|
+
* ```typescript
|
|
104
|
+
* await resetPassword({ newPassword: 'string', resetPasswordToken: 'string' });
|
|
105
|
+
* ```
|
|
106
|
+
* #### output
|
|
107
|
+
* ```json
|
|
108
|
+
* "OK" (No output, resolves on success)
|
|
109
|
+
* ```
|
|
47
110
|
*/
|
|
48
111
|
async function resetPassword({ newPassword, resetPasswordToken, }) {
|
|
49
112
|
(0, parameters_validation_1.required)({ newPassword, resetPasswordToken });
|
|
@@ -57,9 +120,23 @@ async function resetPassword({ newPassword, resetPasswordToken, }) {
|
|
|
57
120
|
});
|
|
58
121
|
}
|
|
59
122
|
/**
|
|
123
|
+
* APICODE(PWD-101)
|
|
60
124
|
* Send an email to the user with a reset password link
|
|
61
|
-
* @param {SendResetPasswordEmailParameters} params - The parameters for the function
|
|
125
|
+
* @param {SendResetPasswordEmailParameters} params - The parameters for the function, including:
|
|
126
|
+
* #### email - `string` | <strong style={{ color: 'red' }}>required</strong>
|
|
127
|
+
* The email address to send the reset link to.
|
|
128
|
+
*
|
|
62
129
|
* @returns {Promise<void>} - A promise that resolves when the email is sent
|
|
130
|
+
*
|
|
131
|
+
* @example
|
|
132
|
+
* #### input
|
|
133
|
+
* ```typescript
|
|
134
|
+
* await sendResetPasswordEmail({ email: 'user@example.com' });
|
|
135
|
+
* ```
|
|
136
|
+
* #### output
|
|
137
|
+
* ```json
|
|
138
|
+
* "OK" (No output, resolves on success)
|
|
139
|
+
* ```
|
|
63
140
|
*/
|
|
64
141
|
async function sendResetPasswordEmail({ email, }) {
|
|
65
142
|
(0, parameters_validation_1.required)({ email });
|
|
@@ -72,9 +149,34 @@ async function sendResetPasswordEmail({ email, }) {
|
|
|
72
149
|
});
|
|
73
150
|
}
|
|
74
151
|
/**
|
|
152
|
+
* APICODE(AUTH-101)
|
|
75
153
|
* Login a user
|
|
76
|
-
* @param {LoginParameters} params - The parameters for the function
|
|
154
|
+
* @param {LoginParameters} params - The parameters for the function, including:
|
|
155
|
+
* #### username - `string` | <strong style={{ color: 'red' }}>required</strong>
|
|
156
|
+
* The username of the user to log in.
|
|
157
|
+
* #### password - `string` | <strong style={{ color: 'red' }}>required</strong>
|
|
158
|
+
* The password of the user to log in.
|
|
159
|
+
*
|
|
77
160
|
* @returns {Promise<LoginResponse>} - A promise that resolves to the response containing the user's login information
|
|
161
|
+
*
|
|
162
|
+
* @example
|
|
163
|
+
* #### input
|
|
164
|
+
* ```typescript
|
|
165
|
+
* const loginResponse = await login({ username: 'user@example.com', password: 'password123' });
|
|
166
|
+
* ```
|
|
167
|
+
* #### output
|
|
168
|
+
* ```json
|
|
169
|
+
* {
|
|
170
|
+
* "token": {
|
|
171
|
+
* "accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c",
|
|
172
|
+
* "expireAt": 1679022000,
|
|
173
|
+
* "refreshToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c"
|
|
174
|
+
* },
|
|
175
|
+
* "user": {
|
|
176
|
+
* "id": "userID"
|
|
177
|
+
* }
|
|
178
|
+
* }
|
|
179
|
+
* ```
|
|
78
180
|
*/
|
|
79
181
|
async function login({ username, password, }) {
|
|
80
182
|
(0, parameters_validation_1.required)({ username, password });
|
|
@@ -89,8 +191,21 @@ async function login({ username, password, }) {
|
|
|
89
191
|
return data;
|
|
90
192
|
}
|
|
91
193
|
/**
|
|
194
|
+
* APICODE(AUTH-103)
|
|
195
|
+
*
|
|
92
196
|
* Logout the user
|
|
197
|
+
*
|
|
93
198
|
* @returns {Promise<void>} - A promise that resolves when the user is logged out
|
|
199
|
+
*
|
|
200
|
+
* @example
|
|
201
|
+
* #### input
|
|
202
|
+
* ```typescript
|
|
203
|
+
* await logout();
|
|
204
|
+
* ```
|
|
205
|
+
* #### output
|
|
206
|
+
* ```json
|
|
207
|
+
* "OK" (No output, resolves on success)
|
|
208
|
+
* ```
|
|
94
209
|
*/
|
|
95
210
|
async function logout() {
|
|
96
211
|
await (0, fetch_instance_1.enhancedFetch)({
|