| /** | |
| * Built-in error schemas for common HTTP API failure responses. | |
| * | |
| * This module provides reusable `Schema.ErrorClass` values for common HTTP | |
| * status codes, plus `HttpApiSchemaError` for request decoding failures raised | |
| * by the HTTP API runtime. The status errors can be used in endpoint or | |
| * middleware error declarations and are understood by builders, generated | |
| * clients, reflection, and OpenAPI generation. | |
| * | |
| * @since 4.0.0 | |
| */ | |
| import * as Data from "../../Data.js"; | |
| import * as Effect from "../../Effect.js"; | |
| import * as ErrorReporter from "../../ErrorReporter.js"; | |
| import { hasProperty } from "../../Predicate.js"; | |
| import * as Schema from "../../Schema.js"; | |
| import * as HttpServerRespondable from "../http/HttpServerRespondable.js"; | |
| import * as HttpServerResponse from "../http/HttpServerResponse.js"; | |
| import * as HttpApiSchema from "./HttpApiSchema.js"; | |
| const badRequestResponse = /*#__PURE__*/HttpServerResponse.empty({ | |
| status: 400 | |
| }); | |
| const unauthorizedResponse = /*#__PURE__*/HttpServerResponse.empty({ | |
| status: 401 | |
| }); | |
| const forbiddenResponse = /*#__PURE__*/HttpServerResponse.empty({ | |
| status: 403 | |
| }); | |
| const notFoundResponse = /*#__PURE__*/HttpServerResponse.empty({ | |
| status: 404 | |
| }); | |
| const methodNotAllowedResponse = /*#__PURE__*/HttpServerResponse.empty({ | |
| status: 405 | |
| }); | |
| const notAcceptableResponse = /*#__PURE__*/HttpServerResponse.empty({ | |
| status: 406 | |
| }); | |
| const requestTimeoutResponse = /*#__PURE__*/HttpServerResponse.empty({ | |
| status: 408 | |
| }); | |
| const conflictResponse = /*#__PURE__*/HttpServerResponse.empty({ | |
| status: 409 | |
| }); | |
| const goneResponse = /*#__PURE__*/HttpServerResponse.empty({ | |
| status: 410 | |
| }); | |
| const internalServerErrorResponse = /*#__PURE__*/HttpServerResponse.empty({ | |
| status: 500 | |
| }); | |
| const notImplementedResponse = /*#__PURE__*/HttpServerResponse.empty({ | |
| status: 501 | |
| }); | |
| const serviceUnavailableResponse = /*#__PURE__*/HttpServerResponse.empty({ | |
| status: 503 | |
| }); | |
| /** | |
| * Built-in HTTP API error for a `400 Bad Request` response. When used directly as | |
| * a server response, it renders as an empty response with status 400. | |
| * | |
| * @category errors | |
| * @since 4.0.0 | |
| */ | |
| export class BadRequest extends /*#__PURE__*/Schema.ErrorClass("effect/HttpApiError/BadRequest")({ | |
| _tag: /*#__PURE__*/Schema.tag("BadRequest") | |
| }, { | |
| description: "BadRequest", | |
| httpApiStatus: 400 | |
| }) { | |
| [ErrorReporter.ignore] = true; | |
| [HttpServerRespondable.symbol]() { | |
| return Effect.succeed(badRequestResponse); | |
| } | |
| static singleton = /*#__PURE__*/new BadRequest(); | |
| } | |
| /** | |
| * No-content schema variant for `BadRequest`, decoding an empty 400 response into | |
| * a `BadRequest` error value. | |
| * | |
| * @category NoContent errors | |
| * @since 4.0.0 | |
| */ | |
| export const BadRequestNoContent = /*#__PURE__*/BadRequest.pipe(/*#__PURE__*/HttpApiSchema.asNoContent({ | |
| decode: () => new BadRequest({}) | |
| })); | |
| /** | |
| * Built-in HTTP API error for a `401 Unauthorized` response. When used directly as | |
| * a server response, it renders as an empty response with status 401. | |
| * | |
| * @category errors | |
| * @since 4.0.0 | |
| */ | |
| export class Unauthorized extends /*#__PURE__*/Schema.ErrorClass("effect/HttpApiError/Unauthorized")({ | |
| _tag: /*#__PURE__*/Schema.tag("Unauthorized") | |
| }, { | |
| description: "Unauthorized", | |
| httpApiStatus: 401 | |
| }) { | |
| [ErrorReporter.ignore] = true; | |
| [HttpServerRespondable.symbol]() { | |
| return Effect.succeed(unauthorizedResponse); | |
| } | |
| } | |
| /** | |
| * No-content schema variant for `Unauthorized`, decoding an empty 401 response | |
| * into an `Unauthorized` error value. | |
| * | |
| * @category NoContent errors | |
| * @since 4.0.0 | |
| */ | |
| export const UnauthorizedNoContent = /*#__PURE__*/Unauthorized.pipe(/*#__PURE__*/HttpApiSchema.asNoContent({ | |
| decode: () => new Unauthorized({}) | |
| })); | |
| /** | |
| * Built-in HTTP API error for a `403 Forbidden` response. When used directly as a | |
| * server response, it renders as an empty response with status 403. | |
| * | |
| * @category errors | |
| * @since 4.0.0 | |
| */ | |
| export class Forbidden extends /*#__PURE__*/Schema.ErrorClass("effect/HttpApiError/Forbidden")({ | |
| _tag: /*#__PURE__*/Schema.tag("Forbidden") | |
| }, { | |
| description: "Forbidden", | |
| httpApiStatus: 403 | |
| }) { | |
| [ErrorReporter.ignore] = true; | |
| [HttpServerRespondable.symbol]() { | |
| return Effect.succeed(forbiddenResponse); | |
| } | |
| } | |
| /** | |
| * No-content schema variant for `Forbidden`, decoding an empty 403 response into a | |
| * `Forbidden` error value. | |
| * | |
| * @category NoContent errors | |
| * @since 4.0.0 | |
| */ | |
| export const ForbiddenNoContent = /*#__PURE__*/Forbidden.pipe(/*#__PURE__*/HttpApiSchema.asNoContent({ | |
| decode: () => new Forbidden({}) | |
| })); | |
| /** | |
| * Built-in HTTP API error for a `404 Not Found` response. When used directly as a | |
| * server response, it renders as an empty response with status 404. | |
| * | |
| * @category errors | |
| * @since 4.0.0 | |
| */ | |
| export class NotFound extends /*#__PURE__*/Schema.ErrorClass("effect/HttpApiError/NotFound")({ | |
| _tag: /*#__PURE__*/Schema.tag("NotFound") | |
| }, { | |
| description: "NotFound", | |
| httpApiStatus: 404 | |
| }) { | |
| [ErrorReporter.ignore] = true; | |
| [HttpServerRespondable.symbol]() { | |
| return Effect.succeed(notFoundResponse); | |
| } | |
| } | |
| /** | |
| * No-content schema variant for `NotFound`, decoding an empty 404 response into a | |
| * `NotFound` error value. | |
| * | |
| * @category NoContent errors | |
| * @since 4.0.0 | |
| */ | |
| export const NotFoundNoContent = /*#__PURE__*/NotFound.pipe(/*#__PURE__*/HttpApiSchema.asNoContent({ | |
| decode: () => new NotFound({}) | |
| })); | |
| /** | |
| * Built-in HTTP API error for a `405 Method Not Allowed` response. When used | |
| * directly as a server response, it renders as an empty response with status 405. | |
| * | |
| * @category errors | |
| * @since 4.0.0 | |
| */ | |
| export class MethodNotAllowed extends /*#__PURE__*/Schema.ErrorClass("effect/HttpApiError/MethodNotAllowed")({ | |
| _tag: /*#__PURE__*/Schema.tag("MethodNotAllowed") | |
| }, { | |
| description: "MethodNotAllowed", | |
| httpApiStatus: 405 | |
| }) { | |
| [ErrorReporter.ignore] = true; | |
| [HttpServerRespondable.symbol]() { | |
| return Effect.succeed(methodNotAllowedResponse); | |
| } | |
| } | |
| /** | |
| * No-content schema variant for `MethodNotAllowed`, decoding an empty 405 response | |
| * into a `MethodNotAllowed` error value. | |
| * | |
| * @category NoContent errors | |
| * @since 4.0.0 | |
| */ | |
| export const MethodNotAllowedNoContent = /*#__PURE__*/MethodNotAllowed.pipe(/*#__PURE__*/HttpApiSchema.asNoContent({ | |
| decode: () => new MethodNotAllowed({}) | |
| })); | |
| /** | |
| * Built-in HTTP API error for a `406 Not Acceptable` response. When used directly | |
| * as a server response, it renders as an empty response with status 406. | |
| * | |
| * @category errors | |
| * @since 4.0.0 | |
| */ | |
| export class NotAcceptable extends /*#__PURE__*/Schema.ErrorClass("effect/HttpApiError/NotAcceptable")({ | |
| _tag: /*#__PURE__*/Schema.tag("NotAcceptable") | |
| }, { | |
| description: "NotAcceptable", | |
| httpApiStatus: 406 | |
| }) { | |
| [ErrorReporter.ignore] = true; | |
| [HttpServerRespondable.symbol]() { | |
| return Effect.succeed(notAcceptableResponse); | |
| } | |
| } | |
| /** | |
| * No-content schema variant for `NotAcceptable`, decoding an empty 406 response | |
| * into a `NotAcceptable` error value. | |
| * | |
| * @category NoContent errors | |
| * @since 4.0.0 | |
| */ | |
| export const NotAcceptableNoContent = /*#__PURE__*/NotAcceptable.pipe(/*#__PURE__*/HttpApiSchema.asNoContent({ | |
| decode: () => new NotAcceptable({}) | |
| })); | |
| /** | |
| * Built-in HTTP API error for a `408 Request Timeout` response. When used directly | |
| * as a server response, it renders as an empty response with status 408. | |
| * | |
| * @category errors | |
| * @since 4.0.0 | |
| */ | |
| export class RequestTimeout extends /*#__PURE__*/Schema.ErrorClass("effect/HttpApiError/RequestTimeout")({ | |
| _tag: /*#__PURE__*/Schema.tag("RequestTimeout") | |
| }, { | |
| description: "RequestTimeout", | |
| httpApiStatus: 408 | |
| }) { | |
| [ErrorReporter.ignore] = true; | |
| [HttpServerRespondable.symbol]() { | |
| return Effect.succeed(requestTimeoutResponse); | |
| } | |
| } | |
| /** | |
| * No-content schema variant for `RequestTimeout`, decoding an empty 408 response | |
| * into a `RequestTimeout` error value. | |
| * | |
| * @category NoContent errors | |
| * @since 4.0.0 | |
| */ | |
| export const RequestTimeoutNoContent = /*#__PURE__*/RequestTimeout.pipe(/*#__PURE__*/HttpApiSchema.asNoContent({ | |
| decode: () => new RequestTimeout({}) | |
| })); | |
| /** | |
| * Built-in HTTP API error for a `409 Conflict` response. When used directly as a | |
| * server response, it renders as an empty response with status 409. | |
| * | |
| * @category errors | |
| * @since 4.0.0 | |
| */ | |
| export class Conflict extends /*#__PURE__*/Schema.ErrorClass("effect/HttpApiError/Conflict")({ | |
| _tag: /*#__PURE__*/Schema.tag("Conflict") | |
| }, { | |
| description: "Conflict", | |
| httpApiStatus: 409 | |
| }) { | |
| [ErrorReporter.ignore] = true; | |
| [HttpServerRespondable.symbol]() { | |
| return Effect.succeed(conflictResponse); | |
| } | |
| } | |
| /** | |
| * No-content schema variant for `Conflict`, decoding an empty 409 response into a | |
| * `Conflict` error value. | |
| * | |
| * @category NoContent errors | |
| * @since 4.0.0 | |
| */ | |
| export const ConflictNoContent = /*#__PURE__*/Conflict.pipe(/*#__PURE__*/HttpApiSchema.asNoContent({ | |
| decode: () => new Conflict({}) | |
| })); | |
| /** | |
| * Built-in HTTP API error for a `410 Gone` response. When used directly as a | |
| * server response, it renders as an empty response with status 410. | |
| * | |
| * @category errors | |
| * @since 4.0.0 | |
| */ | |
| export class Gone extends /*#__PURE__*/Schema.ErrorClass("effect/HttpApiError/Gone")({ | |
| _tag: /*#__PURE__*/Schema.tag("Gone") | |
| }, { | |
| description: "Gone", | |
| httpApiStatus: 410 | |
| }) { | |
| [ErrorReporter.ignore] = true; | |
| [HttpServerRespondable.symbol]() { | |
| return Effect.succeed(goneResponse); | |
| } | |
| } | |
| /** | |
| * No-content schema variant for `Gone`, decoding an empty 410 response into a | |
| * `Gone` error value. | |
| * | |
| * @category NoContent errors | |
| * @since 4.0.0 | |
| */ | |
| export const GoneNoContent = /*#__PURE__*/Gone.pipe(/*#__PURE__*/HttpApiSchema.asNoContent({ | |
| decode: () => new Gone({}) | |
| })); | |
| /** | |
| * Built-in HTTP API error for a `500 Internal Server Error` response. When used | |
| * directly as a server response, it renders as an empty response with status 500. | |
| * | |
| * @category errors | |
| * @since 4.0.0 | |
| */ | |
| export class InternalServerError extends /*#__PURE__*/Schema.ErrorClass("effect/HttpApiError/InternalServerError")({ | |
| _tag: /*#__PURE__*/Schema.tag("InternalServerError") | |
| }, { | |
| description: "InternalServerError", | |
| httpApiStatus: 500 | |
| }) { | |
| [HttpServerRespondable.symbol]() { | |
| return Effect.succeed(internalServerErrorResponse); | |
| } | |
| } | |
| /** | |
| * No-content schema variant for `InternalServerError`, decoding an empty 500 | |
| * response into an `InternalServerError` error value. | |
| * | |
| * @category NoContent errors | |
| * @since 4.0.0 | |
| */ | |
| export const InternalServerErrorNoContent = /*#__PURE__*/InternalServerError.pipe(/*#__PURE__*/HttpApiSchema.asNoContent({ | |
| decode: () => new InternalServerError({}) | |
| })); | |
| /** | |
| * Built-in HTTP API error for a `501 Not Implemented` response. When used directly | |
| * as a server response, it renders as an empty response with status 501. | |
| * | |
| * @category errors | |
| * @since 4.0.0 | |
| */ | |
| export class NotImplemented extends /*#__PURE__*/Schema.ErrorClass("effect/HttpApiError/NotImplemented")({ | |
| _tag: /*#__PURE__*/Schema.tag("NotImplemented") | |
| }, { | |
| description: "NotImplemented", | |
| httpApiStatus: 501 | |
| }) { | |
| [HttpServerRespondable.symbol]() { | |
| return Effect.succeed(notImplementedResponse); | |
| } | |
| } | |
| /** | |
| * No-content schema variant for `NotImplemented`, decoding an empty 501 response | |
| * into a `NotImplemented` error value. | |
| * | |
| * @category NoContent errors | |
| * @since 4.0.0 | |
| */ | |
| export const NotImplementedNoContent = /*#__PURE__*/NotImplemented.pipe(/*#__PURE__*/HttpApiSchema.asNoContent({ | |
| decode: () => new NotImplemented({}) | |
| })); | |
| /** | |
| * Built-in HTTP API error for a `503 Service Unavailable` response. When used | |
| * directly as a server response, it renders as an empty response with status 503. | |
| * | |
| * @category errors | |
| * @since 4.0.0 | |
| */ | |
| export class ServiceUnavailable extends /*#__PURE__*/Schema.ErrorClass("effect/HttpApiError/ServiceUnavailable")({ | |
| _tag: /*#__PURE__*/Schema.tag("ServiceUnavailable") | |
| }, { | |
| description: "ServiceUnavailable", | |
| httpApiStatus: 503 | |
| }) { | |
| [HttpServerRespondable.symbol]() { | |
| return Effect.succeed(serviceUnavailableResponse); | |
| } | |
| } | |
| /** | |
| * No-content schema variant for `ServiceUnavailable`, decoding an empty 503 | |
| * response into a `ServiceUnavailable` error value. | |
| * | |
| * @category NoContent errors | |
| * @since 4.0.0 | |
| */ | |
| export const ServiceUnavailableNoContent = /*#__PURE__*/ServiceUnavailable.pipe(/*#__PURE__*/HttpApiSchema.asNoContent({ | |
| decode: () => new ServiceUnavailable({}) | |
| })); | |
| /** | |
| * Runtime identifier used to mark and detect `HttpApiSchemaError` values. | |
| * | |
| * @category type IDs | |
| * @since 4.0.0 | |
| */ | |
| export const HttpApiSchemaErrorTypeId = "~effect/httpapi/HttpApiError/HttpApiSchemaError"; | |
| /** | |
| * Error raised when an HTTP API request component fails schema decoding. It records | |
| * which component failed and responds as an empty `400 Bad Request` when rendered | |
| * as a server response. | |
| * | |
| * @category errors | |
| * @since 4.0.0 | |
| */ | |
| export class HttpApiSchemaError extends /*#__PURE__*/Data.TaggedClass("HttpApiSchemaError") { | |
| [HttpApiSchemaErrorTypeId] = HttpApiSchemaErrorTypeId; | |
| static is(u) { | |
| return hasProperty(u, HttpApiSchemaErrorTypeId); | |
| } | |
| static wrap(kind, effect) { | |
| return Effect.mapError(effect, error => new HttpApiSchemaError({ | |
| kind, | |
| cause: error | |
| })); | |
| } | |
| name = "HttpApiSchemaError"; | |
| message = this.kind; | |
| [HttpServerRespondable.symbol]() { | |
| return Effect.succeed(badRequestResponse); | |
| } | |
| } | |
| //# sourceMappingURL=HttpApiError.js.map |
Xet Storage Details
- Size:
- 13.3 kB
- Xet hash:
- fb33dac3fbd59b604121cfdbcfcbd5cef34f89aca24ea2fd5c88ea486f6506dc
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.