@djust-b2b/djust-front-sdk 1.20.6 → 1.21.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.
@@ -12,19 +12,19 @@ export interface GetCartsParameters {
12
12
  currency: Currency;
13
13
  pageable: PageableParameters;
14
14
  status?: CartStatusDto[];
15
- type?: CartTypeDto[];
15
+ type?: CartTypeDto;
16
16
  }
17
17
  export interface DeleteCartParameters {
18
18
  cartId: string;
19
19
  }
20
20
  export interface CreateCartParameters {
21
21
  name: string;
22
- type: string;
22
+ type?: CartTypeDto;
23
23
  }
24
24
  export interface UpdateCartParameters {
25
25
  cartId: string;
26
26
  name: string;
27
- type: string;
27
+ type: CartTypeDto;
28
28
  }
29
29
  export interface InitializeOrdersFromCartParameters {
30
30
  cartId: string;
@@ -32,7 +32,7 @@ export declare function deleteCarts(): Promise<DeleteCartsResponse>;
32
32
  * | `currency` | `string` | ✅ | The currency in which to display the carts. |
33
33
  * | `pageable` | `object` | ✅ | The pagination parameters. |
34
34
  * | `status` | `string[]` | ❌ | The status of the carts to retrieve. |
35
- * | `type` | `string[]` | ❌ | The type of carts to retrieve. |
35
+ * | `type` | `string[]` | ❌ | The type of carts to retrieve (e.g. `CART`, `BUYING_LIST`). |
36
36
  *
37
37
  * 📤 **Returns**:
38
38
  * A `Promise` resolving to a `GetCartsResponse` object, containing the list of carts and pagination information.
@@ -61,6 +61,7 @@ export declare function getCarts(params: GetCartsParameters): Promise<GetCartsRe
61
61
  * | Parameter | Type | Required | Description |
62
62
  * |------------|----------|------------|---------------------------------|
63
63
  * | `name` | `string` | ✅ | The name of the cart to create. |
64
+ * | `type` | `CartTypeDto` | ❌ | The type of the cart to create (`CART` (by default) or `BUYING_LIST`). |
64
65
  *
65
66
  * 📤 **Returns**:
66
67
  * A `Promise` resolving to a `GetCartResponse` object, confirming the creation of the cart.
@@ -141,7 +142,7 @@ export declare function getCart(params: GetCartParameters): Promise<GetCartRespo
141
142
  * |------------|----------|------------|---------------------------------------|
142
143
  * | `cartId` | `string` | ✅ | The ID of the cart to update. |
143
144
  * | `name` | `string` | ✅ | The new name of the cart. |
144
- * | `type` | `string` | ❌ | The new name of the cart. |
145
+ * | `type` | `CartTypeDto` | ❌ | The type of cart (`CART` (by default) or `BUYING_LIST`). |
145
146
  *
146
147
  * 📤 **Returns**:
147
148
  * A `Promise<void>` that resolves when the cart is successfully updated.
@@ -52,7 +52,7 @@ async function deleteCarts() {
52
52
  * | `currency` | `string` | ✅ | The currency in which to display the carts. |
53
53
  * | `pageable` | `object` | ✅ | The pagination parameters. |
54
54
  * | `status` | `string[]` | ❌ | The status of the carts to retrieve. |
55
- * | `type` | `string[]` | ❌ | The type of carts to retrieve. |
55
+ * | `type` | `string[]` | ❌ | The type of carts to retrieve (e.g. `CART`, `BUYING_LIST`). |
56
56
  *
57
57
  * 📤 **Returns**:
58
58
  * A `Promise` resolving to a `GetCartsResponse` object, containing the list of carts and pagination information.
@@ -96,6 +96,7 @@ async function getCarts(params) {
96
96
  * | Parameter | Type | Required | Description |
97
97
  * |------------|----------|------------|---------------------------------|
98
98
  * | `name` | `string` | ✅ | The name of the cart to create. |
99
+ * | `type` | `CartTypeDto` | ❌ | The type of the cart to create (`CART` (by default) or `BUYING_LIST`). |
99
100
  *
100
101
  * 📤 **Returns**:
101
102
  * A `Promise` resolving to a `GetCartResponse` object, confirming the creation of the cart.
@@ -111,13 +112,13 @@ async function getCarts(params) {
111
112
  * @returns {Promise<GetCartResponse>} - A promise that resolves when the cart is created.
112
113
  */
113
114
  async function createCart(params) {
114
- const { name } = params;
115
+ const { name, type } = params;
115
116
  // Ensure required parameter is present
116
117
  (0, parameters_validation_1.required)({ name });
117
118
  const { data } = await (0, fetch_instance_1.enhancedFetch)({
118
119
  method: "POST",
119
120
  path: `/v2/shop/carts`,
120
- body: JSON.stringify({ name }),
121
+ body: JSON.stringify({ name, type: type || "CART" }),
121
122
  });
122
123
  return data;
123
124
  }
@@ -207,7 +208,7 @@ async function getCart(params) {
207
208
  * |------------|----------|------------|---------------------------------------|
208
209
  * | `cartId` | `string` | ✅ | The ID of the cart to update. |
209
210
  * | `name` | `string` | ✅ | The new name of the cart. |
210
- * | `type` | `string` | ❌ | The new name of the cart. |
211
+ * | `type` | `CartTypeDto` | ❌ | The type of cart (`CART` (by default) or `BUYING_LIST`). |
211
212
  *
212
213
  * 📤 **Returns**:
213
214
  * A `Promise<void>` that resolves when the cart is successfully updated.
@@ -60,6 +60,32 @@ const serializeParams = (params, useRepeat) => {
60
60
  }
61
61
  return qs.stringify(params, { arrayFormat: "bracket", skipNull: true });
62
62
  };
63
+ // Liste des routes publiques (sans JWT)
64
+ const publicRoutes = new Map([
65
+ ["/auth/token", new Set(["POST"])],
66
+ ["/auth/refresh-token", new Set(["POST"])],
67
+ ["/auth/reset-password", new Set(["POST"])],
68
+ ["/auth/send-reset-password-email", new Set(["POST"])],
69
+ ["/v1/shop/assets", new Set(["GET"])],
70
+ ["/v1/shop/customer-accounts", new Set(["POST"])], // Seulement POST est public
71
+ ["/v1/shop/attributes", new Set(["GET"])],
72
+ ["/v1/shop/custom-fields", new Set(["GET"])],
73
+ ["/v1/shop/offer-inventories", new Set(["GET"])],
74
+ ["/v2/shop/autocomplete", new Set(["GET"])],
75
+ ["/v2/shop/search", new Set(["GET"])],
76
+ ]);
77
+ const publicRoutePatterns = [
78
+ "/v1/shop/navigation-category/",
79
+ "/v1/shop/products/",
80
+ "/v1/shop/product-variants/",
81
+ ];
82
+ const isPublicRoute = (path, method) => {
83
+ var _a;
84
+ if (publicRoutes.has(path) && ((_a = publicRoutes.get(path)) === null || _a === void 0 ? void 0 : _a.has(method))) {
85
+ return true;
86
+ }
87
+ return publicRoutePatterns.some((pattern) => path.startsWith(pattern));
88
+ };
63
89
  const enhancedFetch = async ({ path, method, params = {}, body, }) => {
64
90
  var _a, _b, _c, _d, _e, _f;
65
91
  if (!isClientInitialized(clientConfig)) {
@@ -77,7 +103,7 @@ const enhancedFetch = async ({ path, method, params = {}, body, }) => {
77
103
  // requestHeaders.append("Authorization", `Bearer ${token}`);
78
104
  // }
79
105
  // }
80
- if (accessToken)
106
+ if (!isPublicRoute(path, method) && accessToken)
81
107
  requestHeaders.append("Authorization", `Bearer ${accessToken}`);
82
108
  if (locale)
83
109
  requestHeaders.append("locale", locale);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@djust-b2b/djust-front-sdk",
3
- "version": "1.20.6",
3
+ "version": "1.21.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",