import * as Effect from "../../Effect.ts";
import * as FileSystem from "../../FileSystem.ts";
import * as Inspectable from "../../Inspectable.ts";
import type * as PlatformError from "../../PlatformError.ts";
import * as Schema from "../../Schema.ts";
import type { ParseOptions } from "../../SchemaAST.ts";
import type { Issue } from "../../SchemaIssue.ts";
import type * as Stream_ from "../../Stream.ts";
import * as UrlParams from "./UrlParams.ts";
declare const TypeId = "~effect/http/HttpBody";
/**
 * Returns `true` if the provided value is an `HttpBody`.
 *
 * @category refinements
 * @since 4.0.0
 */
export declare const isHttpBody: (u: unknown) => u is HttpBody;
/**
 * Represents an HTTP request body.
 *
 * **Details**
 *
 * Supported variants include empty bodies, raw bodies, byte arrays, `FormData`, and streams of bytes.
 *
 * @category models
 * @since 4.0.0
 */
export type HttpBody = Empty | Raw | Uint8Array | FormData | Stream;
/**
 * Namespace containing type-level members associated with `HttpBody`.
 *
 * @since 4.0.0
 */
export declare namespace HttpBody {
    /**
     * Common protocol implemented by all HTTP body variants.
     *
     * **Details**
     *
     * It carries the variant tag plus optional `contentType` and `contentLength` metadata.
     *
     * @category models
     * @since 4.0.0
     */
    interface Proto extends Inspectable.Inspectable {
        readonly [TypeId]: typeof TypeId;
        readonly _tag: string;
        readonly contentType?: string | undefined;
        readonly contentLength?: number | undefined;
    }
    /**
     * Minimal Web `File`-like shape used by HTTP helpers that need file metadata.
     *
     * @category models
     * @since 4.0.0
     */
    interface FileLike {
        readonly name: string;
        readonly lastModified: number;
        readonly size: number;
        readonly stream: () => unknown;
        readonly type: string;
    }
}
declare const HttpBodyErrorTypeId = "~effect/http/HttpBody/HttpBodyError";
declare const HttpBodyError_base: new <A extends Record<string, any> = {}>(args: import("../../Types.ts").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("../../Cause.ts").YieldableError & {
    readonly _tag: "HttpBodyError";
} & Readonly<A>;
/**
 * Error produced while constructing an HTTP body from JSON or schema-encoded input.
 *
 * @category errors
 * @since 4.0.0
 */
export declare class HttpBodyError extends HttpBodyError_base<{
    readonly reason: ErrorReason;
    readonly cause?: unknown;
}> {
    /**
     * Marks this value as an HTTP body error for runtime guards.
     *
     * @since 4.0.0
     */
    readonly [HttpBodyErrorTypeId] = "~effect/http/HttpBody/HttpBodyError";
}
/**
 * Reason for an `HttpBodyError`.
 *
 * **Details**
 *
 * `JsonError` represents a `JSON.stringify` failure; `SchemaError` represents a schema encoding issue.
 *
 * @category errors
 * @since 4.0.0
 */
export type ErrorReason = {
    readonly _tag: "JsonError";
} | {
    readonly _tag: "SchemaError";
    readonly issue: Issue;
};
declare abstract class Proto implements HttpBody.Proto {
    readonly [TypeId]: typeof TypeId;
    abstract readonly _tag: string;
    constructor();
    abstract toJSON(): unknown;
    [Inspectable.NodeInspectSymbol](): unknown;
    toString(): string;
}
/**
 * HTTP body variant representing the absence of request content.
 *
 * @category models
 * @since 4.0.0
 */
export declare class Empty extends Proto {
    readonly _tag = "Empty";
    toJSON(): unknown;
}
/**
 * Provides the singleton empty HTTP body.
 *
 * **When to use**
 *
 * Use when you need an HTTP body value that represents no body content.
 *
 * @category constants
 * @since 4.0.0
 */
export declare const empty: Empty;
/**
 * HTTP body variant containing an arbitrary runtime body value with optional content metadata.
 *
 * @category models
 * @since 4.0.0
 */
export declare class Raw extends Proto {
    readonly _tag = "Raw";
    readonly body: unknown;
    readonly contentType: string | undefined;
    readonly contentLength: number | undefined;
    constructor(body: unknown, contentType: string | undefined, contentLength: number | undefined);
    toJSON(): unknown;
}
/**
 * Creates a raw HTTP body from an arbitrary value and optional `contentType` and `contentLength` metadata.
 *
 * @category constructors
 * @since 4.0.0
 */
export declare const raw: (body: unknown, options?: {
    readonly contentType?: string | undefined;
    readonly contentLength?: number | undefined;
} | undefined) => Raw;
/**
 * HTTP body variant backed by a `Uint8Array`.
 *
 * **Details**
 *
 * It stores the bytes, content type, and byte length.
 *
 * @category models
 * @since 4.0.0
 */
export declare class Uint8Array extends Proto {
    readonly _tag = "Uint8Array";
    readonly body: globalThis.Uint8Array;
    readonly contentType: string;
    readonly contentLength: number;
    constructor(body: globalThis.Uint8Array, contentType: string, contentLength: number);
    toJSON(): unknown;
}
/**
 * Creates a byte-array HTTP body.
 *
 * **Details**
 *
 * The content type defaults to `application/octet-stream`, and the content length is the byte array length.
 *
 * @category constructors
 * @since 4.0.0
 */
export declare const uint8Array: (body: globalThis.Uint8Array, contentType?: string) => Uint8Array;
/**
 * Creates a UTF-8 encoded text HTTP body.
 *
 * **Details**
 *
 * The content type defaults to `text/plain`.
 *
 * @category constructors
 * @since 4.0.0
 */
export declare const text: (body: string, contentType?: string) => Uint8Array;
/**
 * Creates a JSON HTTP body using `JSON.stringify`, throwing if serialization fails.
 *
 * **Details**
 *
 * The content type defaults to `application/json`.
 *
 * @category constructors
 * @since 4.0.0
 */
export declare const jsonUnsafe: (body: unknown, contentType?: string) => Uint8Array;
/**
 * Creates a JSON HTTP body in an `Effect`.
 *
 * **Details**
 *
 * `JSON.stringify` failures are captured as `HttpBodyError` values, and the content type defaults to `application/json`.
 *
 * @category constructors
 * @since 4.0.0
 */
export declare const json: (body: unknown, contentType?: string) => Effect.Effect<Uint8Array, HttpBodyError>;
/**
 * Creates a JSON body constructor that first encodes values with the schema's JSON codec.
 *
 * **Details**
 *
 * Schema encoding issues and JSON serialization failures are returned as `HttpBodyError` values.
 *
 * @category constructors
 * @since 4.0.0
 */
export declare const jsonSchema: <S extends Schema.Top>(schema: S, options?: ParseOptions | undefined) => (body: S["Type"], contentType?: string) => Effect.Effect<Uint8Array, HttpBodyError, S["EncodingServices"]>;
/**
 * Creates an `application/x-www-form-urlencoded` HTTP body from `UrlParams`.
 *
 * @category constructors
 * @since 4.0.0
 */
export declare const urlParams: (urlParams: UrlParams.UrlParams, contentType?: string) => Uint8Array;
/**
 * HTTP body variant backed by Web `FormData`.
 *
 * **Details**
 *
 * The content type and content length are left unset so the runtime can supply multipart boundaries.
 *
 * @category models
 * @since 4.0.0
 */
export declare class FormData extends Proto {
    readonly _tag = "FormData";
    readonly contentType: undefined;
    readonly contentLength: undefined;
    readonly formData: globalThis.FormData;
    constructor(formData: globalThis.FormData);
    toJSON(): unknown;
}
/**
 * Wraps a Web `FormData` value as an HTTP body.
 *
 * @category constructors
 * @since 4.0.0
 */
export declare const formData: (body: globalThis.FormData) => FormData;
/**
 * Record input accepted by `formDataRecord`.
 *
 * **Details**
 *
 * Each field may be a single coercible value or an array of coercible values.
 *
 * @category models
 * @since 4.0.0
 */
export type FormDataInput = Record<string, FormDataCoercible | ReadonlyArray<FormDataCoercible>>;
/**
 * Value that can be appended by `formDataRecord`.
 *
 * **Details**
 *
 * `File` and `Blob` values are appended directly, primitive values are converted to strings, and `null` or `undefined` values are skipped.
 *
 * @category models
 * @since 4.0.0
 */
export type FormDataCoercible = string | number | boolean | globalThis.File | globalThis.Blob | null | undefined;
/**
 * Creates a `FormData` HTTP body from a record.
 *
 * **Details**
 *
 * Array fields append each item under the same key; primitive values are stringified, `File` and `Blob` values are appended directly, and nullish values are skipped.
 *
 * @category constructors
 * @since 4.0.0
 */
export declare const formDataRecord: (entries: FormDataInput) => FormData;
/**
 * HTTP body variant backed by a stream of `Uint8Array` chunks.
 *
 * @category models
 * @since 4.0.0
 */
export declare class Stream extends Proto {
    readonly _tag = "Stream";
    readonly stream: Stream_.Stream<globalThis.Uint8Array, unknown>;
    readonly contentType: string;
    readonly contentLength: number | undefined;
    constructor(stream: Stream_.Stream<globalThis.Uint8Array, unknown>, contentType: string, contentLength: number | undefined);
    toJSON(): unknown;
}
/**
 * Creates a streaming HTTP body from a stream of byte chunks.
 *
 * **Details**
 *
 * The content type defaults to `application/octet-stream`; content length is optional.
 *
 * @category constructors
 * @since 4.0.0
 */
export declare const stream: (body: Stream_.Stream<globalThis.Uint8Array, unknown>, contentType?: string, contentLength?: number) => Stream;
/**
 * Creates a streaming HTTP body for a file path.
 *
 * **Details**
 *
 * The effect requires `FileSystem`, stats the file to set the content length, and can fail with `PlatformError`.
 *
 * @category constructors
 * @since 4.0.0
 */
export declare const file: (path: string, options?: {
    readonly bytesToRead?: FileSystem.SizeInput | undefined;
    readonly chunkSize?: FileSystem.SizeInput | undefined;
    readonly offset?: FileSystem.SizeInput | undefined;
    readonly contentType?: string | undefined;
}) => Effect.Effect<Stream, PlatformError.PlatformError, FileSystem.FileSystem>;
/**
 * Creates a streaming HTTP body for a file path using already-known file information.
 *
 * **Details**
 *
 * The effect requires `FileSystem`, uses the provided file size as the content length, and can fail with `PlatformError`.
 *
 * @category constructors
 * @since 4.0.0
 */
export declare const fileFromInfo: (path: string, info: FileSystem.File.Info, options?: {
    readonly bytesToRead?: FileSystem.SizeInput | undefined;
    readonly chunkSize?: FileSystem.SizeInput | undefined;
    readonly offset?: FileSystem.SizeInput | undefined;
    readonly contentType?: string | undefined;
}) => Effect.Effect<Stream, PlatformError.PlatformError, FileSystem.FileSystem>;
export {};
//# sourceMappingURL=HttpBody.d.ts.map