@distilled.cloud/core 1.0.0-rc.15 → 1.0.0-rc.16
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/api.d.ts +118 -13
- package/lib/api.d.ts.map +1 -1
- package/lib/api.js +755 -147
- package/lib/api.js.map +1 -1
- package/lib/category.d.ts.map +1 -1
- package/lib/category.js +146 -146
- package/lib/category.js.map +1 -1
- package/lib/chunks.d.ts +3 -0
- package/lib/chunks.d.ts.map +1 -0
- package/lib/chunks.js +11 -0
- package/lib/chunks.js.map +1 -0
- package/lib/codegen/boolean-string-enums.js +36 -36
- package/lib/codegen/chunk.d.ts +7 -0
- package/lib/codegen/chunk.d.ts.map +1 -0
- package/lib/codegen/chunk.js +139 -0
- package/lib/codegen/chunk.js.map +1 -0
- package/lib/codegen/cli.d.ts.map +1 -1
- package/lib/codegen/cli.js +28 -14
- package/lib/codegen/cli.js.map +1 -1
- package/lib/codegen/datafy.d.ts +14 -0
- package/lib/codegen/datafy.d.ts.map +1 -0
- package/lib/codegen/datafy.js +853 -0
- package/lib/codegen/datafy.js.map +1 -0
- package/lib/codegen/dedupe.d.ts +5 -0
- package/lib/codegen/dedupe.d.ts.map +1 -0
- package/lib/codegen/dedupe.js +153 -0
- package/lib/codegen/dedupe.js.map +1 -0
- package/lib/codegen/emit.js +56 -56
- package/lib/codegen/format.js +18 -18
- package/lib/codegen/generated-at.js +29 -29
- package/lib/codegen/generator.d.ts.map +1 -1
- package/lib/codegen/generator.js +92 -84
- package/lib/codegen/generator.js.map +1 -1
- package/lib/codegen/graph.js +36 -36
- package/lib/codegen/graphql-client.d.ts +2 -0
- package/lib/codegen/graphql-client.d.ts.map +1 -1
- package/lib/codegen/graphql-client.js +55 -26
- package/lib/codegen/graphql-client.js.map +1 -1
- package/lib/codegen/graphql.js +113 -113
- package/lib/codegen/latin1.d.ts +3 -0
- package/lib/codegen/latin1.d.ts.map +1 -0
- package/lib/codegen/latin1.js +126 -0
- package/lib/codegen/latin1.js.map +1 -0
- package/lib/codegen/members.d.ts +7 -0
- package/lib/codegen/members.d.ts.map +1 -1
- package/lib/codegen/members.js +26 -19
- package/lib/codegen/members.js.map +1 -1
- package/lib/codegen/model-diff.js +6 -6
- package/lib/codegen/naming.js +19 -19
- package/lib/codegen/openapi-cli.js +15 -15
- package/lib/codegen/openapi.d.ts +17 -0
- package/lib/codegen/openapi.d.ts.map +1 -1
- package/lib/codegen/openapi.js +323 -169
- package/lib/codegen/openapi.js.map +1 -1
- package/lib/codegen/operations.js +14 -14
- package/lib/codegen/pagination.js +11 -11
- package/lib/codegen/patch-audit.js +57 -57
- package/lib/codegen/patches.js +79 -79
- package/lib/codegen/prelude.js +19 -19
- package/lib/codegen/privatize.d.ts +21 -0
- package/lib/codegen/privatize.d.ts.map +1 -0
- package/lib/codegen/privatize.js +176 -0
- package/lib/codegen/privatize.js.map +1 -0
- package/lib/codegen/proto.js +25 -25
- package/lib/codegen/pure.d.ts +6 -0
- package/lib/codegen/pure.d.ts.map +1 -0
- package/lib/codegen/pure.js +91 -0
- package/lib/codegen/pure.js.map +1 -0
- package/lib/codegen/rewrite-operation-ids.js +108 -108
- package/lib/codegen/spec-path.js +57 -57
- package/lib/codegen/table.d.ts +5 -0
- package/lib/codegen/table.d.ts.map +1 -0
- package/lib/codegen/table.js +249 -0
- package/lib/codegen/table.js.map +1 -0
- package/lib/config.d.ts +27 -0
- package/lib/config.d.ts.map +1 -0
- package/lib/config.js +161 -0
- package/lib/config.js.map +1 -0
- package/lib/crypto.d.ts +76 -0
- package/lib/crypto.d.ts.map +1 -0
- package/lib/crypto.js +130 -0
- package/lib/crypto.js.map +1 -0
- package/lib/debug.d.ts +2 -0
- package/lib/debug.d.ts.map +1 -0
- package/lib/debug.js +8 -0
- package/lib/debug.js.map +1 -0
- package/lib/error-category.d.ts +1 -1
- package/lib/error-category.d.ts.map +1 -1
- package/lib/error-category.js +7 -6
- package/lib/error-category.js.map +1 -1
- package/lib/errors.d.ts +62 -62
- package/lib/errors.d.ts.map +1 -1
- package/lib/errors.js +117 -114
- package/lib/errors.js.map +1 -1
- package/lib/graphql.d.ts +31 -20
- package/lib/graphql.d.ts.map +1 -1
- package/lib/graphql.js +150 -119
- package/lib/graphql.js.map +1 -1
- package/lib/graphql.types.js +4 -3
- package/lib/graphql.types.js.map +1 -1
- package/lib/index.d.ts +3 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +15 -14
- package/lib/index.js.map +1 -1
- package/lib/json-patch.d.ts +2 -2
- package/lib/json-patch.js +28 -28
- package/lib/pagination.d.ts +9 -25
- package/lib/pagination.d.ts.map +1 -1
- package/lib/pagination.js +95 -90
- package/lib/pagination.js.map +1 -1
- package/lib/plain-values.d.ts +10 -0
- package/lib/plain-values.d.ts.map +1 -0
- package/lib/plain-values.js +40 -0
- package/lib/plain-values.js.map +1 -0
- package/lib/protocol-http.d.ts +50 -14
- package/lib/protocol-http.d.ts.map +1 -1
- package/lib/protocol-http.js +351 -178
- package/lib/protocol-http.js.map +1 -1
- package/lib/protocol-rest.d.ts +38 -25
- package/lib/protocol-rest.d.ts.map +1 -1
- package/lib/protocol-rest.js +238 -130
- package/lib/protocol-rest.js.map +1 -1
- package/lib/query.js +16 -16
- package/lib/response-validation-strict.d.ts +48 -0
- package/lib/response-validation-strict.d.ts.map +1 -0
- package/lib/response-validation-strict.js +284 -0
- package/lib/response-validation-strict.js.map +1 -0
- package/lib/response-validation.d.ts +43 -25
- package/lib/response-validation.d.ts.map +1 -1
- package/lib/response-validation.js +112 -70
- package/lib/response-validation.js.map +1 -1
- package/lib/retry-after.d.ts +3 -3
- package/lib/retry-after.js +49 -49
- package/lib/retry.d.ts +48 -29
- package/lib/retry.d.ts.map +1 -1
- package/lib/retry.js +142 -154
- package/lib/retry.js.map +1 -1
- package/lib/schema-lite-impl.d.ts +158 -0
- package/lib/schema-lite-impl.d.ts.map +1 -0
- package/lib/schema-lite-impl.js +341 -0
- package/lib/schema-lite-impl.js.map +1 -0
- package/lib/schema-lite-typed.d.ts +41 -0
- package/lib/schema-lite-typed.d.ts.map +1 -0
- package/lib/schema-lite-typed.js +27 -0
- package/lib/schema-lite-typed.js.map +1 -0
- package/lib/schema-lite.d.ts +40 -0
- package/lib/schema-lite.d.ts.map +1 -0
- package/lib/schema-lite.js +31 -0
- package/lib/schema-lite.js.map +1 -0
- package/lib/schema.d.ts +20 -6
- package/lib/schema.d.ts.map +1 -1
- package/lib/schema.js +202 -30
- package/lib/schema.js.map +1 -1
- package/lib/testing.d.ts +3 -2
- package/lib/testing.d.ts.map +1 -1
- package/lib/testing.js +22 -21
- package/lib/testing.js.map +1 -1
- package/lib/trait.d.ts +13 -13
- package/lib/trait.d.ts.map +1 -1
- package/lib/trait.js +80 -80
- package/lib/trait.js.map +1 -1
- package/lib/xml.d.ts +1 -1
- package/lib/xml.d.ts.map +1 -1
- package/lib/xml.js +38 -26
- package/lib/xml.js.map +1 -1
- package/package.json +9 -7
- package/src/api.ts +1079 -180
- package/src/category.ts +33 -33
- package/src/chunks.ts +30 -0
- package/src/codegen/chunk.ts +147 -0
- package/src/codegen/cli.ts +27 -1
- package/src/codegen/datafy.ts +874 -0
- package/src/codegen/dedupe.ts +173 -0
- package/src/codegen/generator.ts +10 -3
- package/src/codegen/graphql-client.ts +49 -15
- package/src/codegen/latin1.ts +131 -0
- package/src/codegen/members.ts +8 -0
- package/src/codegen/openapi.ts +194 -3
- package/src/codegen/privatize.ts +200 -0
- package/src/codegen/pure.ts +94 -0
- package/src/codegen/table.ts +254 -0
- package/src/config.ts +216 -0
- package/src/crypto.ts +202 -0
- package/src/debug.ts +8 -0
- package/src/error-category.ts +2 -1
- package/src/errors.ts +65 -56
- package/src/graphql.ts +109 -62
- package/src/graphql.types.ts +9 -7
- package/src/index.ts +3 -2
- package/src/json-patch.ts +2 -2
- package/src/pagination.ts +37 -18
- package/src/plain-values.ts +41 -0
- package/src/protocol-http.ts +378 -145
- package/src/protocol-rest.ts +337 -169
- package/src/response-validation-strict.ts +327 -0
- package/src/response-validation.ts +101 -50
- package/src/retry-after.ts +3 -3
- package/src/retry.ts +94 -93
- package/src/schema-lite-impl.ts +550 -0
- package/src/schema-lite-typed.ts +44 -0
- package/src/schema-lite.ts +44 -0
- package/src/schema.ts +258 -14
- package/src/testing.ts +4 -2
- package/src/trait.ts +36 -28
- package/src/xml.ts +31 -17
- package/lib/codegen/boolean-string-enums.test.d.ts +0 -2
- package/lib/codegen/boolean-string-enums.test.d.ts.map +0 -1
- package/lib/codegen/boolean-string-enums.test.js +0 -275
- package/lib/codegen/boolean-string-enums.test.js.map +0 -1
- package/lib/codegen/defer-naming.test.d.ts +0 -2
- package/lib/codegen/defer-naming.test.d.ts.map +0 -1
- package/lib/codegen/defer-naming.test.js +0 -105
- package/lib/codegen/defer-naming.test.js.map +0 -1
- package/lib/codegen/generated-at.test.d.ts +0 -2
- package/lib/codegen/generated-at.test.d.ts.map +0 -1
- package/lib/codegen/generated-at.test.js +0 -81
- package/lib/codegen/generated-at.test.js.map +0 -1
- package/lib/codegen/generator.test.d.ts +0 -2
- package/lib/codegen/generator.test.d.ts.map +0 -1
- package/lib/codegen/generator.test.js +0 -121
- package/lib/codegen/generator.test.js.map +0 -1
- package/lib/codegen/graphql-client.test.d.ts +0 -2
- package/lib/codegen/graphql-client.test.d.ts.map +0 -1
- package/lib/codegen/graphql-client.test.js +0 -171
- package/lib/codegen/graphql-client.test.js.map +0 -1
- package/lib/codegen/openapi-binary.test.d.ts +0 -2
- package/lib/codegen/openapi-binary.test.d.ts.map +0 -1
- package/lib/codegen/openapi-binary.test.js +0 -67
- package/lib/codegen/openapi-binary.test.js.map +0 -1
- package/lib/codegen/patch-audit.test.d.ts +0 -2
- package/lib/codegen/patch-audit.test.d.ts.map +0 -1
- package/lib/codegen/patch-audit.test.js +0 -141
- package/lib/codegen/patch-audit.test.js.map +0 -1
- package/lib/codegen/patches.test.d.ts +0 -2
- package/lib/codegen/patches.test.d.ts.map +0 -1
- package/lib/codegen/patches.test.js +0 -155
- package/lib/codegen/patches.test.js.map +0 -1
- package/lib/codegen/protocol-imports.test.d.ts +0 -2
- package/lib/codegen/protocol-imports.test.d.ts.map +0 -1
- package/lib/codegen/protocol-imports.test.js +0 -36
- package/lib/codegen/protocol-imports.test.js.map +0 -1
- package/lib/codegen/rewrite-operation-ids.test.d.ts +0 -2
- package/lib/codegen/rewrite-operation-ids.test.d.ts.map +0 -1
- package/lib/codegen/rewrite-operation-ids.test.js +0 -451
- package/lib/codegen/rewrite-operation-ids.test.js.map +0 -1
- package/lib/codegen/untagged-unions.test.d.ts +0 -2
- package/lib/codegen/untagged-unions.test.d.ts.map +0 -1
- package/lib/codegen/untagged-unions.test.js +0 -80
- package/lib/codegen/untagged-unions.test.js.map +0 -1
- package/lib/fixtures/xml/upstream-validator.json +0 -397
- package/lib/graphql.test.d.ts +0 -2
- package/lib/graphql.test.d.ts.map +0 -1
- package/lib/graphql.test.js +0 -151
- package/lib/graphql.test.js.map +0 -1
- package/lib/json-patch.test.d.ts +0 -2
- package/lib/json-patch.test.d.ts.map +0 -1
- package/lib/json-patch.test.js +0 -65
- package/lib/json-patch.test.js.map +0 -1
- package/lib/pagination.test.d.ts +0 -2
- package/lib/pagination.test.d.ts.map +0 -1
- package/lib/pagination.test.js +0 -131
- package/lib/pagination.test.js.map +0 -1
- package/lib/protocol-http.test.d.ts +0 -2
- package/lib/protocol-http.test.d.ts.map +0 -1
- package/lib/protocol-http.test.js +0 -228
- package/lib/protocol-http.test.js.map +0 -1
- package/lib/protocol-rest.test.d.ts +0 -2
- package/lib/protocol-rest.test.d.ts.map +0 -1
- package/lib/protocol-rest.test.js +0 -498
- package/lib/protocol-rest.test.js.map +0 -1
- package/lib/response-validation.test.d.ts +0 -2
- package/lib/response-validation.test.d.ts.map +0 -1
- package/lib/response-validation.test.js +0 -72
- package/lib/response-validation.test.js.map +0 -1
- package/lib/retry-after.test.d.ts +0 -2
- package/lib/retry-after.test.d.ts.map +0 -1
- package/lib/retry-after.test.js +0 -204
- package/lib/retry-after.test.js.map +0 -1
- package/lib/retry.test.d.ts +0 -2
- package/lib/retry.test.d.ts.map +0 -1
- package/lib/retry.test.js +0 -407
- package/lib/retry.test.js.map +0 -1
- package/lib/sdks.test.d.ts +0 -2
- package/lib/sdks.test.d.ts.map +0 -1
- package/lib/sdks.test.js +0 -76
- package/lib/sdks.test.js.map +0 -1
- package/lib/xml.test.d.ts +0 -2
- package/lib/xml.test.d.ts.map +0 -1
- package/lib/xml.test.js +0 -210
- package/lib/xml.test.js.map +0 -1
- package/src/codegen/boolean-string-enums.test.ts +0 -299
- package/src/codegen/defer-naming.test.ts +0 -113
- package/src/codegen/generated-at.test.ts +0 -89
- package/src/codegen/generator.test.ts +0 -137
- package/src/codegen/graphql-client.test.ts +0 -189
- package/src/codegen/openapi-binary.test.ts +0 -91
- package/src/codegen/patch-audit.test.ts +0 -160
- package/src/codegen/patches.test.ts +0 -188
- package/src/codegen/protocol-imports.test.ts +0 -39
- package/src/codegen/rewrite-operation-ids.test.ts +0 -472
- package/src/codegen/untagged-unions.test.ts +0 -85
- package/src/fixtures/xml/upstream-validator.json +0 -397
- package/src/graphql.test.ts +0 -198
- package/src/json-patch.test.ts +0 -77
- package/src/pagination.test.ts +0 -169
- package/src/protocol-http.test.ts +0 -276
- package/src/protocol-rest.test.ts +0 -703
- package/src/response-validation.test.ts +0 -89
- package/src/retry-after.test.ts +0 -267
- package/src/retry.test.ts +0 -566
- package/src/sdks.test.ts +0 -87
- package/src/xml.test.ts +0 -251
package/lib/pagination.js
CHANGED
|
@@ -1,25 +1,9 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Pagination utilities for streaming through paginated API responses.
|
|
3
|
-
*
|
|
4
|
-
* Supports multiple pagination styles:
|
|
5
|
-
* - Page-based: page/per_page with a page number that advances
|
|
6
|
-
* - Cursor-based: cursor/limit with an opaque next-cursor string
|
|
7
|
-
* - Token-based (AWS style): NextToken/MaxResults continuation tokens
|
|
8
|
-
* - Relay (GraphQL connections): after/first with a `pageInfo` block whose
|
|
9
|
-
* `hasNextPage` — not the cursor — marks the end
|
|
10
|
-
* - Single: one-shot list endpoints that still expose the paginated surface
|
|
11
|
-
*
|
|
12
|
-
* Each SDK stores a {@link PaginatedTrait} on its operations (sourced from the
|
|
13
|
-
* `smithy.api#paginated` trait in its models) and picks a
|
|
14
|
-
* {@link PaginationStrategy}; these shared utilities handle the streaming.
|
|
15
|
-
* Ported from the distilled repo's `core/pagination`.
|
|
16
|
-
*/
|
|
17
1
|
import * as Effect from "effect/Effect";
|
|
18
2
|
import * as Stream from "effect/Stream";
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
23
7
|
export const getPath = (obj, path) => {
|
|
24
8
|
const parts = path.split(".");
|
|
25
9
|
let current = obj;
|
|
@@ -31,18 +15,18 @@ export const getPath = (obj, path) => {
|
|
|
31
15
|
}
|
|
32
16
|
return current;
|
|
33
17
|
};
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
46
30
|
export const getItems = (obj, path) => {
|
|
47
31
|
let current = [obj];
|
|
48
32
|
for (const part of path.split(".")) {
|
|
@@ -51,8 +35,10 @@ export const getItems = (obj, path) => {
|
|
|
51
35
|
if (value == null || typeof value !== "object")
|
|
52
36
|
continue;
|
|
53
37
|
const child = value[part];
|
|
54
|
-
if (Array.isArray(child))
|
|
55
|
-
|
|
38
|
+
if (Array.isArray(child)) {
|
|
39
|
+
for (const item of child)
|
|
40
|
+
next.push(item);
|
|
41
|
+
}
|
|
56
42
|
else if (child != null)
|
|
57
43
|
next.push(child);
|
|
58
44
|
}
|
|
@@ -61,30 +47,32 @@ export const getItems = (obj, path) => {
|
|
|
61
47
|
return current;
|
|
62
48
|
};
|
|
63
49
|
const missingPaginationConfig = (kind) => Stream.die(new Error(kind));
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
74
60
|
export const isTerminalToken = (token) => token === undefined || token === null || token === "";
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
export const paginateSingle = (operation, input) =>
|
|
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)));
|
|
80
68
|
// ============================================================================
|
|
81
69
|
// Page-based Pagination
|
|
82
70
|
// ============================================================================
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
|
|
88
76
|
export const paginatePageNumber = (operation, input, pagination) => {
|
|
89
77
|
const inputToken = pagination.inputToken;
|
|
90
78
|
const outputToken = pagination.outputToken;
|
|
@@ -118,11 +106,11 @@ export const paginatePageNumber = (operation, input, pagination) => {
|
|
|
118
106
|
// ============================================================================
|
|
119
107
|
// Cursor-based Pagination
|
|
120
108
|
// ============================================================================
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
|
|
126
114
|
export const paginateCursor = (operation, input, pagination) => {
|
|
127
115
|
const inputToken = pagination.inputToken;
|
|
128
116
|
const outputToken = pagination.outputToken;
|
|
@@ -155,10 +143,10 @@ export const paginateCursor = (operation, input, pagination) => {
|
|
|
155
143
|
// ============================================================================
|
|
156
144
|
// Token-based Pagination (AWS style)
|
|
157
145
|
// ============================================================================
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
|
|
162
150
|
export const paginateToken = (operation, input, pagination) => {
|
|
163
151
|
const inputToken = pagination.inputToken;
|
|
164
152
|
const outputToken = pagination.outputToken;
|
|
@@ -182,25 +170,25 @@ export const paginateToken = (operation, input, pagination) => {
|
|
|
182
170
|
// ============================================================================
|
|
183
171
|
// Relay Pagination (GraphQL connections)
|
|
184
172
|
// ============================================================================
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
|
|
197
185
|
export const paginateRelay = (operation, input, pagination) => {
|
|
198
186
|
const inputToken = pagination.inputToken;
|
|
199
187
|
const outputToken = pagination.outputToken;
|
|
200
188
|
if (!inputToken || !outputToken) {
|
|
201
189
|
return missingPaginationConfig("Relay pagination requires inputToken and outputToken");
|
|
202
190
|
}
|
|
203
|
-
// `pageInfo.endCursor`
|
|
191
|
+
// `pageInfo.endCursor` -> `pageInfo.hasNextPage` when the trait doesn't say.
|
|
204
192
|
const hasNextPath = pagination.hasNextPage ??
|
|
205
193
|
`${outputToken.split(".").slice(0, -1).concat("hasNextPage").join(".")}`;
|
|
206
194
|
const startCursor = typeof input[inputToken] === "string" ? input[inputToken] : undefined;
|
|
@@ -215,7 +203,7 @@ export const paginateRelay = (operation, input, pagination) => {
|
|
|
215
203
|
const nextCursor = getPath(response, outputToken);
|
|
216
204
|
const hasNext = getPath(response, hasNextPath) === true;
|
|
217
205
|
// An empty page means the connection is exhausted regardless of what
|
|
218
|
-
// `hasNextPage` claims
|
|
206
|
+
// `hasNextPage` claims -- re-requesting the same cursor would loop.
|
|
219
207
|
const emptyPage = pagination.items !== undefined && getItems(response, pagination.items).length === 0;
|
|
220
208
|
// A connection that keeps returning the same `endCursor` with
|
|
221
209
|
// `hasNextPage: true` (Railway `projects` has done this) would
|
|
@@ -231,10 +219,10 @@ export const paginateRelay = (operation, input, pagination) => {
|
|
|
231
219
|
return [response, nextState];
|
|
232
220
|
}));
|
|
233
221
|
};
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
|
|
238
226
|
export const paginateWithDefaults = (operation, input, pagination) => {
|
|
239
227
|
const mode = pagination.mode ?? "token";
|
|
240
228
|
switch (mode) {
|
|
@@ -254,13 +242,30 @@ export const paginateWithDefaults = (operation, input, pagination) => {
|
|
|
254
242
|
// ============================================================================
|
|
255
243
|
// Item extraction
|
|
256
244
|
// ============================================================================
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
export const extractItems = (pages, itemsPath) =>
|
|
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
|
+
});
|
|
266
271
|
//# sourceMappingURL=pagination.js.map
|
package/lib/pagination.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pagination.js","sourceRoot":"","sources":["../src/pagination.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pagination.js","sourceRoot":"","sources":["../src/pagination.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC;;;GAGG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,GAAY,EAAE,IAAY,EAAW,EAAE;IAC7D,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC9B,IAAI,OAAO,GAAY,GAAG,CAAC;IAC3B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,OAAO,IAAI,IAAI,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;YACnD,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,OAAO,GAAI,OAAmC,CAAC,IAAI,CAAC,CAAC;IACvD,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAEF;;;;;;;;;;;GAWG;AACH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AAE,CAAC;QACzB,KAAK,MAAM,IAAI,IAAI,KAAK;YACtB,KAAK,MAAM,IAAI,IAAI,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;gBAAE,KAAK,CAAC,IAAI,CAAC,IAAY,CAAC,CAAC;QACzE,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC;YACrB,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,KAAmD,CAAC;YACrE,CAAC,CAAC,IAAI,CAAC;IACX,CAAC,CACF,CAAC;IACF,OAAO,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AAC9B,CAAC,CAAyC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Binary/opaque values that must never be treated as key-value objects. */
|
|
2
|
+
export declare const isOpaqueValue: (v: unknown) => boolean;
|
|
3
|
+
/**
|
|
4
|
+
* Deep-unwrap `Redacted` values in an input (plain objects/arrays only --
|
|
5
|
+
* class instances, files, and binary payloads pass through untouched).
|
|
6
|
+
* Sensitive input members accept `string | Redacted<string>`; the wire wants
|
|
7
|
+
* the raw string.
|
|
8
|
+
*/
|
|
9
|
+
export declare const unwrapRedactedDeep: (value: unknown) => unknown;
|
|
10
|
+
//# sourceMappingURL=plain-values.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plain-values.d.ts","sourceRoot":"","sources":["../src/plain-values.ts"],"names":[],"mappings":"AAOA,4EAA4E;AAC5E,eAAO,MAAM,aAAa,MAAO,OAAO,KAAG,OAKxB,CAAC;AASpB;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,UAAW,OAAO,KAAG,OAYnD,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
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
|
+
};
|
|
40
|
+
//# sourceMappingURL=plain-values.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plain-values.js","sourceRoot":"","sources":["../src/plain-values.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAE5C,4EAA4E;AAC5E,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAU,EAAW,EAAE,CACnD,CAAC,YAAY,IAAI;IACjB,CAAC,YAAY,IAAI;IACjB,CAAC,YAAY,WAAW;IACxB,CAAC,YAAY,UAAU;IACvB,CAAC,YAAY,IAAI,CAAC;AAEpB,MAAM,aAAa,GAAG,CAAC,CAAU,EAAgC,EAAE,CACjE,CAAC,KAAK,IAAI;IACV,OAAO,CAAC,KAAK,QAAQ;IACrB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;IACjB,CAAC,aAAa,CAAC,CAAC,CAAC;IACjB,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC,SAAS,IAAI,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC;AAEvF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,KAAc,EAAW,EAAE;IAC5D,IAAI,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC;QAAE,OAAO,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC7D,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC;IAC/D,IAAI,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,MAAM,GAAG,GAA4B,EAAE,CAAC;QACxC,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YAC3C,IAAI,CAAC,KAAK,SAAS;gBAAE,SAAS;YAC9B,GAAG,CAAC,CAAC,CAAC,GAAG,kBAAkB,CAAC,CAAC,CAAC,CAAC;QACjC,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC"}
|
package/lib/protocol-http.d.ts
CHANGED
|
@@ -3,14 +3,15 @@ import * as HttpClientRequest from "effect/http/HttpClientRequest";
|
|
|
3
3
|
* Generic REST protocol machinery, shared by SDK protocol layers.
|
|
4
4
|
*
|
|
5
5
|
* Everything here is driven purely by the trait annotations in
|
|
6
|
-
* `core/trait.ts`
|
|
6
|
+
* `core/trait.ts` -- nothing is provider-specific. An SDK protocol (e.g.
|
|
7
7
|
* cloudflare's) supplies credentials/base-URL, calls {@link buildRequest} to
|
|
8
8
|
* encode, and layers its own response-envelope handling on top of the
|
|
9
9
|
* decode-side helpers ({@link getProps}/{@link mapKeys}/
|
|
10
10
|
* {@link matchTypedError}).
|
|
11
11
|
*/
|
|
12
12
|
import type * as AST from "effect/SchemaAST";
|
|
13
|
-
import {
|
|
13
|
+
import { isOpaqueValue } from "./plain-values.ts";
|
|
14
|
+
import { type ErrorMatcher, type HttpTrait, type KeyDictionaryEntries } from "./trait.ts";
|
|
14
15
|
export declare const getProps: (ast: AST.AST) => readonly AST.PropertySignature[];
|
|
15
16
|
export declare const getAnn: (ast: AST.AST, symbol: symbol) => unknown;
|
|
16
17
|
export declare const getPropAnn: (prop: AST.PropertySignature, symbol: symbol) => unknown;
|
|
@@ -18,14 +19,38 @@ export declare const hasPropAnn: (prop: AST.PropertySignature, symbol: symbol) =
|
|
|
18
19
|
export declare const nameOf: (prop: AST.PropertySignature, symbol: symbol) => string;
|
|
19
20
|
/** Resolve wrappers to the real node: Suspend, encoding, optional/null unions. */
|
|
20
21
|
export declare const resolveNode: (ast: AST.AST) => AST.AST;
|
|
21
|
-
/**
|
|
22
|
-
export
|
|
22
|
+
/** An output member read from a response header (`T.Header`). */
|
|
23
|
+
export interface ResponseHeaderMember {
|
|
24
|
+
readonly key: string;
|
|
25
|
+
/** Lowercase header name. */
|
|
26
|
+
readonly wire: string;
|
|
27
|
+
/** The member is a number; the header's text is parsed. */
|
|
28
|
+
readonly number: boolean;
|
|
29
|
+
}
|
|
30
|
+
/** The output's header-bound members, read from the schema once. */
|
|
31
|
+
export declare const responseHeaderMembers: (outputAst: AST.AST) => ReadonlyArray<ResponseHeaderMember>;
|
|
32
|
+
/**
|
|
33
|
+
* Copy the response headers an output declares onto its decoded body. A
|
|
34
|
+
* number member gets the header parsed; text that is not a number is kept
|
|
35
|
+
* as sent, so strict validation reports it. A body that is not an object
|
|
36
|
+
* (a raw root) is returned as is -- generators bind no headers there.
|
|
37
|
+
*/
|
|
38
|
+
export declare const withResponseHeaders: (members: ReadonlyArray<ResponseHeaderMember>, body: unknown, headers: Record<string, string | undefined>) => unknown;
|
|
39
|
+
export { isOpaqueValue };
|
|
23
40
|
/**
|
|
24
41
|
* Deep-rename keys via a plain dictionary (see `T.KeyDictionary`). An entry
|
|
25
42
|
* may list several wire spellings; encode uses the first (canonical) one and
|
|
26
43
|
* decode maps every listed spelling back to the TS name.
|
|
27
44
|
*/
|
|
28
45
|
export declare const mapKeysByDictionary: (dict: KeyDictionaryEntries, value: unknown, direction: "encode" | "decode") => unknown;
|
|
46
|
+
/**
|
|
47
|
+
* Whether {@link mapKeys} returns every value of `root` unchanged (as a deep
|
|
48
|
+
* copy) in `direction` with no fallback dictionary: no member is renamed,
|
|
49
|
+
* string-encoded (encode) or picked by `T.UnionCases` (decode), and no
|
|
50
|
+
* `T.KeyDictionary` is in scope anywhere below `root`. Protocols use it to
|
|
51
|
+
* skip the walk. Computed once per schema node and direction.
|
|
52
|
+
*/
|
|
53
|
+
export declare const mapsVerbatim: (root: AST.AST, direction: "encode" | "decode") => boolean;
|
|
29
54
|
export declare const mapKeys: (ast: AST.AST, value: unknown, direction: "encode" | "decode", fallback?: KeyDictionaryEntries) => unknown;
|
|
30
55
|
export interface BuildRequestOptions {
|
|
31
56
|
readonly input: unknown;
|
|
@@ -40,12 +65,25 @@ export interface BuildRequestOptions {
|
|
|
40
65
|
*/
|
|
41
66
|
readonly mapMemberHeader?: (name: string, value: string) => string;
|
|
42
67
|
/**
|
|
43
|
-
* Wire name for input keys the schema doesn't declare (spec drift
|
|
68
|
+
* Wire name for input keys the schema doesn't declare (spec drift --
|
|
44
69
|
* unknown keys pass through as body fields rather than being dropped).
|
|
45
70
|
* Defaults to the key verbatim.
|
|
46
71
|
*/
|
|
47
72
|
readonly unknownKeyToWire?: (key: string) => string;
|
|
48
73
|
}
|
|
74
|
+
/**
|
|
75
|
+
* Encode a greedy `{name+}` label: the value may span several path
|
|
76
|
+
* segments (e.g. an Azure scope `/subscriptions/{id}/resourceGroups/{rg}`),
|
|
77
|
+
* so each segment is encoded on its own and the `/` separators are kept.
|
|
78
|
+
* Leading slashes are dropped because the URI template already supplies one.
|
|
79
|
+
*/
|
|
80
|
+
export declare const encodeGreedyLabel: (value: string) => string;
|
|
81
|
+
/**
|
|
82
|
+
* `HttpClientRequest.make(method)(url)` with `headers` set, in one object:
|
|
83
|
+
* the same request as `make(...).pipe(setHeaders(headers))` without the
|
|
84
|
+
* intermediate copies. `url` may carry a query string.
|
|
85
|
+
*/
|
|
86
|
+
export declare const makeRequest: (method: HttpTrait["method"], url: string, headers: Record<string, string>) => HttpClientRequest.HttpClientRequest;
|
|
49
87
|
/**
|
|
50
88
|
* Build an HTTP request from an operation input and its schema, driven by
|
|
51
89
|
* the trait annotations: `Http()` supplies method + URI template, `Label()`
|
|
@@ -55,16 +93,14 @@ export interface BuildRequestOptions {
|
|
|
55
93
|
* `FormDataFile()` members become multipart file parts, and everything else
|
|
56
94
|
* is a JSON body field (wire-named via `Body()` / `KeyDictionary`).
|
|
57
95
|
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
*
|
|
63
|
-
* segments
|
|
64
|
-
*
|
|
65
|
-
* Leading slashes are dropped because the URI template already supplies one.
|
|
96
|
+
* The schema is read once per input schema (see `planFor`); later calls only
|
|
97
|
+
* walk the input value.
|
|
98
|
+
*
|
|
99
|
+
* Throws when the input schema is missing the `Http()` trait -- a codegen
|
|
100
|
+
* bug -- and, before anything is sent, when a label is `.` or `..` (for a
|
|
101
|
+
* greedy `{name+}` label, when any of its segments is). Each surfaces as a
|
|
102
|
+
* defect by the calling protocol's Effect context.
|
|
66
103
|
*/
|
|
67
|
-
export declare const encodeGreedyLabel: (value: string) => string;
|
|
68
104
|
export declare const buildRequest: ({ input, inputAst, baseUrl, headers: baseHeaders, mapMemberHeader, unknownKeyToWire, }: BuildRequestOptions) => HttpClientRequest.HttpClientRequest;
|
|
69
105
|
/** Parsed response metadata supplied by a protocol after it detects a failure. */
|
|
70
106
|
export interface ErrorResponse {
|
|
@@ -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":"AAEA,OAAO,KAAK,iBAAiB,MAAM,+BAA+B,CAAC;AACnE;;;;;;;;;GASG;AACH,OAAO,KAAK,KAAK,GAAG,MAAM,kBAAkB,CAAC;AAE7C,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAcL,KAAK,YAAY,EAEjB,KAAK,SAAS,EACd,KAAK,oBAAoB,EAE1B,MAAM,YAAY,CAAC;AAIpB,eAAO,MAAM,QAAQ,QAAS,GAAG,CAAC,GAAG,KAAG,SAAS,GAAG,CAAC,iBAAiB,EAKrE,CAAC;AAEF,eAAO,MAAM,MAAM,QAAS,GAAG,CAAC,GAAG,UAAU,MAAM,KAAG,OAarD,CAAC;AAEF,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;AAEF,kFAAkF;AAClF,eAAO,MAAM,WAAW,QAAS,GAAG,CAAC,GAAG,KAAG,GAAG,CAAC,GAa9C,CAAC;AAKF,iEAAiE;AACjE,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,6BAA6B;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,2DAA2D;IAC3D,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;CAC1B;AAKD,oEAAoE;AACpE,eAAO,MAAM,qBAAqB,cAAe,GAAG,CA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