Skip to content

Multipart

35 exports Added in v1.0.0 Source

Config

makeConfig

Added in v1.0.0 Source

Signature

declare function makeConfig(headers: Record<string, string>): Effect<BaseConfig>;

Conversions

toPersisted

Added in v1.0.0 Source

Signature

declare function toPersisted(
  stream: Stream<Part, MultipartError>,
  writeFile: (path: string, file: File) => Effect<unknown, unknown, unknown>,
): Effect<Persisted, MultipartError, Scope | FileSystem | Path>;

Errors

ErrorTypeId

Added in v1.0.0 Source

Signature

declare const ErrorTypeId: unique symbol;

ErrorTypeId type

Added in v1.0.0 Source

Signature

type ErrorTypeId = typeof ErrorTypeId;

Signature

declare class MultipartError extends any {
  constructor();
  readonly [ErrorTypeId]: typeof ErrorTypeId;
  message: string;
}

Fiber Refs

Signature

declare class FieldMimeTypes extends any {
  constructor();
}

MaxFieldSize

Added in v1.0.0 Source

Signature

declare class MaxFieldSize extends any {
  constructor();
}

MaxFileSize

Added in v1.0.0 Source

Signature

declare class MaxFileSize extends any {
  constructor();
}

MaxParts

Added in v1.0.0 Source

Signature

declare class MaxParts extends any {
  constructor();
}

Signature

declare const withFieldMimeTypes: {
  (mimeTypes: readonly Array<string>): <A, E, R>(effect: Effect<A, E, R>) => Effect<A, E, R>;
  <A, E, R>(effect: Effect<A, E, R>, mimeTypes: readonly Array<string>): Effect<A, E, R>;
}

withLimits

Added in v1.0.0 Source

Signature

declare const withLimits: {
  (options: {
    readonly fieldMimeTypes?: ReadonlyArray<string>;
    readonly maxFieldSize?: FileSystem.SizeInput;
    readonly maxFileSize?: Option.Option<FileSystem.SizeInput>;
    readonly maxParts?: Option.Option<number>;
    readonly maxTotalSize?: Option.Option<FileSystem.SizeInput>;
  }): <A, E, R>(effect: Effect<A, E, R>) => Effect<A, E, R>;
  <A, E, R>(
    effect: Effect<A, E, R>,
    options: {
      readonly fieldMimeTypes?: ReadonlyArray<string>;
      readonly maxFieldSize?: FileSystem.SizeInput;
      readonly maxFileSize?: Option.Option<FileSystem.SizeInput>;
      readonly maxParts?: Option.Option<number>;
      readonly maxTotalSize?: Option.Option<FileSystem.SizeInput>;
    },
  ): Effect<A, E, R>;
};

withLimits

Added in v1.0.0 Source

Signature

declare const withLimitsStream: {
  (options: {
    readonly fieldMimeTypes?: ReadonlyArray<string>;
    readonly maxFieldSize?: FileSystem.SizeInput;
    readonly maxFileSize?: Option.Option<FileSystem.SizeInput>;
    readonly maxParts?: Option.Option<number>;
    readonly maxTotalSize?: Option.Option<FileSystem.SizeInput>;
  }): <A, E, R>(stream: Stream<A, E, R>) => Stream<A, E, R>;
  <A, E, R>(
    stream: Stream<A, E, R>,
    options: {
      readonly fieldMimeTypes?: ReadonlyArray<string>;
      readonly maxFieldSize?: FileSystem.SizeInput;
      readonly maxFileSize?: Option.Option<FileSystem.SizeInput>;
      readonly maxParts?: Option.Option<number>;
      readonly maxTotalSize?: Option.Option<FileSystem.SizeInput>;
    },
  ): Stream<A, E, R>;
};

Signature

declare const withMaxFieldSize: {
  (size: SizeInput): <A, E, R>(effect: Effect<A, E, R>) => Effect<A, E, R>;
  <A, E, R>(effect: Effect<A, E, R>, size: SizeInput): Effect<A, E, R>;
};

Signature

declare const withMaxFileSize: {
  (size: Option<SizeInput>): <A, E, R>(effect: Effect<A, E, R>) => Effect<A, E, R>;
  <A, E, R>(effect: Effect<A, E, R>, size: Option<SizeInput>): Effect<A, E, R>;
};

withMaxParts

Added in v1.0.0 Source

Signature

declare const withMaxParts: {
  (count: Option<number>): <A, E, R>(effect: Effect<A, E, R>) => Effect<A, E, R>;
  <A, E, R>(effect: Effect<A, E, R>, count: Option<number>): Effect<A, E, R>;
};

Guards

isField

Added in v1.0.0 Source

Signature

declare function isField(u: unknown): u is Field;

isFile

Added in v1.0.0 Source

Signature

declare function isFile(u: unknown): u is File;

isPart

Added in v1.0.0 Source

Signature

declare function isPart(u: unknown): u is Part;

Signature

declare function isPersistedFile(u: unknown): u is PersistedFile;

Models

Field interface

Added in v1.0.0 Source

Signature

interface Field extends Proto {
  readonly _tag: "Field";
  readonly contentType: string;
  readonly key: string;
  readonly value: string;
}

File interface

Added in v1.0.0 Source

Signature

interface File extends Proto {
  readonly _tag: "File";
  readonly content: Stream<Uint8Array<ArrayBufferLike>, MultipartError>;
  readonly contentEffect: Effect<Uint8Array<ArrayBufferLike>, MultipartError>;
  readonly contentType: string;
  readonly key: string;
  readonly name: string;
}

Part type

Added in v1.0.0 Source

Signature

type Part = Field | File;

Persisted interface

Added in v1.0.0 Source

Signature

interface Persisted {
  [key: string]: string | readonly Array<string> | readonly Array<PersistedFile>;
}

PersistedFile interface

Added in v1.0.0 Source

Signature

interface PersistedFile extends Proto {
  readonly _tag: "PersistedFile";
  readonly contentType: string;
  readonly key: string;
  readonly name: string;
  readonly path: string;
}

Other

Signature

declare const collectUint8Array: Channel<
  never,
  Chunk<Uint8Array<ArrayBufferLike>>,
  unknown,
  unknown,
  Uint8Array<ArrayBufferLike>,
  unknown,
  never
>;

Part

Added in v1.0.0 Source

Parsers

makeChannel

Added in v1.0.0 Source

Signature

declare function makeChannel<IE>(
  headers: Record<string, string>,
  bufferSize: number,
): Channel<
  Chunk<Part>,
  Chunk<Uint8Array<ArrayBufferLike>>,
  MultipartError | IE,
  IE,
  unknown,
  unknown
>;

Schemas

FileSchema

Added in v1.0.0 Source

Signature

declare const FileSchema: Schema.Schema<PersistedFile>;

FilesSchema

Added in v1.0.0 Source

Signature

declare const FilesSchema: Schema.Schema<ReadonlyArray<PersistedFile>>;

schemaJson

Added in v1.0.0 Source

Signature

declare function schemaJson<A, I, R>(
  schema: any,
  options?: ParseOptions,
): {
  (field: string): (persisted: Persisted) => Effect<A, ParseError, R>;
  (persisted: Persisted, field: string): Effect<A, ParseError, R>;
};

Signature

declare function schemaPersisted<A, I extends Partial<Persisted>, R>(
  schema: any,
  options?: ParseOptions,
): (persisted: Persisted) => Effect<A, ParseError, R>;

Signature

declare const SingleFileSchema: Schema.transform<
  Schema.Schema<ReadonlyArray<PersistedFile>>,
  Schema.Schema<PersistedFile>
>;

Type Ids

TypeId

Added in v1.0.0 Source

Signature

declare const TypeId: unique symbol;

TypeId type

Added in v1.0.0 Source

Signature

type TypeId = typeof TypeId;