@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/protocol-http.d.ts
CHANGED
|
@@ -1,25 +1,43 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
2
|
+
import * as HttpClientRequest from "effect/http/HttpClientRequest";
|
|
1
3
|
/**
|
|
2
|
-
* Generic REST protocol machinery, shared by SDK
|
|
4
|
+
* Generic REST protocol machinery, shared by SDK protocols.
|
|
3
5
|
*
|
|
4
6
|
* Everything here is driven purely by the trait annotations in
|
|
5
|
-
* `core/trait.ts`
|
|
7
|
+
* `core/trait.ts` -- nothing is provider-specific. An SDK protocol (e.g.
|
|
6
8
|
* cloudflare's) supplies credentials/base-URL, calls {@link buildRequest} to
|
|
7
9
|
* encode, and layers its own response-envelope handling on top of the
|
|
8
10
|
* decode-side helpers ({@link getProps}/{@link mapKeys}/
|
|
9
11
|
* {@link matchTypedError}).
|
|
10
12
|
*/
|
|
11
13
|
import type * as AST from "effect/SchemaAST";
|
|
12
|
-
import
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
import { ConfigError } from "./config.ts";
|
|
15
|
+
import { isOpaqueValue } from "./plain-values.ts";
|
|
16
|
+
import * as Schema from "./schema-lite-typed.ts";
|
|
17
|
+
import { SdkError } from "./sdk-error.ts";
|
|
18
|
+
import { type ErrorMatcher, type HttpTrait, type KeyDictionaryEntries } from "./trait.ts";
|
|
19
|
+
export { getAnn, getProps, resolveNode } from "./annotations.ts";
|
|
16
20
|
export declare const getPropAnn: (prop: AST.PropertySignature, symbol: symbol) => unknown;
|
|
17
21
|
export declare const hasPropAnn: (prop: AST.PropertySignature, symbol: symbol) => boolean;
|
|
18
22
|
export declare const nameOf: (prop: AST.PropertySignature, symbol: symbol) => string;
|
|
19
|
-
/**
|
|
20
|
-
export
|
|
21
|
-
|
|
22
|
-
|
|
23
|
+
/** An output member read from a response header (`T.Header`). */
|
|
24
|
+
export interface ResponseHeaderMember {
|
|
25
|
+
readonly key: string;
|
|
26
|
+
/** Lowercase header name. */
|
|
27
|
+
readonly wire: string;
|
|
28
|
+
/** The member is a number; the header's text is parsed. */
|
|
29
|
+
readonly number: boolean;
|
|
30
|
+
}
|
|
31
|
+
/** The output's header-bound members, read from the schema once. */
|
|
32
|
+
export declare const responseHeaderMembers: (outputAst: AST.AST) => ReadonlyArray<ResponseHeaderMember>;
|
|
33
|
+
/**
|
|
34
|
+
* Copy the response headers an output declares onto its decoded body. A
|
|
35
|
+
* number member gets the header parsed; text that is not a number is kept
|
|
36
|
+
* as sent, so strict validation reports it. A body that is not an object
|
|
37
|
+
* (a raw root) is returned as is -- generators bind no headers there.
|
|
38
|
+
*/
|
|
39
|
+
export declare const withResponseHeaders: (members: ReadonlyArray<ResponseHeaderMember>, body: unknown, headers: Record<string, string | undefined>) => unknown;
|
|
40
|
+
export { isOpaqueValue };
|
|
23
41
|
/**
|
|
24
42
|
* Deep-rename keys via a plain dictionary (see `T.KeyDictionary`). An entry
|
|
25
43
|
* may list several wire spellings; encode uses the first (canonical) one and
|
|
@@ -27,13 +45,19 @@ export declare const isOpaqueValue: (v: unknown) => boolean;
|
|
|
27
45
|
*/
|
|
28
46
|
export declare const mapKeysByDictionary: (dict: KeyDictionaryEntries, value: unknown, direction: "encode" | "decode") => unknown;
|
|
29
47
|
/**
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
|
|
48
|
+
* Whether {@link mapKeys} returns every value of `root` unchanged (as a deep
|
|
49
|
+
* copy) in `direction` with no fallback dictionary: no member is renamed,
|
|
50
|
+
* string-encoded (encode) or picked by `T.UnionCases` (decode, or encode for
|
|
51
|
+
* a union whose cases carry member dictionaries), and no
|
|
52
|
+
* `T.KeyDictionary` is in scope anywhere below `root`. Protocols use it to
|
|
53
|
+
* skip the walk. Computed once per schema node and direction.
|
|
54
|
+
*/
|
|
55
|
+
export declare const mapsVerbatim: (root: AST.AST, direction: "encode" | "decode") => boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Rename keys between TS names and wire names, per the schema (see
|
|
58
|
+
* {@link walkKeys}). A decode with no fallback dictionary returns `value`
|
|
59
|
+
* itself when the schema renames nothing ({@link mapsVerbatim}): the walk
|
|
60
|
+
* would only copy it.
|
|
37
61
|
*/
|
|
38
62
|
export declare const mapKeys: (ast: AST.AST, value: unknown, direction: "encode" | "decode", fallback?: KeyDictionaryEntries) => unknown;
|
|
39
63
|
export interface BuildRequestOptions {
|
|
@@ -49,26 +73,183 @@ export interface BuildRequestOptions {
|
|
|
49
73
|
*/
|
|
50
74
|
readonly mapMemberHeader?: (name: string, value: string) => string;
|
|
51
75
|
/**
|
|
52
|
-
* Wire name for input keys the schema doesn't declare (spec drift
|
|
76
|
+
* Wire name for input keys the schema doesn't declare (spec drift --
|
|
53
77
|
* unknown keys pass through as body fields rather than being dropped).
|
|
54
78
|
* Defaults to the key verbatim.
|
|
55
79
|
*/
|
|
56
80
|
readonly unknownKeyToWire?: (key: string) => string;
|
|
81
|
+
/**
|
|
82
|
+
* Send `{}` on a method that takes a body even when the input declares no
|
|
83
|
+
* body members. Connect unary RPCs (E2B's envd) POST JSON for every call,
|
|
84
|
+
* and refuse a bodyless one with 415.
|
|
85
|
+
*/
|
|
86
|
+
readonly emptyJsonBody?: boolean;
|
|
87
|
+
/**
|
|
88
|
+
* How a query member spells a nested object or an array.
|
|
89
|
+
*
|
|
90
|
+
* - `"dotted"` (default): `created.gte=1`; an array repeats the key
|
|
91
|
+
* (`expand=a&expand=b`).
|
|
92
|
+
* - `"brackets"`: `created[gte]=1`; an array indexes the key
|
|
93
|
+
* (`expand[0]=a&expand[1]=b`), the same rule as form-urlencoded bodies.
|
|
94
|
+
* Stripe needs this: its v2 API refuses `key[]` and repeated keys.
|
|
95
|
+
*
|
|
96
|
+
* `T.CommaDelimited` and `T.DeepQuery` members keep their own spelling.
|
|
97
|
+
*/
|
|
98
|
+
readonly queryStyle?: "dotted" | "brackets";
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Encode a greedy `{name+}` label: the value may span several path
|
|
102
|
+
* segments (e.g. an Azure scope `/subscriptions/{id}/resourceGroups/{rg}`),
|
|
103
|
+
* so each segment is encoded on its own and the `/` separators are kept.
|
|
104
|
+
* Leading slashes are dropped because the URI template already supplies one.
|
|
105
|
+
*/
|
|
106
|
+
export declare const encodeGreedyLabel: (value: string) => string;
|
|
107
|
+
/**
|
|
108
|
+
* Marks a raw body member as binary (core `RawBody`): a string is sent as
|
|
109
|
+
* its bytes, never JSON-encoded, even with no declared media type.
|
|
110
|
+
*/
|
|
111
|
+
export declare const binaryBodySymbol: unique symbol;
|
|
112
|
+
/**
|
|
113
|
+
* `HttpClientRequest.make(method)(url)` with `headers` set, in one object:
|
|
114
|
+
* the same request as `make(...).pipe(setHeaders(headers))` without the
|
|
115
|
+
* intermediate copies. `url` may carry a query string.
|
|
116
|
+
*/
|
|
117
|
+
export declare const makeRequest: (method: HttpTrait["method"], url: string, headers: Record<string, string>) => HttpClientRequest.HttpClientRequest;
|
|
118
|
+
declare const InvalidInput_base: Schema.TaggedErrorClass<"InvalidInput", {
|
|
119
|
+
readonly member: import("effect/Schema").String;
|
|
120
|
+
readonly message: import("effect/Schema").String;
|
|
121
|
+
}> & (new (...args: any[]) => {
|
|
122
|
+
"@distilled.cloud/error/categories": {
|
|
123
|
+
BadRequestError: true;
|
|
124
|
+
};
|
|
125
|
+
});
|
|
126
|
+
/**
|
|
127
|
+
* The input cannot be sent: a path label whose value would address another
|
|
128
|
+
* resource (`.` or `..`, which the URL parser resolves to the parent path,
|
|
129
|
+
* or `""`, which addresses the parent path), or a host label that would
|
|
130
|
+
* address another host. Raised before anything is sent.
|
|
131
|
+
*/
|
|
132
|
+
export declare class InvalidInput extends /*@__PURE__*/ InvalidInput_base {
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* The refusal for an input no request can carry. `cause` is what a step
|
|
136
|
+
* that only reads the caller's values threw: `JSON.stringify` on a `BigInt`,
|
|
137
|
+
* a walk of an object that contains itself.
|
|
138
|
+
*/
|
|
139
|
+
export declare const unsendable: (cause: unknown) => InvalidInput;
|
|
140
|
+
/**
|
|
141
|
+
* The refusal for a path label value that would address another resource,
|
|
142
|
+
* or `undefined`. The URL parser resolves a `.` or `..` segment,
|
|
143
|
+
* percent-encoded or not, so no encoding can carry one
|
|
144
|
+
* (`/projects/p1/branches/..` -> `/projects/p1/`). A greedy label keeps its
|
|
145
|
+
* `/`, so each of its segments counts.
|
|
146
|
+
*
|
|
147
|
+
* Also refuses an empty value, unless the label is `optional`. It leaves the
|
|
148
|
+
* segment empty, and a server that ignores a trailing slash (Smithy routing
|
|
149
|
+
* does) reads `/things/` as the collection `/things`: Kubernetes runs a
|
|
150
|
+
* delete of the Secret `""` as a delete of every Secret in the namespace.
|
|
151
|
+
* A label the schema marks optional is one the API documents as possibly
|
|
152
|
+
* empty (Azure Key Vault's `{secret-version}`), so it may be `""`.
|
|
153
|
+
*
|
|
154
|
+
* Also refuses a value with a lone UTF-16 surrogate (`"\ud800"`):
|
|
155
|
+
* `encodeURIComponent` throws `URIError` on it, and no encoding keeps the
|
|
156
|
+
* name as written.
|
|
157
|
+
*/
|
|
158
|
+
export declare const invalidLabel: (member: string, value: unknown, greedy?: boolean, optional?: boolean) => InvalidInput | undefined;
|
|
159
|
+
/**
|
|
160
|
+
* A path label value, percent-encoded, or the {@link InvalidInput} that
|
|
161
|
+
* {@link invalidLabel} refuses it with. A greedy label keeps its `/` and
|
|
162
|
+
* encodes each segment ({@link encodeGreedyLabel}). Use it wherever a
|
|
163
|
+
* caller's value goes into a URL path, so the check can't be skipped.
|
|
164
|
+
*/
|
|
165
|
+
export declare const encodeLabel: (member: string, value: unknown, greedy?: boolean, optional?: boolean) => string | InvalidInput;
|
|
166
|
+
/**
|
|
167
|
+
* Whether `value` is one DNS host label (RFC 1123), or with
|
|
168
|
+
* `allowSubDomains` a dot-separated name made of them. A value that goes into
|
|
169
|
+
* a URL host must pass it: any other character (`/`, `@`, `#`, `?`, `:`)
|
|
170
|
+
* can move the request to another host, and no encoding fixes a host.
|
|
171
|
+
*/
|
|
172
|
+
export declare const isHostLabel: (value: unknown, allowSubDomains?: boolean) => boolean;
|
|
173
|
+
/**
|
|
174
|
+
* The refusal for a value that goes into a URL host but is not a host label
|
|
175
|
+
* ({@link isHostLabel}), or `undefined`. The host-side counterpart of
|
|
176
|
+
* {@link invalidLabel}. A value read from credentials config fails with
|
|
177
|
+
* {@link invalidHostLabelConfig} instead.
|
|
178
|
+
*/
|
|
179
|
+
export declare const invalidHostLabel: (member: string, value: unknown, allowSubDomains?: boolean) => InvalidInput | undefined;
|
|
180
|
+
/**
|
|
181
|
+
* {@link invalidHostLabel} for a value read from credentials config: the
|
|
182
|
+
* refusal is a `ConfigError` naming the setting (`"S2 basin"`,
|
|
183
|
+
* `"STACKIT region"`), or `undefined`.
|
|
184
|
+
*/
|
|
185
|
+
export declare const invalidHostLabelConfig: (name: string, value: unknown, allowSubDomains?: boolean) => ConfigError | undefined;
|
|
186
|
+
/**
|
|
187
|
+
* The origin (`https://host[:port]`) that a host or origin read from
|
|
188
|
+
* credentials config names, or the `ConfigError` refusing it. The value is
|
|
189
|
+
* a host (`acme.zendesk.com`, `udm.lan:8443`, given `defaultScheme`) or an
|
|
190
|
+
* origin (`https://acme.zendesk.com/`). It picks the host and nothing else:
|
|
191
|
+
* a user, path, query or fragment, a scheme other than `http`/`https`, or a
|
|
192
|
+
* host name that is not DNS labels ({@link isHostLabel}) or an IPv6 literal
|
|
193
|
+
* is refused.
|
|
194
|
+
*/
|
|
195
|
+
export declare const originFromConfig: (name: string, value: string, defaultScheme?: "https" | "http") => string | ConfigError;
|
|
196
|
+
/**
|
|
197
|
+
* Build an HTTP request from an operation input and its schema, driven by
|
|
198
|
+
* the trait annotations: `Http()` supplies method + URI template, `Label()`
|
|
199
|
+
* members fill URI placeholders, `Header()`/`Query()` members bind to
|
|
200
|
+
* headers/query params, `DeepQuery()` struct members expand into dotted
|
|
201
|
+
* query params, `HttpBody()` sends the member as the whole body,
|
|
202
|
+
* `FormDataFile()` members become multipart file parts, and everything else
|
|
203
|
+
* is a JSON body field (wire-named via `Body()` / `KeyDictionary`).
|
|
204
|
+
*
|
|
205
|
+
* The schema is read once per input schema (see `planFor`); later calls only
|
|
206
|
+
* walk the input value.
|
|
207
|
+
*
|
|
208
|
+
* An optional label left out of the input is an empty segment, like `""`
|
|
209
|
+
* (Azure Key Vault's `/secrets/{name}/{version}` -> `/secrets/db/`).
|
|
210
|
+
*
|
|
211
|
+
* Fails with {@link InvalidInput}, before anything is sent, when a label is
|
|
212
|
+
* `.` or `..` (for a greedy `{name+}` label, when any of its segments is),
|
|
213
|
+
* is `""` and the schema marks it required, or has a lone UTF-16 surrogate,
|
|
214
|
+
* and when a JSON body holds a value JSON cannot carry (a `BigInt`, an
|
|
215
|
+
* object that contains itself).
|
|
216
|
+
* Fails with {@link SdkError} when the input schema is missing the `Http()`
|
|
217
|
+
* trait (a codegen bug the generator refuses).
|
|
218
|
+
*/
|
|
219
|
+
export declare const buildRequest: (options: BuildRequestOptions) => Effect.Effect<HttpClientRequest.HttpClientRequest, InvalidInput | SdkError>;
|
|
220
|
+
/** Parsed response metadata supplied by a protocol after it detects a failure. */
|
|
221
|
+
export interface ErrorResponse {
|
|
222
|
+
readonly body?: unknown;
|
|
223
|
+
readonly headers?: Readonly<Record<string, string | undefined>>;
|
|
224
|
+
/**
|
|
225
|
+
* JSON pointer to the object that holds the error's fields when the
|
|
226
|
+
* provider nests them, e.g. `"/error"` for `{ error: { status, details } }`.
|
|
227
|
+
*/
|
|
228
|
+
readonly fieldsAt?: string;
|
|
57
229
|
}
|
|
58
|
-
|
|
230
|
+
/** Every supplied constraint must match; an unconstrained matcher matches nothing. */
|
|
231
|
+
export declare const matchesExpression: (m: ErrorMatcher, code: number | undefined, status: number, message: string, response?: ErrorResponse) => boolean;
|
|
59
232
|
/**
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
233
|
+
* The fields every error built from a response gets, when its class declares
|
|
234
|
+
* them: the body (keys mapped to TS names when the class types it), the
|
|
235
|
+
* headers, and the server's retry hint from `Retry-After` or `RateLimit`.
|
|
63
236
|
*/
|
|
64
|
-
export declare const
|
|
237
|
+
export declare const responseErrorFields: (fields: Record<string, unknown> | undefined, response: ErrorResponse) => Record<string, unknown>;
|
|
65
238
|
/**
|
|
66
239
|
* Pick the operation's typed error class for a failed response: among all
|
|
67
240
|
* declared classes whose matchers (see `applyErrorMatchers`) match the wire
|
|
68
241
|
* failure, the most specific matcher wins (ties break by declaration order).
|
|
242
|
+
* Empty error lists use an HTTP-status message so body/header-only failures can
|
|
243
|
+
* still match. The constructor receives the raw body and headers as well as
|
|
244
|
+
* code/message; error schemas can declare these fields to expose them to callers.
|
|
245
|
+
* Any other field the class declares is read from the JSON body's key of the
|
|
246
|
+
* same name -- at `response.fieldsAt` first, then at the top level -- so a
|
|
247
|
+
* patch that adds `requestId` to an error gets the body's `requestId`. A
|
|
248
|
+
* declared `retryAfter` gets the `Retry-After` / `RateLimit` header hint. The
|
|
249
|
+
* matched `code` and `message` always win over the body's.
|
|
69
250
|
*/
|
|
70
|
-
export declare
|
|
251
|
+
export declare function matchTypedError<E>(errorClasses: ReadonlyArray<new (...args: any[]) => E>, status: number, errors: ReadonlyArray<{
|
|
71
252
|
code?: number;
|
|
72
253
|
message: string;
|
|
73
|
-
}
|
|
254
|
+
}>, response?: ErrorResponse): E | undefined;
|
|
74
255
|
//# sourceMappingURL=protocol-http.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protocol-http.d.ts","
|
|
1
|
+
{"version":3,"file":"protocol-http.d.ts","sources":["../src/protocol-http.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAGxC,OAAO,KAAK,iBAAiB,MAAM,+BAA+B,CAAC;AACnE;;;;;;;;;GASG;AACH,OAAO,KAAK,KAAK,GAAG,MAAM,kBAAkB,CAAC;AAI7C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAkB,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElE,OAAO,KAAK,MAAM,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,OAAO,EAeL,KAAK,YAAY,EAEjB,KAAK,SAAS,EACd,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