@distilled.cloud/core 1.0.0-rc.2 → 1.0.0-rc.21

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 (321) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +33 -0
  3. package/lib/_bundle/aws.js +2 -0
  4. package/lib/_bundle/aws.js.map +1 -0
  5. package/lib/_bundle/base.js +5 -0
  6. package/lib/_bundle/base.js.map +1 -0
  7. package/lib/_bundle/graphql.js +3 -0
  8. package/lib/_bundle/graphql.js.map +1 -0
  9. package/lib/_bundle/grpc.js +3 -0
  10. package/lib/_bundle/grpc.js.map +1 -0
  11. package/lib/_bundle/rest.js +2 -0
  12. package/lib/_bundle/rest.js.map +1 -0
  13. package/lib/_bundle/xml.js +4 -0
  14. package/lib/_bundle/xml.js.map +1 -0
  15. package/lib/annotations.d.ts +17 -0
  16. package/lib/annotations.d.ts.map +1 -0
  17. package/lib/annotations.js +2 -0
  18. package/lib/annotations.js.map +1 -0
  19. package/lib/api.d.ts +220 -51
  20. package/lib/api.d.ts.map +1 -1
  21. package/lib/api.js +1 -178
  22. package/lib/category.d.ts +19 -16
  23. package/lib/category.d.ts.map +1 -1
  24. package/lib/category.js +1 -280
  25. package/lib/chunks.d.ts +3 -0
  26. package/lib/chunks.d.ts.map +1 -0
  27. package/lib/chunks.js +1 -0
  28. package/lib/config.d.ts +81 -0
  29. package/lib/config.d.ts.map +1 -0
  30. package/lib/config.js +1 -0
  31. package/lib/crypto.d.ts +76 -0
  32. package/lib/crypto.d.ts.map +1 -0
  33. package/lib/crypto.js +1 -0
  34. package/lib/error-category.d.ts +1 -1
  35. package/lib/error-category.d.ts.map +1 -1
  36. package/lib/error-category.js +1 -46
  37. package/lib/errors.d.ts +99 -74
  38. package/lib/errors.d.ts.map +1 -1
  39. package/lib/errors.js +1 -186
  40. package/lib/graphql.d.ts +420 -0
  41. package/lib/graphql.d.ts.map +1 -0
  42. package/lib/graphql.js +1 -0
  43. package/lib/graphql.types.d.ts +11 -0
  44. package/lib/graphql.types.d.ts.map +1 -0
  45. package/lib/graphql.types.js +1 -0
  46. package/lib/grpc-transport-cloudflare-http2.d.ts +7 -0
  47. package/lib/grpc-transport-cloudflare-http2.d.ts.map +1 -0
  48. package/lib/grpc-transport-cloudflare-http2.js +6 -0
  49. package/lib/grpc-transport-cloudflare-http2.js.map +1 -0
  50. package/lib/grpc-transport-cloudflare-sockets.d.ts +7 -0
  51. package/lib/grpc-transport-cloudflare-sockets.d.ts.map +1 -0
  52. package/lib/grpc-transport-cloudflare-sockets.js +5 -0
  53. package/lib/grpc-transport-cloudflare-sockets.js.map +1 -0
  54. package/lib/grpc-transport-node-http2.d.ts +19 -0
  55. package/lib/grpc-transport-node-http2.d.ts.map +1 -0
  56. package/lib/grpc-transport-node-http2.js +2 -0
  57. package/lib/grpc-transport-node-http2.js.map +1 -0
  58. package/lib/grpc-transport.d.ts +111 -0
  59. package/lib/grpc-transport.d.ts.map +1 -0
  60. package/lib/grpc-transport.js +1 -0
  61. package/lib/hpack.d.ts +34 -0
  62. package/lib/hpack.d.ts.map +1 -0
  63. package/lib/hpack.js +2 -0
  64. package/lib/hpack.js.map +1 -0
  65. package/lib/index.d.ts +32 -0
  66. package/lib/index.d.ts.map +1 -0
  67. package/lib/index.js +17 -0
  68. package/lib/max-message-bytes.d.ts +42 -0
  69. package/lib/max-message-bytes.d.ts.map +1 -0
  70. package/lib/max-message-bytes.js +2 -0
  71. package/lib/max-message-bytes.js.map +1 -0
  72. package/lib/ndjson.d.ts +3 -0
  73. package/lib/ndjson.d.ts.map +1 -0
  74. package/lib/ndjson.js +2 -0
  75. package/lib/ndjson.js.map +1 -0
  76. package/lib/pagination.d.ts +105 -25
  77. package/lib/pagination.d.ts.map +1 -1
  78. package/lib/pagination.js +1 -182
  79. package/lib/plain-values.d.ts +21 -0
  80. package/lib/plain-values.d.ts.map +1 -0
  81. package/lib/plain-values.js +2 -0
  82. package/lib/plain-values.js.map +1 -0
  83. package/lib/protobuf.d.ts +85 -0
  84. package/lib/protobuf.d.ts.map +1 -0
  85. package/lib/protobuf.js +1 -0
  86. package/lib/protocol-grpc.d.ts +123 -0
  87. package/lib/protocol-grpc.d.ts.map +1 -0
  88. package/lib/protocol-grpc.js +1 -0
  89. package/lib/protocol-http.d.ts +206 -25
  90. package/lib/protocol-http.d.ts.map +1 -1
  91. package/lib/protocol-http.js +1 -554
  92. package/lib/protocol-rest.d.ts +258 -64
  93. package/lib/protocol-rest.d.ts.map +1 -1
  94. package/lib/protocol-rest.js +1 -242
  95. package/lib/protocol.d.ts +113 -0
  96. package/lib/protocol.d.ts.map +1 -0
  97. package/lib/protocol.js +0 -0
  98. package/lib/query.d.ts +29 -0
  99. package/lib/query.d.ts.map +1 -0
  100. package/lib/query.js +1 -0
  101. package/lib/response-validation-strict.d.ts +48 -0
  102. package/lib/response-validation-strict.d.ts.map +1 -0
  103. package/lib/response-validation-strict.js +1 -0
  104. package/lib/response-validation.d.ts +86 -0
  105. package/lib/response-validation.d.ts.map +1 -0
  106. package/lib/response-validation.js +1 -0
  107. package/lib/retry-after.d.ts +4 -4
  108. package/lib/retry-after.d.ts.map +1 -1
  109. package/lib/retry-after.js +1 -112
  110. package/lib/retry-state.d.ts +26 -0
  111. package/lib/retry-state.d.ts.map +1 -0
  112. package/lib/retry-state.js +2 -0
  113. package/lib/retry-state.js.map +1 -0
  114. package/lib/retry.d.ts +141 -42
  115. package/lib/retry.d.ts.map +1 -1
  116. package/lib/retry.js +1 -210
  117. package/lib/schema-lite-impl.d.ts +179 -0
  118. package/lib/schema-lite-impl.d.ts.map +1 -0
  119. package/lib/schema-lite-impl.js +1 -0
  120. package/lib/schema-lite-typed.d.ts +41 -0
  121. package/lib/schema-lite-typed.d.ts.map +1 -0
  122. package/lib/schema-lite-typed.js +1 -0
  123. package/lib/schema-lite.d.ts +41 -0
  124. package/lib/schema-lite.d.ts.map +1 -0
  125. package/lib/schema-lite.js +1 -0
  126. package/lib/schema.d.ts +21 -7
  127. package/lib/schema.d.ts.map +1 -1
  128. package/lib/schema.js +1 -48
  129. package/lib/sdk-error.d.ts +31 -0
  130. package/lib/sdk-error.d.ts.map +1 -0
  131. package/lib/sdk-error.js +1 -0
  132. package/lib/send.d.ts +37 -0
  133. package/lib/send.d.ts.map +1 -0
  134. package/lib/send.js +2 -0
  135. package/lib/send.js.map +1 -0
  136. package/lib/sensitive.d.ts +28 -0
  137. package/lib/sensitive.d.ts.map +1 -0
  138. package/lib/sensitive.js +2 -0
  139. package/lib/sensitive.js.map +1 -0
  140. package/lib/telemetry-debug.d.ts +6 -0
  141. package/lib/telemetry-debug.d.ts.map +1 -0
  142. package/lib/telemetry-debug.js +2 -0
  143. package/lib/telemetry-debug.js.map +1 -0
  144. package/lib/telemetry-hooks.d.ts +32 -0
  145. package/lib/telemetry-hooks.d.ts.map +1 -0
  146. package/lib/telemetry-hooks.js +2 -0
  147. package/lib/telemetry-hooks.js.map +1 -0
  148. package/lib/telemetry-host-rules.d.ts +23 -0
  149. package/lib/telemetry-host-rules.d.ts.map +1 -0
  150. package/lib/telemetry-host-rules.js +2 -0
  151. package/lib/telemetry-host-rules.js.map +1 -0
  152. package/lib/telemetry-lambda-context.d.ts +17 -0
  153. package/lib/telemetry-lambda-context.d.ts.map +1 -0
  154. package/lib/telemetry-lambda-context.js +2 -0
  155. package/lib/telemetry-lambda-context.js.map +1 -0
  156. package/lib/telemetry-message-context.d.ts +52 -0
  157. package/lib/telemetry-message-context.d.ts.map +1 -0
  158. package/lib/telemetry-message-context.js +2 -0
  159. package/lib/telemetry-message-context.js.map +1 -0
  160. package/lib/telemetry-metrics.d.ts +6 -0
  161. package/lib/telemetry-metrics.d.ts.map +1 -0
  162. package/lib/telemetry-metrics.js +2 -0
  163. package/lib/telemetry-metrics.js.map +1 -0
  164. package/lib/telemetry-name-template.d.ts +13 -0
  165. package/lib/telemetry-name-template.d.ts.map +1 -0
  166. package/lib/telemetry-name-template.js +2 -0
  167. package/lib/telemetry-name-template.js.map +1 -0
  168. package/lib/telemetry-stream.d.ts +11 -0
  169. package/lib/telemetry-stream.d.ts.map +1 -0
  170. package/lib/telemetry-stream.js +2 -0
  171. package/lib/telemetry-stream.js.map +1 -0
  172. package/lib/telemetry-xray.d.ts +28 -0
  173. package/lib/telemetry-xray.d.ts.map +1 -0
  174. package/lib/telemetry-xray.js +2 -0
  175. package/lib/telemetry-xray.js.map +1 -0
  176. package/lib/telemetry.d.ts +317 -0
  177. package/lib/telemetry.d.ts.map +1 -0
  178. package/lib/telemetry.js +3 -0
  179. package/lib/telemetry.js.map +1 -0
  180. package/lib/token-cache.d.ts +31 -0
  181. package/lib/token-cache.d.ts.map +1 -0
  182. package/lib/token-cache.js +2 -0
  183. package/lib/token-cache.js.map +1 -0
  184. package/lib/trait.d.ts +94 -20
  185. package/lib/trait.d.ts.map +1 -1
  186. package/lib/trait.js +1 -107
  187. package/lib/unknown-error.d.ts +18 -0
  188. package/lib/unknown-error.d.ts.map +1 -0
  189. package/lib/unknown-error.js +1 -0
  190. package/lib/xml.d.ts +44 -0
  191. package/lib/xml.d.ts.map +1 -0
  192. package/lib/xml.js +1 -0
  193. package/package.json +13 -13
  194. package/src/annotations.ts +53 -0
  195. package/src/api.ts +1597 -234
  196. package/src/category.ts +97 -134
  197. package/src/chunks.ts +30 -0
  198. package/src/config.ts +261 -0
  199. package/src/crypto.ts +202 -0
  200. package/src/error-category.ts +16 -29
  201. package/src/errors.ts +99 -77
  202. package/src/graphql.ts +1817 -0
  203. package/src/graphql.types.ts +120 -0
  204. package/src/grpc-transport-cloudflare-http2.ts +569 -0
  205. package/src/grpc-transport-cloudflare-sockets.ts +368 -0
  206. package/src/grpc-transport-node-http2.ts +307 -0
  207. package/src/grpc-transport.ts +287 -0
  208. package/src/hpack.ts +331 -0
  209. package/src/index.ts +31 -0
  210. package/src/max-message-bytes.ts +58 -0
  211. package/src/ndjson.ts +55 -0
  212. package/src/pagination.ts +379 -94
  213. package/src/plain-values.ts +70 -0
  214. package/src/protobuf.ts +1367 -0
  215. package/src/protocol-grpc.ts +811 -0
  216. package/src/protocol-http.ts +1045 -371
  217. package/src/protocol-rest.ts +908 -255
  218. package/src/protocol.ts +150 -0
  219. package/src/query.ts +39 -0
  220. package/src/response-validation-strict.ts +333 -0
  221. package/src/response-validation.ts +161 -0
  222. package/src/retry-after.ts +8 -14
  223. package/src/retry-state.ts +105 -0
  224. package/src/retry.ts +260 -145
  225. package/src/schema-lite-impl.ts +621 -0
  226. package/src/schema-lite-typed.ts +44 -0
  227. package/src/schema-lite.ts +45 -0
  228. package/src/schema.ts +259 -15
  229. package/src/sdk-error.ts +37 -0
  230. package/src/send.ts +156 -0
  231. package/src/sensitive.ts +188 -0
  232. package/src/telemetry-debug.ts +179 -0
  233. package/src/telemetry-hooks.ts +33 -0
  234. package/src/telemetry-host-rules.ts +39 -0
  235. package/src/telemetry-lambda-context.ts +46 -0
  236. package/src/telemetry-message-context.ts +170 -0
  237. package/src/telemetry-metrics.ts +69 -0
  238. package/src/telemetry-name-template.ts +26 -0
  239. package/src/telemetry-stream.ts +100 -0
  240. package/src/telemetry-xray.ts +66 -0
  241. package/src/telemetry.ts +800 -0
  242. package/src/token-cache.ts +117 -0
  243. package/src/trait.ts +139 -67
  244. package/src/unknown-error.ts +38 -0
  245. package/src/xml.ts +346 -0
  246. package/lib/api.js.map +0 -1
  247. package/lib/category.js.map +0 -1
  248. package/lib/codegen/cli.d.ts +0 -29
  249. package/lib/codegen/cli.d.ts.map +0 -1
  250. package/lib/codegen/cli.js +0 -165
  251. package/lib/codegen/cli.js.map +0 -1
  252. package/lib/codegen/emit.d.ts +0 -129
  253. package/lib/codegen/emit.d.ts.map +0 -1
  254. package/lib/codegen/emit.js +0 -105
  255. package/lib/codegen/emit.js.map +0 -1
  256. package/lib/codegen/format.d.ts +0 -23
  257. package/lib/codegen/format.d.ts.map +0 -1
  258. package/lib/codegen/format.js +0 -28
  259. package/lib/codegen/format.js.map +0 -1
  260. package/lib/codegen/generator.d.ts +0 -334
  261. package/lib/codegen/generator.d.ts.map +0 -1
  262. package/lib/codegen/generator.js +0 -691
  263. package/lib/codegen/generator.js.map +0 -1
  264. package/lib/codegen/graph.d.ts +0 -36
  265. package/lib/codegen/graph.d.ts.map +0 -1
  266. package/lib/codegen/graph.js +0 -136
  267. package/lib/codegen/graph.js.map +0 -1
  268. package/lib/codegen/members.d.ts +0 -25
  269. package/lib/codegen/members.d.ts.map +0 -1
  270. package/lib/codegen/members.js +0 -55
  271. package/lib/codegen/members.js.map +0 -1
  272. package/lib/codegen/naming.d.ts +0 -29
  273. package/lib/codegen/naming.d.ts.map +0 -1
  274. package/lib/codegen/naming.js +0 -74
  275. package/lib/codegen/naming.js.map +0 -1
  276. package/lib/codegen/openapi-cli.d.ts +0 -38
  277. package/lib/codegen/openapi-cli.d.ts.map +0 -1
  278. package/lib/codegen/openapi-cli.js +0 -107
  279. package/lib/codegen/openapi-cli.js.map +0 -1
  280. package/lib/codegen/openapi.d.ts +0 -115
  281. package/lib/codegen/openapi.d.ts.map +0 -1
  282. package/lib/codegen/openapi.js +0 -1220
  283. package/lib/codegen/openapi.js.map +0 -1
  284. package/lib/codegen/operations.d.ts +0 -24
  285. package/lib/codegen/operations.d.ts.map +0 -1
  286. package/lib/codegen/operations.js +0 -56
  287. package/lib/codegen/operations.js.map +0 -1
  288. package/lib/codegen/pagination.d.ts +0 -39
  289. package/lib/codegen/pagination.d.ts.map +0 -1
  290. package/lib/codegen/pagination.js +0 -33
  291. package/lib/codegen/pagination.js.map +0 -1
  292. package/lib/codegen/prelude.d.ts +0 -15
  293. package/lib/codegen/prelude.d.ts.map +0 -1
  294. package/lib/codegen/prelude.js +0 -60
  295. package/lib/codegen/prelude.js.map +0 -1
  296. package/lib/error-category.js.map +0 -1
  297. package/lib/errors.js.map +0 -1
  298. package/lib/json-patch.d.ts +0 -44
  299. package/lib/json-patch.d.ts.map +0 -1
  300. package/lib/json-patch.js +0 -174
  301. package/lib/json-patch.js.map +0 -1
  302. package/lib/pagination.js.map +0 -1
  303. package/lib/protocol-http.js.map +0 -1
  304. package/lib/protocol-rest.js.map +0 -1
  305. package/lib/retry-after.js.map +0 -1
  306. package/lib/retry.js.map +0 -1
  307. package/lib/schema.js.map +0 -1
  308. package/lib/trait.js.map +0 -1
  309. package/src/codegen/cli.ts +0 -268
  310. package/src/codegen/emit.ts +0 -207
  311. package/src/codegen/format.ts +0 -47
  312. package/src/codegen/generator.ts +0 -1153
  313. package/src/codegen/graph.ts +0 -151
  314. package/src/codegen/members.ts +0 -71
  315. package/src/codegen/naming.ts +0 -86
  316. package/src/codegen/openapi-cli.ts +0 -166
  317. package/src/codegen/openapi.ts +0 -1450
  318. package/src/codegen/operations.ts +0 -76
  319. package/src/codegen/pagination.ts +0 -71
  320. package/src/codegen/prelude.ts +0 -70
  321. package/src/json-patch.ts +0 -222
@@ -1,25 +1,43 @@
1
+ import * as Effect from "effect/Effect";
2
+ import * as HttpClientRequest from "effect/http/HttpClientRequest";
1
3
  /**
2
- * Generic REST protocol machinery, shared by SDK protocol layers.
4
+ * Generic REST protocol machinery, shared by SDK protocols.
3
5
  *
4
6
  * Everything here is driven purely by the trait annotations in
5
- * `core/trait.ts` — nothing is provider-specific. An SDK protocol (e.g.
7
+ * `core/trait.ts` -- nothing is provider-specific. An SDK protocol (e.g.
6
8
  * cloudflare's) supplies credentials/base-URL, calls {@link buildRequest} to
7
9
  * encode, and layers its own response-envelope handling on top of the
8
10
  * decode-side helpers ({@link getProps}/{@link mapKeys}/
9
11
  * {@link matchTypedError}).
10
12
  */
11
13
  import type * as AST from "effect/SchemaAST";
12
- import * as HttpClientRequest from "effect/unstable/http/HttpClientRequest";
13
- import { type ErrorMatcher, type KeyDictionaryEntries } from "./trait.ts";
14
- export declare const getProps: (ast: AST.AST) => readonly AST.PropertySignature[];
15
- export declare const getAnn: (ast: AST.AST, symbol: symbol) => unknown;
14
+ import { ConfigError } from "./config.ts";
15
+ import { isOpaqueValue } from "./plain-values.ts";
16
+ import * as Schema from "./schema-lite-typed.ts";
17
+ import { SdkError } from "./sdk-error.ts";
18
+ import { type ErrorMatcher, type HttpTrait, type KeyDictionaryEntries } from "./trait.ts";
19
+ export { getAnn, getProps, resolveNode } from "./annotations.ts";
16
20
  export declare const getPropAnn: (prop: AST.PropertySignature, symbol: symbol) => unknown;
17
21
  export declare const hasPropAnn: (prop: AST.PropertySignature, symbol: symbol) => boolean;
18
22
  export declare const nameOf: (prop: AST.PropertySignature, symbol: symbol) => string;
19
- /** Resolve wrappers to the real node: Suspend, encoding, optional/null unions. */
20
- export declare const resolveNode: (ast: AST.AST) => AST.AST;
21
- /** Binary/opaque values that must never be treated as key-value objects. */
22
- export declare const isOpaqueValue: (v: unknown) => boolean;
23
+ /** An output member read from a response header (`T.Header`). */
24
+ export interface ResponseHeaderMember {
25
+ readonly key: string;
26
+ /** Lowercase header name. */
27
+ readonly wire: string;
28
+ /** The member is a number; the header's text is parsed. */
29
+ readonly number: boolean;
30
+ }
31
+ /** The output's header-bound members, read from the schema once. */
32
+ export declare const responseHeaderMembers: (outputAst: AST.AST) => ReadonlyArray<ResponseHeaderMember>;
33
+ /**
34
+ * Copy the response headers an output declares onto its decoded body. A
35
+ * number member gets the header parsed; text that is not a number is kept
36
+ * as sent, so strict validation reports it. A body that is not an object
37
+ * (a raw root) is returned as is -- generators bind no headers there.
38
+ */
39
+ export declare const withResponseHeaders: (members: ReadonlyArray<ResponseHeaderMember>, body: unknown, headers: Record<string, string | undefined>) => unknown;
40
+ export { isOpaqueValue };
23
41
  /**
24
42
  * Deep-rename keys via a plain dictionary (see `T.KeyDictionary`). An entry
25
43
  * may list several wire spellings; encode uses the first (canonical) one and
@@ -27,13 +45,19 @@ export declare const isOpaqueValue: (v: unknown) => boolean;
27
45
  */
28
46
  export declare const mapKeysByDictionary: (dict: KeyDictionaryEntries, value: unknown, direction: "encode" | "decode") => unknown;
29
47
  /**
30
- * Recursively rename keys between TS names and wire names, per the schema.
31
- *
32
- * `fallback` is the nearest ancestor `T.KeyDictionary` — schema-known members
33
- * always map via their own annotations, but opaque values (Document members,
34
- * keys the schema doesn't know) deep-rename via the dictionary so nested
35
- * TS-cased content still reaches the wire in wire case. Content with no
36
- * dictionary in scope passes through verbatim.
48
+ * Whether {@link mapKeys} returns every value of `root` unchanged (as a deep
49
+ * copy) in `direction` with no fallback dictionary: no member is renamed,
50
+ * string-encoded (encode) or picked by `T.UnionCases` (decode, or encode for
51
+ * a union whose cases carry member dictionaries), and no
52
+ * `T.KeyDictionary` is in scope anywhere below `root`. Protocols use it to
53
+ * skip the walk. Computed once per schema node and direction.
54
+ */
55
+ export declare const mapsVerbatim: (root: AST.AST, direction: "encode" | "decode") => boolean;
56
+ /**
57
+ * Rename keys between TS names and wire names, per the schema (see
58
+ * {@link walkKeys}). A decode with no fallback dictionary returns `value`
59
+ * itself when the schema renames nothing ({@link mapsVerbatim}): the walk
60
+ * would only copy it.
37
61
  */
38
62
  export declare const mapKeys: (ast: AST.AST, value: unknown, direction: "encode" | "decode", fallback?: KeyDictionaryEntries) => unknown;
39
63
  export interface BuildRequestOptions {
@@ -49,26 +73,183 @@ export interface BuildRequestOptions {
49
73
  */
50
74
  readonly mapMemberHeader?: (name: string, value: string) => string;
51
75
  /**
52
- * Wire name for input keys the schema doesn't declare (spec drift —
76
+ * Wire name for input keys the schema doesn't declare (spec drift --
53
77
  * unknown keys pass through as body fields rather than being dropped).
54
78
  * Defaults to the key verbatim.
55
79
  */
56
80
  readonly unknownKeyToWire?: (key: string) => string;
81
+ /**
82
+ * Send `{}` on a method that takes a body even when the input declares no
83
+ * body members. Connect unary RPCs (E2B's envd) POST JSON for every call,
84
+ * and refuse a bodyless one with 415.
85
+ */
86
+ readonly emptyJsonBody?: boolean;
87
+ /**
88
+ * How a query member spells a nested object or an array.
89
+ *
90
+ * - `"dotted"` (default): `created.gte=1`; an array repeats the key
91
+ * (`expand=a&expand=b`).
92
+ * - `"brackets"`: `created[gte]=1`; an array indexes the key
93
+ * (`expand[0]=a&expand[1]=b`), the same rule as form-urlencoded bodies.
94
+ * Stripe needs this: its v2 API refuses `key[]` and repeated keys.
95
+ *
96
+ * `T.CommaDelimited` and `T.DeepQuery` members keep their own spelling.
97
+ */
98
+ readonly queryStyle?: "dotted" | "brackets";
99
+ }
100
+ /**
101
+ * Encode a greedy `{name+}` label: the value may span several path
102
+ * segments (e.g. an Azure scope `/subscriptions/{id}/resourceGroups/{rg}`),
103
+ * so each segment is encoded on its own and the `/` separators are kept.
104
+ * Leading slashes are dropped because the URI template already supplies one.
105
+ */
106
+ export declare const encodeGreedyLabel: (value: string) => string;
107
+ /**
108
+ * Marks a raw body member as binary (core `RawBody`): a string is sent as
109
+ * its bytes, never JSON-encoded, even with no declared media type.
110
+ */
111
+ export declare const binaryBodySymbol: unique symbol;
112
+ /**
113
+ * `HttpClientRequest.make(method)(url)` with `headers` set, in one object:
114
+ * the same request as `make(...).pipe(setHeaders(headers))` without the
115
+ * intermediate copies. `url` may carry a query string.
116
+ */
117
+ export declare const makeRequest: (method: HttpTrait["method"], url: string, headers: Record<string, string>) => HttpClientRequest.HttpClientRequest;
118
+ declare const InvalidInput_base: Schema.TaggedErrorClass<"InvalidInput", {
119
+ readonly member: import("effect/Schema").String;
120
+ readonly message: import("effect/Schema").String;
121
+ }> & (new (...args: any[]) => {
122
+ "@distilled.cloud/error/categories": {
123
+ BadRequestError: true;
124
+ };
125
+ });
126
+ /**
127
+ * The input cannot be sent: a path label whose value would address another
128
+ * resource (`.` or `..`, which the URL parser resolves to the parent path,
129
+ * or `""`, which addresses the parent path), or a host label that would
130
+ * address another host. Raised before anything is sent.
131
+ */
132
+ export declare class InvalidInput extends /*@__PURE__*/ InvalidInput_base {
133
+ }
134
+ /**
135
+ * The refusal for an input no request can carry. `cause` is what a step
136
+ * that only reads the caller's values threw: `JSON.stringify` on a `BigInt`,
137
+ * a walk of an object that contains itself.
138
+ */
139
+ export declare const unsendable: (cause: unknown) => InvalidInput;
140
+ /**
141
+ * The refusal for a path label value that would address another resource,
142
+ * or `undefined`. The URL parser resolves a `.` or `..` segment,
143
+ * percent-encoded or not, so no encoding can carry one
144
+ * (`/projects/p1/branches/..` -> `/projects/p1/`). A greedy label keeps its
145
+ * `/`, so each of its segments counts.
146
+ *
147
+ * Also refuses an empty value, unless the label is `optional`. It leaves the
148
+ * segment empty, and a server that ignores a trailing slash (Smithy routing
149
+ * does) reads `/things/` as the collection `/things`: Kubernetes runs a
150
+ * delete of the Secret `""` as a delete of every Secret in the namespace.
151
+ * A label the schema marks optional is one the API documents as possibly
152
+ * empty (Azure Key Vault's `{secret-version}`), so it may be `""`.
153
+ *
154
+ * Also refuses a value with a lone UTF-16 surrogate (`"\ud800"`):
155
+ * `encodeURIComponent` throws `URIError` on it, and no encoding keeps the
156
+ * name as written.
157
+ */
158
+ export declare const invalidLabel: (member: string, value: unknown, greedy?: boolean, optional?: boolean) => InvalidInput | undefined;
159
+ /**
160
+ * A path label value, percent-encoded, or the {@link InvalidInput} that
161
+ * {@link invalidLabel} refuses it with. A greedy label keeps its `/` and
162
+ * encodes each segment ({@link encodeGreedyLabel}). Use it wherever a
163
+ * caller's value goes into a URL path, so the check can't be skipped.
164
+ */
165
+ export declare const encodeLabel: (member: string, value: unknown, greedy?: boolean, optional?: boolean) => string | InvalidInput;
166
+ /**
167
+ * Whether `value` is one DNS host label (RFC 1123), or with
168
+ * `allowSubDomains` a dot-separated name made of them. A value that goes into
169
+ * a URL host must pass it: any other character (`/`, `@`, `#`, `?`, `:`)
170
+ * can move the request to another host, and no encoding fixes a host.
171
+ */
172
+ export declare const isHostLabel: (value: unknown, allowSubDomains?: boolean) => boolean;
173
+ /**
174
+ * The refusal for a value that goes into a URL host but is not a host label
175
+ * ({@link isHostLabel}), or `undefined`. The host-side counterpart of
176
+ * {@link invalidLabel}. A value read from credentials config fails with
177
+ * {@link invalidHostLabelConfig} instead.
178
+ */
179
+ export declare const invalidHostLabel: (member: string, value: unknown, allowSubDomains?: boolean) => InvalidInput | undefined;
180
+ /**
181
+ * {@link invalidHostLabel} for a value read from credentials config: the
182
+ * refusal is a `ConfigError` naming the setting (`"S2 basin"`,
183
+ * `"STACKIT region"`), or `undefined`.
184
+ */
185
+ export declare const invalidHostLabelConfig: (name: string, value: unknown, allowSubDomains?: boolean) => ConfigError | undefined;
186
+ /**
187
+ * The origin (`https://host[:port]`) that a host or origin read from
188
+ * credentials config names, or the `ConfigError` refusing it. The value is
189
+ * a host (`acme.zendesk.com`, `udm.lan:8443`, given `defaultScheme`) or an
190
+ * origin (`https://acme.zendesk.com/`). It picks the host and nothing else:
191
+ * a user, path, query or fragment, a scheme other than `http`/`https`, or a
192
+ * host name that is not DNS labels ({@link isHostLabel}) or an IPv6 literal
193
+ * is refused.
194
+ */
195
+ export declare const originFromConfig: (name: string, value: string, defaultScheme?: "https" | "http") => string | ConfigError;
196
+ /**
197
+ * Build an HTTP request from an operation input and its schema, driven by
198
+ * the trait annotations: `Http()` supplies method + URI template, `Label()`
199
+ * members fill URI placeholders, `Header()`/`Query()` members bind to
200
+ * headers/query params, `DeepQuery()` struct members expand into dotted
201
+ * query params, `HttpBody()` sends the member as the whole body,
202
+ * `FormDataFile()` members become multipart file parts, and everything else
203
+ * is a JSON body field (wire-named via `Body()` / `KeyDictionary`).
204
+ *
205
+ * The schema is read once per input schema (see `planFor`); later calls only
206
+ * walk the input value.
207
+ *
208
+ * An optional label left out of the input is an empty segment, like `""`
209
+ * (Azure Key Vault's `/secrets/{name}/{version}` -> `/secrets/db/`).
210
+ *
211
+ * Fails with {@link InvalidInput}, before anything is sent, when a label is
212
+ * `.` or `..` (for a greedy `{name+}` label, when any of its segments is),
213
+ * is `""` and the schema marks it required, or has a lone UTF-16 surrogate,
214
+ * and when a JSON body holds a value JSON cannot carry (a `BigInt`, an
215
+ * object that contains itself).
216
+ * Fails with {@link SdkError} when the input schema is missing the `Http()`
217
+ * trait (a codegen bug the generator refuses).
218
+ */
219
+ export declare const buildRequest: (options: BuildRequestOptions) => Effect.Effect<HttpClientRequest.HttpClientRequest, InvalidInput | SdkError>;
220
+ /** Parsed response metadata supplied by a protocol after it detects a failure. */
221
+ export interface ErrorResponse {
222
+ readonly body?: unknown;
223
+ readonly headers?: Readonly<Record<string, string | undefined>>;
224
+ /**
225
+ * JSON pointer to the object that holds the error's fields when the
226
+ * provider nests them, e.g. `"/error"` for `{ error: { status, details } }`.
227
+ */
228
+ readonly fieldsAt?: string;
57
229
  }
58
- export declare const buildRequest: ({ input, inputAst, baseUrl, headers: baseHeaders, mapMemberHeader, unknownKeyToWire, }: BuildRequestOptions) => HttpClientRequest.HttpClientRequest;
230
+ /** Every supplied constraint must match; an unconstrained matcher matches nothing. */
231
+ export declare const matchesExpression: (m: ErrorMatcher, code: number | undefined, status: number, message: string, response?: ErrorResponse) => boolean;
59
232
  /**
60
- * Whether one matcher matches one wire error: every present field must
61
- * match; a matcher (or a message object) with no constraints matches
62
- * nothing.
233
+ * The fields every error built from a response gets, when its class declares
234
+ * them: the body (keys mapped to TS names when the class types it), the
235
+ * headers, and the server's retry hint from `Retry-After` or `RateLimit`.
63
236
  */
64
- export declare const matchesExpression: (m: ErrorMatcher, code: number | undefined, status: number, message: string) => boolean;
237
+ export declare const responseErrorFields: (fields: Record<string, unknown> | undefined, response: ErrorResponse) => Record<string, unknown>;
65
238
  /**
66
239
  * Pick the operation's typed error class for a failed response: among all
67
240
  * declared classes whose matchers (see `applyErrorMatchers`) match the wire
68
241
  * failure, the most specific matcher wins (ties break by declaration order).
242
+ * Empty error lists use an HTTP-status message so body/header-only failures can
243
+ * still match. The constructor receives the raw body and headers as well as
244
+ * code/message; error schemas can declare these fields to expose them to callers.
245
+ * Any other field the class declares is read from the JSON body's key of the
246
+ * same name -- at `response.fieldsAt` first, then at the top level -- so a
247
+ * patch that adds `requestId` to an error gets the body's `requestId`. A
248
+ * declared `retryAfter` gets the `Retry-After` / `RateLimit` header hint. The
249
+ * matched `code` and `message` always win over the body's.
69
250
  */
70
- export declare const matchTypedError: (errorClasses: ReadonlyArray<unknown>, status: number, errors: ReadonlyArray<{
251
+ export declare function matchTypedError<E>(errorClasses: ReadonlyArray<new (...args: any[]) => E>, status: number, errors: ReadonlyArray<{
71
252
  code?: number;
72
253
  message: string;
73
- }>) => unknown | undefined;
254
+ }>, response?: ErrorResponse): E | undefined;
74
255
  //# sourceMappingURL=protocol-http.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"protocol-http.d.ts","sourceRoot":"","sources":["../src/protocol-http.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,KAAK,GAAG,MAAM,kBAAkB,CAAC;AAE7C,OAAO,KAAK,iBAAiB,MAAM,wCAAwC,CAAC;AAC5E,OAAO,EAYL,KAAK,YAAY,EAEjB,KAAK,oBAAoB,EAC1B,MAAM,YAAY,CAAC;AAIpB,eAAO,MAAM,QAAQ,QAAS,GAAG,CAAC,GAAG,KAAG,SAAS,GAAG,CAAC,iBAAiB,EAMrE,CAAC;AAEF,eAAO,MAAM,MAAM,QAAS,GAAG,CAAC,GAAG,UAAU,MAAM,KAAG,OAkBrD,CAAC;AAEF,eAAO,MAAM,UAAU,SACf,GAAG,CAAC,iBAAiB,UACnB,MAAM,KACb,OAAoC,CAAC;AACxC,eAAO,MAAM,UAAU,SACf,GAAG,CAAC,iBAAiB,UACnB,MAAM,KACb,OAAiD,CAAC;AACrD,eAAO,MAAM,MAAM,SAAU,GAAG,CAAC,iBAAiB,UAAU,MAAM,KAAG,MAGpE,CAAC;AAEF,kFAAkF;AAClF,eAAO,MAAM,WAAW,QAAS,GAAG,CAAC,GAAG,KAAG,GAAG,CAAC,GAc9C,CAAC;AAKF,4EAA4E;AAC5E,eAAO,MAAM,aAAa,MAAO,OAAO,KAAG,OAKxB,CAAC;AAEpB;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,SACxB,oBAAoB,SACnB,OAAO,aACH,QAAQ,GAAG,QAAQ,KAC7B,OA4BF,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,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