@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/graphql.js
CHANGED
|
@@ -1,65 +1,67 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
53
|
import * as Context from "effect/Context";
|
|
54
54
|
import * as Data from "effect/Data";
|
|
55
55
|
import * as Effect from "effect/Effect";
|
|
56
56
|
import * as Option from "effect/Option";
|
|
57
|
+
import * as Redacted from "effect/Redacted";
|
|
57
58
|
import * as Schedule from "effect/Schedule";
|
|
58
59
|
import * as S from "effect/Schema";
|
|
59
60
|
import * as Stream from "effect/Stream";
|
|
60
|
-
|
|
61
|
-
const
|
|
62
|
-
|
|
61
|
+
import { unwrapRedactedDeep } from "./plain-values.js";
|
|
62
|
+
export const QuerySymbol = /*@__PURE__*/ Symbol.for("@distilled.cloud/graphql/Query");
|
|
63
|
+
const inspect = /*@__PURE__*/ Symbol.for("nodejs.util.inspect.custom");
|
|
64
|
+
|
|
63
65
|
export class GqlError {
|
|
64
66
|
_tag = "GqlError";
|
|
65
67
|
message;
|
|
@@ -67,45 +69,47 @@ export class GqlError {
|
|
|
67
69
|
this.message = message;
|
|
68
70
|
}
|
|
69
71
|
}
|
|
70
|
-
//
|
|
72
|
+
// U+2500U+2500 Errors U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500
|
|
71
73
|
//
|
|
72
74
|
// Every entry of a GraphQL `errors` array becomes one typed issue. Generated
|
|
73
75
|
// SDKs declare tagged error classes plus the matchers that recognize them,
|
|
74
76
|
// scoped to the root fields that can return them (or global). `Query.fn`
|
|
75
77
|
// classifies each entry against the roots its path points at, so the error
|
|
76
78
|
// channel is the union of the errors declared by the roots the plan reads.
|
|
77
|
-
|
|
79
|
+
|
|
78
80
|
export const errorFields = {
|
|
79
81
|
message: S.String,
|
|
80
|
-
code: S.optional(S.String),
|
|
81
|
-
path: S.optional(
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
82
|
+
code: /*@__PURE__*/ S.optional(S.String),
|
|
83
|
+
path: /*@__PURE__*/ S.optional(
|
|
84
|
+
/*@__PURE__*/ S.Array(/*@__PURE__*/ S.Union([S.String, S.Number]))),
|
|
85
|
+
locations: /*@__PURE__*/ S.optional(
|
|
86
|
+
/*@__PURE__*/ S.Array(/*@__PURE__*/ S.Struct({ line: S.Number, column: S.Number }))),
|
|
87
|
+
extensions: /*@__PURE__*/ S.optional(S.Unknown),
|
|
88
|
+
traceId: /*@__PURE__*/ S.optional(S.String),
|
|
89
|
+
status: /*@__PURE__*/ S.optional(S.Number),
|
|
90
|
+
|
|
91
|
+
retryAfter: /*@__PURE__*/ S.optional(S.Number),
|
|
88
92
|
};
|
|
89
|
-
|
|
90
|
-
export class UnknownGraphQLError extends S.TaggedError()("UnknownGraphQLError", {
|
|
93
|
+
|
|
94
|
+
export class UnknownGraphQLError extends /*@__PURE__*/ /*@__PURE__*/ S.TaggedError()("UnknownGraphQLError", {
|
|
91
95
|
...errorFields,
|
|
92
|
-
|
|
93
|
-
coordinate: S.optional(S.String),
|
|
96
|
+
|
|
97
|
+
coordinate: /*@__PURE__*/ S.optional(S.String),
|
|
94
98
|
}) {
|
|
95
99
|
}
|
|
96
|
-
|
|
97
|
-
export class GraphQLFailure extends Data.TaggedError("GraphQLFailure") {
|
|
100
|
+
|
|
101
|
+
export class GraphQLFailure extends /*@__PURE__*/ /*@__PURE__*/ Data.TaggedError("GraphQLFailure") {
|
|
98
102
|
get message() {
|
|
99
103
|
return this.errors
|
|
100
104
|
.map((e) => `${e._tag}${e.path?.length ? ` at ${e.path.join(".")}` : ""}: ${e.message}`)
|
|
101
105
|
.join("; ");
|
|
102
106
|
}
|
|
103
107
|
}
|
|
104
|
-
|
|
105
|
-
export class GraphQLTransportError extends Data.TaggedError("GraphQLTransportError") {
|
|
108
|
+
|
|
109
|
+
export class GraphQLTransportError extends /*@__PURE__*/ /*@__PURE__*/ Data.TaggedError("GraphQLTransportError") {
|
|
106
110
|
}
|
|
107
|
-
|
|
108
|
-
export class GraphQLPaginationError extends Data.TaggedError("GraphQLPaginationError") {
|
|
111
|
+
|
|
112
|
+
export class GraphQLPaginationError extends /*@__PURE__*/ /*@__PURE__*/ Data.TaggedError("GraphQLPaginationError") {
|
|
109
113
|
}
|
|
110
114
|
export const errorSpec = (make, tag, matchers, options = {}) => ({
|
|
111
115
|
tag,
|
|
@@ -114,9 +118,10 @@ export const errorSpec = (make, tag, matchers, options = {}) => ({
|
|
|
114
118
|
retryable: options.retryable ?? false,
|
|
115
119
|
global: options.global ?? false,
|
|
116
120
|
});
|
|
117
|
-
export const scalarField = (name) => ({
|
|
121
|
+
export const scalarField = (name, options = {}) => ({
|
|
118
122
|
name,
|
|
119
123
|
kind: "scalar",
|
|
124
|
+
...(options.sensitive ? { sensitive: true } : {}),
|
|
120
125
|
});
|
|
121
126
|
export const objectField = (name, objectType) => ({
|
|
122
127
|
name,
|
|
@@ -129,7 +134,7 @@ export const listField = (name, itemType, argTypes) => ({
|
|
|
129
134
|
of: itemType,
|
|
130
135
|
argTypes,
|
|
131
136
|
});
|
|
132
|
-
|
|
137
|
+
|
|
133
138
|
export const connectionField = (name, nodeType, argTypes) => ({
|
|
134
139
|
name,
|
|
135
140
|
kind: "connection",
|
|
@@ -163,7 +168,7 @@ const fieldsOf = (typeRef) => {
|
|
|
163
168
|
return fieldsOf(typeRef.of);
|
|
164
169
|
return {};
|
|
165
170
|
};
|
|
166
|
-
export class GqlTransport extends Context.Service()("@distilled.cloud/graphql/Transport") {
|
|
171
|
+
export class GqlTransport extends /*@__PURE__*/ /*@__PURE__*/ Context.Service()("@distilled.cloud/graphql/Transport") {
|
|
167
172
|
}
|
|
168
173
|
const log = (..._args) => { };
|
|
169
174
|
export class QueryNode {
|
|
@@ -270,7 +275,7 @@ export const rootList = (op, field, meta, args, argTypes, errors = []) => make({
|
|
|
270
275
|
type: listRef(objectRef(meta)),
|
|
271
276
|
errors,
|
|
272
277
|
});
|
|
273
|
-
|
|
278
|
+
|
|
274
279
|
export const rootConnection = (op, field, meta, args, argTypes, errors = []) => make({
|
|
275
280
|
_tag: "Root",
|
|
276
281
|
op,
|
|
@@ -281,8 +286,8 @@ export const rootConnection = (op, field, meta, args, argTypes, errors = []) =>
|
|
|
281
286
|
connection: true,
|
|
282
287
|
errors,
|
|
283
288
|
});
|
|
284
|
-
|
|
285
|
-
export const rootLeaf = (op, field, list, args, argTypes, errors = []) => make({
|
|
289
|
+
|
|
290
|
+
export const rootLeaf = (op, field, list, args, argTypes, errors = [], options = {}) => make({
|
|
286
291
|
_tag: "Root",
|
|
287
292
|
op,
|
|
288
293
|
field,
|
|
@@ -290,6 +295,7 @@ export const rootLeaf = (op, field, list, args, argTypes, errors = []) => make({
|
|
|
290
295
|
argTypes,
|
|
291
296
|
type: list ? listRef({ tag: "scalar" }) : { tag: "scalar" },
|
|
292
297
|
errors,
|
|
298
|
+
...(options.sensitive ? { sensitive: true } : {}),
|
|
293
299
|
});
|
|
294
300
|
const printExpr = (expr) => {
|
|
295
301
|
switch (expr._tag) {
|
|
@@ -345,7 +351,8 @@ const bindArgs = (forest, args, argTypes) => {
|
|
|
345
351
|
return hasArgs ? bound : undefined;
|
|
346
352
|
};
|
|
347
353
|
const ensureChild = (forest, parent, field, options) => {
|
|
348
|
-
const
|
|
354
|
+
const args = unwrapRedactedDeep(options.args);
|
|
355
|
+
const key = args === undefined ? field : `${field}:${stableStringify(args)}`;
|
|
349
356
|
const existing = parent.children.get(key);
|
|
350
357
|
if (existing)
|
|
351
358
|
return existing;
|
|
@@ -359,10 +366,11 @@ const ensureChild = (forest, parent, field, options) => {
|
|
|
359
366
|
const sel = {
|
|
360
367
|
field,
|
|
361
368
|
alias,
|
|
362
|
-
args: bindArgs(forest,
|
|
369
|
+
args: bindArgs(forest, args, options.argTypes),
|
|
363
370
|
children: new Map(),
|
|
364
371
|
isScalar: options.isScalar ?? false,
|
|
365
372
|
isList: options.isList ?? false,
|
|
373
|
+
...(options.sensitive ? { sensitive: true } : {}),
|
|
366
374
|
};
|
|
367
375
|
parent.children.set(key, sel);
|
|
368
376
|
return sel;
|
|
@@ -385,6 +393,7 @@ const paintAbs = (forest, expr) => {
|
|
|
385
393
|
// Leaf roots (`projectDelete: Boolean!`) take no sub-selection.
|
|
386
394
|
isScalar: expr.type.tag === "scalar" || (expr.type.tag === "list" && expr.type.of.tag === "scalar"),
|
|
387
395
|
isList: expr.type.tag === "list" && !expr.connection,
|
|
396
|
+
sensitive: expr.sensitive,
|
|
388
397
|
});
|
|
389
398
|
const key = node.alias ?? node.field;
|
|
390
399
|
forest.rootAlias.set(expr, key);
|
|
@@ -399,6 +408,7 @@ const paintAbs = (forest, expr) => {
|
|
|
399
408
|
argTypes: expr.field.argTypes,
|
|
400
409
|
isScalar: expr.field.kind === "scalar",
|
|
401
410
|
isList: expr.field.kind === "list",
|
|
411
|
+
sensitive: expr.field.sensitive,
|
|
402
412
|
});
|
|
403
413
|
const path = [...parentPath, node.alias ?? node.field];
|
|
404
414
|
return expr.field.kind === "connection" ? [...path, ...paintConnection(forest, node)] : path;
|
|
@@ -455,6 +465,7 @@ const paintRel = (forest, expr, listSel) => {
|
|
|
455
465
|
argTypes: expr.field.argTypes,
|
|
456
466
|
isScalar: expr.field.kind === "scalar",
|
|
457
467
|
isList: expr.field.kind === "list",
|
|
468
|
+
sensitive: expr.field.sensitive,
|
|
458
469
|
});
|
|
459
470
|
if (expr.field.kind === "connection")
|
|
460
471
|
paintConnection(forest, child);
|
|
@@ -530,10 +541,10 @@ const visitRel = (plan, forest, listSel) => {
|
|
|
530
541
|
}
|
|
531
542
|
}
|
|
532
543
|
};
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
544
|
+
|
|
545
|
+
|
|
546
|
+
|
|
547
|
+
|
|
537
548
|
const visitPlan = (plan, forest) => {
|
|
538
549
|
if (isQuery(plan)) {
|
|
539
550
|
log("visit", printExpr(plan.expr));
|
|
@@ -629,6 +640,25 @@ const readField = (parent, name) => {
|
|
|
629
640
|
}
|
|
630
641
|
return parent[name];
|
|
631
642
|
};
|
|
643
|
+
|
|
644
|
+
const redactStrings = (value) => typeof value === "string"
|
|
645
|
+
? Redacted.make(value)
|
|
646
|
+
: Array.isArray(value)
|
|
647
|
+
? value.map(redactStrings)
|
|
648
|
+
: value;
|
|
649
|
+
|
|
650
|
+
const redactSelected = (sel, data) => {
|
|
651
|
+
if (sel.children.size === 0 || data === null || typeof data !== "object")
|
|
652
|
+
return data;
|
|
653
|
+
if (Array.isArray(data))
|
|
654
|
+
return data.map((item) => redactSelected(sel, item));
|
|
655
|
+
const out = { ...data };
|
|
656
|
+
for (const child of sel.children.values()) {
|
|
657
|
+
const key = child.alias ?? child.field;
|
|
658
|
+
out[key] = child.sensitive ? redactStrings(out[key]) : redactSelected(child, out[key]);
|
|
659
|
+
}
|
|
660
|
+
return out;
|
|
661
|
+
};
|
|
632
662
|
const extractAbs = (expr, data, rootAlias) => {
|
|
633
663
|
switch (expr._tag) {
|
|
634
664
|
case "Root": {
|
|
@@ -735,10 +765,10 @@ const interpretPlan = (plan, data, rootAlias) => Effect.gen(function* () {
|
|
|
735
765
|
}
|
|
736
766
|
return plan;
|
|
737
767
|
});
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
768
|
+
|
|
769
|
+
|
|
770
|
+
|
|
771
|
+
|
|
742
772
|
const evaluatePlan = (plan) => Effect.gen(function* () {
|
|
743
773
|
const forest = emptyForest();
|
|
744
774
|
visitPlan(plan, forest);
|
|
@@ -752,25 +782,26 @@ const evaluatePlan = (plan) => Effect.gen(function* () {
|
|
|
752
782
|
}
|
|
753
783
|
return (yield* interpretPlan(plan, data, rootAlias));
|
|
754
784
|
});
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
785
|
+
|
|
786
|
+
|
|
787
|
+
|
|
788
|
+
|
|
789
|
+
|
|
760
790
|
const execute = (compiled) => {
|
|
761
791
|
const once = Effect.gen(function* () {
|
|
762
792
|
const transport = yield* GqlTransport;
|
|
763
793
|
const response = yield* transport.execute(compiled);
|
|
794
|
+
const data = redactSelected(compiled.tree, response.data);
|
|
764
795
|
const raw = response.errors ?? [];
|
|
765
796
|
if (raw.length === 0)
|
|
766
|
-
return
|
|
797
|
+
return data;
|
|
767
798
|
const issues = raw.map((error) => classify(compiled, error, response));
|
|
768
799
|
const [first, ...rest] = issues;
|
|
769
800
|
return yield* Effect.fail(rest.every((issue) => issue._tag === first._tag)
|
|
770
801
|
? first
|
|
771
802
|
: new GraphQLFailure({
|
|
772
803
|
errors: [first, ...rest],
|
|
773
|
-
data
|
|
804
|
+
data,
|
|
774
805
|
status: response.status,
|
|
775
806
|
}));
|
|
776
807
|
});
|
|
@@ -792,11 +823,11 @@ const isRetryable = (compiled, error) => {
|
|
|
792
823
|
: retryable.has(error._tag);
|
|
793
824
|
};
|
|
794
825
|
const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
826
|
+
|
|
827
|
+
|
|
828
|
+
|
|
829
|
+
|
|
830
|
+
|
|
800
831
|
const classify = (compiled, raw, response) => {
|
|
801
832
|
const path = Array.isArray(raw.path) ? raw.path : undefined;
|
|
802
833
|
const root = typeof path?.[0] === "string" ? compiled.rootErrors.get(path[0]) : undefined;
|
|
@@ -847,7 +878,7 @@ const classify = (compiled, raw, response) => {
|
|
|
847
878
|
const uniqueByTag = (specs) => [
|
|
848
879
|
...new Map(specs.map((spec) => [spec.tag, spec])).values(),
|
|
849
880
|
];
|
|
850
|
-
|
|
881
|
+
|
|
851
882
|
export const ofQuery = (value) => make({ _tag: "Literal", value, type: { tag: "scalar" } });
|
|
852
883
|
const filterImpl = (source, predicate) => {
|
|
853
884
|
const proto = itemQuery(source);
|
|
@@ -922,22 +953,22 @@ export function flatMapQuery(sourceOrFlatMapFn, flatMapFn) {
|
|
|
922
953
|
}
|
|
923
954
|
return flatMapImpl(sourceOrFlatMapFn, flatMapFn);
|
|
924
955
|
}
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
956
|
+
|
|
957
|
+
|
|
958
|
+
|
|
959
|
+
|
|
960
|
+
|
|
930
961
|
export const queryFn = (build) => (...args) => {
|
|
931
962
|
const plan = build(...args);
|
|
932
963
|
return evaluatePlan(plan);
|
|
933
964
|
};
|
|
934
|
-
//
|
|
965
|
+
// U+2500U+2500 Pagination U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500U+2500
|
|
935
966
|
//
|
|
936
967
|
// A connection lens hides `edges`/`pageInfo`. `Query.pages` re-evaluates the
|
|
937
968
|
// query once per page: it sets the connection's `after` argument, paints
|
|
938
969
|
// `pageInfo { hasNextPage endCursor }` next to `edges`, and stops when
|
|
939
970
|
// `hasNextPage` is false.
|
|
940
|
-
|
|
971
|
+
|
|
941
972
|
const connectionOf = (expr) => {
|
|
942
973
|
const base = graphqlBase(expr);
|
|
943
974
|
const isConnection = (base._tag === "Root" && base.connection === true) ||
|
|
@@ -951,7 +982,7 @@ const connectionOf = (expr) => {
|
|
|
951
982
|
}
|
|
952
983
|
return base;
|
|
953
984
|
};
|
|
954
|
-
|
|
985
|
+
|
|
955
986
|
const withCursor = (expr, connection, after) => {
|
|
956
987
|
if (expr === connection) {
|
|
957
988
|
const current = expr;
|
|
@@ -1008,12 +1039,12 @@ const fetchPage = (query, connection, state) => Effect.gen(function* () {
|
|
|
1008
1039
|
Option.some({ after: cursor, seen: new Set([...state.seen, cursor]) }),
|
|
1009
1040
|
];
|
|
1010
1041
|
});
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1042
|
+
|
|
1043
|
+
|
|
1044
|
+
|
|
1045
|
+
|
|
1046
|
+
|
|
1047
|
+
|
|
1017
1048
|
export const pagesQuery = (query) => Stream.unwrap(Effect.sync(() => {
|
|
1018
1049
|
const connection = connectionOf(query.expr);
|
|
1019
1050
|
const after = connection.args?.after;
|
|
@@ -1022,6 +1053,6 @@ export const pagesQuery = (query) => Stream.unwrap(Effect.sync(() => {
|
|
|
1022
1053
|
seen: new Set(),
|
|
1023
1054
|
}, (state) => fetchPage(query, connection, state).pipe(Effect.map(([items, next]) => [[items], next])));
|
|
1024
1055
|
}));
|
|
1025
|
-
|
|
1056
|
+
|
|
1026
1057
|
export const itemsQuery = (query) => pagesQuery(query).pipe(Stream.flatMap(Stream.fromIterable));
|
|
1027
1058
|
//# sourceMappingURL=graphql.js.map
|