quetch 0.18.2 → 0.19.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 (159) hide show
  1. package/dist/constants/SymbolSelf.d.ts +1 -0
  2. package/dist/constants/SymbolSelf.js +2 -0
  3. package/dist/constants/SymbolSelf.js.map +1 -0
  4. package/dist/constants.d.ts +1 -0
  5. package/dist/constants.js +1 -0
  6. package/dist/constants.js.map +1 -1
  7. package/dist/middlewares/fetchLocal.d.ts +1 -1
  8. package/dist/tools/defineCheckQuery.d.ts +1 -1
  9. package/dist/tools/defineCustomFetch.d.ts +1 -1
  10. package/dist/tools/defineGenericFetch.d.ts +1 -1
  11. package/dist/tools/fieldListFromFilter.d.ts +1 -1
  12. package/dist/tools/filterChildren.d.ts +1 -1
  13. package/dist/tools/filterFromContext.d.ts +1 -1
  14. package/dist/tools/filterFromContext.js +11 -1
  15. package/dist/tools/filterFromContext.js.map +1 -1
  16. package/dist/tools/get.d.ts +2 -2
  17. package/dist/tools/get.js +2 -0
  18. package/dist/tools/get.js.map +1 -1
  19. package/dist/tools/isFilterGroup.d.ts +1 -1
  20. package/dist/tools/normalizeOrder.d.ts +1 -1
  21. package/dist/tools/normalizeOrder.js.map +1 -1
  22. package/dist/tools/queryItemList.d.ts +1 -1
  23. package/dist/tools/reverseOrder.d.ts +1 -1
  24. package/dist/tools/reverseOrder.js.map +1 -1
  25. package/dist/tools/sortItemList.d.ts +1 -1
  26. package/dist/tools/sortItemList.js.map +1 -1
  27. package/dist/tools/testFilter.d.ts +1 -1
  28. package/dist/tools/testFilter.js.map +1 -1
  29. package/dist/types/AggregateFunction.d.ts +3 -2
  30. package/dist/types/CombineUnion.d.ts +9 -0
  31. package/dist/types/CombineUnion.js +1 -0
  32. package/dist/types/CombineUnion.js.map +1 -0
  33. package/dist/types/Context.d.ts +1 -1
  34. package/dist/types/CustomFetch.d.ts +1 -1
  35. package/dist/types/CustomFieldAggregateMap.d.ts +1 -1
  36. package/dist/types/CustomFieldMap.d.ts +1 -1
  37. package/dist/types/Field.d.ts +4 -2
  38. package/dist/types/FieldFiltered.d.ts +4 -2
  39. package/dist/types/FieldFunction.d.ts +1 -1
  40. package/dist/types/FieldFunctionCustom.d.ts +1 -1
  41. package/dist/types/FieldFunctionFormatDate.d.ts +1 -1
  42. package/dist/types/Filter.d.ts +1 -1
  43. package/dist/types/FilterArray.d.ts +1 -2
  44. package/dist/types/FilterBoolean.d.ts +1 -1
  45. package/dist/types/FilterChildren.d.ts +1 -1
  46. package/dist/types/FilterCustom.d.ts +1 -1
  47. package/dist/types/FilterField.d.ts +1 -1
  48. package/dist/types/FilterGroup.d.ts +1 -1
  49. package/dist/types/FilterNumber.d.ts +1 -1
  50. package/dist/types/FilterString.d.ts +1 -1
  51. package/dist/types/FilterStringIntersect.d.ts +1 -1
  52. package/dist/types/FilterStringMatch.d.ts +1 -1
  53. package/dist/types/Get.d.ts +1 -1
  54. package/dist/types/Group.d.ts +1 -1
  55. package/dist/types/Immutable.d.ts +1 -1
  56. package/dist/types/InjectCustomFields.d.ts +1 -1
  57. package/dist/types/KeyFiltered.d.ts +10 -4
  58. package/dist/types/KeyFromUnion.d.ts +1 -0
  59. package/dist/types/KeyFromUnion.js +1 -0
  60. package/dist/types/KeyFromUnion.js.map +1 -0
  61. package/dist/types/Order.d.ts +1 -1
  62. package/dist/types/Path.d.ts +4 -2
  63. package/dist/types/PathFiltered.d.ts +3 -2
  64. package/dist/types/Primitive.d.ts +1 -0
  65. package/dist/types/Primitive.js +1 -0
  66. package/dist/types/Primitive.js.map +1 -0
  67. package/dist/types/Query.d.ts +2 -2
  68. package/dist/types/QueryAggregate.d.ts +1 -1
  69. package/dist/types/QueryCreate.d.ts +1 -1
  70. package/dist/types/QueryCreateMultiple.d.ts +1 -1
  71. package/dist/types/QueryDelete.d.ts +1 -1
  72. package/dist/types/QueryDeleteMultiple.d.ts +1 -1
  73. package/dist/types/QueryRead.d.ts +1 -1
  74. package/dist/types/QueryReadMultiple.d.ts +1 -1
  75. package/dist/types/QuerySettings.d.ts +1 -1
  76. package/dist/types/QueryUpdate.d.ts +1 -1
  77. package/dist/types/QueryUpdateMultiple.d.ts +1 -1
  78. package/dist/types/Result.d.ts +7 -7
  79. package/dist/types/Value.d.ts +1 -1
  80. package/dist/types.d.ts +3 -3
  81. package/lib/constants/SymbolSelf.ts +1 -0
  82. package/lib/constants.ts +1 -0
  83. package/lib/middlewares/fetchLocal.ts +1 -1
  84. package/lib/tools/defineCheckQuery.ts +1 -1
  85. package/lib/tools/defineCustomFetch.ts +1 -1
  86. package/lib/tools/defineGenericFetch.ts +1 -1
  87. package/lib/tools/fieldListFromFilter.ts +1 -1
  88. package/lib/tools/filterChildren.ts +1 -1
  89. package/lib/tools/filterFromContext.test.ts +30 -0
  90. package/lib/tools/filterFromContext.ts +13 -5
  91. package/lib/tools/get.test.ts +1 -0
  92. package/lib/tools/get.ts +14 -9
  93. package/lib/tools/isFilterGroup.ts +1 -1
  94. package/lib/tools/normalizeOrder.ts +1 -3
  95. package/lib/tools/queryItemList.test.ts +2 -2
  96. package/lib/tools/queryItemList.ts +3 -3
  97. package/lib/tools/reverseOrder.ts +1 -3
  98. package/lib/tools/sortItemList.ts +3 -3
  99. package/lib/tools/testFilter.test.ts +1 -1
  100. package/lib/tools/testFilter.ts +6 -9
  101. package/lib/types/AggregateFunction.ts +3 -2
  102. package/lib/types/CombineUnion.ts +18 -0
  103. package/lib/types/Context.ts +1 -1
  104. package/lib/types/CustomFetch.ts +1 -1
  105. package/lib/types/CustomFieldAggregateMap.ts +1 -4
  106. package/lib/types/CustomFieldMap.ts +1 -1
  107. package/lib/types/Field.ts +4 -4
  108. package/lib/types/FieldFiltered.ts +4 -4
  109. package/lib/types/FieldFunction.ts +1 -1
  110. package/lib/types/FieldFunctionCustom.ts +1 -1
  111. package/lib/types/FieldFunctionFormatDate.ts +1 -1
  112. package/lib/types/Filter.ts +1 -1
  113. package/lib/types/FilterArray.ts +1 -2
  114. package/lib/types/FilterBoolean.ts +1 -1
  115. package/lib/types/FilterChildren.ts +1 -1
  116. package/lib/types/FilterCustom.ts +1 -1
  117. package/lib/types/FilterField.ts +1 -1
  118. package/lib/types/FilterGroup.ts +1 -1
  119. package/lib/types/FilterNumber.ts +1 -1
  120. package/lib/types/FilterString.ts +1 -1
  121. package/lib/types/FilterStringIntersect.ts +1 -1
  122. package/lib/types/FilterStringMatch.ts +1 -1
  123. package/lib/types/Get.ts +1 -1
  124. package/lib/types/Group.ts +1 -1
  125. package/lib/types/Immutable.ts +1 -1
  126. package/lib/types/InjectCustomFields.ts +1 -4
  127. package/lib/types/KeyFiltered.ts +29 -5
  128. package/lib/types/KeyFromUnion.ts +1 -0
  129. package/lib/types/Order.ts +1 -1
  130. package/lib/types/Path.ts +15 -9
  131. package/lib/types/PathFiltered.ts +16 -13
  132. package/lib/types/Primitive.ts +1 -0
  133. package/lib/types/Query.ts +2 -2
  134. package/lib/types/QueryAggregate.ts +1 -1
  135. package/lib/types/QueryCreate.ts +1 -1
  136. package/lib/types/QueryCreateMultiple.ts +1 -1
  137. package/lib/types/QueryDelete.ts +1 -1
  138. package/lib/types/QueryDeleteMultiple.ts +1 -1
  139. package/lib/types/QueryRead.ts +1 -1
  140. package/lib/types/QueryReadMultiple.ts +1 -1
  141. package/lib/types/QuerySettings.ts +1 -1
  142. package/lib/types/QueryUpdate.ts +1 -1
  143. package/lib/types/QueryUpdateMultiple.ts +1 -1
  144. package/lib/types/Result.ts +5 -8
  145. package/lib/types/Value.ts +1 -1
  146. package/lib/types.ts +3 -3
  147. package/package.json +6 -5
  148. package/dist/types/Any.d.ts +0 -1
  149. package/dist/types/Any.js +0 -1
  150. package/dist/types/Any.js.map +0 -1
  151. package/dist/types/Mutable.d.ts +0 -3
  152. package/dist/types/Mutable.js +0 -1
  153. package/dist/types/Mutable.js.map +0 -1
  154. package/dist/types/Normalized.d.ts +0 -2
  155. package/dist/types/Normalized.js +0 -1
  156. package/dist/types/Normalized.js.map +0 -1
  157. package/lib/types/Any.ts +0 -10
  158. package/lib/types/Mutable.ts +0 -3
  159. package/lib/types/Normalized.ts +0 -3
@@ -3,7 +3,7 @@ import type { FieldFiltered } from "./FieldFiltered";
3
3
  /**
4
4
  * Formats the date found in a given field, which can be an ISO string date or a timestamp.
5
5
  */
6
- export type FieldFunctionFormatDate<T extends object> = {
6
+ export type FieldFunctionFormatDate<T> = {
7
7
  operator: "formatDate";
8
8
  field: FieldFiltered<T, string | number>;
9
9
  format: string;
@@ -12,7 +12,7 @@ import type { FilterStringMatch } from "./FilterStringMatch";
12
12
  /**
13
13
  * Describes a predicate for filtering items.
14
14
  */
15
- export type Filter<T extends object> =
15
+ export type Filter<T> =
16
16
  | FilterArray<T>
17
17
  | FilterBoolean<T>
18
18
  | FilterChildren<T>
@@ -1,4 +1,3 @@
1
- import type { Any } from "./Any";
2
1
  import type { FieldFiltered } from "./FieldFiltered";
3
2
  import type { Value } from "./Value";
4
3
 
@@ -9,7 +8,7 @@ import type { Value } from "./Value";
9
8
  * - `include` requires every value to be present in the array.
10
9
  * - `intersect` requires at least one item of the value to be present in the array.
11
10
  */
12
- export type FilterArray<T extends object, P = Any> = {
11
+ export type FilterArray<T, P = any> = {
13
12
  operator: "equal" | "include" | "intersect";
14
13
  field: FieldFiltered<T, P[]>;
15
14
  } & Value<T, P[]>;
@@ -4,7 +4,7 @@ import type { Value } from "./Value";
4
4
  /**
5
5
  * Checks if a given boolean field is `true` or `false`.
6
6
  */
7
- export type FilterBoolean<T extends object> = {
7
+ export type FilterBoolean<T> = {
8
8
  operator: "equal" | "notEqual";
9
9
  field: FieldFiltered<T, boolean>;
10
10
  } & Value<T, boolean>;
@@ -7,7 +7,7 @@ import type { Filter } from "./Filter";
7
7
  * Matches the direct children of a specified `value` item.
8
8
  * If `deep` is `true`, also captures all the descendants.
9
9
  */
10
- export type FilterChildren<T extends object> = {
10
+ export type FilterChildren<T> = {
11
11
  operator: "children";
12
12
  value?: Context<T> | string;
13
13
  deep?: boolean;
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Custom filter where `value(item)` returns `true` for matching items.
3
3
  */
4
- export type FilterCustom<T extends object> = {
4
+ export type FilterCustom<T> = {
5
5
  operator: "custom";
6
6
  value: (item: T) => boolean;
7
7
  };
@@ -3,7 +3,7 @@ import type { Field } from "./Field";
3
3
  /**
4
4
  * Checks if a given field exists.
5
5
  */
6
- export type FilterField<T extends object> = {
6
+ export type FilterField<T> = {
7
7
  operator: "exist";
8
8
  /**
9
9
  * The field name or path for which to check its existence.
@@ -3,7 +3,7 @@ import type { Filter } from "./Filter";
3
3
  /**
4
4
  * Joins a list of filters with a specific boolean operator.
5
5
  */
6
- export type FilterGroup<T extends object> =
6
+ export type FilterGroup<T> =
7
7
  | {
8
8
  /**
9
9
  * Boolean operator to use for joining the filters.
@@ -4,7 +4,7 @@ import type { Value } from "./Value";
4
4
  /**
5
5
  * Checks if a given number field matches a given number value according to a given operator.
6
6
  */
7
- export type FilterNumber<T extends object> = {
7
+ export type FilterNumber<T> = {
8
8
  operator:
9
9
  | "equal"
10
10
  | "notEqual"
@@ -5,7 +5,7 @@ import type { Value } from "./Value";
5
5
  /**
6
6
  * Checks if a given string field matches a given string value according to a given operator.
7
7
  */
8
- export type FilterString<T extends object> = {
8
+ export type FilterString<T> = {
9
9
  operator:
10
10
  | "equal"
11
11
  // FIXME: Redundant with `"not"` operator
@@ -5,7 +5,7 @@ import type { Value } from "./Value";
5
5
  /**
6
6
  * Checks if a given string field has any of the provided values.
7
7
  */
8
- export type FilterStringIntersect<T extends object> = {
8
+ export type FilterStringIntersect<T> = {
9
9
  operator: "intersect";
10
10
  field: FieldFiltered<T, string>;
11
11
  options?: Intl.CollatorOptions;
@@ -6,7 +6,7 @@ import type { Value } from "./Value";
6
6
  /**
7
7
  * Checks if a given string field matches a given regular expression, the value being a raw regular expression string.
8
8
  */
9
- export type FilterStringMatch<T extends object> = {
9
+ export type FilterStringMatch<T> = {
10
10
  operator: "match";
11
11
  field: FieldFiltered<T, string>;
12
12
  /**
package/lib/types/Get.ts CHANGED
@@ -3,7 +3,7 @@ import type { Path } from "./Path";
3
3
  /**
4
4
  * Returns the type of the property at the specified `P` path.
5
5
  */
6
- export type Get<T, P> = [P] extends [[infer K, ...infer R]]
6
+ export type Get<T, P> = [P] extends [readonly [infer K, ...infer R]]
7
7
  ? K extends keyof T
8
8
  ? R extends Path<T[K]>
9
9
  ? Get<T[K], R>
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Specifies how items should be grouped.
3
3
  */
4
- export type Group<T extends object> =
4
+ export type Group<T> =
5
5
  | keyof T
6
6
  | {
7
7
  field: keyof T;
@@ -1,3 +1,3 @@
1
- export type Immutable<T extends object> = {
1
+ export type Immutable<T> = {
2
2
  readonly [K in keyof T]: T[K];
3
3
  };
@@ -5,10 +5,7 @@ import type { FieldFunctionReturn } from "./FieldFunctionReturn";
5
5
  /**
6
6
  * Injects the custom fields into the entity type.
7
7
  */
8
- export type InjectCustomFields<
9
- T extends object,
10
- C extends CustomFieldMap<T> | undefined,
11
- > =
8
+ export type InjectCustomFields<T, C extends CustomFieldMap<T> | undefined> =
12
9
  C extends CustomFieldMap<T>
13
10
  ? {
14
11
  readonly [K in keyof T | keyof C]: K extends keyof T
@@ -1,7 +1,31 @@
1
+ import type { SymbolSelf } from "../constants/SymbolSelf";
2
+
3
+ import type { Key } from "./Key";
4
+ import type { Primitive } from "./Primitive";
5
+
6
+ type SymbolSelfType = typeof SymbolSelf;
7
+
1
8
  /**
2
- * Returns object type with field extending the provided `P` type.
9
+ * Returns union of keys whose mapped value extend the provided `P` type.
3
10
  */
4
- export type KeyFiltered<T extends object, P> = keyof T &
5
- keyof {
6
- [K in keyof T as T[K] extends P ? K : never]-?: T[K];
7
- };
11
+ export type KeyFiltered<T, P> = [0] extends [1 & T]
12
+ ? Key | SymbolSelfType
13
+ : T extends object
14
+ ? T extends Primitive
15
+ ? [MapPrimitive<T>] extends [P]
16
+ ? SymbolSelfType
17
+ : never
18
+ : keyof {
19
+ [K in keyof T as Extract<T[K], P> extends never ? never : K]-?: T[K];
20
+ }
21
+ : never;
22
+
23
+ type MapPrimitive<P> = P extends String
24
+ ? string
25
+ : P extends Number
26
+ ? number
27
+ : P extends Boolean
28
+ ? boolean
29
+ : P extends BigInt
30
+ ? bigint
31
+ : never;
@@ -0,0 +1 @@
1
+ export type KeyFromUnion<U> = U extends U ? keyof U : never;
@@ -3,7 +3,7 @@ import type { Field } from "./Field";
3
3
  /**
4
4
  * Order item.
5
5
  */
6
- export type Order<T extends object> =
6
+ export type Order<T> =
7
7
  | Field<T>
8
8
  | {
9
9
  field: Field<T>;
package/lib/types/Path.ts CHANGED
@@ -1,11 +1,17 @@
1
1
  import type { Increment } from "./Increment";
2
+ import type { Key } from "./Key";
3
+ import type { Primitive } from "./Primitive";
2
4
 
3
- export type Path<T, D = 0> = D extends 2
4
- ? never
5
- : T extends Array<infer P>
6
- ? readonly [number] | readonly [number, ...Path<P, Increment<D>>]
7
- : T extends object
8
- ? {
9
- [K in keyof T]-?: [K] | [K, ...Path<T[K], Increment<D>>];
10
- }[keyof T]
11
- : never;
5
+ export type Path<T, D = 6> = [0] extends [1 & T]
6
+ ? readonly (Key | never)[]
7
+ : D extends -1
8
+ ? never
9
+ : T extends Array<infer P>
10
+ ? readonly [number] | readonly [number, ...Path<P, Increment<D>>]
11
+ : T extends object
12
+ ? T extends Primitive
13
+ ? readonly never[]
14
+ : {
15
+ [K in keyof T]: [K] | [K, ...Path<T[K], Increment<D>>];
16
+ }[keyof T]
17
+ : never;
@@ -1,15 +1,18 @@
1
1
  import type { Increment } from "./Increment";
2
+ import type { Key } from "./Key";
2
3
 
3
- export type PathFiltered<T, P, D = 0> = D extends 4
4
- ? never
5
- : T extends ReadonlyArray<infer I>
6
- ? I extends P
7
- ? readonly [number]
8
- : readonly [number, ...PathFiltered<I, P, Increment<D>>]
9
- : T extends object
10
- ? {
11
- [K in keyof T]-?: T[K] extends P
12
- ? readonly [K]
13
- : readonly [K, ...PathFiltered<T[K], P, Increment<D>>];
14
- }[keyof T]
15
- : never;
4
+ export type PathFiltered<T, P, D = 7> = [0] extends [1 & T]
5
+ ? readonly (Key | never)[]
6
+ : D extends -1
7
+ ? never
8
+ : T extends ReadonlyArray<infer I>
9
+ ? Extract<I, P> extends never
10
+ ? readonly [number, ...PathFiltered<I, P, Increment<D>>]
11
+ : readonly [number]
12
+ : T extends object
13
+ ? {
14
+ [K in keyof T]: Extract<T[K], P> extends never
15
+ ? readonly [K, ...PathFiltered<T[K], P, Increment<D>>]
16
+ : readonly [K];
17
+ }[keyof T]
18
+ : never;
@@ -0,0 +1 @@
1
+ export type Primitive = String | Number | Boolean | BigInt;
@@ -13,9 +13,9 @@ import type { QueryUpdateMultiple } from "./QueryUpdateMultiple";
13
13
  */
14
14
  export type Query<
15
15
  /**
16
- * Type of the object item to be queried.
16
+ * Type of the item to be queried.
17
17
  */
18
- T extends object,
18
+ T,
19
19
  > =
20
20
  | QueryRead<T>
21
21
  | QueryReadMultiple<T>
@@ -8,7 +8,7 @@ import type { QuerySettings } from "./QuerySettings";
8
8
  /**
9
9
  * Query for computing an aggregated value.
10
10
  */
11
- export type QueryAggregate<T extends object> = {
11
+ export type QueryAggregate<T> = {
12
12
  method: "aggregate";
13
13
  /**
14
14
  * Common item properties to use for identifying the item.
@@ -5,7 +5,7 @@ import type { QuerySettings } from "./QuerySettings";
5
5
  /**
6
6
  * Query for creating an item.
7
7
  */
8
- export type QueryCreate<T extends object> = {
8
+ export type QueryCreate<T> = {
9
9
  method: "create";
10
10
  multiple?: false;
11
11
  /**
@@ -5,7 +5,7 @@ import type { QuerySettings } from "./QuerySettings";
5
5
  /**
6
6
  * Query for creating multiple items.
7
7
  */
8
- export type QueryCreateMultiple<T extends object> = {
8
+ export type QueryCreateMultiple<T> = {
9
9
  method: "create";
10
10
  multiple: true;
11
11
  /**
@@ -6,7 +6,7 @@ import type { QuerySettings } from "./QuerySettings";
6
6
  /**
7
7
  * Query for deleting an item.
8
8
  */
9
- export type QueryDelete<T extends object> = {
9
+ export type QueryDelete<T> = {
10
10
  method: "delete";
11
11
  multiple?: false;
12
12
  /**
@@ -6,7 +6,7 @@ import type { QuerySettings } from "./QuerySettings";
6
6
  /**
7
7
  * Query for deleting multiple items.
8
8
  */
9
- export type QueryDeleteMultiple<T extends object> = {
9
+ export type QueryDeleteMultiple<T> = {
10
10
  method: "delete";
11
11
  multiple: true;
12
12
  /**
@@ -7,7 +7,7 @@ import type { QuerySettings } from "./QuerySettings";
7
7
  /**
8
8
  * Query for reading a single item.
9
9
  */
10
- export type QueryRead<T extends object> = {
10
+ export type QueryRead<T> = {
11
11
  method?: "read";
12
12
  multiple?: false;
13
13
  /**
@@ -8,7 +8,7 @@ import type { QuerySettings } from "./QuerySettings";
8
8
  /**
9
9
  * Query for getting a list of items.
10
10
  */
11
- export type QueryReadMultiple<T extends object> = {
11
+ export type QueryReadMultiple<T> = {
12
12
  method?: "read";
13
13
  multiple: true;
14
14
  /**
@@ -5,7 +5,7 @@ import type { FilterChildren } from "./FilterChildren";
5
5
  /**
6
6
  * Settings to use when doing a query.
7
7
  */
8
- export type QuerySettings<T extends object> = {
8
+ export type QuerySettings<T> = {
9
9
  // TODO: Move `path*` and `transform*` to fetch middleware?
10
10
  /**
11
11
  * String used to separate the path nodes of an item.
@@ -6,7 +6,7 @@ import type { QuerySettings } from "./QuerySettings";
6
6
  /**
7
7
  * Query for updating an item.
8
8
  */
9
- export type QueryUpdate<T extends object> = {
9
+ export type QueryUpdate<T> = {
10
10
  method: "update";
11
11
  multiple?: false;
12
12
  /**
@@ -7,7 +7,7 @@ import type { QuerySettings } from "./QuerySettings";
7
7
  /**
8
8
  * Query for updating multiple items.
9
9
  */
10
- export type QueryUpdateMultiple<T extends object> = {
10
+ export type QueryUpdateMultiple<T> = {
11
11
  method: "update";
12
12
  multiple: true;
13
13
  /**
@@ -4,23 +4,20 @@ import type { Query } from "./Query";
4
4
  /**
5
5
  * Picks fields `F` from object `T`.
6
6
  */
7
- export type PickFields<
8
- T extends object | undefined,
9
- F extends string | number | symbol,
10
- > = [F] extends [keyof T]
7
+ export type PickFields<T, F extends string | number | symbol> = [F] extends [
8
+ keyof T,
9
+ ]
11
10
  ? { readonly [K in F]: T[K] }
12
11
  : { readonly [K in keyof T]: T[K] };
13
12
 
14
- export type ResultRead<T extends object, Q extends Query<T>> = [Q] extends [
13
+ export type ResultRead<T, Q extends Query<T>> = [Q] extends [
15
14
  // FIXME: `keyof T` should be `Field<T>`
16
15
  { fields: (keyof T)[] },
17
16
  ]
18
17
  ? PickFields<T, Item<Q["fields"]>>
19
18
  : T;
20
19
 
21
- export type Result<T extends object, Q extends Query<T>> = [Q] extends [
22
- { method: "read" },
23
- ]
20
+ export type Result<T, Q extends Query<T>> = [Q] extends [{ method: "read" }]
24
21
  ? [Q] extends [{ multiple: true }]
25
22
  ? readonly ResultRead<T, Q>[]
26
23
  : ResultRead<T, Q>
@@ -3,7 +3,7 @@ import type { FieldFiltered } from "./FieldFiltered";
3
3
  /**
4
4
  * Actual `value` or `valueField` leading to the value.
5
5
  */
6
- export type Value<T extends object, V> =
6
+ export type Value<T, V> =
7
7
  | {
8
8
  /**
9
9
  * Value to use.
package/lib/types.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  // File automatically generated by `vite-plugin-module-list`
2
2
  export type { AggregateFunction } from "./types/AggregateFunction";
3
3
  export type { AggregateFunctionOperator } from "./types/AggregateFunctionOperator";
4
- export type { Any } from "./types/Any";
4
+ export type { CombineUnion } from "./types/CombineUnion";
5
5
  export type { Context } from "./types/Context";
6
6
  export type { CustomFetch } from "./types/CustomFetch";
7
7
  export type { CustomFieldAggregateMap } from "./types/CustomFieldAggregateMap";
@@ -35,14 +35,14 @@ export type { Item } from "./types/Item";
35
35
  export type { Join } from "./types/Join";
36
36
  export type { Key } from "./types/Key";
37
37
  export type { KeyFiltered } from "./types/KeyFiltered";
38
+ export type { KeyFromUnion } from "./types/KeyFromUnion";
38
39
  export type { Locale } from "./types/Locale";
39
- export type { Mutable } from "./types/Mutable";
40
40
  export type { NextHandler } from "./types/NextHandler";
41
- export type { Normalized } from "./types/Normalized";
42
41
  export type { Order } from "./types/Order";
43
42
  export type { Parameters } from "./types/Parameters";
44
43
  export type { Path } from "./types/Path";
45
44
  export type { PathFiltered } from "./types/PathFiltered";
45
+ export type { Primitive } from "./types/Primitive";
46
46
  export type { Query } from "./types/Query";
47
47
  export type { QueryAggregate } from "./types/QueryAggregate";
48
48
  export type { QueryCreate } from "./types/QueryCreate";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "quetch",
3
- "version": "0.18.2",
3
+ "version": "0.19.0",
4
4
  "type": "module",
5
5
  "main": "./dist/main.js",
6
6
  "exports": {
@@ -39,6 +39,7 @@
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": "tsc --project tsconfig.package.json --noEmit",
42
43
  "lint:ts:fix": "eslint --fix .",
43
44
  "release:init": "npm publish --access=public",
44
45
  "release:patch": "npm version patch && git push origin --follow-tags && npm publish",
@@ -53,7 +54,7 @@
53
54
  "@preact/preset-vite": "^2.9.1",
54
55
  "@types/eslint": "^9.6.1",
55
56
  "@types/node": "^22.8.5",
56
- "@typescript-eslint/parser": "^8.12.2",
57
+ "@typescript-eslint/parser": "^8.16.0",
57
58
  "autoprefixer": "^10.4.20",
58
59
  "cssnano": "^6.1.2",
59
60
  "eslint": "^8.57.1",
@@ -70,9 +71,9 @@
70
71
  "prettier": "^3.3.3",
71
72
  "prettier-plugin-tailwindcss": "^0.6.8",
72
73
  "tailwindcss": "^3.4.14",
73
- "typedoc": "^0.26.10",
74
- "typedoc-plugin-markdown": "^4.2.9",
75
- "typescript": "^5.6.3",
74
+ "typedoc": "^0.27.0",
75
+ "typedoc-plugin-markdown": "^4.3.0",
76
+ "typescript": "^5.7.2",
76
77
  "vite": "^5.4.10",
77
78
  "vite-plugin-module-list": "^2.2.2",
78
79
  "vitest": "^2.1.4"
@@ -1 +0,0 @@
1
- export type Any = boolean | string | number | object | symbol | null | undefined | Array<any> | ((...args: any[]) => any);
package/dist/types/Any.js DELETED
@@ -1 +0,0 @@
1
- //# sourceMappingURL=Any.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Any.js","sourceRoot":"","sources":["../../lib/types/Any.ts"],"names":[],"mappings":""}
@@ -1,3 +0,0 @@
1
- export type Mutable<T extends object> = {
2
- -readonly [K in keyof T]: T[K];
3
- };
@@ -1 +0,0 @@
1
- //# sourceMappingURL=Mutable.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Mutable.js","sourceRoot":"","sources":["../../lib/types/Mutable.ts"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- import type { IntersectUnion } from "./IntersectUnion";
2
- export type Normalized<T extends object> = Required<IntersectUnion<T>>;
@@ -1 +0,0 @@
1
- //# sourceMappingURL=Normalized.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Normalized.js","sourceRoot":"","sources":["../../lib/types/Normalized.ts"],"names":[],"mappings":""}
package/lib/types/Any.ts DELETED
@@ -1,10 +0,0 @@
1
- export type Any =
2
- | boolean
3
- | string
4
- | number
5
- | object
6
- | symbol
7
- | null
8
- | undefined
9
- | Array<any>
10
- | ((...args: any[]) => any);
@@ -1,3 +0,0 @@
1
- export type Mutable<T extends object> = {
2
- -readonly [K in keyof T]: T[K];
3
- };
@@ -1,3 +0,0 @@
1
- import type { IntersectUnion } from "./IntersectUnion";
2
-
3
- export type Normalized<T extends object> = Required<IntersectUnion<T>>;