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

Version Packages #4213

Merged
merged 1 commit into from
Jan 13, 2025
Merged

Version Packages #4213

merged 1 commit into from
Jan 13, 2025

Conversation

github-actions[bot]
Copy link
Contributor

@github-actions github-actions bot commented Jan 5, 2025

This PR was opened by the Changesets release GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated.

Releases

@effect/[email protected]

Patch Changes

@effect/[email protected]

Patch Changes

@effect/[email protected]

Patch Changes

@effect/[email protected]

Patch Changes

@effect/[email protected]

Patch Changes

@effect/[email protected]

Patch Changes

@effect/[email protected]

Patch Changes

[email protected]

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

@effect/[email protected]

Patch Changes

@effect/[email protected]

Patch Changes

@effect/[email protected]

Patch Changes

  • #4226 212e784 Thanks @gcanti! - Ensure the encoding kind of success responses is respected in the OpenAPI spec.

    Before

    When generating an OpenAPI spec for a request with a success schema of type `HttpApiSchema.Text()``, the response content type was incorrectly set to "application/json" instead of "text/plain".

    import {
      HttpApi,
      HttpApiEndpoint,
      HttpApiGroup,
      HttpApiSchema,
      OpenApi
    } from "@effect/platform"
    
    const api = HttpApi.make("api").add(
      HttpApiGroup.make("group").add(
        HttpApiEndpoint.get("get", "/").addSuccess(HttpApiSchema.Text())
      )
    )
    
    const spec = OpenApi.fromApi(api)
    
    console.log(JSON.stringify(spec.paths, null, 2))
    /*
    Output:
    {
      "/": {
        "get": {
          "tags": [
            "group"
          ],
          "operationId": "group.get",
          "parameters": [],
          "security": [],
          "responses": {
            "200": {
              "description": "a string",
              "content": {
                "application/json": {
                  "schema": {
                    "type": "string"
                  }
                }
              }
            },
            "400": {
              "description": "The request did not match the expected schema",
              "content": {
                "application/json": {
                  "schema": {
                    "$ref": "#/components/schemas/HttpApiDecodeError"
                  }
                }
              }
            }
          }
        }
      }
    }
    */

    After

    import {
      HttpApi,
      HttpApiEndpoint,
      HttpApiGroup,
      HttpApiSchema,
      OpenApi
    } from "@effect/platform"
    
    const api = HttpApi.make("api").add(
      HttpApiGroup.make("group").add(
        HttpApiEndpoint.get("get", "/").addSuccess(HttpApiSchema.Text())
      )
    )
    
    const spec = OpenApi.fromApi(api)
    
    console.log(JSON.stringify(spec.paths, null, 2))
    /*
    Output:
    {
      "/": {
        "get": {
          "tags": [
            "group"
          ],
          "operationId": "group.get",
          "parameters": [],
          "security": [],
          "responses": {
            "200": {
              "description": "a string",
              "content": {
    -            "application/json": {
    +            "text/plain": {
                  "schema": {
                    "type": "string"
                  }
                }
              }
            },
            "400": {
              "description": "The request did not match the expected schema",
              "content": {
                "application/json": {
                  "schema": {
                    "$ref": "#/components/schemas/HttpApiDecodeError"
                  }
                }
              }
            }
          }
        }
      }
    }
    */
  • #4234 f852cb0 Thanks @gcanti! - Deduplicate errors in OpenApi.fromApi.

    When multiple identical errors were added to the same endpoint, group, or API, they were all included in the generated OpenAPI specification, leading to redundant entries in the anyOf array for error schemas.

    Identical errors are now deduplicated in the OpenAPI specification. This ensures that each error schema is included only once, simplifying the generated spec and improving readability.

    Before

    import {
      HttpApi,
      HttpApiEndpoint,
      HttpApiGroup,
      OpenApi
    } from "@effect/platform"
    import { Schema } from "effect"
    
    const err = Schema.String.annotations({ identifier: "err" })
    const api = HttpApi.make("api")
      .add(
        HttpApiGroup.make("group1")
          .add(
            HttpApiEndpoint.get("get1", "/1")
              .addSuccess(Schema.String)
              .addError(err)
              .addError(err)
          )
          .addError(err)
          .addError(err)
      )
      .addError(err)
      .addError(err)
    
    const spec = OpenApi.fromApi(api)
    
    console.log(JSON.stringify(spec.paths, null, 2))
    /*
    Output:
    {
      "/1": {
        "get": {
          "tags": [
            "group1"
          ],
          "operationId": "group1.get1",
          "parameters": [],
          "security": [],
          "responses": {
            "200": {
              "description": "a string",
              "content": {
                "application/json": {
                  "schema": {
                    "type": "string"
                  }
                }
              }
            },
            "400": {
              "description": "The request did not match the expected schema",
              "content": {
                "application/json": {
                  "schema": {
                    "$ref": "#/components/schemas/HttpApiDecodeError"
                  }
                }
              }
            },
            "500": {
              "description": "a string",
              "content": {
                "application/json": {
                  "schema": "schema": {
                    "anyOf": [
                      {
                        "$ref": "#/components/schemas/err"
                      },
                      {
                        "$ref": "#/components/schemas/err"
                      },
                      {
                        "$ref": "#/components/schemas/err"
                      }
                    ]
                  }
                }
              }
            }
          }
        }
      }
    }
    */

    After

    import {
      HttpApi,
      HttpApiEndpoint,
      HttpApiGroup,
      OpenApi
    } from "@effect/platform"
    import { Schema } from "effect"
    
    const err = Schema.String.annotations({ identifier: "err" })
    const api = HttpApi.make("api")
      .add(
        HttpApiGroup.make("group1")
          .add(
            HttpApiEndpoint.get("get1", "/1")
              .addSuccess(Schema.String)
              .addError(err)
              .addError(err)
          )
          .addError(err)
          .addError(err)
      )
      .addError(err)
      .addError(err)
    
    const spec = OpenApi.fromApi(api)
    
    console.log(JSON.stringify(spec.paths, null, 2))
    /*
    Output:
    {
      "/1": {
        "get": {
          "tags": [
            "group1"
          ],
          "operationId": "group1.get1",
          "parameters": [],
          "security": [],
          "responses": {
            "200": {
              "description": "a string",
              "content": {
                "application/json": {
                  "schema": {
                    "type": "string"
                  }
                }
              }
            },
            "400": {
              "description": "The request did not match the expected schema",
              "content": {
                "application/json": {
                  "schema": {
                    "$ref": "#/components/schemas/HttpApiDecodeError"
                  }
                }
              }
            },
            "500": {
              "description": "a string",
              "content": {
                "application/json": {
                  "schema": {
                    "$ref": "#/components/schemas/err"
                  }
                }
              }
            }
          }
        }
      }
    }
    */
  • #4233 7276ae2 Thanks @gcanti! - Ensure the encoding kind of error responses is respected in the OpenAPI spec.

    Before

    When generating an OpenAPI spec for a request with an error schema of type `HttpApiSchema.Text()``, the response content type was incorrectly set to "application/json" instead of "text/plain".

    import {
      HttpApi,
      HttpApiEndpoint,
      HttpApiGroup,
      HttpApiSchema,
      OpenApi
    } from "@effect/platform"
    
    const api = HttpApi.make("api").add(
      HttpApiGroup.make("group").add(
        HttpApiEndpoint.get("get", "/").addError(HttpApiSchema.Text())
      )
    )
    
    const spec = OpenApi.fromApi(api)
    
    console.log(JSON.stringify(spec.paths, null, 2))
    /*
    Output:
    {
      "/": {
        "get": {
          "tags": [
            "group"
          ],
          "operationId": "group.get",
          "parameters": [],
          "security": [],
          "responses": {
            "204": {
              "description": "Success"
            },
            "400": {
              "description": "The request did not match the expected schema",
              "content": {
                "application/json": {
                  "schema": {
                    "$ref": "#/components/schemas/HttpApiDecodeError"
                  }
                }
              }
            },
            "500": {
              "description": "a string",
              "content": {
                "application/json": {
                  "schema": {
                    "type": "string"
                  }
                }
              }
            }
          }
        }
      }
    }
    */

    After

    import { HttpApi, HttpApiEndpoint, HttpApiGroup, HttpApiSchema, OpenApi } from "@effect/platform"
    
    const api = HttpApi.make("api").add(
      HttpApiGroup.make("group").add(
        HttpApiEndpoint.get("get", "/").addError(HttpApiSchema.Text())
      )
    )
    
    const spec = OpenApi.fromApi(api)
    
    console.log(JSON.stringify(spec.paths, null, 2))
    /*
    Output:
    {
      "/": {
        "get": {
          "tags": [
            "group"
          ],
          "operationId": "group.get",
          "parameters": [],
          "security": [],
          "responses": {
            "204": {
              "description": "Success"
            },
            "400": {
              "description": "The request did not match the expected schema",
              "content": {
                "application/json": {
                  "schema": {
                    "$ref": "#/components/schemas/HttpApiDecodeError"
                  }
                }
              }
            },
            "500": {
              "description": "a string",
              "content": {
    +            "text/plain": {
    -            "application/json": {
                  "schema": {
                    "type": "string"
                  }
                }
              }
            }
          }
        }
      }
    }
    */
  • #4226 212e784 Thanks @gcanti! - Add missing deprecated key to OpenApi.annotations API.

  • #4226 212e784 Thanks @gcanti! - Fix: Prevent request body from being added to the OpenAPI spec for GET methods in OpenApi.fromApi.

    When creating a GET endpoint with a request payload, the requestBody was incorrectly added to the OpenAPI specification, which is invalid for GET methods.

    Before

    import {
      HttpApi,
      HttpApiEndpoint,
      HttpApiGroup,
      OpenApi
    } from "@effect/platform"
    import { Schema } from "effect"
    
    const api = HttpApi.make("api").add(
      HttpApiGroup.make("group").add(
        HttpApiEndpoint.get("get", "/")
          .addSuccess(Schema.String)
          .setPayload(
            Schema.Struct({
              a: Schema.String
            })
          )
      )
    )
    
    const spec = OpenApi.fromApi(api)
    
    console.log(JSON.stringify(spec.paths, null, 2))
    /*
    Output:
    {
      "/": {
        "get": {
          "tags": [
            "group"
          ],
          "operationId": "group.get",
          "parameters": [
            {
              "name": "a",
              "in": "query",
              "schema": {
                "type": "string"
              },
              "required": true
            }
          ],
          "security": [],
          "responses": {
            "200": {
              "description": "a string",
              "content": {
                "application/json": {
                  "schema": {
                    "type": "string"
                  }
                }
              }
            },
            "400": {
              "description": "The request did not match the expected schema",
              "content": {
                "application/json": {
                  "schema": {
                    "$ref": "#/components/schemas/HttpApiDecodeError"
                  }
                }
              }
            }
          },
          "requestBody": {
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "a"
                  ],
                  "properties": {
                    "a": {
                      "type": "string"
                    }
                  },
                  "additionalProperties": false
                }
              }
            },
            "required": true
          }
        }
      }
    }
    */

    After

    import {
      HttpApi,
      HttpApiEndpoint,
      HttpApiGroup,
      OpenApi
    } from "@effect/platform"
    import { Schema } from "effect"
    
    const api = HttpApi.make("api").add(
      HttpApiGroup.make("group").add(
        HttpApiEndpoint.get("get", "/")
          .addSuccess(Schema.String)
          .setPayload(
            Schema.Struct({
              a: Schema.String
            })
          )
      )
    )
    
    const spec = OpenApi.fromApi(api)
    
    console.log(JSON.stringify(spec.paths, null, 2))
    /*
    Output:
    {
      "/": {
        "get": {
          "tags": [
            "group"
          ],
          "operationId": "group.get",
          "parameters": [
            {
              "name": "a",
              "in": "query",
              "schema": {
                "type": "string"
              },
              "required": true
            }
          ],
          "security": [],
          "responses": {
            "200": {
              "description": "a string",
              "content": {
                "application/json": {
                  "schema": {
                    "type": "string"
                  }
                }
              }
            },
            "400": {
              "description": "The request did not match the expected schema",
              "content": {
                "application/json": {
                  "schema": {
                    "$ref": "#/components/schemas/HttpApiDecodeError"
                  }
                }
              }
            }
          }
        }
      }
    }
    */
  • #4226 212e784 Thanks @gcanti! - Add "application/x-www-form-urlencoded" to OpenApiSpecContentType type as it is generated by the system when using HttpApiSchema.withEncoding({ kind: "UrlParams" })

    Example

    import {
      HttpApi,
      HttpApiEndpoint,
      HttpApiGroup,
      HttpApiSchema,
      OpenApi
    } from "@effect/platform"
    import { Schema } from "effect"
    
    const api = HttpApi.make("api").add(
      HttpApiGroup.make("group").add(
        HttpApiEndpoint.post("post", "/")
          .addSuccess(Schema.String)
          .setPayload(
            Schema.Struct({ foo: Schema.String }).pipe(
              HttpApiSchema.withEncoding({ kind: "UrlParams" })
            )
          )
      )
    )
    
    const spec = OpenApi.fromApi(api)
    
    console.log(JSON.stringify(spec.paths, null, 2))
    /*
    Output:
    {
      "/": {
        "post": {
          "tags": [
            "group"
          ],
          "operationId": "group.post",
          "parameters": [],
          "security": [],
          "responses": {
            "200": {
              "description": "a string",
              "content": {
                "application/json": {
                  "schema": {
                    "type": "string"
                  }
                }
              }
            },
            "400": {
              "description": "The request did not match the expected schema",
              "content": {
                "application/json": {
                  "schema": {
                    "$ref": "#/components/schemas/HttpApiDecodeError"
                  }
                }
              }
            }
          },
          "requestBody": {
            "content": {
              "application/x-www-form-urlencoded": {
                "schema": {
                  "type": "object",
                  "required": [
                    "foo"
                  ],
                  "properties": {
                    "foo": {
                      "type": "string"
                    }
                  },
                  "additionalProperties": false
                }
              }
            },
            "required": true
          }
        }
      }
    }
    */
  • Updated dependencies [734af82, b63c780, c640d77, 0def088]:

@effect/[email protected]

Patch Changes

@effect/[email protected]

Patch Changes

@effect/[email protected]

Patch Changes

@effect/[email protected]

Patch Changes

@effect/[email protected]

Patch Changes

@effect/[email protected]

Patch Changes

@effect/[email protected]

Patch Changes

@effect/[email protected]

Patch Changes

@effect/[email protected]

Patch Changes

@effect/[email protected]

Patch Changes

@effect/[email protected]

Patch Changes

@effect/[email protected]

Patch Changes

@effect/[email protected]

Patch Changes

@effect/[email protected]

Patch Changes

@effect/[email protected]

Patch Changes

@effect/[email protected]

Patch Changes

@effect/[email protected]

Patch Changes

@effect/[email protected]

Patch Changes

@effect/[email protected]

Patch Changes

@effect/[email protected]

Patch Changes

@effect/[email protected]

Patch Changes

@effect/[email protected]

Patch Changes

@effect/[email protected]

Patch Changes

@effect/[email protected]

Patch Changes

@github-actions github-actions bot force-pushed the changeset-release/main branch 8 times, most recently from 7dfd882 to f25cb21 Compare January 11, 2025 20:20
@github-actions github-actions bot force-pushed the changeset-release/main branch 3 times, most recently from dd6d1d6 to 3178f5c Compare January 12, 2025 19:07
@github-actions github-actions bot force-pushed the changeset-release/main branch from 3178f5c to 307219e Compare January 13, 2025 00:36
@gcanti gcanti merged commit 766e852 into main Jan 13, 2025
@gcanti gcanti deleted the changeset-release/main branch January 13, 2025 08:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

1 participant