@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
package/lib/errors.d.ts CHANGED
@@ -6,21 +6,32 @@
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
  * Opaque schema for an Effect `Duration.Duration` value.
13
13
  *
14
14
  * Used on retryable errors to carry a server-provided wait hint (e.g. parsed
15
15
  * from `Retry-After` or the IETF `Ratelimit` header). Core does not encode/decode
16
- * this field over the wire — it is constructed at runtime by `matchError` from
16
+ * this field over the wire -- it is constructed at runtime by `matchError` from
17
17
  * whatever the service actually returns (delay-seconds, HTTP-date, epoch, etc.)
18
18
  * and consumed at runtime by the retry policy.
19
19
  */
20
- export declare const DurationSchema: Schema.declare<Duration.Duration, Duration.Duration>;
21
- declare const Unauthorized_base: Schema.Class<Unauthorized, Schema.TaggedStruct<"Unauthorized", {
22
- readonly message: Schema.String;
23
- }>, import("effect/Cause").YieldableError> & (new (...args: any[]) => {
20
+ export declare const DurationSchema: import("effect/Schema").declare<Duration.Duration, Duration.Duration>;
21
+ /**
22
+ * Fields every error built from an HTTP response declares: the parsed body
23
+ * (the raw text when it wasn't JSON) and the response headers, for whatever
24
+ * the SDK does not type -- a request ID, nested details.
25
+ */
26
+ export declare const ResponseErrorFields: {
27
+ body: import("effect/Schema").optional<import("effect/Schema").Unknown>;
28
+ headers: import("effect/Schema").optional<Schema.$Record<import("effect/Schema").String, import("effect/Schema").String>>;
29
+ };
30
+ declare const Unauthorized_base: Schema.TaggedErrorClass<"Unauthorized", {
31
+ readonly body: import("effect/Schema").optional<import("effect/Schema").Unknown>;
32
+ readonly headers: import("effect/Schema").optional<Schema.$Record<import("effect/Schema").String, import("effect/Schema").String>>;
33
+ readonly message: import("effect/Schema").String;
34
+ }> & (new (...args: any[]) => {
24
35
  "@distilled.cloud/error/categories": {
25
36
  AuthError: true;
26
37
  };
@@ -28,11 +39,13 @@ declare const Unauthorized_base: Schema.Class<Unauthorized, Schema.TaggedStruct<
28
39
  /**
29
40
  * Unauthorized - Authentication failure (401).
30
41
  */
31
- export declare class Unauthorized extends Unauthorized_base {
42
+ export declare class Unauthorized extends /*@__PURE__*/ Unauthorized_base {
32
43
  }
33
- declare const Forbidden_base: Schema.Class<Forbidden, Schema.TaggedStruct<"Forbidden", {
34
- readonly message: Schema.String;
35
- }>, import("effect/Cause").YieldableError> & (new (...args: any[]) => {
44
+ declare const Forbidden_base: Schema.TaggedErrorClass<"Forbidden", {
45
+ readonly body: import("effect/Schema").optional<import("effect/Schema").Unknown>;
46
+ readonly headers: import("effect/Schema").optional<Schema.$Record<import("effect/Schema").String, import("effect/Schema").String>>;
47
+ readonly message: import("effect/Schema").String;
48
+ }> & (new (...args: any[]) => {
36
49
  "@distilled.cloud/error/categories": {
37
50
  AuthError: true;
38
51
  };
@@ -40,11 +53,13 @@ declare const Forbidden_base: Schema.Class<Forbidden, Schema.TaggedStruct<"Forbi
40
53
  /**
41
54
  * Forbidden - Access denied (403).
42
55
  */
43
- export declare class Forbidden extends Forbidden_base {
56
+ export declare class Forbidden extends /*@__PURE__*/ Forbidden_base {
44
57
  }
45
- declare const NotFound_base: Schema.Class<NotFound, Schema.TaggedStruct<"NotFound", {
46
- readonly message: Schema.String;
47
- }>, import("effect/Cause").YieldableError> & (new (...args: any[]) => {
58
+ declare const NotFound_base: Schema.TaggedErrorClass<"NotFound", {
59
+ readonly body: import("effect/Schema").optional<import("effect/Schema").Unknown>;
60
+ readonly headers: import("effect/Schema").optional<Schema.$Record<import("effect/Schema").String, import("effect/Schema").String>>;
61
+ readonly message: import("effect/Schema").String;
62
+ }> & (new (...args: any[]) => {
48
63
  "@distilled.cloud/error/categories": {
49
64
  NotFoundError: true;
50
65
  };
@@ -52,11 +67,13 @@ declare const NotFound_base: Schema.Class<NotFound, Schema.TaggedStruct<"NotFoun
52
67
  /**
53
68
  * NotFound - Resource not found (404).
54
69
  */
55
- export declare class NotFound extends NotFound_base {
70
+ export declare class NotFound extends /*@__PURE__*/ NotFound_base {
56
71
  }
57
- declare const BadRequest_base: Schema.Class<BadRequest, Schema.TaggedStruct<"BadRequest", {
58
- readonly message: Schema.String;
59
- }>, import("effect/Cause").YieldableError> & (new (...args: any[]) => {
72
+ declare const BadRequest_base: Schema.TaggedErrorClass<"BadRequest", {
73
+ readonly body: import("effect/Schema").optional<import("effect/Schema").Unknown>;
74
+ readonly headers: import("effect/Schema").optional<Schema.$Record<import("effect/Schema").String, import("effect/Schema").String>>;
75
+ readonly message: import("effect/Schema").String;
76
+ }> & (new (...args: any[]) => {
60
77
  "@distilled.cloud/error/categories": {
61
78
  BadRequestError: true;
62
79
  };
@@ -64,11 +81,13 @@ declare const BadRequest_base: Schema.Class<BadRequest, Schema.TaggedStruct<"Bad
64
81
  /**
65
82
  * BadRequest - Invalid request (400).
66
83
  */
67
- export declare class BadRequest extends BadRequest_base {
84
+ export declare class BadRequest extends /*@__PURE__*/ BadRequest_base {
68
85
  }
69
- declare const Conflict_base: Schema.Class<Conflict, Schema.TaggedStruct<"Conflict", {
70
- readonly message: Schema.String;
71
- }>, import("effect/Cause").YieldableError> & (new (...args: any[]) => {
86
+ declare const Conflict_base: Schema.TaggedErrorClass<"Conflict", {
87
+ readonly body: import("effect/Schema").optional<import("effect/Schema").Unknown>;
88
+ readonly headers: import("effect/Schema").optional<Schema.$Record<import("effect/Schema").String, import("effect/Schema").String>>;
89
+ readonly message: import("effect/Schema").String;
90
+ }> & (new (...args: any[]) => {
72
91
  "@distilled.cloud/error/categories": {
73
92
  ConflictError: true;
74
93
  };
@@ -76,11 +95,13 @@ declare const Conflict_base: Schema.Class<Conflict, Schema.TaggedStruct<"Conflic
76
95
  /**
77
96
  * Conflict - Resource conflict (409).
78
97
  */
79
- export declare class Conflict extends Conflict_base {
98
+ export declare class Conflict extends /*@__PURE__*/ Conflict_base {
80
99
  }
81
- declare const UnprocessableEntity_base: Schema.Class<UnprocessableEntity, Schema.TaggedStruct<"UnprocessableEntity", {
82
- readonly message: Schema.String;
83
- }>, import("effect/Cause").YieldableError> & (new (...args: any[]) => {
100
+ declare const UnprocessableEntity_base: Schema.TaggedErrorClass<"UnprocessableEntity", {
101
+ readonly body: import("effect/Schema").optional<import("effect/Schema").Unknown>;
102
+ readonly headers: import("effect/Schema").optional<Schema.$Record<import("effect/Schema").String, import("effect/Schema").String>>;
103
+ readonly message: import("effect/Schema").String;
104
+ }> & (new (...args: any[]) => {
84
105
  "@distilled.cloud/error/categories": {
85
106
  BadRequestError: true;
86
107
  };
@@ -88,12 +109,14 @@ declare const UnprocessableEntity_base: Schema.Class<UnprocessableEntity, Schema
88
109
  /**
89
110
  * UnprocessableEntity - Validation error (422).
90
111
  */
91
- export declare class UnprocessableEntity extends UnprocessableEntity_base {
112
+ export declare class UnprocessableEntity extends /*@__PURE__*/ UnprocessableEntity_base {
92
113
  }
93
- declare const TooManyRequests_base: Schema.Class<TooManyRequests, Schema.TaggedStruct<"TooManyRequests", {
94
- readonly message: Schema.String;
95
- readonly retryAfter: Schema.optional<Schema.declare<Duration.Duration, Duration.Duration>>;
96
- }>, import("effect/Cause").YieldableError> & (new (...args: any[]) => {
114
+ declare const TooManyRequests_base: Schema.TaggedErrorClass<"TooManyRequests", {
115
+ readonly body: import("effect/Schema").optional<import("effect/Schema").Unknown>;
116
+ readonly headers: import("effect/Schema").optional<Schema.$Record<import("effect/Schema").String, import("effect/Schema").String>>;
117
+ readonly message: import("effect/Schema").String;
118
+ readonly retryAfter: import("effect/Schema").optional<import("effect/Schema").declare<Duration.Duration, Duration.Duration>>;
119
+ }> & (new (...args: any[]) => {
97
120
  "@distilled.cloud/error/categories": {
98
121
  ThrottlingError: true;
99
122
  };
@@ -103,12 +126,14 @@ declare const TooManyRequests_base: Schema.Class<TooManyRequests, Schema.TaggedS
103
126
  /**
104
127
  * TooManyRequests - Rate limited (429).
105
128
  */
106
- export declare class TooManyRequests extends TooManyRequests_base {
129
+ export declare class TooManyRequests extends /*@__PURE__*/ TooManyRequests_base {
107
130
  }
108
- declare const Locked_base: Schema.Class<Locked, Schema.TaggedStruct<"Locked", {
109
- readonly message: Schema.String;
110
- readonly retryAfter: Schema.optional<Schema.declare<Duration.Duration, Duration.Duration>>;
111
- }>, import("effect/Cause").YieldableError> & (new (...args: any[]) => {
131
+ declare const Locked_base: Schema.TaggedErrorClass<"Locked", {
132
+ readonly body: import("effect/Schema").optional<import("effect/Schema").Unknown>;
133
+ readonly headers: import("effect/Schema").optional<Schema.$Record<import("effect/Schema").String, import("effect/Schema").String>>;
134
+ readonly message: import("effect/Schema").String;
135
+ readonly retryAfter: import("effect/Schema").optional<import("effect/Schema").declare<Duration.Duration, Duration.Duration>>;
136
+ }> & (new (...args: any[]) => {
112
137
  "@distilled.cloud/error/categories": {
113
138
  LockedError: true;
114
139
  };
@@ -118,13 +143,15 @@ declare const Locked_base: Schema.Class<Locked, Schema.TaggedStruct<"Locked", {
118
143
  /**
119
144
  * Locked - Resource locked (423).
120
145
  */
121
- export declare class Locked extends Locked_base {
146
+ export declare class Locked extends /*@__PURE__*/ Locked_base {
122
147
  }
123
- declare const InternalServerError_base: Schema.Class<InternalServerError, Schema.TaggedStruct<"InternalServerError", {
124
- readonly message: Schema.String;
125
- readonly code: Schema.optional<Schema.Number>;
126
- readonly retryAfter: Schema.optional<Schema.declare<Duration.Duration, Duration.Duration>>;
127
- }>, import("effect/Cause").YieldableError> & (new (...args: any[]) => {
148
+ declare const InternalServerError_base: Schema.TaggedErrorClass<"InternalServerError", {
149
+ readonly body: import("effect/Schema").optional<import("effect/Schema").Unknown>;
150
+ readonly headers: import("effect/Schema").optional<Schema.$Record<import("effect/Schema").String, import("effect/Schema").String>>;
151
+ readonly message: import("effect/Schema").String;
152
+ readonly code: import("effect/Schema").optional<import("effect/Schema").Number>;
153
+ readonly retryAfter: import("effect/Schema").optional<import("effect/Schema").declare<Duration.Duration, Duration.Duration>>;
154
+ }> & (new (...args: any[]) => {
128
155
  "@distilled.cloud/error/categories": {
129
156
  ServerError: true;
130
157
  };
@@ -139,12 +166,14 @@ declare const InternalServerError_base: Schema.Class<InternalServerError, Schema
139
166
  * 200 envelope carrying `{ code: 10002, message: "An unknown error has
140
167
  * occurred" }` for transient backend failures on some endpoints).
141
168
  */
142
- export declare class InternalServerError extends InternalServerError_base {
169
+ export declare class InternalServerError extends /*@__PURE__*/ InternalServerError_base {
143
170
  }
144
- declare const BadGateway_base: Schema.Class<BadGateway, Schema.TaggedStruct<"BadGateway", {
145
- readonly message: Schema.String;
146
- readonly retryAfter: Schema.optional<Schema.declare<Duration.Duration, Duration.Duration>>;
147
- }>, import("effect/Cause").YieldableError> & (new (...args: any[]) => {
171
+ declare const BadGateway_base: Schema.TaggedErrorClass<"BadGateway", {
172
+ readonly body: import("effect/Schema").optional<import("effect/Schema").Unknown>;
173
+ readonly headers: import("effect/Schema").optional<Schema.$Record<import("effect/Schema").String, import("effect/Schema").String>>;
174
+ readonly message: import("effect/Schema").String;
175
+ readonly retryAfter: import("effect/Schema").optional<import("effect/Schema").declare<Duration.Duration, Duration.Duration>>;
176
+ }> & (new (...args: any[]) => {
148
177
  "@distilled.cloud/error/categories": {
149
178
  ServerError: true;
150
179
  };
@@ -154,12 +183,14 @@ declare const BadGateway_base: Schema.Class<BadGateway, Schema.TaggedStruct<"Bad
154
183
  /**
155
184
  * BadGateway - Bad gateway (502).
156
185
  */
157
- export declare class BadGateway extends BadGateway_base {
186
+ export declare class BadGateway extends /*@__PURE__*/ BadGateway_base {
158
187
  }
159
- declare const ServiceUnavailable_base: Schema.Class<ServiceUnavailable, Schema.TaggedStruct<"ServiceUnavailable", {
160
- readonly message: Schema.String;
161
- readonly retryAfter: Schema.optional<Schema.declare<Duration.Duration, Duration.Duration>>;
162
- }>, import("effect/Cause").YieldableError> & (new (...args: any[]) => {
188
+ declare const ServiceUnavailable_base: Schema.TaggedErrorClass<"ServiceUnavailable", {
189
+ readonly body: import("effect/Schema").optional<import("effect/Schema").Unknown>;
190
+ readonly headers: import("effect/Schema").optional<Schema.$Record<import("effect/Schema").String, import("effect/Schema").String>>;
191
+ readonly message: import("effect/Schema").String;
192
+ readonly retryAfter: import("effect/Schema").optional<import("effect/Schema").declare<Duration.Duration, Duration.Duration>>;
193
+ }> & (new (...args: any[]) => {
163
194
  "@distilled.cloud/error/categories": {
164
195
  ServerError: true;
165
196
  };
@@ -169,12 +200,14 @@ declare const ServiceUnavailable_base: Schema.Class<ServiceUnavailable, Schema.T
169
200
  /**
170
201
  * ServiceUnavailable - Service unavailable (503).
171
202
  */
172
- export declare class ServiceUnavailable extends ServiceUnavailable_base {
203
+ export declare class ServiceUnavailable extends /*@__PURE__*/ ServiceUnavailable_base {
173
204
  }
174
- declare const GatewayTimeout_base: Schema.Class<GatewayTimeout, Schema.TaggedStruct<"GatewayTimeout", {
175
- readonly message: Schema.String;
176
- readonly retryAfter: Schema.optional<Schema.declare<Duration.Duration, Duration.Duration>>;
177
- }>, import("effect/Cause").YieldableError> & (new (...args: any[]) => {
205
+ declare const GatewayTimeout_base: Schema.TaggedErrorClass<"GatewayTimeout", {
206
+ readonly body: import("effect/Schema").optional<import("effect/Schema").Unknown>;
207
+ readonly headers: import("effect/Schema").optional<Schema.$Record<import("effect/Schema").String, import("effect/Schema").String>>;
208
+ readonly message: import("effect/Schema").String;
209
+ readonly retryAfter: import("effect/Schema").optional<import("effect/Schema").declare<Duration.Duration, Duration.Duration>>;
210
+ }> & (new (...args: any[]) => {
178
211
  "@distilled.cloud/error/categories": {
179
212
  ServerError: true;
180
213
  };
@@ -182,22 +215,14 @@ declare const GatewayTimeout_base: Schema.Class<GatewayTimeout, Schema.TaggedStr
182
215
  "@distilled.cloud/error/retryable": Category.RetryableInfo;
183
216
  });
184
217
  /**
185
- * GatewayTimeout - Gateway timeout (504).
186
- */
187
- export declare class GatewayTimeout extends GatewayTimeout_base {
188
- }
189
- declare const ConfigError_base: Schema.Class<ConfigError, Schema.TaggedStruct<"ConfigError", {
190
- readonly message: Schema.String;
191
- }>, import("effect/Cause").YieldableError> & (new (...args: any[]) => {
192
- "@distilled.cloud/error/categories": {
193
- ConfigurationError: true;
194
- };
195
- });
196
- /**
197
- * Configuration error - missing or invalid configuration.
218
+ * GatewayTimeout - HTTP request or gateway timeout (408, 504).
198
219
  */
199
- export declare class ConfigError extends ConfigError_base {
220
+ export declare class GatewayTimeout extends /*@__PURE__*/ GatewayTimeout_base {
200
221
  }
222
+ export { ConfigError } from "./config.ts";
223
+ export { InvalidInput } from "./protocol-http.ts";
224
+ export { SdkError } from "./sdk-error.ts";
225
+ export { UnknownErrorFields, type UnknownErrorProps } from "./unknown-error.ts";
201
226
  /**
202
227
  * Mapping from HTTP status codes to common error classes.
203
228
  */
@@ -206,6 +231,7 @@ export declare const HTTP_STATUS_MAP: {
206
231
  readonly 401: typeof Unauthorized;
207
232
  readonly 403: typeof Forbidden;
208
233
  readonly 404: typeof NotFound;
234
+ readonly 408: typeof GatewayTimeout;
209
235
  readonly 409: typeof Conflict;
210
236
  readonly 422: typeof UnprocessableEntity;
211
237
  readonly 423: typeof Locked;
@@ -222,8 +248,8 @@ export declare const HTTP_STATUS_MAP: {
222
248
  export declare const DEFAULT_ERROR_STATUSES: Set<number>;
223
249
  /**
224
250
  * HTTP status codes whose corresponding error class in {@link HTTP_STATUS_MAP}
225
- * declares a `retryAfter` field. The retry policy honors `error.retryAfter`
226
- * with precedence over the default backoff for these.
251
+ * declares a `retryAfter` field. The retry policy waits at least
252
+ * `error.retryAfter` for these.
227
253
  *
228
254
  * `matchError` implementations should only pass `retryAfter` into the
229
255
  * constructor when the status is in this set; passing it on non-retryable
@@ -242,5 +268,4 @@ export declare const API_ERRORS: readonly [typeof Unauthorized, typeof Forbidden
242
268
  export declare const DEFAULT_ERRORS: readonly [typeof Unauthorized, typeof TooManyRequests, typeof InternalServerError, typeof BadGateway, typeof ServiceUnavailable, typeof GatewayTimeout];
243
269
  export type DefaultErrors = InstanceType<(typeof DEFAULT_ERRORS)[number]>;
244
270
  export declare const RETRYABLE: "@distilled/errors/retryable";
245
- export {};
246
271
  //# sourceMappingURL=errors.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAC5C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAC;AAM1C;;;;;;;;GAQG;AACH,eAAO,MAAM,cAAc,sDAE1B,CAAC;;;;;;;;AAMF;;GAEG;AACH,qBAAa,YAAa,SAAQ,iBAGJ;CAAG;;;;;;;;AAEjC;;GAEG;AACH,qBAAa,SAAU,SAAQ,cAGD;CAAG;;;;;;;;AAEjC;;GAEG;AACH,qBAAa,QAAS,SAAQ,aAEK;CAAG;;;;;;;;AAEtC;;GAEG;AACH,qBAAa,UAAW,SAAQ,eAGI;CAAG;;;;;;;;AAEvC;;GAEG;AACH,qBAAa,QAAS,SAAQ,aAEK;CAAG;;;;;;;;AAEtC;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,wBAGL;CAAG;;;;;;;;;;;AAEvC;;GAEG;AACH,qBAAa,eAAgB,SAAQ,oBASpC;CAAG;;;;;;;;;;;AAEJ;;GAEG;AACH,qBAAa,MAAO,SAAQ,WAG+B;CAAG;;;;;;;;;;;;AAE9D;;;;;;;GAOG;AACH,qBAAa,mBAAoB,SAAQ,wBAOiB;CAAG;;;;;;;;;;;AAE7D;;GAEG;AACH,qBAAa,UAAW,SAAQ,eAM0B;CAAG;;;;;;;;;;;AAE7D;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,uBAMkB;CAAG;;;;;;;;;;;AAE7D;;GAEG;AACH,qBAAa,cAAe,SAAQ,mBAMsB;CAAG;;;;;;;;AAE7D;;GAEG;AACH,qBAAa,WAAY,SAAQ,gBAGM;CAAG;AAM1C;;GAEG;AACH,eAAO,MAAM,eAAe;aAC1B,GAAG;aACH,GAAG;aACH,GAAG;aACH,GAAG;aACH,GAAG;aACH,GAAG;aACH,GAAG;aACH,GAAG;aACH,GAAG;aACH,GAAG;aACH,GAAG;aACH,GAAG;CACK,CAAC;AAEX;;;GAGG;AACH,eAAO,MAAM,sBAAsB,aAA0C,CAAC;AAE9E;;;;;;;;;GASG;AACH,eAAO,MAAM,uBAAuB,aAA0C,CAAC;AAE/E;;GAEG;AACH,eAAO,MAAM,UAAU,2QAab,CAAC;AAEX;;;GAGG;AACH,eAAO,MAAM,cAAc,yJAOjB,CAAC;AAEX,MAAM,MAAM,aAAa,GAAG,YAAY,CAAC,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;AAE1E,eAAO,MAAM,SAAS,EAAG,6BAAsC,CAAC"}
1
+ {"version":3,"file":"errors.d.ts","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAC5C,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,wBAAwB,CAAC;AAMjD;;;;;;;;GAQG;AACH,eAAO,MAAM,cAAc,uEAAuE,CAAC;AAEnG;;;;GAIG;AACH,eAAO,MAAM,mBAAmB;IAC9B,IAAI;IACJ,OAAO;CACR,CAAC;;;;;;;;;;AAMF;;GAEG;AACH,qBAAa,YACX,SAAQ,aAAa,CAAC,iBAGS;CAAG;;;;;;;;;;AAEpC;;GAEG;AACH,qBAAa,SACX,SAAQ,aAAa,CAAC,cAGS;CAAG;;;;;;;;;;AAEpC;;GAEG;AACH,qBAAa,QACX,SAAQ,aAAa,CAAC,aAGa;CAAG;;;;;;;;;;AAExC;;GAEG;AACH,qBAAa,UACX,SAAQ,aAAa,CAAC,eAGe;CAAG;;;;;;;;;;AAE1C;;GAEG;AACH,qBAAa,QACX,SAAQ,aAAa,CAAC,aAGa;CAAG;;;;;;;;;;AAExC;;GAEG;AACH,qBAAa,mBACX,SAAQ,aAAa,CAAC,wBAGe;CAAG;;;;;;;;;;;;;AAE1C;;GAEG;AACH,qBAAa,eACX,SAAQ,aAAa,CAAC,oBAOrB;CAAG;;;;;;;;;;;;;AAEN;;GAEG;AACH,qBAAa,MACX,SAAQ,aAAa,CAAC,WAImD;CAAG;;;;;;;;;;;;;;AAE9E;;;;;;;GAOG;AACH,qBAAa,mBACX,SAAQ,aAAa,CAAC,wBAKmD;CAAG;;;;;;;;;;;;;AAE9E;;GAEG;AACH,qBAAa,UACX,SAAQ,aAAa,CAAC,eAImD;CAAG;;;;;;;;;;;;;AAE9E;;GAEG;AACH,qBAAa,kBACX,SAAQ,aAAa,CAAC,uBAImD;CAAG;;;;;;;;;;;;;AAE9E;;GAEG;AACH,qBAAa,cACX,SAAQ,aAAa,CAAC,mBAImD;CAAG;AAI9E,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAI1C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAIlD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAI1C,OAAO,EAAE,kBAAkB,EAAE,KAAK,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAMhF;;GAEG;AACH,eAAO,MAAM,eAAe;aAC1B,GAAG;aACH,GAAG;aACH,GAAG;aACH,GAAG;aACH,GAAG;aACH,GAAG;aACH,GAAG;aACH,GAAG;aACH,GAAG;aACH,GAAG;aACH,GAAG;aACH,GAAG;aACH,GAAG;CACK,CAAC;AAEX;;;GAGG;AACH,eAAO,MAAM,sBAAsB,aAAwD,CAAC;AAE5F;;;;;;;;;GASG;AACH,eAAO,MAAM,uBAAuB,aAA6D,CAAC;AAElG;;GAEG;AACH,eAAO,MAAM,UAAU,2QAab,CAAC;AAEX;;;GAGG;AACH,eAAO,MAAM,cAAc,yJAOjB,CAAC;AAEX,MAAM,MAAM,aAAa,GAAG,YAAY,CAAC,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;AAE1E,eAAO,MAAM,SAAS,EAAG,6BAAsC,CAAC"}
package/lib/errors.js CHANGED
@@ -1,186 +1 @@
1
- /**
2
- * Common error types shared across SDKs.
3
- *
4
- * Each SDK defines its own provider-specific errors (e.g., Unauthorized, NotFound)
5
- * using the category system. This module provides base error types and utilities
6
- * that are used across all SDKs.
7
- */
8
- import * as Duration from "effect/Duration";
9
- import * as Schema from "effect/Schema";
10
- import * as Category from "./category.js";
11
- // ============================================================================
12
- // Shared Schema Helpers
13
- // ============================================================================
14
- /**
15
- * Opaque schema for an Effect `Duration.Duration` value.
16
- *
17
- * Used on retryable errors to carry a server-provided wait hint (e.g. parsed
18
- * from `Retry-After` or the IETF `Ratelimit` header). Core does not encode/decode
19
- * this field over the wire — it is constructed at runtime by `matchError` from
20
- * whatever the service actually returns (delay-seconds, HTTP-date, epoch, etc.)
21
- * and consumed at runtime by the retry policy.
22
- */
23
- export const DurationSchema = Schema.declare(Duration.isDuration);
24
- // ============================================================================
25
- // Common HTTP Status Error Classes
26
- // ============================================================================
27
- /**
28
- * Unauthorized - Authentication failure (401).
29
- */
30
- export class Unauthorized extends Schema.TaggedErrorClass()("Unauthorized", { message: Schema.String }).pipe(Category.withAuthError) {
31
- }
32
- /**
33
- * Forbidden - Access denied (403).
34
- */
35
- export class Forbidden extends Schema.TaggedErrorClass()("Forbidden", { message: Schema.String }).pipe(Category.withAuthError) {
36
- }
37
- /**
38
- * NotFound - Resource not found (404).
39
- */
40
- export class NotFound extends Schema.TaggedErrorClass()("NotFound", {
41
- message: Schema.String,
42
- }).pipe(Category.withNotFoundError) {
43
- }
44
- /**
45
- * BadRequest - Invalid request (400).
46
- */
47
- export class BadRequest extends Schema.TaggedErrorClass()("BadRequest", { message: Schema.String }).pipe(Category.withBadRequestError) {
48
- }
49
- /**
50
- * Conflict - Resource conflict (409).
51
- */
52
- export class Conflict extends Schema.TaggedErrorClass()("Conflict", {
53
- message: Schema.String,
54
- }).pipe(Category.withConflictError) {
55
- }
56
- /**
57
- * UnprocessableEntity - Validation error (422).
58
- */
59
- export class UnprocessableEntity extends Schema.TaggedErrorClass()("UnprocessableEntity", { message: Schema.String }).pipe(Category.withBadRequestError) {
60
- }
61
- /**
62
- * TooManyRequests - Rate limited (429).
63
- */
64
- export class TooManyRequests extends Schema.TaggedErrorClass()("TooManyRequests", {
65
- message: Schema.String,
66
- retryAfter: Schema.optional(DurationSchema),
67
- }).pipe(Category.withThrottlingError, Category.withRetryable({ throttling: true })) {
68
- }
69
- /**
70
- * Locked - Resource locked (423).
71
- */
72
- export class Locked extends Schema.TaggedErrorClass()("Locked", {
73
- message: Schema.String,
74
- retryAfter: Schema.optional(DurationSchema),
75
- }).pipe(Category.withLockedError, Category.withRetryable()) {
76
- }
77
- /**
78
- * InternalServerError - Server error.
79
- *
80
- * Mapped from HTTP 500 by default. Per-service patches may also pin it to a
81
- * specific in-band error code/message combination (e.g. Cloudflare returns a
82
- * 200 envelope carrying `{ code: 10002, message: "An unknown error has
83
- * occurred" }` for transient backend failures on some endpoints).
84
- */
85
- export class InternalServerError extends Schema.TaggedErrorClass()("InternalServerError", {
86
- message: Schema.String,
87
- code: Schema.optional(Schema.Number),
88
- retryAfter: Schema.optional(DurationSchema),
89
- }).pipe(Category.withServerError, Category.withRetryable()) {
90
- }
91
- /**
92
- * BadGateway - Bad gateway (502).
93
- */
94
- export class BadGateway extends Schema.TaggedErrorClass()("BadGateway", {
95
- message: Schema.String,
96
- retryAfter: Schema.optional(DurationSchema),
97
- }).pipe(Category.withServerError, Category.withRetryable()) {
98
- }
99
- /**
100
- * ServiceUnavailable - Service unavailable (503).
101
- */
102
- export class ServiceUnavailable extends Schema.TaggedErrorClass()("ServiceUnavailable", {
103
- message: Schema.String,
104
- retryAfter: Schema.optional(DurationSchema),
105
- }).pipe(Category.withServerError, Category.withRetryable()) {
106
- }
107
- /**
108
- * GatewayTimeout - Gateway timeout (504).
109
- */
110
- export class GatewayTimeout extends Schema.TaggedErrorClass()("GatewayTimeout", {
111
- message: Schema.String,
112
- retryAfter: Schema.optional(DurationSchema),
113
- }).pipe(Category.withServerError, Category.withRetryable()) {
114
- }
115
- /**
116
- * Configuration error - missing or invalid configuration.
117
- */
118
- export class ConfigError extends Schema.TaggedErrorClass()("ConfigError", { message: Schema.String }).pipe(Category.withConfigurationError) {
119
- }
120
- // ============================================================================
121
- // Error Maps
122
- // ============================================================================
123
- /**
124
- * Mapping from HTTP status codes to common error classes.
125
- */
126
- export const HTTP_STATUS_MAP = {
127
- 400: BadRequest,
128
- 401: Unauthorized,
129
- 403: Forbidden,
130
- 404: NotFound,
131
- 409: Conflict,
132
- 422: UnprocessableEntity,
133
- 423: Locked,
134
- 429: TooManyRequests,
135
- 500: InternalServerError,
136
- 502: BadGateway,
137
- 503: ServiceUnavailable,
138
- 504: GatewayTimeout,
139
- };
140
- /**
141
- * HTTP status codes that are considered "default" errors (always present).
142
- * These are excluded from per-operation error types since they're handled globally.
143
- */
144
- export const DEFAULT_ERROR_STATUSES = new Set([401, 429, 500, 502, 503, 504]);
145
- /**
146
- * HTTP status codes whose corresponding error class in {@link HTTP_STATUS_MAP}
147
- * declares a `retryAfter` field. The retry policy honors `error.retryAfter`
148
- * with precedence over the default backoff for these.
149
- *
150
- * `matchError` implementations should only pass `retryAfter` into the
151
- * constructor when the status is in this set; passing it on non-retryable
152
- * classes (BadRequest/Unauthorized/etc.) would silently retain it as a
153
- * stale field on the instance and pollute serialized output.
154
- */
155
- export const RETRYABLE_HTTP_STATUSES = new Set([423, 429, 500, 502, 503, 504]);
156
- /**
157
- * All common API error classes.
158
- */
159
- export const API_ERRORS = [
160
- Unauthorized,
161
- Forbidden,
162
- NotFound,
163
- BadRequest,
164
- Conflict,
165
- UnprocessableEntity,
166
- TooManyRequests,
167
- Locked,
168
- InternalServerError,
169
- BadGateway,
170
- ServiceUnavailable,
171
- GatewayTimeout,
172
- ];
173
- /**
174
- * Default errors that apply to ALL operations.
175
- * These are infrastructure-level errors that can occur regardless of the operation.
176
- */
177
- export const DEFAULT_ERRORS = [
178
- Unauthorized,
179
- TooManyRequests,
180
- InternalServerError,
181
- BadGateway,
182
- ServiceUnavailable,
183
- GatewayTimeout,
184
- ];
185
- export const RETRYABLE = "@distilled/errors/retryable";
186
- //# sourceMappingURL=errors.js.map
1
+ export { errors$API_ERRORS as API_ERRORS, errors$BadGateway as BadGateway, errors$BadRequest as BadRequest, errors$ConfigError as ConfigError, errors$Conflict as Conflict, errors$DEFAULT_ERRORS as DEFAULT_ERRORS, errors$DEFAULT_ERROR_STATUSES as DEFAULT_ERROR_STATUSES, errors$DurationSchema as DurationSchema, errors$Forbidden as Forbidden, errors$GatewayTimeout as GatewayTimeout, errors$HTTP_STATUS_MAP as HTTP_STATUS_MAP, errors$InternalServerError as InternalServerError, errors$InvalidInput as InvalidInput, errors$Locked as Locked, errors$NotFound as NotFound, errors$RETRYABLE as RETRYABLE, errors$RETRYABLE_HTTP_STATUSES as RETRYABLE_HTTP_STATUSES, errors$ResponseErrorFields as ResponseErrorFields, errors$SdkError as SdkError, errors$ServiceUnavailable as ServiceUnavailable, errors$TooManyRequests as TooManyRequests, errors$Unauthorized as Unauthorized, errors$UnknownErrorFields as UnknownErrorFields, errors$UnprocessableEntity as UnprocessableEntity } from "./_bundle/rest.js";