quetch 0.31.0 → 0.32.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/tools/filterChildren.d.ts +2 -1
- package/dist/tools/filterChildren.js +3 -2
- package/dist/tools/filterChildren.js.map +1 -1
- package/dist/tools/testFilter.js +1 -2
- package/dist/tools/testFilter.js.map +1 -1
- package/dist/tools/transformerFilterChildren.js +1 -1
- package/dist/tools/transformerFilterChildren.js.map +1 -1
- package/dist/types/IntersectUnion.d.ts +3 -0
- package/dist/types/Prettify.d.ts +6 -0
- package/dist/types/Prettify.js +1 -0
- package/dist/types/Prettify.js.map +1 -0
- package/dist/types/QueryRead.d.ts +2 -1
- package/dist/types/QueryReadMultiple.d.ts +2 -1
- package/dist/types/Result.d.ts +28 -20
- package/dist/types.d.ts +1 -0
- package/doc/README.md +1 -0
- package/doc/classes/RequestError.md +5 -5
- package/doc/functions/aggregate.md +1 -1
- package/doc/functions/branch.md +1 -1
- package/doc/functions/cache.md +1 -1
- package/doc/functions/combine.md +1 -1
- package/doc/functions/comparatorFieldValues.md +1 -1
- package/doc/functions/cork.md +1 -1
- package/doc/functions/defineCheckQuery.md +1 -1
- package/doc/functions/defineCustomFetch.md +1 -1
- package/doc/functions/defineGenericFetch.md +1 -1
- package/doc/functions/escapeRegex.md +1 -1
- package/doc/functions/fetchExternal.md +1 -1
- package/doc/functions/fetchLocal.md +1 -1
- package/doc/functions/fieldListFromFilter.md +1 -1
- package/doc/functions/filterChildren.md +8 -2
- package/doc/functions/filterFromValue.md +1 -1
- package/doc/functions/get.md +1 -1
- package/doc/functions/groupFilters.md +1 -1
- package/doc/functions/identity.md +1 -1
- package/doc/functions/intrinsicFilter.md +1 -1
- package/doc/functions/isFilterGroup.md +1 -1
- package/doc/functions/log.md +1 -1
- package/doc/functions/normalizeOrder.md +1 -1
- package/doc/functions/queryItemList.md +1 -1
- package/doc/functions/querySettings.md +1 -1
- package/doc/functions/retry.md +1 -1
- package/doc/functions/reverseOrder.md +1 -1
- package/doc/functions/sameField.md +1 -1
- package/doc/functions/sortItemList.md +1 -1
- package/doc/functions/splitPath.md +2 -2
- package/doc/functions/testFilter.md +1 -1
- package/doc/functions/transformerFilterChildren.md +1 -1
- package/doc/interfaces/CustomFetch.md +1 -1
- package/doc/type-aliases/AggregateFunction.md +1 -1
- package/doc/type-aliases/AggregateFunctionOperator.md +1 -1
- package/doc/type-aliases/CombineUnion.md +1 -1
- package/doc/type-aliases/Context.md +1 -1
- package/doc/type-aliases/CustomFieldAggregateMap.md +1 -1
- package/doc/type-aliases/CustomFieldMap.md +1 -1
- package/doc/type-aliases/Decrement.md +1 -1
- package/doc/type-aliases/DepthLimit.md +1 -1
- package/doc/type-aliases/Field.md +1 -1
- package/doc/type-aliases/FieldFiltered.md +1 -1
- package/doc/type-aliases/FieldFunction.md +1 -1
- package/doc/type-aliases/FieldFunctionCustom.md +1 -1
- package/doc/type-aliases/FieldFunctionFormatDate.md +1 -1
- package/doc/type-aliases/FieldFunctionReturn.md +1 -1
- package/doc/type-aliases/FieldKey.md +1 -1
- package/doc/type-aliases/FieldMap.md +1 -1
- package/doc/type-aliases/Filter.md +1 -1
- package/doc/type-aliases/FilterArray.md +1 -1
- package/doc/type-aliases/FilterBoolean.md +1 -1
- package/doc/type-aliases/FilterChildren.md +1 -1
- package/doc/type-aliases/FilterCustom.md +1 -1
- package/doc/type-aliases/FilterField.md +1 -1
- package/doc/type-aliases/FilterGroup.md +1 -1
- package/doc/type-aliases/FilterNumber.md +1 -1
- package/doc/type-aliases/FilterOperator.md +1 -1
- package/doc/type-aliases/FilterString.md +1 -1
- package/doc/type-aliases/FilterStringIntersect.md +1 -1
- package/doc/type-aliases/FilterStringMatch.md +1 -1
- package/doc/type-aliases/Get.md +1 -1
- package/doc/type-aliases/Group.md +1 -1
- package/doc/type-aliases/Handler.md +1 -1
- package/doc/type-aliases/Immutable.md +1 -1
- package/doc/type-aliases/InjectCustomFields.md +1 -1
- package/doc/type-aliases/IntersectUnion.md +3 -1
- package/doc/type-aliases/IntrinsicFilter.md +1 -1
- package/doc/type-aliases/Item.md +1 -1
- package/doc/type-aliases/Join.md +1 -1
- package/doc/type-aliases/Key.md +1 -1
- package/doc/type-aliases/KeyFiltered.md +1 -1
- package/doc/type-aliases/KeyFromUnion.md +1 -1
- package/doc/type-aliases/Locale.md +1 -1
- package/doc/type-aliases/NextHandler.md +1 -1
- package/doc/type-aliases/NormalizedPathFieldSettings.md +1 -1
- package/doc/type-aliases/Order.md +1 -1
- package/doc/type-aliases/OrderNormalized.md +1 -1
- package/doc/type-aliases/Parameters.md +1 -1
- package/doc/type-aliases/Path.md +1 -1
- package/doc/type-aliases/PathFiltered.md +1 -1
- package/doc/type-aliases/Prettify.md +19 -0
- package/doc/type-aliases/Primitive.md +1 -1
- package/doc/type-aliases/PrimitiveObject.md +1 -1
- package/doc/type-aliases/Query.md +1 -1
- package/doc/type-aliases/QueryAggregate.md +1 -1
- package/doc/type-aliases/QueryCreate.md +1 -1
- package/doc/type-aliases/QueryCreateMultiple.md +1 -1
- package/doc/type-aliases/QueryDelete.md +1 -1
- package/doc/type-aliases/QueryDeleteMultiple.md +1 -1
- package/doc/type-aliases/QueryMethod.md +1 -1
- package/doc/type-aliases/QueryRead.md +2 -2
- package/doc/type-aliases/QueryReadMultiple.md +2 -2
- package/doc/type-aliases/QuerySettings.md +1 -1
- package/doc/type-aliases/QueryUpdate.md +1 -1
- package/doc/type-aliases/QueryUpdateMultiple.md +1 -1
- package/doc/type-aliases/Result.md +4 -2
- package/doc/type-aliases/Store.md +1 -1
- package/doc/type-aliases/Value.md +1 -1
- package/doc/type-aliases/ValueMap.md +1 -1
- package/doc/variables/CACHE.md +1 -1
- package/doc/variables/FILTER_ANY.md +1 -1
- package/doc/variables/FILTER_NONE.md +1 -1
- package/doc/variables/SELF.md +1 -1
- package/lib/tools/filterChildren.ts +3 -1
- package/lib/tools/testFilter.ts +1 -2
- package/lib/tools/transformerFilterChildren.ts +1 -0
- package/lib/types/IntersectUnion.ts +3 -0
- package/lib/types/Prettify.ts +8 -0
- package/lib/types/QueryRead.ts +2 -1
- package/lib/types/QueryReadMultiple.ts +2 -1
- package/lib/types/Result.ts +63 -21
- package/lib/types.ts +1 -0
- package/package.json +4 -2
package/lib/types/QueryRead.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Context } from "./Context";
|
|
2
|
+
import type { Field } from "./Field";
|
|
2
3
|
import type { Filter } from "./Filter";
|
|
3
4
|
import type { Order } from "./Order";
|
|
4
5
|
import type { Parameters } from "./Parameters";
|
|
@@ -23,7 +24,7 @@ export type QueryRead<T> = {
|
|
|
23
24
|
/**
|
|
24
25
|
* Item fields to pick. If omitted, all fields are picked.
|
|
25
26
|
*/
|
|
26
|
-
fields?: readonly
|
|
27
|
+
fields?: readonly Field<T>[];
|
|
27
28
|
/**
|
|
28
29
|
* Filter for finding the item, if it cannot be found based on the `context`.
|
|
29
30
|
*/
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Context } from "./Context";
|
|
2
|
+
import type { Field } from "./Field";
|
|
2
3
|
import type { Filter } from "./Filter";
|
|
3
4
|
import type { Group } from "./Group";
|
|
4
5
|
import type { Order } from "./Order";
|
|
@@ -26,7 +27,7 @@ export type QueryReadMultiple<T> = {
|
|
|
26
27
|
/**
|
|
27
28
|
* Item fields to pick. If omitted, all fields are picked.
|
|
28
29
|
*/
|
|
29
|
-
fields?: readonly
|
|
30
|
+
fields?: readonly Field<T>[];
|
|
30
31
|
/**
|
|
31
32
|
* Filter for finding the items.
|
|
32
33
|
*/
|
package/lib/types/Result.ts
CHANGED
|
@@ -1,28 +1,70 @@
|
|
|
1
|
-
|
|
1
|
+
/* eslint-disable line-comment-position */
|
|
2
|
+
import type { Field } from "./Field";
|
|
3
|
+
import type { IntersectUnion } from "./IntersectUnion";
|
|
4
|
+
import type { Prettify } from "./Prettify";
|
|
5
|
+
import type { Primitive } from "./Primitive";
|
|
2
6
|
import type { Query } from "./Query";
|
|
7
|
+
import type { QueryRead } from "./QueryRead";
|
|
8
|
+
import type { QueryReadMultiple } from "./QueryReadMultiple";
|
|
3
9
|
|
|
4
10
|
/**
|
|
5
11
|
* Picks fields `F` from object `T`.
|
|
6
12
|
*/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
13
|
+
type PickFields<T, F extends readonly Field<T>[]> = [unknown] extends [T]
|
|
14
|
+
? T
|
|
15
|
+
: T extends Primitive
|
|
16
|
+
? T
|
|
17
|
+
: [F] extends [readonly [infer J, ...infer R]]
|
|
18
|
+
? Merge<
|
|
19
|
+
| // J is a single key
|
|
20
|
+
([J] extends [keyof T]
|
|
21
|
+
? PickField<T, J, T[J]>
|
|
22
|
+
: // J is a path
|
|
23
|
+
[J] extends [readonly [infer K, ...infer S]]
|
|
24
|
+
? [K] extends [keyof T]
|
|
25
|
+
? PickField<
|
|
26
|
+
T,
|
|
27
|
+
K,
|
|
28
|
+
PickFields<
|
|
29
|
+
T[K],
|
|
30
|
+
S extends readonly Field<T[K]>[] ? S : never
|
|
31
|
+
>
|
|
32
|
+
>
|
|
33
|
+
: never
|
|
34
|
+
: never)
|
|
35
|
+
| (R extends readonly never[]
|
|
36
|
+
? never
|
|
37
|
+
: R extends readonly Field<T>[]
|
|
38
|
+
? PickFields<T, R>
|
|
39
|
+
: never)
|
|
40
|
+
>
|
|
41
|
+
: never;
|
|
12
42
|
|
|
13
|
-
|
|
14
|
-
// FIXME: `keyof T` should be `Field<T>`
|
|
15
|
-
{ fields: (keyof T)[] },
|
|
16
|
-
]
|
|
17
|
-
? PickFields<T, Item<Q["fields"]>>
|
|
18
|
-
: T;
|
|
43
|
+
type Merge<T> = Prettify<IntersectUnion<T>>;
|
|
19
44
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
45
|
+
/**
|
|
46
|
+
* Picks a field `K` from object `T` and returns an object with the field `K` and the value `V`.
|
|
47
|
+
*/
|
|
48
|
+
type PickField<T, K extends keyof T, V> = {
|
|
49
|
+
[P in keyof Pick<T, K>]: V;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Result of a read query.
|
|
54
|
+
*/
|
|
55
|
+
type ResultRead<T, Q extends Query<T>> = [unknown] extends [T]
|
|
56
|
+
? T
|
|
57
|
+
: [Q] extends [{ fields: readonly Field<T>[] }]
|
|
58
|
+
? PickFields<T, Q["fields"]>
|
|
59
|
+
: T;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Result of a read and aggregate query.
|
|
63
|
+
*/
|
|
64
|
+
export type Result<T, Q extends Query<T>> = [Q] extends [QueryReadMultiple<T>]
|
|
65
|
+
? readonly ResultRead<T, Q>[]
|
|
66
|
+
: [Q] extends [QueryRead<T>]
|
|
67
|
+
? ResultRead<T, Q>
|
|
68
|
+
: [Q] extends [{ method: "aggregate" }]
|
|
69
|
+
? number
|
|
70
|
+
: never;
|
package/lib/types.ts
CHANGED
|
@@ -48,6 +48,7 @@ export type { OrderNormalized } from "./types/OrderNormalized";
|
|
|
48
48
|
export type { Parameters } from "./types/Parameters";
|
|
49
49
|
export type { Path } from "./types/Path";
|
|
50
50
|
export type { PathFiltered } from "./types/PathFiltered";
|
|
51
|
+
export type { Prettify } from "./types/Prettify";
|
|
51
52
|
export type { Primitive } from "./types/Primitive";
|
|
52
53
|
export type { PrimitiveObject } from "./types/PrimitiveObject";
|
|
53
54
|
export type { Query } from "./types/Query";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "quetch",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.32.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/main.js",
|
|
6
6
|
"exports": {
|
|
@@ -39,7 +39,9 @@
|
|
|
39
39
|
"lint": "npm run lint:ts",
|
|
40
40
|
"lint:fix": "npm run lint:ts:fix",
|
|
41
41
|
"lint:ts": "eslint . && tsc --project tsconfig.package.json --noEmit",
|
|
42
|
-
"lint:types
|
|
42
|
+
"lint:types": "NODE_OPTIONS=--max-old-space-size=8192 tsc --project tsconfig.package.json --noEmit",
|
|
43
|
+
"lint:types:trace": "NODE_OPTIONS=--max-old-space-size=8192 tsc --project tsconfig.package.json --noEmit --generateTrace ./trace",
|
|
44
|
+
"lint:types:trace:analyze": "npx analyze-trace trace",
|
|
43
45
|
"lint:ts:fix": "eslint --fix .",
|
|
44
46
|
"release:init": "npm publish --access=public",
|
|
45
47
|
"release:patch": "npm version patch && git push origin --follow-tags && npm publish",
|