quetch 0.31.1 → 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.
Files changed (120) hide show
  1. package/dist/types/IntersectUnion.d.ts +3 -0
  2. package/dist/types/Prettify.d.ts +6 -0
  3. package/dist/types/Prettify.js +1 -0
  4. package/dist/types/Prettify.js.map +1 -0
  5. package/dist/types/QueryRead.d.ts +2 -1
  6. package/dist/types/QueryReadMultiple.d.ts +2 -1
  7. package/dist/types/Result.d.ts +28 -20
  8. package/dist/types.d.ts +1 -0
  9. package/doc/README.md +1 -0
  10. package/doc/classes/RequestError.md +5 -5
  11. package/doc/functions/aggregate.md +1 -1
  12. package/doc/functions/branch.md +1 -1
  13. package/doc/functions/cache.md +1 -1
  14. package/doc/functions/combine.md +1 -1
  15. package/doc/functions/comparatorFieldValues.md +1 -1
  16. package/doc/functions/cork.md +1 -1
  17. package/doc/functions/defineCheckQuery.md +1 -1
  18. package/doc/functions/defineCustomFetch.md +1 -1
  19. package/doc/functions/defineGenericFetch.md +1 -1
  20. package/doc/functions/escapeRegex.md +1 -1
  21. package/doc/functions/fetchExternal.md +1 -1
  22. package/doc/functions/fetchLocal.md +1 -1
  23. package/doc/functions/fieldListFromFilter.md +1 -1
  24. package/doc/functions/filterChildren.md +1 -1
  25. package/doc/functions/filterFromValue.md +1 -1
  26. package/doc/functions/get.md +1 -1
  27. package/doc/functions/groupFilters.md +1 -1
  28. package/doc/functions/identity.md +1 -1
  29. package/doc/functions/intrinsicFilter.md +1 -1
  30. package/doc/functions/isFilterGroup.md +1 -1
  31. package/doc/functions/log.md +1 -1
  32. package/doc/functions/normalizeOrder.md +1 -1
  33. package/doc/functions/queryItemList.md +1 -1
  34. package/doc/functions/querySettings.md +1 -1
  35. package/doc/functions/retry.md +1 -1
  36. package/doc/functions/reverseOrder.md +1 -1
  37. package/doc/functions/sameField.md +1 -1
  38. package/doc/functions/sortItemList.md +1 -1
  39. package/doc/functions/splitPath.md +2 -2
  40. package/doc/functions/testFilter.md +1 -1
  41. package/doc/functions/transformerFilterChildren.md +1 -1
  42. package/doc/interfaces/CustomFetch.md +1 -1
  43. package/doc/type-aliases/AggregateFunction.md +1 -1
  44. package/doc/type-aliases/AggregateFunctionOperator.md +1 -1
  45. package/doc/type-aliases/CombineUnion.md +1 -1
  46. package/doc/type-aliases/Context.md +1 -1
  47. package/doc/type-aliases/CustomFieldAggregateMap.md +1 -1
  48. package/doc/type-aliases/CustomFieldMap.md +1 -1
  49. package/doc/type-aliases/Decrement.md +1 -1
  50. package/doc/type-aliases/DepthLimit.md +1 -1
  51. package/doc/type-aliases/Field.md +1 -1
  52. package/doc/type-aliases/FieldFiltered.md +1 -1
  53. package/doc/type-aliases/FieldFunction.md +1 -1
  54. package/doc/type-aliases/FieldFunctionCustom.md +1 -1
  55. package/doc/type-aliases/FieldFunctionFormatDate.md +1 -1
  56. package/doc/type-aliases/FieldFunctionReturn.md +1 -1
  57. package/doc/type-aliases/FieldKey.md +1 -1
  58. package/doc/type-aliases/FieldMap.md +1 -1
  59. package/doc/type-aliases/Filter.md +1 -1
  60. package/doc/type-aliases/FilterArray.md +1 -1
  61. package/doc/type-aliases/FilterBoolean.md +1 -1
  62. package/doc/type-aliases/FilterChildren.md +1 -1
  63. package/doc/type-aliases/FilterCustom.md +1 -1
  64. package/doc/type-aliases/FilterField.md +1 -1
  65. package/doc/type-aliases/FilterGroup.md +1 -1
  66. package/doc/type-aliases/FilterNumber.md +1 -1
  67. package/doc/type-aliases/FilterOperator.md +1 -1
  68. package/doc/type-aliases/FilterString.md +1 -1
  69. package/doc/type-aliases/FilterStringIntersect.md +1 -1
  70. package/doc/type-aliases/FilterStringMatch.md +1 -1
  71. package/doc/type-aliases/Get.md +1 -1
  72. package/doc/type-aliases/Group.md +1 -1
  73. package/doc/type-aliases/Handler.md +1 -1
  74. package/doc/type-aliases/Immutable.md +1 -1
  75. package/doc/type-aliases/InjectCustomFields.md +1 -1
  76. package/doc/type-aliases/IntersectUnion.md +3 -1
  77. package/doc/type-aliases/IntrinsicFilter.md +1 -1
  78. package/doc/type-aliases/Item.md +1 -1
  79. package/doc/type-aliases/Join.md +1 -1
  80. package/doc/type-aliases/Key.md +1 -1
  81. package/doc/type-aliases/KeyFiltered.md +1 -1
  82. package/doc/type-aliases/KeyFromUnion.md +1 -1
  83. package/doc/type-aliases/Locale.md +1 -1
  84. package/doc/type-aliases/NextHandler.md +1 -1
  85. package/doc/type-aliases/NormalizedPathFieldSettings.md +1 -1
  86. package/doc/type-aliases/Order.md +1 -1
  87. package/doc/type-aliases/OrderNormalized.md +1 -1
  88. package/doc/type-aliases/Parameters.md +1 -1
  89. package/doc/type-aliases/Path.md +1 -1
  90. package/doc/type-aliases/PathFiltered.md +1 -1
  91. package/doc/type-aliases/Prettify.md +19 -0
  92. package/doc/type-aliases/Primitive.md +1 -1
  93. package/doc/type-aliases/PrimitiveObject.md +1 -1
  94. package/doc/type-aliases/Query.md +1 -1
  95. package/doc/type-aliases/QueryAggregate.md +1 -1
  96. package/doc/type-aliases/QueryCreate.md +1 -1
  97. package/doc/type-aliases/QueryCreateMultiple.md +1 -1
  98. package/doc/type-aliases/QueryDelete.md +1 -1
  99. package/doc/type-aliases/QueryDeleteMultiple.md +1 -1
  100. package/doc/type-aliases/QueryMethod.md +1 -1
  101. package/doc/type-aliases/QueryRead.md +2 -2
  102. package/doc/type-aliases/QueryReadMultiple.md +2 -2
  103. package/doc/type-aliases/QuerySettings.md +1 -1
  104. package/doc/type-aliases/QueryUpdate.md +1 -1
  105. package/doc/type-aliases/QueryUpdateMultiple.md +1 -1
  106. package/doc/type-aliases/Result.md +4 -2
  107. package/doc/type-aliases/Store.md +1 -1
  108. package/doc/type-aliases/Value.md +1 -1
  109. package/doc/type-aliases/ValueMap.md +1 -1
  110. package/doc/variables/CACHE.md +1 -1
  111. package/doc/variables/FILTER_ANY.md +1 -1
  112. package/doc/variables/FILTER_NONE.md +1 -1
  113. package/doc/variables/SELF.md +1 -1
  114. package/lib/types/IntersectUnion.ts +3 -0
  115. package/lib/types/Prettify.ts +8 -0
  116. package/lib/types/QueryRead.ts +2 -1
  117. package/lib/types/QueryReadMultiple.ts +2 -1
  118. package/lib/types/Result.ts +63 -21
  119. package/lib/types.ts +1 -0
  120. package/package.json +4 -2
@@ -10,4 +10,4 @@
10
10
 
11
11
  ## Defined in
12
12
 
13
- [lib/types/FilterOperator.ts:3](https://github.com/nevoland/quetch/blob/11efc4791b6b46376df8dcc576f30e0b288063ba/lib/types/FilterOperator.ts#L3)
13
+ [lib/types/FilterOperator.ts:3](https://github.com/nevoland/quetch/blob/f290c9f2f51b8b7accd7522858dc7670791c1cb4/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/11efc4791b6b46376df8dcc576f30e0b288063ba/lib/types/FilterString.ts#L8)
37
+ [lib/types/FilterString.ts:8](https://github.com/nevoland/quetch/blob/f290c9f2f51b8b7accd7522858dc7670791c1cb4/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/11efc4791b6b46376df8dcc576f30e0b288063ba/lib/types/FilterStringIntersect.ts#L8)
37
+ [lib/types/FilterStringIntersect.ts:8](https://github.com/nevoland/quetch/blob/f290c9f2f51b8b7accd7522858dc7670791c1cb4/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/11efc4791b6b46376df8dcc576f30e0b288063ba/lib/types/FilterStringMatch.ts#L9)
53
+ [lib/types/FilterStringMatch.ts:9](https://github.com/nevoland/quetch/blob/f290c9f2f51b8b7accd7522858dc7670791c1cb4/lib/types/FilterStringMatch.ts#L9)
@@ -20,4 +20,4 @@ Returns the type of the property at the specified `P` path.
20
20
 
21
21
  ## Defined in
22
22
 
23
- [lib/types/Get.ts:8](https://github.com/nevoland/quetch/blob/11efc4791b6b46376df8dcc576f30e0b288063ba/lib/types/Get.ts#L8)
23
+ [lib/types/Get.ts:8](https://github.com/nevoland/quetch/blob/f290c9f2f51b8b7accd7522858dc7670791c1cb4/lib/types/Get.ts#L8)
@@ -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/11efc4791b6b46376df8dcc576f30e0b288063ba/lib/types/Group.ts#L4)
19
+ [lib/types/Group.ts:4](https://github.com/nevoland/quetch/blob/f290c9f2f51b8b7accd7522858dc7670791c1cb4/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/11efc4791b6b46376df8dcc576f30e0b288063ba/lib/types/Handler.ts#L6)
39
+ [lib/types/Handler.ts:6](https://github.com/nevoland/quetch/blob/f290c9f2f51b8b7accd7522858dc7670791c1cb4/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/11efc4791b6b46376df8dcc576f30e0b288063ba/lib/types/Immutable.ts#L1)
17
+ [lib/types/Immutable.ts:1](https://github.com/nevoland/quetch/blob/f290c9f2f51b8b7accd7522858dc7670791c1cb4/lib/types/Immutable.ts#L1)
@@ -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/11efc4791b6b46376df8dcc576f30e0b288063ba/lib/types/InjectCustomFields.ts#L8)
21
+ [lib/types/InjectCustomFields.ts:8](https://github.com/nevoland/quetch/blob/f290c9f2f51b8b7accd7522858dc7670791c1cb4/lib/types/InjectCustomFields.ts#L8)
@@ -8,10 +8,12 @@
8
8
 
9
9
  > **IntersectUnion**\<`T`\>: `T` *extends* `any` ? (`_`) => `void` : `never` *extends* (`_`) => `void` ? `U` : `never`
10
10
 
11
+ Converts a union type to an intersection type.
12
+
11
13
  ## Type Parameters
12
14
 
13
15
  • **T**
14
16
 
15
17
  ## Defined in
16
18
 
17
- [lib/types/IntersectUnion.ts:1](https://github.com/nevoland/quetch/blob/11efc4791b6b46376df8dcc576f30e0b288063ba/lib/types/IntersectUnion.ts#L1)
19
+ [lib/types/IntersectUnion.ts:4](https://github.com/nevoland/quetch/blob/f290c9f2f51b8b7accd7522858dc7670791c1cb4/lib/types/IntersectUnion.ts#L4)
@@ -16,4 +16,4 @@ Filter that does not rely on query settings, and thus can be evaluated directly
16
16
 
17
17
  ## Defined in
18
18
 
19
- [lib/types/IntrinsicFilter.ts:6](https://github.com/nevoland/quetch/blob/11efc4791b6b46376df8dcc576f30e0b288063ba/lib/types/IntrinsicFilter.ts#L6)
19
+ [lib/types/IntrinsicFilter.ts:6](https://github.com/nevoland/quetch/blob/f290c9f2f51b8b7accd7522858dc7670791c1cb4/lib/types/IntrinsicFilter.ts#L6)
@@ -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/11efc4791b6b46376df8dcc576f30e0b288063ba/lib/types/Item.ts#L4)
21
+ [lib/types/Item.ts:4](https://github.com/nevoland/quetch/blob/f290c9f2f51b8b7accd7522858dc7670791c1cb4/lib/types/Item.ts#L4)
@@ -16,4 +16,4 @@
16
16
 
17
17
  ## Defined in
18
18
 
19
- [lib/types/Join.ts:1](https://github.com/nevoland/quetch/blob/11efc4791b6b46376df8dcc576f30e0b288063ba/lib/types/Join.ts#L1)
19
+ [lib/types/Join.ts:1](https://github.com/nevoland/quetch/blob/f290c9f2f51b8b7accd7522858dc7670791c1cb4/lib/types/Join.ts#L1)
@@ -10,4 +10,4 @@
10
10
 
11
11
  ## Defined in
12
12
 
13
- [lib/types/Key.ts:1](https://github.com/nevoland/quetch/blob/11efc4791b6b46376df8dcc576f30e0b288063ba/lib/types/Key.ts#L1)
13
+ [lib/types/Key.ts:1](https://github.com/nevoland/quetch/blob/f290c9f2f51b8b7accd7522858dc7670791c1cb4/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/11efc4791b6b46376df8dcc576f30e0b288063ba/lib/types/KeyFiltered.ts#L10)
21
+ [lib/types/KeyFiltered.ts:10](https://github.com/nevoland/quetch/blob/f290c9f2f51b8b7accd7522858dc7670791c1cb4/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/11efc4791b6b46376df8dcc576f30e0b288063ba/lib/types/KeyFromUnion.ts#L1)
17
+ [lib/types/KeyFromUnion.ts:1](https://github.com/nevoland/quetch/blob/f290c9f2f51b8b7accd7522858dc7670791c1cb4/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/11efc4791b6b46376df8dcc576f30e0b288063ba/lib/types/Locale.ts#L1)
13
+ [lib/types/Locale.ts:1](https://github.com/nevoland/quetch/blob/f290c9f2f51b8b7accd7522858dc7670791c1cb4/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/11efc4791b6b46376df8dcc576f30e0b288063ba/lib/types/NextHandler.ts#L4)
31
+ [lib/types/NextHandler.ts:4](https://github.com/nevoland/quetch/blob/f290c9f2f51b8b7accd7522858dc7670791c1cb4/lib/types/NextHandler.ts#L4)
@@ -54,4 +54,4 @@ String used to escape the separator.
54
54
 
55
55
  ## Defined in
56
56
 
57
- [lib/types/NormalizedPathFieldSettings.ts:6](https://github.com/nevoland/quetch/blob/11efc4791b6b46376df8dcc576f30e0b288063ba/lib/types/NormalizedPathFieldSettings.ts#L6)
57
+ [lib/types/NormalizedPathFieldSettings.ts:6](https://github.com/nevoland/quetch/blob/f290c9f2f51b8b7accd7522858dc7670791c1cb4/lib/types/NormalizedPathFieldSettings.ts#L6)
@@ -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/11efc4791b6b46376df8dcc576f30e0b288063ba/lib/types/Order.ts#L6)
19
+ [lib/types/Order.ts:6](https://github.com/nevoland/quetch/blob/f290c9f2f51b8b7accd7522858dc7670791c1cb4/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/11efc4791b6b46376df8dcc576f30e0b288063ba/lib/types/OrderNormalized.ts#L3)
27
+ [lib/types/OrderNormalized.ts:3](https://github.com/nevoland/quetch/blob/f290c9f2f51b8b7accd7522858dc7670791c1cb4/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/11efc4791b6b46376df8dcc576f30e0b288063ba/lib/types/Parameters.ts#L1)
13
+ [lib/types/Parameters.ts:1](https://github.com/nevoland/quetch/blob/f290c9f2f51b8b7accd7522858dc7670791c1cb4/lib/types/Parameters.ts#L1)
@@ -16,4 +16,4 @@
16
16
 
17
17
  ## Defined in
18
18
 
19
- [lib/types/Path.ts:6](https://github.com/nevoland/quetch/blob/11efc4791b6b46376df8dcc576f30e0b288063ba/lib/types/Path.ts#L6)
19
+ [lib/types/Path.ts:6](https://github.com/nevoland/quetch/blob/f290c9f2f51b8b7accd7522858dc7670791c1cb4/lib/types/Path.ts#L6)
@@ -18,4 +18,4 @@
18
18
 
19
19
  ## Defined in
20
20
 
21
- [lib/types/PathFiltered.ts:5](https://github.com/nevoland/quetch/blob/11efc4791b6b46376df8dcc576f30e0b288063ba/lib/types/PathFiltered.ts#L5)
21
+ [lib/types/PathFiltered.ts:5](https://github.com/nevoland/quetch/blob/f290c9f2f51b8b7accd7522858dc7670791c1cb4/lib/types/PathFiltered.ts#L5)
@@ -0,0 +1,19 @@
1
+ [**quetch**](../README.md)
2
+
3
+ ***
4
+
5
+ [quetch](../README.md) / Prettify
6
+
7
+ # Type Alias: Prettify\<T\>
8
+
9
+ > **Prettify**\<`T`\>: `T` *extends* (...`args`) => `any` ? `T` : `T` *extends* readonly `any`[] ? `T` : `{ [K in keyof T]: Prettify<T[K]> }`
10
+
11
+ Prettifies a type by recursively removing any intersections or unions.
12
+
13
+ ## Type Parameters
14
+
15
+ • **T**
16
+
17
+ ## Defined in
18
+
19
+ [lib/types/Prettify.ts:4](https://github.com/nevoland/quetch/blob/f290c9f2f51b8b7accd7522858dc7670791c1cb4/lib/types/Prettify.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/11efc4791b6b46376df8dcc576f30e0b288063ba/lib/types/Primitive.ts#L1)
13
+ [lib/types/Primitive.ts:1](https://github.com/nevoland/quetch/blob/f290c9f2f51b8b7accd7522858dc7670791c1cb4/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/11efc4791b6b46376df8dcc576f30e0b288063ba/lib/types/PrimitiveObject.ts#L1)
13
+ [lib/types/PrimitiveObject.ts:1](https://github.com/nevoland/quetch/blob/f290c9f2f51b8b7accd7522858dc7670791c1cb4/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/11efc4791b6b46376df8dcc576f30e0b288063ba/lib/types/Query.ts#L14)
19
+ [lib/types/Query.ts:14](https://github.com/nevoland/quetch/blob/f290c9f2f51b8b7accd7522858dc7670791c1cb4/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/11efc4791b6b46376df8dcc576f30e0b288063ba/lib/types/QueryAggregate.ts#L11)
71
+ [lib/types/QueryAggregate.ts:11](https://github.com/nevoland/quetch/blob/f290c9f2f51b8b7accd7522858dc7670791c1cb4/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/11efc4791b6b46376df8dcc576f30e0b288063ba/lib/types/QueryCreate.ts#L8)
53
+ [lib/types/QueryCreate.ts:8](https://github.com/nevoland/quetch/blob/f290c9f2f51b8b7accd7522858dc7670791c1cb4/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/11efc4791b6b46376df8dcc576f30e0b288063ba/lib/types/QueryCreateMultiple.ts#L8)
51
+ [lib/types/QueryCreateMultiple.ts:8](https://github.com/nevoland/quetch/blob/f290c9f2f51b8b7accd7522858dc7670791c1cb4/lib/types/QueryCreateMultiple.ts#L8)
@@ -60,4 +60,4 @@ Query settings.
60
60
 
61
61
  ## Defined in
62
62
 
63
- [lib/types/QueryDelete.ts:9](https://github.com/nevoland/quetch/blob/11efc4791b6b46376df8dcc576f30e0b288063ba/lib/types/QueryDelete.ts#L9)
63
+ [lib/types/QueryDelete.ts:9](https://github.com/nevoland/quetch/blob/f290c9f2f51b8b7accd7522858dc7670791c1cb4/lib/types/QueryDelete.ts#L9)
@@ -62,4 +62,4 @@ Query settings.
62
62
 
63
63
  ## Defined in
64
64
 
65
- [lib/types/QueryDeleteMultiple.ts:9](https://github.com/nevoland/quetch/blob/11efc4791b6b46376df8dcc576f30e0b288063ba/lib/types/QueryDeleteMultiple.ts#L9)
65
+ [lib/types/QueryDeleteMultiple.ts:9](https://github.com/nevoland/quetch/blob/f290c9f2f51b8b7accd7522858dc7670791c1cb4/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/11efc4791b6b46376df8dcc576f30e0b288063ba/lib/types/QueryMethod.ts#L6)
15
+ [lib/types/QueryMethod.ts:6](https://github.com/nevoland/quetch/blob/f290c9f2f51b8b7accd7522858dc7670791c1cb4/lib/types/QueryMethod.ts#L6)
@@ -24,7 +24,7 @@ Common item properties to use for identifying the context in which to get the it
24
24
 
25
25
  ### fields?
26
26
 
27
- > `optional` **fields**: readonly keyof `T`[]
27
+ > `optional` **fields**: readonly [`Field`](Field.md)\<`T`\>[]
28
28
 
29
29
  Item fields to pick. If omitted, all fields are picked.
30
30
 
@@ -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/11efc4791b6b46376df8dcc576f30e0b288063ba/lib/types/QueryRead.ts#L10)
79
+ [lib/types/QueryRead.ts:11](https://github.com/nevoland/quetch/blob/f290c9f2f51b8b7accd7522858dc7670791c1cb4/lib/types/QueryRead.ts#L11)
@@ -24,7 +24,7 @@ Common item properties to use for identifying the item.
24
24
 
25
25
  ### fields?
26
26
 
27
- > `optional` **fields**: readonly keyof `T`[]
27
+ > `optional` **fields**: readonly [`Field`](Field.md)\<`T`\>[]
28
28
 
29
29
  Item fields to pick. If omitted, all fields are picked.
30
30
 
@@ -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/11efc4791b6b46376df8dcc576f30e0b288063ba/lib/types/QueryReadMultiple.ts#L11)
83
+ [lib/types/QueryReadMultiple.ts:12](https://github.com/nevoland/quetch/blob/f290c9f2f51b8b7accd7522858dc7670791c1cb4/lib/types/QueryReadMultiple.ts#L12)
@@ -86,4 +86,4 @@ The second value to compare.
86
86
 
87
87
  ## Defined in
88
88
 
89
- [lib/types/QuerySettings.ts:8](https://github.com/nevoland/quetch/blob/11efc4791b6b46376df8dcc576f30e0b288063ba/lib/types/QuerySettings.ts#L8)
89
+ [lib/types/QuerySettings.ts:8](https://github.com/nevoland/quetch/blob/f290c9f2f51b8b7accd7522858dc7670791c1cb4/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/11efc4791b6b46376df8dcc576f30e0b288063ba/lib/types/QueryUpdate.ts#L9)
71
+ [lib/types/QueryUpdate.ts:9](https://github.com/nevoland/quetch/blob/f290c9f2f51b8b7accd7522858dc7670791c1cb4/lib/types/QueryUpdate.ts#L9)
@@ -74,4 +74,4 @@ Partial property values to update.
74
74
 
75
75
  ## Defined in
76
76
 
77
- [lib/types/QueryUpdateMultiple.ts:10](https://github.com/nevoland/quetch/blob/11efc4791b6b46376df8dcc576f30e0b288063ba/lib/types/QueryUpdateMultiple.ts#L10)
77
+ [lib/types/QueryUpdateMultiple.ts:10](https://github.com/nevoland/quetch/blob/f290c9f2f51b8b7accd7522858dc7670791c1cb4/lib/types/QueryUpdateMultiple.ts#L10)
@@ -6,7 +6,9 @@
6
6
 
7
7
  # Type Alias: Result\<T, Q\>
8
8
 
9
- > **Result**\<`T`, `Q`\>: [`Q`] *extends* [`object`] ? [`Q`] *extends* [`object`] ? readonly `ResultRead`\<`T`, `Q`\>[] : `ResultRead`\<`T`, `Q`\> : [`Q`] *extends* [`object`] ? `number` : [`Q`] *extends* [`object`] ? readonly `ResultRead`\<`T`, `Q`\>[] : `ResultRead`\<`T`, `Q`\>
9
+ > **Result**\<`T`, `Q`\>: [`Q`] *extends* [[`QueryReadMultiple`](QueryReadMultiple.md)\<`T`\>] ? readonly `ResultRead`\<`T`, `Q`\>[] : [`Q`] *extends* [[`QueryRead`](QueryRead.md)\<`T`\>] ? `ResultRead`\<`T`, `Q`\> : [`Q`] *extends* [`object`] ? `number` : `never`
10
+
11
+ Result of a read and aggregate query.
10
12
 
11
13
  ## Type Parameters
12
14
 
@@ -16,4 +18,4 @@
16
18
 
17
19
  ## Defined in
18
20
 
19
- [lib/types/Result.ts:20](https://github.com/nevoland/quetch/blob/11efc4791b6b46376df8dcc576f30e0b288063ba/lib/types/Result.ts#L20)
21
+ [lib/types/Result.ts:64](https://github.com/nevoland/quetch/blob/f290c9f2f51b8b7accd7522858dc7670791c1cb4/lib/types/Result.ts#L64)
@@ -68,4 +68,4 @@
68
68
 
69
69
  ## Defined in
70
70
 
71
- [lib/types/Store.ts:2](https://github.com/nevoland/quetch/blob/11efc4791b6b46376df8dcc576f30e0b288063ba/lib/types/Store.ts#L2)
71
+ [lib/types/Store.ts:2](https://github.com/nevoland/quetch/blob/f290c9f2f51b8b7accd7522858dc7670791c1cb4/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/11efc4791b6b46376df8dcc576f30e0b288063ba/lib/types/Value.ts#L6)
39
+ [lib/types/Value.ts:6](https://github.com/nevoland/quetch/blob/f290c9f2f51b8b7accd7522858dc7670791c1cb4/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/11efc4791b6b46376df8dcc576f30e0b288063ba/lib/types/ValueMap.ts#L6)
21
+ [lib/types/ValueMap.ts:6](https://github.com/nevoland/quetch/blob/f290c9f2f51b8b7accd7522858dc7670791c1cb4/lib/types/ValueMap.ts#L6)
@@ -10,4 +10,4 @@
10
10
 
11
11
  ## Defined in
12
12
 
13
- [lib/constants/CACHE.ts:1](https://github.com/nevoland/quetch/blob/11efc4791b6b46376df8dcc576f30e0b288063ba/lib/constants/CACHE.ts#L1)
13
+ [lib/constants/CACHE.ts:1](https://github.com/nevoland/quetch/blob/f290c9f2f51b8b7accd7522858dc7670791c1cb4/lib/constants/CACHE.ts#L1)
@@ -16,4 +16,4 @@
16
16
 
17
17
  ## Defined in
18
18
 
19
- [lib/constants/FILTER\_ANY.ts:1](https://github.com/nevoland/quetch/blob/11efc4791b6b46376df8dcc576f30e0b288063ba/lib/constants/FILTER_ANY.ts#L1)
19
+ [lib/constants/FILTER\_ANY.ts:1](https://github.com/nevoland/quetch/blob/f290c9f2f51b8b7accd7522858dc7670791c1cb4/lib/constants/FILTER_ANY.ts#L1)
@@ -16,4 +16,4 @@
16
16
 
17
17
  ## Defined in
18
18
 
19
- [lib/constants/FILTER\_NONE.ts:1](https://github.com/nevoland/quetch/blob/11efc4791b6b46376df8dcc576f30e0b288063ba/lib/constants/FILTER_NONE.ts#L1)
19
+ [lib/constants/FILTER\_NONE.ts:1](https://github.com/nevoland/quetch/blob/f290c9f2f51b8b7accd7522858dc7670791c1cb4/lib/constants/FILTER_NONE.ts#L1)
@@ -10,4 +10,4 @@
10
10
 
11
11
  ## Defined in
12
12
 
13
- [lib/constants/SELF.ts:1](https://github.com/nevoland/quetch/blob/11efc4791b6b46376df8dcc576f30e0b288063ba/lib/constants/SELF.ts#L1)
13
+ [lib/constants/SELF.ts:1](https://github.com/nevoland/quetch/blob/f290c9f2f51b8b7accd7522858dc7670791c1cb4/lib/constants/SELF.ts#L1)
@@ -1,3 +1,6 @@
1
+ /**
2
+ * Converts a union type to an intersection type.
3
+ */
1
4
  export type IntersectUnion<T> = (
2
5
  T extends any ? (_: T) => void : never
3
6
  ) extends (_: infer U) => void
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Prettifies a type by recursively removing any intersections or unions.
3
+ */
4
+ export type Prettify<T> = T extends (...args: any[]) => any
5
+ ? T
6
+ : T extends readonly any[]
7
+ ? T
8
+ : { [K in keyof T]: Prettify<T[K]> };
@@ -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 (keyof T)[];
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 (keyof T)[];
30
+ fields?: readonly Field<T>[];
30
31
  /**
31
32
  * Filter for finding the items.
32
33
  */
@@ -1,28 +1,70 @@
1
- import type { Item } from "./Item";
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
- export type PickFields<T, F extends string | number | symbol> = [F] extends [
8
- keyof T,
9
- ]
10
- ? { readonly [K in F]: T[K] }
11
- : { readonly [K in keyof T]: T[K] };
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
- export type ResultRead<T, Q extends Query<T>> = [Q] extends [
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
- export type Result<T, Q extends Query<T>> = [Q] extends [{ method: "read" }]
21
- ? [Q] extends [{ multiple: true }]
22
- ? readonly ResultRead<T, Q>[]
23
- : ResultRead<T, Q>
24
- : [Q] extends [{ method: "aggregate" }]
25
- ? number
26
- : [Q] extends [{ multiple: true }]
27
- ? readonly ResultRead<T, Q>[]
28
- : ResultRead<T, Q>;
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.31.1",
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:trace": "tsc --project tsconfig.package.json --noEmit --generateTrace ./trace",
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",