@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.
@@ -6,24 +6,83 @@ exports.getSupplierEvaluations = getSupplierEvaluations;
6
6
  const parameters_validation_1 = require("../../helpers/parameters-validation");
7
7
  const fetch_instance_1 = require("../../settings/fetch-instance");
8
8
  /**
9
- * Get suppliers
9
+ * 📄 Fetches a paginated list of suppliers.
10
+ *
11
+ * This function retrieves a list of suppliers based on the provided pagination parameters.
12
+ * If no specific filters or sorting are provided, it fetches the default paginated list.
13
+ *
14
+ * 🛠 **Endpoint**: `GET /v1/shop/suppliers`
15
+ *
16
+ * | Parameter | Type | Required | Description |
17
+ * |----------------------|-------------------------------|------------|---------------------------------------------------------------|
18
+ * | `pageable.page` | `number` | ✅ | The page number to fetch (0-based index). |
19
+ * | `pageable.size` | `number` | ✅ | The number of items per page. |
20
+ * | `pageable.sort` | `string[]` | ❌ | Sorting criteria (e.g., `["createdAt,desc"]`). |
21
+ * | `supplierStatus` | `string` | ❌ | Available values : ACTIVE, INACTIVE, SUSPENDED |
22
+ * | `supplierIds` | `string[]` | ❌ | Only returns information from its suppliers id |
23
+ * | `idType` | `string[]` | ❌ | Specifies the type of the id (ex: DJUST_ID, EXTERNAL_ID ) |
24
+ *
25
+ * 📤 **Returns**:
26
+ * A `Promise` resolving to a `GetSuppliersResponse` object,
27
+ * containing the paginated list of suppliers with metadata such as total pages, size, and current page.
28
+ *
29
+ * 🛠 **Example usage**:
30
+ * ```ts
31
+ * const suppliers = await getSuppliers({
32
+ * pageable: { page: 0, size: 10, sort: ["createdAt,desc"] },
33
+ * supplierStatus: 'ACTIVE',
34
+ * idType: 'EXTERNAL_ID'
35
+ * });
36
+ *
37
+ * console.log(suppliers);
38
+ * ```
39
+ *
40
+ * @param {GetSuppliersParameters} params - The pagination parameters for fetching suppliers.
41
+ * @throws {Error} If `pageable` is missing or invalid.
42
+ * @returns {Promise<GetSuppliersResponse>} A promise resolving to the paginated suppliers response.
10
43
  */
11
- async function getSuppliers({ pageable, }) {
44
+ async function getSuppliers({ pageable, supplierStatus, supplierIds, idType, }) {
12
45
  (0, parameters_validation_1.required)({ pageable });
13
46
  const { data } = await (0, fetch_instance_1.enhancedFetch)({
14
47
  method: "GET",
15
- path: `/v1/shop/autocomplete`,
48
+ path: `/v1/shop/suppliers`,
16
49
  params: {
17
50
  pageable,
18
51
  page: pageable.page,
19
52
  size: pageable.size,
20
53
  sort: pageable.sort,
54
+ supplierStatus,
55
+ supplierIds,
56
+ idType,
21
57
  },
22
58
  });
23
59
  return data;
24
60
  }
25
61
  /**
26
- * Get a supplier
62
+ * 📄 Fetches the details of a specific supplier.
63
+ *
64
+ * This function retrieves detailed information about a supplier, identified by its unique `supplierId` and optional `idType`.
65
+ *
66
+ * 🛠 **Endpoint**: `GET /v1/shop/suppliers/{supplierId}`
67
+ *
68
+ * | Parameter | Type | Required | Description |
69
+ * |----------------|------------|------------|---------------------------------------------------------|
70
+ * | `supplierId` | `string` | ✅ | The unique id of the supplier to fetch. |
71
+ * | `idType` | `string` | ❌ | Specifies the type of the id (ex: DJUST_ID, EXTERNAL_ID)|
72
+ *
73
+ * 📤 **Returns**:
74
+ * A `Promise` resolving to a `GetSupplierResponse` object, containing the details of the supplier.
75
+ *
76
+ * 🛠 **Example usage**:
77
+ * ```ts
78
+ * const supplier = await getSupplier({ supplierId: "supplier123", idType: "DJUST_ID" });
79
+ *
80
+ * console.log(supplier);
81
+ * ```
82
+ *
83
+ * @param {GetSupplierParameters} params - The parameters for fetching the supplier details.
84
+ * @throws {Error} If `supplierId` is missing.
85
+ * @returns {Promise<GetSupplierResponse>} A promise resolving to the supplier details.
27
86
  */
28
87
  async function getSupplier({ supplierId, idType, }) {
29
88
  (0, parameters_validation_1.required)({ supplierId, idType });
@@ -37,7 +96,39 @@ async function getSupplier({ supplierId, idType, }) {
37
96
  return data;
38
97
  }
39
98
  /**
40
- * Get supplier evaluations
99
+ * 📄 Fetches evaluations for a specific supplier.
100
+ *
101
+ * This function retrieves a list of evaluations associated with a supplier, identified by its `supplierId`.
102
+ * Pagination and sorting options are available to refine the results.
103
+ *
104
+ * 🛠 **Endpoint**: `GET /v1/shop/suppliers/{supplierId}/evaluations`
105
+ *
106
+ * | Parameter | Type | Required | Description |
107
+ * |----------------------|-------------------------------|------------|---------------------------------------------------------------|
108
+ * | `supplierId` | `string` | ✅ | The unique id of the supplier. |
109
+ * | `idType` | `string` | ❌ | Specifies the type of the id (ex: DJUST_ID, EXTERNAL_ID) |
110
+ * | `pageable.page` | `number` | ✅ | The page number to fetch (0-based index). |
111
+ * | `pageable.size` | `number` | ✅ | The number of items per page. |
112
+ * | `pageable.sort` | `string[]` | ❌ | Sorting criteria (e.g., `["createdAt,desc"]`). |
113
+ *
114
+ * 📤 **Returns**:
115
+ * A `Promise` resolving to a `GetSupplierEvaluationsResponse` object,
116
+ * containing the paginated list of supplier evaluations with metadata.
117
+ *
118
+ * 🛠 **Example usage**:
119
+ * ```ts
120
+ * const evaluations = await getSupplierEvaluations({
121
+ * supplierId: "supplier123",
122
+ * idType: "EXTERNAL_ID",
123
+ * pageable: { page: 1, size: 10, sort: ["createdAt,desc"] },
124
+ * });
125
+ *
126
+ * console.log(evaluations);
127
+ * ```
128
+ *
129
+ * @param {GetSupplierEvaluationsParameters} params - The parameters for fetching supplier evaluations.
130
+ * @throws {Error} If `supplierId` or `pageable` is missing.
131
+ * @returns {Promise<GetSupplierEvaluationsResponse>} A promise resolving to the supplier evaluations response.
41
132
  */
42
133
  async function getSupplierEvaluations({ supplierId, idType, pageable, }) {
43
134
  (0, parameters_validation_1.required)({ supplierId, idType });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@djust-b2b/djust-front-sdk",
3
- "version": "1.12.0",
3
+ "version": "1.13.0",
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",