@djust-b2b/djust-front-sdk 2.15.3 → 2.16.1

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.
@@ -53,9 +53,9 @@ export interface GetCustomerAccountOrdersParameters {
53
53
  nbPreviewLines?: number;
54
54
  logisticOrderStatuses?: string[];
55
55
  /**
56
- * @deprecated
56
+ * @deprecated Use logisticOrderStatuses instead
57
57
  */
58
- orderLogisticStatusType: string;
58
+ orderLogisticStatusType?: string;
59
59
  }
60
60
  export interface GetCustomerAccountUsersParameters {
61
61
  pageable: PageableParameters;
@@ -20,6 +20,7 @@ export declare function getCustomerAccount(config?: DjustConfig): Promise<GetCus
20
20
  /**
21
21
  * 📋 Get customer accounts.
22
22
  *
23
+ * This function retrieves a paginated list of customer accounts.
23
24
  *
24
25
  * 🛠 **Endpoint**: `GET /v2/shop/customer-accounts`
25
26
  *
@@ -28,18 +29,17 @@ export declare function getCustomerAccount(config?: DjustConfig): Promise<GetCus
28
29
  * | `pageable` | `object` | ❌ | The pagination parameters to retrieve paginated results. |
29
30
  *
30
31
  * 📤 **Returns**:
31
- * A `Promise<GetCustomerAccountResponseV2>`.
32
+ * A `Promise<GetCustomerAccountResponseV2>` containing the paginated list of customer accounts.
32
33
  *
33
- * 🛠 **Example Usage**:
34
+ * 🛠 **Example usage**:
34
35
  * ```typescript
35
- * const orders = await getCustomerAccountV2({
36
- * pageable: { page: 1, size: 10 },
36
+ * const accounts = await getCustomerAccountV2({
37
+ * pageable: { page: 0, size: 20 },
37
38
  * });
39
+ * console.log(accounts);
38
40
  * ```
39
41
  *
40
- * @param {GetCustomerAccountParametersV2} params - The parameters for fetching customer accounts:
41
- * - `pageable` - Pagination parameters.
42
- *
42
+ * @param {PageableParameters} pageable - The pagination parameters.
43
43
  * @returns {Promise<GetCustomerAccountResponseV2>} - The response containing the customer accounts.
44
44
  */
45
45
  export declare function getCustomerAccountV2(pageable: PageableParameters): Promise<GetCustomerAccountResponseV2>;
@@ -123,6 +123,13 @@ export declare function createCustomerAccount({ createAddressRequests, createCus
123
123
  * 📤 **Returns**:
124
124
  * A `Promise<UpdateCustomerAccountResponse>` containing the updated customer account details.
125
125
  *
126
+ * 🛠 **Example usage**:
127
+ * ```ts
128
+ * const response = await updateCustomerAccount({
129
+ * name: "Updated Company Name",
130
+ * accountManager: "John Doe",
131
+ * vatNumber: "FR12345678901",
132
+ * });
126
133
  * console.log(response);
127
134
  * ```
128
135
  */
@@ -300,12 +307,9 @@ export declare function getCustomerAccountCustomFields({ customFieldIds, idType,
300
307
  * |----------------------|------------|--------------|---------------------------------------------------------------------------|
301
308
  * | `pageable` | `object` | ✅ | The pagination parameters to retrieve paginated results. |
302
309
  * | `locale` | `string` | ✅ | The locale to be used for the response. |
303
- * | `nbPreviewLines` | `number` | ❌ | The number of order lines to retrieve by orders. |
310
+ * | `nbPreviewLines` | `number` | ❌ | The number of order lines to retrieve by orders (default: 100). |
304
311
  * | `logisticOrderStatuses`| `string[]`| ❌ | The statuses of the orders to retrieve. |
305
- * | `orderLogisticStatusType`| `string`| ❌ | The statuses of the orders to retrieve (deprecated). |
306
- * | `includeInactive` | `boolean` | ❌ | Whether to include inactive orders in the response. |
307
- * | `limit` | `number` | ❌ | The maximum number of orders to return. |
308
- * | `offset` | `number` | ❌ | The number of orders to skip before starting to collect results. |
312
+ * | `orderLogisticStatusType`| `string`| ❌ | The status of the orders to retrieve (deprecated, use logisticOrderStatuses instead). |
309
313
  *
310
314
  * 📤 **Returns**:
311
315
  * A `Promise<GetCustomerAccountOrdersResponse>` containing the retrieved customer account orders.
@@ -313,50 +317,48 @@ export declare function getCustomerAccountCustomFields({ customFieldIds, idType,
313
317
  * 🛠 **Example Usage**:
314
318
  * ```typescript
315
319
  * const orders = await getCustomerAccountOrders({
316
- * pageable: { page: 1, size: 10 },
320
+ * pageable: { page: 0, size: 20, sort: ['createdAt,DESC'] },
317
321
  * locale: 'en',
318
- * nbPreviewLines: 10,
322
+ * nbPreviewLines: 100,
319
323
  * logisticOrderStatuses: ["ORDER_CREATED", "WAITING_CUSTOMER_APPROVAL"],
320
324
  * });
321
325
  * ```
322
326
  *
323
327
  * @param {GetCustomerAccountOrdersParameters} params - The parameters for fetching customer account orders:
324
- * - `pageable` - Pagination parameters.
328
+ * - `pageable` - Pagination parameters (page, size, sort).
325
329
  * - `locale` - The locale for the response.
326
- * - `nbPreviewLines` (optional) - Number of order lines to put in the response.
327
- * - `logisticOrderStatuses` (optional) - Statuses of the orders to retrieve.
328
- * - `orderLogisticStatusType` (deprecated) - Statuses of the orders to retrieve.
329
- * - `includeInactive` (optional) - Whether to include inactive orders.
330
- * - `limit` (optional) - The maximum number of orders to return.
331
- * - `offset` (optional) - The number of orders to skip before collecting results.
330
+ * - `nbPreviewLines` (optional) - Number of order lines to put in the response (default: 100).
331
+ * - `logisticOrderStatuses` (optional) - Array of statuses of the orders to retrieve.
332
+ * - `orderLogisticStatusType` (optional, deprecated) - Single status of the orders to retrieve. Use logisticOrderStatuses instead.
332
333
  *
333
334
  * @returns {Promise<GetCustomerAccountOrdersResponse>} - The response containing the customer account orders.
334
335
  */
335
336
  export declare function getCustomerAccountOrders(params: GetCustomerAccountOrdersParameters & DjustConfig): Promise<GetCustomerAccountOrdersResponse>;
336
337
  /**
337
- * ## Retrieve Customer Account Users
338
+ * 📋 Retrieve Customer Account Users
338
339
  *
339
340
  * This function retrieves the list of users associated with a specific customer account.
340
341
  *
341
- * ### API Code: ACCOUNT-502
342
- *
343
- * ### **Endpoint**: `GET /v1/shop/customer-accounts/users`
342
+ * 🛠 **Endpoint**: `GET /v1/shop/customer-accounts/users` [ACCOUNT-502]
344
343
  *
345
344
  * | **Parameter** | **Type** | **Required** | **Description** |
346
345
  * |-------------------|------------|--------------|-------------------------------------------------------------|
347
346
  * | `pageable` | `object` | ✅ | Object containing pagination details: `page`, `size`, etc. |
348
347
  * | `forAllAccounts` | `boolean` | ❌ | Specifies if we want to retrieve users of all my users' accounts |
348
+ * | `query` | `string` | ❌ | Search query to filter users. |
349
349
  * | `locale` | `string` | ❌ | The locale in which data should be retrieved. |
350
350
  *
351
- * ### **Returns**:
351
+ * 📤 **Returns**:
352
352
  * A `Promise<GetCustomerAccountUsersResponse>` containing the list of users and pagination metadata.
353
353
  *
354
- * ### **Example Usage**:
354
+ * 🛠 **Example usage**:
355
355
  * ```typescript
356
356
  * const response = await getCustomerAccountUsers({
357
- * pageable: { page: 1, size: 10 },
358
- * locale: "en-US",
357
+ * pageable: { page: 0, size: 20 },
358
+ * locale: "fr-FR",
359
+ * query: "john",
359
360
  * });
361
+ * console.log(response);
360
362
  * ```
361
363
  */
362
364
  export declare function getCustomerAccountUsers(params: GetCustomerAccountUsersParameters & DjustConfig): Promise<GetCustomerAccountUsersResponse>;
@@ -49,6 +49,7 @@ async function getCustomerAccount(config) {
49
49
  /**
50
50
  * 📋 Get customer accounts.
51
51
  *
52
+ * This function retrieves a paginated list of customer accounts.
52
53
  *
53
54
  * 🛠 **Endpoint**: `GET /v2/shop/customer-accounts`
54
55
  *
@@ -57,18 +58,17 @@ async function getCustomerAccount(config) {
57
58
  * | `pageable` | `object` | ❌ | The pagination parameters to retrieve paginated results. |
58
59
  *
59
60
  * 📤 **Returns**:
60
- * A `Promise<GetCustomerAccountResponseV2>`.
61
+ * A `Promise<GetCustomerAccountResponseV2>` containing the paginated list of customer accounts.
61
62
  *
62
- * 🛠 **Example Usage**:
63
+ * 🛠 **Example usage**:
63
64
  * ```typescript
64
- * const orders = await getCustomerAccountV2({
65
- * pageable: { page: 1, size: 10 },
65
+ * const accounts = await getCustomerAccountV2({
66
+ * pageable: { page: 0, size: 20 },
66
67
  * });
68
+ * console.log(accounts);
67
69
  * ```
68
70
  *
69
- * @param {GetCustomerAccountParametersV2} params - The parameters for fetching customer accounts:
70
- * - `pageable` - Pagination parameters.
71
- *
71
+ * @param {PageableParameters} pageable - The pagination parameters.
72
72
  * @returns {Promise<GetCustomerAccountResponseV2>} - The response containing the customer accounts.
73
73
  */
74
74
  async function getCustomerAccountV2(pageable) {
@@ -188,6 +188,13 @@ async function createCustomerAccount({ createAddressRequests, createCustomerUser
188
188
  * 📤 **Returns**:
189
189
  * A `Promise<UpdateCustomerAccountResponse>` containing the updated customer account details.
190
190
  *
191
+ * 🛠 **Example usage**:
192
+ * ```ts
193
+ * const response = await updateCustomerAccount({
194
+ * name: "Updated Company Name",
195
+ * accountManager: "John Doe",
196
+ * vatNumber: "FR12345678901",
197
+ * });
191
198
  * console.log(response);
192
199
  * ```
193
200
  */
@@ -441,12 +448,9 @@ async function getCustomerAccountCustomFields({ customFieldIds, idType, pageable
441
448
  * |----------------------|------------|--------------|---------------------------------------------------------------------------|
442
449
  * | `pageable` | `object` | ✅ | The pagination parameters to retrieve paginated results. |
443
450
  * | `locale` | `string` | ✅ | The locale to be used for the response. |
444
- * | `nbPreviewLines` | `number` | ❌ | The number of order lines to retrieve by orders. |
451
+ * | `nbPreviewLines` | `number` | ❌ | The number of order lines to retrieve by orders (default: 100). |
445
452
  * | `logisticOrderStatuses`| `string[]`| ❌ | The statuses of the orders to retrieve. |
446
- * | `orderLogisticStatusType`| `string`| ❌ | The statuses of the orders to retrieve (deprecated). |
447
- * | `includeInactive` | `boolean` | ❌ | Whether to include inactive orders in the response. |
448
- * | `limit` | `number` | ❌ | The maximum number of orders to return. |
449
- * | `offset` | `number` | ❌ | The number of orders to skip before starting to collect results. |
453
+ * | `orderLogisticStatusType`| `string`| ❌ | The status of the orders to retrieve (deprecated, use logisticOrderStatuses instead). |
450
454
  *
451
455
  * 📤 **Returns**:
452
456
  * A `Promise<GetCustomerAccountOrdersResponse>` containing the retrieved customer account orders.
@@ -454,22 +458,19 @@ async function getCustomerAccountCustomFields({ customFieldIds, idType, pageable
454
458
  * 🛠 **Example Usage**:
455
459
  * ```typescript
456
460
  * const orders = await getCustomerAccountOrders({
457
- * pageable: { page: 1, size: 10 },
461
+ * pageable: { page: 0, size: 20, sort: ['createdAt,DESC'] },
458
462
  * locale: 'en',
459
- * nbPreviewLines: 10,
463
+ * nbPreviewLines: 100,
460
464
  * logisticOrderStatuses: ["ORDER_CREATED", "WAITING_CUSTOMER_APPROVAL"],
461
465
  * });
462
466
  * ```
463
467
  *
464
468
  * @param {GetCustomerAccountOrdersParameters} params - The parameters for fetching customer account orders:
465
- * - `pageable` - Pagination parameters.
469
+ * - `pageable` - Pagination parameters (page, size, sort).
466
470
  * - `locale` - The locale for the response.
467
- * - `nbPreviewLines` (optional) - Number of order lines to put in the response.
468
- * - `logisticOrderStatuses` (optional) - Statuses of the orders to retrieve.
469
- * - `orderLogisticStatusType` (deprecated) - Statuses of the orders to retrieve.
470
- * - `includeInactive` (optional) - Whether to include inactive orders.
471
- * - `limit` (optional) - The maximum number of orders to return.
472
- * - `offset` (optional) - The number of orders to skip before collecting results.
471
+ * - `nbPreviewLines` (optional) - Number of order lines to put in the response (default: 100).
472
+ * - `logisticOrderStatuses` (optional) - Array of statuses of the orders to retrieve.
473
+ * - `orderLogisticStatusType` (optional, deprecated) - Single status of the orders to retrieve. Use logisticOrderStatuses instead.
473
474
  *
474
475
  * @returns {Promise<GetCustomerAccountOrdersResponse>} - The response containing the customer account orders.
475
476
  */
@@ -485,34 +486,36 @@ async function getCustomerAccountOrders(params) {
485
486
  locale: params.locale,
486
487
  nbPreviewLines: params.nbPreviewLines,
487
488
  logisticOrderStatuses: params.logisticOrderStatuses,
489
+ orderLogisticStatusType: params.orderLogisticStatusType,
488
490
  },
489
491
  });
490
492
  return data;
491
493
  }
492
494
  /**
493
- * ## Retrieve Customer Account Users
495
+ * 📋 Retrieve Customer Account Users
494
496
  *
495
497
  * This function retrieves the list of users associated with a specific customer account.
496
498
  *
497
- * ### API Code: ACCOUNT-502
498
- *
499
- * ### **Endpoint**: `GET /v1/shop/customer-accounts/users`
499
+ * 🛠 **Endpoint**: `GET /v1/shop/customer-accounts/users` [ACCOUNT-502]
500
500
  *
501
501
  * | **Parameter** | **Type** | **Required** | **Description** |
502
502
  * |-------------------|------------|--------------|-------------------------------------------------------------|
503
503
  * | `pageable` | `object` | ✅ | Object containing pagination details: `page`, `size`, etc. |
504
504
  * | `forAllAccounts` | `boolean` | ❌ | Specifies if we want to retrieve users of all my users' accounts |
505
+ * | `query` | `string` | ❌ | Search query to filter users. |
505
506
  * | `locale` | `string` | ❌ | The locale in which data should be retrieved. |
506
507
  *
507
- * ### **Returns**:
508
+ * 📤 **Returns**:
508
509
  * A `Promise<GetCustomerAccountUsersResponse>` containing the list of users and pagination metadata.
509
510
  *
510
- * ### **Example Usage**:
511
+ * 🛠 **Example usage**:
511
512
  * ```typescript
512
513
  * const response = await getCustomerAccountUsers({
513
- * pageable: { page: 1, size: 10 },
514
- * locale: "en-US",
514
+ * pageable: { page: 0, size: 20 },
515
+ * locale: "fr-FR",
516
+ * query: "john",
515
517
  * });
518
+ * console.log(response);
516
519
  * ```
517
520
  */
518
521
  async function getCustomerAccountUsers(params) {
@@ -97,13 +97,17 @@ const isClientInitialized = (config) => "apiKey" in config && "clientId" in conf
97
97
  const serializeParams = (params, useRepeat) => {
98
98
  if (useRepeat) {
99
99
  return Object.keys(params)
100
+ .filter((key) => params[key] !== undefined && params[key] !== null)
100
101
  .map((key) => Array.isArray(params[key])
101
102
  ? params[key]
103
+ .filter((val) => val !== undefined && val !== null)
102
104
  .map((val) => `${encodeURIComponent(key)}=${encodeURIComponent(val)}`)
103
105
  .join("&")
104
106
  : `${encodeURIComponent(key)}=${encodeURIComponent(params[key])}`)
107
+ .filter(Boolean)
105
108
  .join("&");
106
109
  }
110
+ // Use "bracket" format for arrays by default (e.g., logisticStatus[]=VALUE1&logisticStatus[]=VALUE2)
107
111
  return qs.stringify(params, { arrayFormat: "bracket", skipNull: true });
108
112
  };
109
113
  const isTokenValid = (token) => {
@@ -153,7 +157,8 @@ const enhancedFetch = async ({ path, method, params = {}, body, }) => {
153
157
  headers.forEach((value, key) => requestHeaders.append(key, value));
154
158
  }
155
159
  let fullPath = `${clientConfig.baseUrl}${path}`;
156
- const useRepeatFormat = path.includes("search");
160
+ // Use repeat format for search endpoints and customer-accounts/orders endpoint
161
+ const useRepeatFormat = path.includes("search") || path.includes("/customer-accounts/orders");
157
162
  if (params) {
158
163
  const urlParams = serializeParams(params, useRepeatFormat);
159
164
  fullPath += `?${urlParams}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@djust-b2b/djust-front-sdk",
3
- "version": "2.15.3",
3
+ "version": "2.16.1",
4
4
  "description": "DJUST Front SDK is a versatile JavaScript Software Development Kit (SDK)",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",