@ethlete/query 5.21.0 → 5.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.
@@ -2871,6 +2871,15 @@ const uncacheableRequestHasCacheKeyParam = (key) => {
2871
2871
  const uncacheableRequestHasSkipCacheParam = () => {
2872
2872
  return new RuntimeError(301 /* RuntimeErrorCode.UNCACHEABLE_REQUEST_HAS_SKIP_CACHE_PARAM */, `This request is uncacheable, but skipCache is set to true. Please remove it.`);
2873
2873
  };
2874
+ const pagedQueryPageBiggerThanTotalPages = (page, totalPages) => {
2875
+ return new RuntimeError(400 /* RuntimeErrorCode.PAGED_QUERY_PAGE_BIGGER_THAN_TOTAL_PAGES */, `The page "${page}" is bigger than the total pages "${totalPages}".`);
2876
+ };
2877
+ const pagedQueryNextPageCalledWithoutPreviousPage = () => {
2878
+ return new RuntimeError(401 /* RuntimeErrorCode.PAGED_QUERY_NEXT_PAGE_CALLED_WITHOUT_PREVIOUS_PAGE */, `fetchNextPage() has been called but the current page is not yet loaded. Please call it after the previous page has been loaded.`);
2879
+ };
2880
+ const pagedQueryPreviousPageCalledButAlreadyAtFirstPage = () => {
2881
+ return new RuntimeError(402 /* RuntimeErrorCode.PAGED_QUERY_PREVIOUS_PAGE_CALLED_BUT_ALREADY_AT_FIRST_PAGE */, `fetchPreviousPage() has been called but the current page is already the first page.`);
2882
+ };
2874
2883
 
2875
2884
  /* eslint-disable @typescript-eslint/no-empty-function */
2876
2885
  const defaultResponseTransformer = (response) => {
@@ -3342,8 +3351,8 @@ const createHttpRequest = (options) => {
3342
3351
  updateErrorState(e);
3343
3352
  return throwError(() => e);
3344
3353
  }));
3345
- const execute = () => {
3346
- if (loading() || !isStale()) {
3354
+ const execute = (options) => {
3355
+ if (loading() || (!isStale() && !options?.skipCache)) {
3347
3356
  // Do not execute if there is already a request in progress or the request is not stale
3348
3357
  return false;
3349
3358
  }
@@ -3450,6 +3459,383 @@ const createHttpRequest = (options) => {
3450
3459
  return httpRequest;
3451
3460
  };
3452
3461
 
3462
+ /* eslint-disable @typescript-eslint/no-empty-function */
3463
+ const createQueryFeature = (config) => {
3464
+ return config;
3465
+ };
3466
+ const withArgs = (args) => {
3467
+ return createQueryFeature({
3468
+ type: "withArgs" /* QueryFeatureType.WithArgs */,
3469
+ fn: (context) => {
3470
+ const currArgs = computed(() => args());
3471
+ queryEffect(() => {
3472
+ const currArgsNow = currArgs();
3473
+ if (currArgsNow === null)
3474
+ return;
3475
+ untracked(() => {
3476
+ if (currArgsNow === QUERY_ARGS_RESET) {
3477
+ context.state.args.set(null);
3478
+ return;
3479
+ }
3480
+ context.state.args.set(currArgsNow);
3481
+ if (context.flags.shouldAutoExecute)
3482
+ context.execute({ args: currArgsNow });
3483
+ });
3484
+ }, QUERY_EFFECT_ERROR_MESSAGE, { injector: context.deps.injector });
3485
+ },
3486
+ });
3487
+ };
3488
+ const withPolling = (options) => {
3489
+ return createQueryFeature({
3490
+ type: "withPolling" /* QueryFeatureType.WithPolling */,
3491
+ fn: (context) => {
3492
+ if (!context.flags.shouldAutoExecuteMethod) {
3493
+ throw withPollingUsedOnUnsupportedHttpMethod(context.creatorInternals.method);
3494
+ }
3495
+ let intervalId = null;
3496
+ queryEffect(() => {
3497
+ const args = context.state.args();
3498
+ untracked(() => {
3499
+ if (intervalId !== null)
3500
+ clearInterval(intervalId);
3501
+ if (args === null)
3502
+ return;
3503
+ if (options.executeInitially) {
3504
+ context.execute({ args });
3505
+ }
3506
+ intervalId = window.setInterval(() => {
3507
+ context.execute({ args });
3508
+ }, options.interval);
3509
+ });
3510
+ }, QUERY_EFFECT_ERROR_MESSAGE, { injector: context.deps.injector });
3511
+ context.deps.destroyRef.onDestroy(() => intervalId !== null && clearInterval(intervalId));
3512
+ },
3513
+ });
3514
+ };
3515
+ const withLogging = (options) => {
3516
+ return createQueryFeature({
3517
+ type: "withLogging" /* QueryFeatureType.WithLogging */,
3518
+ fn: (context) => {
3519
+ effect(() => {
3520
+ const event = context.state.latestHttpEvent();
3521
+ if (event === null)
3522
+ return;
3523
+ untracked(() => {
3524
+ options.logFn(event);
3525
+ });
3526
+ }, { injector: context.deps.injector });
3527
+ },
3528
+ });
3529
+ };
3530
+ const withErrorHandling = (options) => {
3531
+ return createQueryFeature({
3532
+ type: "withErrorHandling" /* QueryFeatureType.WithErrorHandling */,
3533
+ fn: (context) => {
3534
+ effect(() => {
3535
+ const error = context.state.error();
3536
+ if (error === null)
3537
+ return;
3538
+ untracked(() => {
3539
+ options.handler(error);
3540
+ });
3541
+ }, { injector: context.deps.injector });
3542
+ },
3543
+ });
3544
+ };
3545
+ const withSuccessHandling = (options) => {
3546
+ return createQueryFeature({
3547
+ type: "withSuccessHandling" /* QueryFeatureType.WithSuccessHandling */,
3548
+ fn: (context) => {
3549
+ effect(() => {
3550
+ const response = context.state.response();
3551
+ if (response === null)
3552
+ return;
3553
+ untracked(() => {
3554
+ options.handler(response);
3555
+ });
3556
+ }, { injector: context.deps.injector });
3557
+ },
3558
+ });
3559
+ };
3560
+ const withAutoRefresh = (options) => {
3561
+ return createQueryFeature({
3562
+ type: "withAutoRefresh" /* QueryFeatureType.WithAutoRefresh */,
3563
+ fn: (context) => {
3564
+ if (!context.flags.shouldAutoExecuteMethod) {
3565
+ throw withAutoRefreshUsedOnUnsupportedHttpMethod(context.creatorInternals.method);
3566
+ }
3567
+ if (context.queryConfig.onlyManualExecution && !options.ignoreOnlyManualExecution) {
3568
+ throw withAutoRefreshUsedOnUnsupportedHttpMethod(context.creatorInternals.method);
3569
+ }
3570
+ queryEffect(() => {
3571
+ for (const signal of options.signalChanges) {
3572
+ signal();
3573
+ }
3574
+ untracked(() => {
3575
+ const args = context.state.args();
3576
+ if (args === null)
3577
+ return;
3578
+ context.execute({ args });
3579
+ });
3580
+ }, QUERY_EFFECT_ERROR_MESSAGE, { injector: context.deps.injector });
3581
+ },
3582
+ });
3583
+ };
3584
+
3585
+ const transformArrayResponse = (responses) => responses.filter((r) => !!r).flatMap((r) => r);
3586
+ const transformPaginatedResponse = (responses) => responses.filter((r) => !!r).flatMap((r) => r.items);
3587
+ const createQueryStack = (computation, options) => {
3588
+ const { append = false, appendFn = (oldQueries, newQueries) => {
3589
+ const queries = [...oldQueries, ...newQueries];
3590
+ const lastQuery = newQueries[newQueries.length - 1] ?? oldQueries[oldQueries.length - 1] ?? null;
3591
+ return { queries, lastQuery };
3592
+ }, transform, } = options ?? {};
3593
+ const injector = inject(Injector);
3594
+ const queries = signal([]);
3595
+ const lastQuery = signal(null);
3596
+ effect(() => {
3597
+ const newQueryOrQueries = runInInjectionContext(injector, () => computation());
3598
+ const newQueries = Array.isArray(newQueryOrQueries) ? newQueryOrQueries : [newQueryOrQueries].filter((q) => !!q);
3599
+ untracked(() => {
3600
+ const oldQueries = queries();
3601
+ if (append) {
3602
+ const { queries: appendedQueries, lastQuery: lastAppendedQuery } = appendFn(oldQueries, newQueries);
3603
+ queries.set(appendedQueries);
3604
+ lastQuery.set(lastAppendedQuery);
3605
+ }
3606
+ else {
3607
+ for (const oldQuery of oldQueries) {
3608
+ if (!newQueries.some((q) => q.id() === oldQuery.id())) {
3609
+ oldQuery.destroy();
3610
+ }
3611
+ }
3612
+ queries.set(newQueries);
3613
+ lastQuery.set(newQueries[newQueries.length - 1] ?? null);
3614
+ }
3615
+ });
3616
+ });
3617
+ const loading = computed(() => queries().some((q) => q.loading()));
3618
+ const error = computed(() => queries()
3619
+ .map((q) => q.error())
3620
+ .find((e) => e !== null) ?? null);
3621
+ const response = computed(() => {
3622
+ const responses = queries().map((q) => q.response());
3623
+ return transform?.(responses) ?? responses;
3624
+ });
3625
+ const execute = (options) => {
3626
+ for (const query of queries()) {
3627
+ query.execute({ options: { skipCache: options?.skipCache } });
3628
+ }
3629
+ };
3630
+ const clear = () => {
3631
+ for (const query of queries()) {
3632
+ query.destroy();
3633
+ }
3634
+ queries.set([]);
3635
+ lastQuery.set(null);
3636
+ };
3637
+ const stack = {
3638
+ queries: queries.asReadonly(),
3639
+ lastQuery: lastQuery.asReadonly(),
3640
+ loading,
3641
+ error,
3642
+ response,
3643
+ execute,
3644
+ clear,
3645
+ };
3646
+ return stack;
3647
+ };
3648
+
3649
+ const ethletePaginationAdapter = (response) => {
3650
+ const pagination = {
3651
+ items: response.items,
3652
+ totalPages: response.totalPageCount,
3653
+ currentPage: response.currentPage,
3654
+ itemsPerPage: response.itemsPerPage,
3655
+ totalHits: response.totalHits,
3656
+ };
3657
+ return pagination;
3658
+ };
3659
+ const ggLikePaginationAdapter = (response) => {
3660
+ const pagination = {
3661
+ items: response.items,
3662
+ totalPages: response.totalPageCount,
3663
+ currentPage: response.currentPage,
3664
+ itemsPerPage: response.itemsPerPage,
3665
+ totalHits: response.totalHits,
3666
+ };
3667
+ return pagination;
3668
+ };
3669
+ const dynLikePaginationAdapter = (response) => {
3670
+ const pagination = {
3671
+ items: response.items,
3672
+ totalPages: response.totalPages,
3673
+ currentPage: response.currentPage,
3674
+ itemsPerPage: response.limit,
3675
+ totalHits: response.totalHits,
3676
+ };
3677
+ return pagination;
3678
+ };
3679
+ const contentfulGqlLikePaginationAdapter = (response) => {
3680
+ const totalPages = Math.max(Math.ceil(response.total / response.limit), 1); // If there are no items, there is still one page
3681
+ const currentPage = Math.max(Math.ceil(response.skip / response.limit) + 1, 1);
3682
+ const pagination = {
3683
+ items: response.items,
3684
+ totalPages,
3685
+ currentPage,
3686
+ itemsPerPage: response.limit,
3687
+ totalHits: response.total,
3688
+ };
3689
+ return pagination;
3690
+ };
3691
+ const createPagedQuery = (options) => {
3692
+ const { responseNormalizer, queryCreator } = options;
3693
+ const currentPageArgs = signal(null);
3694
+ const initialPage = signal(options.initialPage ?? 1);
3695
+ const loadedMinPage = signal(initialPage());
3696
+ const loadedMaxPage = signal(initialPage());
3697
+ const lastResetTimestamp = signal(Date.now());
3698
+ const pageDirection = signal('next');
3699
+ const stack = createQueryStack(() => {
3700
+ const args = currentPageArgs();
3701
+ if (!args)
3702
+ return null;
3703
+ return queryCreator(withArgs(() => {
3704
+ return args;
3705
+ }));
3706
+ }, {
3707
+ append: true,
3708
+ appendFn: (oldQueries, newQueries) => {
3709
+ const newQuery = newQueries[0];
3710
+ const dir = pageDirection();
3711
+ if (!newQuery) {
3712
+ const lastQuery = oldQueries[oldQueries.length - 1] ?? null;
3713
+ return { queries: oldQueries, lastQuery };
3714
+ }
3715
+ else if (dir === 'previous') {
3716
+ return { queries: [newQuery, ...oldQueries], lastQuery: newQuery };
3717
+ }
3718
+ else {
3719
+ return { queries: [...oldQueries, newQuery], lastQuery: newQuery };
3720
+ }
3721
+ },
3722
+ transform: transformArrayResponse,
3723
+ });
3724
+ effect(() => {
3725
+ lastResetTimestamp();
3726
+ const args = options.args(initialPage());
3727
+ untracked(() => {
3728
+ stack.clear();
3729
+ currentPageArgs.set(args);
3730
+ loadedMinPage.set(initialPage());
3731
+ loadedMaxPage.set(initialPage());
3732
+ });
3733
+ });
3734
+ const pagination = computed(() => {
3735
+ const res = stack.lastQuery()?.response();
3736
+ if (!res)
3737
+ return null;
3738
+ return responseNormalizer(res);
3739
+ });
3740
+ const fetchPreviousPage = () => {
3741
+ const page = loadedMinPage() - 1;
3742
+ if (page < 1) {
3743
+ if (isDevMode()) {
3744
+ throw pagedQueryPreviousPageCalledButAlreadyAtFirstPage();
3745
+ }
3746
+ return;
3747
+ }
3748
+ currentPageArgs.set(options.args(page));
3749
+ loadedMinPage.set(page);
3750
+ pageDirection.set('previous');
3751
+ };
3752
+ const fetchNextPage = () => {
3753
+ const page = loadedMaxPage() + 1;
3754
+ const currentPagination = pagination();
3755
+ if (!currentPagination) {
3756
+ if (isDevMode()) {
3757
+ throw pagedQueryNextPageCalledWithoutPreviousPage();
3758
+ }
3759
+ return;
3760
+ }
3761
+ if (page > currentPagination.totalPages) {
3762
+ if (isDevMode()) {
3763
+ throw pagedQueryPageBiggerThanTotalPages(page, currentPagination.totalPages);
3764
+ }
3765
+ return;
3766
+ }
3767
+ currentPageArgs.set(options.args(page));
3768
+ loadedMaxPage.set(page);
3769
+ pageDirection.set('next');
3770
+ };
3771
+ const reset = (resetOptions) => {
3772
+ const page = resetOptions?.initialPage ?? initialPage();
3773
+ initialPage.set(page);
3774
+ pageDirection.set('next');
3775
+ lastResetTimestamp.set(Date.now());
3776
+ };
3777
+ const canFetchPreviousPage = computed(() => loadedMinPage() > 1);
3778
+ const canFetchNextPage = computed(() => {
3779
+ const currentPagination = pagination();
3780
+ return currentPagination ? loadedMaxPage() < currentPagination.totalPages : false;
3781
+ });
3782
+ const items = computed(() => {
3783
+ return stack
3784
+ .response()
3785
+ .map((r) => responseNormalizer(r).items)
3786
+ .flat();
3787
+ });
3788
+ const isFirstLoad = computed(() => {
3789
+ return stack.queries().length === 1 && !!stack.lastQuery()?.loading();
3790
+ });
3791
+ const execute = (options) => {
3792
+ if (options?.where) {
3793
+ const queriesToExecute = [];
3794
+ for (const [index, query] of stack.queries().entries()) {
3795
+ // TODO: Use the where condition here.
3796
+ if (query.response()) {
3797
+ queriesToExecute.push(query);
3798
+ if (index !== 0) {
3799
+ const prevQuery = stack.queries()[index - 1];
3800
+ if (prevQuery) {
3801
+ queriesToExecute.push(prevQuery);
3802
+ }
3803
+ }
3804
+ if (index !== stack.queries().length - 1) {
3805
+ const nextQuery = stack.queries()[index + 1];
3806
+ if (nextQuery) {
3807
+ queriesToExecute.push(nextQuery);
3808
+ }
3809
+ }
3810
+ }
3811
+ }
3812
+ for (const query of queriesToExecute) {
3813
+ query.execute({ options: { skipCache: options.skipCache } });
3814
+ }
3815
+ }
3816
+ else {
3817
+ stack.execute({ skipCache: options?.skipCache });
3818
+ }
3819
+ };
3820
+ const pagedQuery = {
3821
+ pagination,
3822
+ fetchPreviousPage,
3823
+ fetchNextPage,
3824
+ canFetchPreviousPage,
3825
+ canFetchNextPage,
3826
+ items,
3827
+ direction: pageDirection.asReadonly(),
3828
+ loading: stack.loading,
3829
+ error: stack.error,
3830
+ lastQuery: stack.lastQuery,
3831
+ isFirstLoad,
3832
+ queries: stack.queries(),
3833
+ reset,
3834
+ execute,
3835
+ };
3836
+ return pagedQuery;
3837
+ };
3838
+
3453
3839
  const setupQueryDependencies = (options) => {
3454
3840
  const environmentInjector = inject(EnvironmentInjector);
3455
3841
  const queryEnvironmentInjector = createEnvironmentInjector([], environmentInjector);
@@ -3519,9 +3905,9 @@ const createExecuteFn = (executeOptions) => {
3519
3905
  const executeState = setupQueryExecuteState();
3520
3906
  const reset = () => resetExecuteState({ executeState, executeOptions });
3521
3907
  const exec = (executeArgs) => {
3522
- const { args = executeOptions.state.args() } = executeArgs ?? {};
3908
+ const { args = executeOptions.state.args(), options } = executeArgs ?? {};
3523
3909
  cleanupPreviousExecute({ executeOptions, executeState });
3524
- queryExecute({ executeOptions, executeState, args });
3910
+ queryExecute({ executeOptions, executeState, args, options });
3525
3911
  };
3526
3912
  exec['reset'] = reset;
3527
3913
  exec['currentRepositoryKey'] = executeState.previousKey.asReadonly();
@@ -3648,7 +4034,7 @@ const createQueryRepository = (config) => {
3648
4034
  if (cacheEntry) {
3649
4035
  bind(key, options.destroyRef, cacheEntry.request);
3650
4036
  if (runQueryOptions?.skipCache || cacheEntry.request.isStale()) {
3651
- cacheEntry.request.execute();
4037
+ cacheEntry.request.execute({ skipCache: runQueryOptions?.skipCache });
3652
4038
  }
3653
4039
  return { key, request: cacheEntry.request };
3654
4040
  }
@@ -3906,193 +4292,6 @@ const createSecurePatchQuery = (client, authProvider) => {
3906
4292
  return (creatorOptions) => createSecureQueryCreator(creatorOptions, { method: 'PATCH', client, authProvider });
3907
4293
  };
3908
4294
 
3909
- /* eslint-disable @typescript-eslint/no-empty-function */
3910
- const createQueryFeature = (config) => {
3911
- return config;
3912
- };
3913
- const withArgs = (args) => {
3914
- return createQueryFeature({
3915
- type: "withArgs" /* QueryFeatureType.WithArgs */,
3916
- fn: (context) => {
3917
- const currArgs = computed(() => args());
3918
- queryEffect(() => {
3919
- const currArgsNow = currArgs();
3920
- if (currArgsNow === null)
3921
- return;
3922
- untracked(() => {
3923
- if (currArgsNow === QUERY_ARGS_RESET) {
3924
- context.state.args.set(null);
3925
- return;
3926
- }
3927
- context.state.args.set(currArgsNow);
3928
- if (context.flags.shouldAutoExecute)
3929
- context.execute({ args: currArgsNow });
3930
- });
3931
- }, QUERY_EFFECT_ERROR_MESSAGE, { injector: context.deps.injector });
3932
- },
3933
- });
3934
- };
3935
- const withPolling = (options) => {
3936
- return createQueryFeature({
3937
- type: "withPolling" /* QueryFeatureType.WithPolling */,
3938
- fn: (context) => {
3939
- if (!context.flags.shouldAutoExecuteMethod) {
3940
- throw withPollingUsedOnUnsupportedHttpMethod(context.creatorInternals.method);
3941
- }
3942
- let intervalId = null;
3943
- queryEffect(() => {
3944
- const args = context.state.args();
3945
- untracked(() => {
3946
- if (intervalId !== null)
3947
- clearInterval(intervalId);
3948
- if (args === null)
3949
- return;
3950
- if (options.executeInitially) {
3951
- context.execute({ args });
3952
- }
3953
- intervalId = window.setInterval(() => {
3954
- context.execute({ args });
3955
- }, options.interval);
3956
- });
3957
- }, QUERY_EFFECT_ERROR_MESSAGE, { injector: context.deps.injector });
3958
- context.deps.destroyRef.onDestroy(() => intervalId !== null && clearInterval(intervalId));
3959
- },
3960
- });
3961
- };
3962
- const withLogging = (options) => {
3963
- return createQueryFeature({
3964
- type: "withLogging" /* QueryFeatureType.WithLogging */,
3965
- fn: (context) => {
3966
- effect(() => {
3967
- const event = context.state.latestHttpEvent();
3968
- if (event === null)
3969
- return;
3970
- untracked(() => {
3971
- options.logFn(event);
3972
- });
3973
- }, { injector: context.deps.injector });
3974
- },
3975
- });
3976
- };
3977
- const withErrorHandling = (options) => {
3978
- return createQueryFeature({
3979
- type: "withErrorHandling" /* QueryFeatureType.WithErrorHandling */,
3980
- fn: (context) => {
3981
- effect(() => {
3982
- const error = context.state.error();
3983
- if (error === null)
3984
- return;
3985
- untracked(() => {
3986
- options.handler(error);
3987
- });
3988
- }, { injector: context.deps.injector });
3989
- },
3990
- });
3991
- };
3992
- const withSuccessHandling = (options) => {
3993
- return createQueryFeature({
3994
- type: "withSuccessHandling" /* QueryFeatureType.WithSuccessHandling */,
3995
- fn: (context) => {
3996
- effect(() => {
3997
- const response = context.state.response();
3998
- if (response === null)
3999
- return;
4000
- untracked(() => {
4001
- options.handler(response);
4002
- });
4003
- }, { injector: context.deps.injector });
4004
- },
4005
- });
4006
- };
4007
- const withAutoRefresh = (options) => {
4008
- return createQueryFeature({
4009
- type: "withAutoRefresh" /* QueryFeatureType.WithAutoRefresh */,
4010
- fn: (context) => {
4011
- if (!context.flags.shouldAutoExecuteMethod) {
4012
- throw withAutoRefreshUsedOnUnsupportedHttpMethod(context.creatorInternals.method);
4013
- }
4014
- if (context.queryConfig.onlyManualExecution && !options.ignoreOnlyManualExecution) {
4015
- throw withAutoRefreshUsedOnUnsupportedHttpMethod(context.creatorInternals.method);
4016
- }
4017
- queryEffect(() => {
4018
- for (const signal of options.signalChanges) {
4019
- signal();
4020
- }
4021
- untracked(() => {
4022
- const args = context.state.args();
4023
- if (args === null)
4024
- return;
4025
- context.execute({ args });
4026
- });
4027
- }, QUERY_EFFECT_ERROR_MESSAGE, { injector: context.deps.injector });
4028
- },
4029
- });
4030
- };
4031
-
4032
- const transformArrayResponse = (responses) => responses.filter((r) => !!r).flatMap((r) => r);
4033
- const transformPaginatedResponse = (responses) => responses.filter((r) => !!r).flatMap((r) => r.items);
4034
- const createQueryStack = (computation, options) => {
4035
- const { append = false, appendFn = (oldQueries, newQueries) => {
4036
- const queries = [...oldQueries, ...newQueries];
4037
- const lastQuery = newQueries[newQueries.length - 1] ?? oldQueries[oldQueries.length - 1] ?? null;
4038
- return { queries, lastQuery };
4039
- }, transform, } = options ?? {};
4040
- const injector = inject(Injector);
4041
- const queries = signal([]);
4042
- const lastQuery = signal(null);
4043
- effect(() => {
4044
- const newQueryOrQueries = runInInjectionContext(injector, () => computation());
4045
- const newQueries = Array.isArray(newQueryOrQueries) ? newQueryOrQueries : [newQueryOrQueries];
4046
- untracked(() => {
4047
- const oldQueries = queries();
4048
- if (append) {
4049
- const { queries: appendedQueries, lastQuery: lastAppendedQuery } = appendFn(oldQueries, newQueries);
4050
- queries.set(appendedQueries);
4051
- lastQuery.set(lastAppendedQuery);
4052
- }
4053
- else {
4054
- for (const oldQuery of oldQueries) {
4055
- if (!newQueries.some((q) => q.id() === oldQuery.id())) {
4056
- oldQuery.destroy();
4057
- }
4058
- }
4059
- queries.set(newQueries);
4060
- lastQuery.set(newQueries[newQueries.length - 1] ?? null);
4061
- }
4062
- });
4063
- });
4064
- const loading = computed(() => queries().some((q) => q.loading()));
4065
- const error = computed(() => queries()
4066
- .map((q) => q.error())
4067
- .find((e) => e !== null) ?? null);
4068
- const response = computed(() => {
4069
- const responses = queries().map((q) => q.response());
4070
- return transform?.(responses) ?? responses;
4071
- });
4072
- const execute = () => {
4073
- for (const query of queries()) {
4074
- query.execute();
4075
- }
4076
- };
4077
- const clear = () => {
4078
- for (const query of queries()) {
4079
- query.destroy();
4080
- }
4081
- queries.set([]);
4082
- lastQuery.set(null);
4083
- };
4084
- const stack = {
4085
- queries: queries.asReadonly(),
4086
- lastQuery: lastQuery.asReadonly(),
4087
- loading,
4088
- error,
4089
- response,
4090
- execute,
4091
- clear,
4092
- };
4093
- return stack;
4094
- };
4095
-
4096
4295
  var index = /*#__PURE__*/Object.freeze({
4097
4296
  __proto__: null,
4098
4297
  QUERY_ARGS_RESET: QUERY_ARGS_RESET,
@@ -4101,6 +4300,7 @@ var index = /*#__PURE__*/Object.freeze({
4101
4300
  applyQueryFeatures: applyQueryFeatures,
4102
4301
  bearerExpiresInPropertyNotNumber: bearerExpiresInPropertyNotNumber,
4103
4302
  cleanupPreviousExecute: cleanupPreviousExecute,
4303
+ contentfulGqlLikePaginationAdapter: contentfulGqlLikePaginationAdapter,
4104
4304
  cookieLoginTriedButCookieDisabled: cookieLoginTriedButCookieDisabled,
4105
4305
  createBearerAuthProvider: createBearerAuthProvider,
4106
4306
  createBearerAuthProviderConfig: createBearerAuthProviderConfig,
@@ -4108,6 +4308,7 @@ var index = /*#__PURE__*/Object.freeze({
4108
4308
  createExecuteFn: createExecuteFn,
4109
4309
  createGetQuery: createGetQuery,
4110
4310
  createHttpRequest: createHttpRequest,
4311
+ createPagedQuery: createPagedQuery,
4111
4312
  createPatchQuery: createPatchQuery,
4112
4313
  createPostQuery: createPostQuery,
4113
4314
  createPutQuery: createPutQuery,
@@ -4131,12 +4332,18 @@ var index = /*#__PURE__*/Object.freeze({
4131
4332
  defaultResponseTransformerResponseNotContainingRefreshToken: defaultResponseTransformerResponseNotContainingRefreshToken,
4132
4333
  defaultResponseTransformerResponseNotObject: defaultResponseTransformerResponseNotObject,
4133
4334
  disableCookieCalledWithoutCookieConfig: disableCookieCalledWithoutCookieConfig,
4335
+ dynLikePaginationAdapter: dynLikePaginationAdapter,
4134
4336
  enableCookieCalledWithoutCookieConfig: enableCookieCalledWithoutCookieConfig,
4337
+ ethletePaginationAdapter: ethletePaginationAdapter,
4135
4338
  extractExpiresInSeconds: extractExpiresInSeconds,
4136
4339
  getQueryFeatureUsage: getQueryFeatureUsage,
4340
+ ggLikePaginationAdapter: ggLikePaginationAdapter,
4137
4341
  loginCalledWithoutConfig: loginCalledWithoutConfig,
4138
4342
  loginWithTokenCalledWithoutConfig: loginWithTokenCalledWithoutConfig,
4139
4343
  maybeExecute: maybeExecute,
4344
+ pagedQueryNextPageCalledWithoutPreviousPage: pagedQueryNextPageCalledWithoutPreviousPage,
4345
+ pagedQueryPageBiggerThanTotalPages: pagedQueryPageBiggerThanTotalPages,
4346
+ pagedQueryPreviousPageCalledButAlreadyAtFirstPage: pagedQueryPreviousPageCalledButAlreadyAtFirstPage,
4140
4347
  provideBearerAuthProvider: provideBearerAuthProvider,
4141
4348
  provideQueryClient: provideQueryClient,
4142
4349
  queryEffect: queryEffect,