@effect/platform 0.18.4 → 0.18.5

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 (72) hide show
  1. package/Command/dist/effect-platform-Command.esm.js +12 -200
  2. package/CommandExecutor/dist/effect-platform-CommandExecutor.esm.js +9 -71
  3. package/Effectify/dist/effect-platform-Effectify.esm.js +2 -23
  4. package/Error/dist/effect-platform-Error.esm.js +2 -54
  5. package/FileSystem/dist/effect-platform-FileSystem.esm.js +10 -177
  6. package/Http/Body/dist/effect-platform-Http-Body.esm.js +13 -151
  7. package/Http/Client/dist/effect-platform-Http-Client.esm.js +28 -164
  8. package/Http/ClientError/dist/effect-platform-Http-ClientError.esm.js +3 -48
  9. package/Http/ClientRequest/dist/effect-platform-Http-ClientRequest.esm.js +20 -241
  10. package/Http/ClientResponse/dist/effect-platform-Http-ClientResponse.esm.js +22 -35
  11. package/Http/Etag/dist/effect-platform-Http-Etag.esm.js +17 -1
  12. package/Http/FormData/dist/effect-platform-Http-FormData.esm.js +17 -155
  13. package/Http/Headers/dist/effect-platform-Http-Headers.esm.js +4 -74
  14. package/Http/IncomingMessage/dist/effect-platform-Http-IncomingMessage.esm.js +6 -1
  15. package/Http/Middleware/dist/effect-platform-Http-Middleware.esm.js +30 -52
  16. package/Http/Platform/dist/effect-platform-Http-Platform.esm.js +56 -1
  17. package/Http/Router/dist/effect-platform-Http-Router.esm.js +25 -224
  18. package/Http/Server/dist/effect-platform-Http-Server.esm.js +18 -1
  19. package/Http/ServerError/dist/effect-platform-Http-ServerError.esm.js +2 -70
  20. package/Http/ServerRequest/dist/effect-platform-Http-ServerRequest.esm.js +20 -65
  21. package/Http/ServerResponse/dist/effect-platform-Http-ServerResponse.esm.js +21 -126
  22. package/Http/UrlParams/dist/effect-platform-Http-UrlParams.esm.js +4 -101
  23. package/HttpClient/dist/effect-platform-HttpClient.esm.js +32 -18
  24. package/HttpServer/dist/effect-platform-HttpServer.esm.js +36 -24
  25. package/KeyValueStore/dist/effect-platform-KeyValueStore.esm.js +15 -78
  26. package/Path/dist/effect-platform-Path.esm.js +8 -33
  27. package/Runtime/dist/effect-platform-Runtime.esm.js +3 -26
  28. package/dist/App-687366d8.esm.js +5 -0
  29. package/dist/Body-ec1353f9.esm.js +170 -0
  30. package/dist/Client-52ebd74a.esm.js +346 -0
  31. package/dist/ClientError-98b5da8c.esm.js +55 -0
  32. package/dist/ClientRequest-fc429335.esm.js +281 -0
  33. package/dist/ClientResponse-9f276554.esm.js +46 -0
  34. package/dist/Command-d8ab0c8d.esm.js +403 -0
  35. package/dist/CommandExecutor-5807b66b.esm.js +80 -0
  36. package/dist/Effectify-e5a9d266.esm.js +43 -0
  37. package/dist/Error-3099667c.esm.js +75 -0
  38. package/dist/FileSystem-7e31dccd.esm.js +271 -0
  39. package/dist/FormData-f54de878.esm.js +270 -0
  40. package/dist/Headers-58b56a08.esm.js +85 -0
  41. package/dist/HttpClient-27710864.esm.js +24 -0
  42. package/dist/HttpServer-e1d88a1c.esm.js +30 -0
  43. package/{internal/keyValueStore.esm.js → dist/KeyValueStore-2f9a70bf.esm.js} +102 -15
  44. package/dist/Middleware-27760041.esm.js +105 -0
  45. package/{internal/path.esm.js → dist/Path-46f84ba7.esm.js} +40 -4
  46. package/dist/Router-bf32317a.esm.js +454 -0
  47. package/dist/Runtime-7265fb98.esm.js +31 -0
  48. package/dist/ServerError-04ad5b57.esm.js +99 -0
  49. package/dist/ServerRequest-03161edc.esm.js +125 -0
  50. package/dist/ServerResponse-675e9456.esm.js +249 -0
  51. package/dist/UrlParams-1286c728.esm.js +114 -0
  52. package/{internal/http/body.esm.js → dist/body-20d78ec1.esm.js} +2 -2
  53. package/{internal/http/clientError.esm.js → dist/clientError-c4e1466c.esm.js} +1 -1
  54. package/{internal/http/clientRequest.esm.js → dist/clientRequest-1e9e0b0d.esm.js} +4 -4
  55. package/{internal/http/clientResponse.esm.js → dist/clientResponse-ce25dbf3.esm.js} +5 -5
  56. package/{internal/commandExecutor.esm.js → dist/commandExecutor-d6457489.esm.js} +1 -1
  57. package/dist/effect-platform.esm.js +58 -20
  58. package/package.json +1 -2
  59. package/internal/command.esm.js +0 -185
  60. package/internal/effectify.esm.js +0 -18
  61. package/internal/error.esm.js +0 -17
  62. package/internal/fileSystem.esm.js +0 -82
  63. package/internal/http/client.esm.js +0 -157
  64. package/internal/http/etag.esm.js +0 -19
  65. package/internal/http/formData.esm.js +0 -95
  66. package/internal/http/middleware.esm.js +0 -46
  67. package/internal/http/platform.esm.js +0 -52
  68. package/internal/http/router.esm.js +0 -199
  69. package/internal/http/server.esm.js +0 -20
  70. package/internal/http/serverError.esm.js +0 -23
  71. package/internal/http/serverRequest.esm.js +0 -50
  72. package/internal/http/serverResponse.esm.js +0 -105
@@ -4,18 +4,18 @@ import * as Effect from 'effect/Effect';
4
4
  import { dual, pipe } from 'effect/Function';
5
5
  import * as Layer from 'effect/Layer';
6
6
  import * as Option from 'effect/Option';
7
- import { FileSystem } from '../FileSystem/dist/effect-platform-FileSystem.esm.js';
8
- import { Path } from '../Path/dist/effect-platform-Path.esm.js';
7
+ import { a as FileSystem } from './FileSystem-7e31dccd.esm.js';
8
+ import { a as Path } from './Path-46f84ba7.esm.js';
9
9
 
10
10
  /** @internal */
11
- const TypeId = /*#__PURE__*/Symbol.for("@effect/platform/KeyValueStore");
11
+ const TypeId$1 = /*#__PURE__*/Symbol.for("@effect/platform/KeyValueStore");
12
12
 
13
13
  /** @internal */
14
- const keyValueStoreTag = /*#__PURE__*/Context.Tag(TypeId);
14
+ const keyValueStoreTag = /*#__PURE__*/Context.Tag(TypeId$1);
15
15
 
16
16
  /** @internal */
17
- const make = impl => keyValueStoreTag.of({
18
- [TypeId]: TypeId,
17
+ const make$1 = impl => keyValueStoreTag.of({
18
+ [TypeId$1]: TypeId$1,
19
19
  has: key => Effect.map(impl.get(key), Option.isSome),
20
20
  isEmpty: Effect.map(impl.size, size => size === 0),
21
21
  modify: (key, f) => Effect.flatMap(impl.get(key), o => {
@@ -32,7 +32,7 @@ const make = impl => keyValueStoreTag.of({
32
32
  });
33
33
 
34
34
  /** @internal */
35
- const prefix = /*#__PURE__*/dual(2, (self, prefix) => ({
35
+ const prefix$1 = /*#__PURE__*/dual(2, (self, prefix) => ({
36
36
  ...self,
37
37
  get: key => self.get(`${prefix}${key}`),
38
38
  set: (key, value) => self.set(`${prefix}${key}`, value),
@@ -42,7 +42,7 @@ const prefix = /*#__PURE__*/dual(2, (self, prefix) => ({
42
42
  }));
43
43
 
44
44
  /** @internal */
45
- const SchemaStoreTypeId = /*#__PURE__*/Symbol.for("@effect/platform/KeyValueStore/SchemaStore");
45
+ const SchemaStoreTypeId$1 = /*#__PURE__*/Symbol.for("@effect/platform/KeyValueStore/SchemaStore");
46
46
 
47
47
  /** @internal */
48
48
  const makeSchemaStore = (store, schema) => {
@@ -62,7 +62,7 @@ const makeSchemaStore = (store, schema) => {
62
62
  return Effect.as(set(key, newValue), Option.some(newValue));
63
63
  });
64
64
  return {
65
- [SchemaStoreTypeId]: SchemaStoreTypeId,
65
+ [SchemaStoreTypeId$1]: SchemaStoreTypeId$1,
66
66
  get,
67
67
  set,
68
68
  modify,
@@ -75,9 +75,9 @@ const makeSchemaStore = (store, schema) => {
75
75
  };
76
76
 
77
77
  /** @internal */
78
- const layerMemory = /*#__PURE__*/Layer.sync(keyValueStoreTag, () => {
78
+ const layerMemory$1 = /*#__PURE__*/Layer.sync(keyValueStoreTag, () => {
79
79
  const store = new Map();
80
- return make({
80
+ return make$1({
81
81
  get: key => Effect.sync(() => Option.fromNullable(store.get(key))),
82
82
  set: (key, value) => Effect.sync(() => store.set(key, value)),
83
83
  remove: key => Effect.sync(() => store.delete(key)),
@@ -87,7 +87,7 @@ const layerMemory = /*#__PURE__*/Layer.sync(keyValueStoreTag, () => {
87
87
  });
88
88
 
89
89
  /** @internal */
90
- const layerFileSystem = directory => Layer.effect(keyValueStoreTag, Effect.gen(function* (_) {
90
+ const layerFileSystem$1 = directory => Layer.effect(keyValueStoreTag, Effect.gen(function* (_) {
91
91
  const fs = yield* _(FileSystem);
92
92
  const path = yield* _(Path);
93
93
  const keyPath = key => path.join(directory, encodeURIComponent(key));
@@ -96,7 +96,7 @@ const layerFileSystem = directory => Layer.effect(keyValueStoreTag, Effect.gen(f
96
96
  recursive: true
97
97
  }));
98
98
  }
99
- return make({
99
+ return make$1({
100
100
  get: key => pipe(Effect.map(fs.readFileString(keyPath(key)), Option.some), Effect.catchTag("SystemError", sysError => sysError.reason === "NotFound" ? Effect.succeed(Option.none()) : Effect.fail(sysError))),
101
101
  set: (key, value) => fs.writeFileString(keyPath(key), value),
102
102
  remove: key => fs.remove(keyPath(key)),
@@ -111,7 +111,7 @@ const layerFileSystem = directory => Layer.effect(keyValueStoreTag, Effect.gen(f
111
111
  }));
112
112
 
113
113
  /** @internal */
114
- const layerSchema = (schema, tagIdentifier) => {
114
+ const layerSchema$1 = (schema, tagIdentifier) => {
115
115
  const tag = Context.Tag(tagIdentifier);
116
116
  const layer = Layer.effect(tag, Effect.map(keyValueStoreTag, store => store.forSchema(schema)));
117
117
  return {
@@ -120,4 +120,91 @@ const layerSchema = (schema, tagIdentifier) => {
120
120
  };
121
121
  };
122
122
 
123
- export { SchemaStoreTypeId, TypeId, keyValueStoreTag, layerFileSystem, layerMemory, layerSchema, make, prefix };
123
+ /**
124
+ * @since 1.0.0
125
+ */
126
+ /**
127
+ * @since 1.0.0
128
+ * @category type id
129
+ */
130
+ const TypeId = TypeId$1;
131
+
132
+ /**
133
+ * @since 1.0.0
134
+ * @category type id
135
+ */
136
+
137
+ /**
138
+ * @since 1.0.0
139
+ * @category models
140
+ */
141
+
142
+ /**
143
+ * @since 1.0.0
144
+ */
145
+
146
+ /**
147
+ * @since 1.0.0
148
+ * @category tags
149
+ */
150
+ const KeyValueStore = keyValueStoreTag;
151
+
152
+ /**
153
+ * @since 1.0.0
154
+ * @category constructors
155
+ */
156
+ const make = make$1;
157
+
158
+ /**
159
+ * @since 1.0.0
160
+ * @category combinators
161
+ */
162
+ const prefix = prefix$1;
163
+
164
+ /**
165
+ * @since 1.0.0
166
+ * @category layers
167
+ */
168
+ const layerMemory = layerMemory$1;
169
+
170
+ /**
171
+ * @since 1.0.0
172
+ * @category layers
173
+ */
174
+ const layerFileSystem = layerFileSystem$1;
175
+
176
+ /**
177
+ * @since 1.0.0
178
+ * @category type id
179
+ */
180
+ const SchemaStoreTypeId = SchemaStoreTypeId$1;
181
+
182
+ /**
183
+ * @since 1.0.0
184
+ * @category type id
185
+ */
186
+
187
+ /**
188
+ * @since 1.0.0
189
+ * @category models
190
+ */
191
+
192
+ /**
193
+ * @since 1.0.0
194
+ * @category layers
195
+ */
196
+ const layerSchema = layerSchema$1;
197
+
198
+ var KeyValueStore$1 = /*#__PURE__*/Object.freeze({
199
+ __proto__: null,
200
+ TypeId: TypeId,
201
+ KeyValueStore: KeyValueStore,
202
+ make: make,
203
+ prefix: prefix,
204
+ layerMemory: layerMemory,
205
+ layerFileSystem: layerFileSystem,
206
+ SchemaStoreTypeId: SchemaStoreTypeId,
207
+ layerSchema: layerSchema
208
+ });
209
+
210
+ export { KeyValueStore$1 as K, SchemaStoreTypeId as S, TypeId as T, KeyValueStore as a, layerFileSystem as b, layerSchema as c, layerMemory as l, make as m, prefix as p };
@@ -0,0 +1,105 @@
1
+ import * as Effect from 'effect/Effect';
2
+ import { flow } from 'effect/Function';
3
+ import { s as set } from './Headers-58b56a08.esm.js';
4
+ import { schemaExternalSpan } from '../Http/IncomingMessage/dist/effect-platform-Http-IncomingMessage.esm.js';
5
+ import { a as ServerRequest } from './ServerRequest-03161edc.esm.js';
6
+ import { s as setHeader } from './ServerResponse-675e9456.esm.js';
7
+
8
+ /** @internal */
9
+ const make$1 = middleware => middleware;
10
+
11
+ /** @internal */
12
+ const logger$1 = /*#__PURE__*/make$1(httpApp => {
13
+ let counter = 0;
14
+ return Effect.flatMap(ServerRequest, request => Effect.withLogSpan(Effect.onExit(httpApp, exit => exit._tag === "Failure" ? Effect.annotateLogs(Effect.log(exit.cause), {
15
+ "http.method": request.method,
16
+ "http.url": request.url,
17
+ "http.status": 500
18
+ }) : Effect.annotateLogs(Effect.log(""), {
19
+ "http.method": request.method,
20
+ "http.url": request.url,
21
+ "http.status": exit.value.status
22
+ })), `http.span.${++counter}`));
23
+ });
24
+
25
+ /** @internal */
26
+ const tracer$1 = /*#__PURE__*/make$1(httpApp => Effect.flatMap(ServerRequest, request => Effect.flatMap(Effect.orElseSucceed(schemaExternalSpan(request), () => undefined), parent => Effect.withSpan(Effect.tap(httpApp, response => Effect.annotateCurrentSpan("http.status", response.status)), `http ${request.method}`, {
27
+ attributes: {
28
+ "http.method": request.method,
29
+ "http.url": request.url
30
+ },
31
+ parent
32
+ }))));
33
+
34
+ /** @internal */
35
+ const b3Response$1 = /*#__PURE__*/make$1(httpApp => Effect.flatMap(Effect.currentSpan, span => span._tag === "Some" ? Effect.map(httpApp, res => setHeader(res, "b3", `${span.value.traceId}-${span.value.spanId}-1${span.value.parent._tag === "Some" ? `-${span.value.parent.value.spanId}` : ""}`)) : httpApp));
36
+
37
+ /** @internal */
38
+ const xForwardedHeaders$1 = /*#__PURE__*/make$1(httpApp => Effect.updateService(httpApp, ServerRequest, request => request.headers["x-forwarded-host"] ? request.modify({
39
+ headers: set(request.headers, "host", request.headers["x-forwarded-host"]),
40
+ remoteAddress: request.headers["x-forwarded-for"]?.split(",")[0].trim()
41
+ }) : request));
42
+
43
+ /** @internal */
44
+ const loggerTracer$1 = /*#__PURE__*/flow(tracer$1, logger$1);
45
+
46
+ /**
47
+ * @since 1.0.0
48
+ */
49
+
50
+ /**
51
+ * @since 1.0.0
52
+ * @category models
53
+ */
54
+
55
+ /**
56
+ * @since 1.0.0
57
+ */
58
+
59
+ /**
60
+ * @since 1.0.0
61
+ * @category constructors
62
+ */
63
+ const make = make$1;
64
+
65
+ /**
66
+ * @since 1.0.0
67
+ * @category constructors
68
+ */
69
+ const b3Response = b3Response$1;
70
+
71
+ /**
72
+ * @since 1.0.0
73
+ * @category constructors
74
+ */
75
+ const logger = logger$1;
76
+
77
+ /**
78
+ * @since 1.0.0
79
+ * @category constructors
80
+ */
81
+ const tracer = tracer$1;
82
+
83
+ /**
84
+ * @since 1.0.0
85
+ * @category constructors
86
+ */
87
+ const loggerTracer = loggerTracer$1;
88
+
89
+ /**
90
+ * @since 1.0.0
91
+ * @category constructors
92
+ */
93
+ const xForwardedHeaders = xForwardedHeaders$1;
94
+
95
+ var Middleware = /*#__PURE__*/Object.freeze({
96
+ __proto__: null,
97
+ make: make,
98
+ b3Response: b3Response,
99
+ logger: logger,
100
+ tracer: tracer,
101
+ loggerTracer: loggerTracer,
102
+ xForwardedHeaders: xForwardedHeaders
103
+ });
104
+
105
+ export { Middleware as M, loggerTracer as a, b3Response as b, logger as l, make as m, tracer as t, xForwardedHeaders as x };
@@ -3,13 +3,13 @@ import * as Effect from 'effect/Effect';
3
3
  import { identity } from 'effect/Function';
4
4
  import * as Layer from 'effect/Layer';
5
5
  import * as PathB from 'path-browserify';
6
- import { BadArgument } from '../Error/dist/effect-platform-Error.esm.js';
6
+ import { B as BadArgument } from './Error-3099667c.esm.js';
7
7
 
8
8
  /** @internal */
9
- const Path = /*#__PURE__*/Tag("@effect/platform/Path");
9
+ const Path$2 = /*#__PURE__*/Tag("@effect/platform/Path");
10
10
 
11
11
  /** @internal */
12
- const layer = /*#__PURE__*/Layer.succeed(Path, /*#__PURE__*/Path.of({
12
+ const layer$1 = /*#__PURE__*/Layer.succeed(Path$2, /*#__PURE__*/Path$2.of({
13
13
  ...PathB,
14
14
  fromFileUrl,
15
15
  toFileUrl,
@@ -89,4 +89,40 @@ function encodePathChars(filepath) {
89
89
  return filepath;
90
90
  }
91
91
 
92
- export { Path, layer };
92
+ /**
93
+ * @since 1.0.0
94
+ */
95
+
96
+ /**
97
+ * @since 1.0.0
98
+ * @category model
99
+ */
100
+
101
+ /**
102
+ * @since 1.0.0
103
+ */
104
+
105
+ /**
106
+ * @since 1.0.0
107
+ * @category tag
108
+ */
109
+ const Path = Path$2;
110
+
111
+ /**
112
+ * An implementation of the Path interface that can be used in all environments
113
+ * (including browsers).
114
+ *
115
+ * It uses the POSIX standard for paths.
116
+ *
117
+ * @since 1.0.0
118
+ * @category layer
119
+ */
120
+ const layer = layer$1;
121
+
122
+ var Path$1 = /*#__PURE__*/Object.freeze({
123
+ __proto__: null,
124
+ Path: Path,
125
+ layer: layer
126
+ });
127
+
128
+ export { Path$1 as P, Path as a, layer as l };