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.12.7 age adoption passing confidence

Release Notes

Effect-TS/effect (effect)

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"
        }
      ]
    }
    */

    After

    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#",
      "type": "string"
    }
    */
  • #​4138 cec0b4d Thanks @​gcanti! - JSONSchema: handle the nullable keyword for OpenAPI target, closes #​4075.

    Before

    import { OpenApiJsonSchema } from "@&#8203;effect/platform"
    import { Schema } from "effect"
    
    const schema = Schema.NullOr(Schema.String)
    
    console.log(JSON.stringify(OpenApiJsonSchema.make(schema), null, 2))
    /*
    {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "enum": [
            null
          ]
        }
      ]
    }
    */

    After

    import { OpenApiJsonSchema } from "@&#8203;effect/platform"
    import { Schema } from "effect"
    
    const schema = Schema.NullOr(Schema.String)
    
    console.log(JSON.stringify(OpenApiJsonSchema.make(schema), null, 2))
    /*
    {
      "type": "string",
      "nullable": true
    }
    */
  • #​4128 8d978c5 Thanks @​gcanti! - JSONSchema: add type for homogeneous enum schemas, closes #​4127

    Before

    import { JSONSchema, Schema } from "effect"
    
    const schema = Schema.Literal("a", "b")
    
    console.log(JSON.stringify(JSONSchema.make(schema), null, 2))
    /*
    {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "enum": [
        "a",
        "b"
      ]
    }
    */

    After

    import { JSONSchema, Schema } from "effect"
    
    const schema = Schema.Literal("a", "b")
    
    console.log(JSON.stringify(JSONSchema.make(schema), null, 2))
    /*
    {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "type": "string",
      "enum": [
        "a",
        "b"
      ]
    }
    */
  • #​4138 cec0b4d Thanks @​gcanti! - JSONSchema: use { "type": "null" } to represent the null literal

    Before

    import { JSONSchema, Schema } from "effect"
    
    const schema = Schema.NullOr(Schema.String)
    
    console.log(JSON.stringify(JSONSchema.make(schema), null, 2))
    /*
    {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "anyOf": [
        {
          "type": "string"
        },
        {
          "enum": [
            null
          ]
        }
      ]
    }
    */

    After

    import { JSONSchema, Schema } from "effect"
    
    const schema = Schema.NullOr(Schema.String)
    
    console.log(JSON.stringify(JSONSchema.make(schema), null, 2))
    /*
    {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    }
    */
  • #​4138 cec0b4d Thanks @​gcanti! - JSONSchema: handle empty native enums.

    Before

    import { JSONSchema, Schema } from "effect"
    
    enum Empty {}
    
    const schema = Schema.Enums(Empty)
    
    console.log(JSON.stringify(JSONSchema.make(schema), null, 2))
    /*
    {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "$comment": "/schemas/enums",
      "anyOf": [] // <= invalid schema!
    }
    */

    After

    import { JSONSchema, Schema } from "effect"
    
    enum Empty {}
    
    const schema = Schema.Enums(Empty)
    
    console.log(JSON.stringify(JSONSchema.make(schema), null, 2))
    /*
    {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "$id": "/schemas/never",
      "not": {}
    }
    */

v3.11.6

Compare Source

Patch Changes
  • #​4118 662d1ce Thanks @​gcanti! - Allow the transformation created by the Class API to be annotated on all its components: the type side, the transformation itself, and the encoded side.

    Example

    import { Schema, SchemaAST } from "effect"
    
    class A extends Schema.Class<A>("A")(
      {
        a: Schema.NonEmptyString
      },
      [
        { identifier: "TypeID" }, // annotations for the type side
        { identifier: "TransformationID" }, // annotations for the the transformation itself
        { identifier: "EncodedID" } // annotations for the the encoded side
      ]
    ) {}
    
    console.log(SchemaAST.getIdentifierAnnotation(A.ast.to)) // Some("TypeID")
    console.log(SchemaAST.getIdentifierAnnotation(A.ast)) // Some("TransformationID")
    console.log(SchemaAST.getIdentifierAnnotation(A.ast.from)) // Some("EncodedID")
    
    A.make({ a: "" })
    /*
    ParseError: TypeID
    └─ ["a"]
       └─ NonEmptyString
          └─ Predicate refinement failure
             └─ Expected NonEmptyString, actual ""
    */
    
    Schema.encodeSync(A)({ a: "" })
    /*
    ParseError: TransformationID
    └─ Type side transformation failure
       └─ TypeID
          └─ ["a"]
             └─ NonEmptyString
                └─ Predicate refinement failure
                   └─ Expected NonEmptyString, actual ""
    */
  • #​4126 31c62d8 Thanks @​gcanti! - Rewrite the Arbitrary compiler from scratch, closes #​2312

v3.11.5

Compare Source

Patch Changes
  • #​4019 9f5a6f7 Thanks @​gcanti! - Add missing jsonSchema annotations to the following filters:

    • lowercased
    • capitalized
    • uncapitalized
    • uppercased

    Before

    import { JSONSchema, Schema } from "effect"
    
    const schema = Schema.Struct({
      a: Schema.Uppercased
    })
    
    console.log(JSON.stringify(JSONSchema.make(schema), null, 2))
    /*
    throws:
    Error: Missing annotation
    details: Generating a JSON Schema for this schema requires a "jsonSchema" annotation
    schema (Refinement): Uppercased
    */

    After

    import { JSONSchema, Schema } from "effect"
    
    const schema = Schema.Uppercased
    
    console.log(JSON.stringify(JSONSchema.make(schema), null, 2))
    /*
    Output:
    {
      "$ref": "#/$defs/Uppercased",
      "$schema": "http://json-schema.org/draft-07/schema#",
      "$defs": {
        "Uppercased": {
          "type": "string",
          "description": "an uppercase string",
          "title": "Uppercased",
          "pattern": "^[^a-z]*$"
        }
      }
    }
    */
  • #​4111 22905cf Thanks @​gcanti! - JSONSchema: merge refinement fragments instead of just overwriting them.

    Before

    import { JSONSchema, Schema } from "effect"
    
    export const schema = Schema.String.pipe(
      Schema.startsWith("a"), // <= overwritten!
      Schema.endsWith("c")
    )
    
    console.log(JSON.stringify(JSONSchema.make(schema), null, 2))
    /*
    {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "type": "string",
      "description": "a string ending with \"c\"",
      "pattern": "^.*c$" // <= overwritten!
    }
    */

    After

    import { JSONSchema, Schema } from "effect"
    
    export const schema = Schema.String.pipe(
      Schema.startsWith("a"), // <= preserved!
      Schema.endsWith("c")
    )
    
    console.log(JSON.stringify(JSONSchema.make(schema), null, 2))
    /*
    {
      "type": "string",
      "description": "a string ending with \"c\"",
      "pattern": "^.*c$",
      "allOf": [
        {
          "pattern": "^a" // <= preserved!
        }
      ],
      "$schema": "http://json-schema.org/draft-07/schema#"
    }
    */
  • #​4019 9f5a6f7 Thanks @​gcanti! - JSONSchema: Correct the output order when generating a JSON Schema from a Union that includes literals and primitive schemas.

    Before

    import { JSONSchema, Schema } from "effect"
    
    const schema = Schema.Union(Schema.Literal(1, 2), Schema.String)
    
    console.log(JSON.stringify(JSONSchema.make(schema), null, 2))
    /*
    {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "anyOf": [
        {
          "type": "string"
        },
        {
          "enum": [
            1,
            2
          ]
        }
      ]
    }
    */

    After

    import { JSONSchema, Schema } from "effect"
    
    const schema = Schema.Union(Schema.Literal(1, 2), Schema.String)
    
    console.log(JSON.stringify(JSONSchema.make(schema), null, 2))
    /*
    {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "anyOf": [
        {
          "enum": [
            1,
            2
          ]
        },
        {
          "type": "string"
        }
      ]
    }
    */
  • #​4107 1e59e4f Thanks @​tim-smart! - remove FnEffect type to improve return type of Effect.fn

  • #​4108 8d914e5 Thanks @​gcanti! - JSONSchema: represent never as {"not":{}}

    Before

    import { JSONSchema, Schema } from "effect"
    
    const schema = Schema.Never
    
    console.log(JSON.stringify(JSONSchema.make(schema), null, 2))
    /*
    throws:
    Error: Missing annotation
    details: Generating a JSON Schema for this schema requires a "jsonSchema" annotation
    schema (NeverKeyword): never
    */

    After

    import { JSONSchema, Schema } from "effect"
    
    const schema = Schema.Never
    
    console.log(JSON.stringify(JSONSchema.make(schema), null, 2))
    /*
    {
      "$id": "/schemas/never",
      "not": {},
      "title": "never",
      "$schema": "http://json-schema.org/draft-07/schema#"
    }
    */
  • #​4115 03bb00f Thanks @​tim-smart! - avoid using non-namespaced "async" internally

  • #​4019 9f5a6f7 Thanks @​gcanti! - JSONSchema: fix special case in parseJson handling to target the "to" side of the transformation only at the top level.

    Before

    import { JSONSchema, Schema } from "effect"
    
    const schema = Schema.parseJson(
      Schema.Struct({
        a: Schema.parseJson(
          Schema.Struct({
            b: Schema.String
          })
        )
      })
    )
    
    console.log(JSON.stringify(JSONSchema.make(schema), null, 2))
    /*
    {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "type": "object",
      "required": [
        "a"
      ],
      "properties": {
        "a": {
          "type": "object",
          "required": [
            "b"
          ],
          "properties": {
            "b": {
              "type": "string"
            }
          },
          "additionalProperties": false
        }
      },
      "additionalProperties": false
    }
    */

    After

    import { JSONSchema, Schema } from "effect"
    
    const schema = Schema.parseJson(
      Schema.Struct({
        a: Schema.parseJson(
          Schema.Struct({
            b: Schema.String
          })
        )
      })
    )
    
    console.log(JSON.stringify(JSONSchema.make(schema), null, 2))
    /*
    {
      "type": "object",
      "required": [
        "a"
      ],
      "properties": {
        "a": {
          "type": "string",
          "contentMediaType": "application/json"
        }
      },
      "additionalProperties": false,
      "$schema": "http://json-schema.org/draft-07/schema#"
    }
    */
  • #​4101 14e1149 Thanks @​gcanti! - Schema: align the make constructor of structs with the behavior of the Class API constructors when all fields have a default.

    Before

    import { Schema } from "effect"
    
    const schema = Schema.Struct({
      a: Schema.propertySignature(Schema.Number).pipe(
        Schema.withConstructorDefault(() => 0)
      )
    })
    
    // TypeScript error: Expected 1-2 arguments, but got 0.ts(2554)
    console.log(schema.make())

    After

    import { Schema } from "effect"
    
    const schema = Schema.Struct({
      a: Schema.propertySignature(Schema.Number).pipe(
        Schema.withConstructorDefault(() => 0)
      )
    })
    
    console.log(schema.make())
    // Output: { a: 0 }
  • #​4019 9f5a6f7 Thanks @​gcanti! - JSONSchema: Fix issue where identifier is ignored when a refinement is applied to a schema, closes #​4012

    Before

    import { JSONSchema, Schema } from "effect"
    
    const schema = Schema.NonEmptyString
    
    console.log(JSON.stringify(JSONSchema.make(schema), null, 2))
    /*
    {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "type": "string",
      "description": "a non empty string",
      "title": "NonEmptyString",
      "minLength": 1
    }
    */

    After

    import { JSONSchema, Schema } from "effect"
    
    const schema = Schema.NonEmptyString
    
    console.log(JSON.stringify(JSONSchema.make(schema), null, 2))
    /*
    {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "$ref": "#/$defs/NonEmptyString",
      "$defs": {
        "NonEmptyString": {
          "type": "string",
          "description": "a non empty string",
          "title": "NonEmptyString",
          "minLength": 1
        }
      }
    }
    */
  • #​4019 9f5a6f7 Thanks @​gcanti! - JSONSchema: Use identifier with Class APIs to create a $ref instead of inlining the schema.

    Before

    import { JSONSchema, Schema } from "effect"
    
    class A extends Schema.Class<A>("A")({
      a: Schema.String
    }) {}
    
    console.log(JSON.stringify(JSONSchema.make(A), null, 2))
    /*
    {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "type": "object",
      "required": [
        "a"
      ],
      "properties": {
        "a": {
          "type": "string"
        }
      },
      "additionalProperties": false
    }
    */

    After

    import { JSONSchema, Schema } from "effect"
    
    class A extends Schema.Class<A>("A")({
      a: Schema.String
    }) {}
    
    console.log(JSON.stringify(JSONSchema.make(A), null, 2))
    /*
    {
      "$ref": "#/$defs/A",
      "$schema": "http://json-schema.org/draft-07/schema#",
      "$defs": {
        "A": {
          "type": "object",
          "required": [
            "a"
          ],
          "properties": {
            "a": {
              "type": "string"
            }
          },
          "additionalProperties": false
        }
      }
    }
    */

v3.11.4

Compare Source

Patch Changes

v3.11.3

Compare Source

Patch Changes
  • #​4080 90906f7 Thanks @​gcanti! - Fix the Schema.TemplateLiteral output type when the arguments include a branded type.

    Before

    import { Schema } from "effect"
    
    const schema = Schema.TemplateLiteral(
      "a ",
      Schema.String.pipe(Schema.brand("MyBrand"))
    )
    
    // type Type = `a ${Schema.brand<typeof Schema.String, "MyBrand"> & string}`
    // | `a ${Schema.brand<typeof Schema.String, "MyBrand"> & number}`
    // | `a ${Schema.brand<typeof Schema.String, "MyBrand"> & bigint}`
    // | `a ${Schema.brand<...> & false}`
    // | `a ${Schema.brand<...> & true}`
    type Type = typeof schema.Type

    After

    import { Schema } from "effect"
    
    const schema = Schema.TemplateLiteral(
      "a ",
      Schema.String.pipe(Schema.brand("MyBrand"))
    )
    
    // type Type = `a ${string & Brand<"MyBrand">}`
    type Type = typeof schema.Type
  • #​4076 3862cd3 Thanks @​gcanti! - Schema: fix bug in Schema.TemplateLiteralParser resulting in a runtime error.

    Before

    import { Schema } from "effect"
    
    const schema = Schema.TemplateLiteralParser("a", "b")
    // throws TypeError: Cannot read properties of undefined (reading 'replace')

    After

    import { Schema } from "effect"
    
    const schema = Schema.TemplateLiteralParser("a", "b")
    
    console.log(Schema.decodeUnknownSync(schema)("ab"))
    // Output: [ 'a', 'b' ]
  • #​4076 3862cd3 Thanks @​gcanti! - SchemaAST: fix TemplateLiteral model.

    Added Literal and Union as valid types.

  • #​4083 [343b6aa](https://redirect.github.com/Effect-TS/effec


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/schema@0.60.4
npm error Found: effect@3.1.3
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/schema@0.60.4
npm error node_modules/@effect/schema
npm error   @effect/schema@"0.60.4" from the root project
npm error
npm error Conflicting peer dependency: effect@2.4.19
npm error node_modules/effect
npm error   peer effect@"^2.1.1" from @effect/schema@0.60.4
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 4 times, most recently from 508616b to c65c204 Compare January 1, 2025 04:57
@renovate renovate bot force-pushed the renovate/effect-3.x branch 7 times, most recently from f189423 to 82acf90 Compare January 9, 2025 10:32
@renovate renovate bot force-pushed the renovate/effect-3.x branch 7 times, most recently from 2700a02 to 482e5f8 Compare January 16, 2025 04:47
@renovate renovate bot force-pushed the renovate/effect-3.x branch 8 times, most recently from 88542fa to 4376221 Compare January 24, 2025 02:10
@renovate renovate bot force-pushed the renovate/effect-3.x branch 2 times, most recently from cf1439f to 7bbf27f Compare January 27, 2025 04:38
@renovate renovate bot force-pushed the renovate/effect-3.x branch from 7bbf27f to b07d2d5 Compare January 28, 2025 08:50
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