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

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 (291) hide show
  1. package/LICENSE +201 -0
  2. package/lib/_bundle/aws.js +2 -0
  3. package/lib/_bundle/aws.js.map +1 -0
  4. package/lib/_bundle/base.js +5 -0
  5. package/lib/_bundle/base.js.map +1 -0
  6. package/lib/_bundle/graphql.js +3 -0
  7. package/lib/_bundle/graphql.js.map +1 -0
  8. package/lib/_bundle/grpc.js +2 -0
  9. package/lib/_bundle/grpc.js.map +1 -0
  10. package/lib/_bundle/rest.js +2 -0
  11. package/lib/_bundle/rest.js.map +1 -0
  12. package/lib/_bundle/xml.js +4 -0
  13. package/lib/_bundle/xml.js.map +1 -0
  14. package/lib/annotations.d.ts +17 -0
  15. package/lib/annotations.d.ts.map +1 -0
  16. package/lib/annotations.js +2 -0
  17. package/lib/annotations.js.map +1 -0
  18. package/lib/api.d.ts +174 -18
  19. package/lib/api.d.ts.map +1 -1
  20. package/lib/api.js +1 -178
  21. package/lib/category.d.ts +4 -4
  22. package/lib/category.d.ts.map +1 -1
  23. package/lib/category.js +1 -280
  24. package/lib/chunks.d.ts +3 -0
  25. package/lib/chunks.d.ts.map +1 -0
  26. package/lib/chunks.js +1 -0
  27. package/lib/config.d.ts +68 -0
  28. package/lib/config.d.ts.map +1 -0
  29. package/lib/config.js +1 -0
  30. package/lib/crypto.d.ts +76 -0
  31. package/lib/crypto.d.ts.map +1 -0
  32. package/lib/crypto.js +1 -0
  33. package/lib/error-category.d.ts +1 -1
  34. package/lib/error-category.d.ts.map +1 -1
  35. package/lib/error-category.js +1 -46
  36. package/lib/errors.d.ts +64 -72
  37. package/lib/errors.d.ts.map +1 -1
  38. package/lib/errors.js +1 -186
  39. package/lib/graphql.d.ts +403 -0
  40. package/lib/graphql.d.ts.map +1 -0
  41. package/lib/graphql.js +1 -0
  42. package/lib/graphql.types.d.ts +12 -0
  43. package/lib/graphql.types.d.ts.map +1 -0
  44. package/lib/graphql.types.js +1 -0
  45. package/lib/grpc-transport-cloudflare-http2.d.ts +7 -0
  46. package/lib/grpc-transport-cloudflare-http2.d.ts.map +1 -0
  47. package/lib/grpc-transport-cloudflare-http2.js +6 -0
  48. package/lib/grpc-transport-cloudflare-http2.js.map +1 -0
  49. package/lib/grpc-transport-cloudflare-sockets.d.ts +7 -0
  50. package/lib/grpc-transport-cloudflare-sockets.d.ts.map +1 -0
  51. package/lib/grpc-transport-cloudflare-sockets.js +5 -0
  52. package/lib/grpc-transport-cloudflare-sockets.js.map +1 -0
  53. package/lib/grpc-transport-node-http2.d.ts +19 -0
  54. package/lib/grpc-transport-node-http2.d.ts.map +1 -0
  55. package/lib/grpc-transport-node-http2.js +2 -0
  56. package/lib/grpc-transport-node-http2.js.map +1 -0
  57. package/lib/grpc-transport.d.ts +76 -0
  58. package/lib/grpc-transport.d.ts.map +1 -0
  59. package/lib/grpc-transport.js +1 -0
  60. package/lib/hpack.d.ts +34 -0
  61. package/lib/hpack.d.ts.map +1 -0
  62. package/lib/hpack.js +2 -0
  63. package/lib/hpack.js.map +1 -0
  64. package/lib/index.d.ts +32 -0
  65. package/lib/index.d.ts.map +1 -0
  66. package/lib/index.js +17 -0
  67. package/lib/pagination.d.ts +101 -24
  68. package/lib/pagination.d.ts.map +1 -1
  69. package/lib/pagination.js +1 -182
  70. package/lib/plain-values.d.ts +10 -0
  71. package/lib/plain-values.d.ts.map +1 -0
  72. package/lib/plain-values.js +2 -0
  73. package/lib/plain-values.js.map +1 -0
  74. package/lib/protobuf.d.ts +92 -0
  75. package/lib/protobuf.d.ts.map +1 -0
  76. package/lib/protobuf.js +1 -0
  77. package/lib/protocol-grpc.d.ts +86 -0
  78. package/lib/protocol-grpc.d.ts.map +1 -0
  79. package/lib/protocol-grpc.js +1 -0
  80. package/lib/protocol-http.d.ts +102 -23
  81. package/lib/protocol-http.d.ts.map +1 -1
  82. package/lib/protocol-http.js +1 -554
  83. package/lib/protocol-rest.d.ts +120 -50
  84. package/lib/protocol-rest.d.ts.map +1 -1
  85. package/lib/protocol-rest.js +1 -242
  86. package/lib/query.d.ts +29 -0
  87. package/lib/query.d.ts.map +1 -0
  88. package/lib/query.js +1 -0
  89. package/lib/response-validation-strict.d.ts +48 -0
  90. package/lib/response-validation-strict.d.ts.map +1 -0
  91. package/lib/response-validation-strict.js +1 -0
  92. package/lib/response-validation.d.ts +86 -0
  93. package/lib/response-validation.d.ts.map +1 -0
  94. package/lib/response-validation.js +1 -0
  95. package/lib/retry-after.d.ts +3 -3
  96. package/lib/retry-after.d.ts.map +1 -1
  97. package/lib/retry-after.js +1 -112
  98. package/lib/retry.d.ts +48 -29
  99. package/lib/retry.d.ts.map +1 -1
  100. package/lib/retry.js +1 -210
  101. package/lib/schema-lite-impl.d.ts +158 -0
  102. package/lib/schema-lite-impl.d.ts.map +1 -0
  103. package/lib/schema-lite-impl.js +1 -0
  104. package/lib/schema-lite-typed.d.ts +41 -0
  105. package/lib/schema-lite-typed.d.ts.map +1 -0
  106. package/lib/schema-lite-typed.js +1 -0
  107. package/lib/schema-lite.d.ts +40 -0
  108. package/lib/schema-lite.d.ts.map +1 -0
  109. package/lib/schema-lite.js +1 -0
  110. package/lib/schema.d.ts +21 -7
  111. package/lib/schema.d.ts.map +1 -1
  112. package/lib/schema.js +1 -48
  113. package/lib/sdk-error.d.ts +27 -0
  114. package/lib/sdk-error.d.ts.map +1 -0
  115. package/lib/sdk-error.js +1 -0
  116. package/lib/sensitive.d.ts +28 -0
  117. package/lib/sensitive.d.ts.map +1 -0
  118. package/lib/sensitive.js +2 -0
  119. package/lib/sensitive.js.map +1 -0
  120. package/lib/telemetry-debug.d.ts +6 -0
  121. package/lib/telemetry-debug.d.ts.map +1 -0
  122. package/lib/telemetry-debug.js +2 -0
  123. package/lib/telemetry-debug.js.map +1 -0
  124. package/lib/telemetry-hooks.d.ts +32 -0
  125. package/lib/telemetry-hooks.d.ts.map +1 -0
  126. package/lib/telemetry-hooks.js +2 -0
  127. package/lib/telemetry-hooks.js.map +1 -0
  128. package/lib/telemetry-host-rules.d.ts +23 -0
  129. package/lib/telemetry-host-rules.d.ts.map +1 -0
  130. package/lib/telemetry-host-rules.js +2 -0
  131. package/lib/telemetry-host-rules.js.map +1 -0
  132. package/lib/telemetry-lambda-context.d.ts +17 -0
  133. package/lib/telemetry-lambda-context.d.ts.map +1 -0
  134. package/lib/telemetry-lambda-context.js +2 -0
  135. package/lib/telemetry-lambda-context.js.map +1 -0
  136. package/lib/telemetry-message-context.d.ts +52 -0
  137. package/lib/telemetry-message-context.d.ts.map +1 -0
  138. package/lib/telemetry-message-context.js +2 -0
  139. package/lib/telemetry-message-context.js.map +1 -0
  140. package/lib/telemetry-metrics.d.ts +6 -0
  141. package/lib/telemetry-metrics.d.ts.map +1 -0
  142. package/lib/telemetry-metrics.js +2 -0
  143. package/lib/telemetry-metrics.js.map +1 -0
  144. package/lib/telemetry-name-template.d.ts +13 -0
  145. package/lib/telemetry-name-template.d.ts.map +1 -0
  146. package/lib/telemetry-name-template.js +2 -0
  147. package/lib/telemetry-name-template.js.map +1 -0
  148. package/lib/telemetry-stream.d.ts +11 -0
  149. package/lib/telemetry-stream.d.ts.map +1 -0
  150. package/lib/telemetry-stream.js +2 -0
  151. package/lib/telemetry-stream.js.map +1 -0
  152. package/lib/telemetry-xray.d.ts +28 -0
  153. package/lib/telemetry-xray.d.ts.map +1 -0
  154. package/lib/telemetry-xray.js +2 -0
  155. package/lib/telemetry-xray.js.map +1 -0
  156. package/lib/telemetry.d.ts +288 -0
  157. package/lib/telemetry.d.ts.map +1 -0
  158. package/lib/telemetry.js +3 -0
  159. package/lib/telemetry.js.map +1 -0
  160. package/lib/trait.d.ts +71 -20
  161. package/lib/trait.d.ts.map +1 -1
  162. package/lib/trait.js +1 -107
  163. package/lib/unknown-error.d.ts +18 -0
  164. package/lib/unknown-error.d.ts.map +1 -0
  165. package/lib/unknown-error.js +1 -0
  166. package/lib/xml.d.ts +44 -0
  167. package/lib/xml.d.ts.map +1 -0
  168. package/lib/xml.js +1 -0
  169. package/package.json +13 -13
  170. package/src/annotations.ts +53 -0
  171. package/src/api.ts +1370 -200
  172. package/src/category.ts +76 -106
  173. package/src/chunks.ts +30 -0
  174. package/src/config.ts +245 -0
  175. package/src/crypto.ts +202 -0
  176. package/src/error-category.ts +16 -29
  177. package/src/errors.ts +75 -75
  178. package/src/graphql.ts +1778 -0
  179. package/src/graphql.types.ts +105 -0
  180. package/src/grpc-transport-cloudflare-http2.ts +494 -0
  181. package/src/grpc-transport-cloudflare-sockets.ts +299 -0
  182. package/src/grpc-transport-node-http2.ts +234 -0
  183. package/src/grpc-transport.ts +118 -0
  184. package/src/hpack.ts +331 -0
  185. package/src/index.ts +31 -0
  186. package/src/pagination.ts +368 -94
  187. package/src/plain-values.ts +41 -0
  188. package/src/protobuf.ts +1332 -0
  189. package/src/protocol-grpc.ts +641 -0
  190. package/src/protocol-http.ts +622 -322
  191. package/src/protocol-rest.ts +440 -227
  192. package/src/query.ts +39 -0
  193. package/src/response-validation-strict.ts +327 -0
  194. package/src/response-validation.ts +161 -0
  195. package/src/retry-after.ts +7 -13
  196. package/src/retry.ts +96 -110
  197. package/src/schema-lite-impl.ts +550 -0
  198. package/src/schema-lite-typed.ts +44 -0
  199. package/src/schema-lite.ts +44 -0
  200. package/src/schema.ts +259 -15
  201. package/src/sdk-error.ts +33 -0
  202. package/src/sensitive.ts +154 -0
  203. package/src/telemetry-debug.ts +179 -0
  204. package/src/telemetry-hooks.ts +33 -0
  205. package/src/telemetry-host-rules.ts +39 -0
  206. package/src/telemetry-lambda-context.ts +46 -0
  207. package/src/telemetry-message-context.ts +170 -0
  208. package/src/telemetry-metrics.ts +69 -0
  209. package/src/telemetry-name-template.ts +26 -0
  210. package/src/telemetry-stream.ts +100 -0
  211. package/src/telemetry-xray.ts +66 -0
  212. package/src/telemetry.ts +832 -0
  213. package/src/trait.ts +106 -67
  214. package/src/unknown-error.ts +38 -0
  215. package/src/xml.ts +346 -0
  216. package/lib/api.js.map +0 -1
  217. package/lib/category.js.map +0 -1
  218. package/lib/codegen/cli.d.ts +0 -29
  219. package/lib/codegen/cli.d.ts.map +0 -1
  220. package/lib/codegen/cli.js +0 -165
  221. package/lib/codegen/cli.js.map +0 -1
  222. package/lib/codegen/emit.d.ts +0 -129
  223. package/lib/codegen/emit.d.ts.map +0 -1
  224. package/lib/codegen/emit.js +0 -105
  225. package/lib/codegen/emit.js.map +0 -1
  226. package/lib/codegen/format.d.ts +0 -23
  227. package/lib/codegen/format.d.ts.map +0 -1
  228. package/lib/codegen/format.js +0 -28
  229. package/lib/codegen/format.js.map +0 -1
  230. package/lib/codegen/generator.d.ts +0 -334
  231. package/lib/codegen/generator.d.ts.map +0 -1
  232. package/lib/codegen/generator.js +0 -691
  233. package/lib/codegen/generator.js.map +0 -1
  234. package/lib/codegen/graph.d.ts +0 -36
  235. package/lib/codegen/graph.d.ts.map +0 -1
  236. package/lib/codegen/graph.js +0 -136
  237. package/lib/codegen/graph.js.map +0 -1
  238. package/lib/codegen/members.d.ts +0 -25
  239. package/lib/codegen/members.d.ts.map +0 -1
  240. package/lib/codegen/members.js +0 -55
  241. package/lib/codegen/members.js.map +0 -1
  242. package/lib/codegen/naming.d.ts +0 -29
  243. package/lib/codegen/naming.d.ts.map +0 -1
  244. package/lib/codegen/naming.js +0 -74
  245. package/lib/codegen/naming.js.map +0 -1
  246. package/lib/codegen/openapi-cli.d.ts +0 -38
  247. package/lib/codegen/openapi-cli.d.ts.map +0 -1
  248. package/lib/codegen/openapi-cli.js +0 -107
  249. package/lib/codegen/openapi-cli.js.map +0 -1
  250. package/lib/codegen/openapi.d.ts +0 -115
  251. package/lib/codegen/openapi.d.ts.map +0 -1
  252. package/lib/codegen/openapi.js +0 -1220
  253. package/lib/codegen/openapi.js.map +0 -1
  254. package/lib/codegen/operations.d.ts +0 -24
  255. package/lib/codegen/operations.d.ts.map +0 -1
  256. package/lib/codegen/operations.js +0 -56
  257. package/lib/codegen/operations.js.map +0 -1
  258. package/lib/codegen/pagination.d.ts +0 -39
  259. package/lib/codegen/pagination.d.ts.map +0 -1
  260. package/lib/codegen/pagination.js +0 -33
  261. package/lib/codegen/pagination.js.map +0 -1
  262. package/lib/codegen/prelude.d.ts +0 -15
  263. package/lib/codegen/prelude.d.ts.map +0 -1
  264. package/lib/codegen/prelude.js +0 -60
  265. package/lib/codegen/prelude.js.map +0 -1
  266. package/lib/error-category.js.map +0 -1
  267. package/lib/errors.js.map +0 -1
  268. package/lib/json-patch.d.ts +0 -44
  269. package/lib/json-patch.d.ts.map +0 -1
  270. package/lib/json-patch.js +0 -174
  271. package/lib/json-patch.js.map +0 -1
  272. package/lib/pagination.js.map +0 -1
  273. package/lib/protocol-http.js.map +0 -1
  274. package/lib/protocol-rest.js.map +0 -1
  275. package/lib/retry-after.js.map +0 -1
  276. package/lib/retry.js.map +0 -1
  277. package/lib/schema.js.map +0 -1
  278. package/lib/trait.js.map +0 -1
  279. package/src/codegen/cli.ts +0 -268
  280. package/src/codegen/emit.ts +0 -207
  281. package/src/codegen/format.ts +0 -47
  282. package/src/codegen/generator.ts +0 -1153
  283. package/src/codegen/graph.ts +0 -151
  284. package/src/codegen/members.ts +0 -71
  285. package/src/codegen/naming.ts +0 -86
  286. package/src/codegen/openapi-cli.ts +0 -166
  287. package/src/codegen/openapi.ts +0 -1450
  288. package/src/codegen/operations.ts +0 -76
  289. package/src/codegen/pagination.ts +0 -71
  290. package/src/codegen/prelude.ts +0 -70
  291. package/src/json-patch.ts +0 -222
package/lib/category.js CHANGED
@@ -1,280 +1 @@
1
- /**
2
- * Error Category System
3
- *
4
- * Provides a unified error classification system across all SDKs.
5
- * Error classes are decorated with categories using `.pipe()` on Schema.TaggedError classes,
6
- * enabling semantic error handling (e.g., catch all auth errors regardless of provider).
7
- *
8
- * @example
9
- * ```ts
10
- * import * as Category from "@distilled.cloud/core/category";
11
- *
12
- * export class Unauthorized extends Schema.TaggedErrorClass<Unauthorized>()(
13
- * "Unauthorized",
14
- * { message: Schema.String },
15
- * ).pipe(Category.withAuthError) {}
16
- *
17
- * // Catch by category
18
- * effect.pipe(Category.catchAuthError((err) => Effect.succeed("handled")))
19
- * ```
20
- */
21
- import * as Effect from "effect/Effect";
22
- import * as Predicate from "effect/Predicate";
23
- import * as HttpClientError from "effect/unstable/http/HttpClientError";
24
- // ============================================================================
25
- // Error Category Constants
26
- // ============================================================================
27
- export const AuthError = "AuthError";
28
- export const BadRequestError = "BadRequestError";
29
- export const ConflictError = "ConflictError";
30
- export const NotFoundError = "NotFoundError";
31
- export const QuotaError = "QuotaError";
32
- export const ServerError = "ServerError";
33
- export const ThrottlingError = "ThrottlingError";
34
- export const NetworkError = "NetworkError";
35
- export const ParseError = "ParseError";
36
- export const ConfigurationError = "ConfigurationError";
37
- export const TimeoutError = "TimeoutError";
38
- export const RetryableError = "RetryableError";
39
- export const LockedError = "LockedError";
40
- export const AbortedError = "AbortedError";
41
- export const AlreadyExistsError = "AlreadyExistsError";
42
- export const DependencyViolationError = "DependencyViolationError";
43
- // ============================================================================
44
- // Category Storage Key
45
- // ============================================================================
46
- /**
47
- * Key for storing categories on error prototypes.
48
- * Shared across all SDKs so category checking works uniformly.
49
- */
50
- export const categoriesKey = "@distilled.cloud/error/categories";
51
- /**
52
- * Key for storing retryable trait on error prototypes.
53
- * Separate from categories - indicates this error should be retried.
54
- */
55
- export const retryableKey = "@distilled.cloud/error/retryable";
56
- // ============================================================================
57
- // Category Decorator
58
- // ============================================================================
59
- /**
60
- * Add one or more categories to an error class.
61
- * Use with .pipe() on Schema.TaggedError classes.
62
- *
63
- * @example
64
- * ```ts
65
- * export class MyError extends Schema.TaggedErrorClass<MyError>()(
66
- * "MyError",
67
- * { message: Schema.String },
68
- * ).pipe(Category.withCategory(Category.AuthError)) {}
69
- * ```
70
- */
71
- export const withCategory = (...categories) => (C) => {
72
- for (const category of categories) {
73
- if (!(categoriesKey in C.prototype)) {
74
- C.prototype[categoriesKey] = {};
75
- }
76
- C.prototype[categoriesKey][category] = true;
77
- }
78
- return C;
79
- };
80
- /**
81
- * Mark an error class as retryable.
82
- * Use with .pipe() on Schema.TaggedError classes.
83
- *
84
- * @example
85
- * ```ts
86
- * // Standard retryable error
87
- * export class TransientError extends Schema.TaggedErrorClass<TransientError>()(
88
- * "TransientError",
89
- * { message: Schema.String },
90
- * ).pipe(Category.withRetryable()) {}
91
- *
92
- * // Throttling error (uses longer backoff)
93
- * export class RateLimitError extends Schema.TaggedErrorClass<RateLimitError>()(
94
- * "RateLimitError",
95
- * { message: Schema.String },
96
- * ).pipe(Category.withRetryable({ throttling: true })) {}
97
- * ```
98
- */
99
- export const withRetryable = (info = {}) => (C) => {
100
- C.prototype[retryableKey] = info;
101
- return C;
102
- };
103
- // ============================================================================
104
- // Category Decorators (convenience functions for common categories)
105
- // ============================================================================
106
- export const withAuthError = withCategory(AuthError);
107
- export const withBadRequestError = withCategory(BadRequestError);
108
- export const withConflictError = withCategory(ConflictError);
109
- export const withNotFoundError = withCategory(NotFoundError);
110
- export const withQuotaError = withCategory(QuotaError);
111
- export const withServerError = withCategory(ServerError);
112
- export const withThrottlingError = withCategory(ThrottlingError);
113
- export const withNetworkError = withCategory(NetworkError);
114
- export const withParseError = withCategory(ParseError);
115
- export const withConfigurationError = withCategory(ConfigurationError);
116
- export const withTimeoutError = withCategory(TimeoutError);
117
- export const withRetryableError = withCategory(RetryableError);
118
- export const withLockedError = withCategory(LockedError);
119
- export const withAbortedError = withCategory(AbortedError);
120
- export const withAlreadyExistsError = withCategory(AlreadyExistsError);
121
- export const withDependencyViolationError = withCategory(DependencyViolationError);
122
- // ============================================================================
123
- // Category Predicates
124
- // ============================================================================
125
- /**
126
- * Check if an error has a specific category.
127
- */
128
- export const hasCategory = (error, category) => {
129
- if (Predicate.isObject(error) &&
130
- Predicate.hasProperty(categoriesKey)(error)) {
131
- // @ts-expect-error - dynamic property access
132
- return category in error[categoriesKey];
133
- }
134
- return false;
135
- };
136
- export const isAuthError = (error) => hasCategory(error, AuthError);
137
- export const isBadRequestError = (error) => hasCategory(error, BadRequestError);
138
- export const isConflictError = (error) => hasCategory(error, ConflictError);
139
- export const isNotFoundError = (error) => hasCategory(error, NotFoundError);
140
- export const isQuotaError = (error) => hasCategory(error, QuotaError);
141
- export const isServerError = (error) => hasCategory(error, ServerError);
142
- export const isThrottlingError = (error) => hasCategory(error, ThrottlingError);
143
- export const isNetworkError = (error) => hasCategory(error, NetworkError);
144
- export const isParseError = (error) => hasCategory(error, ParseError);
145
- export const isConfigurationError = (error) => hasCategory(error, ConfigurationError);
146
- export const isTimeoutError = (error) => hasCategory(error, TimeoutError);
147
- export const isRetryableError = (error) => hasCategory(error, RetryableError);
148
- export const isLockedError = (error) => hasCategory(error, LockedError);
149
- export const isAbortedError = (error) => hasCategory(error, AbortedError);
150
- export const isAlreadyExistsError = (error) => hasCategory(error, AlreadyExistsError);
151
- export const isDependencyViolationError = (error) => hasCategory(error, DependencyViolationError);
152
- // ============================================================================
153
- // Transient Error Detection (for retry logic)
154
- // ============================================================================
155
- /**
156
- * Check if an error has the retryable trait (set via withRetryable).
157
- */
158
- export const isRetryable = (error) => {
159
- if (Predicate.isObject(error) && Predicate.hasProperty(retryableKey)(error)) {
160
- return true;
161
- }
162
- return false;
163
- };
164
- /**
165
- * Check if an error is a throttling error.
166
- * Either has ThrottlingError category or retryable trait with throttling: true.
167
- */
168
- export const isThrottling = (error) => {
169
- if (Predicate.isObject(error) && Predicate.hasProperty(retryableKey)(error)) {
170
- // @ts-expect-error - dynamic property access
171
- return error[retryableKey]?.throttling === true;
172
- }
173
- return hasCategory(error, ThrottlingError);
174
- };
175
- /**
176
- * Check if an error is an Effect `HttpClientError` caused by a wire-level
177
- * transport failure (undici `ConnectTimeoutError`, socket reset, DNS
178
- * failure, premature stream close, …). The request never reached the
179
- * server (or the response never finished) so retrying is safe.
180
- *
181
- * Status-code retries are intentionally left to the per-SDK API client,
182
- * which knows whether a given response is genuinely retryable.
183
- */
184
- const isHttpTransportError = (error) => HttpClientError.isHttpClientError(error) &&
185
- error.reason._tag === "TransportError";
186
- /**
187
- * Check if an error is a transient error that should be automatically retried.
188
- * Transient errors include:
189
- * - Errors marked with withRetryable()
190
- * - RetryableError category
191
- * - ThrottlingError (rate limiting)
192
- * - ServerError (5xx responses)
193
- * - NetworkError (connection issues)
194
- * - TimeoutError (request timed out)
195
- * - LockedError (423 - resource temporarily locked)
196
- * - Effect `HttpClientError` with `reason._tag === "TransportError"`
197
- * (undici connect/read timeout, socket reset, DNS failure, premature
198
- * stream close)
199
- */
200
- export const isTransientError = (error) => {
201
- // Check for retryable trait first
202
- if (isRetryable(error)) {
203
- return true;
204
- }
205
- // Fall back to category-based checking
206
- return (hasCategory(error, RetryableError) ||
207
- hasCategory(error, ThrottlingError) ||
208
- hasCategory(error, ServerError) ||
209
- hasCategory(error, NetworkError) ||
210
- hasCategory(error, TimeoutError) ||
211
- hasCategory(error, LockedError) ||
212
- isHttpTransportError(error));
213
- };
214
- // ============================================================================
215
- // Category Catchers
216
- // ============================================================================
217
- const makeCatcher = (category) => (f) => (effect) => Effect.catchIf(effect, (e) => hasCategory(e, category), f);
218
- /**
219
- * Catch errors matching any of the specified categories.
220
- *
221
- * @example
222
- * ```ts
223
- * effect.pipe(
224
- * Category.catchErrors(Category.AuthError, Category.NotFoundError, (err) =>
225
- * Effect.succeed("handled")
226
- * )
227
- * )
228
- * ```
229
- */
230
- export const catchErrors = (...args) => (effect) => {
231
- const handler = args.pop();
232
- const categories = args;
233
- return Effect.catchIf(effect, (e) => categories.some((cat) => hasCategory(e, cat)), handler);
234
- };
235
- // Alias for convenience
236
- export { catchErrors as catch };
237
- export const catchAuthError = makeCatcher(AuthError);
238
- export const catchBadRequestError = makeCatcher(BadRequestError);
239
- export const catchConflictError = makeCatcher(ConflictError);
240
- export const catchNotFoundError = makeCatcher(NotFoundError);
241
- export const catchQuotaError = makeCatcher(QuotaError);
242
- export const catchServerError = makeCatcher(ServerError);
243
- export const catchThrottlingError = makeCatcher(ThrottlingError);
244
- export const catchNetworkError = makeCatcher(NetworkError);
245
- export const catchParseError = makeCatcher(ParseError);
246
- export const catchConfigurationError = makeCatcher(ConfigurationError);
247
- export const catchTimeoutError = makeCatcher(TimeoutError);
248
- export const catchRetryableError = makeCatcher(RetryableError);
249
- export const catchLockedError = makeCatcher(LockedError);
250
- export const catchAbortedError = makeCatcher(AbortedError);
251
- export const catchAlreadyExistsError = makeCatcher(AlreadyExistsError);
252
- export const catchDependencyViolationError = makeCatcher(DependencyViolationError);
253
- /**
254
- * Catch errors with specified categories with full type narrowing.
255
- *
256
- * @example
257
- * ```ts
258
- * effect.pipe(
259
- * Category.catchCategory(Category.AuthError, (err) => Effect.succeed("handled"))
260
- * )
261
- * ```
262
- */
263
- export const catchCategory = (...args) => (effect) => {
264
- const f = args.pop();
265
- const categories = args;
266
- return Effect.catchIf(effect, (e) => {
267
- if (Predicate.isObject(e) && Predicate.hasProperty(categoriesKey)(e)) {
268
- for (const cat of categories) {
269
- // @ts-expect-error - dynamic property access
270
- if (cat in e[categoriesKey]) {
271
- return true;
272
- }
273
- }
274
- }
275
- return false;
276
- },
277
- // @ts-expect-error - type narrowing limitation
278
- (e) => f(e));
279
- };
280
- //# sourceMappingURL=category.js.map
1
+ export { category$AbortedError as AbortedError, category$AlreadyExistsError as AlreadyExistsError, category$AuthError as AuthError, category$BadRequestError as BadRequestError, category$ConfigurationError as ConfigurationError, category$ConflictError as ConflictError, category$DependencyViolationError as DependencyViolationError, category$LockedError as LockedError, category$NetworkError as NetworkError, category$NotFoundError as NotFoundError, category$ParseError as ParseError, category$QuotaError as QuotaError, category$RetryableError as RetryableError, category$ServerError as ServerError, category$ThrottlingError as ThrottlingError, category$TimeoutError as TimeoutError, category$catch as catch, category$catchAbortedError as catchAbortedError, category$catchAlreadyExistsError as catchAlreadyExistsError, category$catchAuthError as catchAuthError, category$catchBadRequestError as catchBadRequestError, category$catchCategory as catchCategory, category$catchConfigurationError as catchConfigurationError, category$catchConflictError as catchConflictError, category$catchDependencyViolationError as catchDependencyViolationError, category$catchErrors as catchErrors, category$catchLockedError as catchLockedError, category$catchNetworkError as catchNetworkError, category$catchNotFoundError as catchNotFoundError, category$catchParseError as catchParseError, category$catchQuotaError as catchQuotaError, category$catchRetryableError as catchRetryableError, category$catchServerError as catchServerError, category$catchThrottlingError as catchThrottlingError, category$catchTimeoutError as catchTimeoutError, category$categoriesKey as categoriesKey, category$hasCategory as hasCategory, category$isAbortedError as isAbortedError, category$isAlreadyExistsError as isAlreadyExistsError, category$isAuthError as isAuthError, category$isBadRequestError as isBadRequestError, category$isConfigurationError as isConfigurationError, category$isConflictError as isConflictError, category$isDependencyViolationError as isDependencyViolationError, category$isLockedError as isLockedError, category$isNetworkError as isNetworkError, category$isNotFoundError as isNotFoundError, category$isParseError as isParseError, category$isQuotaError as isQuotaError, category$isRetryable as isRetryable, category$isRetryableError as isRetryableError, category$isServerError as isServerError, category$isThrottling as isThrottling, category$isThrottlingError as isThrottlingError, category$isTimeoutError as isTimeoutError, category$isTransientError as isTransientError, category$retryableKey as retryableKey, category$withAbortedError as withAbortedError, category$withAlreadyExistsError as withAlreadyExistsError, category$withAuthError as withAuthError, category$withBadRequestError as withBadRequestError, category$withCategory as withCategory, category$withConfigurationError as withConfigurationError, category$withConflictError as withConflictError, category$withDependencyViolationError as withDependencyViolationError, category$withLockedError as withLockedError, category$withNetworkError as withNetworkError, category$withNotFoundError as withNotFoundError, category$withParseError as withParseError, category$withQuotaError as withQuotaError, category$withRetryable as withRetryable, category$withRetryableError as withRetryableError, category$withServerError as withServerError, category$withThrottlingError as withThrottlingError, category$withTimeoutError as withTimeoutError } from "./_bundle/base.js";
@@ -0,0 +1,3 @@
1
+ /** Schema `j` of the chunk `build`, built on first use. */
2
+ export declare const at: (build: (j: number) => unknown, j: number) => any;
3
+ //# sourceMappingURL=chunks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunks.d.ts","sourceRoot":"","sources":["../src/chunks.ts"],"names":[],"mappings":"AAsBA,2DAA2D;AAE3D,eAAO,MAAM,EAAE,UAAW,CAAC,CAAC,EAAE,MAAM,KAAK,OAAO,KAAK,MAAM,KAAG,GAK7D,CAAC"}
package/lib/chunks.js ADDED
@@ -0,0 +1 @@
1
+ export { chunks$at as at } from "./_bundle/aws.js";
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Environment configuration for credentials, endpoints and regions: the
3
+ * small part of `effect/Config` that SDKs use, as plain Effects.
4
+ *
5
+ * Importing `effect/Config` costs about 280 KB of heap per process (it pulls
6
+ * in ConfigProvider, Schema-based parsing and their dependencies), and every
7
+ * SDK whose credentials read the environment paid it at import. These
8
+ * readers do the same lookups without it:
9
+ *
10
+ * - When the caller provided a `ConfigProvider` (found by its context key),
11
+ * the value comes from that provider, so `ConfigProvider.fromUnknown(...)`
12
+ * in tests and custom providers on Workers keep working.
13
+ * - Otherwise the value comes from `process.env`, which is what Effect's
14
+ * default provider reads.
15
+ *
16
+ * A missing variable fails with {@link ConfigError} (with its `key`), which `withDefault`, `option` and `orElse` handle. A provided
17
+ * `ConfigProvider` that cannot read its source fails with its `SourceError`,
18
+ * which those helpers pass through.
19
+ *
20
+ * Credentials read these on every request, so without a provider a whole
21
+ * reader tree (`all`, `withDefault`, `orElse`, ...) runs as one synchronous
22
+ * read of `process.env` in a single fiber step: each reader carries a plain
23
+ * `read` function next to its effect, and the combinators compose those.
24
+ * A missing value inside the tree is a plain marker; the tagged error is
25
+ * only built if the whole tree fails.
26
+ */
27
+ import type { SourceError } from "effect/ConfigProvider";
28
+ import * as Effect from "effect/Effect";
29
+ import * as Option from "effect/Option";
30
+ import * as Redact from "effect/Redacted";
31
+ import * as Schema from "./schema-lite-typed.ts";
32
+ declare const ConfigError_base: Schema.TaggedErrorClass<"ConfigError", {
33
+ readonly message: import("effect/Schema").String;
34
+ readonly key: import("effect/Schema").optional<import("effect/Schema").String>;
35
+ }> & (new (...args: any[]) => {
36
+ "@distilled.cloud/error/categories": {
37
+ ConfigurationError: true;
38
+ };
39
+ });
40
+ /**
41
+ * Configuration error - missing or invalid configuration. `key` is the
42
+ * configuration value (e.g. an environment variable) when one is missing.
43
+ */
44
+ export declare class ConfigError extends /*@__PURE__*/ ConfigError_base {
45
+ }
46
+ /** The string value of environment variable `name`. */
47
+ export declare const String: (name: string) => Effect.Effect<string, ConfigError | SourceError>;
48
+ /** The value of `name`, redacted. */
49
+ export declare const Redacted: (name: string) => Effect.Effect<Redact.Redacted<string>, ConfigError | SourceError>;
50
+ /**
51
+ * The failure of a missing value: {@link ConfigError}, matched by its tag
52
+ * (Effect's own config errors share it). `option`, `withDefault` and `orElse` handle
53
+ * only this failure; any other failure of `self` propagates.
54
+ */
55
+ type Missed = {
56
+ readonly _tag: "ConfigError";
57
+ };
58
+ /** The value as an `Option`: `None` when missing. */
59
+ export declare const option: <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<Option.Option<A>, Exclude<E, Missed>, R>;
60
+ /** Use `value` when missing. */
61
+ export declare const withDefault: <B>(value: B) => <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A | B, Exclude<E, Missed>, R>;
62
+ /** Try `that` when missing. */
63
+ export declare const orElse: <A2, E2, R2>(that: () => Effect.Effect<A2, E2, R2>) => <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A | A2, Exclude<E, Missed> | E2, R | R2>;
64
+ export declare const map: <A, B>(f: (a: A) => B) => <E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<B, E, R>;
65
+ /** Read every value of a struct of readers. */
66
+ export declare const all: <const T extends Record<string, Effect.Effect<any, any, any>>>(readers: T) => Effect.Effect<{ -readonly [K in keyof T]: Effect.Success<T[K]>; }, Effect.Error<T[keyof T]>, Effect.Services<T[keyof T]>>;
67
+ export {};
68
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts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Redacted, config$String as String, config$all as all, config$map as map, config$option as option, config$orElse as orElse, config$withDefault as withDefault } from "./_bundle/base.js";
@@ -0,0 +1,76 @@
1
+ /**
2
+ * Hashing and HMAC for request signing, as a swappable service.
3
+ *
4
+ * SDKs that sign requests (AWS SigV4, webhook verification, ...) read
5
+ * {@link Crypto} from the context. It is a reference with a default, so it
6
+ * never appears in an operation's requirements: by default it uses
7
+ * `node:crypto` when the runtime has it (Node, Bun, Deno -- synchronous, and
8
+ * several times faster than WebCrypto for small inputs) and WebCrypto
9
+ * (`crypto.subtle`) everywhere else.
10
+ *
11
+ * Provide a layer to choose or replace the implementation:
12
+ *
13
+ * ```ts
14
+ * import { Crypto } from "@distilled.cloud/core";
15
+ * program.pipe(Effect.provide(Crypto.webCrypto)); // force WebCrypto
16
+ * program.pipe(Effect.provide(Crypto.layer(myHsmBackedCrypto)));
17
+ * ```
18
+ *
19
+ * HMAC keys are imported once into an implementation-specific handle
20
+ * ({@link HmacKey}) so callers can cache them: preparing a raw key is most of
21
+ * an HMAC's cost in both `node:crypto` and WebCrypto.
22
+ */
23
+ import * as Context from "effect/Context";
24
+ import * as Effect from "effect/Effect";
25
+ import * as Layer from "effect/Layer";
26
+ declare const CryptoError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
27
+ readonly _tag: "CryptoError";
28
+ } & Readonly<A>;
29
+ /** A hashing or HMAC operation failed in the crypto implementation. */
30
+ export declare class CryptoError extends /*@__PURE__*/ CryptoError_base<{
31
+ readonly operation: "hmac" | "sha256" | "importKey";
32
+ readonly cause: unknown;
33
+ }> {
34
+ }
35
+ /** An imported HMAC-SHA256 key. Opaque: only the implementation that made it can use it. */
36
+ export interface HmacKey {
37
+ readonly "~distilled/HmacKey": unique symbol;
38
+ }
39
+ export type Bytes = Uint8Array | string;
40
+ export interface CryptoImpl {
41
+ /** Name for diagnostics, e.g. "node:crypto" or "webcrypto". */
42
+ readonly name: string;
43
+ readonly sha256: (data: Bytes) => Effect.Effect<Uint8Array, CryptoError>;
44
+ readonly importHmacKey: (key: Bytes) => Effect.Effect<HmacKey, CryptoError>;
45
+ readonly hmacSha256: (key: HmacKey, data: Bytes) => Effect.Effect<Uint8Array, CryptoError>;
46
+ /**
47
+ * The same operations as plain functions, for implementations that are
48
+ * synchronous (node:crypto). They throw on failure. Signers use them to
49
+ * skip the per-operation effects when present.
50
+ */
51
+ readonly sync?: {
52
+ readonly sha256: (data: Bytes) => Uint8Array;
53
+ readonly importHmacKey: (key: Bytes) => HmacKey;
54
+ readonly hmacSha256: (key: HmacKey, data: Bytes) => Uint8Array;
55
+ /** `hex(sha256(data))`, when the implementation can produce hex itself. */
56
+ readonly sha256Hex?: (data: Bytes) => string;
57
+ /** `hex(hmacSha256(key, data))`, when the implementation can produce hex itself. */
58
+ readonly hmacSha256Hex?: (key: HmacKey, data: Bytes) => string;
59
+ };
60
+ }
61
+ /** `node:crypto` implementation, or undefined when the runtime has no `node:crypto`. */
62
+ export declare const makeNodeCrypto: () => CryptoImpl | undefined;
63
+ /** WebCrypto (`crypto.subtle`) implementation. */
64
+ export declare const makeWebCrypto: () => CryptoImpl;
65
+ /** The crypto implementation signing code uses. Defaults to `node:crypto` when available, else WebCrypto. */
66
+ export declare const Crypto: Context.Reference<CryptoImpl>;
67
+ /** Use a custom implementation. */
68
+ export declare const layer: (impl: CryptoImpl) => Layer.Layer<never>;
69
+ /** Force WebCrypto, even where `node:crypto` exists. */
70
+ export declare const webCrypto: Layer.Layer<never>;
71
+ /** Force `node:crypto`; fails at layer build when the runtime has none. */
72
+ export declare const nodeCrypto: Layer.Layer<never, CryptoError>;
73
+ /** Lowercase hex of bytes. */
74
+ export declare const hex: (bytes: Uint8Array) => string;
75
+ export {};
76
+ //# sourceMappingURL=crypto.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"crypto.d.ts","sourceRoot":"","sources":["../src/crypto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AE,OAAO,EAAE,IAAI,EAAE,KAAK,KAAK,UAAU,CAAC;QAC/D,2EAA2E;QAC3E,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,KAAK,KAAK,MAAM,CAAC;QAC7C,oFAAoF;QACpF,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,KAAK,MAAM,CAAC;KAChE,CAAC;CACH;AA8BD,wFAAwF;AACxF,eAAO,MAAM,cAAc,QAAO,UAAU,GAAG,SA0C9C,CAAC;AAWF,kDAAkD;AAClD,eAAO,MAAM,aAAa,QAAO,UAqB/B,CAAC;AAIH,6GAA6G;AAC7G,eAAO,MAAM,MAAM,+BAEjB,CAAC;AAEH,mCAAmC;AACnC,eAAO,MAAM,KAAK,SAAU,UAAU,KAAG,KAAK,CAAC,KAAK,CAAC,KAAK,CAAgC,CAAC;AAE3F,wDAAwD;AACxD,eAAO,MAAM,SAAS,EAAE,KAAK,CAAC,KAAK,CAAC,KAAK,CAAmD,CAAC;AAE7F,2EAA2E;AAC3E,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE,WAAW,CAUtD,CAAC;AAGF,8BAA8B;AAC9B,eAAO,MAAM,GAAG,UAAW,UAAU,KAAG,MAIvC,CAAC"}
package/lib/crypto.js ADDED
@@ -0,0 +1 @@
1
+ export { crypto$Crypto as Crypto, crypto$CryptoError as CryptoError, crypto$hex as hex, crypto$layer as layer, crypto$makeNodeCrypto as makeNodeCrypto, crypto$makeWebCrypto as makeWebCrypto, crypto$nodeCrypto as nodeCrypto, crypto$webCrypto as webCrypto } from "./_bundle/aws.js";
@@ -1,4 +1,4 @@
1
- import { Effect } from "effect";
1
+ import * as Effect from "effect/Effect";
2
2
  export declare const categoriesKey = "@distilled/meta/error-categories";
3
3
  export declare const withCategory: <Categories extends Array<PropertyKey>>(...categories: Categories) => <Args extends Array<any>, Ret, C extends {
4
4
  new (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UAAU,CAAC,CAAC,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,EAAE,CAEpF,CAAC"}
@@ -1,46 +1 @@
1
- import { Effect, Predicate } from "effect";
2
- export const categoriesKey = "@distilled/meta/error-categories";
3
- export const withCategory = (...categories) => (C) => {
4
- // @ts-expect-error
5
- const Mixed = class extends C {
6
- };
7
- for (const category of categories) {
8
- if (!(categoriesKey in Mixed.prototype)) {
9
- // @ts-expect-error
10
- Mixed.prototype[categoriesKey] = {};
11
- }
12
- // @ts-expect-error
13
- Mixed.prototype[categoriesKey][category] = true;
14
- }
15
- return Mixed;
16
- };
17
- /**
18
- * Runtime check: does `value` carry the given category?
19
- * Works on instances tagged via `withCategory(...)`.
20
- */
21
- export const hasCategory = (category) => (value) => {
22
- if (!Predicate.isObject(value))
23
- return false;
24
- if (!Predicate.hasProperty(categoriesKey)(value))
25
- return false;
26
- return category in value[categoriesKey];
27
- };
28
- /** True if `value` has any of the given categories. */
29
- export const hasAnyCategory = (...categories) => (value) => {
30
- if (!Predicate.isObject(value))
31
- return false;
32
- if (!Predicate.hasProperty(categoriesKey)(value))
33
- return false;
34
- const cats = value[categoriesKey];
35
- for (const c of categories)
36
- if (c in cats)
37
- return true;
38
- return false;
39
- };
40
- export const catchCategory = (...args) => (effect) => {
41
- const f = args.pop();
42
- const categories = args;
43
- const matches = hasAnyCategory(...categories);
44
- return Effect.catchIf(effect, matches, (e) => f(e));
45
- };
46
- //# sourceMappingURL=error-category.js.map
1
+ export { error_category$catchCategory as catchCategory, error_category$categoriesKey as categoriesKey, error_category$hasAnyCategory as hasAnyCategory, error_category$hasCategory as hasCategory, error_category$withCategory as withCategory } from "./_bundle/rest.js";