@effect/platform 0.68.5 → 0.69.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.
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 +243 -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 +84 -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 +231 -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 +236 -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 +532 -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 +318 -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
@@ -1,12 +1,14 @@
1
1
  /**
2
2
  * @since 1.0.0
3
3
  */
4
- import * as Schema from "@effect/schema/Schema";
5
- import * as Chunk from "effect/Chunk";
6
4
  import * as Context from "effect/Context";
5
+ import * as HashMap from "effect/HashMap";
6
+ import * as HashSet from "effect/HashSet";
7
7
  import { type Pipeable } from "effect/Pipeable";
8
- import * as HttpApiEndpoint from "./HttpApiEndpoint.js";
8
+ import * as Schema from "effect/Schema";
9
+ import type * as HttpApiEndpoint from "./HttpApiEndpoint.js";
9
10
  import type { HttpApiDecodeError } from "./HttpApiError.js";
11
+ import type * as HttpApiMiddleware from "./HttpApiMiddleware.js";
10
12
  import type { PathInput } from "./HttpRouter.js";
11
13
  /**
12
14
  * @since 1.0.0
@@ -32,265 +34,165 @@ export declare const isHttpApiGroup: (u: unknown) => u is HttpApiGroup.Any;
32
34
  * @since 1.0.0
33
35
  * @category models
34
36
  */
35
- export interface HttpApiGroup<out Name extends string, out Endpoints extends HttpApiEndpoint.HttpApiEndpoint.All = never, in out Error = HttpApiDecodeError, out ErrorR = never> extends Pipeable {
37
+ export interface HttpApiGroup<out Id extends string, out Endpoints extends HttpApiEndpoint.HttpApiEndpoint.Any = never, in out Error = HttpApiDecodeError, out R = never, out TopLevel extends (true | false) = false> extends Pipeable {
36
38
  new (_: never): {};
37
39
  readonly [TypeId]: TypeId;
38
- readonly identifier: Name;
39
- readonly endpoints: Chunk.Chunk<Endpoints>;
40
- readonly errorSchema: Schema.Schema<Error, unknown, ErrorR>;
40
+ readonly identifier: Id;
41
+ readonly topLevel: TopLevel;
42
+ readonly endpoints: HashMap.HashMap<string, Endpoints>;
43
+ readonly errorSchema: Schema.Schema<Error, unknown, R>;
41
44
  readonly annotations: Context.Context<never>;
42
- }
43
- /**
44
- * @since 1.0.0
45
- * @category models
46
- */
47
- export declare namespace HttpApiGroup {
45
+ readonly middlewares: HashSet.HashSet<HttpApiMiddleware.TagClassAny>;
48
46
  /**
49
- * @since 1.0.0
50
- * @category models
51
- */
52
- type Any = HttpApiGroup<any, any, any, any> | HttpApiGroup<any, any, any, never> | HttpApiGroup<any, any, never, never>;
53
- /**
54
- * @since 1.0.0
55
- * @category models
47
+ * Add an `HttpApiEndpoint` to an `HttpApiGroup`.
56
48
  */
57
- interface Service<Name extends string> {
58
- readonly _: unique symbol;
59
- readonly name: Name;
60
- }
49
+ add<A extends HttpApiEndpoint.HttpApiEndpoint.Any>(endpoint: A): HttpApiGroup<Id, Endpoints | A, Error, R, TopLevel>;
61
50
  /**
62
- * @since 1.0.0
63
- * @category models
51
+ * Add an error schema to an `HttpApiGroup`, which is shared by all endpoints in the
52
+ * group.
64
53
  */
65
- type ToService<Group> = Group extends HttpApiGroup<infer Name, infer _Endpoints, infer _Error, infer _ErrorR> ? Service<Name> : never;
54
+ addError<A, I, R>(schema: Schema.Schema<A, I, R>, annotations?: {
55
+ readonly status?: number | undefined;
56
+ }): HttpApiGroup<Id, Endpoints, Error | A, R | R, TopLevel>;
66
57
  /**
67
- * @since 1.0.0
68
- * @category models
58
+ * Add a path prefix to all endpoints in an `HttpApiGroup`. Note that this will only
59
+ * add the prefix to the endpoints before this api is called.
69
60
  */
70
- type WithName<Group, Name extends string> = Extract<Group, {
71
- readonly identifier: Name;
72
- }>;
61
+ prefix(prefix: PathInput): HttpApiGroup<Id, Endpoints, Error, R, TopLevel>;
73
62
  /**
74
- * @since 1.0.0
75
- * @category models
63
+ * Add an `HttpApiMiddleware` to the `HttpApiGroup`.
64
+ *
65
+ * It will be applied to all endpoints in the group.
76
66
  */
77
- type Endpoints<Group> = Group extends HttpApiGroup<infer _Name, infer _Endpoints, infer _Error, infer _ErrorR> ? _Endpoints : never;
67
+ middleware<I extends HttpApiMiddleware.HttpApiMiddleware.AnyId, S>(middleware: Context.Tag<I, S>): HttpApiGroup<Id, Endpoints, Error | HttpApiMiddleware.HttpApiMiddleware.Error<I>, R | I | HttpApiMiddleware.HttpApiMiddleware.ErrorContext<I>, TopLevel>;
78
68
  /**
79
- * @since 1.0.0
80
- * @category models
69
+ * Add an `HttpApiMiddleware` to each endpoint in the `HttpApiGroup`.
70
+ *
71
+ * Endpoints added after this api is called will not have the middleware
72
+ * applied.
81
73
  */
82
- type EndpointsWithName<Group extends Any, Name extends string> = Endpoints<WithName<Group, Name>>;
74
+ middlewareEndpoints<I extends HttpApiMiddleware.HttpApiMiddleware.AnyId, S>(middleware: Context.Tag<I, S>): HttpApiGroup<Id, HttpApiEndpoint.HttpApiEndpoint.AddContext<Endpoints, I>, Error, R, TopLevel>;
83
75
  /**
84
- * @since 1.0.0
85
- * @category models
76
+ * Merge the annotations of an `HttpApiGroup` with a new context.
86
77
  */
87
- type Error<Group> = Group extends HttpApiGroup<infer _Name, infer _Endpoints, infer _Error, infer _ErrorR> ? _Error : never;
78
+ annotateContext<I>(context: Context.Context<I>): HttpApiGroup<Id, Endpoints, Error, R, TopLevel>;
88
79
  /**
89
- * @since 1.0.0
90
- * @category models
80
+ * Add an annotation to an `HttpApiGroup`.
91
81
  */
92
- type ErrorWithName<Group extends Any, Name extends string> = Error<WithName<Group, Name>>;
82
+ annotate<I, S>(tag: Context.Tag<I, S>, value: S): HttpApiGroup<Id, Endpoints, Error, R, TopLevel>;
93
83
  /**
94
- * @since 1.0.0
95
- * @category models
84
+ * For each endpoint in an `HttpApiGroup`, update the annotations with a new
85
+ * context.
86
+ *
87
+ * Note that this will only update the annotations before this api is called.
96
88
  */
97
- type Context<Group> = Group extends HttpApiGroup<infer _Name, infer _Endpoints, infer _Error, infer _ErrorR> ? _ErrorR | HttpApiEndpoint.HttpApiEndpoint.Context<_Endpoints> : never;
89
+ annotateEndpointsContext<I>(context: Context.Context<I>): HttpApiGroup<Id, Endpoints, Error, R, TopLevel>;
98
90
  /**
99
- * @since 1.0.0
100
- * @category models
91
+ * For each endpoint in an `HttpApiGroup`, add an annotation.
92
+ *
93
+ * Note that this will only add the annotation to the endpoints before this api
94
+ * is called.
101
95
  */
102
- type ContextWithName<Group extends Any, Name extends string> = Context<WithName<Group, Name>>;
96
+ annotateEndpoints<I, S>(tag: Context.Tag<I, S>, value: S): HttpApiGroup<Id, Endpoints, Error, R, TopLevel>;
103
97
  }
104
98
  /**
105
- * An `HttpApiGroup` is a collection of `HttpApiEndpoint`s. You can use an `HttpApiGroup` to
106
- * represent a portion of your domain.
107
- *
108
- * The endpoints can be implemented later using the `HttpApiBuilder.group` api.
109
- *
110
99
  * @since 1.0.0
111
- * @category constructors
100
+ * @category models
112
101
  */
113
- export declare const make: <Name extends string>(identifier: Name) => HttpApiGroup<Name>;
102
+ export interface Group<Name extends string> {
103
+ readonly _: unique symbol;
104
+ readonly name: Name;
105
+ }
114
106
  /**
115
- * Add an `HttpApiEndpoint` to an `HttpApiGroup`.
116
- *
117
107
  * @since 1.0.0
118
- * @category endpoints
108
+ * @category models
119
109
  */
120
- export declare const add: {
110
+ export declare namespace HttpApiGroup {
121
111
  /**
122
- * Add an `HttpApiEndpoint` to an `HttpApiGroup`.
123
- *
124
112
  * @since 1.0.0
125
- * @category endpoints
113
+ * @category models
126
114
  */
127
- <A extends HttpApiEndpoint.HttpApiEndpoint.All>(endpoint: A): <Name extends string, Endpoints extends HttpApiEndpoint.HttpApiEndpoint.All, Error, ErrorR>(self: HttpApiGroup<Name, Endpoints, Error, ErrorR>) => HttpApiGroup<Name, Endpoints | A, Error, ErrorR>;
115
+ interface Any {
116
+ readonly [TypeId]: TypeId;
117
+ }
128
118
  /**
129
- * Add an `HttpApiEndpoint` to an `HttpApiGroup`.
130
- *
131
119
  * @since 1.0.0
132
- * @category endpoints
120
+ * @category models
133
121
  */
134
- <Name extends string, Endpoints extends HttpApiEndpoint.HttpApiEndpoint.All, Error, ErrorR, A extends HttpApiEndpoint.HttpApiEndpoint.All>(self: HttpApiGroup<Name, Endpoints, Error, ErrorR>, endpoint: A): HttpApiGroup<Name, Endpoints | A, Error, ErrorR>;
135
- };
136
- /**
137
- * Add an error schema to an `HttpApiGroup`, which is shared by all endpoints in the
138
- * group.
139
- *
140
- * @since 1.0.0
141
- * @category errors
142
- */
143
- export declare const addError: {
122
+ type AnyWithProps = HttpApiGroup<string, HttpApiEndpoint.HttpApiEndpoint.AnyWithProps, any, any, boolean>;
144
123
  /**
145
- * Add an error schema to an `HttpApiGroup`, which is shared by all endpoints in the
146
- * group.
147
- *
148
124
  * @since 1.0.0
149
- * @category errors
125
+ * @category models
150
126
  */
151
- <A, I, R>(schema: Schema.Schema<A, I, R>, annotations?: {
152
- readonly status?: number | undefined;
153
- }): <Name extends string, Endpoints extends HttpApiEndpoint.HttpApiEndpoint.All, Error, ErrorR>(self: HttpApiGroup<Name, Endpoints, Error, ErrorR>) => HttpApiGroup<Name, Endpoints, Error | A, ErrorR | R>;
127
+ type ToService<A> = A extends HttpApiGroup<infer Name, infer _Endpoints, infer _Error, infer _R, infer _TopLevel> ? Group<Name> : never;
154
128
  /**
155
- * Add an error schema to an `HttpApiGroup`, which is shared by all endpoints in the
156
- * group.
157
- *
158
129
  * @since 1.0.0
159
- * @category errors
130
+ * @category models
160
131
  */
161
- <Name extends string, Endpoints extends HttpApiEndpoint.HttpApiEndpoint.All, Error, ErrorR, A, I, R>(self: HttpApiGroup<Name, Endpoints, Error, ErrorR>, schema: Schema.Schema<A, I, R>, annotations?: {
162
- readonly status?: number | undefined;
163
- }): HttpApiGroup<Name, Endpoints, Error | A, ErrorR | R>;
164
- };
165
- /**
166
- * Add a path prefix to all endpoints in an `HttpApiGroup`. Note that this will only
167
- * add the prefix to the endpoints before this api is called.
168
- *
169
- * @since 1.0.0
170
- * @category endpoints
171
- */
172
- export declare const prefix: {
132
+ type WithName<Group, Name extends string> = Extract<Group, {
133
+ readonly identifier: Name;
134
+ }>;
173
135
  /**
174
- * Add a path prefix to all endpoints in an `HttpApiGroup`. Note that this will only
175
- * add the prefix to the endpoints before this api is called.
176
- *
177
136
  * @since 1.0.0
178
- * @category endpoints
137
+ * @category models
179
138
  */
180
- (prefix: PathInput): <Name extends string, Endpoints extends HttpApiEndpoint.HttpApiEndpoint.All, Error, ErrorR>(self: HttpApiGroup<Name, Endpoints, Error, ErrorR>) => HttpApiGroup<Name, Endpoints, Error, ErrorR>;
139
+ type Name<Group> = Group extends HttpApiGroup<infer _Name, infer _Endpoints, infer _Error, infer _R, infer _TopLevel> ? _Name : never;
181
140
  /**
182
- * Add a path prefix to all endpoints in an `HttpApiGroup`. Note that this will only
183
- * add the prefix to the endpoints before this api is called.
184
- *
185
141
  * @since 1.0.0
186
- * @category endpoints
142
+ * @category models
187
143
  */
188
- <Name extends string, Endpoints extends HttpApiEndpoint.HttpApiEndpoint.All, Error, ErrorR>(self: HttpApiGroup<Name, Endpoints, Error, ErrorR>, prefix: PathInput): HttpApiGroup<Name, Endpoints, Error, ErrorR>;
189
- };
190
- /**
191
- * Merge the annotations of an `HttpApiGroup` with a new context.
192
- *
193
- * @since 1.0.0
194
- * @category annotations
195
- */
196
- export declare const annotateMerge: {
144
+ type Endpoints<Group> = Group extends HttpApiGroup<infer _Name, infer _Endpoints, infer _Error, infer _R, infer _TopLevel> ? _Endpoints : never;
197
145
  /**
198
- * Merge the annotations of an `HttpApiGroup` with a new context.
199
- *
200
146
  * @since 1.0.0
201
- * @category annotations
147
+ * @category models
202
148
  */
203
- <I>(context: Context.Context<I>): <A extends HttpApiGroup.Any>(self: A) => A;
149
+ type EndpointsWithName<Group extends Any, Name extends string> = Endpoints<WithName<Group, Name>>;
204
150
  /**
205
- * Merge the annotations of an `HttpApiGroup` with a new context.
206
- *
207
151
  * @since 1.0.0
208
- * @category annotations
152
+ * @category models
209
153
  */
210
- <A extends HttpApiGroup.Any, I>(self: A, context: Context.Context<I>): A;
211
- };
212
- /**
213
- * Add an annotation to an `HttpApiGroup`.
214
- *
215
- * @since 1.0.0
216
- * @category annotations
217
- */
218
- export declare const annotate: {
154
+ type Error<Group> = Group extends HttpApiGroup<infer _Name, infer _Endpoints, infer _Error, infer _R, infer _TopLevel> ? _Error : never;
219
155
  /**
220
- * Add an annotation to an `HttpApiGroup`.
221
- *
222
156
  * @since 1.0.0
223
- * @category annotations
157
+ * @category models
224
158
  */
225
- <I, S>(tag: Context.Tag<I, S>, value: S): <A extends HttpApiGroup.Any>(self: A) => A;
159
+ type Provides<Group extends Any> = HttpApiMiddleware.HttpApiMiddleware.ExtractProvides<Context<Group>>;
226
160
  /**
227
- * Add an annotation to an `HttpApiGroup`.
228
- *
229
161
  * @since 1.0.0
230
- * @category annotations
162
+ * @category models
231
163
  */
232
- <A extends HttpApiGroup.Any, I, S>(self: A, tag: Context.Tag<I, S>, value: S): A;
233
- };
234
- /**
235
- * For each endpoint in an `HttpApiGroup`, update the annotations with a new
236
- * context.
237
- *
238
- * Note that this will only update the annotations before this api is called.
239
- *
240
- * @since 1.0.0
241
- * @category annotations
242
- */
243
- export declare const annotateEndpointsMerge: {
164
+ type ErrorWithName<Group extends Any, Name extends string> = Error<WithName<Group, Name>>;
244
165
  /**
245
- * For each endpoint in an `HttpApiGroup`, update the annotations with a new
246
- * context.
247
- *
248
- * Note that this will only update the annotations before this api is called.
249
- *
250
166
  * @since 1.0.0
251
- * @category annotations
167
+ * @category models
252
168
  */
253
- <I>(context: Context.Context<I>): <A extends HttpApiGroup.Any>(self: A) => A;
169
+ type Context<Group> = Group extends HttpApiGroup<infer _Name, infer _Endpoints, infer _Error, infer _R, infer _TopLevel> ? HttpApiMiddleware.HttpApiMiddleware.Only<_R> | Exclude<HttpApiEndpoint.HttpApiEndpoint.Context<_Endpoints>, HttpApiMiddleware.HttpApiMiddleware.ExtractProvides<HttpApiEndpoint.HttpApiEndpoint.Context<_Endpoints> | _R>> : never;
254
170
  /**
255
- * For each endpoint in an `HttpApiGroup`, update the annotations with a new
256
- * context.
257
- *
258
- * Note that this will only update the annotations before this api is called.
259
- *
260
171
  * @since 1.0.0
261
- * @category annotations
172
+ * @category models
262
173
  */
263
- <A extends HttpApiGroup.Any, I>(self: A, context: Context.Context<I>): A;
264
- };
265
- /**
266
- * For each endpoint in an `HttpApiGroup`, add an annotation.
267
- *
268
- * Note that this will only add the annotation to the endpoints before this api
269
- * is called.
270
- *
271
- * @since 1.0.0
272
- * @category annotations
273
- */
274
- export declare const annotateEndpoints: {
174
+ type ClientContext<Group> = Group extends HttpApiGroup<infer _Name, infer _Endpoints, infer _Error, infer _R, infer _TopLevel> ? _R | HttpApiEndpoint.HttpApiEndpoint.Context<_Endpoints> | HttpApiEndpoint.HttpApiEndpoint.ErrorContext<_Endpoints> : never;
275
175
  /**
276
- * For each endpoint in an `HttpApiGroup`, add an annotation.
277
- *
278
- * Note that this will only add the annotation to the endpoints before this api
279
- * is called.
280
- *
281
176
  * @since 1.0.0
282
- * @category annotations
177
+ * @category models
283
178
  */
284
- <I, S>(tag: Context.Tag<I, S>, value: S): <A extends HttpApiGroup.Any>(self: A) => A;
179
+ type ErrorContext<Group> = Group extends HttpApiGroup<infer _Name, infer _Endpoints, infer _Error, infer _R, infer _TopLevel> ? HttpApiMiddleware.HttpApiMiddleware.Without<_R> | HttpApiEndpoint.HttpApiEndpoint.ErrorContext<_Endpoints> : never;
285
180
  /**
286
- * For each endpoint in an `HttpApiGroup`, add an annotation.
287
- *
288
- * Note that this will only add the annotation to the endpoints before this api
289
- * is called.
290
- *
291
181
  * @since 1.0.0
292
- * @category annotations
182
+ * @category models
293
183
  */
294
- <A extends HttpApiGroup.Any, I, S>(self: A, tag: Context.Tag<I, S>, value: S): A;
295
- };
184
+ type ContextWithName<Group extends Any, Name extends string> = Context<WithName<Group, Name>>;
185
+ }
186
+ /**
187
+ * An `HttpApiGroup` is a collection of `HttpApiEndpoint`s. You can use an `HttpApiGroup` to
188
+ * represent a portion of your domain.
189
+ *
190
+ * The endpoints can be implemented later using the `HttpApiBuilder.group` api.
191
+ *
192
+ * @since 1.0.0
193
+ * @category constructors
194
+ */
195
+ export declare const make: <const Id extends string, const TopLevel extends (true | false) = false>(identifier: Id, options?: {
196
+ readonly topLevel?: TopLevel | undefined;
197
+ }) => HttpApiGroup<Id, never, never, never, TopLevel>;
296
198
  //# sourceMappingURL=HttpApiGroup.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"HttpApiGroup.d.ts","sourceRoot":"","sources":["../../src/HttpApiGroup.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAA;AAC/C,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AAEzC,OAAO,EAAE,KAAK,QAAQ,EAAiB,MAAM,iBAAiB,CAAA;AAE9D,OAAO,KAAK,eAAe,MAAM,sBAAsB,CAAA;AACvD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAE3D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAEhD;;;GAGG;AACH,eAAO,MAAM,MAAM,EAAE,OAAO,MAAoD,CAAA;AAEhF;;;GAGG;AACH,MAAM,MAAM,MAAM,GAAG,OAAO,MAAM,CAAA;AAElC;;;GAGG;AACH,eAAO,MAAM,cAAc,MAAO,OAAO,KAAG,CAAC,IAAI,YAAY,CAAC,GAAuC,CAAA;AAErG;;;;;;;;GAQG;AACH,MAAM,WAAW,YAAY,CAC3B,GAAG,CAAC,IAAI,SAAS,MAAM,EACvB,GAAG,CAAC,SAAS,SAAS,eAAe,CAAC,eAAe,CAAC,GAAG,GAAG,KAAK,EACjE,EAAE,CAAC,GAAG,CAAC,KAAK,GAAG,kBAAkB,EACjC,GAAG,CAAC,MAAM,GAAG,KAAK,CAClB,SAAQ,QAAQ;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,QAAQ,SAAS,CAAC,IAAI,GAAG,KAAK,CAAC,sBAAsB,EAAE,YAAY;IACrH,QAAQ,CAAC,QAAQ,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAA;CACzC,KAAG,YAAY,CAAC,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,CAQ9C,CAAA"}
@@ -0,0 +1,231 @@
1
+ /**
2
+ * @since 1.0.0
3
+ */
4
+ import * as Context from "effect/Context";
5
+ import type * as Effect from "effect/Effect";
6
+ import * as Schema from "effect/Schema";
7
+ import type { Simplify } from "effect/Types";
8
+ import type * as HttpApiSecurity from "./HttpApiSecurity.js";
9
+ import type * as HttpRouter from "./HttpRouter.js";
10
+ /**
11
+ * @since 1.0.0
12
+ * @category type ids
13
+ */
14
+ export declare const TypeId: unique symbol;
15
+ /**
16
+ * @since 1.0.0
17
+ * @category type ids
18
+ */
19
+ export type TypeId = typeof TypeId;
20
+ /**
21
+ * @since 1.0.0
22
+ * @category type ids
23
+ */
24
+ export declare const SecurityTypeId: unique symbol;
25
+ /**
26
+ * @since 1.0.0
27
+ * @category type ids
28
+ */
29
+ export type SecurityTypeId = typeof SecurityTypeId;
30
+ /**
31
+ * @since 1.0.0
32
+ * @category guards
33
+ */
34
+ export declare const isSecurity: (u: TagClassAny) => u is TagClassSecurityAny;
35
+ /**
36
+ * @since 1.0.0
37
+ * @category models
38
+ */
39
+ export interface HttpApiMiddleware<Provides, E> extends Effect.Effect<Provides, E, HttpRouter.HttpRouter.Provided> {
40
+ }
41
+ /**
42
+ * @since 1.0.0
43
+ * @category models
44
+ */
45
+ export type HttpApiMiddlewareSecurity<Security extends Record<string, HttpApiSecurity.HttpApiSecurity>, Provides, E> = {
46
+ readonly [K in keyof Security]: (_: HttpApiSecurity.HttpApiSecurity.Type<Security[K]>) => Effect.Effect<Provides, E, HttpRouter.HttpRouter.Provided>;
47
+ };
48
+ /**
49
+ * @since 1.0.0
50
+ * @category models
51
+ */
52
+ export declare namespace HttpApiMiddleware {
53
+ /**
54
+ * @since 1.0.0
55
+ * @category models
56
+ */
57
+ interface Any {
58
+ readonly [TypeId]: TypeId;
59
+ }
60
+ /**
61
+ * @since 1.0.0
62
+ * @category models
63
+ */
64
+ interface AnyId {
65
+ readonly [TypeId]: {
66
+ readonly provides: any;
67
+ };
68
+ }
69
+ /**
70
+ * @since 1.0.0
71
+ * @category models
72
+ */
73
+ type Provides<A> = A extends {
74
+ readonly [TypeId]: {
75
+ readonly provides: infer P;
76
+ };
77
+ } ? P : never;
78
+ /**
79
+ * @since 1.0.0
80
+ * @category models
81
+ */
82
+ type ExtractProvides<A> = Provides<Only<A>>;
83
+ /**
84
+ * @since 1.0.0
85
+ * @category models
86
+ */
87
+ type Error<A> = A extends {
88
+ readonly [TypeId]: {
89
+ readonly failure: infer E;
90
+ };
91
+ } ? E : never;
92
+ /**
93
+ * @since 1.0.0
94
+ * @category models
95
+ */
96
+ type ErrorContext<A> = A extends {
97
+ readonly [TypeId]: {
98
+ readonly failureContext: infer R;
99
+ };
100
+ } ? R : never;
101
+ /**
102
+ * @since 1.0.0
103
+ * @category models
104
+ */
105
+ type Only<R> = Extract<R, AnyId>;
106
+ /**
107
+ * @since 1.0.0
108
+ * @category models
109
+ */
110
+ type Without<R> = Exclude<R, AnyId>;
111
+ }
112
+ /**
113
+ * @since 1.0.0
114
+ * @category models
115
+ */
116
+ export type TagClass<Self, Name extends string, Options> = Options extends {
117
+ readonly security: Record<string, HttpApiSecurity.HttpApiSecurity>;
118
+ } ? TagClass.Base<Self, Name, Options, Simplify<HttpApiMiddlewareSecurity<Options["security"], TagClass.Service<Options>, TagClass.FailureService<Options>>>> & TagClass.SecurityFields<Options["security"]> : TagClass.Base<Self, Name, Options, HttpApiMiddleware<TagClass.Service<Options>, TagClass.FailureService<Options>>>;
119
+ /**
120
+ * @since 1.0.0
121
+ * @category models
122
+ */
123
+ export declare namespace TagClass {
124
+ /**
125
+ * @since 1.0.0
126
+ * @category models
127
+ */
128
+ type Provides<Options> = Options extends {
129
+ readonly provides: Context.Tag<any, any>;
130
+ readonly optional?: false;
131
+ } ? Context.Tag.Identifier<Options["provides"]> : never;
132
+ /**
133
+ * @since 1.0.0
134
+ * @category models
135
+ */
136
+ type Service<Options> = Options extends {
137
+ readonly provides: Context.Tag<any, any>;
138
+ } ? Context.Tag.Service<Options["provides"]> : void;
139
+ /**
140
+ * @since 1.0.0
141
+ * @category models
142
+ */
143
+ type FailureSchema<Options> = Options extends {
144
+ readonly failure: Schema.Schema.All;
145
+ readonly optional?: false;
146
+ } ? Options["failure"] : typeof Schema.Never;
147
+ /**
148
+ * @since 1.0.0
149
+ * @category models
150
+ */
151
+ type Failure<Options> = Schema.Schema.Type<FailureSchema<Options>>;
152
+ /**
153
+ * @since 1.0.0
154
+ * @category models
155
+ */
156
+ type FailureContext<Options> = Schema.Schema.Context<FailureSchema<Options>>;
157
+ /**
158
+ * @since 1.0.0
159
+ * @category models
160
+ */
161
+ type FailureService<Options> = Optional<Options> extends true ? unknown : Failure<Options>;
162
+ /**
163
+ * @since 1.0.0
164
+ * @category models
165
+ */
166
+ type Optional<Options> = Options extends {
167
+ readonly optional: true;
168
+ } ? true : false;
169
+ /**
170
+ * @since 1.0.0
171
+ * @category models
172
+ */
173
+ type Base<Self, Name extends string, Options, Service> = BaseConstructor<Self, Name, Options, Service> & (Optional<Options> extends true ? {} : Options extends {
174
+ readonly provides: Context.Tag<any, any>;
175
+ } ? {
176
+ readonly provides: Options["provides"];
177
+ } : {});
178
+ /**
179
+ * @since 1.0.0
180
+ * @category models
181
+ */
182
+ interface BaseConstructor<Self, Name extends string, Options, Service> extends Context.Tag<Self, Service> {
183
+ new (_: never): Context.TagClassShape<Name, Service> & {
184
+ readonly [TypeId]: {
185
+ readonly provides: Provides<Options>;
186
+ readonly failure: Failure<Options>;
187
+ readonly failureContext: FailureContext<Options>;
188
+ };
189
+ };
190
+ readonly [TypeId]: TypeId;
191
+ readonly optional: Optional<Options>;
192
+ readonly failure: FailureSchema<Options>;
193
+ }
194
+ /**
195
+ * @since 1.0.0
196
+ * @category models
197
+ */
198
+ interface SecurityFields<Security extends Record<string, HttpApiSecurity.HttpApiSecurity>> {
199
+ readonly [SecurityTypeId]: SecurityTypeId;
200
+ readonly security: Security;
201
+ }
202
+ }
203
+ /**
204
+ * @since 1.0.0
205
+ * @category models
206
+ */
207
+ export interface TagClassAny extends Context.Tag<any, HttpApiMiddleware.Any> {
208
+ readonly [TypeId]: TypeId;
209
+ readonly optional: boolean;
210
+ readonly provides?: Context.Tag<any, any>;
211
+ readonly failure: Schema.Schema.All;
212
+ }
213
+ /**
214
+ * @since 1.0.0
215
+ * @category models
216
+ */
217
+ export interface TagClassSecurityAny extends TagClassAny {
218
+ readonly [SecurityTypeId]: SecurityTypeId;
219
+ readonly security: Record<string, HttpApiSecurity.HttpApiSecurity>;
220
+ }
221
+ /**
222
+ * @since 1.0.0
223
+ * @category tags
224
+ */
225
+ export declare const Tag: <Self>() => <const Name extends string, const Options extends {
226
+ readonly optional?: boolean;
227
+ readonly failure?: Schema.Schema.All;
228
+ readonly provides?: Context.Tag<any, any>;
229
+ readonly security?: Record<string, HttpApiSecurity.HttpApiSecurity>;
230
+ }>(id: Name, options?: Options | undefined) => TagClass<Self, Name, Options>;
231
+ //# sourceMappingURL=HttpApiMiddleware.d.ts.map