Skip to content

effect@3.11.0

Choose a tag to compare

@github-actions github-actions released this 02 Dec 00:21
· 1382 commits to main since this release
87ab6a1

Minor Changes

  • #3835 147434b Thanks @IMax153! - Ensure scopes are preserved by stream / sink / channel operations

    NOTE: This change does modify the public signature of several Stream / Sink / Channel methods. Namely, certain run methods that previously removed a Scope from the environment will no longer do so. This was a bug with the previous implementation of how scopes were propagated, and is why this change is being made in a minor release.

  • #3835 6e69493 Thanks @tim-smart! - add Context.Reference - a Tag with a default value

  • #3835 147434b Thanks @IMax153! - Add Effect.scopedWith to run an effect that depends on a Scope, and then closes the Scope after the effect has completed

    import { Effect, Scope } from "effect"
    
    const program: Effect.Effect<void> = Effect.scopedWith((scope) =>
      Effect.acquireRelease(Effect.log("Acquiring..."), () =>
        Effect.log("Releasing...")
      ).pipe(Scope.extend(scope))
    )
    
    Effect.runPromise(program)
    // Output:
    // timestamp=2024-11-26T16:44:54.158Z level=INFO fiber=#0 message=Acquiring...
    // timestamp=2024-11-26T16:44:54.165Z level=INFO fiber=#0 message=Releasing...
  • #3835 d9fe79b Thanks @tim-smart! - remove Env, EnvRef & FiberFlags from Micro

  • #3835 251d189 Thanks @KhraksMamtsov! - Config.url constructor has been added, which parses a string using new URL()

  • #3835 5a259f3 Thanks @tim-smart! - use fiber based runtime for Micro module

    • Improved performance
    • Improved interruption model
    • Consistency with the Effect data type
  • #3835 b4ce4ea Thanks @SandroMaglione! - New methods extractAll and extractSchema to UrlParams (added Schema.BooleanFromString).

  • #3835 15fcc5a Thanks @fubhy! - Integrated DateTime with Cron to add timezone support for cron expressions.

  • #3835 9bc9a47 Thanks @KhraksMamtsov! - URL and URLFromSelf schemas have been added

  • #3835 aadb8a4 Thanks @fubhy! - Added BigDecimal.toExponential for scientific notation formatting of BigDecimal values.

    The implementation of BigDecimal.format now uses scientific notation for values with
    at least 16 decimal places or trailing zeroes. Previously, extremely large or small values
    could cause OutOfMemory errors when formatting.

  • #3835 1e2747c Thanks @KhraksMamtsov! - - JSONSchema module

    • add format?: string optional field to JsonSchema7String interface
    • Schema module
      • add custom json schema annotation to UUID schema including format: "uuid"
    • OpenApiJsonSchema module
      • add format?: string optional field to String and Numeric interfaces
  • #3835 e0b9b09 Thanks @mikearnaldi! - Implement Effect.fn to define traced functions.

    import { Effect } from "effect"
    
    const logExample = Effect.fn("example")(function* <N extends number>(n: N) {
      yield* Effect.annotateCurrentSpan("n", n)
      yield* Effect.logInfo(`got: ${n}`)
      yield* Effect.fail(new Error())
    }, Effect.delay("1 second"))
    
    Effect.runFork(logExample(100).pipe(Effect.catchAllCause(Effect.logError)))
  • #3835 c36f3b9 Thanks @KhraksMamtsov! - Config.redacted has been made more flexible and can now wrap any other config. This allows to transform or validate config values before it’s hidden.

    import { Config } from "effect"
    
    Effect.gen(function* () {
      // can be any string including empty
      const pass1 = yield* Config.redacted("PASSWORD")
      //    ^? Redacted<string>
    
      // can't be empty string
      const pass2 = yield* Config.redacted(Config.nonEmptyString("PASSWORD"))
      //    ^? Redacted<string>
    
      const pass2 = yield* Config.redacted(Config.number("SECRET_NUMBER"))
      //    ^? Redacted<number>
    })
  • #3835 aadb8a4 Thanks @fubhy! - Added BigDecimal.unsafeFromNumber and BigDecimal.safeFromNumber.

    Deprecated BigDecimal.fromNumber in favour of BigDecimal.unsafeFromNumber.

    The current implementation of BigDecimal.fromNumber and BigDecimal.unsafeFromNumber now throws
    a RangeError for numbers that are not finite such as NaN, +Infinity or -Infinity.

Patch Changes