@distilled.cloud/core 1.0.0-rc.20 → 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/README.md +33 -0
- package/lib/_bundle/aws.js +1 -1
- package/lib/_bundle/aws.js.map +1 -1
- 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/grpc.js +2 -1
- package/lib/_bundle/grpc.js.map +1 -1
- package/lib/_bundle/rest.js +1 -1
- package/lib/_bundle/rest.js.map +1 -1
- package/lib/annotations.d.ts.map +1 -1
- package/lib/api.d.ts +71 -58
- package/lib/api.d.ts.map +1 -1
- package/lib/api.js +1 -1
- package/lib/category.d.ts +15 -12
- package/lib/category.d.ts.map +1 -1
- package/lib/chunks.d.ts.map +1 -1
- package/lib/config.d.ts +13 -0
- package/lib/config.d.ts.map +1 -1
- package/lib/crypto.d.ts.map +1 -1
- package/lib/error-category.d.ts.map +1 -1
- package/lib/errors.d.ts +35 -2
- package/lib/errors.d.ts.map +1 -1
- package/lib/errors.js +1 -1
- package/lib/graphql.d.ts +21 -4
- package/lib/graphql.d.ts.map +1 -1
- package/lib/graphql.types.d.ts +0 -1
- package/lib/graphql.types.d.ts.map +1 -1
- package/lib/grpc-transport-cloudflare-http2.d.ts.map +1 -1
- package/lib/grpc-transport-cloudflare-http2.js +2 -2
- package/lib/grpc-transport-cloudflare-http2.js.map +1 -1
- package/lib/grpc-transport-cloudflare-sockets.d.ts.map +1 -1
- package/lib/grpc-transport-cloudflare-sockets.js +4 -4
- package/lib/grpc-transport-cloudflare-sockets.js.map +1 -1
- package/lib/grpc-transport-node-http2.d.ts.map +1 -1
- package/lib/grpc-transport-node-http2.js +1 -1
- package/lib/grpc-transport-node-http2.js.map +1 -1
- package/lib/grpc-transport.d.ts +53 -18
- package/lib/grpc-transport.d.ts.map +1 -1
- package/lib/grpc-transport.js +1 -1
- package/lib/hpack.d.ts.map +1 -1
- package/lib/index.d.ts.map +1 -1
- 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 +4 -1
- package/lib/pagination.d.ts.map +1 -1
- package/lib/plain-values.d.ts +11 -0
- package/lib/plain-values.d.ts.map +1 -1
- package/lib/plain-values.js +1 -1
- package/lib/plain-values.js.map +1 -1
- package/lib/protobuf.d.ts +12 -19
- package/lib/protobuf.d.ts.map +1 -1
- package/lib/protobuf.js +1 -1
- package/lib/protocol-grpc.d.ts +47 -10
- package/lib/protocol-grpc.d.ts.map +1 -1
- package/lib/protocol-grpc.js +1 -1
- package/lib/protocol-http.d.ts +110 -8
- package/lib/protocol-http.d.ts.map +1 -1
- package/lib/protocol-http.js +1 -1
- package/lib/protocol-rest.d.ts +161 -37
- package/lib/protocol-rest.d.ts.map +1 -1
- package/lib/protocol-rest.js +1 -1
- 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.map +1 -1
- package/lib/response-validation-strict.d.ts.map +1 -1
- package/lib/response-validation.d.ts.map +1 -1
- package/lib/retry-after.d.ts +1 -1
- package/lib/retry-after.d.ts.map +1 -1
- 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 +100 -20
- package/lib/retry.d.ts.map +1 -1
- package/lib/retry.js +1 -1
- package/lib/schema-lite-impl.d.ts +25 -4
- package/lib/schema-lite-impl.d.ts.map +1 -1
- package/lib/schema-lite-impl.js +1 -1
- package/lib/schema-lite-typed.d.ts.map +1 -1
- package/lib/schema-lite.d.ts +1 -0
- package/lib/schema-lite.d.ts.map +1 -1
- package/lib/schema-lite.js +1 -1
- package/lib/schema.d.ts.map +1 -1
- package/lib/sdk-error.d.ts +4 -0
- package/lib/sdk-error.d.ts.map +1 -1
- 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.map +1 -1
- package/lib/sensitive.js +1 -1
- package/lib/sensitive.js.map +1 -1
- package/lib/telemetry-debug.d.ts.map +1 -1
- package/lib/telemetry-debug.js +1 -1
- package/lib/telemetry-debug.js.map +1 -1
- package/lib/telemetry-hooks.d.ts.map +1 -1
- package/lib/telemetry-host-rules.d.ts.map +1 -1
- package/lib/telemetry-lambda-context.d.ts.map +1 -1
- package/lib/telemetry-message-context.d.ts.map +1 -1
- package/lib/telemetry-metrics.d.ts.map +1 -1
- package/lib/telemetry-metrics.js +1 -1
- package/lib/telemetry-metrics.js.map +1 -1
- package/lib/telemetry-name-template.d.ts.map +1 -1
- package/lib/telemetry-stream.d.ts.map +1 -1
- package/lib/telemetry-stream.js +1 -1
- package/lib/telemetry-stream.js.map +1 -1
- package/lib/telemetry-xray.d.ts.map +1 -1
- package/lib/telemetry.d.ts +29 -0
- package/lib/telemetry.d.ts.map +1 -1
- package/lib/telemetry.js +2 -2
- package/lib/telemetry.js.map +1 -1
- 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 +24 -1
- package/lib/trait.d.ts.map +1 -1
- package/lib/trait.js +1 -1
- package/lib/unknown-error.d.ts.map +1 -1
- package/lib/xml.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/api.ts +402 -209
- package/src/category.ts +21 -28
- package/src/config.ts +17 -1
- package/src/errors.ts +24 -2
- package/src/graphql.ts +65 -26
- package/src/graphql.types.ts +15 -0
- package/src/grpc-transport-cloudflare-http2.ts +374 -299
- package/src/grpc-transport-cloudflare-sockets.ts +150 -81
- package/src/grpc-transport-node-http2.ts +119 -46
- package/src/grpc-transport.ts +211 -42
- package/src/max-message-bytes.ts +58 -0
- package/src/ndjson.ts +55 -0
- package/src/pagination.ts +26 -15
- package/src/plain-values.ts +30 -1
- package/src/protobuf.ts +40 -5
- package/src/protocol-grpc.ts +518 -348
- package/src/protocol-http.ts +474 -100
- package/src/protocol-rest.ts +580 -140
- package/src/protocol.ts +150 -0
- package/src/response-validation-strict.ts +9 -3
- package/src/retry-after.ts +1 -1
- package/src/retry-state.ts +105 -0
- package/src/retry.ts +176 -47
- package/src/schema-lite-impl.ts +81 -10
- package/src/schema-lite.ts +1 -0
- package/src/sdk-error.ts +4 -0
- package/src/send.ts +156 -0
- package/src/sensitive.ts +49 -15
- package/src/telemetry.ts +2 -34
- package/src/token-cache.ts +117 -0
- package/src/trait.ts +34 -1
package/lib/protocol-http.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as Effect from "effect/Effect";
|
|
2
2
|
import * as HttpClientRequest from "effect/http/HttpClientRequest";
|
|
3
3
|
/**
|
|
4
|
-
* Generic REST protocol machinery, shared by SDK
|
|
4
|
+
* Generic REST protocol machinery, shared by SDK protocols.
|
|
5
5
|
*
|
|
6
6
|
* Everything here is driven purely by the trait annotations in
|
|
7
7
|
* `core/trait.ts` -- nothing is provider-specific. An SDK protocol (e.g.
|
|
@@ -11,6 +11,7 @@ import * as HttpClientRequest from "effect/http/HttpClientRequest";
|
|
|
11
11
|
* {@link matchTypedError}).
|
|
12
12
|
*/
|
|
13
13
|
import type * as AST from "effect/SchemaAST";
|
|
14
|
+
import { ConfigError } from "./config.ts";
|
|
14
15
|
import { isOpaqueValue } from "./plain-values.ts";
|
|
15
16
|
import * as Schema from "./schema-lite-typed.ts";
|
|
16
17
|
import { SdkError } from "./sdk-error.ts";
|
|
@@ -46,11 +47,18 @@ export declare const mapKeysByDictionary: (dict: KeyDictionaryEntries, value: un
|
|
|
46
47
|
/**
|
|
47
48
|
* Whether {@link mapKeys} returns every value of `root` unchanged (as a deep
|
|
48
49
|
* copy) in `direction` with no fallback dictionary: no member is renamed,
|
|
49
|
-
* string-encoded (encode) or picked by `T.UnionCases` (decode
|
|
50
|
+
* string-encoded (encode) or picked by `T.UnionCases` (decode, or encode for
|
|
51
|
+
* a union whose cases carry member dictionaries), and no
|
|
50
52
|
* `T.KeyDictionary` is in scope anywhere below `root`. Protocols use it to
|
|
51
53
|
* skip the walk. Computed once per schema node and direction.
|
|
52
54
|
*/
|
|
53
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.
|
|
61
|
+
*/
|
|
54
62
|
export declare const mapKeys: (ast: AST.AST, value: unknown, direction: "encode" | "decode", fallback?: KeyDictionaryEntries) => unknown;
|
|
55
63
|
export interface BuildRequestOptions {
|
|
56
64
|
readonly input: unknown;
|
|
@@ -76,6 +84,18 @@ export interface BuildRequestOptions {
|
|
|
76
84
|
* and refuse a bodyless one with 415.
|
|
77
85
|
*/
|
|
78
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";
|
|
79
99
|
}
|
|
80
100
|
/**
|
|
81
101
|
* Encode a greedy `{name+}` label: the value may span several path
|
|
@@ -84,6 +104,11 @@ export interface BuildRequestOptions {
|
|
|
84
104
|
* Leading slashes are dropped because the URI template already supplies one.
|
|
85
105
|
*/
|
|
86
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;
|
|
87
112
|
/**
|
|
88
113
|
* `HttpClientRequest.make(method)(url)` with `headers` set, in one object:
|
|
89
114
|
* the same request as `make(...).pipe(setHeaders(headers))` without the
|
|
@@ -100,19 +125,74 @@ declare const InvalidInput_base: Schema.TaggedErrorClass<"InvalidInput", {
|
|
|
100
125
|
});
|
|
101
126
|
/**
|
|
102
127
|
* The input cannot be sent: a path label whose value would address another
|
|
103
|
-
* resource (`.` or `..`, which the URL parser resolves to the parent path
|
|
104
|
-
*
|
|
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.
|
|
105
131
|
*/
|
|
106
132
|
export declare class InvalidInput extends /*@__PURE__*/ InvalidInput_base {
|
|
107
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;
|
|
108
140
|
/**
|
|
109
141
|
* The refusal for a path label value that would address another resource,
|
|
110
142
|
* or `undefined`. The URL parser resolves a `.` or `..` segment,
|
|
111
143
|
* percent-encoded or not, so no encoding can carry one
|
|
112
144
|
* (`/projects/p1/branches/..` -> `/projects/p1/`). A greedy label keeps its
|
|
113
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.
|
|
114
157
|
*/
|
|
115
|
-
export declare const invalidLabel: (member: string, value: unknown, greedy?: boolean) => InvalidInput | undefined;
|
|
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;
|
|
116
196
|
/**
|
|
117
197
|
* Build an HTTP request from an operation input and its schema, driven by
|
|
118
198
|
* the trait annotations: `Http()` supplies method + URI template, `Label()`
|
|
@@ -125,8 +205,14 @@ export declare const invalidLabel: (member: string, value: unknown, greedy?: boo
|
|
|
125
205
|
* The schema is read once per input schema (see `planFor`); later calls only
|
|
126
206
|
* walk the input value.
|
|
127
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
|
+
*
|
|
128
211
|
* Fails with {@link InvalidInput}, before anything is sent, when a label is
|
|
129
|
-
* `.` or `..` (for a greedy `{name+}` label, when any of its segments 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).
|
|
130
216
|
* Fails with {@link SdkError} when the input schema is missing the `Http()`
|
|
131
217
|
* trait (a codegen bug the generator refuses).
|
|
132
218
|
*/
|
|
@@ -135,9 +221,20 @@ export declare const buildRequest: (options: BuildRequestOptions) => Effect.Effe
|
|
|
135
221
|
export interface ErrorResponse {
|
|
136
222
|
readonly body?: unknown;
|
|
137
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;
|
|
138
229
|
}
|
|
139
230
|
/** Every supplied constraint must match; an unconstrained matcher matches nothing. */
|
|
140
231
|
export declare const matchesExpression: (m: ErrorMatcher, code: number | undefined, status: number, message: string, response?: ErrorResponse) => boolean;
|
|
232
|
+
/**
|
|
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`.
|
|
236
|
+
*/
|
|
237
|
+
export declare const responseErrorFields: (fields: Record<string, unknown> | undefined, response: ErrorResponse) => Record<string, unknown>;
|
|
141
238
|
/**
|
|
142
239
|
* Pick the operation's typed error class for a failed response: among all
|
|
143
240
|
* declared classes whose matchers (see `applyErrorMatchers`) match the wire
|
|
@@ -145,9 +242,14 @@ export declare const matchesExpression: (m: ErrorMatcher, code: number | undefin
|
|
|
145
242
|
* Empty error lists use an HTTP-status message so body/header-only failures can
|
|
146
243
|
* still match. The constructor receives the raw body and headers as well as
|
|
147
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.
|
|
148
250
|
*/
|
|
149
|
-
export declare
|
|
251
|
+
export declare function matchTypedError<E>(errorClasses: ReadonlyArray<new (...args: any[]) => E>, status: number, errors: ReadonlyArray<{
|
|
150
252
|
code?: number;
|
|
151
253
|
message: string;
|
|
152
|
-
}>, response?: ErrorResponse)
|
|
254
|
+
}>, response?: ErrorResponse): E | undefined;
|
|
153
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,KAAK,oBAAoB,EAE1B,MAAM,YAAY,CAAC;AAIpB,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE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/B,YAAY,EAAE,aAAa,CAAC,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC,EACtD,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,aAAa,CAAC;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,EACzD,QAAQ,GAAE,aAAkB,GAC3B,CAAC,GAAG,SAAS,CA+Bf"}
|
package/lib/protocol-http.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { protocol_http$InvalidInput as InvalidInput, protocol_http$buildRequest as buildRequest, protocol_http$encodeGreedyLabel as encodeGreedyLabel, protocol_http$getAnn as getAnn, protocol_http$getPropAnn as getPropAnn, protocol_http$getProps as getProps, protocol_http$hasPropAnn as hasPropAnn, protocol_http$invalidLabel as invalidLabel, protocol_http$isOpaqueValue as isOpaqueValue, protocol_http$makeRequest as makeRequest, protocol_http$mapKeys as mapKeys, protocol_http$mapKeysByDictionary as mapKeysByDictionary, protocol_http$mapsVerbatim as mapsVerbatim, protocol_http$matchTypedError as matchTypedError, protocol_http$matchesExpression as matchesExpression, protocol_http$nameOf as nameOf, protocol_http$resolveNode as resolveNode, protocol_http$responseHeaderMembers as responseHeaderMembers, protocol_http$withResponseHeaders as withResponseHeaders } from "./_bundle/rest.js";
|
|
1
|
+
export { protocol_http$InvalidInput as InvalidInput, protocol_http$binaryBodySymbol as binaryBodySymbol, protocol_http$buildRequest as buildRequest, protocol_http$encodeGreedyLabel as encodeGreedyLabel, protocol_http$encodeLabel as encodeLabel, protocol_http$getAnn as getAnn, protocol_http$getPropAnn as getPropAnn, protocol_http$getProps as getProps, protocol_http$hasPropAnn as hasPropAnn, protocol_http$invalidHostLabel as invalidHostLabel, protocol_http$invalidHostLabelConfig as invalidHostLabelConfig, protocol_http$invalidLabel as invalidLabel, protocol_http$isHostLabel as isHostLabel, protocol_http$isOpaqueValue as isOpaqueValue, protocol_http$makeRequest as makeRequest, protocol_http$mapKeys as mapKeys, protocol_http$mapKeysByDictionary as mapKeysByDictionary, protocol_http$mapsVerbatim as mapsVerbatim, protocol_http$matchTypedError as matchTypedError, protocol_http$matchesExpression as matchesExpression, protocol_http$nameOf as nameOf, protocol_http$originFromConfig as originFromConfig, protocol_http$resolveNode as resolveNode, protocol_http$responseErrorFields as responseErrorFields, protocol_http$responseHeaderMembers as responseHeaderMembers, protocol_http$unsendable as unsendable, protocol_http$withResponseHeaders as withResponseHeaders } from "./_bundle/rest.js";
|
package/lib/protocol-rest.d.ts
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import * as Context from "effect/Context";
|
|
2
2
|
import * as Effect from "effect/Effect";
|
|
3
|
-
import * as
|
|
3
|
+
import type * as HttpClientError from "effect/http/HttpClientError";
|
|
4
|
+
import type * as HttpClientResponse from "effect/http/HttpClientResponse";
|
|
5
|
+
import type * as Schema from "effect/Schema";
|
|
4
6
|
import type * as AST from "effect/SchemaAST";
|
|
7
|
+
import type * as Stream from "effect/Stream";
|
|
5
8
|
import { rawResponseRootSymbol } from "./annotations.ts";
|
|
6
|
-
import
|
|
9
|
+
import { InternalServerError } from "./errors.ts";
|
|
7
10
|
import { unwrapRedactedDeep } from "./plain-values.ts";
|
|
11
|
+
import { type InvalidInput } from "./protocol-http.ts";
|
|
12
|
+
import type { DeclaredErrorClass, Protocol } from "./protocol.ts";
|
|
13
|
+
import { SdkError } from "./sdk-error.ts";
|
|
8
14
|
import { sensitiveValueSymbol, wrapSensitive } from "./sensitive.ts";
|
|
9
15
|
import type { UnknownErrorProps } from "./unknown-error.ts";
|
|
10
16
|
export { sensitiveValueSymbol };
|
|
@@ -32,8 +38,33 @@ export declare const RawResponse: (_value?: unknown) => import("./trait.ts").Ann
|
|
|
32
38
|
export { rawResponseRootSymbol };
|
|
33
39
|
export declare const RawResponseRoot: () => import("./trait.ts").Annotation;
|
|
34
40
|
export declare const binaryResponseSymbol: unique symbol;
|
|
35
|
-
/**
|
|
41
|
+
/**
|
|
42
|
+
* Decode a successful raw binary response as a {@link BinaryStream} of the
|
|
43
|
+
* body, never read as text or into one buffer. On a whole output, the
|
|
44
|
+
* output is the stream. On the `RawResponse()` member of a structure
|
|
45
|
+
* output, that member gets the stream and the structure's `Header` members
|
|
46
|
+
* get their response headers (a download's `Content-Type`).
|
|
47
|
+
*/
|
|
36
48
|
export declare const BinaryResponse: () => import("./trait.ts").Annotation;
|
|
49
|
+
/**
|
|
50
|
+
* A binary download's body, read as it arrives. It fails with the
|
|
51
|
+
* `HttpClientError` of a read that breaks off (a connection reset).
|
|
52
|
+
* `Stream.mkUint8Array` collects it into one buffer.
|
|
53
|
+
*/
|
|
54
|
+
export type BinaryStream = Stream.Stream<Uint8Array, HttpClientError.HttpClientError>;
|
|
55
|
+
/** The schema of a {@link BinaryStream}, for a binary download's body member. */
|
|
56
|
+
export declare const BinaryStream: Schema.Schema<BinaryStream>;
|
|
57
|
+
/**
|
|
58
|
+
* A binary upload's body from a stream: a `T.HttpBody()` member may take
|
|
59
|
+
* one, and the protocol sends it as it is pulled, without buffering it.
|
|
60
|
+
* A stream can be sent once, so a call with one is never retried. With no
|
|
61
|
+
* modeled `Content-Length` member set, the body goes out chunked.
|
|
62
|
+
*/
|
|
63
|
+
export type UploadStream = Stream.Stream<Uint8Array, unknown>;
|
|
64
|
+
/** A raw request body (`T.HttpBody()` on a binary member): what `buildRequest` sends verbatim. */
|
|
65
|
+
export type RawBody = string | Uint8Array | ArrayBuffer | Blob | UploadStream;
|
|
66
|
+
/** The schema of a {@link RawBody}, for a binary upload's body member. */
|
|
67
|
+
export declare const RawBody: Schema.Schema<RawBody>;
|
|
37
68
|
export { unwrapRedactedDeep };
|
|
38
69
|
export { wrapSensitive };
|
|
39
70
|
/**
|
|
@@ -72,34 +103,50 @@ export interface RestErrorEnvelope {
|
|
|
72
103
|
readonly code?: string | number;
|
|
73
104
|
readonly message?: string;
|
|
74
105
|
}
|
|
75
|
-
|
|
106
|
+
/**
|
|
107
|
+
* What this module's own code fails with, whatever the options: the errors
|
|
108
|
+
* every REST protocol declares. A label that would address another resource
|
|
109
|
+
* (`InvalidInput`), a request it can't build or an operation it can't
|
|
110
|
+
* stream (`SdkError`), the transport or a body read (`HttpClientError`), and
|
|
111
|
+
* a 5xx response that neither the operation nor its service declares
|
|
112
|
+
* (`InternalServerError`, which the retry policy retries).
|
|
113
|
+
*/
|
|
114
|
+
export type RestProtocolError = InvalidInput | SdkError | HttpClientError.HttpClientError | InternalServerError;
|
|
115
|
+
/**
|
|
116
|
+
* Options of {@link restProtocol}. The type parameters after `Credentials`
|
|
117
|
+
* are what each option fails with or reads; `restProtocol` infers them from
|
|
118
|
+
* the options, and they are the errors its protocol declares.
|
|
119
|
+
*/
|
|
120
|
+
export interface RestProtocolOptions<Credentials, CredentialsError, CredentialsRequirements, RouteError, ClassifiedError, UnknownError, ParseError> {
|
|
76
121
|
/**
|
|
77
|
-
* Resolve credentials ON THE CALLING FIBER -- evaluated per request,
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
* erased at the protocol boundary (Protocol effects carry none) and
|
|
85
|
-
* reintroduced for callers by the generated `<Sdk>OpError` /
|
|
86
|
-
* `<Sdk>OpContext` annotations.
|
|
122
|
+
* Resolve credentials ON THE CALLING FIBER -- evaluated per request, so
|
|
123
|
+
* context-provided credentials and token refreshes are picked up. Either
|
|
124
|
+
* an effect, or -- for the distilled credentials-service convention --
|
|
125
|
+
* the `Credentials` service key whose value is that effect (read from the calling fiber's context; an
|
|
126
|
+
* already-resolved `Effect.succeed` value costs no extra fiber step). What
|
|
127
|
+
* it fails with (declared on the credentials) reaches every operation
|
|
128
|
+
* through the protocol, and what it reads is the protocol's requirement.
|
|
87
129
|
*/
|
|
88
|
-
readonly credentials: Effect.Effect<
|
|
130
|
+
readonly credentials: Effect.Effect<Credentials, CredentialsError, CredentialsRequirements> | Context.Key<CredentialsRequirements, Effect.Effect<Credentials, CredentialsError>>;
|
|
89
131
|
/**
|
|
90
132
|
* API base URL from the resolved credentials. Receives the operation's
|
|
91
133
|
* route so APIs with more than one endpoint (e.g. S2's account vs
|
|
92
134
|
* per-basin hosts, chosen by path) can route per request; single-endpoint
|
|
93
|
-
* providers ignore the argument.
|
|
94
|
-
*
|
|
95
|
-
*
|
|
135
|
+
* providers ignore the argument. `server` is the operation's host name
|
|
136
|
+
* (`T.Http({ server })`) for APIs that serve some operations from another
|
|
137
|
+
* host; map it to a base URL from the credentials. To refuse a route (e.g.
|
|
138
|
+
* a required scope missing from the credentials), return `Effect.fail` of
|
|
139
|
+
* the error the call fails with. A THROWN error fails the call with
|
|
140
|
+
* `SdkError`, as anything thrown under a call does (the defect boundary,
|
|
141
|
+
* `./api.ts`).
|
|
96
142
|
*/
|
|
97
|
-
readonly baseUrl: (credentials:
|
|
143
|
+
readonly baseUrl: (credentials: Credentials, target: {
|
|
98
144
|
readonly uri: string;
|
|
99
145
|
readonly method: string;
|
|
100
|
-
|
|
146
|
+
readonly server?: string | undefined;
|
|
147
|
+
}) => string | Effect.Effect<never, RouteError>;
|
|
101
148
|
/** Auth (and any fixed) headers from the resolved credentials. */
|
|
102
|
-
readonly headers: (credentials:
|
|
149
|
+
readonly headers: (credentials: Credentials) => Record<string, string>;
|
|
103
150
|
/**
|
|
104
151
|
* Extract `{ code?, message? }` from a parsed non-2xx JSON body. Default:
|
|
105
152
|
* lenient `{ code?, message? | error? }` (covers the common REST error
|
|
@@ -107,26 +154,26 @@ export interface RestProtocolOptions<C> {
|
|
|
107
154
|
*/
|
|
108
155
|
readonly errorEnvelope?: (body: unknown) => RestErrorEnvelope | undefined;
|
|
109
156
|
/**
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
*
|
|
157
|
+
* JSON pointer to the object that holds a failure's fields when the
|
|
158
|
+
* provider nests them, e.g. `"/error"` for `{ error: { status, details } }`.
|
|
159
|
+
* A typed error's declared fields are read there first, then at the top
|
|
160
|
+
* level of the body.
|
|
114
161
|
*/
|
|
115
|
-
readonly
|
|
162
|
+
readonly errorFieldsAt?: string;
|
|
116
163
|
/**
|
|
117
|
-
* The provider's own reading of a failure, consulted before
|
|
118
|
-
*
|
|
164
|
+
* The provider's own reading of a failure, consulted before the classes
|
|
165
|
+
* the operation and its service declare: return the error to fail with, or
|
|
119
166
|
* `undefined` to decode the failure as usual. For rules a status alone
|
|
120
167
|
* can't express, e.g. a 403 that is a rate limit because of its headers.
|
|
121
168
|
*/
|
|
122
|
-
readonly classifyError?: (info: RestErrorInfo) =>
|
|
169
|
+
readonly classifyError?: (info: RestErrorInfo) => ClassifiedError | undefined;
|
|
123
170
|
/**
|
|
124
171
|
* Fallback error for failures nothing else matched: the SDK's
|
|
125
172
|
* `Unknown<Sdk>Error`, built from {@link unknownErrorProps}. Only non-5xx
|
|
126
|
-
* statuses reach it (
|
|
127
|
-
* carries no retryable category.
|
|
173
|
+
* statuses reach it (an undeclared 5xx is `InternalServerError`), so the
|
|
174
|
+
* class carries no retryable category.
|
|
128
175
|
*/
|
|
129
|
-
readonly unknownError: (info: RestErrorInfo) =>
|
|
176
|
+
readonly unknownError: (info: RestErrorInfo) => UnknownError;
|
|
130
177
|
/**
|
|
131
178
|
* The SDK's `<Sdk>ParseError`, raised when a 2xx body does not match the
|
|
132
179
|
* operation's output schema in strict mode (see
|
|
@@ -136,7 +183,7 @@ export interface RestProtocolOptions<C> {
|
|
|
136
183
|
* with sensitive members; `cause` is the schema error, or `"Invalid JSON
|
|
137
184
|
* response"`.
|
|
138
185
|
*/
|
|
139
|
-
readonly parseError: (info: RestParseErrorInfo) =>
|
|
186
|
+
readonly parseError: (info: RestParseErrorInfo) => ParseError;
|
|
140
187
|
/** Transform the parsed 2xx JSON before decoding (e.g. stripNulls). */
|
|
141
188
|
readonly transformResponse?: (body: unknown) => unknown;
|
|
142
189
|
/** Passed through to `buildRequest` (member-header transforms). */
|
|
@@ -146,6 +193,43 @@ export interface RestProtocolOptions<C> {
|
|
|
146
193
|
/** Passed through to `buildRequest`: send `{}` when a bodied call has no body members. */
|
|
147
194
|
readonly emptyJsonBody?: boolean;
|
|
148
195
|
}
|
|
196
|
+
/**
|
|
197
|
+
* The body of a streamed 2xx response, for {@link StreamFraming.stream}.
|
|
198
|
+
* `Failure` is what the call fails with.
|
|
199
|
+
*/
|
|
200
|
+
export interface FramedBody<Failure> {
|
|
201
|
+
readonly body: Stream.Stream<Uint8Array, Failure>;
|
|
202
|
+
/**
|
|
203
|
+
* Decode one parsed frame as one element of the output's `items`, as a
|
|
204
|
+
* 2xx body decodes (key mapping, strict validation, `Redacted`).
|
|
205
|
+
*/
|
|
206
|
+
readonly item: (json: unknown, text: string) => Effect.Effect<unknown, Failure>;
|
|
207
|
+
/** The SDK's parse error for a frame that is not JSON. */
|
|
208
|
+
readonly invalid: (text: string) => Failure;
|
|
209
|
+
}
|
|
210
|
+
/** A plain call's framed body, read whole: the output JSON, or not JSON. */
|
|
211
|
+
export interface CollectedBody {
|
|
212
|
+
readonly json: unknown;
|
|
213
|
+
readonly nonJson: boolean;
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* How a server-streaming operation's body is framed (`API.makeStreaming`,
|
|
217
|
+
* output `{ items }`): its `framing` config, e.g. `ndjson` from
|
|
218
|
+
* core/ndjson. An operation without one can't stream (`.stream()` fails
|
|
219
|
+
* with `SdkError`, see `API.cannotStream`).
|
|
220
|
+
*/
|
|
221
|
+
export interface StreamFraming {
|
|
222
|
+
/**
|
|
223
|
+
* A plain call's whole body as `{ items }`, or `undefined` when the
|
|
224
|
+
* response's `Content-Type` is not this framing (decoded as usual).
|
|
225
|
+
*/
|
|
226
|
+
readonly collect: (text: string, contentType: string | undefined) => CollectedBody | undefined;
|
|
227
|
+
/**
|
|
228
|
+
* Each frame as it arrives, through `item`. `open` sends the request and
|
|
229
|
+
* fails with the operation's typed error on a failed status.
|
|
230
|
+
*/
|
|
231
|
+
readonly stream: <Failure, Requirements>(open: Effect.Effect<FramedBody<Failure>, Failure, Requirements>) => Stream.Stream<unknown, Failure, Requirements>;
|
|
232
|
+
}
|
|
149
233
|
/** A 2xx body a protocol read, for {@link checkSuccess}. */
|
|
150
234
|
export interface SuccessBody {
|
|
151
235
|
/** The value to check and return: the body mapped onto the output's TS names. */
|
|
@@ -186,9 +270,49 @@ export declare const checkSuccess: (context: Context.Context<any>, outputAst: AS
|
|
|
186
270
|
*/
|
|
187
271
|
export declare const validateSuccess: <E>(outputAst: AST.AST, read: SuccessBody, parseError: (info: RestParseErrorInfo) => E) => Effect.Effect<unknown, E>;
|
|
188
272
|
/**
|
|
189
|
-
*
|
|
190
|
-
*
|
|
191
|
-
*
|
|
273
|
+
* Read a 2xx response of a binary output ({@link BinaryResponse}) as a
|
|
274
|
+
* {@link BinaryStream}: the stream itself for a binary whole output, or the
|
|
275
|
+
* structure with the stream in its body member and its header members
|
|
276
|
+
* filled. `undefined` when the output is not binary. The call returns once
|
|
277
|
+
* the headers arrive; a body read that fails later (reset or abort
|
|
278
|
+
* mid-body) fails the stream with its `HttpClientError`. For hand-written
|
|
279
|
+
* protocols too, so every SDK decodes a download the same way.
|
|
280
|
+
*/
|
|
281
|
+
export declare const readBinaryResponse: (response: HttpClientResponse.HttpClientResponse, outputAst: AST.AST) => Effect.Effect<unknown> | undefined;
|
|
282
|
+
/**
|
|
283
|
+
* The class core has for `status`, when the operation or its service
|
|
284
|
+
* declares it: a list of declared errors can hold core's status classes
|
|
285
|
+
* (`Unauthorized`, `TooManyRequests`, ...), which are matched by status.
|
|
286
|
+
* For a protocol that reads failed responses itself.
|
|
287
|
+
*/
|
|
288
|
+
export declare const declaredStatusClass: (status: number, declared: ReadonlyArray<DeclaredErrorClass>) => DeclaredErrorClass | undefined;
|
|
289
|
+
/**
|
|
290
|
+
* The methods of {@link restProtocol}, for either form of `credentials`.
|
|
291
|
+
* For the protocols core builds on them (core/protocol-grpc).
|
|
292
|
+
*/
|
|
293
|
+
export declare const restProtocolMethods: <Credentials, CredentialsError = never, CredentialsRequirements = never, RouteError = never, ClassifiedError = never, UnknownError = never, ParseError = never>(options: RestProtocolOptions<Credentials, CredentialsError, CredentialsRequirements, RouteError, ClassifiedError, UnknownError, ParseError>) => Protocol<CredentialsError | RouteError | ClassifiedError | UnknownError | ParseError | RestProtocolError, CredentialsRequirements>;
|
|
294
|
+
/**
|
|
295
|
+
* {@link restProtocol}'s options for one form of `credentials`. The service
|
|
296
|
+
* key and the effect are separate signatures: a key is also an effect (of
|
|
297
|
+
* the service), so one signature for both could not tell which it is given.
|
|
298
|
+
*/
|
|
299
|
+
type TypedRestOptions<CredentialsSource, Credentials, RouteError, ClassifiedError, UnknownError, ParseError> = Omit<RestProtocolOptions<Credentials, never, never, RouteError, ClassifiedError, UnknownError, ParseError>, "credentials"> & {
|
|
300
|
+
/** See {@link RestProtocolOptions.credentials}. */
|
|
301
|
+
readonly credentials: CredentialsSource;
|
|
302
|
+
};
|
|
303
|
+
/**
|
|
304
|
+
* The protocol for a simple REST JSON API (core/protocol). Assign the
|
|
305
|
+
* result to a module-level const in the provider's `protocol.ts`:
|
|
306
|
+
*
|
|
307
|
+
* export const NeonProtocol = restProtocol({ ... });
|
|
308
|
+
*
|
|
309
|
+
* A failed response becomes, in this order: what `classifyError` returns, a
|
|
310
|
+
* class the operation or its service declares (by its matchers, or by status
|
|
311
|
+
* for one of core's status classes), `InternalServerError` for any other
|
|
312
|
+
* 5xx, and `unknownError` for the rest. The protocol declares what the
|
|
313
|
+
* options and {@link RestProtocolError} fail with: the result's type lists
|
|
314
|
+
* them, so no SDK writes that list by hand.
|
|
192
315
|
*/
|
|
193
|
-
export declare
|
|
316
|
+
export declare function restProtocol<Credentials, CredentialsError = never, CredentialsRequirements = never, RouteError = never, ClassifiedError = never, UnknownError = never, ParseError = never>(options: TypedRestOptions<Context.Key<CredentialsRequirements, Effect.Effect<Credentials, CredentialsError>>, Credentials, RouteError, ClassifiedError, UnknownError, ParseError>): Protocol<CredentialsError | RouteError | ClassifiedError | UnknownError | ParseError | RestProtocolError, CredentialsRequirements>;
|
|
317
|
+
export declare function restProtocol<Credentials, CredentialsError = never, CredentialsRequirements = never, RouteError = never, ClassifiedError = never, UnknownError = never, ParseError = never>(options: TypedRestOptions<Effect.Effect<Credentials, CredentialsError, CredentialsRequirements>, Credentials, RouteError, ClassifiedError, UnknownError, ParseError>): Protocol<CredentialsError | RouteError | ClassifiedError | UnknownError | ParseError | RestProtocolError, CredentialsRequirements>;
|
|
194
318
|
//# sourceMappingURL=protocol-rest.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protocol-rest.d.ts","
|
|
1
|
+
{"version":3,"file":"protocol-rest.d.ts","sources":["../src/protocol-rest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,KAAK,KAAK,eAAe,MAAM,6BAA6B,CAAC;AAEpE,OAAO,KAAK,KAAK,kBAAkB,MAAM,gCAAgC,CAAC;AAC1E,OAAO,KAAK,KAAK,MAAM,MAAM,eAAe,CAAC;AAC7C,OAAO,KAAK,KAAK,GAAG,MAAM,kBAAkB,CAAC;AAC7C,OAAO,KAAK,KAAK,MAAM,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,qBAAqB,EAAe,MAAM,kBAAkB,CAAC;AAEtE,OAAO,EAAmB,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAEnE,OAAO,EAAkB,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvE,OAAO,EAaL,KAAK,YAAY,EAElB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAKV,kBAAkB,EAClB,QAAQ,EACT,MAAM,eAAe,CAAC;AAIvB,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,OAAO,EAAkB,oBAAoB,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAA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ACL,UAAU,EACV,eAAe,EACf,YAAY,EACZ,UAAU,CACX,EACD,aAAa,CACd,GAAG;IACF,mDAAmD;IACnD,QAAQ,CAAC,WAAW,EAAE,iBAAiB,CAAC;CACzC,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,wBAAgB,YAAY,CAC1B,WAAW,EACX,gBAAgB,GAAG,KAAK,EACxB,uBAAuB,GAAG,KAAK,EAC/B,UAAU,GAAG,KAAK,EAClB,eAAe,GAAG,KAAK,EACvB,YAAY,GAAG,KAAK,EACpB,UAAU,GAAG,KAAK,EAElB,OAAO,EAAE,gBAAgB,CACvB,OAAO,CAAC,GAAG,CAAC,uBAAuB,EAAE,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE,gBAAgB,CAAC,CAAC,EAClF,WAAW,EACX,UAAU,EACV,eAAe,EACf,YAAY,EACZ,UAAU,CACX,GACA,QAAQ,CACT,gBAAgB,GAAG,UAAU,GAAG,eAAe,GAAG,YAAY,GAAG,UAAU,GAAG,iBAAiB,EAC/F,uBAAuB,CACxB,CAAC;AACF,wBAAgB,YAAY,CAC1B,WAAW,EACX,gBAAgB,GAAG,KAAK,EACxB,uBAAuB,GAAG,KAAK,EAC/B,UAAU,GAAG,KAAK,EAClB,eAAe,GAAG,KAAK,EACvB,YAAY,GAAG,KAAK,EACpB,UAAU,GAAG,KAAK,EAElB,OAAO,EAAE,gBAAgB,CACvB,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE,gBAAgB,EAAE,uBAAuB,CAAC,EACrE,WAAW,EACX,UAAU,EACV,eAAe,EACf,YAAY,EACZ,UAAU,CACX,GACA,QAAQ,CACT,gBAAgB,GAAG,UAAU,GAAG,eAAe,GAAG,YAAY,GAAG,UAAU,GAAG,iBAAiB,EAC/F,uBAAuB,CACxB,CAAC"}
|
package/lib/protocol-rest.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { protocol_rest$BinaryResponse as BinaryResponse, protocol_rest$RawResponse as RawResponse, protocol_rest$RawResponseRoot as RawResponseRoot, protocol_rest$SensitiveValue as SensitiveValue, protocol_rest$binaryResponseSymbol as binaryResponseSymbol, protocol_rest$checkSuccess as checkSuccess, protocol_rest$
|
|
1
|
+
export { protocol_rest$BinaryResponse as BinaryResponse, protocol_rest$BinaryStream as BinaryStream, protocol_rest$RawBody as RawBody, protocol_rest$RawResponse as RawResponse, protocol_rest$RawResponseRoot as RawResponseRoot, protocol_rest$SensitiveValue as SensitiveValue, protocol_rest$binaryResponseSymbol as binaryResponseSymbol, protocol_rest$checkSuccess as checkSuccess, protocol_rest$declaredStatusClass as declaredStatusClass, protocol_rest$hasSensitiveMember as hasSensitiveMember, protocol_rest$rawResponseRootSymbol as rawResponseRootSymbol, protocol_rest$rawResponseSymbol as rawResponseSymbol, protocol_rest$readBinaryResponse as readBinaryResponse, protocol_rest$restProtocol as restProtocol, protocol_rest$restProtocolMethods as restProtocolMethods, protocol_rest$sensitiveValueSymbol as sensitiveValueSymbol, protocol_rest$unknownErrorProps as unknownErrorProps, protocol_rest$unwrapRedactedDeep as unwrapRedactedDeep, protocol_rest$validateSuccess as validateSuccess, protocol_rest$wrapSensitive as wrapSensitive } from "./_bundle/rest.js";
|