@effect/platform 0.85.2 → 0.86.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/HttpApiBuilder.js +15 -5
- package/dist/cjs/HttpApiBuilder.js.map +1 -1
- package/dist/cjs/HttpApiSchema.js +6 -6
- package/dist/cjs/HttpApiSchema.js.map +1 -1
- package/dist/cjs/HttpIncomingMessage.js +7 -5
- package/dist/cjs/HttpIncomingMessage.js.map +1 -1
- package/dist/cjs/HttpServerRequest.js +10 -4
- package/dist/cjs/HttpServerRequest.js.map +1 -1
- package/dist/cjs/Multipart.js +400 -47
- package/dist/cjs/Multipart.js.map +1 -1
- package/dist/dts/HttpApiBuilder.d.ts.map +1 -1
- package/dist/dts/HttpApiSchema.d.ts +19 -4
- package/dist/dts/HttpApiSchema.d.ts.map +1 -1
- package/dist/dts/HttpIncomingMessage.d.ts +5 -2
- package/dist/dts/HttpIncomingMessage.d.ts.map +1 -1
- package/dist/dts/HttpServerRequest.d.ts +6 -1
- package/dist/dts/HttpServerRequest.d.ts.map +1 -1
- package/dist/dts/Multipart.d.ts +167 -88
- package/dist/dts/Multipart.d.ts.map +1 -1
- package/dist/esm/HttpApiBuilder.js +15 -5
- package/dist/esm/HttpApiBuilder.js.map +1 -1
- package/dist/esm/HttpApiSchema.js +6 -6
- package/dist/esm/HttpApiSchema.js.map +1 -1
- package/dist/esm/HttpIncomingMessage.js +5 -4
- package/dist/esm/HttpIncomingMessage.js.map +1 -1
- package/dist/esm/HttpServerRequest.js +6 -1
- package/dist/esm/HttpServerRequest.js.map +1 -1
- package/dist/esm/Multipart.js +385 -46
- package/dist/esm/Multipart.js.map +1 -1
- package/package.json +2 -2
- package/src/HttpApiBuilder.ts +16 -5
- package/src/HttpApiSchema.ts +23 -7
- package/src/HttpIncomingMessage.ts +5 -7
- package/src/HttpServerRequest.ts +6 -1
- package/src/Multipart.ts +632 -128
- package/dist/cjs/internal/multipart.js +0 -364
- package/dist/cjs/internal/multipart.js.map +0 -1
- package/dist/dts/internal/multipart.d.ts +0 -2
- package/dist/dts/internal/multipart.d.ts.map +0 -1
- package/dist/esm/internal/multipart.js +0 -347
- package/dist/esm/internal/multipart.js.map +0 -1
- package/src/internal/multipart.ts +0 -491
package/src/HttpApiSchema.ts
CHANGED
|
@@ -7,10 +7,13 @@ import * as Effectable from "effect/Effectable"
|
|
|
7
7
|
import type { LazyArg } from "effect/Function"
|
|
8
8
|
import { constant, constVoid, dual } from "effect/Function"
|
|
9
9
|
import { globalValue } from "effect/GlobalValue"
|
|
10
|
+
import type * as Option from "effect/Option"
|
|
10
11
|
import { hasProperty } from "effect/Predicate"
|
|
11
12
|
import * as Schema from "effect/Schema"
|
|
12
13
|
import * as AST from "effect/SchemaAST"
|
|
13
14
|
import * as Struct from "effect/Struct"
|
|
15
|
+
import type * as FileSystem from "./FileSystem.js"
|
|
16
|
+
import type * as Multipart_ from "./Multipart.js"
|
|
14
17
|
|
|
15
18
|
/**
|
|
16
19
|
* @since 1.0.0
|
|
@@ -111,14 +114,15 @@ export const getEmptyDecodeable = (ast: AST.AST): boolean =>
|
|
|
111
114
|
* @since 1.0.0
|
|
112
115
|
* @category annotations
|
|
113
116
|
*/
|
|
114
|
-
export const getMultipart = (ast: AST.AST):
|
|
117
|
+
export const getMultipart = (ast: AST.AST): Multipart_.withLimits.Options | undefined =>
|
|
118
|
+
getAnnotation<Multipart_.withLimits.Options>(ast, AnnotationMultipart)
|
|
115
119
|
|
|
116
120
|
/**
|
|
117
121
|
* @since 1.0.0
|
|
118
122
|
* @category annotations
|
|
119
123
|
*/
|
|
120
|
-
export const getMultipartStream = (ast: AST.AST):
|
|
121
|
-
getAnnotation<
|
|
124
|
+
export const getMultipartStream = (ast: AST.AST): Multipart_.withLimits.Options | undefined =>
|
|
125
|
+
getAnnotation<Multipart_.withLimits.Options>(ast, AnnotationMultipartStream)
|
|
122
126
|
|
|
123
127
|
const encodingJson: Encoding = {
|
|
124
128
|
kind: "Json",
|
|
@@ -422,9 +426,15 @@ export interface Multipart<S extends Schema.Schema.Any>
|
|
|
422
426
|
* @since 1.0.0
|
|
423
427
|
* @category multipart
|
|
424
428
|
*/
|
|
425
|
-
export const Multipart = <S extends Schema.Schema.Any>(self: S
|
|
429
|
+
export const Multipart = <S extends Schema.Schema.Any>(self: S, options?: {
|
|
430
|
+
readonly maxParts?: Option.Option<number> | undefined
|
|
431
|
+
readonly maxFieldSize?: FileSystem.SizeInput | undefined
|
|
432
|
+
readonly maxFileSize?: Option.Option<FileSystem.SizeInput> | undefined
|
|
433
|
+
readonly maxTotalSize?: Option.Option<FileSystem.SizeInput> | undefined
|
|
434
|
+
readonly fieldMimeTypes?: ReadonlyArray<string> | undefined
|
|
435
|
+
}): Multipart<S> =>
|
|
426
436
|
self.annotations({
|
|
427
|
-
[AnnotationMultipart]:
|
|
437
|
+
[AnnotationMultipart]: options ?? {}
|
|
428
438
|
}) as any
|
|
429
439
|
|
|
430
440
|
/**
|
|
@@ -455,9 +465,15 @@ export interface MultipartStream<S extends Schema.Schema.Any> extends
|
|
|
455
465
|
* @since 1.0.0
|
|
456
466
|
* @category multipart
|
|
457
467
|
*/
|
|
458
|
-
export const MultipartStream = <S extends Schema.Schema.Any>(self: S
|
|
468
|
+
export const MultipartStream = <S extends Schema.Schema.Any>(self: S, options?: {
|
|
469
|
+
readonly maxParts?: Option.Option<number> | undefined
|
|
470
|
+
readonly maxFieldSize?: FileSystem.SizeInput | undefined
|
|
471
|
+
readonly maxFileSize?: Option.Option<FileSystem.SizeInput> | undefined
|
|
472
|
+
readonly maxTotalSize?: Option.Option<FileSystem.SizeInput> | undefined
|
|
473
|
+
readonly fieldMimeTypes?: ReadonlyArray<string> | undefined
|
|
474
|
+
}): MultipartStream<S> =>
|
|
459
475
|
self.annotations({
|
|
460
|
-
[AnnotationMultipartStream]:
|
|
476
|
+
[AnnotationMultipartStream]: options ?? {}
|
|
461
477
|
}) as any
|
|
462
478
|
|
|
463
479
|
const defaultContentType = (encoding: Encoding["kind"]) => {
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @since 1.0.0
|
|
3
3
|
*/
|
|
4
|
+
import * as Context from "effect/Context"
|
|
4
5
|
import * as Effect from "effect/Effect"
|
|
5
|
-
import * as FiberRef from "effect/FiberRef"
|
|
6
6
|
import { dual } from "effect/Function"
|
|
7
|
-
import * as Global from "effect/GlobalValue"
|
|
8
7
|
import * as Inspectable from "effect/Inspectable"
|
|
9
8
|
import * as Option from "effect/Option"
|
|
10
9
|
import type * as ParseResult from "effect/ParseResult"
|
|
@@ -85,10 +84,9 @@ export const schemaHeaders = <A, I extends Readonly<Record<string, string | unde
|
|
|
85
84
|
* @since 1.0.0
|
|
86
85
|
* @category fiber refs
|
|
87
86
|
*/
|
|
88
|
-
export
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
)
|
|
87
|
+
export class MaxBodySize extends Context.Reference<MaxBodySize>()("@effect/platform/HttpIncomingMessage/MaxBodySize", {
|
|
88
|
+
defaultValue: Option.none<FileSystem.Size>
|
|
89
|
+
}) {}
|
|
92
90
|
|
|
93
91
|
/**
|
|
94
92
|
* @since 1.0.0
|
|
@@ -105,7 +103,7 @@ export const withMaxBodySize = dual<
|
|
|
105
103
|
* @category fiber refs
|
|
106
104
|
*/
|
|
107
105
|
<A, E, R>(effect: Effect.Effect<A, E, R>, size: Option.Option<FileSystem.SizeInput>) => Effect.Effect<A, E, R>
|
|
108
|
-
>(2, (effect, size) => Effect.
|
|
106
|
+
>(2, (effect, size) => Effect.provideService(effect, MaxBodySize, Option.map(size, FileSystem.Size)))
|
|
109
107
|
|
|
110
108
|
/**
|
|
111
109
|
* @since 1.0.0
|
package/src/HttpServerRequest.ts
CHANGED