zitejs 0.9.109 → 0.9.110
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/cjs/runtime/filterConditionTypes.test-d.d.ts +1 -0
- package/dist/cjs/runtime/filterConditionTypes.test-d.js +40 -0
- package/dist/cjs/runtime/index.d.ts +7 -2
- package/dist/esm/runtime/filterConditionTypes.test-d.d.ts +1 -0
- package/dist/esm/runtime/filterConditionTypes.test-d.js +38 -0
- package/dist/esm/runtime/index.d.ts +7 -2
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const vitest_1 = require("vitest");
|
|
4
|
+
(0, vitest_1.describe)("FilterCondition in/notIn", () => {
|
|
5
|
+
// The idiom that regressed. `.filter(Boolean)` does not narrow in TypeScript,
|
|
6
|
+
// so this is `(string | undefined)[]` — compiling at all is the assertion.
|
|
7
|
+
(0, vitest_1.it)("accepts .map(…).filter(Boolean) over a nullable column", () => {
|
|
8
|
+
const keys = routes.map((r) => r.compositeRouteKey).filter(Boolean);
|
|
9
|
+
(0, vitest_1.expectTypeOf)(keys).toEqualTypeOf();
|
|
10
|
+
(0, vitest_1.expectTypeOf)().toMatchTypeOf();
|
|
11
|
+
(0, vitest_1.expectTypeOf)().toMatchTypeOf();
|
|
12
|
+
});
|
|
13
|
+
// One array of a union, not a union of arrays.
|
|
14
|
+
(0, vitest_1.it)("collapses a nullable column to a single array type", () => {
|
|
15
|
+
(0, vitest_1.expectTypeOf)().toEqualTypeOf();
|
|
16
|
+
});
|
|
17
|
+
// The unwrapping that the conditional exists for: an array-valued column is
|
|
18
|
+
// filtered by its ELEMENT type, not by arrays of arrays.
|
|
19
|
+
(0, vitest_1.it)("still unwraps an array-valued column to its element type", () => {
|
|
20
|
+
(0, vitest_1.expectTypeOf)().toEqualTypeOf();
|
|
21
|
+
});
|
|
22
|
+
(0, vitest_1.it)("leaves a plain scalar column alone", () => {
|
|
23
|
+
(0, vitest_1.expectTypeOf)().toEqualTypeOf();
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
(0, vitest_1.describe)("RecordFilters", () => {
|
|
27
|
+
// Through the keyed wrapper, which is how app code actually reaches it.
|
|
28
|
+
(0, vitest_1.it)("accepts the idiom on a nullable key", () => {
|
|
29
|
+
const filters = {
|
|
30
|
+
compositeRouteKey: {
|
|
31
|
+
in: routes.map((r) => r.compositeRouteKey).filter(Boolean),
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
(0, vitest_1.expectTypeOf)(filters).toMatchTypeOf();
|
|
35
|
+
});
|
|
36
|
+
(0, vitest_1.it)("accepts an element-typed `in` on an array column", () => {
|
|
37
|
+
const filters = { tags: { in: ["urgent"] } };
|
|
38
|
+
(0, vitest_1.expectTypeOf)(filters).toMatchTypeOf();
|
|
39
|
+
});
|
|
40
|
+
});
|
|
@@ -8,6 +8,11 @@
|
|
|
8
8
|
* the operands buys little while breaking real migrated code: dates are ISO
|
|
9
9
|
* strings here but 1.0 accepted `number | Date` on every comparison, and
|
|
10
10
|
* `contains` was `any`.
|
|
11
|
+
*
|
|
12
|
+
* On `in`/`notIn` the `[]` sits OUTSIDE the conditional. A naked `V`
|
|
13
|
+
* distributes, so a nullable column produced `string[] | undefined[]` — two
|
|
14
|
+
* separate array types, neither of which accepts the `(string | undefined)[]`
|
|
15
|
+
* that `.map(…).filter(Boolean)` yields.
|
|
11
16
|
*/
|
|
12
17
|
export type FilterCondition<V> = {
|
|
13
18
|
/** Substring match (text fields) or "has any of these" (linked records). */
|
|
@@ -15,9 +20,9 @@ export type FilterCondition<V> = {
|
|
|
15
20
|
/** Not equal, or — against `null` — "is set". */
|
|
16
21
|
not?: V | null;
|
|
17
22
|
/** An empty array matches NOTHING — the SDK's filters convert to the nested format, where `in: []` is "is one of nothing". */
|
|
18
|
-
in?: V extends Array<infer E> ? E
|
|
23
|
+
in?: (V extends Array<infer E> ? E : V)[];
|
|
19
24
|
/** An empty array applies no filter at all — "is not one of nothing" is always true. */
|
|
20
|
-
notIn?: V extends Array<infer E> ? E
|
|
25
|
+
notIn?: (V extends Array<infer E> ? E : V)[];
|
|
21
26
|
lt?: V | number | Date;
|
|
22
27
|
lte?: V | number | Date;
|
|
23
28
|
gt?: V | number | Date;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { describe, it, expectTypeOf } from "vitest";
|
|
2
|
+
describe("FilterCondition in/notIn", () => {
|
|
3
|
+
// The idiom that regressed. `.filter(Boolean)` does not narrow in TypeScript,
|
|
4
|
+
// so this is `(string | undefined)[]` — compiling at all is the assertion.
|
|
5
|
+
it("accepts .map(…).filter(Boolean) over a nullable column", () => {
|
|
6
|
+
const keys = routes.map((r) => r.compositeRouteKey).filter(Boolean);
|
|
7
|
+
expectTypeOf(keys).toEqualTypeOf();
|
|
8
|
+
expectTypeOf().toMatchTypeOf();
|
|
9
|
+
expectTypeOf().toMatchTypeOf();
|
|
10
|
+
});
|
|
11
|
+
// One array of a union, not a union of arrays.
|
|
12
|
+
it("collapses a nullable column to a single array type", () => {
|
|
13
|
+
expectTypeOf().toEqualTypeOf();
|
|
14
|
+
});
|
|
15
|
+
// The unwrapping that the conditional exists for: an array-valued column is
|
|
16
|
+
// filtered by its ELEMENT type, not by arrays of arrays.
|
|
17
|
+
it("still unwraps an array-valued column to its element type", () => {
|
|
18
|
+
expectTypeOf().toEqualTypeOf();
|
|
19
|
+
});
|
|
20
|
+
it("leaves a plain scalar column alone", () => {
|
|
21
|
+
expectTypeOf().toEqualTypeOf();
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
describe("RecordFilters", () => {
|
|
25
|
+
// Through the keyed wrapper, which is how app code actually reaches it.
|
|
26
|
+
it("accepts the idiom on a nullable key", () => {
|
|
27
|
+
const filters = {
|
|
28
|
+
compositeRouteKey: {
|
|
29
|
+
in: routes.map((r) => r.compositeRouteKey).filter(Boolean),
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
expectTypeOf(filters).toMatchTypeOf();
|
|
33
|
+
});
|
|
34
|
+
it("accepts an element-typed `in` on an array column", () => {
|
|
35
|
+
const filters = { tags: { in: ["urgent"] } };
|
|
36
|
+
expectTypeOf(filters).toMatchTypeOf();
|
|
37
|
+
});
|
|
38
|
+
});
|
|
@@ -8,6 +8,11 @@
|
|
|
8
8
|
* the operands buys little while breaking real migrated code: dates are ISO
|
|
9
9
|
* strings here but 1.0 accepted `number | Date` on every comparison, and
|
|
10
10
|
* `contains` was `any`.
|
|
11
|
+
*
|
|
12
|
+
* On `in`/`notIn` the `[]` sits OUTSIDE the conditional. A naked `V`
|
|
13
|
+
* distributes, so a nullable column produced `string[] | undefined[]` — two
|
|
14
|
+
* separate array types, neither of which accepts the `(string | undefined)[]`
|
|
15
|
+
* that `.map(…).filter(Boolean)` yields.
|
|
11
16
|
*/
|
|
12
17
|
export type FilterCondition<V> = {
|
|
13
18
|
/** Substring match (text fields) or "has any of these" (linked records). */
|
|
@@ -15,9 +20,9 @@ export type FilterCondition<V> = {
|
|
|
15
20
|
/** Not equal, or — against `null` — "is set". */
|
|
16
21
|
not?: V | null;
|
|
17
22
|
/** An empty array matches NOTHING — the SDK's filters convert to the nested format, where `in: []` is "is one of nothing". */
|
|
18
|
-
in?: V extends Array<infer E> ? E
|
|
23
|
+
in?: (V extends Array<infer E> ? E : V)[];
|
|
19
24
|
/** An empty array applies no filter at all — "is not one of nothing" is always true. */
|
|
20
|
-
notIn?: V extends Array<infer E> ? E
|
|
25
|
+
notIn?: (V extends Array<infer E> ? E : V)[];
|
|
21
26
|
lt?: V | number | Date;
|
|
22
27
|
lte?: V | number | Date;
|
|
23
28
|
gt?: V | number | Date;
|