apify-client 2.23.1 → 2.23.2-beta.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.
package/dist/bundle.js CHANGED
@@ -16087,8 +16087,13 @@ const SAFETY_BUFFER_PERCENT = 0.01 / 100; // 0.01%
16087
16087
  var _this = this;
16088
16088
  ow__rspack_import_4_default()(options, ow__rspack_import_4_default().object.exactShape({
16089
16089
  limit: (ow__rspack_import_4_default().optional.number.not.negative),
16090
- exclusiveStartId: (ow__rspack_import_4_default().optional.string)
16091
- }));
16090
+ exclusiveStartId: (ow__rspack_import_4_default().optional.string),
16091
+ cursor: (ow__rspack_import_4_default().optional.string),
16092
+ filter: ow__rspack_import_4_default().optional.array.ofType(ow__rspack_import_4_default().string.oneOf([
16093
+ 'locked',
16094
+ 'pending'
16095
+ ])).minLength(1)
16096
+ }).validate((0,_utils__rspack_import_3.mutuallyExclusive)('exclusiveStartId', 'cursor')));
16092
16097
  const getPaginatedList = async function() {
16093
16098
  let rqListOptions = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
16094
16099
  const response = await _this.httpClient.call({
@@ -16097,6 +16102,7 @@ const SAFETY_BUFFER_PERCENT = 0.01 / 100; // 0.01%
16097
16102
  timeout: Math.min(_base_resource_client__rspack_import_2.MEDIUM_TIMEOUT_MILLIS, _this.timeoutMillis ?? Infinity),
16098
16103
  params: _this._params({
16099
16104
  ...rqListOptions,
16105
+ filter: rqListOptions.filter ? rqListOptions.filter.join(',') : undefined,
16100
16106
  clientKey: _this.clientKey
16101
16107
  })
16102
16108
  });
@@ -16110,13 +16116,15 @@ const SAFETY_BUFFER_PERCENT = 0.01 / 100; // 0.01%
16110
16116
  // RQ API response does not indicate whether there are more requests left, so we have to try and in case
16111
16117
  // of exhausting all requests we get response with empty items which ends the loop.
16112
16118
  while(currentPage.items.length > 0 && // Continue only if at least some items were returned in the last page.
16119
+ currentPage.nextCursor && // Continue only if the API returned a cursor for the next page.
16113
16120
  (remainingItems === undefined || remainingItems > 0 // Continue only if the limit was not exceeded.
16114
16121
  )){
16115
- const exclusiveStartId = currentPage.items[currentPage.items.length - 1].id;
16116
16122
  const newOptions = {
16117
16123
  ...options,
16118
16124
  limit: remainingItems,
16119
- exclusiveStartId
16125
+ // remove original exclusiveStartId, if there was any, and use cursor-based pagination
16126
+ exclusiveStartId: undefined,
16127
+ cursor: currentPage.nextCursor
16120
16128
  };
16121
16129
  currentPage = await getPaginatedList(newOptions);
16122
16130
  yield* currentPage.items;
@@ -16169,13 +16177,22 @@ const SAFETY_BUFFER_PERCENT = 0.01 / 100; // 0.01%
16169
16177
  ow__rspack_import_4_default()(options, ow__rspack_import_4_default().object.exactShape({
16170
16178
  limit: (ow__rspack_import_4_default().optional.number.not.negative),
16171
16179
  maxPageLimit: (ow__rspack_import_4_default().optional.number),
16172
- exclusiveStartId: (ow__rspack_import_4_default().optional.string)
16173
- }));
16174
- const { limit, exclusiveStartId, maxPageLimit = DEFAULT_REQUEST_QUEUE_REQUEST_PAGE_LIMIT } = options;
16175
- return new _utils__rspack_import_3.PaginationIterator({
16176
- getPage: this.listRequests.bind(this),
16180
+ exclusiveStartId: (ow__rspack_import_4_default().optional.string),
16181
+ cursor: (ow__rspack_import_4_default().optional.string),
16182
+ filter: ow__rspack_import_4_default().optional.array.ofType(ow__rspack_import_4_default().string.oneOf([
16183
+ 'locked',
16184
+ 'pending'
16185
+ ])).minLength(1)
16186
+ }).validate((0,_utils__rspack_import_3.mutuallyExclusive)('exclusiveStartId', 'cursor')));
16187
+ const { limit, exclusiveStartId, cursor, filter, maxPageLimit = DEFAULT_REQUEST_QUEUE_REQUEST_PAGE_LIMIT } = options;
16188
+ return new _utils__rspack_import_3.RequestQueuePaginationIterator({
16189
+ getPage: async (pageOptions)=>this.listRequests({
16190
+ ...pageOptions,
16191
+ filter
16192
+ }),
16177
16193
  limit,
16178
16194
  exclusiveStartId,
16195
+ cursor,
16179
16196
  maxPageLimit
16180
16197
  });
16181
16198
  }
@@ -17854,7 +17871,7 @@ class Statistics {
17854
17871
  "use strict";
17855
17872
  __webpack_require__.r(__webpack_exports__);
17856
17873
  __webpack_require__.d(__webpack_exports__, {
17857
- PaginationIterator: () => (PaginationIterator),
17874
+ RequestQueuePaginationIterator: () => (RequestQueuePaginationIterator),
17858
17875
  applyQueryParamsToUrl: () => (applyQueryParamsToUrl),
17859
17876
  asArray: () => (asArray),
17860
17877
  cast: () => (cast),
@@ -17864,6 +17881,7 @@ __webpack_require__.d(__webpack_exports__, {
17864
17881
  isNode: () => (isNode),
17865
17882
  isStream: () => (isStream),
17866
17883
  maybeGzipValue: () => (maybeGzipValue),
17884
+ mutuallyExclusive: () => (mutuallyExclusive),
17867
17885
  parseDateFields: () => (parseDateFields),
17868
17886
  pluckData: () => (pluckData),
17869
17887
  sliceArrayByByteLength: () => (sliceArrayByByteLength),
@@ -18002,7 +18020,7 @@ function isStream(value) {
18002
18020
  function getVersionData() {
18003
18021
  if (true) {
18004
18022
  return {
18005
- version: "2.23.1"
18023
+ version: "2.23.2-beta.1"
18006
18024
  };
18007
18025
  }
18008
18026
  // eslint-disable-next-line
@@ -18012,24 +18030,27 @@ _computedKey = Symbol.asyncIterator;
18012
18030
  let _computedKey1 = _computedKey;
18013
18031
  /**
18014
18032
  * Helper class to create async iterators from paginated list endpoints with exclusive start key.
18015
- */ class PaginationIterator {
18033
+ */ class RequestQueuePaginationIterator {
18016
18034
  async *[_computedKey1]() {
18017
- let nextPageExclusiveStartId;
18035
+ let nextCursor = this.cursor;
18036
+ // allow using exclusiveStartId for the first page, but then we'll delete it to avoid using it for any later page
18037
+ let nextExclusiveStartId = this.exclusiveStartId;
18018
18038
  let iterateItemCount = 0;
18019
18039
  while(true){
18020
18040
  const pageLimit = this.limit ? Math.min(this.maxPageLimit, this.limit - iterateItemCount) : this.maxPageLimit;
18021
- const pageExclusiveStartId = nextPageExclusiveStartId || this.exclusiveStartId;
18022
18041
  const page = await this.getPage({
18023
18042
  limit: pageLimit,
18024
- exclusiveStartId: pageExclusiveStartId
18043
+ cursor: nextCursor,
18044
+ exclusiveStartId: nextExclusiveStartId
18025
18045
  });
18026
18046
  // There are no more pages to iterate
18027
18047
  if (page.items.length === 0) return;
18028
18048
  yield page;
18029
18049
  iterateItemCount += page.items.length;
18030
18050
  // Limit reached stopping to iterate
18031
- if (this.limit && iterateItemCount >= this.limit) return;
18032
- nextPageExclusiveStartId = page.items[page.items.length - 1].id;
18051
+ if (this.limit && iterateItemCount >= this.limit || !page.nextCursor) return;
18052
+ nextCursor = page.nextCursor;
18053
+ nextExclusiveStartId = undefined; // see comment above - delete it for any page after the first one, and paginate with cursor
18033
18054
  }
18034
18055
  }
18035
18056
  constructor(options){
@@ -18037,9 +18058,11 @@ let _computedKey1 = _computedKey;
18037
18058
  (0,_swc_helpers_define_property__rspack_import_1._)(this, "getPage", void 0);
18038
18059
  (0,_swc_helpers_define_property__rspack_import_1._)(this, "limit", void 0);
18039
18060
  (0,_swc_helpers_define_property__rspack_import_1._)(this, "exclusiveStartId", void 0);
18061
+ (0,_swc_helpers_define_property__rspack_import_1._)(this, "cursor", void 0);
18040
18062
  this.maxPageLimit = options.maxPageLimit;
18041
18063
  this.limit = options.limit;
18042
18064
  this.exclusiveStartId = options.exclusiveStartId;
18065
+ this.cursor = options.cursor;
18043
18066
  this.getPage = options.getPage;
18044
18067
  }
18045
18068
  }
@@ -18069,6 +18092,18 @@ function asArray(value) {
18069
18092
  }
18070
18093
  return url;
18071
18094
  }
18095
+ const mutuallyExclusive = function() {
18096
+ for(var _len = arguments.length, keys = new Array(_len), _key = 0; _key < _len; _key++){
18097
+ keys[_key] = arguments[_key];
18098
+ }
18099
+ return (value)=>{
18100
+ const presentKeys = keys.filter((key)=>typeof value[key] !== 'undefined');
18101
+ return {
18102
+ validator: presentKeys.length <= 1,
18103
+ message: `At most one of the following fields is allowed: ${keys.join(', ')}`
18104
+ };
18105
+ };
18106
+ };
18072
18107
 
18073
18108
 
18074
18109
  },
@@ -26623,7 +26658,7 @@ const isIterable = (thing) => thing != null && isFunction(thing[iterator]);
26623
26658
  },
26624
26659
  8330(module) {
26625
26660
  "use strict";
26626
- module.exports = JSON.parse('{"name":"apify-client","version":"2.23.1","description":"Apify API client for JavaScript","main":"dist/index.js","module":"dist/index.mjs","types":"dist/index.d.ts","browser":"dist/bundle.js","unpkg":"dist/bundle.js","exports":{"./package.json":"./package.json","./browser":"./dist/bundle.js",".":{"import":"./dist/index.mjs","require":"./dist/index.js","types":"./dist/index.d.ts","browser":"./dist/bundle.js"}},"keywords":["apify","api","apifier","crawler","scraper"],"author":{"name":"Apify","email":"support@apify.com","url":"https://apify.com"},"contributors":["Jan Curn <jan@apify.com>","Marek Trunkát <marek@apify.com>","Ondra Urban <ondra@apify.com>","Jakub Drobník <jakub.drobnik@apify.com>"],"license":"Apache-2.0","repository":{"type":"git","url":"git+https://github.com/apify/apify-client-js"},"bugs":{"url":"https://github.com/apify/apify-client-js/issues"},"homepage":"https://docs.apify.com/api/client/js/","files":["dist","!dist/*.tsbuildinfo"],"scripts":{"build":"npm run clean && npm run build:node && npm run build:browser","postbuild":"gen-esm-wrapper dist/index.js dist/index.mjs","prepublishOnly":"(test $CI || (echo \\"Publishing is reserved to CI!\\"; exit 1))","clean":"rimraf dist","test":"npm run build && vitest run","test:bundling":"npm run build && npm --prefix=./test/bundling run bundle:all","lint":"eslint","lint:fix":"eslint --fix","tsc-check-tests":"tsc --noEmit --project test/tsconfig.json","format":"prettier --write .","format:check":"prettier --check .","build:node":"tsc","build:browser":"rsbuild build"},"dependencies":{"@apify/consts":"^2.50.0","@apify/log":"^2.2.6","@apify/utilities":"^2.23.2","@crawlee/types":"^3.3.0","ansi-colors":"^4.1.1","async-retry":"^1.3.3","axios":"^1.6.7","content-type":"^1.0.5","ow":"^0.28.2","proxy-agent":"^6.5.0","tslib":"^2.5.0","type-fest":"^4.0.0"},"devDependencies":{"@apify/eslint-config":"^1.0.0","@apify/tsconfig":"^0.1.1","@crawlee/puppeteer":"^3.2.2","@rsbuild/core":"^1.3.6","@rsbuild/plugin-node-polyfill":"^1.3.0","@rspack/cli":"^1.7.6","@rspack/core":"^1.7.6","@stylistic/eslint-plugin-ts":"^4.2.0","@types/async-retry":"^1.4.5","@types/compression":"^1.8.1","@types/content-type":"^1.1.5","@types/express":"^5.0.0","@types/node":"^24.0.0","ajv":"^8.17.1","body-parser":"^2.0.0","compression":"^1.7.4","esbuild":"0.27.4","eslint":"^9.24.0","eslint-config-prettier":"^10.1.2","express":"^5.0.0","gen-esm-wrapper":"^1.1.2","globals":"^17.0.0","prettier":"^3.5.3","puppeteer":"^24.0.0","rimraf":"^6.0.0","rolldown":"^1.0.0-rc.4","typescript":"^5.8.3","typescript-eslint":"^8.29.1","vitest":"^4.0.16","webpack":"^5.105.2","webpack-cli":"^7.0.0"},"packageManager":"npm@10.9.2"}')
26661
+ module.exports = JSON.parse('{"name":"apify-client","version":"2.23.2-beta.1","description":"Apify API client for JavaScript","main":"dist/index.js","module":"dist/index.mjs","types":"dist/index.d.ts","browser":"dist/bundle.js","unpkg":"dist/bundle.js","exports":{"./package.json":"./package.json","./browser":"./dist/bundle.js",".":{"import":"./dist/index.mjs","require":"./dist/index.js","types":"./dist/index.d.ts","browser":"./dist/bundle.js"}},"keywords":["apify","api","apifier","crawler","scraper"],"author":{"name":"Apify","email":"support@apify.com","url":"https://apify.com"},"contributors":["Jan Curn <jan@apify.com>","Marek Trunkát <marek@apify.com>","Ondra Urban <ondra@apify.com>","Jakub Drobník <jakub.drobnik@apify.com>"],"license":"Apache-2.0","repository":{"type":"git","url":"git+https://github.com/apify/apify-client-js"},"bugs":{"url":"https://github.com/apify/apify-client-js/issues"},"homepage":"https://docs.apify.com/api/client/js/","files":["dist","!dist/*.tsbuildinfo"],"scripts":{"build":"npm run clean && npm run build:node && npm run build:browser","postbuild":"gen-esm-wrapper dist/index.js dist/index.mjs","prepublishOnly":"(test $CI || (echo \\"Publishing is reserved to CI!\\"; exit 1))","clean":"rimraf dist","test":"npm run build && vitest run","test:bundling":"npm run build && npm --prefix=./test/bundling run bundle:all","lint":"eslint","lint:fix":"eslint --fix","tsc-check-tests":"tsc --noEmit --project test/tsconfig.json","format":"prettier --write .","format:check":"prettier --check .","build:node":"tsc","build:browser":"rsbuild build"},"dependencies":{"@apify/consts":"^2.50.0","@apify/log":"^2.2.6","@apify/utilities":"^2.23.2","@crawlee/types":"^3.3.0","ansi-colors":"^4.1.1","async-retry":"^1.3.3","axios":"^1.6.7","content-type":"^1.0.5","ow":"^0.28.2","proxy-agent":"^6.5.0","tslib":"^2.5.0","type-fest":"^4.0.0"},"devDependencies":{"@apify/eslint-config":"^1.0.0","@apify/tsconfig":"^0.1.1","@crawlee/puppeteer":"^3.2.2","@rsbuild/core":"^1.3.6","@rsbuild/plugin-node-polyfill":"^1.3.0","@rspack/cli":"^1.7.6","@rspack/core":"^1.7.6","@stylistic/eslint-plugin-ts":"^4.2.0","@types/async-retry":"^1.4.5","@types/compression":"^1.8.1","@types/content-type":"^1.1.5","@types/express":"^5.0.0","@types/node":"^24.0.0","ajv":"^8.17.1","body-parser":"^2.0.0","compression":"^1.7.4","esbuild":"0.27.4","eslint":"^9.24.0","eslint-config-prettier":"^10.1.2","express":"^5.0.0","gen-esm-wrapper":"^1.1.2","globals":"^17.0.0","prettier":"^3.5.3","puppeteer":"^24.0.0","rimraf":"^6.0.0","rolldown":"^1.0.0-rc.4","typescript":"^5.8.3","typescript-eslint":"^8.29.1","vitest":"^4.0.16","webpack":"^5.105.2","webpack-cli":"^7.0.0"},"packageManager":"npm@10.9.2"}')
26627
26662
 
26628
26663
  },
26629
26664