Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

⬆️ Update dependency effect to v3 #126

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

renovate[bot]
Copy link
Contributor

@renovate renovate bot commented Apr 16, 2024

This PR contains the following updates:

Package Change Age Adoption Passing Confidence
effect (source) 2.2.5 -> 3.13.1 age adoption passing confidence

Release Notes

Effect-TS/effect (effect)

v3.13.1

Compare Source

Patch Changes

v3.13.0

Compare Source

Minor Changes
  • #​4280 8baef83 Thanks @​tim-smart! - add Promise based apis to Fiber{Handle,Set,Map} modules

  • #​4280 655bfe2 Thanks @​gcanti! - Add Effect.transposeOption, closes #​3142.

    Converts an Option of an Effect into an Effect of an Option.

    Details

    This function transforms an Option<Effect<A, E, R>> into an
    Effect<Option<A>, E, R>. If the Option is None, the resulting Effect
    will immediately succeed with a None value. If the Option is Some, the
    inner Effect will be executed, and its result wrapped in a Some.

    Example

    import { Effect, Option } from "effect"
    
    //      ┌─── Option<Effect<number, never, never>>
    //      ▼
    const maybe = Option.some(Effect.succeed(42))
    
    //      ┌─── Effect<Option<number>, never, never>
    //      ▼
    const result = Effect.transposeOption(maybe)
    
    console.log(Effect.runSync(result))
    // Output: { _id: 'Option', _tag: 'Some', value: 42 }
  • #​4280 d90cbc2 Thanks @​indietyp! - Add Effect.whenLogLevel, which conditionally executes an effect if the specified log level is enabled

  • #​4280 75632bd Thanks @​tim-smart! - add RcMap.touch, for reseting the idle timeout for an item

  • #​4280 c874a2e Thanks @​LaureRC! - Add HashMap.some

  • #​4280 bf865e5 Thanks @​tim-smart! - allow accessing args in Effect.fn pipe

  • #​4280 f98b2b7 Thanks @​tim-smart! - add RcMap.invalidate api, for removing a resource from an RcMap

  • #​4280 de8ce92 Thanks @​mikearnaldi! - Add Layer.updateService mirroring Effect.updateService

  • #​4280 db426a5 Thanks @​KhraksMamtsov! - Differ implements Pipeable

  • #​4280 6862444 Thanks @​thewilkybarkid! - Make it easy to convert a DateTime.Zoned to a DateTime.Utc

  • #​4280 5fc8a90 Thanks @​gcanti! - Add missing Either.void constructor.

  • #​4280 546a492 Thanks @​vinassefranche! - Add HashMap.toValues and HashSet.toValues getters

  • #​4280 65c4796 Thanks @​tim-smart! - add {FiberHandle,FiberSet,FiberMap}.awaitEmpty apis

  • #​4280 9760fdc Thanks @​gcanti! - Schema: Add standardSchemaV1 API to Generate a Standard Schema v1.

    Example

    import { Schema } from "effect"
    
    const schema = Schema.Struct({
      name: Schema.String
    })
    
    //      ┌─── StandardSchemaV1<{ readonly name: string; }>
    //      ▼
    const standardSchema = Schema.standardSchemaV1(schema)
  • #​4280 5b471e7 Thanks @​fubhy! - Added Duration.formatIso and Duration.fromIso for formatting and parsing ISO8601 durations.

  • #​4280 4f810cc Thanks @​tim-smart! - add Effect.filterEffect* apis

Effect.filterEffectOrElse

Filters an effect with an effectful predicate, falling back to an alternative
effect if the predicate fails.

import { Effect, pipe } from "effect"

// Define a user interface
interface User {
  readonly name: string
}

// Simulate an asynchronous authentication function
declare const auth: () => Promise<User | null>

const program = pipe(
  Effect.promise(() => auth()),
  // Use filterEffectOrElse with an effectful predicate
  Effect.filterEffectOrElse({
    predicate: (user) => Effect.succeed(user !== null),
    orElse: (user) => Effect.fail(new Error(`Unauthorized user: ${user}`))
  })
)
Effect.filterEffectOrFail

Filters an effect with an effectful predicate, failing with a custom error if the predicate fails.

import { Effect, pipe } from "effect"

// Define a user interface
interface User {
  readonly name: string
}

// Simulate an asynchronous authentication function
declare const auth: () => Promise<User | null>

const program = pipe(
  Effect.promise(() => auth()),
  // Use filterEffectOrFail with an effectful predicate
  Effect.filterEffectOrFail({
    predicate: (user) => Effect.succeed(user !== null),
    orFailWith: (user) => Effect.fail(new Error(`Unauthorized user: ${user}`))
  })
)
Patch Changes
  • #​4280 cf8b2dd Thanks @​KhraksMamtsov! - Trie<out A> type annotations have been aligned. The type parameter was made covariant because the structure is immutable.

v3.12.12

Compare Source

Patch Changes
  • #​4440 4018eae Thanks @​gcanti! - Schema: add missing support for tuple annotations in TaggedRequest.

  • #​4439 543d36d Thanks @​gcanti! - Schedule: fix unsafe tapOutput signature.

    Previously, tapOutput allowed using an output type that wasn't properly inferred, leading to potential runtime errors. Now, TypeScript correctly detects mismatches at compile time, preventing unexpected crashes.

    Before (Unsafe, Causes Runtime Error)

    import { Effect, Schedule, Console } from "effect"
    
    const schedule = Schedule.once.pipe(
      Schedule.as<number | string>(1),
      Schedule.tapOutput((s: string) => Console.log(s.trim())) // ❌ Runtime error
    )
    
    Effect.runPromise(Effect.void.pipe(Effect.schedule(schedule)))
    // throws: TypeError: s.trim is not a function

    After (Safe, Catches Type Error at Compile Time)

    import { Console, Schedule } from "effect"
    
    const schedule = Schedule.once.pipe(
      Schedule.as<number | string>(1),
      // ✅ Type Error: Type 'number' is not assignable to type 'string'
      Schedule.tapOutput((s: string) => Console.log(s.trim()))
    )
  • #​4447 f70a65a Thanks @​gcanti! - Preserve function length property in Effect.fn / Effect.fnUntraced, closes #​4435

    Previously, functions created with Effect.fn and Effect.fnUntraced always had a .length of 0, regardless of their actual number of parameters. This has been fixed so that the length property correctly reflects the expected number of arguments.

    Before

    import { Effect } from "effect"
    
    const fn1 = Effect.fn("fn1")(function* (n: number) {
      return n
    })
    
    console.log(fn1.length)
    // Output: 0 ❌ (incorrect)
    
    const fn2 = Effect.fnUntraced(function* (n: number) {
      return n
    })
    
    console.log(fn2.length)
    // Output: 0 ❌ (incorrect)

    After

    import { Effect } from "effect"
    
    const fn1 = Effect.fn("fn1")(function* (n: number) {
      return n
    })
    
    console.log(fn1.length)
    // Output: 1 ✅ (correct)
    
    const fn2 = Effect.fnUntraced(function* (n: number) {
      return n
    })
    
    console.log(fn2.length)
    // Output: 1 ✅ (correct)
  • #​4422 ba409f6 Thanks @​mikearnaldi! - Fix Context.Tag inference using explicit generics

  • #​4432 3d2e356 Thanks @​tim-smart! - use Map for Scope finalizers, to ensure they are always added

v3.12.11

Compare Source

Patch Changes

v3.12.10

Compare Source

Patch Changes
  • #​4412 e30f132 Thanks @​KhraksMamtsov! - Fix STM unification

  • #​4403 33fa667 Thanks @​gcanti! - Duration: fix format output when the input is zero.

    Before

    import { Duration } from "effect"
    
    console.log(Duration.format(Duration.zero))
    // Output: ""

    After

    import { Duration } from "effect"
    
    console.log(Duration.format(Duration.zero))
    // Output: "0"
  • #​4411 87f5f28 Thanks @​gcanti! - Enhance TagClass and ReferenceClass to enforce key type narrowing, closes #​4409.

    The key property in TagClass and ReferenceClass now correctly retains its specific string value, just like in Effect.Service

    import { Context, Effect } from "effect"
    
    // -------------------------------------------------------------------------------------
    // `key` field
    // -------------------------------------------------------------------------------------
    
    class A extends Effect.Service<A>()("A", { succeed: { a: "value" } }) {}
    
    // $ExpectType "A"
    A.key
    
    class B extends Context.Tag("B")<B, { a: "value" }>() {}
    
    // $ExpectType "B"
    B.key
    
    class C extends Context.Reference<C>()("C", { defaultValue: () => 0 }) {}
    
    // $ExpectType "C"
    C.key
  • #​4397 4dbd170 Thanks @​thewilkybarkid! - Make Array.makeBy dual

v3.12.9

Compare Source

Patch Changes

v3.12.8

Compare Source

Patch Changes
  • #​4341 766113c Thanks @​fubhy! - Improve Duration.decode Handling of High-Resolution Time

    • Ensured Immutability: Added the readonly modifier to [seconds: number, nanos: number] in DurationInput to prevent accidental modifications.
    • Better Edge Case Handling: Now correctly processes special values like -Infinity and NaN when they appear in the tuple representation of duration.
  • #​4333 712277f Thanks @​gcanti! - Cron: unsafeParse now throws a more informative error instead of a generic one

  • #​4387 f269122 Thanks @​KhraksMamtsov! - A more precise signature has been applied for Effect.schedule

  • #​4351 430c846 Thanks @​tim-smart! - fix Layer.scope types to correctly use the Scope tag identifier

  • #​4344 7b03057 Thanks @​IMax153! - Expose Schedule.isSchedule

  • #​4313 a9c94c8 Thanks @​gcanti! - Schema: Update Duration Encoding to a Tagged Union Format.

    This changeset fixes the Duration schema to support all possible duration types, including finite, infinite, and nanosecond durations. The encoding format has been updated from a tuple (readonly [seconds: number, nanos: number]) to a tagged union.

    This update introduces a change to the encoding format. The previous tuple representation is replaced with a more expressive tagged union, which accommodates all duration types:

    type DurationEncoded =
      | {
          readonly _tag: "Millis"
          readonly millis: number
        }
      | {
          readonly _tag: "Nanos"
          readonly nanos: string
        }
      | {
          readonly _tag: "Infinity"
        }

    Rationale

    The Duration schema is primarily used to encode durations for transmission. The new tagged union format ensures clear and precise encoding for:

    • Finite durations, such as milliseconds.
    • Infinite durations, such as Duration.infinity.
    • Nanosecond durations.

    Example

    import { Duration, Schema } from "effect"
    
    // Encoding a finite duration in milliseconds
    console.log(Schema.encodeSync(Schema.Duration)(Duration.millis(1000)))
    // Output: { _tag: 'Millis', millis: 1000 }
    
    // Encoding an infinite duration
    console.log(Schema.encodeSync(Schema.Duration)(Duration.infinity))
    // Output: { _tag: 'Infinity' }
    
    // Encoding a duration in nanoseconds
    console.log(Schema.encodeSync(Schema.Duration)(Duration.nanos(1000n)))
    // Output: { _tag: 'Nanos', nanos: '1000' }
  • #​4331 107e6f0 Thanks @​gcanti! - Schema: Improve encoding in Defect and add test for array-based defects.

  • #​4329 65c11b9 Thanks @​gcanti! - Schema: Update itemsCount to allow 0 as a valid argument, closes #​4328.

  • #​4330 e386d2f Thanks @​gcanti! - Add missing overload for Option.as.

  • #​4352 9172efb Thanks @​tim-smart! - optimize Stream.toReadableStream

v3.12.7

Compare Source

Patch Changes

v3.12.6

Compare Source

Patch Changes
  • #​4307 289c13b Thanks @​gcanti! - Schema: Enhance error messages for discriminated unions.

    Before

    import { Schema } from "effect"
    
    const schema = Schema.Union(
      Schema.Tuple(Schema.Literal(-1), Schema.Literal(0)).annotations({
        identifier: "A"
      }),
      Schema.Tuple(Schema.NonNegativeInt, Schema.NonNegativeInt).annotations({
        identifier: "B"
      })
    ).annotations({ identifier: "AB" })
    
    Schema.decodeUnknownSync(schema)([-500, 0])
    /*
    throws:
    ParseError: AB
    ├─ { readonly 0: -1 }
    │  └─ ["0"]
    │     └─ Expected -1, actual -500
    └─ B
       └─ [0]
          └─ NonNegativeInt
             └─ From side refinement failure
                └─ NonNegative
                   └─ Predicate refinement failure
                      └─ Expected a non-negative number, actual -500
    */

    After

    import { Schema } from "effect"
    
    const schema = Schema.Union(
      Schema.Tuple(Schema.Literal(-1), Schema.Literal(0)).annotations({
        identifier: "A"
      }),
      Schema.Tuple(Schema.NonNegativeInt, Schema.NonNegativeInt).annotations({
        identifier: "B"
      })
    ).annotations({ identifier: "AB" })
    
    Schema.decodeUnknownSync(schema)([-500, 0])
    /*
    throws:
    ParseError: AB
    -├─ { readonly 0: -1 }
    +├─ A
    │  └─ ["0"]
    │     └─ Expected -1, actual -500
    └─ B
       └─ [0]
          └─ NonNegativeInt
             └─ From side refinement failure
                └─ NonNegative
                   └─ Predicate refinement failure
                      └─ Expected a non-negative number, actual -500
    */
  • #​4298 8b4e75d Thanks @​KhraksMamtsov! - Added type-level validation for the Effect.Service function to ensure the Self generic parameter is provided. If the generic is missing, the MissingSelfGeneric type will be returned, indicating that the generic parameter must be specified. This improves type safety and prevents misuse of the Effect.Service function.

    type MissingSelfGeneric =
      `Missing \`Self\` generic - use \`class Self extends Service<Self>()...\``
  • #​4292 fc5e0f0 Thanks @​gcanti! - Improve UnknownException error messages

    UnknownException error messages now include the name of the Effect api that
    created the error.

    import { Effect } from "effect"
    
    Effect.tryPromise(() =>
      Promise.reject(new Error("The operation failed"))
    ).pipe(Effect.catchAllCause(Effect.logError), Effect.runFork)
    
    // timestamp=2025-01-21T00:41:03.403Z level=ERROR fiber=#&#8203;0 cause="UnknownException: An unknown error occurred in Effect.tryPromise
    //     at fail (.../effect/packages/effect/src/internal/core-effect.ts:1654:19)
    //     at <anonymous> (.../effect/packages/effect/src/internal/core-effect.ts:1674:26) {
    //   [cause]: Error: The operation failed
    //       at <anonymous> (.../effect/scratchpad/error.ts:4:24)
    //       at .../effect/packages/effect/src/internal/core-effect.ts:1671:7
    // }"
  • #​4309 004fd2b Thanks @​gcanti! - Schema: Enforce Finite Durations in DurationFromNanos.

    This update ensures that DurationFromNanos only accepts finite durations. Previously, the schema did not explicitly enforce this constraint.

    A filter has been added to validate that the duration is finite.

    DurationFromSelf
    +.pipe(
    +  filter((duration) => duration_.isFinite(duration), {
    +    description: "a finite duration"
    +  })
    )
  • #​4314 b2a31be Thanks @​gcanti! - Duration: make DurationValue properties readonly.

  • #​4287 5514d05 Thanks @​gcanti! - Array: Fix Either import and correct partition example.

  • #​4301 bf5f0ae Thanks @​gcanti! - Schema: Fix BigIntFromNumber to enforce upper and lower bounds.

    This update ensures the BigIntFromNumber schema adheres to safe integer limits by applying the following bounds:

    BigIntFromSelf
    +  .pipe(
    +    betweenBigInt(
    +      BigInt(Number.MIN_SAFE_INTEGER),
    +      BigInt(Number.MAX_SAFE_INTEGER)
    +    )
    +  )
  • #​4228 3b19bcf Thanks @​fubhy! - Fixed conflicting ParseError tags between Cron and Schema

  • #​4294 b064b3b Thanks @​tim-smart! - ensure cause is rendered in FiberFailure

  • #​4307 289c13b Thanks @​gcanti! - Schema: Add Support for Infinity in Duration.

    This update adds support for encoding Duration.infinity in Schema.Duration.

    Before

    Attempting to encode Duration.infinity resulted in a ParseError due to the lack of support for Infinity in Schema.Duration:

    import { Duration, Schema } from "effect"
    
    console.log(Schema.encodeUnknownSync(Schema.Duration)(Duration.infinity))
    /*
    throws:
    ParseError: Duration
    └─ Encoded side transformation failure
       └─ HRTime
          └─ [0]
             └─ NonNegativeInt
                └─ Predicate refinement failure
                   └─ Expected an integer, actual Infinity
    */

    After

    The updated behavior successfully encodes Duration.infinity as [ -1, 0 ]:

    import { Duration, Schema } from "effect"
    
    console.log(Schema.encodeUnknownSync(Schema.Duration)(Duration.infinity))
    // Output: [ -1, 0 ]
  • #​4300 f474678 Thanks @​gcanti! - Schema: update pluck type signature to respect optional fields.

    Before

    import { Schema } from "effect"
    
    const schema1 = Schema.Struct({ a: Schema.optional(Schema.String) })
    
    /*
    const schema2: Schema.Schema<string | undefined, {
        readonly a: string | undefined;
    }, never>
    */
    const schema2 = Schema.pluck(schema1, "a")

    After

    import { Schema } from "effect"
    
    const schema1 = Schema.Struct({ a: Schema.optional(Schema.String) })
    
    /*
    const schema2: Schema.Schema<string | undefined, {
        readonly a?: string | undefined;
    }, never>
    */
    const schema2 = Schema.pluck(schema1, "a")
  • #​4296 ee187d0 Thanks @​gcanti! - fix: update Cause.isCause type from 'never' to 'unknown'

v3.12.5

Compare Source

Patch Changes
  • #​4273 a8b0ddb Thanks @​gcanti! - Arbitrary: Fix bug adjusting array constraints for schemas with fixed and rest elements

    This fix ensures that when a schema includes both fixed elements and a rest element, the constraints for the array are correctly adjusted. The adjustment now subtracts the number of values generated by the fixed elements from the overall constraints.

  • #​4259 507d546 Thanks @​gcanti! - Schema: improve error messages for invalid transformations

    Before

    import { Schema } from "effect"
    
    Schema.decodeUnknownSync(Schema.NumberFromString)("a")
    /*
    throws:
    ParseError: NumberFromString
    └─ Transformation process failure
       └─ Expected NumberFromString, actual "a"
    */

    After

    import { Schema } from "effect"
    
    Schema.decodeUnknownSync(Schema.NumberFromString)("a")
    /*
    throws:
    ParseError: NumberFromString
    └─ Transformation process failure
       └─ Unable to decode "a" into a number
    */
  • #​4273 a8b0ddb Thanks @​gcanti! - Schema: Extend Support for Array filters, closes #​4269.

    Added support for minItems, maxItems, and itemsCount to all schemas where A extends ReadonlyArray, including NonEmptyArray.

    Example

    import { Schema } from "effect"
    
    // Previously, this would have caused an error
    const schema = Schema.NonEmptyArray(Schema.String).pipe(Schema.maxItems(2))
  • #​4257 8db239b Thanks @​gcanti! - Schema: Correct BigInt and BigIntFromNumber identifier annotations to follow naming conventions

  • #​4276 84a0911 Thanks @​tim-smart! - fix formatting of time zone offsets that round to 60 minutes

  • #​4276 84a0911 Thanks @​tim-smart! - ensure DateTimeZonedFromSelf arbitrary generates in the range supported by the time zone database

  • #​4267 3179a9f Thanks @​tim-smart! - ensure DateTime.Zoned produces valid dates

  • #​4264 6cb9b76 Thanks @​gcanti! - Relocate the Issue definition from platform/HttpApiError to Schema (renamed as ArrayFormatterIssue).

  • #​4266 1fcbe55 Thanks @​gcanti! - Schema: Replace the TimeZoneFromSelf interface with a class definition and fix the arbitraries for DateTimeUtcFromSelf and DateTimeZonedFromSelf (fc.date({ noInvalidDate: true })).

  • #​4279 d9a63d9 Thanks @​tim-smart! - improve performance of Effect.forkIn

v3.12.4

Compare Source

Patch Changes

v3.12.3

Compare Source

Patch Changes
  • #​4244 d7dac48 Thanks @​gcanti! - Improve pattern handling by merging multiple patterns into a union, closes #​4243.

    Previously, the algorithm always prioritized the first pattern when multiple patterns were encountered.

    This fix introduces a merging strategy that combines patterns into a union (e.g., (?:${pattern1})|(?:${pattern2})). By doing so, all patterns have an equal chance to generate values when using FastCheck.stringMatching.

    Example

    import { Arbitrary, FastCheck, Schema } from "effect"
    
    // /^[^A-Z]*$/ (given by Lowercase) + /^0x[0-9a-f]{40}$/
    const schema = Schema.Lowercase.pipe(Schema.pattern(/^0x[0-9a-f]{40}$/))
    
    const arb = Arbitrary.make(schema)
    
    // Before this fix, the first pattern would always dominate,
    // making it impossible to generate values
    const sample = FastCheck.sample(arb, { numRuns: 100 })
    
    console.log(sample)
  • #​4252 1d7fd2b Thanks @​gcanti! - Fix: Correct Arbitrary.make to support nested TemplateLiterals.

    Previously, Arbitrary.make did not properly handle nested TemplateLiteral schemas, resulting in incorrect or empty outputs. This fix ensures that nested template literals are processed correctly, producing valid arbitrary values.

    Before

    import { Arbitrary, FastCheck, Schema as S } from "effect"
    
    const schema = S.TemplateLiteral(
      "<",
      S.TemplateLiteral("h", S.Literal(1, 2)),
      ">"
    )
    
    const arb = Arbitrary.make(schema)
    
    console.log(FastCheck.sample(arb, { numRuns: 10 }))
    /*
    Output:
    [
      '<>', '<>', '<>',
      '<>', '<>', '<>',
      '<>', '<>', '<>',
      '<>'
    ]
    */

    After

    import { Arbitrary, FastCheck, Schema as S } from "effect"
    
    const schema = S.TemplateLiteral(
      "<",
      S.TemplateLiteral("h", S.Literal(1, 2)),
      ">"
    )
    
    const arb = Arbitrary.make(schema)
    
    console.log(FastCheck.sample(arb, { numRuns: 10 }))
    /*
    Output:
    [
      '<h2>', '<h2>',
      '<h2>', '<h2>',
      '<h2>', '<h1>',
      '<h2>', '<h1>',
      '<h1>', '<h1>'
    ]
    */
  • #​4252 1d7fd2b Thanks @​gcanti! - Fix: Allow Schema.TemplateLiteral to handle strings with linebreaks, closes #​4251.

    Before

    import { Schema } from "effect"
    
    const schema = Schema.TemplateLiteral("a: ", Schema.String)
    
    console.log(Schema.decodeSync(schema)("a: b \n c"))
    // throws: ParseError: Expected `a: ${string}`, actual "a: b \n c"

    After

    import { Schema } from "effect"
    
    const schema = Schema.TemplateLiteral("a: ", Schema.String)
    
    console.log(Schema.decodeSync(schema)("a: b \n c"))
    /*
    Output:
    a: b
     c
    */

v3.12.2

Compare Source

Patch Changes
  • #​4220 734af82 Thanks @​KhraksMamtsov! - fix inference for contravariant type-parameters

  • #​4212 b63c780 Thanks @​KhraksMamtsov! - Refine Effect.validateAll return type to use NonEmptyArray for errors.

    This refinement is possible because Effect.validateAll guarantees that when the input iterable is non-empty, any validation failure will produce at least one error. In such cases, the errors are inherently non-empty, making it safe and accurate to represent them using a NonEmptyArray type. This change aligns the return type with the function's actual behavior, improving type safety and making the API more predictable for developers.

  • #​4219 c640d77 Thanks @​whoisandy! - fix: ManagedRuntime.Context to work when Context is of type never

  • #​4236 0def088 Thanks @​tim-smart! - fix color option for Logger.prettyLogger

v3.12.1

Compare Source

Patch Changes

v3.12.0

Compare Source

Minor Changes
Patch Changes

v3.11.10

Compare Source

Patch Changes
  • #​4176 39457d4 Thanks @​mikearnaldi! - Fix Stream.scoped example

  • #​4181 a475cc2 Thanks @​gcanti! - Schema: Fix withDecodingDefault implementation to align with its signature (now removes undefined from the AST).

    Additionally, a new constraint has been added to the signature to prevent calling withDecodingDefault after withConstructorDefault, which previously led to the following issue:

    import { Schema } from "effect"
    
    const schema = Schema.Struct({
      a: Schema.optional(Schema.String).pipe(
        Schema.withConstructorDefault(() => undefined), // this is invalidated by the following call to `withDecodingDefault`
        Schema.withDecodingDefault(() => "")
      )
    })
  • #​4175 199214e Thanks @​gcanti! - Schema: refactor annotations:

    • Export internal Uint8 schema

    • Export internal NonNegativeInt schema

    • Remove title annotations that are identical to identifiers

    • Avoid setting a title annotation when applying branding

    • Add more title annotations to refinements

    • Improve toString output and provide more precise error messages for refinements:

      Before

      import { Schema } from "effect"
      
      const schema = Schema.Number.pipe(
        Schema.int({ identifier: "MyInt" }),
        Schema.positive()
      )
      
      console.log(String(schema))
      // Output: a positive number
      
      Schema.decodeUnknownSync(schema)(1.1)
      /*
      throws:
      ParseError: a positive number
      └─ From side refinement failure
        └─ MyInt
            └─ Predicate refinement failure
              └─ Expected MyInt, actual 1.1
      */

      After

      • toString now combines all refinements with " & " instead of showing only the last one.
      • The last message ("Expected ...") now uses the extended description to make the error message clearer.
      import { Schema } from "effect"
      
      const schema = Schema.Number.pipe(
        Schema.int({ identifier: "MyInt" }),
        Schema.positive()
      )
      
      console.log(String(schema))
      // Output: MyInt & positive // <= all the refinements
      
      Schema.decodeUnknownSync(schema)(1.1)
      /*
      throws:
      ParseError: MyInt & positive
      └─ From side refinement failure
        └─ MyInt
            └─ Predicate refinement failure
              └─ Expected an integer, actual 1.1 // <= extended description
      */
  • #​4182 b3c160d Thanks @​mikearnaldi! - Replace absolute imports with relative ones

v3.11.9

Compare Source

Patch Changes
  • #​4113 1c08a0b Thanks @​thewilkybarkid! - Schema: Support template literals in Schema.Config.

    Example

    import { Schema } from "effect"
    
    // const config: Config<`a${string}`>
    const config = Schema.Config(
      "A",
      Schema.TemplateLiteral(Schema.Literal("a"), Schema.String)
    )
  • #​4174 1ce703b Thanks @​gcanti! - Schema: Add support for TemplateLiteral parameters in TemplateLiteral, closes #​4166.

    This update also adds support for TemplateLiteral and TemplateLiteralParser parameters in TemplateLiteralParser.

    Before

    import { Schema } from "effect"
    
    const schema = Schema.TemplateLiteralParser(
      "<",
      Schema.TemplateLiteralParser("h", Schema.Literal(1, 2)),
      ">"
    )
    /*
    throws:
    Error: Unsupported template literal span
    schema (TemplateLiteral): `h${"1" | "2"}`
    */

    After

    import { Schema } from "effect"
    
    // Schema<readonly ["<", readonly ["h", 2 | 1], ">"], "<h2>" | "<h1>", never>
    const schema = Schema.TemplateLiteralParser(
      "<",
      Schema.TemplateLiteralParser("h", Schema.Literal(1, 2)),
      ">"
    )
    
    console.log(Schema.decodeUnknownSync(schema)("<h1>"))
    // Output: [ '<', [ 'h', 1 ], '>' ]
  • #​4174 1ce703b Thanks @​gcanti! - Schema: Fix bug in TemplateLiteralParser where unions of numeric literals were not coerced correctly.

    Before

    import { Schema } from "effect"
    
    const schema = Schema.TemplateLiteralParser("a", Schema.Literal(1, 2))
    
    console.log(Schema.decodeUnknownSync(schema)("a1"))
    /*
    throws:
    ParseError: (`a${"1" | "2"}` <-> readonly ["a", 1 | 2])
    └─ Type side transformation failure
       └─ readonly ["a", 1 | 2]
          └─ [1]
             └─ 1 | 2
                ├─ Expected 1, actual "1"
                └─ Expected 2, actual "1"
    */

    After

    import { Schema } from "effect"
    
    const schema = Schema.TemplateLiteralParser("a", Schema.Literal(1, 2))
    
    console.log(Schema.decodeUnknownSync(schema)("a1"))
    // Output: [ 'a', 1 ]
    
    console.log(Schema.decodeUnknownSync(schema)("a2"))
    // Output: [ 'a', 2 ]
    
    console.log(Schema.decodeUnknownSync(schema)("a3"))
    /*
    throws:
    ParseError: (`a${"1" | "2"}` <-> readonly ["a", 1 | 2])
    └─ Encoded side transformation failure
       └─ Expected `a${"1" | "2"}`, actual "a3"
    */

v3.11.8

Compare Source

Patch Changes

v3.11.7

Compare Source

Patch Changes
  • #​4137 2408616 Thanks @​gcanti! - Arbitrary: fix bug where refinements in declarations raised an incorrect missing annotation error, closes #​4136

  • #​4138 cec0b4d Thanks @​gcanti! - JSONSchema: ignore never members in unions.

    Before

    import { JSONSchema, Schema } from "effect"
    
    const schema = Schema.Union(Schema.String, Schema.Never)
    
    console.log(JSON.stringify(JSONSchema.make(schema), null, 2))
    /*
    {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "anyOf": [
        {
          "type": "string"
        },
        {
          "$id": "/schemas/never",
          "not": {},
          "title": "never"
      

Configuration

📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

Rebasing: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this PR and you won't be reminded about this update again.


  • If you want to rebase/retry this PR, check this box

This PR was generated by Mend Renovate. View the repository job log.

@renovate renovate bot added renovate upgrade Any kind of dependency updates labels Apr 16, 2024
Copy link
Contributor Author

renovate bot commented Apr 16, 2024

⚠ Artifact update problem

Renovate failed to update an artifact related to this branch. You probably do not want to merge this PR as-is.

♻ Renovate will retry this branch, including artifacts, only when one of the following happens:

  • any of the package files in this branch needs updating, or
  • the branch becomes conflicted, or
  • you click the rebase/retry checkbox if found above, or
  • you rename this PR's title to start with "rebase!" to trigger it manually

The artifact failure details are included below:

File name: package-lock.json
npm error code ERESOLVE
npm error ERESOLVE could not resolve
npm error
npm error While resolving: @effect/[email protected]
npm error Found: [email protected]
npm error node_modules/effect
npm error   effect@"3.1.3" from the root project
npm error
npm error Could not resolve dependency:
npm error peer effect@"^2.1.1" from @effect/[email protected]
npm error node_modules/@effect/schema
npm error   @effect/schema@"0.60.4" from the root project
npm error
npm error Conflicting peer dependency: [email protected]
npm error node_modules/effect
npm error   peer effect@"^2.1.1" from @effect/[email protected]
npm error   node_modules/@effect/schema
npm error     @effect/schema@"0.60.4" from the root project
npm error
npm error Fix the upstream dependency conflict, or retry
npm error this command with --force or --legacy-peer-deps
npm error to accept an incorrect (and potentially broken) dependency resolution.
npm error
npm error
npm error For a full report see:
npm error /tmp/renovate/cache/others/npm/_logs/2024-05-08T22_22_18_081Z-eresolve-report.txt

npm error A complete log of this run can be found in: /tmp/renovate/cache/others/npm/_logs/2024-05-08T22_22_18_081Z-debug-0.log

@renovate renovate bot force-pushed the renovate/effect-3.x branch 8 times, most recently from ac64789 to 5c44085 Compare April 25, 2024 04:19
@renovate renovate bot force-pushed the renovate/effect-3.x branch 10 times, most recently from 9d2cf0f to d4fa257 Compare May 2, 2024 22:37
@renovate renovate bot force-pushed the renovate/effect-3.x branch 9 times, most recently from b3879b8 to a7c2703 Compare May 8, 2024 22:22
@renovate renovate bot force-pushed the renovate/effect-3.x branch 6 times, most recently from 482e5f8 to 7a6da2b Compare January 17, 2025 12:33
@renovate renovate bot force-pushed the renovate/effect-3.x branch 9 times, most recently from cf1439f to 7bbf27f Compare January 27, 2025 04:38
@renovate renovate bot force-pushed the renovate/effect-3.x branch 6 times, most recently from adaa3a5 to d271801 Compare February 4, 2025 08:28
@renovate renovate bot force-pushed the renovate/effect-3.x branch 5 times, most recently from bef27c7 to 7b80912 Compare February 11, 2025 13:10
@renovate renovate bot force-pushed the renovate/effect-3.x branch 2 times, most recently from cb060fe to 8da22b5 Compare February 14, 2025 02:14
@renovate renovate bot force-pushed the renovate/effect-3.x branch from 8da22b5 to 9f29b79 Compare February 14, 2025 18:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
renovate upgrade Any kind of dependency updates
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0 participants