quetch 0.9.2 → 0.10.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/RequestError.js.map +1 -1
- package/dist/middlewares/aggregate.d.ts +9 -3
- package/dist/middlewares/aggregate.js.map +1 -1
- package/dist/middlewares/cache.d.ts +6 -5
- package/dist/middlewares/cache.js.map +1 -1
- package/dist/middlewares/fetchLocal.d.ts +2 -7
- package/dist/middlewares/fetchLocal.js +5 -0
- package/dist/middlewares/fetchLocal.js.map +1 -1
- package/dist/tools/defineCheckQuery.d.ts +3 -7
- package/dist/tools/defineCheckQuery.js.map +1 -1
- package/dist/tools/defineCustomFetch.d.ts +8 -20
- package/dist/tools/defineCustomFetch.js +3 -3
- package/dist/tools/defineCustomFetch.js.map +1 -1
- package/dist/tools/defineGenericFetch.d.ts +14 -13
- package/dist/tools/defineGenericFetch.js +9 -0
- package/dist/tools/defineGenericFetch.js.map +1 -1
- package/dist/tools/filterItem.d.ts +1 -1
- package/dist/tools/queryItemList.d.ts +3 -8
- package/dist/tools/queryItemList.js.map +1 -1
- package/dist/types/CustomFetch.d.ts +1 -7
- package/dist/types/Group.d.ts +0 -2
- package/dist/types/Parameters.d.ts +1 -0
- package/dist/types/Parameters.js +2 -0
- package/dist/types/Parameters.js.map +1 -0
- package/dist/types/Query.d.ts +2 -36
- package/dist/types/QueryAggregate.d.ts +15 -0
- package/dist/types/QueryCreate.d.ts +18 -0
- package/dist/types/QueryCreateMultiple.d.ts +15 -0
- package/dist/types/QueryDelete.d.ts +15 -2
- package/dist/types/QueryDeleteMultiple.d.ts +15 -2
- package/dist/types/QueryMethod.d.ts +1 -1
- package/dist/types/QueryRead.d.ts +15 -0
- package/dist/types/QueryReadMultiple.d.ts +15 -0
- package/dist/types/QuerySettings.d.ts +22 -1
- package/dist/types/QueryUpdate.d.ts +15 -0
- package/dist/types/QueryUpdateMultiple.d.ts +15 -0
- package/dist/types/Result.d.ts +15 -12
- package/dist/types.d.ts +2 -2
- package/doc/README.md +228 -292
- package/doc/interfaces/CustomFetch.md +5 -30
- package/lib/errors/RequestError.ts +2 -2
- package/lib/middlewares/aggregate.ts +9 -4
- package/lib/middlewares/cache.ts +21 -18
- package/lib/middlewares/fetchLocal.ts +2 -15
- package/lib/tools/defineCheckQuery.ts +8 -12
- package/lib/tools/defineCustomFetch.ts +12 -34
- package/lib/tools/defineGenericFetch.ts +14 -20
- package/lib/tools/filterItem.ts +1 -1
- package/lib/tools/queryItemList.ts +8 -20
- package/lib/types/CustomFetch.ts +1 -7
- package/lib/types/Group.ts +0 -3
- package/lib/types/Parameters.ts +1 -0
- package/lib/types/Query.ts +9 -43
- package/lib/types/QueryAggregate.ts +15 -0
- package/lib/types/QueryCreate.ts +19 -0
- package/lib/types/QueryCreateMultiple.ts +16 -0
- package/lib/types/QueryDelete.ts +15 -2
- package/lib/types/QueryDeleteMultiple.ts +15 -2
- package/lib/types/QueryMethod.ts +1 -1
- package/lib/types/QueryRead.ts +15 -0
- package/lib/types/QueryReadMultiple.ts +15 -0
- package/lib/types/QuerySettings.ts +22 -1
- package/lib/types/QueryUpdate.ts +15 -0
- package/lib/types/QueryUpdateMultiple.ts +15 -0
- package/lib/types/Result.ts +13 -22
- package/lib/types.ts +2 -2
- package/package.json +1 -1
- package/dist/types/CustomRequest.d.ts +0 -16
- package/dist/types/CustomRequest.js +0 -2
- package/dist/types/CustomRequest.js.map +0 -1
- package/dist/types/QueryAny.d.ts +0 -7
- package/dist/types/QueryAny.js +0 -2
- package/dist/types/QueryAny.js.map +0 -1
- package/lib/types/CustomRequest.ts +0 -21
- package/lib/types/QueryAny.ts +0 -8
|
@@ -1,10 +1,17 @@
|
|
|
1
|
+
import type { Context } from "./Context";
|
|
1
2
|
import type { Filter } from "./Filter";
|
|
3
|
+
import type { Parameters } from "./Parameters";
|
|
4
|
+
import type { QuerySettings } from "./QuerySettings";
|
|
2
5
|
/**
|
|
3
6
|
* Query for updating an item.
|
|
4
7
|
*/
|
|
5
8
|
export type QueryUpdate<T extends object> = {
|
|
6
9
|
method: "update";
|
|
7
10
|
multiple?: false;
|
|
11
|
+
/**
|
|
12
|
+
* Common item properties to use for identifying the context in which to update the item.
|
|
13
|
+
*/
|
|
14
|
+
context?: Context<T>;
|
|
8
15
|
/**
|
|
9
16
|
* Partial property values to update.
|
|
10
17
|
*/
|
|
@@ -16,4 +23,12 @@ export type QueryUpdate<T extends object> = {
|
|
|
16
23
|
offset?: never;
|
|
17
24
|
order: never;
|
|
18
25
|
group?: never;
|
|
26
|
+
/**
|
|
27
|
+
* Query parameters.
|
|
28
|
+
*/
|
|
29
|
+
parameters?: Parameters;
|
|
30
|
+
/**
|
|
31
|
+
* Query settings.
|
|
32
|
+
*/
|
|
33
|
+
settings?: QuerySettings<T>;
|
|
19
34
|
};
|
|
@@ -1,11 +1,18 @@
|
|
|
1
|
+
import type { Context } from "./Context";
|
|
1
2
|
import type { Filter } from "./Filter";
|
|
2
3
|
import type { Order } from "./Order";
|
|
4
|
+
import type { Parameters } from "./Parameters";
|
|
5
|
+
import type { QuerySettings } from "./QuerySettings";
|
|
3
6
|
/**
|
|
4
7
|
* Query for updating multiple items.
|
|
5
8
|
*/
|
|
6
9
|
export type QueryUpdateMultiple<T extends object> = {
|
|
7
10
|
method: "update";
|
|
8
11
|
multiple: true;
|
|
12
|
+
/**
|
|
13
|
+
* Common item properties to use for identifying the context in which to update the item.
|
|
14
|
+
*/
|
|
15
|
+
context?: Context<T>;
|
|
9
16
|
/**
|
|
10
17
|
* Partial property values to update.
|
|
11
18
|
*/
|
|
@@ -23,4 +30,12 @@ export type QueryUpdateMultiple<T extends object> = {
|
|
|
23
30
|
* Sets the upper bound of the number of items to update.
|
|
24
31
|
*/
|
|
25
32
|
limit?: number;
|
|
33
|
+
/**
|
|
34
|
+
* Query parameters.
|
|
35
|
+
*/
|
|
36
|
+
parameters?: Parameters;
|
|
37
|
+
/**
|
|
38
|
+
* Query settings.
|
|
39
|
+
*/
|
|
40
|
+
settings?: QuerySettings<T>;
|
|
26
41
|
};
|
package/dist/types/Result.d.ts
CHANGED
|
@@ -1,23 +1,26 @@
|
|
|
1
|
-
import type { CustomFieldMap } from "./CustomFieldMap";
|
|
2
|
-
import type { InjectCustomFields } from "./InjectCustomFields";
|
|
3
1
|
import type { Item } from "./Item";
|
|
4
2
|
import type { Query } from "./Query";
|
|
3
|
+
/**
|
|
4
|
+
* Picks fields `F` from object `T`.
|
|
5
|
+
*/
|
|
5
6
|
export type PickFields<T extends object | undefined, F extends string | number | symbol> = [F] extends [keyof T] ? {
|
|
6
7
|
readonly [K in F]: T[K];
|
|
7
8
|
} : {
|
|
8
9
|
readonly [K in keyof T]: T[K];
|
|
9
10
|
};
|
|
10
|
-
export type ResultRead<T extends object, Q extends Query<T
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
export type Result<T extends object, Q extends Query<T
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
export type ResultRead<T extends object, Q extends Query<T>> = [Q] extends [
|
|
12
|
+
{
|
|
13
|
+
fields: (keyof T)[];
|
|
14
|
+
}
|
|
15
|
+
] ? PickFields<T, Item<Q["fields"]>> : T;
|
|
16
|
+
export type Result<T extends object, Q extends Query<T>> = [Q] extends [
|
|
17
|
+
{
|
|
18
|
+
method: "read";
|
|
19
|
+
}
|
|
20
|
+
] ? [Q] extends [{
|
|
18
21
|
multiple: true;
|
|
19
|
-
}] ? ResultRead<T, Q
|
|
22
|
+
}] ? ResultRead<T, Q>[] : ResultRead<T, Q> : [Q] extends [{
|
|
20
23
|
method: "aggregate";
|
|
21
24
|
}] ? number : [Q] extends [{
|
|
22
25
|
multiple: true;
|
|
23
|
-
}] ? ResultRead<T, Q
|
|
26
|
+
}] ? ResultRead<T, Q>[] : ResultRead<T, Q>;
|
package/dist/types.d.ts
CHANGED
|
@@ -5,7 +5,6 @@ export type { Context } from "./types/Context";
|
|
|
5
5
|
export type { CustomFetch } from "./types/CustomFetch";
|
|
6
6
|
export type { CustomFieldAggregateMap } from "./types/CustomFieldAggregateMap";
|
|
7
7
|
export type { CustomFieldMap } from "./types/CustomFieldMap";
|
|
8
|
-
export type { CustomRequest } from "./types/CustomRequest";
|
|
9
8
|
export type { FieldFunction } from "./types/FieldFunction";
|
|
10
9
|
export type { FieldFunctionCustom } from "./types/FieldFunctionCustom";
|
|
11
10
|
export type { FieldFunctionFormatDate } from "./types/FieldFunctionFormatDate";
|
|
@@ -14,6 +13,7 @@ export type { Filter } from "./types/Filter";
|
|
|
14
13
|
export type { FilterArray } from "./types/FilterArray";
|
|
15
14
|
export type { FilterBoolean } from "./types/FilterBoolean";
|
|
16
15
|
export type { FilterChildren } from "./types/FilterChildren";
|
|
16
|
+
export type { FilterCustom } from "./types/FilterCustom";
|
|
17
17
|
export type { FilterField } from "./types/FilterField";
|
|
18
18
|
export type { FilterGroup } from "./types/FilterGroup";
|
|
19
19
|
export type { FilterKeys } from "./types/FilterKeys";
|
|
@@ -32,9 +32,9 @@ export type { Key } from "./types/Key";
|
|
|
32
32
|
export type { Mutable } from "./types/Mutable";
|
|
33
33
|
export type { NextHandler } from "./types/NextHandler";
|
|
34
34
|
export type { Order } from "./types/Order";
|
|
35
|
+
export type { Parameters } from "./types/Parameters";
|
|
35
36
|
export type { Query } from "./types/Query";
|
|
36
37
|
export type { QueryAggregate } from "./types/QueryAggregate";
|
|
37
|
-
export type { QueryAny } from "./types/QueryAny";
|
|
38
38
|
export type { QueryCreate } from "./types/QueryCreate";
|
|
39
39
|
export type { QueryCreateMultiple } from "./types/QueryCreateMultiple";
|
|
40
40
|
export type { QueryDelete } from "./types/QueryDelete";
|