quetch 0.19.5 → 0.21.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/fieldListFromFilter.js +6 -2
- package/dist/tools/fieldListFromFilter.js.map +1 -1
- package/dist/tools/queryItemList.js +2 -2
- package/dist/tools/queryItemList.js.map +1 -1
- package/dist/tools/sameField.d.ts +2 -0
- package/dist/tools/sameField.js +13 -0
- package/dist/tools/sameField.js.map +1 -0
- package/dist/tools/sortItemList.d.ts +3 -2
- package/dist/tools/sortItemList.js +23 -2
- package/dist/tools/sortItemList.js.map +1 -1
- package/dist/tools/testFilter.js +46 -30
- package/dist/tools/testFilter.js.map +1 -1
- package/dist/tools.d.ts +1 -0
- package/dist/tools.js +1 -0
- package/dist/tools.js.map +1 -1
- package/dist/types/Field.d.ts +2 -3
- package/dist/types/FieldKey.d.ts +3 -0
- package/dist/types/FieldKey.js +1 -0
- package/dist/types/FieldKey.js.map +1 -0
- package/dist/types/FieldMap.d.ts +5 -0
- package/dist/types/FieldMap.js +1 -0
- package/dist/types/FieldMap.js.map +1 -0
- package/dist/types/FilterArray.d.ts +1 -1
- package/dist/types/FilterChildren.d.ts +1 -1
- package/dist/types/FilterField.d.ts +1 -1
- package/dist/types/FilterNumber.d.ts +1 -1
- package/dist/types/FilterString.d.ts +1 -1
- package/dist/types/FilterStringIntersect.d.ts +1 -1
- package/dist/types/FilterStringMatch.d.ts +1 -1
- package/dist/types/QuerySettings.d.ts +10 -4
- package/dist/types/ValueMap.d.ts +7 -0
- package/dist/types/ValueMap.js +1 -0
- package/dist/types/ValueMap.js.map +1 -0
- package/dist/types.d.ts +3 -0
- package/doc/README.md +4 -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/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/filterFromContext.md +1 -1
- package/doc/functions/get.md +1 -1
- 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 +27 -0
- package/doc/functions/sortItemList.md +8 -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 +17 -0
- package/doc/type-aliases/FieldMap.md +21 -0
- package/doc/type-aliases/Filter.md +1 -1
- package/doc/type-aliases/FilterArray.md +2 -2
- package/doc/type-aliases/FilterBoolean.md +1 -1
- package/doc/type-aliases/FilterChildren.md +2 -2
- package/doc/type-aliases/FilterCustom.md +1 -1
- package/doc/type-aliases/FilterField.md +2 -2
- package/doc/type-aliases/FilterGroup.md +1 -1
- package/doc/type-aliases/FilterNumber.md +2 -2
- package/doc/type-aliases/FilterOperator.md +1 -1
- package/doc/type-aliases/FilterString.md +2 -2
- package/doc/type-aliases/FilterStringIntersect.md +2 -2
- package/doc/type-aliases/FilterStringMatch.md +2 -2
- 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 +1 -1
- 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 +17 -5
- 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 +21 -0
- package/doc/variables/CACHE.md +1 -1
- package/doc/variables/SELF.md +1 -1
- package/lib/tools/fieldListFromFilter.ts +6 -2
- package/lib/tools/queryItemList.ts +2 -2
- package/lib/tools/sameField.ts +15 -0
- package/lib/tools/sortItemList.test.ts +59 -0
- package/lib/tools/sortItemList.ts +39 -2
- package/lib/tools/testFilter.test.ts +62 -2
- package/lib/tools/testFilter.ts +66 -41
- package/lib/tools.ts +1 -0
- package/lib/types/Field.ts +2 -4
- package/lib/types/FieldKey.ts +5 -0
- package/lib/types/FieldMap.ts +6 -0
- package/lib/types/FilterArray.ts +7 -1
- package/lib/types/FilterChildren.ts +1 -1
- package/lib/types/FilterField.ts +1 -1
- package/lib/types/FilterNumber.ts +5 -1
- package/lib/types/FilterString.ts +7 -1
- package/lib/types/FilterStringIntersect.ts +1 -1
- package/lib/types/FilterStringMatch.ts +1 -1
- package/lib/types/QuerySettings.ts +10 -5
- package/lib/types/ValueMap.ts +14 -0
- package/lib/types.ts +3 -0
- package/package.json +1 -1
package/lib/tools/testFilter.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { EMPTY_OBJECT } from "unchangeable";
|
|
2
|
+
|
|
1
3
|
import { CACHE } from "../constants/CACHE.js";
|
|
2
4
|
import type { QuerySettings } from "../types/QuerySettings.js";
|
|
3
5
|
import type { FieldFiltered, Filter, FilterString } from "../types.js";
|
|
@@ -103,7 +105,9 @@ export function testFilter<T>(
|
|
|
103
105
|
}
|
|
104
106
|
return true;
|
|
105
107
|
}
|
|
106
|
-
case "children":
|
|
108
|
+
case "children":
|
|
109
|
+
case "notChildren": {
|
|
110
|
+
const not = filter.operator[0] === "n";
|
|
107
111
|
if (filter[CACHE] === undefined) {
|
|
108
112
|
switch (true) {
|
|
109
113
|
case settings?.transformFilterChildren !== undefined:
|
|
@@ -111,72 +115,83 @@ export function testFilter<T>(
|
|
|
111
115
|
break;
|
|
112
116
|
default: {
|
|
113
117
|
const {
|
|
114
|
-
|
|
115
|
-
pathFieldSeparator
|
|
116
|
-
} = settings ||
|
|
118
|
+
pathField = "id" as FieldFiltered<T, string>,
|
|
119
|
+
pathFieldSeparator,
|
|
120
|
+
} = settings || (EMPTY_OBJECT as QuerySettings<T>);
|
|
117
121
|
filter[CACHE] = filterChildren(
|
|
118
122
|
filter.value as string,
|
|
119
|
-
|
|
123
|
+
pathField,
|
|
120
124
|
filter.deep,
|
|
121
125
|
pathFieldSeparator,
|
|
122
126
|
);
|
|
123
127
|
}
|
|
124
128
|
}
|
|
125
129
|
}
|
|
126
|
-
return testFilter(filter[CACHE], value);
|
|
130
|
+
return negate(testFilter(filter[CACHE], value), not);
|
|
127
131
|
}
|
|
128
132
|
case "custom": {
|
|
129
133
|
return filter.value(value);
|
|
130
134
|
}
|
|
131
|
-
case "startWith":
|
|
135
|
+
case "startWith":
|
|
136
|
+
case "notStartWith": {
|
|
137
|
+
const not = filter.operator[0] === "n";
|
|
132
138
|
const rightValue = valueFromFilter(value, filter);
|
|
133
139
|
const leftValue = get<T, any>(value, filter.field) as string | undefined;
|
|
134
140
|
if (leftValue === undefined || leftValue.length < rightValue.length) {
|
|
135
|
-
return false;
|
|
141
|
+
return negate(false, not);
|
|
136
142
|
}
|
|
137
143
|
if (filter.options !== undefined || filter.locale !== undefined) {
|
|
138
|
-
return (
|
|
144
|
+
return negate(
|
|
139
145
|
rightValue.localeCompare(
|
|
140
146
|
leftValue.slice(0, rightValue.length),
|
|
141
147
|
filter.locale,
|
|
142
148
|
filter.options,
|
|
143
|
-
) === 0
|
|
149
|
+
) === 0,
|
|
150
|
+
not,
|
|
144
151
|
);
|
|
145
152
|
}
|
|
146
|
-
return leftValue.startsWith(rightValue) ?? false;
|
|
153
|
+
return negate(leftValue.startsWith(rightValue) ?? false, not);
|
|
147
154
|
}
|
|
148
|
-
case "endWith":
|
|
155
|
+
case "endWith":
|
|
156
|
+
case "notEndWith": {
|
|
157
|
+
const not = filter.operator[0] === "n";
|
|
149
158
|
const rightValue = valueFromFilter(value, filter);
|
|
150
159
|
const leftValue = get<T, any>(value, filter.field) as string | undefined;
|
|
151
160
|
if (leftValue === undefined || leftValue.length < rightValue.length) {
|
|
152
|
-
return false;
|
|
161
|
+
return negate(false, not);
|
|
153
162
|
}
|
|
154
163
|
if (filter.options !== undefined || filter.locale !== undefined) {
|
|
155
|
-
return (
|
|
164
|
+
return negate(
|
|
156
165
|
rightValue.localeCompare(
|
|
157
166
|
leftValue.slice(-rightValue.length),
|
|
158
167
|
filter.locale,
|
|
159
168
|
filter.options,
|
|
160
|
-
) === 0
|
|
169
|
+
) === 0,
|
|
170
|
+
not,
|
|
161
171
|
);
|
|
162
172
|
}
|
|
163
|
-
return leftValue.endsWith(rightValue) ?? false;
|
|
173
|
+
return negate(leftValue.endsWith(rightValue) ?? false, not);
|
|
164
174
|
}
|
|
165
|
-
case "include":
|
|
175
|
+
case "include":
|
|
176
|
+
case "notInclude": {
|
|
177
|
+
const not = filter.operator[0] === "n";
|
|
166
178
|
const rightValue = valueFromFilter(value, filter);
|
|
167
179
|
const leftValue = get<T, any>(value, filter.field) as string | any[];
|
|
168
180
|
if (leftValue == null) {
|
|
169
|
-
return false;
|
|
181
|
+
return negate(false, not);
|
|
170
182
|
}
|
|
171
183
|
if (isArray(rightValue)) {
|
|
172
184
|
// FIXME: Get unique values
|
|
173
185
|
if (!isArray(leftValue) || leftValue.length < rightValue.length) {
|
|
174
|
-
return false;
|
|
186
|
+
return negate(false, not);
|
|
175
187
|
}
|
|
176
|
-
return
|
|
188
|
+
return negate(
|
|
189
|
+
rightValue.every((value) => leftValue.includes(value)),
|
|
190
|
+
not,
|
|
191
|
+
);
|
|
177
192
|
}
|
|
178
193
|
if (isArray(leftValue) || leftValue.length < rightValue.length) {
|
|
179
|
-
return false;
|
|
194
|
+
return negate(false, not);
|
|
180
195
|
}
|
|
181
196
|
if (
|
|
182
197
|
(filter as FilterString<T>).options ||
|
|
@@ -192,12 +207,12 @@ export function testFilter<T>(
|
|
|
192
207
|
(filter as FilterString<T>).options,
|
|
193
208
|
) === 0
|
|
194
209
|
) {
|
|
195
|
-
return true;
|
|
210
|
+
return negate(true, not);
|
|
196
211
|
}
|
|
197
212
|
}
|
|
198
|
-
return false;
|
|
213
|
+
return negate(false, not);
|
|
199
214
|
}
|
|
200
|
-
return leftValue.includes?.(rightValue) ?? false;
|
|
215
|
+
return negate(leftValue.includes?.(rightValue) ?? false, not);
|
|
201
216
|
}
|
|
202
217
|
case "greaterThan": {
|
|
203
218
|
const rightValue = valueFromFilter(value, filter);
|
|
@@ -267,11 +282,13 @@ export function testFilter<T>(
|
|
|
267
282
|
}
|
|
268
283
|
return leftValue <= rightValue;
|
|
269
284
|
}
|
|
270
|
-
case "match":
|
|
285
|
+
case "match":
|
|
286
|
+
case "notMatch": {
|
|
287
|
+
const not = filter.operator[0] === "n";
|
|
271
288
|
const rightValue = valueFromFilter(value, filter);
|
|
272
289
|
const leftValue = get<T, any>(value, filter.field) as string | undefined;
|
|
273
290
|
if (leftValue === undefined) {
|
|
274
|
-
return false;
|
|
291
|
+
return negate(false, not);
|
|
275
292
|
}
|
|
276
293
|
if (filter[CACHE] === undefined) {
|
|
277
294
|
filter[CACHE] = new RegExp(
|
|
@@ -281,39 +298,47 @@ export function testFilter<T>(
|
|
|
281
298
|
}`,
|
|
282
299
|
);
|
|
283
300
|
}
|
|
284
|
-
return filter[CACHE].test(leftValue);
|
|
301
|
+
return negate(filter[CACHE].test(leftValue), not);
|
|
285
302
|
}
|
|
286
|
-
case "intersect":
|
|
303
|
+
case "intersect":
|
|
304
|
+
case "notIntersect": {
|
|
305
|
+
const not = filter.operator[0] === "n";
|
|
287
306
|
const rightValue = valueFromFilter(value, filter);
|
|
288
307
|
const leftValue = get<T, any>(value, filter.field);
|
|
289
308
|
if (leftValue == null) {
|
|
290
|
-
return false;
|
|
309
|
+
return negate(false, not);
|
|
291
310
|
}
|
|
292
311
|
if (isArray(leftValue)) {
|
|
293
|
-
return (
|
|
312
|
+
return negate(
|
|
294
313
|
isArray(rightValue) &&
|
|
295
|
-
|
|
314
|
+
rightValue.some((value) => leftValue.includes(value)),
|
|
315
|
+
not,
|
|
296
316
|
);
|
|
297
317
|
}
|
|
298
318
|
if (
|
|
299
319
|
(filter as FilterString<T>).options ||
|
|
300
320
|
(filter as FilterString<T>).locale
|
|
301
321
|
) {
|
|
302
|
-
return (
|
|
322
|
+
return negate(
|
|
303
323
|
leftValue !== undefined &&
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
324
|
+
(rightValue as string[]).some(
|
|
325
|
+
(value) =>
|
|
326
|
+
value.localeCompare(
|
|
327
|
+
leftValue as string,
|
|
328
|
+
(filter as FilterString<T>).locale,
|
|
329
|
+
(filter as FilterString<T>).options,
|
|
330
|
+
) === 0,
|
|
331
|
+
),
|
|
332
|
+
not,
|
|
312
333
|
);
|
|
313
334
|
}
|
|
314
|
-
return rightValue.includes(leftValue as string);
|
|
335
|
+
return negate(rightValue.includes(leftValue as string), not);
|
|
315
336
|
}
|
|
316
337
|
default:
|
|
317
338
|
throw new Error(`Unknown filter operator '${(filter as any).operator}'`);
|
|
318
339
|
}
|
|
319
340
|
}
|
|
341
|
+
|
|
342
|
+
function negate(value: boolean, condition: boolean) {
|
|
343
|
+
return condition ? !value : value;
|
|
344
|
+
}
|
package/lib/tools.ts
CHANGED
|
@@ -12,5 +12,6 @@ export { isFilterGroup } from "./tools/isFilterGroup.js";
|
|
|
12
12
|
export { normalizeOrder } from "./tools/normalizeOrder.js";
|
|
13
13
|
export { queryItemList } from "./tools/queryItemList.js";
|
|
14
14
|
export { reverseOrder } from "./tools/reverseOrder.js";
|
|
15
|
+
export { sameField } from "./tools/sameField.js";
|
|
15
16
|
export { sortItemList } from "./tools/sortItemList.js";
|
|
16
17
|
export { testFilter } from "./tools/testFilter.js";
|
package/lib/types/Field.ts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import type { SELF } from "../constants/SELF.js";
|
|
2
|
-
|
|
3
1
|
import type { CombineUnion } from "./CombineUnion";
|
|
2
|
+
import type { FieldKey } from "./FieldKey.js";
|
|
4
3
|
import type { Path } from "./Path";
|
|
5
|
-
import type { Primitive } from "./Primitive";
|
|
6
4
|
|
|
7
5
|
export type Field<T> = KeyOrPath<CombineUnion<T>>;
|
|
8
6
|
|
|
9
|
-
type KeyOrPath<T> =
|
|
7
|
+
type KeyOrPath<T> = FieldKey<T> | Path<T>;
|
package/lib/types/FilterArray.ts
CHANGED
|
@@ -9,6 +9,12 @@ import type { Value } from "./Value";
|
|
|
9
9
|
* - `intersect` requires at least one item of the value to be present in the array.
|
|
10
10
|
*/
|
|
11
11
|
export type FilterArray<T, P = any> = {
|
|
12
|
-
operator:
|
|
12
|
+
operator:
|
|
13
|
+
| "equal"
|
|
14
|
+
| "include"
|
|
15
|
+
| "intersect"
|
|
16
|
+
| "notEqual"
|
|
17
|
+
| "notInclude"
|
|
18
|
+
| "notIntersect";
|
|
13
19
|
field: FieldFiltered<T, P[]>;
|
|
14
20
|
} & Value<T, P[]>;
|
|
@@ -8,7 +8,7 @@ import type { Filter } from "./Filter";
|
|
|
8
8
|
* If `deep` is `true`, also captures all the descendants.
|
|
9
9
|
*/
|
|
10
10
|
export type FilterChildren<T> = {
|
|
11
|
-
operator: "children";
|
|
11
|
+
operator: "children" | "notChildren";
|
|
12
12
|
value?: Context<T> | string;
|
|
13
13
|
deep?: boolean;
|
|
14
14
|
[CACHE]?: Filter<T>;
|
package/lib/types/FilterField.ts
CHANGED
|
@@ -11,6 +11,10 @@ export type FilterNumber<T> = {
|
|
|
11
11
|
| "greaterThan"
|
|
12
12
|
| "greaterThanOrEqual"
|
|
13
13
|
| "lowerThan"
|
|
14
|
-
| "lowerThanOrEqual"
|
|
14
|
+
| "lowerThanOrEqual"
|
|
15
|
+
| "between"
|
|
16
|
+
| "notBetween"
|
|
17
|
+
| "betweenOrEqual"
|
|
18
|
+
| "notBetweenOrEqual";
|
|
15
19
|
field: FieldFiltered<T, number>;
|
|
16
20
|
} & Value<T, number>;
|
|
@@ -11,12 +11,18 @@ export type FilterString<T> = {
|
|
|
11
11
|
// FIXME: Redundant with `"not"` operator
|
|
12
12
|
| "notEqual"
|
|
13
13
|
| "startWith"
|
|
14
|
+
| "notStartWith"
|
|
14
15
|
| "endWith"
|
|
16
|
+
| "notEndWith"
|
|
15
17
|
| "include"
|
|
16
18
|
| "greaterThan"
|
|
17
19
|
| "greaterThanOrEqual"
|
|
18
20
|
| "lowerThan"
|
|
19
|
-
| "lowerThanOrEqual"
|
|
21
|
+
| "lowerThanOrEqual"
|
|
22
|
+
| "between"
|
|
23
|
+
| "notBetween"
|
|
24
|
+
| "betweenOrEqual"
|
|
25
|
+
| "notBetweenOrEqual";
|
|
20
26
|
field: FieldFiltered<T, string>;
|
|
21
27
|
options?: Intl.CollatorOptions;
|
|
22
28
|
locale?: Locale;
|
|
@@ -6,7 +6,7 @@ import type { Value } from "./Value";
|
|
|
6
6
|
* Checks if a given string field has any of the provided values.
|
|
7
7
|
*/
|
|
8
8
|
export type FilterStringIntersect<T> = {
|
|
9
|
-
operator: "intersect";
|
|
9
|
+
operator: "intersect" | "notIntersect";
|
|
10
10
|
field: FieldFiltered<T, string>;
|
|
11
11
|
options?: Intl.CollatorOptions;
|
|
12
12
|
locale?: Locale;
|
|
@@ -7,7 +7,7 @@ import type { Value } from "./Value";
|
|
|
7
7
|
* Checks if a given string field matches a given regular expression, the value being a raw regular expression string.
|
|
8
8
|
*/
|
|
9
9
|
export type FilterStringMatch<T> = {
|
|
10
|
-
operator: "match";
|
|
10
|
+
operator: "match" | "notMatch";
|
|
11
11
|
field: FieldFiltered<T, string>;
|
|
12
12
|
/**
|
|
13
13
|
* Regular expression options.
|
|
@@ -6,15 +6,20 @@ import type { FilterChildren } from "./FilterChildren";
|
|
|
6
6
|
* Settings to use when doing a query.
|
|
7
7
|
*/
|
|
8
8
|
export type QuerySettings<T> = {
|
|
9
|
-
// TODO: Move `path*` and `transform*` to fetch middleware?
|
|
10
9
|
/**
|
|
11
|
-
*
|
|
10
|
+
* Path to the field that contains the path value of an item, used for displaying items in a tree.
|
|
12
11
|
*/
|
|
13
|
-
|
|
12
|
+
pathField?: FieldFiltered<T, string>;
|
|
14
13
|
/**
|
|
15
|
-
*
|
|
14
|
+
* String used to escape the separator.
|
|
15
|
+
*
|
|
16
|
+
* @default "\\"
|
|
16
17
|
*/
|
|
17
|
-
|
|
18
|
+
pathFieldSeparatorEscape?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Maps path fields to a string used to separate the path nodes of a field value.
|
|
21
|
+
*/
|
|
22
|
+
pathFieldSeparator?: string;
|
|
18
23
|
/**
|
|
19
24
|
* Returns a filter that captures the items expressed by the provided `FilterChildren`. The return filter cannot use filters of type `FilterChildren`.
|
|
20
25
|
*
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Primitive } from "./Primitive";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Maps the properties of the provided value `T` to a specific value `V`.
|
|
5
|
+
*/
|
|
6
|
+
export type ValueMap<T, V> = T extends Primitive
|
|
7
|
+
? V
|
|
8
|
+
: T extends Array<infer P>
|
|
9
|
+
? Record<number, ValueMap<P, V>>
|
|
10
|
+
: T extends object
|
|
11
|
+
? {
|
|
12
|
+
[K in keyof T]?: ValueMap<T[K], V>;
|
|
13
|
+
}
|
|
14
|
+
: never;
|
package/lib/types.ts
CHANGED
|
@@ -12,6 +12,8 @@ export type { FieldFunction } from "./types/FieldFunction";
|
|
|
12
12
|
export type { FieldFunctionCustom } from "./types/FieldFunctionCustom";
|
|
13
13
|
export type { FieldFunctionFormatDate } from "./types/FieldFunctionFormatDate";
|
|
14
14
|
export type { FieldFunctionReturn } from "./types/FieldFunctionReturn";
|
|
15
|
+
export type { FieldKey } from "./types/FieldKey";
|
|
16
|
+
export type { FieldMap } from "./types/FieldMap";
|
|
15
17
|
export type { Filter } from "./types/Filter";
|
|
16
18
|
export type { FilterArray } from "./types/FilterArray";
|
|
17
19
|
export type { FilterBoolean } from "./types/FilterBoolean";
|
|
@@ -60,3 +62,4 @@ export type { QueryUpdateMultiple } from "./types/QueryUpdateMultiple";
|
|
|
60
62
|
export type { Result } from "./types/Result";
|
|
61
63
|
export type { Store } from "./types/Store";
|
|
62
64
|
export type { Value } from "./types/Value";
|
|
65
|
+
export type { ValueMap } from "./types/ValueMap";
|