@dereekb/util 12.0.6 → 12.1.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.
@@ -5939,9 +5939,11 @@ function fetchPageFactory(config) {
5939
5939
  return async () => {
5940
5940
  const result = await fetch(input);
5941
5941
  const {
5942
- cursor,
5942
+ cursor: readCursor,
5943
+ nextPageCursor,
5943
5944
  hasNext: readHasNext
5944
5945
  } = await readFetchPageResultInfo(result);
5946
+ const cursor = readCursor != null ? readCursor : previous == null ? void 0 : previous.cursor;
5945
5947
  const hasNext = readHasNext !== false;
5946
5948
  const page = previous ? previous.page + 1 : util.FIRST_PAGE;
5947
5949
  const isAtMaxPage = page >= maxPage;
@@ -5953,6 +5955,7 @@ function fetchPageFactory(config) {
5953
5955
  hasNext,
5954
5956
  isAtMaxPage,
5955
5957
  cursor,
5958
+ nextPageCursor,
5956
5959
  fetchNext: util.cachedGetter(async () => {
5957
5960
  // assert max page
5958
5961
  if (isAtMaxPage) {
@@ -6228,6 +6231,20 @@ function makeUrlSearchParams(input, options) {
6228
6231
  }
6229
6232
  return searchParams;
6230
6233
  }
6234
+ /**
6235
+ * Merges an array of MakeUrlSearchParamsOptions into a single MakeUrlSearchParamsOptions value.
6236
+ */
6237
+ function mergeMakeUrlSearchParamsOptions(options) {
6238
+ const omitKeys = new Set();
6239
+ util.useIterableOrValue(options, x => {
6240
+ if ((x == null ? void 0 : x.omitKeys) != null) {
6241
+ util.useIterableOrValue(x.omitKeys, key => omitKeys.add(key));
6242
+ }
6243
+ });
6244
+ return {
6245
+ omitKeys: omitKeys.size > 0 ? Array.from(omitKeys) : undefined
6246
+ };
6247
+ }
6231
6248
 
6232
6249
  var defineProperty = objectDefineProperty.f;
6233
6250
 
@@ -6753,6 +6770,7 @@ exports.iterateFetchPages = iterateFetchPages;
6753
6770
  exports.iterateFetchPagesByEachItem = iterateFetchPagesByEachItem;
6754
6771
  exports.iterateFetchPagesByItems = iterateFetchPagesByItems;
6755
6772
  exports.makeUrlSearchParams = makeUrlSearchParams;
6773
+ exports.mergeMakeUrlSearchParamsOptions = mergeMakeUrlSearchParamsOptions;
6756
6774
  exports.mergeRequestHeaders = mergeRequestHeaders;
6757
6775
  exports.mergeRequestInits = mergeRequestInits;
6758
6776
  exports.nodeFetchService = nodeFetchService;
@@ -5937,9 +5937,11 @@ function fetchPageFactory(config) {
5937
5937
  return async () => {
5938
5938
  const result = await fetch(input);
5939
5939
  const {
5940
- cursor,
5940
+ cursor: readCursor,
5941
+ nextPageCursor,
5941
5942
  hasNext: readHasNext
5942
5943
  } = await readFetchPageResultInfo(result);
5944
+ const cursor = readCursor != null ? readCursor : previous == null ? void 0 : previous.cursor;
5943
5945
  const hasNext = readHasNext !== false;
5944
5946
  const page = previous ? previous.page + 1 : FIRST_PAGE;
5945
5947
  const isAtMaxPage = page >= maxPage;
@@ -5951,6 +5953,7 @@ function fetchPageFactory(config) {
5951
5953
  hasNext,
5952
5954
  isAtMaxPage,
5953
5955
  cursor,
5956
+ nextPageCursor,
5954
5957
  fetchNext: cachedGetter(async () => {
5955
5958
  // assert max page
5956
5959
  if (isAtMaxPage) {
@@ -6226,6 +6229,20 @@ function makeUrlSearchParams(input, options) {
6226
6229
  }
6227
6230
  return searchParams;
6228
6231
  }
6232
+ /**
6233
+ * Merges an array of MakeUrlSearchParamsOptions into a single MakeUrlSearchParamsOptions value.
6234
+ */
6235
+ function mergeMakeUrlSearchParamsOptions(options) {
6236
+ const omitKeys = new Set();
6237
+ useIterableOrValue(options, x => {
6238
+ if ((x == null ? void 0 : x.omitKeys) != null) {
6239
+ useIterableOrValue(x.omitKeys, key => omitKeys.add(key));
6240
+ }
6241
+ });
6242
+ return {
6243
+ omitKeys: omitKeys.size > 0 ? Array.from(omitKeys) : undefined
6244
+ };
6245
+ }
6229
6246
 
6230
6247
  var defineProperty = objectDefineProperty.f;
6231
6248
 
@@ -6720,4 +6737,4 @@ const fetchApiFetchService = fetchService({
6720
6737
  */
6721
6738
  const nodeFetchService = fetchApiFetchService;
6722
6739
 
6723
- export { DEFAULT_FETCH_HANDLER, DEFAULT_FETCH_REQUEST_FACTORY, FETCH_PAGE_FACTORY_DEFAULT_MAX_PAGE, FetchPageLimitReachedError, FetchPageNoNextPageError, FetchRequestFactoryError, FetchResponseError, FetchTimeoutError, JsonResponseParseError, configureFetch, fetchApiFetchService, fetchJsonBodyString, fetchJsonFunction, fetchJsonRequestInit, fetchJsonRequestInitFunction, fetchOk, fetchPageFactory, fetchRequestFactory, fetchService, fetchTimeout, fetchURL, fetchURLQueryKeyValueStringTuples, fetchURLSearchParamsObjectToURLSearchParams, headersToHeadersTuple, isFetchRequest, isURL, isURLSearchParams, iterateFetchPages, iterateFetchPagesByEachItem, iterateFetchPagesByItems, makeUrlSearchParams, mergeRequestHeaders, mergeRequestInits, nodeFetchService, queryParamsToSearchParams, rateLimitedFetchHandler, requireOkResponse, returnNullHandleFetchJsonParseErrorFunction, throwJsonResponseParseErrorFunction };
6740
+ export { DEFAULT_FETCH_HANDLER, DEFAULT_FETCH_REQUEST_FACTORY, FETCH_PAGE_FACTORY_DEFAULT_MAX_PAGE, FetchPageLimitReachedError, FetchPageNoNextPageError, FetchRequestFactoryError, FetchResponseError, FetchTimeoutError, JsonResponseParseError, configureFetch, fetchApiFetchService, fetchJsonBodyString, fetchJsonFunction, fetchJsonRequestInit, fetchJsonRequestInitFunction, fetchOk, fetchPageFactory, fetchRequestFactory, fetchService, fetchTimeout, fetchURL, fetchURLQueryKeyValueStringTuples, fetchURLSearchParamsObjectToURLSearchParams, headersToHeadersTuple, isFetchRequest, isURL, isURLSearchParams, iterateFetchPages, iterateFetchPagesByEachItem, iterateFetchPagesByItems, makeUrlSearchParams, mergeMakeUrlSearchParamsOptions, mergeRequestHeaders, mergeRequestInits, nodeFetchService, queryParamsToSearchParams, rateLimitedFetchHandler, requireOkResponse, returnNullHandleFetchJsonParseErrorFunction, throwJsonResponseParseErrorFunction };
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dereekb/util/fetch",
3
- "version": "12.0.6",
3
+ "version": "12.1.1",
4
4
  ".": {
5
5
  "types": "./src/index.d.ts",
6
6
  "node": {
@@ -34,6 +34,10 @@ export interface FetchPageResultInfo extends Page {
34
34
  * Cursor for this page, if applicable.
35
35
  */
36
36
  readonly cursor?: Maybe<FetchPageCursor>;
37
+ /**
38
+ * Cursor for the next page, if applicable.
39
+ */
40
+ readonly nextPageCursor?: Maybe<FetchPageCursor>;
37
41
  /**
38
42
  * Whether or not there are more results to fetch.
39
43
  *
@@ -1,4 +1,4 @@
1
- import { type Maybe, type ArrayOrValue, type IterableOrValue, type ObjectKey, type FilterKeyValueTuplesInput } from '@dereekb/util';
1
+ import { type Maybe, type ArrayOrValue, type IterableOrValue, type ObjectKey } from '@dereekb/util';
2
2
  /**
3
3
  * Options for makeUrlSearchParams()
4
4
  */
@@ -7,10 +7,6 @@ export interface MakeUrlSearchParamsOptions {
7
7
  * Optional iterable of keys to remove from the search params.
8
8
  */
9
9
  readonly omitKeys?: Maybe<IterableOrValue<ObjectKey>>;
10
- /**
11
- * Optional filter for merging the objects together.
12
- */
13
- readonly mergeFilter?: FilterKeyValueTuplesInput;
14
10
  }
15
11
  /**
16
12
  * Creates URLSearchParams from the input objects. The input objects are merged together.
@@ -20,3 +16,7 @@ export interface MakeUrlSearchParamsOptions {
20
16
  * @returns
21
17
  */
22
18
  export declare function makeUrlSearchParams(input: Maybe<ArrayOrValue<Maybe<object | Record<string, string | number>>>>, options?: Maybe<MakeUrlSearchParamsOptions>): URLSearchParams;
19
+ /**
20
+ * Merges an array of MakeUrlSearchParamsOptions into a single MakeUrlSearchParamsOptions value.
21
+ */
22
+ export declare function mergeMakeUrlSearchParamsOptions(options: ArrayOrValue<Maybe<MakeUrlSearchParamsOptions>>): MakeUrlSearchParamsOptions;