@effect/platform 0.11.5 → 0.12.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 (191) hide show
  1. package/FileSystem.d.ts +16 -9
  2. package/FileSystem.d.ts.map +1 -1
  3. package/FileSystem.js.map +1 -1
  4. package/Http/App.d.ts +18 -0
  5. package/Http/App.d.ts.map +1 -0
  6. package/Http/App.js +6 -0
  7. package/Http/App.js.map +1 -0
  8. package/Http/Body.d.ts +37 -14
  9. package/Http/Body.d.ts.map +1 -1
  10. package/Http/Body.js +17 -5
  11. package/Http/Body.js.map +1 -1
  12. package/Http/Client.d.ts +2 -2
  13. package/Http/Client.d.ts.map +1 -1
  14. package/Http/Client.js +3 -3
  15. package/Http/Client.js.map +1 -1
  16. package/Http/ClientRequest.d.ts +44 -1
  17. package/Http/ClientRequest.d.ts.map +1 -1
  18. package/Http/ClientRequest.js +21 -3
  19. package/Http/ClientRequest.js.map +1 -1
  20. package/Http/ClientResponse.d.ts +13 -1
  21. package/Http/ClientResponse.d.ts.map +1 -1
  22. package/Http/ClientResponse.js +14 -2
  23. package/Http/ClientResponse.js.map +1 -1
  24. package/Http/FormData.d.ts +97 -4
  25. package/Http/FormData.d.ts.map +1 -1
  26. package/Http/FormData.js +77 -2
  27. package/Http/FormData.js.map +1 -1
  28. package/Http/Headers.d.ts +29 -3
  29. package/Http/Headers.d.ts.map +1 -1
  30. package/Http/Headers.js +13 -1
  31. package/Http/Headers.js.map +1 -1
  32. package/Http/IncomingMessage.d.ts +26 -5
  33. package/Http/IncomingMessage.d.ts.map +1 -1
  34. package/Http/IncomingMessage.js +38 -3
  35. package/Http/IncomingMessage.js.map +1 -1
  36. package/Http/Middleware.d.ts +56 -0
  37. package/Http/Middleware.d.ts.map +1 -0
  38. package/Http/Middleware.js +46 -0
  39. package/Http/Middleware.js.map +1 -0
  40. package/Http/Router.d.ts +221 -0
  41. package/Http/Router.d.ts.map +1 -0
  42. package/Http/Router.js +148 -0
  43. package/Http/Router.js.map +1 -0
  44. package/Http/Server.d.ts +85 -0
  45. package/Http/Server.d.ts.map +1 -0
  46. package/Http/Server.js +34 -0
  47. package/Http/Server.js.map +1 -0
  48. package/Http/ServerError.d.ts +96 -0
  49. package/Http/ServerError.d.ts.map +1 -0
  50. package/Http/ServerError.js +40 -0
  51. package/Http/ServerError.js.map +1 -0
  52. package/Http/ServerRequest.d.ts +82 -0
  53. package/Http/ServerRequest.d.ts.map +1 -0
  54. package/Http/ServerRequest.js +66 -0
  55. package/Http/ServerRequest.js.map +1 -0
  56. package/Http/ServerResponse.d.ts +168 -0
  57. package/Http/ServerResponse.d.ts.map +1 -0
  58. package/Http/ServerResponse.js +116 -0
  59. package/Http/ServerResponse.js.map +1 -0
  60. package/Http/UrlParams.d.ts +20 -5
  61. package/Http/UrlParams.d.ts.map +1 -1
  62. package/Http/UrlParams.js.map +1 -1
  63. package/HttpServer.d.ts +44 -0
  64. package/HttpServer.d.ts.map +1 -0
  65. package/HttpServer.js +29 -0
  66. package/HttpServer.js.map +1 -0
  67. package/internal/fileSystem.js +15 -11
  68. package/internal/fileSystem.js.map +1 -1
  69. package/internal/http/body.js +28 -28
  70. package/internal/http/body.js.map +1 -1
  71. package/internal/http/client.d.ts.map +1 -1
  72. package/internal/http/client.js +32 -26
  73. package/internal/http/client.js.map +1 -1
  74. package/internal/http/clientRequest.js +22 -6
  75. package/internal/http/clientRequest.js.map +1 -1
  76. package/internal/http/clientResponse.js +15 -12
  77. package/internal/http/clientResponse.js.map +1 -1
  78. package/internal/http/formData.d.ts +8 -0
  79. package/internal/http/formData.d.ts.map +1 -0
  80. package/internal/http/formData.js +88 -0
  81. package/internal/http/formData.js.map +1 -0
  82. package/internal/http/middleware.d.ts +2 -0
  83. package/internal/http/middleware.d.ts.map +1 -0
  84. package/internal/http/middleware.js +43 -0
  85. package/internal/http/middleware.js.map +1 -0
  86. package/internal/http/router.d.ts +2 -0
  87. package/internal/http/router.d.ts.map +1 -0
  88. package/internal/http/router.js +187 -0
  89. package/internal/http/router.js.map +1 -0
  90. package/internal/http/server.d.ts +2 -0
  91. package/internal/http/server.d.ts.map +1 -0
  92. package/internal/http/server.js +30 -0
  93. package/internal/http/server.js.map +1 -0
  94. package/internal/http/serverError.d.ts +2 -0
  95. package/internal/http/serverError.d.ts.map +1 -0
  96. package/internal/http/serverError.js +30 -0
  97. package/internal/http/serverError.js.map +1 -0
  98. package/internal/http/serverRequest.d.ts +2 -0
  99. package/internal/http/serverRequest.d.ts.map +1 -0
  100. package/internal/http/serverRequest.js +57 -0
  101. package/internal/http/serverRequest.js.map +1 -0
  102. package/internal/http/serverResponse.d.ts +2 -0
  103. package/internal/http/serverResponse.d.ts.map +1 -0
  104. package/internal/http/serverResponse.js +109 -0
  105. package/internal/http/serverResponse.js.map +1 -0
  106. package/mjs/FileSystem.mjs.map +1 -1
  107. package/mjs/Http/App.mjs +2 -0
  108. package/mjs/Http/App.mjs.map +1 -0
  109. package/mjs/Http/Body.mjs +12 -2
  110. package/mjs/Http/Body.mjs.map +1 -1
  111. package/mjs/Http/Client.mjs +1 -1
  112. package/mjs/Http/Client.mjs.map +1 -1
  113. package/mjs/Http/ClientRequest.mjs +16 -1
  114. package/mjs/Http/ClientRequest.mjs.map +1 -1
  115. package/mjs/Http/ClientResponse.mjs +11 -1
  116. package/mjs/Http/ClientResponse.mjs.map +1 -1
  117. package/mjs/Http/FormData.mjs +62 -1
  118. package/mjs/Http/FormData.mjs.map +1 -1
  119. package/mjs/Http/Headers.mjs +10 -0
  120. package/mjs/Http/Headers.mjs.map +1 -1
  121. package/mjs/Http/IncomingMessage.mjs +32 -1
  122. package/mjs/Http/IncomingMessage.mjs.map +1 -1
  123. package/mjs/Http/Middleware.mjs +32 -0
  124. package/mjs/Http/Middleware.mjs.map +1 -0
  125. package/mjs/Http/Router.mjs +117 -0
  126. package/mjs/Http/Router.mjs.map +1 -0
  127. package/mjs/Http/Server.mjs +22 -0
  128. package/mjs/Http/Server.mjs.map +1 -0
  129. package/mjs/Http/ServerError.mjs +27 -0
  130. package/mjs/Http/ServerError.mjs.map +1 -0
  131. package/mjs/Http/ServerRequest.mjs +48 -0
  132. package/mjs/Http/ServerRequest.mjs.map +1 -0
  133. package/mjs/Http/ServerResponse.mjs +90 -0
  134. package/mjs/Http/ServerResponse.mjs.map +1 -0
  135. package/mjs/Http/UrlParams.mjs.map +1 -1
  136. package/mjs/HttpServer.mjs +24 -0
  137. package/mjs/HttpServer.mjs.map +1 -0
  138. package/mjs/internal/fileSystem.mjs +15 -11
  139. package/mjs/internal/fileSystem.mjs.map +1 -1
  140. package/mjs/internal/http/body.mjs +23 -25
  141. package/mjs/internal/http/body.mjs.map +1 -1
  142. package/mjs/internal/http/client.mjs +30 -24
  143. package/mjs/internal/http/client.mjs.map +1 -1
  144. package/mjs/internal/http/clientRequest.mjs +16 -4
  145. package/mjs/internal/http/clientRequest.mjs.map +1 -1
  146. package/mjs/internal/http/clientResponse.mjs +15 -12
  147. package/mjs/internal/http/clientResponse.mjs.map +1 -1
  148. package/mjs/internal/http/formData.mjs +67 -0
  149. package/mjs/internal/http/formData.mjs.map +1 -0
  150. package/mjs/internal/http/middleware.mjs +29 -0
  151. package/mjs/internal/http/middleware.mjs.map +1 -0
  152. package/mjs/internal/http/router.mjs +155 -0
  153. package/mjs/internal/http/router.mjs.map +1 -0
  154. package/mjs/internal/http/server.mjs +17 -0
  155. package/mjs/internal/http/server.mjs.map +1 -0
  156. package/mjs/internal/http/serverError.mjs +17 -0
  157. package/mjs/internal/http/serverError.mjs.map +1 -0
  158. package/mjs/internal/http/serverRequest.mjs +41 -0
  159. package/mjs/internal/http/serverRequest.mjs.map +1 -0
  160. package/mjs/internal/http/serverResponse.mjs +82 -0
  161. package/mjs/internal/http/serverResponse.mjs.map +1 -0
  162. package/package.json +2 -1
  163. package/src/FileSystem.ts +20 -25
  164. package/src/Http/App.ts +19 -0
  165. package/src/Http/Body.ts +41 -14
  166. package/src/Http/Client.ts +6 -3
  167. package/src/Http/ClientRequest.ts +52 -2
  168. package/src/Http/ClientResponse.ts +13 -1
  169. package/src/Http/FormData.ts +121 -5
  170. package/src/Http/Headers.ts +37 -3
  171. package/src/Http/IncomingMessage.ts +46 -3
  172. package/src/Http/Middleware.ts +69 -0
  173. package/src/Http/Router.ts +342 -0
  174. package/src/Http/Server.ts +134 -0
  175. package/src/Http/ServerError.ts +111 -0
  176. package/src/Http/ServerRequest.ts +120 -0
  177. package/src/Http/ServerResponse.ts +202 -0
  178. package/src/Http/UrlParams.ts +20 -5
  179. package/src/HttpServer.ts +44 -0
  180. package/src/internal/fileSystem.ts +10 -7
  181. package/src/internal/http/body.ts +65 -39
  182. package/src/internal/http/client.ts +45 -36
  183. package/src/internal/http/clientRequest.ts +64 -4
  184. package/src/internal/http/clientResponse.ts +21 -13
  185. package/src/internal/http/formData.ts +140 -0
  186. package/src/internal/http/middleware.ts +72 -0
  187. package/src/internal/http/router.ts +298 -0
  188. package/src/internal/http/server.ts +80 -0
  189. package/src/internal/http/serverError.ts +26 -0
  190. package/src/internal/http/serverRequest.ts +71 -0
  191. package/src/internal/http/serverResponse.ts +255 -0
@@ -0,0 +1,155 @@
1
+ import * as Chunk from "@effect/data/Chunk";
2
+ import * as Context from "@effect/data/Context";
3
+ import * as Equal from "@effect/data/Equal";
4
+ import { dual } from "@effect/data/Function";
5
+ import * as Hash from "@effect/data/Hash";
6
+ import * as Option from "@effect/data/Option";
7
+ import { pipeArguments } from "@effect/data/Pipeable";
8
+ import * as Effect from "@effect/io/Effect";
9
+ import * as Error from "@effect/platform/Http/ServerError";
10
+ import * as ServerRequest from "@effect/platform/Http/ServerRequest";
11
+ import * as Schema from "@effect/schema/Schema";
12
+ import * as Channel from "@effect/stream/Channel";
13
+ import * as Sink from "@effect/stream/Sink";
14
+ import * as Stream from "@effect/stream/Stream";
15
+ import FindMyWay from "find-my-way";
16
+ /** @internal */
17
+ export const TypeId = /*#__PURE__*/Symbol.for("@effect/platform/Http/Router");
18
+ /** @internal */
19
+ export const RouteTypeId = /*#__PURE__*/Symbol.for("@effect/platform/Http/Router/Route");
20
+ /** @internal */
21
+ export const RouteContextTypeId = /*#__PURE__*/Symbol.for("@effect/platform/Http/Router/RouteContext");
22
+ /** @internal */
23
+ export const RouteContext = /*#__PURE__*/Context.Tag("@effect/platform/Http/Router/RouteContext");
24
+ /** @internal */
25
+ export const params = /*#__PURE__*/Effect.map(RouteContext, _ => _.params);
26
+ /** @internal */
27
+ export const searchParams = /*#__PURE__*/Effect.map(RouteContext, _ => _.searchParams);
28
+ /** @internal */
29
+ export const schemaParams = schema => {
30
+ const parse = Schema.parse(schema);
31
+ return Effect.flatMap(RouteContext, _ => parse({
32
+ ..._.searchParams,
33
+ ..._.params
34
+ }));
35
+ };
36
+ class RouterImpl {
37
+ constructor(routes, mounts) {
38
+ this.routes = routes;
39
+ this.mounts = mounts;
40
+ // implements HttpApp/Effect
41
+ this._tag = "Commit"; // OP_COMMIT
42
+ this[TypeId] = TypeId;
43
+ this[Effect.EffectTypeId] = undefined;
44
+ this[Stream.StreamTypeId] = undefined;
45
+ this[Sink.SinkTypeId] = undefined;
46
+ this[Channel.ChannelTypeId] = undefined;
47
+ }
48
+ pipe() {
49
+ return pipeArguments(this, arguments);
50
+ }
51
+ commit() {
52
+ if (this.httpApp === undefined) {
53
+ this.httpApp = toHttpApp(this);
54
+ }
55
+ return this.httpApp;
56
+ }
57
+ [(Effect.EffectTypeId, Stream.StreamTypeId, Sink.SinkTypeId, Channel.ChannelTypeId, Equal.symbol)](that) {
58
+ return this === that;
59
+ }
60
+ [Hash.symbol]() {
61
+ return Hash.random(this);
62
+ }
63
+ }
64
+ const toHttpApp = self => {
65
+ const router = FindMyWay();
66
+ Chunk.forEach(self.mounts, ([path, app]) => {
67
+ const fn = () => {};
68
+ fn.handler = Effect.updateService(app, ServerRequest.ServerRequest, request => sliceRequestUrl(request, path));
69
+ router.all(path, fn);
70
+ router.all(path + "/*", fn);
71
+ });
72
+ Chunk.forEach(self.routes, route => {
73
+ const fn = () => {};
74
+ fn.handler = route;
75
+ if (route.method === "*") {
76
+ router.all(route.path, fn);
77
+ } else {
78
+ router.on(route.method, route.path, fn);
79
+ }
80
+ });
81
+ return Effect.flatMap(ServerRequest.ServerRequest, request => {
82
+ const result = router.find(request.method, request.url);
83
+ if (result === null) {
84
+ return Effect.fail(Error.RouteNotFound({
85
+ request
86
+ }));
87
+ }
88
+ const handler = result.handler.handler;
89
+ if (RouteTypeId in handler) {
90
+ const route = handler;
91
+ if (route.prefix._tag === "Some") {
92
+ request = sliceRequestUrl(request, route.prefix.value);
93
+ }
94
+ return Effect.mapInputContext(route.handler, context => Context.add(Context.add(context, ServerRequest.ServerRequest, request), RouteContext, new RouteContextImpl(result.params, result.searchParams)));
95
+ }
96
+ return handler;
97
+ });
98
+ };
99
+ function sliceRequestUrl(request, prefix) {
100
+ const prefexLen = prefix.length;
101
+ return request.setUrl(request.url.length <= prefexLen ? "/" : request.url.slice(prefexLen));
102
+ }
103
+ class RouteImpl {
104
+ constructor(method, path, handler, prefix = Option.none()) {
105
+ this.method = method;
106
+ this.path = path;
107
+ this.handler = handler;
108
+ this.prefix = prefix;
109
+ this[RouteTypeId] = RouteTypeId;
110
+ }
111
+ }
112
+ class RouteContextImpl {
113
+ constructor(params, searchParams) {
114
+ this.params = params;
115
+ this.searchParams = searchParams;
116
+ this[RouteContextTypeId] = RouteContextTypeId;
117
+ }
118
+ }
119
+ /** @internal */
120
+ export const empty = /*#__PURE__*/new RouterImpl( /*#__PURE__*/Chunk.empty(), /*#__PURE__*/Chunk.empty());
121
+ /** @internal */
122
+ export const fromIterable = routes => new RouterImpl(Chunk.fromIterable(routes), Chunk.empty());
123
+ /** @internal */
124
+ export const makeRoute = (method, path, handler, prefix = Option.none()) => new RouteImpl(method, path, handler, prefix);
125
+ /** @internal */
126
+ export const concat = /*#__PURE__*/dual(2, (self, that) => new RouterImpl(Chunk.appendAll(self.routes, that.routes), self.mounts));
127
+ const removeTrailingSlash = path => path.endsWith("/") ? path.slice(0, -1) : path;
128
+ /** @internal */
129
+ export const prefixAll = /*#__PURE__*/dual(2, (self, prefix) => {
130
+ prefix = removeTrailingSlash(prefix);
131
+ return new RouterImpl(Chunk.map(self.routes, route => new RouteImpl(route.method, route.path === "/" ? prefix : prefix + route.path, route.handler, Option.orElse(Option.map(route.prefix, _ => prefix + _), () => Option.some(prefix)))), Chunk.map(self.mounts, ([path, app]) => [path === "/" ? prefix : prefix + path, app]));
132
+ });
133
+ /** @internal */
134
+ export const mount = /*#__PURE__*/dual(3, (self, path, that) => concat(self, prefixAll(that, path)));
135
+ /** @internal */
136
+ export const mountApp = /*#__PURE__*/dual(3, (self, path, that) => new RouterImpl(self.routes, Chunk.append(self.mounts, [removeTrailingSlash(path), that])));
137
+ /** @internal */
138
+ export const route = method => dual(3, (self, path, handler) => new RouterImpl(Chunk.append(self.routes, new RouteImpl(method, path, handler)), self.mounts));
139
+ /** @internal */
140
+ export const all = /*#__PURE__*/route("*");
141
+ /** @internal */
142
+ export const get = /*#__PURE__*/route("GET");
143
+ /** @internal */
144
+ export const post = /*#__PURE__*/route("POST");
145
+ /** @internal */
146
+ export const put = /*#__PURE__*/route("PUT");
147
+ /** @internal */
148
+ export const patch = /*#__PURE__*/route("PATCH");
149
+ /** @internal */
150
+ export const del = /*#__PURE__*/route("DELETE");
151
+ /** @internal */
152
+ export const head = /*#__PURE__*/route("HEAD");
153
+ /** @internal */
154
+ export const options = /*#__PURE__*/route("OPTIONS");
155
+ //# sourceMappingURL=router.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"router.mjs","names":["Chunk","Context","Equal","dual","Hash","Option","pipeArguments","Effect","Error","ServerRequest","Schema","Channel","Sink","Stream","FindMyWay","TypeId","Symbol","for","RouteTypeId","RouteContextTypeId","RouteContext","Tag","params","map","_","searchParams","schemaParams","schema","parse","flatMap","RouterImpl","constructor","routes","mounts","_tag","EffectTypeId","undefined","StreamTypeId","SinkTypeId","ChannelTypeId","pipe","arguments","commit","httpApp","toHttpApp","symbol","that","random","self","router","forEach","path","app","fn","handler","updateService","request","sliceRequestUrl","all","route","method","on","result","find","url","fail","RouteNotFound","prefix","value","mapInputContext","context","add","RouteContextImpl","prefexLen","length","setUrl","slice","RouteImpl","none","empty","fromIterable","makeRoute","concat","appendAll","removeTrailingSlash","endsWith","prefixAll","orElse","some","mount","mountApp","append","get","post","put","patch","del","head","options"],"sources":["../../../src/internal/http/router.ts"],"sourcesContent":[null],"mappings":"AAAA,OAAO,KAAKA,KAAK,MAAM,oBAAoB;AAC3C,OAAO,KAAKC,OAAO,MAAM,sBAAsB;AAC/C,OAAO,KAAKC,KAAK,MAAM,oBAAoB;AAC3C,SAASC,IAAI,QAAQ,uBAAuB;AAC5C,OAAO,KAAKC,IAAI,MAAM,mBAAmB;AACzC,OAAO,KAAKC,MAAM,MAAM,qBAAqB;AAC7C,SAASC,aAAa,QAAQ,uBAAuB;AACrD,OAAO,KAAKC,MAAM,MAAM,mBAAmB;AAI3C,OAAO,KAAKC,KAAK,MAAM,mCAAmC;AAC1D,OAAO,KAAKC,aAAa,MAAM,qCAAqC;AACpE,OAAO,KAAKC,MAAM,MAAM,uBAAuB;AAC/C,OAAO,KAAKC,OAAO,MAAM,wBAAwB;AACjD,OAAO,KAAKC,IAAI,MAAM,qBAAqB;AAC3C,OAAO,KAAKC,MAAM,MAAM,uBAAuB;AAE/C,OAAOC,SAAS,MAAM,aAAa;AAEnC;AACA,OAAO,MAAMC,MAAM,gBAAkBC,MAAM,CAACC,GAAG,CAAC,8BAA8B,CAAkB;AAEhG;AACA,OAAO,MAAMC,WAAW,gBAAuBF,MAAM,CAACC,GAAG,CAAC,oCAAoC,CAAuB;AAErH;AACA,OAAO,MAAME,kBAAkB,gBAA8BH,MAAM,CAACC,GAAG,CACrE,2CAA2C,CACf;AAE9B;AACA,OAAO,MAAMG,YAAY,gBAAGnB,OAAO,CAACoB,GAAG,CAAsB,2CAA2C,CAAC;AAEzG;AACA,OAAO,MA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AChB,MAAM,EAAEhC,KAAK,CAAC2F,MAAM,CAAC3C,IAAI,CAACf,MAAM,EAAE,CAACmD,mBAAmB,CAACjC,IAAI,CAAC,EAAEL,IAAI,CAAC,CAAQ,CAAC,CACvH;AAED;AACA,OAAO,MAAMa,KAAK,GAAIC,MAA2B,IAW/CzD,IAAI,CAUF,CAAC,EAAE,CAAC6C,IAAI,EAAEG,IAAI,EAAEG,OAAO,KACvB,IAAIxB,UAAU,CACZ9B,KAAK,CAAC2F,MAAM,CAAC3C,IAAI,CAAChB,MAAM,EAAE,IAAI6C,SAAS,CAACjB,MAAM,EAAET,IAAI,EAAEG,OAAO,CAAC,CAAQ,EACtEN,IAAI,CAACf,MAAM,CACZ,CAAC;AAEN;AACA,OAAO,MAAMyB,GAAG,gBAAGC,KAAK,CAAC,GAAG,CAAC;AAE7B;AACA,OAAO,MAAMiC,GAAG,gBAAGjC,KAAK,CAAC,KAAK,CAAC;AAE/B;AACA,OAAO,MAAMkC,IAAI,gBAAGlC,KAAK,CAAC,MAAM,CAAC;AAEjC;AACA,OAAO,MAAMmC,GAAG,gBAAGnC,KAAK,CAAC,KAAK,CAAC;AAE/B;AACA,OAAO,MAAMoC,KAAK,gBAAGpC,KAAK,CAAC,OAAO,CAAC;AAEnC;AACA,OAAO,MAAMqC,GAAG,gBAAGrC,KAAK,CAAC,QAAQ,CAAC;AAElC;AACA,OAAO,MAAMsC,IAAI,gBAAGtC,KAAK,CAAC,MAAM,CAAC;AAEjC;AACA,OAAO,MAAMuC,OAAO,gBAAGvC,KAAK,CAAC,SAAS,CAAC"}
@@ -0,0 +1,17 @@
1
+ import * as Context from "@effect/data/Context";
2
+ import { dual } from "@effect/data/Function";
3
+ import * as Effect from "@effect/io/Effect";
4
+ /** @internal */
5
+ export const TypeId = /*#__PURE__*/Symbol.for("@effect/platform/Http/Server");
6
+ /** @internal */
7
+ export const serverTag = /*#__PURE__*/Context.Tag("@effect/platform/Http/Server");
8
+ const serverProto = {
9
+ [TypeId]: TypeId
10
+ };
11
+ /** @internal */
12
+ export const isServer = u => typeof u === "object" && u !== null && TypeId in u;
13
+ /** @internal */
14
+ export const make = options => Object.assign(Object.create(serverProto), options);
15
+ /** @internal */
16
+ export const serve = /*#__PURE__*/dual(args => Effect.isEffect(args[0]), (httpApp, middleware) => Effect.flatMap(serverTag, server => server.serve(httpApp, middleware)));
17
+ //# sourceMappingURL=server.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.mjs","names":["Context","dual","Effect","TypeId","Symbol","for","serverTag","Tag","serverProto","isServer","u","make","options","Object","assign","create","serve","args","isEffect","httpApp","middleware","flatMap","server"],"sources":["../../../src/internal/http/server.ts"],"sourcesContent":[null],"mappings":"AAAA,OAAO,KAAKA,OAAO,MAAM,sBAAsB;AAC/C,SAASC,IAAI,QAAQ,uBAAuB;AAC5C,OAAO,KAAKC,MAAM,MAAM,mBAAmB;AAQ3C;AACA,OAAO,MAAMC,MAAM,gBAAkBC,MAAM,CAACC,GAAG,CAAC,8BAA8B,CAAkB;AAEhG;AACA,OAAO,MAAMC,SAAS,gBAAGN,OAAO,CAACO,GAAG,CAAgB,8BAA8B,CAAC;AAEnF,MAAMC,WAAW,GAAG;EAClB,CAACL,MAAM,GAAGA;CACX;AAED;AACA,OAAO,MAAMM,QAAQ,GAAIC,CAAU,IAAyB,OAAOA,CAAC,KAAK,QAAQ,IAAIA,CAAC,KAAK,IAAI,IAAIP,MAAM,IAAIO,CAAC;AAE9G;AACA,OAAO,MAAMC,IAAI,GACfC,OAMC,IACiBC,MAAM,CAACC,MAAM,CAACD,MAAM,CAACE,MAAM,CAACP,WAAW,CAAC,EAAEI,OAAO,CAAC;AAEtE;AACA,OAAO,MAAMI,KAAK,gBAAGf,IAAI,CA+BtBgB,IAAI,IAAKf,MAAM,CAACgB,QAAQ,CAACD,IAAI,CAAC,CAAC,CAAC,CAAC,EACjC,CACCE,OAA0B,EAC1BC,UAAoD,KAMpDlB,MAAM,CAACmB,OAAO,CACZf,SAAS,EACRgB,MAAM,IAAKA,MAAM,CAACN,KAAK,CAACG,OAAO,EAAEC,UAAU,CAAC,CACtC,CACZ"}
@@ -0,0 +1,17 @@
1
+ import * as Data from "@effect/data/Data";
2
+ /** @internal */
3
+ export const TypeId = /*#__PURE__*/Symbol.for("@effect/platform/Http/Error");
4
+ const make = tag => props => Data.struct({
5
+ [TypeId]: TypeId,
6
+ _tag: tag,
7
+ ...props
8
+ });
9
+ /** @internal */
10
+ export const requestError = /*#__PURE__*/make("RequestError");
11
+ /** @internal */
12
+ export const responseError = /*#__PURE__*/make("ResponseError");
13
+ /** @internal */
14
+ export const routeNotFound = /*#__PURE__*/make("RouteNotFound");
15
+ /** @internal */
16
+ export const serveError = /*#__PURE__*/make("ServeError");
17
+ //# sourceMappingURL=serverError.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serverError.mjs","names":["Data","TypeId","Symbol","for","make","tag","props","struct","_tag","requestError","responseError","routeNotFound","serveError"],"sources":["../../../src/internal/http/serverError.ts"],"sourcesContent":[null],"mappings":"AAAA,OAAO,KAAKA,IAAI,MAAM,mBAAmB;AAGzC;AACA,OAAO,MAAMC,MAAM,gBAAiBC,MAAM,CAACC,GAAG,CAC5C,6BAA6B,CACd;AAEjB,MAAMC,IAAI,GAAqCC,GAAc,IAAMC,KAA8C,IAC/GN,IAAI,CAACO,MAAM,CAAC;EACV,CAACN,MAAM,GAAGA,MAAM;EAChBO,IAAI,EAAEH,GAAG;EACT,GAAGC;CACC,CAAC;AAET;AACA,OAAO,MAAMG,YAAY,gBAAGL,IAAI,CAAqB,cAAc,CAAC;AAEpE;AACA,OAAO,MAAMM,aAAa,gBAAGN,IAAI,CAAsB,eAAe,CAAC;AAEvE;AACA,OAAO,MAAMO,aAAa,gBAAGP,IAAI,CAAsB,eAAe,CAAC;AAEvE;AACA,OAAO,MAAMQ,UAAU,gBAAGR,IAAI,CAAmB,YAAY,CAAC"}
@@ -0,0 +1,41 @@
1
+ import * as Context from "@effect/data/Context";
2
+ import * as Effect from "@effect/io/Effect";
3
+ import * as FormData from "@effect/platform/Http/FormData";
4
+ import * as IncomingMessage from "@effect/platform/Http/IncomingMessage";
5
+ import * as Error from "@effect/platform/Http/ServerError";
6
+ /** @internal */
7
+ export const TypeId = /*#__PURE__*/Symbol.for("@effect/platform/Http/ServerRequest");
8
+ /** @internal */
9
+ export const serverRequestTag = /*#__PURE__*/Context.Tag(TypeId);
10
+ /** @internal */
11
+ export const formDataRecord = /*#__PURE__*/Effect.map( /*#__PURE__*/Effect.flatMap(serverRequestTag, request => request.formData), FormData.toRecord);
12
+ /** @internal */
13
+ export const schemaHeaders = schema => {
14
+ const parse = IncomingMessage.schemaHeaders(schema);
15
+ return Effect.flatMap(serverRequestTag, parse);
16
+ };
17
+ /** @internal */
18
+ export const schemaBodyJson = schema => {
19
+ const parse = IncomingMessage.schemaBodyJson(schema);
20
+ return Effect.flatMap(serverRequestTag, parse);
21
+ };
22
+ /** @internal */
23
+ export const schemaBodyUrlParams = schema => {
24
+ const parse = IncomingMessage.schemaBodyUrlParams(schema);
25
+ return Effect.flatMap(serverRequestTag, parse);
26
+ };
27
+ /** @internal */
28
+ export const schemaFormData = schema => {
29
+ const parse = FormData.schemaRecord(schema);
30
+ return Effect.flatMap(Effect.flatMap(serverRequestTag, request => request.formData), parse);
31
+ };
32
+ /** @internal */
33
+ export const schemaFormDataJson = schema => {
34
+ const parse = FormData.schemaJson(schema);
35
+ return field => Effect.flatMap(serverRequestTag, request => Effect.flatMap(request.formData, formData => Effect.catchTag(parse(formData, field), "FormDataError", error => Effect.fail(Error.RequestError({
36
+ reason: "Decode",
37
+ request,
38
+ error: error.error
39
+ })))));
40
+ };
41
+ //# sourceMappingURL=serverRequest.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serverRequest.mjs","names":["Context","Effect","FormData","IncomingMessage","Error","TypeId","Symbol","for","serverRequestTag","Tag","formDataRecord","map","flatMap","request","formData","toRecord","schemaHeaders","schema","parse","schemaBodyJson","schemaBodyUrlParams","schemaFormData","schemaRecord","schemaFormDataJson","schemaJson","field","catchTag","error","fail","RequestError","reason"],"sources":["../../../src/internal/http/serverRequest.ts"],"sourcesContent":[null],"mappings":"AAAA,OAAO,KAAKA,OAAO,MAAM,sBAAsB;AAC/C,OAAO,KAAKC,MAAM,MAAM,mBAAmB;AAC3C,OAAO,KAAKC,QAAQ,MAAM,gCAAgC;AAC1D,OAAO,KAAKC,eAAe,MAAM,uCAAuC;AACxE,OAAO,KAAKC,KAAK,MAAM,mCAAmC;AAI1D;AACA,OAAO,MAAMC,MAAM,gBAAyBC,MAAM,CAACC,GAAG,CAAC,qCAAqC,CAAyB;AAErH;AACA,OAAO,MAAMC,gBAAgB,gBAAGR,OAAO,CAACS,GAAG,CAA8BJ,MAAM,CAAC;AAEhF;AACA,OAAO,MAAMK,cAAc,gBAAGT,MAAM,CAACU,GAAG,eACtCV,MAAM,CAACW,OAAO,CAACJ,gBAAgB,EAAGK,OAAO,IAAKA,OAAO,CAACC,QAAQ,CAAC,EAC/DZ,QAAQ,CAACa,QAAQ,CAClB;AAED;AACA,OAAO,MAAMC,aAAa,GAAmDC,MAA2B,IAAI;EAC1G,MAAMC,KAAK,GAAGf,eAAe,CAACa,aAAa,CAACC,MAAM,CAAC;EACnD,OAAOhB,MAAM,CAACW,OAAO,CAACJ,gBAAgB,EAAEU,KAAK,CAAC;AAChD,CAAC;AAED;AACA,OAAO,MAAMC,cAAc,GAAUF,MAA2B,IAAI;EAClE,MAAMC,KAAK,GAAGf,eAAe,CAACgB,cAAc,CAACF,MAAM,CAAC;EACpD,OAAOhB,MAAM,CAACW,OAAO,CAACJ,gBAAgB,EAAEU,KAAK,CAAC;AAChD,CAAC;AAED;AACA,OAAO,MAAME,mBAAmB,GAAmDH,MAA2B,IAAI;EAChH,MAAMC,KAAK,GAAGf,eAAe,CAACiB,mBAAmB,CAACH,MAAM,CAAC;EACzD,OAAOhB,MAAM,CAACW,OAAO,CAACJ,gBAAgB,EAAEU,KAAK,CAAC;AAChD,CAAC;AAED;AACA,OAAO,MAAMG,cAAc,GACzBJ,MAA2B,IACzB;EACF,MAAMC,KAAK,GAAGhB,QAAQ,CAACoB,YAAY,CAACL,MAAM,CAAC;EAC3C,OAAOhB,MAAM,CAACW,OAAO,CACnBX,MAAM,CAACW,OAAO,CAACJ,gBAAgB,EAAGK,OAAO,IAAKA,OAAO,CAACC,QAAQ,CAAC,EAC/DI,KAAK,CACN;AACH,CAAC;AAED;AACA,OAAO,MAAMK,kBAAkB,GAAUN,MAA2B,IAAI;EACtE,MAAMC,KAAK,GAAGhB,QAAQ,CAACsB,UAAU,CAACP,MAAM,CAAC;EACzC,OAAQQ,KAAa,IACnBxB,MAAM,CAACW,OAAO,CAACJ,gBAAgB,EAAGK,OAAO,IACvCZ,MAAM,CAACW,OAAO,CACZC,OAAO,CAACC,QAAQ,EACfA,QAAQ,IACPb,MAAM,CAACyB,QAAQ,CACbR,KAAK,CAACJ,QAAQ,EAAEW,KAAK,CAAC,EACtB,eAAe,EACdE,KAAK,IACJ1B,MAAM,CAAC2B,IAAI,CACTxB,KAAK,CAACyB,YAAY,CAAC;IACjBC,MAAM,EAAE,QAAQ;IAChBjB,OAAO;IACPc,KAAK,EAAEA,KAAK,CAACA;GACd,CAAC,CACH,CACJ,CACJ,CAAC;AACR,CAAC"}
@@ -0,0 +1,82 @@
1
+ import { dual } from "@effect/data/Function";
2
+ import { pipeArguments } from "@effect/data/Pipeable";
3
+ import * as Effect from "@effect/io/Effect";
4
+ import * as Headers from "@effect/platform/Http/Headers";
5
+ import * as ServerRequest from "@effect/platform/Http/ServerRequest";
6
+ import * as UrlParams from "@effect/platform/Http/UrlParams";
7
+ import * as internalBody from "@effect/platform/internal/http/body";
8
+ import * as internalError from "@effect/platform/internal/http/serverError";
9
+ /** @internal */
10
+ export const TypeId = /*#__PURE__*/Symbol.for("@effect/platform/Http/ServerResponse");
11
+ class ServerResponseImpl {
12
+ constructor(status, statusText, headers, body) {
13
+ this.status = status;
14
+ this.statusText = statusText;
15
+ this.headers = headers;
16
+ this.body = body;
17
+ this[TypeId] = TypeId;
18
+ }
19
+ pipe() {
20
+ return pipeArguments(this, arguments);
21
+ }
22
+ }
23
+ /** @internal */
24
+ export const isServerResponse = u => typeof u === "object" && u !== null && TypeId in u;
25
+ /** @internal */
26
+ export const toNonEffectBody = self => self.body._tag === "Effect" ? Effect.map(Effect.catchAll(self.body.effect, error => Effect.flatMap(ServerRequest.ServerRequest, request => Effect.fail(internalError.responseError({
27
+ reason: "Decode",
28
+ request,
29
+ response: self,
30
+ error
31
+ })))), body => setBody(self, body)) : Effect.succeed(self);
32
+ /** @internal */
33
+ export const empty = options => new ServerResponseImpl(options?.status ?? 204, options?.statusText, options?.headers ?? Headers.empty, internalBody.empty);
34
+ /** @internal */
35
+ export const uint8Array = (body, options) => new ServerResponseImpl(options?.status ?? 200, options?.statusText, options?.headers ?? Headers.empty, internalBody.uint8Array(body, options?.contentType));
36
+ /** @internal */
37
+ export const text = (body, options) => new ServerResponseImpl(options?.status ?? 200, options?.statusText, options?.headers ?? Headers.empty, internalBody.text(body, options?.contentType));
38
+ /** @internal */
39
+ export const json = (body, options) => new ServerResponseImpl(options?.status ?? 200, options?.statusText, options?.headers ?? Headers.empty, internalBody.json(body));
40
+ /** @internal */
41
+ export const unsafeJson = (body, options) => new ServerResponseImpl(options?.status ?? 200, options?.statusText, options?.headers ?? Headers.empty, internalBody.unsafeJson(body));
42
+ /** @internal */
43
+ export const schemaJson = schema => {
44
+ const encode = internalBody.jsonSchema(schema);
45
+ return (body, options) => new ServerResponseImpl(options?.status ?? 200, options?.statusText, options?.headers ?? Headers.empty, encode(body));
46
+ };
47
+ /** @internal */
48
+ export const file = (path, options) => Effect.map(internalBody.file(path, options), body => new ServerResponseImpl(options?.status ?? 200, options?.statusText, options?.headers ?? Headers.empty, body));
49
+ /** @internal */
50
+ export const urlParams = (body, options) => new ServerResponseImpl(options?.status ?? 200, options?.statusText, options?.headers ?? Headers.empty, internalBody.text(UrlParams.toString(UrlParams.fromInput(body)), "application/x-www-form-urlencoded"));
51
+ /** @internal */
52
+ export const effect = (body, options) => new ServerResponseImpl(options?.status ?? 200, options?.statusText, options?.headers ?? Headers.empty, internalBody.effect(body));
53
+ /** @internal */
54
+ export const raw = (body, options) => new ServerResponseImpl(options?.status ?? 200, options?.statusText, options?.headers ?? Headers.empty, internalBody.raw(body));
55
+ /** @internal */
56
+ export const formData = (body, options) => new ServerResponseImpl(options?.status ?? 200, options?.statusText, options?.headers ?? Headers.empty, internalBody.formData(body));
57
+ /** @internal */
58
+ export const stream = (body, options) => new ServerResponseImpl(options?.status ?? 200, options?.statusText, options?.headers ?? Headers.empty, internalBody.stream(body, options?.contentType, options?.contentLength));
59
+ /** @internal */
60
+ export const setHeader = /*#__PURE__*/dual(3, (self, key, value) => new ServerResponseImpl(self.status, self.statusText, Headers.set(self.headers, key, value), self.body));
61
+ /** @internal */
62
+ export const setHeaders = /*#__PURE__*/dual(2, (self, input) => new ServerResponseImpl(self.status, self.statusText, Headers.setAll(self.headers, input), self.body));
63
+ /** @internal */
64
+ export const setStatus = /*#__PURE__*/dual(args => isServerResponse(args[0]), (self, status, statusText) => new ServerResponseImpl(status, statusText, self.headers, self.body));
65
+ /** @internal */
66
+ export const setBody = /*#__PURE__*/dual(2, (self, body) => {
67
+ let headers = self.headers;
68
+ if (body._tag === "Empty") {
69
+ headers = Headers.remove(Headers.remove(headers, "Content-Type"), "Content-length");
70
+ } else {
71
+ const contentType = body.contentType;
72
+ if (contentType) {
73
+ headers = Headers.set(headers, "content-type", contentType);
74
+ }
75
+ const contentLength = body.contentLength;
76
+ if (contentLength) {
77
+ headers = Headers.set(headers, "content-length", contentLength.toString());
78
+ }
79
+ }
80
+ return new ServerResponseImpl(self.status, self.statusText, headers, body);
81
+ });
82
+ //# sourceMappingURL=serverResponse.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serverResponse.mjs","names":["dual","pipeArguments","Effect","Headers","ServerRequest","UrlParams","internalBody","internalError","TypeId","Symbol","for","ServerResponseImpl","constructor","status","statusText","headers","body","pipe","arguments","isServerResponse","u","toNonEffectBody","self","_tag","map","catchAll","effect","error","flatMap","request","fail","responseError","reason","response","setBody","succeed","empty","options","uint8Array","contentType","text","json","unsafeJson","schemaJson","schema","encode","jsonSchema","file","path","urlParams","toString","fromInput","raw","formData","stream","contentLength","setHeader","key","value","set","setHeaders","input","setAll","setStatus","args","remove"],"sources":["../../../src/internal/http/serverResponse.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,IAAI,QAAQ,uBAAuB;AAC5C,SAASC,aAAa,QAAQ,uBAAuB;AACrD,OAAO,KAAKC,MAAM,MAAM,mBAAmB;AAI3C,OAAO,KAAKC,OAAO,MAAM,+BAA+B;AAExD,OAAO,KAAKC,aAAa,MAAM,qCAAqC;AAEpE,OAAO,KAAKC,SAAS,MAAM,iCAAiC;AAC5D,OAAO,KAAKC,YAAY,MAAM,qCAAqC;AACnE,OAAO,KAAKC,aAAa,MAAM,4CAA4C;AAI3E;AACA,OAAO,MAAMC,MAAM,gBAA0BC,MAAM,CAACC,GAAG,CAAC,sCAAsC,CAA0B;AAExH,MAAMC,kBAAkB;EAEtBC,YACWC,MAAc,EACdC,UAA8B,EAC9BC,OAAwB,EACxBC,IAAe;IAHf,KAAAH,MAAM,GAANA,MAAM;IACN,KAAAC,UAAU,GAAVA,UAAU;IACV,KAAAC,OAAO,GAAPA,OAAO;IACP,KAAAC,IAAI,GAAJA,IAAI;IAEb,IAAI,CAACR,MAAM,CAAC,GAAGA,MAAM;EACvB;EACAS,IAAIA,CAAA;IACF,OAAOhB,aAAa,CAAC,IAAI,EAAEiB,SAAS,CAAC;EACvC;;AAGF;AACA,OAAO,MAAMC,gBAAgB,GAAIC,CAAU,IACzC,OAAOA,CAAC,KAAK,QAAQ,IAAIA,CAAC,KAAK,IAAI,IAAIZ,MAAM,IAAIY,CAAC;AAEpD;AACA,OAAO,MAAMC,eAAe,GAC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,MAAMkB,OAAO,gBAAGlC,IAAI,CAGzB,CAAC,EAAE,CAACsB,IAAI,EAAEN,IAAI,KAAI;EAClB,IAAID,OAAO,GAAGO,IAAI,CAACP,OAAO;EAC1B,IAAIC,IAAI,CAACO,IAAI,KAAK,OAAO,EAAE;IACzBR,OAAO,GAAGZ,OAAO,CAAC8D,MAAM,CAAC9D,OAAO,CAAC8D,MAAM,CAAClD,OAAO,EAAE,cAAc,CAAC,EAAE,gBAAgB,CAAC;GACpF,MAAM;IACL,MAAMwB,WAAW,GAAGvB,IAAI,CAACuB,WAAW;IACpC,IAAIA,WAAW,EAAE;MACfxB,OAAO,GAAGZ,OAAO,CAACwD,GAAG,CAAC5C,OAAO,EAAE,cAAc,EAAEwB,WAAW,CAAC;;IAG7D,MAAMgB,aAAa,GAAGvC,IAAI,CAACuC,aAAa;IACxC,IAAIA,aAAa,EAAE;MACjBxC,OAAO,GAAGZ,OAAO,CAACwD,GAAG,CAAC5C,OAAO,EAAE,gBAAgB,EAAEwC,aAAa,CAACL,QAAQ,EAAE,CAAC;;;EAG9E,OAAO,IAAIvC,kBAAkB,CAC3BW,IAAI,CAACT,MAAM,EACXS,IAAI,CAACR,UAAU,EACfC,OAAO,EACPC,IAAI,CACL;AACH,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@effect/platform",
3
- "version": "0.11.5",
3
+ "version": "0.12.0",
4
4
  "description": "Unified interfaces for common platform-specific services",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -25,6 +25,7 @@
25
25
  "sideEffects": [],
26
26
  "author": "Effect contributors",
27
27
  "dependencies": {
28
+ "find-my-way": "^7.6.2",
28
29
  "path-browserify": "^1.0.1"
29
30
  },
30
31
  "peerDependencies": {
package/src/FileSystem.ts CHANGED
@@ -219,7 +219,7 @@ export interface FileSystem {
219
219
  */
220
220
  readonly truncate: (
221
221
  path: string,
222
- length?: Size
222
+ length?: SizeInput
223
223
  ) => Effect.Effect<never, PlatformError, void>
224
224
  /**
225
225
  * Change the file system timestamps of the file at `path`.
@@ -255,11 +255,19 @@ export interface FileSystem {
255
255
  */
256
256
  export type Size = Brand.Branded<bigint, "Size">
257
257
 
258
+ /**
259
+ * Represents a size in bytes.
260
+ *
261
+ * @since 1.0.0
262
+ * @category model
263
+ */
264
+ export type SizeInput = bigint | number | Size
265
+
258
266
  /**
259
267
  * @since 1.0.0
260
268
  * @category constructor
261
269
  */
262
- export const Size: (bytes: number | bigint) => Size = internal.Size
270
+ export const Size: (bytes: SizeInput) => Size = internal.Size
263
271
 
264
272
  /**
265
273
  * @since 1.0.0
@@ -360,9 +368,9 @@ export interface SinkOptions extends OpenFileOptions {}
360
368
  */
361
369
  export interface StreamOptions {
362
370
  readonly bufferSize?: number
363
- readonly bytesToRead?: Size
364
- readonly chunkSize?: Size
365
- readonly offset?: Size
371
+ readonly bytesToRead?: SizeInput
372
+ readonly chunkSize?: SizeInput
373
+ readonly offset?: SizeInput
366
374
  }
367
375
 
368
376
  /**
@@ -422,28 +430,15 @@ export const isFile = (u: unknown): u is File => typeof u === "object" && u !==
422
430
  * @category model
423
431
  */
424
432
  export interface File {
425
- readonly [FileTypeId]: (_: never) => unknown
433
+ readonly [FileTypeId]: FileTypeId
426
434
  readonly fd: File.Descriptor
427
435
  readonly stat: Effect.Effect<never, PlatformError, File.Info>
428
- readonly seek: (
429
- offset: Size,
430
- from: SeekMode
431
- ) => Effect.Effect<never, never, void>
432
- readonly read: (
433
- buffer: Uint8Array
434
- ) => Effect.Effect<never, PlatformError, Size>
435
- readonly readAlloc: (
436
- size: Size
437
- ) => Effect.Effect<never, PlatformError, Option<Uint8Array>>
438
- readonly truncate: (
439
- length?: Size
440
- ) => Effect.Effect<never, PlatformError, void>
441
- readonly write: (
442
- buffer: Uint8Array
443
- ) => Effect.Effect<never, PlatformError, Size>
444
- readonly writeAll: (
445
- buffer: Uint8Array
446
- ) => Effect.Effect<never, PlatformError, void>
436
+ readonly seek: (offset: SizeInput, from: SeekMode) => Effect.Effect<never, never, void>
437
+ readonly read: (buffer: Uint8Array) => Effect.Effect<never, PlatformError, Size>
438
+ readonly readAlloc: (size: SizeInput) => Effect.Effect<never, PlatformError, Option<Uint8Array>>
439
+ readonly truncate: (length?: SizeInput) => Effect.Effect<never, PlatformError, void>
440
+ readonly write: (buffer: Uint8Array) => Effect.Effect<never, PlatformError, Size>
441
+ readonly writeAll: (buffer: Uint8Array) => Effect.Effect<never, PlatformError, void>
447
442
  }
448
443
 
449
444
  /**
@@ -0,0 +1,19 @@
1
+ /**
2
+ * @since 1.0.0
3
+ */
4
+ import type * as Effect from "@effect/io/Effect"
5
+ import type * as ServerRequest from "@effect/platform/Http/ServerRequest"
6
+ import type * as ServerResponse from "@effect/platform/Http/ServerResponse"
7
+
8
+ /**
9
+ * @since 1.0.0
10
+ * @category models
11
+ */
12
+ export interface HttpApp<R, E, A> extends Effect.Effect<R | ServerRequest.ServerRequest, E, A> {
13
+ }
14
+
15
+ /**
16
+ * @since 1.0.0
17
+ * @category models
18
+ */
19
+ export type Default<R, E> = HttpApp<R, E, ServerResponse.ServerResponse>
package/src/Http/Body.ts CHANGED
@@ -2,6 +2,8 @@
2
2
  * @since 1.0.0
3
3
  */
4
4
  import type * as Effect from "@effect/io/Effect"
5
+ import type * as PlatformError from "@effect/platform/Error"
6
+ import type * as FileSystem from "@effect/platform/FileSystem"
5
7
  import * as internal from "@effect/platform/internal/http/body"
6
8
  import type * as Schema from "@effect/schema/Schema"
7
9
  import type * as Stream_ from "@effect/stream/Stream"
@@ -22,7 +24,13 @@ export type TypeId = typeof TypeId
22
24
  * @since 1.0.0
23
25
  * @category models
24
26
  */
25
- export type Body = Empty | Raw | Bytes | BytesEffect | FormData | Stream
27
+ export type Body = Empty | Raw | Uint8Array | EffectBody | FormData | Stream
28
+
29
+ /**
30
+ * @since 1.0.0
31
+ * @category models
32
+ */
33
+ export type NonEffect = Exclude<Body, EffectBody>
26
34
 
27
35
  /**
28
36
  * @since 1.0.0
@@ -73,49 +81,57 @@ export const raw: (body: unknown) => Raw = internal.raw
73
81
  * @since 1.0.0
74
82
  * @category models
75
83
  */
76
- export interface Bytes extends Body.Proto {
77
- readonly _tag: "Bytes"
78
- readonly body: Uint8Array
84
+ export interface Uint8Array extends Body.Proto {
85
+ readonly _tag: "Uint8Array"
86
+ readonly body: globalThis.Uint8Array
87
+ readonly contentType: string
88
+ readonly contentLength: number
79
89
  }
80
90
 
81
91
  /**
82
92
  * @since 1.0.0
83
93
  * @category constructors
84
94
  */
85
- export const bytes: (body: Uint8Array) => Bytes = internal.bytes
95
+ export const uint8Array: (body: globalThis.Uint8Array) => Uint8Array = internal.uint8Array
86
96
 
87
97
  /**
88
98
  * @since 1.0.0
89
99
  * @category constructors
90
100
  */
91
- export const text: (body: string, contentType?: string) => Bytes = internal.text
101
+ export const text: (body: string, contentType?: string) => Uint8Array = internal.text
92
102
 
93
103
  /**
94
104
  * @since 1.0.0
95
105
  * @category models
96
106
  */
97
- export interface BytesEffect extends Body.Proto {
98
- readonly _tag: "BytesEffect"
99
- readonly body: Effect.Effect<never, unknown, Uint8Array>
107
+ export interface EffectBody extends Body.Proto {
108
+ readonly _tag: "Effect"
109
+ readonly effect: Effect.Effect<never, unknown, NonEffect>
100
110
  }
101
111
 
102
112
  /**
103
113
  * @since 1.0.0
104
114
  * @category constructors
105
115
  */
106
- export const bytesEffect: (body: Effect.Effect<never, unknown, Uint8Array>) => BytesEffect = internal.bytesEffect
116
+ export const effect: (body: Effect.Effect<never, unknown, NonEffect>) => EffectBody = internal.effect
107
117
 
108
118
  /**
109
119
  * @since 1.0.0
110
120
  * @category constructors
111
121
  */
112
- export const json: (body: unknown) => BytesEffect = internal.json
122
+ export const unsafeJson: (body: unknown) => Uint8Array = internal.unsafeJson
113
123
 
114
124
  /**
115
125
  * @since 1.0.0
116
126
  * @category constructors
117
127
  */
118
- export const jsonSchema: <I, A>(schema: Schema.Schema<I, A>) => (body: A) => BytesEffect = internal.jsonSchema
128
+ export const json: (body: unknown) => EffectBody = internal.json
129
+
130
+ /**
131
+ * @since 1.0.0
132
+ * @category constructors
133
+ */
134
+ export const jsonSchema: <I, A>(schema: Schema.Schema<I, A>) => (body: A) => EffectBody = internal.jsonSchema
119
135
 
120
136
  /**
121
137
  * @since 1.0.0
@@ -138,11 +154,22 @@ export const formData: (body: globalThis.FormData) => FormData = internal.formDa
138
154
  */
139
155
  export interface Stream extends Body.Proto {
140
156
  readonly _tag: "Stream"
141
- readonly stream: Stream_.Stream<never, unknown, Uint8Array>
157
+ readonly stream: Stream_.Stream<never, unknown, globalThis.Uint8Array>
158
+ readonly contentType: string
159
+ readonly contentLength?: number
142
160
  }
143
161
 
144
162
  /**
145
163
  * @since 1.0.0
146
164
  * @category constructors
147
165
  */
148
- export const stream: (body: Stream_.Stream<never, unknown, Uint8Array>) => Stream = internal.stream
166
+ export const stream: (body: Stream_.Stream<never, unknown, globalThis.Uint8Array>) => Stream = internal.stream
167
+
168
+ /**
169
+ * @since 1.0.0
170
+ * @category constructors
171
+ */
172
+ export const file: (
173
+ path: string,
174
+ options?: FileSystem.StreamOptions & { readonly contentType?: string }
175
+ ) => Effect.Effect<FileSystem.FileSystem, PlatformError.PlatformError, Stream> = internal.file
@@ -49,7 +49,7 @@ export const Client: Context.Tag<Client.Default, Client.Default> = internal.tag
49
49
  * @since 1.0.0
50
50
  * @category layers
51
51
  */
52
- export const fetchLayer: Layer.Layer<never, never, Client.Default> = internal.fetchLayer
52
+ export const layer: Layer.Layer<never, never, Client.Default> = internal.layer
53
53
 
54
54
  /**
55
55
  * @since 1.0.0
@@ -189,8 +189,11 @@ export const filterStatusOk: <R, E>(
189
189
  * @since 1.0.0
190
190
  * @category constructors
191
191
  */
192
- export const make: <R, E, A>(f: (request: ClientRequest.ClientRequest) => Effect.Effect<R, E, A>) => Client<R, E, A> =
193
- internal.make
192
+ export const make: (
193
+ f: (
194
+ request: ClientRequest.ClientRequest.NonEffectBody
195
+ ) => Effect.Effect<never, Error.HttpClientError, ClientResponse.ClientResponse>
196
+ ) => Client.Default = internal.make
194
197
 
195
198
  /**
196
199
  * @since 1.0.0