@ethlete/query 0.1.0-next.1 → 0.1.0-next.10
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/esm2020/lib/auth/bearer-auth-provider.mjs +4 -3
- package/esm2020/lib/directives/infinity-query-trigger.directive.mjs +3 -3
- package/esm2020/lib/directives/infinity-query.directive.mjs +37 -10
- package/esm2020/lib/directives/query.directive.mjs +3 -3
- package/esm2020/lib/infinite-query/infinity-query.types.mjs +1 -1
- package/esm2020/lib/query/query.mjs +6 -2
- package/esm2020/lib/query/query.utils.mjs +17 -2
- package/esm2020/lib/query-form/query-form.mjs +7 -4
- package/esm2020/lib/query-form/query-form.types.mjs +1 -1
- package/esm2020/lib/query-form/query-form.utils.mjs +21 -1
- package/esm2020/lib/request/request.mjs +5 -3
- package/esm2020/lib/request/request.types.mjs +1 -1
- package/esm2020/lib/request/request.util.mjs +24 -6
- package/esm2020/lib/utils/deep-freeze.util.mjs +5 -1
- package/fesm2015/ethlete-query.mjs +126 -29
- package/fesm2015/ethlete-query.mjs.map +1 -1
- package/fesm2020/ethlete-query.mjs +123 -29
- package/fesm2020/ethlete-query.mjs.map +1 -1
- package/lib/directives/infinity-query-trigger.directive.d.ts +1 -1
- package/lib/directives/infinity-query.directive.d.ts +8 -2
- package/lib/directives/query.directive.d.ts +1 -1
- package/lib/infinite-query/infinity-query.types.d.ts +5 -2
- package/lib/query/query.utils.d.ts +8 -3
- package/lib/query-form/query-form.d.ts +1 -1
- package/lib/query-form/query-form.types.d.ts +11 -1
- package/lib/query-form/query-form.utils.d.ts +5 -0
- package/lib/request/request.types.d.ts +2 -0
- package/lib/request/request.util.d.ts +2 -2
- package/lib/utils/deep-freeze.util.d.ts +1 -1
- package/package.json +6 -5
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { __awaiter } from 'tslib';
|
|
2
|
-
import { Subject, timer, filter, takeWhile, BehaviorSubject, interval, takeUntil, tap,
|
|
2
|
+
import { Subject, timer, filter, takeWhile, switchMap, of, BehaviorSubject, interval, takeUntil, tap, fromEvent, startWith, concat, take, debounceTime, combineLatest, map, distinctUntilChanged } from 'rxjs';
|
|
3
3
|
import * as i0 from '@angular/core';
|
|
4
4
|
import { Directive, Input, InjectionToken, inject, ChangeDetectorRef, ViewContainerRef, TemplateRef, ErrorHandler, ElementRef } from '@angular/core';
|
|
5
|
+
import * as i1 from '@ethlete/core';
|
|
6
|
+
import { DestroyDirective } from '@ethlete/core';
|
|
5
7
|
import { FormGroup } from '@angular/forms';
|
|
6
8
|
import { Router, ActivatedRoute } from '@angular/router';
|
|
7
9
|
|
|
@@ -166,13 +168,15 @@ const buildTimestampFromSeconds = (seconds) => {
|
|
|
166
168
|
}
|
|
167
169
|
return new Date(Date.now() + seconds * 1000).getTime();
|
|
168
170
|
};
|
|
169
|
-
const buildRequestError = (error) => __awaiter(void 0, void 0, void 0, function* () {
|
|
171
|
+
const buildRequestError = (error, route, requestInit) => __awaiter(void 0, void 0, void 0, function* () {
|
|
170
172
|
if (error instanceof DOMException && error.code === error.ABORT_ERR) {
|
|
171
173
|
const err = {
|
|
172
174
|
code: -1,
|
|
173
175
|
message: 'Request aborted',
|
|
174
176
|
detail: null,
|
|
175
177
|
raw: error,
|
|
178
|
+
route,
|
|
179
|
+
requestInit,
|
|
176
180
|
};
|
|
177
181
|
return err;
|
|
178
182
|
}
|
|
@@ -182,6 +186,8 @@ const buildRequestError = (error) => __awaiter(void 0, void 0, void 0, function*
|
|
|
182
186
|
message: 'Syntax error',
|
|
183
187
|
detail: null,
|
|
184
188
|
raw: error,
|
|
189
|
+
route,
|
|
190
|
+
requestInit,
|
|
185
191
|
};
|
|
186
192
|
return err;
|
|
187
193
|
}
|
|
@@ -191,23 +197,35 @@ const buildRequestError = (error) => __awaiter(void 0, void 0, void 0, function*
|
|
|
191
197
|
message: `${error.name}: ${error.message}`,
|
|
192
198
|
detail: null,
|
|
193
199
|
raw: error,
|
|
200
|
+
route,
|
|
201
|
+
requestInit,
|
|
194
202
|
};
|
|
195
203
|
return err;
|
|
196
204
|
}
|
|
197
205
|
if (isFetchResponse(error)) {
|
|
198
206
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
199
|
-
let detail;
|
|
207
|
+
let detail = null;
|
|
200
208
|
try {
|
|
201
|
-
detail = yield error.
|
|
209
|
+
detail = yield error.json();
|
|
202
210
|
}
|
|
203
|
-
catch (
|
|
204
|
-
|
|
211
|
+
catch (_a) {
|
|
212
|
+
// noop
|
|
213
|
+
}
|
|
214
|
+
if (!detail) {
|
|
215
|
+
try {
|
|
216
|
+
detail = yield error.text();
|
|
217
|
+
}
|
|
218
|
+
catch (_b) {
|
|
219
|
+
// noop
|
|
220
|
+
}
|
|
205
221
|
}
|
|
206
222
|
const err = {
|
|
207
223
|
code: error.status,
|
|
208
224
|
message: error.statusText,
|
|
209
225
|
detail,
|
|
210
226
|
raw: error,
|
|
227
|
+
route,
|
|
228
|
+
requestInit,
|
|
211
229
|
};
|
|
212
230
|
return err;
|
|
213
231
|
}
|
|
@@ -216,6 +234,8 @@ const buildRequestError = (error) => __awaiter(void 0, void 0, void 0, function*
|
|
|
216
234
|
message: 'Unknown error',
|
|
217
235
|
detail: null,
|
|
218
236
|
raw: error,
|
|
237
|
+
route,
|
|
238
|
+
requestInit,
|
|
219
239
|
};
|
|
220
240
|
return err;
|
|
221
241
|
});
|
|
@@ -257,12 +277,15 @@ const guessContentType = (body) => {
|
|
|
257
277
|
};
|
|
258
278
|
|
|
259
279
|
const request = (options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
280
|
+
var _a, _b;
|
|
260
281
|
try {
|
|
261
282
|
const response = yield fetch(options.route, options.init);
|
|
262
283
|
if (!response.ok) {
|
|
263
284
|
throw response;
|
|
264
285
|
}
|
|
265
|
-
const
|
|
286
|
+
const isJsonResponse = (_a = response.headers.get('Content-Type')) === null || _a === void 0 ? void 0 : _a.includes('application/json');
|
|
287
|
+
const isTextResponse = (_b = response.headers.get('Content-Type')) === null || _b === void 0 ? void 0 : _b.includes('text/plain');
|
|
288
|
+
const data = (isJsonResponse ? yield response.json() : isTextResponse ? yield response.text() : null);
|
|
266
289
|
const expiresInSeconds = options.cacheAdapter
|
|
267
290
|
? options.cacheAdapter(response.headers)
|
|
268
291
|
: extractExpiresInSeconds(response.headers);
|
|
@@ -270,7 +293,7 @@ const request = (options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
270
293
|
return { data, expiresInTimestamp };
|
|
271
294
|
}
|
|
272
295
|
catch (error) {
|
|
273
|
-
throw yield buildRequestError(error);
|
|
296
|
+
throw yield buildRequestError(error, options.route, options.init);
|
|
274
297
|
}
|
|
275
298
|
});
|
|
276
299
|
|
|
@@ -351,11 +374,12 @@ class BearerAuthProvider {
|
|
|
351
374
|
route,
|
|
352
375
|
});
|
|
353
376
|
const body = bodyAdapter ? bodyAdapter(this._refreshToken) : { refreshToken: this._refreshToken };
|
|
377
|
+
const requestInit = { body: buildBody(body), method };
|
|
354
378
|
this.onRefreshInitiation$.next();
|
|
355
379
|
try {
|
|
356
380
|
const result = yield request({
|
|
357
381
|
route: fullRoute,
|
|
358
|
-
init:
|
|
382
|
+
init: requestInit,
|
|
359
383
|
});
|
|
360
384
|
const tokens = responseAdapter ? responseAdapter(result.data) : result.data;
|
|
361
385
|
if (!tokens.token) {
|
|
@@ -370,7 +394,7 @@ class BearerAuthProvider {
|
|
|
370
394
|
}
|
|
371
395
|
catch (error) {
|
|
372
396
|
if (error instanceof Error) {
|
|
373
|
-
this.onRefreshFailure$.next(yield buildRequestError(error));
|
|
397
|
+
this.onRefreshFailure$.next(yield buildRequestError(error, fullRoute, requestInit));
|
|
374
398
|
}
|
|
375
399
|
else {
|
|
376
400
|
this.onRefreshFailure$.next(error);
|
|
@@ -404,6 +428,10 @@ const gql = (strings, ...values) => {
|
|
|
404
428
|
};
|
|
405
429
|
|
|
406
430
|
const deepFreeze = (object) => {
|
|
431
|
+
// check if object is actually an object or frozen
|
|
432
|
+
if (!object || typeof object !== 'object' || Object.isFrozen(object)) {
|
|
433
|
+
return object;
|
|
434
|
+
}
|
|
407
435
|
// Retrieve the property names defined on object
|
|
408
436
|
const propNames = Object.getOwnPropertyNames(object);
|
|
409
437
|
// Freeze properties before freezing self
|
|
@@ -434,11 +462,26 @@ function filterFailure() {
|
|
|
434
462
|
return source.pipe(filter((value) => isQueryStateFailure(value)));
|
|
435
463
|
};
|
|
436
464
|
}
|
|
465
|
+
function filterQueryStates(allowedStates) {
|
|
466
|
+
return function (source) {
|
|
467
|
+
return source.pipe(filter((value) => value && allowedStates.includes(value.type)));
|
|
468
|
+
};
|
|
469
|
+
}
|
|
437
470
|
function takeUntilResponse() {
|
|
438
471
|
return function (source) {
|
|
439
472
|
return source.pipe(takeWhile((value) => isQueryStateLoading(value), true));
|
|
440
473
|
};
|
|
441
474
|
}
|
|
475
|
+
function filterNull() {
|
|
476
|
+
return function (source) {
|
|
477
|
+
return source.pipe(filter((value) => value !== null));
|
|
478
|
+
};
|
|
479
|
+
}
|
|
480
|
+
function switchQueryState() {
|
|
481
|
+
return function (source) {
|
|
482
|
+
return source.pipe(switchMap((value) => { var _a; return (_a = value === null || value === void 0 ? void 0 : value.state$) !== null && _a !== void 0 ? _a : of(null); }));
|
|
483
|
+
};
|
|
484
|
+
}
|
|
442
485
|
const isQueryStateLoading = (state) => (state === null || state === void 0 ? void 0 : state.type) === "LOADING" /* QueryStateType.Loading */;
|
|
443
486
|
const isQueryStateSuccess = (state) => (state === null || state === void 0 ? void 0 : state.type) === "SUCCESS" /* QueryStateType.Success */;
|
|
444
487
|
const isQueryStateFailure = (state) => (state === null || state === void 0 ? void 0 : state.type) === "FAILURE" /* QueryStateType.Failure */;
|
|
@@ -564,7 +607,11 @@ class Query {
|
|
|
564
607
|
const isResponseObject = typeof response === 'object';
|
|
565
608
|
const isGql = isGqlQueryConfig(this._queryConfig);
|
|
566
609
|
let responseData = null;
|
|
567
|
-
if (isGql &&
|
|
610
|
+
if (isGql &&
|
|
611
|
+
isResponseObject &&
|
|
612
|
+
!!response.data &&
|
|
613
|
+
typeof response.data === 'object' &&
|
|
614
|
+
'data' in response.data) {
|
|
568
615
|
responseData = response.data['data'];
|
|
569
616
|
}
|
|
570
617
|
else {
|
|
@@ -706,9 +753,9 @@ class QueryDirective {
|
|
|
706
753
|
}
|
|
707
754
|
}
|
|
708
755
|
}
|
|
709
|
-
QueryDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
710
|
-
QueryDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "
|
|
711
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
756
|
+
QueryDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.2", ngImport: i0, type: QueryDirective, deps: [{ token: i0.TemplateRef }, { token: i0.ViewContainerRef }, { token: i0.ErrorHandler }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
757
|
+
QueryDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.0.2", type: QueryDirective, isStandalone: true, selector: "[query]", inputs: { query: "query", cache: ["queryCache", "cache"] }, ngImport: i0 });
|
|
758
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.2", ngImport: i0, type: QueryDirective, decorators: [{
|
|
712
759
|
type: Directive,
|
|
713
760
|
args: [{
|
|
714
761
|
// eslint-disable-next-line @angular-eslint/directive-selector
|
|
@@ -873,6 +920,7 @@ const skipPaginationPageParamCalculator = ({ page, itemsPerPage }) => itemsPerPa
|
|
|
873
920
|
const INFINITY_QUERY_TOKEN = new InjectionToken('INFINITY_QUERY_TOKEN');
|
|
874
921
|
class InfinityQueryDirective {
|
|
875
922
|
constructor() {
|
|
923
|
+
this._queryConfigChanged$ = new Subject();
|
|
876
924
|
this._viewContext = {
|
|
877
925
|
$implicit: null,
|
|
878
926
|
infinityQuery: null,
|
|
@@ -886,17 +934,19 @@ class InfinityQueryDirective {
|
|
|
886
934
|
itemsPerPage: null,
|
|
887
935
|
};
|
|
888
936
|
this._infinityQueryInstance = null;
|
|
889
|
-
this._destroy$ =
|
|
937
|
+
this._destroy$ = inject(DestroyDirective).destroy$;
|
|
890
938
|
this._cdr = inject(ChangeDetectorRef);
|
|
891
939
|
this._viewContainerRef = inject(ViewContainerRef);
|
|
892
940
|
this._mainTemplateRef = inject((TemplateRef));
|
|
893
941
|
this._errorHandler = inject(ErrorHandler);
|
|
942
|
+
this._data$ = new BehaviorSubject([]);
|
|
894
943
|
this._isMainViewCreated = false;
|
|
895
944
|
}
|
|
896
945
|
get infinityQuery() {
|
|
897
946
|
return this._infinityQuery;
|
|
898
947
|
}
|
|
899
948
|
set infinityQuery(v) {
|
|
949
|
+
this._cleanup();
|
|
900
950
|
this._infinityQuery = v;
|
|
901
951
|
this._infinityQueryInstance = this._setupInfinityQuery(v);
|
|
902
952
|
this._loadNextPage();
|
|
@@ -907,6 +957,12 @@ class InfinityQueryDirective {
|
|
|
907
957
|
get instance() {
|
|
908
958
|
return this._infinityQueryInstance;
|
|
909
959
|
}
|
|
960
|
+
get data$() {
|
|
961
|
+
return this._data$.asObservable();
|
|
962
|
+
}
|
|
963
|
+
get data() {
|
|
964
|
+
return this._data$.getValue();
|
|
965
|
+
}
|
|
910
966
|
static ngTemplateContextGuard(dir, ctx) {
|
|
911
967
|
return true;
|
|
912
968
|
}
|
|
@@ -915,8 +971,6 @@ class InfinityQueryDirective {
|
|
|
915
971
|
}
|
|
916
972
|
ngOnDestroy() {
|
|
917
973
|
var _a;
|
|
918
|
-
this._destroy$.next(true);
|
|
919
|
-
this._destroy$.unsubscribe();
|
|
920
974
|
(_a = this.instance) === null || _a === void 0 ? void 0 : _a._destroy();
|
|
921
975
|
}
|
|
922
976
|
_setupInfinityQuery(config) {
|
|
@@ -955,15 +1009,17 @@ class InfinityQueryDirective {
|
|
|
955
1009
|
this._viewContext.currentPage = null;
|
|
956
1010
|
this._viewContext.itemsPerPage = null;
|
|
957
1011
|
this._viewContext.totalPages = null;
|
|
1012
|
+
this._data$.next([]);
|
|
958
1013
|
}
|
|
959
1014
|
this._cdr.markForCheck();
|
|
960
|
-
}), takeUntil(this._destroy$))
|
|
1015
|
+
}), takeUntil(this._destroy$), takeUntil(this._queryConfigChanged$))
|
|
961
1016
|
.subscribe();
|
|
962
1017
|
instance.data$
|
|
963
1018
|
.pipe(tap((data) => {
|
|
964
1019
|
this._viewContext.infinityQuery = this._viewContext.$implicit = data;
|
|
1020
|
+
this._data$.next(data);
|
|
965
1021
|
this._cdr.markForCheck();
|
|
966
|
-
}), takeUntil(this._destroy$))
|
|
1022
|
+
}), takeUntil(this._destroy$), takeUntil(this._queryConfigChanged$))
|
|
967
1023
|
.subscribe();
|
|
968
1024
|
return instance;
|
|
969
1025
|
}
|
|
@@ -979,16 +1035,33 @@ class InfinityQueryDirective {
|
|
|
979
1035
|
this._viewContainerRef.createEmbeddedView(this._mainTemplateRef, this._viewContext);
|
|
980
1036
|
}
|
|
981
1037
|
}
|
|
1038
|
+
_cleanup() {
|
|
1039
|
+
var _a;
|
|
1040
|
+
this._queryConfigChanged$.next(true);
|
|
1041
|
+
(_a = this.instance) === null || _a === void 0 ? void 0 : _a._destroy();
|
|
1042
|
+
this._viewContext.loading = false;
|
|
1043
|
+
this._viewContext.error = null;
|
|
1044
|
+
this._viewContext.infinityQuery = null;
|
|
1045
|
+
this._viewContext.$implicit = null;
|
|
1046
|
+
this._viewContext.isFirstLoad = false;
|
|
1047
|
+
this._viewContext.canLoadMore = false;
|
|
1048
|
+
this._viewContext.currentPage = null;
|
|
1049
|
+
this._viewContext.itemsPerPage = null;
|
|
1050
|
+
this._viewContext.totalPages = null;
|
|
1051
|
+
this._data$.next([]);
|
|
1052
|
+
}
|
|
982
1053
|
}
|
|
983
|
-
InfinityQueryDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
984
|
-
InfinityQueryDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "
|
|
985
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
1054
|
+
InfinityQueryDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.2", ngImport: i0, type: InfinityQueryDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
1055
|
+
InfinityQueryDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.0.2", type: InfinityQueryDirective, isStandalone: true, selector: "[infinityQuery]", inputs: { infinityQuery: "infinityQuery" }, providers: [{ provide: INFINITY_QUERY_TOKEN, useExisting: InfinityQueryDirective }], exportAs: ["infinityQuery"], hostDirectives: [{ directive: i1.DestroyDirective }], ngImport: i0 });
|
|
1056
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.2", ngImport: i0, type: InfinityQueryDirective, decorators: [{
|
|
986
1057
|
type: Directive,
|
|
987
1058
|
args: [{
|
|
988
1059
|
// eslint-disable-next-line @angular-eslint/directive-selector
|
|
989
1060
|
selector: '[infinityQuery]',
|
|
1061
|
+
exportAs: 'infinityQuery',
|
|
990
1062
|
standalone: true,
|
|
991
1063
|
providers: [{ provide: INFINITY_QUERY_TOKEN, useExisting: InfinityQueryDirective }],
|
|
1064
|
+
hostDirectives: [DestroyDirective],
|
|
992
1065
|
}]
|
|
993
1066
|
}], propDecorators: { infinityQuery: [{
|
|
994
1067
|
type: Input
|
|
@@ -1032,9 +1105,9 @@ class InfinityQueryTriggerDirective {
|
|
|
1032
1105
|
this._observer.observe(this._elementRef.nativeElement);
|
|
1033
1106
|
}
|
|
1034
1107
|
}
|
|
1035
|
-
InfinityQueryTriggerDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
1036
|
-
InfinityQueryTriggerDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "
|
|
1037
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
1108
|
+
InfinityQueryTriggerDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.2", ngImport: i0, type: InfinityQueryTriggerDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
1109
|
+
InfinityQueryTriggerDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.0.2", type: InfinityQueryTriggerDirective, isStandalone: true, selector: "[infinityQueryTrigger], infinity-query-trigger", inputs: { scrollContainerSelector: "scrollContainerSelector" }, ngImport: i0 });
|
|
1110
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.2", ngImport: i0, type: InfinityQueryTriggerDirective, decorators: [{
|
|
1038
1111
|
type: Directive,
|
|
1039
1112
|
args: [{
|
|
1040
1113
|
// eslint-disable-next-line @angular-eslint/directive-selector
|
|
@@ -1248,10 +1321,11 @@ class QueryForm {
|
|
|
1248
1321
|
const queryParams = this._activatedRoute.snapshot.queryParams;
|
|
1249
1322
|
for (const [key, field] of Object.entries(this._fields)) {
|
|
1250
1323
|
const value = queryParams[key];
|
|
1251
|
-
|
|
1324
|
+
// We only check using == because the value types can be different (e.g. "1" and 1)
|
|
1325
|
+
if (value === undefined || value == field.control.value) {
|
|
1252
1326
|
continue;
|
|
1253
1327
|
}
|
|
1254
|
-
const deserializedValue = (_c = (_b = (_a = field.data).
|
|
1328
|
+
const deserializedValue = (_c = (_b = (_a = field.data).queryParamToValueTransformFn) === null || _b === void 0 ? void 0 : _b.call(_a, value)) !== null && _c !== void 0 ? _c : value;
|
|
1255
1329
|
field.setValue(deserializedValue);
|
|
1256
1330
|
}
|
|
1257
1331
|
}
|
|
@@ -1293,6 +1367,7 @@ class QueryForm {
|
|
|
1293
1367
|
return defaultValues;
|
|
1294
1368
|
}
|
|
1295
1369
|
_syncViaUrlQueryParams(values) {
|
|
1370
|
+
var _a, _b;
|
|
1296
1371
|
if (!this._router || !this._activatedRoute) {
|
|
1297
1372
|
return;
|
|
1298
1373
|
}
|
|
@@ -1302,7 +1377,9 @@ class QueryForm {
|
|
|
1302
1377
|
delete queryParams[key];
|
|
1303
1378
|
}
|
|
1304
1379
|
else {
|
|
1305
|
-
queryParams[key] =
|
|
1380
|
+
queryParams[key] = this._fields[key].data.valueToQueryParamTransformFn
|
|
1381
|
+
? (_b = (_a = this._fields[key].data).valueToQueryParamTransformFn) === null || _b === void 0 ? void 0 : _b.call(_a, value)
|
|
1382
|
+
: value;
|
|
1306
1383
|
}
|
|
1307
1384
|
}
|
|
1308
1385
|
this._router.navigate([], {
|
|
@@ -1384,10 +1461,30 @@ const transformToDateArray = (value) => {
|
|
|
1384
1461
|
}
|
|
1385
1462
|
return null;
|
|
1386
1463
|
};
|
|
1464
|
+
const transformToSort = (value) => {
|
|
1465
|
+
if (typeof value === 'string') {
|
|
1466
|
+
const [active, direction] = value.split(':');
|
|
1467
|
+
return {
|
|
1468
|
+
active,
|
|
1469
|
+
direction: direction,
|
|
1470
|
+
};
|
|
1471
|
+
}
|
|
1472
|
+
return null;
|
|
1473
|
+
};
|
|
1474
|
+
const transformToSortQueryParam = (value) => {
|
|
1475
|
+
if (typeof value === 'string') {
|
|
1476
|
+
return value;
|
|
1477
|
+
}
|
|
1478
|
+
if (value && typeof value === 'object' && 'active' in value && 'direction' in value) {
|
|
1479
|
+
const valAsSort = value;
|
|
1480
|
+
return valAsSort.direction ? `${valAsSort.active}:${valAsSort.direction}` : null;
|
|
1481
|
+
}
|
|
1482
|
+
return null;
|
|
1483
|
+
};
|
|
1387
1484
|
|
|
1388
1485
|
/**
|
|
1389
1486
|
* Generated bundle index. Do not edit.
|
|
1390
1487
|
*/
|
|
1391
1488
|
|
|
1392
|
-
export { BasicAuthProvider, BearerAuthProvider, CustomHeaderAuthProvider, INFINITY_QUERY_TOKEN, InfinityQuery, InfinityQueryDirective, InfinityQueryTriggerDirective, Query, QueryClient, QueryDirective, QueryError, QueryField, QueryForm, QueryStore, buildBody, buildErrorMessage, buildGqlCacheKey, buildQueryArrayString, buildQueryString, buildRequestError, buildRoute, buildTimestampFromSeconds, createInfinityQueryConfig, decryptBearer, deepFreeze, def, extractExpiresInSeconds, filterFailure, filterInvalidParams, filterSuccess, gql, guessContentType, invalidBaseRouteError, invalidBodyError, invalidRouteError, isAbortRequestError, isBasicAuthProvider, isBearerAuthProvider, isCustomHeaderAuthProvider, isFetchResponse, isGqlQueryConfig, isParamValid, isQueryStateCancelled, isQueryStateFailure, isQueryStateLoading, isQueryStatePrepared, isQueryStateSuccess, isRequestError, mergeHeaders, pathParamsMissingInRouteFunctionError, queryStateAlreadyHasKeyError, queryStateCannotTransformError, queryStateDoesNotContainKeyError, request, shouldCacheQuery, skipPaginationPageParamCalculator, takeUntilResponse, transformGql, transformMethod, transformToBoolean, transformToBooleanArray, transformToDate, transformToDateArray, transformToNumber, transformToNumberArray, transformToString, transformToStringArray };
|
|
1489
|
+
export { BasicAuthProvider, BearerAuthProvider, CustomHeaderAuthProvider, INFINITY_QUERY_TOKEN, InfinityQuery, InfinityQueryDirective, InfinityQueryTriggerDirective, Query, QueryClient, QueryDirective, QueryError, QueryField, QueryForm, QueryStore, buildBody, buildErrorMessage, buildGqlCacheKey, buildQueryArrayString, buildQueryString, buildRequestError, buildRoute, buildTimestampFromSeconds, createInfinityQueryConfig, decryptBearer, deepFreeze, def, extractExpiresInSeconds, filterFailure, filterInvalidParams, filterNull, filterQueryStates, filterSuccess, gql, guessContentType, invalidBaseRouteError, invalidBodyError, invalidRouteError, isAbortRequestError, isBasicAuthProvider, isBearerAuthProvider, isCustomHeaderAuthProvider, isFetchResponse, isGqlQueryConfig, isParamValid, isQueryStateCancelled, isQueryStateFailure, isQueryStateLoading, isQueryStatePrepared, isQueryStateSuccess, isRequestError, mergeHeaders, pathParamsMissingInRouteFunctionError, queryStateAlreadyHasKeyError, queryStateCannotTransformError, queryStateDoesNotContainKeyError, request, shouldCacheQuery, skipPaginationPageParamCalculator, switchQueryState, takeUntilResponse, transformGql, transformMethod, transformToBoolean, transformToBooleanArray, transformToDate, transformToDateArray, transformToNumber, transformToNumberArray, transformToSort, transformToSortQueryParam, transformToString, transformToStringArray };
|
|
1393
1490
|
//# sourceMappingURL=ethlete-query.mjs.map
|