viell-effect-schema-http 0.1.0-rc.1 → 0.1.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 (47) hide show
  1. package/README.md +78 -47
  2. package/dist/concurrency/Interaction.d.ts +39 -6
  3. package/dist/concurrency/Interaction.d.ts.map +1 -1
  4. package/dist/concurrency/Interaction.js +25 -4
  5. package/dist/concurrency/Interaction.js.map +1 -1
  6. package/dist/http/Body.d.ts +126 -16
  7. package/dist/http/Body.d.ts.map +1 -1
  8. package/dist/http/Body.js +106 -12
  9. package/dist/http/Body.js.map +1 -1
  10. package/dist/http/Operation.d.ts +70 -7
  11. package/dist/http/Operation.d.ts.map +1 -1
  12. package/dist/http/Operation.js +51 -4
  13. package/dist/http/Operation.js.map +1 -1
  14. package/dist/http/Policy.d.ts +48 -13
  15. package/dist/http/Policy.d.ts.map +1 -1
  16. package/dist/http/Policy.js +31 -10
  17. package/dist/http/Policy.js.map +1 -1
  18. package/dist/http/Request.d.ts +232 -42
  19. package/dist/http/Request.d.ts.map +1 -1
  20. package/dist/http/Request.js +195 -33
  21. package/dist/http/Request.js.map +1 -1
  22. package/dist/http/Response.d.ts +82 -7
  23. package/dist/http/Response.d.ts.map +1 -1
  24. package/dist/http/Response.js +62 -4
  25. package/dist/http/Response.js.map +1 -1
  26. package/dist/http/Transport.d.ts +59 -11
  27. package/dist/http/Transport.d.ts.map +1 -1
  28. package/dist/http/Transport.js +46 -9
  29. package/dist/http/Transport.js.map +1 -1
  30. package/dist/http/UrlEncoding.d.ts +64 -8
  31. package/dist/http/UrlEncoding.d.ts.map +1 -1
  32. package/dist/http/UrlEncoding.js +36 -4
  33. package/dist/http/UrlEncoding.js.map +1 -1
  34. package/dist/main.d.ts +24 -0
  35. package/dist/main.d.ts.map +1 -1
  36. package/dist/main.js +24 -0
  37. package/dist/main.js.map +1 -1
  38. package/package.json +3 -3
  39. package/src/concurrency/Interaction.ts +39 -6
  40. package/src/http/Body.ts +126 -16
  41. package/src/http/Operation.ts +70 -7
  42. package/src/http/Policy.ts +48 -13
  43. package/src/http/Request.ts +232 -42
  44. package/src/http/Response.ts +82 -7
  45. package/src/http/Transport.ts +59 -11
  46. package/src/http/UrlEncoding.ts +64 -8
  47. package/src/main.ts +24 -0
package/README.md CHANGED
@@ -1,58 +1,89 @@
1
1
  # Effect Schema HTTP
2
2
 
3
- Consumer-owned HTTP contracts composed with Effect. Describe what an external service accepts and
4
- returns, encode application values with Schema, and execute through the `HttpClient` service of
5
- `effect/http`.
3
+ Define what your application sends to an HTTP service and what it expects back. Effect Schema
4
+ validates and transforms values, and your Effect HTTP client sends the request. The contract belongs
5
+ to your application; the server does not need to use this library or Effect.
6
6
 
7
- Agents write and maintain this project. Its code is not human-reviewed.
7
+ ## Example
8
8
 
9
- ## Status and scope
9
+ Describe a user lookup and the JSON response your application understands:
10
10
 
11
- `0.1.0-rc.1` is the first release candidate, intended to become `0.1.0` after qualification and
12
- publication prerequisites. It is distributed on [GitHub
13
- Releases](https://github.com/viell-dev/slop-effect-schema-http/releases/tag/0.1.0-rc.1), with an
14
- installable tarball and SHA-256 checksums. It is not published on npm. The source is
15
- [MIT-licensed](./LICENSE).
11
+ ```ts
12
+ import { Effect, Schema } from "effect";
13
+ import { FetchHttpClient } from "effect/http";
14
+ import { Body, Operation, Request, Response } from "viell-effect-schema-http";
16
15
 
17
- Download the tarball, then install it in an ESM project:
16
+ const api = Request.baseUrl("https://api.example.test");
17
+
18
+ const getUser = Operation.make(
19
+ Request.get("").pipe(
20
+ api,
21
+ Request.path(Schema.NumberFromString, (id, encode) => `/users/${encode(id)}`),
22
+ ),
23
+ Response.status(
24
+ 200,
25
+ Body.jsonSchema(Schema.Struct({ id: Schema.Number, name: Schema.String })),
26
+ ),
27
+ );
28
+
29
+ const program = getUser
30
+ .execute({ path: 42 })
31
+ .pipe(Effect.provide(FetchHttpClient.layer));
32
+ // Replace the example endpoint with your service, then: await Effect.runPromise(program).
33
+ ```
34
+
35
+ Reuse `api` across requests to share the base URL. The path renderer supplies `/users/42`, which is
36
+ joined to that base; it replaces the empty path passed to `Request.get`. The path schema encodes the
37
+ number as URL text. The response schema validates the returned JSON. Constructing `program` sends
38
+ nothing; evaluating it produces a typed user or an Effect failure. [Getting
39
+ started](https://viell-dev.github.io/slop-effect-schema-http/getting-started) supplies a complete
40
+ in-memory example you can run without a server or credentials.
41
+
42
+ ## Install
43
+
44
+ In an existing Node.js 24 ESM project with Effect `^4.0.7`, add the library:
18
45
 
19
46
  ```sh
20
- npm install ./viell-effect-schema-http-0.1.0-rc.1.tgz effect@4.1.1
47
+ npm install viell-effect-schema-http
21
48
  ```
22
49
 
23
- The initial environment scope is Node.js 24 on Windows/Linux and browser Fetch in Chromium, with
24
- Effect `^4.0.7`. Isolated consumers check Effect 4.0.7 and 4.1.1, and TypeScript 6.0.3 and 7.0.2.
25
- See [compatibility and limits](https://viell-dev.github.io/slop-effect-schema-http/limits) for the
26
- qualification boundaries. Compatible fixes use `0.1.x`; breaking API changes require `0.2.0` and
27
- migration guidance.
28
-
29
- The [documentation site](https://viell-dev.github.io/slop-effect-schema-http/) provides local
30
- installation, a runnable example, API links, and limits and recovery guidance. It describes the
31
- latest installable release, including this candidate until a stable release exists. The [release
32
- tracker](https://github.com/viell-dev/slop-effect-schema-http/issues/2) records qualification and
33
- remaining publication steps.
34
-
35
- The existing modules describe request URLs, headers, query parameters and bodies; select and decode
36
- responses; compose operations with execution policies; and integrate with Effect's HTTP client. They
37
- describe an external service from the consumer's perspective. This project does not generate a
38
- server or replace the HTTP client's transport.
39
-
40
- The public entry point exports `Body`, `Interaction`, `Operation`, `Policy`, `Request`, `Response`,
41
- `Transport`, and `UrlEncoding`. Their TypeScript source and doc comments are the current API
42
- reference. [docs/design.md](./docs/design.md) records the design decisions: what the library
43
- promises, and what it leaves to the consumer, to Effect, or to the transport.
44
-
45
- See the [verification guide](./CONTRIBUTING.md#behavior-tests) for the module tests, separate
46
- hostile-server suite, and their coverage limits. Confirmed defects remain discoverable in the [open
47
- bug
48
- issues](https://github.com/viell-dev/slop-effect-schema-http/issues?q=is%3Aissue+is%3Aopen+label%3A%22Type%3A+Bug%22).
49
-
50
- ## Development
51
-
52
- Follow [CONTRIBUTING.md](./CONTRIBUTING.md#development-and-verification) for setup, commands, tests,
53
- and pull requests. Report defects and proposed changes in the [issue
54
- tracker](https://github.com/viell-dev/slop-effect-schema-http/issues), with synthetic inputs, the
55
- commit and tool versions, reproduction commands, and expected and actual results. Do not include
56
- credentials or private service data. For a sensitive security report, use [GitHub private
57
- vulnerability
50
+ `0.1.0` is the first stable release. The same package is available as a checksummed [GitHub release
51
+ tarball](https://github.com/viell-dev/slop-effect-schema-http/releases/tag/0.1.0).
52
+
53
+ TypeScript declarations and editor documentation are included. The supported environments are Node
54
+ 24 on Windows/Linux and browser Fetch in Chromium. See [compatibility and
55
+ limits](https://viell-dev.github.io/slop-effect-schema-http/limits) for tested Effect/compiler
56
+ versions and provider boundaries.
57
+
58
+ ## Documentation
59
+
60
+ - [Getting started](https://viell-dev.github.io/slop-effect-schema-http/getting-started):
61
+ installation, a runnable example and the expected output.
62
+ - [Usage](https://viell-dev.github.io/slop-effect-schema-http/usage): add PATCH and DELETE actions,
63
+ share URL descriptions and connect an operation to your HTTP client.
64
+ - [Module guides](https://viell-dev.github.io/slop-effect-schema-http/api): Request, Body, Response,
65
+ Operation, Policy, Interaction, UrlEncoding and Transport, from basic use to advanced behavior.
66
+ - [Limits and recovery](https://viell-dev.github.io/slop-effect-schema-http/limits): compatibility,
67
+ failure stages and bug reporting.
68
+ - [What's in 0.1](https://viell-dev.github.io/slop-effect-schema-http/release-notes/0.1) introduces
69
+ the release; [Versions](https://viell-dev.github.io/slop-effect-schema-http/versions) covers
70
+ updates and compatibility policy. [CHANGELOG.md](./CHANGELOG.md) records the detailed history.
71
+
72
+ The library provides finite-body codecs, typed contracts, ordered response selection, retry policies
73
+ and scoped interaction coordination. It uses the application's HTTP transport and Effect runtime.
74
+ Streaming bodies, server generation and a general cache are outside its scope. The [design
75
+ contract](https://viell-dev.github.io/slop-effect-schema-http/design) explains the precise
76
+ guarantees.
77
+
78
+ ## Project and contribution
79
+
80
+ Agents write and maintain this project. Its code is not human-reviewed. The source is
81
+ [MIT-licensed](./LICENSE). The [release
82
+ tracker](https://github.com/viell-dev/slop-effect-schema-http/issues/2) records the first stable
83
+ release's qualification and publication.
84
+
85
+ Use [CONTRIBUTING.md](./CONTRIBUTING.md) for checkout setup, verification and pull requests. [Report
86
+ a defect](https://github.com/viell-dev/slop-effect-schema-http/issues) with a small synthetic
87
+ reproduction and library, Effect and environment versions. Include expected and actual results; keep
88
+ credentials and private service data out. For sensitive security reports, use [private vulnerability
58
89
  reporting](https://github.com/viell-dev/slop-effect-schema-http/security/advisories/new).
@@ -2,30 +2,63 @@ import { Effect, type Equivalence, Scope } from "effect";
2
2
  declare const Closed_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
3
3
  readonly _tag: "InteractionClosed";
4
4
  } & Readonly<A>;
5
- /** The interaction was closed; it admits no further work. */
5
+ /**
6
+ * A call tried to start work after the interaction had permanently closed.
7
+ *
8
+ * @remarks
9
+ * The error's `_tag` is `"InteractionClosed"`.
10
+ */
6
11
  export declare class Closed extends Closed_base {
7
12
  }
13
+ /**
14
+ * Options for one call to an interaction.
15
+ */
8
16
  export interface RunOptions {
9
17
  /** Start fresh work, superseding active work and bypassing the retained result. */
10
18
  readonly force?: boolean | undefined;
11
19
  }
12
- /** One user-facing interaction: at most one active execution and one retained success. */
20
+ /**
21
+ * Coordinate one active execution and one retained successful result.
22
+ *
23
+ * @remarks
24
+ * Use for one user-facing activity, such as a search field. Equal input shares work or reuses a
25
+ * success; different input supersedes active work. This is not a cache of all previous inputs.
26
+ */
13
27
  export interface Interaction<in I, out A, out E = never> {
14
28
  /** Equal input joins active work or reuses the retained success; different input supersedes active work. */
15
29
  readonly run: (input: I, options?: RunOptions) => Effect.Effect<A, E | Closed>;
16
30
  /** Permanent and idempotent. Every caller waits for all owned finalizers, including superseded work. */
17
31
  readonly close: Effect.Effect<void>;
18
32
  }
33
+ /**
34
+ * Choose how inputs compare and which successful results are retained.
35
+ */
19
36
  export interface Options<I, A> {
20
37
  /** Defaults to `Equal.equals`, which compares plain objects and arrays structurally. */
21
38
  readonly equivalence?: Equivalence.Equivalence<I> | undefined;
22
- /** Whether a successful result is retained for reuse. The result is returned either way. */
39
+ /** Whether to retain a success. Defaults to retaining; the result is returned either way. */
23
40
  readonly retain?: ((value: A, input: I) => boolean) | undefined;
24
41
  }
25
42
  /**
26
- * Acquire an interaction in the current Scope. Services are captured at acquisition, like a Layer. Every
27
- * execution belongs to the interaction rather than to a caller, and runs in its own child Scope, so
28
- * interrupting one waiter never cancels work another waiter shares.
43
+ * Acquire a scoped interaction around an Effect-returning function.
44
+ *
45
+ * @example
46
+ * ```ts
47
+ * import { Effect } from "effect";
48
+ * import { Interaction } from "viell-effect-schema-http";
49
+ * const program = Effect.scoped(Effect.gen(function* () {
50
+ * const lookup = yield* Interaction.make((id: number) => Effect.succeed({ id }));
51
+ * const first = yield* lookup.run(42);
52
+ * const reused = yield* lookup.run(42);
53
+ * return [first, reused];
54
+ * }));
55
+ * ```
56
+ *
57
+ * @remarks
58
+ * Keep the acquiring scope alive while calls should be accepted. Required services are captured
59
+ * at acquisition. Each execution belongs to the interaction in its own child scope; cancelling
60
+ * one waiter does not cancel shared work. Closing the acquiring scope closes the interaction
61
+ * and waits for all owned cleanup.
29
62
  */
30
63
  export declare const make: <I, A, E, R>(execute: (input: I) => Effect.Effect<A, E, R>, options?: Options<I, A> | undefined) => Effect.Effect<Interaction<I, A, E>, never, R | Scope.Scope>;
31
64
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"Interaction.d.ts","sourceRoot":"","sources":["../../src/concurrency/Interaction.ts"],"names":[],"mappings":"AAAA,OAAO,EA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,EAGhB,KAAK,EAEN,MAAM,QAAQ,CAAC;;;;AAEhB;;;;;GAKG;AACH,qBAAa,MAAO,SAAQ,WAAqC;CAAG;AAEpE;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,mFAAmF;IACnF,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CACtC;AAED;;;;;;GAMG;AACH,MAAM,WAAW,WAAW,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,KAAK;IACrD,4GAA4G;IAC5G,QAAQ,CAAC,GAAG,EAAE,CACZ,KAAK,EAAE,CAAC,EACR,OAAO,CAAC,EAAE,UAAU,KACjB,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,CAAC;IAClC,wGAAwG;IACxG,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;CACrC;AAED;;GAEG;AACH,MAAM,WAAW,OAAO,CAAC,CAAC,EAAE,CAAC;IAC3B,wFAAwF;IACxF,QAAQ,CAAC,WAAW,CAAC,EAAE,WAAW,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC;IAC9D,6FAA6F;IAC7F,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,KAAK,OAAO,CAAC,GAAG,SAAS,CAAC;CACjE;AAQD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,IAAI,GAAgC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,mBACxC,CAAC,KAAK,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,qGA2G7C,CAAC"}
@@ -1,11 +1,32 @@
1
1
  import { Context, Data, Deferred, Effect, Equal, Exit, Scope, Semaphore, } from "effect";
2
- /** The interaction was closed; it admits no further work. */
2
+ /**
3
+ * A call tried to start work after the interaction had permanently closed.
4
+ *
5
+ * @remarks
6
+ * The error's `_tag` is `"InteractionClosed"`.
7
+ */
3
8
  export class Closed extends Data.TaggedError("InteractionClosed") {
4
9
  }
5
10
  /**
6
- * Acquire an interaction in the current Scope. Services are captured at acquisition, like a Layer. Every
7
- * execution belongs to the interaction rather than to a caller, and runs in its own child Scope, so
8
- * interrupting one waiter never cancels work another waiter shares.
11
+ * Acquire a scoped interaction around an Effect-returning function.
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * import { Effect } from "effect";
16
+ * import { Interaction } from "viell-effect-schema-http";
17
+ * const program = Effect.scoped(Effect.gen(function* () {
18
+ * const lookup = yield* Interaction.make((id: number) => Effect.succeed({ id }));
19
+ * const first = yield* lookup.run(42);
20
+ * const reused = yield* lookup.run(42);
21
+ * return [first, reused];
22
+ * }));
23
+ * ```
24
+ *
25
+ * @remarks
26
+ * Keep the acquiring scope alive while calls should be accepted. Required services are captured
27
+ * at acquisition. Each execution belongs to the interaction in its own child scope; cancelling
28
+ * one waiter does not cancel shared work. Closing the acquiring scope closes the interaction
29
+ * and waits for all owned cleanup.
9
30
  */
10
31
  export const make = Effect.fnUntraced(function* (execute, options) {
11
32
  const context = yield* Effect.context();
@@ -1 +1 @@
1
- {"version":3,"file":"Interaction.js","sourceRoot":"","sources":["../../src/concurrency/Interaction.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,IAAI,EACJ,QAAQ,EACR,MAAM,EACN,KAAK,EAEL,IAAI,EAEJ,KAAK,EACL,SAAS,GACV,MAAM,QAAQ,CAAC;AAEhB,6DAA6D;AAC7D,MAAM,OAAO,MAAO,SAAQ,IAAI,CAAC,WAAW,CAAC,mBAAmB,CAAC;CAAG;AA+BpE;;;;GAIG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,EAC7C,OAA6C,EAC7C,OAAuB;IAEvB,MAAM,OAAO,GA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E,CAAC,OAAO,CAAC,MAAM,CAAC,CAC5B,CACF,CAAC;IAEJ,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC;AACxB,CAAC,CAAC,CAAC"}
@@ -1,52 +1,162 @@
1
1
  import { Effect, Pipeable, Schema } from "effect";
2
2
  import { HttpBody, HttpClientError, type HttpClientResponse, type UrlParams } from "effect/http";
3
- /** A finite outgoing representation, encoded once per operation evaluation. */
3
+ /**
4
+ * Turn an application value into a finite outgoing HTTP body.
5
+ *
6
+ * @remarks
7
+ * Use with `Request.body`. Encoding occurs once per operation evaluation, before dispatch.
8
+ */
4
9
  export interface Encoder<in A, out E = never, out R = never> extends Pipeable.Pipeable {
5
10
  readonly encode: (value: A) => Effect.Effect<HttpBody.HttpBody, E, R>;
6
11
  }
7
- /** A finite incoming representation. The decoder owns the selected response body. */
12
+ /**
13
+ * Read a finite response body into an application value.
14
+ *
15
+ * @remarks
16
+ * Use with `Response.status` or `Response.when`. Read the body within the returned Effect;
17
+ * `Operation.make` closes the attempt's resources before returning the decoded result.
18
+ */
8
19
  export interface Decoder<out A, out E = never, out R = never> extends Pipeable.Pipeable {
9
20
  readonly decode: (response: HttpClientResponse.HttpClientResponse) => Effect.Effect<A, E, R>;
10
- /** Contributes to the automatic `Accept` header of an operation. */
21
+ /** Contributes to automatic `Accept`; it does not validate response Content-Type. */
11
22
  readonly mediaType: string | undefined;
12
23
  }
13
- /** Both directions of one representation. Errors and services stay separate per direction. */
24
+ /**
25
+ * An encoder and decoder for the same application value.
26
+ *
27
+ * @remarks
28
+ * Encoding and decoding errors and required services are tracked separately.
29
+ */
14
30
  export interface Codec<A, EncodeError = never, DecodeError = never, EncodeServices = never, DecodeServices = never> extends Encoder<A, EncodeError, EncodeServices>, Decoder<A, DecodeError, DecodeServices> {
15
31
  }
32
+ /**
33
+ * Create a custom outgoing body encoder from an Effect-returning function.
34
+ *
35
+ * @remarks
36
+ * Return an Effect `HttpBody` with the representation and content metadata your service needs.
37
+ */
16
38
  export declare const encoder: <A, E = never, R = never>(encode: (value: A) => Effect.Effect<HttpBody.HttpBody, E, R>) => Encoder<A, E, R>;
39
+ /**
40
+ * Create a custom response-body decoder from an Effect-returning function.
41
+ *
42
+ * @remarks
43
+ * `mediaType` contributes to automatic `Accept`; it does not validate response Content-Type.
44
+ * Return typed failures through the Effect error channel; thrown exceptions are defects.
45
+ */
17
46
  export declare const decoder: <A, E = never, R = never>(decode: (response: HttpClientResponse.HttpClientResponse) => Effect.Effect<A, E, R>, mediaType?: string) => Decoder<A, E, R>;
47
+ /**
48
+ * Combine custom encoding and decoding functions into one body codec.
49
+ *
50
+ * @remarks
51
+ * `mediaType` describes the accepted response representation. Outgoing content metadata comes
52
+ * from the `HttpBody` returned by `encode`.
53
+ */
18
54
  export declare const make: <A, EncodeError = never, DecodeError = never, EncodeServices = never, DecodeServices = never>(options: {
19
55
  readonly encode: (value: A) => Effect.Effect<HttpBody.HttpBody, EncodeError, EncodeServices>;
20
56
  readonly decode: (response: HttpClientResponse.HttpClientResponse) => Effect.Effect<A, DecodeError, DecodeServices>;
21
57
  readonly mediaType?: string | undefined;
22
58
  }) => Codec<A, EncodeError, DecodeError, EncodeServices, DecodeServices>;
23
59
  /**
24
- * Any JSON value, encoded with `HttpBody.json`. Like it, a value `JSON.stringify` omits, such as `undefined`,
25
- * encodes as an empty body; use {@link jsonSchema} to validate first. Unlike `response.json`, an empty
26
- * response body is a decoding failure rather than `null`.
60
+ * Read and write JSON without schema validation.
61
+ *
62
+ * @remarks
63
+ * Encoding uses Effect's `HttpBody.json`. Values omitted by `JSON.stringify`, such as
64
+ * `undefined`, produce an empty outgoing body. An empty incoming body is a decoding failure,
65
+ * not `null`. Use {@link jsonSchema} to validate and transform application values.
27
66
  */
28
67
  export declare const json: Codec<unknown, HttpBody.HttpBodyError, HttpClientError.HttpClientError>;
29
68
  /**
30
- * UTF-8 text. Incoming decoding delegates to `response.text`. Fetch-backed providers ignore charset
31
- * parameters, strip a leading UTF-8 BOM, and replace malformed bytes with U+FFFD without failing.
32
- * Use {@link bytes} with a schema or custom decoder for strict or non-UTF-8 decoding.
69
+ * Read and write text, with `text/plain` as the media type.
70
+ *
71
+ * @remarks
72
+ * Outgoing text is UTF-8. Incoming decoding delegates to the provider's `response.text`.
73
+ * Fetch-backed providers ignore charset parameters, strip a leading UTF-8 BOM, and replace
74
+ * malformed bytes with U+FFFD. Use {@link bytes} for strict or non-UTF-8 decoding.
33
75
  */
34
76
  export declare const text: Codec<string, never, HttpClientError.HttpClientError>;
77
+ /**
78
+ * Read and write `Uint8Array` bodies as `application/octet-stream`.
79
+ *
80
+ * @remarks
81
+ * Incoming bytes are buffered. Use a schema or custom decoder to interpret another encoding.
82
+ */
35
83
  export declare const bytes: Codec<Uint8Array, never, HttpClientError.HttpClientError>;
36
- /** Multipart form data. The transport owns the boundary and its Content-Type. */
84
+ /**
85
+ * Read and write Web `FormData` as multipart form data.
86
+ *
87
+ * @remarks
88
+ * The transport supplies the outgoing multipart boundary and its Content-Type. Do not set a
89
+ * boundary-less Content-Type manually. Decoding delegates to the HTTP provider.
90
+ */
37
91
  export declare const formData: Codec<FormData, never, HttpClientError.HttpClientError>;
92
+ /**
93
+ * Read and write form bodies using Effect's `UrlParams.UrlParams`.
94
+ *
95
+ * @remarks
96
+ * Construct values with `UrlParams.fromInput` from `effect/http`. The media type is
97
+ * `application/x-www-form-urlencoded`.
98
+ */
38
99
  export declare const urlEncoded: Codec<UrlParams.UrlParams, never, HttpClientError.HttpClientError>;
39
- /** No outgoing body. Incoming bytes, including unexpected ones, are drained without buffering. */
100
+ /**
101
+ * Send no body, or discard an incoming body when its content is not needed.
102
+ *
103
+ * @remarks
104
+ * Decoding drains even unexpected incoming bytes without buffering them. Draining has no
105
+ * intrinsic timeout; use an attempt or operation timeout for an unbounded response.
106
+ */
40
107
  export declare const empty: Codec<void, never, HttpClientError.HttpClientError>;
108
+ /**
109
+ * Transform a decoded value with a pure function, preserving its media type.
110
+ *
111
+ * @remarks
112
+ * Returns a decoder only. Use {@link mapEffect} if the transformation may fail or need services.
113
+ */
41
114
  export declare const map: <A, B>(f: (value: A) => B) => <E, R>(self: Decoder<A, E, R>) => Decoder<B, E, R>;
115
+ /**
116
+ * Transform a decoded value with an Effect, adding its errors and required services.
117
+ *
118
+ * @remarks
119
+ * Returns a decoder only and preserves the media type. When used in a response case, this work
120
+ * is part of that attempt's decoding and is covered by its timeout.
121
+ */
42
122
  export declare const mapEffect: <A, B, E2, R2>(f: (value: A) => Effect.Effect<B, E2, R2>) => <E, R>(self: Decoder<A, E, R>) => Decoder<B, E | E2, R | R2>;
43
- /** Validate a decoded value with a schema. A failure is final: it never falls through to another response case. */
123
+ /**
124
+ * Validate and transform a decoded value with an Effect schema.
125
+ *
126
+ * @example
127
+ * ```ts
128
+ * import { Schema } from "effect";
129
+ * import { Body } from "viell-effect-schema-http";
130
+ * const numberFromText = Body.text.pipe(Body.schema(Schema.NumberFromString));
131
+ * // Decodes the text "42" to the number 42.
132
+ * ```
133
+ *
134
+ * @remarks
135
+ * Returns a decoder with the schema's application type. A failure in a selected response case
136
+ * is final for that attempt; it does not try a later response case.
137
+ */
44
138
  export declare const schema: <S extends Schema.Constraint>(contract: S) => <A, E, R>(self: Decoder<A, E, R>) => Decoder<S["Type"], E | Schema.SchemaError, R | S["DecodingServices"]>;
45
- /** Validate application input with a schema and encode it with the selected wire encoder. */
139
+ /**
140
+ * Validate and encode application input before passing it to a body encoder.
141
+ *
142
+ * @remarks
143
+ * The schema's encoded type must match the underlying encoder's input. Returns an encoder only;
144
+ * use {@link schema} for the decoding direction.
145
+ */
46
146
  export declare const encodeSchema: <S extends Schema.Constraint>(contract: S) => <E, R>(self: Encoder<S["Encoded"], E, R>) => Encoder<S["Type"], E | Schema.SchemaError, R | S["EncodingServices"]>;
47
147
  /**
48
- * Bidirectional JSON through the schema's canonical JSON codec (`Schema.toCodecJson`), as in Effect's own
49
- * JSON body helpers.
148
+ * Read and write schema-validated JSON using the schema's application type.
149
+ *
150
+ * @example
151
+ * ```ts
152
+ * import { Schema } from "effect";
153
+ * import { Body } from "viell-effect-schema-http";
154
+ * const user = Body.jsonSchema(Schema.Struct({ id: Schema.Number, name: Schema.String }));
155
+ * ```
156
+ *
157
+ * @remarks
158
+ * Uses `Schema.toCodecJson` to obtain the schema's canonical JSON codec. Encoding failures occur
159
+ * before dispatch; an operation wraps response decoding failures in `Response.DecodeError`.
50
160
  */
51
161
  export declare const jsonSchema: <S extends Schema.Constraint>(contract: S) => Codec<S["Type"], Schema.SchemaError | HttpBody.HttpBodyError, Schema.SchemaError | HttpClientError.HttpClientError, S["EncodingServices"], S["DecodingServices"]>;
52
162
  //# sourceMappingURL=Body.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Body.d.ts","sourceRoot":"","sources":["../../src/http/Body.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAU,MAAM,QAAQ,CAAC;AAC1D,OAAO,EACL,QAAQ,EACR,eAAe,EACf,KAAK,kBAAkB,EACvB,KAAK,SAAS,EACf,MAAM,aAAa,CAAC;AAErB,+EAA+E;AAC/E,MAAM,WAAW,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,KAAK,EAAE,GAAG,CAAC,CAAC,GAAG,KAAK,CACzD,SAAQ,QAAQ,CAAC,QAAQ;IACzB,QAAQ,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;CACvE;AAED,qFAAqF;AACrF,MAAM,WAAW,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,KAAK,EAAE,GAAG,CAAC,CAAC,GAAG,KAAK,CAC1D,SAAQ,QAAQ,CAAC,QAAQ;IACzB,QAAQ,CAAC,MAAM,EAAE,CACf,QAAQ,EAAE,kBAAkB,C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