@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/src/errors.ts CHANGED
@@ -6,8 +6,8 @@
6
6
  * that are used across all SDKs.
7
7
  */
8
8
  import * as Duration from "effect/Duration";
9
- import * as Schema from "effect/Schema";
10
9
  import * as Category from "./category.ts";
10
+ import * as Schema from "./schema-lite-typed.ts";
11
11
 
12
12
  // ============================================================================
13
13
  // Shared Schema Helpers
@@ -18,11 +18,11 @@ import * as Category from "./category.ts";
18
18
  *
19
19
  * Used on retryable errors to carry a server-provided wait hint (e.g. parsed
20
20
  * from `Retry-After` or the IETF `Ratelimit` header). Core does not encode/decode
21
- * this field over the wire — it is constructed at runtime by `matchError` from
21
+ * this field over the wire -- it is constructed at runtime by `matchError` from
22
22
  * whatever the service actually returns (delay-seconds, HTTP-date, epoch, etc.)
23
23
  * and consumed at runtime by the retry policy.
24
24
  */
25
- export const DurationSchema = Schema.declare<Duration.Duration>(Duration.isDuration);
25
+ export const DurationSchema = /*@__PURE__*/ Schema.declare<Duration.Duration>(Duration.isDuration);
26
26
 
27
27
  // ============================================================================
28
28
  // Common HTTP Status Error Classes
@@ -31,61 +31,71 @@ export const DurationSchema = Schema.declare<Duration.Duration>(Duration.isDurat
31
31
  /**
32
32
  * Unauthorized - Authentication failure (401).
33
33
  */
34
- export class Unauthorized extends Schema.TaggedError<Unauthorized>()("Unauthorized", {
35
- message: Schema.String,
36
- }).pipe(Category.withAuthError) {}
34
+ export class Unauthorized
35
+ extends /*@__PURE__*/ Schema.TaggedError<Unauthorized>()("Unauthorized", {
36
+ message: Schema.String,
37
+ }).pipe(Category.withAuthError) {}
37
38
 
38
39
  /**
39
40
  * Forbidden - Access denied (403).
40
41
  */
41
- export class Forbidden extends Schema.TaggedError<Forbidden>()("Forbidden", {
42
- message: Schema.String,
43
- }).pipe(Category.withAuthError) {}
42
+ export class Forbidden
43
+ extends /*@__PURE__*/ Schema.TaggedError<Forbidden>()("Forbidden", {
44
+ message: Schema.String,
45
+ }).pipe(Category.withAuthError) {}
44
46
 
45
47
  /**
46
48
  * NotFound - Resource not found (404).
47
49
  */
48
- export class NotFound extends Schema.TaggedError<NotFound>()("NotFound", {
49
- message: Schema.String,
50
- }).pipe(Category.withNotFoundError) {}
50
+ export class NotFound
51
+ extends /*@__PURE__*/ Schema.TaggedError<NotFound>()("NotFound", {
52
+ message: Schema.String,
53
+ }).pipe(Category.withNotFoundError) {}
51
54
 
52
55
  /**
53
56
  * BadRequest - Invalid request (400).
54
57
  */
55
- export class BadRequest extends Schema.TaggedError<BadRequest>()("BadRequest", {
56
- message: Schema.String,
57
- }).pipe(Category.withBadRequestError) {}
58
+ export class BadRequest
59
+ extends /*@__PURE__*/ Schema.TaggedError<BadRequest>()("BadRequest", {
60
+ message: Schema.String,
61
+ }).pipe(Category.withBadRequestError) {}
58
62
 
59
63
  /**
60
64
  * Conflict - Resource conflict (409).
61
65
  */
62
- export class Conflict extends Schema.TaggedError<Conflict>()("Conflict", {
63
- message: Schema.String,
64
- }).pipe(Category.withConflictError) {}
66
+ export class Conflict
67
+ extends /*@__PURE__*/ Schema.TaggedError<Conflict>()("Conflict", {
68
+ message: Schema.String,
69
+ }).pipe(Category.withConflictError) {}
65
70
 
66
71
  /**
67
72
  * UnprocessableEntity - Validation error (422).
68
73
  */
69
- export class UnprocessableEntity extends Schema.TaggedError<UnprocessableEntity>()(
70
- "UnprocessableEntity",
71
- { message: Schema.String },
72
- ).pipe(Category.withBadRequestError) {}
74
+ export class UnprocessableEntity
75
+ extends /*@__PURE__*/ Schema.TaggedError<UnprocessableEntity>()("UnprocessableEntity", {
76
+ message: Schema.String,
77
+ }).pipe(Category.withBadRequestError) {}
73
78
 
74
79
  /**
75
80
  * TooManyRequests - Rate limited (429).
76
81
  */
77
- export class TooManyRequests extends Schema.TaggedError<TooManyRequests>()("TooManyRequests", {
78
- message: Schema.String,
79
- retryAfter: Schema.optional(DurationSchema),
80
- }).pipe(Category.withThrottlingError, Category.withRetryable({ throttling: true })) {}
82
+ export class TooManyRequests
83
+ extends /*@__PURE__*/ Schema.TaggedError<TooManyRequests>()("TooManyRequests", {
84
+ message: Schema.String,
85
+ retryAfter: /*@__PURE__*/ Schema.optional(DurationSchema),
86
+ }).pipe(
87
+ Category.withThrottlingError,
88
+ /*@__PURE__*/ Category.withRetryable({ throttling: true }),
89
+ ) {}
81
90
 
82
91
  /**
83
92
  * Locked - Resource locked (423).
84
93
  */
85
- export class Locked extends Schema.TaggedError<Locked>()("Locked", {
86
- message: Schema.String,
87
- retryAfter: Schema.optional(DurationSchema),
88
- }).pipe(Category.withLockedError, Category.withRetryable()) {}
94
+ export class Locked
95
+ extends /*@__PURE__*/ Schema.TaggedError<Locked>()("Locked", {
96
+ message: Schema.String,
97
+ retryAfter: /*@__PURE__*/ Schema.optional(DurationSchema),
98
+ }).pipe(Category.withLockedError, /*@__PURE__*/ Category.withRetryable()) {}
89
99
 
90
100
  /**
91
101
  * InternalServerError - Server error.
@@ -95,48 +105,47 @@ export class Locked extends Schema.TaggedError<Locked>()("Locked", {
95
105
  * 200 envelope carrying `{ code: 10002, message: "An unknown error has
96
106
  * occurred" }` for transient backend failures on some endpoints).
97
107
  */
98
- export class InternalServerError extends Schema.TaggedError<InternalServerError>()(
99
- "InternalServerError",
100
- {
108
+ export class InternalServerError
109
+ extends /*@__PURE__*/ Schema.TaggedError<InternalServerError>()("InternalServerError", {
101
110
  message: Schema.String,
102
- code: Schema.optional(Schema.Number),
103
- retryAfter: Schema.optional(DurationSchema),
104
- },
105
- ).pipe(Category.withServerError, Category.withRetryable()) {}
111
+ code: /*@__PURE__*/ Schema.optional(Schema.Number),
112
+ retryAfter: /*@__PURE__*/ Schema.optional(DurationSchema),
113
+ }).pipe(Category.withServerError, /*@__PURE__*/ Category.withRetryable()) {}
106
114
 
107
115
  /**
108
116
  * BadGateway - Bad gateway (502).
109
117
  */
110
- export class BadGateway extends Schema.TaggedError<BadGateway>()("BadGateway", {
111
- message: Schema.String,
112
- retryAfter: Schema.optional(DurationSchema),
113
- }).pipe(Category.withServerError, Category.withRetryable()) {}
118
+ export class BadGateway
119
+ extends /*@__PURE__*/ Schema.TaggedError<BadGateway>()("BadGateway", {
120
+ message: Schema.String,
121
+ retryAfter: /*@__PURE__*/ Schema.optional(DurationSchema),
122
+ }).pipe(Category.withServerError, /*@__PURE__*/ Category.withRetryable()) {}
114
123
 
115
124
  /**
116
125
  * ServiceUnavailable - Service unavailable (503).
117
126
  */
118
- export class ServiceUnavailable extends Schema.TaggedError<ServiceUnavailable>()(
119
- "ServiceUnavailable",
120
- {
127
+ export class ServiceUnavailable
128
+ extends /*@__PURE__*/ Schema.TaggedError<ServiceUnavailable>()("ServiceUnavailable", {
121
129
  message: Schema.String,
122
- retryAfter: Schema.optional(DurationSchema),
123
- },
124
- ).pipe(Category.withServerError, Category.withRetryable()) {}
130
+ retryAfter: /*@__PURE__*/ Schema.optional(DurationSchema),
131
+ }).pipe(Category.withServerError, /*@__PURE__*/ Category.withRetryable()) {}
125
132
 
126
133
  /**
127
134
  * GatewayTimeout - HTTP request or gateway timeout (408, 504).
128
135
  */
129
- export class GatewayTimeout extends Schema.TaggedError<GatewayTimeout>()("GatewayTimeout", {
130
- message: Schema.String,
131
- retryAfter: Schema.optional(DurationSchema),
132
- }).pipe(Category.withServerError, Category.withRetryable()) {}
136
+ export class GatewayTimeout
137
+ extends /*@__PURE__*/ Schema.TaggedError<GatewayTimeout>()("GatewayTimeout", {
138
+ message: Schema.String,
139
+ retryAfter: /*@__PURE__*/ Schema.optional(DurationSchema),
140
+ }).pipe(Category.withServerError, /*@__PURE__*/ Category.withRetryable()) {}
133
141
 
134
142
  /**
135
143
  * Configuration error - missing or invalid configuration.
136
144
  */
137
- export class ConfigError extends Schema.TaggedError<ConfigError>()("ConfigError", {
138
- message: Schema.String,
139
- }).pipe(Category.withConfigurationError) {}
145
+ export class ConfigError
146
+ extends /*@__PURE__*/ Schema.TaggedError<ConfigError>()("ConfigError", {
147
+ message: Schema.String,
148
+ }).pipe(Category.withConfigurationError) {}
140
149
 
141
150
  // ============================================================================
142
151
  // Error Maps
@@ -165,7 +174,7 @@ export const HTTP_STATUS_MAP = {
165
174
  * HTTP status codes that are considered "default" errors (always present).
166
175
  * These are excluded from per-operation error types since they're handled globally.
167
176
  */
168
- export const DEFAULT_ERROR_STATUSES = new Set([401, 429, 500, 502, 503, 504]);
177
+ export const DEFAULT_ERROR_STATUSES = /*@__PURE__*/ new Set([401, 429, 500, 502, 503, 504]);
169
178
 
170
179
  /**
171
180
  * HTTP status codes whose corresponding error class in {@link HTTP_STATUS_MAP}
@@ -177,7 +186,7 @@ export const DEFAULT_ERROR_STATUSES = new Set([401, 429, 500, 502, 503, 504]);
177
186
  * classes (BadRequest/Unauthorized/etc.) would silently retain it as a
178
187
  * stale field on the instance and pollute serialized output.
179
188
  */
180
- export const RETRYABLE_HTTP_STATUSES = new Set([408, 423, 429, 500, 502, 503, 504]);
189
+ export const RETRYABLE_HTTP_STATUSES = /*@__PURE__*/ new Set([408, 423, 429, 500, 502, 503, 504]);
181
190
 
182
191
  /**
183
192
  * All common API error classes.
package/src/graphql.ts CHANGED
@@ -1,14 +1,14 @@
1
1
  /**
2
- * GraphQL Query algebra — the runtime generated GraphQL SDKs target.
2
+ * GraphQL Query algebra -- the runtime generated GraphQL SDKs target.
3
3
  *
4
- * ── Why this exists ────────────────────────────────────────────────────────
4
+ * U+2500U+2500 Why this exists 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+2500
5
5
  * A GraphQL document is a *selection*, not an RPC. Distilled used to bake a
6
6
  * max-depth selection into every operation (`Railway.me({})` downloaded the
7
7
  * world). This module instead treats every field as a lazy `Query<Value>`:
8
8
  * reading `user.email` records that field, and nothing is posted until
9
9
  * `Query.fn` evaluates the plan you returned.
10
10
  *
11
- * ── The two phases ─────────────────────────────────────────────────────────
11
+ * U+2500U+2500 The two phases 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+2500
12
12
  * 1. Build (your function). `Railway.me()` / `user.email` / `Query.map` do
13
13
  * not talk to the network. They construct an expression tree:
14
14
  * Of | Map | Filter | FlatMap | Prop | Root
@@ -21,26 +21,26 @@
21
21
  * against the JSON. Effects reached via FlatMap (e.g.
22
22
  * `usernameIsAvailable(name)`) run *after* the POST, with real values.
23
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
24
+ * U+2500U+2500 Combinators 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+2500
25
+ * - `Query.of(x)` -- a literal; never selected.
26
+ * - `Query.map` on a list -- callback receives `Query<Item>` so `p.name` is
27
27
  * still a Query (selected). On a scalar, callback receives the value
28
28
  * after extract (`stars => stars > 5`). Relay connections (`edges { node }`)
29
29
  * are lists of the node type, so `projects({ first: 20 }).pipe(Query.map)`
30
30
  * maps projects, not edges.
31
- * - `Query.filter` — predicate is `Query<Item> => Query<boolean>`; the
31
+ * - `Query.filter` -- predicate is `Query<Item> => Query<boolean>`; the
32
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
33
+ * - `Query.flatMap` -- after extract, run `(value) => Effect | Query`.
34
+ * - `Query.pages` / `Query.items` -- a Stream over every page / node of a
35
35
  * Relay connection, one POST per page (see "Pagination").
36
36
  *
37
- * ── Types ──────────────────────────────────────────────────────────────────
37
+ * U+2500U+2500 Types 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
38
38
  * `Query<Value>` is `QueryNode<Value>` plus the GraphQL fields of `Value`,
39
39
  * so `user.name` type-checks. That copy is a circular type alias
40
40
  * (`Query<User>` contains `Query<Project[]>` which contains `Query<User>`
41
41
  * again). TypeScript leaves the cycle lazy; there is no depth cap.
42
42
  *
43
- * ── Transport ──────────────────────────────────────────────────────────────
43
+ * U+2500U+2500 Transport 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
44
44
  * {@link GqlTransport.execute} posts `{ query, variables, operationName }`.
45
45
  * The Effect it returns may require Credentials / HttpClient; those leak
46
46
  * into `Query.fn`'s requirements. It returns the parsed `data` and raw
@@ -54,12 +54,14 @@ 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";
61
+ import { unwrapRedactedDeep } from "./plain-values.ts";
60
62
 
61
- export const QuerySymbol = Symbol.for("@distilled.cloud/graphql/Query");
62
- const inspect = Symbol.for("nodejs.util.inspect.custom");
63
+ export const QuerySymbol = /*@__PURE__*/ Symbol.for("@distilled.cloud/graphql/Query");
64
+ const inspect = /*@__PURE__*/ Symbol.for("nodejs.util.inspect.custom");
63
65
 
64
66
  /** A plan that cannot be compiled (a programming error, raised as a defect). */
65
67
  export class GqlError {
@@ -70,7 +72,7 @@ export class GqlError {
70
72
  }
71
73
  }
72
74
 
73
- // ── Errors ──────────────────────────────────────────────────────────────────
75
+ // 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
74
76
  //
75
77
  // Every entry of a GraphQL `errors` array becomes one typed issue. Generated
76
78
  // SDKs declare tagged error classes plus the matchers that recognize them,
@@ -81,14 +83,18 @@ export class GqlError {
81
83
  /** Fields every classified GraphQL error carries. */
82
84
  export const errorFields = {
83
85
  message: S.String,
84
- code: S.optional(S.String),
85
- path: S.optional(S.Array(S.Union([S.String, S.Number]))),
86
- locations: S.optional(S.Array(S.Struct({ line: S.Number, column: S.Number }))),
87
- extensions: S.optional(S.Unknown),
88
- traceId: S.optional(S.String),
89
- status: S.optional(S.Number),
86
+ code: /*@__PURE__*/ S.optional(S.String),
87
+ path: /*@__PURE__*/ S.optional(
88
+ /*@__PURE__*/ S.Array(/*@__PURE__*/ S.Union([S.String, S.Number])),
89
+ ),
90
+ locations: /*@__PURE__*/ S.optional(
91
+ /*@__PURE__*/ S.Array(/*@__PURE__*/ S.Struct({ line: S.Number, column: S.Number })),
92
+ ),
93
+ extensions: /*@__PURE__*/ S.optional(S.Unknown),
94
+ traceId: /*@__PURE__*/ S.optional(S.String),
95
+ status: /*@__PURE__*/ S.optional(S.Number),
90
96
  /** Server retry hint in seconds. */
91
- retryAfter: S.optional(S.Number),
97
+ retryAfter: /*@__PURE__*/ S.optional(S.Number),
92
98
  };
93
99
 
94
100
  /** The shape shared by every classified GraphQL error. */
@@ -110,23 +116,22 @@ export interface GraphQLIssue {
110
116
  export type GraphQLIssueProps = Omit<GraphQLIssue, "_tag">;
111
117
 
112
118
  /** A GraphQL error no declared matcher recognizes. */
113
- export class UnknownGraphQLError extends S.TaggedError<UnknownGraphQLError>()(
114
- "UnknownGraphQLError",
115
- {
119
+ export class UnknownGraphQLError
120
+ extends /*@__PURE__*/ S.TaggedError<UnknownGraphQLError>()("UnknownGraphQLError", {
116
121
  ...errorFields,
117
122
  /** Root field the error path points at, when the path is known. */
118
- coordinate: S.optional(S.String),
119
- },
120
- ) {}
123
+ coordinate: /*@__PURE__*/ S.optional(S.String),
124
+ }) {}
121
125
 
122
126
  /** One response carried errors with different tags; none is hidden. */
123
- export class GraphQLFailure<E extends GraphQLIssue = GraphQLIssue> extends Data.TaggedError(
124
- "GraphQLFailure",
125
- )<{
126
- readonly errors: readonly [E, ...E[]];
127
- readonly data: unknown;
128
- readonly status?: number;
129
- }> {
127
+ export class GraphQLFailure<E extends GraphQLIssue = GraphQLIssue>
128
+ extends /*@__PURE__*/ Data.TaggedError("GraphQLFailure")<{
129
+ readonly errors: readonly [E, ...E[]];
130
+ /** The partial response data, with sensitive fields wrapped in `Redacted`. */
131
+ readonly data: unknown;
132
+ readonly status?: number;
133
+ }>
134
+ {
130
135
  get message(): string {
131
136
  return this.errors
132
137
  .map((e) => `${e._tag}${e.path?.length ? ` at ${e.path.join(".")}` : ""}: ${e.message}`)
@@ -135,19 +140,21 @@ export class GraphQLFailure<E extends GraphQLIssue = GraphQLIssue> extends Data.
135
140
  }
136
141
 
137
142
  /** The request never produced a GraphQL response (network, HTTP, non-JSON). */
138
- export class GraphQLTransportError extends Data.TaggedError("GraphQLTransportError")<{
139
- readonly message: string;
140
- readonly status?: number;
141
- /** Server retry hint in seconds. */
142
- readonly retryAfter?: number;
143
- readonly cause?: unknown;
144
- }> {}
143
+ export class GraphQLTransportError
144
+ extends /*@__PURE__*/ Data.TaggedError("GraphQLTransportError")<{
145
+ readonly message: string;
146
+ readonly status?: number;
147
+ /** Server retry hint in seconds. */
148
+ readonly retryAfter?: number;
149
+ readonly cause?: unknown;
150
+ }> {}
145
151
 
146
152
  /** A paginated connection reported more pages without a new cursor. */
147
- export class GraphQLPaginationError extends Data.TaggedError("GraphQLPaginationError")<{
148
- readonly message: string;
149
- readonly cursor: string | null;
150
- }> {}
153
+ export class GraphQLPaginationError
154
+ extends /*@__PURE__*/ Data.TaggedError("GraphQLPaginationError")<{
155
+ readonly message: string;
156
+ readonly cursor: string | null;
157
+ }> {}
151
158
 
152
159
  /** Recognizes a raw GraphQL error. Every present property must match. */
153
160
  export interface ErrorMatcher {
@@ -207,6 +214,8 @@ export type FieldMeta = {
207
214
  readonly kind: "scalar" | "object" | "list" | "connection";
208
215
  readonly of?: TypeMeta;
209
216
  readonly argTypes?: ArgMeta;
217
+ /** The value is a secret: extracted strings are wrapped in `Redacted`. */
218
+ readonly sensitive?: boolean;
210
219
  };
211
220
 
212
221
  export type TypeMeta = {
@@ -214,9 +223,13 @@ export type TypeMeta = {
214
223
  readonly fields: Record<string, FieldMeta>;
215
224
  };
216
225
 
217
- export const scalarField = (name: string): FieldMeta => ({
226
+ export const scalarField = (
227
+ name: string,
228
+ options: { readonly sensitive?: boolean } = {},
229
+ ): FieldMeta => ({
218
230
  name,
219
231
  kind: "scalar",
232
+ ...(options.sensitive ? { sensitive: true } : {}),
220
233
  });
221
234
  export const objectField = (name: string, objectType: TypeMeta): FieldMeta => ({
222
235
  name,
@@ -279,6 +292,8 @@ export interface SelNode {
279
292
  children: Map<string, SelNode>;
280
293
  isScalar: boolean;
281
294
  isList: boolean;
295
+ /** The value is a secret: its strings are wrapped in `Redacted`. */
296
+ sensitive?: boolean;
282
297
  }
283
298
 
284
299
  export interface CompiledOperation {
@@ -289,21 +304,22 @@ export interface CompiledOperation {
289
304
  readonly tree: SelNode;
290
305
  }
291
306
 
292
- export class GqlTransport extends Context.Service<
293
- GqlTransport,
294
- {
295
- readonly execute: (
296
- req: CompiledOperation,
297
- ) => Effect.Effect<GraphQLResponse, GraphQLTransportError, any>;
298
- }
299
- >()("@distilled.cloud/graphql/Transport") {}
307
+ export class GqlTransport
308
+ extends /*@__PURE__*/ Context.Service<
309
+ GqlTransport,
310
+ {
311
+ readonly execute: (
312
+ req: CompiledOperation,
313
+ ) => Effect.Effect<GraphQLResponse, GraphQLTransportError, any>;
314
+ }
315
+ >()("@distilled.cloud/graphql/Transport") {}
300
316
 
301
317
  const log = (..._args: Array<unknown>): void => {};
302
318
 
303
319
  /**
304
320
  * GraphQL fields copied onto a Query so `user.name` type-checks.
305
321
  * `Query<User>` contains `projects: Query<Project[]>`, which contains
306
- * `owner: Query<User>` again — TypeScript leaves the cycle lazy. Fields
322
+ * `owner: Query<User>` again -- TypeScript leaves the cycle lazy. Fields
307
323
  * inherit the errors of the root they were read from.
308
324
  */
309
325
  type QueryFields<Value, Error> = [NonNullable<Value>] extends [ReadonlyArray<infer Item>]
@@ -385,6 +401,8 @@ type RootExpr = {
385
401
  readonly connection?: boolean;
386
402
  /** Errors this root field can return, including global errors. */
387
403
  readonly errors: ReadonlyArray<ErrorSpec>;
404
+ /** Leaf root whose value is a secret: extracted strings are wrapped in `Redacted`. */
405
+ readonly sensitive?: boolean;
388
406
  };
389
407
 
390
408
  type PropExpr = {
@@ -651,6 +669,7 @@ export const rootLeaf = <Value, Error = never>(
651
669
  args?: Record<string, unknown>,
652
670
  argTypes?: ArgMeta,
653
671
  errors: ReadonlyArray<ErrorSpec> = [],
672
+ options: { readonly sensitive?: boolean } = {},
654
673
  ): Query<Value, Error> =>
655
674
  make({
656
675
  _tag: "Root",
@@ -660,6 +679,7 @@ export const rootLeaf = <Value, Error = never>(
660
679
  argTypes,
661
680
  type: list ? listRef({ tag: "scalar" }) : { tag: "scalar" },
662
681
  errors,
682
+ ...(options.sensitive ? { sensitive: true } : {}),
663
683
  });
664
684
 
665
685
  const printExpr = (expr: Expr): string => {
@@ -706,7 +726,7 @@ type Forest = {
706
726
  varI: number;
707
727
  aliasI: number;
708
728
  rootAlias: WeakMap<object, string>;
709
- /** Response key of each root → the root field and its declared errors. */
729
+ /** Response key of each root -> the root field and its declared errors. */
710
730
  rootErrors: Map<string, RootErrors>;
711
731
  };
712
732
 
@@ -744,9 +764,11 @@ const ensureChild = (
744
764
  argTypes?: ArgMeta;
745
765
  isScalar?: boolean;
746
766
  isList?: boolean;
767
+ sensitive?: boolean;
747
768
  },
748
769
  ): SelNode => {
749
- const key = options.args === undefined ? field : `${field}:${stableStringify(options.args)}`;
770
+ const args = unwrapRedactedDeep(options.args) as Record<string, unknown> | undefined;
771
+ const key = args === undefined ? field : `${field}:${stableStringify(args)}`;
750
772
  const existing = parent.children.get(key);
751
773
  if (existing) return existing;
752
774
  const taken = new Set([...parent.children.values()].map((c) => c.alias ?? c.field));
@@ -759,10 +781,11 @@ const ensureChild = (
759
781
  const sel: SelNode = {
760
782
  field,
761
783
  alias,
762
- args: bindArgs(forest, options.args, options.argTypes),
784
+ args: bindArgs(forest, args, options.argTypes),
763
785
  children: new Map(),
764
786
  isScalar: options.isScalar ?? false,
765
787
  isList: options.isList ?? false,
788
+ ...(options.sensitive ? { sensitive: true } : {}),
766
789
  };
767
790
  parent.children.set(key, sel);
768
791
  return sel;
@@ -790,6 +813,7 @@ const paintAbs = (forest: Forest, expr: Expr): Path => {
790
813
  isScalar:
791
814
  expr.type.tag === "scalar" || (expr.type.tag === "list" && expr.type.of.tag === "scalar"),
792
815
  isList: expr.type.tag === "list" && !expr.connection,
816
+ sensitive: expr.sensitive,
793
817
  });
794
818
  const key = node.alias ?? node.field;
795
819
  forest.rootAlias.set(expr, key);
@@ -804,6 +828,7 @@ const paintAbs = (forest: Forest, expr: Expr): Path => {
804
828
  argTypes: expr.field.argTypes,
805
829
  isScalar: expr.field.kind === "scalar",
806
830
  isList: expr.field.kind === "list",
831
+ sensitive: expr.field.sensitive,
807
832
  });
808
833
  const path = [...parentPath, node.alias ?? node.field];
809
834
  return expr.field.kind === "connection" ? [...path, ...paintConnection(forest, node)] : path;
@@ -864,6 +889,7 @@ const paintRel = (forest: Forest, expr: Expr, listSel: SelNode): void => {
864
889
  argTypes: expr.field.argTypes,
865
890
  isScalar: expr.field.kind === "scalar",
866
891
  isList: expr.field.kind === "list",
892
+ sensitive: expr.field.sensitive,
867
893
  });
868
894
  if (expr.field.kind === "connection") paintConnection(forest, child);
869
895
  return;
@@ -1044,6 +1070,26 @@ const readField = (parent: unknown, name: string): unknown => {
1044
1070
  return (parent as Record<string, unknown>)[name];
1045
1071
  };
1046
1072
 
1073
+ /** Wrap every string of a sensitive scalar (or list of them) in `Redacted`. */
1074
+ const redactStrings = (value: unknown): unknown =>
1075
+ typeof value === "string"
1076
+ ? Redacted.make(value)
1077
+ : Array.isArray(value)
1078
+ ? value.map(redactStrings)
1079
+ : value;
1080
+
1081
+ /** Copy `data` with the strings of every sensitive field `sel` selects wrapped in `Redacted`. */
1082
+ const redactSelected = (sel: SelNode, data: unknown): unknown => {
1083
+ if (sel.children.size === 0 || data === null || typeof data !== "object") return data;
1084
+ if (Array.isArray(data)) return data.map((item) => redactSelected(sel, item));
1085
+ const out: Record<string, unknown> = { ...data };
1086
+ for (const child of sel.children.values()) {
1087
+ const key = child.alias ?? child.field;
1088
+ out[key] = child.sensitive ? redactStrings(out[key]) : redactSelected(child, out[key]);
1089
+ }
1090
+ return out;
1091
+ };
1092
+
1047
1093
  const extractAbs = (expr: Expr, data: unknown, rootAlias: WeakMap<object, string>): unknown => {
1048
1094
  switch (expr._tag) {
1049
1095
  case "Root": {
@@ -1198,8 +1244,9 @@ const execute = (compiled: Compiled): Effect.Effect<unknown, ExecuteError, GqlTr
1198
1244
  const once = Effect.gen(function* () {
1199
1245
  const transport = yield* GqlTransport;
1200
1246
  const response = yield* transport.execute(compiled);
1247
+ const data = redactSelected(compiled.tree, response.data);
1201
1248
  const raw = response.errors ?? [];
1202
- if (raw.length === 0) return response.data;
1249
+ if (raw.length === 0) return data;
1203
1250
  const issues = raw.map((error) => classify(compiled, error, response));
1204
1251
  const [first, ...rest] = issues as [GraphQLIssue, ...GraphQLIssue[]];
1205
1252
  return yield* Effect.fail(
@@ -1207,7 +1254,7 @@ const execute = (compiled: Compiled): Effect.Effect<unknown, ExecuteError, GqlTr
1207
1254
  ? first
1208
1255
  : new GraphQLFailure({
1209
1256
  errors: [first, ...rest],
1210
- data: response.data,
1257
+ data,
1211
1258
  status: response.status,
1212
1259
  }),
1213
1260
  );
@@ -1448,7 +1495,7 @@ export function flatMapQuery(sourceOrFlatMapFn: any, flatMapFn?: any): any {
1448
1495
  }
1449
1496
 
1450
1497
  /**
1451
- * Builder → Effect. The inner function is *not* a generator; it returns a
1498
+ * Builder -> Effect. The inner function is *not* a generator; it returns a
1452
1499
  * plan of Query/Effect values. Query.fn visits the plan, POSTs one document,
1453
1500
  * then interprets Map/Filter/FlatMap/Of.
1454
1501
  */
@@ -1463,7 +1510,7 @@ export const queryFn =
1463
1510
  return evaluatePlan(plan);
1464
1511
  };
1465
1512
 
1466
- // ── Pagination ──────────────────────────────────────────────────────────────
1513
+ // 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
1467
1514
  //
1468
1515
  // A connection lens hides `edges`/`pageInfo`. `Query.pages` re-evaluates the
1469
1516
  // query once per page: it sets the connection's `after` argument, paints
@@ -26,7 +26,7 @@ type _Projects = Assert<
26
26
  >;
27
27
  type _Flag = Assert<Equal<Unwrapped["flag"], boolean>>;
28
28
 
29
- // ── Errors ──────────────────────────────────────────────────────────────────
29
+ // 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
30
30
  declare class NotFound {
31
31
  readonly _tag: "NotFound";
32
32
  readonly message: string;
@@ -64,7 +64,7 @@ type _QueryError = Assert<
64
64
  >
65
65
  >;
66
66
 
67
- // ── Pagination ──────────────────────────────────────────────────────────────
67
+ // 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
68
68
  declare const services: Query<ReadonlyArray<{ name: string }>, NotFound>;
69
69
  type PagedItems = ReturnType<typeof itemsQuery<{ name: string }, NotFound>>;
70
70
  type _ItemsValue = Assert<Equal<Stream.Success<PagedItems>, { name: string }>>;
@@ -76,24 +76,26 @@ type _ItemsError = Assert<
76
76
  >;
77
77
  export type _Services = typeof services;
78
78
 
79
- // ── Nullability ─────────────────────────────────────────────────────────────
79
+ // U+2500U+2500 Nullability 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+2500
80
80
  declare const nullable: Query<{
81
81
  owner: { name: string; tags: ReadonlyArray<string> | null } | null;
82
82
  }>;
83
83
  type _NullParent = Assert<Equal<UnwrapPlan<typeof nullable.owner.name>, string | null>>;
84
84
 
85
- // ── Query.map on objects ────────────────────────────────────────────────────
85
+ // U+2500U+2500 Query.map on objects 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+2500
86
86
  declare const service: Query<{
87
87
  name: string;
88
88
  stars: number;
89
89
  latestDeployment: { id: string; status: string } | null;
90
90
  tags: ReadonlyArray<{ label: string }>;
91
91
  }>;
92
- const deployment = service.latestDeployment.pipe(mapQuery((d) => ({ id: d.id, status: d.status })));
92
+ const deployment = /*@__PURE__*/ service.latestDeployment.pipe(
93
+ /*@__PURE__*/ mapQuery((d) => ({ id: d.id, status: d.status })),
94
+ );
93
95
  type _ObjectMap = Assert<
94
96
  Equal<UnwrapPlan<typeof deployment>, { id: string; status: string } | null>
95
97
  >;
96
- const popular = service.stars.pipe(mapQuery((stars) => stars > 5));
98
+ const popular = /*@__PURE__*/ service.stars.pipe(/*@__PURE__*/ mapQuery((stars) => stars > 5));
97
99
  type _ScalarMap = Assert<Equal<UnwrapPlan<typeof popular>, boolean>>;
98
- const labels = service.tags.pipe(mapQuery((tag) => tag.label));
100
+ const labels = /*@__PURE__*/ service.tags.pipe(/*@__PURE__*/ mapQuery((tag) => tag.label));
99
101
  type _ListMap = Assert<Equal<UnwrapPlan<typeof labels>, ReadonlyArray<string>>>;