@effect-app/infra 0.217.0 → 0.218.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.
@@ -1,7 +1,7 @@
1
1
  /* eslint-disable @typescript-eslint/no-explicit-any */
2
2
  /* eslint-disable @typescript-eslint/ban-types */
3
3
  import type { ValidationError } from "@effect-app/infra/errors"
4
- import type { StructFields } from "effect-app/schema"
4
+ import type { Struct } from "effect-app/schema"
5
5
  import { type RouteDescriptorAny } from "./schema/routing.js"
6
6
  import type {} from "effect-app/utils"
7
7
  import type { Layer, Ref, Scope } from "effect-app"
@@ -17,13 +17,13 @@ export const RouteDescriptors = Context.GenericTag<Ref<RouteDescriptorAny[]>>("@
17
17
  export function match<
18
18
  R,
19
19
  M,
20
- PathA extends StructFields,
21
- CookieA extends StructFields,
22
- QueryA extends StructFields,
23
- BodyA extends StructFields,
24
- HeaderA extends StructFields,
20
+ PathA extends Struct.Fields,
21
+ CookieA extends Struct.Fields,
22
+ QueryA extends Struct.Fields,
23
+ BodyA extends Struct.Fields,
24
+ HeaderA extends Struct.Fields,
25
25
  ReqA extends PathA & QueryA & BodyA,
26
- ResA extends StructFields,
26
+ ResA extends Struct.Fields,
27
27
  ResE,
28
28
  MiddlewareE,
29
29
  PPath extends `/${string}`,
@@ -17,7 +17,7 @@ export const parseJwt = <R, I, A>(
17
17
  (s, __, ast) =>
18
18
  S.ParseResult.try({
19
19
  try: () => jwtDecode(s, options),
20
- catch: (e: any) => S.ParseResult.type(ast, s, e?.message)
20
+ catch: (e: any) => new S.ParseResult.Type(ast, s, e?.message)
21
21
  }),
22
22
  (_): Effect<string, ParseIssue> => {
23
23
  throw new Error("not implemented")
@@ -393,12 +393,12 @@ export function makeRepo<
393
393
  _.ast._tag === "Union"
394
394
  // we need to get the TypeLiteral, incase of class it's behind a transform...
395
395
  ? S.union(..._.ast.types.map((_) =>
396
- (S.make(_._tag === "Transform" ? _.from : _) as unknown as Schema<T, From>)
396
+ (S.make(_._tag === "Transformation" ? _.from : _) as unknown as Schema<T, From>)
397
397
  .pipe(S.pick("id"))
398
398
  ))
399
399
  : _
400
400
  .ast
401
- ._tag === "Transform"
401
+ ._tag === "Transformation"
402
402
  ? (S
403
403
  .make(
404
404
  _
@@ -1 +1 @@
1
- {"version":3,"file":"query.test.d.ts","sourceRoot":"","sources":["../query.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAQ,KAAK,EAAgB,CAAC,EAAE,MAAM,YAAY,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcjE,qBAAa,CAAE,SAAQ,MAOrB;CAAG;AACL,MAAM,CAAC,OAAO,WAAW,CAAC,CAAC;IACzB,KAAY,IAAI,GAAG,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAA;CAC3C;;;;;;;;;;;;;;;;;;;;;;;;;AAGD,qBAAa,WAAY,SAAQ,gBAA6D;CAAG"}
1
+ {"version":3,"file":"query.test.d.ts","sourceRoot":"","sources":["../query.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAQ,KAAK,EAAgB,CAAC,EAAE,MAAM,YAAY,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcjE,qBAAa,CAAE,SAAQ,MAOrB;CAAG;AACL,MAAM,CAAC,OAAO,WAAW,CAAC,CAAC;IACzB,KAAY,IAAI,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAA;CAC9C;;;;;;;;;;;;;;;;;;;;;;;;;AAGD,qBAAa,WAAY,SAAQ,gBAA6D;CAAG"}
@@ -16,12 +16,12 @@ export class s extends S.Class<s>()({
16
16
  id: S.StringId.withDefault,
17
17
  displayName: S.NonEmptyString255,
18
18
  n: S.Date.withDefault,
19
- union: someUnion.pipe(
20
- S.withDefaultConstructor(() => ({ _tag: "string", value: "hi" }) as S.Schema.To<typeof someUnion>)
21
- )
19
+ union: S.propertySignature(someUnion, {
20
+ default: () => ({ _tag: "string", value: "hi" }) as S.Schema.Type<typeof someUnion>
21
+ })
22
22
  }) {}
23
23
  export declare namespace s {
24
- export type From = S.Schema.From<typeof s>
24
+ export type From = S.Schema.Encoded<typeof s>
25
25
  }
26
26
 
27
27
  const MakeSomeService = Effect.succeed({ a: 1 })
@@ -124,8 +124,8 @@ it("collect", () =>
124
124
  project(
125
125
  S.transformTo(
126
126
  // TODO: sample case with narrowing down a union?
127
- S.from(S.struct(pick(s.fields, "displayName", "n"))), // for projection performance benefit, this should be limited to the fields interested, and leads to SELECT fields
128
- S.to(S.option(S.string)),
127
+ S.encodedSchema(S.struct(pick(s.fields, "displayName", "n"))), // for projection performance benefit, this should be limited to the fields interested, and leads to SELECT fields
128
+ S.typeSchema(S.option(S.string)),
129
129
  (_) =>
130
130
  _.displayName === "Riley" && _.n === "2020-01-01T00:00:00.000Z"
131
131
  ? Option.some(`${_.displayName}-${_.n}`)
@@ -147,8 +147,8 @@ it("collect", () =>
147
147
  project(
148
148
  S.transformTo(
149
149
  // TODO: sample case with narrowing down a union?
150
- S.from(S.struct(pick(s.fields, "union"))), // for projection performance benefit, this should be limited to the fields interested, and leads to SELECT fields
151
- S.to(S.option(S.string)),
150
+ S.encodedSchema(S.struct(pick(s.fields, "union"))), // for projection performance benefit, this should be limited to the fields interested, and leads to SELECT fields
151
+ S.typeSchema(S.option(S.string)),
152
152
  (_) =>
153
153
  _.union._tag === "string"
154
154
  ? Option.some(_.union.value)