@ethlete/query 4.0.0 → 4.1.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/esm2020/lib/directives/query.directive.mjs +10 -1
- package/esm2020/lib/request/request.util.mjs +7 -2
- package/fesm2015/ethlete-query.mjs +33 -20
- package/fesm2015/ethlete-query.mjs.map +1 -1
- package/fesm2020/ethlete-query.mjs +33 -20
- package/fesm2020/ethlete-query.mjs.map +1 -1
- package/lib/directives/query.directive.d.ts +1 -0
- package/package.json +1 -1
|
@@ -49,6 +49,25 @@ const queryStateDoesNotContainKeyError = (data) => new QueryError('005', 'The qu
|
|
|
49
49
|
const queryStateCannotTransformError = (data) => new QueryError('006', 'The query state cannot be transformed because it is not loading', data);
|
|
50
50
|
const invalidBodyError = (data) => new QueryError('007', 'The body is not valid or upsupported', data);
|
|
51
51
|
|
|
52
|
+
const isSymfonyError = (error) => {
|
|
53
|
+
if (!error || typeof error !== 'object') {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
const symfonyError = error;
|
|
57
|
+
return (symfonyError.class !== undefined &&
|
|
58
|
+
symfonyError.detail !== undefined &&
|
|
59
|
+
symfonyError.status !== undefined &&
|
|
60
|
+
symfonyError.title !== undefined &&
|
|
61
|
+
symfonyError.trace !== undefined &&
|
|
62
|
+
symfonyError.type !== undefined);
|
|
63
|
+
};
|
|
64
|
+
const isSymfonyPagerfantaOutOfRangeError = (error) => {
|
|
65
|
+
if (!isSymfonyError(error)) {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
return error.class.startsWith('Pagerfanta') && error.class.endsWith('OutOfRangeCurrentPageException');
|
|
69
|
+
};
|
|
70
|
+
|
|
52
71
|
const isRequestError = (error) => error instanceof Object && 'status' in error && 'statusText' in error && 'url' in error;
|
|
53
72
|
const buildRoute = (options) => {
|
|
54
73
|
if (options.base.endsWith('/')) {
|
|
@@ -279,9 +298,13 @@ const shouldRetryRequest = (config) => {
|
|
|
279
298
|
if (!isRequestError(config.error)) {
|
|
280
299
|
return { retry: false };
|
|
281
300
|
}
|
|
282
|
-
const { status } = config.error;
|
|
301
|
+
const { status, detail } = config.error;
|
|
283
302
|
// Retry on 5xx errors
|
|
284
303
|
if (status >= 500) {
|
|
304
|
+
// Don't retry if a requested page is out of range
|
|
305
|
+
if (isSymfonyPagerfantaOutOfRangeError(detail)) {
|
|
306
|
+
return { retry: false };
|
|
307
|
+
}
|
|
285
308
|
return { retry: true, delay: defaultRetryDelay };
|
|
286
309
|
}
|
|
287
310
|
// Retry on 408 or 425 errors
|
|
@@ -506,25 +529,6 @@ const gql = (strings, ...values) => {
|
|
|
506
529
|
return str;
|
|
507
530
|
};
|
|
508
531
|
|
|
509
|
-
const isSymfonyError = (error) => {
|
|
510
|
-
if (!error || typeof error !== 'object') {
|
|
511
|
-
return false;
|
|
512
|
-
}
|
|
513
|
-
const symfonyError = error;
|
|
514
|
-
return (symfonyError.class !== undefined &&
|
|
515
|
-
symfonyError.detail !== undefined &&
|
|
516
|
-
symfonyError.status !== undefined &&
|
|
517
|
-
symfonyError.title !== undefined &&
|
|
518
|
-
symfonyError.trace !== undefined &&
|
|
519
|
-
symfonyError.type !== undefined);
|
|
520
|
-
};
|
|
521
|
-
const isSymfonyPagerfantaOutOfRangeError = (error) => {
|
|
522
|
-
if (!isSymfonyError(error)) {
|
|
523
|
-
return false;
|
|
524
|
-
}
|
|
525
|
-
return error.class.startsWith('Pagerfanta') && error.class.endsWith('OutOfRangeCurrentPageException');
|
|
526
|
-
};
|
|
527
|
-
|
|
528
532
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
529
533
|
function filterSuccess() {
|
|
530
534
|
return function (source) {
|
|
@@ -1174,6 +1178,7 @@ class QueryDirective {
|
|
|
1174
1178
|
$implicit: null,
|
|
1175
1179
|
etQuery: null,
|
|
1176
1180
|
loading: false,
|
|
1181
|
+
refreshing: false,
|
|
1177
1182
|
error: null,
|
|
1178
1183
|
progress: null,
|
|
1179
1184
|
};
|
|
@@ -1192,6 +1197,12 @@ class QueryDirective {
|
|
|
1192
1197
|
this._subscription?.unsubscribe();
|
|
1193
1198
|
this._subscription = null;
|
|
1194
1199
|
if (!this.query) {
|
|
1200
|
+
this._viewContext.$implicit = null;
|
|
1201
|
+
this._viewContext.etQuery = null;
|
|
1202
|
+
this._viewContext.loading = false;
|
|
1203
|
+
this._viewContext.refreshing = false;
|
|
1204
|
+
this._viewContext.error = null;
|
|
1205
|
+
this._viewContext.progress = null;
|
|
1195
1206
|
return;
|
|
1196
1207
|
}
|
|
1197
1208
|
const query = isQuery(this.query) ? this.query : this.query.query;
|
|
@@ -1202,9 +1213,11 @@ class QueryDirective {
|
|
|
1202
1213
|
if (isQueryStateLoading(state)) {
|
|
1203
1214
|
this._viewContext.loading = true;
|
|
1204
1215
|
this._viewContext.progress = state.progress ?? null;
|
|
1216
|
+
this._viewContext.refreshing = state.meta.triggeredVia === 'auto' || state.meta.triggeredVia === 'poll';
|
|
1205
1217
|
}
|
|
1206
1218
|
else {
|
|
1207
1219
|
this._viewContext.loading = false;
|
|
1220
|
+
this._viewContext.refreshing = false;
|
|
1208
1221
|
this._viewContext.progress = null;
|
|
1209
1222
|
}
|
|
1210
1223
|
if (isQueryStateSuccess(state)) {
|