@effect/platform 0.68.6 → 0.69.1

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.
Files changed (229) hide show
  1. package/HttpApiMiddleware/package.json +6 -0
  2. package/README.md +306 -233
  3. package/dist/cjs/Headers.js +7 -2
  4. package/dist/cjs/Headers.js.map +1 -1
  5. package/dist/cjs/HttpApi.js +90 -78
  6. package/dist/cjs/HttpApi.js.map +1 -1
  7. package/dist/cjs/HttpApiBuilder.js +245 -255
  8. package/dist/cjs/HttpApiBuilder.js.map +1 -1
  9. package/dist/cjs/HttpApiClient.js +64 -59
  10. package/dist/cjs/HttpApiClient.js.map +1 -1
  11. package/dist/cjs/HttpApiEndpoint.js +74 -109
  12. package/dist/cjs/HttpApiEndpoint.js.map +1 -1
  13. package/dist/cjs/HttpApiError.js +3 -4
  14. package/dist/cjs/HttpApiError.js.map +1 -1
  15. package/dist/cjs/HttpApiGroup.js +103 -100
  16. package/dist/cjs/HttpApiGroup.js.map +1 -1
  17. package/dist/cjs/HttpApiMiddleware.js +67 -0
  18. package/dist/cjs/HttpApiMiddleware.js.map +1 -0
  19. package/dist/cjs/HttpApiSchema.js +33 -7
  20. package/dist/cjs/HttpApiSchema.js.map +1 -1
  21. package/dist/cjs/HttpApiSecurity.js +2 -2
  22. package/dist/cjs/HttpApiSecurity.js.map +1 -1
  23. package/dist/cjs/HttpApiSwagger.js +3 -1
  24. package/dist/cjs/HttpApiSwagger.js.map +1 -1
  25. package/dist/cjs/HttpBody.js.map +1 -1
  26. package/dist/cjs/HttpIncomingMessage.js +5 -1
  27. package/dist/cjs/HttpIncomingMessage.js.map +1 -1
  28. package/dist/cjs/HttpServer.js +12 -1
  29. package/dist/cjs/HttpServer.js.map +1 -1
  30. package/dist/cjs/HttpServerRespondable.js +1 -1
  31. package/dist/cjs/HttpServerRespondable.js.map +1 -1
  32. package/dist/cjs/OpenApi.js +102 -63
  33. package/dist/cjs/OpenApi.js.map +1 -1
  34. package/dist/cjs/OpenApiJsonSchema.js +58 -47
  35. package/dist/cjs/OpenApiJsonSchema.js.map +1 -1
  36. package/dist/cjs/Transferable.js +2 -2
  37. package/dist/cjs/Transferable.js.map +1 -1
  38. package/dist/cjs/UrlParams.js +5 -1
  39. package/dist/cjs/UrlParams.js.map +1 -1
  40. package/dist/cjs/Worker.js.map +1 -1
  41. package/dist/cjs/WorkerError.js +1 -5
  42. package/dist/cjs/WorkerError.js.map +1 -1
  43. package/dist/cjs/WorkerRunner.js.map +1 -1
  44. package/dist/cjs/index.js +3 -1
  45. package/dist/cjs/internal/httpBody.js +1 -1
  46. package/dist/cjs/internal/httpBody.js.map +1 -1
  47. package/dist/cjs/internal/httpClientRequest.js.map +1 -1
  48. package/dist/cjs/internal/httpClientResponse.js +1 -1
  49. package/dist/cjs/internal/httpClientResponse.js.map +1 -1
  50. package/dist/cjs/internal/httpRouter.js +1 -1
  51. package/dist/cjs/internal/httpRouter.js.map +1 -1
  52. package/dist/cjs/internal/httpServer.js +7 -1
  53. package/dist/cjs/internal/httpServer.js.map +1 -1
  54. package/dist/cjs/internal/httpServerRequest.js +1 -1
  55. package/dist/cjs/internal/httpServerRequest.js.map +1 -1
  56. package/dist/cjs/internal/httpServerResponse.js.map +1 -1
  57. package/dist/cjs/internal/keyValueStore.js +1 -1
  58. package/dist/cjs/internal/keyValueStore.js.map +1 -1
  59. package/dist/cjs/internal/multipart.js +1 -1
  60. package/dist/cjs/internal/multipart.js.map +1 -1
  61. package/dist/cjs/internal/worker.js +6 -7
  62. package/dist/cjs/internal/worker.js.map +1 -1
  63. package/dist/cjs/internal/workerRunner.js +3 -4
  64. package/dist/cjs/internal/workerRunner.js.map +1 -1
  65. package/dist/dts/Headers.d.ts +4 -6
  66. package/dist/dts/Headers.d.ts.map +1 -1
  67. package/dist/dts/HttpApi.d.ts +64 -140
  68. package/dist/dts/HttpApi.d.ts.map +1 -1
  69. package/dist/dts/HttpApiBuilder.d.ts +86 -167
  70. package/dist/dts/HttpApiBuilder.d.ts.map +1 -1
  71. package/dist/dts/HttpApiClient.d.ts +34 -11
  72. package/dist/dts/HttpApiClient.d.ts.map +1 -1
  73. package/dist/dts/HttpApiEndpoint.d.ts +119 -273
  74. package/dist/dts/HttpApiEndpoint.d.ts.map +1 -1
  75. package/dist/dts/HttpApiError.d.ts +5 -2
  76. package/dist/dts/HttpApiError.d.ts.map +1 -1
  77. package/dist/dts/HttpApiGroup.d.ts +96 -194
  78. package/dist/dts/HttpApiGroup.d.ts.map +1 -1
  79. package/dist/dts/HttpApiMiddleware.d.ts +228 -0
  80. package/dist/dts/HttpApiMiddleware.d.ts.map +1 -0
  81. package/dist/dts/HttpApiSchema.d.ts +6 -2
  82. package/dist/dts/HttpApiSchema.d.ts.map +1 -1
  83. package/dist/dts/HttpApiSecurity.d.ts +1 -1
  84. package/dist/dts/HttpApiSecurity.d.ts.map +1 -1
  85. package/dist/dts/HttpApiSwagger.d.ts +2 -2
  86. package/dist/dts/HttpApiSwagger.d.ts.map +1 -1
  87. package/dist/dts/HttpBody.d.ts +2 -2
  88. package/dist/dts/HttpBody.d.ts.map +1 -1
  89. package/dist/dts/HttpClientRequest.d.ts +2 -2
  90. package/dist/dts/HttpClientRequest.d.ts.map +1 -1
  91. package/dist/dts/HttpClientResponse.d.ts +3 -3
  92. package/dist/dts/HttpClientResponse.d.ts.map +1 -1
  93. package/dist/dts/HttpIncomingMessage.d.ts +3 -3
  94. package/dist/dts/HttpIncomingMessage.d.ts.map +1 -1
  95. package/dist/dts/HttpRouter.d.ts +3 -3
  96. package/dist/dts/HttpRouter.d.ts.map +1 -1
  97. package/dist/dts/HttpServer.d.ts +15 -0
  98. package/dist/dts/HttpServer.d.ts.map +1 -1
  99. package/dist/dts/HttpServerRequest.d.ts +3 -3
  100. package/dist/dts/HttpServerRequest.d.ts.map +1 -1
  101. package/dist/dts/HttpServerRespondable.d.ts.map +1 -1
  102. package/dist/dts/HttpServerResponse.d.ts +2 -2
  103. package/dist/dts/HttpServerResponse.d.ts.map +1 -1
  104. package/dist/dts/KeyValueStore.d.ts +2 -2
  105. package/dist/dts/KeyValueStore.d.ts.map +1 -1
  106. package/dist/dts/Multipart.d.ts +3 -3
  107. package/dist/dts/Multipart.d.ts.map +1 -1
  108. package/dist/dts/OpenApi.d.ts +17 -39
  109. package/dist/dts/OpenApi.d.ts.map +1 -1
  110. package/dist/dts/OpenApiJsonSchema.d.ts +10 -5
  111. package/dist/dts/OpenApiJsonSchema.d.ts.map +1 -1
  112. package/dist/dts/Transferable.d.ts +4 -1
  113. package/dist/dts/Transferable.d.ts.map +1 -1
  114. package/dist/dts/UrlParams.d.ts +3 -6
  115. package/dist/dts/UrlParams.d.ts.map +1 -1
  116. package/dist/dts/Worker.d.ts +7 -8
  117. package/dist/dts/Worker.d.ts.map +1 -1
  118. package/dist/dts/WorkerError.d.ts +1 -1
  119. package/dist/dts/WorkerError.d.ts.map +1 -1
  120. package/dist/dts/WorkerRunner.d.ts +2 -3
  121. package/dist/dts/WorkerRunner.d.ts.map +1 -1
  122. package/dist/dts/index.d.ts +4 -0
  123. package/dist/dts/index.d.ts.map +1 -1
  124. package/dist/dts/internal/httpRouter.d.ts.map +1 -1
  125. package/dist/esm/Headers.js +7 -2
  126. package/dist/esm/Headers.js.map +1 -1
  127. package/dist/esm/HttpApi.js +88 -77
  128. package/dist/esm/HttpApi.js.map +1 -1
  129. package/dist/esm/HttpApiBuilder.js +238 -244
  130. package/dist/esm/HttpApiBuilder.js.map +1 -1
  131. package/dist/esm/HttpApiClient.js +64 -59
  132. package/dist/esm/HttpApiClient.js.map +1 -1
  133. package/dist/esm/HttpApiEndpoint.js +73 -106
  134. package/dist/esm/HttpApiEndpoint.js.map +1 -1
  135. package/dist/esm/HttpApiError.js +3 -4
  136. package/dist/esm/HttpApiError.js.map +1 -1
  137. package/dist/esm/HttpApiGroup.js +102 -99
  138. package/dist/esm/HttpApiGroup.js.map +1 -1
  139. package/dist/esm/HttpApiMiddleware.js +56 -0
  140. package/dist/esm/HttpApiMiddleware.js.map +1 -0
  141. package/dist/esm/HttpApiSchema.js +31 -5
  142. package/dist/esm/HttpApiSchema.js.map +1 -1
  143. package/dist/esm/HttpApiSecurity.js +1 -1
  144. package/dist/esm/HttpApiSecurity.js.map +1 -1
  145. package/dist/esm/HttpApiSwagger.js +4 -2
  146. package/dist/esm/HttpApiSwagger.js.map +1 -1
  147. package/dist/esm/HttpBody.js.map +1 -1
  148. package/dist/esm/HttpIncomingMessage.js +4 -1
  149. package/dist/esm/HttpIncomingMessage.js.map +1 -1
  150. package/dist/esm/HttpServer.js +11 -0
  151. package/dist/esm/HttpServer.js.map +1 -1
  152. package/dist/esm/HttpServerRespondable.js +1 -1
  153. package/dist/esm/HttpServerRespondable.js.map +1 -1
  154. package/dist/esm/OpenApi.js +97 -59
  155. package/dist/esm/OpenApi.js.map +1 -1
  156. package/dist/esm/OpenApiJsonSchema.js +56 -46
  157. package/dist/esm/OpenApiJsonSchema.js.map +1 -1
  158. package/dist/esm/Transferable.js +2 -2
  159. package/dist/esm/Transferable.js.map +1 -1
  160. package/dist/esm/UrlParams.js +4 -1
  161. package/dist/esm/UrlParams.js.map +1 -1
  162. package/dist/esm/Worker.js.map +1 -1
  163. package/dist/esm/WorkerError.js +1 -4
  164. package/dist/esm/WorkerError.js.map +1 -1
  165. package/dist/esm/WorkerRunner.js.map +1 -1
  166. package/dist/esm/index.js +4 -0
  167. package/dist/esm/index.js.map +1 -1
  168. package/dist/esm/internal/httpBody.js +1 -1
  169. package/dist/esm/internal/httpBody.js.map +1 -1
  170. package/dist/esm/internal/httpClientRequest.js.map +1 -1
  171. package/dist/esm/internal/httpClientResponse.js +1 -1
  172. package/dist/esm/internal/httpClientResponse.js.map +1 -1
  173. package/dist/esm/internal/httpRouter.js +1 -1
  174. package/dist/esm/internal/httpRouter.js.map +1 -1
  175. package/dist/esm/internal/httpServer.js +6 -0
  176. package/dist/esm/internal/httpServer.js.map +1 -1
  177. package/dist/esm/internal/httpServerRequest.js +1 -1
  178. package/dist/esm/internal/httpServerRequest.js.map +1 -1
  179. package/dist/esm/internal/httpServerResponse.js.map +1 -1
  180. package/dist/esm/internal/keyValueStore.js +1 -1
  181. package/dist/esm/internal/keyValueStore.js.map +1 -1
  182. package/dist/esm/internal/multipart.js +1 -1
  183. package/dist/esm/internal/multipart.js.map +1 -1
  184. package/dist/esm/internal/worker.js +6 -7
  185. package/dist/esm/internal/worker.js.map +1 -1
  186. package/dist/esm/internal/workerRunner.js +3 -4
  187. package/dist/esm/internal/workerRunner.js.map +1 -1
  188. package/package.json +10 -3
  189. package/src/Headers.ts +12 -4
  190. package/src/HttpApi.ts +183 -258
  191. package/src/HttpApiBuilder.ts +534 -481
  192. package/src/HttpApiClient.ts +163 -112
  193. package/src/HttpApiEndpoint.ts +443 -564
  194. package/src/HttpApiError.ts +4 -6
  195. package/src/HttpApiGroup.ts +277 -325
  196. package/src/HttpApiMiddleware.ts +317 -0
  197. package/src/HttpApiSchema.ts +39 -2
  198. package/src/HttpApiSecurity.ts +1 -1
  199. package/src/HttpApiSwagger.ts +3 -3
  200. package/src/HttpBody.ts +2 -2
  201. package/src/HttpClientRequest.ts +2 -2
  202. package/src/HttpClientResponse.ts +3 -3
  203. package/src/HttpIncomingMessage.ts +3 -3
  204. package/src/HttpRouter.ts +3 -3
  205. package/src/HttpServer.ts +21 -0
  206. package/src/HttpServerRequest.ts +3 -3
  207. package/src/HttpServerRespondable.ts +1 -1
  208. package/src/HttpServerResponse.ts +2 -2
  209. package/src/KeyValueStore.ts +2 -2
  210. package/src/Multipart.ts +3 -3
  211. package/src/OpenApi.ts +113 -104
  212. package/src/OpenApiJsonSchema.ts +67 -53
  213. package/src/Transferable.ts +2 -2
  214. package/src/UrlParams.ts +3 -3
  215. package/src/Worker.ts +7 -8
  216. package/src/WorkerError.ts +1 -1
  217. package/src/WorkerRunner.ts +2 -3
  218. package/src/index.ts +5 -0
  219. package/src/internal/httpBody.ts +2 -2
  220. package/src/internal/httpClientRequest.ts +2 -2
  221. package/src/internal/httpClientResponse.ts +3 -3
  222. package/src/internal/httpRouter.ts +2 -2
  223. package/src/internal/httpServer.ts +13 -0
  224. package/src/internal/httpServerRequest.ts +3 -3
  225. package/src/internal/httpServerResponse.ts +2 -2
  226. package/src/internal/keyValueStore.ts +1 -1
  227. package/src/internal/multipart.ts +3 -3
  228. package/src/internal/worker.ts +6 -7
  229. package/src/internal/workerRunner.ts +3 -4
@@ -0,0 +1,317 @@
1
+ /**
2
+ * @since 1.0.0
3
+ */
4
+ import * as Context from "effect/Context"
5
+ import type * as Effect from "effect/Effect"
6
+ import { hasProperty } from "effect/Predicate"
7
+ import * as Schema from "effect/Schema"
8
+ import type { Mutable, Simplify } from "effect/Types"
9
+ import type * as HttpApiSecurity from "./HttpApiSecurity.js"
10
+ import type * as HttpRouter from "./HttpRouter.js"
11
+
12
+ /**
13
+ * @since 1.0.0
14
+ * @category type ids
15
+ */
16
+ export const TypeId: unique symbol = Symbol.for("@effect/platform/HttpApiMiddleware")
17
+
18
+ /**
19
+ * @since 1.0.0
20
+ * @category type ids
21
+ */
22
+ export type TypeId = typeof TypeId
23
+
24
+ /**
25
+ * @since 1.0.0
26
+ * @category type ids
27
+ */
28
+ export const SecurityTypeId: unique symbol = Symbol.for("@effect/platform/HttpApiMiddleware/Security")
29
+
30
+ /**
31
+ * @since 1.0.0
32
+ * @category type ids
33
+ */
34
+ export type SecurityTypeId = typeof SecurityTypeId
35
+
36
+ /**
37
+ * @since 1.0.0
38
+ * @category guards
39
+ */
40
+ export const isSecurity = (u: TagClassAny): u is TagClassSecurityAny => hasProperty(u, SecurityTypeId)
41
+
42
+ /**
43
+ * @since 1.0.0
44
+ * @category models
45
+ */
46
+ export interface HttpApiMiddleware<Provides, E> extends Effect.Effect<Provides, E, HttpRouter.HttpRouter.Provided> {}
47
+
48
+ /**
49
+ * @since 1.0.0
50
+ * @category models
51
+ */
52
+ export type HttpApiMiddlewareSecurity<Security extends Record<string, HttpApiSecurity.HttpApiSecurity>, Provides, E> = {
53
+ readonly [K in keyof Security]: (
54
+ _: HttpApiSecurity.HttpApiSecurity.Type<Security[K]>
55
+ ) => Effect.Effect<Provides, E, HttpRouter.HttpRouter.Provided>
56
+ }
57
+
58
+ /**
59
+ * @since 1.0.0
60
+ * @category models
61
+ */
62
+ export declare namespace HttpApiMiddleware {
63
+ /**
64
+ * @since 1.0.0
65
+ * @category models
66
+ */
67
+ export interface Any {
68
+ readonly [TypeId]: TypeId
69
+ }
70
+
71
+ /**
72
+ * @since 1.0.0
73
+ * @category models
74
+ */
75
+ export interface AnyId {
76
+ readonly [TypeId]: {
77
+ readonly provides: any
78
+ }
79
+ }
80
+
81
+ /**
82
+ * @since 1.0.0
83
+ * @category models
84
+ */
85
+ export type Provides<A> = A extends { readonly [TypeId]: { readonly provides: infer P } } ? P : never
86
+
87
+ /**
88
+ * @since 1.0.0
89
+ * @category models
90
+ */
91
+ export type ExtractProvides<A> = Provides<Only<A>>
92
+
93
+ /**
94
+ * @since 1.0.0
95
+ * @category models
96
+ */
97
+ export type Error<A> = A extends { readonly [TypeId]: { readonly failure: infer E } } ? E : never
98
+
99
+ /**
100
+ * @since 1.0.0
101
+ * @category models
102
+ */
103
+ export type ErrorContext<A> = A extends { readonly [TypeId]: { readonly failureContext: infer R } } ? R : never
104
+
105
+ /**
106
+ * @since 1.0.0
107
+ * @category models
108
+ */
109
+ export type Only<R> = Extract<R, AnyId>
110
+
111
+ /**
112
+ * @since 1.0.0
113
+ * @category models
114
+ */
115
+ export type Without<R> = Exclude<R, AnyId>
116
+ }
117
+
118
+ /**
119
+ * @since 1.0.0
120
+ * @category models
121
+ */
122
+ export type TagClass<
123
+ Self,
124
+ Name extends string,
125
+ Options
126
+ > = Options extends { readonly security: Record<string, HttpApiSecurity.HttpApiSecurity> } ? TagClass.BaseSecurity<
127
+ Self,
128
+ Name,
129
+ Options,
130
+ Simplify<
131
+ HttpApiMiddlewareSecurity<
132
+ Options["security"],
133
+ TagClass.Service<Options>,
134
+ TagClass.FailureService<Options>
135
+ >
136
+ >,
137
+ Options["security"]
138
+ >
139
+ : TagClass.Base<
140
+ Self,
141
+ Name,
142
+ Options,
143
+ HttpApiMiddleware<
144
+ TagClass.Service<Options>,
145
+ TagClass.FailureService<Options>
146
+ >
147
+ >
148
+
149
+ /**
150
+ * @since 1.0.0
151
+ * @category models
152
+ */
153
+ export declare namespace TagClass {
154
+ /**
155
+ * @since 1.0.0
156
+ * @category models
157
+ */
158
+ export type Provides<Options> = Options extends {
159
+ readonly provides: Context.Tag<any, any>
160
+ readonly optional?: false
161
+ } ? Context.Tag.Identifier<Options["provides"]>
162
+ : never
163
+
164
+ /**
165
+ * @since 1.0.0
166
+ * @category models
167
+ */
168
+ export type Service<Options> = Options extends { readonly provides: Context.Tag<any, any> }
169
+ ? Context.Tag.Service<Options["provides"]>
170
+ : void
171
+
172
+ /**
173
+ * @since 1.0.0
174
+ * @category models
175
+ */
176
+ export type FailureSchema<Options> = Options extends
177
+ { readonly failure: Schema.Schema.All; readonly optional?: false } ? Options["failure"]
178
+ : typeof Schema.Never
179
+
180
+ /**
181
+ * @since 1.0.0
182
+ * @category models
183
+ */
184
+ export type Failure<Options> = Options extends
185
+ { readonly failure: Schema.Schema<infer _A, infer _I, infer _R>; readonly optional?: false } ? _A
186
+ : never
187
+
188
+ /**
189
+ * @since 1.0.0
190
+ * @category models
191
+ */
192
+ export type FailureContext<Options> = Schema.Schema.Context<FailureSchema<Options>>
193
+
194
+ /**
195
+ * @since 1.0.0
196
+ * @category models
197
+ */
198
+ export type FailureService<Options> = Optional<Options> extends true ? unknown : Failure<Options>
199
+
200
+ /**
201
+ * @since 1.0.0
202
+ * @category models
203
+ */
204
+ export type Optional<Options> = Options extends { readonly optional: true } ? true : false
205
+
206
+ /**
207
+ * @since 1.0.0
208
+ * @category models
209
+ */
210
+ export interface Base<Self, Name extends string, Options, Service> extends Context.Tag<Self, Service> {
211
+ new(_: never):
212
+ & Context.TagClassShape<Name, Service>
213
+ & {
214
+ readonly [TypeId]: {
215
+ readonly provides: Provides<Options>
216
+ readonly failure: Failure<Options>
217
+ readonly failureContext: FailureContext<Options>
218
+ }
219
+ }
220
+ readonly [TypeId]: TypeId
221
+ readonly optional: Optional<Options>
222
+ readonly failure: FailureSchema<Options>
223
+ readonly provides: Options extends { readonly provides: Context.Tag<any, any> } ? Options["provides"]
224
+ : undefined
225
+ }
226
+
227
+ /**
228
+ * @since 1.0.0
229
+ * @category models
230
+ */
231
+ export interface BaseSecurity<
232
+ Self,
233
+ Name extends string,
234
+ Options,
235
+ Service,
236
+ Security extends Record<string, HttpApiSecurity.HttpApiSecurity>
237
+ > extends Base<Self, Name, Options, Service> {
238
+ readonly [SecurityTypeId]: SecurityTypeId
239
+ readonly security: Security
240
+ }
241
+ }
242
+
243
+ /**
244
+ * @since 1.0.0
245
+ * @category models
246
+ */
247
+ export interface TagClassAny extends Context.Tag<any, HttpApiMiddleware.Any> {
248
+ readonly [TypeId]: TypeId
249
+ readonly optional: boolean
250
+ readonly provides?: Context.Tag<any, any>
251
+ readonly failure: Schema.Schema.All
252
+ }
253
+
254
+ /**
255
+ * @since 1.0.0
256
+ * @category models
257
+ */
258
+ export interface TagClassSecurityAny extends TagClassAny {
259
+ readonly [SecurityTypeId]: SecurityTypeId
260
+ readonly security: Record<string, HttpApiSecurity.HttpApiSecurity>
261
+ }
262
+
263
+ /**
264
+ * @since 1.0.0
265
+ * @category tags
266
+ */
267
+ export const Tag = <Self>(): <
268
+ const Name extends string,
269
+ const Options extends {
270
+ readonly optional?: boolean
271
+ readonly failure?: Schema.Schema.All
272
+ readonly provides?: Context.Tag<any, any>
273
+ readonly security?: Record<string, HttpApiSecurity.HttpApiSecurity>
274
+ }
275
+ >(
276
+ id: Name,
277
+ options?: Options | undefined
278
+ ) => TagClass<Self, Name, Options> =>
279
+ (
280
+ id: string,
281
+ options?: {
282
+ readonly optional?: boolean
283
+ readonly security?: Record<string, HttpApiSecurity.HttpApiSecurity>
284
+ readonly failure?: Schema.Schema.All
285
+ readonly provides?: Context.Tag<any, any>
286
+ }
287
+ ) => {
288
+ const Err = globalThis.Error as any
289
+ const limit = Err.stackTraceLimit
290
+ Err.stackTraceLimit = 2
291
+ const creationError = new Err()
292
+ Err.stackTraceLimit = limit
293
+
294
+ function TagClass() {}
295
+ const TagClass_ = TagClass as any as Mutable<TagClassSecurityAny>
296
+ Object.setPrototypeOf(TagClass, Object.getPrototypeOf(Context.GenericTag<Self, any>(id)))
297
+ TagClass.key = id
298
+ Object.defineProperty(TagClass, "stack", {
299
+ get() {
300
+ return creationError.stack
301
+ }
302
+ })
303
+ TagClass_[TypeId] = TypeId
304
+ TagClass_.failure = options?.optional === true || options?.failure === undefined ? Schema.Never : options.failure
305
+ if (options?.provides) {
306
+ TagClass_.provides = options.provides
307
+ }
308
+ TagClass_.optional = options?.optional ?? false
309
+ if (options?.security) {
310
+ if (Object.keys(options.security).length === 0) {
311
+ throw new Error("HttpApiMiddleware.Tag: security object must not be empty")
312
+ }
313
+ TagClass_[SecurityTypeId] = SecurityTypeId
314
+ TagClass_.security = options.security
315
+ }
316
+ return TagClass as any
317
+ }
@@ -1,11 +1,12 @@
1
1
  /**
2
2
  * @since 1.0.0
3
3
  */
4
- import * as AST from "@effect/schema/AST"
5
- import * as Schema from "@effect/schema/Schema"
6
4
  import type { Brand } from "effect/Brand"
7
5
  import type { LazyArg } from "effect/Function"
8
6
  import { constVoid, dual } from "effect/Function"
7
+ import { globalValue } from "effect/GlobalValue"
8
+ import * as Schema from "effect/Schema"
9
+ import * as AST from "effect/SchemaAST"
9
10
  import * as Struct from "effect/Struct"
10
11
 
11
12
  /**
@@ -400,3 +401,39 @@ export const Text = (options?: {
400
401
  export const Uint8Array = (options?: {
401
402
  readonly contentType?: string
402
403
  }): typeof Schema.Uint8ArrayFromSelf => withEncoding(Schema.Uint8ArrayFromSelf, { kind: "Uint8Array", ...options })
404
+
405
+ const astCache = globalValue(
406
+ "@effect/platform/HttpApiSchema/astCache",
407
+ () => new WeakMap<AST.AST, Schema.Schema.Any>()
408
+ )
409
+
410
+ /**
411
+ * @since 1.0.0
412
+ */
413
+ export const deunionize = (
414
+ schemas: Set<Schema.Schema.Any>,
415
+ schema: Schema.Schema.Any
416
+ ): void => {
417
+ if (astCache.has(schema.ast)) {
418
+ schemas.add(astCache.get(schema.ast)!)
419
+ return
420
+ }
421
+ const ast = schema.ast
422
+ if (ast._tag === "Union") {
423
+ for (const astType of ast.types) {
424
+ if (astCache.has(astType)) {
425
+ schemas.add(astCache.get(astType)!)
426
+ continue
427
+ }
428
+ const memberSchema = Schema.make(AST.annotations(astType, {
429
+ ...ast.annotations,
430
+ ...astType.annotations
431
+ }))
432
+ astCache.set(astType, memberSchema)
433
+ schemas.add(memberSchema)
434
+ }
435
+ } else {
436
+ astCache.set(ast, schema)
437
+ schemas.add(schema)
438
+ }
439
+ }
@@ -140,7 +140,7 @@ export const basic: Basic = Object.assign(Object.create(Proto), {
140
140
  * @since 1.0.0
141
141
  * @category annotations
142
142
  */
143
- export const annotateMerge: {
143
+ export const annotateContext: {
144
144
  /**
145
145
  * @since 1.0.0
146
146
  * @category annotations
@@ -3,7 +3,7 @@
3
3
  */
4
4
  import * as Effect from "effect/Effect"
5
5
  import type { Layer } from "effect/Layer"
6
- import { HttpApi } from "./HttpApi.js"
6
+ import { Api } from "./HttpApi.js"
7
7
  import { Router } from "./HttpApiBuilder.js"
8
8
  import * as HttpServerResponse from "./HttpServerResponse.js"
9
9
  import * as internal from "./internal/apiSwagger.js"
@@ -15,10 +15,10 @@ import * as OpenApi from "./OpenApi.js"
15
15
  */
16
16
  export const layer = (options?: {
17
17
  readonly path?: `/${string}` | undefined
18
- }): Layer<never, never, HttpApi.Service> =>
18
+ }): Layer<never, never, Api> =>
19
19
  Router.use((router) =>
20
20
  Effect.gen(function*() {
21
- const api = yield* HttpApi
21
+ const { api } = yield* Api
22
22
  const spec = OpenApi.fromApi(api)
23
23
  const response = HttpServerResponse.html(`<!DOCTYPE html>
24
24
  <html lang="en">
package/src/HttpBody.ts CHANGED
@@ -1,11 +1,11 @@
1
1
  /**
2
2
  * @since 1.0.0
3
3
  */
4
- import type * as ParseResult from "@effect/schema/ParseResult"
5
- import type * as Schema from "@effect/schema/Schema"
6
4
  import type * as Effect from "effect/Effect"
7
5
  import type { Inspectable } from "effect/Inspectable"
6
+ import type * as ParseResult from "effect/ParseResult"
8
7
  import * as Predicate from "effect/Predicate"
8
+ import type * as Schema from "effect/Schema"
9
9
  import type * as Stream_ from "effect/Stream"
10
10
  import type * as PlatformError from "./Error.js"
11
11
  import type * as FileSystem from "./FileSystem.js"
@@ -1,13 +1,13 @@
1
1
  /**
2
2
  * @since 1.0.0
3
3
  */
4
- import type { ParseOptions } from "@effect/schema/AST"
5
- import type * as Schema from "@effect/schema/Schema"
6
4
  import type * as Effect from "effect/Effect"
7
5
  import type { Inspectable } from "effect/Inspectable"
8
6
  import type * as Option from "effect/Option"
9
7
  import type { Pipeable } from "effect/Pipeable"
10
8
  import type { Redacted } from "effect/Redacted"
9
+ import type * as Schema from "effect/Schema"
10
+ import type { ParseOptions } from "effect/SchemaAST"
11
11
  import type * as Stream from "effect/Stream"
12
12
  import type * as PlatformError from "./Error.js"
13
13
  import type * as FileSystem from "./FileSystem.js"
@@ -1,10 +1,10 @@
1
1
  /**
2
2
  * @since 1.0.0
3
3
  */
4
- import type { ParseOptions } from "@effect/schema/AST"
5
- import type * as ParseResult from "@effect/schema/ParseResult"
6
- import type * as Schema from "@effect/schema/Schema"
7
4
  import type * as Effect from "effect/Effect"
5
+ import type * as ParseResult from "effect/ParseResult"
6
+ import type * as Schema from "effect/Schema"
7
+ import type { ParseOptions } from "effect/SchemaAST"
8
8
  import type * as Scope from "effect/Scope"
9
9
  import type * as Stream from "effect/Stream"
10
10
  import type { Unify } from "effect/Unify"
@@ -1,15 +1,15 @@
1
1
  /**
2
2
  * @since 1.0.0
3
3
  */
4
- import type { ParseOptions } from "@effect/schema/AST"
5
- import type * as ParseResult from "@effect/schema/ParseResult"
6
- import * as Schema from "@effect/schema/Schema"
7
4
  import * as Effect from "effect/Effect"
8
5
  import * as FiberRef from "effect/FiberRef"
9
6
  import { dual } from "effect/Function"
10
7
  import * as Global from "effect/GlobalValue"
11
8
  import type { Inspectable } from "effect/Inspectable"
12
9
  import * as Option from "effect/Option"
10
+ import type * as ParseResult from "effect/ParseResult"
11
+ import * as Schema from "effect/Schema"
12
+ import type { ParseOptions } from "effect/SchemaAST"
13
13
  import type * as Stream from "effect/Stream"
14
14
  import * as FileSystem from "./FileSystem.js"
15
15
  import type * as Headers from "./Headers.js"
package/src/HttpRouter.ts CHANGED
@@ -1,9 +1,6 @@
1
1
  /**
2
2
  * @since 1.0.0
3
3
  */
4
- import type { ParseOptions } from "@effect/schema/AST"
5
- import type * as ParseResult from "@effect/schema/ParseResult"
6
- import type * as Schema from "@effect/schema/Schema"
7
4
  import type * as Cause from "effect/Cause"
8
5
  import type * as Chunk from "effect/Chunk"
9
6
  import type * as Context from "effect/Context"
@@ -12,6 +9,9 @@ import type { FiberRef } from "effect/FiberRef"
12
9
  import type { Inspectable } from "effect/Inspectable"
13
10
  import type * as Layer from "effect/Layer"
14
11
  import type * as Option from "effect/Option"
12
+ import type * as ParseResult from "effect/ParseResult"
13
+ import type * as Schema from "effect/Schema"
14
+ import type { ParseOptions } from "effect/SchemaAST"
15
15
  import type * as Scope from "effect/Scope"
16
16
  import type { RouterConfig } from "find-my-way-ts"
17
17
  import type * as Etag from "./Etag.js"
package/src/HttpServer.ts CHANGED
@@ -5,11 +5,15 @@ import type * as Context from "effect/Context"
5
5
  import type * as Effect from "effect/Effect"
6
6
  import type * as Layer from "effect/Layer"
7
7
  import type * as Scope from "effect/Scope"
8
+ import type { Generator } from "./Etag.js"
9
+ import type { FileSystem } from "./FileSystem.js"
8
10
  import type * as App from "./HttpApp.js"
9
11
  import type * as Client from "./HttpClient.js"
10
12
  import type * as Middleware from "./HttpMiddleware.js"
13
+ import type { HttpPlatform } from "./HttpPlatform.js"
11
14
  import type * as ServerRequest from "./HttpServerRequest.js"
12
15
  import * as internal from "./internal/httpServer.js"
16
+ import type { Path } from "./Path.js"
13
17
 
14
18
  /**
15
19
  * @since 1.0.0
@@ -231,3 +235,20 @@ export const withLogAddress: <A, E, R>(layer: Layer.Layer<A, E, R>) => Layer.Lay
231
235
  */
232
236
  export const layerTestClient: Layer.Layer<Client.HttpClient, never, Client.HttpClient | HttpServer> =
233
237
  internal.layerTestClient
238
+
239
+ /**
240
+ * A Layer providing the `HttpPlatform`, `FileSystem`, `Etag.Generator`, and `Path`
241
+ * services.
242
+ *
243
+ * The `FileSystem` service is a no-op implementation, so this layer is only
244
+ * useful for platforms that have no file system.
245
+ *
246
+ * @since 1.0.0
247
+ * @category layers
248
+ */
249
+ export const layerContext: Layer.Layer<
250
+ | HttpPlatform
251
+ | FileSystem
252
+ | Generator
253
+ | Path
254
+ > = internal.layerContext
@@ -1,15 +1,15 @@
1
1
  /**
2
2
  * @since 1.0.0
3
3
  */
4
- import type { ParseOptions } from "@effect/schema/AST"
5
- import type * as ParseResult from "@effect/schema/ParseResult"
6
- import type * as Schema from "@effect/schema/Schema"
7
4
  import type { Channel } from "effect/Channel"
8
5
  import type { Chunk } from "effect/Chunk"
9
6
  import type * as Context from "effect/Context"
10
7
  import type * as Effect from "effect/Effect"
11
8
  import type { Option } from "effect/Option"
9
+ import type * as ParseResult from "effect/ParseResult"
12
10
  import type { ReadonlyRecord } from "effect/Record"
11
+ import type * as Schema from "effect/Schema"
12
+ import type { ParseOptions } from "effect/SchemaAST"
13
13
  import type * as Scope from "effect/Scope"
14
14
  import type * as Stream from "effect/Stream"
15
15
  import type * as FileSystem from "./FileSystem.js"
@@ -1,9 +1,9 @@
1
1
  /**
2
2
  * @since 1.0.0
3
3
  */
4
- import * as ParseResult from "@effect/schema/ParseResult"
5
4
  import * as Cause from "effect/Cause"
6
5
  import * as Effect from "effect/Effect"
6
+ import * as ParseResult from "effect/ParseResult"
7
7
  import { hasProperty } from "effect/Predicate"
8
8
  import type { HttpServerResponse } from "./HttpServerResponse.js"
9
9
  import * as ServerResponse from "./HttpServerResponse.js"
@@ -1,11 +1,11 @@
1
1
  /**
2
2
  * @since 1.0.0
3
3
  */
4
- import type { ParseOptions } from "@effect/schema/AST"
5
- import type * as Schema from "@effect/schema/Schema"
6
4
  import type * as Effect from "effect/Effect"
7
5
  import type { Inspectable } from "effect/Inspectable"
8
6
  import type * as Runtime from "effect/Runtime"
7
+ import type * as Schema from "effect/Schema"
8
+ import type { ParseOptions } from "effect/SchemaAST"
9
9
  import type * as Stream from "effect/Stream"
10
10
  import type { Cookie, Cookies, CookiesError } from "./Cookies.js"
11
11
  import type * as PlatformError from "./Error.js"
@@ -1,13 +1,13 @@
1
1
  /**
2
2
  * @since 1.0.0
3
3
  */
4
- import type * as ParseResult from "@effect/schema/ParseResult"
5
- import type * as Schema from "@effect/schema/Schema"
6
4
  import type * as Context from "effect/Context"
7
5
  import type * as Effect from "effect/Effect"
8
6
  import type { LazyArg } from "effect/Function"
9
7
  import type * as Layer from "effect/Layer"
10
8
  import type * as Option from "effect/Option"
9
+ import type * as ParseResult from "effect/ParseResult"
10
+ import type * as Schema from "effect/Schema"
11
11
  import type * as PlatformError from "./Error.js"
12
12
  import type * as FileSystem from "./FileSystem.js"
13
13
  import * as internal from "./internal/keyValueStore.js"
package/src/Multipart.ts CHANGED
@@ -1,9 +1,6 @@
1
1
  /**
2
2
  * @since 1.0.0
3
3
  */
4
- import type { ParseOptions } from "@effect/schema/AST"
5
- import type * as ParseResult from "@effect/schema/ParseResult"
6
- import type * as Schema from "@effect/schema/Schema"
7
4
  import type { YieldableError } from "effect/Cause"
8
5
  import type * as Channel from "effect/Channel"
9
6
  import type * as Chunk from "effect/Chunk"
@@ -11,6 +8,9 @@ import type * as Effect from "effect/Effect"
11
8
  import type * as FiberRef from "effect/FiberRef"
12
9
  import type { Inspectable } from "effect/Inspectable"
13
10
  import type * as Option from "effect/Option"
11
+ import type * as ParseResult from "effect/ParseResult"
12
+ import type * as Schema from "effect/Schema"
13
+ import type { ParseOptions } from "effect/SchemaAST"
14
14
  import type * as Scope from "effect/Scope"
15
15
  import type * as Stream from "effect/Stream"
16
16
  import type * as Multipasta from "multipasta"