quetch 0.23.1 → 0.24.1
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/filterFromValue.d.ts +2 -0
- package/dist/tools/{filterFromContext.js → filterFromValue.js} +26 -10
- package/dist/tools/filterFromValue.js.map +1 -0
- package/dist/tools/queryItemList.js +3 -3
- package/dist/tools/queryItemList.js.map +1 -1
- package/dist/tools.d.ts +1 -1
- package/dist/tools.js +1 -1
- package/dist/tools.js.map +1 -1
- package/doc/README.md +1 -1
- 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/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 +1 -1
- package/doc/functions/filterFromValue.md +27 -0
- package/doc/functions/get.md +2 -2
- package/doc/functions/identity.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/retry.md +1 -1
- package/doc/functions/reverseOrder.md +1 -1
- package/doc/functions/sameField.md +9 -1
- package/doc/functions/sortItemList.md +1 -1
- package/doc/functions/splitPath.md +2 -2
- package/doc/functions/testFilter.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/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 +44 -6
- 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/Increment.md +1 -1
- package/doc/type-aliases/InjectCustomFields.md +1 -1
- package/doc/type-aliases/IntersectUnion.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/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 +2 -2
- package/doc/type-aliases/PathFiltered.md +1 -1
- 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 +1 -1
- package/doc/type-aliases/QueryReadMultiple.md +1 -1
- 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 +1 -1
- 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/SELF.md +1 -1
- package/lib/tools/{filterFromContext.test.ts → filterFromValue.test.ts} +8 -8
- package/lib/tools/{filterFromContext.ts → filterFromValue.ts} +27 -13
- package/lib/tools/queryItemList.ts +3 -3
- package/lib/tools/testFilter.test.ts +2 -2
- package/lib/tools.ts +1 -1
- package/package.json +1 -1
- package/dist/tools/filterFromContext.d.ts +0 -2
- package/dist/tools/filterFromContext.js.map +0 -1
- package/doc/functions/filterFromContext.md +0 -27
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
# Type Alias: FilterGroup\<T\>
|
|
8
8
|
|
|
9
|
-
> **FilterGroup**\<`T`\>: \{`operator`: `"all"`;`value`: readonly [`Filter`](Filter.md)\<`T`\>[]; \} \| \{`operator`: `"any"` \| `"none"`;`value`: readonly [`Filter`](Filter.md)\<`T`\>[]; \}
|
|
9
|
+
> **FilterGroup**\<`T`\>: \{`operator`: `"all"`;`value`: readonly [`Filter`](Filter.md)\<`T`\>[]; \} \| \{`maximum`: `number`;`minimum`: `number`;`operator`: `"any"`;`value`: readonly [`Filter`](Filter.md)\<`T`\>[]; \} \| \{`operator`: `"none"`;`value`: readonly [`Filter`](Filter.md)\<`T`\>[]; \}
|
|
10
10
|
|
|
11
11
|
Joins a list of filters with a specific boolean operator.
|
|
12
12
|
|
|
@@ -22,7 +22,7 @@ Joins a list of filters with a specific boolean operator.
|
|
|
22
22
|
|
|
23
23
|
> **operator**: `"all"`
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
Checks if all filters are true.
|
|
26
26
|
|
|
27
27
|
### value
|
|
28
28
|
|
|
@@ -30,13 +30,51 @@ Boolean operator to use for joining the filters.
|
|
|
30
30
|
|
|
31
31
|
Filters to join.
|
|
32
32
|
|
|
33
|
-
\{`
|
|
33
|
+
\{`maximum`: `number`;`minimum`: `number`;`operator`: `"any"`;`value`: readonly [`Filter`](Filter.md)\<`T`\>[]; \}
|
|
34
|
+
|
|
35
|
+
### maximum?
|
|
36
|
+
|
|
37
|
+
> `optional` **maximum**: `number`
|
|
38
|
+
|
|
39
|
+
Maximum number of filters that can match.
|
|
40
|
+
|
|
41
|
+
#### Default
|
|
42
|
+
|
|
43
|
+
```ts
|
|
44
|
+
Infinity
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### minimum?
|
|
48
|
+
|
|
49
|
+
> `optional` **minimum**: `number`
|
|
50
|
+
|
|
51
|
+
Minimum number of filters that must match.
|
|
52
|
+
|
|
53
|
+
#### Default
|
|
54
|
+
|
|
55
|
+
`1` if filters are provided, `0` otherwise
|
|
56
|
+
|
|
57
|
+
### operator
|
|
58
|
+
|
|
59
|
+
> **operator**: `"any"`
|
|
60
|
+
|
|
61
|
+
Checks if at least one of the filters match.
|
|
62
|
+
Always true if no filters are provided.
|
|
63
|
+
|
|
64
|
+
### value?
|
|
65
|
+
|
|
66
|
+
> `optional` **value**: readonly [`Filter`](Filter.md)\<`T`\>[]
|
|
67
|
+
|
|
68
|
+
Filters to join.
|
|
69
|
+
|
|
70
|
+
\{`operator`: `"none"`;`value`: readonly [`Filter`](Filter.md)\<`T`\>[]; \}
|
|
34
71
|
|
|
35
72
|
### operator
|
|
36
73
|
|
|
37
|
-
> **operator**: `"
|
|
74
|
+
> **operator**: `"none"`
|
|
38
75
|
|
|
39
|
-
|
|
76
|
+
Checks if none of the filters match.
|
|
77
|
+
Always false if no filters are provided.
|
|
40
78
|
|
|
41
79
|
### value?
|
|
42
80
|
|
|
@@ -46,4 +84,4 @@ Filters to join.
|
|
|
46
84
|
|
|
47
85
|
## Defined in
|
|
48
86
|
|
|
49
|
-
[lib/types/FilterGroup.ts:6](https://github.com/nevoland/quetch/blob/
|
|
87
|
+
[lib/types/FilterGroup.ts:6](https://github.com/nevoland/quetch/blob/ac27bbd10371e5d511c6f132fbd86a55d2c14316/lib/types/FilterGroup.ts#L6)
|
|
@@ -26,4 +26,4 @@ Checks if a given number field matches a given number value according to a given
|
|
|
26
26
|
|
|
27
27
|
## Defined in
|
|
28
28
|
|
|
29
|
-
[lib/types/FilterNumber.ts:7](https://github.com/nevoland/quetch/blob/
|
|
29
|
+
[lib/types/FilterNumber.ts:7](https://github.com/nevoland/quetch/blob/ac27bbd10371e5d511c6f132fbd86a55d2c14316/lib/types/FilterNumber.ts#L7)
|
|
@@ -10,4 +10,4 @@
|
|
|
10
10
|
|
|
11
11
|
## Defined in
|
|
12
12
|
|
|
13
|
-
[lib/types/FilterOperator.ts:3](https://github.com/nevoland/quetch/blob/
|
|
13
|
+
[lib/types/FilterOperator.ts:3](https://github.com/nevoland/quetch/blob/ac27bbd10371e5d511c6f132fbd86a55d2c14316/lib/types/FilterOperator.ts#L3)
|
|
@@ -34,4 +34,4 @@ Checks if a given string field matches a given string value according to a given
|
|
|
34
34
|
|
|
35
35
|
## Defined in
|
|
36
36
|
|
|
37
|
-
[lib/types/FilterString.ts:8](https://github.com/nevoland/quetch/blob/
|
|
37
|
+
[lib/types/FilterString.ts:8](https://github.com/nevoland/quetch/blob/ac27bbd10371e5d511c6f132fbd86a55d2c14316/lib/types/FilterString.ts#L8)
|
|
@@ -34,4 +34,4 @@ Checks if a given string field has any of the provided values.
|
|
|
34
34
|
|
|
35
35
|
## Defined in
|
|
36
36
|
|
|
37
|
-
[lib/types/FilterStringIntersect.ts:8](https://github.com/nevoland/quetch/blob/
|
|
37
|
+
[lib/types/FilterStringIntersect.ts:8](https://github.com/nevoland/quetch/blob/ac27bbd10371e5d511c6f132fbd86a55d2c14316/lib/types/FilterStringIntersect.ts#L8)
|
|
@@ -50,4 +50,4 @@ Ignore casing differences if `true`.
|
|
|
50
50
|
|
|
51
51
|
## Defined in
|
|
52
52
|
|
|
53
|
-
[lib/types/FilterStringMatch.ts:9](https://github.com/nevoland/quetch/blob/
|
|
53
|
+
[lib/types/FilterStringMatch.ts:9](https://github.com/nevoland/quetch/blob/ac27bbd10371e5d511c6f132fbd86a55d2c14316/lib/types/FilterStringMatch.ts#L9)
|
package/doc/type-aliases/Get.md
CHANGED
|
@@ -18,4 +18,4 @@ Returns the type of the property at the specified `P` path.
|
|
|
18
18
|
|
|
19
19
|
## Defined in
|
|
20
20
|
|
|
21
|
-
[lib/types/Get.ts:6](https://github.com/nevoland/quetch/blob/
|
|
21
|
+
[lib/types/Get.ts:6](https://github.com/nevoland/quetch/blob/ac27bbd10371e5d511c6f132fbd86a55d2c14316/lib/types/Get.ts#L6)
|
|
@@ -16,4 +16,4 @@ Specifies how items should be grouped.
|
|
|
16
16
|
|
|
17
17
|
## Defined in
|
|
18
18
|
|
|
19
|
-
[lib/types/Group.ts:4](https://github.com/nevoland/quetch/blob/
|
|
19
|
+
[lib/types/Group.ts:4](https://github.com/nevoland/quetch/blob/ac27bbd10371e5d511c6f132fbd86a55d2c14316/lib/types/Group.ts#L4)
|
|
@@ -36,4 +36,4 @@ Handles an `input` query and returns an `output` promise, eventually using the `
|
|
|
36
36
|
|
|
37
37
|
## Defined in
|
|
38
38
|
|
|
39
|
-
[lib/types/Handler.ts:6](https://github.com/nevoland/quetch/blob/
|
|
39
|
+
[lib/types/Handler.ts:6](https://github.com/nevoland/quetch/blob/ac27bbd10371e5d511c6f132fbd86a55d2c14316/lib/types/Handler.ts#L6)
|
|
@@ -14,4 +14,4 @@
|
|
|
14
14
|
|
|
15
15
|
## Defined in
|
|
16
16
|
|
|
17
|
-
[lib/types/Immutable.ts:1](https://github.com/nevoland/quetch/blob/
|
|
17
|
+
[lib/types/Immutable.ts:1](https://github.com/nevoland/quetch/blob/ac27bbd10371e5d511c6f132fbd86a55d2c14316/lib/types/Immutable.ts#L1)
|
|
@@ -14,4 +14,4 @@
|
|
|
14
14
|
|
|
15
15
|
## Defined in
|
|
16
16
|
|
|
17
|
-
[lib/types/Increment.ts:5](https://github.com/nevoland/quetch/blob/
|
|
17
|
+
[lib/types/Increment.ts:5](https://github.com/nevoland/quetch/blob/ac27bbd10371e5d511c6f132fbd86a55d2c14316/lib/types/Increment.ts#L5)
|
|
@@ -18,4 +18,4 @@ Injects the custom fields into the entity type.
|
|
|
18
18
|
|
|
19
19
|
## Defined in
|
|
20
20
|
|
|
21
|
-
[lib/types/InjectCustomFields.ts:8](https://github.com/nevoland/quetch/blob/
|
|
21
|
+
[lib/types/InjectCustomFields.ts:8](https://github.com/nevoland/quetch/blob/ac27bbd10371e5d511c6f132fbd86a55d2c14316/lib/types/InjectCustomFields.ts#L8)
|
|
@@ -14,4 +14,4 @@
|
|
|
14
14
|
|
|
15
15
|
## Defined in
|
|
16
16
|
|
|
17
|
-
[lib/types/IntersectUnion.ts:1](https://github.com/nevoland/quetch/blob/
|
|
17
|
+
[lib/types/IntersectUnion.ts:1](https://github.com/nevoland/quetch/blob/ac27bbd10371e5d511c6f132fbd86a55d2c14316/lib/types/IntersectUnion.ts#L1)
|
package/doc/type-aliases/Item.md
CHANGED
|
@@ -18,4 +18,4 @@ Returns the inferred item type of an array, or an alternative type if it is some
|
|
|
18
18
|
|
|
19
19
|
## Defined in
|
|
20
20
|
|
|
21
|
-
[lib/types/Item.ts:4](https://github.com/nevoland/quetch/blob/
|
|
21
|
+
[lib/types/Item.ts:4](https://github.com/nevoland/quetch/blob/ac27bbd10371e5d511c6f132fbd86a55d2c14316/lib/types/Item.ts#L4)
|
package/doc/type-aliases/Join.md
CHANGED
|
@@ -16,4 +16,4 @@
|
|
|
16
16
|
|
|
17
17
|
## Defined in
|
|
18
18
|
|
|
19
|
-
[lib/types/Join.ts:1](https://github.com/nevoland/quetch/blob/
|
|
19
|
+
[lib/types/Join.ts:1](https://github.com/nevoland/quetch/blob/ac27bbd10371e5d511c6f132fbd86a55d2c14316/lib/types/Join.ts#L1)
|
package/doc/type-aliases/Key.md
CHANGED
|
@@ -10,4 +10,4 @@
|
|
|
10
10
|
|
|
11
11
|
## Defined in
|
|
12
12
|
|
|
13
|
-
[lib/types/Key.ts:1](https://github.com/nevoland/quetch/blob/
|
|
13
|
+
[lib/types/Key.ts:1](https://github.com/nevoland/quetch/blob/ac27bbd10371e5d511c6f132fbd86a55d2c14316/lib/types/Key.ts#L1)
|
|
@@ -18,4 +18,4 @@ Returns union of keys whose mapped value extend the provided `P` type.
|
|
|
18
18
|
|
|
19
19
|
## Defined in
|
|
20
20
|
|
|
21
|
-
[lib/types/KeyFiltered.ts:10](https://github.com/nevoland/quetch/blob/
|
|
21
|
+
[lib/types/KeyFiltered.ts:10](https://github.com/nevoland/quetch/blob/ac27bbd10371e5d511c6f132fbd86a55d2c14316/lib/types/KeyFiltered.ts#L10)
|
|
@@ -14,4 +14,4 @@
|
|
|
14
14
|
|
|
15
15
|
## Defined in
|
|
16
16
|
|
|
17
|
-
[lib/types/KeyFromUnion.ts:1](https://github.com/nevoland/quetch/blob/
|
|
17
|
+
[lib/types/KeyFromUnion.ts:1](https://github.com/nevoland/quetch/blob/ac27bbd10371e5d511c6f132fbd86a55d2c14316/lib/types/KeyFromUnion.ts#L1)
|
|
@@ -10,4 +10,4 @@
|
|
|
10
10
|
|
|
11
11
|
## Defined in
|
|
12
12
|
|
|
13
|
-
[lib/types/Locale.ts:1](https://github.com/nevoland/quetch/blob/
|
|
13
|
+
[lib/types/Locale.ts:1](https://github.com/nevoland/quetch/blob/ac27bbd10371e5d511c6f132fbd86a55d2c14316/lib/types/Locale.ts#L1)
|
|
@@ -28,4 +28,4 @@ Handles an `input` query and returns an `output` promise.
|
|
|
28
28
|
|
|
29
29
|
## Defined in
|
|
30
30
|
|
|
31
|
-
[lib/types/NextHandler.ts:4](https://github.com/nevoland/quetch/blob/
|
|
31
|
+
[lib/types/NextHandler.ts:4](https://github.com/nevoland/quetch/blob/ac27bbd10371e5d511c6f132fbd86a55d2c14316/lib/types/NextHandler.ts#L4)
|
|
@@ -16,4 +16,4 @@ Order item.
|
|
|
16
16
|
|
|
17
17
|
## Defined in
|
|
18
18
|
|
|
19
|
-
[lib/types/Order.ts:6](https://github.com/nevoland/quetch/blob/
|
|
19
|
+
[lib/types/Order.ts:6](https://github.com/nevoland/quetch/blob/ac27bbd10371e5d511c6f132fbd86a55d2c14316/lib/types/Order.ts#L6)
|
|
@@ -24,4 +24,4 @@
|
|
|
24
24
|
|
|
25
25
|
## Defined in
|
|
26
26
|
|
|
27
|
-
[lib/types/OrderNormalized.ts:3](https://github.com/nevoland/quetch/blob/
|
|
27
|
+
[lib/types/OrderNormalized.ts:3](https://github.com/nevoland/quetch/blob/ac27bbd10371e5d511c6f132fbd86a55d2c14316/lib/types/OrderNormalized.ts#L3)
|
|
@@ -10,4 +10,4 @@
|
|
|
10
10
|
|
|
11
11
|
## Defined in
|
|
12
12
|
|
|
13
|
-
[lib/types/Parameters.ts:1](https://github.com/nevoland/quetch/blob/
|
|
13
|
+
[lib/types/Parameters.ts:1](https://github.com/nevoland/quetch/blob/ac27bbd10371e5d511c6f132fbd86a55d2c14316/lib/types/Parameters.ts#L1)
|
package/doc/type-aliases/Path.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
# Type Alias: Path\<T, D\>
|
|
8
8
|
|
|
9
|
-
> **Path**\<`T`, `D`\>: [`0`] *extends* [`1` & `T`] ? readonly ([`Key`](Key.md) \| `never`)[] : `D` *extends* `-1` ? `never` : `T` *extends* [`Primitive`](Primitive.md) ? readonly `never`[] : `T` *extends* infer P[] ? readonly [`number`] \| readonly [`number`, `...Path<P, Increment<D>>`] : `T` *extends* `object` ? \{ \[K in keyof T\]: \[K\] \| \[K, ...
|
|
9
|
+
> **Path**\<`T`, `D`\>: [`0`] *extends* [`1` & `T`] ? readonly ([`Key`](Key.md) \| `never`)[] : `D` *extends* `-1` ? `never` : `T` *extends* [`Primitive`](Primitive.md) ? readonly `never`[] : `T` *extends* infer P[] ? readonly [`number`] \| readonly [`number`, `...Path<P, Increment<D>>`] : `T` *extends* `object` ? \{ \[K in keyof T\]: readonly \[K\] \| readonly \[K, ...(...)\] \}\[keyof `T`\] : `never`
|
|
10
10
|
|
|
11
11
|
## Type Parameters
|
|
12
12
|
|
|
@@ -16,4 +16,4 @@
|
|
|
16
16
|
|
|
17
17
|
## Defined in
|
|
18
18
|
|
|
19
|
-
[lib/types/Path.ts:5](https://github.com/nevoland/quetch/blob/
|
|
19
|
+
[lib/types/Path.ts:5](https://github.com/nevoland/quetch/blob/ac27bbd10371e5d511c6f132fbd86a55d2c14316/lib/types/Path.ts#L5)
|
|
@@ -18,4 +18,4 @@
|
|
|
18
18
|
|
|
19
19
|
## Defined in
|
|
20
20
|
|
|
21
|
-
[lib/types/PathFiltered.ts:4](https://github.com/nevoland/quetch/blob/
|
|
21
|
+
[lib/types/PathFiltered.ts:4](https://github.com/nevoland/quetch/blob/ac27bbd10371e5d511c6f132fbd86a55d2c14316/lib/types/PathFiltered.ts#L4)
|
|
@@ -10,4 +10,4 @@
|
|
|
10
10
|
|
|
11
11
|
## Defined in
|
|
12
12
|
|
|
13
|
-
[lib/types/Primitive.ts:1](https://github.com/nevoland/quetch/blob/
|
|
13
|
+
[lib/types/Primitive.ts:1](https://github.com/nevoland/quetch/blob/ac27bbd10371e5d511c6f132fbd86a55d2c14316/lib/types/Primitive.ts#L1)
|
|
@@ -10,4 +10,4 @@
|
|
|
10
10
|
|
|
11
11
|
## Defined in
|
|
12
12
|
|
|
13
|
-
[lib/types/PrimitiveObject.ts:1](https://github.com/nevoland/quetch/blob/
|
|
13
|
+
[lib/types/PrimitiveObject.ts:1](https://github.com/nevoland/quetch/blob/ac27bbd10371e5d511c6f132fbd86a55d2c14316/lib/types/PrimitiveObject.ts#L1)
|
|
@@ -16,4 +16,4 @@ Query that fetches or mutates an entity.
|
|
|
16
16
|
|
|
17
17
|
## Defined in
|
|
18
18
|
|
|
19
|
-
[lib/types/Query.ts:14](https://github.com/nevoland/quetch/blob/
|
|
19
|
+
[lib/types/Query.ts:14](https://github.com/nevoland/quetch/blob/ac27bbd10371e5d511c6f132fbd86a55d2c14316/lib/types/Query.ts#L14)
|
|
@@ -68,4 +68,4 @@ Query settings.
|
|
|
68
68
|
|
|
69
69
|
## Defined in
|
|
70
70
|
|
|
71
|
-
[lib/types/QueryAggregate.ts:11](https://github.com/nevoland/quetch/blob/
|
|
71
|
+
[lib/types/QueryAggregate.ts:11](https://github.com/nevoland/quetch/blob/ac27bbd10371e5d511c6f132fbd86a55d2c14316/lib/types/QueryAggregate.ts#L11)
|
|
@@ -50,4 +50,4 @@ Value properties of the item to create.
|
|
|
50
50
|
|
|
51
51
|
## Defined in
|
|
52
52
|
|
|
53
|
-
[lib/types/QueryCreate.ts:8](https://github.com/nevoland/quetch/blob/
|
|
53
|
+
[lib/types/QueryCreate.ts:8](https://github.com/nevoland/quetch/blob/ac27bbd10371e5d511c6f132fbd86a55d2c14316/lib/types/QueryCreate.ts#L8)
|
|
@@ -48,4 +48,4 @@ Query settings.
|
|
|
48
48
|
|
|
49
49
|
## Defined in
|
|
50
50
|
|
|
51
|
-
[lib/types/QueryCreateMultiple.ts:8](https://github.com/nevoland/quetch/blob/
|
|
51
|
+
[lib/types/QueryCreateMultiple.ts:8](https://github.com/nevoland/quetch/blob/ac27bbd10371e5d511c6f132fbd86a55d2c14316/lib/types/QueryCreateMultiple.ts#L8)
|
|
@@ -48,4 +48,4 @@ Query settings.
|
|
|
48
48
|
|
|
49
49
|
## Defined in
|
|
50
50
|
|
|
51
|
-
[lib/types/QueryDelete.ts:9](https://github.com/nevoland/quetch/blob/
|
|
51
|
+
[lib/types/QueryDelete.ts:9](https://github.com/nevoland/quetch/blob/ac27bbd10371e5d511c6f132fbd86a55d2c14316/lib/types/QueryDelete.ts#L9)
|
|
@@ -48,4 +48,4 @@ Query settings.
|
|
|
48
48
|
|
|
49
49
|
## Defined in
|
|
50
50
|
|
|
51
|
-
[lib/types/QueryDeleteMultiple.ts:9](https://github.com/nevoland/quetch/blob/
|
|
51
|
+
[lib/types/QueryDeleteMultiple.ts:9](https://github.com/nevoland/quetch/blob/ac27bbd10371e5d511c6f132fbd86a55d2c14316/lib/types/QueryDeleteMultiple.ts#L9)
|
|
@@ -12,4 +12,4 @@ Available query methods.
|
|
|
12
12
|
|
|
13
13
|
## Defined in
|
|
14
14
|
|
|
15
|
-
[lib/types/QueryMethod.ts:6](https://github.com/nevoland/quetch/blob/
|
|
15
|
+
[lib/types/QueryMethod.ts:6](https://github.com/nevoland/quetch/blob/ac27bbd10371e5d511c6f132fbd86a55d2c14316/lib/types/QueryMethod.ts#L6)
|
|
@@ -76,4 +76,4 @@ Query settings.
|
|
|
76
76
|
|
|
77
77
|
## Defined in
|
|
78
78
|
|
|
79
|
-
[lib/types/QueryRead.ts:10](https://github.com/nevoland/quetch/blob/
|
|
79
|
+
[lib/types/QueryRead.ts:10](https://github.com/nevoland/quetch/blob/ac27bbd10371e5d511c6f132fbd86a55d2c14316/lib/types/QueryRead.ts#L10)
|
|
@@ -80,4 +80,4 @@ Query settings.
|
|
|
80
80
|
|
|
81
81
|
## Defined in
|
|
82
82
|
|
|
83
|
-
[lib/types/QueryReadMultiple.ts:11](https://github.com/nevoland/quetch/blob/
|
|
83
|
+
[lib/types/QueryReadMultiple.ts:11](https://github.com/nevoland/quetch/blob/ac27bbd10371e5d511c6f132fbd86a55d2c14316/lib/types/QueryReadMultiple.ts#L11)
|
|
@@ -80,4 +80,4 @@ A filter that captures the items expressed by the provided `FilterChildren`.
|
|
|
80
80
|
|
|
81
81
|
## Defined in
|
|
82
82
|
|
|
83
|
-
[lib/types/QuerySettings.ts:8](https://github.com/nevoland/quetch/blob/
|
|
83
|
+
[lib/types/QuerySettings.ts:8](https://github.com/nevoland/quetch/blob/ac27bbd10371e5d511c6f132fbd86a55d2c14316/lib/types/QuerySettings.ts#L8)
|
|
@@ -68,4 +68,4 @@ Partial property values to update.
|
|
|
68
68
|
|
|
69
69
|
## Defined in
|
|
70
70
|
|
|
71
|
-
[lib/types/QueryUpdate.ts:9](https://github.com/nevoland/quetch/blob/
|
|
71
|
+
[lib/types/QueryUpdate.ts:9](https://github.com/nevoland/quetch/blob/ac27bbd10371e5d511c6f132fbd86a55d2c14316/lib/types/QueryUpdate.ts#L9)
|
|
@@ -72,4 +72,4 @@ Partial property values to update.
|
|
|
72
72
|
|
|
73
73
|
## Defined in
|
|
74
74
|
|
|
75
|
-
[lib/types/QueryUpdateMultiple.ts:10](https://github.com/nevoland/quetch/blob/
|
|
75
|
+
[lib/types/QueryUpdateMultiple.ts:10](https://github.com/nevoland/quetch/blob/ac27bbd10371e5d511c6f132fbd86a55d2c14316/lib/types/QueryUpdateMultiple.ts#L10)
|
|
@@ -16,4 +16,4 @@
|
|
|
16
16
|
|
|
17
17
|
## Defined in
|
|
18
18
|
|
|
19
|
-
[lib/types/Result.ts:20](https://github.com/nevoland/quetch/blob/
|
|
19
|
+
[lib/types/Result.ts:20](https://github.com/nevoland/quetch/blob/ac27bbd10371e5d511c6f132fbd86a55d2c14316/lib/types/Result.ts#L20)
|
|
@@ -68,4 +68,4 @@
|
|
|
68
68
|
|
|
69
69
|
## Defined in
|
|
70
70
|
|
|
71
|
-
[lib/types/Store.ts:2](https://github.com/nevoland/quetch/blob/
|
|
71
|
+
[lib/types/Store.ts:2](https://github.com/nevoland/quetch/blob/ac27bbd10371e5d511c6f132fbd86a55d2c14316/lib/types/Store.ts#L2)
|
|
@@ -36,4 +36,4 @@ Path leading to the value.
|
|
|
36
36
|
|
|
37
37
|
## Defined in
|
|
38
38
|
|
|
39
|
-
[lib/types/Value.ts:6](https://github.com/nevoland/quetch/blob/
|
|
39
|
+
[lib/types/Value.ts:6](https://github.com/nevoland/quetch/blob/ac27bbd10371e5d511c6f132fbd86a55d2c14316/lib/types/Value.ts#L6)
|
|
@@ -18,4 +18,4 @@ Maps the properties of the provided value `T` to a specific value `V`.
|
|
|
18
18
|
|
|
19
19
|
## Defined in
|
|
20
20
|
|
|
21
|
-
[lib/types/ValueMap.ts:6](https://github.com/nevoland/quetch/blob/
|
|
21
|
+
[lib/types/ValueMap.ts:6](https://github.com/nevoland/quetch/blob/ac27bbd10371e5d511c6f132fbd86a55d2c14316/lib/types/ValueMap.ts#L6)
|
package/doc/variables/CACHE.md
CHANGED
|
@@ -10,4 +10,4 @@
|
|
|
10
10
|
|
|
11
11
|
## Defined in
|
|
12
12
|
|
|
13
|
-
[lib/constants/CACHE.ts:1](https://github.com/nevoland/quetch/blob/
|
|
13
|
+
[lib/constants/CACHE.ts:1](https://github.com/nevoland/quetch/blob/ac27bbd10371e5d511c6f132fbd86a55d2c14316/lib/constants/CACHE.ts#L1)
|
package/doc/variables/SELF.md
CHANGED
|
@@ -10,4 +10,4 @@
|
|
|
10
10
|
|
|
11
11
|
## Defined in
|
|
12
12
|
|
|
13
|
-
[lib/constants/SELF.ts:1](https://github.com/nevoland/quetch/blob/
|
|
13
|
+
[lib/constants/SELF.ts:1](https://github.com/nevoland/quetch/blob/ac27bbd10371e5d511c6f132fbd86a55d2c14316/lib/constants/SELF.ts#L1)
|
|
@@ -2,10 +2,10 @@ import { expect, test } from "vitest";
|
|
|
2
2
|
|
|
3
3
|
import { SELF } from "../constants.js";
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { filterFromValue } from "./filterFromValue.js";
|
|
6
6
|
|
|
7
7
|
test("returns filter from context", () => {
|
|
8
|
-
expect(
|
|
8
|
+
expect(filterFromValue({ a: 1 })).toEqual({
|
|
9
9
|
operator: "all",
|
|
10
10
|
value: [
|
|
11
11
|
{
|
|
@@ -15,7 +15,7 @@ test("returns filter from context", () => {
|
|
|
15
15
|
},
|
|
16
16
|
],
|
|
17
17
|
});
|
|
18
|
-
expect(
|
|
18
|
+
expect(filterFromValue({ a: { b: 1 } })).toEqual({
|
|
19
19
|
operator: "all",
|
|
20
20
|
value: [
|
|
21
21
|
{
|
|
@@ -25,7 +25,7 @@ test("returns filter from context", () => {
|
|
|
25
25
|
},
|
|
26
26
|
],
|
|
27
27
|
});
|
|
28
|
-
expect(
|
|
28
|
+
expect(filterFromValue({ a: { b: undefined } })).toEqual({
|
|
29
29
|
operator: "all",
|
|
30
30
|
value: [
|
|
31
31
|
{
|
|
@@ -35,7 +35,7 @@ test("returns filter from context", () => {
|
|
|
35
35
|
},
|
|
36
36
|
],
|
|
37
37
|
});
|
|
38
|
-
expect(
|
|
38
|
+
expect(filterFromValue({ a: { b: null } })).toEqual({
|
|
39
39
|
operator: "all",
|
|
40
40
|
value: [
|
|
41
41
|
{
|
|
@@ -45,7 +45,7 @@ test("returns filter from context", () => {
|
|
|
45
45
|
},
|
|
46
46
|
],
|
|
47
47
|
});
|
|
48
|
-
expect(
|
|
48
|
+
expect(filterFromValue({ [SELF]: 3 })).toEqual({
|
|
49
49
|
operator: "all",
|
|
50
50
|
value: [
|
|
51
51
|
{
|
|
@@ -55,7 +55,7 @@ test("returns filter from context", () => {
|
|
|
55
55
|
},
|
|
56
56
|
],
|
|
57
57
|
});
|
|
58
|
-
expect(
|
|
58
|
+
expect(filterFromValue({ a: null })).toEqual({
|
|
59
59
|
operator: "all",
|
|
60
60
|
value: [
|
|
61
61
|
{
|
|
@@ -65,7 +65,7 @@ test("returns filter from context", () => {
|
|
|
65
65
|
},
|
|
66
66
|
],
|
|
67
67
|
});
|
|
68
|
-
expect(
|
|
68
|
+
expect(filterFromValue({ a: { b: 1 }, c: 2 })).toEqual({
|
|
69
69
|
operator: "all",
|
|
70
70
|
value: [
|
|
71
71
|
{
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import { EMPTY_ARRAY } from "unchangeable";
|
|
2
2
|
|
|
3
3
|
import { SELF } from "../constants/SELF.js";
|
|
4
|
-
import type {
|
|
4
|
+
import type { Filter } from "../types.js";
|
|
5
5
|
|
|
6
6
|
const { entries } = Object;
|
|
7
7
|
|
|
8
|
-
export function
|
|
8
|
+
export function filterFromValue<T>(value: T): Filter<T> {
|
|
9
9
|
return {
|
|
10
10
|
operator: "all",
|
|
11
|
-
value: criteria(
|
|
11
|
+
value: criteria(value),
|
|
12
12
|
};
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
function criteria<T>(
|
|
16
|
-
|
|
16
|
+
value: T,
|
|
17
17
|
path: readonly string[] = EMPTY_ARRAY,
|
|
18
18
|
): readonly Filter<T>[] {
|
|
19
|
-
return entriesAndSelf(
|
|
19
|
+
return entriesAndSelf(value).flatMap(([field, value]) => {
|
|
20
20
|
switch (typeof value) {
|
|
21
21
|
case "symbol":
|
|
22
22
|
return [
|
|
@@ -48,7 +48,7 @@ function criteria<T>(
|
|
|
48
48
|
} as Filter<T>,
|
|
49
49
|
];
|
|
50
50
|
}
|
|
51
|
-
return criteria(value, [...path, field as string]);
|
|
51
|
+
return criteria<T>(value, [...path, field as string]);
|
|
52
52
|
}
|
|
53
53
|
default:
|
|
54
54
|
return EMPTY_ARRAY;
|
|
@@ -57,12 +57,26 @@ function criteria<T>(
|
|
|
57
57
|
});
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
function entriesAndSelf(
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
60
|
+
function entriesAndSelf<T>(value: T): readonly [string | typeof SELF, any][] {
|
|
61
|
+
switch (typeof value) {
|
|
62
|
+
case "symbol":
|
|
63
|
+
case "bigint":
|
|
64
|
+
case "string":
|
|
65
|
+
case "number":
|
|
66
|
+
case "boolean":
|
|
67
|
+
case "undefined":
|
|
68
|
+
return [[SELF, value]];
|
|
69
|
+
case "object": {
|
|
70
|
+
if (value == null) {
|
|
71
|
+
return [[SELF, value]];
|
|
72
|
+
}
|
|
73
|
+
const result = entries(value) as [string | typeof SELF, any][];
|
|
74
|
+
if (SELF in value) {
|
|
75
|
+
result.push([SELF, value[SELF]]);
|
|
76
|
+
}
|
|
77
|
+
return result;
|
|
78
|
+
}
|
|
79
|
+
default:
|
|
80
|
+
return EMPTY_ARRAY;
|
|
66
81
|
}
|
|
67
|
-
return result;
|
|
68
82
|
}
|
|
@@ -7,7 +7,7 @@ import type {
|
|
|
7
7
|
Result,
|
|
8
8
|
} from "../types.js";
|
|
9
9
|
|
|
10
|
-
import {
|
|
10
|
+
import { filterFromValue } from "./filterFromValue.js";
|
|
11
11
|
import { sortItemList } from "./sortItemList.js";
|
|
12
12
|
import { testFilter } from "./testFilter.js";
|
|
13
13
|
|
|
@@ -22,11 +22,11 @@ function mergeContextAndFilter<T>(
|
|
|
22
22
|
return filter ?? { operator: "any" };
|
|
23
23
|
}
|
|
24
24
|
if (filter === undefined) {
|
|
25
|
-
return
|
|
25
|
+
return filterFromValue(context as T);
|
|
26
26
|
}
|
|
27
27
|
return {
|
|
28
28
|
operator: "all",
|
|
29
|
-
value: [
|
|
29
|
+
value: [filterFromValue(context as T), filter],
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
32
|
|
|
@@ -4,7 +4,7 @@ import { CACHE } from "../constants/CACHE.js";
|
|
|
4
4
|
import { SELF } from "../constants.js";
|
|
5
5
|
import type { FilterChildren } from "../types.js";
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { filterFromValue } from "./filterFromValue.js";
|
|
8
8
|
import { testFilter } from "./testFilter.js";
|
|
9
9
|
|
|
10
10
|
test("tests filter lists", () => {
|
|
@@ -344,7 +344,7 @@ test("tests filter on array values", () => {
|
|
|
344
344
|
test("tests filter with paths", () => {
|
|
345
345
|
const context = { value: { filter: { field: "label" } } };
|
|
346
346
|
expect(
|
|
347
|
-
testFilter(
|
|
347
|
+
testFilter(filterFromValue(context), {
|
|
348
348
|
value: { filter: { field: "label" } },
|
|
349
349
|
}),
|
|
350
350
|
).toBe(true);
|
package/lib/tools.ts
CHANGED
|
@@ -6,7 +6,7 @@ export { defineGenericFetch } from "./tools/defineGenericFetch.js";
|
|
|
6
6
|
export { escapeRegex } from "./tools/escapeRegex.js";
|
|
7
7
|
export { fieldListFromFilter } from "./tools/fieldListFromFilter.js";
|
|
8
8
|
export { filterChildren } from "./tools/filterChildren.js";
|
|
9
|
-
export {
|
|
9
|
+
export { filterFromValue } from "./tools/filterFromValue.js";
|
|
10
10
|
export { get } from "./tools/get.js";
|
|
11
11
|
export { isFilterGroup } from "./tools/isFilterGroup.js";
|
|
12
12
|
export { normalizeOrder } from "./tools/normalizeOrder.js";
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"filterFromContext.js","sourceRoot":"","sources":["../../lib/tools/filterFromContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAG5C,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC;AAE3B,MAAM,UAAU,iBAAiB,CAAI,OAAmB;IACtD,OAAO;QACL,QAAQ,EAAE,KAAK;QACf,KAAK,EAAE,QAAQ,CAAC,OAAO,CAAC;KACzB,CAAC;AACJ,CAAC;AAED,SAAS,QAAQ,CACf,OAAe,EACf,OAA0B,WAAW;IAErC,OAAO,cAAc,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,EAAE,KAAK,CAAC,EAAE,EAAE;QACxD,QAAQ,OAAO,KAAK,EAAE,CAAC;YACrB,KAAK,QAAQ;gBACX,OAAO;oBACL;wBACE,KAAK,EAAE,IAAI;wBACX,QAAQ,EAAE,OAAO;wBACjB,KAAK;qBACC;iBACT,CAAC;YACJ,KAAK,QAAQ,CAAC;YACd,KAAK,QAAQ,CAAC;YACd,KAAK,QAAQ,CAAC;YACd,KAAK,SAAS,CAAC;YACf,KAAK,WAAW;gBACd,OAAO;oBACL;wBACE,KAAK,EAAE,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,EAAE,KAAK,CAAC;wBACnD,QAAQ,EAAE,OAAO;wBACjB,KAAK;qBACO;iBACf,CAAC;YACJ,KAAK,QAAQ,CAAC,CAAC,CAAC;gBACd,IAAI,KAAK,IAAI,IAAI,EAAE,CAAC;oBAClB,OAAO;wBACL;4BACE,KAAK,EAAE,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,EAAE,KAAK,CAAC;4BACnD,QAAQ,EAAE,OAAO;4BACjB,KAAK;yBACO;qBACf,CAAC;gBACJ,CAAC;gBACD,OAAO,QAAQ,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI,EAAE,KAAe,CAAC,CAAC,CAAC;YACrD,CAAC;YACD;gBACE,OAAO,WAAW,CAAC;YACrB,SAAS;QACX,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAS,cAAc,CACrB,OAAe;IAEf,MAAM,MAAM,GAAG,OAAO,CAAC,OAAO,CAAkC,CAAC;IACjE,IAAI,IAAI,IAAI,OAAO,EAAE,CAAC;QACpB,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACrC,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|