@effect-app/infra 2.45.3 → 2.47.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.
@@ -5,8 +5,7 @@ import { Context, Effect, flow, Layer, Option, pipe, S, Struct } from "effect-ap
5
5
  import { inspect } from "util"
6
6
  import { expect, expectTypeOf, it } from "vitest"
7
7
  import { setupRequestContextFromCurrent } from "../src/api/setupRequest.js"
8
- import type { QueryEnd, QueryProjection, QueryWhere } from "../src/Model/query.js"
9
- import { and, count, make, one, or, order, page, project, toFilter, where } from "../src/Model/query.js"
8
+ import { and, count, make, one, or, order, page, project, type QueryEnd, type QueryProjection, type QueryWhere, toFilter, where } from "../src/Model/query.js"
10
9
  import { makeRepo } from "../src/Model/Repository.js"
11
10
  import { memFilter, MemoryStoreLive } from "../src/Store/Memory.js"
12
11
 
@@ -863,3 +862,44 @@ it("does not allow string queries on arrays", () =>
863
862
  expectTypeOf(good4).toEqualTypeOf<QueryWhere<Some, Some>>()
864
863
  })
865
864
  .pipe(Effect.provide(MemoryStoreLive), setupRequestContextFromCurrent(), Effect.runPromise))
865
+
866
+ it("test array.length", () =>
867
+ Effect
868
+ .gen(function*() {
869
+ type Something = {
870
+ readonly id: string
871
+ readonly items: string[]
872
+ readonly tuple: [string, string]
873
+ }
874
+ const base = make<Something>()
875
+
876
+ const query1 = base.pipe(
877
+ where("items.length", 0)
878
+ )
879
+
880
+ const query2 = base.pipe(
881
+ where("items.length", "gt", 2)
882
+ )
883
+
884
+ const query3 = base.pipe(
885
+ where("tuple.length", 2)
886
+ )
887
+
888
+ base.pipe(
889
+ // @ts-expect-error tuple.length is not valid
890
+ where("tuple.length", 3)
891
+ )
892
+
893
+ expectTypeOf(query1).toEqualTypeOf<
894
+ QueryWhere<Something, Something>
895
+ >()
896
+
897
+ expectTypeOf(query2).toEqualTypeOf<
898
+ QueryWhere<Something, Something>
899
+ >()
900
+
901
+ expectTypeOf(query3).toEqualTypeOf<
902
+ QueryWhere<Something, Something>
903
+ >()
904
+ })
905
+ .pipe(Effect.provide(MemoryStoreLive), setupRequestContextFromCurrent(), Effect.runPromise))