quetch 0.3.0 → 0.5.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.
@@ -0,0 +1,11 @@
1
+ import type { CustomFieldMap } from "./CustomFieldMap";
2
+ import type { Query } from "./Query";
3
+ import type { Result } from "./Result";
4
+ export interface GenericFetch<T extends object> {
5
+ <Q extends Query<T, {}>>(query: Q & {
6
+ customFields?: never;
7
+ }): Promise<Result<T, Q, {}>>;
8
+ <Q extends Query<T, C>, C extends CustomFieldMap<T>>(query: Q & {
9
+ customFields: C;
10
+ }): Promise<Result<T, Q, C>>;
11
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=GenericFetch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GenericFetch.js","sourceRoot":"","sources":["../../lib/types/GenericFetch.ts"],"names":[],"mappings":""}
@@ -14,7 +14,26 @@ type QueryBase<T extends object> = QueryRead<T> | QueryReadMultiple<T> | QueryCr
14
14
  /**
15
15
  * Query that fetches or mutates an entity.
16
16
  */
17
- export type Query<T extends object, C extends CustomFieldMap<T> | undefined> = QueryBase<InjectCustomFields<T, C>> & {
17
+ export type Query<
18
+ /**
19
+ * Type.
20
+ */
21
+ T extends object,
22
+ /**
23
+ * Custom fields.
24
+ */
25
+ C extends CustomFieldMap<T> | undefined,
26
+ /**
27
+ * Methods.
28
+ */
29
+ M extends QueryBase<never>["method"] = QueryBase<never>["method"],
30
+ /**
31
+ * Multiple.
32
+ */
33
+ L extends boolean | undefined = boolean> = Extract<QueryBase<InjectCustomFields<T, C>>, {
34
+ method?: M;
35
+ multiple?: L;
36
+ }> & {
18
37
  /**
19
38
  * Common item properties to use for identifying the item.
20
39
  */
@@ -3,5 +3,6 @@
3
3
  */
4
4
  export type QueryCreate<T extends object> = {
5
5
  method: "create";
6
+ multiple?: false;
6
7
  value: Partial<T>;
7
8
  };
@@ -5,6 +5,7 @@ import type { Filter } from "./Filter";
5
5
  */
6
6
  export type QueryDelete<T extends object> = {
7
7
  method: "delete";
8
+ multiple?: false;
8
9
  filter?: Filter<T>;
9
10
  customFields?: CustomFieldMap<T>;
10
11
  };
@@ -4,6 +4,7 @@ import type { Filter } from "./Filter";
4
4
  */
5
5
  export type QueryUpdate<T extends object> = {
6
6
  method: "update";
7
+ multiple?: false;
7
8
  /**
8
9
  * Partial property values to update.
9
10
  */
package/dist/types.d.ts CHANGED
@@ -20,6 +20,7 @@ export type { FilterSequence } from "./types/FilterSequence";
20
20
  export type { FilterString } from "./types/FilterString";
21
21
  export type { FilterStringIntersect } from "./types/FilterStringIntersect";
22
22
  export type { FilterStringMatch } from "./types/FilterStringMatch";
23
+ export type { GenericFetch } from "./types/GenericFetch";
23
24
  export type { Get } from "./types/Get";
24
25
  export type { Group } from "./types/Group";
25
26
  export type { Handler } from "./types/Handler";
package/doc/README.md CHANGED
@@ -4,6 +4,10 @@ quetch
4
4
 
5
5
  ## Table of contents
6
6
 
7
+ ### Interfaces
8
+
9
+ - [GenericFetch](interfaces/GenericFetch.md)
10
+
7
11
  ### Type Aliases
8
12
 
9
13
  - [AggregateFunction](README.md#aggregatefunction)
@@ -90,7 +94,7 @@ Aggregation function.
90
94
 
91
95
  #### Defined in
92
96
 
93
- [lib/types/AggregateFunction.ts:4](https://github.com/nevoland/quetch/blob/f8fb38a/lib/types/AggregateFunction.ts#L4)
97
+ [lib/types/AggregateFunction.ts:4](https://github.com/nevoland/quetch/blob/c839ceb/lib/types/AggregateFunction.ts#L4)
94
98
 
95
99
  ___
96
100
 
@@ -100,7 +104,7 @@ ___
100
104
 
101
105
  #### Defined in
102
106
 
103
- [lib/types/AggregateFunctionOperator.ts:3](https://github.com/nevoland/quetch/blob/f8fb38a/lib/types/AggregateFunctionOperator.ts#L3)
107
+ [lib/types/AggregateFunctionOperator.ts:3](https://github.com/nevoland/quetch/blob/c839ceb/lib/types/AggregateFunctionOperator.ts#L3)
104
108
 
105
109
  ___
106
110
 
@@ -110,7 +114,7 @@ ___
110
114
 
111
115
  #### Defined in
112
116
 
113
- [lib/types/Any.ts:1](https://github.com/nevoland/quetch/blob/f8fb38a/lib/types/Any.ts#L1)
117
+ [lib/types/Any.ts:1](https://github.com/nevoland/quetch/blob/c839ceb/lib/types/Any.ts#L1)
114
118
 
115
119
  ___
116
120
 
@@ -126,7 +130,7 @@ ___
126
130
 
127
131
  #### Defined in
128
132
 
129
- [lib/types/Context.ts:1](https://github.com/nevoland/quetch/blob/f8fb38a/lib/types/Context.ts#L1)
133
+ [lib/types/Context.ts:1](https://github.com/nevoland/quetch/blob/c839ceb/lib/types/Context.ts#L1)
130
134
 
131
135
  ___
132
136
 
@@ -142,7 +146,7 @@ ___
142
146
 
143
147
  #### Defined in
144
148
 
145
- [lib/types/CustomFieldAggregateMap.ts:3](https://github.com/nevoland/quetch/blob/f8fb38a/lib/types/CustomFieldAggregateMap.ts#L3)
149
+ [lib/types/CustomFieldAggregateMap.ts:3](https://github.com/nevoland/quetch/blob/c839ceb/lib/types/CustomFieldAggregateMap.ts#L3)
146
150
 
147
151
  ___
148
152
 
@@ -158,7 +162,7 @@ ___
158
162
 
159
163
  #### Defined in
160
164
 
161
- [lib/types/CustomFieldMap.ts:3](https://github.com/nevoland/quetch/blob/f8fb38a/lib/types/CustomFieldMap.ts#L3)
165
+ [lib/types/CustomFieldMap.ts:3](https://github.com/nevoland/quetch/blob/c839ceb/lib/types/CustomFieldMap.ts#L3)
162
166
 
163
167
  ___
164
168
 
@@ -184,7 +188,7 @@ ___
184
188
 
185
189
  #### Defined in
186
190
 
187
- [lib/types/CustomRequest.ts:4](https://github.com/nevoland/quetch/blob/f8fb38a/lib/types/CustomRequest.ts#L4)
191
+ [lib/types/CustomRequest.ts:4](https://github.com/nevoland/quetch/blob/c839ceb/lib/types/CustomRequest.ts#L4)
188
192
 
189
193
  ___
190
194
 
@@ -200,7 +204,7 @@ ___
200
204
 
201
205
  #### Defined in
202
206
 
203
- [lib/types/FieldFunction.ts:4](https://github.com/nevoland/quetch/blob/f8fb38a/lib/types/FieldFunction.ts#L4)
207
+ [lib/types/FieldFunction.ts:4](https://github.com/nevoland/quetch/blob/c839ceb/lib/types/FieldFunction.ts#L4)
204
208
 
205
209
  ___
206
210
 
@@ -225,7 +229,7 @@ Applies a custom field transform function.
225
229
 
226
230
  #### Defined in
227
231
 
228
- [lib/types/FieldFunctionCustom.ts:4](https://github.com/nevoland/quetch/blob/f8fb38a/lib/types/FieldFunctionCustom.ts#L4)
232
+ [lib/types/FieldFunctionCustom.ts:4](https://github.com/nevoland/quetch/blob/c839ceb/lib/types/FieldFunctionCustom.ts#L4)
229
233
 
230
234
  ___
231
235
 
@@ -251,7 +255,7 @@ Formats the date found in a given field, which can be an ISO string date or a ti
251
255
 
252
256
  #### Defined in
253
257
 
254
- [lib/types/FieldFunctionFormatDate.ts:6](https://github.com/nevoland/quetch/blob/f8fb38a/lib/types/FieldFunctionFormatDate.ts#L6)
258
+ [lib/types/FieldFunctionFormatDate.ts:6](https://github.com/nevoland/quetch/blob/c839ceb/lib/types/FieldFunctionFormatDate.ts#L6)
255
259
 
256
260
  ___
257
261
 
@@ -269,7 +273,7 @@ Return types of custom field functions.
269
273
 
270
274
  #### Defined in
271
275
 
272
- [lib/types/FieldFunctionReturn.ts:4](https://github.com/nevoland/quetch/blob/f8fb38a/lib/types/FieldFunctionReturn.ts#L4)
276
+ [lib/types/FieldFunctionReturn.ts:4](https://github.com/nevoland/quetch/blob/c839ceb/lib/types/FieldFunctionReturn.ts#L4)
273
277
 
274
278
  ___
275
279
 
@@ -287,7 +291,7 @@ Describes a predicate for filtering items.
287
291
 
288
292
  #### Defined in
289
293
 
290
- [lib/types/Filter.ts:12](https://github.com/nevoland/quetch/blob/f8fb38a/lib/types/Filter.ts#L12)
294
+ [lib/types/Filter.ts:12](https://github.com/nevoland/quetch/blob/c839ceb/lib/types/Filter.ts#L12)
291
295
 
292
296
  ___
293
297
 
@@ -314,7 +318,7 @@ Checks if a given array field matches a given array value according to a given o
314
318
 
315
319
  #### Defined in
316
320
 
317
- [lib/types/FilterArray.ts:7](https://github.com/nevoland/quetch/blob/f8fb38a/lib/types/FilterArray.ts#L7)
321
+ [lib/types/FilterArray.ts:7](https://github.com/nevoland/quetch/blob/c839ceb/lib/types/FilterArray.ts#L7)
318
322
 
319
323
  ___
320
324
 
@@ -340,7 +344,7 @@ Checks if a given boolean field is `true` or `false`.
340
344
 
341
345
  #### Defined in
342
346
 
343
- [lib/types/FilterBoolean.ts:6](https://github.com/nevoland/quetch/blob/f8fb38a/lib/types/FilterBoolean.ts#L6)
347
+ [lib/types/FilterBoolean.ts:6](https://github.com/nevoland/quetch/blob/c839ceb/lib/types/FilterBoolean.ts#L6)
344
348
 
345
349
  ___
346
350
 
@@ -365,7 +369,7 @@ Checks if a given field exists.
365
369
 
366
370
  #### Defined in
367
371
 
368
- [lib/types/FilterField.ts:4](https://github.com/nevoland/quetch/blob/f8fb38a/lib/types/FilterField.ts#L4)
372
+ [lib/types/FilterField.ts:4](https://github.com/nevoland/quetch/blob/c839ceb/lib/types/FilterField.ts#L4)
369
373
 
370
374
  ___
371
375
 
@@ -384,7 +388,7 @@ Returns object type with field extending the provided `P` type.
384
388
 
385
389
  #### Defined in
386
390
 
387
- [lib/types/FilterKeys.ts:4](https://github.com/nevoland/quetch/blob/f8fb38a/lib/types/FilterKeys.ts#L4)
391
+ [lib/types/FilterKeys.ts:4](https://github.com/nevoland/quetch/blob/c839ceb/lib/types/FilterKeys.ts#L4)
388
392
 
389
393
  ___
390
394
 
@@ -410,7 +414,7 @@ Checks if a given number field matches a given number value according to a given
410
414
 
411
415
  #### Defined in
412
416
 
413
- [lib/types/FilterNumber.ts:6](https://github.com/nevoland/quetch/blob/f8fb38a/lib/types/FilterNumber.ts#L6)
417
+ [lib/types/FilterNumber.ts:6](https://github.com/nevoland/quetch/blob/c839ceb/lib/types/FilterNumber.ts#L6)
414
418
 
415
419
  ___
416
420
 
@@ -420,7 +424,7 @@ ___
420
424
 
421
425
  #### Defined in
422
426
 
423
- [lib/types/FilterOperator.ts:3](https://github.com/nevoland/quetch/blob/f8fb38a/lib/types/FilterOperator.ts#L3)
427
+ [lib/types/FilterOperator.ts:3](https://github.com/nevoland/quetch/blob/c839ceb/lib/types/FilterOperator.ts#L3)
424
428
 
425
429
  ___
426
430
 
@@ -438,7 +442,7 @@ Joins a list of filters with a specific boolean operator.
438
442
 
439
443
  #### Defined in
440
444
 
441
- [lib/types/FilterSequence.ts:6](https://github.com/nevoland/quetch/blob/f8fb38a/lib/types/FilterSequence.ts#L6)
445
+ [lib/types/FilterSequence.ts:6](https://github.com/nevoland/quetch/blob/c839ceb/lib/types/FilterSequence.ts#L6)
442
446
 
443
447
  ___
444
448
 
@@ -464,7 +468,7 @@ Checks if a given string field matches a given string value according to a given
464
468
 
465
469
  #### Defined in
466
470
 
467
- [lib/types/FilterString.ts:6](https://github.com/nevoland/quetch/blob/f8fb38a/lib/types/FilterString.ts#L6)
471
+ [lib/types/FilterString.ts:6](https://github.com/nevoland/quetch/blob/c839ceb/lib/types/FilterString.ts#L6)
468
472
 
469
473
  ___
470
474
 
@@ -490,7 +494,7 @@ Checks if a given string field has any of the provided values.
490
494
 
491
495
  #### Defined in
492
496
 
493
- [lib/types/FilterStringIntersect.ts:6](https://github.com/nevoland/quetch/blob/f8fb38a/lib/types/FilterStringIntersect.ts#L6)
497
+ [lib/types/FilterStringIntersect.ts:6](https://github.com/nevoland/quetch/blob/c839ceb/lib/types/FilterStringIntersect.ts#L6)
494
498
 
495
499
  ___
496
500
 
@@ -520,7 +524,7 @@ Checks if a given string field matches a given regular expression.
520
524
 
521
525
  #### Defined in
522
526
 
523
- [lib/types/FilterStringMatch.ts:6](https://github.com/nevoland/quetch/blob/f8fb38a/lib/types/FilterStringMatch.ts#L6)
527
+ [lib/types/FilterStringMatch.ts:6](https://github.com/nevoland/quetch/blob/c839ceb/lib/types/FilterStringMatch.ts#L6)
524
528
 
525
529
  ___
526
530
 
@@ -540,7 +544,7 @@ Returns the type of the property at the specified `K` key.
540
544
 
541
545
  #### Defined in
542
546
 
543
- [lib/types/Get.ts:4](https://github.com/nevoland/quetch/blob/f8fb38a/lib/types/Get.ts#L4)
547
+ [lib/types/Get.ts:4](https://github.com/nevoland/quetch/blob/c839ceb/lib/types/Get.ts#L4)
544
548
 
545
549
  ___
546
550
 
@@ -558,7 +562,7 @@ Specifies how items should be grouped.
558
562
 
559
563
  #### Defined in
560
564
 
561
- [lib/types/Group.ts:6](https://github.com/nevoland/quetch/blob/f8fb38a/lib/types/Group.ts#L6)
565
+ [lib/types/Group.ts:6](https://github.com/nevoland/quetch/blob/c839ceb/lib/types/Group.ts#L6)
562
566
 
563
567
  ___
564
568
 
@@ -594,7 +598,7 @@ Handles an `input` query and returns an `output` promise, eventually using the `
594
598
 
595
599
  #### Defined in
596
600
 
597
- [lib/types/Handler.ts:6](https://github.com/nevoland/quetch/blob/f8fb38a/lib/types/Handler.ts#L6)
601
+ [lib/types/Handler.ts:6](https://github.com/nevoland/quetch/blob/c839ceb/lib/types/Handler.ts#L6)
598
602
 
599
603
  ___
600
604
 
@@ -610,7 +614,7 @@ ___
610
614
 
611
615
  #### Defined in
612
616
 
613
- [lib/types/Immutable.ts:1](https://github.com/nevoland/quetch/blob/f8fb38a/lib/types/Immutable.ts#L1)
617
+ [lib/types/Immutable.ts:1](https://github.com/nevoland/quetch/blob/c839ceb/lib/types/Immutable.ts#L1)
614
618
 
615
619
  ___
616
620
 
@@ -629,7 +633,7 @@ Injects the custom fields into the entity type.
629
633
 
630
634
  #### Defined in
631
635
 
632
- [lib/types/InjectCustomFields.ts:8](https://github.com/nevoland/quetch/blob/f8fb38a/lib/types/InjectCustomFields.ts#L8)
636
+ [lib/types/InjectCustomFields.ts:8](https://github.com/nevoland/quetch/blob/c839ceb/lib/types/InjectCustomFields.ts#L8)
633
637
 
634
638
  ___
635
639
 
@@ -648,7 +652,7 @@ Returns the inferred item type of an array, or an alternative type if it is some
648
652
 
649
653
  #### Defined in
650
654
 
651
- [lib/types/Item.ts:4](https://github.com/nevoland/quetch/blob/f8fb38a/lib/types/Item.ts#L4)
655
+ [lib/types/Item.ts:4](https://github.com/nevoland/quetch/blob/c839ceb/lib/types/Item.ts#L4)
652
656
 
653
657
  ___
654
658
 
@@ -658,7 +662,7 @@ ___
658
662
 
659
663
  #### Defined in
660
664
 
661
- [lib/types/Key.ts:1](https://github.com/nevoland/quetch/blob/f8fb38a/lib/types/Key.ts#L1)
665
+ [lib/types/Key.ts:1](https://github.com/nevoland/quetch/blob/c839ceb/lib/types/Key.ts#L1)
662
666
 
663
667
  ___
664
668
 
@@ -674,7 +678,7 @@ ___
674
678
 
675
679
  #### Defined in
676
680
 
677
- [lib/types/Mutable.ts:1](https://github.com/nevoland/quetch/blob/f8fb38a/lib/types/Mutable.ts#L1)
681
+ [lib/types/Mutable.ts:1](https://github.com/nevoland/quetch/blob/c839ceb/lib/types/Mutable.ts#L1)
678
682
 
679
683
  ___
680
684
 
@@ -707,7 +711,7 @@ Handles an `input` query and returns an `output` promise.
707
711
 
708
712
  #### Defined in
709
713
 
710
- [lib/types/NextHandler.ts:4](https://github.com/nevoland/quetch/blob/f8fb38a/lib/types/NextHandler.ts#L4)
714
+ [lib/types/NextHandler.ts:4](https://github.com/nevoland/quetch/blob/c839ceb/lib/types/NextHandler.ts#L4)
711
715
 
712
716
  ___
713
717
 
@@ -725,13 +729,13 @@ Order item.
725
729
 
726
730
  #### Defined in
727
731
 
728
- [lib/types/Order.ts:4](https://github.com/nevoland/quetch/blob/f8fb38a/lib/types/Order.ts#L4)
732
+ [lib/types/Order.ts:4](https://github.com/nevoland/quetch/blob/c839ceb/lib/types/Order.ts#L4)
729
733
 
730
734
  ___
731
735
 
732
736
  ### Query
733
737
 
734
- Ƭ **Query**<`T`, `C`\>: `QueryBase`<[`InjectCustomFields`](README.md#injectcustomfields)<`T`, `C`\>\> & { `context?`: [`Context`](README.md#context)<`T`\> }
738
+ Ƭ **Query**<`T`, `C`, `M`, `L`\>: `Extract`<`QueryBase`<[`InjectCustomFields`](README.md#injectcustomfields)<`T`, `C`\>\>, { `method?`: `M` ; `multiple?`: `L` }\> & { `context?`: [`Context`](README.md#context)<`T`\> }
735
739
 
736
740
  Query that fetches or mutates an entity.
737
741
 
@@ -741,10 +745,12 @@ Query that fetches or mutates an entity.
741
745
  | :------ | :------ |
742
746
  | `T` | extends `object` |
743
747
  | `C` | extends [`CustomFieldMap`](README.md#customfieldmap)<`T`\> \| `undefined` |
748
+ | `M` | extends `QueryBase`<`never`\>[``"method"``] = `QueryBase`<`never`\>[``"method"``] |
749
+ | `L` | extends `boolean` \| `undefined` = `boolean` |
744
750
 
745
751
  #### Defined in
746
752
 
747
- [lib/types/Query.ts:28](https://github.com/nevoland/quetch/blob/f8fb38a/lib/types/Query.ts#L28)
753
+ [lib/types/Query.ts:28](https://github.com/nevoland/quetch/blob/c839ceb/lib/types/Query.ts#L28)
748
754
 
749
755
  ___
750
756
 
@@ -770,7 +776,7 @@ Query for computing an aggregated value.
770
776
 
771
777
  #### Defined in
772
778
 
773
- [lib/types/QueryAggregate.ts:7](https://github.com/nevoland/quetch/blob/f8fb38a/lib/types/QueryAggregate.ts#L7)
779
+ [lib/types/QueryAggregate.ts:7](https://github.com/nevoland/quetch/blob/c839ceb/lib/types/QueryAggregate.ts#L7)
774
780
 
775
781
  ___
776
782
 
@@ -780,7 +786,7 @@ ___
780
786
 
781
787
  #### Defined in
782
788
 
783
- [lib/types/QueryAny.ts:5](https://github.com/nevoland/quetch/blob/f8fb38a/lib/types/QueryAny.ts#L5)
789
+ [lib/types/QueryAny.ts:5](https://github.com/nevoland/quetch/blob/c839ceb/lib/types/QueryAny.ts#L5)
784
790
 
785
791
  ___
786
792
 
@@ -801,11 +807,12 @@ Query for creating an item.
801
807
  | Name | Type |
802
808
  | :------ | :------ |
803
809
  | `method` | ``"create"`` |
810
+ | `multiple?` | ``false`` |
804
811
  | `value` | `Partial`<`T`\> |
805
812
 
806
813
  #### Defined in
807
814
 
808
- [lib/types/QueryCreate.ts:4](https://github.com/nevoland/quetch/blob/f8fb38a/lib/types/QueryCreate.ts#L4)
815
+ [lib/types/QueryCreate.ts:4](https://github.com/nevoland/quetch/blob/c839ceb/lib/types/QueryCreate.ts#L4)
809
816
 
810
817
  ___
811
818
 
@@ -831,7 +838,7 @@ Query for creating multiple items.
831
838
 
832
839
  #### Defined in
833
840
 
834
- [lib/types/QueryCreateMultiple.ts:4](https://github.com/nevoland/quetch/blob/f8fb38a/lib/types/QueryCreateMultiple.ts#L4)
841
+ [lib/types/QueryCreateMultiple.ts:4](https://github.com/nevoland/quetch/blob/c839ceb/lib/types/QueryCreateMultiple.ts#L4)
835
842
 
836
843
  ___
837
844
 
@@ -854,10 +861,11 @@ Query for deleting an item.
854
861
  | `customFields?` | [`CustomFieldMap`](README.md#customfieldmap)<`T`\> |
855
862
  | `filter?` | [`Filter`](README.md#filter)<`T`\> |
856
863
  | `method` | ``"delete"`` |
864
+ | `multiple?` | ``false`` |
857
865
 
858
866
  #### Defined in
859
867
 
860
- [lib/types/QueryDelete.ts:7](https://github.com/nevoland/quetch/blob/f8fb38a/lib/types/QueryDelete.ts#L7)
868
+ [lib/types/QueryDelete.ts:7](https://github.com/nevoland/quetch/blob/c839ceb/lib/types/QueryDelete.ts#L7)
861
869
 
862
870
  ___
863
871
 
@@ -884,7 +892,7 @@ Query for deleting multiple items.
884
892
 
885
893
  #### Defined in
886
894
 
887
- [lib/types/QueryDeleteMultiple.ts:7](https://github.com/nevoland/quetch/blob/f8fb38a/lib/types/QueryDeleteMultiple.ts#L7)
895
+ [lib/types/QueryDeleteMultiple.ts:7](https://github.com/nevoland/quetch/blob/c839ceb/lib/types/QueryDeleteMultiple.ts#L7)
888
896
 
889
897
  ___
890
898
 
@@ -896,7 +904,7 @@ Available query methods.
896
904
 
897
905
  #### Defined in
898
906
 
899
- [lib/types/QueryMethod.ts:6](https://github.com/nevoland/quetch/blob/f8fb38a/lib/types/QueryMethod.ts#L6)
907
+ [lib/types/QueryMethod.ts:6](https://github.com/nevoland/quetch/blob/c839ceb/lib/types/QueryMethod.ts#L6)
900
908
 
901
909
  ___
902
910
 
@@ -926,7 +934,7 @@ Query for reading a single item.
926
934
 
927
935
  #### Defined in
928
936
 
929
- [lib/types/QueryRead.ts:7](https://github.com/nevoland/quetch/blob/f8fb38a/lib/types/QueryRead.ts#L7)
937
+ [lib/types/QueryRead.ts:7](https://github.com/nevoland/quetch/blob/c839ceb/lib/types/QueryRead.ts#L7)
930
938
 
931
939
  ___
932
940
 
@@ -957,7 +965,7 @@ Query for getting a list of items.
957
965
 
958
966
  #### Defined in
959
967
 
960
- [lib/types/QueryReadMultiple.ts:8](https://github.com/nevoland/quetch/blob/f8fb38a/lib/types/QueryReadMultiple.ts#L8)
968
+ [lib/types/QueryReadMultiple.ts:8](https://github.com/nevoland/quetch/blob/c839ceb/lib/types/QueryReadMultiple.ts#L8)
961
969
 
962
970
  ___
963
971
 
@@ -980,13 +988,14 @@ Query for updating an item.
980
988
  | `filter?` | [`Filter`](README.md#filter)<`T`\> | Filter for finding the item, if it cannot be found based on the `context`. |
981
989
  | `group?` | `never` | - |
982
990
  | `method` | ``"update"`` | - |
991
+ | `multiple?` | ``false`` | - |
983
992
  | `offset?` | `never` | - |
984
993
  | `order` | `never` | - |
985
994
  | `value` | `Partial`<`T`\> | Partial property values to update. |
986
995
 
987
996
  #### Defined in
988
997
 
989
- [lib/types/QueryUpdate.ts:6](https://github.com/nevoland/quetch/blob/f8fb38a/lib/types/QueryUpdate.ts#L6)
998
+ [lib/types/QueryUpdate.ts:6](https://github.com/nevoland/quetch/blob/c839ceb/lib/types/QueryUpdate.ts#L6)
990
999
 
991
1000
  ___
992
1001
 
@@ -1016,7 +1025,7 @@ Query for updating multiple items.
1016
1025
 
1017
1026
  #### Defined in
1018
1027
 
1019
- [lib/types/QueryUpdateMultiple.ts:7](https://github.com/nevoland/quetch/blob/f8fb38a/lib/types/QueryUpdateMultiple.ts#L7)
1028
+ [lib/types/QueryUpdateMultiple.ts:7](https://github.com/nevoland/quetch/blob/c839ceb/lib/types/QueryUpdateMultiple.ts#L7)
1020
1029
 
1021
1030
  ___
1022
1031
 
@@ -1035,7 +1044,7 @@ ___
1035
1044
 
1036
1045
  #### Defined in
1037
1046
 
1038
- [lib/types/Result.ts:25](https://github.com/nevoland/quetch/blob/f8fb38a/lib/types/Result.ts#L25)
1047
+ [lib/types/Result.ts:25](https://github.com/nevoland/quetch/blob/c839ceb/lib/types/Result.ts#L25)
1039
1048
 
1040
1049
  ___
1041
1050
 
@@ -1060,7 +1069,7 @@ ___
1060
1069
 
1061
1070
  #### Defined in
1062
1071
 
1063
- [lib/types/Store.ts:2](https://github.com/nevoland/quetch/blob/f8fb38a/lib/types/Store.ts#L2)
1072
+ [lib/types/Store.ts:2](https://github.com/nevoland/quetch/blob/c839ceb/lib/types/Store.ts#L2)
1064
1073
 
1065
1074
  ## Functions
1066
1075
 
@@ -1101,7 +1110,7 @@ If a query occurs twice, `mergeQuery(query, currentQuery)` is called and the out
1101
1110
 
1102
1111
  #### Defined in
1103
1112
 
1104
- [lib/middlewares/aggregate.ts:16](https://github.com/nevoland/quetch/blob/f8fb38a/lib/middlewares/aggregate.ts#L16)
1113
+ [lib/middlewares/aggregate.ts:16](https://github.com/nevoland/quetch/blob/c839ceb/lib/middlewares/aggregate.ts#L16)
1105
1114
 
1106
1115
  ___
1107
1116
 
@@ -1143,7 +1152,7 @@ const customFetch = combine(
1143
1152
 
1144
1153
  #### Defined in
1145
1154
 
1146
- [lib/middlewares/branch.ts:21](https://github.com/nevoland/quetch/blob/f8fb38a/lib/middlewares/branch.ts#L21)
1155
+ [lib/middlewares/branch.ts:21](https://github.com/nevoland/quetch/blob/c839ceb/lib/middlewares/branch.ts#L21)
1147
1156
 
1148
1157
  ___
1149
1158
 
@@ -1172,7 +1181,7 @@ ___
1172
1181
 
1173
1182
  #### Defined in
1174
1183
 
1175
- [lib/middlewares/cache.ts:39](https://github.com/nevoland/quetch/blob/f8fb38a/lib/middlewares/cache.ts#L39)
1184
+ [lib/middlewares/cache.ts:39](https://github.com/nevoland/quetch/blob/c839ceb/lib/middlewares/cache.ts#L39)
1176
1185
 
1177
1186
  ___
1178
1187
 
@@ -1245,7 +1254,7 @@ Handler that combines all provided handlers.
1245
1254
 
1246
1255
  #### Defined in
1247
1256
 
1248
- [lib/middlewares/combine.ts:801](https://github.com/nevoland/quetch/blob/f8fb38a/lib/middlewares/combine.ts#L801)
1257
+ [lib/middlewares/combine.ts:801](https://github.com/nevoland/quetch/blob/c839ceb/lib/middlewares/combine.ts#L801)
1249
1258
 
1250
1259
  ___
1251
1260
 
@@ -1267,7 +1276,7 @@ Uncallable handler used to terminate a sequence of handlers combined with `combi
1267
1276
 
1268
1277
  #### Defined in
1269
1278
 
1270
- [lib/types/NextHandler.ts:4](https://github.com/nevoland/quetch/blob/f8fb38a/lib/types/NextHandler.ts#L4)
1279
+ [lib/types/NextHandler.ts:4](https://github.com/nevoland/quetch/blob/c839ceb/lib/types/NextHandler.ts#L4)
1271
1280
 
1272
1281
  ___
1273
1282
 
@@ -1332,7 +1341,7 @@ typeof `query`
1332
1341
 
1333
1342
  #### Defined in
1334
1343
 
1335
- [lib/tools/defineCheckQuery.ts:8](https://github.com/nevoland/quetch/blob/f8fb38a/lib/tools/defineCheckQuery.ts#L8)
1344
+ [lib/tools/defineCheckQuery.ts:8](https://github.com/nevoland/quetch/blob/c839ceb/lib/tools/defineCheckQuery.ts#L8)
1336
1345
 
1337
1346
  ___
1338
1347
 
@@ -1439,7 +1448,7 @@ ___
1439
1448
 
1440
1449
  #### Defined in
1441
1450
 
1442
- [lib/tools/defineCustomFetch.ts:11](https://github.com/nevoland/quetch/blob/f8fb38a/lib/tools/defineCustomFetch.ts#L11)
1451
+ [lib/tools/defineCustomFetch.ts:11](https://github.com/nevoland/quetch/blob/c839ceb/lib/tools/defineCustomFetch.ts#L11)
1443
1452
 
1444
1453
  ___
1445
1454
 
@@ -1514,7 +1523,7 @@ ___
1514
1523
 
1515
1524
  #### Defined in
1516
1525
 
1517
- [lib/tools/defineGenericFetch.ts:5](https://github.com/nevoland/quetch/blob/f8fb38a/lib/tools/defineGenericFetch.ts#L5)
1526
+ [lib/tools/defineGenericFetch.ts:5](https://github.com/nevoland/quetch/blob/c839ceb/lib/tools/defineGenericFetch.ts#L5)
1518
1527
 
1519
1528
  ___
1520
1529
 
@@ -1538,7 +1547,7 @@ Handler that returns a promise that resolves to the response.
1538
1547
 
1539
1548
  #### Defined in
1540
1549
 
1541
- [lib/middlewares/fetchExternal.ts:12](https://github.com/nevoland/quetch/blob/f8fb38a/lib/middlewares/fetchExternal.ts#L12)
1550
+ [lib/middlewares/fetchExternal.ts:12](https://github.com/nevoland/quetch/blob/c839ceb/lib/middlewares/fetchExternal.ts#L12)
1542
1551
 
1543
1552
  ___
1544
1553
 
@@ -1563,7 +1572,7 @@ Promise that resolves to the response.
1563
1572
 
1564
1573
  #### Defined in
1565
1574
 
1566
- [lib/middlewares/fetchLocal.ts:9](https://github.com/nevoland/quetch/blob/f8fb38a/lib/middlewares/fetchLocal.ts#L9)
1575
+ [lib/middlewares/fetchLocal.ts:9](https://github.com/nevoland/quetch/blob/c839ceb/lib/middlewares/fetchLocal.ts#L9)
1567
1576
 
1568
1577
  ___
1569
1578
 
@@ -1589,7 +1598,7 @@ ___
1589
1598
 
1590
1599
  #### Defined in
1591
1600
 
1592
- [lib/tools/filterFromContext.ts:5](https://github.com/nevoland/quetch/blob/f8fb38a/lib/tools/filterFromContext.ts#L5)
1601
+ [lib/tools/filterFromContext.ts:5](https://github.com/nevoland/quetch/blob/c839ceb/lib/tools/filterFromContext.ts#L5)
1593
1602
 
1594
1603
  ___
1595
1604
 
@@ -1620,7 +1629,7 @@ Checks wether the provided `value` matches the `filter` or not.
1620
1629
 
1621
1630
  #### Defined in
1622
1631
 
1623
- [lib/tools/filterItem.ts:12](https://github.com/nevoland/quetch/blob/f8fb38a/lib/tools/filterItem.ts#L12)
1632
+ [lib/tools/filterItem.ts:12](https://github.com/nevoland/quetch/blob/c839ceb/lib/tools/filterItem.ts#L12)
1624
1633
 
1625
1634
  ___
1626
1635
 
@@ -1650,7 +1659,7 @@ ___
1650
1659
 
1651
1660
  #### Defined in
1652
1661
 
1653
- [lib/middlewares/identity.ts:3](https://github.com/nevoland/quetch/blob/f8fb38a/lib/middlewares/identity.ts#L3)
1662
+ [lib/middlewares/identity.ts:3](https://github.com/nevoland/quetch/blob/c839ceb/lib/middlewares/identity.ts#L3)
1654
1663
 
1655
1664
  ___
1656
1665
 
@@ -1683,7 +1692,7 @@ Query handler
1683
1692
 
1684
1693
  #### Defined in
1685
1694
 
1686
- [lib/middlewares/log.ts:11](https://github.com/nevoland/quetch/blob/f8fb38a/lib/middlewares/log.ts#L11)
1695
+ [lib/middlewares/log.ts:11](https://github.com/nevoland/quetch/blob/c839ceb/lib/middlewares/log.ts#L11)
1687
1696
 
1688
1697
  ___
1689
1698
 
@@ -1714,7 +1723,7 @@ ___
1714
1723
 
1715
1724
  #### Defined in
1716
1725
 
1717
- [lib/tools/normalizeOrder.ts:3](https://github.com/nevoland/quetch/blob/f8fb38a/lib/tools/normalizeOrder.ts#L3)
1726
+ [lib/tools/normalizeOrder.ts:3](https://github.com/nevoland/quetch/blob/c839ceb/lib/tools/normalizeOrder.ts#L3)
1718
1727
 
1719
1728
  ___
1720
1729
 
@@ -1741,7 +1750,7 @@ ___
1741
1750
 
1742
1751
  #### Defined in
1743
1752
 
1744
- [lib/tools/queryItemList.ts:41](https://github.com/nevoland/quetch/blob/f8fb38a/lib/tools/queryItemList.ts#L41)
1753
+ [lib/tools/queryItemList.ts:41](https://github.com/nevoland/quetch/blob/c839ceb/lib/tools/queryItemList.ts#L41)
1745
1754
 
1746
1755
  ___
1747
1756
 
@@ -1770,7 +1779,7 @@ Handler
1770
1779
 
1771
1780
  #### Defined in
1772
1781
 
1773
- [lib/middlewares/retry.ts:15](https://github.com/nevoland/quetch/blob/f8fb38a/lib/middlewares/retry.ts#L15)
1782
+ [lib/middlewares/retry.ts:15](https://github.com/nevoland/quetch/blob/c839ceb/lib/middlewares/retry.ts#L15)
1774
1783
 
1775
1784
  ___
1776
1785
 
@@ -1801,4 +1810,4 @@ The same array sorted in place.
1801
1810
 
1802
1811
  #### Defined in
1803
1812
 
1804
- [lib/tools/sortItemList.ts:12](https://github.com/nevoland/quetch/blob/f8fb38a/lib/tools/sortItemList.ts#L12)
1813
+ [lib/tools/sortItemList.ts:12](https://github.com/nevoland/quetch/blob/c839ceb/lib/tools/sortItemList.ts#L12)
@@ -0,0 +1,60 @@
1
+ [quetch](../README.md) / GenericFetch
2
+
3
+ # Interface: GenericFetch<T\>
4
+
5
+ ## Type parameters
6
+
7
+ | Name | Type |
8
+ | :------ | :------ |
9
+ | `T` | extends `object` |
10
+
11
+ ## Callable
12
+
13
+ ### GenericFetch
14
+
15
+ ▸ **GenericFetch**<`Q`\>(`query`): `Promise`<[`Result`](../README.md#result)<`T`, `Q`, {}, { readonly [K in string \| number \| symbol]: K extends keyof T ? T[K] : K extends never ? Object[K] extends FieldFunctionCustom<T\> ? ReturnType<Object[K]["value"]\> : Object[K]["operator"] extends "formatDate" ? FieldFunctionReturn[Object[K]["operator"]] : never : never }\>\>
16
+
17
+ #### Type parameters
18
+
19
+ | Name | Type |
20
+ | :------ | :------ |
21
+ | `Q` | extends [`Query`](../README.md#query)<`T`, {}\> |
22
+
23
+ #### Parameters
24
+
25
+ | Name | Type |
26
+ | :------ | :------ |
27
+ | `query` | `Q` & { `customFields?`: `undefined` } |
28
+
29
+ #### Returns
30
+
31
+ `Promise`<[`Result`](../README.md#result)<`T`, `Q`, {}, { readonly [K in string \| number \| symbol]: K extends keyof T ? T[K] : K extends never ? Object[K] extends FieldFunctionCustom<T\> ? ReturnType<Object[K]["value"]\> : Object[K]["operator"] extends "formatDate" ? FieldFunctionReturn[Object[K]["operator"]] : never : never }\>\>
32
+
33
+ #### Defined in
34
+
35
+ [lib/types/GenericFetch.ts:6](https://github.com/nevoland/quetch/blob/c839ceb/lib/types/GenericFetch.ts#L6)
36
+
37
+ ### GenericFetch
38
+
39
+ ▸ **GenericFetch**<`Q`, `C`\>(`query`): `Promise`<[`Result`](../README.md#result)<`T`, `Q`, `C`, [`InjectCustomFields`](../README.md#injectcustomfields)<`T`, `C`\>\>\>
40
+
41
+ #### Type parameters
42
+
43
+ | Name | Type |
44
+ | :------ | :------ |
45
+ | `Q` | extends [`Query`](../README.md#query)<`T`, `C`\> |
46
+ | `C` | extends [`CustomFieldMap`](../README.md#customfieldmap)<`T`\> |
47
+
48
+ #### Parameters
49
+
50
+ | Name | Type |
51
+ | :------ | :------ |
52
+ | `query` | `Q` & { `customFields`: `C` } |
53
+
54
+ #### Returns
55
+
56
+ `Promise`<[`Result`](../README.md#result)<`T`, `Q`, `C`, [`InjectCustomFields`](../README.md#injectcustomfields)<`T`, `C`\>\>\>
57
+
58
+ #### Defined in
59
+
60
+ [lib/types/GenericFetch.ts:9](https://github.com/nevoland/quetch/blob/c839ceb/lib/types/GenericFetch.ts#L9)
@@ -0,0 +1,12 @@
1
+ import type { CustomFieldMap } from "./CustomFieldMap";
2
+ import type { Query } from "./Query";
3
+ import type { Result } from "./Result";
4
+
5
+ export interface GenericFetch<T extends object> {
6
+ <Q extends Query<T, {}>>(
7
+ query: Q & { customFields?: never },
8
+ ): Promise<Result<T, Q, {}>>;
9
+ <Q extends Query<T, C>, C extends CustomFieldMap<T>>(
10
+ query: Q & { customFields: C },
11
+ ): Promise<Result<T, Q, C>>;
12
+ }
@@ -26,9 +26,26 @@ type QueryBase<T extends object> =
26
26
  * Query that fetches or mutates an entity.
27
27
  */
28
28
  export type Query<
29
+ /**
30
+ * Type.
31
+ */
29
32
  T extends object,
33
+ /**
34
+ * Custom fields.
35
+ */
30
36
  C extends CustomFieldMap<T> | undefined,
31
- > = QueryBase<InjectCustomFields<T, C>> & {
37
+ /**
38
+ * Methods.
39
+ */
40
+ M extends QueryBase<never>["method"] = QueryBase<never>["method"],
41
+ /**
42
+ * Multiple.
43
+ */
44
+ L extends boolean | undefined = boolean,
45
+ > = Extract<
46
+ QueryBase<InjectCustomFields<T, C>>,
47
+ { method?: M; multiple?: L }
48
+ > & {
32
49
  /**
33
50
  * Common item properties to use for identifying the item.
34
51
  */
@@ -3,5 +3,6 @@
3
3
  */
4
4
  export type QueryCreate<T extends object> = {
5
5
  method: "create";
6
+ multiple?: false;
6
7
  value: Partial<T>;
7
8
  };
@@ -6,6 +6,7 @@ import type { Filter } from "./Filter";
6
6
  */
7
7
  export type QueryDelete<T extends object> = {
8
8
  method: "delete";
9
+ multiple?: false;
9
10
  filter?: Filter<T>;
10
11
  customFields?: CustomFieldMap<T>;
11
12
  };
@@ -5,6 +5,7 @@ import type { Filter } from "./Filter";
5
5
  */
6
6
  export type QueryUpdate<T extends object> = {
7
7
  method: "update";
8
+ multiple?: false;
8
9
  /**
9
10
  * Partial property values to update.
10
11
  */
package/lib/types.ts CHANGED
@@ -21,6 +21,7 @@ export type { FilterSequence } from "./types/FilterSequence";
21
21
  export type { FilterString } from "./types/FilterString";
22
22
  export type { FilterStringIntersect } from "./types/FilterStringIntersect";
23
23
  export type { FilterStringMatch } from "./types/FilterStringMatch";
24
+ export type { GenericFetch } from "./types/GenericFetch";
24
25
  export type { Get } from "./types/Get";
25
26
  export type { Group } from "./types/Group";
26
27
  export type { Handler } from "./types/Handler";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "quetch",
3
- "version": "0.3.0",
3
+ "version": "0.5.0",
4
4
  "type": "module",
5
5
  "main": "./dist/main.js",
6
6
  "exports": {