@distilled.cloud/core 1.0.0-rc.16 → 1.0.0-rc.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/_bundle/aws.js +2 -0
- package/lib/_bundle/aws.js.map +1 -0
- package/lib/_bundle/base.js +5 -0
- package/lib/_bundle/base.js.map +1 -0
- package/lib/_bundle/graphql.js +3 -0
- package/lib/_bundle/graphql.js.map +1 -0
- package/lib/_bundle/rest.js +2 -0
- package/lib/_bundle/rest.js.map +1 -0
- package/lib/_bundle/xml.js +4 -0
- package/lib/_bundle/xml.js.map +1 -0
- package/lib/annotations.d.ts +15 -0
- package/lib/annotations.d.ts.map +1 -0
- package/lib/annotations.js +2 -0
- package/lib/annotations.js.map +1 -0
- package/lib/api.d.ts +15 -0
- package/lib/api.d.ts.map +1 -1
- package/lib/api.js +1 -796
- package/lib/category.d.ts.map +1 -1
- package/lib/category.js +1 -278
- package/lib/chunks.js +1 -11
- package/lib/config.d.ts +54 -13
- package/lib/config.d.ts.map +1 -1
- package/lib/config.js +1 -161
- package/lib/crypto.js +1 -130
- package/lib/debug.d.ts.map +1 -1
- package/lib/debug.js +1 -8
- package/lib/error-category.d.ts.map +1 -1
- package/lib/error-category.js +1 -47
- package/lib/errors.d.ts +2 -13
- package/lib/errors.d.ts.map +1 -1
- package/lib/errors.js +1 -198
- package/lib/graphql.d.ts +14 -0
- package/lib/graphql.d.ts.map +1 -1
- package/lib/graphql.js +1 -1058
- package/lib/graphql.types.js +1 -6
- package/lib/index.d.ts +3 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -15
- package/lib/pagination.d.ts +34 -2
- package/lib/pagination.d.ts.map +1 -1
- package/lib/pagination.js +1 -271
- package/lib/plain-values.js +1 -39
- package/lib/plain-values.js.map +1 -1
- package/lib/protocol-http.d.ts +30 -6
- package/lib/protocol-http.d.ts.map +1 -1
- package/lib/protocol-http.js +1 -812
- package/lib/protocol-rest.d.ts +53 -39
- package/lib/protocol-rest.d.ts.map +1 -1
- package/lib/protocol-rest.js +1 -375
- package/lib/query.js +1 -27
- package/lib/response-validation-strict.js +1 -284
- package/lib/response-validation.d.ts +4 -3
- package/lib/response-validation.d.ts.map +1 -1
- package/lib/response-validation.js +1 -118
- package/lib/retry-after.js +1 -112
- package/lib/retry.js +1 -197
- package/lib/schema-lite-impl.js +1 -341
- package/lib/schema-lite-typed.js +1 -27
- package/lib/schema-lite.js +1 -31
- package/lib/schema.js +1 -220
- package/lib/telemetry-debug.d.ts +14 -0
- package/lib/telemetry-debug.d.ts.map +1 -0
- package/lib/telemetry-debug.js +2 -0
- package/lib/telemetry-debug.js.map +1 -0
- package/lib/telemetry-hooks.d.ts +32 -0
- package/lib/telemetry-hooks.d.ts.map +1 -0
- package/lib/telemetry-hooks.js +2 -0
- package/lib/telemetry-hooks.js.map +1 -0
- package/lib/telemetry-host-rules.d.ts +23 -0
- package/lib/telemetry-host-rules.d.ts.map +1 -0
- package/lib/telemetry-host-rules.js +2 -0
- package/lib/telemetry-host-rules.js.map +1 -0
- package/lib/telemetry-lambda-context.d.ts +17 -0
- package/lib/telemetry-lambda-context.d.ts.map +1 -0
- package/lib/telemetry-lambda-context.js +2 -0
- package/lib/telemetry-lambda-context.js.map +1 -0
- package/lib/telemetry-message-context.d.ts +52 -0
- package/lib/telemetry-message-context.d.ts.map +1 -0
- package/lib/telemetry-message-context.js +2 -0
- package/lib/telemetry-message-context.js.map +1 -0
- package/lib/telemetry-metrics.d.ts +6 -0
- package/lib/telemetry-metrics.d.ts.map +1 -0
- package/lib/telemetry-metrics.js +2 -0
- package/lib/telemetry-metrics.js.map +1 -0
- package/lib/telemetry-name-template.d.ts +13 -0
- package/lib/telemetry-name-template.d.ts.map +1 -0
- package/lib/telemetry-name-template.js +2 -0
- package/lib/telemetry-name-template.js.map +1 -0
- package/lib/telemetry-stream.d.ts +9 -0
- package/lib/telemetry-stream.d.ts.map +1 -0
- package/lib/telemetry-stream.js +2 -0
- package/lib/telemetry-stream.js.map +1 -0
- package/lib/telemetry-xray.d.ts +28 -0
- package/lib/telemetry-xray.d.ts.map +1 -0
- package/lib/telemetry-xray.js +2 -0
- package/lib/telemetry-xray.js.map +1 -0
- package/lib/telemetry.d.ts +269 -0
- package/lib/telemetry.d.ts.map +1 -0
- package/lib/telemetry.js +3 -0
- package/lib/telemetry.js.map +1 -0
- package/lib/trait.js +1 -131
- package/lib/xml.js +1 -323
- package/package.json +1 -3
- package/src/annotations.ts +37 -0
- package/src/api.ts +130 -30
- package/src/category.ts +21 -22
- package/src/config.ts +58 -29
- package/src/debug.ts +9 -6
- package/src/error-category.ts +12 -14
- package/src/errors.ts +7 -7
- package/src/graphql.ts +123 -18
- package/src/index.ts +3 -2
- package/src/pagination.ts +119 -6
- package/src/protocol-http.ts +63 -43
- package/src/protocol-rest.ts +201 -140
- package/src/response-validation.ts +4 -3
- package/src/telemetry-debug.ts +135 -0
- package/src/telemetry-hooks.ts +33 -0
- package/src/telemetry-host-rules.ts +39 -0
- package/src/telemetry-lambda-context.ts +46 -0
- package/src/telemetry-message-context.ts +170 -0
- package/src/telemetry-metrics.ts +69 -0
- package/src/telemetry-name-template.ts +26 -0
- package/src/telemetry-stream.ts +91 -0
- package/src/telemetry-xray.ts +66 -0
- package/src/telemetry.ts +768 -0
- package/lib/api.js.map +0 -1
- package/lib/category.js.map +0 -1
- package/lib/chunks.js.map +0 -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/config.js.map +0 -1
- package/lib/crypto.js.map +0 -1
- package/lib/debug.js.map +0 -1
- package/lib/error-category.js.map +0 -1
- package/lib/errors.js.map +0 -1
- package/lib/graphql.js.map +0 -1
- package/lib/graphql.types.js.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/json-patch.d.ts +0 -58
- package/lib/json-patch.d.ts.map +0 -1
- package/lib/json-patch.js +0 -227
- package/lib/json-patch.js.map +0 -1
- package/lib/pagination.js.map +0 -1
- package/lib/protocol-http.js.map +0 -1
- package/lib/protocol-rest.js.map +0 -1
- package/lib/query.js.map +0 -1
- package/lib/response-validation-strict.js.map +0 -1
- package/lib/response-validation.js.map +0 -1
- package/lib/retry-after.js.map +0 -1
- package/lib/retry.js.map +0 -1
- package/lib/schema-lite-impl.js.map +0 -1
- package/lib/schema-lite-typed.js.map +0 -1
- package/lib/schema-lite.js.map +0 -1
- package/lib/schema.js.map +0 -1
- package/lib/testing.d.ts +0 -40
- package/lib/testing.d.ts.map +0 -1
- package/lib/testing.js +0 -42
- package/lib/testing.js.map +0 -1
- package/lib/trait.js.map +0 -1
- package/lib/xml.js.map +0 -1
- package/src/codegen/boolean-string-enums.ts +0 -155
- package/src/codegen/chunk.ts +0 -147
- package/src/codegen/cli.ts +0 -293
- package/src/codegen/datafy.ts +0 -874
- package/src/codegen/dedupe.ts +0 -173
- package/src/codegen/emit.ts +0 -200
- package/src/codegen/format.ts +0 -49
- package/src/codegen/generated-at.ts +0 -88
- package/src/codegen/generator.ts +0 -1229
- package/src/codegen/graph.ts +0 -151
- package/src/codegen/graphql-client.ts +0 -545
- package/src/codegen/graphql.ts +0 -1145
- package/src/codegen/latin1.ts +0 -131
- package/src/codegen/members.ts +0 -79
- package/src/codegen/model-diff.ts +0 -67
- package/src/codegen/naming.ts +0 -85
- package/src/codegen/openapi-cli.ts +0 -141
- package/src/codegen/openapi.ts +0 -1845
- package/src/codegen/operations.ts +0 -73
- package/src/codegen/pagination.ts +0 -64
- package/src/codegen/patch-audit.ts +0 -480
- package/src/codegen/patches.ts +0 -581
- package/src/codegen/prelude.ts +0 -70
- package/src/codegen/privatize.ts +0 -200
- package/src/codegen/proto.ts +0 -1092
- package/src/codegen/pure.ts +0 -94
- package/src/codegen/rewrite-operation-ids.ts +0 -1219
- package/src/codegen/spec-path.ts +0 -112
- package/src/codegen/table.ts +0 -254
- package/src/json-patch.ts +0 -273
- package/src/testing.ts +0 -74
package/lib/graphql.types.js
CHANGED
|
@@ -1,6 +1 @@
|
|
|
1
|
-
|
|
2
|
-
const deployment = /*@__PURE__*/ service.latestDeployment.pipe(
|
|
3
|
-
/*@__PURE__*/ mapQuery((d) => ({ id: d.id, status: d.status })));
|
|
4
|
-
const popular = /*@__PURE__*/ service.stars.pipe(/*@__PURE__*/ mapQuery((stars) => stars > 5));
|
|
5
|
-
const labels = /*@__PURE__*/ service.tags.pipe(/*@__PURE__*/ mapQuery((tag) => tag.label));
|
|
6
|
-
//# sourceMappingURL=graphql.types.js.map
|
|
1
|
+
export {};
|
package/lib/index.d.ts
CHANGED
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
*
|
|
10
10
|
* Each namespace is also importable on its own subpath
|
|
11
11
|
* (`@distilled.cloud/core/response-validation`, ...); generated SDKs use the
|
|
12
|
-
* subpaths.
|
|
13
|
-
*
|
|
12
|
+
* subpaths. The code generator and test helpers live in the unpublished
|
|
13
|
+
* `@distilled.cloud/dev` package.
|
|
14
14
|
*/
|
|
15
15
|
export * as API from "./api.ts";
|
|
16
16
|
export * as Category from "./category.ts";
|
|
@@ -24,5 +24,6 @@ export * as Crypto from "./crypto.ts";
|
|
|
24
24
|
export * as ResponseValidation from "./response-validation.ts";
|
|
25
25
|
export * as Retry from "./retry.ts";
|
|
26
26
|
export * as RetryAfter from "./retry-after.ts";
|
|
27
|
+
export * as Telemetry from "./telemetry.ts";
|
|
27
28
|
export * as Trait from "./trait.ts";
|
|
28
29
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAChC,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AACtC,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AACxC,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAC;AAC9C,OAAO,KAAK,YAAY,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,YAAY,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AACtC,OAAO,KAAK,kBAAkB,MAAM,0BAA0B,CAAC;AAC/D,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAC;AAC/C,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAChC,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AACtC,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AACxC,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAC;AAC9C,OAAO,KAAK,YAAY,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,YAAY,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AACtC,OAAO,KAAK,kBAAkB,MAAM,0BAA0B,CAAC;AAC/D,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAC;AAC/C,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAC;AAC5C,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -1,17 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
1
|
export * as API from "./api.js";
|
|
16
2
|
export * as Category from "./category.js";
|
|
17
3
|
export * as Errors from "./errors.js";
|
|
@@ -24,5 +10,5 @@ export * as Crypto from "./crypto.js";
|
|
|
24
10
|
export * as ResponseValidation from "./response-validation.js";
|
|
25
11
|
export * as Retry from "./retry.js";
|
|
26
12
|
export * as RetryAfter from "./retry-after.js";
|
|
13
|
+
export * as Telemetry from "./telemetry.js";
|
|
27
14
|
export * as Trait from "./trait.js";
|
|
28
|
-
//# sourceMappingURL=index.js.map
|
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,8 +22,11 @@ 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" | "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
|
/** The path to the output member containing the next page/cursor token */
|
|
28
32
|
readonly outputToken?: string;
|
|
@@ -89,6 +93,29 @@ export declare const paginateToken: <Input extends Record<string, unknown>, Outp
|
|
|
89
93
|
* terminates, so a malformed response can't spin forever.
|
|
90
94
|
*/
|
|
91
95
|
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>;
|
|
96
|
+
/**
|
|
97
|
+
* Hand a response's headers to the link traversal running on this fiber, if
|
|
98
|
+
* any. Protocols call it for every response they decode; outside
|
|
99
|
+
* {@link paginateLink} it does nothing.
|
|
100
|
+
*/
|
|
101
|
+
export declare const recordPageHeaders: (context: Context.Context<never>, headers: Readonly<Record<string, string | undefined>>) => void;
|
|
102
|
+
/**
|
|
103
|
+
* The URL of the `rel="next"` link in a `Link` header value, e.g.
|
|
104
|
+
* `<https://api.github.com/repositories/1/issues?page=2>; rel="next", <...>; rel="last"`.
|
|
105
|
+
*/
|
|
106
|
+
export declare const nextLink: (header: string | undefined) => string | undefined;
|
|
107
|
+
/**
|
|
108
|
+
* Stream of pages that follows the `Link` response header: each request
|
|
109
|
+
* takes `inputToken` from the query of the previous response's `rel="next"`
|
|
110
|
+
* URL, and traversal ends when a response has no next link (or its token
|
|
111
|
+
* repeats the current one). The response body carries no token, so this
|
|
112
|
+
* works for APIs whose list responses are bare arrays.
|
|
113
|
+
*
|
|
114
|
+
* The protocol must report response headers through
|
|
115
|
+
* {@link recordPageHeaders} (the REST protocol does); otherwise traversal
|
|
116
|
+
* stops after the first page.
|
|
117
|
+
*/
|
|
118
|
+
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
119
|
/**
|
|
93
120
|
* Shared default pagination dispatcher for SDKs that use generic
|
|
94
121
|
* token/cursor/page traversal.
|
|
@@ -103,4 +130,9 @@ export declare const paginateWithDefaults: PaginationStrategy;
|
|
|
103
130
|
* @returns A Stream of individual items
|
|
104
131
|
*/
|
|
105
132
|
export declare const extractItems: <Output, Item, E, R>(pages: Stream.Stream<Output, E, R>, itemsPath: string) => Stream.Stream<Item, E, R>;
|
|
133
|
+
/**
|
|
134
|
+
* The items of a stream of pages that are themselves the lists (bare-array
|
|
135
|
+
* responses).
|
|
136
|
+
*/
|
|
137
|
+
export declare const extractArrayItems: <Output, Item, E, R>(pages: Stream.Stream<Output, E, R>) => Stream.Stream<Item, E, R>;
|
|
106
138
|
//# 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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ANGED
|
@@ -1,271 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import * as Stream from "effect/Stream";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export const getPath = (obj, path) => {
|
|
8
|
-
const parts = path.split(".");
|
|
9
|
-
let current = obj;
|
|
10
|
-
for (const part of parts) {
|
|
11
|
-
if (current == null || typeof current !== "object") {
|
|
12
|
-
return undefined;
|
|
13
|
-
}
|
|
14
|
-
current = current[part];
|
|
15
|
-
}
|
|
16
|
-
return current;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
export const getItems = (obj, path) => {
|
|
31
|
-
let current = [obj];
|
|
32
|
-
for (const part of path.split(".")) {
|
|
33
|
-
const next = [];
|
|
34
|
-
for (const value of current) {
|
|
35
|
-
if (value == null || typeof value !== "object")
|
|
36
|
-
continue;
|
|
37
|
-
const child = value[part];
|
|
38
|
-
if (Array.isArray(child)) {
|
|
39
|
-
for (const item of child)
|
|
40
|
-
next.push(item);
|
|
41
|
-
}
|
|
42
|
-
else if (child != null)
|
|
43
|
-
next.push(child);
|
|
44
|
-
}
|
|
45
|
-
current = next;
|
|
46
|
-
}
|
|
47
|
-
return current;
|
|
48
|
-
};
|
|
49
|
-
const missingPaginationConfig = (kind) => Stream.die(new Error(kind));
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
export const isTerminalToken = (token) => token === undefined || token === null || token === "";
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
export const paginateSingle = (operation, input) =>
|
|
66
|
-
// `Stream.fromEffect` keeps `mapEffect`'s concurrency machinery out of bundles.
|
|
67
|
-
Stream.fromEffect(Effect.suspend(() => operation(input)));
|
|
68
|
-
// ============================================================================
|
|
69
|
-
// Page-based Pagination
|
|
70
|
-
// ============================================================================
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
export const paginatePageNumber = (operation, input, pagination) => {
|
|
77
|
-
const inputToken = pagination.inputToken;
|
|
78
|
-
const outputToken = pagination.outputToken;
|
|
79
|
-
if (!inputToken || !outputToken) {
|
|
80
|
-
return missingPaginationConfig("Page-number pagination requires inputToken and outputToken");
|
|
81
|
-
}
|
|
82
|
-
const startPage = typeof input[inputToken] === "number" ? input[inputToken] : 1;
|
|
83
|
-
return Stream.unfold({ page: startPage, done: false }, (state) => Effect.gen(function* () {
|
|
84
|
-
if (state.done)
|
|
85
|
-
return undefined;
|
|
86
|
-
const requestPayload = { ...input, [inputToken]: state.page };
|
|
87
|
-
const response = yield* operation(requestPayload);
|
|
88
|
-
const nextPage = getPath(response, outputToken);
|
|
89
|
-
// Some APIs report the CURRENT page at `outputToken` rather than the
|
|
90
|
-
// next one (e.g. Cloudflare's `result_info.page`). Taking that value as
|
|
91
|
-
// the next page re-requests the same page forever. Only accept an
|
|
92
|
-
// *advancing* page number; otherwise advance by one and terminate when
|
|
93
|
-
// a page comes back with no items (or the token is absent).
|
|
94
|
-
const items = pagination.items
|
|
95
|
-
? getPath(response, pagination.items)
|
|
96
|
-
: undefined;
|
|
97
|
-
const nextState = {
|
|
98
|
-
page: typeof nextPage === "number" && nextPage > state.page ? nextPage : state.page + 1,
|
|
99
|
-
done: nextPage === null ||
|
|
100
|
-
nextPage === undefined ||
|
|
101
|
-
(items !== undefined && items.length === 0),
|
|
102
|
-
};
|
|
103
|
-
return [response, nextState];
|
|
104
|
-
}));
|
|
105
|
-
};
|
|
106
|
-
// ============================================================================
|
|
107
|
-
// Cursor-based Pagination
|
|
108
|
-
// ============================================================================
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
export const paginateCursor = (operation, input, pagination) => {
|
|
115
|
-
const inputToken = pagination.inputToken;
|
|
116
|
-
const outputToken = pagination.outputToken;
|
|
117
|
-
if (!inputToken || !outputToken) {
|
|
118
|
-
return missingPaginationConfig("Cursor pagination requires inputToken and outputToken");
|
|
119
|
-
}
|
|
120
|
-
const startCursor = typeof input[inputToken] === "string" ? input[inputToken] : undefined;
|
|
121
|
-
return Stream.suspend(() => {
|
|
122
|
-
// Cursor history belongs to this traversal, not to the reusable stream.
|
|
123
|
-
const requestedCursors = new Set();
|
|
124
|
-
return Stream.unfold({ cursor: startCursor, done: false }, (state) => Effect.gen(function* () {
|
|
125
|
-
if (state.done)
|
|
126
|
-
return undefined;
|
|
127
|
-
if (state.cursor !== undefined)
|
|
128
|
-
requestedCursors.add(state.cursor);
|
|
129
|
-
const requestPayload = {
|
|
130
|
-
...input,
|
|
131
|
-
...(state.cursor ? { [inputToken]: state.cursor } : {}),
|
|
132
|
-
};
|
|
133
|
-
const response = yield* operation(requestPayload);
|
|
134
|
-
const nextCursor = getPath(response, outputToken);
|
|
135
|
-
const nextState = {
|
|
136
|
-
cursor: nextCursor ?? undefined,
|
|
137
|
-
done: isTerminalToken(nextCursor) || (nextCursor != null && requestedCursors.has(nextCursor)),
|
|
138
|
-
};
|
|
139
|
-
return [response, nextState];
|
|
140
|
-
}));
|
|
141
|
-
});
|
|
142
|
-
};
|
|
143
|
-
// ============================================================================
|
|
144
|
-
// Token-based Pagination (AWS style)
|
|
145
|
-
// ============================================================================
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
export const paginateToken = (operation, input, pagination) => {
|
|
151
|
-
const inputToken = pagination.inputToken;
|
|
152
|
-
const outputToken = pagination.outputToken;
|
|
153
|
-
if (!inputToken || !outputToken) {
|
|
154
|
-
return missingPaginationConfig("Token pagination requires inputToken and outputToken");
|
|
155
|
-
}
|
|
156
|
-
const startToken = input[inputToken];
|
|
157
|
-
return Stream.unfold({ token: startToken, done: false }, (state) => Effect.gen(function* () {
|
|
158
|
-
if (state.done)
|
|
159
|
-
return undefined;
|
|
160
|
-
const requestPayload = state.token !== undefined ? { ...input, [inputToken]: state.token } : input;
|
|
161
|
-
const response = yield* operation(requestPayload);
|
|
162
|
-
const nextToken = getPath(response, outputToken);
|
|
163
|
-
const nextState = {
|
|
164
|
-
token: nextToken,
|
|
165
|
-
done: isTerminalToken(nextToken),
|
|
166
|
-
};
|
|
167
|
-
return [response, nextState];
|
|
168
|
-
}));
|
|
169
|
-
};
|
|
170
|
-
// ============================================================================
|
|
171
|
-
// Relay Pagination (GraphQL connections)
|
|
172
|
-
// ============================================================================
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
export const paginateRelay = (operation, input, pagination) => {
|
|
186
|
-
const inputToken = pagination.inputToken;
|
|
187
|
-
const outputToken = pagination.outputToken;
|
|
188
|
-
if (!inputToken || !outputToken) {
|
|
189
|
-
return missingPaginationConfig("Relay pagination requires inputToken and outputToken");
|
|
190
|
-
}
|
|
191
|
-
// `pageInfo.endCursor` -> `pageInfo.hasNextPage` when the trait doesn't say.
|
|
192
|
-
const hasNextPath = pagination.hasNextPage ??
|
|
193
|
-
`${outputToken.split(".").slice(0, -1).concat("hasNextPage").join(".")}`;
|
|
194
|
-
const startCursor = typeof input[inputToken] === "string" ? input[inputToken] : undefined;
|
|
195
|
-
return Stream.unfold({ cursor: startCursor, done: false }, (state) => Effect.gen(function* () {
|
|
196
|
-
if (state.done)
|
|
197
|
-
return undefined;
|
|
198
|
-
const requestPayload = {
|
|
199
|
-
...input,
|
|
200
|
-
...(state.cursor ? { [inputToken]: state.cursor } : {}),
|
|
201
|
-
};
|
|
202
|
-
const response = yield* operation(requestPayload);
|
|
203
|
-
const nextCursor = getPath(response, outputToken);
|
|
204
|
-
const hasNext = getPath(response, hasNextPath) === true;
|
|
205
|
-
// An empty page means the connection is exhausted regardless of what
|
|
206
|
-
// `hasNextPage` claims -- re-requesting the same cursor would loop.
|
|
207
|
-
const emptyPage = pagination.items !== undefined && getItems(response, pagination.items).length === 0;
|
|
208
|
-
// A connection that keeps returning the same `endCursor` with
|
|
209
|
-
// `hasNextPage: true` (Railway `projects` has done this) would
|
|
210
|
-
// otherwise paginate forever.
|
|
211
|
-
const stuckCursor = state.cursor !== undefined &&
|
|
212
|
-
nextCursor !== undefined &&
|
|
213
|
-
nextCursor !== null &&
|
|
214
|
-
nextCursor === state.cursor;
|
|
215
|
-
const nextState = {
|
|
216
|
-
cursor: nextCursor ?? undefined,
|
|
217
|
-
done: !hasNext || isTerminalToken(nextCursor) || emptyPage || stuckCursor,
|
|
218
|
-
};
|
|
219
|
-
return [response, nextState];
|
|
220
|
-
}));
|
|
221
|
-
};
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
export const paginateWithDefaults = (operation, input, pagination) => {
|
|
227
|
-
const mode = pagination.mode ?? "token";
|
|
228
|
-
switch (mode) {
|
|
229
|
-
case "page":
|
|
230
|
-
return paginatePageNumber(operation, input, pagination);
|
|
231
|
-
case "cursor":
|
|
232
|
-
return paginateCursor(operation, input, pagination);
|
|
233
|
-
case "relay":
|
|
234
|
-
return paginateRelay(operation, input, pagination);
|
|
235
|
-
case "single":
|
|
236
|
-
return paginateSingle(operation, input, pagination);
|
|
237
|
-
case "token":
|
|
238
|
-
default:
|
|
239
|
-
return paginateToken(operation, input, pagination);
|
|
240
|
-
}
|
|
241
|
-
};
|
|
242
|
-
// ============================================================================
|
|
243
|
-
// Item extraction
|
|
244
|
-
// ============================================================================
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
export const extractItems = (pages, itemsPath) =>
|
|
254
|
-
// Flattens each pulled chunk of pages directly, skipping pages with no
|
|
255
|
-
// items. `Stream.flatMap` / `flattenIterable` would do the same but pull in
|
|
256
|
-
// Effect's concurrent-merge machinery (Queue, Semaphore, ...): about 5 KB
|
|
257
|
-
// gzip in every bundle that uses a paginated operation.
|
|
258
|
-
Stream.transformPull(pages, (pull) => {
|
|
259
|
-
// Same error channel as `pull` (its `Done` included), so the stream ends where the pages end.
|
|
260
|
-
const next = Effect.flatMap(pull, (chunk) => {
|
|
261
|
-
const items = [];
|
|
262
|
-
for (const page of chunk)
|
|
263
|
-
for (const item of getItems(page, itemsPath))
|
|
264
|
-
items.push(item);
|
|
265
|
-
return items.length > 0
|
|
266
|
-
? Effect.succeed(items)
|
|
267
|
-
: next;
|
|
268
|
-
});
|
|
269
|
-
return Effect.succeed(next);
|
|
270
|
-
});
|
|
271
|
-
//# sourceMappingURL=pagination.js.map
|
|
1
|
+
export { pagination$extractArrayItems as extractArrayItems, pagination$extractItems as extractItems, pagination$getItems as getItems, pagination$getPath as getPath, pagination$isTerminalToken as isTerminalToken, pagination$nextLink as nextLink, pagination$paginateCursor as paginateCursor, 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";
|
package/lib/plain-values.js
CHANGED
|
@@ -1,40 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import * as Redacted from "effect/Redacted";
|
|
7
|
-
|
|
8
|
-
export const isOpaqueValue = (v) => v instanceof Blob ||
|
|
9
|
-
v instanceof File ||
|
|
10
|
-
v instanceof ArrayBuffer ||
|
|
11
|
-
v instanceof Uint8Array ||
|
|
12
|
-
v instanceof Date;
|
|
13
|
-
const isPlainObject = (v) => v !== null &&
|
|
14
|
-
typeof v === "object" &&
|
|
15
|
-
!Array.isArray(v) &&
|
|
16
|
-
!isOpaqueValue(v) &&
|
|
17
|
-
(Object.getPrototypeOf(v) === Object.prototype || Object.getPrototypeOf(v) === null);
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
export const unwrapRedactedDeep = (value) => {
|
|
25
|
-
if (Redacted.isRedacted(value))
|
|
26
|
-
return Redacted.value(value);
|
|
27
|
-
if (Array.isArray(value))
|
|
28
|
-
return value.map(unwrapRedactedDeep);
|
|
29
|
-
if (isPlainObject(value)) {
|
|
30
|
-
const out = {};
|
|
31
|
-
for (const [k, v] of Object.entries(value)) {
|
|
32
|
-
if (v === undefined)
|
|
33
|
-
continue;
|
|
34
|
-
out[k] = unwrapRedactedDeep(v);
|
|
35
|
-
}
|
|
36
|
-
return out;
|
|
37
|
-
}
|
|
38
|
-
return value;
|
|
39
|
-
};
|
|
1
|
+
import*as e from"effect/Redacted";const isOpaqueValue=e=>e instanceof Blob||e instanceof File||e instanceof ArrayBuffer||e instanceof Uint8Array||e instanceof Date;const isPlainObject=e=>e!==null&&typeof e===`object`&&!Array.isArray(e)&&!isOpaqueValue(e)&&(Object.getPrototypeOf(e)===Object.prototype||Object.getPrototypeOf(e)===null);const unwrapRedactedDeep=t=>{if(e.isRedacted(t))return e.value(t);if(Array.isArray(t))return t.map(unwrapRedactedDeep);if(isPlainObject(t)){const e={};for(const[n,r]of Object.entries(t)){if(r===void 0)continue;e[n]=unwrapRedactedDeep(r)}return e}return t};export{isOpaqueValue,unwrapRedactedDeep};
|
|
40
2
|
//# sourceMappingURL=plain-values.js.map
|
package/lib/plain-values.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plain-values.js","
|
|
1
|
+
{"version":3,"file":"plain-values.js","names":["Redacted","v","value","out","k"],"sources":["../src/plain-values.ts"],"mappings":"kCAQA,MAAa,cAAiB,GAC5BC,aAAa,MACbA,aAAa,MACbA,aAAa,aACbA,aAAa,YACbA,aAAa,KAEf,MAAM,cAAiB,GACrBA,IAAM,MACN,OAAOA,IAAM,UACb,CAAC,MAAM,QAAQA,CAAC,GAChB,CAAC,cAAcA,CAAC,IACf,OAAO,eAAeA,CAAC,IAAM,OAAO,WAAa,OAAO,eAAeA,CAAC,IAAM,MAQjF,MAAa,mBAAsB,GAA4B,CAC7D,GAAID,EAAS,WAAWE,CAAK,EAAG,OAAOF,EAAS,MAAME,CAAK,EAC3D,GAAI,MAAM,QAAQA,CAAK,EAAG,OAAOA,EAAM,IAAI,kBAAkB,EAC7D,GAAI,cAAcA,CAAK,EAAG,CACxB,MAAMC,EAA+B,CAAC,EACtC,IAAK,KAAM,CAACC,EAAGH,KAAM,OAAO,QAAQC,CAAK,EAAG,CAC1C,GAAID,IAAM,IAAA,GAAW,SACrB,EAAIG,GAAK,mBAAmBH,CAAC,CAC/B,CACA,OAAOE,CACT,CACA,OAAOD,CACT"}
|
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,9 +12,9 @@ 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";
|
|
14
16
|
import { type ErrorMatcher, type HttpTrait, type KeyDictionaryEntries } from "./trait.ts";
|
|
15
|
-
export
|
|
16
|
-
export declare const getAnn: (ast: AST.AST, symbol: symbol) => unknown;
|
|
17
|
+
export { getAnn, getProps } from "./annotations.ts";
|
|
17
18
|
export declare const getPropAnn: (prop: AST.PropertySignature, symbol: symbol) => unknown;
|
|
18
19
|
export declare const hasPropAnn: (prop: AST.PropertySignature, symbol: symbol) => boolean;
|
|
19
20
|
export declare const nameOf: (prop: AST.PropertySignature, symbol: symbol) => string;
|
|
@@ -84,6 +85,29 @@ export declare const encodeGreedyLabel: (value: string) => string;
|
|
|
84
85
|
* intermediate copies. `url` may carry a query string.
|
|
85
86
|
*/
|
|
86
87
|
export declare const makeRequest: (method: HttpTrait["method"], url: string, headers: Record<string, string>) => HttpClientRequest.HttpClientRequest;
|
|
88
|
+
declare const InvalidInput_base: Schema.TaggedErrorClass<"InvalidInput", {
|
|
89
|
+
readonly member: import("effect/Schema").String;
|
|
90
|
+
readonly message: import("effect/Schema").String;
|
|
91
|
+
}> & (new (...args: any[]) => {
|
|
92
|
+
"@distilled.cloud/error/categories": {
|
|
93
|
+
BadRequestError: true;
|
|
94
|
+
};
|
|
95
|
+
});
|
|
96
|
+
/**
|
|
97
|
+
* The input cannot be sent: a path label whose value would address another
|
|
98
|
+
* resource (`.` or `..`, which the URL parser resolves to the parent path).
|
|
99
|
+
* Raised before anything is sent.
|
|
100
|
+
*/
|
|
101
|
+
export declare class InvalidInput extends /*@__PURE__*/ InvalidInput_base {
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* The refusal for a path label value that would address another resource,
|
|
105
|
+
* or `undefined`. The URL parser resolves a `.` or `..` segment,
|
|
106
|
+
* percent-encoded or not, so no encoding can carry one
|
|
107
|
+
* (`/projects/p1/branches/..` -> `/projects/p1/`). A greedy label keeps its
|
|
108
|
+
* `/`, so each of its segments counts.
|
|
109
|
+
*/
|
|
110
|
+
export declare const invalidLabel: (member: string, value: unknown, greedy?: boolean) => InvalidInput | undefined;
|
|
87
111
|
/**
|
|
88
112
|
* Build an HTTP request from an operation input and its schema, driven by
|
|
89
113
|
* the trait annotations: `Http()` supplies method + URI template, `Label()`
|
|
@@ -96,12 +120,12 @@ export declare const makeRequest: (method: HttpTrait["method"], url: string, hea
|
|
|
96
120
|
* The schema is read once per input schema (see `planFor`); later calls only
|
|
97
121
|
* walk the input value.
|
|
98
122
|
*
|
|
123
|
+
* Fails with {@link InvalidInput}, before anything is sent, when a label is
|
|
124
|
+
* `.` or `..` (for a greedy `{name+}` label, when any of its segments is).
|
|
99
125
|
* Throws when the input schema is missing the `Http()` trait -- a codegen
|
|
100
|
-
* bug
|
|
101
|
-
* greedy `{name+}` label, when any of its segments is). Each surfaces as a
|
|
102
|
-
* defect by the calling protocol's Effect context.
|
|
126
|
+
* bug, which the calling protocol's Effect surfaces as a defect.
|
|
103
127
|
*/
|
|
104
|
-
export declare const buildRequest: (
|
|
128
|
+
export declare const buildRequest: (options: BuildRequestOptions) => Effect.Effect<HttpClientRequest.HttpClientRequest, InvalidInput>;
|
|
105
129
|
/** Parsed response metadata supplied by a protocol after it detects a failure. */
|
|
106
130
|
export interface ErrorResponse {
|
|
107
131
|
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;AAI7C,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,MAAM,MAAM,wBAAwB,CAAC;AAEjD,OAAO,EAcL,KAAK,YAAY,EAEjB,KAAK,SAAS,EACd,KAAK,oBAAoB,EAE1B,MAAM,YAAY,CAAC;AAIpB,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAEpD,eAAO,MAAM,UAAU,SAAU,GAAG,CAAC,iBAAiB,UAAU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