@effect/platform 0.67.1 → 0.68.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/README.md +66 -52
  2. package/dist/cjs/FetchHttpClient.js.map +1 -1
  3. package/dist/cjs/HttpClient.js +43 -31
  4. package/dist/cjs/HttpClient.js.map +1 -1
  5. package/dist/cjs/HttpClientRequest.js.map +1 -1
  6. package/dist/cjs/PlatformConfigProvider.js +24 -1
  7. package/dist/cjs/PlatformConfigProvider.js.map +1 -1
  8. package/dist/cjs/internal/fetchHttpClient.js +1 -1
  9. package/dist/cjs/internal/fetchHttpClient.js.map +1 -1
  10. package/dist/cjs/internal/httpClient.js +41 -38
  11. package/dist/cjs/internal/httpClient.js.map +1 -1
  12. package/dist/cjs/internal/httpClientRequest.js +5 -9
  13. package/dist/cjs/internal/httpClientRequest.js.map +1 -1
  14. package/dist/cjs/internal/platformConfigProvider.js +117 -0
  15. package/dist/cjs/internal/platformConfigProvider.js.map +1 -0
  16. package/dist/dts/FetchHttpClient.d.ts +1 -1
  17. package/dist/dts/FetchHttpClient.d.ts.map +1 -1
  18. package/dist/dts/HttpApiClient.d.ts +2 -2
  19. package/dist/dts/HttpApiClient.d.ts.map +1 -1
  20. package/dist/dts/HttpClient.d.ts +118 -186
  21. package/dist/dts/HttpClient.d.ts.map +1 -1
  22. package/dist/dts/HttpClientRequest.d.ts +2 -5
  23. package/dist/dts/HttpClientRequest.d.ts.map +1 -1
  24. package/dist/dts/HttpServer.d.ts +1 -1
  25. package/dist/dts/HttpServer.d.ts.map +1 -1
  26. package/dist/dts/PlatformConfigProvider.d.ts +23 -0
  27. package/dist/dts/PlatformConfigProvider.d.ts.map +1 -1
  28. package/dist/dts/internal/httpClient.d.ts +23 -1
  29. package/dist/dts/internal/httpClient.d.ts.map +1 -1
  30. package/dist/dts/internal/platformConfigProvider.d.ts +2 -0
  31. package/dist/dts/internal/platformConfigProvider.d.ts.map +1 -0
  32. package/dist/esm/FetchHttpClient.js.map +1 -1
  33. package/dist/esm/HttpClient.js +42 -30
  34. package/dist/esm/HttpClient.js.map +1 -1
  35. package/dist/esm/HttpClientRequest.js.map +1 -1
  36. package/dist/esm/PlatformConfigProvider.js +23 -0
  37. package/dist/esm/PlatformConfigProvider.js.map +1 -1
  38. package/dist/esm/internal/fetchHttpClient.js +1 -1
  39. package/dist/esm/internal/fetchHttpClient.js.map +1 -1
  40. package/dist/esm/internal/httpClient.js +29 -33
  41. package/dist/esm/internal/httpClient.js.map +1 -1
  42. package/dist/esm/internal/httpClientRequest.js +4 -8
  43. package/dist/esm/internal/httpClientRequest.js.map +1 -1
  44. package/dist/esm/internal/platformConfigProvider.js +106 -0
  45. package/dist/esm/internal/platformConfigProvider.js.map +1 -0
  46. package/package.json +2 -2
  47. package/src/FetchHttpClient.ts +1 -1
  48. package/src/HttpApiClient.ts +2 -2
  49. package/src/HttpClient.ts +258 -279
  50. package/src/HttpClientRequest.ts +2 -7
  51. package/src/HttpServer.ts +1 -1
  52. package/src/PlatformConfigProvider.ts +30 -0
  53. package/src/internal/fetchHttpClient.ts +1 -1
  54. package/src/internal/httpClient.ts +191 -303
  55. package/src/internal/httpClientRequest.ts +4 -10
  56. package/src/internal/platformConfigProvider.ts +148 -0
@@ -6,16 +6,13 @@ import type * as Schema from "@effect/schema/Schema"
6
6
  import type * as Effect from "effect/Effect"
7
7
  import type { Inspectable } from "effect/Inspectable"
8
8
  import type * as Option from "effect/Option"
9
+ import type { Pipeable } from "effect/Pipeable"
9
10
  import type { Redacted } from "effect/Redacted"
10
- import type { Scope } from "effect/Scope"
11
11
  import type * as Stream from "effect/Stream"
12
12
  import type * as PlatformError from "./Error.js"
13
13
  import type * as FileSystem from "./FileSystem.js"
14
14
  import type * as Headers from "./Headers.js"
15
15
  import type * as Body from "./HttpBody.js"
16
- import type { HttpClient } from "./HttpClient.js"
17
- import type { HttpClientError } from "./HttpClientError.js"
18
- import type { HttpClientResponse } from "./HttpClientResponse.js"
19
16
  import type { HttpMethod } from "./HttpMethod.js"
20
17
  import * as internal from "./internal/httpClientRequest.js"
21
18
  import type * as UrlParams from "./UrlParams.js"
@@ -36,9 +33,7 @@ export type TypeId = typeof TypeId
36
33
  * @since 1.0.0
37
34
  * @category models
38
35
  */
39
- export interface HttpClientRequest
40
- extends Effect.Effect<HttpClientResponse, HttpClientError, HttpClient.Service | Scope>, Inspectable
41
- {
36
+ export interface HttpClientRequest extends Inspectable, Pipeable {
42
37
  readonly [TypeId]: TypeId
43
38
  readonly method: HttpMethod
44
39
  readonly url: string
package/src/HttpServer.ts CHANGED
@@ -229,5 +229,5 @@ export const withLogAddress: <A, E, R>(layer: Layer.Layer<A, E, R>) => Layer.Lay
229
229
  * @since 1.0.0
230
230
  * @category layers
231
231
  */
232
- export const layerTestClient: Layer.Layer<Client.HttpClient.Service, never, Client.HttpClient.Service | HttpServer> =
232
+ export const layerTestClient: Layer.Layer<Client.HttpClient, never, Client.HttpClient | HttpServer> =
233
233
  internal.layerTestClient
@@ -15,6 +15,7 @@ import * as HashSet from "effect/HashSet"
15
15
  import * as Layer from "effect/Layer"
16
16
  import { isPlatformError, type PlatformError } from "./Error.js"
17
17
  import * as FileSystem from "./FileSystem.js"
18
+ import * as internal from "./internal/platformConfigProvider.js"
18
19
  import * as Path from "./Path.js"
19
20
 
20
21
  /**
@@ -111,3 +112,32 @@ export const layerFileTree = (options?: {
111
112
  Effect.map(Layer.setConfigProvider),
112
113
  Layer.unwrapEffect
113
114
  )
115
+
116
+ /**
117
+ * Create a dotenv ConfigProvider.
118
+ *
119
+ * @category constructors
120
+ * @since 1.0.0
121
+ */
122
+ export const fromDotEnv: (
123
+ paths: string
124
+ ) => Effect.Effect<ConfigProvider.ConfigProvider, PlatformError, FileSystem.FileSystem> = internal.fromDotEnv
125
+
126
+ /**
127
+ * Add the dotenv ConfigProvider to the environment, as a fallback to the current ConfigProvider.
128
+ * If the file is not found, a debug log is produced and empty layer is returned.
129
+ *
130
+ * @since 1.0.0
131
+ * @category layers
132
+ */
133
+ export const layerDotEnvAdd: (path: string) => Layer.Layer<never, never, FileSystem.FileSystem> =
134
+ internal.layerDotEnvAdd
135
+
136
+ /**
137
+ * Add the dotenv ConfigProvider to the environment, replacing the current ConfigProvider.
138
+ *
139
+ * @since 1.0.0
140
+ * @category layers
141
+ */
142
+ export const layerDotEnv: (path: string) => Layer.Layer<never, PlatformError, FileSystem.FileSystem> =
143
+ internal.layerDotEnv
@@ -11,7 +11,7 @@ export const fetchTagKey = "@effect/platform/FetchHttpClient/Fetch"
11
11
  /** @internal */
12
12
  export const requestInitTagKey = "@effect/platform/FetchHttpClient/FetchOptions"
13
13
 
14
- const fetch: Client.HttpClient.Service = client.makeService((request, url, signal, fiber) => {
14
+ const fetch: Client.HttpClient = client.make((request, url, signal, fiber) => {
15
15
  const context = fiber.getFiberRef(FiberRef.currentContext)
16
16
  const fetch: typeof globalThis.fetch = context.unsafeMap.get(fetchTagKey) ?? globalThis.fetch
17
17
  const options: RequestInit = context.unsafeMap.get(requestInitTagKey) ?? {}