@distilled.cloud/core 1.0.0-rc.17 → 1.0.0-rc.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/_bundle/base.js +2 -2
- package/lib/_bundle/base.js.map +1 -1
- package/lib/_bundle/graphql.js +2 -2
- package/lib/_bundle/graphql.js.map +1 -1
- package/lib/_bundle/grpc.js +2 -0
- package/lib/_bundle/grpc.js.map +1 -0
- package/lib/_bundle/rest.js +1 -1
- package/lib/_bundle/rest.js.map +1 -1
- package/lib/_bundle/xml.js +1 -1
- package/lib/_bundle/xml.js.map +1 -1
- 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 +52 -1
- package/lib/api.d.ts.map +1 -1
- package/lib/api.js +1 -1
- package/lib/category.d.ts.map +1 -1
- package/lib/config.d.ts +54 -13
- package/lib/config.d.ts.map +1 -1
- package/lib/config.js +1 -1
- package/lib/error-category.d.ts.map +1 -1
- package/lib/errors.d.ts +3 -13
- package/lib/errors.d.ts.map +1 -1
- package/lib/errors.js +1 -1
- package/lib/graphql.d.ts +26 -5
- package/lib/graphql.d.ts.map +1 -1
- package/lib/graphql.types.d.ts.map +1 -1
- 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 +76 -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 +6 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +4 -0
- package/lib/pagination.d.ts +55 -3
- package/lib/pagination.d.ts.map +1 -1
- package/lib/pagination.js +1 -1
- package/lib/protobuf.d.ts +92 -0
- package/lib/protobuf.d.ts.map +1 -0
- package/lib/protobuf.js +1 -0
- package/lib/protocol-grpc.d.ts +86 -0
- package/lib/protocol-grpc.d.ts.map +1 -0
- package/lib/protocol-grpc.js +1 -0
- package/lib/protocol-http.d.ts +38 -9
- package/lib/protocol-http.d.ts.map +1 -1
- package/lib/protocol-http.js +1 -1
- package/lib/protocol-rest.d.ts +60 -42
- package/lib/protocol-rest.d.ts.map +1 -1
- package/lib/protocol-rest.js +1 -1
- package/lib/response-validation.d.ts +5 -4
- package/lib/response-validation.d.ts.map +1 -1
- package/lib/schema-lite-typed.js +1 -2
- package/lib/sdk-error.d.ts +27 -0
- package/lib/sdk-error.d.ts.map +1 -0
- package/lib/sdk-error.js +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 +288 -0
- package/lib/telemetry.d.ts.map +1 -0
- package/lib/telemetry.js +3 -0
- package/lib/telemetry.js.map +1 -0
- package/lib/trait.d.ts +7 -0
- package/lib/trait.d.ts.map +1 -1
- package/lib/trait.js +1 -1
- package/lib/xml.d.ts.map +1 -1
- package/package.json +3 -5
- package/src/annotations.ts +53 -0
- package/src/api.ts +316 -43
- package/src/category.ts +21 -22
- package/src/config.ts +58 -29
- package/src/error-category.ts +12 -14
- package/src/errors.ts +11 -7
- package/src/graphql.ts +191 -63
- package/src/graphql.types.ts +5 -1
- package/src/grpc-transport-cloudflare-http2.ts +494 -0
- package/src/grpc-transport-cloudflare-sockets.ts +299 -0
- package/src/grpc-transport-node-http2.ts +234 -0
- package/src/grpc-transport.ts +118 -0
- package/src/hpack.ts +331 -0
- package/src/index.ts +6 -2
- package/src/pagination.ts +193 -8
- package/src/protobuf.ts +1332 -0
- package/src/protocol-grpc.ts +641 -0
- package/src/protocol-http.ts +87 -67
- package/src/protocol-rest.ts +183 -191
- package/src/response-validation.ts +8 -5
- package/src/sdk-error.ts +33 -0
- package/src/sensitive.ts +154 -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 +832 -0
- package/src/trait.ts +10 -0
- package/src/xml.ts +10 -1
- package/lib/codegen/boolean-string-enums.d.ts +0 -36
- package/lib/codegen/boolean-string-enums.d.ts.map +0 -1
- package/lib/codegen/boolean-string-enums.js +0 -147
- package/lib/codegen/boolean-string-enums.js.map +0 -1
- package/lib/codegen/chunk.d.ts +0 -7
- package/lib/codegen/chunk.d.ts.map +0 -1
- package/lib/codegen/chunk.js +0 -139
- package/lib/codegen/chunk.js.map +0 -1
- package/lib/codegen/cli.d.ts +0 -80
- package/lib/codegen/cli.d.ts.map +0 -1
- package/lib/codegen/cli.js +0 -166
- package/lib/codegen/cli.js.map +0 -1
- package/lib/codegen/datafy.d.ts +0 -14
- package/lib/codegen/datafy.d.ts.map +0 -1
- package/lib/codegen/datafy.js +0 -853
- package/lib/codegen/datafy.js.map +0 -1
- package/lib/codegen/dedupe.d.ts +0 -5
- package/lib/codegen/dedupe.d.ts.map +0 -1
- package/lib/codegen/dedupe.js +0 -153
- package/lib/codegen/dedupe.js.map +0 -1
- package/lib/codegen/emit.d.ts +0 -125
- package/lib/codegen/emit.d.ts.map +0 -1
- package/lib/codegen/emit.js +0 -99
- package/lib/codegen/emit.js.map +0 -1
- package/lib/codegen/format.d.ts +0 -11
- package/lib/codegen/format.d.ts.map +0 -1
- package/lib/codegen/format.js +0 -32
- package/lib/codegen/format.js.map +0 -1
- package/lib/codegen/generated-at.d.ts +0 -29
- package/lib/codegen/generated-at.d.ts.map +0 -1
- package/lib/codegen/generated-at.js +0 -78
- package/lib/codegen/generated-at.js.map +0 -1
- package/lib/codegen/generator.d.ts +0 -353
- package/lib/codegen/generator.d.ts.map +0 -1
- package/lib/codegen/generator.js +0 -810
- package/lib/codegen/generator.js.map +0 -1
- package/lib/codegen/graph.d.ts +0 -36
- package/lib/codegen/graph.d.ts.map +0 -1
- package/lib/codegen/graph.js +0 -136
- package/lib/codegen/graph.js.map +0 -1
- package/lib/codegen/graphql-client.d.ts +0 -70
- package/lib/codegen/graphql-client.d.ts.map +0 -1
- package/lib/codegen/graphql-client.js +0 -439
- package/lib/codegen/graphql-client.js.map +0 -1
- package/lib/codegen/graphql.d.ts +0 -207
- package/lib/codegen/graphql.d.ts.map +0 -1
- package/lib/codegen/graphql.js +0 -786
- package/lib/codegen/graphql.js.map +0 -1
- package/lib/codegen/latin1.d.ts +0 -3
- package/lib/codegen/latin1.d.ts.map +0 -1
- package/lib/codegen/latin1.js +0 -126
- package/lib/codegen/latin1.js.map +0 -1
- package/lib/codegen/members.d.ts +0 -32
- package/lib/codegen/members.d.ts.map +0 -1
- package/lib/codegen/members.js +0 -62
- package/lib/codegen/members.js.map +0 -1
- package/lib/codegen/model-diff.d.ts +0 -10
- package/lib/codegen/model-diff.d.ts.map +0 -1
- package/lib/codegen/model-diff.js +0 -67
- package/lib/codegen/model-diff.js.map +0 -1
- package/lib/codegen/naming.d.ts +0 -29
- package/lib/codegen/naming.d.ts.map +0 -1
- package/lib/codegen/naming.js +0 -74
- package/lib/codegen/naming.js.map +0 -1
- package/lib/codegen/openapi-cli.d.ts +0 -52
- package/lib/codegen/openapi-cli.d.ts.map +0 -1
- package/lib/codegen/openapi-cli.js +0 -84
- package/lib/codegen/openapi-cli.js.map +0 -1
- package/lib/codegen/openapi.d.ts +0 -209
- package/lib/codegen/openapi.d.ts.map +0 -1
- package/lib/codegen/openapi.js +0 -1548
- package/lib/codegen/openapi.js.map +0 -1
- package/lib/codegen/operations.d.ts +0 -24
- package/lib/codegen/operations.d.ts.map +0 -1
- package/lib/codegen/operations.js +0 -56
- package/lib/codegen/operations.js.map +0 -1
- package/lib/codegen/pagination.d.ts +0 -39
- package/lib/codegen/pagination.d.ts.map +0 -1
- package/lib/codegen/pagination.js +0 -31
- package/lib/codegen/pagination.js.map +0 -1
- package/lib/codegen/patch-audit.d.ts +0 -84
- package/lib/codegen/patch-audit.d.ts.map +0 -1
- package/lib/codegen/patch-audit.js +0 -366
- package/lib/codegen/patch-audit.js.map +0 -1
- package/lib/codegen/patches.d.ts +0 -129
- package/lib/codegen/patches.d.ts.map +0 -1
- package/lib/codegen/patches.js +0 -472
- package/lib/codegen/patches.js.map +0 -1
- package/lib/codegen/prelude.d.ts +0 -15
- package/lib/codegen/prelude.d.ts.map +0 -1
- package/lib/codegen/prelude.js +0 -60
- package/lib/codegen/prelude.js.map +0 -1
- package/lib/codegen/privatize.d.ts +0 -21
- package/lib/codegen/privatize.d.ts.map +0 -1
- package/lib/codegen/privatize.js +0 -176
- package/lib/codegen/privatize.js.map +0 -1
- package/lib/codegen/proto.d.ts +0 -121
- package/lib/codegen/proto.d.ts.map +0 -1
- package/lib/codegen/proto.js +0 -960
- package/lib/codegen/proto.js.map +0 -1
- package/lib/codegen/pure.d.ts +0 -6
- package/lib/codegen/pure.d.ts.map +0 -1
- package/lib/codegen/pure.js +0 -91
- package/lib/codegen/pure.js.map +0 -1
- package/lib/codegen/rewrite-operation-ids.d.ts +0 -154
- package/lib/codegen/rewrite-operation-ids.d.ts.map +0 -1
- package/lib/codegen/rewrite-operation-ids.js +0 -1117
- package/lib/codegen/rewrite-operation-ids.js.map +0 -1
- package/lib/codegen/spec-path.d.ts +0 -16
- package/lib/codegen/spec-path.d.ts.map +0 -1
- package/lib/codegen/spec-path.js +0 -101
- package/lib/codegen/spec-path.js.map +0 -1
- package/lib/codegen/table.d.ts +0 -5
- package/lib/codegen/table.d.ts.map +0 -1
- package/lib/codegen/table.js +0 -249
- package/lib/codegen/table.js.map +0 -1
- package/lib/debug.d.ts +0 -2
- package/lib/debug.d.ts.map +0 -1
- package/lib/debug.js +0 -1
- package/lib/json-patch.d.ts +0 -58
- package/lib/json-patch.d.ts.map +0 -1
- package/lib/json-patch.js +0 -2
- package/lib/json-patch.js.map +0 -1
- package/lib/schema-lite-typed.js.map +0 -1
- package/lib/testing.d.ts +0 -40
- package/lib/testing.d.ts.map +0 -1
- package/lib/testing.js +0 -2
- package/lib/testing.js.map +0 -1
- package/src/codegen/boolean-string-enums.ts +0 -155
- package/src/codegen/chunk.ts +0 -147
- package/src/codegen/cli.ts +0 -293
- package/src/codegen/datafy.ts +0 -874
- package/src/codegen/dedupe.ts +0 -173
- package/src/codegen/emit.ts +0 -200
- package/src/codegen/format.ts +0 -49
- package/src/codegen/generated-at.ts +0 -88
- package/src/codegen/generator.ts +0 -1229
- package/src/codegen/graph.ts +0 -151
- package/src/codegen/graphql-client.ts +0 -545
- package/src/codegen/graphql.ts +0 -1145
- package/src/codegen/latin1.ts +0 -131
- package/src/codegen/members.ts +0 -79
- package/src/codegen/model-diff.ts +0 -67
- package/src/codegen/naming.ts +0 -85
- package/src/codegen/openapi-cli.ts +0 -141
- package/src/codegen/openapi.ts +0 -1845
- package/src/codegen/operations.ts +0 -73
- package/src/codegen/pagination.ts +0 -64
- package/src/codegen/patch-audit.ts +0 -480
- package/src/codegen/patches.ts +0 -581
- package/src/codegen/prelude.ts +0 -70
- package/src/codegen/privatize.ts +0 -200
- package/src/codegen/proto.ts +0 -1092
- package/src/codegen/pure.ts +0 -94
- package/src/codegen/rewrite-operation-ids.ts +0 -1219
- package/src/codegen/spec-path.ts +0 -112
- package/src/codegen/table.ts +0 -254
- package/src/debug.ts +0 -8
- package/src/json-patch.ts +0 -273
- package/src/testing.ts +0 -74
package/lib/pagination.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as Context from "effect/Context";
|
|
1
2
|
import * as Effect from "effect/Effect";
|
|
2
3
|
import * as Stream from "effect/Stream";
|
|
3
4
|
/**
|
|
@@ -21,10 +22,17 @@ export declare const getItems: (obj: unknown, path: string) => readonly unknown[
|
|
|
21
22
|
/** Pagination trait describing how to navigate between pages. */
|
|
22
23
|
export interface PaginatedTrait {
|
|
23
24
|
/** Pagination strategy */
|
|
24
|
-
readonly mode?: "token" | "page" | "cursor" | "relay" | "single";
|
|
25
|
-
/**
|
|
25
|
+
readonly mode?: "token" | "page" | "cursor" | "relay" | "link" | "keyset" | "single";
|
|
26
|
+
/**
|
|
27
|
+
* The name of the input member containing the page/cursor token. In link
|
|
28
|
+
* mode it is also the query parameter read from the `rel="next"` URL.
|
|
29
|
+
*/
|
|
26
30
|
readonly inputToken?: string;
|
|
27
|
-
/**
|
|
31
|
+
/**
|
|
32
|
+
* The path to the output member containing the next page/cursor token. In
|
|
33
|
+
* keyset mode it is a path within one item: the key the next page starts
|
|
34
|
+
* after.
|
|
35
|
+
*/
|
|
28
36
|
readonly outputToken?: string;
|
|
29
37
|
/**
|
|
30
38
|
* The path to the output member containing the paginated items. Segments
|
|
@@ -43,6 +51,13 @@ export interface PaginatedTrait {
|
|
|
43
51
|
readonly hasNextPage?: string;
|
|
44
52
|
}
|
|
45
53
|
export type PaginationStrategy = <Input extends Record<string, unknown>, Output, E, R>(operation: (input: Input) => Effect.Effect<Output, E, R>, input: Input, pagination: PaginatedTrait) => Stream.Stream<Output, E, R>;
|
|
54
|
+
/**
|
|
55
|
+
* The stream of a paginated operation whose trait lacks a field its
|
|
56
|
+
* strategy reads: it fails with {@link SdkError} (part of every
|
|
57
|
+
* operation's error channel, so the strategy's `E` is cast to hold it).
|
|
58
|
+
* The generator refuses such traits.
|
|
59
|
+
*/
|
|
60
|
+
export declare const missingPaginationConfig: (message: string) => Stream.Stream<never>;
|
|
46
61
|
/**
|
|
47
62
|
* Whether a continuation token/cursor returned by a paginated operation
|
|
48
63
|
* means "no more pages".
|
|
@@ -76,6 +91,15 @@ export declare const paginateCursor: <Input extends Record<string, unknown>, Out
|
|
|
76
91
|
* `inputToken` until it comes back absent.
|
|
77
92
|
*/
|
|
78
93
|
export declare const paginateToken: <Input extends Record<string, unknown>, Output, E, R>(operation: (input: Input) => Effect.Effect<Output, E, R>, input: Input, pagination: PaginatedTrait) => Stream.Stream<Output, E, R>;
|
|
94
|
+
/**
|
|
95
|
+
* Stream of pages using keyset pagination: the next request starts after
|
|
96
|
+
* the key of the page's last item. `inputToken` is the input member the key
|
|
97
|
+
* goes to and `outputToken` the key's path within an item (both may be
|
|
98
|
+
* dot-separated: Modal's `List*` calls take `pagination.createdBefore` and
|
|
99
|
+
* key on each item's `createdAt`). Traversal ends on an empty page, a page
|
|
100
|
+
* smaller than the requested `pageSize`, or a key that doesn't advance.
|
|
101
|
+
*/
|
|
102
|
+
export declare const paginateKeyset: <Input extends Record<string, unknown>, Output, E, R>(operation: (input: Input) => Effect.Effect<Output, E, R>, input: Input, pagination: PaginatedTrait) => Stream.Stream<Output, E, R>;
|
|
79
103
|
/**
|
|
80
104
|
* Stream of pages over a Relay connection -- pass `pageInfo.endCursor` back as
|
|
81
105
|
* `after` for as long as `pageInfo.hasNextPage` is true.
|
|
@@ -89,6 +113,29 @@ export declare const paginateToken: <Input extends Record<string, unknown>, Outp
|
|
|
89
113
|
* terminates, so a malformed response can't spin forever.
|
|
90
114
|
*/
|
|
91
115
|
export declare const paginateRelay: <Input extends Record<string, unknown>, Output, E, R>(operation: (input: Input) => Effect.Effect<Output, E, R>, input: Input, pagination: PaginatedTrait) => Stream.Stream<Output, E, R>;
|
|
116
|
+
/**
|
|
117
|
+
* Hand a response's headers to the link traversal running on this fiber, if
|
|
118
|
+
* any. Protocols call it for every response they decode; outside
|
|
119
|
+
* {@link paginateLink} it does nothing.
|
|
120
|
+
*/
|
|
121
|
+
export declare const recordPageHeaders: (context: Context.Context<never>, headers: Readonly<Record<string, string | undefined>>) => void;
|
|
122
|
+
/**
|
|
123
|
+
* The URL of the `rel="next"` link in a `Link` header value, e.g.
|
|
124
|
+
* `<https://api.github.com/repositories/1/issues?page=2>; rel="next", <...>; rel="last"`.
|
|
125
|
+
*/
|
|
126
|
+
export declare const nextLink: (header: string | undefined) => string | undefined;
|
|
127
|
+
/**
|
|
128
|
+
* Stream of pages that follows the `Link` response header: each request
|
|
129
|
+
* takes `inputToken` from the query of the previous response's `rel="next"`
|
|
130
|
+
* URL, and traversal ends when a response has no next link (or its token
|
|
131
|
+
* repeats the current one). The response body carries no token, so this
|
|
132
|
+
* works for APIs whose list responses are bare arrays.
|
|
133
|
+
*
|
|
134
|
+
* The protocol must report response headers through
|
|
135
|
+
* {@link recordPageHeaders} (the REST protocol does); otherwise traversal
|
|
136
|
+
* stops after the first page.
|
|
137
|
+
*/
|
|
138
|
+
export declare const paginateLink: <Input extends Record<string, unknown>, Output, E, R>(operation: (input: Input) => Effect.Effect<Output, E, R>, input: Input, pagination: PaginatedTrait) => Stream.Stream<Output, E, R>;
|
|
92
139
|
/**
|
|
93
140
|
* Shared default pagination dispatcher for SDKs that use generic
|
|
94
141
|
* token/cursor/page traversal.
|
|
@@ -103,4 +150,9 @@ export declare const paginateWithDefaults: PaginationStrategy;
|
|
|
103
150
|
* @returns A Stream of individual items
|
|
104
151
|
*/
|
|
105
152
|
export declare const extractItems: <Output, Item, E, R>(pages: Stream.Stream<Output, E, R>, itemsPath: string) => Stream.Stream<Item, E, R>;
|
|
153
|
+
/**
|
|
154
|
+
* The items of a stream of pages that are themselves the lists (bare-array
|
|
155
|
+
* responses).
|
|
156
|
+
*/
|
|
157
|
+
export declare const extractArrayItems: <Output, Item, E, R>(pages: Stream.Stream<Output, E, R>) => Stream.Stream<Item, E, R>;
|
|
106
158
|
//# sourceMappingURL=pagination.d.ts.map
|
package/lib/pagination.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pagination.d.ts","sourceRoot":"","sources":["../src/pagination.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pagination.d.ts","sourceRoot":"","sources":["../src/pagination.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAGxC;;;GAGG;AACH,eAAO,MAAM,OAAO,QAAS,OAAO,QAAQ,MAAM,KAAG,OAUpD,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,QAAQ,QAAS,OAAO,QAAQ,MAAM,KAAG,SAAS,OAAO,EAcrE,CAAC;AAMF,iEAAiE;AACjE,MAAM,WAAW,cAAc;IAC7B,0BAA0B;IAC1B,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,QAAQ,GAAG,QAAQ,CAAC;IACrF;;;OAGG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B;;;;OAIG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B;;;;OAIG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,yDAAyD;IACzD,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B;;;;;OAKG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED,MAAM,MAAM,kBAAkB,GAAG,CAAC,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,EACnF,SAAS,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC,EACxD,KAAK,EAAE,KAAK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jD,KAAK,cACA,cAAc,KACzB,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC,CAiC5B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,oBAAoB,EAAE,kBAoBlC,CAAC;AAMF;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY,GAAI,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,SACtC,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC,aACvB,MAAM,KAChB,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,CAA6D,CAAC;AAEzF;;;GAGG;AACH,eAAO,MAAM,iBAAiB,GAAI,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,SAC3C,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC,KACjC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,CAAqE,CAAC"}
|
package/lib/pagination.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { pagination$extractItems as extractItems, pagination$getItems as getItems, pagination$getPath as getPath, pagination$isTerminalToken as isTerminalToken, pagination$paginateCursor as paginateCursor, pagination$paginatePageNumber as paginatePageNumber, pagination$paginateRelay as paginateRelay, pagination$paginateSingle as paginateSingle, pagination$paginateToken as paginateToken, pagination$paginateWithDefaults as paginateWithDefaults } from "./_bundle/base.js";
|
|
1
|
+
export { pagination$extractArrayItems as extractArrayItems, pagination$extractItems as extractItems, pagination$getItems as getItems, pagination$getPath as getPath, pagination$isTerminalToken as isTerminalToken, pagination$missingPaginationConfig as missingPaginationConfig, pagination$nextLink as nextLink, pagination$paginateCursor as paginateCursor, pagination$paginateKeyset as paginateKeyset, pagination$paginateLink as paginateLink, pagination$paginatePageNumber as paginatePageNumber, pagination$paginateRelay as paginateRelay, pagination$paginateSingle as paginateSingle, pagination$paginateToken as paginateToken, pagination$paginateWithDefaults as paginateWithDefaults, pagination$recordPageHeaders as recordPageHeaders } from "./_bundle/base.js";
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Protobuf binary wire codec over generated descriptors.
|
|
3
|
+
*
|
|
4
|
+
* Proto-sourced SDKs keep their schemas in proto3 JSON shape (camelCase wire
|
|
5
|
+
* names, 64-bit integers as strings, bytes as base64, enums by name,
|
|
6
|
+
* `google.protobuf.Timestamp` as RFC 3339). Servers that only speak binary
|
|
7
|
+
* gRPC need the same values as protobuf bytes, so this module transcodes
|
|
8
|
+
* between the two using a descriptor table the converter emits next to the
|
|
9
|
+
* services (`src/descriptors.ts`): field numbers, scalar kinds, message and
|
|
10
|
+
* enum references.
|
|
11
|
+
*
|
|
12
|
+
* Decoding follows proto3: a field without presence (a plain scalar, enum,
|
|
13
|
+
* `repeated` or `map` field) reads as its default when the wire omits it
|
|
14
|
+
* (`""`, `0`, `"0"` for 64-bit integers, `false`, the enum's zero value,
|
|
15
|
+
* `[]`, `{}`), so the JSON always carries it. Fields with presence (marked
|
|
16
|
+
* `optional`, message fields and `oneof` members) are omitted when absent.
|
|
17
|
+
* Enum numbers map back to names, and unknown fields are skipped.
|
|
18
|
+
*/
|
|
19
|
+
/** A scalar or composite field kind. */
|
|
20
|
+
export type FieldKind = "double" | "float" | "int32" | "int64" | "uint32" | "uint64" | "sint32" | "sint64" | "fixed32" | "fixed64" | "sfixed32" | "sfixed64" | "bool" | "string" | "bytes" | "enum" | "message" | "map";
|
|
21
|
+
/** `[keyKind, valueKind, valueRef?]` for a `map<K, V>` field. */
|
|
22
|
+
export type MapRef = readonly [key: FieldKind, value: FieldKind, ref?: string];
|
|
23
|
+
/**
|
|
24
|
+
* One field: `[number, jsonName, kind, ref?, repeated?, presence?]`. `ref`
|
|
25
|
+
* names the message or enum for `message`/`enum` kinds and is a
|
|
26
|
+
* {@link MapRef} for `map`; `repeated` is `1` for repeated fields. `presence`
|
|
27
|
+
* is set for a field whose absence is observable: `1` for a proto3
|
|
28
|
+
* `optional` field, and `n >= 2` for the members of the message's oneof `n`
|
|
29
|
+
* (setting one member clears the others). Message fields always have
|
|
30
|
+
* presence.
|
|
31
|
+
*/
|
|
32
|
+
export type FieldDescriptor = readonly [
|
|
33
|
+
number: number,
|
|
34
|
+
jsonName: string,
|
|
35
|
+
kind: FieldKind,
|
|
36
|
+
ref?: string | MapRef | 0,
|
|
37
|
+
repeated?: 0 | 1,
|
|
38
|
+
presence?: number
|
|
39
|
+
];
|
|
40
|
+
export interface ProtoDescriptors {
|
|
41
|
+
/** Message full name -> fields. */
|
|
42
|
+
readonly messages: Readonly<Record<string, ReadonlyArray<FieldDescriptor>>>;
|
|
43
|
+
/** Enum full name -> value name -> number. */
|
|
44
|
+
readonly enums: Readonly<Record<string, Readonly<Record<string, number>>>>;
|
|
45
|
+
/**
|
|
46
|
+
* gRPC method path (`/<package>.<Service>/<Method>`) ->
|
|
47
|
+
* `[requestMessage, responseMessage, serverStream?]`. A server-streaming
|
|
48
|
+
* method's JSON output is `{ items: [response, ...] }`.
|
|
49
|
+
*/
|
|
50
|
+
readonly methods: Readonly<Record<string, readonly [request: string, response: string, serverStream?: 0 | 1]>>;
|
|
51
|
+
}
|
|
52
|
+
/** A value the descriptors can't encode (a wrong type for its field). */
|
|
53
|
+
export declare class ProtobufEncodeError extends Error {
|
|
54
|
+
readonly _tag = "ProtobufEncodeError";
|
|
55
|
+
}
|
|
56
|
+
/** Bytes that aren't valid protobuf for the expected message. */
|
|
57
|
+
export declare class ProtobufDecodeError extends Error {
|
|
58
|
+
readonly _tag: string;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Valid protobuf whose value proto3 JSON can't represent: a Timestamp
|
|
62
|
+
* outside years 0001 to 9999, or a Duration beyond 10,000 years.
|
|
63
|
+
*/
|
|
64
|
+
export declare class ProtobufJsonRangeError extends ProtobufDecodeError {
|
|
65
|
+
readonly _tag = "ProtobufJsonRangeError";
|
|
66
|
+
}
|
|
67
|
+
/** Encode a proto3 JSON value of message `name` to protobuf bytes. */
|
|
68
|
+
export declare const encodeMessage: (d: ProtoDescriptors, name: string, value: unknown) => Uint8Array;
|
|
69
|
+
/**
|
|
70
|
+
* Decode protobuf bytes of message `name` to a proto3 JSON value. As in any
|
|
71
|
+
* proto3 parser, the last value of a singular field wins, a message field
|
|
72
|
+
* seen more than once is merged, setting a oneof member clears the others,
|
|
73
|
+
* a field whose wire type doesn't match its kind is skipped as unknown, and
|
|
74
|
+
* unknown fields are dropped.
|
|
75
|
+
*/
|
|
76
|
+
export declare const decodeMessage: (d: ProtoDescriptors, name: string, bytes: Uint8Array) => unknown;
|
|
77
|
+
/** One gRPC message frame: `[flag=0][u32 length BE][payload]`. */
|
|
78
|
+
export declare const frame: (payload: Uint8Array) => Uint8Array;
|
|
79
|
+
/**
|
|
80
|
+
* Reads gRPC message frames from a body that arrives in chunks: `push` each
|
|
81
|
+
* chunk and get back the messages it completed. `rest` is the number of
|
|
82
|
+
* bytes held for an incomplete frame (`0` once a body ends cleanly).
|
|
83
|
+
* Compressed frames are rejected; gRPC-Web trailer frames are skipped.
|
|
84
|
+
*/
|
|
85
|
+
export declare class FrameReader {
|
|
86
|
+
private buf;
|
|
87
|
+
get rest(): number;
|
|
88
|
+
push(chunk: Uint8Array): Uint8Array[];
|
|
89
|
+
}
|
|
90
|
+
/** Split a whole gRPC body into message payloads. */
|
|
91
|
+
export declare const unframe: (body: Uint8Array) => Uint8Array[];
|
|
92
|
+
//# sourceMappingURL=protobuf.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protobuf.d.ts","sourceRoot":"","sources":["../src/protobuf.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,wCAAwC;AACxC,MAAM,MAAM,SAAS,GACjB,QAAQ,GACR,OAAO,GACP,OAAO,GACP,OAAO,GACP,QAAQ,GACR,QAAQ,GACR,QAAQ,GACR,QAAQ,GACR,SAAS,GACT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AGG;AACH,qBAAa,sBAAuB,SAAQ,mBAAmB;IAC7D,SAAkB,IAAI,4BAA4B;CACnD;AAytBD,sEAAsE;AACtE,eAAO,MAAM,aAAa,MAAO,gBAAgB,QAAQ,MAAM,SAAS,OAAO,KAAG,UAOjF,CAAC;AAoUF;;;;;;GAMG;AACH,eAAO,MAAM,aAAa,MAAO,gBAAgB,QAAQ,MAAM,SAAS,UAAU,KAAG,OA0EpF,CAAC;AA4CF,kEAAkE;AAClE,eAAO,MAAM,KAAK,YAAa,UAAU,KAAG,UAK3C,CAAC;AAEF;;;;;GAKG;AACH,qBAAa,WAAW;IACtB,OAAO,CAAC,GAAG,CAAkD;IAE7D,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,IAAI,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU,EAAE,CAuBpC;CACF;AAED,qDAAqD;AACrD,eAAO,MAAM,OAAO,SAAU,UAAU,KAAG,UAAU,EAKpD,CAAC"}
|
package/lib/protobuf.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { protobuf$FrameReader as FrameReader, protobuf$ProtobufDecodeError as ProtobufDecodeError, protobuf$ProtobufEncodeError as ProtobufEncodeError, protobuf$ProtobufJsonRangeError as ProtobufJsonRangeError, protobuf$decodeMessage as decodeMessage, protobuf$encodeMessage as encodeMessage, protobuf$frame as frame, protobuf$unframe as unframe } from "./_bundle/grpc.js";
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* gRPC (binary protobuf) protocol for proto-sourced SDKs.
|
|
3
|
+
*
|
|
4
|
+
* Proto SDKs are generated as REST-shaped operations: each RPC is
|
|
5
|
+
* `POST /<package>.<Service>/<Method>` with a proto3 JSON body. Servers that
|
|
6
|
+
* accept JSON (Connect, grpc-gateway) use {@link makeRestProtocol} directly.
|
|
7
|
+
* Servers that only speak gRPC use this protocol, which builds the request
|
|
8
|
+
* with the REST protocol and speaks gRPC on the wire:
|
|
9
|
+
*
|
|
10
|
+
* - **Request**: the proto3 JSON body is transcoded to one protobuf message
|
|
11
|
+
* ({@link encodeMessage}) in one gRPC frame, sent as `application/grpc`.
|
|
12
|
+
* - **Transport**: the call goes through the `HttpClient` the
|
|
13
|
+
* `GrpcTransport` reference holds, or the caller's `HttpClient` when it
|
|
14
|
+
* holds none (see `@distilled.cloud/core/grpc-transport`). Plain `fetch`
|
|
15
|
+
* works where a proxy bridges HTTP/1.1 to gRPC (envoy).
|
|
16
|
+
* - **Status**: the call's `grpc-status` is read from the trailers, or from
|
|
17
|
+
* the headers of a trailers-only reply. A transport that can't see
|
|
18
|
+
* trailers (`fetch`) leaves only the headers; a reply with message frames
|
|
19
|
+
* and no status there is treated as OK.
|
|
20
|
+
* - **Errors**: a non-zero status becomes the operation's typed error. The
|
|
21
|
+
* REST decoder receives `{ code, status, message }` (`{ code: 5, status:
|
|
22
|
+
* "NOT_FOUND", ... }`) with the HTTP status grpc-gateway maps the code to
|
|
23
|
+
* (`NOT_FOUND` -> 404, `UNAVAILABLE` -> 503, ...), so error matchers key on
|
|
24
|
+
* the numeric gRPC `code`, and categories and retries follow the HTTP
|
|
25
|
+
* status.
|
|
26
|
+
* - **Response**: protobuf messages are transcoded back to proto3 JSON and
|
|
27
|
+
* decoded by the operation's output schema, so schemas, sensitive values
|
|
28
|
+
* and response validation behave exactly as for REST.
|
|
29
|
+
*
|
|
30
|
+
* A server-streaming method's output is `{ items: [message, ...] }`. Calling
|
|
31
|
+
* the operation collects the whole stream; its `.stream(input)` (see
|
|
32
|
+
* `API.makeStreaming`) emits each message as it arrives, and stopping the
|
|
33
|
+
* stream cancels the call.
|
|
34
|
+
*
|
|
35
|
+
* {@link Deadline} bounds calls in its scope: it is sent as `grpc-timeout`
|
|
36
|
+
* and enforced here, and a call that runs past it fails with
|
|
37
|
+
* `DEADLINE_EXCEEDED` (code 4).
|
|
38
|
+
*/
|
|
39
|
+
import * as Context from "effect/Context";
|
|
40
|
+
import * as Duration from "effect/Duration";
|
|
41
|
+
import * as Layer from "effect/Layer";
|
|
42
|
+
import * as API from "./api.ts";
|
|
43
|
+
import { type ProtoDescriptors } from "./protobuf.ts";
|
|
44
|
+
import { type RestProtocolOptions } from "./protocol-rest.ts";
|
|
45
|
+
/** gRPC status code -> name. */
|
|
46
|
+
export declare const GRPC_STATUS_NAMES: Readonly<Record<number, string>>;
|
|
47
|
+
/** gRPC status code -> HTTP status (grpc-gateway's mapping). */
|
|
48
|
+
export declare const GRPC_HTTP_STATUS: Readonly<Record<number, number>>;
|
|
49
|
+
/**
|
|
50
|
+
* The deadline of gRPC calls in its scope, from when each call starts.
|
|
51
|
+
* `undefined` (the default) sets none.
|
|
52
|
+
*
|
|
53
|
+
* ```ts
|
|
54
|
+
* router.taskExecWait(input).pipe(Effect.provideService(Deadline, "30 seconds"));
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
export declare const Deadline: Context.Reference<Duration.Input | undefined>;
|
|
58
|
+
export interface GrpcProtocolOptions<C> extends RestProtocolOptions<C> {
|
|
59
|
+
/** The SDK's generated descriptors (`src/descriptors.ts`). */
|
|
60
|
+
readonly descriptors: ProtoDescriptors;
|
|
61
|
+
/**
|
|
62
|
+
* The error for a non-zero status no typed error matched, from its gRPC
|
|
63
|
+
* code. By default the REST decoder classifies it by the HTTP status the
|
|
64
|
+
* code maps to (`UNAVAILABLE` -> `ServiceUnavailable`, which retries), which
|
|
65
|
+
* keeps retries working but merges codes that share a status
|
|
66
|
+
* (`INVALID_ARGUMENT`, `FAILED_PRECONDITION` and `OUT_OF_RANGE` are all
|
|
67
|
+
* `BadRequest`).
|
|
68
|
+
*/
|
|
69
|
+
readonly statusError?: (info: StatusInfo) => unknown;
|
|
70
|
+
}
|
|
71
|
+
/** A non-OK gRPC status, as `statusError` receives it. */
|
|
72
|
+
export interface StatusInfo {
|
|
73
|
+
readonly code: number;
|
|
74
|
+
readonly message: string;
|
|
75
|
+
/** `google.rpc.Status.details` from `grpc-status-details-bin`, as proto3 JSON `Any`s. */
|
|
76
|
+
readonly details: ReadonlyArray<unknown>;
|
|
77
|
+
readonly headers: Readonly<Record<string, string>>;
|
|
78
|
+
}
|
|
79
|
+
/** gRPC's mapping of an HTTP status, for a reply that carries no gRPC status. */
|
|
80
|
+
export declare const HTTP_GRPC_STATUS: Readonly<Record<number, number>>;
|
|
81
|
+
/**
|
|
82
|
+
* A gRPC protocol over the given REST protocol options. See the module
|
|
83
|
+
* documentation for the wire behavior.
|
|
84
|
+
*/
|
|
85
|
+
export declare const makeGrpcProtocol: <C>(options: GrpcProtocolOptions<C>) => Layer.Layer<API.Protocol>;
|
|
86
|
+
//# sourceMappingURL=protocol-grpc.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol-grpc.d.ts","sourceRoot":"","sources":["../src/protocol-grpc.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAM5C,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAEtC,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAEhC,OAAO,EAKL,KAAK,gBAAgB,EACtB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAoB,KAAK,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAIhF,gCAAgC;AAChC,eAAO,MAAM,iBAAiB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAkB9D,CAAC;AAEF,gEAAgE;AAChE,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAkB7D,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,QAAQ,+CAGpB,CAAC;AAEF,MAAM,WAAW,mBAAmB,CAAC,CAAC,CAAE,SAAQ,mBAAmB,CAAC,CAAC,CAAC;IACpE,8DAA8D;IAC9D,QAAQ,CAAC,WAAW,EAAE,gBAAgB,CAAC;IACvC;;;;;;;OAOG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,OAAO,CAAC;CACtD;AAED,0DAA0D;AAC1D,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,yFAAyF;IACzF,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC;IACzC,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CACpD;AAED,iFAAiF;AACjF,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAS7D,CAAC;AAiHF;;;GAGG;AACH,eAAO,MAAM,gBAAgB,GAAI,CAAC,WAAW,mBAAmB,CAAC,CAAC,CAAC,KAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,CAsX5C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { protocol_grpc$Deadline as Deadline, protocol_grpc$GRPC_HTTP_STATUS as GRPC_HTTP_STATUS, protocol_grpc$GRPC_STATUS_NAMES as GRPC_STATUS_NAMES, protocol_grpc$HTTP_GRPC_STATUS as HTTP_GRPC_STATUS, protocol_grpc$makeGrpcProtocol as makeGrpcProtocol } from "./_bundle/grpc.js";
|
package/lib/protocol-http.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
1
2
|
import * as HttpClientRequest from "effect/http/HttpClientRequest";
|
|
2
3
|
/**
|
|
3
4
|
* Generic REST protocol machinery, shared by SDK protocol layers.
|
|
@@ -11,14 +12,13 @@ import * as HttpClientRequest from "effect/http/HttpClientRequest";
|
|
|
11
12
|
*/
|
|
12
13
|
import type * as AST from "effect/SchemaAST";
|
|
13
14
|
import { isOpaqueValue } from "./plain-values.ts";
|
|
15
|
+
import * as Schema from "./schema-lite-typed.ts";
|
|
16
|
+
import { SdkError } from "./sdk-error.ts";
|
|
14
17
|
import { type ErrorMatcher, type HttpTrait, type KeyDictionaryEntries } from "./trait.ts";
|
|
15
|
-
export
|
|
16
|
-
export declare const getAnn: (ast: AST.AST, symbol: symbol) => unknown;
|
|
18
|
+
export { getAnn, getProps, resolveNode } from "./annotations.ts";
|
|
17
19
|
export declare const getPropAnn: (prop: AST.PropertySignature, symbol: symbol) => unknown;
|
|
18
20
|
export declare const hasPropAnn: (prop: AST.PropertySignature, symbol: symbol) => boolean;
|
|
19
21
|
export declare const nameOf: (prop: AST.PropertySignature, symbol: symbol) => string;
|
|
20
|
-
/** Resolve wrappers to the real node: Suspend, encoding, optional/null unions. */
|
|
21
|
-
export declare const resolveNode: (ast: AST.AST) => AST.AST;
|
|
22
22
|
/** An output member read from a response header (`T.Header`). */
|
|
23
23
|
export interface ResponseHeaderMember {
|
|
24
24
|
readonly key: string;
|
|
@@ -70,6 +70,12 @@ export interface BuildRequestOptions {
|
|
|
70
70
|
* Defaults to the key verbatim.
|
|
71
71
|
*/
|
|
72
72
|
readonly unknownKeyToWire?: (key: string) => string;
|
|
73
|
+
/**
|
|
74
|
+
* Send `{}` on a method that takes a body even when the input declares no
|
|
75
|
+
* body members. Connect unary RPCs (E2B's envd) POST JSON for every call,
|
|
76
|
+
* and refuse a bodyless one with 415.
|
|
77
|
+
*/
|
|
78
|
+
readonly emptyJsonBody?: boolean;
|
|
73
79
|
}
|
|
74
80
|
/**
|
|
75
81
|
* Encode a greedy `{name+}` label: the value may span several path
|
|
@@ -84,6 +90,29 @@ export declare const encodeGreedyLabel: (value: string) => string;
|
|
|
84
90
|
* intermediate copies. `url` may carry a query string.
|
|
85
91
|
*/
|
|
86
92
|
export declare const makeRequest: (method: HttpTrait["method"], url: string, headers: Record<string, string>) => HttpClientRequest.HttpClientRequest;
|
|
93
|
+
declare const InvalidInput_base: Schema.TaggedErrorClass<"InvalidInput", {
|
|
94
|
+
readonly member: import("effect/Schema").String;
|
|
95
|
+
readonly message: import("effect/Schema").String;
|
|
96
|
+
}> & (new (...args: any[]) => {
|
|
97
|
+
"@distilled.cloud/error/categories": {
|
|
98
|
+
BadRequestError: true;
|
|
99
|
+
};
|
|
100
|
+
});
|
|
101
|
+
/**
|
|
102
|
+
* 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
|
+
* Raised before anything is sent.
|
|
105
|
+
*/
|
|
106
|
+
export declare class InvalidInput extends /*@__PURE__*/ InvalidInput_base {
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* The refusal for a path label value that would address another resource,
|
|
110
|
+
* or `undefined`. The URL parser resolves a `.` or `..` segment,
|
|
111
|
+
* percent-encoded or not, so no encoding can carry one
|
|
112
|
+
* (`/projects/p1/branches/..` -> `/projects/p1/`). A greedy label keeps its
|
|
113
|
+
* `/`, so each of its segments counts.
|
|
114
|
+
*/
|
|
115
|
+
export declare const invalidLabel: (member: string, value: unknown, greedy?: boolean) => InvalidInput | undefined;
|
|
87
116
|
/**
|
|
88
117
|
* Build an HTTP request from an operation input and its schema, driven by
|
|
89
118
|
* the trait annotations: `Http()` supplies method + URI template, `Label()`
|
|
@@ -96,12 +125,12 @@ export declare const makeRequest: (method: HttpTrait["method"], url: string, hea
|
|
|
96
125
|
* The schema is read once per input schema (see `planFor`); later calls only
|
|
97
126
|
* walk the input value.
|
|
98
127
|
*
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
*
|
|
128
|
+
* 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).
|
|
130
|
+
* Fails with {@link SdkError} when the input schema is missing the `Http()`
|
|
131
|
+
* trait (a codegen bug the generator refuses).
|
|
103
132
|
*/
|
|
104
|
-
export declare const buildRequest: (
|
|
133
|
+
export declare const buildRequest: (options: BuildRequestOptions) => Effect.Effect<HttpClientRequest.HttpClientRequest, InvalidInput | SdkError>;
|
|
105
134
|
/** Parsed response metadata supplied by a protocol after it detects a failure. */
|
|
106
135
|
export interface ErrorResponse {
|
|
107
136
|
readonly body?: unknown;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protocol-http.d.ts","sourceRoot":"","sources":["../src/protocol-http.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"protocol-http.d.ts","sourceRoot":"","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;AAG7C,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,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,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEjE,eAAO,MAAM,UAAU,SAAU,GAAG,CAAC,iBAAiB,UAAU,MAAM,KAAG,OAC9C,CAAC;AAC5B,eAAO,MAAM,UAAU,SAAU,GAAG,CAAC,iBAAiB,UAAU,MAAM,KAAG,OACjC,CAAC;AACzC,eAAO,MAAM,MAAM,SAAU,GAAG,CAAC,iBAAiB,UAAU,MAAM,KAAG,MAGpE,CAAC;AAMF,iEAAiE;AACjE,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,GAAG,EAAE,MA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AG,SA4BZ,CAAC"}
|
package/lib/protocol-http.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { 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$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$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";
|
package/lib/protocol-rest.d.ts
CHANGED
|
@@ -1,40 +1,16 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Generic REST protocol factory for simple bearer/header-auth JSON APIs
|
|
3
|
-
* (Neon, Fly.io, PlanetScale, Supabase, Turso, ...).
|
|
4
|
-
*
|
|
5
|
-
* `makeRestProtocol(options)` builds a core {@link API.Protocol} layer:
|
|
6
|
-
*
|
|
7
|
-
* request: credentials resolved from the CALLING fiber's context on every
|
|
8
|
-
* request (the layer itself is memoized per process -- see
|
|
9
|
-
* `core/api`), auth headers + base URL from the provider's
|
|
10
|
-
* options, request built by `buildRequest` from
|
|
11
|
-
* `core/protocol-http` (deep-unwrapping any `Redacted` input
|
|
12
|
-
* values first)
|
|
13
|
-
*
|
|
14
|
-
* response: 2xx JSON -> optional `transformResponse` -> recursive wire->TS
|
|
15
|
-
* key mapping (`mapKeys`) -> in strict mode, a schema check
|
|
16
|
-
* failing with the provider's `parseError` (see
|
|
17
|
-
* `core/response-validation`) -> `Redacted` wrapping of members
|
|
18
|
-
* marked with {@link SensitiveValue}; non-2xx -> typed error:
|
|
19
|
-
* per-op matcher classes (`matchTypedError`), then the status
|
|
20
|
-
* map (default `HTTP_STATUS_MAP`), then an `InternalServerError`
|
|
21
|
-
* for unmapped 5xx, then the provider's `unknownError` fallback
|
|
22
|
-
* -- with `retryAfter` durations stamped from the standard hint
|
|
23
|
-
* headers on retryable statuses.
|
|
24
|
-
*
|
|
25
|
-
* Anything provider-specific (envelope quirks, bespoke error codes) belongs
|
|
26
|
-
* in the provider package -- via these options or a hand-written protocol.
|
|
27
|
-
*/
|
|
28
1
|
import * as Context from "effect/Context";
|
|
29
2
|
import * as Effect from "effect/Effect";
|
|
30
3
|
import * as Layer from "effect/Layer";
|
|
31
4
|
import type * as AST from "effect/SchemaAST";
|
|
5
|
+
import { rawResponseRootSymbol } from "./annotations.ts";
|
|
32
6
|
import * as API from "./api.ts";
|
|
33
7
|
import { unwrapRedactedDeep } from "./plain-values.ts";
|
|
34
|
-
|
|
8
|
+
import { sensitiveValueSymbol, wrapSensitive } from "./sensitive.ts";
|
|
9
|
+
export { sensitiveValueSymbol };
|
|
35
10
|
/**
|
|
36
|
-
* Marks a string member as sensitive (mirrors
|
|
37
|
-
* The REST protocol wraps decoded values in
|
|
11
|
+
* Marks a string member, map value or list element as sensitive (mirrors
|
|
12
|
+
* `smithy.api#sensitive`). The REST protocol wraps decoded values in
|
|
13
|
+
* `Redacted` on the way out (an untyped `S.Unknown` value whole) and
|
|
38
14
|
* accepts `string | Redacted<string>` on the way in (unwrapped before
|
|
39
15
|
* serialization). Takes an ignored argument so generators can inline the
|
|
40
16
|
* smithy trait value (`T.SensitiveValue({})`).
|
|
@@ -46,28 +22,24 @@ export declare const rawResponseSymbol: unique symbol;
|
|
|
46
22
|
* body (mirrors `com.distilled.openapi#rawResponse`).
|
|
47
23
|
*/
|
|
48
24
|
export declare const RawResponse: (_value?: unknown) => import("./trait.ts").Annotation;
|
|
49
|
-
export declare const rawResponseRootSymbol: unique symbol;
|
|
50
25
|
/**
|
|
51
26
|
* Marks a response schema whose ENTIRE value is the response body (the
|
|
52
27
|
* generator's `rootPipe` for synthesized bare-payload wrappers): the emitted
|
|
53
28
|
* response type IS the payload type and the protocol returns the mapped body
|
|
54
29
|
* directly.
|
|
55
30
|
*/
|
|
31
|
+
export { rawResponseRootSymbol };
|
|
56
32
|
export declare const RawResponseRoot: () => import("./trait.ts").Annotation;
|
|
57
33
|
export declare const binaryResponseSymbol: unique symbol;
|
|
58
34
|
/** Decode a successful raw binary response as bytes, without text conversion. */
|
|
59
35
|
export declare const BinaryResponse: () => import("./trait.ts").Annotation;
|
|
60
36
|
export { unwrapRedactedDeep };
|
|
37
|
+
export { wrapSensitive };
|
|
61
38
|
/**
|
|
62
|
-
*
|
|
63
|
-
* marked {@link SensitiveValue}
|
|
64
|
-
*
|
|
65
|
-
|
|
66
|
-
export declare const wrapSensitive: (ast: AST.AST, value: unknown) => unknown;
|
|
67
|
-
/**
|
|
68
|
-
* Whether any member reachable from `ast` is marked {@link SensitiveValue}.
|
|
69
|
-
* Parse errors for such an output withhold the response body (see
|
|
70
|
-
* {@link RestParseErrorInfo}); hand-written protocols use this to do the same.
|
|
39
|
+
* Whether any member, map value or list element reachable from `ast` is
|
|
40
|
+
* marked {@link SensitiveValue}. Such an output is decoded through
|
|
41
|
+
* {@link wrapSensitive}, and its parse errors withhold the response body (see
|
|
42
|
+
* {@link checkSuccess}, which every REST-style protocol's success path uses).
|
|
71
43
|
*/
|
|
72
44
|
export declare const hasSensitiveMember: (ast: AST.AST) => boolean;
|
|
73
45
|
/** What the wire said about a failure, for the `unknownError` fallback. */
|
|
@@ -134,6 +106,13 @@ export interface RestProtocolOptions<C> {
|
|
|
134
106
|
* else to {@link unknownError}.
|
|
135
107
|
*/
|
|
136
108
|
readonly statusMap?: Readonly<Record<number, new (args: any) => any>>;
|
|
109
|
+
/**
|
|
110
|
+
* The provider's own reading of a failure, consulted before per-op typed
|
|
111
|
+
* matching and the status map: return the error to fail with, or
|
|
112
|
+
* `undefined` to decode the failure as usual. For rules a status alone
|
|
113
|
+
* can't express, e.g. a 403 that is a rate limit because of its headers.
|
|
114
|
+
*/
|
|
115
|
+
readonly classifyError?: (info: RestErrorInfo) => unknown;
|
|
137
116
|
/** Fallback error for failures nothing else matched. */
|
|
138
117
|
readonly unknownError: (info: RestErrorInfo) => unknown;
|
|
139
118
|
/**
|
|
@@ -152,9 +131,48 @@ export interface RestProtocolOptions<C> {
|
|
|
152
131
|
readonly mapMemberHeader?: (name: string, value: string) => string;
|
|
153
132
|
/** Passed through to `buildRequest` (wire names for unmodeled input keys). */
|
|
154
133
|
readonly unknownKeyToWire?: (key: string) => string;
|
|
134
|
+
/** Passed through to `buildRequest`: send `{}` when a bodied call has no body members. */
|
|
135
|
+
readonly emptyJsonBody?: boolean;
|
|
136
|
+
}
|
|
137
|
+
/** A 2xx body a protocol read, for {@link checkSuccess}. */
|
|
138
|
+
export interface SuccessBody {
|
|
139
|
+
/** The value to check and return: the body mapped onto the output's TS names. */
|
|
140
|
+
readonly value: unknown;
|
|
141
|
+
/** What a parse error reports as `body` for an output without sensitive members. */
|
|
142
|
+
readonly body: unknown;
|
|
143
|
+
/** Whether the body was not JSON. */
|
|
144
|
+
readonly nonJson: boolean;
|
|
155
145
|
}
|
|
156
|
-
/**
|
|
157
|
-
export
|
|
146
|
+
/** The outcome of {@link checkSuccess}: the value, or the parse error's fields. */
|
|
147
|
+
export type SuccessCheck = {
|
|
148
|
+
readonly ok: true;
|
|
149
|
+
readonly value: unknown;
|
|
150
|
+
} | {
|
|
151
|
+
readonly ok: false;
|
|
152
|
+
readonly error: RestParseErrorInfo;
|
|
153
|
+
};
|
|
154
|
+
/**
|
|
155
|
+
* Check a 2xx body against the operation's output schema and deliver its
|
|
156
|
+
* sensitive values as `Redacted`. Every REST-style protocol ends its success
|
|
157
|
+
* path here, so all of them treat a body that can hold a secret alike:
|
|
158
|
+
*
|
|
159
|
+
* - The checked value comes back through {@link wrapSensitive}.
|
|
160
|
+
* - A mismatch (validating modes, see `core/response-validation`) reports
|
|
161
|
+
* `read.body` and the schema error.
|
|
162
|
+
* - For an output with sensitive members ({@link hasSensitiveMember}), a
|
|
163
|
+
* non-JSON body fails in every mode with `"Invalid JSON response"`, and a
|
|
164
|
+
* mismatch reports `body: "[REDACTED]"` and the schema error without the
|
|
165
|
+
* value it found (`withholdActual`).
|
|
166
|
+
*
|
|
167
|
+
* Synchronous, for protocols that already hold the calling fiber's context;
|
|
168
|
+
* {@link validateSuccess} is the `Effect` form.
|
|
169
|
+
*/
|
|
170
|
+
export declare const checkSuccess: (context: Context.Context<any>, outputAst: AST.AST, read: SuccessBody) => SuccessCheck;
|
|
171
|
+
/**
|
|
172
|
+
* {@link checkSuccess} on the calling fiber, failing with `parseError` (the
|
|
173
|
+
* SDK's `<Sdk>ParseError`) built from the withheld-or-not fields.
|
|
174
|
+
*/
|
|
175
|
+
export declare const validateSuccess: <E>(outputAst: AST.AST, read: SuccessBody, parseError: (info: RestParseErrorInfo) => E) => Effect.Effect<unknown, E>;
|
|
158
176
|
/**
|
|
159
177
|
* Build a `Layer<Protocol>` for a simple REST JSON API. Assign the result to
|
|
160
178
|
* a module-level const in the provider's `protocol.ts` -- `API.make` memoizes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protocol-rest.d.ts","sourceRoot":"","sources":["../src/protocol-rest.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"protocol-rest.d.ts","sourceRoot":"","sources":["../src/protocol-rest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAIxC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,KAAK,GAAG,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,qBAAqB,EAAe,MAAM,kBAAkB,CAAC;AACtE,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAGhC,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAevD,OAAO,EAAkB,oBAAoB,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAoCrF,OAAO,EAAE,oBAAoB,EAAE,CAAC;AAChC;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,YAAa,OAAO,oCAA+C,CAAC;AAE/F,eAAO,MAAM,iBAAiB,eAAiE,CAAC;AAChG;;;GAGG;AACH,eAAO,MAAM,WAAW,YAAa,OAAO,oCAA4C,CAAC;AAEzF;;;;;GAKG;AACH,OAAO,EAAE,qBAAqB,EAAE,CAAC;AACjC,eAAO,MAAM,eAAe,uCAAoD,CAAC;AAEjF,eAAO,MAAM,oBAAoB,eAEhC,CAAC;AAEF,iFAAiF;AACjF,eAAO,MAAM,cAAc,uCAAmD,CAAC;AAM/E,OAAO,EAAE,kBAAkB,EAAE,CAAC;AAE9B,OAAO,EAAE,aAAa,EAAE,CAAC;AAEzB;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,KAAK,OAAwB,CAAC;AAM5E,2EAA2E;AAC3E,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,MAAM,EAAE,MAAM,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,KAAK,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,kBAAkB,CAAA;CAAE,CAAC;AAE/D;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,YAAY,YACd,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,aAClB,GAAG,CAAC,GAAG,QACZ,WAAW,KAChB,YAeF,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,eAAe,GAAI,CAAC,aACpB,GAAG,CAAC,GAAG,QACZ,WAAW,cACL,CAAC,IAAI,EAAE,kBAAkB,KAAK,CAAC,KAC1C,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC,CAIvB,CAAC;AA0CL;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,GAAI,CAAC,WAAW,mBAAmB,CAAC,CAAC,CAAC,KAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,CA2N7F,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$
|
|
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$hasSensitiveMember as hasSensitiveMember, protocol_rest$makeRestProtocol as makeRestProtocol, protocol_rest$rawResponseRootSymbol as rawResponseRootSymbol, protocol_rest$rawResponseSymbol as rawResponseSymbol, protocol_rest$sensitiveValueSymbol as sensitiveValueSymbol, protocol_rest$unwrapRedactedDeep as unwrapRedactedDeep, protocol_rest$validateSuccess as validateSuccess, protocol_rest$wrapSensitive as wrapSensitive } from "./_bundle/rest.js";
|
|
@@ -7,9 +7,10 @@
|
|
|
7
7
|
* lenient (default): the response is returned as the protocol read it.
|
|
8
8
|
* A body that does not match the declared output type
|
|
9
9
|
* (a missing member, a wrong primitive, a non-JSON
|
|
10
|
-
* body) still succeeds, except that
|
|
11
|
-
*
|
|
12
|
-
*
|
|
10
|
+
* body) still succeeds, except that a non-JSON body for
|
|
11
|
+
* an output with sensitive members fails in every mode
|
|
12
|
+
* (REST-style protocols through core's `checkSuccess`
|
|
13
|
+
* in `protocol-rest`, plus ZeroSSL and AWS).
|
|
13
14
|
* additionalProperties: the response is checked against the output
|
|
14
15
|
* schema, and a mismatch fails the call with the SDK's
|
|
15
16
|
* `<Sdk>ParseError` (AWS: `ParseError`). Keys the
|
|
@@ -40,7 +41,7 @@ import * as Context from "effect/Context";
|
|
|
40
41
|
import * as Effect from "effect/Effect";
|
|
41
42
|
import * as Layer from "effect/Layer";
|
|
42
43
|
import type * as AST from "effect/SchemaAST";
|
|
43
|
-
import { type Decode,
|
|
44
|
+
import { type Decode, SchemaMismatch } from "./response-validation-strict.ts";
|
|
44
45
|
export { SchemaMismatch, withholdActual } from "./response-validation-strict.ts";
|
|
45
46
|
export type Mode = "lenient" | "additionalProperties" | "strict";
|
|
46
47
|
/**
|