@autofleet/network 1.5.2-beta-1 → 1.5.2

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.
Files changed (2) hide show
  1. package/index.js +12 -2
  2. package/package.json +2 -2
package/index.js CHANGED
@@ -174,12 +174,22 @@ module.exports = class Network {
174
174
  return currentResult;
175
175
  }
176
176
 
177
- async getAllPagesFromQueryEndpoint(url, options = {}) {
177
+ /**
178
+ * Fetches all pages from a paginated API endpoint until all results are retrieved
179
+ * or an optional page limit is reached.
180
+ *
181
+ * @param {string} url - The endpoint URL to send the request to.
182
+ * @param {object} [options={}] - Additional options to include in the request payload.
183
+ * @param {number} [pageLimit=100] - The maximum number of pages to fetch.
184
+ * Set to -1 for no limit.
185
+ * @returns {Promise<Array>} - A promise that resolves to an array of all results.
186
+ */
187
+ async getAllPagesFromQueryEndpoint(url, options = {}, pageLimit = 100) {
178
188
  let currentResult = [];
179
189
 
180
190
  let moreResultsToLoad = true;
181
191
  let page = 1;
182
- while(moreResultsToLoad && page < 100) {
192
+ while (moreResultsToLoad && (pageLimit === -1 || page < pageLimit)) {
183
193
  const { data } = await this.post(url, {
184
194
  ...options,
185
195
  page: page,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autofleet/network",
3
- "version": "1.5.2-beta-1",
3
+ "version": "1.5.2",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -12,7 +12,7 @@
12
12
  "license": "ISC",
13
13
  "dependencies": {
14
14
  "@autofleet/axios-cache-adapter": "^2.7.3-hotfix-1",
15
- "@autofleet/logger": "^4.0.0-beta-2",
15
+ "@autofleet/logger": "^2.0.2",
16
16
  "agentkeepalive": "^4.3.0",
17
17
  "axios": "^0.26.1",
18
18
  "axios-retry": "^3.2.4",