@ethlete/query 5.33.3 → 5.35.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.
- package/CHANGELOG.md +14 -0
- package/fesm2022/ethlete-query.mjs +42 -14
- package/fesm2022/ethlete-query.mjs.map +1 -1
- package/lib/experimental/auth/bearer-auth-provider-config.d.ts +10 -6
- package/lib/experimental/auth/bearer-auth-provider.d.ts +9 -5
- package/lib/experimental/http/paged-query-stack.d.ts +10 -2
- package/lib/experimental/http/query-stack.d.ts +9 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @ethlete/query
|
|
2
2
|
|
|
3
|
+
## 5.35.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`4f65c4c`](https://github.com/ethlete-io/ethdk/commit/4f65c4ceeb2eec9fe1102c19638c21c42525870d) Thanks [@TomTomB](https://github.com/TomTomB)! - Add subtle namespace to query stack
|
|
8
|
+
|
|
9
|
+
- [`895ab11`](https://github.com/ethlete-io/ethdk/commit/895ab11f64425671558c18254694c12b7232fcbd) Thanks [@TomTomB](https://github.com/TomTomB)! - Add isLastPageLoaded and isFirstPageLoaded to paged query stack
|
|
10
|
+
|
|
11
|
+
## 5.34.0
|
|
12
|
+
|
|
13
|
+
### Minor Changes
|
|
14
|
+
|
|
15
|
+
- [`2cf5165`](https://github.com/ethlete-io/ethdk/commit/2cf5165074956da6ce918ac9a7b0585897744651) Thanks [@TomTomB](https://github.com/TomTomB)! - Add bearerDecryptFn to query 3 bearer auth provider config
|
|
16
|
+
|
|
3
17
|
## 5.33.3
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
|
@@ -3002,6 +3002,12 @@ const createBearerAuthProvider = (options) => {
|
|
|
3002
3002
|
const query = latestExecutedQuery();
|
|
3003
3003
|
return query?.query?.tokens()?.tokens ?? null;
|
|
3004
3004
|
});
|
|
3005
|
+
const bearerData = computed(() => {
|
|
3006
|
+
const accessToken = tokens()?.accessToken;
|
|
3007
|
+
if (!accessToken)
|
|
3008
|
+
return null;
|
|
3009
|
+
return (options.bearerDecryptFn?.(accessToken) ?? decryptBearer(accessToken));
|
|
3010
|
+
});
|
|
3005
3011
|
toObservable(computed(() => {
|
|
3006
3012
|
const query = latestExecutedQuery();
|
|
3007
3013
|
const expiresIn = query?.query?.expiresIn() ?? null;
|
|
@@ -3149,6 +3155,7 @@ const createBearerAuthProvider = (options) => {
|
|
|
3149
3155
|
tryLoginWithCookie,
|
|
3150
3156
|
latestExecutedQuery: latestNonInternalQuery.asReadonly(),
|
|
3151
3157
|
tokens,
|
|
3158
|
+
bearerData,
|
|
3152
3159
|
};
|
|
3153
3160
|
if (cookieEnabled()) {
|
|
3154
3161
|
if (!cookieOptions.autoLoginExcludeRoutes.some((r) => route().startsWith(r))) {
|
|
@@ -3178,6 +3185,7 @@ const createBearerAuthProviderConfig = (options) => {
|
|
|
3178
3185
|
selectRole: options.selectRole,
|
|
3179
3186
|
tokenLogin: options.tokenLogin,
|
|
3180
3187
|
tokenRefresh: options.tokenRefresh,
|
|
3188
|
+
bearerDecryptFn: options.bearerDecryptFn,
|
|
3181
3189
|
};
|
|
3182
3190
|
return bearerAuthProviderConfig;
|
|
3183
3191
|
};
|
|
@@ -3889,18 +3897,19 @@ const createQueryStack = (options) => {
|
|
|
3889
3897
|
dependencies?.();
|
|
3890
3898
|
untracked(() => clear());
|
|
3891
3899
|
});
|
|
3892
|
-
effect(() =>
|
|
3893
|
-
|
|
3894
|
-
if (
|
|
3895
|
-
return;
|
|
3896
|
-
const newArgsArray = Array.isArray(
|
|
3900
|
+
effect(() => runWithArgs(args(dependencies?.())));
|
|
3901
|
+
const runWithArgs = (args) => {
|
|
3902
|
+
if (args === null)
|
|
3903
|
+
return null;
|
|
3904
|
+
const newArgsArray = Array.isArray(args) ? args : [args];
|
|
3897
3905
|
const newQueries = runInInjectionContext(injector, () => newArgsArray.map((newArgsEntry) => queryCreator(withArgs(() => newArgsEntry), ...features)));
|
|
3898
|
-
untracked(() => {
|
|
3906
|
+
const result = untracked(() => {
|
|
3899
3907
|
const oldQueries = queries();
|
|
3900
3908
|
if (append) {
|
|
3901
3909
|
const { queries: appendedQueries, lastQuery: lastAppendedQuery } = appendFn(oldQueries, newQueries);
|
|
3902
3910
|
queries.set(appendedQueries);
|
|
3903
3911
|
lastQuery.set(lastAppendedQuery);
|
|
3912
|
+
return lastAppendedQuery;
|
|
3904
3913
|
}
|
|
3905
3914
|
else {
|
|
3906
3915
|
for (const oldQuery of oldQueries) {
|
|
@@ -3909,10 +3918,13 @@ const createQueryStack = (options) => {
|
|
|
3909
3918
|
}
|
|
3910
3919
|
}
|
|
3911
3920
|
queries.set(newQueries);
|
|
3912
|
-
|
|
3921
|
+
const last = newQueries[newQueries.length - 1] ?? null;
|
|
3922
|
+
lastQuery.set(last);
|
|
3923
|
+
return last;
|
|
3913
3924
|
}
|
|
3914
3925
|
});
|
|
3915
|
-
|
|
3926
|
+
return result;
|
|
3927
|
+
};
|
|
3916
3928
|
const loading = computed(() => queries().some((q) => q.loading()));
|
|
3917
3929
|
const error = computed(() => queries()
|
|
3918
3930
|
.map((q) => q.error())
|
|
@@ -3942,6 +3954,9 @@ const createQueryStack = (options) => {
|
|
|
3942
3954
|
response,
|
|
3943
3955
|
execute,
|
|
3944
3956
|
clear,
|
|
3957
|
+
subtle: {
|
|
3958
|
+
runWithArgs,
|
|
3959
|
+
},
|
|
3945
3960
|
};
|
|
3946
3961
|
return stack;
|
|
3947
3962
|
};
|
|
@@ -4010,7 +4025,7 @@ const createPagedQueryStack = (options) => {
|
|
|
4010
4025
|
const lastResetTimestamp = signal(Date.now());
|
|
4011
4026
|
const pageDirection = signal('next');
|
|
4012
4027
|
const stack = createQueryStack({
|
|
4013
|
-
args: () =>
|
|
4028
|
+
args: () => null,
|
|
4014
4029
|
queryCreator,
|
|
4015
4030
|
append: true,
|
|
4016
4031
|
features,
|
|
@@ -4038,6 +4053,7 @@ const createPagedQueryStack = (options) => {
|
|
|
4038
4053
|
currentPageArgs.set(args);
|
|
4039
4054
|
loadedMinPage.set(initialPage());
|
|
4040
4055
|
loadedMaxPage.set(initialPage());
|
|
4056
|
+
stack.subtle.runWithArgs(args);
|
|
4041
4057
|
});
|
|
4042
4058
|
});
|
|
4043
4059
|
const maxPagination = computed(() => {
|
|
@@ -4054,44 +4070,54 @@ const createPagedQueryStack = (options) => {
|
|
|
4054
4070
|
return null;
|
|
4055
4071
|
return responseNormalizer(res, all);
|
|
4056
4072
|
});
|
|
4073
|
+
const isFirstPageLoaded = computed(() => {
|
|
4074
|
+
const min = minPagination();
|
|
4075
|
+
return min ? loadedMinPage() === min.currentPage : false;
|
|
4076
|
+
});
|
|
4077
|
+
const isLastPageLoaded = computed(() => {
|
|
4078
|
+
const max = maxPagination();
|
|
4079
|
+
return max ? loadedMaxPage() === max.totalPages : false;
|
|
4080
|
+
});
|
|
4057
4081
|
const fetchPreviousPage = () => {
|
|
4058
4082
|
const page = loadedMinPage() - 1;
|
|
4059
4083
|
const allResponses = stack.response();
|
|
4060
4084
|
if (!canFetchNewPage(page)) {
|
|
4061
|
-
return;
|
|
4085
|
+
return null;
|
|
4062
4086
|
}
|
|
4063
4087
|
if (page < 1) {
|
|
4064
4088
|
if (isDevMode()) {
|
|
4065
4089
|
throw pagedQueryStackPreviousPageCalledButAlreadyAtFirstPage();
|
|
4066
4090
|
}
|
|
4067
|
-
return;
|
|
4091
|
+
return null;
|
|
4068
4092
|
}
|
|
4069
4093
|
currentPageArgs.set(options.args(page, allResponses));
|
|
4070
4094
|
loadedMinPage.set(page);
|
|
4071
4095
|
pageDirection.set('previous');
|
|
4096
|
+
return stack.subtle.runWithArgs(currentPageArgs());
|
|
4072
4097
|
};
|
|
4073
4098
|
const fetchNextPage = () => {
|
|
4074
4099
|
const page = loadedMaxPage() + 1;
|
|
4075
4100
|
const currentPagination = maxPagination();
|
|
4076
4101
|
const allResponses = stack.response();
|
|
4077
4102
|
if (!canFetchNewPage(page)) {
|
|
4078
|
-
return;
|
|
4103
|
+
return null;
|
|
4079
4104
|
}
|
|
4080
4105
|
if (!currentPagination) {
|
|
4081
4106
|
if (isDevMode()) {
|
|
4082
4107
|
throw pagedQueryStackNextPageCalledWithoutPreviousPage();
|
|
4083
4108
|
}
|
|
4084
|
-
return;
|
|
4109
|
+
return null;
|
|
4085
4110
|
}
|
|
4086
4111
|
if (page > currentPagination.totalPages) {
|
|
4087
4112
|
if (isDevMode()) {
|
|
4088
4113
|
throw pagedQueryStackPageBiggerThanTotalPages(page, currentPagination.totalPages);
|
|
4089
4114
|
}
|
|
4090
|
-
return;
|
|
4115
|
+
return null;
|
|
4091
4116
|
}
|
|
4092
4117
|
currentPageArgs.set(options.args(page, allResponses));
|
|
4093
4118
|
loadedMaxPage.set(page);
|
|
4094
4119
|
pageDirection.set('next');
|
|
4120
|
+
return stack.subtle.runWithArgs(currentPageArgs());
|
|
4095
4121
|
};
|
|
4096
4122
|
const canFetchNewPage = (pageToLoad) => {
|
|
4097
4123
|
const currentMaxPagination = maxPagination();
|
|
@@ -4192,6 +4218,8 @@ const createPagedQueryStack = (options) => {
|
|
|
4192
4218
|
lastQuery: stack.lastQuery,
|
|
4193
4219
|
isFirstLoad,
|
|
4194
4220
|
queries: stack.queries,
|
|
4221
|
+
isLastPageLoaded,
|
|
4222
|
+
isFirstPageLoaded,
|
|
4195
4223
|
reset,
|
|
4196
4224
|
execute,
|
|
4197
4225
|
};
|