@distilled.cloud/core 1.0.0-rc.17 → 1.0.0-rc.18
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.
- package/lib/_bundle/base.js +2 -2
- package/lib/_bundle/base.js.map +1 -1
- package/lib/_bundle/graphql.js +2 -2
- package/lib/_bundle/graphql.js.map +1 -1
- package/lib/_bundle/rest.js +1 -1
- package/lib/_bundle/rest.js.map +1 -1
- package/lib/annotations.d.ts +15 -0
- package/lib/annotations.d.ts.map +1 -0
- package/lib/annotations.js +2 -0
- package/lib/annotations.js.map +1 -0
- package/lib/api.d.ts +15 -0
- package/lib/api.d.ts.map +1 -1
- package/lib/api.js +1 -1
- package/lib/category.d.ts.map +1 -1
- package/lib/config.d.ts +54 -13
- package/lib/config.d.ts.map +1 -1
- package/lib/config.js +1 -1
- package/lib/debug.d.ts.map +1 -1
- package/lib/error-category.d.ts.map +1 -1
- package/lib/errors.d.ts +2 -13
- package/lib/errors.d.ts.map +1 -1
- package/lib/errors.js +1 -1
- package/lib/graphql.d.ts +14 -0
- package/lib/graphql.d.ts.map +1 -1
- package/lib/index.d.ts +3 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -0
- package/lib/pagination.d.ts +34 -2
- package/lib/pagination.d.ts.map +1 -1
- package/lib/pagination.js +1 -1
- package/lib/protocol-http.d.ts +30 -6
- package/lib/protocol-http.d.ts.map +1 -1
- package/lib/protocol-http.js +1 -1
- package/lib/protocol-rest.d.ts +53 -39
- package/lib/protocol-rest.d.ts.map +1 -1
- package/lib/protocol-rest.js +1 -1
- package/lib/response-validation.d.ts +4 -3
- package/lib/response-validation.d.ts.map +1 -1
- package/lib/schema-lite-typed.js +1 -2
- package/lib/telemetry-debug.d.ts +14 -0
- package/lib/telemetry-debug.d.ts.map +1 -0
- package/lib/telemetry-debug.js +2 -0
- package/lib/telemetry-debug.js.map +1 -0
- package/lib/telemetry-hooks.d.ts +32 -0
- package/lib/telemetry-hooks.d.ts.map +1 -0
- package/lib/telemetry-hooks.js +2 -0
- package/lib/telemetry-hooks.js.map +1 -0
- package/lib/telemetry-host-rules.d.ts +23 -0
- package/lib/telemetry-host-rules.d.ts.map +1 -0
- package/lib/telemetry-host-rules.js +2 -0
- package/lib/telemetry-host-rules.js.map +1 -0
- package/lib/telemetry-lambda-context.d.ts +17 -0
- package/lib/telemetry-lambda-context.d.ts.map +1 -0
- package/lib/telemetry-lambda-context.js +2 -0
- package/lib/telemetry-lambda-context.js.map +1 -0
- package/lib/telemetry-message-context.d.ts +52 -0
- package/lib/telemetry-message-context.d.ts.map +1 -0
- package/lib/telemetry-message-context.js +2 -0
- package/lib/telemetry-message-context.js.map +1 -0
- package/lib/telemetry-metrics.d.ts +6 -0
- package/lib/telemetry-metrics.d.ts.map +1 -0
- package/lib/telemetry-metrics.js +2 -0
- package/lib/telemetry-metrics.js.map +1 -0
- package/lib/telemetry-name-template.d.ts +13 -0
- package/lib/telemetry-name-template.d.ts.map +1 -0
- package/lib/telemetry-name-template.js +2 -0
- package/lib/telemetry-name-template.js.map +1 -0
- package/lib/telemetry-stream.d.ts +9 -0
- package/lib/telemetry-stream.d.ts.map +1 -0
- package/lib/telemetry-stream.js +2 -0
- package/lib/telemetry-stream.js.map +1 -0
- package/lib/telemetry-xray.d.ts +28 -0
- package/lib/telemetry-xray.d.ts.map +1 -0
- package/lib/telemetry-xray.js +2 -0
- package/lib/telemetry-xray.js.map +1 -0
- package/lib/telemetry.d.ts +269 -0
- package/lib/telemetry.d.ts.map +1 -0
- package/lib/telemetry.js +3 -0
- package/lib/telemetry.js.map +1 -0
- package/package.json +1 -3
- package/src/annotations.ts +37 -0
- package/src/api.ts +123 -24
- package/src/category.ts +21 -22
- package/src/config.ts +58 -29
- package/src/debug.ts +9 -6
- package/src/error-category.ts +12 -14
- package/src/errors.ts +7 -7
- package/src/graphql.ts +123 -18
- package/src/index.ts +3 -2
- package/src/pagination.ts +119 -6
- package/src/protocol-http.ts +63 -43
- package/src/protocol-rest.ts +201 -140
- package/src/response-validation.ts +4 -3
- package/src/telemetry-debug.ts +135 -0
- package/src/telemetry-hooks.ts +33 -0
- package/src/telemetry-host-rules.ts +39 -0
- package/src/telemetry-lambda-context.ts +46 -0
- package/src/telemetry-message-context.ts +170 -0
- package/src/telemetry-metrics.ts +69 -0
- package/src/telemetry-name-template.ts +26 -0
- package/src/telemetry-stream.ts +91 -0
- package/src/telemetry-xray.ts +66 -0
- package/src/telemetry.ts +768 -0
- package/lib/codegen/boolean-string-enums.d.ts +0 -36
- package/lib/codegen/boolean-string-enums.d.ts.map +0 -1
- package/lib/codegen/boolean-string-enums.js +0 -147
- package/lib/codegen/boolean-string-enums.js.map +0 -1
- package/lib/codegen/chunk.d.ts +0 -7
- package/lib/codegen/chunk.d.ts.map +0 -1
- package/lib/codegen/chunk.js +0 -139
- package/lib/codegen/chunk.js.map +0 -1
- package/lib/codegen/cli.d.ts +0 -80
- package/lib/codegen/cli.d.ts.map +0 -1
- package/lib/codegen/cli.js +0 -166
- package/lib/codegen/cli.js.map +0 -1
- package/lib/codegen/datafy.d.ts +0 -14
- package/lib/codegen/datafy.d.ts.map +0 -1
- package/lib/codegen/datafy.js +0 -853
- package/lib/codegen/datafy.js.map +0 -1
- package/lib/codegen/dedupe.d.ts +0 -5
- package/lib/codegen/dedupe.d.ts.map +0 -1
- package/lib/codegen/dedupe.js +0 -153
- package/lib/codegen/dedupe.js.map +0 -1
- package/lib/codegen/emit.d.ts +0 -125
- package/lib/codegen/emit.d.ts.map +0 -1
- package/lib/codegen/emit.js +0 -99
- package/lib/codegen/emit.js.map +0 -1
- package/lib/codegen/format.d.ts +0 -11
- package/lib/codegen/format.d.ts.map +0 -1
- package/lib/codegen/format.js +0 -32
- package/lib/codegen/format.js.map +0 -1
- package/lib/codegen/generated-at.d.ts +0 -29
- package/lib/codegen/generated-at.d.ts.map +0 -1
- package/lib/codegen/generated-at.js +0 -78
- package/lib/codegen/generated-at.js.map +0 -1
- package/lib/codegen/generator.d.ts +0 -353
- package/lib/codegen/generator.d.ts.map +0 -1
- package/lib/codegen/generator.js +0 -810
- package/lib/codegen/generator.js.map +0 -1
- package/lib/codegen/graph.d.ts +0 -36
- package/lib/codegen/graph.d.ts.map +0 -1
- package/lib/codegen/graph.js +0 -136
- package/lib/codegen/graph.js.map +0 -1
- package/lib/codegen/graphql-client.d.ts +0 -70
- package/lib/codegen/graphql-client.d.ts.map +0 -1
- package/lib/codegen/graphql-client.js +0 -439
- package/lib/codegen/graphql-client.js.map +0 -1
- package/lib/codegen/graphql.d.ts +0 -207
- package/lib/codegen/graphql.d.ts.map +0 -1
- package/lib/codegen/graphql.js +0 -786
- package/lib/codegen/graphql.js.map +0 -1
- package/lib/codegen/latin1.d.ts +0 -3
- package/lib/codegen/latin1.d.ts.map +0 -1
- package/lib/codegen/latin1.js +0 -126
- package/lib/codegen/latin1.js.map +0 -1
- package/lib/codegen/members.d.ts +0 -32
- package/lib/codegen/members.d.ts.map +0 -1
- package/lib/codegen/members.js +0 -62
- package/lib/codegen/members.js.map +0 -1
- package/lib/codegen/model-diff.d.ts +0 -10
- package/lib/codegen/model-diff.d.ts.map +0 -1
- package/lib/codegen/model-diff.js +0 -67
- package/lib/codegen/model-diff.js.map +0 -1
- package/lib/codegen/naming.d.ts +0 -29
- package/lib/codegen/naming.d.ts.map +0 -1
- package/lib/codegen/naming.js +0 -74
- package/lib/codegen/naming.js.map +0 -1
- package/lib/codegen/openapi-cli.d.ts +0 -52
- package/lib/codegen/openapi-cli.d.ts.map +0 -1
- package/lib/codegen/openapi-cli.js +0 -84
- package/lib/codegen/openapi-cli.js.map +0 -1
- package/lib/codegen/openapi.d.ts +0 -209
- package/lib/codegen/openapi.d.ts.map +0 -1
- package/lib/codegen/openapi.js +0 -1548
- package/lib/codegen/openapi.js.map +0 -1
- package/lib/codegen/operations.d.ts +0 -24
- package/lib/codegen/operations.d.ts.map +0 -1
- package/lib/codegen/operations.js +0 -56
- package/lib/codegen/operations.js.map +0 -1
- package/lib/codegen/pagination.d.ts +0 -39
- package/lib/codegen/pagination.d.ts.map +0 -1
- package/lib/codegen/pagination.js +0 -31
- package/lib/codegen/pagination.js.map +0 -1
- package/lib/codegen/patch-audit.d.ts +0 -84
- package/lib/codegen/patch-audit.d.ts.map +0 -1
- package/lib/codegen/patch-audit.js +0 -366
- package/lib/codegen/patch-audit.js.map +0 -1
- package/lib/codegen/patches.d.ts +0 -129
- package/lib/codegen/patches.d.ts.map +0 -1
- package/lib/codegen/patches.js +0 -472
- package/lib/codegen/patches.js.map +0 -1
- package/lib/codegen/prelude.d.ts +0 -15
- package/lib/codegen/prelude.d.ts.map +0 -1
- package/lib/codegen/prelude.js +0 -60
- package/lib/codegen/prelude.js.map +0 -1
- package/lib/codegen/privatize.d.ts +0 -21
- package/lib/codegen/privatize.d.ts.map +0 -1
- package/lib/codegen/privatize.js +0 -176
- package/lib/codegen/privatize.js.map +0 -1
- package/lib/codegen/proto.d.ts +0 -121
- package/lib/codegen/proto.d.ts.map +0 -1
- package/lib/codegen/proto.js +0 -960
- package/lib/codegen/proto.js.map +0 -1
- package/lib/codegen/pure.d.ts +0 -6
- package/lib/codegen/pure.d.ts.map +0 -1
- package/lib/codegen/pure.js +0 -91
- package/lib/codegen/pure.js.map +0 -1
- package/lib/codegen/rewrite-operation-ids.d.ts +0 -154
- package/lib/codegen/rewrite-operation-ids.d.ts.map +0 -1
- package/lib/codegen/rewrite-operation-ids.js +0 -1117
- package/lib/codegen/rewrite-operation-ids.js.map +0 -1
- package/lib/codegen/spec-path.d.ts +0 -16
- package/lib/codegen/spec-path.d.ts.map +0 -1
- package/lib/codegen/spec-path.js +0 -101
- package/lib/codegen/spec-path.js.map +0 -1
- package/lib/codegen/table.d.ts +0 -5
- package/lib/codegen/table.d.ts.map +0 -1
- package/lib/codegen/table.js +0 -249
- package/lib/codegen/table.js.map +0 -1
- package/lib/json-patch.d.ts +0 -58
- package/lib/json-patch.d.ts.map +0 -1
- package/lib/json-patch.js +0 -2
- package/lib/json-patch.js.map +0 -1
- package/lib/schema-lite-typed.js.map +0 -1
- package/lib/testing.d.ts +0 -40
- package/lib/testing.d.ts.map +0 -1
- package/lib/testing.js +0 -2
- package/lib/testing.js.map +0 -1
- package/src/codegen/boolean-string-enums.ts +0 -155
- package/src/codegen/chunk.ts +0 -147
- package/src/codegen/cli.ts +0 -293
- package/src/codegen/datafy.ts +0 -874
- package/src/codegen/dedupe.ts +0 -173
- package/src/codegen/emit.ts +0 -200
- package/src/codegen/format.ts +0 -49
- package/src/codegen/generated-at.ts +0 -88
- package/src/codegen/generator.ts +0 -1229
- package/src/codegen/graph.ts +0 -151
- package/src/codegen/graphql-client.ts +0 -545
- package/src/codegen/graphql.ts +0 -1145
- package/src/codegen/latin1.ts +0 -131
- package/src/codegen/members.ts +0 -79
- package/src/codegen/model-diff.ts +0 -67
- package/src/codegen/naming.ts +0 -85
- package/src/codegen/openapi-cli.ts +0 -141
- package/src/codegen/openapi.ts +0 -1845
- package/src/codegen/operations.ts +0 -73
- package/src/codegen/pagination.ts +0 -64
- package/src/codegen/patch-audit.ts +0 -480
- package/src/codegen/patches.ts +0 -581
- package/src/codegen/prelude.ts +0 -70
- package/src/codegen/privatize.ts +0 -200
- package/src/codegen/proto.ts +0 -1092
- package/src/codegen/pure.ts +0 -94
- package/src/codegen/rewrite-operation-ids.ts +0 -1219
- package/src/codegen/spec-path.ts +0 -112
- package/src/codegen/table.ts +0 -254
- package/src/json-patch.ts +0 -273
- package/src/testing.ts +0 -74
package/src/api.ts
CHANGED
|
@@ -15,6 +15,7 @@ import type * as AST from "effect/SchemaAST";
|
|
|
15
15
|
import * as Scope from "effect/Scope";
|
|
16
16
|
import type * as Stream from "effect/Stream";
|
|
17
17
|
import { SingleShotGen } from "effect/Utils";
|
|
18
|
+
import { getAnn, rawResponseRootSymbol } from "./annotations.ts";
|
|
18
19
|
import { isThrottling } from "./category.ts";
|
|
19
20
|
import * as Pagination from "./pagination.ts";
|
|
20
21
|
import {
|
|
@@ -25,6 +26,7 @@ import {
|
|
|
25
26
|
resolveServerRetryHintCapMs,
|
|
26
27
|
serverHintMillis,
|
|
27
28
|
} from "./retry.ts";
|
|
29
|
+
import * as Telemetry from "./telemetry.ts";
|
|
28
30
|
|
|
29
31
|
//#region Protocol
|
|
30
32
|
|
|
@@ -239,6 +241,14 @@ export interface OperationConfig<
|
|
|
239
241
|
* {@link ProtocolOperationConfig.endpointHostPrefix}).
|
|
240
242
|
*/
|
|
241
243
|
endpointHostPrefix?: string;
|
|
244
|
+
/** The service's `com.distilled.telemetry#service` trait (a module const). */
|
|
245
|
+
telemetry?: Telemetry.ServiceTelemetry;
|
|
246
|
+
/**
|
|
247
|
+
* The operation's `com.distilled.telemetry#operation` trait, with its
|
|
248
|
+
* input rules; only what differs from the service's rules when it names
|
|
249
|
+
* its `op` (a string is just the op).
|
|
250
|
+
*/
|
|
251
|
+
span?: Telemetry.SpanConfig | string;
|
|
242
252
|
}
|
|
243
253
|
|
|
244
254
|
/**
|
|
@@ -264,6 +274,26 @@ const backoffDelay = (b: Backoff, attempt: number, error: unknown): Effect.Effec
|
|
|
264
274
|
|
|
265
275
|
const NO_BACKOFF: Backoff = { baseMs: 0, factor: 1, capMs: 0 };
|
|
266
276
|
|
|
277
|
+
/**
|
|
278
|
+
* BRAINSTORM: the sleep before retry `attempt` (1-based). The retry is
|
|
279
|
+
* recorded on the operation span; debug mode also makes the sleep a span.
|
|
280
|
+
*/
|
|
281
|
+
const backoffSleep = (
|
|
282
|
+
delay: Duration.Input,
|
|
283
|
+
attempt: number,
|
|
284
|
+
error: unknown,
|
|
285
|
+
): Effect.Effect<void> =>
|
|
286
|
+
Effect.withFiber((fiber) => {
|
|
287
|
+
const context = fiber.context as Context.Context<any>;
|
|
288
|
+
const delayMs = typeof delay === "number" ? delay : 0;
|
|
289
|
+
Telemetry.retried(context, attempt, error, delayMs);
|
|
290
|
+
return Telemetry.phase(context, "distilled.retry.backoff", Effect.sleep(delay), {
|
|
291
|
+
"distilled.retry.attempt": attempt,
|
|
292
|
+
"distilled.retry.delay_ms": Math.round(delayMs),
|
|
293
|
+
"distilled.retry.reason": (error as { _tag?: string } | null)?._tag,
|
|
294
|
+
});
|
|
295
|
+
});
|
|
296
|
+
|
|
267
297
|
/**
|
|
268
298
|
* Wrap one operation call with the caller-provided retry policy, if the
|
|
269
299
|
* operation declares a retry tag. The call runs once with no retry
|
|
@@ -271,35 +301,44 @@ const NO_BACKOFF: Backoff = { baseMs: 0, factor: 1, capMs: 0 };
|
|
|
271
301
|
* {@link Backoff} data run by a small loop; a caller-supplied `schedule`
|
|
272
302
|
* runs under `Effect.retry`, with the first failure replayed as attempt one
|
|
273
303
|
* so delays and counts match running the whole call under it.
|
|
304
|
+
*
|
|
305
|
+
* With `TelemetryDebug.layer`, every try runs as `Attempt` span n.
|
|
274
306
|
*/
|
|
275
307
|
const applyRetry = (
|
|
276
308
|
base: Effect.Effect<any, any, any>,
|
|
277
309
|
retryKey: Context.Key<any, RetryPolicy> | undefined,
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
310
|
+
debug: Telemetry.DebugHooks | undefined,
|
|
311
|
+
): Effect.Effect<any, any, any> => {
|
|
312
|
+
const first = debug === undefined ? base : debug.attempt(base, 1);
|
|
313
|
+
return retryKey === undefined
|
|
314
|
+
? first
|
|
315
|
+
: Effect.catch(first, (error) =>
|
|
282
316
|
Effect.flatMap(Effect.serviceOption(retryKey), (opt) => {
|
|
283
|
-
if (Option.isNone(opt)) return retryWith(base, defaultOptions, error);
|
|
317
|
+
if (Option.isNone(opt)) return retryWith(base, defaultOptions, error, debug);
|
|
284
318
|
const policy = opt.value;
|
|
285
|
-
if (typeof policy !== "function") return retryWith(base, policy, error);
|
|
319
|
+
if (typeof policy !== "function") return retryWith(base, policy, error, debug);
|
|
286
320
|
return Effect.flatMap(Ref.make<unknown>(error), (lastError) =>
|
|
287
321
|
retryWith(
|
|
288
322
|
Effect.tapError(base, (e) => Ref.set(lastError, e)),
|
|
289
323
|
policy(lastError),
|
|
290
324
|
error,
|
|
325
|
+
debug,
|
|
291
326
|
),
|
|
292
327
|
);
|
|
293
328
|
}),
|
|
294
329
|
);
|
|
330
|
+
};
|
|
295
331
|
|
|
296
332
|
const retryWith = (
|
|
297
333
|
base: Effect.Effect<any, any, any>,
|
|
298
334
|
opts: RetryOptions,
|
|
299
335
|
error: unknown,
|
|
336
|
+
debug: Telemetry.DebugHooks | undefined,
|
|
300
337
|
): Effect.Effect<any, any, any> => {
|
|
301
338
|
const keepGoing = opts.while;
|
|
302
339
|
if (!keepGoing || !keepGoing(error)) return Effect.fail(error);
|
|
340
|
+
// Attempt n (2, 3, ...) of the call.
|
|
341
|
+
const again = (n: number) => (debug === undefined ? base : debug.attempt(base, n));
|
|
303
342
|
if (opts.schedule) {
|
|
304
343
|
// Drive the caller's schedule through its own `step`, as Effect.retry
|
|
305
344
|
// does, without importing the Schedule module into every bundle: the
|
|
@@ -311,6 +350,7 @@ const retryWith = (
|
|
|
311
350
|
>;
|
|
312
351
|
};
|
|
313
352
|
return Effect.flatMap(schedule.step, (next) => {
|
|
353
|
+
let attempt = 0;
|
|
314
354
|
const loop = (e: unknown): Effect.Effect<any, any, any> =>
|
|
315
355
|
!keepGoing(e)
|
|
316
356
|
? Effect.fail(e)
|
|
@@ -318,7 +358,9 @@ const retryWith = (
|
|
|
318
358
|
Effect.matchEffect(next(clock.currentTimeMillisUnsafe(), e), {
|
|
319
359
|
onFailure: () => Effect.fail(e),
|
|
320
360
|
onSuccess: ([, delay]) =>
|
|
321
|
-
Effect.flatMap(
|
|
361
|
+
Effect.flatMap(backoffSleep(delay, ++attempt, e), () =>
|
|
362
|
+
Effect.catch(again(attempt + 1), loop),
|
|
363
|
+
),
|
|
322
364
|
}),
|
|
323
365
|
);
|
|
324
366
|
return loop(error);
|
|
@@ -329,7 +371,9 @@ const retryWith = (
|
|
|
329
371
|
!keepGoing(e) || (b.maxRetries !== undefined && n >= b.maxRetries)
|
|
330
372
|
? Effect.fail(e)
|
|
331
373
|
: Effect.flatMap(backoffDelay(b, n, e), (ms) =>
|
|
332
|
-
Effect.flatMap(
|
|
374
|
+
Effect.flatMap(backoffSleep(ms, n + 1, e), () =>
|
|
375
|
+
Effect.catch(again(n + 2), (next) => step(next, n + 1)),
|
|
376
|
+
),
|
|
333
377
|
);
|
|
334
378
|
return step(error, 0);
|
|
335
379
|
};
|
|
@@ -351,8 +395,18 @@ interface Prepared extends PreparedOperation {
|
|
|
351
395
|
readonly cfg: OperationConfig<any, any, any, any, any>;
|
|
352
396
|
/** The built protocol service, once its layer has been built. */
|
|
353
397
|
service?: ProtocolShape;
|
|
398
|
+
/** The operation span's facts, from the telemetry traits; built on the first traced call. */
|
|
399
|
+
info?: Telemetry.OperationInfo;
|
|
354
400
|
}
|
|
355
401
|
|
|
402
|
+
const infoOf = (p: Prepared): Telemetry.OperationInfo =>
|
|
403
|
+
(p.info ??= Telemetry.operationInfo(
|
|
404
|
+
p.cfg.telemetry,
|
|
405
|
+
p.cfg.span,
|
|
406
|
+
p.cfg.operationName,
|
|
407
|
+
p.inputAst,
|
|
408
|
+
));
|
|
409
|
+
|
|
356
410
|
const stateKey = /*@__PURE__*/ Symbol.for("@distilled.cloud/core/api/OperationState");
|
|
357
411
|
|
|
358
412
|
// Lazily resolve the operation config + schema ASTs on first call, not at
|
|
@@ -377,6 +431,14 @@ const prepare = (state: OperationState): Prepared => {
|
|
|
377
431
|
|
|
378
432
|
const stateOf = (op: unknown): OperationState => (op as Record<symbol, OperationState>)[stateKey]!;
|
|
379
433
|
|
|
434
|
+
/**
|
|
435
|
+
* The span facts an operation's calls carry (name, kind, fixed attributes,
|
|
436
|
+
* input rules), as the runtime builds them from its generated config. For
|
|
437
|
+
* tests and tooling.
|
|
438
|
+
*/
|
|
439
|
+
export const describeOperation = (op: unknown): Telemetry.OperationInfo =>
|
|
440
|
+
infoOf(prepare(stateOf(op)));
|
|
441
|
+
|
|
380
442
|
const defineState = (op: unknown, state: OperationState): OperationState => {
|
|
381
443
|
Object.defineProperty(op, stateKey, { value: state });
|
|
382
444
|
return state;
|
|
@@ -389,27 +451,59 @@ const runWith = (
|
|
|
389
451
|
): Effect.Effect<any, any, any> => {
|
|
390
452
|
if (protocol.call !== undefined) return protocol.call(p, input);
|
|
391
453
|
const { cfg, inputAst, outputAst, errors } = p;
|
|
392
|
-
return Effect.
|
|
393
|
-
|
|
394
|
-
|
|
454
|
+
return Effect.withFiber((fiber) => {
|
|
455
|
+
const context = fiber.context as Context.Context<any>;
|
|
456
|
+
const client = Context.get(context, HttpClient.HttpClient);
|
|
457
|
+
return Effect.flatMap(protocol.encode({ input, inputAst, config: cfg }), (request) =>
|
|
458
|
+
Effect.flatMap(Telemetry.execute(context, client, request), (response) =>
|
|
395
459
|
protocol.decode({ response, outputAst, errors, config: cfg }),
|
|
396
460
|
),
|
|
397
|
-
)
|
|
398
|
-
);
|
|
461
|
+
);
|
|
462
|
+
});
|
|
399
463
|
};
|
|
400
464
|
|
|
401
|
-
const
|
|
465
|
+
const callUntraced = (
|
|
466
|
+
state: OperationState,
|
|
467
|
+
input: unknown,
|
|
468
|
+
debug: Telemetry.DebugHooks | undefined,
|
|
469
|
+
): Effect.Effect<any, any, any> => {
|
|
402
470
|
// Warm path: the operation is prepared and its protocol built, so the call
|
|
403
471
|
// is whatever the protocol returns, with no wrapper effects around it.
|
|
404
472
|
const p = state.prepared;
|
|
405
|
-
if (p?.service !== undefined) return applyRetry(runWith(p, p.service, input), p.cfg.retry);
|
|
473
|
+
if (p?.service !== undefined) return applyRetry(runWith(p, p.service, input), p.cfg.retry, debug);
|
|
406
474
|
return Effect.suspend(() => {
|
|
407
475
|
const prepared = prepare(state);
|
|
408
|
-
const call = Effect.flatMap(
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
476
|
+
const call = Effect.flatMap(
|
|
477
|
+
debug === undefined
|
|
478
|
+
? protocolContext(prepared.cfg.protocol)
|
|
479
|
+
: debug.phase("distilled.setup", protocolContext(prepared.cfg.protocol), {
|
|
480
|
+
"distilled.setup.first_call": true,
|
|
481
|
+
}),
|
|
482
|
+
(protocolCtx) => {
|
|
483
|
+
const service = (prepared.service = Context.get(protocolCtx, Protocol));
|
|
484
|
+
return runWith(prepared, service, input);
|
|
485
|
+
},
|
|
486
|
+
);
|
|
487
|
+
return applyRetry(call, prepared.cfg.retry, debug);
|
|
488
|
+
});
|
|
489
|
+
};
|
|
490
|
+
|
|
491
|
+
/**
|
|
492
|
+
* BRAINSTORM: the call in its operation span (recorded only when an
|
|
493
|
+
* exporter is installed), whose stack frame is the caller (captured here,
|
|
494
|
+
* synchronously, while the caller is still on the JS stack).
|
|
495
|
+
*/
|
|
496
|
+
const callOperation = (
|
|
497
|
+
state: OperationState,
|
|
498
|
+
input: unknown,
|
|
499
|
+
entry: Function,
|
|
500
|
+
): Effect.Effect<any, any, any> => {
|
|
501
|
+
const callSite = Telemetry.captureCallSite(entry);
|
|
502
|
+
return Effect.withFiber((fiber) => {
|
|
503
|
+
const debug = fiber.getRef(Telemetry.Debug);
|
|
504
|
+
return Telemetry.operationSpan(fiber, debug, infoOf(prepare(state)), callSite, input, (sent) =>
|
|
505
|
+
callUntraced(state, sent, debug),
|
|
506
|
+
);
|
|
413
507
|
});
|
|
414
508
|
};
|
|
415
509
|
|
|
@@ -474,7 +568,7 @@ const OperationProto: object = /*@__PURE__*/ Object.setPrototypeOf(
|
|
|
474
568
|
);
|
|
475
569
|
|
|
476
570
|
const makeOperation = (state: OperationState, proto: object): any => {
|
|
477
|
-
const fn = (input: unknown) => callOperation(state, input);
|
|
571
|
+
const fn = (input: unknown) => callOperation(state, input, fn);
|
|
478
572
|
defineState(fn, state);
|
|
479
573
|
return Object.setPrototypeOf(fn, proto);
|
|
480
574
|
};
|
|
@@ -571,7 +665,12 @@ const streamsOf = (state: OperationState, call: (input: any) => Effect.Effect<an
|
|
|
571
665
|
const pages = (input: Record<string, unknown>) => paginate(call, input, pag());
|
|
572
666
|
const items = (input: Record<string, unknown>) => {
|
|
573
667
|
const p = pag();
|
|
574
|
-
|
|
668
|
+
if (!p.items) return pages(input);
|
|
669
|
+
// A bare-array response's schema is its sole member's value
|
|
670
|
+
// (`RawResponseRoot`), so the member `items` names is the page itself.
|
|
671
|
+
return getAnn(prepare(state).outputAst, rawResponseRootSymbol) !== undefined
|
|
672
|
+
? Pagination.extractArrayItems(pages(input))
|
|
673
|
+
: Pagination.extractItems(pages(input), p.items);
|
|
575
674
|
};
|
|
576
675
|
return { pages, items };
|
|
577
676
|
};
|
|
@@ -830,7 +929,7 @@ export const opPaginated = (fn: DataFn): any => (definer ? definer(fn, 1) : asOp
|
|
|
830
929
|
|
|
831
930
|
/** The call path of a data operation. */
|
|
832
931
|
export const call = (op: unknown, input: unknown): Effect.Effect<any, any, any> =>
|
|
833
|
-
callOperation(stateOf(op), input);
|
|
932
|
+
callOperation(stateOf(op), input, op as Function);
|
|
834
933
|
|
|
835
934
|
/**
|
|
836
935
|
* Generated error classes described by data:
|
|
@@ -1272,7 +1371,7 @@ export const lazyService = (
|
|
|
1272
1371
|
len?: number,
|
|
1273
1372
|
): { readonly o: () => any; readonly e: (name: string) => any; readonly E: any } => {
|
|
1274
1373
|
const svc: LazyService = { url, spec, kinds, ns, at, len, o: [], e: [], oi: 0, ei: 0 };
|
|
1275
|
-
if (!primed && at !== undefined
|
|
1374
|
+
if (!primed && at !== undefined) prime(svc);
|
|
1276
1375
|
return {
|
|
1277
1376
|
o: () => {
|
|
1278
1377
|
const paginated = kinds[svc.o.length] === "p";
|
package/src/category.ts
CHANGED
|
@@ -320,19 +320,19 @@ const makeCatcher =
|
|
|
320
320
|
* )
|
|
321
321
|
* ```
|
|
322
322
|
*/
|
|
323
|
-
export const catchErrors =
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
323
|
+
export const catchErrors = <Categories extends Category[], A2, E2, R2>(
|
|
324
|
+
...args: [...Categories, (err: any) => Effect.Effect<A2, E2, R2>]
|
|
325
|
+
) => {
|
|
326
|
+
// Split once, without mutating `args`, so one catcher can be reused.
|
|
327
|
+
const handler = args[args.length - 1] as (err: any) => Effect.Effect<A2, E2, R2>;
|
|
328
|
+
const categories = args.slice(0, -1) as unknown as Categories;
|
|
329
|
+
return <A, E, R>(effect: Effect.Effect<A, E, R>) =>
|
|
330
|
+
Effect.catchIf(
|
|
331
331
|
effect,
|
|
332
332
|
(e) => categories.some((cat) => hasCategory(e, cat)),
|
|
333
333
|
handler,
|
|
334
334
|
) as Effect.Effect<A | A2, E | E2, R | R2>;
|
|
335
|
-
|
|
335
|
+
};
|
|
336
336
|
|
|
337
337
|
// Alias for convenience
|
|
338
338
|
export { catchErrors as catch };
|
|
@@ -364,19 +364,18 @@ export const catchDependencyViolationError = /*@__PURE__*/ makeCatcher(Dependenc
|
|
|
364
364
|
* )
|
|
365
365
|
* ```
|
|
366
366
|
*/
|
|
367
|
-
export const catchCategory =
|
|
368
|
-
<E,
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
]
|
|
373
|
-
) =>
|
|
374
|
-
|
|
367
|
+
export const catchCategory = <E, const Categories extends Array<AllKeys<E>>, A2, E2, R2>(
|
|
368
|
+
...args: [...Categories, f: (err: ExtractAll<E, Categories[number]>) => Effect.Effect<A2, E2, R2>]
|
|
369
|
+
) => {
|
|
370
|
+
// Split once, without mutating `args`, so one catcher can be reused.
|
|
371
|
+
const f = args[args.length - 1] as (
|
|
372
|
+
err: ExtractAll<E, Categories[number]>,
|
|
373
|
+
) => Effect.Effect<A2, E2, R2>;
|
|
374
|
+
const categories = args.slice(0, -1) as unknown as Categories;
|
|
375
|
+
return <A, R>(
|
|
375
376
|
effect: Effect.Effect<A, E, R>,
|
|
376
|
-
): Effect.Effect<A | A2, E2 | Exclude<E, ExtractAll<E, Categories[number]>>, R | R2> =>
|
|
377
|
-
|
|
378
|
-
const categories = args;
|
|
379
|
-
return Effect.catchIf(
|
|
377
|
+
): Effect.Effect<A | A2, E2 | Exclude<E, ExtractAll<E, Categories[number]>>, R | R2> =>
|
|
378
|
+
Effect.catchIf(
|
|
380
379
|
effect,
|
|
381
380
|
(e) => {
|
|
382
381
|
if (Predicate.isObject(e) && Predicate.hasProperty(categoriesKey)(e)) {
|
|
@@ -392,4 +391,4 @@ export const catchCategory =
|
|
|
392
391
|
// @ts-expect-error - type narrowing limitation
|
|
393
392
|
(e) => f(e),
|
|
394
393
|
) as any;
|
|
395
|
-
|
|
394
|
+
};
|
package/src/config.ts
CHANGED
|
@@ -13,8 +13,9 @@
|
|
|
13
13
|
* - Otherwise the value comes from `process.env`, which is what Effect's
|
|
14
14
|
* default provider reads.
|
|
15
15
|
*
|
|
16
|
-
* A missing variable fails with {@link
|
|
17
|
-
*
|
|
16
|
+
* A missing variable fails with {@link ConfigError} (with its `key`), which `withDefault`, `option` and `orElse` handle. A provided
|
|
17
|
+
* `ConfigProvider` that cannot read its source fails with its `SourceError`,
|
|
18
|
+
* which those helpers pass through.
|
|
18
19
|
*
|
|
19
20
|
* Credentials read these on every request, so without a provider a whole
|
|
20
21
|
* reader tree (`all`, `withDefault`, `orElse`, ...) runs as one synchronous
|
|
@@ -23,25 +24,30 @@
|
|
|
23
24
|
* A missing value inside the tree is a plain marker; the tagged error is
|
|
24
25
|
* only built if the whole tree fails.
|
|
25
26
|
*/
|
|
27
|
+
import type { SourceError } from "effect/ConfigProvider";
|
|
26
28
|
import * as Context from "effect/Context";
|
|
27
|
-
import * as Data from "effect/Data";
|
|
28
29
|
import * as Effect from "effect/Effect";
|
|
29
30
|
import * as Option from "effect/Option";
|
|
30
31
|
import * as Redact from "effect/Redacted";
|
|
32
|
+
import * as Category from "./category.ts";
|
|
33
|
+
import * as Schema from "./schema-lite-typed.ts";
|
|
31
34
|
|
|
32
|
-
/**
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
/**
|
|
36
|
+
* Configuration error - missing or invalid configuration. `key` is the
|
|
37
|
+
* configuration value (e.g. an environment variable) when one is missing.
|
|
38
|
+
*/
|
|
39
|
+
export class ConfigError
|
|
40
|
+
extends /*@__PURE__*/ Schema.TaggedError<ConfigError>()("ConfigError", {
|
|
41
|
+
message: Schema.String,
|
|
42
|
+
key: /*@__PURE__*/ Schema.optional(Schema.String),
|
|
43
|
+
}).pipe(Category.withConfigurationError) {}
|
|
38
44
|
|
|
39
45
|
const CONFIG_PROVIDER_KEY = "effect/ConfigProvider";
|
|
40
46
|
|
|
41
47
|
interface ProvidedConfigProvider {
|
|
42
48
|
readonly load: (
|
|
43
49
|
path: ReadonlyArray<string>,
|
|
44
|
-
) => Effect.Effect<{ readonly _tag: string; readonly value?: string } | undefined,
|
|
50
|
+
) => Effect.Effect<{ readonly _tag: string; readonly value?: string } | undefined, SourceError>;
|
|
45
51
|
}
|
|
46
52
|
|
|
47
53
|
const fromEnv = (name: string): string | undefined =>
|
|
@@ -81,7 +87,7 @@ const hasProvider = (context: Context.Context<never>): boolean =>
|
|
|
81
87
|
Context.getOrUndefined(context, providerKey) !== undefined;
|
|
82
88
|
|
|
83
89
|
const missingError = (m: Missing) =>
|
|
84
|
-
new
|
|
90
|
+
new ConfigError({ key: m.name, message: `Expected ${m.name} to be set` });
|
|
85
91
|
|
|
86
92
|
const fromReader = <A>(reader: Reader<A>): Effect.Effect<A, any, any> => {
|
|
87
93
|
const effect = Effect.withFiber((fiber) => {
|
|
@@ -94,41 +100,62 @@ const fromReader = <A>(reader: Reader<A>): Effect.Effect<A, any, any> => {
|
|
|
94
100
|
return effect;
|
|
95
101
|
};
|
|
96
102
|
|
|
97
|
-
/**
|
|
98
|
-
|
|
103
|
+
/**
|
|
104
|
+
* The raw value of `name` from the provided `ConfigProvider`, or undefined
|
|
105
|
+
* when unset. A provider that cannot read its source fails with `SourceError`.
|
|
106
|
+
*/
|
|
107
|
+
const lookup = (name: string): Effect.Effect<string | undefined, SourceError> =>
|
|
99
108
|
Effect.flatMap(Effect.context<never>(), (context) => {
|
|
100
109
|
const provider = context.mapUnsafe.get(CONFIG_PROVIDER_KEY) as
|
|
101
110
|
| ProvidedConfigProvider
|
|
102
111
|
| undefined;
|
|
103
112
|
if (!provider) return Effect.succeed(fromEnv(name));
|
|
104
|
-
return provider.load([name])
|
|
105
|
-
|
|
106
|
-
Effect.orElseSucceed(() => undefined),
|
|
113
|
+
return Effect.map(provider.load([name]), (node) =>
|
|
114
|
+
node?._tag === "Value" ? node.value : undefined,
|
|
107
115
|
);
|
|
108
116
|
});
|
|
109
117
|
|
|
110
|
-
const required = (name: string): Effect.Effect<string,
|
|
118
|
+
const required = (name: string): Effect.Effect<string, ConfigError | SourceError> =>
|
|
111
119
|
fromReader({
|
|
112
120
|
read: () => fromEnv(name) ?? new Missing(name),
|
|
113
121
|
viaEffect: () =>
|
|
114
122
|
Effect.flatMap(lookup(name), (value) =>
|
|
115
123
|
value === undefined ? Effect.fail(missingError(new Missing(name))) : Effect.succeed(value),
|
|
116
124
|
),
|
|
117
|
-
}) as Effect.Effect<string,
|
|
125
|
+
}) as Effect.Effect<string, ConfigError | SourceError>;
|
|
118
126
|
|
|
119
127
|
/** The string value of environment variable `name`. */
|
|
120
|
-
export const String = (name: string): Effect.Effect<string,
|
|
128
|
+
export const String = (name: string): Effect.Effect<string, ConfigError | SourceError> =>
|
|
129
|
+
required(name);
|
|
121
130
|
|
|
122
131
|
/** The value of `name`, redacted. */
|
|
123
|
-
export const Redacted = (
|
|
132
|
+
export const Redacted = (
|
|
133
|
+
name: string,
|
|
134
|
+
): Effect.Effect<Redact.Redacted<string>, ConfigError | SourceError> =>
|
|
124
135
|
map((value: string) => Redact.make(value))(required(name));
|
|
125
136
|
|
|
137
|
+
/**
|
|
138
|
+
* The failure of a missing value: {@link ConfigError}, matched by its tag
|
|
139
|
+
* (Effect's own config errors share it). `option`, `withDefault` and `orElse` handle
|
|
140
|
+
* only this failure; any other failure of `self` propagates.
|
|
141
|
+
*/
|
|
142
|
+
type Missed = { readonly _tag: "ConfigError" };
|
|
143
|
+
|
|
144
|
+
const isMissed = (error: unknown): boolean =>
|
|
145
|
+
typeof error === "object" && error !== null && (error as Missed)._tag === "ConfigError";
|
|
146
|
+
|
|
147
|
+
const catchMissed = <A, E, R, A2, E2, R2>(
|
|
148
|
+
self: Effect.Effect<A, E, R>,
|
|
149
|
+
f: () => Effect.Effect<A2, E2, R2>,
|
|
150
|
+
): Effect.Effect<A | A2, Exclude<E, Missed> | E2, R | R2> =>
|
|
151
|
+
Effect.catchIf(self, isMissed, f) as Effect.Effect<A | A2, Exclude<E, Missed> | E2, R | R2>;
|
|
152
|
+
|
|
126
153
|
/** The value as an `Option`: `None` when missing. */
|
|
127
154
|
export const option = <A, E, R>(
|
|
128
155
|
self: Effect.Effect<A, E, R>,
|
|
129
|
-
): Effect.Effect<Option.Option<A>,
|
|
156
|
+
): Effect.Effect<Option.Option<A>, Exclude<E, Missed>, R> => {
|
|
130
157
|
const viaEffect = () =>
|
|
131
|
-
|
|
158
|
+
catchMissed(Effect.map(self, Option.some), () => Effect.succeed(Option.none<A>()));
|
|
132
159
|
const reader = readerOf(self);
|
|
133
160
|
if (!reader) return viaEffect();
|
|
134
161
|
return fromReader({
|
|
@@ -138,14 +165,14 @@ export const option = <A, E, R>(
|
|
|
138
165
|
return value instanceof Missing ? Option.none<A>() : Option.some(value);
|
|
139
166
|
},
|
|
140
167
|
viaEffect,
|
|
141
|
-
}) as Effect.Effect<Option.Option<A>,
|
|
168
|
+
}) as Effect.Effect<Option.Option<A>, Exclude<E, Missed>, R>;
|
|
142
169
|
};
|
|
143
170
|
|
|
144
171
|
/** Use `value` when missing. */
|
|
145
172
|
export const withDefault =
|
|
146
173
|
<B>(value: B) =>
|
|
147
|
-
<A, E, R>(self: Effect.Effect<A, E, R>): Effect.Effect<A | B,
|
|
148
|
-
const viaEffect = () =>
|
|
174
|
+
<A, E, R>(self: Effect.Effect<A, E, R>): Effect.Effect<A | B, Exclude<E, Missed>, R> => {
|
|
175
|
+
const viaEffect = () => catchMissed(self, () => Effect.succeed(value));
|
|
149
176
|
const reader = readerOf(self);
|
|
150
177
|
if (!reader) return viaEffect();
|
|
151
178
|
return fromReader<A | B>({
|
|
@@ -154,14 +181,16 @@ export const withDefault =
|
|
|
154
181
|
return v instanceof Missing ? value : v;
|
|
155
182
|
},
|
|
156
183
|
viaEffect,
|
|
157
|
-
}) as Effect.Effect<A | B,
|
|
184
|
+
}) as Effect.Effect<A | B, Exclude<E, Missed>, R>;
|
|
158
185
|
};
|
|
159
186
|
|
|
160
187
|
/** Try `that` when missing. */
|
|
161
188
|
export const orElse =
|
|
162
189
|
<A2, E2, R2>(that: () => Effect.Effect<A2, E2, R2>) =>
|
|
163
|
-
<A, E, R>(
|
|
164
|
-
|
|
190
|
+
<A, E, R>(
|
|
191
|
+
self: Effect.Effect<A, E, R>,
|
|
192
|
+
): Effect.Effect<A | A2, Exclude<E, Missed> | E2, R | R2> => {
|
|
193
|
+
const viaEffect = () => catchMissed(self, that);
|
|
165
194
|
const reader = readerOf(self);
|
|
166
195
|
if (!reader) return viaEffect();
|
|
167
196
|
return fromReader<A | A2>({
|
|
@@ -172,7 +201,7 @@ export const orElse =
|
|
|
172
201
|
return fallback ? fallback.read() : DEFER;
|
|
173
202
|
},
|
|
174
203
|
viaEffect,
|
|
175
|
-
}) as Effect.Effect<A | A2, E2, R | R2>;
|
|
204
|
+
}) as Effect.Effect<A | A2, Exclude<E, Missed> | E2, R | R2>;
|
|
176
205
|
};
|
|
177
206
|
|
|
178
207
|
export const map =
|
package/src/debug.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* Whether the call running on this fiber logs its requests and responses to
|
|
3
|
+
* stderr (`[distilled] -> GET /zones/{zone_id}`, `[distilled] <- 200 ...`):
|
|
4
|
+
* `TelemetryDebug.layerWith({ logRequests: true })` from
|
|
5
|
+
* `./telemetry-debug.ts`. Protocols check it on every request; outside a
|
|
6
|
+
* fiber, or without that layer, it is false.
|
|
4
7
|
*/
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
import * as Fiber from "effect/Fiber";
|
|
9
|
+
import { Debug } from "./telemetry.ts";
|
|
10
|
+
|
|
11
|
+
export const debugHttp = (): boolean => Fiber.getCurrent()?.getRef(Debug)?.logRequests === true;
|
package/src/error-category.ts
CHANGED
|
@@ -56,18 +56,16 @@ export const hasAnyCategory =
|
|
|
56
56
|
return false;
|
|
57
57
|
};
|
|
58
58
|
|
|
59
|
-
export const catchCategory =
|
|
60
|
-
<E,
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
]
|
|
65
|
-
) =>
|
|
66
|
-
|
|
59
|
+
export const catchCategory = <E, const Categories extends Array<AllKeys<E>>, A2, E2, R2>(
|
|
60
|
+
...args: [...Categories, f: (err: ExtractAll<E, Categories[number]>) => Effect.Effect<A2, E2, R2>]
|
|
61
|
+
) => {
|
|
62
|
+
// Split once, without mutating `args`, so one catcher can be reused.
|
|
63
|
+
const f = args[args.length - 1] as (
|
|
64
|
+
err: ExtractAll<E, Categories[number]>,
|
|
65
|
+
) => Effect.Effect<A2, E2, R2>;
|
|
66
|
+
const matches = hasAnyCategory(...(args.slice(0, -1) as Array<PropertyKey>));
|
|
67
|
+
return <A, R>(
|
|
67
68
|
effect: Effect.Effect<A, E, R>,
|
|
68
|
-
): Effect.Effect<A | A2, E2 | Exclude<E, ExtractAll<E, Categories[number]>>, R | R2> =>
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
const matches = hasAnyCategory(...categories);
|
|
72
|
-
return Effect.catchIf(effect, matches, (e) => f(e as ExtractAll<E, Categories[number]>)) as any;
|
|
73
|
-
};
|
|
69
|
+
): Effect.Effect<A | A2, E2 | Exclude<E, ExtractAll<E, Categories[number]>>, R | R2> =>
|
|
70
|
+
Effect.catchIf(effect, matches, (e) => f(e as ExtractAll<E, Categories[number]>)) as any;
|
|
71
|
+
};
|
package/src/errors.ts
CHANGED
|
@@ -139,13 +139,13 @@ export class GatewayTimeout
|
|
|
139
139
|
retryAfter: /*@__PURE__*/ Schema.optional(DurationSchema),
|
|
140
140
|
}).pipe(Category.withServerError, /*@__PURE__*/ Category.withRetryable()) {}
|
|
141
141
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
142
|
+
// Defined with the config readers (core's `base` bundle group, which every
|
|
143
|
+
// program loads) so they can fail with it without importing this module.
|
|
144
|
+
export { ConfigError } from "./config.ts";
|
|
145
|
+
|
|
146
|
+
// Defined with the label check (`protocol-http.ts`), so protocols can fail
|
|
147
|
+
// with it without importing every class in this module.
|
|
148
|
+
export { InvalidInput } from "./protocol-http.ts";
|
|
149
149
|
|
|
150
150
|
// ============================================================================
|
|
151
151
|
// Error Maps
|