import * as Channel from "effect/Channel"; import * as Chunk from "effect/Chunk"; import * as Context from "effect/Context"; import * as Effect from "effect/Effect"; import * as Inspectable from "effect/Inspectable"; import * as Option from "effect/Option"; import type * as ParseResult from "effect/ParseResult"; import * as Schema from "effect/Schema"; import type { ParseOptions } from "effect/SchemaAST"; import type * as Scope from "effect/Scope"; import * as Stream from "effect/Stream"; import * as MP from "multipasta"; import * as FileSystem from "./FileSystem.js"; import * as Path from "./Path.js"; /** * @since 1.0.0 * @category type ids */ export declare const TypeId: unique symbol; /** * @since 1.0.0 * @category type ids */ export type TypeId = typeof TypeId; /** * @since 1.0.0 * @category models */ export type Part = Field | File; /** * @since 1.0.0 */ export declare namespace Part { /** * @since 1.0.0 * @category models */ interface Proto extends Inspectable.Inspectable { readonly [TypeId]: TypeId; readonly _tag: string; } } /** * @since 1.0.0 * @category models */ export interface Field extends Part.Proto { readonly _tag: "Field"; readonly key: string; readonly contentType: string; readonly value: string; } /** * @since 1.0.0 * @category Guards */ export declare const isPart: (u: unknown) => u is Part; /** * @since 1.0.0 * @category Guards */ export declare const isField: (u: unknown) => u is Field; /** * @since 1.0.0 * @category models */ export interface File extends Part.Proto { readonly _tag: "File"; readonly key: string; readonly name: string; readonly contentType: string; readonly content: Stream.Stream; readonly contentEffect: Effect.Effect; } /** * @since 1.0.0 * @category Guards */ export declare const isFile: (u: unknown) => u is File; /** * @since 1.0.0 * @category models */ export interface PersistedFile extends Part.Proto { readonly _tag: "PersistedFile"; readonly key: string; readonly name: string; readonly contentType: string; readonly path: string; } /** * @since 1.0.0 * @category Guards */ export declare const isPersistedFile: (u: unknown) => u is PersistedFile; /** * @since 1.0.0 * @category models */ export interface Persisted { readonly [key: string]: ReadonlyArray | ReadonlyArray | string; } /** * @since 1.0.0 * @category Errors */ export declare const ErrorTypeId: unique symbol; /** * @since 1.0.0 * @category Errors */ export type ErrorTypeId = typeof ErrorTypeId; declare const MultipartError_base: Schema.TaggedErrorClass; } & { reason: Schema.Literal<["FileTooLarge", "FieldTooLarge", "BodyTooLarge", "TooManyParts", "InternalError", "Parse"]>; cause: typeof Schema.Defect; }>; /** * @since 1.0.0 * @category Errors */ export declare class MultipartError extends MultipartError_base { /** * @since 1.0.0 */ readonly [ErrorTypeId]: ErrorTypeId; /** * @since 1.0.0 */ get message(): string; } /** * @since 1.0.0 * @category Schemas */ export declare const FileSchema: Schema.Schema; /** * @since 1.0.0 * @category Schemas */ export declare const FilesSchema: Schema.Schema>; /** * @since 1.0.0 * @category Schemas */ export declare const SingleFileSchema: Schema.transform>, Schema.Schema>; /** * @since 1.0.0 * @category Schemas */ export declare const schemaPersisted: , R>(schema: Schema.Schema, options?: ParseOptions | undefined) => (persisted: Persisted) => Effect.Effect; /** * @since 1.0.0 * @category Schemas */ export declare const schemaJson: (schema: Schema.Schema, options?: ParseOptions | undefined) => { (field: string): (persisted: Persisted) => Effect.Effect; (persisted: Persisted, field: string): Effect.Effect; }; /** * @since 1.0.0 * @category Config */ export declare const makeConfig: (headers: Record) => Effect.Effect; /** * @since 1.0.0 * @category Parsers */ export declare const makeChannel: (headers: Record, bufferSize?: number) => Channel.Channel, Chunk.Chunk, MultipartError | IE, IE, unknown, unknown>; /** * @since 1.0.0 */ export declare const collectUint8Array: Channel.Channel>, unknown, unknown, Uint8Array, unknown, never>; /** * @since 1.0.0 * @category Conversions */ export declare const toPersisted: (stream: Stream.Stream, writeFile?: (path: string, file: File) => Effect.Effect) => Effect.Effect; /** * @since 1.0.0 * @category fiber refs */ export declare const withLimits: { /** * @since 1.0.0 * @category fiber refs */ (options: { readonly maxParts?: Option.Option | undefined; readonly maxFieldSize?: FileSystem.SizeInput | undefined; readonly maxFileSize?: Option.Option | undefined; readonly maxTotalSize?: Option.Option | undefined; readonly fieldMimeTypes?: ReadonlyArray | undefined; }): (effect: Effect.Effect) => Effect.Effect; /** * @since 1.0.0 * @category fiber refs */ (effect: Effect.Effect, options: { readonly maxParts?: Option.Option | undefined; readonly maxFieldSize?: FileSystem.SizeInput | undefined; readonly maxFileSize?: Option.Option | undefined; readonly maxTotalSize?: Option.Option | undefined; readonly fieldMimeTypes?: ReadonlyArray | undefined; }): Effect.Effect; }; /** * @since 1.0.0 * @category fiber refs */ export declare const withLimitsStream: { /** * @since 1.0.0 * @category fiber refs */ (options: { readonly maxParts?: Option.Option | undefined; readonly maxFieldSize?: FileSystem.SizeInput | undefined; readonly maxFileSize?: Option.Option | undefined; readonly maxTotalSize?: Option.Option | undefined; readonly fieldMimeTypes?: ReadonlyArray | undefined; }): (stream: Stream.Stream) => Stream.Stream; /** * @since 1.0.0 * @category fiber refs */ (stream: Stream.Stream, options: { readonly maxParts?: Option.Option | undefined; readonly maxFieldSize?: FileSystem.SizeInput | undefined; readonly maxFileSize?: Option.Option | undefined; readonly maxTotalSize?: Option.Option | undefined; readonly fieldMimeTypes?: ReadonlyArray | undefined; }): Stream.Stream; }; /** * @since 1.0.0 * @category fiber refs */ export declare namespace withLimits { /** * @since 1.0.0 * @category fiber refs */ type Options = { readonly maxParts?: Option.Option | undefined; readonly maxFieldSize?: FileSystem.SizeInput | undefined; readonly maxFileSize?: Option.Option | undefined; readonly maxTotalSize?: Option.Option | undefined; readonly fieldMimeTypes?: ReadonlyArray | undefined; }; } declare const MaxParts_base: Context.ReferenceClass>; /** * @since 1.0.0 * @category fiber refs */ export declare class MaxParts extends MaxParts_base { } /** * @since 1.0.0 * @category fiber refs */ export declare const withMaxParts: { /** * @since 1.0.0 * @category fiber refs */ (count: Option.Option): (effect: Effect.Effect) => Effect.Effect; /** * @since 1.0.0 * @category fiber refs */ (effect: Effect.Effect, count: Option.Option): Effect.Effect; }; declare const MaxFieldSize_base: Context.ReferenceClass; /** * @since 1.0.0 * @category fiber refs */ export declare class MaxFieldSize extends MaxFieldSize_base { } /** * @since 1.0.0 * @category fiber refs */ export declare const withMaxFieldSize: { /** * @since 1.0.0 * @category fiber refs */ (size: FileSystem.SizeInput): (effect: Effect.Effect) => Effect.Effect; /** * @since 1.0.0 * @category fiber refs */ (effect: Effect.Effect, size: FileSystem.SizeInput): Effect.Effect; }; declare const MaxFileSize_base: Context.ReferenceClass>; /** * @since 1.0.0 * @category fiber refs */ export declare class MaxFileSize extends MaxFileSize_base { } /** * @since 1.0.0 * @category fiber refs */ export declare const withMaxFileSize: { /** * @since 1.0.0 * @category fiber refs */ (size: Option.Option): (effect: Effect.Effect) => Effect.Effect; /** * @since 1.0.0 * @category fiber refs */ (effect: Effect.Effect, size: Option.Option): Effect.Effect; }; declare const FieldMimeTypes_base: Context.ReferenceClass>; /** * @since 1.0.0 * @category fiber refs */ export declare class FieldMimeTypes extends FieldMimeTypes_base { } /** * @since 1.0.0 * @category fiber refs */ export declare const withFieldMimeTypes: { /** * @since 1.0.0 * @category fiber refs */ (mimeTypes: ReadonlyArray): (effect: Effect.Effect) => Effect.Effect; /** * @since 1.0.0 * @category fiber refs */ (effect: Effect.Effect, mimeTypes: ReadonlyArray): Effect.Effect; }; export {}; //# sourceMappingURL=Multipart.d.ts.map