@effect/platform 0.85.1 → 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 +8 -10
- 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 +8 -10
- 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 +25 -11
- 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",
|
|
@@ -137,10 +141,8 @@ export const getEncoding = (ast: AST.AST, fallback = encodingJson): Encoding =>
|
|
|
137
141
|
* @category annotations
|
|
138
142
|
*/
|
|
139
143
|
export const getParam = (ast: AST.AST | Schema.PropertySignature.AST): string | undefined => {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
}
|
|
143
|
-
return (ast.annotations[AnnotationParam] as any)?.name as string | undefined
|
|
144
|
+
const annotations = ast._tag === "PropertySignatureTransformation" ? ast.to.annotations : ast.annotations
|
|
145
|
+
return (annotations[AnnotationParam] as any)?.name as string | undefined
|
|
144
146
|
}
|
|
145
147
|
|
|
146
148
|
/**
|
|
@@ -424,9 +426,15 @@ export interface Multipart<S extends Schema.Schema.Any>
|
|
|
424
426
|
* @since 1.0.0
|
|
425
427
|
* @category multipart
|
|
426
428
|
*/
|
|
427
|
-
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> =>
|
|
428
436
|
self.annotations({
|
|
429
|
-
[AnnotationMultipart]:
|
|
437
|
+
[AnnotationMultipart]: options ?? {}
|
|
430
438
|
}) as any
|
|
431
439
|
|
|
432
440
|
/**
|
|
@@ -457,9 +465,15 @@ export interface MultipartStream<S extends Schema.Schema.Any> extends
|
|
|
457
465
|
* @since 1.0.0
|
|
458
466
|
* @category multipart
|
|
459
467
|
*/
|
|
460
|
-
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> =>
|
|
461
475
|
self.annotations({
|
|
462
|
-
[AnnotationMultipartStream]:
|
|
476
|
+
[AnnotationMultipartStream]: options ?? {}
|
|
463
477
|
}) as any
|
|
464
478
|
|
|
465
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