Skip to content
This repository has been archived by the owner on Jul 16, 2024. It is now read-only.

Commit

Permalink
use multipasta for multipart parsing (#250)
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-smart authored Nov 13, 2023
1 parent da5d00f commit 6e18090
Show file tree
Hide file tree
Showing 39 changed files with 955 additions and 618 deletions.
8 changes: 8 additions & 0 deletions .changeset/gold-knives-carry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@effect/platform-browser": minor
"@effect/platform-node": minor
"@effect/platform-bun": minor
"@effect/platform": minor
---

updated FormData model and apis
2 changes: 1 addition & 1 deletion docs/platform-bun/Worker.ts.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Worker.ts
nav_order: 18
nav_order: 19
parent: "@effect/platform-bun"
---

Expand Down
2 changes: 1 addition & 1 deletion docs/platform-bun/WorkerRunner.ts.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: WorkerRunner.ts
nav_order: 19
nav_order: 20
parent: "@effect/platform-bun"
---

Expand Down
16 changes: 15 additions & 1 deletion docs/platform-node/Http/FormData.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ Also includes exports from [`@effect/platform/Http/FormData`](https://effect-ts.
- [constructors](#constructors)
- [formData](#formdata)
- [stream](#stream)
- [conversions](#conversions)
- [fileToReadable](#filetoreadable)
- [exports](#exports)
- [From "@effect/platform/Http/FormData"](#from-effectplatformhttpformdata)

Expand All @@ -32,7 +34,7 @@ Also includes exports from [`@effect/platform/Http/FormData`](https://effect-ts.
export declare const formData: (
source: Readable,
headers: IncomingHttpHeaders
) => Effect.Effect<Path.Path | FileSystem.FileSystem | Scope.Scope, FormData.FormDataError, FormData>
) => Effect.Effect<FileSystem.FileSystem | Path.Path | Scope.Scope, FormData.FormDataError, FormData.PersistedFormData>
```
Added in v1.0.0
Expand All @@ -50,6 +52,18 @@ export declare const stream: (
Added in v1.0.0
# conversions
## fileToReadable
**Signature**
```ts
export declare const fileToReadable: (file: FormData.File) => Readable
```
Added in v1.0.0
# exports
## From "@effect/platform/Http/FormData"
Expand Down
2 changes: 1 addition & 1 deletion docs/platform-node/Worker.ts.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Worker.ts
nav_order: 21
nav_order: 22
parent: "@effect/platform-node"
---

Expand Down
2 changes: 1 addition & 1 deletion docs/platform-node/WorkerRunner.ts.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: WorkerRunner.ts
nav_order: 22
nav_order: 23
parent: "@effect/platform-node"
---

Expand Down
13 changes: 13 additions & 0 deletions docs/platform-node/index.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Added in v1.0.0
- [From "./Runtime.js"](#from-runtimejs)
- [From "./Sink.js"](#from-sinkjs)
- [From "./Stream.js"](#from-streamjs)
- [From "./Terminal.js"](#from-terminaljs)
- [From "./Worker.js"](#from-workerjs)
- [From "./WorkerRunner.js"](#from-workerrunnerjs)

Expand Down Expand Up @@ -191,6 +192,18 @@ export * as Stream from "./Stream.js"

Added in v1.0.0

## From "./Terminal.js"

Re-exports all named exports from the "./Terminal.js" module as `Terminal`.

**Signature**

```ts
export * as Terminal from "./Terminal.js"
```

Added in v1.0.0

## From "./Worker.js"

Re-exports all named exports from the "./Worker.js" module as `Worker`.
Expand Down
396 changes: 198 additions & 198 deletions docs/platform/Effectify.ts.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/platform/Error.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ Added in v1.0.0
export interface Base extends Data.Case {
readonly [PlatformErrorTypeId]: typeof PlatformErrorTypeId
readonly _tag: string
readonly module: "Command" | "FileSystem" | "Path" | "KeyValueStore" | "Clipboard" | "Stream"
readonly module: "Clipboard" | "Command" | "FileSystem" | "KeyValueStore" | "Path" | "Stream" | "Terminal"
readonly method: string
readonly message: string
}
Expand Down
148 changes: 85 additions & 63 deletions docs/platform/Http/FormData.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,32 +12,34 @@ Added in v1.0.0

<h2 class="text-delta">Table of contents</h2>

- [conversions](#conversions)
- [toRecord](#torecord)
- [constructors](#constructors)
- [formData](#formdata)
- [makeChannel](#makechannel)
- [makeConfig](#makeconfig)
- [errors](#errors)
- [FormDataError](#formdataerror)
- [FormDataError (interface)](#formdataerror-interface)
- [fiber refs](#fiber-refs)
- [fieldMimeTypes](#fieldmimetypes)
- [maxFieldSize](#maxfieldsize)
- [maxFields](#maxfields)
- [maxFileSize](#maxfilesize)
- [maxFiles](#maxfiles)
- [maxParts](#maxparts)
- [withFieldMimeTypes](#withfieldmimetypes)
- [withMaxFieldSize](#withmaxfieldsize)
- [withMaxFields](#withmaxfields)
- [withMaxFileSize](#withmaxfilesize)
- [withMaxFiles](#withmaxfiles)
- [withMaxParts](#withmaxparts)
- [models](#models)
- [Field (interface)](#field-interface)
- [File (interface)](#file-interface)
- [Part (type alias)](#part-type-alias)
- [PersistedFile (interface)](#persistedfile-interface)
- [PersistedFormData (interface)](#persistedformdata-interface)
- [refinements](#refinements)
- [isField](#isfield)
- [schema](#schema)
- [filesSchema](#filesschema)
- [schemaJson](#schemajson)
- [schemaRecord](#schemarecord)
- [schemaPersisted](#schemapersisted)
- [type ids](#type-ids)
- [ErrorTypeId](#errortypeid)
- [ErrorTypeId (type alias)](#errortypeid-type-alias)
Expand All @@ -49,14 +51,40 @@ Added in v1.0.0

---

# conversions
# constructors

## toRecord
## formData

**Signature**

```ts
export declare const toRecord: (formData: FormData) => Record<string, string | Array<globalThis.File>>
export declare const formData: (
stream: Stream.Stream<never, FormDataError, Part>,
writeFile?: ((path: string, file: File) => Effect.Effect<FileSystem.FileSystem, FormDataError, void>) | undefined
) => Effect.Effect<FileSystem.FileSystem | Path.Path | Scope.Scope, FormDataError, PersistedFormData>
```
Added in v1.0.0
## makeChannel
**Signature**
```ts
export declare const makeChannel: <IE>(
headers: Record<string, string>,
bufferSize?: number
) => Channel.Channel<never, IE, Chunk.Chunk<Uint8Array>, unknown, FormDataError | IE, Chunk.Chunk<Part>, unknown>
```
Added in v1.0.0
## makeConfig
**Signature**
```ts
export declare const makeConfig: (headers: Record<string, string>) => Effect.Effect<never, never, Multipasta.BaseConfig>
```
Added in v1.0.0
Expand All @@ -81,7 +109,7 @@ Added in v1.0.0
export interface FormDataError extends Data.Case {
readonly [ErrorTypeId]: ErrorTypeId
readonly _tag: "FormDataError"
readonly reason: "FileTooLarge" | "FieldTooLarge" | "InternalError" | "Parse"
readonly reason: "FileTooLarge" | "FieldTooLarge" | "BodyTooLarge" | "TooManyParts" | "InternalError" | "Parse"
readonly error: unknown
}
```
Expand Down Expand Up @@ -110,16 +138,6 @@ export declare const maxFieldSize: FiberRef.FiberRef<FileSystem.Size>
Added in v1.0.0
## maxFields
**Signature**
```ts
export declare const maxFields: FiberRef.FiberRef<Option.Option<number>>
```
Added in v1.0.0
## maxFileSize
**Signature**
Expand All @@ -130,16 +148,6 @@ export declare const maxFileSize: FiberRef.FiberRef<Option.Option<FileSystem.Siz
Added in v1.0.0
## maxFiles
**Signature**
```ts
export declare const maxFiles: FiberRef.FiberRef<Option.Option<number>>
```
Added in v1.0.0
## maxParts
**Signature**
Expand Down Expand Up @@ -176,19 +184,6 @@ export declare const withMaxFieldSize: {
Added in v1.0.0
## withMaxFields
**Signature**
```ts
export declare const withMaxFields: {
(count: Option.Option<number>): <R, E, A>(effect: Effect.Effect<R, E, A>) => Effect.Effect<R, E, A>
<R, E, A>(effect: Effect.Effect<R, E, A>, count: Option.Option<number>): Effect.Effect<R, E, A>
}
```
Added in v1.0.0
## withMaxFileSize
**Signature**
Expand All @@ -202,19 +197,6 @@ export declare const withMaxFileSize: {
Added in v1.0.0
## withMaxFiles
**Signature**
```ts
export declare const withMaxFiles: {
(count: Option.Option<number>): <R, E, A>(effect: Effect.Effect<R, E, A>) => Effect.Effect<R, E, A>
<R, E, A>(effect: Effect.Effect<R, E, A>, count: Option.Option<number>): Effect.Effect<R, E, A>
}
```
Added in v1.0.0
## withMaxParts
**Signature**
Expand Down Expand Up @@ -271,14 +253,54 @@ export type Part = Field | File
Added in v1.0.0
## PersistedFile (interface)
**Signature**
```ts
export interface PersistedFile extends Part.Proto {
readonly _tag: "PersistedFile"
readonly key: string
readonly name: string
readonly contentType: string
readonly path: string
}
```

Added in v1.0.0

## PersistedFormData (interface)

**Signature**

```ts
export interface PersistedFormData {
readonly [key: string]: ReadonlyArray<PersistedFile> | string
}
```

Added in v1.0.0

# refinements

## isField

**Signature**

```ts
export declare const isField: (u: unknown) => u is Field
```
Added in v1.0.0
# schema
## filesSchema
**Signature**
```ts
export declare const filesSchema: Schema.Schema<readonly globalThis.File[], readonly globalThis.File[]>
export declare const filesSchema: Schema.Schema<readonly PersistedFile[], readonly PersistedFile[]>
```
Added in v1.0.0
Expand All @@ -291,21 +313,21 @@ Added in v1.0.0
export declare const schemaJson: <I, A>(
schema: Schema.Schema<I, A>
) => {
(field: string): (formData: FormData) => Effect.Effect<never, FormDataError | ParseResult.ParseError, A>
(formData: FormData, field: string): Effect.Effect<never, FormDataError | ParseResult.ParseError, A>
(field: string): (formData: PersistedFormData) => Effect.Effect<never, FormDataError | ParseResult.ParseError, A>
(formData: PersistedFormData, field: string): Effect.Effect<never, FormDataError | ParseResult.ParseError, A>
}
```
Added in v1.0.0
## schemaRecord
## schemaPersisted
**Signature**
```ts
export declare const schemaRecord: <I extends Readonly<Record<string, string | readonly globalThis.File[]>>, A>(
export declare const schemaPersisted: <I extends PersistedFormData, A>(
schema: Schema.Schema<I, A>
) => (formData: FormData) => Effect.Effect<never, ParseResult.ParseError, A>
) => (formData: PersistedFormData) => Effect.Effect<never, ParseResult.ParseError, A>
```
Added in v1.0.0
Expand Down
Loading

0 comments on commit 6e18090

Please sign in to comment.