viell-effect-schema-http 0.1.0 → 0.3.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 (56) hide show
  1. package/README.md +44 -29
  2. package/dist/concurrency/Interaction.d.ts +7 -1
  3. package/dist/concurrency/Interaction.d.ts.map +1 -1
  4. package/dist/concurrency/Interaction.js.map +1 -1
  5. package/dist/http/Body.d.ts +25 -13
  6. package/dist/http/Body.d.ts.map +1 -1
  7. package/dist/http/Body.js +18 -8
  8. package/dist/http/Body.js.map +1 -1
  9. package/dist/http/Operation.d.ts +276 -13
  10. package/dist/http/Operation.d.ts.map +1 -1
  11. package/dist/http/Operation.js +210 -11
  12. package/dist/http/Operation.js.map +1 -1
  13. package/dist/http/Policy.d.ts +28 -2
  14. package/dist/http/Policy.d.ts.map +1 -1
  15. package/dist/http/Policy.js +28 -2
  16. package/dist/http/Policy.js.map +1 -1
  17. package/dist/http/Request.d.ts +520 -85
  18. package/dist/http/Request.d.ts.map +1 -1
  19. package/dist/http/Request.js +658 -143
  20. package/dist/http/Request.js.map +1 -1
  21. package/dist/http/Response.d.ts +130 -6
  22. package/dist/http/Response.d.ts.map +1 -1
  23. package/dist/http/Response.js +88 -7
  24. package/dist/http/Response.js.map +1 -1
  25. package/dist/http/UrlEncoding.d.ts +24 -7
  26. package/dist/http/UrlEncoding.d.ts.map +1 -1
  27. package/dist/http/UrlEncoding.js +7 -3
  28. package/dist/http/UrlEncoding.js.map +1 -1
  29. package/dist/http/internal/excess.d.ts +44 -0
  30. package/dist/http/internal/excess.d.ts.map +1 -0
  31. package/dist/http/internal/excess.js +231 -0
  32. package/dist/http/internal/excess.js.map +1 -0
  33. package/dist/http/internal/fields.d.ts +17 -4
  34. package/dist/http/internal/fields.d.ts.map +1 -1
  35. package/dist/http/internal/fields.js +11 -6
  36. package/dist/http/internal/fields.js.map +1 -1
  37. package/dist/http/internal/input.d.ts +70 -0
  38. package/dist/http/internal/input.d.ts.map +1 -0
  39. package/dist/http/internal/input.js +93 -0
  40. package/dist/http/internal/input.js.map +1 -0
  41. package/dist/http/internal/shape.d.ts +63 -0
  42. package/dist/http/internal/shape.d.ts.map +1 -0
  43. package/dist/http/internal/shape.js +225 -0
  44. package/dist/http/internal/shape.js.map +1 -0
  45. package/package.json +13 -12
  46. package/src/concurrency/Interaction.ts +7 -1
  47. package/src/http/Body.ts +41 -18
  48. package/src/http/Operation.ts +474 -33
  49. package/src/http/Policy.ts +30 -2
  50. package/src/http/Request.ts +1176 -253
  51. package/src/http/Response.ts +246 -23
  52. package/src/http/UrlEncoding.ts +32 -8
  53. package/src/http/internal/excess.ts +333 -0
  54. package/src/http/internal/fields.ts +37 -9
  55. package/src/http/internal/input.ts +228 -0
  56. package/src/http/internal/shape.ts +359 -0
@@ -9,18 +9,60 @@ import * as Response from "./Response.js";
9
9
  * @remarks
10
10
  * `execute(input)` returns a cold Effect: work starts when it is evaluated, and each evaluation
11
11
  * runs again. `Operation.make` supplies HTTP execution; `fromEffect` adapts an existing function.
12
- * With `make`, the request bindings determine `I`. Extract an operation's input type with
13
- * `Parameters<typeof operation.execute>[0]`.
12
+ * With `make`, the request bindings determine `I`. {@link InputOf} extracts it.
13
+ *
14
+ * `make` also keeps what it was built from in `parts`, which `P` describes, so {@link mapRequest},
15
+ * {@link mapResponse} and {@link mapOptions} can derive a variant. Annotating a value as
16
+ * `Operation<I, A, E, R>` leaves `P` unknown, which stops those functions compiling on it.
14
17
  */
15
- export interface Operation<in I, out A, out E = never, out R = never> extends Pipeable.Pipeable {
18
+ export interface Operation<in I, out A, out E = never, out R = never, out P = unknown> extends Pipeable.Pipeable {
19
+ /** Describe one evaluation for this input. Nothing runs until the Effect does. */
16
20
  readonly execute: (input: I) => Effect.Effect<A, E, R>;
21
+ /** What the operation was built from. A value from {@link fromEffect} has no parts. */
22
+ readonly parts?: P;
17
23
  }
24
+ /**
25
+ * The input an operation's `execute` takes.
26
+ *
27
+ * @example
28
+ * ```ts
29
+ * import { Schema } from "effect";
30
+ * import { Body, Operation, Request, Response } from "viell-effect-schema-http";
31
+ * const search = Operation.make(
32
+ * Request.get("https://api.example.test/things").pipe(
33
+ * Request.query(Schema.Struct({ sort: Schema.String })),
34
+ * ),
35
+ * Response.status(200, Body.json),
36
+ * );
37
+ * type SearchInput = Operation.InputOf<typeof search>;
38
+ * const searchAll = (input: SearchInput) => search.execute(input);
39
+ * ```
40
+ *
41
+ * @remarks
42
+ * `Request.InputOf` gives the same for a request.
43
+ */
44
+ export type InputOf<O> = O extends Operation<infer I, unknown, unknown, unknown, unknown> ? I : never;
18
45
  /**
19
46
  * Adapt an Effect-returning function to the operation interface.
20
47
  *
48
+ * @example
49
+ * ```ts
50
+ * import { Body, Operation, Request, Response } from "viell-effect-schema-http";
51
+ * const health = Operation.make(
52
+ * Request.get("https://api.example.test/health"),
53
+ * Response.status(200, Body.text),
54
+ * );
55
+ * // Callers can run this and map its result, and cannot adjust what it sends.
56
+ * const sealed = Operation.fromEffect(health.execute);
57
+ * ```
58
+ *
21
59
  * @remarks
22
60
  * The function is suspended until evaluation. This adapter adds no HTTP dispatch, decoding,
23
61
  * retry policy or scope management beyond what the supplied function already does.
62
+ *
63
+ * The result has no parts, at compile time or at run time. So
64
+ * `Operation.fromEffect(operation.execute)` seals a definition: it keeps the same types and offers
65
+ * no adjustment.
24
66
  */
25
67
  export declare const fromEffect: <I, A, E, R>(execute: (input: I) => Effect.Effect<A, E, R>) => Operation<I, A, E, R>;
26
68
  /**
@@ -36,10 +78,12 @@ export interface Options<E = HttpClientError.HttpClientError, R = never, EP = ne
36
78
  * Applied after request preparation, suitable for fresh credentials or URL-dependent signatures.
37
79
  * Run a signer after other request edits it must cover. Native status filters can reject responses
38
80
  * before the declared response contract sees them.
81
+ * `attempt` starts at `1` and matches the `http.attempt` log annotation. A function with an optional
82
+ * second parameter of its own receives the number there, so wrap one in an arrow function.
39
83
  * Appending native URL parameters can reserialize the entire query as form data, changing bare keys and
40
84
  * escapes. Prefer Request query combinators, or preserve the query text when editing the URL directly.
41
85
  */
42
- readonly transformClient?: ((client: HttpClient.HttpClient) => HttpClient.HttpClient.With<E, R>) | undefined;
86
+ readonly transformClient?: ((client: HttpClient.HttpClient, attempt: number) => HttpClient.HttpClient.With<E, R>) | undefined;
43
87
  }
44
88
  /**
45
89
  * Combine a request and response contract into an executable HTTP operation.
@@ -64,9 +108,13 @@ export interface Options<E = HttpClientError.HttpClientError, R = never, EP = ne
64
108
  * Each evaluation prepares input once. Each attempt then owns a scope covering client execution
65
109
  * and body decoding; cleanup completes before classification or a retry delay. Decoder and
66
110
  * client `Scope` requirements are supplied by the attempt. Interruption and defects never retry.
67
- * An automatic `Accept` header is added only when the request has none.
111
+ * An automatic `Accept` header is added only when the request declares none and has not removed
112
+ * it with `Request.removeHeader`.
113
+ *
114
+ * The result keeps its parts, so a definition written once can be adjusted where it is used with
115
+ * {@link mapRequest}, {@link mapResponse} and {@link mapOptions}. The original never changes.
68
116
  */
69
- export declare const make: <I, E, R, H extends boolean, Q extends boolean, A, E2, R2, E3 = HttpClientError.HttpClientError, R3 = never, EP = never, RP = never>(request: Request.Request<I, E, R, H, Q>, response: Response.Response<A, E2, R2>, options?: Options<E3, R3, EP, RP>) => Operation<I, A, E | E3 | EP | Request.InvalidRequest | HttpClientError.HttpClientError | Response.UnexpectedResponse | Response.DecodeError<E2 | HttpClientError.HttpClientError> | Cause.TimeoutError, R | RP | Exclude<R2 | R3, Scope.Scope> | HttpClient.HttpClient>;
117
+ export declare const make: <I, E, R, A, E2, R2, E3 = HttpClientError.HttpClientError, R3 = never, EP = never, RP = never, C extends Response.AnyCase = Response.AnyCase>(request: Request.Request<I, E, R>, response: Response.Response<A, E2, R2, C>, options?: Options<E3, R3, EP, RP>) => Http<Request.Request<I, E, R>, Response.Response<A, E2, R2, C>, Options<E3, R3, EP, RP>>;
70
118
  /**
71
119
  * Return the Effect for an operation's input, in direct or pipeable form.
72
120
  *
@@ -77,21 +125,236 @@ export declare const execute: {
77
125
  <I>(input: I): <A, E, R>(self: Operation<I, A, E, R>) => Effect.Effect<A, E, R>;
78
126
  <I, A, E, R>(self: Operation<I, A, E, R>, input: I): Effect.Effect<A, E, R>;
79
127
  };
128
+ /**
129
+ * The conversion {@link map} and {@link mapEffect} recorded, run once after the parts.
130
+ *
131
+ * @remarks
132
+ * Only its failures and services are in the type. Its result is the operation's own `A`, and what
133
+ * it was written for is what the response still produces, so neither is repeated here.
134
+ */
135
+ export interface Step<out E = never, out R = never> {
136
+ /** Convert the operation's result. */
137
+ readonly run: (value: never) => Effect.Effect<unknown, E, R>;
138
+ }
139
+ /**
140
+ * What {@link make} keeps: the three parts as given, and any recorded {@link Step}.
141
+ *
142
+ * @remarks
143
+ * Read a part with `operation.parts?.request`. Each whole part is one type parameter, which keeps
144
+ * the parameter count down as `Schema.decodeTo` does.
145
+ *
146
+ * `S` is invariant: widening it by annotation could otherwise make any response look as if it fits
147
+ * a recorded step.
148
+ *
149
+ * {@link mapRequest}, {@link mapResponse}, {@link mapOptions} and {@link unmap} build from these,
150
+ * so they drop an `execute` replaced on the value. {@link map} and {@link mapEffect} wrap
151
+ * `execute` itself, and keep it.
152
+ */
153
+ export interface Parts<out Q, in out S, out O, out T = undefined> {
154
+ /** The request it was built from. */
155
+ readonly request: Q;
156
+ /** The response contract it was built from. */
157
+ readonly response: S;
158
+ /** The options it was built with, or `undefined` for none. */
159
+ readonly options: O | undefined;
160
+ /** The recorded {@link Step}, or `undefined` for none. */
161
+ readonly step: T;
162
+ }
163
+ type RequestFailure<Q> = Q extends Request.Request<never, infer E, unknown> ? E : never;
164
+ type RequestServices<Q> = Q extends Request.Request<never, unknown, infer R> ? R : never;
165
+ type ValueOf<S> = S extends Response.Response<infer A, unknown, unknown, infer _C> ? A : never;
166
+ type ResponseFailure<S> = S extends Response.Response<unknown, infer E, unknown, infer _C> ? E : never;
167
+ type ResponseServices<S> = S extends Response.Response<unknown, unknown, infer R, infer _C> ? R : never;
168
+ type ClientFailure<O> = O extends Options<infer E, infer _R, infer _EP, infer _RP> ? E : never;
169
+ type ClientServices<O> = O extends Options<infer _E, infer R, infer _EP, infer _RP> ? R : never;
170
+ type PolicyFailure<O> = O extends Options<infer _E, infer _R, infer E, infer _RP> ? E : never;
171
+ type PolicyServices<O> = O extends Options<infer _E, infer _R, infer _EP, infer R> ? R : never;
172
+ type StepFailure<T> = T extends Step<infer E, unknown> ? E : never;
173
+ type StepServices<T> = T extends Step<unknown, infer R> ? R : never;
174
+ /** An operation fresh from {@link make}: three parts, no step, and the response's own result. */
175
+ export type Http<Q, S, O> = Derived<ValueOf<S>, Q, S, O>;
176
+ /**
177
+ * An operation built from parts, returning `B`.
178
+ *
179
+ * @remarks
180
+ * `B` comes first so that an editor hover shows the result before the parts. The unions stay
181
+ * inline: a named alias would print with all of `Q`, `S` and `O` repeated inside it.
182
+ */
183
+ export type Derived<B, Q, S, O, T = undefined> = Operation<Request.InputOf<Q>, B, RequestFailure<Q> | ClientFailure<O> | PolicyFailure<O> | StepFailure<T> | Request.InvalidRequest | HttpClientError.HttpClientError | Response.UnexpectedResponse | Response.DecodeError<ResponseFailure<S> | HttpClientError.HttpClientError> | Cause.TimeoutError, RequestServices<Q> | PolicyServices<O> | StepServices<T> | Exclude<ResponseServices<S> | ClientServices<O>, Scope.Scope> | HttpClient.HttpClient, Parts<Q, S, O, T>>;
184
+ /**
185
+ * Any operation carrying the parts `P` and returning `B`.
186
+ *
187
+ * @remarks
188
+ * What {@link mapRequest}, {@link mapResponse}, {@link mapOptions} and {@link unmap} accept. The
189
+ * input, failures and services are left open because a variant works them out again from `P`.
190
+ */
191
+ export type Adjustable<B, P> = Operation<never, B, unknown, unknown, P>;
192
+ /**
193
+ * Derive a variant with a changed request. A recorded result step stays.
194
+ *
195
+ * @example
196
+ * ```ts
197
+ * import { Body, Operation, Request, Response } from "viell-effect-schema-http";
198
+ * const getThings = Operation.make(
199
+ * Request.get("https://api.example.test/things?limit=25"),
200
+ * Response.status(200, Body.json),
201
+ * );
202
+ * const firstFive = Request.setQuery("limit", "5");
203
+ * const fewerThings = getThings.pipe(Operation.mapRequest(firstFive));
204
+ * // getThings still asks for 25.
205
+ * ```
206
+ *
207
+ * @remarks
208
+ * The function receives the current request, so every `Request` function works here, including a
209
+ * binding that changes the operation's input. The automatic `Accept` and the options carry over.
210
+ * The library cannot tell whether a change alters the shape of the answer: selecting fields or
211
+ * embedding relations usually does, and then needs {@link mapResponse} too.
212
+ *
213
+ * Works on any operation from {@link make}, mapped or not. A value from {@link fromEffect} has no
214
+ * parts, and one annotated as a plain `Operation<I, A, E, R>` hides them: both are compile errors.
215
+ */
216
+ export declare const mapRequest: <I, E, R, I2, E2, R2>(f: (request: Request.Request<I, E, R>) => Request.Request<I2, E2, R2>) => <B, S, O, T>(self: Adjustable<B, Parts<Request.Request<I, E, R>, S, O, T>>) => Derived<B, Request.Request<I2, E2, R2>, S, O, T>;
217
+ interface NoLongerFits<A> {
218
+ readonly "Use Operation.unmap first, then map again: this response no longer fits the mapping.": A;
219
+ }
220
+ /**
221
+ * The rule {@link mapResponse} applies to a new result `A2`, given the current result `A`.
222
+ *
223
+ * @remarks
224
+ * With no step, `T` is `undefined` and anything fits. With a step, `A2` must be something the
225
+ * current response could produce. An `any` result proves nothing, so it does not fit either.
226
+ *
227
+ * `W` is everything the function returned, and stays `never` when nothing was inferred from it.
228
+ * That means the function itself does not compile, as with a key the contract lacks. `A2` then
229
+ * reads `unknown` for no reason of its own, so the rule stands aside and leaves the function's own
230
+ * error as the only one. A function that returns a response, or `any`, always gives `W` a value, so
231
+ * a result that really is `unknown` is still refused.
232
+ */
233
+ export type Fits<A2, A, T, W = unknown> = [T] extends [undefined] ? unknown : [W] extends [never] ? unknown : 0 extends 1 & A2 ? NoLongerFits<A2> : [A2] extends [A] ? unknown : NoLongerFits<A2>;
234
+ /**
235
+ * Derive a variant with a changed response. A recorded result step stays, and has to fit.
236
+ *
237
+ * @example
238
+ * ```ts
239
+ * import { Schema } from "effect";
240
+ * import { Body, Operation, Request, Response } from "viell-effect-schema-http";
241
+ * const Thing = Schema.Struct({ id: Schema.Number, name: Schema.String });
242
+ * const ThingOption = Schema.Struct({ id: Schema.Number });
243
+ * const getThing = Operation.make(
244
+ * Request.get("https://api.example.test/things/1"),
245
+ * Response.status(200, Body.jsonSchema(Thing)),
246
+ * );
247
+ * const asOption = Response.replace(200, Body.jsonSchema(ThingOption));
248
+ * const thingOption = getThing.pipe(Operation.mapResponse(asOption));
249
+ * ```
250
+ *
251
+ * @remarks
252
+ * The function receives the current response, so {@link Response.replace},
253
+ * {@link Response.remove} and {@link Response.orElse} all work here. The automatic `Accept` follows
254
+ * the new response.
255
+ *
256
+ * On a mapped operation the new result must fit: it has to be assignable to the current response's
257
+ * result, and not `any`, because the recorded step was written for that result. So a same-shape
258
+ * replace or a removal works, and anything else is a compile error that names {@link unmap}.
259
+ * A narrowed result is the new baseline, so widening it back needs {@link unmap} as well.
260
+ * This is a compile-time rule: a cast gets past it, and the step then receives the wrong shape.
261
+ */
262
+ export declare const mapResponse: <A, E, R, C extends Response.AnyCase, A2, E2, R2, C2 extends Response.AnyCase, W = never>(f: (response: Response.Response<A, E, R, C>) => Response.Response<A2, E2, R2, C2> & W) => <B, Q, O, T>(self: Adjustable<B, Parts<Q, Response.Response<A, E, R, C>, O, T>> & Fits<A2, A, T, W>) => Derived<[T] extends [undefined] ? A2 : B, Q, Response.Response<A2, E2, R2, C2>, O, T>;
263
+ /**
264
+ * Derive a variant with changed options. A recorded result step stays.
265
+ *
266
+ * @example
267
+ * ```ts
268
+ * import { Schedule } from "effect";
269
+ * import {
270
+ * Body,
271
+ * Operation,
272
+ * Policy,
273
+ * Request,
274
+ * Response,
275
+ * } from "viell-effect-schema-http";
276
+ * const getThings = Operation.make(
277
+ * Request.get("https://api.example.test/things"),
278
+ * Response.status(200, Body.json),
279
+ * );
280
+ * const retryTwice = Policy.make(Schedule.recurs(2));
281
+ * const patient = getThings.pipe(
282
+ * Operation.mapOptions((options) => ({ ...options, policy: retryTwice })),
283
+ * );
284
+ * ```
285
+ *
286
+ * @remarks
287
+ * The function receives the current options, or `undefined` if there are none, and its result
288
+ * replaces them. Spread them to keep what you do not change. A failure or service type that only
289
+ * a dropped option added leaves with it.
290
+ */
291
+ export declare const mapOptions: <O, E = HttpClientError.HttpClientError, R = never, EP = never, RP = never>(f: (options: O | undefined) => Options<E, R, EP, RP>) => <B, Q, S, T>(self: Adjustable<B, Parts<Q, S, O, T>>) => Derived<B, Q, S, Options<E, R, EP, RP>, T>;
292
+ /**
293
+ * Remove every recorded result step, so the operation returns what its response decodes.
294
+ *
295
+ * @example
296
+ * ```ts
297
+ * import { Schema } from "effect";
298
+ * import { Body, Operation, Request, Response } from "viell-effect-schema-http";
299
+ * const Page = Schema.Struct({ data: Schema.Array(Schema.String) });
300
+ * const Names = Schema.Struct({ data: Schema.Array(Schema.Number) });
301
+ * const getThings = Operation.make(
302
+ * Request.get("https://api.example.test/things"),
303
+ * Response.status(200, Body.jsonSchema(Page)),
304
+ * ).pipe(Operation.map((page) => page.data));
305
+ *
306
+ * const asIds = Response.replace(200, Body.jsonSchema(Names));
307
+ * const thingIds = getThings.pipe(
308
+ * Operation.unmap,
309
+ * Operation.mapResponse(asIds),
310
+ * Operation.map((page) => page.data),
311
+ * );
312
+ * ```
313
+ *
314
+ * @remarks
315
+ * This is the route to a response {@link mapResponse} refuses: remove the mapping, change the
316
+ * response, then map again. The failures and services the steps added leave with them. On an
317
+ * operation with no step this changes nothing.
318
+ */
319
+ export declare const unmap: <B, Q, S, O, T>(self: Adjustable<B, Parts<Q, S, O, T>>) => Http<Q, S, O>;
320
+ /**
321
+ * The parts after {@link map} or {@link mapEffect} records a step adding failures `E` and services
322
+ * `R`. An operation with no parts stays that way.
323
+ *
324
+ * @remarks
325
+ * The conditional lives here, in the fifth argument, because a conditional return type would stop
326
+ * `flow` composing these functions.
327
+ */
328
+ export type Next<P, E, R> = [P] extends [
329
+ Parts<infer Q, infer S, infer O, infer T>
330
+ ] ? Parts<Q, S, O, Step<StepFailure<T> | E, StepServices<T> | R>> : P;
80
331
  /**
81
332
  * Transform an operation's successful result with a pure function.
82
333
  *
83
334
  * @remarks
84
- * Keeps the input, error and service types. Runs after the operation and its retry policy finish.
85
- * Use {@link mapEffect} to return a typed failure or perform further effectful work.
335
+ * Keeps the input, error and service types. Runs once, after the operation and its retry policy
336
+ * finish, outside each attempt's scope and timeout. Use {@link mapEffect} to return a typed failure
337
+ * or perform further effectful work.
338
+ *
339
+ * The operation keeps its parts and records this as a step, so {@link mapRequest} and
340
+ * {@link mapOptions} still work on the result, and {@link mapResponse} works while the new result
341
+ * fits. Two maps combine into one step. The mapping applies to the whole result, whichever case
342
+ * produced it. For a conversion that belongs to one case, use `Body.map` on that case's decoder: a
343
+ * later `Response.replace` takes the conversion with the case.
86
344
  */
87
- export declare const map: <A, B>(f: (value: A) => B) => <I, E, R>(self: Operation<I, A, E, R>) => Operation<I, B, E, R>;
345
+ export declare const map: <A, B>(f: (value: A) => B) => <I, E, R, P = unknown>(self: Operation<I, A, E, R, P>) => Operation<I, B, E, R, Next<P, never, never>>;
88
346
  /**
89
347
  * Transform an operation's successful result with an Effect.
90
348
  *
91
349
  * @remarks
92
- * Adds the transformation's errors and required services. Runs after the operation's retry
93
- * policy completes, so failures here do not trigger that policy. Use it to turn a recognized
94
- * response outcome into an application error.
350
+ * Adds the transformation's errors and required services. Runs once, after the operation's retry
351
+ * policy completes, outside each attempt's scope and timeout, so failures here do not trigger that
352
+ * policy and arrive as themselves. Use it to turn a recognized response outcome into an application
353
+ * error.
354
+ *
355
+ * The operation keeps its parts and records this as a step, as {@link map} describes. Its failures
356
+ * and services stay through a variant and leave with {@link unmap}.
95
357
  */
96
- export declare const mapEffect: <A, B, E2, R2>(f: (value: A) => Effect.Effect<B, E2, R2>) => <I, E, R>(self: Operation<I, A, E, R>) => Operation<I, B, E | E2, R | R2>;
358
+ export declare const mapEffect: <A, B, E2, R2>(f: (value: A) => Effect.Effect<B, E2, R2>) => <I, E, R, P = unknown>(self: Operation<I, A, E, R, P>) => Operation<I, B, E | E2, R | R2, Next<P, E2, R2>>;
359
+ export {};
97
360
  //# sourceMappingURL=Operation.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Operation.d.ts","sourceRoot":"","sources":["../../src/http/Operation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EAGL,MAAM,EAIN,QAAQ,EAGR,KAAK,KAAK,EACX,MAAM,QAAQ,CAAC;AAChB,OAAO,EACL,UAAU,EACV,eAAe,EAGhB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AACtC,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AACxC,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAC;AAG1C;;;;;;;;GAQG;AACH,MAAM,WAAW,SAAS,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,KAAK,EAAE,GAAG,CAAC,CAAC,GAAG,KAAK,CAClE,SAAQ,QAAQ,CAAC,QAAQ;IACzB,QAAQ,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;CACxD;AAED;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,GAAI,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EACnC,SAAS,CAAC,KAAK,EAAE,CAAC,KAAK,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,KAC5C,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAGrB,CAAC;AAEH;;GAEG;AACH,MAAM,WAAW,OAAO,CACtB,CAAC,GAAG,eAAe,CAAC,eAAe,EACnC,CAAC,GAAG,KAAK,EACT,EAAE,GAAG,KAAK,EACV,EAAE,GAAG,KAAK;IAEV,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AE,CAAC,KAAK,CAAC,MACxB,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,OAAO,EACnB,MAAM,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,KAC7B,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,CACW,CAAC;AAE5D;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,SAAS,GACnB,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,CAAC,KAAK,EAAE,CAAC,KAAK,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,MACvD,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,OAAO,EACnB,MAAM,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,KAC7B,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,EAAE,EAAE,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CACT,CAAC"}
@@ -7,9 +7,24 @@ import * as Transport from "./Transport.js";
7
7
  /**
8
8
  * Adapt an Effect-returning function to the operation interface.
9
9
  *
10
+ * @example
11
+ * ```ts
12
+ * import { Body, Operation, Request, Response } from "viell-effect-schema-http";
13
+ * const health = Operation.make(
14
+ * Request.get("https://api.example.test/health"),
15
+ * Response.status(200, Body.text),
16
+ * );
17
+ * // Callers can run this and map its result, and cannot adjust what it sends.
18
+ * const sealed = Operation.fromEffect(health.execute);
19
+ * ```
20
+ *
10
21
  * @remarks
11
22
  * The function is suspended until evaluation. This adapter adds no HTTP dispatch, decoding,
12
23
  * retry policy or scope management beyond what the supplied function already does.
24
+ *
25
+ * The result has no parts, at compile time or at run time. So
26
+ * `Operation.fromEffect(operation.execute)` seals a definition: it keeps the same types and offers
27
+ * no adjustment.
13
28
  */
14
29
  export const fromEffect = (execute) => ({
15
30
  ...Pipeable.Prototype,
@@ -46,14 +61,20 @@ const outcome = (exit) => Exit.isSuccess(exit)
46
61
  * Each evaluation prepares input once. Each attempt then owns a scope covering client execution
47
62
  * and body decoding; cleanup completes before classification or a retry delay. Decoder and
48
63
  * client `Scope` requirements are supplied by the attempt. Interruption and defects never retry.
49
- * An automatic `Accept` header is added only when the request has none.
64
+ * An automatic `Accept` header is added only when the request declares none and has not removed
65
+ * it with `Request.removeHeader`.
66
+ *
67
+ * The result keeps its parts, so a definition written once can be adjusted where it is used with
68
+ * {@link mapRequest}, {@link mapResponse} and {@link mapOptions}. The original never changes.
50
69
  */
51
70
  export const make = (request, response, options) => {
52
71
  const policy = options?.policy ?? Policy.none;
53
72
  const accept = response.accepts.join(", ");
54
73
  const execute = Effect.fnUntraced(function* (input) {
55
74
  const compiled = yield* Request.compile(request, input);
56
- const prepared = accept !== "" && compiled.request.headers.accept === undefined
75
+ const prepared = accept !== "" &&
76
+ compiled.request.headers.accept === undefined &&
77
+ !compiled.removedHeaders.has("accept")
57
78
  ? HttpClientRequest.setHeader(compiled.request, "accept", accept)
58
79
  : compiled.request;
59
80
  const client = yield* HttpClient.HttpClient;
@@ -70,7 +91,8 @@ export const make = (request, response, options) => {
70
91
  const execution = Effect.scoped(Effect.gen(function* () {
71
92
  const send = options?.transformClient === undefined
72
93
  ? HttpClient.withScope(client).execute
73
- : HttpClient.withScope(options.transformClient(client)).execute;
94
+ : HttpClient.withScope(options.transformClient(client, attempt))
95
+ .execute;
74
96
  // A fresh request identity keeps the scoped abort controller of this attempt separate.
75
97
  const received = yield* send(HttpClientRequest.setHeaders(prepared, {})).pipe(Effect.provideService(Transport.HeaderLines, compiled.headerLines),
76
98
  // Client middleware can reject a response, such as filterStatusOk; its metadata still classifies the attempt.
@@ -117,7 +139,11 @@ export const make = (request, response, options) => {
117
139
  yield* Effect.logDebug("HTTP retrying").pipe(Effect.annotateLogs({ "http.attempt": attempt + 1 }));
118
140
  }
119
141
  }, Effect.onExit((exit) => Effect.logDebug("HTTP operation completed").pipe(Effect.annotateLogs({ "http.outcome": outcome(exit) }))), Effect.withLogSpan("schema-http.operation"));
120
- return { ...Pipeable.Prototype, execute };
142
+ return {
143
+ ...Pipeable.Prototype,
144
+ execute,
145
+ parts: { request, response, options, step: undefined },
146
+ };
121
147
  };
122
148
  /**
123
149
  * Return the Effect for an operation's input, in direct or pipeable form.
@@ -126,21 +152,194 @@ export const make = (request, response, options) => {
126
152
  * Equivalent to `operation.execute(input)`. It does not itself evaluate the Effect.
127
153
  */
128
154
  export const execute = Function.dual(2, (self, input) => self.execute(input));
155
+ /** The types refuse an operation with no parts; a cast or plain JavaScript gets a clear failure. */
156
+ const partsOf = (self) => {
157
+ if (self.parts === undefined)
158
+ throw new Error("This operation has no parts to adjust: it came from Operation.fromEffect");
159
+ return self.parts;
160
+ };
161
+ /** Rebuild through {@link make}, so the automatic `Accept` follows the response. */
162
+ const rebuild = (parts) => {
163
+ const { request, response, options, step } = parts;
164
+ const built = make(request, response, options);
165
+ const result = step === undefined
166
+ ? built
167
+ : {
168
+ ...built,
169
+ execute: (input) => Effect.flatMap(built.execute(input), step.run),
170
+ parts: { request, response, options, step },
171
+ };
172
+ return result;
173
+ };
174
+ /**
175
+ * Derive a variant with a changed request. A recorded result step stays.
176
+ *
177
+ * @example
178
+ * ```ts
179
+ * import { Body, Operation, Request, Response } from "viell-effect-schema-http";
180
+ * const getThings = Operation.make(
181
+ * Request.get("https://api.example.test/things?limit=25"),
182
+ * Response.status(200, Body.json),
183
+ * );
184
+ * const firstFive = Request.setQuery("limit", "5");
185
+ * const fewerThings = getThings.pipe(Operation.mapRequest(firstFive));
186
+ * // getThings still asks for 25.
187
+ * ```
188
+ *
189
+ * @remarks
190
+ * The function receives the current request, so every `Request` function works here, including a
191
+ * binding that changes the operation's input. The automatic `Accept` and the options carry over.
192
+ * The library cannot tell whether a change alters the shape of the answer: selecting fields or
193
+ * embedding relations usually does, and then needs {@link mapResponse} too.
194
+ *
195
+ * Works on any operation from {@link make}, mapped or not. A value from {@link fromEffect} has no
196
+ * parts, and one annotated as a plain `Operation<I, A, E, R>` hides them: both are compile errors.
197
+ */
198
+ export const mapRequest = (f) => (self) => {
199
+ const parts = partsOf(self);
200
+ return rebuild({ ...parts, request: f(parts.request) });
201
+ };
202
+ /**
203
+ * Derive a variant with a changed response. A recorded result step stays, and has to fit.
204
+ *
205
+ * @example
206
+ * ```ts
207
+ * import { Schema } from "effect";
208
+ * import { Body, Operation, Request, Response } from "viell-effect-schema-http";
209
+ * const Thing = Schema.Struct({ id: Schema.Number, name: Schema.String });
210
+ * const ThingOption = Schema.Struct({ id: Schema.Number });
211
+ * const getThing = Operation.make(
212
+ * Request.get("https://api.example.test/things/1"),
213
+ * Response.status(200, Body.jsonSchema(Thing)),
214
+ * );
215
+ * const asOption = Response.replace(200, Body.jsonSchema(ThingOption));
216
+ * const thingOption = getThing.pipe(Operation.mapResponse(asOption));
217
+ * ```
218
+ *
219
+ * @remarks
220
+ * The function receives the current response, so {@link Response.replace},
221
+ * {@link Response.remove} and {@link Response.orElse} all work here. The automatic `Accept` follows
222
+ * the new response.
223
+ *
224
+ * On a mapped operation the new result must fit: it has to be assignable to the current response's
225
+ * result, and not `any`, because the recorded step was written for that result. So a same-shape
226
+ * replace or a removal works, and anything else is a compile error that names {@link unmap}.
227
+ * A narrowed result is the new baseline, so widening it back needs {@link unmap} as well.
228
+ * This is a compile-time rule: a cast gets past it, and the step then receives the wrong shape.
229
+ */
230
+ export const mapResponse = (f) => (self) => {
231
+ const parts = partsOf(self);
232
+ return rebuild({ ...parts, response: f(parts.response) });
233
+ };
234
+ /**
235
+ * Derive a variant with changed options. A recorded result step stays.
236
+ *
237
+ * @example
238
+ * ```ts
239
+ * import { Schedule } from "effect";
240
+ * import {
241
+ * Body,
242
+ * Operation,
243
+ * Policy,
244
+ * Request,
245
+ * Response,
246
+ * } from "viell-effect-schema-http";
247
+ * const getThings = Operation.make(
248
+ * Request.get("https://api.example.test/things"),
249
+ * Response.status(200, Body.json),
250
+ * );
251
+ * const retryTwice = Policy.make(Schedule.recurs(2));
252
+ * const patient = getThings.pipe(
253
+ * Operation.mapOptions((options) => ({ ...options, policy: retryTwice })),
254
+ * );
255
+ * ```
256
+ *
257
+ * @remarks
258
+ * The function receives the current options, or `undefined` if there are none, and its result
259
+ * replaces them. Spread them to keep what you do not change. A failure or service type that only
260
+ * a dropped option added leaves with it.
261
+ */
262
+ export const mapOptions = (f) => (self) => {
263
+ const parts = partsOf(self);
264
+ return rebuild({ ...parts, options: f(parts.options) });
265
+ };
266
+ /**
267
+ * Remove every recorded result step, so the operation returns what its response decodes.
268
+ *
269
+ * @example
270
+ * ```ts
271
+ * import { Schema } from "effect";
272
+ * import { Body, Operation, Request, Response } from "viell-effect-schema-http";
273
+ * const Page = Schema.Struct({ data: Schema.Array(Schema.String) });
274
+ * const Names = Schema.Struct({ data: Schema.Array(Schema.Number) });
275
+ * const getThings = Operation.make(
276
+ * Request.get("https://api.example.test/things"),
277
+ * Response.status(200, Body.jsonSchema(Page)),
278
+ * ).pipe(Operation.map((page) => page.data));
279
+ *
280
+ * const asIds = Response.replace(200, Body.jsonSchema(Names));
281
+ * const thingIds = getThings.pipe(
282
+ * Operation.unmap,
283
+ * Operation.mapResponse(asIds),
284
+ * Operation.map((page) => page.data),
285
+ * );
286
+ * ```
287
+ *
288
+ * @remarks
289
+ * This is the route to a response {@link mapResponse} refuses: remove the mapping, change the
290
+ * response, then map again. The failures and services the steps added leave with them. On an
291
+ * operation with no step this changes nothing.
292
+ */
293
+ export const unmap = (self) => rebuild({ ...partsOf(self), step: undefined });
294
+ /**
295
+ * Wrap the operation's own `execute`, and record the step for a later {@link rebuild}. Two steps
296
+ * combine into one, so the type does not grow with each map.
297
+ */
298
+ const addStep = (self, f) => {
299
+ const wrapped = fromEffect((input) => Effect.flatMap(self.execute(input), f));
300
+ const parts = self.parts;
301
+ const previous = parts?.step;
302
+ const result = parts === undefined
303
+ ? wrapped
304
+ : {
305
+ ...wrapped,
306
+ parts: {
307
+ ...parts,
308
+ step: {
309
+ run: previous === undefined
310
+ ? f
311
+ : (value) => Effect.flatMap(previous.run(value), f),
312
+ },
313
+ },
314
+ };
315
+ return result;
316
+ };
129
317
  /**
130
318
  * Transform an operation's successful result with a pure function.
131
319
  *
132
320
  * @remarks
133
- * Keeps the input, error and service types. Runs after the operation and its retry policy finish.
134
- * Use {@link mapEffect} to return a typed failure or perform further effectful work.
321
+ * Keeps the input, error and service types. Runs once, after the operation and its retry policy
322
+ * finish, outside each attempt's scope and timeout. Use {@link mapEffect} to return a typed failure
323
+ * or perform further effectful work.
324
+ *
325
+ * The operation keeps its parts and records this as a step, so {@link mapRequest} and
326
+ * {@link mapOptions} still work on the result, and {@link mapResponse} works while the new result
327
+ * fits. Two maps combine into one step. The mapping applies to the whole result, whichever case
328
+ * produced it. For a conversion that belongs to one case, use `Body.map` on that case's decoder: a
329
+ * later `Response.replace` takes the conversion with the case.
135
330
  */
136
- export const map = (f) => (self) => fromEffect((input) => Effect.map(self.execute(input), f));
331
+ export const map = (f) => (self) => addStep(self, (value) => Effect.succeed(f(value)));
137
332
  /**
138
333
  * Transform an operation's successful result with an Effect.
139
334
  *
140
335
  * @remarks
141
- * Adds the transformation's errors and required services. Runs after the operation's retry
142
- * policy completes, so failures here do not trigger that policy. Use it to turn a recognized
143
- * response outcome into an application error.
336
+ * Adds the transformation's errors and required services. Runs once, after the operation's retry
337
+ * policy completes, outside each attempt's scope and timeout, so failures here do not trigger that
338
+ * policy and arrive as themselves. Use it to turn a recognized response outcome into an application
339
+ * error.
340
+ *
341
+ * The operation keeps its parts and records this as a step, as {@link map} describes. Its failures
342
+ * and services stay through a variant and leave with {@link unmap}.
144
343
  */
145
- export const mapEffect = (f) => (self) => fromEffect((input) => Effect.flatMap(self.execute(input), f));
344
+ export const mapEffect = (f) => (self) => addStep(self, (value) => f(value));
146
345
  //# sourceMappingURL=Operation.js.map