quetch 0.2.1 → 0.4.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/dist/errors/RequestError.d.ts +3 -3
- package/dist/errors.d.ts +1 -1
- package/dist/errors.js +1 -1
- package/dist/errors.js.map +1 -1
- package/dist/middlewares/aggregate.d.ts +3 -3
- package/dist/middlewares/aggregate.js +1 -1
- package/dist/middlewares/aggregate.js.map +1 -1
- package/dist/middlewares/cache.d.ts +4 -4
- package/dist/middlewares/cache.js +3 -3
- package/dist/middlewares/cache.js.map +1 -1
- package/dist/middlewares.d.ts +9 -9
- package/dist/middlewares.js +9 -9
- package/dist/middlewares.js.map +1 -1
- package/dist/tools/cork.d.ts +5 -0
- package/dist/tools/cork.js +5 -0
- package/dist/tools/cork.js.map +1 -0
- package/dist/tools/defineCheckQuery.d.ts +12 -7
- package/dist/tools/defineCheckQuery.js +5 -0
- package/dist/tools/defineCheckQuery.js.map +1 -1
- package/dist/tools/defineCustomFetch.d.ts +26 -18
- package/dist/tools/defineCustomFetch.js +9 -3
- package/dist/tools/defineCustomFetch.js.map +1 -1
- package/dist/tools/defineGenericFetch.d.ts +14 -0
- package/dist/tools/defineGenericFetch.js +12 -0
- package/dist/tools/defineGenericFetch.js.map +1 -0
- package/dist/tools/queryItemList.js +3 -3
- package/dist/tools/queryItemList.js.map +1 -1
- package/dist/tools/sortItemList.js +3 -3
- package/dist/tools/sortItemList.js.map +1 -1
- package/dist/tools.d.ts +9 -8
- package/dist/tools.js +9 -8
- package/dist/tools.js.map +1 -1
- package/dist/types/AggregateFunction.d.ts +9 -0
- package/dist/types/AggregateFunction.js +2 -0
- package/dist/types/AggregateFunction.js.map +1 -0
- package/dist/types/AggregateFunctionOperator.d.ts +2 -0
- package/dist/types/AggregateFunctionOperator.js +2 -0
- package/dist/types/AggregateFunctionOperator.js.map +1 -0
- package/dist/types/Any.d.ts +1 -0
- package/dist/types/Any.js +2 -0
- package/dist/types/Any.js.map +1 -0
- package/dist/types/Context.d.ts +3 -0
- package/dist/types/Context.js +2 -0
- package/dist/types/Context.js.map +1 -0
- package/dist/types/CustomFieldAggregateMap.d.ts +2 -0
- package/dist/types/CustomFieldAggregateMap.js +2 -0
- package/dist/types/CustomFieldAggregateMap.js.map +1 -0
- package/dist/types/CustomFieldMap.d.ts +2 -0
- package/dist/types/CustomFieldMap.js +2 -0
- package/dist/types/CustomFieldMap.js.map +1 -0
- package/dist/types/CustomRequest.d.ts +16 -0
- package/dist/types/CustomRequest.js +2 -0
- package/dist/types/CustomRequest.js.map +1 -0
- package/dist/types/FieldFunction.d.ts +3 -0
- package/dist/types/FieldFunction.js +2 -0
- package/dist/types/FieldFunction.js.map +1 -0
- package/dist/types/FieldFunctionCustom.d.ts +7 -0
- package/dist/types/FieldFunctionCustom.js +2 -0
- package/dist/types/FieldFunctionCustom.js.map +1 -0
- package/dist/types/FieldFunctionFormatDate.d.ts +9 -0
- package/dist/types/FieldFunctionFormatDate.js +2 -0
- package/dist/types/FieldFunctionFormatDate.js.map +1 -0
- package/dist/types/FieldFunctionReturn.d.ts +6 -0
- package/dist/types/FieldFunctionReturn.js +2 -0
- package/dist/types/FieldFunctionReturn.js.map +1 -0
- package/dist/types/Filter.d.ts +12 -0
- package/dist/types/Filter.js +2 -0
- package/dist/types/Filter.js.map +1 -0
- package/dist/types/FilterArray.d.ts +10 -0
- package/dist/types/FilterArray.js +2 -0
- package/dist/types/FilterArray.js.map +1 -0
- package/dist/types/FilterBoolean.d.ts +9 -0
- package/dist/types/FilterBoolean.js +2 -0
- package/dist/types/FilterBoolean.js.map +1 -0
- package/dist/types/FilterField.d.ts +7 -0
- package/dist/types/FilterField.js +2 -0
- package/dist/types/FilterField.js.map +1 -0
- package/dist/types/FilterKeys.d.ts +6 -0
- package/dist/types/FilterKeys.js +2 -0
- package/dist/types/FilterKeys.js.map +1 -0
- package/dist/types/FilterNumber.d.ts +9 -0
- package/dist/types/FilterNumber.js +2 -0
- package/dist/types/FilterNumber.js.map +1 -0
- package/dist/types/FilterOperator.d.ts +2 -0
- package/dist/types/FilterOperator.js +2 -0
- package/dist/types/FilterOperator.js.map +1 -0
- package/dist/types/FilterSequence.d.ts +23 -0
- package/dist/types/FilterSequence.js +2 -0
- package/dist/types/FilterSequence.js.map +1 -0
- package/dist/types/FilterString.d.ts +9 -0
- package/dist/types/FilterString.js +2 -0
- package/dist/types/FilterString.js.map +1 -0
- package/dist/types/FilterStringIntersect.d.ts +9 -0
- package/dist/types/FilterStringIntersect.js +2 -0
- package/dist/types/FilterStringIntersect.js.map +1 -0
- package/dist/types/FilterStringMatch.d.ts +29 -0
- package/dist/types/FilterStringMatch.js +2 -0
- package/dist/types/FilterStringMatch.js.map +1 -0
- package/dist/types/GenericFetch.d.ts +11 -0
- package/dist/types/GenericFetch.js +2 -0
- package/dist/types/GenericFetch.js.map +1 -0
- package/dist/types/Get.d.ts +6 -0
- package/dist/types/Get.js +2 -0
- package/dist/types/Get.js.map +1 -0
- package/dist/types/Group.d.ts +8 -0
- package/dist/types/Group.js +2 -0
- package/dist/types/Group.js.map +1 -0
- package/dist/types/Handler.d.ts +5 -0
- package/dist/types/Handler.js +2 -0
- package/dist/types/Handler.js.map +1 -0
- package/dist/types/Immutable.d.ts +3 -0
- package/dist/types/Immutable.js +2 -0
- package/dist/types/Immutable.js.map +1 -0
- package/dist/types/InjectCustomFields.d.ts +9 -0
- package/dist/types/InjectCustomFields.js +2 -0
- package/dist/types/InjectCustomFields.js.map +1 -0
- package/dist/types/Item.d.ts +4 -0
- package/dist/types/Item.js +2 -0
- package/dist/types/Item.js.map +1 -0
- package/dist/types/Key.d.ts +1 -0
- package/dist/types/Key.js +2 -0
- package/dist/types/Key.js.map +1 -0
- package/dist/types/Mutable.d.ts +3 -0
- package/dist/types/Mutable.js +2 -0
- package/dist/types/Mutable.js.map +1 -0
- package/dist/types/NextHandler.d.ts +4 -0
- package/dist/types/NextHandler.js +2 -0
- package/dist/types/NextHandler.js.map +1 -0
- package/dist/types/Order.d.ts +7 -0
- package/dist/types/Order.js +2 -0
- package/dist/types/Order.js.map +1 -0
- package/dist/types/Query.d.ts +23 -0
- package/dist/types/Query.js +2 -0
- package/dist/types/Query.js.map +1 -0
- package/dist/types/QueryAggregate.d.ts +10 -0
- package/dist/types/QueryAggregate.js +2 -0
- package/dist/types/QueryAggregate.js.map +1 -0
- package/dist/types/QueryAny.d.ts +7 -0
- package/dist/types/QueryAny.js +2 -0
- package/dist/types/QueryAny.js.map +1 -0
- package/dist/types/QueryCreate.d.ts +7 -0
- package/dist/types/QueryCreate.js +2 -0
- package/dist/types/QueryCreate.js.map +1 -0
- package/dist/types/QueryCreateMultiple.d.ts +8 -0
- package/dist/types/QueryCreateMultiple.js +2 -0
- package/dist/types/QueryCreateMultiple.js.map +1 -0
- package/dist/types/QueryDelete.d.ts +10 -0
- package/dist/types/QueryDelete.js +2 -0
- package/dist/types/QueryDelete.js.map +1 -0
- package/dist/types/QueryDeleteMultiple.d.ts +11 -0
- package/dist/types/QueryDeleteMultiple.js +2 -0
- package/dist/types/QueryDeleteMultiple.js.map +1 -0
- package/dist/types/QueryMethod.d.ts +5 -0
- package/dist/types/QueryMethod.js +2 -0
- package/dist/types/QueryMethod.js.map +1 -0
- package/dist/types/QueryRead.d.ts +23 -0
- package/dist/types/QueryRead.js +2 -0
- package/dist/types/QueryRead.js.map +1 -0
- package/dist/types/QueryReadMultiple.d.ts +34 -0
- package/dist/types/QueryReadMultiple.js +2 -0
- package/dist/types/QueryReadMultiple.js.map +1 -0
- package/dist/types/QueryUpdate.d.ts +18 -0
- package/dist/types/QueryUpdate.js +2 -0
- package/dist/types/QueryUpdate.js.map +1 -0
- package/dist/types/QueryUpdateMultiple.d.ts +26 -0
- package/dist/types/QueryUpdateMultiple.js +2 -0
- package/dist/types/QueryUpdateMultiple.js.map +1 -0
- package/dist/types/Result.d.ts +25 -0
- package/dist/types/Result.js +2 -0
- package/dist/types/Result.js.map +1 -0
- package/dist/types/Store.d.ts +6 -0
- package/dist/types/Store.js +2 -0
- package/dist/types/Store.js.map +1 -0
- package/dist/types.d.ts +47 -396
- package/doc/README.md +537 -219
- package/doc/interfaces/GenericFetch.md +60 -0
- package/lib/errors/RequestError.ts +2 -2
- package/lib/errors.ts +1 -1
- package/lib/middlewares/aggregate.ts +5 -5
- package/lib/middlewares/cache.ts +7 -12
- package/lib/middlewares.ts +9 -9
- package/lib/tools/cork.ts +6 -0
- package/lib/tools/defineCheckQuery.ts +20 -15
- package/lib/tools/defineCustomFetch.ts +40 -62
- package/lib/tools/defineGenericFetch.ts +33 -0
- package/lib/tools/queryItemList.test.ts +6 -6
- package/lib/tools/queryItemList.ts +3 -3
- package/lib/tools/sortItemList.ts +3 -3
- package/lib/tools.ts +9 -8
- package/lib/types/AggregateFunction.ts +17 -0
- package/lib/types/AggregateFunctionOperator.ts +6 -0
- package/lib/types/Any.ts +10 -0
- package/lib/types/Context.ts +3 -0
- package/lib/types/CustomFieldAggregateMap.ts +6 -0
- package/lib/types/CustomFieldMap.ts +3 -0
- package/lib/types/CustomRequest.ts +21 -0
- package/lib/types/FieldFunction.ts +6 -0
- package/lib/types/FieldFunctionCustom.ts +7 -0
- package/lib/types/FieldFunctionFormatDate.ts +10 -0
- package/lib/types/FieldFunctionReturn.ts +6 -0
- package/lib/types/Filter.ts +20 -0
- package/lib/types/FilterArray.ts +11 -0
- package/lib/types/FilterBoolean.ts +10 -0
- package/lib/types/FilterField.ts +7 -0
- package/lib/types/FilterKeys.ts +6 -0
- package/lib/types/FilterNumber.ts +16 -0
- package/lib/types/FilterOperator.ts +3 -0
- package/lib/types/FilterSequence.ts +26 -0
- package/lib/types/FilterString.ts +19 -0
- package/lib/types/FilterStringIntersect.ts +10 -0
- package/lib/types/FilterStringMatch.ts +30 -0
- package/lib/types/GenericFetch.ts +12 -0
- package/lib/types/Get.ts +8 -0
- package/lib/types/Group.ts +11 -0
- package/lib/types/Handler.ts +9 -0
- package/lib/types/Immutable.ts +3 -0
- package/lib/types/InjectCustomFields.ts +23 -0
- package/lib/types/Item.ts +8 -0
- package/lib/types/Key.ts +1 -0
- package/lib/types/Mutable.ts +3 -0
- package/lib/types/NextHandler.ts +4 -0
- package/lib/types/Order.ts +9 -0
- package/lib/types/Query.ts +36 -0
- package/lib/types/QueryAggregate.ts +11 -0
- package/lib/types/QueryAny.ts +8 -0
- package/lib/types/QueryCreate.ts +7 -0
- package/lib/types/QueryCreateMultiple.ts +8 -0
- package/lib/types/QueryDelete.ts +11 -0
- package/lib/types/QueryDeleteMultiple.ts +12 -0
- package/lib/types/QueryMethod.ts +6 -0
- package/lib/types/QueryRead.ts +24 -0
- package/lib/types/QueryReadMultiple.ts +36 -0
- package/lib/types/QueryUpdate.ts +19 -0
- package/lib/types/QueryUpdateMultiple.ts +27 -0
- package/lib/types/Result.ts +38 -0
- package/lib/types/Store.ts +7 -0
- package/lib/types.ts +48 -562
- package/package.json +3 -3
- package/dist/errors/QueryError.d.ts +0 -5
- package/dist/errors/QueryError.js +0 -23
- package/dist/errors/QueryError.js.map +0 -1
- package/dist/middlewares/concurrent.d.ts +0 -2
- package/dist/middlewares/concurrent.js +0 -20
- package/dist/middlewares/concurrent.js.map +0 -1
- package/dist/middlewares/fetch.d.ts +0 -2
- package/dist/middlewares/fetch.js +0 -20
- package/dist/middlewares/fetch.js.map +0 -1
- package/dist/middlewares/logQuery.d.ts +0 -2
- package/dist/middlewares/logQuery.js +0 -25
- package/dist/middlewares/logQuery.js.map +0 -1
- package/dist/tools/add.d.ts +0 -8
- package/dist/tools/add.js +0 -11
- package/dist/tools/add.js.map +0 -1
- package/dist/tools/add.test.d.ts +0 -1
- package/dist/tools/add.test.js +0 -6
- package/dist/tools/add.test.js.map +0 -1
- package/dist/tools/filterItem.test.d.ts +0 -1
- package/dist/tools/filterItem.test.js +0 -86
- package/dist/tools/filterItem.test.js.map +0 -1
- package/dist/tools/impasse.d.ts +0 -2
- package/dist/tools/impasse.js +0 -2
- package/dist/tools/impasse.js.map +0 -1
- package/dist/tools/queryItemList.test.d.ts +0 -1
- package/dist/tools/queryItemList.test.js +0 -181
- package/dist/tools/queryItemList.test.js.map +0 -1
- package/dist/tools/sortItemList.test.d.ts +0 -1
- package/dist/tools/sortItemList.test.js +0 -47
- package/dist/tools/sortItemList.test.js.map +0 -1
- package/lib/tools/impasse.ts +0 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"QueryRead.js","sourceRoot":"","sources":["../../lib/types/QueryRead.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { Filter } from "./Filter";
|
|
2
|
+
import type { Group } from "./Group";
|
|
3
|
+
import type { Order } from "./Order";
|
|
4
|
+
/**
|
|
5
|
+
* Query for getting a list of items.
|
|
6
|
+
*/
|
|
7
|
+
export type QueryReadMultiple<T extends object> = {
|
|
8
|
+
method?: "read";
|
|
9
|
+
multiple: true;
|
|
10
|
+
/**
|
|
11
|
+
* Offset of the first matching item.
|
|
12
|
+
*/
|
|
13
|
+
offset?: number;
|
|
14
|
+
/**
|
|
15
|
+
* Upper bound of the number of items to return.
|
|
16
|
+
*/
|
|
17
|
+
limit?: number;
|
|
18
|
+
/**
|
|
19
|
+
* Item fields to pick. If omitted, all fields are picked.
|
|
20
|
+
*/
|
|
21
|
+
fields?: readonly (keyof T)[];
|
|
22
|
+
/**
|
|
23
|
+
* Filter that picks the items.
|
|
24
|
+
*/
|
|
25
|
+
filter?: Filter<T>;
|
|
26
|
+
/**
|
|
27
|
+
* Order by which the items should be sorted.
|
|
28
|
+
*/
|
|
29
|
+
order?: Order<T>[];
|
|
30
|
+
/**
|
|
31
|
+
* Groups items by specified fields.
|
|
32
|
+
*/
|
|
33
|
+
group?: Group<T>[];
|
|
34
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"QueryReadMultiple.js","sourceRoot":"","sources":["../../lib/types/QueryReadMultiple.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Filter } from "./Filter";
|
|
2
|
+
/**
|
|
3
|
+
* Query for updating an item.
|
|
4
|
+
*/
|
|
5
|
+
export type QueryUpdate<T extends object> = {
|
|
6
|
+
method: "update";
|
|
7
|
+
/**
|
|
8
|
+
* Partial property values to update.
|
|
9
|
+
*/
|
|
10
|
+
value: Partial<T>;
|
|
11
|
+
/**
|
|
12
|
+
* Filter for finding the item, if it cannot be found based on the `context`.
|
|
13
|
+
*/
|
|
14
|
+
filter?: Filter<T>;
|
|
15
|
+
offset?: never;
|
|
16
|
+
order: never;
|
|
17
|
+
group?: never;
|
|
18
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"QueryUpdate.js","sourceRoot":"","sources":["../../lib/types/QueryUpdate.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Filter } from "./Filter";
|
|
2
|
+
import type { Order } from "./Order";
|
|
3
|
+
/**
|
|
4
|
+
* Query for updating multiple items.
|
|
5
|
+
*/
|
|
6
|
+
export type QueryUpdateMultiple<T extends object> = {
|
|
7
|
+
method: "update";
|
|
8
|
+
multiple: true;
|
|
9
|
+
/**
|
|
10
|
+
* Partial property values to update.
|
|
11
|
+
*/
|
|
12
|
+
value: Partial<T>[];
|
|
13
|
+
filter?: Filter<T>;
|
|
14
|
+
/**
|
|
15
|
+
* Order by which the items should be sorted.
|
|
16
|
+
*/
|
|
17
|
+
order?: Order<T>[];
|
|
18
|
+
/**
|
|
19
|
+
* Offset of the first matching item to update.
|
|
20
|
+
*/
|
|
21
|
+
offset?: number;
|
|
22
|
+
/**
|
|
23
|
+
* Sets the upper bound of the number of items to update.
|
|
24
|
+
*/
|
|
25
|
+
limit?: number;
|
|
26
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"QueryUpdateMultiple.js","sourceRoot":"","sources":["../../lib/types/QueryUpdateMultiple.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { CustomFieldMap } from "./CustomFieldMap";
|
|
2
|
+
import type { InjectCustomFields } from "./InjectCustomFields";
|
|
3
|
+
import type { Item } from "./Item";
|
|
4
|
+
import type { Query } from "./Query";
|
|
5
|
+
export type PickFields<T extends object, F extends string | number | symbol> = [
|
|
6
|
+
F
|
|
7
|
+
] extends [keyof T] ? {
|
|
8
|
+
readonly [K in F]: T[K];
|
|
9
|
+
} : {
|
|
10
|
+
readonly [K in keyof T]: T[K];
|
|
11
|
+
};
|
|
12
|
+
export type ResultRead<T extends object, Q extends Query<T, C>, C extends CustomFieldMap<T>, U extends InjectCustomFields<T, C> = InjectCustomFields<T, C>> = [C] extends [CustomFieldMap<T>] ? [Q] extends [{
|
|
13
|
+
fields: (keyof U)[];
|
|
14
|
+
}] ? PickFields<U, Item<Q["fields"]>> : U : [Q] extends [{
|
|
15
|
+
fields: (keyof T)[];
|
|
16
|
+
}] ? PickFields<T, Item<Q["fields"]>> : T;
|
|
17
|
+
export type Result<T extends object, Q extends Query<T, C>, C extends CustomFieldMap<T>, U extends InjectCustomFields<T, C> = InjectCustomFields<T, C>> = [Q] extends [{
|
|
18
|
+
method: "read";
|
|
19
|
+
}] ? [Q] extends [{
|
|
20
|
+
multiple: true;
|
|
21
|
+
}] ? ResultRead<T, Q, C, U>[] : ResultRead<T, Q, C, U> : [Q] extends [{
|
|
22
|
+
method: "aggregate";
|
|
23
|
+
}] ? number : [Q] extends [{
|
|
24
|
+
multiple: true;
|
|
25
|
+
}] ? ResultRead<T, Q, C, U>[] : ResultRead<T, Q, C, U>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Result.js","sourceRoot":"","sources":["../../lib/types/Result.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Store.js","sourceRoot":"","sources":["../../lib/types/Store.ts"],"names":[],"mappings":""}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,396 +1,47 @@
|
|
|
1
|
-
export type
|
|
2
|
-
export type
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
export type
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
export type
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
type
|
|
20
|
-
type
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
export type
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
export type
|
|
37
|
-
export type
|
|
38
|
-
export type
|
|
39
|
-
|
|
40
|
-
};
|
|
41
|
-
export type
|
|
42
|
-
|
|
43
|
-
};
|
|
44
|
-
export type
|
|
45
|
-
|
|
46
|
-
};
|
|
47
|
-
export type
|
|
48
|
-
type: string | T[];
|
|
49
|
-
/**
|
|
50
|
-
* Common item properties to use for identifying the item.
|
|
51
|
-
*
|
|
52
|
-
* @example
|
|
53
|
-
* ```typescript
|
|
54
|
-
* { context: { id: "000001" } }
|
|
55
|
-
* { context: { organisation: "World Company" } }
|
|
56
|
-
* ```
|
|
57
|
-
*/
|
|
58
|
-
context?: Context<T>;
|
|
59
|
-
/**
|
|
60
|
-
* Abort signal to abort the request.
|
|
61
|
-
*/
|
|
62
|
-
signal?: AbortSignal;
|
|
63
|
-
};
|
|
64
|
-
/**
|
|
65
|
-
* Available query methods.
|
|
66
|
-
*/
|
|
67
|
-
export type QueryMethod = Exclude<Query<never, never>["method"], undefined>;
|
|
68
|
-
/**
|
|
69
|
-
* Injects the custom fields into the entity type.
|
|
70
|
-
*/
|
|
71
|
-
type InjectCustomField<T extends object, C extends CustomFieldMap<T>> = {
|
|
72
|
-
readonly [K in keyof T | keyof C]: K extends keyof T ? T[K] : K extends keyof C ? C[K] extends FieldFunctionCustom<T> ? ReturnType<C[K]["value"]> : C[K]["operator"] extends keyof FieldFunctionReturn ? FieldFunctionReturn[C[K]["operator"]] : never : never;
|
|
73
|
-
};
|
|
74
|
-
/**
|
|
75
|
-
* Query for getting a single item.
|
|
76
|
-
*/
|
|
77
|
-
export type QueryGet<T extends object, C extends CustomFieldMap<T>> = QueryBase<T> & {
|
|
78
|
-
method?: "get";
|
|
79
|
-
multiple?: false;
|
|
80
|
-
offset?: never;
|
|
81
|
-
orderBy?: never;
|
|
82
|
-
groupBy?: never;
|
|
83
|
-
} & ({
|
|
84
|
-
/**
|
|
85
|
-
* Item fields to pick. If omitted, all fields are picked.
|
|
86
|
-
*/
|
|
87
|
-
fields?: readonly (keyof InjectCustomField<T, C>)[];
|
|
88
|
-
/**
|
|
89
|
-
* Filter for finding the item, if it cannot be found based on the `context`.
|
|
90
|
-
*/
|
|
91
|
-
filter?: Filter<InjectCustomField<T, C>>;
|
|
92
|
-
/**
|
|
93
|
-
* Custom fields to add to each item, which can be used in the `filter`.
|
|
94
|
-
*/
|
|
95
|
-
customFields: C;
|
|
96
|
-
} | {
|
|
97
|
-
/**
|
|
98
|
-
* Item fields to pick. If omitted, all fields are picked.
|
|
99
|
-
*/
|
|
100
|
-
fields?: readonly (keyof T)[];
|
|
101
|
-
/**
|
|
102
|
-
* Filter for finding the item, if it cannot be found based on the `context`.
|
|
103
|
-
*/
|
|
104
|
-
filter?: Filter<T>;
|
|
105
|
-
customFields?: never;
|
|
106
|
-
});
|
|
107
|
-
/**
|
|
108
|
-
* Query for getting a list of items.
|
|
109
|
-
*/
|
|
110
|
-
export type QueryGetMultiple<T extends object, C extends CustomFieldMap<T>> = QueryBase<T> & {
|
|
111
|
-
method?: "get";
|
|
112
|
-
multiple: true;
|
|
113
|
-
/**
|
|
114
|
-
* Offset of the first matching item.
|
|
115
|
-
*/
|
|
116
|
-
offset?: number;
|
|
117
|
-
/**
|
|
118
|
-
* Upper bound of the number of items to return.
|
|
119
|
-
*/
|
|
120
|
-
limit?: number;
|
|
121
|
-
} & ({
|
|
122
|
-
/**
|
|
123
|
-
* Item fields to pick. If omitted, all fields are picked.
|
|
124
|
-
*/
|
|
125
|
-
fields?: readonly (keyof InjectCustomField<T, C>)[];
|
|
126
|
-
/**
|
|
127
|
-
* Filter that picks the items.
|
|
128
|
-
*/
|
|
129
|
-
filter?: Filter<InjectCustomField<T, C>>;
|
|
130
|
-
/**
|
|
131
|
-
* Custom fields to add to each item, which can be used in the `filter` and `groupBy`.
|
|
132
|
-
*/
|
|
133
|
-
customFields: C;
|
|
134
|
-
/**
|
|
135
|
-
* Order by which the items should be sorted.
|
|
136
|
-
*/
|
|
137
|
-
orderBy?: Order<InjectCustomField<T, C>>[];
|
|
138
|
-
/**
|
|
139
|
-
* Groups items by specified fields.
|
|
140
|
-
*/
|
|
141
|
-
groupBy?: Group<InjectCustomField<T, C>>[];
|
|
142
|
-
} | {
|
|
143
|
-
/**
|
|
144
|
-
* Item fields to pick. If omitted, all fields are picked.
|
|
145
|
-
*/
|
|
146
|
-
fields?: readonly (keyof T)[];
|
|
147
|
-
/**
|
|
148
|
-
* Filter that picks the items.
|
|
149
|
-
*/
|
|
150
|
-
filter?: Filter<T>;
|
|
151
|
-
customFields?: never;
|
|
152
|
-
/**
|
|
153
|
-
* Order by which the items should be sorted.
|
|
154
|
-
*/
|
|
155
|
-
orderBy?: Order<T>[];
|
|
156
|
-
/**
|
|
157
|
-
* Groups items by specified fields.
|
|
158
|
-
*/
|
|
159
|
-
groupBy?: Group<T>[];
|
|
160
|
-
});
|
|
161
|
-
/**
|
|
162
|
-
* Query for creating an item.
|
|
163
|
-
*/
|
|
164
|
-
export type QueryCreate<T extends object> = QueryBase<T> & {
|
|
165
|
-
method: "create";
|
|
166
|
-
value: Partial<T>;
|
|
167
|
-
};
|
|
168
|
-
/**
|
|
169
|
-
* Query for creating multiple items.
|
|
170
|
-
*/
|
|
171
|
-
export type QueryCreateMultiple<T extends object> = QueryBase<T> & {
|
|
172
|
-
method: "create";
|
|
173
|
-
multiple: true;
|
|
174
|
-
value: Partial<T>[];
|
|
175
|
-
};
|
|
176
|
-
/**
|
|
177
|
-
* Query for updating an item.
|
|
178
|
-
*/
|
|
179
|
-
export type QueryUpdate<T extends object, C extends CustomFieldMap<T>> = QueryBase<T> & {
|
|
180
|
-
method: "update";
|
|
181
|
-
value: Partial<T>;
|
|
182
|
-
/**
|
|
183
|
-
* Custom fields to add to each item, which can be used in the `filter`.
|
|
184
|
-
*/
|
|
185
|
-
customFields?: C;
|
|
186
|
-
/**
|
|
187
|
-
* Filter for finding the item, if it cannot be found based on the `context`.
|
|
188
|
-
*/
|
|
189
|
-
filter?: Filter<InjectCustomField<T, C>>;
|
|
190
|
-
offset?: never;
|
|
191
|
-
orderBy: never;
|
|
192
|
-
groupBy?: never;
|
|
193
|
-
};
|
|
194
|
-
/**
|
|
195
|
-
* Query for updating multiple items.
|
|
196
|
-
*/
|
|
197
|
-
export type QueryUpdateMultiple<T extends object, C extends CustomFieldMap<T>> = QueryBase<T> & {
|
|
198
|
-
method: "update";
|
|
199
|
-
multiple: true;
|
|
200
|
-
value: Partial<T>[];
|
|
201
|
-
/**
|
|
202
|
-
* Custom fields to add to each item, which can be used in the `filter`.
|
|
203
|
-
*/
|
|
204
|
-
customFields?: C;
|
|
205
|
-
filter?: Filter<T>;
|
|
206
|
-
/**
|
|
207
|
-
* Order by which the items should be sorted.
|
|
208
|
-
*/
|
|
209
|
-
orderBy?: Order<InjectCustomField<T, C>>[];
|
|
210
|
-
/**
|
|
211
|
-
* Offset of the first matching item to update.
|
|
212
|
-
*/
|
|
213
|
-
offset?: number;
|
|
214
|
-
/**
|
|
215
|
-
* Sets the upper bound of the number of items to update.
|
|
216
|
-
*/
|
|
217
|
-
limit?: number;
|
|
218
|
-
};
|
|
219
|
-
/**
|
|
220
|
-
* Query for deleting an item.
|
|
221
|
-
*/
|
|
222
|
-
export type QueryDelete<T extends object, C extends CustomFieldMap<T>> = QueryBase<T> & {
|
|
223
|
-
method: "delete";
|
|
224
|
-
filter?: Filter<InjectCustomField<T, C>>;
|
|
225
|
-
};
|
|
226
|
-
/**
|
|
227
|
-
* Query for deleting multiple items.
|
|
228
|
-
*/
|
|
229
|
-
export type QueryDeleteMultiple<T extends object, C extends CustomFieldMap<T>> = QueryBase<T> & {
|
|
230
|
-
method: "delete";
|
|
231
|
-
multiple: true;
|
|
232
|
-
filter?: Filter<InjectCustomField<T, C>>;
|
|
233
|
-
};
|
|
234
|
-
/**
|
|
235
|
-
* Query for computing an aggregated value.
|
|
236
|
-
*/
|
|
237
|
-
export type QueryAggregate<T extends object, C extends CustomFieldMap<T>> = QueryBase<T> & {
|
|
238
|
-
method: "aggregate";
|
|
239
|
-
aggregator: AggregateFunction<InjectCustomField<T, C>>;
|
|
240
|
-
filter?: Filter<InjectCustomField<T, C>>;
|
|
241
|
-
};
|
|
242
|
-
/**
|
|
243
|
-
* Order item.
|
|
244
|
-
*/
|
|
245
|
-
export type Order<T extends object> = keyof T | {
|
|
246
|
-
field: keyof T;
|
|
247
|
-
descending?: boolean;
|
|
248
|
-
};
|
|
249
|
-
export type FilterKeys<T extends object, P> = {
|
|
250
|
-
[K in keyof T]-?: T[K] extends P ? K : never;
|
|
251
|
-
}[keyof T];
|
|
252
|
-
export type FieldFunction<T extends object> = FieldFunctionCustom<T> | FieldFunctionFormatDate<T>;
|
|
253
|
-
/**
|
|
254
|
-
* Applies a custom field transform function.
|
|
255
|
-
*/
|
|
256
|
-
export type FieldFunctionCustom<T extends object> = {
|
|
257
|
-
operator: "custom";
|
|
258
|
-
value: (item: T) => any;
|
|
259
|
-
};
|
|
260
|
-
/**
|
|
261
|
-
* Formats the date found in a given field, which can be an ISO string date or a timestamp.
|
|
262
|
-
*/
|
|
263
|
-
export type FieldFunctionFormatDate<T extends object> = {
|
|
264
|
-
operator: "formatDate";
|
|
265
|
-
field: FilterKeys<T, string | number>;
|
|
266
|
-
format: string;
|
|
267
|
-
};
|
|
268
|
-
/**
|
|
269
|
-
* Possible field function operators.
|
|
270
|
-
*/
|
|
271
|
-
export type FieldFunctionOperator = FieldFunction<never>["operator"];
|
|
272
|
-
/**
|
|
273
|
-
* Return types of custom field functions.
|
|
274
|
-
*/
|
|
275
|
-
export type FieldFunctionReturn = {
|
|
276
|
-
formatDate: string;
|
|
277
|
-
};
|
|
278
|
-
export type CustomFieldMap<T extends object> = Record<string, FieldFunction<T>>;
|
|
279
|
-
/**
|
|
280
|
-
* Aggregation function.
|
|
281
|
-
*/
|
|
282
|
-
export type AggregateFunction<T extends object> = "length" | {
|
|
283
|
-
operator: "length";
|
|
284
|
-
} | {
|
|
285
|
-
operator: "median" | "standardDeviation" | "mean" | "minimum" | "maximum" | "variance" | "mode";
|
|
286
|
-
field: keyof T;
|
|
287
|
-
};
|
|
288
|
-
export type AggregateFunctionOperator = Exclude<AggregateFunction<{}>, string>["operator"];
|
|
289
|
-
type CustomFieldAggregateMap<T extends object> = Record<string, AggregateFunction<T>>;
|
|
290
|
-
type Group<T extends object> = keyof T | {
|
|
291
|
-
field: keyof T;
|
|
292
|
-
customFields?: CustomFieldAggregateMap<T>;
|
|
293
|
-
};
|
|
294
|
-
/**
|
|
295
|
-
* Describes a predicate for filtering items.
|
|
296
|
-
*/
|
|
297
|
-
export type Filter<T extends object> = FilterList<T> | FilterField<T> | FilterBoolean<T> | FilterString<T> | FilterStringMatch<T> | FilterStringIntersect<T> | FilterNumber<T> | FilterArray<T>;
|
|
298
|
-
export type FilterOperator = Filter<never>["operator"];
|
|
299
|
-
/**
|
|
300
|
-
* Joins a list of filters with a specific boolean operator.
|
|
301
|
-
*/
|
|
302
|
-
export type FilterList<T extends object> = {
|
|
303
|
-
/**
|
|
304
|
-
* Boolean operator to use for joining the filters.
|
|
305
|
-
*/
|
|
306
|
-
operator: "all";
|
|
307
|
-
/**
|
|
308
|
-
* Filters to join.
|
|
309
|
-
*/
|
|
310
|
-
value: Filter<T>[];
|
|
311
|
-
} | {
|
|
312
|
-
/**
|
|
313
|
-
* Boolean operator to use for joining the filters.
|
|
314
|
-
*/
|
|
315
|
-
operator: "any" | "none";
|
|
316
|
-
/**
|
|
317
|
-
* Filters to join.
|
|
318
|
-
*/
|
|
319
|
-
value?: Filter<T>[];
|
|
320
|
-
};
|
|
321
|
-
/**
|
|
322
|
-
* Checks if a given field exists.
|
|
323
|
-
*/
|
|
324
|
-
export type FilterField<T extends object> = {
|
|
325
|
-
operator: "exist";
|
|
326
|
-
field: keyof T;
|
|
327
|
-
};
|
|
328
|
-
/**
|
|
329
|
-
* Checks if a given boolean field is `true` or `false`.
|
|
330
|
-
*/
|
|
331
|
-
export type FilterBoolean<T extends object> = {
|
|
332
|
-
operator: "equal" | "notEqual";
|
|
333
|
-
field: FilterKeys<T, boolean>;
|
|
334
|
-
value: boolean;
|
|
335
|
-
};
|
|
336
|
-
/**
|
|
337
|
-
* Checks if a given string field matches a given string value according to a given operator.
|
|
338
|
-
*/
|
|
339
|
-
export type FilterString<T extends object> = {
|
|
340
|
-
operator: "equal" | "notEqual" | "startWith" | "endWith" | "include" | "greaterThan" | "greaterThanOrEqual" | "lowerThan" | "lowerThanOrEqual";
|
|
341
|
-
field: FilterKeys<T, string>;
|
|
342
|
-
value: string;
|
|
343
|
-
};
|
|
344
|
-
/**
|
|
345
|
-
* Checks if a given string field matches a given regular expression.
|
|
346
|
-
*/
|
|
347
|
-
export type FilterStringMatch<T extends object> = {
|
|
348
|
-
operator: "match";
|
|
349
|
-
field: FilterKeys<T, string>;
|
|
350
|
-
/**
|
|
351
|
-
* Raw regular expression string.
|
|
352
|
-
*/
|
|
353
|
-
value: string;
|
|
354
|
-
/**
|
|
355
|
-
* Regular expression options.
|
|
356
|
-
*/
|
|
357
|
-
options?: {
|
|
358
|
-
/**
|
|
359
|
-
* When matching, casing differences are ignored.
|
|
360
|
-
*/
|
|
361
|
-
ignoreCase?: boolean;
|
|
362
|
-
/**
|
|
363
|
-
* Allows . to match newlines.
|
|
364
|
-
*/
|
|
365
|
-
dotAll?: boolean;
|
|
366
|
-
};
|
|
367
|
-
/**
|
|
368
|
-
* Compiled regular expression generated by the `testFilter` function.
|
|
369
|
-
*/
|
|
370
|
-
regularExpression?: RegExp;
|
|
371
|
-
};
|
|
372
|
-
/**
|
|
373
|
-
* Checks if a given string field has any of the provided values.
|
|
374
|
-
*/
|
|
375
|
-
export type FilterStringIntersect<T extends object> = {
|
|
376
|
-
operator: "intersect";
|
|
377
|
-
field: FilterKeys<T, string>;
|
|
378
|
-
value: string[];
|
|
379
|
-
};
|
|
380
|
-
/**
|
|
381
|
-
* Checks if a given number field matches a given number value according to a given operator.
|
|
382
|
-
*/
|
|
383
|
-
export type FilterNumber<T extends object> = {
|
|
384
|
-
operator: "equal" | "notEqual" | "greaterThan" | "greaterThanOrEqual" | "lowerThan" | "lowerThanOrEqual";
|
|
385
|
-
field: FilterKeys<T, number>;
|
|
386
|
-
value: number;
|
|
387
|
-
};
|
|
388
|
-
/**
|
|
389
|
-
* Checks if a given array field matches a given array value according to a given operator.
|
|
390
|
-
*/
|
|
391
|
-
export type FilterArray<T extends object, P = Any> = {
|
|
392
|
-
operator: "equal" | "include" | "intersect";
|
|
393
|
-
field: FilterKeys<T, P[]>;
|
|
394
|
-
value: P[];
|
|
395
|
-
};
|
|
396
|
-
export {};
|
|
1
|
+
export type { AggregateFunction } from "./types/AggregateFunction";
|
|
2
|
+
export type { AggregateFunctionOperator } from "./types/AggregateFunctionOperator";
|
|
3
|
+
export type { Any } from "./types/Any";
|
|
4
|
+
export type { Context } from "./types/Context";
|
|
5
|
+
export type { CustomFieldAggregateMap } from "./types/CustomFieldAggregateMap";
|
|
6
|
+
export type { CustomFieldMap } from "./types/CustomFieldMap";
|
|
7
|
+
export type { CustomRequest } from "./types/CustomRequest";
|
|
8
|
+
export type { FieldFunction } from "./types/FieldFunction";
|
|
9
|
+
export type { FieldFunctionCustom } from "./types/FieldFunctionCustom";
|
|
10
|
+
export type { FieldFunctionFormatDate } from "./types/FieldFunctionFormatDate";
|
|
11
|
+
export type { FieldFunctionReturn } from "./types/FieldFunctionReturn";
|
|
12
|
+
export type { Filter } from "./types/Filter";
|
|
13
|
+
export type { FilterArray } from "./types/FilterArray";
|
|
14
|
+
export type { FilterBoolean } from "./types/FilterBoolean";
|
|
15
|
+
export type { FilterField } from "./types/FilterField";
|
|
16
|
+
export type { FilterKeys } from "./types/FilterKeys";
|
|
17
|
+
export type { FilterNumber } from "./types/FilterNumber";
|
|
18
|
+
export type { FilterOperator } from "./types/FilterOperator";
|
|
19
|
+
export type { FilterSequence } from "./types/FilterSequence";
|
|
20
|
+
export type { FilterString } from "./types/FilterString";
|
|
21
|
+
export type { FilterStringIntersect } from "./types/FilterStringIntersect";
|
|
22
|
+
export type { FilterStringMatch } from "./types/FilterStringMatch";
|
|
23
|
+
export type { GenericFetch } from "./types/GenericFetch";
|
|
24
|
+
export type { Get } from "./types/Get";
|
|
25
|
+
export type { Group } from "./types/Group";
|
|
26
|
+
export type { Handler } from "./types/Handler";
|
|
27
|
+
export type { Immutable } from "./types/Immutable";
|
|
28
|
+
export type { InjectCustomFields } from "./types/InjectCustomFields";
|
|
29
|
+
export type { Item } from "./types/Item";
|
|
30
|
+
export type { Key } from "./types/Key";
|
|
31
|
+
export type { Mutable } from "./types/Mutable";
|
|
32
|
+
export type { NextHandler } from "./types/NextHandler";
|
|
33
|
+
export type { Order } from "./types/Order";
|
|
34
|
+
export type { Query } from "./types/Query";
|
|
35
|
+
export type { QueryAggregate } from "./types/QueryAggregate";
|
|
36
|
+
export type { QueryAny } from "./types/QueryAny";
|
|
37
|
+
export type { QueryCreate } from "./types/QueryCreate";
|
|
38
|
+
export type { QueryCreateMultiple } from "./types/QueryCreateMultiple";
|
|
39
|
+
export type { QueryDelete } from "./types/QueryDelete";
|
|
40
|
+
export type { QueryDeleteMultiple } from "./types/QueryDeleteMultiple";
|
|
41
|
+
export type { QueryMethod } from "./types/QueryMethod";
|
|
42
|
+
export type { QueryRead } from "./types/QueryRead";
|
|
43
|
+
export type { QueryReadMultiple } from "./types/QueryReadMultiple";
|
|
44
|
+
export type { QueryUpdate } from "./types/QueryUpdate";
|
|
45
|
+
export type { QueryUpdateMultiple } from "./types/QueryUpdateMultiple";
|
|
46
|
+
export type { Result } from "./types/Result";
|
|
47
|
+
export type { Store } from "./types/Store";
|