Packages

effect

4.1.4 · 11 Nov 2026MIT67.1M / weekRepositoryHomepagenpmAtom feed

Your version

3.11.5

10 Dec 2024Where it was published

3.22.5 is the newest release of 3.x.

In short

4 new9 fixed

Security

2 advisories affect 3.11.5; 3.22.1 fixes them

Release note

Patch Changes

  • 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]*$"
        }
      }
    }
    */
  • 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#"
    }
    */
  • 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"
        }
      ]
    }
    */
  • Remove FnEffect type to improve return type of Effect.fn

  • 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#"
    }
    */
  • Avoid using non-namespaced "async" internally

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

A whole project to check? Paste its package.json in the dependency check: every deprecated, outdated or vulnerable dependency, with what to upgrade to. Free, no account.