@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.
Files changed (312) hide show
  1. package/lib/api.d.ts +118 -13
  2. package/lib/api.d.ts.map +1 -1
  3. package/lib/api.js +755 -147
  4. package/lib/api.js.map +1 -1
  5. package/lib/category.d.ts.map +1 -1
  6. package/lib/category.js +146 -146
  7. package/lib/category.js.map +1 -1
  8. package/lib/chunks.d.ts +3 -0
  9. package/lib/chunks.d.ts.map +1 -0
  10. package/lib/chunks.js +11 -0
  11. package/lib/chunks.js.map +1 -0
  12. package/lib/codegen/boolean-string-enums.js +36 -36
  13. package/lib/codegen/chunk.d.ts +7 -0
  14. package/lib/codegen/chunk.d.ts.map +1 -0
  15. package/lib/codegen/chunk.js +139 -0
  16. package/lib/codegen/chunk.js.map +1 -0
  17. package/lib/codegen/cli.d.ts.map +1 -1
  18. package/lib/codegen/cli.js +28 -14
  19. package/lib/codegen/cli.js.map +1 -1
  20. package/lib/codegen/datafy.d.ts +14 -0
  21. package/lib/codegen/datafy.d.ts.map +1 -0
  22. package/lib/codegen/datafy.js +853 -0
  23. package/lib/codegen/datafy.js.map +1 -0
  24. package/lib/codegen/dedupe.d.ts +5 -0
  25. package/lib/codegen/dedupe.d.ts.map +1 -0
  26. package/lib/codegen/dedupe.js +153 -0
  27. package/lib/codegen/dedupe.js.map +1 -0
  28. package/lib/codegen/emit.js +56 -56
  29. package/lib/codegen/format.js +18 -18
  30. package/lib/codegen/generated-at.js +29 -29
  31. package/lib/codegen/generator.d.ts.map +1 -1
  32. package/lib/codegen/generator.js +92 -84
  33. package/lib/codegen/generator.js.map +1 -1
  34. package/lib/codegen/graph.js +36 -36
  35. package/lib/codegen/graphql-client.d.ts +2 -0
  36. package/lib/codegen/graphql-client.d.ts.map +1 -1
  37. package/lib/codegen/graphql-client.js +55 -26
  38. package/lib/codegen/graphql-client.js.map +1 -1
  39. package/lib/codegen/graphql.js +113 -113
  40. package/lib/codegen/latin1.d.ts +3 -0
  41. package/lib/codegen/latin1.d.ts.map +1 -0
  42. package/lib/codegen/latin1.js +126 -0
  43. package/lib/codegen/latin1.js.map +1 -0
  44. package/lib/codegen/members.d.ts +7 -0
  45. package/lib/codegen/members.d.ts.map +1 -1
  46. package/lib/codegen/members.js +26 -19
  47. package/lib/codegen/members.js.map +1 -1
  48. package/lib/codegen/model-diff.js +6 -6
  49. package/lib/codegen/naming.js +19 -19
  50. package/lib/codegen/openapi-cli.js +15 -15
  51. package/lib/codegen/openapi.d.ts +17 -0
  52. package/lib/codegen/openapi.d.ts.map +1 -1
  53. package/lib/codegen/openapi.js +323 -169
  54. package/lib/codegen/openapi.js.map +1 -1
  55. package/lib/codegen/operations.js +14 -14
  56. package/lib/codegen/pagination.js +11 -11
  57. package/lib/codegen/patch-audit.js +57 -57
  58. package/lib/codegen/patches.js +79 -79
  59. package/lib/codegen/prelude.js +19 -19
  60. package/lib/codegen/privatize.d.ts +21 -0
  61. package/lib/codegen/privatize.d.ts.map +1 -0
  62. package/lib/codegen/privatize.js +176 -0
  63. package/lib/codegen/privatize.js.map +1 -0
  64. package/lib/codegen/proto.js +25 -25
  65. package/lib/codegen/pure.d.ts +6 -0
  66. package/lib/codegen/pure.d.ts.map +1 -0
  67. package/lib/codegen/pure.js +91 -0
  68. package/lib/codegen/pure.js.map +1 -0
  69. package/lib/codegen/rewrite-operation-ids.js +108 -108
  70. package/lib/codegen/spec-path.js +57 -57
  71. package/lib/codegen/table.d.ts +5 -0
  72. package/lib/codegen/table.d.ts.map +1 -0
  73. package/lib/codegen/table.js +249 -0
  74. package/lib/codegen/table.js.map +1 -0
  75. package/lib/config.d.ts +27 -0
  76. package/lib/config.d.ts.map +1 -0
  77. package/lib/config.js +161 -0
  78. package/lib/config.js.map +1 -0
  79. package/lib/crypto.d.ts +76 -0
  80. package/lib/crypto.d.ts.map +1 -0
  81. package/lib/crypto.js +130 -0
  82. package/lib/crypto.js.map +1 -0
  83. package/lib/debug.d.ts +2 -0
  84. package/lib/debug.d.ts.map +1 -0
  85. package/lib/debug.js +8 -0
  86. package/lib/debug.js.map +1 -0
  87. package/lib/error-category.d.ts +1 -1
  88. package/lib/error-category.d.ts.map +1 -1
  89. package/lib/error-category.js +7 -6
  90. package/lib/error-category.js.map +1 -1
  91. package/lib/errors.d.ts +62 -62
  92. package/lib/errors.d.ts.map +1 -1
  93. package/lib/errors.js +117 -114
  94. package/lib/errors.js.map +1 -1
  95. package/lib/graphql.d.ts +31 -20
  96. package/lib/graphql.d.ts.map +1 -1
  97. package/lib/graphql.js +150 -119
  98. package/lib/graphql.js.map +1 -1
  99. package/lib/graphql.types.js +4 -3
  100. package/lib/graphql.types.js.map +1 -1
  101. package/lib/index.d.ts +3 -2
  102. package/lib/index.d.ts.map +1 -1
  103. package/lib/index.js +15 -14
  104. package/lib/index.js.map +1 -1
  105. package/lib/json-patch.d.ts +2 -2
  106. package/lib/json-patch.js +28 -28
  107. package/lib/pagination.d.ts +9 -25
  108. package/lib/pagination.d.ts.map +1 -1
  109. package/lib/pagination.js +95 -90
  110. package/lib/pagination.js.map +1 -1
  111. package/lib/plain-values.d.ts +10 -0
  112. package/lib/plain-values.d.ts.map +1 -0
  113. package/lib/plain-values.js +40 -0
  114. package/lib/plain-values.js.map +1 -0
  115. package/lib/protocol-http.d.ts +50 -14
  116. package/lib/protocol-http.d.ts.map +1 -1
  117. package/lib/protocol-http.js +351 -178
  118. package/lib/protocol-http.js.map +1 -1
  119. package/lib/protocol-rest.d.ts +38 -25
  120. package/lib/protocol-rest.d.ts.map +1 -1
  121. package/lib/protocol-rest.js +238 -130
  122. package/lib/protocol-rest.js.map +1 -1
  123. package/lib/query.js +16 -16
  124. package/lib/response-validation-strict.d.ts +48 -0
  125. package/lib/response-validation-strict.d.ts.map +1 -0
  126. package/lib/response-validation-strict.js +284 -0
  127. package/lib/response-validation-strict.js.map +1 -0
  128. package/lib/response-validation.d.ts +43 -25
  129. package/lib/response-validation.d.ts.map +1 -1
  130. package/lib/response-validation.js +112 -70
  131. package/lib/response-validation.js.map +1 -1
  132. package/lib/retry-after.d.ts +3 -3
  133. package/lib/retry-after.js +49 -49
  134. package/lib/retry.d.ts +48 -29
  135. package/lib/retry.d.ts.map +1 -1
  136. package/lib/retry.js +142 -154
  137. package/lib/retry.js.map +1 -1
  138. package/lib/schema-lite-impl.d.ts +158 -0
  139. package/lib/schema-lite-impl.d.ts.map +1 -0
  140. package/lib/schema-lite-impl.js +341 -0
  141. package/lib/schema-lite-impl.js.map +1 -0
  142. package/lib/schema-lite-typed.d.ts +41 -0
  143. package/lib/schema-lite-typed.d.ts.map +1 -0
  144. package/lib/schema-lite-typed.js +27 -0
  145. package/lib/schema-lite-typed.js.map +1 -0
  146. package/lib/schema-lite.d.ts +40 -0
  147. package/lib/schema-lite.d.ts.map +1 -0
  148. package/lib/schema-lite.js +31 -0
  149. package/lib/schema-lite.js.map +1 -0
  150. package/lib/schema.d.ts +20 -6
  151. package/lib/schema.d.ts.map +1 -1
  152. package/lib/schema.js +202 -30
  153. package/lib/schema.js.map +1 -1
  154. package/lib/testing.d.ts +3 -2
  155. package/lib/testing.d.ts.map +1 -1
  156. package/lib/testing.js +22 -21
  157. package/lib/testing.js.map +1 -1
  158. package/lib/trait.d.ts +13 -13
  159. package/lib/trait.d.ts.map +1 -1
  160. package/lib/trait.js +80 -80
  161. package/lib/trait.js.map +1 -1
  162. package/lib/xml.d.ts +1 -1
  163. package/lib/xml.d.ts.map +1 -1
  164. package/lib/xml.js +38 -26
  165. package/lib/xml.js.map +1 -1
  166. package/package.json +9 -7
  167. package/src/api.ts +1079 -180
  168. package/src/category.ts +33 -33
  169. package/src/chunks.ts +30 -0
  170. package/src/codegen/chunk.ts +147 -0
  171. package/src/codegen/cli.ts +27 -1
  172. package/src/codegen/datafy.ts +874 -0
  173. package/src/codegen/dedupe.ts +173 -0
  174. package/src/codegen/generator.ts +10 -3
  175. package/src/codegen/graphql-client.ts +49 -15
  176. package/src/codegen/latin1.ts +131 -0
  177. package/src/codegen/members.ts +8 -0
  178. package/src/codegen/openapi.ts +194 -3
  179. package/src/codegen/privatize.ts +200 -0
  180. package/src/codegen/pure.ts +94 -0
  181. package/src/codegen/table.ts +254 -0
  182. package/src/config.ts +216 -0
  183. package/src/crypto.ts +202 -0
  184. package/src/debug.ts +8 -0
  185. package/src/error-category.ts +2 -1
  186. package/src/errors.ts +65 -56
  187. package/src/graphql.ts +109 -62
  188. package/src/graphql.types.ts +9 -7
  189. package/src/index.ts +3 -2
  190. package/src/json-patch.ts +2 -2
  191. package/src/pagination.ts +37 -18
  192. package/src/plain-values.ts +41 -0
  193. package/src/protocol-http.ts +378 -145
  194. package/src/protocol-rest.ts +337 -169
  195. package/src/response-validation-strict.ts +327 -0
  196. package/src/response-validation.ts +101 -50
  197. package/src/retry-after.ts +3 -3
  198. package/src/retry.ts +94 -93
  199. package/src/schema-lite-impl.ts +550 -0
  200. package/src/schema-lite-typed.ts +44 -0
  201. package/src/schema-lite.ts +44 -0
  202. package/src/schema.ts +258 -14
  203. package/src/testing.ts +4 -2
  204. package/src/trait.ts +36 -28
  205. package/src/xml.ts +31 -17
  206. package/lib/codegen/boolean-string-enums.test.d.ts +0 -2
  207. package/lib/codegen/boolean-string-enums.test.d.ts.map +0 -1
  208. package/lib/codegen/boolean-string-enums.test.js +0 -275
  209. package/lib/codegen/boolean-string-enums.test.js.map +0 -1
  210. package/lib/codegen/defer-naming.test.d.ts +0 -2
  211. package/lib/codegen/defer-naming.test.d.ts.map +0 -1
  212. package/lib/codegen/defer-naming.test.js +0 -105
  213. package/lib/codegen/defer-naming.test.js.map +0 -1
  214. package/lib/codegen/generated-at.test.d.ts +0 -2
  215. package/lib/codegen/generated-at.test.d.ts.map +0 -1
  216. package/lib/codegen/generated-at.test.js +0 -81
  217. package/lib/codegen/generated-at.test.js.map +0 -1
  218. package/lib/codegen/generator.test.d.ts +0 -2
  219. package/lib/codegen/generator.test.d.ts.map +0 -1
  220. package/lib/codegen/generator.test.js +0 -121
  221. package/lib/codegen/generator.test.js.map +0 -1
  222. package/lib/codegen/graphql-client.test.d.ts +0 -2
  223. package/lib/codegen/graphql-client.test.d.ts.map +0 -1
  224. package/lib/codegen/graphql-client.test.js +0 -171
  225. package/lib/codegen/graphql-client.test.js.map +0 -1
  226. package/lib/codegen/openapi-binary.test.d.ts +0 -2
  227. package/lib/codegen/openapi-binary.test.d.ts.map +0 -1
  228. package/lib/codegen/openapi-binary.test.js +0 -67
  229. package/lib/codegen/openapi-binary.test.js.map +0 -1
  230. package/lib/codegen/patch-audit.test.d.ts +0 -2
  231. package/lib/codegen/patch-audit.test.d.ts.map +0 -1
  232. package/lib/codegen/patch-audit.test.js +0 -141
  233. package/lib/codegen/patch-audit.test.js.map +0 -1
  234. package/lib/codegen/patches.test.d.ts +0 -2
  235. package/lib/codegen/patches.test.d.ts.map +0 -1
  236. package/lib/codegen/patches.test.js +0 -155
  237. package/lib/codegen/patches.test.js.map +0 -1
  238. package/lib/codegen/protocol-imports.test.d.ts +0 -2
  239. package/lib/codegen/protocol-imports.test.d.ts.map +0 -1
  240. package/lib/codegen/protocol-imports.test.js +0 -36
  241. package/lib/codegen/protocol-imports.test.js.map +0 -1
  242. package/lib/codegen/rewrite-operation-ids.test.d.ts +0 -2
  243. package/lib/codegen/rewrite-operation-ids.test.d.ts.map +0 -1
  244. package/lib/codegen/rewrite-operation-ids.test.js +0 -451
  245. package/lib/codegen/rewrite-operation-ids.test.js.map +0 -1
  246. package/lib/codegen/untagged-unions.test.d.ts +0 -2
  247. package/lib/codegen/untagged-unions.test.d.ts.map +0 -1
  248. package/lib/codegen/untagged-unions.test.js +0 -80
  249. package/lib/codegen/untagged-unions.test.js.map +0 -1
  250. package/lib/fixtures/xml/upstream-validator.json +0 -397
  251. package/lib/graphql.test.d.ts +0 -2
  252. package/lib/graphql.test.d.ts.map +0 -1
  253. package/lib/graphql.test.js +0 -151
  254. package/lib/graphql.test.js.map +0 -1
  255. package/lib/json-patch.test.d.ts +0 -2
  256. package/lib/json-patch.test.d.ts.map +0 -1
  257. package/lib/json-patch.test.js +0 -65
  258. package/lib/json-patch.test.js.map +0 -1
  259. package/lib/pagination.test.d.ts +0 -2
  260. package/lib/pagination.test.d.ts.map +0 -1
  261. package/lib/pagination.test.js +0 -131
  262. package/lib/pagination.test.js.map +0 -1
  263. package/lib/protocol-http.test.d.ts +0 -2
  264. package/lib/protocol-http.test.d.ts.map +0 -1
  265. package/lib/protocol-http.test.js +0 -228
  266. package/lib/protocol-http.test.js.map +0 -1
  267. package/lib/protocol-rest.test.d.ts +0 -2
  268. package/lib/protocol-rest.test.d.ts.map +0 -1
  269. package/lib/protocol-rest.test.js +0 -498
  270. package/lib/protocol-rest.test.js.map +0 -1
  271. package/lib/response-validation.test.d.ts +0 -2
  272. package/lib/response-validation.test.d.ts.map +0 -1
  273. package/lib/response-validation.test.js +0 -72
  274. package/lib/response-validation.test.js.map +0 -1
  275. package/lib/retry-after.test.d.ts +0 -2
  276. package/lib/retry-after.test.d.ts.map +0 -1
  277. package/lib/retry-after.test.js +0 -204
  278. package/lib/retry-after.test.js.map +0 -1
  279. package/lib/retry.test.d.ts +0 -2
  280. package/lib/retry.test.d.ts.map +0 -1
  281. package/lib/retry.test.js +0 -407
  282. package/lib/retry.test.js.map +0 -1
  283. package/lib/sdks.test.d.ts +0 -2
  284. package/lib/sdks.test.d.ts.map +0 -1
  285. package/lib/sdks.test.js +0 -76
  286. package/lib/sdks.test.js.map +0 -1
  287. package/lib/xml.test.d.ts +0 -2
  288. package/lib/xml.test.d.ts.map +0 -1
  289. package/lib/xml.test.js +0 -210
  290. package/lib/xml.test.js.map +0 -1
  291. package/src/codegen/boolean-string-enums.test.ts +0 -299
  292. package/src/codegen/defer-naming.test.ts +0 -113
  293. package/src/codegen/generated-at.test.ts +0 -89
  294. package/src/codegen/generator.test.ts +0 -137
  295. package/src/codegen/graphql-client.test.ts +0 -189
  296. package/src/codegen/openapi-binary.test.ts +0 -91
  297. package/src/codegen/patch-audit.test.ts +0 -160
  298. package/src/codegen/patches.test.ts +0 -188
  299. package/src/codegen/protocol-imports.test.ts +0 -39
  300. package/src/codegen/rewrite-operation-ids.test.ts +0 -472
  301. package/src/codegen/untagged-unions.test.ts +0 -85
  302. package/src/fixtures/xml/upstream-validator.json +0 -397
  303. package/src/graphql.test.ts +0 -198
  304. package/src/json-patch.test.ts +0 -77
  305. package/src/pagination.test.ts +0 -169
  306. package/src/protocol-http.test.ts +0 -276
  307. package/src/protocol-rest.test.ts +0 -703
  308. package/src/response-validation.test.ts +0 -89
  309. package/src/retry-after.test.ts +0 -267
  310. package/src/retry.test.ts +0 -566
  311. package/src/sdks.test.ts +0 -87
  312. package/src/xml.test.ts +0 -251
package/lib/graphql.js CHANGED
@@ -1,65 +1,67 @@
1
- /**
2
- * GraphQL Query algebra — the runtime generated GraphQL SDKs target.
3
- *
4
- * ── Why this exists ────────────────────────────────────────────────────────
5
- * A GraphQL document is a *selection*, not an RPC. Distilled used to bake a
6
- * max-depth selection into every operation (`Railway.me({})` downloaded the
7
- * world). This module instead treats every field as a lazy `Query<Value>`:
8
- * reading `user.email` records that field, and nothing is posted until
9
- * `Query.fn` evaluates the plan you returned.
10
- *
11
- * ── The two phases ─────────────────────────────────────────────────────────
12
- * 1. Build (your function). `Railway.me()` / `user.email` / `Query.map` do
13
- * not talk to the network. They construct an expression tree:
14
- * Of | Map | Filter | FlatMap | Prop | Root
15
- * The inner function of `Query.fn` is therefore a *builder*, not an
16
- * Effect generator. No `yield*` inside it.
17
- *
18
- * 2. Evaluate (`Query.fn`). Walk the returned plan, paint every GraphQL
19
- * field that appears onto one selection forest, POST that document
20
- * once through {@link GqlTransport}, then interpret Map/Filter/FlatMap
21
- * against the JSON. Effects reached via FlatMap (e.g.
22
- * `usernameIsAvailable(name)`) run *after* the POST, with real values.
23
- *
24
- * ── Combinators ────────────────────────────────────────────────────────────
25
- * - `Query.of(x)` — a literal; never selected.
26
- * - `Query.map` on a list — callback receives `Query<Item>` so `p.name` is
27
- * still a Query (selected). On a scalar, callback receives the value
28
- * after extract (`stars => stars > 5`). Relay connections (`edges { node }`)
29
- * are lists of the node type, so `projects({ first: 20 }).pipe(Query.map)`
30
- * maps projects, not edges.
31
- * - `Query.filter` — predicate is `Query<Item> => Query<boolean>`; the
32
- * boolean Query is walked for fields, then run per row after the POST.
33
- * - `Query.flatMap` — after extract, run `(value) => Effect | Query`.
34
- * - `Query.pages` / `Query.items` — a Stream over every page / node of a
35
- * Relay connection, one POST per page (see "Pagination").
36
- *
37
- * ── Types ──────────────────────────────────────────────────────────────────
38
- * `Query<Value>` is `QueryNode<Value>` plus the GraphQL fields of `Value`,
39
- * so `user.name` type-checks. That copy is a circular type alias
40
- * (`Query<User>` contains `Query<Project[]>` which contains `Query<User>`
41
- * again). TypeScript leaves the cycle lazy; there is no depth cap.
42
- *
43
- * ── Transport ──────────────────────────────────────────────────────────────
44
- * {@link GqlTransport.execute} posts `{ query, variables, operationName }`.
45
- * The Effect it returns may require Credentials / HttpClient; those leak
46
- * into `Query.fn`'s requirements. It returns the parsed `data` and raw
47
- * `errors`; `Query.fn` classifies the errors (see "Errors" below). Compile
48
- * failures are {@link GqlError} defects.
49
- *
50
- * Generated SDKs export *roots* (`Railway.me`, `Railway.project`).
51
- * Combinators live in `@distilled.cloud/core/query`.
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
- export const QuerySymbol = Symbol.for("@distilled.cloud/graphql/Query");
61
- const inspect = Symbol.for("nodejs.util.inspect.custom");
62
- /** A plan that cannot be compiled (a programming error, raised as a defect). */
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
- // ── Errors ──────────────────────────────────────────────────────────────────
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
- /** Fields every classified GraphQL error carries. */
79
+
78
80
  export const errorFields = {
79
81
  message: S.String,
80
- code: S.optional(S.String),
81
- path: S.optional(S.Array(S.Union([S.String, S.Number]))),
82
- locations: S.optional(S.Array(S.Struct({ line: S.Number, column: S.Number }))),
83
- extensions: S.optional(S.Unknown),
84
- traceId: S.optional(S.String),
85
- status: S.optional(S.Number),
86
- /** Server retry hint in seconds. */
87
- retryAfter: S.optional(S.Number),
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
- /** A GraphQL error no declared matcher recognizes. */
90
- export class UnknownGraphQLError extends S.TaggedError()("UnknownGraphQLError", {
93
+
94
+ export class UnknownGraphQLError extends /*@__PURE__*/ /*@__PURE__*/ S.TaggedError()("UnknownGraphQLError", {
91
95
  ...errorFields,
92
- /** Root field the error path points at, when the path is known. */
93
- coordinate: S.optional(S.String),
96
+
97
+ coordinate: /*@__PURE__*/ S.optional(S.String),
94
98
  }) {
95
99
  }
96
- /** One response carried errors with different tags; none is hidden. */
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
- /** The request never produced a GraphQL response (network, HTTP, non-JSON). */
105
- export class GraphQLTransportError extends Data.TaggedError("GraphQLTransportError") {
108
+
109
+ export class GraphQLTransportError extends /*@__PURE__*/ /*@__PURE__*/ Data.TaggedError("GraphQLTransportError") {
106
110
  }
107
- /** A paginated connection reported more pages without a new cursor. */
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
- /** Relay connection: GraphQL `edges { node }` presented as `Query<Item[]>`. */
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
- /** Root Relay connection: typed as `Query<Item[]>`, document uses `edges { node }`. */
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
- /** Root field whose GraphQL type is a scalar, enum, or list of those. */
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 key = options.args === undefined ? field : `${field}:${stableStringify(options.args)}`;
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, options.args, options.argTypes),
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
- * Recurse through a builder return value. Query nodes contribute GraphQL
535
- * fields to `forest`; Effects are ignored until interpret (FlatMap).
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
- * Compile every Query in `plan` into one document, POST it, then replace
740
- * Query/Effect leaves with plain data (`UnwrapPlan`).
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
- * POST one compiled document and fail with its classified errors. Queries
757
- * are retried (bounded) while every failure is retryable; mutations never
758
- * are, since an error can follow a side effect that already happened.
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 response.data;
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: response.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
- * Pick the most specific matcher among the errors the root at `path[0]`
797
- * declares (or the global errors for a path-less error). A tie between
798
- * different tags is ambiguous and stays {@link UnknownGraphQLError}.
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
- /** `Query.of` / pure. */
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
- * Builder → Effect. The inner function is *not* a generator; it returns a
927
- * plan of Query/Effect values. Query.fn visits the plan, POSTs one document,
928
- * then interprets Map/Filter/FlatMap/Of.
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
- // ── Pagination ──────────────────────────────────────────────────────────────
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
- /** The connection a paged query reads, below any list-level Map/Filter. */
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
- /** Rebuild `expr` with the connection's `after` argument set. */
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
- * Every page of a Relay connection, one request per page. `query` is a
1013
- * connection lens (root or nested under objects), optionally mapped or
1014
- * filtered: `Query.pages(Railway.project({ id }).services({ first: 50 }))`.
1015
- * Starts from the query's own `after` argument, if any.
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
- /** Every node of a Relay connection, across all pages. */
1056
+
1026
1057
  export const itemsQuery = (query) => pagesQuery(query).pipe(Stream.flatMap(Stream.fromIterable));
1027
1058
  //# sourceMappingURL=graphql.js.map