@distilled.cloud/core 1.0.0-rc.2 → 1.0.0-rc.21
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/LICENSE +201 -0
- package/README.md +33 -0
- package/lib/_bundle/aws.js +2 -0
- package/lib/_bundle/aws.js.map +1 -0
- package/lib/_bundle/base.js +5 -0
- package/lib/_bundle/base.js.map +1 -0
- package/lib/_bundle/graphql.js +3 -0
- package/lib/_bundle/graphql.js.map +1 -0
- package/lib/_bundle/grpc.js +3 -0
- package/lib/_bundle/grpc.js.map +1 -0
- package/lib/_bundle/rest.js +2 -0
- package/lib/_bundle/rest.js.map +1 -0
- package/lib/_bundle/xml.js +4 -0
- package/lib/_bundle/xml.js.map +1 -0
- package/lib/annotations.d.ts +17 -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 +220 -51
- package/lib/api.d.ts.map +1 -1
- package/lib/api.js +1 -178
- package/lib/category.d.ts +19 -16
- package/lib/category.d.ts.map +1 -1
- package/lib/category.js +1 -280
- package/lib/chunks.d.ts +3 -0
- package/lib/chunks.d.ts.map +1 -0
- package/lib/chunks.js +1 -0
- package/lib/config.d.ts +81 -0
- package/lib/config.d.ts.map +1 -0
- package/lib/config.js +1 -0
- package/lib/crypto.d.ts +76 -0
- package/lib/crypto.d.ts.map +1 -0
- package/lib/crypto.js +1 -0
- package/lib/error-category.d.ts +1 -1
- package/lib/error-category.d.ts.map +1 -1
- package/lib/error-category.js +1 -46
- package/lib/errors.d.ts +99 -74
- package/lib/errors.d.ts.map +1 -1
- package/lib/errors.js +1 -186
- package/lib/graphql.d.ts +420 -0
- package/lib/graphql.d.ts.map +1 -0
- package/lib/graphql.js +1 -0
- package/lib/graphql.types.d.ts +11 -0
- package/lib/graphql.types.d.ts.map +1 -0
- package/lib/graphql.types.js +1 -0
- package/lib/grpc-transport-cloudflare-http2.d.ts +7 -0
- package/lib/grpc-transport-cloudflare-http2.d.ts.map +1 -0
- package/lib/grpc-transport-cloudflare-http2.js +6 -0
- package/lib/grpc-transport-cloudflare-http2.js.map +1 -0
- package/lib/grpc-transport-cloudflare-sockets.d.ts +7 -0
- package/lib/grpc-transport-cloudflare-sockets.d.ts.map +1 -0
- package/lib/grpc-transport-cloudflare-sockets.js +5 -0
- package/lib/grpc-transport-cloudflare-sockets.js.map +1 -0
- package/lib/grpc-transport-node-http2.d.ts +19 -0
- package/lib/grpc-transport-node-http2.d.ts.map +1 -0
- package/lib/grpc-transport-node-http2.js +2 -0
- package/lib/grpc-transport-node-http2.js.map +1 -0
- package/lib/grpc-transport.d.ts +111 -0
- package/lib/grpc-transport.d.ts.map +1 -0
- package/lib/grpc-transport.js +1 -0
- package/lib/hpack.d.ts +34 -0
- package/lib/hpack.d.ts.map +1 -0
- package/lib/hpack.js +2 -0
- package/lib/hpack.js.map +1 -0
- package/lib/index.d.ts +32 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +17 -0
- package/lib/max-message-bytes.d.ts +42 -0
- package/lib/max-message-bytes.d.ts.map +1 -0
- package/lib/max-message-bytes.js +2 -0
- package/lib/max-message-bytes.js.map +1 -0
- package/lib/ndjson.d.ts +3 -0
- package/lib/ndjson.d.ts.map +1 -0
- package/lib/ndjson.js +2 -0
- package/lib/ndjson.js.map +1 -0
- package/lib/pagination.d.ts +105 -25
- package/lib/pagination.d.ts.map +1 -1
- package/lib/pagination.js +1 -182
- package/lib/plain-values.d.ts +21 -0
- package/lib/plain-values.d.ts.map +1 -0
- package/lib/plain-values.js +2 -0
- package/lib/plain-values.js.map +1 -0
- package/lib/protobuf.d.ts +85 -0
- package/lib/protobuf.d.ts.map +1 -0
- package/lib/protobuf.js +1 -0
- package/lib/protocol-grpc.d.ts +123 -0
- package/lib/protocol-grpc.d.ts.map +1 -0
- package/lib/protocol-grpc.js +1 -0
- package/lib/protocol-http.d.ts +206 -25
- package/lib/protocol-http.d.ts.map +1 -1
- package/lib/protocol-http.js +1 -554
- package/lib/protocol-rest.d.ts +258 -64
- package/lib/protocol-rest.d.ts.map +1 -1
- package/lib/protocol-rest.js +1 -242
- package/lib/protocol.d.ts +113 -0
- package/lib/protocol.d.ts.map +1 -0
- package/lib/protocol.js +0 -0
- package/lib/query.d.ts +29 -0
- package/lib/query.d.ts.map +1 -0
- package/lib/query.js +1 -0
- package/lib/response-validation-strict.d.ts +48 -0
- package/lib/response-validation-strict.d.ts.map +1 -0
- package/lib/response-validation-strict.js +1 -0
- package/lib/response-validation.d.ts +86 -0
- package/lib/response-validation.d.ts.map +1 -0
- package/lib/response-validation.js +1 -0
- package/lib/retry-after.d.ts +4 -4
- package/lib/retry-after.d.ts.map +1 -1
- package/lib/retry-after.js +1 -112
- package/lib/retry-state.d.ts +26 -0
- package/lib/retry-state.d.ts.map +1 -0
- package/lib/retry-state.js +2 -0
- package/lib/retry-state.js.map +1 -0
- package/lib/retry.d.ts +141 -42
- package/lib/retry.d.ts.map +1 -1
- package/lib/retry.js +1 -210
- package/lib/schema-lite-impl.d.ts +179 -0
- package/lib/schema-lite-impl.d.ts.map +1 -0
- package/lib/schema-lite-impl.js +1 -0
- package/lib/schema-lite-typed.d.ts +41 -0
- package/lib/schema-lite-typed.d.ts.map +1 -0
- package/lib/schema-lite-typed.js +1 -0
- package/lib/schema-lite.d.ts +41 -0
- package/lib/schema-lite.d.ts.map +1 -0
- package/lib/schema-lite.js +1 -0
- package/lib/schema.d.ts +21 -7
- package/lib/schema.d.ts.map +1 -1
- package/lib/schema.js +1 -48
- package/lib/sdk-error.d.ts +31 -0
- package/lib/sdk-error.d.ts.map +1 -0
- package/lib/sdk-error.js +1 -0
- package/lib/send.d.ts +37 -0
- package/lib/send.d.ts.map +1 -0
- package/lib/send.js +2 -0
- package/lib/send.js.map +1 -0
- package/lib/sensitive.d.ts +28 -0
- package/lib/sensitive.d.ts.map +1 -0
- package/lib/sensitive.js +2 -0
- package/lib/sensitive.js.map +1 -0
- package/lib/telemetry-debug.d.ts +6 -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 +11 -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 +317 -0
- package/lib/telemetry.d.ts.map +1 -0
- package/lib/telemetry.js +3 -0
- package/lib/telemetry.js.map +1 -0
- package/lib/token-cache.d.ts +31 -0
- package/lib/token-cache.d.ts.map +1 -0
- package/lib/token-cache.js +2 -0
- package/lib/token-cache.js.map +1 -0
- package/lib/trait.d.ts +94 -20
- package/lib/trait.d.ts.map +1 -1
- package/lib/trait.js +1 -107
- package/lib/unknown-error.d.ts +18 -0
- package/lib/unknown-error.d.ts.map +1 -0
- package/lib/unknown-error.js +1 -0
- package/lib/xml.d.ts +44 -0
- package/lib/xml.d.ts.map +1 -0
- package/lib/xml.js +1 -0
- package/package.json +13 -13
- package/src/annotations.ts +53 -0
- package/src/api.ts +1597 -234
- package/src/category.ts +97 -134
- package/src/chunks.ts +30 -0
- package/src/config.ts +261 -0
- package/src/crypto.ts +202 -0
- package/src/error-category.ts +16 -29
- package/src/errors.ts +99 -77
- package/src/graphql.ts +1817 -0
- package/src/graphql.types.ts +120 -0
- package/src/grpc-transport-cloudflare-http2.ts +569 -0
- package/src/grpc-transport-cloudflare-sockets.ts +368 -0
- package/src/grpc-transport-node-http2.ts +307 -0
- package/src/grpc-transport.ts +287 -0
- package/src/hpack.ts +331 -0
- package/src/index.ts +31 -0
- package/src/max-message-bytes.ts +58 -0
- package/src/ndjson.ts +55 -0
- package/src/pagination.ts +379 -94
- package/src/plain-values.ts +70 -0
- package/src/protobuf.ts +1367 -0
- package/src/protocol-grpc.ts +811 -0
- package/src/protocol-http.ts +1045 -371
- package/src/protocol-rest.ts +908 -255
- package/src/protocol.ts +150 -0
- package/src/query.ts +39 -0
- package/src/response-validation-strict.ts +333 -0
- package/src/response-validation.ts +161 -0
- package/src/retry-after.ts +8 -14
- package/src/retry-state.ts +105 -0
- package/src/retry.ts +260 -145
- package/src/schema-lite-impl.ts +621 -0
- package/src/schema-lite-typed.ts +44 -0
- package/src/schema-lite.ts +45 -0
- package/src/schema.ts +259 -15
- package/src/sdk-error.ts +37 -0
- package/src/send.ts +156 -0
- package/src/sensitive.ts +188 -0
- package/src/telemetry-debug.ts +179 -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 +100 -0
- package/src/telemetry-xray.ts +66 -0
- package/src/telemetry.ts +800 -0
- package/src/token-cache.ts +117 -0
- package/src/trait.ts +139 -67
- package/src/unknown-error.ts +38 -0
- package/src/xml.ts +346 -0
- package/lib/api.js.map +0 -1
- package/lib/category.js.map +0 -1
- package/lib/codegen/cli.d.ts +0 -29
- package/lib/codegen/cli.d.ts.map +0 -1
- package/lib/codegen/cli.js +0 -165
- package/lib/codegen/cli.js.map +0 -1
- package/lib/codegen/emit.d.ts +0 -129
- package/lib/codegen/emit.d.ts.map +0 -1
- package/lib/codegen/emit.js +0 -105
- package/lib/codegen/emit.js.map +0 -1
- package/lib/codegen/format.d.ts +0 -23
- package/lib/codegen/format.d.ts.map +0 -1
- package/lib/codegen/format.js +0 -28
- package/lib/codegen/format.js.map +0 -1
- package/lib/codegen/generator.d.ts +0 -334
- package/lib/codegen/generator.d.ts.map +0 -1
- package/lib/codegen/generator.js +0 -691
- 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/members.d.ts +0 -25
- package/lib/codegen/members.d.ts.map +0 -1
- package/lib/codegen/members.js +0 -55
- package/lib/codegen/members.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 -38
- package/lib/codegen/openapi-cli.d.ts.map +0 -1
- package/lib/codegen/openapi-cli.js +0 -107
- package/lib/codegen/openapi-cli.js.map +0 -1
- package/lib/codegen/openapi.d.ts +0 -115
- package/lib/codegen/openapi.d.ts.map +0 -1
- package/lib/codegen/openapi.js +0 -1220
- 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 -33
- package/lib/codegen/pagination.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/error-category.js.map +0 -1
- package/lib/errors.js.map +0 -1
- package/lib/json-patch.d.ts +0 -44
- package/lib/json-patch.d.ts.map +0 -1
- package/lib/json-patch.js +0 -174
- package/lib/json-patch.js.map +0 -1
- package/lib/pagination.js.map +0 -1
- package/lib/protocol-http.js.map +0 -1
- package/lib/protocol-rest.js.map +0 -1
- package/lib/retry-after.js.map +0 -1
- package/lib/retry.js.map +0 -1
- package/lib/schema.js.map +0 -1
- package/lib/trait.js.map +0 -1
- package/src/codegen/cli.ts +0 -268
- package/src/codegen/emit.ts +0 -207
- package/src/codegen/format.ts +0 -47
- package/src/codegen/generator.ts +0 -1153
- package/src/codegen/graph.ts +0 -151
- package/src/codegen/members.ts +0 -71
- package/src/codegen/naming.ts +0 -86
- package/src/codegen/openapi-cli.ts +0 -166
- package/src/codegen/openapi.ts +0 -1450
- package/src/codegen/operations.ts +0 -76
- package/src/codegen/pagination.ts +0 -71
- package/src/codegen/prelude.ts +0 -70
- package/src/json-patch.ts +0 -222
package/lib/api.d.ts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import * as Context from "effect/Context";
|
|
2
2
|
import * as Effect from "effect/Effect";
|
|
3
|
-
import * as
|
|
3
|
+
import * as HttpClient from "effect/http/HttpClient";
|
|
4
|
+
import type * as HttpClientError from "effect/http/HttpClientError";
|
|
5
|
+
import type * as HttpClientRequest from "effect/http/HttpClientRequest";
|
|
4
6
|
import * as S from "effect/Schema";
|
|
5
7
|
import type * as AST from "effect/SchemaAST";
|
|
6
|
-
import
|
|
8
|
+
import * as Stream from "effect/Stream";
|
|
7
9
|
import * as Pagination from "./pagination.ts";
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import type * as HttpClientResponse from "effect/unstable/http/HttpClientResponse";
|
|
10
|
+
import type { Protocol } from "./protocol.ts";
|
|
11
|
+
import { type Policy as RetryPolicy, type RetryOverride } from "./retry.ts";
|
|
12
|
+
import { SdkError } from "./sdk-error.ts";
|
|
13
|
+
import * as Telemetry from "./telemetry.ts";
|
|
13
14
|
/**
|
|
14
15
|
* The view of an operation's config that protocols receive on every
|
|
15
16
|
* encode/decode call. The object is the same memoized config instance for
|
|
@@ -34,36 +35,39 @@ export interface ProtocolOperationConfig {
|
|
|
34
35
|
*/
|
|
35
36
|
readonly endpointHostPrefix?: string;
|
|
36
37
|
readonly pagination?: Pagination.PaginatedTrait;
|
|
38
|
+
/**
|
|
39
|
+
* How a server-streaming operation's body is framed, for protocols that
|
|
40
|
+
* read it per operation (core/protocol-rest takes a `StreamFraming`, e.g.
|
|
41
|
+
* `ndjson` from core/ndjson). Set only on the operations that stream, so
|
|
42
|
+
* programs that call none never bundle the framing.
|
|
43
|
+
*/
|
|
44
|
+
readonly framing?: unknown;
|
|
45
|
+
/**
|
|
46
|
+
* One frame of `.stream()`, for an operation whose plain call has its own
|
|
47
|
+
* output and streams only when its input asks (see
|
|
48
|
+
* {@link OperationConfig.streamInput}). Protocols decode each frame
|
|
49
|
+
* against it instead of an element of the output's `items`.
|
|
50
|
+
*/
|
|
51
|
+
readonly items?: S.Top;
|
|
37
52
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
readonly inputAst: AST.AST;
|
|
42
|
-
/** The operation's config (memoized per operation — see {@link ProtocolOperationConfig}). */
|
|
43
|
-
readonly config: ProtocolOperationConfig;
|
|
44
|
-
}) => Effect.Effect<HttpClientRequest.HttpClientRequest>;
|
|
45
|
-
readonly decode: (args: {
|
|
46
|
-
readonly response: HttpClientResponse.HttpClientResponse;
|
|
47
|
-
readonly outputAst: AST.AST;
|
|
48
|
-
/**
|
|
49
|
-
* The operation's declared error classes (from `OperationConfig.errors`).
|
|
50
|
-
* Protocols use these to surface wire failures as the operation's typed
|
|
51
|
-
* errors — e.g. by consulting matcher metadata stamped on the class.
|
|
52
|
-
*/
|
|
53
|
-
readonly errors: ReadonlyArray<ApiErrorClass>;
|
|
54
|
-
/** The operation's config (memoized per operation — see {@link ProtocolOperationConfig}). */
|
|
55
|
-
readonly config: ProtocolOperationConfig;
|
|
56
|
-
}) => Effect.Effect<unknown>;
|
|
57
|
-
}>;
|
|
58
|
-
/**
|
|
59
|
-
* The Protocol service knows how to turn a value into an HTTP request using
|
|
60
|
-
* only the input schema's trait annotations, and how to turn a response back
|
|
61
|
-
* into an output value using the output schema's trait annotations.
|
|
62
|
-
*
|
|
63
|
-
* Swap implementations by providing a different `Layer<Protocol>`.
|
|
53
|
+
/**
|
|
54
|
+
* One operation as a protocol's {@link Protocol.call} sees it. Built once per
|
|
55
|
+
* operation on its first call; the same object is passed on every call.
|
|
64
56
|
*/
|
|
65
|
-
export
|
|
57
|
+
export interface PreparedOperation {
|
|
58
|
+
readonly config: ProtocolOperationConfig;
|
|
59
|
+
readonly inputAst: AST.AST;
|
|
60
|
+
readonly outputAst: AST.AST;
|
|
61
|
+
readonly errors: ReadonlyArray<ApiErrorClass>;
|
|
62
|
+
/** Per-operation slot owned by the operation's protocol (compiled codecs). */
|
|
63
|
+
compiled?: unknown;
|
|
66
64
|
}
|
|
65
|
+
/**
|
|
66
|
+
* Run `f` on the value of `effect` -- directly when `effect` is already a
|
|
67
|
+
* successful `Exit` (e.g. a `Credentials` service holding
|
|
68
|
+
* `Effect.succeed(config)`), so a resolved value costs no fiber step.
|
|
69
|
+
*/
|
|
70
|
+
export declare const withValue: <A, E, R, B, E2, R2>(effect: Effect.Effect<A, E, R>, f: (a: A) => Effect.Effect<B, E2, R2>) => Effect.Effect<B, E | E2, R | R2>;
|
|
67
71
|
export type ApiErrorClass = {
|
|
68
72
|
new (...args: any[]): {
|
|
69
73
|
readonly _tag: string;
|
|
@@ -71,35 +75,58 @@ export type ApiErrorClass = {
|
|
|
71
75
|
};
|
|
72
76
|
};
|
|
73
77
|
/**
|
|
74
|
-
* The shape of a generated SDK operation
|
|
78
|
+
* The shape of a generated SDK operation -- usable two ways (mirrors the
|
|
75
79
|
* distilled repo's OperationMethod):
|
|
76
80
|
*
|
|
77
|
-
* 1. Direct call: `yield* operation(input)`
|
|
78
|
-
* 2. Yield first: `const fn = yield* operation`
|
|
81
|
+
* 1. Direct call: `yield* operation(input)` -- an Effect with requirements.
|
|
82
|
+
* 2. Yield first: `const fn = yield* operation` -- captures the current
|
|
79
83
|
* context and returns a requirement-free call function.
|
|
80
84
|
*
|
|
81
85
|
* Generated service files annotate every exported operation with this type
|
|
82
86
|
* explicitly (against their hand-emitted interfaces), so the compiler never
|
|
83
87
|
* has to infer it back out of the schema generics.
|
|
84
88
|
*/
|
|
85
|
-
export type OperationMethod<I, O, E, R> = Effect.Effect<(input: I) => Effect.Effect<O, E, never>, never, R> & ((input: I) => Effect.Effect<O, E, R>)
|
|
86
|
-
|
|
89
|
+
export type OperationMethod<I, O, E, R> = Effect.Effect<(input: I) => Effect.Effect<O, E, never>, never, R> & ((input: I) => Effect.Effect<O, E, R>) & OperationSchemas<I, O>;
|
|
90
|
+
/**
|
|
91
|
+
* An operation's request and response schemas, built on first access.
|
|
92
|
+
* Generated modules export operations, errors and types; the schemas
|
|
93
|
+
* themselves are module-private, so this is how to reach them as values.
|
|
94
|
+
*/
|
|
95
|
+
export interface OperationSchemas<I, O> {
|
|
96
|
+
readonly input: S.Codec<I, any>;
|
|
97
|
+
readonly output: S.Codec<O, any>;
|
|
98
|
+
}
|
|
99
|
+
export interface OperationConfig<I extends S.Top, O extends S.Top, PE, PR, E extends readonly ApiErrorClass[] = readonly ApiErrorClass[], SE extends readonly ApiErrorClass[] = readonly ApiErrorClass[]> {
|
|
87
100
|
input?: I;
|
|
88
101
|
output?: O;
|
|
102
|
+
/** The errors declared on the operation: only this operation returns them. */
|
|
89
103
|
errors?: E;
|
|
90
104
|
/**
|
|
91
|
-
* The
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
|
|
105
|
+
* The errors declared on the operation's service: the same list on every
|
|
106
|
+
* operation of the service. The protocol matches a failed response
|
|
107
|
+
* against the operation's classes, then these.
|
|
108
|
+
*/
|
|
109
|
+
serviceErrors?: SE;
|
|
110
|
+
/**
|
|
111
|
+
* What encodes and decodes this operation's wire format: a protocol
|
|
112
|
+
* (core/protocol), an object whose type states the errors the protocol
|
|
113
|
+
* declares (`PE`) and what its methods read (`PR`), so the operation's
|
|
114
|
+
* type gets them from the protocol. It resolves call-dependent services
|
|
115
|
+
* (credentials etc.) inside encode/decode, on the calling fiber.
|
|
95
116
|
*/
|
|
96
|
-
protocol:
|
|
117
|
+
protocol: Protocol<PE, PR>;
|
|
97
118
|
/**
|
|
98
119
|
* SDK-specific retry service tag (see `core/retry`). When provided and the
|
|
99
120
|
* caller's context carries a policy under this tag, every call is retried
|
|
100
121
|
* per that policy (e.g. `Layer.succeed(Cloudflare.Retry.Retry, factory)`).
|
|
101
122
|
*/
|
|
102
123
|
retry?: Context.Key<any, RetryPolicy>;
|
|
124
|
+
/**
|
|
125
|
+
* The operation's `distilled.retry#policy` trait (the service's, with the
|
|
126
|
+
* operation's on top): numbers that replace the default policy's when the
|
|
127
|
+
* caller's context carries no policy. A caller's policy ignores it.
|
|
128
|
+
*/
|
|
129
|
+
retryPolicy?: RetryOverride;
|
|
103
130
|
/**
|
|
104
131
|
* The wire operation name for RPC-style protocols (see
|
|
105
132
|
* {@link ProtocolOperationConfig.operationName}).
|
|
@@ -110,14 +137,54 @@ export interface OperationConfig<I extends S.Top, O extends S.Top, PE, PR, E ext
|
|
|
110
137
|
* {@link ProtocolOperationConfig.endpointHostPrefix}).
|
|
111
138
|
*/
|
|
112
139
|
endpointHostPrefix?: string;
|
|
140
|
+
/** The service's `com.distilled.telemetry#service` trait (a module const). */
|
|
141
|
+
telemetry?: Telemetry.ServiceTelemetry;
|
|
142
|
+
/**
|
|
143
|
+
* The operation's `com.distilled.telemetry#operation` trait, with its
|
|
144
|
+
* input rules; only what differs from the service's rules when it names
|
|
145
|
+
* its `op` (a string is just the op).
|
|
146
|
+
*/
|
|
147
|
+
span?: Telemetry.SpanConfig | string;
|
|
148
|
+
/** The body framing of a server-streaming operation (see {@link ProtocolOperationConfig.framing}). */
|
|
149
|
+
framing?: unknown;
|
|
150
|
+
/** One frame of `.stream()` (see {@link ProtocolOperationConfig.items}). */
|
|
151
|
+
items?: S.Top;
|
|
152
|
+
/**
|
|
153
|
+
* Input members `.stream()` sets over the caller's, for an operation that
|
|
154
|
+
* streams only when its input asks (Boat's `executeSandboxCommand` with
|
|
155
|
+
* `stream: true`). The plain call sends the caller's input as given.
|
|
156
|
+
*/
|
|
157
|
+
streamInput?: Readonly<Record<string, unknown>>;
|
|
113
158
|
}
|
|
114
|
-
|
|
159
|
+
/**
|
|
160
|
+
* The span facts an operation's calls carry (name, kind, fixed attributes,
|
|
161
|
+
* input rules), as the runtime builds them from its generated config. For
|
|
162
|
+
* tests and tooling.
|
|
163
|
+
*/
|
|
164
|
+
export declare const describeOperation: (op: unknown) => Telemetry.OperationInfo;
|
|
165
|
+
/**
|
|
166
|
+
* The HTTP request a call to `op` with `input` would send, built by the
|
|
167
|
+
* operation's protocol (`Protocol.encode`) and not sent: no retry, no span,
|
|
168
|
+
* no response. It fails as the call would before sending (bad input,
|
|
169
|
+
* credentials, endpoint), or with {@link SdkError} when the operation can't
|
|
170
|
+
* be loaded; the operation's type does not tell those failures from a
|
|
171
|
+
* response's, so the error is `unknown`. Presigning builds on it.
|
|
172
|
+
*/
|
|
173
|
+
export declare const encodeRequest: <I, O, E, R>(op: OperationMethod<I, O, E, R>, input: I) => Effect.Effect<HttpClientRequest.HttpClientRequest, unknown, R>;
|
|
174
|
+
/**
|
|
175
|
+
* What an operation `make` builds can fail with: its own errors, its
|
|
176
|
+
* service's, its protocol's, the HTTP client's, and {@link SdkError}, which
|
|
177
|
+
* `make` itself fails with when the operation's config can't be loaded or
|
|
178
|
+
* its protocol can't stream.
|
|
179
|
+
*/
|
|
180
|
+
export type MadeError<E extends readonly ApiErrorClass[], SE extends readonly ApiErrorClass[], PE> = InstanceType<E[number]> | InstanceType<SE[number]> | PE | HttpClientError.HttpClientError | SdkError;
|
|
181
|
+
export declare function make<I extends S.Top, O extends S.Top, PE, PR, const E extends readonly ApiErrorClass[] = readonly [], const SE extends readonly ApiErrorClass[] = readonly []>(configFn: () => OperationConfig<I, O, PE, PR, E, SE>): OperationMethod<S.Schema.Type<I>, S.Schema.Type<O>, MadeError<E, SE, PE>, PR | HttpClient.HttpClient>;
|
|
115
182
|
/**
|
|
116
183
|
* STRUCTURAL fallback for the element type `.items()` yields: the array
|
|
117
184
|
* element of the page response itself, or of its `result` member.
|
|
118
185
|
*
|
|
119
186
|
* It can only see shapes it was taught, so any other envelope
|
|
120
|
-
* (`{ branches: [
|
|
187
|
+
* (`{ branches: [...] }`, `{ data: [...] }`, ...) lands on `unknown` -- which is
|
|
121
188
|
* why generators pass the item type EXPLICITLY as
|
|
122
189
|
* {@link PaginatedOperationMethod}'s `Item` argument, resolved from the
|
|
123
190
|
* pagination trait's `items` path against the response shape. This default
|
|
@@ -133,7 +200,7 @@ export type PaginatedItem<A> = A extends ReadonlyArray<infer Item> ? Item : A ex
|
|
|
133
200
|
* `.pages(input)` streaming every page response and `.items(input)` streaming
|
|
134
201
|
* the individual items across pages.
|
|
135
202
|
*
|
|
136
|
-
* Used twice in {@link PaginatedOperationMethod}
|
|
203
|
+
* Used twice in {@link PaginatedOperationMethod} -- once with the operation's
|
|
137
204
|
* requirements (`R`) for the direct-call style, once with `R = never` for the
|
|
138
205
|
* value `yield* operation` hands back, which has the caller's context baked in.
|
|
139
206
|
*/
|
|
@@ -144,12 +211,12 @@ export interface PaginatedCall<I, O, E, R, Item> {
|
|
|
144
211
|
}
|
|
145
212
|
/**
|
|
146
213
|
* A paginated operation: usable both ways an {@link OperationMethod} is, with
|
|
147
|
-
* `.pages` / `.items` on BOTH
|
|
214
|
+
* `.pages` / `.items` on BOTH -- the operation object for
|
|
148
215
|
* `yield* op.items(input)`, and the requirement-free call function for
|
|
149
216
|
* `const op = yield* operation; yield* op.items(input)` (distilled #145).
|
|
150
217
|
*/
|
|
151
|
-
export type PaginatedOperationMethod<I, O, E, R, Item = PaginatedItem<O>> = Effect.Effect<PaginatedCall<I, O, E, never, Item>, never, R> & PaginatedCall<I, O, E, R, Item>;
|
|
152
|
-
export interface PaginatedOperationConfig<I extends S.Top, O extends S.Top, PE, PR, E extends readonly ApiErrorClass[] = readonly ApiErrorClass[]> extends OperationConfig<I, O, PE, PR, E> {
|
|
218
|
+
export type PaginatedOperationMethod<I, O, E, R, Item = PaginatedItem<O>> = Effect.Effect<PaginatedCall<I, O, E, never, Item>, never, R> & PaginatedCall<I, O, E, R, Item> & OperationSchemas<I, O>;
|
|
219
|
+
export interface PaginatedOperationConfig<I extends S.Top, O extends S.Top, PE, PR, E extends readonly ApiErrorClass[] = readonly ApiErrorClass[], SE extends readonly ApiErrorClass[] = readonly ApiErrorClass[]> extends OperationConfig<I, O, PE, PR, E, SE> {
|
|
153
220
|
/** How to advance between pages (mirrors the `smithy.api#paginated` trait). */
|
|
154
221
|
pagination: Pagination.PaginatedTrait;
|
|
155
222
|
}
|
|
@@ -160,6 +227,108 @@ export interface PaginatedOperationConfig<I extends S.Top, O extends S.Top, PE,
|
|
|
160
227
|
* traversal on the first empty page); the default dispatches on
|
|
161
228
|
* `pagination.mode`.
|
|
162
229
|
*/
|
|
163
|
-
export declare function makePaginated<I extends S.Top, O extends S.Top, PE, PR, const E extends readonly ApiErrorClass[] = readonly []>(configFn: () => PaginatedOperationConfig<I, O, PE, PR, E>, strategy?: Pagination.PaginationStrategy): PaginatedOperationMethod<S.Schema.Type<I>, S.Schema.Type<O>,
|
|
230
|
+
export declare function makePaginated<I extends S.Top, O extends S.Top, PE, PR, const E extends readonly ApiErrorClass[] = readonly [], const SE extends readonly ApiErrorClass[] = readonly []>(configFn: () => PaginatedOperationConfig<I, O, PE, PR, E, SE>, strategy?: Pagination.PaginationStrategy): PaginatedOperationMethod<S.Schema.Type<I>, S.Schema.Type<O>, MadeError<E, SE, PE>, PR | HttpClient.HttpClient>;
|
|
231
|
+
/** The message type of a server-streaming output, `{ items: Message[] }`. */
|
|
232
|
+
export type StreamedItem<O> = O extends {
|
|
233
|
+
readonly items: ReadonlyArray<infer Item>;
|
|
234
|
+
} ? Item : O extends {
|
|
235
|
+
readonly items?: ReadonlyArray<infer Item> | undefined;
|
|
236
|
+
} ? Item : unknown;
|
|
237
|
+
/**
|
|
238
|
+
* The callable half of a server-streaming operation: the call, which
|
|
239
|
+
* collects the whole stream into `{ items }`, plus `.stream(input)`, which
|
|
240
|
+
* emits each message as it arrives.
|
|
241
|
+
*/
|
|
242
|
+
export interface StreamingCall<I, O, E, R, Item> {
|
|
243
|
+
(input: I): Effect.Effect<O, E, R>;
|
|
244
|
+
readonly stream: (input: I) => Stream.Stream<Item, E, R>;
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* A server-streaming operation: usable both ways an {@link OperationMethod}
|
|
248
|
+
* is, with `.stream` on both the operation and the requirement-free call
|
|
249
|
+
* function `yield* operation` returns.
|
|
250
|
+
*/
|
|
251
|
+
export type StreamingOperationMethod<I, O, E, R, Item = StreamedItem<O>> = Effect.Effect<StreamingCall<I, O, E, never, Item>, never, R> & StreamingCall<I, O, E, R, Item> & OperationSchemas<I, O>;
|
|
252
|
+
/** The `.stream()` of an operation its protocol can't stream: fails with {@link SdkError}. */
|
|
253
|
+
export declare const cannotStream: (operation: Pick<PreparedOperation, "config">) => Stream.Stream<never, SdkError>;
|
|
254
|
+
/**
|
|
255
|
+
* Like {@link make}, for a server-streaming RPC whose output is `{ items }`:
|
|
256
|
+
* calling it collects the stream, and `.stream(input)` emits each message as
|
|
257
|
+
* the protocol receives it (see {@link Protocol.stream}).
|
|
258
|
+
*
|
|
259
|
+
* An operation that streams only when its input asks keeps its own output:
|
|
260
|
+
* its config sets `items` (one frame) and `streamInput` (what `.stream()`
|
|
261
|
+
* sends), and the plain call is a normal call.
|
|
262
|
+
*/
|
|
263
|
+
export declare function makeStreaming<I extends S.Top, O extends S.Top, PE, PR, const E extends readonly ApiErrorClass[] = readonly [], const SE extends readonly ApiErrorClass[] = readonly []>(configFn: () => OperationConfig<I, O, PE, PR, E, SE>): StreamingOperationMethod<S.Schema.Type<I>, S.Schema.Type<O>, MadeError<E, SE, PE>, PR | HttpClient.HttpClient>;
|
|
264
|
+
/**
|
|
265
|
+
* Generated operations described by data instead of code.
|
|
266
|
+
*
|
|
267
|
+
* A service module holds each operation as one arrow that is both the
|
|
268
|
+
* callable operation and the holder of its description:
|
|
269
|
+
*
|
|
270
|
+
* export const getFile = API.op((i) => i === API.D ? ['{input:#1,...};__more', [__0, __4, ...]] : API.call(getFile, i));
|
|
271
|
+
*
|
|
272
|
+
* Called with {@link D}, it returns `[data, refs]`: `;`-separated entries
|
|
273
|
+
* in a small expression language (below) and the values they name. `refs[0]`
|
|
274
|
+
* is the schema-lite `at` (lazy schema wrapper). Schemas reached by more
|
|
275
|
+
* than one operation live in shared holders, `function __d3() { return
|
|
276
|
+
* [data, refs]; }`, named in `refs` so a bundler keeps only the holders an
|
|
277
|
+
* operation reaches. Entry 0 of an operation is its config; the rest are
|
|
278
|
+
* schemas and thunk bodies. Evaluating an entry calls the same
|
|
279
|
+
* constructors the code form called, in the same order, so the result is
|
|
280
|
+
* the same schema.
|
|
281
|
+
*
|
|
282
|
+
* Importing a module allocates one function per operation and one per
|
|
283
|
+
* holder; the data stays text in the module source until first use. A
|
|
284
|
+
* holder's refs may also be values built from module code on first use
|
|
285
|
+
* (service traits, endpoint rules), which its value entries name.
|
|
286
|
+
*
|
|
287
|
+
* Grammar (`;` never appears outside an entry separator; strings escape it):
|
|
288
|
+
*
|
|
289
|
+
* $N refs[N]
|
|
290
|
+
* #N #R:N schema entry N of this holder / of the holder refs[R] (lazy, memoized)
|
|
291
|
+
* ~N ~R:N value entry N of this holder / of refs[R] (a constant, evaluated once)
|
|
292
|
+
* >N thunk `() => entry N`
|
|
293
|
+
* "..." -1.5 true false null JSON literal u undefined
|
|
294
|
+
* {k:e,"k":e} object [e,e] array
|
|
295
|
+
* e(a,b) call e.name member e.name(a,b) method call e@"X" e.annotate({ identifier: "X" })
|
|
296
|
+
*/
|
|
297
|
+
export declare const D: unique symbol;
|
|
298
|
+
type DataFn = (i?: unknown) => any;
|
|
299
|
+
/** A schema of a holder, for module-level code (error classes) that names one at import. */
|
|
300
|
+
export declare const schema: (fn: DataFn, j: number) => any;
|
|
301
|
+
/**
|
|
302
|
+
* The data of an operation whose name recurs in its strings: `%` in them
|
|
303
|
+
* stands for `stem` (a literal `%` is escaped).
|
|
304
|
+
*/
|
|
305
|
+
export declare const named: (stem: string, data: string, refs: unknown) => [string, unknown];
|
|
306
|
+
/** An operation described by data (see the region header). */
|
|
307
|
+
export declare const op: (fn: DataFn) => any;
|
|
308
|
+
/** A paginated operation described by data; its config may name a `strategy`. */
|
|
309
|
+
export declare const opPaginated: (fn: DataFn) => any;
|
|
310
|
+
/** A server-streaming operation described by data. */
|
|
311
|
+
export declare const opStreaming: (fn: DataFn) => any;
|
|
312
|
+
/** The call path of a data operation. */
|
|
313
|
+
export declare const call: (op: unknown, input: unknown) => Effect.Effect<any, any, any>;
|
|
314
|
+
/** An error class described by data (see {@link errorBase}). */
|
|
315
|
+
export declare const error: (fn: DataFn) => any;
|
|
316
|
+
/**
|
|
317
|
+
* The body of a data error class: with `new`, an instance of the built
|
|
318
|
+
* base whose prototype is `newTarget`'s; called plainly, the class's data.
|
|
319
|
+
*/
|
|
320
|
+
export declare const newError: (props: unknown, newTarget: Function | undefined, data: unknown) => any;
|
|
321
|
+
/**
|
|
322
|
+
* The placeholders of a lazy service module (see the region header): `o()`
|
|
323
|
+
* and `e()` make the next operation / error class. A placeholder finds its
|
|
324
|
+
* data by its index; it closes over nothing of its own, so it costs one
|
|
325
|
+
* function.
|
|
326
|
+
*/
|
|
327
|
+
export declare const lazyService: (url: string, spec: string, kinds: string, ns?: readonly any[], at?: number, len?: number) => {
|
|
328
|
+
readonly o: () => any;
|
|
329
|
+
readonly e: (name: string) => any;
|
|
330
|
+
readonly E: any;
|
|
331
|
+
};
|
|
332
|
+
export declare const lazyNamespace: (url: string, spec: string) => any;
|
|
164
333
|
export {};
|
|
165
334
|
//# sourceMappingURL=api.d.ts.map
|
package/lib/api.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","
|
|
1
|
+
{"version":3,"file":"api.d.ts","sources":["../src/api.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAE1C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,KAAK,UAAU,MAAM,wBAAwB,CAAC;AACrD,OAAO,KAAK,KAAK,eAAe,MAAM,6BAA6B,CAAC;AACpE,OAAO,KAAK,KAAK,iBAAiB,MAAM,+BAA+B,CAAC;AAKxE,OAAO,KAAK,CAAC,MAAM,eAAe,CAAC;AACnC,OAAO,KAAK,KAAK,GAAG,MAAM,kBAAkB,CAAC;AAC7C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAIxC,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAC;AAC9C,OAAO,KAAK,EAAa,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzD,OAAO,EAKL,KAAK,MAAM,IAAI,WAAW,EAC1B,KAAK,aAAa,EAGnB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C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
|
|
3
|
-
import * as Layer from "effect/Layer";
|
|
4
|
-
import * as Option from "effect/Option";
|
|
5
|
-
import * as S from "effect/Schema";
|
|
6
|
-
import { pipeArguments } from "effect/Pipeable";
|
|
7
|
-
import * as Ref from "effect/Ref";
|
|
8
|
-
import * as Scope from "effect/Scope";
|
|
9
|
-
import { SingleShotGen } from "effect/Utils";
|
|
10
|
-
import * as Pagination from "./pagination.js";
|
|
11
|
-
import { makeDefault } from "./retry.js";
|
|
12
|
-
import * as HttpClient from "effect/unstable/http/HttpClient";
|
|
13
|
-
/**
|
|
14
|
-
* The Protocol service knows how to turn a value into an HTTP request using
|
|
15
|
-
* only the input schema's trait annotations, and how to turn a response back
|
|
16
|
-
* into an output value using the output schema's trait annotations.
|
|
17
|
-
*
|
|
18
|
-
* Swap implementations by providing a different `Layer<Protocol>`.
|
|
19
|
-
*/
|
|
20
|
-
export class Protocol extends Context.Service()("Protocol") {
|
|
21
|
-
}
|
|
22
|
-
// NOTE: request/response ASTs are handed to the protocol RAW (Suspend nodes
|
|
23
|
-
// included). Pre-resolving Suspends here would drop annotations that sit on
|
|
24
|
-
// intermediate nodes — e.g. a bare-payload response whose payload type is
|
|
25
|
-
// itself a suspended schema carries its EnvelopePayloadRoot marker on the
|
|
26
|
-
// inner Suspend, and unwrapping it silently degrades decode to the struct
|
|
27
|
-
// path. The protocol helpers (core/protocol-http getAnn/getProps) descend
|
|
28
|
-
// Suspends themselves, and `Suspend.thunk` memoizes, so raw ASTs cost
|
|
29
|
-
// nothing extra.
|
|
30
|
-
/**
|
|
31
|
-
* Protocol layers are built once per process and shared by every operation
|
|
32
|
-
* call (keyed by layer value identity — generated operations all reference the
|
|
33
|
-
* same module-level layer const). The build runs against a process-lifetime
|
|
34
|
-
* scope, and concurrent first calls are deduplicated through a private
|
|
35
|
-
* MemoMap.
|
|
36
|
-
*
|
|
37
|
-
* Contract for protocol implementations: the layer build must not capture
|
|
38
|
-
* per-call context. Anything call-dependent — credentials, per-request
|
|
39
|
-
* options — must be resolved inside `encode`/`decode`, which execute on the
|
|
40
|
-
* calling fiber and therefore see the caller's services on every request.
|
|
41
|
-
*/
|
|
42
|
-
const protocolMemoMap = Layer.makeMemoMapUnsafe();
|
|
43
|
-
const protocolScope = Scope.makeUnsafe();
|
|
44
|
-
const protocolContexts = new WeakMap();
|
|
45
|
-
const protocolContext = (layer) => {
|
|
46
|
-
const cached = protocolContexts.get(layer);
|
|
47
|
-
if (cached)
|
|
48
|
-
return Effect.succeed(cached);
|
|
49
|
-
return Effect.map(Layer.buildWithMemoMap(layer, protocolMemoMap, protocolScope), (ctx) => {
|
|
50
|
-
protocolContexts.set(layer, ctx);
|
|
51
|
-
return ctx;
|
|
52
|
-
});
|
|
53
|
-
};
|
|
54
|
-
/**
|
|
55
|
-
* Wrap one operation call with the caller-provided retry policy, if the
|
|
56
|
-
* operation declares a retry tag and the context carries a policy for it.
|
|
57
|
-
*/
|
|
58
|
-
const applyRetry = (base, retryKey) => retryKey === undefined
|
|
59
|
-
? base
|
|
60
|
-
: Effect.flatMap(Effect.serviceOption(retryKey), (opt) => Effect.gen(function* () {
|
|
61
|
-
const lastError = yield* Ref.make(undefined);
|
|
62
|
-
// No policy in context → makeDefault (transient/throttling/server
|
|
63
|
-
// errors, capped exponential backoff + jitter, honors server
|
|
64
|
-
// retryAfter hints). Mirrors the distilled client.
|
|
65
|
-
const policy = Option.isSome(opt) ? opt.value : makeDefault;
|
|
66
|
-
const opts = typeof policy === "function" ? policy(lastError) : policy;
|
|
67
|
-
if (!opts.while)
|
|
68
|
-
return yield* base;
|
|
69
|
-
return yield* base.pipe(Effect.tapError((e) => Ref.set(lastError, e)), Effect.retry({
|
|
70
|
-
while: (e) => opts.while(e),
|
|
71
|
-
...(opts.schedule ? { schedule: opts.schedule } : {}),
|
|
72
|
-
}));
|
|
73
|
-
}));
|
|
74
|
-
export function make(configFn) {
|
|
75
|
-
let prepared;
|
|
76
|
-
const prepare = () => {
|
|
77
|
-
if (prepared)
|
|
78
|
-
return prepared;
|
|
79
|
-
const cfg = configFn();
|
|
80
|
-
prepared = {
|
|
81
|
-
cfg,
|
|
82
|
-
inputAst: cfg.input.ast,
|
|
83
|
-
outputAst: cfg.output.ast,
|
|
84
|
-
};
|
|
85
|
-
return prepared;
|
|
86
|
-
};
|
|
87
|
-
const fn = (input) => Effect.suspend(() => {
|
|
88
|
-
const { cfg, inputAst, outputAst } = prepare();
|
|
89
|
-
const call = Effect.flatMap(protocolContext(cfg.protocol), (protocolCtx) => Effect.gen(function* () {
|
|
90
|
-
const protocol = yield* Protocol;
|
|
91
|
-
const client = yield* HttpClient.HttpClient;
|
|
92
|
-
const request = yield* protocol.encode({
|
|
93
|
-
input,
|
|
94
|
-
inputAst,
|
|
95
|
-
config: cfg,
|
|
96
|
-
});
|
|
97
|
-
const response = yield* client.execute(request);
|
|
98
|
-
return yield* protocol.decode({
|
|
99
|
-
response,
|
|
100
|
-
outputAst,
|
|
101
|
-
errors: cfg.errors ?? [],
|
|
102
|
-
config: cfg,
|
|
103
|
-
});
|
|
104
|
-
}).pipe(Effect.provideContext(protocolCtx)));
|
|
105
|
-
return applyRetry(call, cfg.retry);
|
|
106
|
-
});
|
|
107
|
-
// Make the operation itself yieldable: `yield* operation` captures the
|
|
108
|
-
// current context and returns a requirement-free call function (mirrors
|
|
109
|
-
// the distilled repo's OperationMethod).
|
|
110
|
-
const Proto = {
|
|
111
|
-
[Symbol.iterator]() {
|
|
112
|
-
return new SingleShotGen(this.asEffect());
|
|
113
|
-
},
|
|
114
|
-
pipe() {
|
|
115
|
-
return pipeArguments(this.asEffect(), arguments);
|
|
116
|
-
},
|
|
117
|
-
asEffect() {
|
|
118
|
-
return Effect.map(Effect.context(), (context) => (input) => Effect.provideContext(fn(input), context));
|
|
119
|
-
},
|
|
120
|
-
};
|
|
121
|
-
Object.assign(fn, Proto);
|
|
122
|
-
// Debug/introspection surface carried over from the distilled client:
|
|
123
|
-
// the operation's metadata is readable off the exported callable
|
|
124
|
-
// (e.g. `iam.listRoles.input` / `.output` / `.errors` / `.operationName`
|
|
125
|
-
// / `.pagination`). Lazy getters, so importing a service module doesn't
|
|
126
|
-
// force its suspended schemas.
|
|
127
|
-
Object.defineProperties(fn, {
|
|
128
|
-
input: { get: () => prepare().cfg.input, configurable: true },
|
|
129
|
-
output: { get: () => prepare().cfg.output, configurable: true },
|
|
130
|
-
errors: { get: () => prepare().cfg.errors ?? [], configurable: true },
|
|
131
|
-
operationName: {
|
|
132
|
-
get: () => prepare().cfg.operationName,
|
|
133
|
-
configurable: true,
|
|
134
|
-
},
|
|
135
|
-
pagination: {
|
|
136
|
-
get: () => prepare().cfg.pagination,
|
|
137
|
-
configurable: true,
|
|
138
|
-
},
|
|
139
|
-
});
|
|
140
|
-
return fn;
|
|
141
|
-
}
|
|
142
|
-
/**
|
|
143
|
-
* Like {@link make}, plus `.pages()` / `.items()` streaming built on the
|
|
144
|
-
* operation's pagination trait. The SDK can pass a provider-specific
|
|
145
|
-
* {@link Pagination.PaginationStrategy} (e.g. Cloudflare stops page-mode
|
|
146
|
-
* traversal on the first empty page); the default dispatches on
|
|
147
|
-
* `pagination.mode`.
|
|
148
|
-
*/
|
|
149
|
-
export function makePaginated(configFn, strategy) {
|
|
150
|
-
const fn = make(configFn);
|
|
151
|
-
// configFn is a cheap object literal over already-constructed consts —
|
|
152
|
-
// re-invoking it here just reads the pagination trait (memoized).
|
|
153
|
-
let pagination;
|
|
154
|
-
const pag = () => (pagination ??= configFn().pagination);
|
|
155
|
-
const paginate = strategy ?? Pagination.paginateWithDefaults;
|
|
156
|
-
// The streams are built over a CALL FUNCTION, so the same code serves both
|
|
157
|
-
// call styles: the operation itself (requirements intact), and the
|
|
158
|
-
// context-bound function `yield* operation` hands back — whose streams
|
|
159
|
-
// inherit that captured context and so need nothing after the yield.
|
|
160
|
-
const withStreams = (call) => {
|
|
161
|
-
const pages = (input) => paginate(call, input, pag());
|
|
162
|
-
const items = (input) => {
|
|
163
|
-
const p = pag();
|
|
164
|
-
return p.items
|
|
165
|
-
? Pagination.extractItems(pages(input), p.items)
|
|
166
|
-
: pages(input);
|
|
167
|
-
};
|
|
168
|
-
return Object.assign(call, { pages, items });
|
|
169
|
-
};
|
|
170
|
-
// `yield* operation` runs through `make`'s Proto.asEffect, which builds a
|
|
171
|
-
// fresh arrow and would drop `.pages` / `.items` (distilled #145). Override
|
|
172
|
-
// it here — Proto's `[Symbol.iterator]`/`pipe` dispatch on `this`, so both
|
|
173
|
-
// pick this up. Only paginated operations pay for it.
|
|
174
|
-
fn.asEffect = () => Effect.map(Effect.context(), (context) => withStreams((input) => Effect.provideContext(fn(input), context)));
|
|
175
|
-
return withStreams(fn);
|
|
176
|
-
}
|
|
177
|
-
//#endregion
|
|
178
|
-
//# sourceMappingURL=api.js.map
|
|
1
|
+
export { api$D as D, api$call as call, api$cannotStream as cannotStream, api$describeOperation as describeOperation, api$encodeRequest as encodeRequest, api$error as error, api$lazyNamespace as lazyNamespace, api$lazyService as lazyService, api$make as make, api$makePaginated as makePaginated, api$makeStreaming as makeStreaming, api$named as named, api$newError as newError, api$op as op, api$opPaginated as opPaginated, api$opStreaming as opStreaming, api$schema as schema, api$withValue as withValue } from "./_bundle/base.js";
|
package/lib/category.d.ts
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* ```ts
|
|
10
10
|
* import * as Category from "@distilled.cloud/core/category";
|
|
11
11
|
*
|
|
12
|
-
* export class Unauthorized extends Schema.
|
|
12
|
+
* export class Unauthorized extends Schema.TaggedError<Unauthorized>()(
|
|
13
13
|
* "Unauthorized",
|
|
14
14
|
* { message: Schema.String },
|
|
15
15
|
* ).pipe(Category.withAuthError) {}
|
|
@@ -56,7 +56,7 @@ export interface RetryableInfo {
|
|
|
56
56
|
*
|
|
57
57
|
* @example
|
|
58
58
|
* ```ts
|
|
59
|
-
* export class MyError extends Schema.
|
|
59
|
+
* export class MyError extends Schema.TaggedError<MyError>()(
|
|
60
60
|
* "MyError",
|
|
61
61
|
* { message: Schema.String },
|
|
62
62
|
* ).pipe(Category.withCategory(Category.AuthError)) {}
|
|
@@ -76,13 +76,13 @@ export declare const withCategory: <Categories extends Array<Category>>(...categ
|
|
|
76
76
|
* @example
|
|
77
77
|
* ```ts
|
|
78
78
|
* // Standard retryable error
|
|
79
|
-
* export class TransientError extends Schema.
|
|
79
|
+
* export class TransientError extends Schema.TaggedError<TransientError>()(
|
|
80
80
|
* "TransientError",
|
|
81
81
|
* { message: Schema.String },
|
|
82
82
|
* ).pipe(Category.withRetryable()) {}
|
|
83
83
|
*
|
|
84
84
|
* // Throttling error (uses longer backoff)
|
|
85
|
-
* export class RateLimitError extends Schema.
|
|
85
|
+
* export class RateLimitError extends Schema.TaggedError<RateLimitError>()(
|
|
86
86
|
* "RateLimitError",
|
|
87
87
|
* { message: Schema.String },
|
|
88
88
|
* ).pipe(Category.withRetryable({ throttling: true })) {}
|
|
@@ -237,18 +237,21 @@ export declare const isRetryable: (error: unknown) => boolean;
|
|
|
237
237
|
*/
|
|
238
238
|
export declare const isThrottling: (error: unknown) => boolean;
|
|
239
239
|
/**
|
|
240
|
-
* Check if an error
|
|
241
|
-
*
|
|
242
|
-
*
|
|
243
|
-
* -
|
|
244
|
-
*
|
|
245
|
-
* -
|
|
246
|
-
*
|
|
247
|
-
* -
|
|
248
|
-
*
|
|
249
|
-
* - Effect `HttpClientError` with `reason._tag === "TransportError"`
|
|
250
|
-
* (
|
|
251
|
-
*
|
|
240
|
+
* Check if an error should be retried automatically. Only errors that say
|
|
241
|
+
* so are retried; an HTTP status alone does not make an error retryable:
|
|
242
|
+
*
|
|
243
|
+
* - errors marked with `withRetryable()` (Smithy `@retryable`, a patch, or
|
|
244
|
+
* the SDK's own error classes);
|
|
245
|
+
* - the `RetryableError` and `ThrottlingError` categories (`ThrottlingError`
|
|
246
|
+
* is HTTP 429, the server's own "try again later");
|
|
247
|
+
* - the `NetworkError` category: the request failed on the way, before any
|
|
248
|
+
* server answered;
|
|
249
|
+
* - an Effect `HttpClientError` with `reason._tag === "TransportError"`
|
|
250
|
+
* (connect timeout, socket reset, DNS failure, premature stream close),
|
|
251
|
+
* which no spec can mark.
|
|
252
|
+
*
|
|
253
|
+
* `ServerError`, `TimeoutError` and `LockedError` describe an
|
|
254
|
+
* error; they do not retry it.
|
|
252
255
|
*/
|
|
253
256
|
export declare const isTransientError: (error: unknown) => boolean;
|
|
254
257
|
export type AllKeys<E> = E extends {
|