quetch 0.11.0 → 0.11.2

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/dist/main.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export type * from "./types.js";
2
2
  export * from "./tools.js";
3
3
  export * from "./middlewares.js";
4
+ export * from "./errors.js";
package/dist/main.js CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from "./tools.js";
2
2
  export * from "./middlewares.js";
3
+ export * from "./errors.js";
3
4
  //# sourceMappingURL=main.js.map
package/dist/main.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"main.js","sourceRoot":"","sources":["../lib/main.ts"],"names":[],"mappings":"AAEA,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC"}
1
+ {"version":3,"file":"main.js","sourceRoot":"","sources":["../lib/main.ts"],"names":[],"mappings":"AAEA,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC"}
@@ -11,12 +11,9 @@ export function fetchExternal(fetch = getGlobal().fetch) {
11
11
  console.error("Could not find a global `fetch` function");
12
12
  }
13
13
  return async (request, _) => {
14
+ let response;
14
15
  try {
15
- const response = await fetch(request);
16
- if (!response.ok) {
17
- throw new RequestError(response.statusText, response.status, undefined, request, response);
18
- }
19
- return response;
16
+ response = await fetch(request);
20
17
  }
21
18
  catch (error) {
22
19
  if (error instanceof Error) {
@@ -24,6 +21,10 @@ export function fetchExternal(fetch = getGlobal().fetch) {
24
21
  }
25
22
  throw new RequestError(String(error), 500, undefined, request);
26
23
  }
24
+ if (!response.ok) {
25
+ throw new RequestError(response.statusText, response.status, undefined, request, response);
26
+ }
27
+ return response;
27
28
  };
28
29
  }
29
30
  //# sourceMappingURL=fetchExternal.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"fetchExternal.js","sourceRoot":"","sources":["../../lib/middlewares/fetchExternal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEpD,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAGzD;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAC3B,KAAK,GAAG,SAAS,EAAE,CAAC,KAAK;IAEzB,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,IAAI,CAAC,KAAK,EAAE,CAAC;QACpD,OAAO,CAAC,KAAK,CAAC,0CAA0C,CAAC,CAAC;IAC5D,CAAC;IACD,OAAO,KAAK,EAAE,OAAO,EAAE,CAAC,EAAE,EAAE;QAC1B,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,OAAO,CAAC,CAAC;YACtC,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;gBACjB,MAAM,IAAI,YAAY,CACpB,QAAQ,CAAC,UAAU,EACnB,QAAQ,CAAC,MAAM,EACf,SAAS,EACT,OAAO,EACP,QAAQ,CACT,CAAC;YACJ,CAAC;YACD,OAAO,QAAQ,CAAC;QAClB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;gBAC3B,MAAM,IAAI,YAAY,CAAC,KAAK,CAAC,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;YACjE,CAAC;YACD,MAAM,IAAI,YAAY,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;QACjE,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"fetchExternal.js","sourceRoot":"","sources":["../../lib/middlewares/fetchExternal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEpD,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAGzD;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAC3B,KAAK,GAAG,SAAS,EAAE,CAAC,KAAK;IAEzB,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,IAAI,CAAC,KAAK,EAAE,CAAC;QACpD,OAAO,CAAC,KAAK,CAAC,0CAA0C,CAAC,CAAC;IAC5D,CAAC;IACD,OAAO,KAAK,EAAE,OAAO,EAAE,CAAC,EAAE,EAAE;QAC1B,IAAI,QAAQ,CAAC;QACb,IAAI,CAAC;YACH,QAAQ,GAAG,MAAM,KAAK,CAAC,OAAO,CAAC,CAAC;QAClC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;gBAC3B,MAAM,IAAI,YAAY,CAAC,KAAK,CAAC,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;YACjE,CAAC;YACD,MAAM,IAAI,YAAY,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;QACjE,CAAC;QACD,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACjB,MAAM,IAAI,YAAY,CACpB,QAAQ,CAAC,UAAU,EACnB,QAAQ,CAAC,MAAM,EACf,SAAS,EACT,OAAO,EACP,QAAQ,CACT,CAAC;QACJ,CAAC;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC,CAAC;AACJ,CAAC"}
package/doc/README.md CHANGED
@@ -4,6 +4,10 @@ quetch
4
4
 
5
5
  ## Table of contents
6
6
 
7
+ ### Classes
8
+
9
+ - [RequestError](classes/RequestError.md)
10
+
7
11
  ### Interfaces
8
12
 
9
13
  - [CustomFetch](interfaces/CustomFetch.md)
@@ -99,7 +103,7 @@ Aggregation function.
99
103
 
100
104
  #### Defined in
101
105
 
102
- [lib/types/AggregateFunction.ts:4](https://github.com/nevoland/quetch/blob/72f665b/lib/types/AggregateFunction.ts#L4)
106
+ [lib/types/AggregateFunction.ts:4](https://github.com/nevoland/quetch/blob/6055b33/lib/types/AggregateFunction.ts#L4)
103
107
 
104
108
  ___
105
109
 
@@ -109,7 +113,7 @@ ___
109
113
 
110
114
  #### Defined in
111
115
 
112
- [lib/types/AggregateFunctionOperator.ts:3](https://github.com/nevoland/quetch/blob/72f665b/lib/types/AggregateFunctionOperator.ts#L3)
116
+ [lib/types/AggregateFunctionOperator.ts:3](https://github.com/nevoland/quetch/blob/6055b33/lib/types/AggregateFunctionOperator.ts#L3)
113
117
 
114
118
  ___
115
119
 
@@ -119,7 +123,7 @@ ___
119
123
 
120
124
  #### Defined in
121
125
 
122
- [lib/types/Any.ts:1](https://github.com/nevoland/quetch/blob/72f665b/lib/types/Any.ts#L1)
126
+ [lib/types/Any.ts:1](https://github.com/nevoland/quetch/blob/6055b33/lib/types/Any.ts#L1)
123
127
 
124
128
  ___
125
129
 
@@ -135,7 +139,7 @@ ___
135
139
 
136
140
  #### Defined in
137
141
 
138
- [lib/types/Context.ts:1](https://github.com/nevoland/quetch/blob/72f665b/lib/types/Context.ts#L1)
142
+ [lib/types/Context.ts:1](https://github.com/nevoland/quetch/blob/6055b33/lib/types/Context.ts#L1)
139
143
 
140
144
  ___
141
145
 
@@ -151,7 +155,7 @@ ___
151
155
 
152
156
  #### Defined in
153
157
 
154
- [lib/types/CustomFieldAggregateMap.ts:3](https://github.com/nevoland/quetch/blob/72f665b/lib/types/CustomFieldAggregateMap.ts#L3)
158
+ [lib/types/CustomFieldAggregateMap.ts:3](https://github.com/nevoland/quetch/blob/6055b33/lib/types/CustomFieldAggregateMap.ts#L3)
155
159
 
156
160
  ___
157
161
 
@@ -167,7 +171,7 @@ ___
167
171
 
168
172
  #### Defined in
169
173
 
170
- [lib/types/CustomFieldMap.ts:3](https://github.com/nevoland/quetch/blob/72f665b/lib/types/CustomFieldMap.ts#L3)
174
+ [lib/types/CustomFieldMap.ts:3](https://github.com/nevoland/quetch/blob/6055b33/lib/types/CustomFieldMap.ts#L3)
171
175
 
172
176
  ___
173
177
 
@@ -183,7 +187,7 @@ ___
183
187
 
184
188
  #### Defined in
185
189
 
186
- [lib/types/FieldFunction.ts:4](https://github.com/nevoland/quetch/blob/72f665b/lib/types/FieldFunction.ts#L4)
190
+ [lib/types/FieldFunction.ts:4](https://github.com/nevoland/quetch/blob/6055b33/lib/types/FieldFunction.ts#L4)
187
191
 
188
192
  ___
189
193
 
@@ -208,7 +212,7 @@ Applies a custom field transform function.
208
212
 
209
213
  #### Defined in
210
214
 
211
- [lib/types/FieldFunctionCustom.ts:4](https://github.com/nevoland/quetch/blob/72f665b/lib/types/FieldFunctionCustom.ts#L4)
215
+ [lib/types/FieldFunctionCustom.ts:4](https://github.com/nevoland/quetch/blob/6055b33/lib/types/FieldFunctionCustom.ts#L4)
212
216
 
213
217
  ___
214
218
 
@@ -234,7 +238,7 @@ Formats the date found in a given field, which can be an ISO string date or a ti
234
238
 
235
239
  #### Defined in
236
240
 
237
- [lib/types/FieldFunctionFormatDate.ts:6](https://github.com/nevoland/quetch/blob/72f665b/lib/types/FieldFunctionFormatDate.ts#L6)
241
+ [lib/types/FieldFunctionFormatDate.ts:6](https://github.com/nevoland/quetch/blob/6055b33/lib/types/FieldFunctionFormatDate.ts#L6)
238
242
 
239
243
  ___
240
244
 
@@ -252,7 +256,7 @@ Return types of custom field functions.
252
256
 
253
257
  #### Defined in
254
258
 
255
- [lib/types/FieldFunctionReturn.ts:4](https://github.com/nevoland/quetch/blob/72f665b/lib/types/FieldFunctionReturn.ts#L4)
259
+ [lib/types/FieldFunctionReturn.ts:4](https://github.com/nevoland/quetch/blob/6055b33/lib/types/FieldFunctionReturn.ts#L4)
256
260
 
257
261
  ___
258
262
 
@@ -270,7 +274,7 @@ Describes a predicate for filtering items.
270
274
 
271
275
  #### Defined in
272
276
 
273
- [lib/types/Filter.ts:15](https://github.com/nevoland/quetch/blob/72f665b/lib/types/Filter.ts#L15)
277
+ [lib/types/Filter.ts:15](https://github.com/nevoland/quetch/blob/6055b33/lib/types/Filter.ts#L15)
274
278
 
275
279
  ___
276
280
 
@@ -297,7 +301,7 @@ Checks if a given array field matches a given array value according to a given o
297
301
 
298
302
  #### Defined in
299
303
 
300
- [lib/types/FilterArray.ts:7](https://github.com/nevoland/quetch/blob/72f665b/lib/types/FilterArray.ts#L7)
304
+ [lib/types/FilterArray.ts:7](https://github.com/nevoland/quetch/blob/6055b33/lib/types/FilterArray.ts#L7)
301
305
 
302
306
  ___
303
307
 
@@ -323,7 +327,7 @@ Checks if a given boolean field is `true` or `false`.
323
327
 
324
328
  #### Defined in
325
329
 
326
- [lib/types/FilterBoolean.ts:6](https://github.com/nevoland/quetch/blob/72f665b/lib/types/FilterBoolean.ts#L6)
330
+ [lib/types/FilterBoolean.ts:6](https://github.com/nevoland/quetch/blob/6055b33/lib/types/FilterBoolean.ts#L6)
327
331
 
328
332
  ___
329
333
 
@@ -351,7 +355,7 @@ If `deep` is `true`, also captures all the descendants.
351
355
 
352
356
  #### Defined in
353
357
 
354
- [lib/types/FilterChildren.ts:10](https://github.com/nevoland/quetch/blob/72f665b/lib/types/FilterChildren.ts#L10)
358
+ [lib/types/FilterChildren.ts:10](https://github.com/nevoland/quetch/blob/6055b33/lib/types/FilterChildren.ts#L10)
355
359
 
356
360
  ___
357
361
 
@@ -376,7 +380,7 @@ Custom filter where `value(item)` returns `true` for matching items.
376
380
 
377
381
  #### Defined in
378
382
 
379
- [lib/types/FilterCustom.ts:4](https://github.com/nevoland/quetch/blob/72f665b/lib/types/FilterCustom.ts#L4)
383
+ [lib/types/FilterCustom.ts:4](https://github.com/nevoland/quetch/blob/6055b33/lib/types/FilterCustom.ts#L4)
380
384
 
381
385
  ___
382
386
 
@@ -401,7 +405,7 @@ Checks if a given field exists.
401
405
 
402
406
  #### Defined in
403
407
 
404
- [lib/types/FilterField.ts:4](https://github.com/nevoland/quetch/blob/72f665b/lib/types/FilterField.ts#L4)
408
+ [lib/types/FilterField.ts:4](https://github.com/nevoland/quetch/blob/6055b33/lib/types/FilterField.ts#L4)
405
409
 
406
410
  ___
407
411
 
@@ -419,7 +423,7 @@ Joins a list of filters with a specific boolean operator.
419
423
 
420
424
  #### Defined in
421
425
 
422
- [lib/types/FilterGroup.ts:6](https://github.com/nevoland/quetch/blob/72f665b/lib/types/FilterGroup.ts#L6)
426
+ [lib/types/FilterGroup.ts:6](https://github.com/nevoland/quetch/blob/6055b33/lib/types/FilterGroup.ts#L6)
423
427
 
424
428
  ___
425
429
 
@@ -438,7 +442,7 @@ Returns object type with field extending the provided `P` type.
438
442
 
439
443
  #### Defined in
440
444
 
441
- [lib/types/FilterKeys.ts:4](https://github.com/nevoland/quetch/blob/72f665b/lib/types/FilterKeys.ts#L4)
445
+ [lib/types/FilterKeys.ts:4](https://github.com/nevoland/quetch/blob/6055b33/lib/types/FilterKeys.ts#L4)
442
446
 
443
447
  ___
444
448
 
@@ -464,7 +468,7 @@ Checks if a given number field matches a given number value according to a given
464
468
 
465
469
  #### Defined in
466
470
 
467
- [lib/types/FilterNumber.ts:6](https://github.com/nevoland/quetch/blob/72f665b/lib/types/FilterNumber.ts#L6)
471
+ [lib/types/FilterNumber.ts:6](https://github.com/nevoland/quetch/blob/6055b33/lib/types/FilterNumber.ts#L6)
468
472
 
469
473
  ___
470
474
 
@@ -474,7 +478,7 @@ ___
474
478
 
475
479
  #### Defined in
476
480
 
477
- [lib/types/FilterOperator.ts:3](https://github.com/nevoland/quetch/blob/72f665b/lib/types/FilterOperator.ts#L3)
481
+ [lib/types/FilterOperator.ts:3](https://github.com/nevoland/quetch/blob/6055b33/lib/types/FilterOperator.ts#L3)
478
482
 
479
483
  ___
480
484
 
@@ -500,7 +504,7 @@ Checks if a given string field matches a given string value according to a given
500
504
 
501
505
  #### Defined in
502
506
 
503
- [lib/types/FilterString.ts:6](https://github.com/nevoland/quetch/blob/72f665b/lib/types/FilterString.ts#L6)
507
+ [lib/types/FilterString.ts:6](https://github.com/nevoland/quetch/blob/6055b33/lib/types/FilterString.ts#L6)
504
508
 
505
509
  ___
506
510
 
@@ -526,7 +530,7 @@ Checks if a given string field has any of the provided values.
526
530
 
527
531
  #### Defined in
528
532
 
529
- [lib/types/FilterStringIntersect.ts:6](https://github.com/nevoland/quetch/blob/72f665b/lib/types/FilterStringIntersect.ts#L6)
533
+ [lib/types/FilterStringIntersect.ts:6](https://github.com/nevoland/quetch/blob/6055b33/lib/types/FilterStringIntersect.ts#L6)
530
534
 
531
535
  ___
532
536
 
@@ -556,7 +560,7 @@ Checks if a given string field matches a given regular expression.
556
560
 
557
561
  #### Defined in
558
562
 
559
- [lib/types/FilterStringMatch.ts:8](https://github.com/nevoland/quetch/blob/72f665b/lib/types/FilterStringMatch.ts#L8)
563
+ [lib/types/FilterStringMatch.ts:8](https://github.com/nevoland/quetch/blob/6055b33/lib/types/FilterStringMatch.ts#L8)
560
564
 
561
565
  ___
562
566
 
@@ -576,7 +580,7 @@ Returns the type of the property at the specified `K` key.
576
580
 
577
581
  #### Defined in
578
582
 
579
- [lib/types/Get.ts:4](https://github.com/nevoland/quetch/blob/72f665b/lib/types/Get.ts#L4)
583
+ [lib/types/Get.ts:4](https://github.com/nevoland/quetch/blob/6055b33/lib/types/Get.ts#L4)
580
584
 
581
585
  ___
582
586
 
@@ -594,7 +598,7 @@ Specifies how items should be grouped.
594
598
 
595
599
  #### Defined in
596
600
 
597
- [lib/types/Group.ts:4](https://github.com/nevoland/quetch/blob/72f665b/lib/types/Group.ts#L4)
601
+ [lib/types/Group.ts:4](https://github.com/nevoland/quetch/blob/6055b33/lib/types/Group.ts#L4)
598
602
 
599
603
  ___
600
604
 
@@ -630,7 +634,7 @@ Handles an `input` query and returns an `output` promise, eventually using the `
630
634
 
631
635
  #### Defined in
632
636
 
633
- [lib/types/Handler.ts:6](https://github.com/nevoland/quetch/blob/72f665b/lib/types/Handler.ts#L6)
637
+ [lib/types/Handler.ts:6](https://github.com/nevoland/quetch/blob/6055b33/lib/types/Handler.ts#L6)
634
638
 
635
639
  ___
636
640
 
@@ -646,7 +650,7 @@ ___
646
650
 
647
651
  #### Defined in
648
652
 
649
- [lib/types/Immutable.ts:1](https://github.com/nevoland/quetch/blob/72f665b/lib/types/Immutable.ts#L1)
653
+ [lib/types/Immutable.ts:1](https://github.com/nevoland/quetch/blob/6055b33/lib/types/Immutable.ts#L1)
650
654
 
651
655
  ___
652
656
 
@@ -665,7 +669,7 @@ Injects the custom fields into the entity type.
665
669
 
666
670
  #### Defined in
667
671
 
668
- [lib/types/InjectCustomFields.ts:8](https://github.com/nevoland/quetch/blob/72f665b/lib/types/InjectCustomFields.ts#L8)
672
+ [lib/types/InjectCustomFields.ts:8](https://github.com/nevoland/quetch/blob/6055b33/lib/types/InjectCustomFields.ts#L8)
669
673
 
670
674
  ___
671
675
 
@@ -684,7 +688,7 @@ Returns the inferred item type of an array, or an alternative type if it is some
684
688
 
685
689
  #### Defined in
686
690
 
687
- [lib/types/Item.ts:4](https://github.com/nevoland/quetch/blob/72f665b/lib/types/Item.ts#L4)
691
+ [lib/types/Item.ts:4](https://github.com/nevoland/quetch/blob/6055b33/lib/types/Item.ts#L4)
688
692
 
689
693
  ___
690
694
 
@@ -694,7 +698,7 @@ ___
694
698
 
695
699
  #### Defined in
696
700
 
697
- [lib/types/Key.ts:1](https://github.com/nevoland/quetch/blob/72f665b/lib/types/Key.ts#L1)
701
+ [lib/types/Key.ts:1](https://github.com/nevoland/quetch/blob/6055b33/lib/types/Key.ts#L1)
698
702
 
699
703
  ___
700
704
 
@@ -710,7 +714,7 @@ ___
710
714
 
711
715
  #### Defined in
712
716
 
713
- [lib/types/Mutable.ts:1](https://github.com/nevoland/quetch/blob/72f665b/lib/types/Mutable.ts#L1)
717
+ [lib/types/Mutable.ts:1](https://github.com/nevoland/quetch/blob/6055b33/lib/types/Mutable.ts#L1)
714
718
 
715
719
  ___
716
720
 
@@ -743,7 +747,7 @@ Handles an `input` query and returns an `output` promise.
743
747
 
744
748
  #### Defined in
745
749
 
746
- [lib/types/NextHandler.ts:4](https://github.com/nevoland/quetch/blob/72f665b/lib/types/NextHandler.ts#L4)
750
+ [lib/types/NextHandler.ts:4](https://github.com/nevoland/quetch/blob/6055b33/lib/types/NextHandler.ts#L4)
747
751
 
748
752
  ___
749
753
 
@@ -761,7 +765,7 @@ Order item.
761
765
 
762
766
  #### Defined in
763
767
 
764
- [lib/types/Order.ts:4](https://github.com/nevoland/quetch/blob/72f665b/lib/types/Order.ts#L4)
768
+ [lib/types/Order.ts:4](https://github.com/nevoland/quetch/blob/6055b33/lib/types/Order.ts#L4)
765
769
 
766
770
  ___
767
771
 
@@ -771,7 +775,7 @@ ___
771
775
 
772
776
  #### Defined in
773
777
 
774
- [lib/types/Parameters.ts:1](https://github.com/nevoland/quetch/blob/72f665b/lib/types/Parameters.ts#L1)
778
+ [lib/types/Parameters.ts:1](https://github.com/nevoland/quetch/blob/6055b33/lib/types/Parameters.ts#L1)
775
779
 
776
780
  ___
777
781
 
@@ -789,7 +793,7 @@ Query that fetches or mutates an entity.
789
793
 
790
794
  #### Defined in
791
795
 
792
- [lib/types/Query.ts:14](https://github.com/nevoland/quetch/blob/72f665b/lib/types/Query.ts#L14)
796
+ [lib/types/Query.ts:14](https://github.com/nevoland/quetch/blob/6055b33/lib/types/Query.ts#L14)
793
797
 
794
798
  ___
795
799
 
@@ -818,7 +822,7 @@ Query for computing an aggregated value.
818
822
 
819
823
  #### Defined in
820
824
 
821
- [lib/types/QueryAggregate.ts:10](https://github.com/nevoland/quetch/blob/72f665b/lib/types/QueryAggregate.ts#L10)
825
+ [lib/types/QueryAggregate.ts:10](https://github.com/nevoland/quetch/blob/6055b33/lib/types/QueryAggregate.ts#L10)
822
826
 
823
827
  ___
824
828
 
@@ -847,7 +851,7 @@ Query for creating an item.
847
851
 
848
852
  #### Defined in
849
853
 
850
- [lib/types/QueryCreate.ts:8](https://github.com/nevoland/quetch/blob/72f665b/lib/types/QueryCreate.ts#L8)
854
+ [lib/types/QueryCreate.ts:8](https://github.com/nevoland/quetch/blob/6055b33/lib/types/QueryCreate.ts#L8)
851
855
 
852
856
  ___
853
857
 
@@ -876,7 +880,7 @@ Query for creating multiple items.
876
880
 
877
881
  #### Defined in
878
882
 
879
- [lib/types/QueryCreateMultiple.ts:8](https://github.com/nevoland/quetch/blob/72f665b/lib/types/QueryCreateMultiple.ts#L8)
883
+ [lib/types/QueryCreateMultiple.ts:8](https://github.com/nevoland/quetch/blob/6055b33/lib/types/QueryCreateMultiple.ts#L8)
880
884
 
881
885
  ___
882
886
 
@@ -905,7 +909,7 @@ Query for deleting an item.
905
909
 
906
910
  #### Defined in
907
911
 
908
- [lib/types/QueryDelete.ts:9](https://github.com/nevoland/quetch/blob/72f665b/lib/types/QueryDelete.ts#L9)
912
+ [lib/types/QueryDelete.ts:9](https://github.com/nevoland/quetch/blob/6055b33/lib/types/QueryDelete.ts#L9)
909
913
 
910
914
  ___
911
915
 
@@ -934,7 +938,7 @@ Query for deleting multiple items.
934
938
 
935
939
  #### Defined in
936
940
 
937
- [lib/types/QueryDeleteMultiple.ts:9](https://github.com/nevoland/quetch/blob/72f665b/lib/types/QueryDeleteMultiple.ts#L9)
941
+ [lib/types/QueryDeleteMultiple.ts:9](https://github.com/nevoland/quetch/blob/6055b33/lib/types/QueryDeleteMultiple.ts#L9)
938
942
 
939
943
  ___
940
944
 
@@ -946,7 +950,7 @@ Available query methods.
946
950
 
947
951
  #### Defined in
948
952
 
949
- [lib/types/QueryMethod.ts:6](https://github.com/nevoland/quetch/blob/72f665b/lib/types/QueryMethod.ts#L6)
953
+ [lib/types/QueryMethod.ts:6](https://github.com/nevoland/quetch/blob/6055b33/lib/types/QueryMethod.ts#L6)
950
954
 
951
955
  ___
952
956
 
@@ -980,7 +984,7 @@ Query for reading a single item.
980
984
 
981
985
  #### Defined in
982
986
 
983
- [lib/types/QueryRead.ts:10](https://github.com/nevoland/quetch/blob/72f665b/lib/types/QueryRead.ts#L10)
987
+ [lib/types/QueryRead.ts:10](https://github.com/nevoland/quetch/blob/6055b33/lib/types/QueryRead.ts#L10)
984
988
 
985
989
  ___
986
990
 
@@ -1014,7 +1018,7 @@ Query for getting a list of items.
1014
1018
 
1015
1019
  #### Defined in
1016
1020
 
1017
- [lib/types/QueryReadMultiple.ts:11](https://github.com/nevoland/quetch/blob/72f665b/lib/types/QueryReadMultiple.ts#L11)
1021
+ [lib/types/QueryReadMultiple.ts:11](https://github.com/nevoland/quetch/blob/6055b33/lib/types/QueryReadMultiple.ts#L11)
1018
1022
 
1019
1023
  ___
1020
1024
 
@@ -1041,7 +1045,7 @@ Settings to use when doing a query.
1041
1045
 
1042
1046
  #### Defined in
1043
1047
 
1044
- [lib/types/QuerySettings.ts:8](https://github.com/nevoland/quetch/blob/72f665b/lib/types/QuerySettings.ts#L8)
1048
+ [lib/types/QuerySettings.ts:8](https://github.com/nevoland/quetch/blob/6055b33/lib/types/QuerySettings.ts#L8)
1045
1049
 
1046
1050
  ___
1047
1051
 
@@ -1074,7 +1078,7 @@ Query for updating an item.
1074
1078
 
1075
1079
  #### Defined in
1076
1080
 
1077
- [lib/types/QueryUpdate.ts:9](https://github.com/nevoland/quetch/blob/72f665b/lib/types/QueryUpdate.ts#L9)
1081
+ [lib/types/QueryUpdate.ts:9](https://github.com/nevoland/quetch/blob/6055b33/lib/types/QueryUpdate.ts#L9)
1078
1082
 
1079
1083
  ___
1080
1084
 
@@ -1107,7 +1111,7 @@ Query for updating multiple items.
1107
1111
 
1108
1112
  #### Defined in
1109
1113
 
1110
- [lib/types/QueryUpdateMultiple.ts:10](https://github.com/nevoland/quetch/blob/72f665b/lib/types/QueryUpdateMultiple.ts#L10)
1114
+ [lib/types/QueryUpdateMultiple.ts:10](https://github.com/nevoland/quetch/blob/6055b33/lib/types/QueryUpdateMultiple.ts#L10)
1111
1115
 
1112
1116
  ___
1113
1117
 
@@ -1124,7 +1128,7 @@ ___
1124
1128
 
1125
1129
  #### Defined in
1126
1130
 
1127
- [lib/types/Result.ts:20](https://github.com/nevoland/quetch/blob/72f665b/lib/types/Result.ts#L20)
1131
+ [lib/types/Result.ts:20](https://github.com/nevoland/quetch/blob/6055b33/lib/types/Result.ts#L20)
1128
1132
 
1129
1133
  ___
1130
1134
 
@@ -1149,7 +1153,7 @@ ___
1149
1153
 
1150
1154
  #### Defined in
1151
1155
 
1152
- [lib/types/Store.ts:2](https://github.com/nevoland/quetch/blob/72f665b/lib/types/Store.ts#L2)
1156
+ [lib/types/Store.ts:2](https://github.com/nevoland/quetch/blob/6055b33/lib/types/Store.ts#L2)
1153
1157
 
1154
1158
  ## Functions
1155
1159
 
@@ -1190,7 +1194,7 @@ If a query occurs twice, `mergeQuery(query, currentQuery)` is called and the out
1190
1194
 
1191
1195
  #### Defined in
1192
1196
 
1193
- [lib/middlewares/aggregate.ts:16](https://github.com/nevoland/quetch/blob/72f665b/lib/middlewares/aggregate.ts#L16)
1197
+ [lib/middlewares/aggregate.ts:16](https://github.com/nevoland/quetch/blob/6055b33/lib/middlewares/aggregate.ts#L16)
1194
1198
 
1195
1199
  ___
1196
1200
 
@@ -1232,7 +1236,7 @@ const customFetch = combine(
1232
1236
 
1233
1237
  #### Defined in
1234
1238
 
1235
- [lib/middlewares/branch.ts:21](https://github.com/nevoland/quetch/blob/72f665b/lib/middlewares/branch.ts#L21)
1239
+ [lib/middlewares/branch.ts:21](https://github.com/nevoland/quetch/blob/6055b33/lib/middlewares/branch.ts#L21)
1236
1240
 
1237
1241
  ___
1238
1242
 
@@ -1267,7 +1271,7 @@ ___
1267
1271
 
1268
1272
  #### Defined in
1269
1273
 
1270
- [lib/middlewares/cache.ts:8](https://github.com/nevoland/quetch/blob/72f665b/lib/middlewares/cache.ts#L8)
1274
+ [lib/middlewares/cache.ts:8](https://github.com/nevoland/quetch/blob/6055b33/lib/middlewares/cache.ts#L8)
1271
1275
 
1272
1276
  ___
1273
1277
 
@@ -1340,7 +1344,7 @@ Handler that combines all provided handlers.
1340
1344
 
1341
1345
  #### Defined in
1342
1346
 
1343
- [lib/middlewares/combine.ts:801](https://github.com/nevoland/quetch/blob/72f665b/lib/middlewares/combine.ts#L801)
1347
+ [lib/middlewares/combine.ts:801](https://github.com/nevoland/quetch/blob/6055b33/lib/middlewares/combine.ts#L801)
1344
1348
 
1345
1349
  ___
1346
1350
 
@@ -1362,7 +1366,7 @@ Uncallable handler used to terminate a sequence of handlers combined with `combi
1362
1366
 
1363
1367
  #### Defined in
1364
1368
 
1365
- [lib/types/NextHandler.ts:4](https://github.com/nevoland/quetch/blob/72f665b/lib/types/NextHandler.ts#L4)
1369
+ [lib/types/NextHandler.ts:4](https://github.com/nevoland/quetch/blob/6055b33/lib/types/NextHandler.ts#L4)
1366
1370
 
1367
1371
  ___
1368
1372
 
@@ -1425,7 +1429,7 @@ typeof `query`
1425
1429
 
1426
1430
  #### Defined in
1427
1431
 
1428
- [lib/tools/defineCheckQuery.ts:8](https://github.com/nevoland/quetch/blob/72f665b/lib/tools/defineCheckQuery.ts#L8)
1432
+ [lib/tools/defineCheckQuery.ts:8](https://github.com/nevoland/quetch/blob/6055b33/lib/tools/defineCheckQuery.ts#L8)
1429
1433
 
1430
1434
  ___
1431
1435
 
@@ -1495,7 +1499,7 @@ A custom fetch function.
1495
1499
 
1496
1500
  #### Defined in
1497
1501
 
1498
- [lib/tools/defineCustomFetch.ts:11](https://github.com/nevoland/quetch/blob/72f665b/lib/tools/defineCustomFetch.ts#L11)
1502
+ [lib/tools/defineCustomFetch.ts:11](https://github.com/nevoland/quetch/blob/6055b33/lib/tools/defineCustomFetch.ts#L11)
1499
1503
 
1500
1504
  ___
1501
1505
 
@@ -1558,7 +1562,7 @@ A curried generic fetch function.
1558
1562
 
1559
1563
  #### Defined in
1560
1564
 
1561
- [lib/tools/defineGenericFetch.ts:14](https://github.com/nevoland/quetch/blob/72f665b/lib/tools/defineGenericFetch.ts#L14)
1565
+ [lib/tools/defineGenericFetch.ts:14](https://github.com/nevoland/quetch/blob/6055b33/lib/tools/defineGenericFetch.ts#L14)
1562
1566
 
1563
1567
  ___
1564
1568
 
@@ -1582,7 +1586,7 @@ Escaped regular expression
1582
1586
 
1583
1587
  #### Defined in
1584
1588
 
1585
- [lib/tools/escapeRegex.ts:7](https://github.com/nevoland/quetch/blob/72f665b/lib/tools/escapeRegex.ts#L7)
1589
+ [lib/tools/escapeRegex.ts:7](https://github.com/nevoland/quetch/blob/6055b33/lib/tools/escapeRegex.ts#L7)
1586
1590
 
1587
1591
  ___
1588
1592
 
@@ -1606,7 +1610,7 @@ Handler that returns a promise that resolves to the response.
1606
1610
 
1607
1611
  #### Defined in
1608
1612
 
1609
- [lib/middlewares/fetchExternal.ts:12](https://github.com/nevoland/quetch/blob/72f665b/lib/middlewares/fetchExternal.ts#L12)
1613
+ [lib/middlewares/fetchExternal.ts:12](https://github.com/nevoland/quetch/blob/6055b33/lib/middlewares/fetchExternal.ts#L12)
1610
1614
 
1611
1615
  ___
1612
1616
 
@@ -1630,7 +1634,7 @@ Promise that resolves to the response.
1630
1634
 
1631
1635
  #### Defined in
1632
1636
 
1633
- [lib/middlewares/fetchLocal.ts:9](https://github.com/nevoland/quetch/blob/72f665b/lib/middlewares/fetchLocal.ts#L9)
1637
+ [lib/middlewares/fetchLocal.ts:9](https://github.com/nevoland/quetch/blob/6055b33/lib/middlewares/fetchLocal.ts#L9)
1634
1638
 
1635
1639
  ___
1636
1640
 
@@ -1659,7 +1663,7 @@ ___
1659
1663
 
1660
1664
  #### Defined in
1661
1665
 
1662
- [lib/tools/filterChildren.ts:5](https://github.com/nevoland/quetch/blob/72f665b/lib/tools/filterChildren.ts#L5)
1666
+ [lib/tools/filterChildren.ts:5](https://github.com/nevoland/quetch/blob/6055b33/lib/tools/filterChildren.ts#L5)
1663
1667
 
1664
1668
  ___
1665
1669
 
@@ -1685,7 +1689,7 @@ ___
1685
1689
 
1686
1690
  #### Defined in
1687
1691
 
1688
- [lib/tools/filterFromContext.ts:5](https://github.com/nevoland/quetch/blob/72f665b/lib/tools/filterFromContext.ts#L5)
1692
+ [lib/tools/filterFromContext.ts:5](https://github.com/nevoland/quetch/blob/6055b33/lib/tools/filterFromContext.ts#L5)
1689
1693
 
1690
1694
  ___
1691
1695
 
@@ -1717,7 +1721,7 @@ Checks wether the provided `value` matches the `filter` or not.
1717
1721
 
1718
1722
  #### Defined in
1719
1723
 
1720
- [lib/tools/filterItem.ts:17](https://github.com/nevoland/quetch/blob/72f665b/lib/tools/filterItem.ts#L17)
1724
+ [lib/tools/filterItem.ts:17](https://github.com/nevoland/quetch/blob/6055b33/lib/tools/filterItem.ts#L17)
1721
1725
 
1722
1726
  ___
1723
1727
 
@@ -1747,7 +1751,7 @@ ___
1747
1751
 
1748
1752
  #### Defined in
1749
1753
 
1750
- [lib/middlewares/identity.ts:3](https://github.com/nevoland/quetch/blob/72f665b/lib/middlewares/identity.ts#L3)
1754
+ [lib/middlewares/identity.ts:3](https://github.com/nevoland/quetch/blob/6055b33/lib/middlewares/identity.ts#L3)
1751
1755
 
1752
1756
  ___
1753
1757
 
@@ -1777,7 +1781,7 @@ Whether the provided filter is a group filter or not.
1777
1781
 
1778
1782
  #### Defined in
1779
1783
 
1780
- [lib/tools/isFilterGroup.ts:9](https://github.com/nevoland/quetch/blob/72f665b/lib/tools/isFilterGroup.ts#L9)
1784
+ [lib/tools/isFilterGroup.ts:9](https://github.com/nevoland/quetch/blob/6055b33/lib/tools/isFilterGroup.ts#L9)
1781
1785
 
1782
1786
  ___
1783
1787
 
@@ -1810,7 +1814,7 @@ Query handler
1810
1814
 
1811
1815
  #### Defined in
1812
1816
 
1813
- [lib/middlewares/log.ts:13](https://github.com/nevoland/quetch/blob/72f665b/lib/middlewares/log.ts#L13)
1817
+ [lib/middlewares/log.ts:13](https://github.com/nevoland/quetch/blob/6055b33/lib/middlewares/log.ts#L13)
1814
1818
 
1815
1819
  ___
1816
1820
 
@@ -1841,7 +1845,7 @@ ___
1841
1845
 
1842
1846
  #### Defined in
1843
1847
 
1844
- [lib/tools/normalizeOrder.ts:3](https://github.com/nevoland/quetch/blob/72f665b/lib/tools/normalizeOrder.ts#L3)
1848
+ [lib/tools/normalizeOrder.ts:3](https://github.com/nevoland/quetch/blob/6055b33/lib/tools/normalizeOrder.ts#L3)
1845
1849
 
1846
1850
  ___
1847
1851
 
@@ -1868,7 +1872,7 @@ ___
1868
1872
 
1869
1873
  #### Defined in
1870
1874
 
1871
- [lib/tools/queryItemList.ts:41](https://github.com/nevoland/quetch/blob/72f665b/lib/tools/queryItemList.ts#L41)
1875
+ [lib/tools/queryItemList.ts:41](https://github.com/nevoland/quetch/blob/6055b33/lib/tools/queryItemList.ts#L41)
1872
1876
 
1873
1877
  ___
1874
1878
 
@@ -1897,7 +1901,7 @@ Handler
1897
1901
 
1898
1902
  #### Defined in
1899
1903
 
1900
- [lib/middlewares/retry.ts:15](https://github.com/nevoland/quetch/blob/72f665b/lib/middlewares/retry.ts#L15)
1904
+ [lib/middlewares/retry.ts:15](https://github.com/nevoland/quetch/blob/6055b33/lib/middlewares/retry.ts#L15)
1901
1905
 
1902
1906
  ___
1903
1907
 
@@ -1928,4 +1932,4 @@ The same array sorted in place.
1928
1932
 
1929
1933
  #### Defined in
1930
1934
 
1931
- [lib/tools/sortItemList.ts:12](https://github.com/nevoland/quetch/blob/72f665b/lib/tools/sortItemList.ts#L12)
1935
+ [lib/tools/sortItemList.ts:12](https://github.com/nevoland/quetch/blob/6055b33/lib/tools/sortItemList.ts#L12)
@@ -0,0 +1,88 @@
1
+ [quetch](../README.md) / RequestError
2
+
3
+ # Class: RequestError
4
+
5
+ Error to be thrown in case there is an issue with the query call. Only instances of this error will be caught by the `retry()` middleware.
6
+
7
+ ## Hierarchy
8
+
9
+ - `Error`
10
+
11
+ ↳ **`RequestError`**
12
+
13
+ ## Table of contents
14
+
15
+ ### Constructors
16
+
17
+ - [constructor](RequestError.md#constructor)
18
+
19
+ ### Properties
20
+
21
+ - [query](RequestError.md#query)
22
+ - [request](RequestError.md#request)
23
+ - [response](RequestError.md#response)
24
+ - [status](RequestError.md#status)
25
+
26
+ ## Constructors
27
+
28
+ ### constructor
29
+
30
+ • **new RequestError**(`message`, `status`, `query?`, `request?`, `response?`)
31
+
32
+ #### Parameters
33
+
34
+ | Name | Type |
35
+ | :------ | :------ |
36
+ | `message` | `string` |
37
+ | `status` | `number` |
38
+ | `query?` | [`Query`](../README.md#query)<`any`\> |
39
+ | `request?` | `Request` |
40
+ | `response?` | `Response` |
41
+
42
+ #### Overrides
43
+
44
+ Error.constructor
45
+
46
+ #### Defined in
47
+
48
+ [lib/errors/RequestError.ts:7](https://github.com/nevoland/quetch/blob/6055b33/lib/errors/RequestError.ts#L7)
49
+
50
+ ## Properties
51
+
52
+ ### query
53
+
54
+ • `Optional` **query**: [`Query`](../README.md#query)<`any`\>
55
+
56
+ #### Defined in
57
+
58
+ [lib/errors/RequestError.ts:10](https://github.com/nevoland/quetch/blob/6055b33/lib/errors/RequestError.ts#L10)
59
+
60
+ ___
61
+
62
+ ### request
63
+
64
+ • `Optional` **request**: `Request`
65
+
66
+ #### Defined in
67
+
68
+ [lib/errors/RequestError.ts:11](https://github.com/nevoland/quetch/blob/6055b33/lib/errors/RequestError.ts#L11)
69
+
70
+ ___
71
+
72
+ ### response
73
+
74
+ • `Optional` **response**: `Response`
75
+
76
+ #### Defined in
77
+
78
+ [lib/errors/RequestError.ts:12](https://github.com/nevoland/quetch/blob/6055b33/lib/errors/RequestError.ts#L12)
79
+
80
+ ___
81
+
82
+ ### status
83
+
84
+ • **status**: `number`
85
+
86
+ #### Defined in
87
+
88
+ [lib/errors/RequestError.ts:9](https://github.com/nevoland/quetch/blob/6055b33/lib/errors/RequestError.ts#L9)
@@ -32,4 +32,4 @@
32
32
 
33
33
  #### Defined in
34
34
 
35
- [lib/types/CustomFetch.ts:5](https://github.com/nevoland/quetch/blob/72f665b/lib/types/CustomFetch.ts#L5)
35
+ [lib/types/CustomFetch.ts:5](https://github.com/nevoland/quetch/blob/6055b33/lib/types/CustomFetch.ts#L5)
package/lib/main.ts CHANGED
@@ -2,3 +2,4 @@ export type * from "./types.js";
2
2
 
3
3
  export * from "./tools.js";
4
4
  export * from "./middlewares.js";
5
+ export * from "./errors.js";
@@ -16,23 +16,24 @@ export function fetchExternal(
16
16
  console.error("Could not find a global `fetch` function");
17
17
  }
18
18
  return async (request, _) => {
19
+ let response;
19
20
  try {
20
- const response = await fetch(request);
21
- if (!response.ok) {
22
- throw new RequestError(
23
- response.statusText,
24
- response.status,
25
- undefined,
26
- request,
27
- response,
28
- );
29
- }
30
- return response;
21
+ response = await fetch(request);
31
22
  } catch (error) {
32
23
  if (error instanceof Error) {
33
24
  throw new RequestError(error.message, 500, undefined, request);
34
25
  }
35
26
  throw new RequestError(String(error), 500, undefined, request);
36
27
  }
28
+ if (!response.ok) {
29
+ throw new RequestError(
30
+ response.statusText,
31
+ response.status,
32
+ undefined,
33
+ request,
34
+ response,
35
+ );
36
+ }
37
+ return response;
37
38
  };
38
39
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "quetch",
3
- "version": "0.11.0",
3
+ "version": "0.11.2",
4
4
  "type": "module",
5
5
  "main": "./dist/main.js",
6
6
  "exports": {