@distilled.cloud/core 1.0.0-rc.15 → 1.0.0-rc.17

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 (318) hide show
  1. package/lib/_bundle/aws.js +2 -0
  2. package/lib/_bundle/aws.js.map +1 -0
  3. package/lib/_bundle/base.js +5 -0
  4. package/lib/_bundle/base.js.map +1 -0
  5. package/lib/_bundle/graphql.js +3 -0
  6. package/lib/_bundle/graphql.js.map +1 -0
  7. package/lib/_bundle/rest.js +2 -0
  8. package/lib/_bundle/rest.js.map +1 -0
  9. package/lib/_bundle/xml.js +4 -0
  10. package/lib/_bundle/xml.js.map +1 -0
  11. package/lib/api.d.ts +118 -13
  12. package/lib/api.d.ts.map +1 -1
  13. package/lib/api.js +1 -188
  14. package/lib/category.d.ts.map +1 -1
  15. package/lib/category.js +1 -278
  16. package/lib/chunks.d.ts +3 -0
  17. package/lib/chunks.d.ts.map +1 -0
  18. package/lib/chunks.js +1 -0
  19. package/lib/codegen/boolean-string-enums.js +36 -36
  20. package/lib/codegen/chunk.d.ts +7 -0
  21. package/lib/codegen/chunk.d.ts.map +1 -0
  22. package/lib/codegen/chunk.js +139 -0
  23. package/lib/codegen/chunk.js.map +1 -0
  24. package/lib/codegen/cli.d.ts.map +1 -1
  25. package/lib/codegen/cli.js +28 -14
  26. package/lib/codegen/cli.js.map +1 -1
  27. package/lib/codegen/datafy.d.ts +14 -0
  28. package/lib/codegen/datafy.d.ts.map +1 -0
  29. package/lib/codegen/datafy.js +853 -0
  30. package/lib/codegen/datafy.js.map +1 -0
  31. package/lib/codegen/dedupe.d.ts +5 -0
  32. package/lib/codegen/dedupe.d.ts.map +1 -0
  33. package/lib/codegen/dedupe.js +153 -0
  34. package/lib/codegen/dedupe.js.map +1 -0
  35. package/lib/codegen/emit.js +56 -56
  36. package/lib/codegen/format.js +18 -18
  37. package/lib/codegen/generated-at.js +29 -29
  38. package/lib/codegen/generator.d.ts.map +1 -1
  39. package/lib/codegen/generator.js +92 -84
  40. package/lib/codegen/generator.js.map +1 -1
  41. package/lib/codegen/graph.js +36 -36
  42. package/lib/codegen/graphql-client.d.ts +2 -0
  43. package/lib/codegen/graphql-client.d.ts.map +1 -1
  44. package/lib/codegen/graphql-client.js +55 -26
  45. package/lib/codegen/graphql-client.js.map +1 -1
  46. package/lib/codegen/graphql.js +113 -113
  47. package/lib/codegen/latin1.d.ts +3 -0
  48. package/lib/codegen/latin1.d.ts.map +1 -0
  49. package/lib/codegen/latin1.js +126 -0
  50. package/lib/codegen/latin1.js.map +1 -0
  51. package/lib/codegen/members.d.ts +7 -0
  52. package/lib/codegen/members.d.ts.map +1 -1
  53. package/lib/codegen/members.js +26 -19
  54. package/lib/codegen/members.js.map +1 -1
  55. package/lib/codegen/model-diff.js +6 -6
  56. package/lib/codegen/naming.js +19 -19
  57. package/lib/codegen/openapi-cli.js +15 -15
  58. package/lib/codegen/openapi.d.ts +17 -0
  59. package/lib/codegen/openapi.d.ts.map +1 -1
  60. package/lib/codegen/openapi.js +323 -169
  61. package/lib/codegen/openapi.js.map +1 -1
  62. package/lib/codegen/operations.js +14 -14
  63. package/lib/codegen/pagination.js +11 -11
  64. package/lib/codegen/patch-audit.js +57 -57
  65. package/lib/codegen/patches.js +79 -79
  66. package/lib/codegen/prelude.js +19 -19
  67. package/lib/codegen/privatize.d.ts +21 -0
  68. package/lib/codegen/privatize.d.ts.map +1 -0
  69. package/lib/codegen/privatize.js +176 -0
  70. package/lib/codegen/privatize.js.map +1 -0
  71. package/lib/codegen/proto.js +25 -25
  72. package/lib/codegen/pure.d.ts +6 -0
  73. package/lib/codegen/pure.d.ts.map +1 -0
  74. package/lib/codegen/pure.js +91 -0
  75. package/lib/codegen/pure.js.map +1 -0
  76. package/lib/codegen/rewrite-operation-ids.js +108 -108
  77. package/lib/codegen/spec-path.js +57 -57
  78. package/lib/codegen/table.d.ts +5 -0
  79. package/lib/codegen/table.d.ts.map +1 -0
  80. package/lib/codegen/table.js +249 -0
  81. package/lib/codegen/table.js.map +1 -0
  82. package/lib/config.d.ts +27 -0
  83. package/lib/config.d.ts.map +1 -0
  84. package/lib/config.js +1 -0
  85. package/lib/crypto.d.ts +76 -0
  86. package/lib/crypto.d.ts.map +1 -0
  87. package/lib/crypto.js +1 -0
  88. package/lib/debug.d.ts +2 -0
  89. package/lib/debug.d.ts.map +1 -0
  90. package/lib/debug.js +1 -0
  91. package/lib/error-category.d.ts +1 -1
  92. package/lib/error-category.d.ts.map +1 -1
  93. package/lib/error-category.js +1 -46
  94. package/lib/errors.d.ts +62 -62
  95. package/lib/errors.d.ts.map +1 -1
  96. package/lib/errors.js +1 -195
  97. package/lib/graphql.d.ts +31 -20
  98. package/lib/graphql.d.ts.map +1 -1
  99. package/lib/graphql.js +1 -1027
  100. package/lib/graphql.types.js +1 -5
  101. package/lib/index.d.ts +3 -2
  102. package/lib/index.d.ts.map +1 -1
  103. package/lib/index.js +1 -15
  104. package/lib/json-patch.d.ts +2 -2
  105. package/lib/json-patch.js +1 -226
  106. package/lib/json-patch.js.map +1 -1
  107. package/lib/pagination.d.ts +9 -25
  108. package/lib/pagination.d.ts.map +1 -1
  109. package/lib/pagination.js +1 -266
  110. package/lib/plain-values.d.ts +10 -0
  111. package/lib/plain-values.d.ts.map +1 -0
  112. package/lib/plain-values.js +2 -0
  113. package/lib/plain-values.js.map +1 -0
  114. package/lib/protocol-http.d.ts +50 -14
  115. package/lib/protocol-http.d.ts.map +1 -1
  116. package/lib/protocol-http.js +1 -639
  117. package/lib/protocol-rest.d.ts +38 -25
  118. package/lib/protocol-rest.d.ts.map +1 -1
  119. package/lib/protocol-rest.js +1 -267
  120. package/lib/query.js +1 -27
  121. package/lib/response-validation-strict.d.ts +48 -0
  122. package/lib/response-validation-strict.d.ts.map +1 -0
  123. package/lib/response-validation-strict.js +1 -0
  124. package/lib/response-validation.d.ts +43 -25
  125. package/lib/response-validation.d.ts.map +1 -1
  126. package/lib/response-validation.js +1 -76
  127. package/lib/retry-after.d.ts +3 -3
  128. package/lib/retry-after.js +1 -112
  129. package/lib/retry.d.ts +48 -29
  130. package/lib/retry.d.ts.map +1 -1
  131. package/lib/retry.js +1 -209
  132. package/lib/schema-lite-impl.d.ts +158 -0
  133. package/lib/schema-lite-impl.d.ts.map +1 -0
  134. package/lib/schema-lite-impl.js +1 -0
  135. package/lib/schema-lite-typed.d.ts +41 -0
  136. package/lib/schema-lite-typed.d.ts.map +1 -0
  137. package/lib/schema-lite-typed.js +2 -0
  138. package/lib/schema-lite-typed.js.map +1 -0
  139. package/lib/schema-lite.d.ts +40 -0
  140. package/lib/schema-lite.d.ts.map +1 -0
  141. package/lib/schema-lite.js +1 -0
  142. package/lib/schema.d.ts +20 -6
  143. package/lib/schema.d.ts.map +1 -1
  144. package/lib/schema.js +1 -48
  145. package/lib/testing.d.ts +3 -2
  146. package/lib/testing.d.ts.map +1 -1
  147. package/lib/testing.js +1 -40
  148. package/lib/testing.js.map +1 -1
  149. package/lib/trait.d.ts +13 -13
  150. package/lib/trait.d.ts.map +1 -1
  151. package/lib/trait.js +1 -131
  152. package/lib/xml.d.ts +1 -1
  153. package/lib/xml.d.ts.map +1 -1
  154. package/lib/xml.js +1 -311
  155. package/package.json +9 -7
  156. package/src/api.ts +1080 -180
  157. package/src/category.ts +33 -33
  158. package/src/chunks.ts +30 -0
  159. package/src/codegen/chunk.ts +147 -0
  160. package/src/codegen/cli.ts +27 -1
  161. package/src/codegen/datafy.ts +874 -0
  162. package/src/codegen/dedupe.ts +173 -0
  163. package/src/codegen/generator.ts +10 -3
  164. package/src/codegen/graphql-client.ts +49 -15
  165. package/src/codegen/latin1.ts +131 -0
  166. package/src/codegen/members.ts +8 -0
  167. package/src/codegen/openapi.ts +194 -3
  168. package/src/codegen/privatize.ts +200 -0
  169. package/src/codegen/pure.ts +94 -0
  170. package/src/codegen/table.ts +254 -0
  171. package/src/config.ts +216 -0
  172. package/src/crypto.ts +202 -0
  173. package/src/debug.ts +8 -0
  174. package/src/error-category.ts +2 -1
  175. package/src/errors.ts +65 -56
  176. package/src/graphql.ts +109 -62
  177. package/src/graphql.types.ts +9 -7
  178. package/src/index.ts +3 -2
  179. package/src/json-patch.ts +2 -2
  180. package/src/pagination.ts +37 -18
  181. package/src/plain-values.ts +41 -0
  182. package/src/protocol-http.ts +378 -145
  183. package/src/protocol-rest.ts +337 -169
  184. package/src/response-validation-strict.ts +327 -0
  185. package/src/response-validation.ts +101 -50
  186. package/src/retry-after.ts +3 -3
  187. package/src/retry.ts +94 -93
  188. package/src/schema-lite-impl.ts +550 -0
  189. package/src/schema-lite-typed.ts +44 -0
  190. package/src/schema-lite.ts +44 -0
  191. package/src/schema.ts +258 -14
  192. package/src/testing.ts +4 -2
  193. package/src/trait.ts +36 -28
  194. package/src/xml.ts +31 -17
  195. package/lib/api.js.map +0 -1
  196. package/lib/category.js.map +0 -1
  197. package/lib/codegen/boolean-string-enums.test.d.ts +0 -2
  198. package/lib/codegen/boolean-string-enums.test.d.ts.map +0 -1
  199. package/lib/codegen/boolean-string-enums.test.js +0 -275
  200. package/lib/codegen/boolean-string-enums.test.js.map +0 -1
  201. package/lib/codegen/defer-naming.test.d.ts +0 -2
  202. package/lib/codegen/defer-naming.test.d.ts.map +0 -1
  203. package/lib/codegen/defer-naming.test.js +0 -105
  204. package/lib/codegen/defer-naming.test.js.map +0 -1
  205. package/lib/codegen/generated-at.test.d.ts +0 -2
  206. package/lib/codegen/generated-at.test.d.ts.map +0 -1
  207. package/lib/codegen/generated-at.test.js +0 -81
  208. package/lib/codegen/generated-at.test.js.map +0 -1
  209. package/lib/codegen/generator.test.d.ts +0 -2
  210. package/lib/codegen/generator.test.d.ts.map +0 -1
  211. package/lib/codegen/generator.test.js +0 -121
  212. package/lib/codegen/generator.test.js.map +0 -1
  213. package/lib/codegen/graphql-client.test.d.ts +0 -2
  214. package/lib/codegen/graphql-client.test.d.ts.map +0 -1
  215. package/lib/codegen/graphql-client.test.js +0 -171
  216. package/lib/codegen/graphql-client.test.js.map +0 -1
  217. package/lib/codegen/openapi-binary.test.d.ts +0 -2
  218. package/lib/codegen/openapi-binary.test.d.ts.map +0 -1
  219. package/lib/codegen/openapi-binary.test.js +0 -67
  220. package/lib/codegen/openapi-binary.test.js.map +0 -1
  221. package/lib/codegen/patch-audit.test.d.ts +0 -2
  222. package/lib/codegen/patch-audit.test.d.ts.map +0 -1
  223. package/lib/codegen/patch-audit.test.js +0 -141
  224. package/lib/codegen/patch-audit.test.js.map +0 -1
  225. package/lib/codegen/patches.test.d.ts +0 -2
  226. package/lib/codegen/patches.test.d.ts.map +0 -1
  227. package/lib/codegen/patches.test.js +0 -155
  228. package/lib/codegen/patches.test.js.map +0 -1
  229. package/lib/codegen/protocol-imports.test.d.ts +0 -2
  230. package/lib/codegen/protocol-imports.test.d.ts.map +0 -1
  231. package/lib/codegen/protocol-imports.test.js +0 -36
  232. package/lib/codegen/protocol-imports.test.js.map +0 -1
  233. package/lib/codegen/rewrite-operation-ids.test.d.ts +0 -2
  234. package/lib/codegen/rewrite-operation-ids.test.d.ts.map +0 -1
  235. package/lib/codegen/rewrite-operation-ids.test.js +0 -451
  236. package/lib/codegen/rewrite-operation-ids.test.js.map +0 -1
  237. package/lib/codegen/untagged-unions.test.d.ts +0 -2
  238. package/lib/codegen/untagged-unions.test.d.ts.map +0 -1
  239. package/lib/codegen/untagged-unions.test.js +0 -80
  240. package/lib/codegen/untagged-unions.test.js.map +0 -1
  241. package/lib/error-category.js.map +0 -1
  242. package/lib/errors.js.map +0 -1
  243. package/lib/fixtures/xml/upstream-validator.json +0 -397
  244. package/lib/graphql.js.map +0 -1
  245. package/lib/graphql.test.d.ts +0 -2
  246. package/lib/graphql.test.d.ts.map +0 -1
  247. package/lib/graphql.test.js +0 -151
  248. package/lib/graphql.test.js.map +0 -1
  249. package/lib/graphql.types.js.map +0 -1
  250. package/lib/index.js.map +0 -1
  251. package/lib/json-patch.test.d.ts +0 -2
  252. package/lib/json-patch.test.d.ts.map +0 -1
  253. package/lib/json-patch.test.js +0 -65
  254. package/lib/json-patch.test.js.map +0 -1
  255. package/lib/pagination.js.map +0 -1
  256. package/lib/pagination.test.d.ts +0 -2
  257. package/lib/pagination.test.d.ts.map +0 -1
  258. package/lib/pagination.test.js +0 -131
  259. package/lib/pagination.test.js.map +0 -1
  260. package/lib/protocol-http.js.map +0 -1
  261. package/lib/protocol-http.test.d.ts +0 -2
  262. package/lib/protocol-http.test.d.ts.map +0 -1
  263. package/lib/protocol-http.test.js +0 -228
  264. package/lib/protocol-http.test.js.map +0 -1
  265. package/lib/protocol-rest.js.map +0 -1
  266. package/lib/protocol-rest.test.d.ts +0 -2
  267. package/lib/protocol-rest.test.d.ts.map +0 -1
  268. package/lib/protocol-rest.test.js +0 -498
  269. package/lib/protocol-rest.test.js.map +0 -1
  270. package/lib/query.js.map +0 -1
  271. package/lib/response-validation.js.map +0 -1
  272. package/lib/response-validation.test.d.ts +0 -2
  273. package/lib/response-validation.test.d.ts.map +0 -1
  274. package/lib/response-validation.test.js +0 -72
  275. package/lib/response-validation.test.js.map +0 -1
  276. package/lib/retry-after.js.map +0 -1
  277. package/lib/retry-after.test.d.ts +0 -2
  278. package/lib/retry-after.test.d.ts.map +0 -1
  279. package/lib/retry-after.test.js +0 -204
  280. package/lib/retry-after.test.js.map +0 -1
  281. package/lib/retry.js.map +0 -1
  282. package/lib/retry.test.d.ts +0 -2
  283. package/lib/retry.test.d.ts.map +0 -1
  284. package/lib/retry.test.js +0 -407
  285. package/lib/retry.test.js.map +0 -1
  286. package/lib/schema.js.map +0 -1
  287. package/lib/sdks.test.d.ts +0 -2
  288. package/lib/sdks.test.d.ts.map +0 -1
  289. package/lib/sdks.test.js +0 -76
  290. package/lib/sdks.test.js.map +0 -1
  291. package/lib/trait.js.map +0 -1
  292. package/lib/xml.js.map +0 -1
  293. package/lib/xml.test.d.ts +0 -2
  294. package/lib/xml.test.d.ts.map +0 -1
  295. package/lib/xml.test.js +0 -210
  296. package/lib/xml.test.js.map +0 -1
  297. package/src/codegen/boolean-string-enums.test.ts +0 -299
  298. package/src/codegen/defer-naming.test.ts +0 -113
  299. package/src/codegen/generated-at.test.ts +0 -89
  300. package/src/codegen/generator.test.ts +0 -137
  301. package/src/codegen/graphql-client.test.ts +0 -189
  302. package/src/codegen/openapi-binary.test.ts +0 -91
  303. package/src/codegen/patch-audit.test.ts +0 -160
  304. package/src/codegen/patches.test.ts +0 -188
  305. package/src/codegen/protocol-imports.test.ts +0 -39
  306. package/src/codegen/rewrite-operation-ids.test.ts +0 -472
  307. package/src/codegen/untagged-unions.test.ts +0 -85
  308. package/src/fixtures/xml/upstream-validator.json +0 -397
  309. package/src/graphql.test.ts +0 -198
  310. package/src/json-patch.test.ts +0 -77
  311. package/src/pagination.test.ts +0 -169
  312. package/src/protocol-http.test.ts +0 -276
  313. package/src/protocol-rest.test.ts +0 -703
  314. package/src/response-validation.test.ts +0 -89
  315. package/src/retry-after.test.ts +0 -267
  316. package/src/retry.test.ts +0 -566
  317. package/src/sdks.test.ts +0 -87
  318. package/src/xml.test.ts +0 -251
package/lib/category.js CHANGED
@@ -1,278 +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.TaggedError<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 HttpClientError from "effect/http/HttpClientError";
23
- import * as Predicate from "effect/Predicate";
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.TaggedError<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.TaggedError<TransientError>()(
88
- * "TransientError",
89
- * { message: Schema.String },
90
- * ).pipe(Category.withRetryable()) {}
91
- *
92
- * // Throttling error (uses longer backoff)
93
- * export class RateLimitError extends Schema.TaggedError<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) && Predicate.hasProperty(categoriesKey)(error)) {
130
- // @ts-expect-error - dynamic property access
131
- return category in error[categoriesKey];
132
- }
133
- return false;
134
- };
135
- export const isAuthError = (error) => hasCategory(error, AuthError);
136
- export const isBadRequestError = (error) => hasCategory(error, BadRequestError);
137
- export const isConflictError = (error) => hasCategory(error, ConflictError);
138
- export const isNotFoundError = (error) => hasCategory(error, NotFoundError);
139
- export const isQuotaError = (error) => hasCategory(error, QuotaError);
140
- export const isServerError = (error) => hasCategory(error, ServerError);
141
- export const isThrottlingError = (error) => hasCategory(error, ThrottlingError);
142
- export const isNetworkError = (error) => hasCategory(error, NetworkError);
143
- export const isParseError = (error) => hasCategory(error, ParseError);
144
- export const isConfigurationError = (error) => hasCategory(error, ConfigurationError);
145
- export const isTimeoutError = (error) => hasCategory(error, TimeoutError);
146
- export const isRetryableError = (error) => hasCategory(error, RetryableError);
147
- export const isLockedError = (error) => hasCategory(error, LockedError);
148
- export const isAbortedError = (error) => hasCategory(error, AbortedError);
149
- export const isAlreadyExistsError = (error) => hasCategory(error, AlreadyExistsError);
150
- export const isDependencyViolationError = (error) => hasCategory(error, DependencyViolationError);
151
- // ============================================================================
152
- // Transient Error Detection (for retry logic)
153
- // ============================================================================
154
- /**
155
- * Check if an error has the retryable trait (set via withRetryable).
156
- */
157
- export const isRetryable = (error) => {
158
- if (Predicate.isObject(error) && Predicate.hasProperty(retryableKey)(error)) {
159
- return true;
160
- }
161
- return false;
162
- };
163
- /**
164
- * Check if an error is a throttling error.
165
- * Either has ThrottlingError category or retryable trait with throttling: true.
166
- */
167
- export const isThrottling = (error) => {
168
- if (Predicate.isObject(error) && Predicate.hasProperty(retryableKey)(error)) {
169
- // @ts-expect-error - dynamic property access
170
- return error[retryableKey]?.throttling === true;
171
- }
172
- return hasCategory(error, ThrottlingError);
173
- };
174
- /**
175
- * Check if an error is an Effect `HttpClientError` caused by a wire-level
176
- * transport failure (undici `ConnectTimeoutError`, socket reset, DNS
177
- * failure, premature stream close, …). The request never reached the
178
- * server (or the response never finished) so retrying is safe.
179
- *
180
- * Status-code retries are intentionally left to the per-SDK API client,
181
- * which knows whether a given response is genuinely retryable.
182
- */
183
- const isHttpTransportError = (error) => HttpClientError.isHttpClientError(error) && error.reason._tag === "TransportError";
184
- /**
185
- * Check if an error is a transient error that should be automatically retried.
186
- * Transient errors include:
187
- * - Errors marked with withRetryable()
188
- * - RetryableError category
189
- * - ThrottlingError (rate limiting)
190
- * - ServerError (5xx responses)
191
- * - NetworkError (connection issues)
192
- * - TimeoutError (request timed out)
193
- * - LockedError (423 - resource temporarily locked)
194
- * - Effect `HttpClientError` with `reason._tag === "TransportError"`
195
- * (undici connect/read timeout, socket reset, DNS failure, premature
196
- * stream close)
197
- */
198
- export const isTransientError = (error) => {
199
- // Check for retryable trait first
200
- if (isRetryable(error)) {
201
- return true;
202
- }
203
- // Fall back to category-based checking
204
- return (hasCategory(error, RetryableError) ||
205
- hasCategory(error, ThrottlingError) ||
206
- hasCategory(error, ServerError) ||
207
- hasCategory(error, NetworkError) ||
208
- hasCategory(error, TimeoutError) ||
209
- hasCategory(error, LockedError) ||
210
- isHttpTransportError(error));
211
- };
212
- // ============================================================================
213
- // Category Catchers
214
- // ============================================================================
215
- const makeCatcher = (category) => (f) => (effect) => Effect.catchIf(effect, (e) => hasCategory(e, category), f);
216
- /**
217
- * Catch errors matching any of the specified categories.
218
- *
219
- * @example
220
- * ```ts
221
- * effect.pipe(
222
- * Category.catchErrors(Category.AuthError, Category.NotFoundError, (err) =>
223
- * Effect.succeed("handled")
224
- * )
225
- * )
226
- * ```
227
- */
228
- export const catchErrors = (...args) => (effect) => {
229
- const handler = args.pop();
230
- const categories = args;
231
- return Effect.catchIf(effect, (e) => categories.some((cat) => hasCategory(e, cat)), handler);
232
- };
233
- // Alias for convenience
234
- export { catchErrors as catch };
235
- export const catchAuthError = makeCatcher(AuthError);
236
- export const catchBadRequestError = makeCatcher(BadRequestError);
237
- export const catchConflictError = makeCatcher(ConflictError);
238
- export const catchNotFoundError = makeCatcher(NotFoundError);
239
- export const catchQuotaError = makeCatcher(QuotaError);
240
- export const catchServerError = makeCatcher(ServerError);
241
- export const catchThrottlingError = makeCatcher(ThrottlingError);
242
- export const catchNetworkError = makeCatcher(NetworkError);
243
- export const catchParseError = makeCatcher(ParseError);
244
- export const catchConfigurationError = makeCatcher(ConfigurationError);
245
- export const catchTimeoutError = makeCatcher(TimeoutError);
246
- export const catchRetryableError = makeCatcher(RetryableError);
247
- export const catchLockedError = makeCatcher(LockedError);
248
- export const catchAbortedError = makeCatcher(AbortedError);
249
- export const catchAlreadyExistsError = makeCatcher(AlreadyExistsError);
250
- export const catchDependencyViolationError = makeCatcher(DependencyViolationError);
251
- /**
252
- * Catch errors with specified categories with full type narrowing.
253
- *
254
- * @example
255
- * ```ts
256
- * effect.pipe(
257
- * Category.catchCategory(Category.AuthError, (err) => Effect.succeed("handled"))
258
- * )
259
- * ```
260
- */
261
- export const catchCategory = (...args) => (effect) => {
262
- const f = args.pop();
263
- const categories = args;
264
- return Effect.catchIf(effect, (e) => {
265
- if (Predicate.isObject(e) && Predicate.hasProperty(categoriesKey)(e)) {
266
- for (const cat of categories) {
267
- // @ts-expect-error - dynamic property access
268
- if (cat in e[categoriesKey]) {
269
- return true;
270
- }
271
- }
272
- }
273
- return false;
274
- },
275
- // @ts-expect-error - type narrowing limitation
276
- (e) => f(e));
277
- };
278
- //# 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";
@@ -1,33 +1,33 @@
1
- /**
2
- * Boolean-valued string enums on request members (dev-time only).
3
- *
4
- * Plenty of APIs document a flag as the string enum `"true" | "false"`
5
- * rather than a JSON boolean — Cloudflare's `validation_enabled`, Clerk's
6
- * `include_invalid`, GrowthBook's `deleteMissing`, and so on. Taken
7
- * literally that surfaces as `"true" | "false" | (string & {})` and every
8
- * caller writes the ternary itself.
9
- *
10
- * {@link generateService} runs this pass over the loaded model before
11
- * emitting: REQUEST members of such an enum are retargeted to a real
12
- * `smithy.api#Boolean` and stamped {@link STRING_ENCODED_TRAIT}, which the
13
- * generator emits as `T.StringEncoded()` and the protocol honors by sending
14
- * the value's string spelling. The TS surface becomes `boolean` with the
15
- * wire unchanged. The model on disk keeps the string enum the description
16
- * documents.
17
- *
18
- * Deliberately narrow:
19
- *
20
- * • request-only shapes — an operation input, or a structure or list the
21
- * inputs reach and no output or error does. A member a response can
22
- * deliver would need the mirror-image decode, which the protocol does
23
- * not do, so a shape used both ways keeps its documented string type;
24
- * • the enum must be exactly `{"true", "false"}` — a three-value enum
25
- * that happens to include them is left alone.
26
- */
27
- /** Synthetic trait: send this member's value as its string spelling. */
1
+
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+
19
+
20
+
21
+
22
+
23
+
24
+
25
+
26
+
27
+
28
28
  export const STRING_ENCODED_TRAIT = "distilled.protocols#stringEncoded";
29
29
  const BOOLEAN = "smithy.api#Boolean";
30
- /** Enum shapes whose values are exactly `"true"` and `"false"`. */
30
+
31
31
  const booleanEnumIds = (shapes) => {
32
32
  const out = new Set();
33
33
  for (const [id, shape] of Object.entries(shapes)) {
@@ -40,7 +40,7 @@ const booleanEnumIds = (shapes) => {
40
40
  }
41
41
  return out;
42
42
  };
43
- /** Every shape id a shape points at: members, list/map entries, mixins. */
43
+
44
44
  const targetsOf = (shape) => {
45
45
  const out = [];
46
46
  for (const member of Object.values(shape?.members ?? {})) {
@@ -70,13 +70,13 @@ const reachable = (shapes, roots) => {
70
70
  }
71
71
  return seen;
72
72
  };
73
- /**
74
- * Shapes an operation input reaches that no output or error does. Operation
75
- * I/O is the spine; the `smithy.api#input`/`#output`/`#error` traits cover
76
- * models whose shapes are not wired through an operation, and a structure
77
- * the inputs never reach counts as a response root — unreachable from a
78
- * request, it can only describe something the API hands back.
79
- */
73
+
74
+
75
+
76
+
77
+
78
+
79
+
80
80
  const requestOnlyShapes = (shapes) => {
81
81
  const requestRoots = [];
82
82
  const responseRoots = [];
@@ -0,0 +1,7 @@
1
+ /** Schemas per builder function: smaller chunks compile less on first use. */
2
+ export declare const CHUNK_SIZE = 32;
3
+ export declare const chunkSchemas: (code: string, filename?: string, chunkSize?: number) => {
4
+ code: string;
5
+ chunked: number;
6
+ };
7
+ //# sourceMappingURL=chunk.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunk.d.ts","sourceRoot":"","sources":["../../src/codegen/chunk.ts"],"names":[],"mappings":"AAsBA,8EAA8E;AAC9E,eAAO,MAAM,UAAU,KAAK,CAAC;AAY7B,eAAO,MAAM,YAAY,SACjB,MAAM,4CAGX;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CA2GjC,CAAC"}
@@ -0,0 +1,139 @@
1
+
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+ import { parseAst } from "rolldown/parseAst";
16
+ import { valueRefs } from "./privatize.js";
17
+
18
+ export const CHUNK_SIZE = 32;
19
+ const stripCasts = (n) => {
20
+ while (n.type === "TSAsExpression" ||
21
+ n.type === "TSSatisfiesExpression" ||
22
+ n.type === "ParenthesizedExpression")
23
+ n = n.expression;
24
+ return n;
25
+ };
26
+ export const chunkSchemas = (code, filename = "generated.ts", chunkSize = CHUNK_SIZE) => {
27
+ const program = parseAst(code, { sourceType: "module", lang: "ts" }, filename);
28
+ const body = program.body;
29
+ const items = [];
30
+ for (const st of body) {
31
+ // Only module-private consts: exports keep their own initializer.
32
+ if (st.type !== "VariableDeclaration" || st.declarations.length !== 1)
33
+ continue;
34
+ const d = st.declarations[0];
35
+ if (!d.init)
36
+ continue;
37
+ const inner = stripCasts(d.init);
38
+ if (inner.type !== "CallExpression")
39
+ continue;
40
+ const text = code.slice(inner.start, inner.end);
41
+ if (/\bAPI\.make/.test(text) || !/\bS\./.test(text))
42
+ continue;
43
+ items.push({
44
+ start: inner.start,
45
+ end: inner.end,
46
+ text,
47
+ name: d.id.name ?? "",
48
+ key: "",
49
+ });
50
+ }
51
+ if (!items.length)
52
+ return { code, chunked: 0 };
53
+ // Group schemas only with schemas reached by exactly the same roots
54
+ // (operations and error classes): a bundle that keeps one builder then
55
+ // needs every schema in it, so nothing unused comes along.
56
+ const refsOf = new Map();
57
+ const roots = [];
58
+ for (const st of body) {
59
+ const decl = st.type === "ExportNamedDeclaration" && st.declaration ? st.declaration : st;
60
+ if (decl.type === "VariableDeclaration") {
61
+ for (const d of decl.declarations) {
62
+ const name = d.id.name;
63
+ if (!name || !d.init)
64
+ continue;
65
+ const refs = valueRefs(d.init, new Set());
66
+ refsOf.set(name, refs);
67
+ const init = d.init;
68
+ if (/\bAPI\.make/.test(code.slice(init.start, init.end)))
69
+ roots.push(refs);
70
+ }
71
+ }
72
+ else if (decl.type === "ClassDeclaration" && decl.id) {
73
+ const refs = valueRefs(decl.superClass, new Set());
74
+ refsOf.set(decl.id.name, refs);
75
+ roots.push(refs);
76
+ }
77
+ }
78
+ const reachedBy = new Map();
79
+ roots.forEach((rootRefs, r) => {
80
+ const seen = new Set();
81
+ const stack = [...rootRefs];
82
+ while (stack.length) {
83
+ const n = stack.pop();
84
+ if (seen.has(n) || !refsOf.has(n))
85
+ continue;
86
+ seen.add(n);
87
+ let list = reachedBy.get(n);
88
+ if (!list)
89
+ reachedBy.set(n, (list = []));
90
+ list.push(r);
91
+ for (const x of refsOf.get(n))
92
+ stack.push(x);
93
+ }
94
+ });
95
+ for (const it of items)
96
+ it.key = (reachedBy.get(it.name) ?? []).join(",");
97
+ const ordered = items
98
+ .map((it, i) => [it, i])
99
+ .sort((a, b) => (a[0].key < b[0].key ? -1 : a[0].key > b[0].key ? 1 : a[1] - b[1]));
100
+ const slot = new Map();
101
+ let chunk = -1;
102
+ let used = chunkSize;
103
+ let lastKey;
104
+ for (const [it] of ordered) {
105
+ if (used >= chunkSize || it.key !== lastKey) {
106
+ chunk++;
107
+ used = 0;
108
+ lastKey = it.key;
109
+ }
110
+ slot.set(it, [chunk, used++]);
111
+ }
112
+ const cases = [];
113
+ for (const it of items) {
114
+ const [c, j] = slot.get(it);
115
+ (cases[c] ??= [])[j] = `case ${j}: return ${it.text};`;
116
+ }
117
+ let out = code;
118
+ for (let i = items.length - 1; i >= 0; i--) {
119
+ const it = items[i];
120
+ // The PURE marker in front of the old initializer, if any, now marks the `at` call.
121
+ const marked = /\/\*[@#]__PURE__\*\/\s*$/.test(out.slice(Math.max(0, it.start - 20), it.start));
122
+ const [c, j] = slot.get(it);
123
+ out = `${out.slice(0, it.start)}${marked ? "" : "/*@__PURE__*/ "}__L.at(__c${c}, ${j})${out.slice(it.end)}`;
124
+ }
125
+ const lastImport = [...body].reverse().find((s) => s.type === "ImportDeclaration");
126
+ const at = lastImport ? lastImport.end : 0;
127
+ // Modules on lite schemas take `at` from schema-lite (lazy lite nodes).
128
+ const helper = code.includes('"@distilled.cloud/core/schema-lite"')
129
+ ? "@distilled.cloud/core/schema-lite"
130
+ : "@distilled.cloud/core/chunks";
131
+ out = `${out.slice(0, at)}\nimport * as __L from "${helper}";${out.slice(at)}`;
132
+ out +=
133
+ "\n// Schema builders: each runs one schema initializer, on that schema's first use.\n" +
134
+ cases
135
+ .map((c, k) => `function __c${k}(j: number): any {\n switch (j) {\n${c.map((x) => ` ${x}`).join("\n")}\n }\n}`)
136
+ .join("\n");
137
+ return { code: out, chunked: items.length };
138
+ };
139
+ //# sourceMappingURL=chunk.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunk.js","sourceRoot":"","sources":["../../src/codegen/chunk.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,QAAQ,EAAE,MAA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AK,MAAM,GAAG,IAAI,CAAC;IAC1E,yEAAyE;IACzE,QAAQ,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,OAAO,CAAC;CACxC;AAED,2EAA2E;AAC3E,eAAO,MAAM,eAAe,YAAa,mBAAmB,KAAG,IA8L9D,CAAC"}
@@ -1,26 +1,32 @@
1
- /**
2
- * The generic generator CLI harness (dev-time only).
3
- *
4
- * Owns the smithy→SDK pipeline every SDK package shares: scan the model
5
- * directory (plus optional hand-authored manual specs), compile each model
6
- * through {@link generateService} with the provider's {@link SdkSpec}, write
7
- * the service modules and the namespaced barrel. Patches are already in
8
- * `.generated-specs` (convert applies them, see `codegen/patches`).
9
- *
10
- * A provider's `scripts/generate.ts` is: trait consts + an SdkSpec + a
11
- * `runGeneratorCli` call.
12
- */
1
+
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
13
  import { NodeRuntime, NodeServices } from "@effect/platform-node";
14
14
  import { Console, Effect } from "effect";
15
15
  import { Flag } from "effect/cli";
16
16
  import { Command } from "effect/cli";
17
17
  import * as FileSystem from "effect/FileSystem";
18
18
  import * as Path from "effect/Path";
19
+ import { chunkSchemas } from "./chunk.js";
20
+ import { dedupeSchemas } from "./dedupe.js";
19
21
  import { barrel } from "./emit.js";
20
22
  import { formatGenerated } from "./format.js";
21
23
  import { stampGeneratedAt } from "./generated-at.js";
22
24
  import { generateService } from "./generator.js";
23
- /** Run the generator CLI (NodeRuntime main — call at module top level). */
25
+ import { toLatin1 } from "./latin1.js";
26
+ import { privatizeSchemas, typeOnlyNamespaceImports } from "./privatize.js";
27
+ import { annotateNestedCalls } from "./pure.js";
28
+ import { tableSchemas } from "./table.js";
29
+
24
30
  export const runGeneratorCli = (options) => {
25
31
  const command = Command.make("generate", {
26
32
  smithy: Flag.String("smithy").pipe(Flag.withDefault(options.smithyDir ?? ".generated-specs"), Flag.withDescription("Directory of Smithy JSON models")),
@@ -89,9 +95,17 @@ export const runGeneratorCli = (options) => {
89
95
  yield* Console.error(`❌ ${resource}`);
90
96
  continue;
91
97
  }
92
- const { code, operations } = generated;
98
+ const { operations } = generated;
93
99
  if (operations === 0)
94
100
  continue;
101
+ // Every nested call in a top-level initializer gets a PURE marker,
102
+ // so one unused schema cannot pin others in a consumer's bundle.
103
+ // Latin-1-only source halves the heap V8 keeps for the module text.
104
+ // Structurally identical schemas become aliases of one schema, and
105
+ // schema consts become module-private (types stay exported).
106
+ const resourceFile = `${resource}.ts`;
107
+ const marked = annotateNestedCalls(generated.code, resourceFile);
108
+ const code = toLatin1(typeOnlyNamespaceImports(tableSchemas(chunkSchemas(privatizeSchemas(dedupeSchemas(marked, resourceFile).code, resourceFile).code, resourceFile).code, resourceFile).code, resourceFile), resourceFile);
95
109
  yield* fs.writeFileString(path.join(outDir, `${resource}.ts`), code);
96
110
  written.push(resource);
97
111
  totalOps += operations;